3 # \author rgruiz, mdejong
7 # ------------------------------------------------------------------------------------------
9 # Script to run complete PMT calibration.
11 # ------------------------------------------------------------------------------------------
13 if [ -z $JPP_DIR ]; then
14 echo "Variable JPP_DIR undefined."
18 source $JPP_DIR/setenv.sh $JPP_DIR
20 set_variable: WORKDIR CALIBRATION_WORKDIR ./
21 set_variable: DEBUG CALIBRATION_DEBUG 2
22 set_variable+ OPTION CALIBRATION_OPTION -A
23 set_variable+ ANGLE_DEPENDENCE CALIBRATION_ANGLE_DEPENDENCE -D
24 set_variable+ NOISE_DEPENDENCE CALIBRATION_NOISE_DEPENDENCE -B
25 set_variable: QE_MAX CALIBRATION_QEMAX 2.0
26 set_variable: MU CALIBRATION_MU 0.25
27 set_variable: TOT_MIN_NS CALIBRATION_TOT_MIN_NS 0.0
28 set_variable: TOT_MAX_NS CALIBRATION_TOT_MAX_NS 35.0
31 usage "$script <detector_file> (input file)+ <PMT parameters file>"
35 fatal "Wrong number of arguments."
38 set_variable DETECTOR $argv[1]
39 set_array INPUT_FILES $argv[2,-2]
40 set_variable PMT_FILE $argv[-1]
42 if [[ ! -d $WORKDIR ]]; then
48 eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
49 eval `JPrintDetector -a $DETECTOR -O SUMMARY`
51 debug "$DETECTOR $DETECTOR_ID"
53 if [[ "$DETECTOR_ID" != [1-9][0-9]* ]]; then
54 fatal "Invalid detector identifier \"$DETECTOR_ID\"."
59 set_variable RUNSETUPID
65 for INPUT_FILE in $INPUT_FILES[*]; do
67 JPrintDAQHeader -f $INPUT_FILE | read ID RUN FRAME_INDEX UTC
69 if (( $DETECTOR_ID != $ID )); then
70 fatal "Inconsistent detector identifier $DETECTOR_ID != $ID."
73 JRuns -D $DETECTOR_ID -@ "RUN = $RUN" -F RUNSETUPID | read SETUP
75 debug "Run $RUN -> $SETUP."
77 if (( $RUN < $RANGE[1] )); then; RANGE[1]=$RUN; fi
78 if (( $RUN > $RANGE[2] )); then; RANGE[2]=$RUN; fi
80 if [[ -z "$SETUP" ]]; then
81 fatal "Missing setup identifier for run $RUN."
83 if [[ -n "$RUNSETUPID" && $RUNSETUPID != $SETUP ]]; then
84 fatal "Inconsistent run setup identifiers $RUNSETUPID != $SETUP $RUN."
87 set_variable RUNSETUPID $SETUP
93 for DAQ_TIMESLICE in JDAQTimesliceL1 JDAQTimeslice; do
95 VALUES=(`JPrintTree -f${^INPUT_FILES} -@ "type = ${DAQ_TIMESLICE}" -k number_of_entries`)
97 if [[ -n "$VALUES" ]] && (( ${#VALUES} == ${#INPUT_FILES} )); then
102 if [[ -z "$VALUES" ]] || (( ${#VALUES} != ${#INPUT_FILES} )); then
103 fatal "No valid data in input file(s)."
124 # PMT gain and gain spread
126 set_variable OUTPUT_FILE $WORKDIR/KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RANGE[1]}-${(l:8::0::0:)RANGE[2]}_%.root
131 -o ${OUTPUT_FILE/\%/calibratetot} \
138 -f ${OUTPUT_FILE/\%/calibratetot} \
139 -o ${OUTPUT_FILE/\%/mergetot} \
146 -f ${OUTPUT_FILE/\%/mergetot} \
147 -o ${OUTPUT_FILE/\%/fittot} \
150 -x "$TOT_MIN_NS $TOT_MAX_NS" \
161 -o ${OUTPUT_FILE/\%/calibratek40} \
168 -f ${OUTPUT_FILE/\%/calibratek40} \
169 -o ${OUTPUT_FILE/\%/mergek40} \
176 -f ${OUTPUT_FILE/\%/mergek40} \
177 -o ${OUTPUT_FILE/\%/fitk40} \
193 -T "$TOT_MIN_NS $TOT_MAX_NS" \