Logo Coherent WaveBurst  
Reference Guide
Logo
 All Namespaces Files Functions Variables Macros Pages
cwb_obchunk.csh
Go to the documentation of this file.
1 #!/bin/tcsh -f
2 
3 onintr irq_ctrlc
4 
5 if ($1 == '') then
6  echo ""
7  echo 'cwb_obchunk --run="..." --search="..." --bin="..." --wlabel="..." --list="..." --trials="..." --bbh="..." --chunk="..." --lag="..." --slag="..." --merge="..." --opt="..."'
8  echo ""
9  echo "run : O1, O2 (def=O2)"
10  echo "search : BurstLF, BurstHF, BurstLD, IMBHB, BBH (def=BBH)"
11  echo "bin : 1,2,... -> bin1_cut, bin2_cut, ..."
12  echo "wlabel : working directory label -> O2_K03_C00_LH_BurstLF_BKG_dev1"
13  echo "list : list of root files used to merge together the chunks"
14  echo "trials : trials to applied to the detected events"
15  echo "bbh : true/false (def=true)"
16  echo "chunk : chunk number: integer number, Ex 02,03,...,15 "
17  echo "merge : merge id: integer number"
18  echo "lag : lag number: integer number"
19  echo "slag : slag number: integer number"
20  echo ""
21  echo "opt : optional"
22  echo " no options -> disable (default)"
23  echo " mkdir : creates open box directory"
24  echo " report : creates report for lag e slag"
25  echo " ced : submit CEDs"
26  echo " plot : creates plots"
27  echo " html : creates chunk html report"
28  echo " all : mkdir+report+ced+plot+html"
29  echo ""
30  echo "question: if not blank then skip question -> Open Box Result, do you want to procede (y/n)? "
31  echo ""
32  echo 'Ex: cwb_obchunk --wlabel="O2_K03_C00_LH_BurstLF_BKG_dev1" --chunk="03" --lag="1" --slag="0" --merge="1" --opt="create"'
33  echo ""
34  exit 1
35 endif
36 
37 setenv CWB_OBCHUNK_RUN "O2"
38 setenv CWB_OBCHUNK_SEARCH "BBH"
39 setenv CWB_OBCHUNK_BIN 1
40 setenv CWB_OBCHUNK_WLABEL ""
41 setenv CWB_OBCHUNK_LIST ""
42 setenv CWB_OBCHUNK_TRIALS 1
43 setenv CWB_OBCHUNK_BBH "true"
44 setenv CWB_OBCHUNK_CHUNK ""
45 setenv CWB_OBCHUNK_LAG ""
46 setenv CWB_OBCHUNK_SLAG ""
47 setenv CWB_OBCHUNK_MERGE ""
48 setenv CWB_OBCHUNK_OPTIONS ""
49 setenv CWB_OBCHUNK_QUESTION ""
50 
51 set cmd_line="$0 $argv"
52 
53 set temp=(`getopt -s tcsh -o r:S:b:w:c:l:s:m:o:q:B:L:T: --long run:,search:,bin:,wlabel:,chunk:,lag:,slag:,merge:,opt:,question:,bbh:,list:,trials: -- $argv:q`)
54 if ($? != 0) then
55  echo "Terminating..." >/dev/stderr
56  exit 1
57 endif
58 eval set argv=\($temp:q\)
59 
60 while (1)
61  switch($1:q)
62  case -r:
63  case --run:
64  setenv CWB_OBCHUNK_RUN $2:q
65  shift ; shift
66  breaksw
67  case -S:
68  case --search:
69  setenv CWB_OBCHUNK_SEARCH $2:q
70  shift ; shift
71  breaksw
72  case -b:
73  case --bin:
74  setenv CWB_OBCHUNK_BIN $2:q
75  shift ; shift
76  breaksw
77  case -w:
78  case --wlabel:
79  setenv CWB_OBCHUNK_WLABEL $2:q
80  shift ; shift
81  breaksw
82  case -L:
83  case --list:
84  setenv CWB_OBCHUNK_LIST $2:q
85  shift ; shift
86  breaksw
87  case -T:
88  case --trials:
89  setenv CWB_OBCHUNK_TRIALS $2:q
90  shift ; shift
91  breaksw
92  case -c:
93  case --chunk:
94  setenv CWB_OBCHUNK_CHUNK $2:q
95  shift ; shift
96  breaksw
97  case -l:
98  case --lag:
99  setenv CWB_OBCHUNK_LAG $2:q
100  shift ; shift
101  breaksw
102  case -s:
103  case --slag:
104  setenv CWB_OBCHUNK_SLAG $2:q
105  shift ; shift
106  breaksw
107  case -m:
108  case --merge:
109  setenv CWB_OBCHUNK_MERGE $2:q
110  shift ; shift
111  breaksw
112  case -o:
113  case --opt:
114  setenv CWB_OBCHUNK_OPTIONS $2:q
115  shift ; shift
116  breaksw
117  case -q:
118  case --question:
119  setenv CWB_OBCHUNK_QUESTION $2:q
120  shift ; shift
121  breaksw
122  case -B:
123  case --bbh:
124  setenv CWB_OBCHUNK_BBH $2:q
125  shift ; shift
126  breaksw
127  case --:
128  shift
129  break
130  default:
131  echo "error - missing parameters!" ; exit 1
132  endsw
133 end
134 
135 if ((( $CWB_OBCHUNK_RUN != 'O1' ) && ( $CWB_OBCHUNK_RUN != 'O2' ))) then
136  echo ""
137  echo --run=\'$CWB_OBCHUNK_RUN\' "is a wrong cwb_obchunk option\n"
138  echo "type cwb_obchunk to list the available options"
139  echo ""
140  exit 1
141 endif
142 
143 if ((( $CWB_OBCHUNK_SEARCH != 'BurstLF' ) && ( $CWB_OBCHUNK_SEARCH != 'BurstHF' ) && ( $CWB_OBCHUNK_SEARCH != 'BurstLD' ) && ( $CWB_OBCHUNK_SEARCH != 'IMBHB' ) && ( $CWB_OBCHUNK_SEARCH != 'BBH' ))) then
144  echo ""
145  echo --search=\'$CWB_OBCHUNK_SEARCH\' "is a wrong cwb_obchunk option\n"
146  echo "type cwb_obchunk to list the available options"
147  echo ""
148  exit 1
149 endif
150 
151 if ( $CWB_OBCHUNK_BIN !~ ^[0-9]+$ ) then
152  echo ""
153  echo --bin=\'$CWB_OBCHUNK_BIN\' "is a wrong cwb_obchunk option\n"
154  echo "type cwb_obchunk to list the available options"
155  echo ""
156  exit 1
157 endif
158 
159 if ( $CWB_OBCHUNK_TRIALS !~ ^[0-9]+$ ) then
160  echo ""
161  echo --trials=\'$CWB_OBCHUNK_TRIALS\' "is a wrong cwb_obchunk option\n"
162  echo "type cwb_obchunk to list the available options"
163  echo ""
164  exit 1
165 endif
166 
167 if (! -d $CWB_OBCHUNK_WLABEL ) then
168  echo ""
169  echo --wlabel=\'$CWB_OBCHUNK_WLABEL\' "working directory do not exist\n"
170  echo "type cwb_obchunk to list the available options"
171  echo ""
172  exit 1
173 endif
174 
175 if ((( $CWB_OBCHUNK_BBH != 'true' ) && ( $CWB_OBCHUNK_BBH != 'false' ))) then
176  echo ""
177  echo --run=\'$CWB_OBCHUNK_BBH\' "is a wrong cwb_obchunk option\n"
178  echo "type cwb_obchunk to list the available options"
179  echo ""
180  exit 1
181 endif
182 
183 if ( $CWB_OBCHUNK_CHUNK !~ ^[0-9]+$ ) then
184  echo ""
185  echo --chunk=\'$CWB_OBCHUNK_CHUNK\' "is a wrong cwb_obchunk option\n"
186  echo "type cwb_obchunk to list the available options"
187  echo ""
188  exit 1
189 endif
190 
191 if ( $CWB_OBCHUNK_MERGE !~ ^[0-9]+$ ) then
192  echo ""
193  echo --merge=\'$CWB_OBCHUNK_MERGE\' "is not an integer\n"
194  echo "type cwb_obchunk to list the available options"
195  echo ""
196  exit 1
197 endif
198 
199 if ( $CWB_OBCHUNK_LAG !~ ^[0-9]+$ ) then
200  echo ""
201  echo --lag=\'$CWB_OBCHUNK_LAG\' "is not an integer\n"
202  echo "type cwb_obchunk to list the available options"
203  echo ""
204  exit 1
205 endif
206 
207 if ( $CWB_OBCHUNK_SLAG !~ ^[0-9]+$ ) then
208  echo ""
209  echo --slag=\'$CWB_OBCHUNK_SLAG\' "is not an integer\n"
210  echo "type cwb_obchunk to list the available options"
211  echo ""
212  exit 1
213 endif
214 
215 if ((( $CWB_OBCHUNK_OPTIONS != 'mkdir' ) && ( $CWB_OBCHUNK_OPTIONS != 'plot' ) && ( $CWB_OBCHUNK_OPTIONS != 'report' ) && ( $CWB_OBCHUNK_OPTIONS != 'ced' ) && ( $CWB_OBCHUNK_OPTIONS != 'html' ) && ( $CWB_OBCHUNK_OPTIONS != 'all' ))) then
216  echo ""
217  echo --opt=\'$CWB_OBCHUNK_OPTIONS\' "is a wrong cwb_obchunk option\n"
218  echo "type cwb_obchunk to list the available options"
219  echo ""
220  exit 1
221 endif
222 
223 if (( $CWB_OBCHUNK_LAG == 0 ) && ( $CWB_OBCHUNK_SLAG == 0 ) && ( $CWB_OBCHUNK_QUESTION == "" )) then
224  echo "Open Box Result, do you want to procede (y/n)?"
225  set answer = $<
226  if ( $answer == "n" ) then
227  echo ""
228  exit 1
229  endif
230 endif
231 
232 
233 if ( $CWB_OBCHUNK_SEARCH == 'BurstLF' ) then
234  set PP_LABEL = V_hvetoLH.C_bin$CWB_OBCHUNK_BIN\_cut.R_rMRA_hveto_i0cc00_i0rho0_freq16_1024
235  set DIR_REP = report/dump/M$CWB_OBCHUNK_MERGE.Box_Result_Bin$CWB_OBCHUNK_BIN\_Lag$CWB_OBCHUNK_LAG\_Slag$CWB_OBCHUNK_SLAG
236 endif
237 
238 if ( $CWB_OBCHUNK_SEARCH == 'BurstHF' ) then
239  set PP_LABEL = V_hvetoLH.C_bin$CWB_OBCHUNK_BIN\_cut.R_rMRA_hveto_i0cc00_i0rho0_freq512_4096
240  set DIR_REP = report/dump/M$CWB_OBCHUNK_MERGE.Box_Result_Bin$CWB_OBCHUNK_BIN\_Lag$CWB_OBCHUNK_LAG\_Slag$CWB_OBCHUNK_SLAG
241 endif
242 
243 if ( $CWB_OBCHUNK_SEARCH == 'BurstLD' ) then
244  set PP_LABEL = V_hvetoLH.C_bin$CWB_OBCHUNK_BIN\_cut.R_rMRA_hveto_i0cc00_i0rho0_freq16_2048
245  set DIR_REP = report/dump/M$CWB_OBCHUNK_MERGE.Box_Result_Bin$CWB_OBCHUNK_BIN\_Lag$CWB_OBCHUNK_LAG\_Slag$CWB_OBCHUNK_SLAG
246 endif
247 
248 if (( $CWB_OBCHUNK_SEARCH == 'IMBHB' ) || ( $CWB_OBCHUNK_SEARCH == 'BBH' )) then
249  set DIR_REP = report/dump/M$CWB_OBCHUNK_MERGE.Box_Result_Lag$CWB_OBCHUNK_LAG\_Slag$CWB_OBCHUNK_SLAG
250  set PP_LABEL = V_hvetoLH.C_bin$CWB_OBCHUNK_BIN\_cut.R_rMRA_hveto_i0cc00_i1rho0_freq16_1024
251 endif
252 
253 set DIR_PWD = $PWD
254 
255 
256 if (( $CWB_OBCHUNK_OPTIONS == 'plot' ) && ( $CWB_OBCHUNK_LIST != '' ) && ( $CWB_OBCHUNK_CHUNK == 99 )) then # create IFAR plots using a list of output root files
257  root -l -b -e $CWB_CONFIG/MACROS/Make_PP_IFAR.C\(\"$CWB_OBCHUNK_LIST\",\"--search=$CWB_OBCHUNK_SEARCH\:bin$CWB_OBCHUNK_BIN\ --run=$CWB_OBCHUNK_RUN\ --bbh=true\ --trials=$CWB_OBCHUNK_TRIALS\ --lag=$CWB_OBCHUNK_LAG\ --slag=$CWB_OBCHUNK_SLAG\ --chunk=$CWB_OBCHUNK_CHUNK\ --pfname=$DIR_PWD/$CWB_OBCHUNK_WLABEL/$DIR_REP/CumulativeNumberVsIFAR.png\"\)
258  root -l -b -e $CWB_CONFIG/MACROS/Make_PP_IFAR.C\(\"$CWB_OBCHUNK_LIST\",\"--search=$CWB_OBCHUNK_SEARCH\:bin$CWB_OBCHUNK_BIN\ --run=$CWB_OBCHUNK_RUN\ --bbh=false\ --trials=$CWB_OBCHUNK_TRIALS\ --lag=$CWB_OBCHUNK_LAG\ --slag=$CWB_OBCHUNK_SLAG\ --chunk=$CWB_OBCHUNK_CHUNK\ --pfname=$DIR_PWD/$CWB_OBCHUNK_WLABEL/$DIR_REP/CumulativeNumberVsIFAR.png\"\)
259  exit 0
260 endif
261 if (( $CWB_OBCHUNK_OPTIONS == 'html' ) && ( $CWB_OBCHUNK_LIST != '' ) && ( $CWB_OBCHUNK_CHUNK == 99 )) then # create html using a list of output root files
262  root -l -b -e $CWB_CONFIG/MACROS/cwb_mkhtml_all.C\(\"$CWB_OBCHUNK_LIST\",\"$CWB_OBCHUNK_RUN\",\"$CWB_OBCHUNK_SEARCH\:Bin$CWB_OBCHUNK_BIN\",$CWB_OBCHUNK_LAG,$CWB_OBCHUNK_SLAG,\"$CWB_OBCHUNK_WLABEL\",\"$DIR_PWD/$CWB_OBCHUNK_WLABEL/$DIR_REP/CumulativeNumberVsIFAR.png\"\)
263  exit 0
264 endif
265 
266 
267 set DIR_BKG = postprod/M$CWB_OBCHUNK_MERGE.$PP_LABEL
268 set DIR_FRG = postprod/M$CWB_OBCHUNK_MERGE.$PP_LABEL\_lag$CWB_OBCHUNK_LAG\_slag$CWB_OBCHUNK_SLAG
269 
270 set WAVE_FILE = ../../../merge/wave_$CWB_OBCHUNK_WLABEL.M$CWB_OBCHUNK_MERGE.V_hvetoLH.C_bin$CWB_OBCHUNK_BIN\_cut.S_ifar.root
271 set RHO_FREQ_FILE = ../../$DIR_BKG/data/rho_frequency.gif
272 set RHO_TIME_FILE = ../../$DIR_BKG/data/rho_time.gif
273 
274 if (( $CWB_OBCHUNK_OPTIONS == 'mkdir' ) || ( $CWB_OBCHUNK_OPTIONS == 'all' )) then
275  echo $CWB_OBCHUNK_WLABEL/$DIR_REP
276  mkdir $CWB_OBCHUNK_WLABEL/$DIR_REP
277 endif
278 
279 if (( $CWB_OBCHUNK_OPTIONS == 'report' ) || ( $CWB_OBCHUNK_OPTIONS == 'all' )) then
280  cd $CWB_OBCHUNK_WLABEL
281  ${CWB_SCRIPTS}/cwb_report.csh M$CWB_OBCHUNK_MERGE.V_hvetoLH.C_bin$CWB_OBCHUNK_BIN\_cut create $CWB_OBCHUNK_LAG $CWB_OBCHUNK_SLAG
282 endif
283 
284 set CED_DAG = condor/$CWB_OBCHUNK_WLABEL.M$CWB_OBCHUNK_MERGE.$PP_LABEL.ced.dag
285 
286 if (( $CWB_OBCHUNK_OPTIONS == 'ced' ) || ( $CWB_OBCHUNK_OPTIONS == 'all' )) then
287  cd $DIR_PWD/$CWB_OBCHUNK_WLABEL
288  if ( $? != 0) then
289  echo "do you wat to force submit (y/n)?"
290  set answer = $<
291  if ( $answer == "n" ) then
292  echo ""
293  exit 1
294  endif
295  endif
296  rm $CED_DAG.*
297  ${CWB_SCRIPTS}/cwb_condor.csh submit $CED_DAG
298 endif
299 
300 if (( $CWB_OBCHUNK_OPTIONS == 'plot' ) || ( $CWB_OBCHUNK_OPTIONS == 'all' )) then
301  cd $DIR_PWD/$CWB_OBCHUNK_WLABEL/$DIR_REP
302  ln -sf $RHO_TIME_FILE
303  ln -sf $RHO_FREQ_FILE
304 
305  root -l -b -e $CWB_CONFIG/MACROS/Make_PP_IFAR.C\(\"$WAVE_FILE\",\"--search=$CWB_OBCHUNK_SEARCH\:bin$CWB_OBCHUNK_BIN\ --run=$CWB_OBCHUNK_RUN\ --bbh=$CWB_OBCHUNK_BBH\ --lag=$CWB_OBCHUNK_LAG\ --slag=$CWB_OBCHUNK_SLAG\ --chunk=$CWB_OBCHUNK_CHUNK\ --pfname=CumulativeNumberVsIFAR.png\"\)
306  root -l -b -e $CWB_CONFIG/MACROS/Draw_FARvsRHO.C\(\"../../$DIR_BKG/data/far_rho.txt\",\"../../$DIR_FRG/data/far_rho.txt\",\"FARvsRank\"\)
307 endif
308 
309 if (( $CWB_OBCHUNK_OPTIONS == 'html' ) || ( $CWB_OBCHUNK_OPTIONS == 'all' )) then
310  cd $DIR_PWD/$CWB_OBCHUNK_WLABEL/$DIR_REP
311  root -l -b -e $CWB_CONFIG/MACROS/cwb_mkhtml_chunk.C\(\"$CWB_OBCHUNK_RUN\",\"$CWB_OBCHUNK_SEARCH\",$CWB_OBCHUNK_BIN,$CWB_OBCHUNK_CHUNK,$CWB_OBCHUNK_BBH,\"$DIR_BKG\",\"$DIR_FRG\",\"$DIR_PWD/$CWB_OBCHUNK_WLABEL/$DIR_REP\",\"$CWB_OBCHUNK_WLABEL\",\"$WAVE_FILE\",$CWB_OBCHUNK_LAG,$CWB_OBCHUNK_SLAG,2\)
312 endif
313 
314 # create cWB_config.log file
315 # make -f $CWB_CONFIG/Makefile.log CMD_LINE="$cmd_line" git >& /dev/null
316 
317 cd $DIR_PWD
318 
319 unsetenv CWB_OBCHUNK_RUN
320 unsetenv CWB_OBCHUNK_SEARCH
321 unsetenv CWB_OBCHUNK_BIN
322 unsetenv CWB_OBCHUNK_WLABEL
323 unsetenv CWB_OBCHUNK_CHUNK
324 unsetenv CWB_OBCHUNK_LAG
325 unsetenv CWB_OBCHUNK_SLAG
326 unsetenv CWB_OBCHUNK_MERGE
327 unsetenv CWB_OBCHUNK_OPTIONS
328 unsetenv CWB_OBCHUNK_QUESTION
329 
330 exit 0
331 irq_ctrlc:
332  ps T | grep root | awk '{print $1}' | xargs kill -9
333  exit 1
shift breaksw case o
shift breaksw case L
Definition: cwb_obchunk.csh:85
shift breaksw case c
Definition: cwb_obchunk.csh:95
shift breaksw case l
shift breaksw case B
int chunk[CHUNK_MAX_SIZE]
shift breaksw case S
Definition: cwb_obchunk.csh:70
shift breaksw case r
Definition: cwb_clchunk.csh:55
shift breaksw case s
shift breaksw case T
Definition: cwb_obchunk.csh:90
shift breaksw case b
Definition: cwb_obchunk.csh:75
shift breaksw case q
shift breaksw case m
shift breaksw case w
Definition: cwb_obchunk.csh:80
search