]>
Commit | Line | Data |
---|---|---|
97561a26 | 1 | #!/bin/bash |
2 | ||
797161e8 | 3 | # General options |
4 | batch=0 | |
5 | proof=0 | |
6 | cent=0 | |
7 | dopass1=0 | |
8 | dopass2=0 | |
9 | dopass3=0 | |
10 | max_rotate=10 | |
11 | prog=aliroot | |
12 | ||
13 | # Input (data and scripts) | |
bd6f5206 | 14 | ana=$ALICE_ROOT/PWGLF/FORWARD/analysis2 |
d969d4af | 15 | esddir="." |
1174780f | 16 | nev=-1 |
797161e8 | 17 | |
18 | # Pass 1 options | |
19 | mc=0 | |
20 | scheme="full" | |
21 | ||
22 | # Pass 2 event selection | |
97561a26 | 23 | vzmin=-10 |
24 | vzmax=10 | |
2176e8cf | 25 | type=INEL |
797161e8 | 26 | mcfilename="none" |
27 | ||
28 | # Pass 3 visualisation options | |
29 | rebin=1 | |
c389303e | 30 | tit= |
797161e8 | 31 | others= |
e1f47419 | 32 | ratios=1 |
33 | asymm=1 | |
797161e8 | 34 | rings=0 |
35 | syserr=1 | |
36 | ||
37 | # Derived variables | |
89c0bcd8 | 38 | pass1=MakeAOD.C |
39 | pass2=MakedNdeta.C | |
797161e8 | 40 | pass3=DrawdNdeta.C++ |
89c0bcd8 | 41 | output1=forward.root |
42 | output2=forward_dndeta.root | |
0be6c8cd | 43 | outputs1="${output1} AliAOD.root event_stat.root EventStat_temp.root" |
44 | outputs2="${output2}" | |
bd6f5206 | 45 | gdb_script=$ALICE_ROOT/PWGLF/FORWARD/analysis2/gdb_cmds |
0be6c8cd | 46 | name=`date +analysis%Y%m%d_%H%M` |
47 | pass2dir=./ | |
97561a26 | 48 | |
20432156 | 49 | #_____________________________________________________________________ |
50 | # Print usage | |
97561a26 | 51 | usage() |
52 | { | |
53 | cat<<EOF | |
54 | Usage: $0 [OPTIONS] | |
55 | ||
56 | Do Pass1 and Pass2 on ESD files in current directory. | |
57 | ||
58 | Options: | |
797161e8 | 59 | General options: |
97561a26 | 60 | -h,--help This help |
89c0bcd8 | 61 | -b,--batch Do batch processing ($batch) |
62 | -P,--proof NWORKERS Run in PROOF(Lite) mode ($proof) | |
797161e8 | 63 | -1,--pass1 Run pass 1 (AOD) ($dopass1) |
64 | -2,--pass2 Run pass 2 (Hists) ($dopass2) | |
65 | -3,--pass3 Run pass 3 (Vizualisation) ($dopass3) | |
66 | -n,--events N Number of events ($nev) | |
89c0bcd8 | 67 | -g,--gdb Run in GDB mode ($gdb) |
797161e8 | 68 | -N,--name STRING Name of analysis ($name) |
e28f5fc5 | 69 | -E,--eloss Run energy loss script |
797161e8 | 70 | -A,--script-dir Script directory ($ana) |
71 | -a,--program Program to use ($prog) | |
72 | Pass 1 options and event selection | |
e1f47419 | 73 | -C,--use-centrality Run centrality task ($cent) |
797161e8 | 74 | -M,--mc Run over MC data ($mc) |
75 | -I,--input-dir PATH Path to input ESD data ($esddir) | |
76 | Pass 2 options | |
77 | -v,--vz-min CM Minimum value of vz ($vzmin) | |
78 | -V,--vz-max CM Maximum value of vz ($vzmax) | |
79 | -t,--trigger TYPE Select trigger TYPE ($type) | |
80 | -S,--scheme SCHEME Normalisation scheme ($scheme) | |
81 | -q,--mcfilename Result of MC analysis ($mcfilename) | |
82 | Pass 3 options | |
83 | -r,--rebin Rebin factor ($rebin) | |
84 | -O,--others WHICH Show other data ($others) | |
85 | -J,--show-rings Show individual rings ($rings) | |
e1f47419 | 86 | -R,--show-ratios Show ratios to other data ($ratios) |
87 | -Z,--show-asymmetry Show asymmetry ($asymm) | |
797161e8 | 88 | -G,--show-syserror Show systematic errors ($syserr) |
ffca499d | 89 | -T,--title STRING Title on plots ($tit) |
97561a26 | 90 | |
91 | TYPE is a comma or space separated list of | |
92 | ||
93 | INEL Inelastic triggers (V0A|V0C|SPD) | |
94 | INEL>0 As above + N_ch > 0 in -0.5<eta<+0.5 | |
95 | NSD Non-single diffractive ((VOA&VOC)|N_ch > 5 -1.9<eta<+1.9) | |
96 | ||
ffca499d | 97 | SCHEME is a comma or space separated list of |
98 | ||
99 | NONE No event-level normalization except trivial one | |
0be6c8cd | 100 | EVENT Event-level normalization |
ffca499d | 101 | BACKGROUND Not implemented yet |
102 | SHAPE Shape correction | |
0be6c8cd | 103 | TRIGGER Trigger efficiency |
104 | FULL Same as EVENTLEVEL,BACKGROUND,SHAPE,TRIGGER | |
ffca499d | 105 | |
797161e8 | 106 | WHICH is a comma or space separated list of |
107 | ||
108 | UA5 UA5 data (900GeV, ppbar, INEL, NSD) | |
109 | CMS CMS data | |
110 | ALICE ALICE published data | |
111 | PYTHIA Event generator data | |
112 | ||
1174780f | 113 | If NWORKERS is 0, then the analysis will be run in local mode. |
97561a26 | 114 | EOF |
115 | } | |
116 | ||
20432156 | 117 | #_____________________________________________________________________ |
0be6c8cd | 118 | test_ralien() |
119 | { | |
120 | aliroot -l -b <<EOF > /dev/null 2>&1 | |
121 | int ret = gSystem->Load("libRAliEn"); | |
122 | gApplication->Terminate(ret); | |
123 | EOF | |
124 | ret=$? | |
125 | return $ret | |
126 | } | |
127 | ||
20432156 | 128 | #_____________________________________________________________________ |
129 | # Toggle a value | |
97561a26 | 130 | toggle() |
131 | { | |
132 | echo $((($1+1)%2)) | |
133 | } | |
134 | ||
20432156 | 135 | #_____________________________________________________________________ |
136 | # Rotate files | |
2176e8cf | 137 | rotate() |
138 | { | |
139 | fname=$1 | |
140 | if test -f ${fname}.${max_rotate} ; then | |
20432156 | 141 | # echo "Removing ${fname}.${max_rotate}" |
142 | rm -f ${fname}.${max_rotate} | |
143 | # echo "Maximum number of rotations - $max_rotate - for $fname found" \ | |
144 | # > /dev/stderr | |
145 | # exit 1 | |
2176e8cf | 146 | fi |
147 | let max=$max_rotate-1 | |
148 | for i in `seq $max -1 1` ; do | |
149 | if test ! -f ${fname}.${i} ; then continue ; fi | |
150 | let newn=$i+1 | |
20432156 | 151 | # echo "Moving ${fname}.$i to ${fname}.$newn" |
2176e8cf | 152 | mv ${fname}.$i ${fname}.$newn |
153 | done | |
154 | if test -f $fname ; then | |
20432156 | 155 | # echo "Moving ${fname} to ${fname}.1" |
2176e8cf | 156 | mv $fname ${fname}.1 |
157 | fi | |
158 | } | |
159 | ||
20432156 | 160 | #_____________________________________________________________________ |
161 | # | |
162 | # Function to run pass | |
163 | # | |
164 | # Arguments (in order) | |
165 | # isBatch: Should we do batch processing | |
166 | # output: Main output file | |
167 | # outputs: All outputs | |
168 | # outdir: Where the output will be put | |
169 | # notlast: Not last pass | |
170 | # script: Script name | |
171 | # args: Arguments for script | |
172 | # | |
173 | run_pass() | |
174 | { | |
175 | isbatch=$1 ; shift | |
176 | output=$1 ; shift | |
177 | outputs=$1 ; shift | |
178 | outdir=$1 ; shift | |
179 | notLast=$1 ; shift | |
180 | script=$1 ; shift | |
181 | args=$1 | |
182 | ||
183 | # --- Log file name ---------------------------------------------- | |
184 | if test "x$output" = "x" ; then | |
185 | log=analysis.log | |
186 | else | |
187 | log=`dirname $output`/`basename $output .root`.log | |
188 | fi | |
189 | ||
190 | # --- Make options for AliROOT ----------------------------------- | |
191 | opts= | |
192 | if test $isbatch -gt 0 || test $notLast -gt 0 ; then | |
193 | opts="-q" | |
194 | fi | |
195 | if test $isbatch -gt 0 ; then | |
196 | opts="-b $opts" | |
197 | fi | |
198 | ||
199 | # --- Rotate output file ----------------------------------------- | |
200 | for i in ${outputs} ${log} ; do | |
201 | rotate ${outdir}${i} | |
202 | done | |
203 | ||
204 | # --- Some print out --------------------------------------------- | |
205 | cat <<-EOF | |
206 | Pass parameters: | |
207 | Batch mode: $isBatch | |
208 | Main output: $output | |
209 | All outputs: $outputs | |
210 | Output directory: $outdir | |
211 | More to do: $notLast | |
212 | Script to run: $script | |
213 | Script arguments: $args | |
214 | Log file: $log | |
215 | AliROOT options: $opts | |
216 | EOF | |
217 | ||
218 | # --- Run AliROOT ------------------------------------------------ | |
797161e8 | 219 | echo "Running ${prog} $opts ${script}${args}" |
20432156 | 220 | if test $isbatch -gt 0 || test $notLast -gt 0 ; then |
797161e8 | 221 | ${prog} ${opts} ${script}"${args}" 2>&1 | tee ${log} |
20432156 | 222 | else |
797161e8 | 223 | ${prog} ${opts} ${script}"${args}" |
20432156 | 224 | fi |
225 | fail=$? | |
226 | ||
227 | # --- Check exit conditions -------------------------------------- | |
228 | if test $fail -gt 0 ; then | |
229 | echo "Returned $fail" | |
230 | exit $fail | |
231 | fi | |
232 | for i in ${outputs} ; do | |
233 | if test ! -f ${outdir}${i} ; then | |
234 | echo "File ${i} not generated in ${outdir}" | |
235 | exit 1 | |
236 | fi | |
237 | done | |
238 | echo "Success (log in $log)" | |
239 | } | |
97561a26 | 240 | |
20432156 | 241 | #_____________________________________________________________________ |
242 | # Loop over arguments | |
97561a26 | 243 | while test $# -gt 0 ; do |
244 | case $1 in | |
797161e8 | 245 | # General options |
246 | -h|--help) usage ; exit 0 ;; | |
e28f5fc5 | 247 | -b|--batch) batch=`toggle $batch` ;; |
797161e8 | 248 | -P|--proof) proof=$2 ; shift ;; |
249 | -1|--pass1|--aod) dopass1=`toggle $dopass1` ;; | |
250 | -2|--pass2|--hist) dopass2=`toggle $dopass2` ;; | |
251 | -3|--pass3|--draw) dopass3=`toggle $dopass3` ;; | |
252 | -n|--events) nev=$2 ; shift ;; | |
253 | -g|--gdb) gdb=`toggle $gdb` ;; | |
254 | -N|--name) name=$2 ; shift ;; | |
255 | -A|--script-dir) ana=$2; shift ;; | |
256 | -a|--program) prog=$2 ; shift ;; | |
89c0bcd8 | 257 | -E|--eloss) pass1=MakeELossFits.C |
258 | pass2=scripts/ExtractELoss.C | |
259 | pass3=scripts/DrawAnaELoss.C | |
260 | output1=forward_eloss.root | |
0be6c8cd | 261 | outputs1="${output1} event_stat.root EventStat_temp.root" |
262 | outputs2="" | |
89c0bcd8 | 263 | dopass2=1 |
e1f47419 | 264 | ;; |
797161e8 | 265 | # Pass 1 options |
266 | -C|--use-centrality) cent=`toggle $cent` ;; | |
267 | -M|--mc) mc=`toggle $mc` ;; | |
268 | -I|--input-dir) esddir=$2 ; shift ;; | |
269 | # Pass 2 options | |
270 | -v|--vz-min) vzmin=$2 ; shift ;; | |
271 | -V|--vz-max) vzmax=$2 ; shift ;; | |
272 | -S|--scheme) scheme=`echo $2 | tr ' ' ','` ; shift ;; | |
273 | -t|--type) type=$2 ; shift ;; | |
274 | -q|--mcname) mcfilename=$2 ; shift ;; | |
275 | # PAss 3 options | |
276 | -r|--rebin) rebin=$2 ; shift ;; | |
277 | -O|--others) others=`echo $2 | tr ',' ' '` ; shift ;; | |
e1f47419 | 278 | -R|--show-ratios) ratios=`toggle $ratios` ;; |
797161e8 | 279 | -J|--show-rings) rings=`toggle $rings` ;; |
e1f47419 | 280 | -Z|--show-asymmetry) asymm=`toggle $asymm` ;; |
797161e8 | 281 | -G|--show-syserror) syserr=`toggle $syserr` ;; |
c89b9ac1 | 282 | -T|--title) tit=$2 ; shift ;; |
97561a26 | 283 | *) echo "$0: Unknown option '$1'" >> /dev/stderr ; exit 1 ;; |
284 | esac | |
285 | shift | |
286 | done | |
287 | ||
20432156 | 288 | #_____________________________________________________________________ |
289 | # Check for RAlien if needed | |
0be6c8cd | 290 | if test "x$name" != "x" && test_ralien ; then |
291 | echo "AliEn plug-in available - output will be in $name" | |
292 | pass2dir=${name}/ | |
293 | fi | |
294 | ||
20432156 | 295 | #_____________________________________________________________________ |
296 | # Pass 1 | |
89c0bcd8 | 297 | if test $dopass1 -gt 0 ; then |
20432156 | 298 | args="(\"${esddir}\",$nev,$proof,$mc,$cent,\"${name}\")" |
299 | echo "Args=$args" | |
300 | run_pass ${batch} ${output1} "${outputs1}" "${pass2dir}" ${dopass2} \ | |
301 | ${ana}/${pass1} ${args} | |
89c0bcd8 | 302 | echo "Pass 1 done" |
97561a26 | 303 | fi |
304 | ||
20432156 | 305 | #_____________________________________________________________________ |
306 | # Pass 2 | |
89c0bcd8 | 307 | if test $dopass2 -gt 0 ; then |
c0812dce | 308 | if test -f forward_dndeta_mc.root ; then |
309 | if test "x$mcfilename" = "xnone" || | |
310 | test "x$mcfilename" = "x" ; then | |
311 | mcfilename=forward_dndeta_mc.root | |
312 | fi | |
313 | fi | |
c89b9ac1 | 314 | args="(\"${pass2dir}\",$nev,\"$type\",$cent,\"$scheme\",$vzmin,$vzmax,$proof,\"$name\",\"$mcfilename\")" |
89c0bcd8 | 315 | if test "x$pass1" = "xMakeELossFits.C" ; then |
0be6c8cd | 316 | args=(\(\"${pass2dir}${output1}\"\)) |
89c0bcd8 | 317 | fi |
c89b9ac1 | 318 | |
20432156 | 319 | run_pass ${batch} ${output2} "${outputs2}" "${pass2dir}" ${dopass3} \ |
320 | ${ana}/${pass2} ${args} | |
89c0bcd8 | 321 | echo "Pass 2 done" |
322 | fi | |
323 | ||
20432156 | 324 | #_____________________________________________________________________ |
325 | # Pass 3 | |
89c0bcd8 | 326 | if test $dopass3 -gt 0 ; then |
0bd4b00f | 327 | tit=`echo $tit | tr ' ' '@'` |
e1f47419 | 328 | flags=0 |
797161e8 | 329 | if test $ratios -gt 0 ; then let flags=$(($flags|0x1)); fi |
330 | if test $asymm -gt 0 ; then let flags=$(($flags|0x2)); fi | |
331 | if test $syserr -gt 0 ; then let flags=$(($flags|0x4)); fi | |
332 | if test $rings -gt 0 ; then let flags=$(($flags|0x8)); fi | |
333 | which=0 | |
334 | others=`echo $others | tr ',' ' ' | tr '[a-z]' '[A-Z]'` | |
335 | for i in $others ; do | |
336 | case $i in | |
337 | UA5) let which=$(($which|0x1)) ;; | |
338 | CMS) let which=$(($which|0x2)) ;; | |
339 | ALICE) let which=$(($which|0x4)) ;; | |
340 | PYTHIA|MC) let which=$(($which|0x8)) ;; | |
341 | esac | |
342 | done | |
8d3650cc | 343 | |
797161e8 | 344 | args="(\"${pass2dir}${output2}\",\"$tit\",$rebin,${which},${flags})" |
89c0bcd8 | 345 | if test "x$pass1" = "xMakeELossFits.C" ; then |
20432156 | 346 | args="(\"${pass2dir}${output1}\")" |
89c0bcd8 | 347 | fi |
20432156 | 348 | |
349 | run_pass ${batch} "" "" "" 0 ${ana}/${pass3} ${args} | |
2176e8cf | 350 | fi |
97561a26 | 351 | |
352 | ||
353 | # | |
354 | # EOF | |
355 | # |