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]"
29 # ------------------------------------------------------------------------------------------
31 # Script to find the optimal voltage of the nanobeacons in a DU
33 # ------------------------------------------------------------------------------------------
43 # print -u2 "$script \n\t [.detx (with complete path)]\n\t [run_number]\n\t [output path]\n\t [string]\n\t [beacon list]\n\t -V [optional if run for V tunning: voltage value]"
49 #------------------------------------
50 # Input-Output definitions
51 #------------------------------------
54 # / __ \ / _ \ / ___/ / _ |
55 # / /_/ / / , _// /__ / __ |
56 # \____/ /_/|_| \___/ /_/ |_|
63 irods_path="/in2p3/km3net/data/raw/sea/KM3NeT_00000029/${string}/"
65 filename="KM3NeT_00000029_0000"
67 #runs=(2660 2661 2662 2663 2664 2665 2666 2667 2668)
69 runs=(2745 2746 2747 2748 2749 2750 2751 2752 2753)
71 #runs=(2813 2814 2815 2816 2817 2818 2819 2820 2821)
73 #runs=(2906 2907 2908 2909 2910 2911 2912 2913 2914)
75 #runs=(2986 2987 2988 2989 2990 2991 2992 2993 2994)
77 voltages=(5.5 6 6.5 7 7.5 8 8.5 10 15)
79 in_detx="/afs/in2p3.fr/home/r/rgracia/sps/KM3NeT/ORCA/Calibration/data/det/ORCA/KM3NeT_00000029_20170920.detx"
83 #####################################################################################################################
86 ##################################
88 # / _ | / _ \ / ___/ / _ | #
89 # / __ | / , _// /__ / __ | #
90 # /_/ |_|/_/|_| \___/ /_/ |_| #
92 ##################################
97 #irods_path="/in2p3/km3net/data/raw/darkroom/KM3NeT_00000038/0/"
99 #filename="KM3NeT_00000038_00000"
101 #runs=(207 208 209 211)
103 #voltages=(15 15 8 8)
105 #in_detx="/afs/in2p3.fr/home/r/rgracia/sps/KM3NeT/ORCA/Calibration/data/det/ARCA/KM3NeT_00000014_20170327.detx"
107 #in_detx="/afs/in2p3.fr/home/r/rgracia/sps/Soft/src/Jpp_trunk/examples/JMonitor/JNanoBeacon/JPulseFinder/temp/KM3NeT_00000038_intrainterDOM_final_pmt7_v1.detx"
109 #####################################################################################################################
114 ###################################################################################################################
115 #GET RUN FILES FROM IRODS AND STORE THEM IN A TEMPORARY DIRECTORY
116 ###################################################################################################################
119 tmpdir="${WORKDIR}/tmp"
121 if [ ! -d ${tmpdir} ]
129 source /usr/local/shared/bin/irods_env.sh >& /dev/null
135 ################################################################################################################
136 #LAUNCH JPULSEFINDER FOR EACH OF THE RUN FILES GRABBED FROM IRODS. STORE THE OUTPUT, AND REMOVE THE RUN FILES.
137 ################################################################################################################
140 outdir_pulse="${WORKDIR}/out/$detector/JPulseFinder"
142 if [ ! -d ${outdir_pulse} ]
146 mkdir -p ${outdir_pulse}
150 pulse_period=6250 #in units of 16 ns
152 stagger_period=220 #in units of 16 ns
156 for i in {1..$((${#runs[@]}))}
160 infile=$tmpdir/${filename}${runs[i]}.root
162 outfile=$outdir_pulse/JPF_${runs[i]}.root
164 outfiles_pulse="${outfiles_pulse} ${outfile}"
166 if [ ! -f $outfile ]; then
168 if [ ! -f $infile ]; then
170 echo "\nGetting file ${filename}${runs[i]}.root from ${irods_path}. Please wait..."
172 iget -f ${irods_path}${filename}${${runs[i]}}.root $tmpdir/
176 echo "\n\nThe file \n${filename}${${runs[i]}}.root \nalready exists in \n$tmpdir.\nContinue..."
185 -stagger $stagger_period \
193 echo "\nThe pulses for run $runs[i] already exist in file\n$outfile\nContinue..."
200 ###############################################################################
201 #LAUNCH JVOLTAGEOPTIMIZER USING THE OUTPUT FROM JPULSEFINDER. STORE THE OUTPUT.
202 ###############################################################################
212 outdir_optimizer="${WORKDIR}/out/$detector/JVoltageOptimizer"
214 if [ ! -d ${outdir_optimizer} ]
218 mkdir -p ${outdir_optimizer}
222 outfile_opt="$outdir_optimizer/JVO_OPT_${runs[1]}_${runs[${#runs[@]}]}.root"
224 outfile_cal="$outdir_optimizer/JVO_CAL_${runs[1]}_${runs[${#runs[@]}]}.root"
226 outfile_txt="$outdir_optimizer/JVO_OPT_${runs[1]}_${runs[${#runs[@]}]}.txt"
228 if [[ ! -f $outfile_opt || ! -f $outfile_cal || ! -f $outfile_txt ]]; then
231 -f "${outfiles_pulse}" \
232 -a $in_detx -s $string \
243 echo "\n\nThe voltage has been optimized. Continue...\n"
247 outdir_calibrator="${WORKDIR}/out/$detector/JInterDomCal"
249 if [ ! -d ${outdir_calibrator} ]
253 mkdir -p ${outdir_calibrator}
257 outfile_txt="$outdir_calibrator/JNBCal_${runs[1]}_${runs[${#runs[@]}]}.txt"
259 outfile_checks="$outdir_calibrator/JNBCal_${runs[1]}_${runs[${#runs[@]}]}.root"
261 outfile_detx="$outdir_calibrator/JNBCal_${runs[1]}_${runs[${#runs[@]}]}.detx"
264 #####################################################################
265 #LAUNCH JINTERDOMCAL USING THE OUTPUT PRODUCED BY JVOLTAGEOPTIMIZER.#
266 #####################################################################
282 ##########################################################################
283 #PRODUCE REPORTS FROM THE OUTPUT FILES FROM CALIBRATION AND OPTIMIZATION.#
284 ##########################################################################
288 calibration_report_name="$outdir_calibrator/calibration_report_${runs[1]}_${runs[${#runs[@]}]}.pdf"
290 optimization_report_name="$outdir_optimizer/optimization_report_${runs[1]}_${runs[${#runs[@]}]}.pdf"
293 echo "Writing calibration report in file:"
294 echo $calibration_report_name
295 echo "------------------------------------\n"
297 python plot_report_calibration.py -ir $outfile_checks -it $outfile_txt -o $calibration_report_name
300 echo "Writing optimization report in file:"
301 echo $optimization_report_name
302 echo "------------------------------------\n"
304 python plot_report_optimization.py -i $outfile_opt -o $optimization_report_name
306 echo "Done... Hasta pronto!"