Jpp  19.1.0-rc.1
the software that should make you happy
JTunePMTThreshold.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 script=${0##*/}
6 
7 # ------------------------------------------------------------------------------------------
8 #
9 # Script to run tune PMT thresholds.
10 #
11 # ------------------------------------------------------------------------------------------
12 
13 if [ -z $JPP_DIR ]; then
14  echo "Variable JPP_DIR undefined."
15  exit
16 fi
17 source $JPP_DIR/setenv.sh $JPP_DIR
18 
19 set_variable: JDAQ_TIMESLICE CALIBRATION_DAQ_TIMESLICE JDAQTimesliceL0
20 set_variable: WORKDIR CALIBRATION_WORKDIR ./
21 set_variable: TOT_RANGE CALIBRATION_TOT_RANGE "0 8"
22 set_variable: FRACTION CALIBRATION_FRACTION 0.5
23 set_variable: DEBUG CALIBRATION_DEBUG 2
24 
25 if do_usage $*; then
26  usage "$script <detector file> (input file)+ <PMT threshold file (JSon format)>"\
27  "\nAuxiliary script to tune PMT thresholds."
28 fi
29 
30 if (( $# < 3 )); then
31  fatal "Wrong number of arguments."
32 fi
33 
34 set_variable DETECTOR $argv[1]
35 set_array INPUT_FILES $argv[2,-2]
36 set_variable JSON_FILE $argv[-1]
37 
38 JEditDetector \
39  -a $DETECTOR \
40  -P "-1 -1 set HIGH_RATE_VETO_DISABLE" \
41  -o $WORKDIR/detector.datx \
42  -d 1
43 
44 set_variable DETECTOR $WORKDIR/detector.datx
45 
46 OUTPUT_FILES=()
47 
48 for INPUT_FILE in $INPUT_FILES[*]; do
49 
50  JPrintDAQHeader -f $INPUT_FILE -d 0 | read DETECTOR_ID RUN FRAME_INDEX TIMESLICE_START
51 
52  set_variable OUTPUT_FILE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUN}_monitor.root
53 
54  if [[ ! -f $OUTPUT_FILE ]]; then
55 
56  echo Processing $INPUT_FILE
57 
58  JCalibrateToT \
59  -a $DETECTOR \
60  -f $INPUT_FILE \
61  -o $OUTPUT_FILE \
62  -C $JDAQ_TIMESLICE \
63  -d $DEBUG
64  fi
65 
66  OUTPUT_FILES+=($OUTPUT_FILE)
67 
68 done
69 
70 JTunePMTThreshold \
71  -f "$OUTPUT_FILES" \
72  -x "$TOT_RANGE" \
73  -t $FRACTION \
74  -o $JSON_FILE \
75  -d $DEBUG --!