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
173 # --- Draw -----------------------------------------------------------
177 # local args=$1 ; shift
180 if test "X$i" = "X*.zip" ; then continue ; fi
181 echo "Will extract $i"
183 if test ! -d $d ; then
187 (cd $d && _draw $scr $@)
194 if test "X$i" = "X*.zip" ; then continue ; fi
195 echo "Will extract $i"
197 if test ! -d $d ; then
201 _dndeta_draw $d ../Draw.C $@
205 # === Script specific functions ======================================
206 # --- Extract corrections --------------------------------------------
209 if test -f .download ; then
210 echo "Already downloaded in `basename $PWD`"
217 # --- Get the grid home dir ------------------------------------------
220 l=`aliroot -l -b <<EOF
221 gSystem->RedirectOutput("/dev/null");
222 TGrid::Connect("alien://");
223 gSystem->RedirectOutput(0);
224 std::cout << gGrid->GetHomeDirectory() << std::endl;
226 my_real_dir="$l/${name}_aod_${now}/output"
227 my_mc_dir="$l/${name}_mcaod_${now}/output"
233 local r=`grep -v ^# $runs | awk '{FS=" \n\t"}{printf "%d\n", $1}' | head -n 1`
234 if test x$r = "x" || test $r -lt 1; then
235 echo "No run for acceptance correction specified" > /dev/stderr
241 # --- Dump the setup -------------------------------------------------
255 my_real_dir=${my_real_dir}
256 my_mc_dir=${my_mc_dir}
263 # --- Run set-ups ----------------------------------------------------
270 # --- Check settings -------------------------------------------------
275 if test "x$runs" = "x" || test ! -f $runs ; then
276 echo "List of run file $runs not found" > /dev/stderr
279 if test "x$mcruns" = "x" ; then mcruns=$runs ; fi
280 if test ! -f $mcruns ; then
281 echo "List of MC runs file $mcruns not found" > /dev/stderr
284 if test "x$real_dir" = "x" ; then
285 echo "No real data directory specified" > /dev/stderr
288 if test "x$mc_dir" = "x" ; then
289 echo "No MC data directory specified" > /dev/stderr
292 if test "x$real_pat" = "x" ; then
293 echo "No real data pattern specified" > /dev/stderr
296 if test "x$mc_pat" = "x" ; then
297 echo "No MC data pattern specified" > /dev/stderr
303 # --- Show the setup -------------------------------------------------
309 Directory: ${real_dir}
311 Output: ${my_real_dir}
317 Use PAR files: ${par}
323 # --- Make URI -------------------------------------------------------
328 local type=$1 ; shift
329 local trig=$1 ; shift
331 local uopt="&merge=50&split=50&aliroot=last,regular"
338 if test $mc -gt 0 ; then
345 uopt="${uopt}&concat"
347 # Modify for input dir for our files
350 if test $mc -gt 0 ; then
355 if test $mc -gt 0; then
358 if test $par -gt 0 ; then
361 if test x$uuopts != x ; then
362 uopt="${uopt}&${uuopts}"
364 url="alien://${dir}?run=${rl}&pattern=${pat}${uopt}#${tree}"
368 # --- Run the train --------------------------------------------------
373 local type=$1 ; shift
374 local trig=$1 ; shift
376 _allAboard "$type" "$trig" $@
378 if test $watch -lt 1 ; then
380 Check https://alimonitor.cern.ch/users/jobs.jsp for progress
384 $0 --what=... --step=terminate
386 until the final merge stage to get the results.
394 $0 --what=... --step=upload
396 to upload the results to our local corrections store.
403 $0 --what=... --step=draw
405 to get a PDF of the diagnostics histograms and the final plots.
410 echo "Now waiting for jobs to finish"
411 (cd ${nme}_${now} && \
412 nice aliroot -l -b -x -q Watch.C\(1\) 2>&1 | \
413 tee watch.log > /dev/null &)
417 # --- Collect a directory --------------------------------------------
427 for ad in $dir/root_archive_* ; do
428 if test ! -d $ad ; then continue ; fi
429 local r=`basename $ad | sed 's/root_archive_0*//'`
430 _collect_files "$ad" "$d" "$M" "$out" "$r" "$files"
435 # === Procedual code =================================================