3# \author rgruiz, mdejong
7# ------------------------------------------------------------------------------------------
9# Script to run complete PMT calibration.
11# ------------------------------------------------------------------------------------------
13if [ -z $JPP_DIR ]; then
14 echo "Variable JPP_DIR undefined."
18source $JPP_DIR/setenv.sh $JPP_DIR
20set_variable: WORKDIR CALIBRATION_WORKDIR ./
21set_variable: DEBUG CALIBRATION_DEBUG 2
22set_variable+ OPTION CALIBRATION_OPTION -A
23set_variable+ ANGLE_DEPENDENCE CALIBRATION_ANGLE_DEPENDENCE -D
24set_variable+ NOISE_DEPENDENCE CALIBRATION_NOISE_DEPENDENCE -B
25set_variable: TEROSTAT_R1 CALIBRATION_TEROSTAT_R1 1.0
26set_variable: QE_MAX CALIBRATION_QEMAX 2.0
27set_variable: MU CALIBRATION_MU 0.25
28set_variable: TOT_MIN_NS CALIBRATION_TOT_MIN_NS 0.0
29set_variable: TOT_MAX_NS CALIBRATION_TOT_MAX_NS 35.0
32 usage "$script <detector_file> (input file)+ <PMT parameters file>"
36 fatal "Wrong number of arguments."
39set_variable DETECTOR $argv[1]
40set_array INPUT_FILES $argv[2,-2]
41set_variable PMT_FILE $argv[-1]
43if [[ ! -d $WORKDIR ]]; then
49eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
50eval `JPrintDetector -a $DETECTOR -O SUMMARY`
52debug "$DETECTOR $DETECTOR_ID"
54if [[ "$DETECTOR_ID" != [1-9][0-9]* ]]; then
55 fatal "Invalid detector identifier \"$DETECTOR_ID\"."
60set_variable RUNSETUPID
66for INPUT_FILE in $INPUT_FILES[*]; do
68 JPrintDAQHeader -f $INPUT_FILE | read ID RUN FRAME_INDEX UTC
70 if (( $DETECTOR_ID != $ID )); then
71 fatal "Inconsistent detector identifier $DETECTOR_ID != $ID."
74 JRuns -D $DETECTOR_ID -@ "RUN = $RUN" -F RUNSETUPID | read SETUP
76 debug "Run $RUN -> $SETUP."
78 if (( $RUN < $RANGE[1] )); then; RANGE[1]=$RUN; fi
79 if (( $RUN > $RANGE[2] )); then; RANGE[2]=$RUN; fi
81 if [[ -z "$SETUP" ]]; then
82 fatal "Missing setup identifier for run $RUN."
84 if [[ -n "$RUNSETUPID" && $RUNSETUPID != $SETUP ]]; then
85 fatal "Inconsistent run setup identifiers $RUNSETUPID != $SETUP $RUN."
88 set_variable RUNSETUPID $SETUP
94for DAQ_TIMESLICE in JDAQTimesliceL1 JDAQTimeslice; do
96 VALUES=(`JPrintTree -f${^INPUT_FILES} -@ "type = ${DAQ_TIMESLICE}" -k number_of_entries`)
98 if [[ -n "$VALUES" ]] && (( ${#VALUES} == ${#INPUT_FILES} )); then
103if [[ -z "$VALUES" ]] || (( ${#VALUES} != ${#INPUT_FILES} )); then
104 fatal "No valid data in input file(s)."
125# PMT gain and gain spread
127set_variable OUTPUT_FILE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RANGE[1]}-${(l:8::0::0:)RANGE[2]}_%.root
132 -o ${OUTPUT_FILE/\%/calibratetot} \
139 -f ${OUTPUT_FILE/\%/calibratetot} \
140 -o ${OUTPUT_FILE/\%/mergetot} \
147 -f ${OUTPUT_FILE/\%/mergetot} \
148 -o ${OUTPUT_FILE/\%/fittot} \
151 -x "$TOT_MIN_NS $TOT_MAX_NS" \
162 -o ${OUTPUT_FILE/\%/calibratek40} \
169 -f ${OUTPUT_FILE/\%/calibratek40} \
170 -o ${OUTPUT_FILE/\%/mergek40} \
176 -@ "TEROSTAT_R1 = $TEROSTAT_R1" \
178 -f ${OUTPUT_FILE/\%/mergek40} \
179 -o ${OUTPUT_FILE/\%/fitk40} \
195 -T "$TOT_MIN_NS $TOT_MAX_NS" \