Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JCheckK40.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2script=${0##*/}
3
4if [ -z $JPP_DIR ]; then
5 echo "Variable JPP_DIR undefined."
6 exit
7fi
8
9source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
10
11set_variable: DEBUG CALIBRATION_DEBUG 1
12set_variable: WORKDIR CALIBRATION_WORKDIR `pwd`
13set_variable: DAQ_TIMESLICE CALIBRATION_TIMESLICE JDAQTimesliceL1
14set_variable+ DATABASE_OPTION CALIBRATION_USEPMTID -U
15set_variable: FORMAT GRAPHICS_FORMAT gif
16set_variable+ BATCH GRAPHICS_BATCH -B
17
18if 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."
23fi
24
25if (( $# == 4 )); then
26 set_variable DETECTOR $argv[1]
27 set_array INPUT_FILES $argv[2,-1]
28else
29 fatal "Wrong number of arguments."
30fi
31
32
33RUNS=()
34
35for 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
61done
62
63#
64# Monitor pair of data taking runs.
65#
66# \param 1 1st run
67# \param 2 2nd run
68#
69function 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
81monitor $RUNS[1] $RUNS[2]
82monitor $RUNS[2] $RUNS[3]
83
84if (( 1 )); then
85
86 eval `JPrintDetector -a $DETECTOR -O SUMMARY`
87
88
89
90 typeset -Z 4 STRING
91 typeset -Z 2 FLOOR
92
93 for STRING in $STRINGS[*]; do
94 for (( FLOOR = 1; $FLOOR <= 18; ++FLOOR )); do
95
96 eval MODULE=\${STRING_${(l:4::0::0:)STRING}\[$(($FLOOR))\]:--1}
97
98 JPlot1D \
99 -f $WORKDIR/monitor\[${RUNS[1]}-${RUNS[2]}\].root:${MODULE} \
100 -f $WORKDIR/monitor\[${RUNS[2]}-${RUNS[3]}\].root:${MODULE} \
101 -y "-10.0 +10.0" \
102 -> "PMT" \
103 -\^ "#Deltat [ns]" \
104 -T "${STRING}.${FLOOR} ($MODULE)" \
105 -L TL \
106 -o ${MODULE}-${RUNS[1]}-${RUNS[2]}-${RUNS[3]}.${FORMAT} $BATCH
107 done
108 done
109
110fi