5 # First, one need to figure out what to analyse. Visit the MonAlisa
8 # * The list of runs and put that in a file - say runs.list
9 # * The directory where the ESD files are stored
10 # - and the pattern that will match these for all runs
11 # * The directory where the MC ESD files are stored
12 # - and the pattern that will match these for all runs
14 # Then, one needs to run this script in set-up mode e.g.,
17 # --name=LHC10h --sys=pbpb --snn=2760 --field=5 \
18 # --real-dir=/alice/data/2010/LHC10h \
19 # --real-pattern=ESDs/pass2/*/AliESDs.root \
20 # --mc-dir=/alice/sim/LHC10h11 \
21 # --mc-pattern=*/AliESDs.root \
22 # --runs=LHC10.list --par
24 # Note, all the settings are written to the file .config in the
25 # current directory, so you do not need to give the parameters at
26 # subsequent steps. As an alternative to giving the parameters, one
27 # can create the file by hand.
29 # Next, we need to generate the corrections. Do
33 # and then monitor output on MonAlisa. When enough has finished, execute
35 # $0 --what=corrs --step=terminate
37 # enough times to get the final merged result. Next, we need to
38 # extract and upload the corrections to our local corrections folder
40 # $0 --what=corrs --step=upload
42 # Now we can submit our AOD generation jobs. Do
46 # and then monitor output on MonAlisa. When enough has finished, execute
48 # $0 --what=aods --step=terminate
50 # enough times to get the final merged result. Next, we need to
51 # download the results and we draw the summary results
53 # $0 --what aods --step=draw
55 # Now, we should do the dN/deta analysis. Do
59 # and then monitor output on MonAlisa. When enough has finished, execute
61 # $0 --what=dndetas --step=terminate
63 # enough times to get the final merged result. Next, we need to download
64 # the results and we can draw the summary and final plot
66 # $0 --what=dndetas --step=draw
82 aliroot="&aliroot=v5-03-75pATF-AN"
83 # root="root=v5-34-02-1"
84 fwd_dir=$ALICE_ROOT/PWGLF/FORWARD/analysis2
93 # === Various functions ==============================================
94 # --- Usage ----------------------------------------------------------
98 Usage: $0 --what OPERATION [OPTIONS]
101 -r,--runs=FILENAME Specify list of runs file ($runs)
102 -n,--name=STRING Base name of jobs ($name)
103 -S,--sys=SYSTEM Collision system ($sys)
104 -E,--snn=ENERGY Center of mass energy per nuclean pair ($snn)
105 -F,--field=FIELD L3 magnetic field ($field)
106 -d,--real-dir=ALIEN_DIR Directory holding real data ($real_dir)
107 -p,--real-pattern=PATTERN Glob pattern to match when searching ($real_pat)
108 -D,--mc-dir=ALIEN_DIR Directory holding MC data ($mc_dir)
109 -P,--mc-pattern=PATTERN Glob pattern to match when searching ($mc_pat)
110 -s,--step=STEP Run stage ($step)
111 -w,--what=TRAINS What to do
112 -a,--par Use par files ($par)
113 -M,--man Show the manual
114 -N,--noact Show what will be done
118 clean Clean directory
119 setup Do intial setup
120 corrs Generate corrections
122 dndeta Generate dNdeta
124 and must be executed in that order. STEP is one of
126 full Run the analysis
127 terminate Terminate the job (may need iterations)
128 upload Upload corrections (only for TRAINS=corrs)
129 draw Draw (partial) results (not for TRAINS=corrs)
133 # --- Manual ---------------------------------------------------------
137 sed -n -e '/BEGIN_MANUAL/,/END_MANUAL/ p' | \
138 sed -e '/\(BEGIN\|END\)_MANUAL/ d' -e 's/^# //' -e "s,\$0,$0,"
141 # === Utilities to execute scripts ===================================
142 # --- Run script -----------------------------------------------------
146 local args=$1 ; shift
147 echo "Will run aliroot -l -b -q $scr($args)"
148 if test $noact -gt 0 ; then return ; fi
154 # --- Run acceptance generation --------------------------------------
158 script ${fwd_dir}/corrs/ExtractAcceptance.C \
159 "${run},${sys},${snn},${field}"
162 # --- Extract corrections --------------------------------------------
167 # --- Extract corrections --------------------------------------------
170 test -f .download && return 0
174 # --- Extract corrections --------------------------------------------
177 test -f .extract && return 0
181 # --- Upload a file --------------------------------------------------
184 test -f .upload && return 0
185 script Upload.C \"file://${here}/${name}_corrs_${now}\"
188 # --- Extract and upload ---------------------------------------------
191 echo "Download, extract, and uploade in `basename $PWD`"
194 if test ! -f $i ; then continue ; fi
195 echo "Extracting and uploading from $i"
196 if test $noact -gt 0 ; then continue ; fi
201 script ../Extract.C "" "" &&
206 # --- Draw -----------------------------------------------------------
213 if test ! -d $d ; then
217 (cd $d && script $scr)
221 # --- Get the grid home dir ------------------------------------------
224 l=`aliroot -l -b <<EOF
225 gSystem->RedirectOutput("/dev/null");
226 TGrid::Connect("alien://");
227 gSystem->RedirectOutput(0);
228 std::cout << gGrid->GetHomeDirectory() << std::endl;
230 my_real_dir="$l/${name}_aod_${now}/output"
231 my_mc_dir="$l/${name}_mcaod_${now}/output"
234 # === Trains =========================================================
235 # --- Run set-ups ----------------------------------------------------
238 run_for_acc=`cat $runs | awk '{FS=" \n\t"}{printf "%d", $1}' | head -n 1`
239 if test x$run_for_acc = "x" || test $run_for_acc -lt 1; then
240 echo "No run for acceptance correction specified" > /dev/stderr
244 now=`date '+%Y%m%d_%H%M'`
247 # Write settings to a file, which we later can source
248 cat > ${dotconf} <<EOF
258 my_real_dir=${my_real_dir}
259 my_mc_dir=${my_mc_dir}
264 if test $noact -lt 1 ; then
265 mkdir -p ${name}_acc_${now}
267 echo "Make acceptance corrections"
268 (cd ${name}_acc_${now} && \
269 accGen $run_for_acc && \
273 # --- Run set-ups ----------------------------------------------------
278 ${name}_mccorr_${now} \
279 ${name}_mceloss_${now} \
280 ${name}_eloss_${now} \
281 ${name}_mcaod_${now} \
283 ${name}_mcdndeta_${now} \
284 ${name}_dndeta_${now} \
288 # --- Check settings -------------------------------------------------
291 if test "x$runs" = "x" || test ! -f $runs ; then
292 echo "List of run file $runs not found" > /dev/stderr
295 if test "X$name" = X ; then
296 echo "No name specified" > /dev/stderr
299 if test "x$sys" = "x" ; then
300 echo "No collision system specified" > /dev/stderr
303 if test "x$snn" = "x" ; then
304 echo "No center of mass energy specified" > /dev/stderr
307 if test "x$field" = "x" ; then
308 echo "No L3 field setting specified" > /dev/stderr
311 if test "x$real_dir" = "x" ; then
312 echo "No real data directory specified" > /dev/stderr
315 if test "x$mc_dir" = "x" ; then
316 echo "No MC data directory specified" > /dev/stderr
319 if test "x$real_pat" = "x" ; then
320 echo "No real data pattern specified" > /dev/stderr
323 if test "x$mc_pat" = "x" ; then
324 echo "No MC data pattern specified" > /dev/stderr
327 if test "X$1" != "Xsetup" && test x$now = x ; then
328 echo "No date/time specified" > /dev/stderr
333 pbpb|pb-pb|aa|a-a) sys=2 ;;
334 ppb|p-pb|pa|p-a) sys=3 ;;
336 *) echo "$0: Unknown system: $sys" ; exit 1 ;;
342 Collision system: $sys
343 sqrt(s_NN): ${snn}GeV
345 Real input directory: ${real_dir}
346 Real file pattern: ${real_pat}
347 MC input directory: ${mc_dir}
348 MC file pattern: ${mc_pat}
349 Real output: ${my_real_dir}
350 MC output directory: ${my_mc_dir}
351 Use PAR files: ${par}
357 # --- Run the train --------------------------------------------------
377 *corr) cl=MakeMCCorrTrain ; mc=1 ;;
378 *eloss) cl=MakeFMDELossTrain ;;
379 *aod) cl=MakeAODTrain
380 opts="--corr=../${name}_corrs_${now} --sys=${sys} --snn=${snn} --field=${field}"
382 *dndeta) cl=MakedNdetaTrain
387 *) echo "$0: Unknown type of train: $type" > /dev/stderr ; exit 1 ;;
391 if test $mc -gt 0; then
400 if test $mc -gt 0 ; then
408 if test $sys -gt 1 ; then opts="${opts} --cent" ; fi ;;
412 if test $par -gt 0 ; then
415 url="alien://${dir}?run=${runs}&pattern=${pat}${uopt}${aliroot}${root}#${tree}"
416 opts="${opts} --include=$ALICE_ROOT/PWGLF/FORWARD/analysis2/trains"
417 opts="${opts} --date=${now} --class=$cl --name=$nme"
419 echo "Running train: runTrain2 ${opts} --url=${url} $@"
420 if test $noact -gt 0 ; then return ; fi
422 runTrain ${opts} --overwrite --url=${url} $@
425 Check https://alimonitor.cern.ch/users/jobs.jsp for progress
429 (cd ${nme}_${now} && aliroot -l -b -q Terminate.C)
431 until the final merge stage, and then do
433 (cd ${nme}_${now} && aliroot -l -b -q Download.C)
442 (cd ${nme}_${now} && aliroot -l -b -q Extract.C)
443 (cd ${nme}_${now} && aliroot -l -b -q 'Upload.C("local://${here}/${name}_corrs_${now}")')
445 to upload the results to our local corrections store.
452 (cd ${nme}_${now} && aliroot -l ${fwd_dir}/DrawAODSummary.C)
454 to get a PDF of the diagnostics histograms
461 (cd ${nme}_${now} && aliroot -l ${fwd_dir}/DrawdNdetaSummary.C)
463 to get a PDF of the diagnostics histograms, and
465 (cd ${nme}_${now} && aliroot -l Draw.C)
467 to get the final plot.
474 # === Wrappers =======================================================
475 # --- Run all correction jobs ----------------------------------------
484 (cd ${name}_mccorr_${now} && terminate)
485 (cd ${name}_mceloss_${now} && terminate)
486 (cd ${name}_eloss_${now} && terminate)
490 (cd ${name}_mccorr_${now} && extract_upload)
491 (cd ${name}_mceloss_${now} && extract_upload)
492 (cd ${name}_eloss_${now} && extract_upload)
496 echo "Draw does not make sense for Correction jobs"
498 # --- Run all AOD jobs -----------------------------------------------
506 (cd ${name}_mcaod_${now} && terminate)
507 (cd ${name}_aod_${now} && terminate)
511 echo "Upload does not make sense for AOD jobs"
515 (cd ${name}_mcaod_${now} && draw ${fwd_dir}/DrawAODSummary.C)
516 (cd ${name}_aod_${now} && draw ${fwd_dir}/DrawAODSummary.C)
519 # --- Run all dN/deta jobs -------------------------------------------
522 allAboard mcdndeta $@
527 (cd ${name}_mcdndeta_${now} && terminate)
528 (cd ${name}_dndeta_${now} && terminate)
532 echo "Upload does not make sense for dN/deta jobs"
536 (cd ${name}_mcdndeta_${now} && draw ${fwd_dir}/DrawdNdetaSummary.C && \
538 (cd ${name}_dndeta_${now} && draw ${fwd_dir}/DrawdNdetaSummary.C && \
542 # === Executable code
543 # --- Source settings if found ---------------------------------------
544 if test -f $dotconf ; then
549 # --- Process command line -------------------------------------------
552 while test $# -gt 0 ; do
558 arg=`echo $1 | sed 's/=.*//'` ;
559 opt=`echo $1 | sed 's/--[^=][^=]*=//'`
564 -*) opt=$2 ; shift ;;
569 -r|--runs) runs=$opt ;;
570 -n|--name) name=$opt ;;
571 -S|--sys) sys=`echo $opt | tr '[A-Z]' '[a-z]'` ;;
572 -E|--snn) snn=$opt ;;
573 -F|--field) field=$opt ;;
574 -d|--real-dir) real_dir=$opt ;;
575 -p|--real-pattern) real_pat=$opt ;;
576 -D|--mc-dir) mc_dir=$opt ;;
577 -P|--mc-pattern) mc_pat=$opt ;;
578 -w|--what) what=`echo $opt | tr '[A-Z]' '[a-z]'` ;;
579 -s|--step) step=`echo $opt | tr '[A-Z]' '[a-z]'` ;;
580 -N|--noact) noact=1 ;;
582 -h|--help) usage ; exit 0 ;;
583 -H|--manual) manual ; exit 0 ;;
584 *) echo "$0: Unknown option $arg" ; exit 1 ;;
588 # --- Check settings -------------------------------------------------
591 # --- Select what to do ----------------------------------------------
594 setup) setup ; exit 0 ;;
595 clean) cleanup ; exit 0 ;;
598 dndeta*) func=dndetas ;;
599 *) echo "$0: Unknown operation: $what" > /dev/stderr ; exit 1 ;;
604 xterm*) func=${func}_terminate ;;
605 xup*) func=${func}_upload ;;
606 xdr*) func=${func}_draw ;;
607 *) echo "$0: Unknown step $step" > /dev/stderr ; exit 1 ;;
610 echo "Will execute $func"