3 # This script runs the Forward QA for the specified production number
5 # The scripts downloads and runs the single run QA in parallel
8 # --- Help output ----------------------------------------------
12 Usage: $0 [OPTIONS] -j [JOBID]
13 $0 [OPTIONS] -p PRODUCTION -P PASS
17 -j,--jobid NUMBER The master job id of the production [$jobid]
18 -v,--verbose Increase verbosity [$verb]
19 -m,--max-files NUMBER Max number of files to get [$maxf]
20 -M,--max-jobs NUMBER Max number of consequtive jobs [$maxjobs]
21 -t,--top DIRECTORY Output directory [$top]
22 -R,--also-results Also get QAresults.root for each run
23 -Q,--qa-number NUMBER Custom QA id [$qanumber]
24 -p,--production IDENTIFIER Production identifier [$prodfull]
25 -P,--pass IDENTIFIER Pass identifier [$passfull]
26 -l,--log-file Log file output [$redir]
27 -b,--barrel NUMBER ? [$barrel]
29 Note the option -j and the options -p and -P are mutually exclusive,
30 The option -Q is only used if the options -p and -P are given.
31 Production identifiers are of the form LHC11h, LHC11h3, or LHC11h_2.
32 Pass identifers are of the form pass2, pass1_HLT, or cpass1.
36 # --- Check AliEn token ----------------------------------------------
40 genv_file=/tmp/gclient_env_${uid}
42 if test ! -f ${genv_file} ; then
43 echo "No such file: ${genv_file}, please do alien-token-init" \
48 alien-token-info | grep -q "Token is still valid"
49 if test $? -ne 0 ; then
50 echo "Token not valid, please re-new" > /dev/stderr
55 # --- Diagnostics output ---------------------------------------------
59 if test $1 -gt $verb ; then return ; fi
64 # --- Handling of exit -----------------------------------------------
68 if test "x$lock" = "x" ; then return ; fi
73 # --- Handling of errors ---------------------------------------------
89 # --- Check the lock -------------------------------------------------
95 if test -f $lock ; then
96 echo "Another QA process is already running:" > /dev/stderr
97 echo "Content of ${lock}:" > /dev/stderr
98 cat $lock > /dev/stderr
110 # --- Parse production information -----------------------------------
113 prodyear=`echo $prodfull | sed 's/LHC\(..\).*/\1/'`
114 prodletter=`echo $prodfull | sed "s/LHC${prodyear}\(.\).*/\1/"`
115 prodpost=`echo $prodfull | sed "s/LHC${prodyear}${prodletter}//"`
120 passno=`echo $passfull | sed 's/.*pass\([0-9]*\).*/\1/'`
121 passpost=`echo $passfull | sed -n "s/.*pass${passno}_//p"`
122 passpre=`echo $passfull | sed -n "s/pass.*//p"`
125 # --- Extract parts from the found path ------------------------------
140 mess 1 "Parsing information from job $@"
143 local lrunn=$1 ; shift
144 local ltype=$1 ; shift
149 mess 10 "prodfull=$prodfull"
150 mess 10 "lrunn=$lrunn"
151 mess 10 "ltype=$ltype"
152 mess 10 "passfull=$passfull"
153 mess 10 "remainder=$remainder"
155 if test "x$passfull" = "x" ; then
161 *) remainder=$passfull
169 xQA*) qanumber=`echo $remainder | sed 's/QA//'` ;;
174 # --- Get the index for information ----------------------------------
176 jobu="http://alimonitor.cern.ch/prod/jobs.jsp?t="
180 mess 1 "Getting the job information"
181 wget -q ${jobu}${jobid} -O job.html
184 p=`grep "/catalogue/index.jsp?path" job.html | head -n $lskip | tail -n 1 | sed -e 's,.*/alice/\(data\|sim\)/\([^<]*\)<.*,\2,' | tr '/' ' '`
189 # --- Append path element --------------------------------------------
194 if test "x$tmp" != "x" ; then tmp="${tmp}/" ; fi
198 # --- Get a list of files to get -------------------------------------
206 mess 3 "Getting file list"
210 if test ${barrel} -gt 0 ; then
213 if test ${barrel} -gt 1 ; then
214 file=trending_barrel.root
215 other=QAresults_barrel.root
220 *) mess 3 "Assuming simulation output"
227 if test "x$passfull" != "x" && test $passno -gt 0 ; then
230 local post=${passpost}
234 *) post="_${post}" ;;
237 path=/alice/${datd}/${year}/${prodfull}/
238 local search="${esdd}${passpre}${paid}${post}"
240 if test $qanumber -gt 0 ; then
241 qapost=`printf "QA%02d" $qanumber`
242 search=`append_to_path "$search" $qapost`
245 search=`append_to_path "$search" $file`
251 mess 1 "Getting list of files from AliEn - can take minutes - be patient"
252 mess 2 "alien_find ${path} ${search}"
253 files=`alien_find ${path} ${search} | grep -v "files found" 2>> ${redir}`
257 mess 1 -n "Total of $numf files ... "
258 if test $maxf -lt 0 ; then
261 mess 1 "using $maxf first of these"
265 # --- Change permissions on files ------------------------------------
268 if test ! -f $1 ; then return ; fi
273 # --- Check if a file is OK ------------------------------------------
277 if test $docheck -lt 1 ; then return 0; fi
278 root -l -b <<EOF >> ${redir} 2>&1
279 .L $ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/CheckQAFile.C
284 mess 2 "Check of $1 -> $ret"
289 # --- Analyse a file -------------------------------------------------
292 local dir=`dirname $1`
293 local inp=`basename $1`
294 local out=`echo $inp | sed 's/trending_/tree_/'`
296 mess 2 -n "Analysing $inp -> $out ... "
298 if test -f $dir/$out ; then
304 root -l -b <<EOF > /dev/stderr
305 .L $ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/RunFileQA.C
306 RunFileQA("$inp", "$out");
316 # --- Download a single file -----------------------------------------
320 local source=$1 ; shift
321 local store=$1 ; shift
323 local o=${store}/`basename $file .root`_${r}.root
325 mess 2 -n "$source -> $o ... "
330 mess 2 -n "copying ... "
331 alien_cp alien:${source} file:${o} >> ${redir} 2>&1
335 if test ! -f $o ; then return 1 ; fi
337 if test $also_results -gt 0 ; then
338 local s=`dirname ${source}`/${other}
339 local q=${store}/`basename $other .root`_${r}.root
341 mess 2 -n "$s -> $q ... "
345 mess 2 -n "copying ... "
346 alien_cp alien:${s} file:${q} >> ${redir} 2>&1
357 1|3|4|5|6) return 2 ;;
365 # --- Submit run analysis to background ------------------------------
374 mess 5 "Submitting $maxjobs jobs from $sta/$maxf"
376 let cur=$sta+$counter
378 local b=`echo $i | sed -e "s,${path},,"`
379 local r=`echo $b | sed -e "s,/.*,,"`
381 printf "%3d/%3d: %s\n" $cur $max $r
384 let counter=$counter+1
386 analyse_run $i $out $r &
387 j=`jobs %% | sed -e 's/^[^0-9]*//' -e 's/[^0-9]*$//'`
388 joblist="$joblist $j"
392 mess 5 "will wait for jobs $joblist"
393 for i in $joblist ; do
394 mess 5 "waiting for $i of $joblist"
396 mess 5 "Analysing ${runs[$counter]} returned $?"
397 let counter=$counter+1
401 # --- Analyse each run in turn ---------------------------------------
402 maxjobs=`grep "processor" /proc/cpuinfo | wc -l`
412 while test $# -gt 0 ; do
413 if test $counter -ge $max ; then
420 let counter=$counter+1
422 if test $queued -eq 1 ; then
426 if test $queued -ge $maxjobs ; then
427 mess 1 "Submitting $queued jobs from $start/$max"
428 submit_runs $out $start $max $list
433 if test $queued -gt 0 ; then
434 mess 1 "Submitting $queued jobs from $start/$max"
435 submit_runs $out $start $max $list
439 # --- Copy style -----------------------------------------------------
442 if test ! -f $style ; then return ; fi
448 # --- Run the final trending -----------------------------------------
453 mess 1 -n "Analysing $dir ... "
459 root -l -b <<EOF > /dev/stderr
460 .L $ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/RunFinalQA.C
465 mess 3 -n "root -l -b -q ${scr}.C "
466 root -l -b -q ${scr}.C > /dev/null 2>&1
472 local idx=`ls trend_*_*.html 2> /dev/null`
474 mess 1 "Making index.html point to $i"
475 sed -e 's,index.html,../index.html,' \
476 -e "s,!--JOBID--,a target='_blank' href='${jobu}${jobid}'>Job</a," \
481 if test ! -f index.html ; then
482 echo "No index file found"
486 fix_perm . > /dev/null 2>&1
494 # --- Make index file ------------------------------------------------
498 local title=$1 ; shift
499 local desc=$1 ; shift
500 mess 1 "Making index in $dir ($title)"
507 cat <<EOF > index.html
510 <title>$title</title>
511 <link rel='stylesheet' href='style.css'>
516 if test ! "x$desc" = "x" ; then
517 echo "$desc" >> index.html
519 echo " <ul>" >> index.html
521 if test ! -d $i ; then continue ; fi
522 echo " <li><a href='$i'>$i</a></li>" >> index.html
524 echo " </ul>" >> index.html
525 if test "x$desc" = "x" ; then
526 echo " <div class='back'><a href='../'>Back</a></div>" \
529 cat <<EOF >> index.html
530 <div class='change'>Last update: $date</div>
536 fix_perm . > /dev/null 2>&1
541 # --- Pass command line options --------------------------------------
545 while test $# -gt 0 ; do
547 -h|--help) usage ; exit 0 ;;
548 -v|--verbose) let verb=$verb+1 ;;
549 -j|--jobid) jobid=$2 ; shift ;;
550 -m|--max-files) maxf=$2 ; shift ;;
551 -M|--max-jobs) maxjobs=$2 ; shift ;;
552 -t|--top) top=$2 ; shift ;;
553 -R|--also-results) also_results=1 ;;
554 -Q|--qa-number) qanumber=$2 ; shift ;;
566 -l|--log-file) redir= ; shift ;;
567 -b|--barrel) barrel=$2; shift ;;
569 *) echo "$0: Unknown argument: $1" > /dev/stderr ; exit 1 ;;
573 # --- Initial setup --------------------------------------------------
574 # First, check we have a valid AliEn token, then retrieve the job
575 # information to parse out the location of the files we need, and
576 # finally make our output directory and check the lock
579 if test ! "x$jobid" = x ; then
580 if test ! "x$prodfull" = "x" || test ! "x$passfull" = "x" ; then
581 cat <<EOF > /dev/stderr
582 Option -j ${jobid} and options -p and -P are mutually exclusive
588 if test "x$prodfull" = "x" || test "x$passfull" = "x" ; then
589 cat<<EOF > /dev/stderr
590 When specifying prodcution and/or pass both options -p and -P _must_
594 elif test ! "x$jobid" = "x" ; then
595 cat <<EOF > /dev/stderr
596 Option -j and options -p ${prodfull} and -P ${passfull} are mutually exclusive
602 proddir=LHC${prodyear}${prodletter}
604 if test ! "x$passno" = "x" ; then
605 store=${store}/pass${passno}
606 elif test ! "x$prodpost" = "x" ; then
607 proddir=${proddir}${prodpost}
610 if test ! "x$qanumber" = "x" && test $qanumber -gt 0 ; then
611 store=${store}_QA${qanumber}
613 mkdir -p ${top}/$store
614 fix_perm ${top}/${proddir}
615 fix_perm ${top}/$store
617 if test "x$redir" = "x" ; then
618 redir=${top}/$store/qa.log
623 check_lock ${top}/$store
627 Production: $prodfull
637 Output directory: ${store}
641 # --- Do a search to find our files ----------------------------------
644 if test $maxf -gt 0 && test $maxf -lt $numf ; then
648 # --- Now get and analyse each run -----------------------------------
649 analyse_runs ${top}/$store $numf $files
651 # --- Now analyse all runs -------------------------------------------
652 style=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/style.css
653 make_trend ${top}/$store
655 # --- Make index files -----------------------------------------------
656 make_index ${top}/${proddir} ${proddir}
657 make_index ${top} "QA for the FMD" \
658 "For more information see <a href='https://twiki.cern.ch/twiki/bin/viewauth/ALICE/FMDQA'>TWiki pages</a>."