Jpp 19.3.0-rc.1
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
101if [[ ! -s $QAQC_FILE ]]; then
102 echo ${PARAMETERS//\.*/} > $QAQC_FILE
103fi
104
105for INPUT_FILE in ${INPUT_FILES[*]}; do
106
107 debug "Processing $INPUT_FILE"
108
109 # determine values
110
111 JPrintMeta -v |& awk '/version/ { print $2 }' | read GIT_VERSION
112 CHECK_EXIT_CODE
113 debug "GIT version $GIT_VERSION"
114
115 set_array DAQ_VERSION `JPrintMeta -f ${INPUT_FILE} -k GIT`
116 debug "DAQ version $DAQ_VERSION[*]"
117
118 echo ${(s/./)DAQ_VERSION[1]} | read DAQ_MAJOR DAQ_MINOR DAQ_PATCH
119
120 if [[ -z $DAQ_VERSION[1] ]]; then
121 JPrintMeta -f ${INPUT_FILE} -k SVN | read DAQ_VERSION
122 fi
123
124 getUUID -f ${INPUT_FILE} -d 0 | read UUID
125 CHECK_EXIT_CODE
126
127 set_array DAQ_HEADER `JPrintDAQHeader -f ${INPUT_FILE} -d 0`
128 set_variable DETECTOR_ID ${DAQ_HEADER[1]}
129 set_variable RUN ${DAQ_HEADER[2]}
130
131 JDetectorDB -D ${DETECTOR_ID} -r ${RUN} -o ${DETECTOR} -WW -d ${DEBUG} # install detector file as-is for a.o. JTriggerReprocessor
132 CHECK_EXIT_CODE
133
134 if [[ "$DAQ_MAJOR" != [0-9][0-9]* ]] || (( $DAQ_MAJOR <= 12 )); then # Jpp-version dependence
135 JEditDetector \
136 -a ${DETECTOR} \
137 -P "-1 -1 set UDP_COUNTER_DISABLE" \
138 -P "-1 -1 set UDP_TRAILER_DISABLE" \
139 -o ${DETECTOR} \
140 -d ${DEBUG}
141 fi
142
143 JAHRSCalibration.sh ${DETECTOR_ID} # install AHRS calibration file
144 CHECK_EXIT_CODE
145
146 set_array LIVETIME_S `getLivetime -f ${INPUT_FILE} -d 0`
147 set_array UTC_S `getUTC -f ${INPUT_FILE} -d 0`
148
149 {{ JTriggerMonitor -f ${INPUT_FILE} -d ${DEBUG} -Q 3 3>&1 1>&4 } | read -A TRIGGER_MONITOR } 4>&1
150 CHECK_EXIT_CODE
151
152 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_reprocessor.root
153
154 JTriggerReprocessor \
155 -a ${DETECTOR} \
156 -f ${INPUT_FILE} \
157 -o ${OUTPUT_FILE} \
158 -U \
159 -C -\.\* \
160 -d ${DEBUG}
161 CHECK_EXIT_CODE
162
163 JPrintTree -f ${OUTPUT_FILE} -@ "type = JDAQEvent" -k number_of_entries | read TRIGGER_REPROCESSOR
164
165 {{ JTurbot \
166 -f ${INPUT_FILE} \
167 -a ${DETECTOR} \
168 -o /dev/null \
169 -d ${DEBUG} \
170 -Q 3 3>&1 1>&4 } | read -A TURBOT } 4>&1
171 CHECK_EXIT_CODE
172
173 {{ JSummaryMonitor -f ${INPUT_FILE} -t 50000 -d ${DEBUG} -Q 3 3>&1 1>&4 } | read -A SUMMARY_MONITOR } 4>&1
174 CHECK_EXIT_CODE
175
176 JAcousticsTriggerProcessor.sh ${DETECTOR} ${RUN}
177
178 if (( $? == 0 )); then
179
180 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_event.root
181
182 NUMBER_OF_ACOUSTICS_EVENTS=(`JPrintTree -f ${OUTPUT_FILE} -@ "type = JACOUSTICS::JEvent" -k number_of_entries`)
183 else
184 NUMBER_OF_ACOUSTICS_EVENTS=(0)
185 fi
186
187 JAHRS.sh ${DETECTOR_ID} ${RUN}
188
189 if (( $? == 0 )); then
190
191 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_ahrs.root
192
193 {{ JAHRSMonitor \
194 -a ${DETECTOR} \
195 -f ${OUTPUT_FILE} \
196 -c ahrs_calibration.txt \
197 -q 0.2 \
198 -d ${DEBUG} \
199 -Q 3 3>&1 1>&4 } | read -A AHRS_MONITOR } 4>&1
200 else
201 AHRS_MONITOR=(0,0)
202 fi
203
204 set_variable OUTPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_trigger.root
205
206 JTriggerProcessor \
207 -a ${DETECTOR} \
208 -f ${INPUT_FILE} \
209 -C JDAQTimesliceSN \
210 -@ "trigger3DMuon.enabled = 1" \
211 -@ "trigger3DMuon.numberOfHits = 3" \
212 -@ "trigger3DMuon.numberOfModules = 3" \
213 -@ "trigger3DMuon.gridAngle_deg = 10" \
214 -@ "trigger3DMuon.TMaxExtra_ns = 500.0e3" \
215 -@ "TMaxEvent_ns = 500.0e3" \
216 -@ "TMaxLocal_ns = 20.0" \
217 -@ "L2.numberOfHits = 4" \
218 -@ "L2.TMaxLocal_ns = 20.0" \
219 -@ "L2.ctMin = 0.0" \
220 -o ${OUTPUT_FILE} \
221 -d ${DEBUG}
222 CHECK_EXIT_CODE
223
224 {{ JSquid \
225 -a ${DETECTOR} \
226 -f ${OUTPUT_FILE} \
227 -o /dev/null \
228 -d ${DEBUG} \
229 -Q 3 3>&1 1>&4 } | read -A SQUID } 4>&1
230
231 {{ JMermaid \
232 -a ${DETECTOR} \
233 -f ${INPUT_FILE} \
234 -o /dev/null \
235 -d ${DEBUG} \
236 -Q 3 3>&1 1>&4 } | read -A MERMAID } 4>&1
237
238 # print values
239
240 printf " %12s" ${GIT_VERSION} >> $QAQC_FILE
241 printf " %12s" ${DAQ_VERSION[1]:-\?} >> $QAQC_FILE
242 printf " %1d" ${#DAQ_VERSION} >> $QAQC_FILE
243 printf " %s" ${UUID:-\?} >> $QAQC_FILE
244 printf " %8d" ${DAQ_HEADER[1,2]} >> $QAQC_FILE
245 printf " %9.1f" ${LIVETIME_S[1]} >> $QAQC_FILE
246 printf " %12.1f" ${UTC_S[1,2]} >> $QAQC_FILE
247
248 for KEY in ${TRIGGER_PARAMETERS[*]}; do
249
250 JPrintTriggerParameters -f ${INPUT_FILE} -k $KEY -d 0 | read VALUE
251
252 printf " %4d" ${VALUE:-0} >> $QAQC_FILE
253 done
254
255 for KEY in ${DAQ[*]}; do
256
257 JPrintTree -f ${INPUT_FILE} -@ "type = $KEY" -k number_of_entries | read VALUE
258
259 printf " %8d" ${VALUE:-0} >> $QAQC_FILE
260 done
261
262 printf " %8d" ${TRIGGER_REPROCESSOR:-0} >> $QAQC_FILE
263 printf " %8d" ${TRIGGER_MONITOR[*]} >> $QAQC_FILE
264 printf " %4d" ${TURBOT[1,2]} >> $QAQC_FILE
265 printf " %7.5f" ${SUMMARY_MONITOR[1,4]} >> $QAQC_FILE
266 printf " %8.1f" ${SUMMARY_MONITOR[5]} >> $QAQC_FILE
267 printf " %7.0f" ${SUMMARY_MONITOR[6,7]} >> $QAQC_FILE
268 printf " %8d" ${SUMMARY_MONITOR[8]} >> $QAQC_FILE
269 printf " %8d" ${SUMMARY_MONITOR[9]} >> $QAQC_FILE
270 printf " %4d" ${NUMBER_OF_ACOUSTICS_EVENTS[1]} >> $QAQC_FILE
271 printf " %5d" ${AHRS_MONITOR[1]} >> $QAQC_FILE
272 printf " %8.3f" ${AHRS_MONITOR[2]} >> $QAQC_FILE
273 printf " %4d" ${SQUID[1,2]} >> $QAQC_FILE
274 printf " %8d" ${MERMAID[1]} >> $QAQC_FILE
275 printf "\n" >> $QAQC_FILE
276done
277
278popd
279
280rm -rf ${WORKDIR}