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
98 # === Various functions ==============================================
101 # === Implement base functions =======================================
102 # --- Usage ----------------------------------------------------------
106 -r,--run=NUMBER Specify run number ($run)
107 -d,--real-ds=NAME Data set of real data ($real_ds)
108 -D,--mc-ds=NAME Data set of MC data ($mc_dir)
109 -P,--server=ADDRESS Proof server ($serv)
110 -W,--workers=N Number of workers ($nwrks)
111 -a,--par Use par files ($par)
112 -b,--batch Do not show GUI
115 # --- handle setup options -------------------------------------------
116 handle_setup_option()
120 # echo "Handle arg=$arg opt=$opt"
122 -r|--run) run=$opt ;;
123 -d|--real-ds) real_ds=$opt ;;
124 -D|--mc-ds) mc_ds=$opt ;;
125 -W|--workers) nwrks=${opt} ;;
126 -P|--server) serv=${opt} ;;
128 *) echo "$0: [SETUP] Unknown option $arg" ; exit 1 ;;
132 # --- Get the grid home dir ------------------------------------------
135 # We should get the PROOF group and user name here
136 # l=`id -n -g`/`id -n -u`
137 l=`aliroot -l -b <<EOF
138 gSystem->RedirectOutput("/dev/null");
139 TProof::Reset("$serv", false);
140 TProof::Open("$serv");
141 gSystem->RedirectOutput(0);
142 Printf("%s/%s", gProof->GetGroup(), gProof->GetUser());
144 my_real_ds="/$l/${name}_aod_${now}"
145 my_mc_ds="/$l/${name}_mcaod_${now}"
147 # --- Dump the setup -------------------------------------------------
158 my_real_ds=${my_real_ds}
167 # ---- Get run number to use for Acceptance map ----------------------
170 if test x$run = "x" || test $run -lt 1; then
171 echo "No run for acceptance correction specified" > /dev/stderr
176 # --- Run set-ups ----------------------------------------------------
179 echo "Calling _setup with $@"
183 # --- Check settings -------------------------------------------------
186 if test "x$run" = "x" || test $run -lt 1 ; then
187 echo "Run not specified, or invalid ($run)" > /dev/stderr
190 if test "x$real_ds" = "x" ; then
191 echo "No real data set specified" > /dev/stderr
194 if test "x$mc_ds" = "x" ; then
195 echo "No MC data set specified" > /dev/stderr
202 # --- Show the setup -------------------------------------------------
209 Output: ${my_real_ds}
213 Use PAR files: ${par}
214 Number of workers: ${nwrks}
219 # --- Make URI -------------------------------------------------------
223 local type=$1 ; shift
224 local trig=$1 ; shift
225 local uopt="mode=default"
229 local oup=`basename ${my_real_ds}`
230 if test $mc -gt 0 ; then
232 oup=`basename ${my_mc_ds}`
237 uopt="${uopt}&dsname=${oup}"
241 # Modify for input dir for our files
243 if test $mc -gt 0 ; then
248 if test x$inp = x; then
249 echo "No input for $nme, giving up" > /dev/stderr
252 if test $mc -gt 0; then
255 if test $par -gt 0 ; then
256 uopt="${uopt}&par=tasks"
258 if test x$uuopts != x ; then
259 uopt="${uopt}&${uuopts}"
261 if test "x$nwrks" != "x" && test $nwrks -gt 0 ; then
262 uopt="${uopt}&workers=${nwrks}"
265 alice-caf.cern.ch) uopts="${uopts}&reset=hard" ;;
268 # PROOF-lite URL form:
270 # lite://<datadir_or_list>[?<options>][#<treeName]
273 # clear=PKGS Clear packages ','-separated
274 # mc Assume simulation input
275 # mode=default|rec|sim AliROOT mode
276 # par=tasks|all Use par files
277 # pattern=GLOB File name pattern
278 # recursive Recursive scan [true]
279 # reset=soft|hard Reset cluster [hard]
280 # workers=N[x] Number of workers to use [8]
281 # wrapper=CMD Wrapper command []
283 url="proof://${serv}/${inp}?${uopt}#${tree}"
287 # --- Run the train --------------------------------------------------
292 local type=$1 ; shift
293 local trig=$1 ; shift
295 if test $batch -gt 0 ; then
298 _allAboard "$type" "$trig" $lopts $@
301 # === Procedual code =================================================