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 -----------------------------------------------------------
215 (cd $d && script $scr)
219 # --- Get the grid home dir ------------------------------------------
222 l=`aliroot -l -b <<EOF
223 gSystem->RedirectOutput("/dev/null");
224 TGrid::Connect("alien://");
225 gSystem->RedirectOutput(0);
226 std::cout << gGrid->GetHomeDirectory() << std::endl;
228 my_real_dir="$l/${name}_${now}_aod/output"
229 my_mc_dir="$l/${name}_${now}_mcaod/output"
232 # === Trains =========================================================
233 # --- Run set-ups ----------------------------------------------------
236 run_for_acc=`cat $runs | awk '{FS=" \n\t"}{printf "%d", $1}' | head -n 1`
237 if test x$run_for_acc = "x" || test $run_for_acc -lt 1; then
238 echo "No run for acceptance correction specified" > /dev/stderr
242 now=`date '+%Y%m%d_%H%M'`
245 # Write settings to a file, which we later can source
246 cat > ${dotconf} <<EOF
256 my_real_dir=${my_real_dir}
257 my_mc_dir=${my_mc_dir}
262 if test $noact -lt 1 ; then
263 mkdir -p ${name}_acc_${now}
265 echo "Make acceptance corrections"
266 (cd ${name}_acc_${now} && \
267 accGen $run_for_acc && \
271 # --- Run set-ups ----------------------------------------------------
276 ${name}_mccorr_${now} \
277 ${name}_mceloss_${now} \
278 ${name}_eloss_${now} \
279 ${name}_mcaod_${now} \
281 ${name}_mcdndeta_${now} \
282 ${name}_dndeta_${now} \
286 # --- 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$name" = X ; then
294 echo "No name specified" > /dev/stderr
297 if test "x$sys" = "x" ; then
298 echo "No collision system specified" > /dev/stderr
301 if test "x$snn" = "x" ; then
302 echo "No center of mass energy specified" > /dev/stderr
305 if test "x$field" = "x" ; then
306 echo "No L3 field setting specified" > /dev/stderr
309 if test "x$real_dir" = "x" ; then
310 echo "No real data directory specified" > /dev/stderr
313 if test "x$mc_dir" = "x" ; then
314 echo "No MC data directory specified" > /dev/stderr
317 if test "x$real_pat" = "x" ; then
318 echo "No real data pattern specified" > /dev/stderr
321 if test "x$mc_pat" = "x" ; then
322 echo "No MC data pattern specified" > /dev/stderr
325 if test "X$1" != "Xsetup" && test x$now = x ; then
326 echo "No date/time specified" > /dev/stderr
331 pbpb|pb-pb|aa|a-a) sys=2 ;;
332 ppb|p-pb|pa|p-a) sys=3 ;;
334 *) echo "$0: Unknown system: $sys" ; exit 1 ;;
340 Collision system: $sys
341 sqrt(s_NN): ${snn}GeV
343 Real input directory: ${real_dir}
344 Real file pattern: ${real_pat}
345 MC input directory: ${mc_dir}
346 MC file pattern: ${mc_pat}
347 Real output: ${my_real_dir}
348 MC output directory: ${my_mc_dir}
349 Use PAR files: ${par}
355 # --- Run the train --------------------------------------------------
375 *corr) cl=MakeMCCorrTrain ; mc=1 ;;
376 *eloss) cl=MakeFMDELossTrain ;;
377 *aod) cl=MakeAODTrain
378 opts="--corr=../${name}_corrs_${now} --sys=${sys} --snn=${snn} --field=${field}"
380 *dndeta) cl=MakedNdetaTrain
385 *) echo "$0: Unknown type of train: $type" > /dev/stderr ; exit 1 ;;
389 if test $mc -gt 0; then
398 if test $mc -gt 0 ; then
406 if test $sys -gt 1 ; then opts="${opts} --cent" ; fi ;;
410 if test $par -gt 0 ; then
413 url="alien://${dir}?run=${runs}&pattern=${pat}${uopt}${aliroot}${root}#${tree}"
414 opts="${opts} --date=${now} --class=$cl --name=$nme"
416 echo "Running train: runTrain2 ${opts} --url=${url} $@"
417 if test $noact -gt 0 ; then return ; fi
419 runTrain2 ${opts} --overwrite --url=${url} $@
422 Check https://alimonitor.cern.ch/users/jobs.jsp for progress
426 (cd ${nme}_${now} && aliroot -l -b -q Terminate.C)
428 until the final merge stage, and then do
430 (cd ${nme}_${now} && aliroot -l -b -q Download.C)
439 (cd ${nme}_${now} && aliroot -l -b -q Extract.C)
440 (cd ${nme}_${now} && aliroot -l -b -q 'Upload.C("local://${here}/${name}_corrs_${now}")')
442 to upload the results to our local corrections store.
449 (cd ${nme}_${now} && aliroot -l ${fwd_dir}/DrawAODSummary.C)
451 to get a PDF of the diagnostics histograms
458 (cd ${nme}_${now} && aliroot -l ${fwd_dir}/DrawdNdetaSummary.C)
460 to get a PDF of the diagnostics histograms, and
462 (cd ${nme}_${now} && aliroot -l draw.C)
464 to get the final plot.
471 # === Wrappers =======================================================
472 # --- Run all correction jobs ----------------------------------------
481 (cd ${name}_mccorr_${now} && terminate)
482 (cd ${name}_mceloss_${now} && terminate)
483 (cd ${name}_eloss_${now} && terminate)
487 (cd ${name}_mccorr_${now} && extract_upload)
488 (cd ${name}_mceloss_${now} && extract_upload)
489 (cd ${name}_eloss_${now} && extract_upload)
493 echo "Draw does not make sense for Correction jobs"
495 # --- Run all AOD jobs -----------------------------------------------
503 (cd ${name}_mcaod_${now} && terminate)
504 (cd ${name}_aod_${now} && terminate)
508 echo "Upload does not make sense for AOD jobs"
512 (cd ${name}_mcaod_${now} && draw ${fwd_dir}/DrawAODSummary.C)
513 (cd ${name}_aod_${now} && draw ${fwd_dir}/DrawAODSummary.C)
516 # --- Run all dN/deta jobs -------------------------------------------
519 allAboard mcdndeta $@
524 (cd ${name}_mcdndeta_${now} && terminate)
525 (cd ${name}_dndeta_${now} && terminate)
529 echo "Upload does not make sense for dN/deta jobs"
533 (cd ${name}_mcdndeta_${now} && draw ${fwd_dir}/DrawdNdetaSummary.C && \
535 (cd ${name}_dndeta_${now} && draw ${fwd_dir}/DrawdNdetaSummary.C && \
539 # === Executable code
540 # --- Source settings if found ---------------------------------------
541 if test -f $dotconf ; then
546 # --- Process command line -------------------------------------------
549 while test $# -gt 0 ; do
555 arg=`echo $1 | sed 's/=.*//'` ;
556 opt=`echo $1 | sed 's/--[^=][^=]*=//'`
561 -*) opt=$2 ; shift ;;
566 -r|--runs) runs=$opt ;;
567 -n|--name) name=$opt ;;
568 -S|--sys) sys=`echo $opt | tr '[A-Z]' '[a-z]'` ;;
569 -E|--snn) snn=$opt ;;
570 -F|--field) field=$opt ;;
571 -d|--real-dir) real_dir=$opt ;;
572 -p|--real-pattern) real_pat=$opt ;;
573 -D|--mc-dir) mc_dir=$opt ;;
574 -P|--mc-pattern) mc_pat=$opt ;;
575 -w|--what) what=`echo $opt | tr '[A-Z]' '[a-z]'` ;;
576 -s|--step) step=`echo $opt | tr '[A-Z]' '[a-z]'` ;;
577 -N|--noact) noact=1 ;;
579 -h|--help) usage ; exit 0 ;;
580 -H|--manual) manual ; exit 0 ;;
581 *) echo "$0: Unknown option $arg" ; exit 1 ;;
585 # --- Check settings -------------------------------------------------
588 # --- Select what to do ----------------------------------------------
591 setup) setup ; exit 0 ;;
592 clean) cleanup ; exit 0 ;;
595 dndeta*) func=dndeta ;;
596 *) echo "$0: Unknown operation: $what" > /dev/stderr ; exit 1 ;;
601 xterm*) func=${func}_terminate ;;
602 xup*) func=${func}_upload ;;
603 xdr*) func=${func}_draw ;;
604 *) echo "$0: Unknown step $step" > /dev/stderr ; exit 1 ;;
607 echo "Will execute $func"