4 # Script to help do PWGLF-Forward analsysis using ProofLite
5 # =========================================================
6 # First, one need to figure out what to analyse. We assume we have
7 # the ESDs from a real run in some directory - possibly in
8 # sub-directories, and similar for the MC data.
10 # Then, one needs to run this script in set-up mode e.g.,
15 # --real-dir=/data/alice/data/pp/lhc10c/000118560/pass3 \
16 # --real-pattern=AliESDs_*.root \
17 # --mc-dir=/data/alice/data/pp/lhc10c/sim/lhc13d4/118560 \
18 # --mc-pattern=root_archive.zip@AliESDs.root
20 # Note, all the settings are written to the file .config in the
21 # current directory, so you do not need to give the parameters at
22 # subsequent steps. Note, you need a valid AliEn token to at this
23 # point to get the acceptance corrections. The run number specified
24 # is only used for getting the acceptance correction.
26 # Note, the use of the ZIP archives root_archive.zip and the sub-part
27 # specification @AliESDs.root for MC data.
29 # Next, we need to generate the corrections. Do
33 # and wait for the jobs to finish and terminate. Next, we need to
34 # extract and upload the corrections to our local corrections folder
36 # $0 --what=corr --step=upload
37 # $0 --what=corr --step=draw
39 # If you already have the corrections, you can pass the option
40 # --corrections in the setup phase and skip this step.
42 # Now we can submit our AOD generation jobs. Do
46 # and wait for the jobs to finish and terminate. If you need to pass
47 # additional options to the train, one can do so after the special
48 # option -- e.g., to limit the number of events to 100000, do
50 # $0 --what=aod -- --events=100000
52 # Next, we need to draw the summary results
54 # $0 --what=aod --step=draw
56 # Now, we should do the dN/deta analysis. Do
60 # and wait for the jobs to finish and terminate. Again, additional
61 # options to the train can be passed after --. If you passed the
62 # option --sys=1 in the setup phase, then this will run 3 jobs for
63 # real and MC each - one for INEL, INEL>0, and NSD (V0-AND). Next, we
64 # need to draw the summary and final plot
66 # $0 --what=dndeta --step=draw
68 # To generate the P(Nch) data, do
71 # $0 --what=multdists --step=draw
73 # To collect all PDFs into a single directory do
79 # Comments, questions, bugs, flames, suggestions, etc. should be sent
80 # to Christian Holm Christensen <cholm@nbi.dk>
83 if test ! -f $ALICE_ROOT/PWGLF/FORWARD/analysis2/baseAnalysis.sh ; then
84 echo "baseAnalysis not found!" > /dev/stderr
87 . $ALICE_ROOT/PWGLF/FORWARD/analysis2/baseAnalysis.sh
100 # === Various functions ==============================================
103 # === Implement base functions =======================================
104 # --- Usage ----------------------------------------------------------
108 -r,--run=NUMBER Specify run number ($run)
109 -d,--real-dir=DIR Directory holding real data ($real_dir)
110 -p,--real-pattern=PATTERN Glob pattern to match when searching ($real_pat)
111 -D,--mc-dir=DIR Directory holding MC data ($mc_dir)
112 -P,--mc-pattern=PATTERN Glob pattern to match when searching ($mc_pat)
113 -W,--workers=N Number of workers ($nwrks)
114 -a,--par Use par files ($par)
117 # --- handle setup options -------------------------------------------
118 handle_setup_option()
123 -r|--run) run=$opt ;;
124 -d|--real-dir) real_dir=$opt ;;
125 -p|--real-pattern) real_pat=$opt ;;
126 -D|--mc-dir) mc_dir=$opt ;;
127 -P|--mc-pattern) mc_pat=$opt ;;
128 -W|--workers) nwrks=${opt} ;;
130 *) echo "$0: [SETUP] Unknown option $arg" ; exit 1 ;;
134 # --- Generic draw ---------------------------------------------------
139 # --- Draw dN/deta ---------------------------------------------------
144 # --- Extract and upload ---------------------------------------------
147 echo "=== Download, extract, and uploade in `basename $PWD` ==="
152 # --- Get the grid home dir ------------------------------------------
156 my_real_dir="$l/${name}_aod_${now}"
157 my_mc_dir="$l/${name}_mcaod_${now}"
158 real_idx="$l/${name}_index_${now}.root"
159 mc_idx="$l/${name}_mcindex_${now}.root"
161 # --- Dump the setup -------------------------------------------------
176 my_real_dir=${my_real_dir}
177 my_mc_dir=${my_mc_dir}
184 if test x$run = "x" || test $run -lt 1; then
185 echo "No run for acceptance correction specified" > /dev/stderr
190 # --- Run set-ups ----------------------------------------------------
193 echo "Calling _setup with $@"
196 # create index - unless there's one in the input directory - then
197 # take that and copy here
198 # [We'd like to link only, but ChainBuilder needs to be updated for that]
199 if test "x$real_dir" != x && test -f ${real_dir}/index.root ; then
201 cp ${real_dir}/index.root ${real_idx}
203 if test ! -f ${real_idx} ; then
204 index ${real_idx} ${real_dir} "${real_pat}" 0
208 # create index - unless there's one in the input directory - then
209 # take that and copy here
210 # [We'd like to link only, but ChainBuilder needs to be updated for that]
211 if test "x$real_dir" != x && test -f ${mc_dir}/index.root ; then
213 cp ${mc_dir}/index.root ${mc_idx}
215 if test ! -f ${mc_idx} ; then
216 index ${mc_idx} ${mc_dir} "${mc_pat}" 0
221 # --- Check settings -------------------------------------------------
224 if test "x$run" = "x" || test $run -lt 1 ; then
225 echo "Run not specified, or invalid ($run)" > /dev/stderr
228 if test "x$real_dir" = "x" ; then
229 echo "No real data directory specified" > /dev/stderr
232 if test "x$mc_dir" = "x" ; then
233 echo "No MC data directory specified" > /dev/stderr
236 if test "x$real_pat" = "x" ; then
237 echo "No real data pattern specified" > /dev/stderr
240 if test "x$mc_pat" = "x" ; then
241 echo "No MC data pattern specified" > /dev/stderr
245 ncpu=`cat /proc/cpuinfo|sed -n 's/^processor[ \t]*: \(.*\)/\1/p'|wc -l`
246 if test "x$nwrks" = "x" || test $nwrks -lt 1 ; then
248 echo "Setting number of workers to $nwrks / $ncpu"
251 # --- Run clean-up ----------------------------------------------------
254 rm -f ${real_idx} ${mc_idx}
259 # === Script specific functions ======================================
260 # --- Create the index -----------------------------------------------
269 if test $m -gt 0 ; then
272 if test "x$d" = "x" ;then
273 echo "No input specified for index for $t data" > /dev/stderr
276 if test ! -d $d && test ! -f $d ;then
277 echo "Specified input ($d) for $t data is not a directory or file " \
281 if test $m -gt 0 ; then
285 .L $ALICE_ROOT/PWGLF/FORWARD/trains/ChainBuilder.C++
286 ChainBuilder::CreateCollection("${o}", "file://${d}?recursive&scan&pattern=${p}${n}#esdTree");
293 # --- Show the setup -------------------------------------------------
299 Directory: ${real_dir}
301 Output: ${my_real_dir}
306 Use PAR files: ${par}
307 Number of workers: ${nwrks}/${ncpu}
311 # --- Make URI -------------------------------------------------------
315 local type=$1 ; shift
316 local trig=$1 ; shift
317 local uopt="mode=default&workers=${nwrks}"
320 local inp=${real_idx}
321 if test $mc -gt 0 ; then
328 # Modify for input dir for our files
329 inp=$my_real_dir/AliAOD.root
330 if test $mc -gt 0 ; then
331 inp=$my_mc_dir/AliAOD.root
335 if test ! -f $inp ; then
336 echo "No input for $nme, giving up" > /dev/stderr
339 if test $mc -gt 0; then
342 if test $par -gt 0 ; then
343 uopt="${uopt}&par=tasks"
345 if test x$uuopts != x ; then
346 uopt="${uopt}&${uuopts}"
348 # PROOF-lite URL form:
350 # lite://<datadir_or_list>[?<options>][#<treeName]
353 # clear=PKGS Clear packages ','-separated
354 # mc Assume simulation input
355 # mode=default|rec|sim AliROOT mode
356 # par=tasks|all Use par files
357 # pattern=GLOB File name pattern
358 # recursive Recursive scan [true]
359 # reset=soft|hard Reset cluster [hard]
360 # workers=N[x] Number of workers to use [8]
361 # wrapper=CMD Wrapper command []
363 url="lite://${inp}?${uopt}#${tree}"
368 # === Procedual code =================================================