Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JQAQC.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2#
3# \author mdejong
4#
5script=${0##*/}
6version=1.0
7doxygen=JDATABASE::JRunQuality
8
9if [ -z $JPP_DIR ]; then
10 echo "Variable JPP_DIR undefined."
11 exit
12fi
13
14source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
15
16# Auxiliary script to produce QA/QC data.
17#
18# The output data are uploaded to the database with a tool that is part of the km3pipe package.
19# The locally produced data as well as the uploaded data can be viewed with applications/scripts JDataMonitor[.sh] and JDataQuality[.sh].
20#
21# Note that if the list of values is extended, the include file JRunQuality.hh should accordingly be updated.
22
23
24
25set_variable: DEBUG QAQC_DEBUG 0
26set_variable: VERSION QAQC_VERSION D_1.0.0
27set_variable: WORKDIR QAQC_WORKDIR ${TMPDIR:-/tmp}/.$$
28
29TRIGGER_PARAMETERS=(
30 trigger3DMuon.enabled
31 trigger3DShower.enabled
32 triggerMXShower.enabled
33 triggerNB.enabled
34 writeL0.prescale
35 writeL1.prescale
36 writeL2.prescale
37 writeSN.prescale)
38
39TRIGGERS=(`JPrintTriggerBits`)
40
41DAQ=(
42 JDAQTimeslice
43 JDAQTimesliceL0
44 JDAQTimesliceL1
45 JDAQTimesliceL2
46 JDAQTimesliceSN
47 JDAQSummaryslice
48 JDAQEvent)
49
50AHRS=(
51 zero_AHRS
52 mean_AHRS)
53
54typeset -a PARAMETERS
55
56PARAMETERS=(
57 GIT JPP nb_of_meta UUID
58 detector run livetime_s UTCMin_s UTCMax_s
59 ${TRIGGER_PARAMETERS[*]}
60 ${DAQ[*]}
61 JTriggerReprocessor
62 ${TRIGGERS[*]}
63 in_sync out_sync DAQ WR HRV FIFO
64 PMTs MEAN_Rate_Hz RMS_Rate_Hz
65 hrv_fifo_failures duplic_timeslices
66 Acoustics ${AHRS[*]}
67 in_usync out_usync
68 event_duration)
69
70if do_usage $*; then
71 usage \
72 "$script (input file)+ <QA/QC file>" \
73 "\nAuxiliary script to produce the following QA/QC data:\n" \
74 ${PARAMETERS//\.*} \
75 "\nSee also: $JPP_PAGES/ Search \"JRunQuality\""
76fi
77
78if (( $# < 2 )); then
79 fatal "Wrong number of arguments."
80fi
81
82set_array INPUT_FILES ${argv[1,-2]}
83set_variable QAQC_FILE ${argv[-1]:a}
84
85for (( i = 1; $i <= ${#INPUT_FILES}; i += 1 )); do
86 if [[ -f $INPUT_FILES[$i] ]]; then
87 INPUT_FILES[$i]=${INPUT_FILES[$i]:a}
88 fi
89done
90
91mkdir -p ${WORKDIR}
92pushd ${WORKDIR}
93
94set_variable ACOUSTICS_DEBUG ${DEBUG}
95set_variable COMPASS_DEBUG ${DEBUG}
96set_variable DETECTOR detector.detx # detector used during data taking
97
98JCookie.sh
99CHECK_EXIT_CODE
100
101# Locally install input files.
102
103if [[ ! -f sound_velocity.txt ]]; then
104 cat>sound_velocity.txt<<EOF
1051539.50 -17e-3 -2000.00
106EOF
107fi
108
109if [[ ! -s $QAQC_FILE ]]; then
110 echo ${PARAMETERS//\.*/} > $QAQC_FILE
111fi
112
113for INPUT_FILE in ${INPUT_FILES[*]}; do
114
115 debug "Processing $INPUT_FILE"
116
117 # determine values
118
119 JPrintMeta -v |& awk '/version/ { print $2 }' | read GIT_VERSION
120 CHECK_EXIT_CODE
121 debug "GIT version $GIT_VERSION"
122
123 set_array DAQ_VERSION `JPrintMeta -f ${INPUT_FILE} -k GIT`
124 debug "DAQ version $DAQ_VERSION[*]"
125
126 echo ${(s/./)DAQ_VERSION[1]} | read DAQ_MAJOR DAQ_MINOR DAQ_PATCH
127
128 if [[ -z $DAQ_VERSION[1] ]]; then
129 JPrintMeta -f ${INPUT_FILE} -k SVN | read DAQ_VERSION
130 fi
131
132 getUUID -f ${INPUT_FILE} -d 0 | read UUID
133 CHECK_EXIT_CODE
134
135 set_array DAQ_HEADER `JPrintDAQHeader -f ${INPUT_FILE} -d 0`
136 set_variable DETECTOR_ID ${DAQ_HEADER[1]}
137 set_variable RUN ${DAQ_HEADER[2]}
138
139 JDetectorDB -D ${DETECTOR_ID} -r ${RUN} -o ${DETECTOR} -WW -d ${DEBUG} # install detector file as-is for a.o. JTriggerReprocessor
140 CHECK_EXIT_CODE
141
142 if [[ "$DAQ_MAJOR" != [0-9][0-9]* ]] || (( $DAQ_MAJOR <= 12 )); then # Jpp-version dependence
143 JEditDetector \
144 -a ${DETECTOR} \
145 -P "-1 -1 set UDP_COUNTER_DISABLE" \
146 -P "-1 -1 set UDP_TRAILER_DISABLE" \
147 -o ${DETECTOR} \
148 -d ${DEBUG}
149 fi
150
151 JAHRSCalibration.sh ${DETECTOR_ID} # install AHRS calibration file
152 CHECK_EXIT_CODE
153
154 set_array LIVETIME_S `getLivetime -f ${INPUT_FILE} -d 0`
155 set_array UTC_S `getUTC -f ${INPUT_FILE} -d 0`
156
157 {{ JTriggerMonitor -f ${INPUT_FILE} -d ${DEBUG} -Q 3 3>&1 1>&4 } | read -A TRIGGER_MONITOR } 4>&1
158 CHECK_EXIT_CODE
159
160 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_reprocessor.root
161
162 JTriggerReprocessor \
163 -a ${DETECTOR} \
164 -f ${INPUT_FILE} \
165 -o ${OUTPUT_FILE} \
166 -U \
167 -C -\.\* \
168 -d ${DEBUG}
169 CHECK_EXIT_CODE
170
171 JPrintTree -f ${OUTPUT_FILE} -@ "type = JDAQEvent" -k number_of_entries | read TRIGGER_REPROCESSOR
172
173 {{ JTurbot \
174 -f ${INPUT_FILE} \
175 -a ${DETECTOR} \
176 -o /dev/null \
177 -d ${DEBUG} \
178 -Q 3 3>&1 1>&4 } | read -A TURBOT } 4>&1
179 CHECK_EXIT_CODE
180
181 {{ JSummaryMonitor -f ${INPUT_FILE} -t 50000 -d ${DEBUG} -Q 3 3>&1 1>&4 } | read -A SUMMARY_MONITOR } 4>&1
182 CHECK_EXIT_CODE
183
184 JAcousticsTriggerProcessor.sh ${DETECTOR} ${RUN}
185
186 if (( $? == 0 )); then
187
188 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_event.root
189
190 NUMBER_OF_ACOUSTICS_EVENTS=(`JPrintTree -f ${OUTPUT_FILE} -@ "type = JACOUSTICS::JEvent" -k number_of_entries`)
191 else
192 NUMBER_OF_ACOUSTICS_EVENTS=(0)
193 fi
194
195 JAHRS.sh ${DETECTOR_ID} ${RUN}
196
197 if (( $? == 0 )); then
198
199 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_ahrs.root
200
201 {{ JAHRSMonitor \
202 -a ${DETECTOR} \
203 -f ${OUTPUT_FILE} \
204 -c ahrs_calibration.txt \
205 -q 0.2 \
206 -d ${DEBUG} \
207 -Q 3 3>&1 1>&4 } | read -A AHRS_MONITOR } 4>&1
208 else
209 AHRS_MONITOR=(0,0)
210 fi
211
212 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_trigger.root
213
214 JTriggerProcessor \
215 -a ${DETECTOR} \
216 -f ${INPUT_FILE} \
217 -C JDAQTimesliceSN \
218 -@ "trigger3DMuon.enabled = 1" \
219 -@ "trigger3DMuon.numberOfHits = 3" \
220 -@ "trigger3DMuon.numberOfModules = 3" \
221 -@ "trigger3DMuon.gridAngle_deg = 10" \
222 -@ "trigger3DMuon.TMaxExtra_ns = 500.0e3" \
223 -@ "TMaxEvent_ns = 500.0e3" \
224 -@ "TMaxLocal_ns = 20.0" \
225 -@ "L2.numberOfHits = 4" \
226 -@ "L2.TMaxLocal_ns = 20.0" \
227 -@ "L2.ctMin = 0.0" \
228 -o ${OUTPUT_FILE} \
229 -d ${DEBUG}
230 CHECK_EXIT_CODE
231
232 {{ JSquid \
233 -a ${DETECTOR} \
234 -f ${OUTPUT_FILE} \
235 -o /dev/null \
236 -d ${DEBUG} \
237 -Q 3 3>&1 1>&4 } | read -A SQUID } 4>&1
238
239 {{ JMermaid \
240 -a ${DETECTOR} \
241 -f ${INPUT_FILE} \
242 -o /dev/null \
243 -d ${DEBUG} \
244 -Q 3 3>&1 1>&4 } | read -A MERMAID } 4>&1
245
246 # print values
247
248 printf " %12s" ${GIT_VERSION} >> $QAQC_FILE
249 printf " %12s" ${DAQ_VERSION[1]:-\?} >> $QAQC_FILE
250 printf " %1d" ${#DAQ_VERSION} >> $QAQC_FILE
251 printf " %s" ${UUID:-\?} >> $QAQC_FILE
252 printf " %8d" ${DAQ_HEADER[1,2]} >> $QAQC_FILE
253 printf " %9.1f" ${LIVETIME_S[1]} >> $QAQC_FILE
254 printf " %12.1f" ${UTC_S[1,2]} >> $QAQC_FILE
255
256 for KEY in ${TRIGGER_PARAMETERS[*]}; do
257
258 JPrintTriggerParameters -f ${INPUT_FILE} -k $KEY -d 0 | read VALUE
259
260 printf " %4d" ${VALUE:-0} >> $QAQC_FILE
261 done
262
263 for KEY in ${DAQ[*]}; do
264
265 JPrintTree -f ${INPUT_FILE} -@ "type = $KEY" -k number_of_entries | read VALUE
266
267 printf " %8d" ${VALUE:-0} >> $QAQC_FILE
268 done
269
270 printf " %8d" ${TRIGGER_REPROCESSOR:-0} >> $QAQC_FILE
271 printf " %8d" ${TRIGGER_MONITOR[*]} >> $QAQC_FILE
272 printf " %4d" ${TURBOT[1,2]} >> $QAQC_FILE
273 printf " %7.5f" ${SUMMARY_MONITOR[1,4]} >> $QAQC_FILE
274 printf " %8.1f" ${SUMMARY_MONITOR[5]} >> $QAQC_FILE
275 printf " %7.0f" ${SUMMARY_MONITOR[6,7]} >> $QAQC_FILE
276 printf " %8d" ${SUMMARY_MONITOR[8]} >> $QAQC_FILE
277 printf " %8d" ${SUMMARY_MONITOR[9]} >> $QAQC_FILE
278 printf " %4d" ${NUMBER_OF_ACOUSTICS_EVENTS[1]} >> $QAQC_FILE
279 printf " %5d" ${AHRS_MONITOR[1]} >> $QAQC_FILE
280 printf " %8.3f" ${AHRS_MONITOR[2]} >> $QAQC_FILE
281 printf " %4d" ${SQUID[1,2]} >> $QAQC_FILE
282 printf " %8d" ${MERMAID[1]} >> $QAQC_FILE
283 printf "\n" >> $QAQC_FILE
284done
285
286popd
287
288rm -rf ${WORKDIR}