6 # | | | \| | __ _ _ __ ___ | |_) | ___ __ _ ___ ___ _ __ ___
7 # _ | | | . ` | / _` | | '_ \ / _ \ | _ < / _ \ / _` | / __| / _ \ | '_ \ / __|
8 # | |__| | | |\ | | (_| | | | | | | (_) | | |_) | | __/ | (_| | | (__ | (_) | | | | | \__ \
9 # \____/ |_| \_| \__,_| |_| |_| \___/ |____/ \___| \__,_| \___| \___/ |_| |_| |___/
14 #This script should be launched everytime a new DU is deployed in the sea, and a set of runs with the nanobeacons tuned at different voltages has been taken. It runs several programs.
17 #First, it copies the run files from irods to a temporary directory and launches JPulseFinder to analyze each of them. JPulseFinder searches for the NB pulses detected by the different PMTs in the neighbor DOMs. Once JPulseFinder has finished, its output is stored and the run files removed from the temporary directory.
23 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
25 if ( do_usage $* ); then
26 usage "$script [edit the different options within]"
30 # ------------------------------------------------------------------------------------------
32 # Script to find the optimal voltage of the nanobeacons in a DU
34 # ------------------------------------------------------------------------------------------
40 JNANODIR="/data/stu18q3km3/src/Jpp/trunk/examples/JNanobeacon"
52 #------------------------------------
53 # Input-Output definitions
54 #------------------------------------
57 # / __ \ / _ \ / ___/ / _ |
58 # / /_/ / / , _// /__ / __ |
59 # \____/ /_/|_| \___/ /_/ |_|
66 path_to_run_files="/data/stu18q3km3/data/KM3NeT_00000029/"
68 filename="KM3NeT_00000029_0000"
70 #runs=(2660 2661 2662 2663 2664 2665 2666 2667 2668)
72 runs=(2745 2746 2747 2748 2749 2750 2751 2752 2753)
74 #runs=(2813 2814 2815 2816 2817 2818 2819 2820 2821)
76 #runs=(2906 2907 2908 2909 2910 2911 2912 2913 2914)
78 #runs=(2986 2987 2988 2989 2990 2991 2992 2993 2994)
80 voltages=(5.5 6 6.5 7 7.5 8 8.5 10 15)
82 in_detx="/data/stu18q3km3/detectors/KM3NeT_00000029_20170920.detx"
94 pulse_period=6250 #in units of 16 ns
96 stagger_period=220 #in units of 16 ns
99 #####################################################################################################################
102 ##################################
103 # ___ ___ _____ ___ #
104 # / _ | / _ \ / ___/ / _ | #
105 # / __ | / , _// /__ / __ | #
106 # /_/ |_|/_/|_| \___/ /_/ |_| #
108 ##################################
114 #path_to_run_files="/in2p3/km3net/data/raw/darkroom/KM3NeT_00000038/0/"
116 #filename="KM3NeT_00000..."
122 #in_detx="path_to_the_following_detector_file/KM3NeT_00000014_20170327.detx"
124 #####################################################################################################################
128 ################################################################################################################
129 #LAUNCH JPULSEFINDER FOR EACH OF THE RUN FILES GRABBED FROM IRODS. STORE THE OUTPUT, AND REMOVE THE RUN FILES.
130 ################################################################################################################
132 outdir_pulse="${WORKDIR}/out/$detector/JPulseFinder"
134 if [ ! -d ${outdir_pulse} ]
138 mkdir -p ${outdir_pulse}
144 for i in {1..$((${#runs[@]}))}
148 infile=$path_to_run_files/${filename}${runs[i]}.root
150 outfile=$outdir_pulse/JPF_${runs[i]}.root
152 outfiles_pulse="${outfiles_pulse} ${outfile}"
154 if [ ! -f $outfile ]; then
161 -stagger $stagger_period \
170 echo "\nThe pulses for run $runs[i] already exist in file\n$outfile\nContinue..."
177 ###############################################################################
178 #LAUNCH JVOLTAGEOPTIMIZER USING THE OUTPUT FROM JPULSEFINDER. STORE THE OUTPUT.
179 ###############################################################################
181 outdir_optimizer="${WORKDIR}/out/$detector/JVoltageOptimizer"
183 if [ ! -d ${outdir_optimizer} ]
187 mkdir -p ${outdir_optimizer}
191 outfile_opt="$outdir_optimizer/JVO_OPT_${runs[1]}_${runs[${#runs[@]}]}.root"
193 outfile_cal="$outdir_optimizer/JVO_CAL_${runs[1]}_${runs[${#runs[@]}]}.root"
195 outfile_txt="$outdir_optimizer/JVO_OPT_${runs[1]}_${runs[${#runs[@]}]}.txt"
197 if [[ ! -f $outfile_opt || ! -f $outfile_cal || ! -f $outfile_txt ]]; then
200 -f "${outfiles_pulse}" \
213 echo "\n\nThe voltage has been optimized. Continue...\n"
217 outdir_calibrator="${WORKDIR}/out/$detector/JInterDomCal"
219 if [ ! -d ${outdir_calibrator} ]
223 mkdir -p ${outdir_calibrator}
227 outfile_txt="$outdir_calibrator/JNBCal_${runs[1]}_${runs[${#runs[@]}]}.txt"
229 outfile_checks="$outdir_calibrator/JNBCal_${runs[1]}_${runs[${#runs[@]}]}.root"
231 outfile_detx="$outdir_calibrator/JNBCal_${runs[1]}_${runs[${#runs[@]}]}.detx"
234 #####################################################################
235 #LAUNCH JINTERDOMCAL USING THE OUTPUT PRODUCED BY JVOLTAGEOPTIMIZER.#
236 #####################################################################
252 ##########################################################################
253 #PRODUCE REPORTS FROM THE OUTPUT FILES FROM CALIBRATION AND OPTIMIZATION.#
254 ##########################################################################
258 calibration_report_name="$outdir_calibrator/calibration_report_${runs[1]}_${runs[${#runs[@]}]}.pdf"
260 optimization_report_name="$outdir_optimizer/optimization_report_${runs[1]}_${runs[${#runs[@]}]}.pdf"
263 echo "Writing calibration report in file:"
264 echo $calibration_report_name
265 echo "------------------------------------\n"
267 python plot_report_calibration.py -ir $outfile_checks -it $outfile_txt -o $calibration_report_name
271 echo "Writing optimization report in file:"
272 echo $optimization_report_name
273 echo "------------------------------------\n"
275 python plot_report_optimization.py -i $outfile_opt -o $optimization_report_name
277 echo "Done... Hasta pronto!"