7doxygen=JDATABASE::JRunQuality
9if [ -z $JPP_DIR ]; then
10 echo "Variable JPP_DIR undefined."
14source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
16# Auxiliary script to produce QA/QC data.
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].
21# Note that if the list of values is extended, the include file JRunQuality.hh should accordingly be updated.
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}
31 trigger3DShower.enabled
32 triggerMXShower.enabled
39TRIGGERS=(`JPrintTriggerBits`)
57 GIT JPP nb_of_meta UUID
58 detector run livetime_s UTCMin_s UTCMax_s
59 ${TRIGGER_PARAMETERS[*]}
63 in_sync out_sync DAQ WR HRV FIFO
64 PMTs MEAN_Rate_Hz RMS_Rate_Hz
65 hrv_fifo_failures duplic_timeslices
74 "$script (input file)+ <QA/QC file>" \
75 "\nAuxiliary script to produce the following QA/QC data:\n" \
77 "\nSee also: $JPP_PAGES/ Search \"JRunQuality\""
81 fatal "Wrong number of arguments."
84set_array INPUT_FILES ${argv[1,-2]}
85set_variable QAQC_FILE ${argv[-1]:a}
87for (( i = 1; $i <= ${#INPUT_FILES}; i += 1 )); do
88 if [[ -f $INPUT_FILES[$i] ]]; then
89 INPUT_FILES[$i]=${INPUT_FILES[$i]:a}
93set_variable ACOUSTICS_DEBUG ${DEBUG}
94set_variable COMPASS_DEBUG ${DEBUG}
95set_variable DETECTOR detector.detx # detector used during data taking
97if (( $ADC == 1 )); then # mandatory input files
99 ACOUSTICS_FILES=(sound_velocity.txt
103 acoustics_trigger_parameters.txt
106 ACOUSTICS_FILES=(${^ACOUSTICS_FILES:a})
112if [[ ! -s $QAQC_FILE ]]; then
113 flock -n $QAQC_FILE echo ${PARAMETERS//\.*/} > $QAQC_FILE
116if [[ ! -d $WORKDIR ]]; then
120for INPUT_FILE in ${INPUT_FILES[*]}; do
122 set_variable DIR `mktemp -d $WORKDIR/qaqc.XXXXXX`
127 debug "Processing $INPUT_FILE"
131 JPrintMeta -v |& awk '/version/ { print $2 }' | read GIT_VERSION
133 debug "GIT version $GIT_VERSION"
135 set_array DAQ_VERSION `JPrintMeta -f ${INPUT_FILE} -k GIT`
136 debug "DAQ version $DAQ_VERSION[*]"
138 echo ${(s/./)DAQ_VERSION[1]} | read DAQ_MAJOR DAQ_MINOR DAQ_PATCH
140 if [[ -z $DAQ_VERSION[1] ]]; then
141 JPrintMeta -f ${INPUT_FILE} -k SVN | read DAQ_VERSION
144 getUUID -f ${INPUT_FILE} -d 0 | read UUID
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]}
151 JDetectorDB -D ${DETECTOR_ID} -r ${RUN} -o ${DETECTOR} -WW -d ${DEBUG} # install detector file as-is for a.o. JTriggerReprocessor
154 if [[ "$DAQ_MAJOR" != [0-9][0-9]* ]] || (( $DAQ_MAJOR <= 12 )); then # Jpp-version dependence
157 -P "-1 -1 set UDP_COUNTER_DISABLE" \
158 -P "-1 -1 set UDP_TRAILER_DISABLE" \
163 JAHRSCalibration.sh ${DETECTOR_ID} # install AHRS calibration file
166 set_array LIVETIME_S `getLivetime -f ${INPUT_FILE} -d 0`
167 set_array UTC_S `getUTC -f ${INPUT_FILE} -d 0`
171 for KEY in ${TRIGGER_PARAMETERS[*]}; do
173 VALUE=$(JPrintTriggerParameters -f ${INPUT_FILE} -k $KEY -d 0)
175 TRIGGER_VALUES+=(${VALUE:-0})
180 for KEY in ${DAQ_PARAMETERS[*]}; do
182 VALUE=$(JPrintTree -f ${INPUT_FILE} -@ "type = $KEY" -k number_of_entries)
184 DAQ_VALUES+=(${VALUE:-0})
187 {{ JTriggerMonitor -f ${INPUT_FILE} -d ${DEBUG} -Q 3 3>&1 1>&4 } | read -A TRIGGER_MONITOR } 4>&1
190 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_reprocessor.root
192 JTriggerReprocessor \
201 JPrintTree -f ${OUTPUT_FILE} -@ "type = JDAQEvent" -k number_of_entries | read TRIGGER_REPROCESSOR
208 -Q 3 3>&1 1>&4 } | read -A TURBOT } 4>&1
211 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_reprocessor2.root
213 JTriggerReprocessor \
227 -Q 3 3>&1 1>&4 } | read -A COELACANTH } 4>&1
230 {{ JSummaryMonitor -f ${INPUT_FILE} -t 50000 -d ${DEBUG} -Q 3 3>&1 1>&4 } | read -A SUMMARY_MONITOR } 4>&1
233 if (( $ADC == 1 )); then
235 cp $ACOUSTICS_FILES[*] ./
237 touch mechanics.txt acoustics_fit_parameters.txt disable.txt
239 JToA.sh ${DETECTOR_ID} ${RUN}
241 JAcousticsEventBuilder \
243 -f KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_toa.root \
246 -V sound_velocity.txt \
248 -@ acoustics_trigger_parameters.txt \
250 -o KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_event.root \
254 cat>sound_velocity.txt<<EOF
255 1539.50 -17e-3 -2000.00
258 JAcousticsTriggerProcessor.sh ${DETECTOR} ${RUN}
261 if (( $? == 0 )); then
263 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_event.root
265 NUMBER_OF_ACOUSTICS_EVENTS=(`JPrintTree -f ${OUTPUT_FILE} -@ "type = JACOUSTICS::JEvent" -k number_of_entries`)
267 NUMBER_OF_ACOUSTICS_EVENTS=(0)
270 JAHRS.sh ${DETECTOR_ID} ${RUN}
272 if (( $? == 0 )); then
274 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_ahrs.root
279 -c ahrs_calibration.txt \
282 -Q 3 3>&1 1>&4 } | read -A AHRS_MONITOR } 4>&1
287 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_trigger.root
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" \
312 -Q 3 3>&1 1>&4 } | read -A SQUID } 4>&1
319 -Q 3 3>&1 1>&4 } | read -A MERMAID } 4>&1
325 -Q 3 3>&1 1>&4 } | read -A HV_CHECK } 4>&1
326 if (( $? != 0 )); then
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