Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
examples/JDataQuality/qaqc.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 version=1.0
6 script=${0##*/}
7 
8 if [ -z $JPP_DIR ]; then
9  echo "Variable JPP_DIR undefined."
10  exit
11 fi
12 
13 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
14 
15 set_variable: DEBUG QAQC_DEBUG 0
16 set_variable: WORKDIR QAQC_WORKDIR ${TMPDIR:-/tmp}/.$$
17 
18 typeset -a PARAMETERS
19 
20 PARAMETERS=(
21  detector run
22  in-usync out-usync
23  event_duration)
24 
25 
26 if do_usage $*; then
27  usage \
28  "$script (input file)+ <QA/QC file>" \
29  "\nAuxiliary script to produce the following QA/QC data:" \
30  "\n$PARAMETERS[*]"
31 fi
32 
33 if (( $# < 2 )); then
34  fatal "Wrong number of arguments."
35 fi
36 
37 set_array INPUT_FILES $argv[1,-2]
38 set_variable QAQC_FILE $argv[-1]
39 
40 
41 mkdir -p $WORKDIR
42 
43 set_variable DETECTOR ${WORKDIR}/detector.detx
44 
45 JCookie.sh
46 CHECK_EXIT_CODE
47 
48 if [[ ! -s $QAQC_FILE ]]; then
49  echo $PARAMETERS[*] > $QAQC_FILE
50 fi
51 
52 for INPUT_FILE in ${INPUT_FILES[*]}; do
53 
54  # determine values
55 
56  JPrintDAQHeader -f ${INPUT_FILE} -d 0 | read -A DAQ_HEADER
57 
58  if (( $? != 0 )); then
59  continue
60  fi
61 
62  set_variable DETECTOR_ID ${DAQ_HEADER[1]}
63  set_variable RUN ${DAQ_HEADER[2]}
64 
65  JDetectorDB -D ${DETECTOR_ID} -r ${RUN} -o ${DETECTOR} # install detector file as-is for JTriggerReprocessor
66  CHECK_EXIT_CODE
67 
68  set_variable OUTPUT_FILE ${WORKDIR}/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_trigger.root
69 
70  JTriggerProcessor \
71  -a ${DETECTOR} \
72  -f ${INPUT_FILE} \
73  -C JDAQTimesliceSN \
74  -@ "trigger3DMuon.enabled = 1" \
75  -@ "trigger3DMuon.numberOfHits = 3" \
76  -@ "trigger3DMuon.numberOfModules = 3" \
77  -@ "trigger3DMuon.gridAngle_deg = 10" \
78  -@ "trigger3DMuon.TMaxExtra_ns = 500.0e3" \
79  -@ "TMaxEvent_ns = 500.0e3" \
80  -@ "TMaxLocal_ns = 20.0" \
81  -@ "L2.numberOfHits = 4" \
82  -@ "L2.TMaxLocal_ns = 20.0" \
83  -@ "L2.ctMin = 0.0" \
84  -o ${OUTPUT_FILE} \
85  -d ${DEBUG}
86 
87  { $JPP_DIR/examples/JDataQuality/JSquid \
88  -a ${DETECTOR} \
89  -f ${OUTPUT_FILE} \
90  -o /dev/null \
91  -d ${DEBUG} \
92  -Q 3 3>&1 1>&4 | read -A SQUID } 4>&1
93 
94  { $JPP_DIR/examples/JDataQuality/JMermaid \
95  -a ${DETECTOR} \
96  -f ${INPUT_FILE} \
97  -o /dev/null \
98  -d ${DEBUG} \
99  -Q 3 3>&1 1>&4 | read -A MERMAID } 4>&1
100 
101  # print values
102 
103  printf " %8d" ${DAQ_HEADER[1,2]} >> $QAQC_FILE
104  printf " %4d" ${SQUID[1,2]} >> $QAQC_FILE
105  printf " %8d" ${MERMAID[*]} >> $QAQC_FILE
106  printf "\n" >> $QAQC_FILE
107 done
108 
109 rm -rf $WORKDIR