4 # Script to help do PWGLF-Forward analsysis using AliEn
5 # =====================================================
6 # First, one need to figure out what to analyse. Visit the MonAlisa
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
15 # Then, one needs to run this script in set-up mode e.g.,
19 # --real-dir=/alice/data/2010/LHC10h \
20 # --real-pattern=ESDs/pass2/*/AliESDs.root \
21 # --mc-dir=/alice/sim/LHC10h11 \
22 # --mc-pattern=*/AliESDs.root \
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.
31 # Next, we need to generate the corrections. Do
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
39 # $0 --what=corrs --step=terminate
41 # enough times to get the final merged result. Next, we need to
42 # extract and upload the corrections to our local corrections folder
44 # $0 --what=corrs --step=upload
45 # $0 --what=corrs --step=draw
47 # Now we can submit our AOD generation jobs. Do
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
55 # $0 --what=aod --step=terminate
57 # enough times to get the final merged result. Next, we need to
58 # download the results and we draw the summary results
60 # $0 --what aod --step=draw
62 # Now, we should do the dN/deta analysis. Do
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
70 # $0 --what=dndeta --step=terminate
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
78 # $0 --what=dndeta --step=draw
80 # When running the trains, one can pass additional options to the
81 # train after the special option -- e.g.,
83 # $0 --what=aod -- --verbose=2 --branches --satellite
87 # Comments, questions, bugs, flames, suggestions, etc. should be sent
88 # to Christian Holm Christensen <cholm@nbi.dk>
91 if test ! -f $ALICE_ROOT/PWGLF/FORWARD/analysis2/baseAnalysis.sh ; then
92 echo "baseAnalysis not found!" > /dev/stderr
95 . $ALICE_ROOT/PWGLF/FORWARD/analysis2/baseAnalysis.sh
108 # === Various functions ==============================================
111 # === Implement base functions =======================================
112 # --- Usage ----------------------------------------------------------
116 -r,--runs=FILENAME Specify list of runs file ($runs)
117 -R,--mc-runs=FILENAME Specify list of MC runs file ($mcruns)
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)
122 -W,--watch Watch for job status and terminate automatically
123 -a,--par Use par files ($par)
126 handle_setup_option()
130 # echo "Grid: Processing '$arg' ('$opt')"
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 ;;
140 *) echo "$0: [SETUP] Unknown option $arg" ; exit 1 ;;
143 # --- Extract corrections --------------------------------------------
149 # --- Extract and upload ---------------------------------------------
152 echo "=== Download, extract, and uploade in `basename $PWD` ==="
155 if test ! -f $i ; then continue ; fi
156 if test $noact -gt 0 ; then continue ; fi
157 local d=`basename $i .zip`
158 if test ! -d $d ; then
162 if test ! -f .zip ; then
163 echo "= Unpacking ../$i"
164 unzip ../$i > /dev/null 2>&1
167 _extract ../Extract.C
173 # --- Draw -----------------------------------------------------------
178 echo "=== Drawing in $dd using $1"
184 # local args=$1 ; shift
187 if test "X$i" = "X*.zip" ; then continue ; fi
188 echo "--- Will extract $i in $dd"
190 if test ! -d $d ; then
194 (cd $d && _draw $scr $@)
199 echo "=== Drawing dN/deta in $1"
204 if test "X$i" = "X*.zip" ; then continue ; fi
205 echo "--- Will extract $i"
207 if test ! -d $d ; then
212 script ${fwd_dir}/DrawdNdetaSummary.C && \
218 # === Script specific functions ======================================
219 # --- Extract corrections --------------------------------------------
222 echo "=== Executing download in `pwd`"
223 if test -f .download ; then
224 echo "--- Already downloaded in `basename $PWD`"
231 # --- Get the grid home dir ------------------------------------------
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;
240 my_real_dir="$l/${name}_aod_${now}/output"
241 my_mc_dir="$l/${name}_mcaod_${now}/output"
247 local r=`grep -v ^# ../$runs | awk '{FS=" \n\t"}{printf "%d\n", $1}' | head -n 1`
248 if test x$r = "x" || test $r -lt 1; then
249 echo "No run for acceptance correction specified" > /dev/stderr
255 # --- Dump the setup -------------------------------------------------
269 my_real_dir=${my_real_dir}
270 my_mc_dir=${my_mc_dir}
277 # --- Run set-ups ----------------------------------------------------
284 # --- Check settings -------------------------------------------------
289 if test "x$runs" = "x" || test ! -f $runs ; then
290 echo "List of run file $runs not found" > /dev/stderr
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
298 if test "x$real_dir" = "x" ; then
299 echo "No real data directory specified" > /dev/stderr
302 if test "x$mc_dir" = "x" ; then
303 echo "No MC data directory specified" > /dev/stderr
306 if test "x$real_pat" = "x" ; then
307 echo "No real data pattern specified" > /dev/stderr
310 if test "x$mc_pat" = "x" ; then
311 echo "No MC data pattern specified" > /dev/stderr
317 # --- Show the setup -------------------------------------------------
323 Directory: ${real_dir}
325 Output: ${my_real_dir}
331 Use PAR files: ${par}
337 # --- Make URI -------------------------------------------------------
342 local type=$1 ; shift
343 local trig=$1 ; shift
345 local uopt="&merge=50&split=50&aliroot=last,regular"
352 if test $mc -gt 0 ; then
359 uopt="${uopt}&concat"
361 # Modify for input dir for our files
364 if test $mc -gt 0 ; then
369 if test $mc -gt 0; then
372 if test $par -gt 0 ; then
375 if test x$uuopts != x ; then
376 uopt="${uopt}&${uuopts}"
378 url="alien://${dir}?run=${rl}&pattern=${pat}${uopt}#${tree}"
382 # --- Run the train --------------------------------------------------
387 local type=$1 ; shift
388 local trig=$1 ; shift
389 _allAboard "$type" "$trig" --batch $@
391 if test $watch -lt 1 ; then
393 Check https://alimonitor.cern.ch/users/jobs.jsp for progress
397 $0 --what=... --step=terminate
399 until the final merge stage to get the results.
407 $0 --what=... --step=upload
409 to upload the results to our local corrections store.
416 $0 --what=... --step=draw
418 to get a PDF of the diagnostics histograms and the final plots.
423 echo "Now waiting for jobs to finish"
424 (cd ${nme}_${now} && \
425 nice aliroot -l -b -x -q Watch.C\(1\) 2>&1 | \
426 tee watch.log > /dev/null &)
430 # --- Collect a directory --------------------------------------------
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"
448 # === Procedual code =================================================