Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
JCheckK40.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 if [ -z $JPP_DIR ]; then
5  echo "Variable JPP_DIR undefined."
6  exit
7 fi
8 
9 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
10 
11 set_variable: DEBUG CALIBRATION_DEBUG 1
12 set_variable: WORKDIR CALIBRATION_WORKDIR `pwd`
13 set_variable: DAQ_TIMESLICE CALIBRATION_TIMESLICE JDAQTimesliceL1
14 set_variable+ DATABASE_OPTION CALIBRATION_USEPMTID -U
15 set_variable: FORMAT GRAPHICS_FORMAT gif
16 set_variable+ BATCH GRAPHICS_BATCH -B
17 
18 if do_usage $*; then
19  usage "$script <detector file> <input file> <input file> <input file>"\
20  "\nThe 1st and 3rd input file should correspond to a data taking run in which the HV settings are complete (e.g. \"vendor\" or \"tuned\")."\
21  "\nThe 2nd input file should correspond to a run with hybrid HV settings."\
22  "\nIn this, half of the PMTs should have the same HV settings as either the 1st or 3rd input file."
23 fi
24 
25 if (( $# == 4 )); then
26  set_variable DETECTOR $argv[1]
27  set_array INPUT_FILES $argv[2,-1]
28 else
29  fatal "Wrong number of arguments."
30 fi
31 
32 
33 RUNS=()
34 
35 for INPUT_FILE in $INPUT_FILES[*]; do
36 
37  JPrintDAQHeader -f $INPUT_FILE | read DETECTOR_ID RUN FRAME_INDEX UTC
38 
39  RUNS+=($RUN)
40 
41  # Background option
42 
43  if (( `JPrintTree -f $INPUT_FILE -@ "type = JDAQSummaryslice" -k number_of_entries` > 0 )); then
44  set_variable OPTION rates
45  else
46  set_variable OPTION counts
47  fi
48 
49  set_variable OUTPUT_FILE $WORKDIR/monitor_${RUN}.root
50 
51  if [[ ! -f $OUTPUT_FILE ]]; then
52 
53  JCalibrateK40 \
54  -f $INPUT_FILE \
55  -C $DAQ_TIMESLICE \
56  -a $DETECTOR \
57  -o $OUTPUT_FILE \
58  -b $OPTION \
59  -d $DEBUG
60  fi
61 done
62 
63 #
64 # Monitor pair of data taking runs.
65 #
66 # \param 1 1st run
67 # \param 2 2nd run
68 #
69 function monitor()
70 {
71  $JPP_DIR/examples/JCalibrate/JCheckK40 \
72  -a $DETECTOR \
73  -f "$WORKDIR/monitor_${1}.root $WORKDIR/monitor_${2}.root" \
74  -o $WORKDIR/monitor\[${1}-${2}\].root \
75  $DATABASE_OPTION \
76  -d $DEBUG --!
77 }
78 
79 # Monitor
80 
81 monitor $RUNS[1] $RUNS[2]
82 monitor $RUNS[2] $RUNS[3]
83 
84 if (( 1 )); then
85 
86  eval `JPrintDetector -a $DETECTOR -O SUMMARY`
87 
88  kill_child_processes_at_exit
89 
90  attach getModule -a $DETECTOR
91 
92  typeset -Z 4 STRING
93  typeset -Z 2 FLOOR
94 
95  for STRING in $STRINGS[*]; do
96  for (( FLOOR = 1; $FLOOR <= 18; ++FLOOR )); do
97 
98  sput $STRING $FLOOR
99  sget MODULE
100 
101  JPlot1D \
102  -f $WORKDIR/monitor\[${RUNS[1]}-${RUNS[2]}\].root:${MODULE} \
103  -f $WORKDIR/monitor\[${RUNS[2]}-${RUNS[3]}\].root:${MODULE} \
104  -y "-10.0 +10.0" \
105  -> "PMT" \
106  -\^ "#Deltat [ns]" \
107  -T "${STRING}.${FLOOR} ($MODULE)" \
108  -L TL \
109  -o ${MODULE}-${RUNS[1]}-${RUNS[2]}-${RUNS[3]}.${FORMAT} $BATCH
110  done
111  done
112 
113  detach
114 fi