Jpp
Calibrate.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 
3 #
4 # _ _ _ ____
5 # | | | \ | | | _ \
6 # | | | \| | __ _ _ __ ___ | |_) | ___ __ _ ___ ___ _ __
7 # _ | | | . ` | / _` | | '_ \ / _ \ | _ < / _ \ / _` | / __| / _ \ | '_ \
8 # | |__| | | |\ | | (_| | | | | | | (_) | | |_) | | __/ | (_| | | (__ | (_) | | | | |
9 # \____/ |_| \_| \__,_| |_| |_| \___/ |____/ \___| \__,_| \___| \___/ |_| |_|
10 #
11 #
12 
13 
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 launches several programs.
15 
16 
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.
18 
19 #
20 
21 version=1.0
22 script=${0##*/}
23 
24 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
25 
26 if ( do_usage $* ); then
27  usage "$script [edit the different options within]"
28 fi
29 
30 # ------------------------------------------------------------------------------------------
31 #
32 # Script to find the optimal voltage of the nanobeacons in a DU
33 #
34 # ------------------------------------------------------------------------------------------
35 
36 echo $*
37 
38 WORKDIR=$PWD
39 
40 function usage()
41 
42 {
43 
44  print -u2 "$script \n\t Choose the adequate options and run it!"
45 
46  exit 1
47 
48 }
49 
50 #------------------------------------
51 # Input-Output definitions
52 #------------------------------------
53 
54 # ____ ___ _____ ___
55 # / __ \ / _ \ / ___/ / _ |
56 # / /_/ / / , _// /__ / __ |
57 # \____/ /_/|_| \___/ /_/ |_|
58 #
59 #####################################################################################################################
60 
61 # detector="ORCA"
62 
63 # string=2
64 
65 # irods_path="/in2p3/km3net/data/raw/sea/KM3NeT_00000029/${string}/"
66 
67 # filename="KM3NeT_00000029_0000"
68 
69 # runs=(2660 2661 2662 2663 2664 2665 2666 2667 2668)
70 
71 # runs=(2745 2746 2747 2748 2749 2750 2751 2752 2753)
72 
73 # voltages=(5.5 6 6.5 7 7.5 8 8.5 10 15)
74 
75 # in_detx="/afs/in2p3.fr/home/r/rgracia/sps/KM3NeT/ORCA/Calibration/data/det/ORCA/KM3NeT_00000029_20170920.detx"
76 
77 #####################################################################################################################
78 
79 
80 
81 # ___ ___ _____ ___
82 # / _ | / _ \ / ___/ / _ |
83 # / __ | / , _// /__ / __ |
84 # /_/ |_|/_/|_| \___/ /_/ |_|
85 #
86 #####################################################################################################################
87 
88 detector="ARCA"
89 
90 #DU3
91 
92 #string=1
93 
94 #irods_path="/in2p3/km3net/data/raw/darkroom/KM3NeT_00000038/0/"
95 
96 #filename="KM3NeT_00000038_00000"
97 
98 #runs=(207 208 209 211)
99 
100 #voltages=(15 15 8 8)
101 
102 #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"
103 
104 #DU1
105 
106 string=1
107 
108 irods_path="/in2p3/km3net/data/raw/sea/KM3NeT_00000014/5/"
109 
110 filename="KM3NeT_00000014_0000"
111 
112 runs=(5077)
113 
114 in_detx="/afs/in2p3.fr/home/r/rgracia/sps/KM3NeT/ORCA/Calibration/data/det/ARCA/KM3NeT_00000014_20170327.detx"
115 
116 top_pmts=1
117 
118 bottom_pmts=4
119 
120 max_neighbors=2
121 
122 analysis_level=1
123 
124 #####################################################################################################################
125 
126 
127 
128 
129 ###################################################################################################################
130 #GET RUN FILES FROM IRODS AND STORE THEM IN A TEMPORARY DIRECTORY
131 ###################################################################################################################
132 
133 
134 tmpdir="${WORKDIR}/tmp"
135 
136 if [ ! -d ${tmpdir} ]
137 
138 then
139 
140  mkdir -p ${tmpdir}
141 
142 fi
143 
144 source /usr/local/shared/bin/irods_env.sh >& /dev/null
145 
146 iinit
147 
148 
149 ################################################################################################################
150 #LAUNCH JPULSEFINDER FOR EACH OF THE RUN FILES GRABBED FROM IRODS. STORE THE OUTPUT, AND REMOVE THE RUN FILES.
151 ################################################################################################################
152 
153 
154 outdir_pulse="${WORKDIR}/out/$detector/JPulseFinder"
155 
156 if [ ! -d ${outdir_pulse} ]
157 
158 then
159 
160  mkdir -p ${outdir_pulse}
161 
162 fi
163 
164 #cd ./../JPulseFinder
165 
166 pulse_period=6250 #in units of 16 ns
167 
168 stagger_period=220 #in units of 16 ns
169 
170 for i in {1..$((${#runs[@]}))}
171 
172 do
173 
174  infile=$tmpdir/${filename}${runs[i]}.root
175 
176  outfile_pulse=$outdir_pulse/JPF_${runs[i]}.root
177 
178  if [ ! -f $outfile_pulse ]; then
179 
180  if [ ! -f $infile ]; then
181 
182  echo "\nGetting file ${filename}${runs[i]}.root from ${irods_path}. Please wait..."
183 
184  iget -f ${irods_path}${filename}${${runs[i]}}.root $tmpdir/
185 
186  else
187 
188  echo "\n\nThe file \n${filename}${${runs[i]}}.root \nalready exists in \n$tmpdir.\nContinue..."
189 
190  fi
191 
192  JPulseFinder \
193  -f $infile \
194  -a $in_detx \
195  -s $string \
196  -p $pulse_period \
197  -stagger $stagger_period \
198  -n $max_neighbors \
199  -o $outfile_pulse \
200  -V ${voltages[i]}
201 
202  #rm -f ${infile}
203 
204  else
205 
206  echo "\nThe pulses for run $runs[i] already exist in file\n$outfile\nContinue..."
207 
208  fi
209 
210  outdir_calibrator="${WORKDIR}/out/$detector/JInterDomCal"
211 
212  if [ ! -d ${outdir_calibrator} ]
213 
214  then
215 
216  mkdir -p ${outdir_calibrator}
217 
218  fi
219 
220  outfile_txt="$outdir_calibrator/JNBCal_${runs[i]}.txt"
221 
222  outfile_checks="$outdir_calibrator/JNBCal_${runs[i]}.root"
223 
224  outfile_detx="$outdir_calibrator/JNBCal_${runs[i]}.detx"
225 
226  JInterDomCal \
227  -a $in_detx \
228  -f $outfile_pulse \
229  -s $string \
230  -t $outfile_txt \
231  -x $outfile_detx \
232  -c $outfile_checks \
233  -u $top_pmts \
234  -d $bottom_pmts \
235  -n $max_neighbors \
236  -l $analysis_level
237 
238  report_name="$outdir_calibrator/calibration_report_${runs[i]}.pdf"
239 
240 
241  echo "Writing calibration report in file:"
242  echo $report_name
243  echo "------------------------------------\n"
244 
245  python plot_report_calibration.py -ir $outfile_checks -it $outfile_txt -o $report_name
246 
247  echo "Done... Hasta pronto!"
248 
249 done