10 aliroot="v5-04-Rev-20"
16 # --- Display help message -------------------------------------------
24 -t|--tag TAG Job tag [****] ($tag)
25 -i|--id NAME Name of production ($id)
26 -R|--run RUN_NO Run number ($run)
27 -c|--copy Copy files to AliEn
28 -n|--jobs JOBS Set number of jobs[**] ($jobs)
29 -m|--events EVENTS Set events/job[**] ($events)
30 -s|--stage STAGE Set the stage[***] ($stage)
31 -o|--output DIR Set base output directory ($aout)
32 -d|--data DIR Set data directory ($adir)
33 -b|--bin DIR Set base bin directory ($abin)
34 -a|--aliroot RELEASE Set AliROOT release [*] ($aliroot)
35 -r|--root RELEASE Set ROOT release [*] ($root)
36 -g|--geant RELEASE Set GEANT3 release [*] ($geant)
37 -f|--final NUMBER Run final merging when down to this ($minmerge)
39 [*] Only make sense with option -c
40 [**] Only make sense for stage 0
41 [***] If stage is set to 6, try to deduce the stage automatically
42 [****] TAG is a short hand for specific id and run
46 # --- Process a return value -----------------------------------------
50 echo -en "$@\e[0m ... "
51 if test "x$log" != "x" ; then
55 # --- Make error -----------------------------------------------------
60 echo -e "\e[31;1mError\e[0m: ${pre} \e[35m${post}\e[0m" > /dev/stderr
63 # --- Process a return value -----------------------------------------
71 if test $ret -eq 0 ; then
78 echo -e "\e[${fmt}m${msg}${ext}\e[0m"
79 if test "x$log" != "x" ; then
80 echo "=== $msg$ext" >> $log
84 # --- Copy a file to AliEn -------------------------------------------
90 local base=`basename $file`
92 if test "x$del" != "x" ; then
93 log_msg cp.log "Removing \e[33malien:${dest}/${base}"
94 if test $noact -lt 1 ; then
95 alien_rm ${dest}/${base} >> cp.log 2>&1
97 log_end cp.log $? " (ignore errors)"
100 log_msg cp.log "Uploading \e[33m${file}\e[0m to \e[33m${dest}"
101 if test $noact -lt 1 ; then
102 alien_cp -n file:${file} alien:${dest}/${base} >> cp.log 2>&1
107 # --- Run merging jpb ------------------------------------------------
116 local tmpdir=`mktemp -d`
118 if test "x$what" = "xAOD" ; then
122 local top=${out}/${tag}/${run}
123 local bse=${what}_Stage_${stage}.xml
124 local xml=${tmpdir}/${bse}
125 local arc=${pre}_archive.zip
131 log_msg cp.log "Creating XML file \e[33m${xml}"
132 if test $stage -eq 1 ; then
134 alien_find -x ${top}/${bse} ${top} */${arc} > ${xml} 2>>cp.log
139 alien_find -x ${top}/${bse} ${top}/${what}_Stage_${prev} */${arc} \
144 if test $ret -ne 0 ; then
145 log_err "Make XML", "Failed to make XML collection $bse"
148 local n=`grep "<event name" ${xml} | wc -l 2>/dev/null`
149 if test $n -lt $minmerge ; then
153 bse=${what}_Stage_${stage}.xml
155 sed "s,$old,$bse," < $xml > $tmp
158 echo -e "\e[33m$n\e[0m input files for \e[32m${what} stage ${stage}\e[0m"
160 copy ${xml} ${top} del
162 log_msg "" "Submitting merging job \e[33m${jdl}"
163 if test $noact -lt 1 ; then
164 alien_submit alien:${dir}/${jdl} ${run} ${stage} ${tag} ${what}
169 # --- Determine the next stage ---------------------------------------
174 log_msg "" "Deduce next stage for \e[33m$out"
175 # First, check for final merge result
176 # echo -e "\nCheck of ${out}/QA_merge_archive.zip"
177 alien_ls ${out}/QA_merge_archive.zip > /dev/null 2>&1
178 if test $? -eq 0 ; then
181 # Then check for production data
182 # echo -e "\nCheck of ${out}/001"
183 alien_ls ${out}/001 > /dev/null 2>&1
186 if test $ret -ne 0 ; then
187 # echo "No output, stage 0 to be done"
190 # Finally, check each merge stage
194 # echo -e "\nCheck of ${out}/QA_Stage_${i}"
195 alien_ls ${out}/QA_Stage_${i} > /dev/null 2>&1
196 if test $? -ne 0 ; then
205 log_msg "" "\e[34;m$stage"
208 # --- Upload files ---------------------------------------------------
214 local tmpdir=`mktemp -d`
218 jdls="Run.jdl Merge.jdl Final.jdl"
220 log_msg "" "Creating \e[33m${i}"
221 sed -e "s|@out@|${out}|" \
222 -e "s|@data@|${data}|" \
223 -e "s|@bin@|${bin}|" \
224 -e "s|@aliroot@|${aliroot}|" \
225 -e "s|@root@|${root}|" \
226 -e "s|@geant@|${geant}|" \
227 < ${i}.in > ${tmpdir}/${i}
231 log_msg cp.log "Removing and re-creating \e[33m${data}"
232 if test $noact -lt 1 ; then
233 alien_rmdir ${data} >> cp.log 2>&1
234 alien_mkdir -p $data >> cp.log 2>&1
239 if test "X$bin" = "X$data" ; then del=0 ; fi
240 copy run.sh $bin $del
241 copy merge.sh $bin $del
260 ${tmpdir}/Merge.jdl \
261 ${tmpdir}/Final.jdl \
262 fmd_corrections.root"
269 # --- Get package versions -------------------------------------------
276 log_msg "" "Checking software packages"
277 if test "x$ali" = "x" ; then
279 log_err "Check versions" "No AliROOT Release specified"
282 if test "x$roo" != "x" && test "x$gean" = "x" ; then
283 log_msg "" "\e[33mAliROOT=$ali ROOT=$roo GEANT=$gean"
288 l=`wget -q http://alimonitor.cern.ch/packages/ -O - | \
289 sed -n -e '/<tr/,/<\/tr>/ p' | \
290 sed -n "/<a.*VO_ALICE@AliRoot::${aliroot}/,/VO_ALICE@ROOT::/ p" | \
291 sed -n -e 's/.*VO_ALICE@\(GEAN\|ROO\)T3*::\(v[-0-9a-zA-Z]*\).*/\L\1=\2/gp'|\
294 if test "X$roo" = "X" || test "X$gean" = "X" ; then
296 log_err "Check versions", "Failed to extract ROOT/GEANT3 versions"
301 log_msg "" "\e[33mAliROOT=$ali ROOT=$root GEANT=$geant"
305 # --- Create an arcive for upload ------------------------------------
308 log_msg "" "Creating archive of files"
309 local name=sim_files${version}
328 fmd_corrections.root"
333 tar -czf ${name}.tar.gz ${name}
339 # --- Set some variables ---------------------------------------------
340 auid=`alien_whoami | sed 's/^ *//'`
341 ahome=/alice/cern.ch/user/`echo $auid | sed 's/^\(.\).*/\1/'`/$auid
347 # --- Proces command line options ------------------------------------
348 while test $# -gt 0 ; do
350 -h|--help) usage; exit 0;;
351 -t|--tag) tag=$2 ; shift ;;
352 -i|--id) id=$2 ; shift ;;
353 -R|--run) run=$2 ; shift ;;
354 -c|--copy) upload=1 ;;
355 -n|--jobs) jobs=$2 ; shift ;;
356 -m|--events) events=$2 ; shift ;;
357 -s|--stage) stage=$2 ; shift ;;
358 -S|--stages) stages=$2 ; shift ;;
359 -b|--bin) abin=$2 ; shift ;;
360 -o|--output) aout=$2 ; shift ;;
361 -d|--data) adir=$2 ; shift ;;
362 -a|--aliroot) aliroot=$2 ; shift ;;
363 -r|--root) root=$2 ; shift ;;
364 -g|--geant) geant=$2 ; shift ;;
365 -f|--final) minmerge=$2 ; shift ;;
366 -A|--archive) archive ; exit 0 ;;
367 -x|--dry-run) noact=1 ;;
369 *) log_err "Unknown option" "$1" ; exit 1 ;;
377 # --- May upload only ------------------------------------------------
378 if test $upload -gt 0 ; then
379 getVersions "$aliroot" "$root" "$geant"
380 push ${abin} ${adir} ${aout}
381 if test $stage -lt 0 ; then
386 # --- Inspect options ------------------------------------------------
388 pp) id=$tag ; run=118506 ;;
389 PbPb) id=$tag ; run=138190 ;;
390 pPb) id=$tag ; run=195483 ;;
391 Pbp) id=$tag ; run=196433 ;;
393 if test "x$id" = "x" ; then
394 log_err "" "No job identifier given"
398 if test "x$run" = "x" ; then
399 log_err "" "No run number given"
405 6) progress $aout/$id/$run ;;
406 *) log_err "Invalid stage" "$stage" ; exit 1 ;;
408 if test $stage -ge 6 ; then
409 log_msg "" "All done"
414 # --- Either run the job or merge ------------------------------------
415 if test $stage -le 0 ; then
416 log_msg "" "Removing old ${aout}/${id}/${run}"
418 if test $noact -lt 1 ; then
419 alien_rmdir ${aout}/${id}/${run} > /dev/null 2>&1
424 log_msg "" "Submitting \e[33mRun.jdl\e[0m for \e[34m$id run\e[0m (\e[34m$jobs\e[0m jobs w/\e[34m$events)"
425 if test $noact -lt 1 ; then
426 echo "alien_submit alien:${adir}/Run.jdl ${run} ${jobs} ${events} ${id} $@"
427 alien_submit alien:${adir}/Run.jdl ${run} ${jobs} ${events} ${id} "$@"
434 for s in $stages ; do
435 merge ${s} ${stage} ${adir} ${aout} ${id} ${run}