Jpp 20.0.0-rc.8
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
24set_variable: DEBUG QAQC_DEBUG 0
25set_variable: VERSION QAQC_VERSION D_1.0.0
26set_variable: ADC QAQC_ADC 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_PARAMETERS=(
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_PARAMETERS[*]}
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 HV_check
70 DB_check)
71
72if do_usage $*; then
73 usage \
74 "$script (input file)+ <QA/QC file>" \
75 "\nAuxiliary script to produce the following QA/QC data:\n" \
76 ${PARAMETERS//\.*} \
77 "\nSee also: $JPP_PAGES/ Search \"JRunQuality\""
78fi
79
80if (( $# < 2 )); then
81 fatal "Wrong number of arguments."
82fi
83
84set_array INPUT_FILES ${argv[1,-2]}
85set_variable QAQC_FILE ${argv[-1]:a}
86
87for (( i = 1; $i <= ${#INPUT_FILES}; i += 1 )); do
88 if [[ -f $INPUT_FILES[$i] ]]; then
89 INPUT_FILES[$i]=${INPUT_FILES[$i]:a}
90 fi
91done
92
93set_variable ACOUSTICS_DEBUG ${DEBUG}
94set_variable COMPASS_DEBUG ${DEBUG}
95set_variable DETECTOR detector.detx # detector used during data taking
96
97if (( $ADC == 1 )); then # mandatory input files
98
99 ACOUSTICS_FILES=(sound_velocity.txt
100 tripod.txt
101 transmitter.txt
102 waveform.txt
103 acoustics_trigger_parameters.txt
104 hydrophone.txt)
105
106 ACOUSTICS_FILES=(${^ACOUSTICS_FILES:a})
107fi
108
109JCookie.sh
110CHECK_EXIT_CODE
111
112if [[ ! -s $QAQC_FILE ]]; then
113 flock -n $QAQC_FILE echo ${PARAMETERS//\.*/} > $QAQC_FILE
114fi
115
116if [[ ! -d $WORKDIR ]]; then
117 mkdir -p $WORKDIR
118fi
119
120for INPUT_FILE in ${INPUT_FILES[*]}; do
121
122 set_variable DIR `mktemp -d $WORKDIR/qaqc.XXXXXX`
123
124 mkdir -p ${DIR}
125 pushd ${DIR}
126
127 debug "Processing $INPUT_FILE"
128
129 # determine values
130
131 JPrintMeta -v |& awk '/version/ { print $2 }' | read GIT_VERSION
132 CHECK_EXIT_CODE
133 debug "GIT version $GIT_VERSION"
134
135 set_array DAQ_VERSION `JPrintMeta -f ${INPUT_FILE} -k GIT`
136 debug "DAQ version $DAQ_VERSION[*]"
137
138 echo ${(s/./)DAQ_VERSION[1]} | read DAQ_MAJOR DAQ_MINOR DAQ_PATCH
139
140 if [[ -z $DAQ_VERSION[1] ]]; then
141 JPrintMeta -f ${INPUT_FILE} -k SVN | read DAQ_VERSION
142 fi
143
144 getUUID -f ${INPUT_FILE} -d 0 | read UUID
145 CHECK_EXIT_CODE
146
147 set_array DAQ_HEADER `JPrintDAQHeader -f ${INPUT_FILE} -d 0`
148 set_variable DETECTOR_ID ${DAQ_HEADER[1]}
149 set_variable RUN ${DAQ_HEADER[2]}
150
151 JDetectorDB -D ${DETECTOR_ID} -r ${RUN} -o ${DETECTOR} -WW -d ${DEBUG} # install detector file as-is for a.o. JTriggerReprocessor
152 CHECK_EXIT_CODE
153
154 if [[ "$DAQ_MAJOR" != [0-9][0-9]* ]] || (( $DAQ_MAJOR <= 12 )); then # Jpp-version dependence
155 JEditDetector \
156 -a ${DETECTOR} \
157 -P "-1 -1 set UDP_COUNTER_DISABLE" \
158 -P "-1 -1 set UDP_TRAILER_DISABLE" \
159 -o ${DETECTOR} \
160 -d ${DEBUG}
161 fi
162
163 JAHRSCalibration.sh ${DETECTOR_ID} # install AHRS calibration file
164 CHECK_EXIT_CODE
165
166 set_array LIVETIME_S `getLivetime -f ${INPUT_FILE} -d 0`
167 set_array UTC_S `getUTC -f ${INPUT_FILE} -d 0`
168
169 TRIGGER_VALUES=()
170
171 for KEY in ${TRIGGER_PARAMETERS[*]}; do
172
173 VALUE=$(JPrintTriggerParameters -f ${INPUT_FILE} -k $KEY -d 0)
174
175 TRIGGER_VALUES+=(${VALUE:-0})
176 done
177
178 DAQ_VALUES=()
179
180 for KEY in ${DAQ_PARAMETERS[*]}; do
181
182 VALUE=$(JPrintTree -f ${INPUT_FILE} -@ "type = $KEY" -k number_of_entries)
183
184 DAQ_VALUES+=(${VALUE:-0})
185 done
186
187 {{ JTriggerMonitor -f ${INPUT_FILE} -d ${DEBUG} -Q 3 3>&1 1>&4 } | read -A TRIGGER_MONITOR } 4>&1
188 CHECK_EXIT_CODE
189
190 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_reprocessor.root
191
192 JTriggerReprocessor \
193 -a ${DETECTOR} \
194 -f ${INPUT_FILE} \
195 -o ${OUTPUT_FILE} \
196 -U \
197 -C -\.\* \
198 -d ${DEBUG}
199 CHECK_EXIT_CODE
200
201 JPrintTree -f ${OUTPUT_FILE} -@ "type = JDAQEvent" -k number_of_entries | read TRIGGER_REPROCESSOR
202
203 {{ JTurbot \
204 -f ${INPUT_FILE} \
205 -a ${DETECTOR} \
206 -o /dev/null \
207 -d ${DEBUG} \
208 -Q 3 3>&1 1>&4 } | read -A TURBOT } 4>&1
209 CHECK_EXIT_CODE
210
211 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_reprocessor2.root
212
213 JTriggerReprocessor \
214 -a ${DETECTOR} \
215 -f ${INPUT_FILE} \
216 -o ${OUTPUT_FILE} \
217 -US \
218 -C -\.\* \
219 -d ${DEBUG}
220 CHECK_EXIT_CODE
221
222 {{ JCoelacanth \
223 -f ${INPUT_FILE} \
224 -f ${OUTPUT_FILE} \
225 -a ${DETECTOR} \
226 -d ${DEBUG} \
227 -Q 3 3>&1 1>&4 } | read -A COELACANTH } 4>&1
228 CHECK_EXIT_CODE
229
230 {{ JSummaryMonitor -f ${INPUT_FILE} -t 50000 -d ${DEBUG} -Q 3 3>&1 1>&4 } | read -A SUMMARY_MONITOR } 4>&1
231 CHECK_EXIT_CODE
232
233 if (( $ADC == 1 )); then
234
235 cp $ACOUSTICS_FILES[*] ./
236
237 touch mechanics.txt acoustics_fit_parameters.txt disable.txt
238
239 JToA.sh ${DETECTOR_ID} ${RUN}
240
241 JAcousticsEventBuilder \
242 -a ${DETECTOR} \
243 -f KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_toa.root \
244 -T tripod.txt \
245 -Y transmitter.txt \
246 -V sound_velocity.txt \
247 -W waveform.txt \
248 -@ acoustics_trigger_parameters.txt \
249 -H hydrophone.txt \
250 -o KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_event.root \
251 -d ${DEBUG}
252 else
253
254 cat>sound_velocity.txt<<EOF
255 1539.50 -17e-3 -2000.00
256EOF
257
258 JAcousticsTriggerProcessor.sh ${DETECTOR} ${RUN}
259 fi
260
261 if (( $? == 0 )); then
262
263 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_event.root
264
265 NUMBER_OF_ACOUSTICS_EVENTS=(`JPrintTree -f ${OUTPUT_FILE} -@ "type = JACOUSTICS::JEvent" -k number_of_entries`)
266 else
267 NUMBER_OF_ACOUSTICS_EVENTS=(0)
268 fi
269
270 JAHRS.sh ${DETECTOR_ID} ${RUN}
271
272 if (( $? == 0 )); then
273
274 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_ahrs.root
275
276 {{ JAHRSMonitor \
277 -a ${DETECTOR} \
278 -f ${OUTPUT_FILE} \
279 -c ahrs_calibration.txt \
280 -q 0.2 \
281 -d ${DEBUG} \
282 -Q 3 3>&1 1>&4 } | read -A AHRS_MONITOR } 4>&1
283 else
284 AHRS_MONITOR=(0,0)
285 fi
286
287 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_trigger.root
288
289 JTriggerProcessor \
290 -a ${DETECTOR} \
291 -f ${INPUT_FILE} \
292 -C JDAQTimesliceSN \
293 -@ "trigger3DMuon.enabled = 1" \
294 -@ "trigger3DMuon.numberOfHits = 3" \
295 -@ "trigger3DMuon.numberOfModules = 3" \
296 -@ "trigger3DMuon.gridAngle_deg = 10" \
297 -@ "trigger3DMuon.TMaxExtra_ns = 500.0e3" \
298 -@ "TMaxEvent_ns = 500.0e3" \
299 -@ "TMaxLocal_ns = 20.0" \
300 -@ "L2.numberOfHits = 4" \
301 -@ "L2.TMaxLocal_ns = 20.0" \
302 -@ "L2.ctMin = 0.0" \
303 -o ${OUTPUT_FILE} \
304 -d ${DEBUG}
305 CHECK_EXIT_CODE
306
307 {{ JSquid \
308 -a ${DETECTOR} \
309 -f ${OUTPUT_FILE} \
310 -o /dev/null \
311 -d ${DEBUG} \
312 -Q 3 3>&1 1>&4 } | read -A SQUID } 4>&1
313
314 {{ JMermaid \
315 -a ${DETECTOR} \
316 -f ${INPUT_FILE} \
317 -o /dev/null \
318 -d ${DEBUG} \
319 -Q 3 3>&1 1>&4 } | read -A MERMAID } 4>&1
320
321 {{ JCheckHV \
322 -D ${DETECTOR_ID} \
323 -R ${RUN} \
324 -d ${DEBUG} \
325 -Q 3 3>&1 1>&4 } | read -A HV_CHECK } 4>&1
326 if (( $? != 0 )); then
327 HV_CHECK[1]=-1
328 fi
329
330 # print values
331
332 ( flock 9; \
333 print -u 9 -f " %12s" ${GIT_VERSION}; \
334 print -u 9 -f " %12s" ${DAQ_VERSION[1]:-\?}; \
335 print -u 9 -f " %1d" ${#DAQ_VERSION}; \
336 print -u 9 -f " %s" ${UUID:-\?}; \
337 print -u 9 -f " %8d" ${DAQ_HEADER[1,2]}; \
338 print -u 9 -f " %9.1f" ${LIVETIME_S[1]}; \
339 print -u 9 -f " %12.1f" ${UTC_S[1,2]}; \
340 print -u 9 -f " %4d" ${TRIGGER_VALUES[*]}; \
341 print -u 9 -f " %8d" ${DAQ_VALUES[*]}; \
342 print -u 9 -f " %8d" ${TRIGGER_REPROCESSOR:-0}; \
343 print -u 9 -f " %8d" ${TRIGGER_MONITOR[*]}; \
344 print -u 9 -f " %4d" ${TURBOT[1,2]}; \
345 print -u 9 -f " %7.5f" ${SUMMARY_MONITOR[1,4]}; \
346 print -u 9 -f " %8.1f" ${SUMMARY_MONITOR[5]}; \
347 print -u 9 -f " %7.0f" ${SUMMARY_MONITOR[6,7]}; \
348 print -u 9 -f " %8d" ${SUMMARY_MONITOR[8]}; \
349 print -u 9 -f " %8d" ${SUMMARY_MONITOR[9]}; \
350 print -u 9 -f " %4d" ${NUMBER_OF_ACOUSTICS_EVENTS[1]}; \
351 print -u 9 -f " %5d" ${AHRS_MONITOR[1]}; \
352 print -u 9 -f " %8.3f" ${AHRS_MONITOR[2]}; \
353 print -u 9 -f " %4d" ${SQUID[1,2]}; \
354 print -u 9 -f " %8d" ${MERMAID[1]}; \
355 print -u 9 -f " %8d" ${HV_CHECK[1]}; \
356 print -u 9 -f " %8d" ${COELACANTH[1]}; \
357 print -u 9 -f "\n"; ) 9>>$QAQC_FILE
358
359 popd
360
361 rm -rf ${DIR}
362done
363