]>
Commit | Line | Data |
---|---|---|
5934a3e3 | 1 | #!/bin/bash |
2 | # | |
3 | # BEGIN_MANUAL | |
1f7aa5c7 | 4 | # Script to help do PWGLF-Forward analsysis using AliEn |
5 | # ===================================================== | |
5934a3e3 | 6 | # First, one need to figure out what to analyse. Visit the MonAlisa |
7 | # pages and find | |
8 | # | |
9 | # * The list of runs and put that in a file - say runs.list | |
10 | # * The directory where the ESD files are stored | |
11 | # - and the pattern that will match these for all runs | |
12 | # * The directory where the MC ESD files are stored | |
13 | # - and the pattern that will match these for all runs | |
14 | # | |
15 | # Then, one needs to run this script in set-up mode e.g., | |
16 | # | |
1ff25622 | 17 | # $0 --what=setup \ |
8449e3e0 | 18 | # --name=LHC10h \ |
5934a3e3 | 19 | # --real-dir=/alice/data/2010/LHC10h \ |
20 | # --real-pattern=ESDs/pass2/*/AliESDs.root \ | |
1ff25622 | 21 | # --mc-dir=/alice/sim/LHC10h11 \ |
5934a3e3 | 22 | # --mc-pattern=*/AliESDs.root \ |
8449e3e0 | 23 | # --runs=LHC10.list \ |
24 | # --par | |
5934a3e3 | 25 | # |
26 | # Note, all the settings are written to the file .config in the | |
27 | # current directory, so you do not need to give the parameters at | |
28 | # subsequent steps. As an alternative to giving the parameters, one | |
29 | # can create the file by hand. | |
30 | # | |
31 | # Next, we need to generate the corrections. Do | |
32 | # | |
1ff25622 | 33 | # $0 --what=corrs |
5934a3e3 | 34 | # |
8449e3e0 | 35 | # and wait for the jobs to finish and terminate. If 'watching' is |
36 | # turned off, one can also monitor output on MonAlisa, and then when | |
37 | # enough has finished, execute | |
5934a3e3 | 38 | # |
1ff25622 | 39 | # $0 --what=corrs --step=terminate |
5934a3e3 | 40 | # |
1ff25622 | 41 | # enough times to get the final merged result. Next, we need to |
42 | # extract and upload the corrections to our local corrections folder | |
5934a3e3 | 43 | # |
1ff25622 | 44 | # $0 --what=corrs --step=upload |
81775aba | 45 | # $0 --what=corrs --step=draw |
5934a3e3 | 46 | # |
47 | # Now we can submit our AOD generation jobs. Do | |
48 | # | |
1f7aa5c7 | 49 | # $0 --what=aod |
5934a3e3 | 50 | # |
8449e3e0 | 51 | # and wait for the jobs to finish and terminate. If 'watching' is |
52 | # turned off, one can also monitor output on MonAlisa, and then when | |
53 | # enough has finished, execute | |
5934a3e3 | 54 | # |
1f7aa5c7 | 55 | # $0 --what=aod --step=terminate |
5934a3e3 | 56 | # |
1ff25622 | 57 | # enough times to get the final merged result. Next, we need to |
58 | # download the results and we draw the summary results | |
5934a3e3 | 59 | # |
1f7aa5c7 | 60 | # $0 --what aod --step=draw |
5934a3e3 | 61 | # |
62 | # Now, we should do the dN/deta analysis. Do | |
63 | # | |
1f7aa5c7 | 64 | # $0 --what=dndeta |
5934a3e3 | 65 | # |
8449e3e0 | 66 | # and wait for the jobs to finish and terminate. If 'watching' is |
67 | # turned off, one can also monitor output on MonAlisa, and then when | |
68 | # enough has finished, execute | |
5934a3e3 | 69 | # |
1f7aa5c7 | 70 | # $0 --what=dndeta --step=terminate |
5934a3e3 | 71 | # |
81775aba | 72 | # enough times to get the final merged result. If you passed the |
73 | # option --sys=1 in the setup phase, then this will run 3 jobs for | |
74 | # real and MC each - one for INEL, INEL>0, and NSD (V0-AND). Next, we | |
75 | # need to download the results and we can draw the summary and final | |
76 | # plot | |
5934a3e3 | 77 | # |
1f7aa5c7 | 78 | # $0 --what=dndeta --step=draw |
79 | # | |
80 | # When running the trains, one can pass additional options to the | |
81 | # train after the special option -- e.g., | |
82 | # | |
83 | # $0 --what=aod -- --verbose=2 --branches --satellite | |
5934a3e3 | 84 | # |
85 | # Enjoy | |
86 | # | |
1f7aa5c7 | 87 | # Comments, questions, bugs, flames, suggestions, etc. should be sent |
88 | # to Christian Holm Christensen <cholm@nbi.dk> | |
89 | # | |
5934a3e3 | 90 | # END_MANUAL |
c7a8b4d9 | 91 | if test ! -f $ALICE_ROOT/PWGLF/FORWARD/analysis2/baseAnalysis.sh ; then |
92 | echo "baseAnalysis not found!" > /dev/stderr | |
93 | exit 1 | |
94 | fi | |
95 | . $ALICE_ROOT/PWGLF/FORWARD/analysis2/baseAnalysis.sh | |
5934a3e3 | 96 | |
97 | runs= | |
bfab35d9 | 98 | mcruns= |
5934a3e3 | 99 | par=0 |
5934a3e3 | 100 | real_dir= |
101 | real_pat= | |
102 | mc_dir= | |
103 | mc_pat= | |
1ff25622 | 104 | my_real_dir= |
5934a3e3 | 105 | my_mc_dir= |
bfab35d9 | 106 | watch=0 |
5934a3e3 | 107 | |
1ff25622 | 108 | # === Various functions ============================================== |
c7a8b4d9 | 109 | |
110 | ||
111 | # === Implement base functions ======================================= | |
5934a3e3 | 112 | # --- Usage ---------------------------------------------------------- |
c7a8b4d9 | 113 | setup_usage() |
5934a3e3 | 114 | { |
115 | cat <<EOF | |
5934a3e3 | 116 | -r,--runs=FILENAME Specify list of runs file ($runs) |
bfab35d9 | 117 | -R,--mc-runs=FILENAME Specify list of MC runs file ($mcruns) |
5934a3e3 | 118 | -d,--real-dir=ALIEN_DIR Directory holding real data ($real_dir) |
119 | -p,--real-pattern=PATTERN Glob pattern to match when searching ($real_pat) | |
120 | -D,--mc-dir=ALIEN_DIR Directory holding MC data ($mc_dir) | |
121 | -P,--mc-pattern=PATTERN Glob pattern to match when searching ($mc_pat) | |
8449e3e0 | 122 | -W,--watch Watch for job status and terminate automatically |
5934a3e3 | 123 | -a,--par Use par files ($par) |
5934a3e3 | 124 | EOF |
125 | } | |
c7a8b4d9 | 126 | handle_setup_option() |
5934a3e3 | 127 | { |
c7a8b4d9 | 128 | local arg="$1" |
129 | local opt="$2" | |
130 | # echo "Grid: Processing '$arg' ('$opt')" | |
131 | case $arg in | |
132 | -r|--runs) runs=$opt ;; | |
133 | -R|--mc-runs) mcruns=$opt ;; | |
134 | -d|--real-dir) real_dir=$opt ;; | |
135 | -p|--real-pattern) real_pat=$opt ;; | |
136 | -D|--mc-dir) mc_dir=$opt ;; | |
137 | -P|--mc-pattern) mc_pat=$opt ;; | |
138 | -W|--watch) let watch=\!$watch ;; | |
139 | -a|--par) par=1 ;; | |
140 | *) echo "$0: [SETUP] Unknown option $arg" ; exit 1 ;; | |
141 | esac | |
142 | } | |
1ff25622 | 143 | # --- Extract corrections -------------------------------------------- |
144 | terminate() | |
145 | { | |
146 | script Terminate.C | |
147 | } | |
c7a8b4d9 | 148 | |
1ff25622 | 149 | # --- Extract and upload --------------------------------------------- |
150 | extract_upload() | |
151 | { | |
8449e3e0 | 152 | echo "=== Download, extract, and uploade in `basename $PWD` ===" |
1ff25622 | 153 | download |
154 | for i in *.zip ; do | |
155 | if test ! -f $i ; then continue ; fi | |
1ff25622 | 156 | if test $noact -gt 0 ; then continue ; fi |
8449e3e0 | 157 | local d=`basename $i .zip` |
158 | if test ! -d $d ; then | |
159 | mkdir $d | |
160 | fi | |
161 | cd $d | |
162 | if test ! -f .zip ; then | |
163 | echo "= Unpacking ../$i" | |
164 | unzip ../$i > /dev/null 2>&1 | |
165 | touch .zip | |
166 | fi | |
e65b8b56 | 167 | _extract ../Extract.C |
8449e3e0 | 168 | upload |
169 | cd .. | |
1ff25622 | 170 | done |
171 | } | |
172 | ||
173 | # --- Draw ----------------------------------------------------------- | |
174 | draw() | |
175 | { | |
e65b8b56 | 176 | local dd=`pwd` |
177 | dd=`basename $dd` | |
178 | echo "=== Drawing in $dd using $1" | |
179 | local scr=$1 ; shift | |
180 | case x$scr in | |
181 | x/*) ;; | |
182 | x*) scr=../$scr ;; | |
183 | esac | |
81775aba | 184 | # local args=$1 ; shift |
1ff25622 | 185 | download |
186 | for i in *.zip ; do | |
bfab35d9 | 187 | if test "X$i" = "X*.zip" ; then continue ; fi |
e65b8b56 | 188 | echo "--- Will extract $i in $dd" |
1ff25622 | 189 | d=`basename $i .zip` |
73b32206 | 190 | if test ! -d $d ; then |
191 | mkdir -p $d | |
192 | unzip $i -d $d | |
193 | fi | |
c7a8b4d9 | 194 | (cd $d && _draw $scr $@) |
1ff25622 | 195 | done |
196 | } | |
bfab35d9 | 197 | dndeta_draw() |
198 | { | |
e65b8b56 | 199 | echo "=== Drawing dN/deta in $1" |
200 | local top=$1 ; shift | |
201 | cd $top | |
c7a8b4d9 | 202 | download |
203 | for i in *.zip ; do | |
204 | if test "X$i" = "X*.zip" ; then continue ; fi | |
e65b8b56 | 205 | echo "--- Will extract $i" |
c7a8b4d9 | 206 | d=`basename $i .zip` |
207 | if test ! -d $d ; then | |
208 | mkdir -p $d | |
209 | unzip $i -d $d | |
210 | fi | |
e65b8b56 | 211 | (cd $d && \ |
212 | script ${fwd_dir}/DrawdNdetaSummary.C && \ | |
213 | script ../Draw.C) | |
c7a8b4d9 | 214 | done |
e65b8b56 | 215 | cd .. |
bfab35d9 | 216 | } |
1ff25622 | 217 | |
c7a8b4d9 | 218 | # === Script specific functions ====================================== |
219 | # --- Extract corrections -------------------------------------------- | |
220 | download() | |
221 | { | |
e65b8b56 | 222 | echo "=== Executing download in `pwd`" |
c7a8b4d9 | 223 | if test -f .download ; then |
e65b8b56 | 224 | echo "--- Already downloaded in `basename $PWD`" |
c7a8b4d9 | 225 | return 0 |
226 | fi | |
227 | script Download.C | |
228 | touch .download | |
229 | } | |
230 | ||
5934a3e3 | 231 | # --- Get the grid home dir ------------------------------------------ |
232 | outputs() | |
233 | { | |
234 | l=`aliroot -l -b <<EOF | |
235 | gSystem->RedirectOutput("/dev/null"); | |
236 | TGrid::Connect("alien://"); | |
237 | gSystem->RedirectOutput(0); | |
238 | std::cout << gGrid->GetHomeDirectory() << std::endl; | |
239 | EOF` | |
73b32206 | 240 | my_real_dir="$l/${name}_aod_${now}/output" |
241 | my_mc_dir="$l/${name}_mcaod_${now}/output" | |
5934a3e3 | 242 | } |
243 | ||
c7a8b4d9 | 244 | |
245 | run_for_acc() | |
1ff25622 | 246 | { |
e65b8b56 | 247 | local r=`grep -v ^# ../$runs | awk '{FS=" \n\t"}{printf "%d\n", $1}' | head -n 1` |
c7a8b4d9 | 248 | if test x$r = "x" || test $r -lt 1; then |
1ff25622 | 249 | echo "No run for acceptance correction specified" > /dev/stderr |
250 | exit 1 | |
251 | fi | |
c7a8b4d9 | 252 | echo $r |
253 | } | |
1ff25622 | 254 | |
c7a8b4d9 | 255 | # --- Dump the setup ------------------------------------------------- |
256 | dump_setup() | |
257 | { | |
258 | local out=$1 | |
259 | cat >> ${out} <<-EOF | |
260 | # Real data | |
81775aba | 261 | runs=${runs} |
81775aba | 262 | real_dir=${real_dir} |
263 | real_pat=${real_pat} | |
c7a8b4d9 | 264 | # Simulated data |
265 | mcruns=${mcruns} | |
81775aba | 266 | mc_dir=${mc_dir} |
267 | mc_pat=${mc_pat} | |
c7a8b4d9 | 268 | # Output directories |
81775aba | 269 | my_real_dir=${my_real_dir} |
270 | my_mc_dir=${my_mc_dir} | |
c7a8b4d9 | 271 | # Other options |
81775aba | 272 | par=${par} |
81775aba | 273 | watch=${watch} |
81775aba | 274 | EOF |
c7a8b4d9 | 275 | } |
1ff25622 | 276 | |
277 | # --- Run set-ups ---------------------------------------------------- | |
c7a8b4d9 | 278 | setup() |
1ff25622 | 279 | { |
c7a8b4d9 | 280 | _setup $@ |
281 | } | |
bfab35d9 | 282 | |
1ff25622 | 283 | |
5934a3e3 | 284 | # --- Check settings ------------------------------------------------- |
c7a8b4d9 | 285 | check_setup() |
5934a3e3 | 286 | { |
c7a8b4d9 | 287 | check_token |
288 | ||
bfab35d9 | 289 | if test "x$runs" = "x" || test ! -f $runs ; then |
290 | echo "List of run file $runs not found" > /dev/stderr | |
291 | exit 1 | |
292 | fi | |
293 | if test "x$mcruns" = "x" ; then mcruns=$runs ; fi | |
294 | if test ! -f $mcruns ; then | |
295 | echo "List of MC runs file $mcruns not found" > /dev/stderr | |
296 | exit 1 | |
297 | fi | |
bfab35d9 | 298 | if test "x$real_dir" = "x" ; then |
299 | echo "No real data directory specified" > /dev/stderr | |
300 | exit 1 | |
301 | fi | |
302 | if test "x$mc_dir" = "x" ; then | |
303 | echo "No MC data directory specified" > /dev/stderr | |
304 | exit 1 | |
305 | fi | |
306 | if test "x$real_pat" = "x" ; then | |
307 | echo "No real data pattern specified" > /dev/stderr | |
308 | exit 1 | |
309 | fi | |
310 | if test "x$mc_pat" = "x" ; then | |
311 | echo "No MC data pattern specified" > /dev/stderr | |
312 | exit 1 | |
313 | fi | |
bfab35d9 | 314 | |
bfab35d9 | 315 | } |
316 | ||
317 | # --- Show the setup ------------------------------------------------- | |
318 | print_setup() | |
319 | { | |
81775aba | 320 | cat <<-EOF |
c7a8b4d9 | 321 | Real data: |
322 | Run file: ${runs} | |
323 | Directory: ${real_dir} | |
324 | Pattern: ${real_pat} | |
325 | Output: ${my_real_dir} | |
326 | MC data: | |
327 | Run file: ${mcruns} | |
328 | Directory: ${mc_dir} | |
329 | Pattern: ${mc_pat} | |
330 | Output: ${my_mc_dir} | |
81775aba | 331 | Use PAR files: ${par} |
81775aba | 332 | EOF |
5934a3e3 | 333 | } |
5934a3e3 | 334 | |
c7a8b4d9 | 335 | |
336 | ||
337 | # --- Make URI ------------------------------------------------------- | |
338 | # Must modify URL | |
339 | url_opts() | |
5934a3e3 | 340 | { |
c7a8b4d9 | 341 | local mc=$1 ; shift |
342 | local type=$1 ; shift | |
343 | local trig=$1 ; shift | |
5934a3e3 | 344 | |
c7a8b4d9 | 345 | local uopt="&merge=50&split=50&aliroot=last,regular" |
346 | ||
347 | local dir=$real_dir | |
348 | local pat=$real_pat | |
349 | local rl=$runs | |
350 | local tree=esdTree | |
351 | ||
352 | if test $mc -gt 0 ; then | |
353 | dir=$mc_dir | |
354 | pat=$mc_pat | |
355 | rl=$mcruns | |
356 | fi | |
5934a3e3 | 357 | case $type in |
c7a8b4d9 | 358 | *dndeta|*multdists) |
8449e3e0 | 359 | uopt="${uopt}&concat" |
81775aba | 360 | tree=aodTree |
361 | # Modify for input dir for our files | |
362 | dir=$my_real_dir | |
363 | pat="*/AliAOD.root" | |
364 | if test $mc -gt 0 ; then | |
365 | dir=$my_mc_dir | |
366 | fi | |
367 | ;; | |
bfab35d9 | 368 | esac |
8449e3e0 | 369 | if test $mc -gt 0; then |
370 | uopt="${uopt}&mc" | |
371 | fi | |
5934a3e3 | 372 | if test $par -gt 0 ; then |
373 | uopt="${uopt}&par" | |
374 | fi | |
bfab35d9 | 375 | if test x$uuopts != x ; then |
376 | uopt="${uopt}&${uuopts}" | |
377 | fi | |
c7a8b4d9 | 378 | url="alien://${dir}?run=${rl}&pattern=${pat}${uopt}#${tree}" |
379 | } | |
5934a3e3 | 380 | |
c7a8b4d9 | 381 | |
382 | # --- Run the train -------------------------------------------------- | |
383 | # Usage: | |
384 | # | |
385 | allAboard() | |
386 | { | |
387 | local type=$1 ; shift | |
388 | local trig=$1 ; shift | |
e65b8b56 | 389 | _allAboard "$type" "$trig" --batch $@ |
5934a3e3 | 390 | |
8449e3e0 | 391 | if test $watch -lt 1 ; then |
392 | cat <<-EOF | |
393 | Check https://alimonitor.cern.ch/users/jobs.jsp for progress | |
394 | ||
395 | Remember to do | |
396 | ||
c7a8b4d9 | 397 | $0 --what=... --step=terminate |
8449e3e0 | 398 | |
c7a8b4d9 | 399 | until the final merge stage to get the results. |
8449e3e0 | 400 | EOF |
401 | ||
402 | case $type in | |
403 | *corr|*esd) | |
404 | cat <<-EOF | |
405 | Then, do | |
406 | ||
c7a8b4d9 | 407 | $0 --what=... --step=upload |
8449e3e0 | 408 | |
409 | to upload the results to our local corrections store. | |
410 | EOF | |
411 | ;; | |
c7a8b4d9 | 412 | *aod|*dndeta) |
8449e3e0 | 413 | cat <<-EOF |
414 | Then, do | |
415 | ||
c7a8b4d9 | 416 | $0 --what=... --step=draw |
8449e3e0 | 417 | |
c7a8b4d9 | 418 | to get a PDF of the diagnostics histograms and the final plots. |
8449e3e0 | 419 | EOF |
420 | ;; | |
421 | esac | |
422 | else | |
423 | echo "Now waiting for jobs to finish" | |
424 | (cd ${nme}_${now} && \ | |
c7a8b4d9 | 425 | nice aliroot -l -b -x -q Watch.C\(1\) 2>&1 | \ |
426 | tee watch.log > /dev/null &) | |
8449e3e0 | 427 | fi |
5934a3e3 | 428 | } |
429 | ||
c7a8b4d9 | 430 | # --- Collect a directory -------------------------------------------- |
431 | collect_files() | |
5934a3e3 | 432 | { |
c7a8b4d9 | 433 | local dir=$1 ; shift |
434 | local d=$1 ; shift | |
435 | local M=$1 ; shift | |
436 | local out=$1 ; shift | |
437 | local r=$1 ; shift | |
438 | local files="$1" | |
5934a3e3 | 439 | |
c7a8b4d9 | 440 | for ad in $dir/root_archive_* ; do |
441 | if test ! -d $ad ; then continue ; fi | |
442 | local r=`basename $ad | sed 's/root_archive_0*//'` | |
443 | _collect_files "$ad" "$d" "$M" "$out" "$r" "$files" | |
444 | done # for ad in ... | |
5934a3e3 | 445 | } |
446 | ||
c7a8b4d9 | 447 | |
bfab35d9 | 448 | # === Procedual code ================================================= |
c7a8b4d9 | 449 | runIt $@ |
5934a3e3 | 450 | |
451 | # | |
452 | # EOF | |
453 | # | |
454 |