-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_data.sh
executable file
·113 lines (95 loc) · 3.19 KB
/
get_data.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
########################
# Functions:
# 1. This script transfer data from HothDAQ to MVD
# 2. This script convert binary into root
# Usage:
# bash get_data.sh
#########################
#======================================
# GLOBAL PARAMETERS (you don't need to change it very often)
#DAQ_DIR=/home/rootless/ToolApplication
#DAQ_DIR=/data/0/BNLBOX/WbLS-DATA/phase_3
DAQ_DIR=/data/1/WbLS-DATA/phase_3
GECO_DIR=/home/rootless/GECO_Logging
#MVD_DIR=/media/disk_a/BNLBOX/WbLS-DATA
MVD_DIR=/media/disk_e/WbLS-DATA
DAQ_USER=rootless
DAQ_IP=130.199.33.252
#======================================
echo "Enter a run type (muon, alpha, led, geco)"
read RUN_TYPE
if [ $RUN_TYPE != "geco" ]; then
echo "Do you want to transfer temperature data? (1: yes, 0: no)"
read TRANSFER_TEMP
fi
echo "Enter a run phase (phase0, phase1, phase2, phase3)"
read RUN_PHASE
# note:
# muon stores muon data
# calibration stores led, alpha lightbulb, ...
# debug store test data
# alpha stores alpha lightbulb
# [create your own]
DO_CSV=0
DO_ROOTER=0
if [ $RUN_TYPE = "geco" ]; then
echo "Do you want to convert geco log to csv file (1: yes, 0: no)?"
read DO_CSV
else
echo "Which sub-directory do you want to store the data? String options: muon, calibration, debug (mkdir yours if needed)"
echo "Hint: muon stores good muon data; calibration stores led, alpha lightbulb. etc...; debug stores test data"
read MVD_SUB_FOLDER
echo "Do you want to run rooter (1: yes, 0: no)?"
read DO_ROOTER
fi
echo "Enter an integer for the date (0: today; -1 yesterday; -2: 2 days ago ...)"
read d
DATE=$(date -d "$d day" '+%y%m%d')
echo "Start transfering data taken on $DATE"
function transfer_data() {
if [ $RUN_TYPE != "geco" ]; then
output_dir=${MVD_DIR}/raw_binary/${RUN_PHASE}/${MVD_SUB_FOLDER}
scp -o ControlPath=bgconn ${DAQ_USER}@${DAQ_IP}:${DAQ_DIR}/*${RUN_TYPE}_*${DATE}*.bin $output_dir
find ${output_dir}/*${RUN_TYPE}_*${DATE}*.bin -type f > tmp.list
if [ $TRANSFER_TEMP -eq 1 ]; then
output_dir=${MVD_DIR}/temp_data/${RUN_PHASE}
scp -o ControlPath=bgconn ${DAQ_USER}@${DAQ_IP}:${DAQ_DIR}/*${RUN_TYPE}_*${DATE}*_temp*.txt $output_dir
fi
else
output_dir=${MVD_DIR}/db/geco
scp -o ControlPath=bgconn ${DAQ_USER}@${DAQ_IP}:${GECO_DIR}/*IMon_*${DATE}*.log $output_dir
find ${output_dir}/*IMon_*${DATE}*.log -type f > tmp.list
fi
}
function run_rooter() {
output_dir=${MVD_DIR}/raw_root/${RUN_PHASE}/${MVD_SUB_FOLDER}/
while read fpath; do
case "$fpath" in \#*) continue ;; esac
echo " "
echo "processing $fpath ..."
python src/raw_data_rooter_v1740.py --if_path=${fpath} --output_dir=${output_dir}
done < tmp.list
}
function run_log2csv() {
output_dir=${MVD_DIR}/db/geco/
while read fpath; do
case "$fpath" in \#*) continue ;; esac
echo " "
echo "processing $fpath ..."
python tools/log2csv.py ${fpath}
done < tmp.list
}
# execute the transfer functions
ssh -fMNS bgconn -o ControlPersist=yes ${DAQ_USER}@${DAQ_IP}
transfer_data
ssh -S bgconn -O exit -
# execute the rooter
if [ $DO_ROOTER -eq 1 ]; then
source drop_env/bin/activate
run_rooter
fi
if [ $DO_CSV -eq 1 ]; then
source drop_env/bin/activate
run_log2csv
fi