script=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/script.js
topmk=$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/makeIndex.sh
-# --- Help output ----------------------------------------------
-usage()
-{
- cat <<EOF
-Usage: $0 [OPTIONS] -j [JOBID]
- $0 [OPTIONS] -p PRODUCTION -P PASS
-
-Options:
- -h,--help This help
- -j,--jobid NUMBER The master job id of the production [$jobid]
- -v,--verbose Increase verbosity [$verb]
- -m,--max-files NUMBER Max number of files to get [$maxf]
- -M,--max-jobs NUMBER Max number of consequtive jobs [$maxjobs]
- -t,--top DIRECTORY Output directory [$top]
- -R,--also-results Also get QAresults.root for each run
- -Q,--qa-number NUMBER Custom QA id [$qanumber]
- -p,--production IDENTIFIER Production identifier [$prodfull]
- -P,--pass IDENTIFIER Pass identifier [$passfull]
- -l,--log-file Log file output [$redir]
- -b,--barrel MODE Fetch barrel data [$barrel]
- -f,--force Force re-run analysis [$force]
- -V,--variance Errors=variance (not min/max) [$variance]
- -L,--local Local trending_<X>.root files [$from_local]
- -d,--directory DIR Search custom AliEn directory [$path]
-
-Note the option -j and the options -p and -P are mutually exclusive,
-The option -Q is only used if the options -p and -P are given.
-Production identifiers are of the form LHC11h, LHC11h3, or LHC11h_2.
-Pass identifers are of the form pass2, pass1_HLT, or cpass1.
-If barrel mode>0, then do not assume ESD directory.
-If barrel mode>1, then get trending_barrel.root and QAresults_barrel.root
-Option -d is for hand-made QA passes.
-If optiond -d is not specified then official QA passes are assumed.
-EOF
-}
-
# --- Check AliEn token ----------------------------------------------
check_token()
{
# --- Diagnostics output ---------------------------------------------
verb=0
+print() {
+ local col=$1 ; shift
+ local lvl=$1 ; shift
+ local opt=
+ if test $lvl -gt $verb; then return ; fi
+ case $1 in
+ -*) opt=$1 ; shift ;;
+ esac
+ echo -e ${opt} "\e[${col}m$*\e[0m"
+ # echo -e ${opt} "\e[${col}m$*\e[0m"
+}
mess()
{
- if test $1 -gt $verb ; then return ; fi
- shift
- echo $*
+ print 95 $@
+}
+
+err()
+{
+ echo -e "\e[1mError: \e[91m$*\e[0m" > /dev/stderr
+}
+warn()
+{
+ echo -e "\e[1mWarning: \e[93m$*\e[0m" > /dev/stderr
+}
+info()
+{
+ print 96 0 $@
+}
+ok()
+{
+ print 92 0 "OK"
}
# --- Handling of exit -----------------------------------------------
last=
handle_err()
{
- echo "Error: $last"
+ err "$last"
exit 1
}
enable_trap()
lock=$loc/.lock
if test -f $lock ; then
- echo "Another QA process is already running:" > /dev/stderr
- echo "Content of ${lock}:" > /dev/stderr
+ err "Another QA process is already running:"
+ err "Content of ${lock}:"
cat $lock > /dev/stderr
trap - EXIT
- exit 1
+ exit 1
+ fi
local now=`date`
- cat <<EOF > $lock
-Process: $$
-User: $USER
-Start: $now
-EOF
- fi
+ cat <<-EOF > $lock
+ Process: $$
+ User: $USER
+ Start: $now
+ EOF
}
# --- Parse production information -----------------------------------
remainder=
qanumber=0
barrel=0
-get_parts()
-{
- mess 1 "Parsing information from job $@"
- year=$1 ; shift
- prodfull=$1 ; shift
- local lrunn=$1 ; shift
- local ltype=$1 ; shift
- passfull=$1 ; shift
- remainder=$1
-
- mess 10 "year=$year"
- mess 10 "prodfull=$prodfull"
- mess 10 "lrunn=$lrunn"
- mess 10 "ltype=$ltype"
- mess 10 "passfull=$passfull"
- mess 10 "remainder=$remainder"
-
- if test "x$passfull" = "x" ; then
- remainder=
- passfull=$ltype
- fi
- case x$passfull in
- *pass*) ;;
- *) remainder=$passfull
- passfull=
- ;;
- esac
- parse_pass
- parse_prod
-
- case x$remainder in
- xQA*) qanumber=`echo $remainder | sed 's/QA//'` ;;
- *) ;;
- esac
-
-}
-# --- Get the index for information ----------------------------------
-skip=0
-jobu="http://alimonitor.cern.ch/prod/jobs.jsp?t="
-jobid=
-get_job()
-{
- mess 1 "Getting the job information"
- wget -q ${jobu}${jobid} -O job.html
- local lskip
- let lskip=$skip+1
- p=`grep "/catalogue/index.jsp?path" job.html | head -n $lskip | tail -n 1 | sed -e 's,.*/alice/\(data\|sim\)/\([^<]*\)<.*,\2,' | tr '/' ' '`
- rm -f job.html
- get_parts $p
-}
# --- Append path element --------------------------------------------
append_to_path()
from_local=0
type=data
passid=
+mc=0
get_filelist()
{
mess 3 "Getting file list"
file=trending_barrel.root
other=QAresults_barrel.root
fi
- case x$prodpost in
- x_*) ;;
- x) ;;
- *) mess 3 "Assuming simulation output"
- datd=sim
- type=sim
- passfull=passMC
- esdd=
- ;;
- esac
-
+ if test $mc -gt 0 ; then
+ datd=sim
+ type=sim
+ esdd=
+ fi
+
local paid=
if echo "$passno" | grep -q -E '^[0-9]*[.]?[0-9]*$' ; then
if test "x$passfull" != "x" && test $passno -gt 0 ; then
post=
fi
passid=${paid}
+ if test $mc -gt 0 ; then passid="passMC" ; fi
local post=${passpost}
case x$post in
x_*) ;;
EOF
if test $from_local -lt 1 ; then
- mess 1 "Getting list of files from AliEn - can take minutes - be patient"
+ mess 1 "Get list of files from AliEn - can take minutes - be patient"
mess 2 "alien_find ${path} ${search}"
- files=`alien_find ${path} ${search} | grep -v "\(files found\|AND THE\)" 2>> ${redir}`
+ files=`alien_find ${path} ${search} | \
+ grep -v "\(files found\|AND THE\)" 2>> ${redir}`
else
- files=`ls ${top}/${store}/trending_*.root | sed 's,${top}/${store}/,,g'`
+ files=`ls ${top}/${store}/*/input.root | \
+ sed 's,${top}/${store}/,,g'`
fi
for i in $files ; do
let numf=$numf+1
done
mess 1 -n "Total of $numf files ... "
+ ret=$numf
if test $maxf -lt 0 ; then
mess 1 "using all"
else
mess 1 "using $maxf first of these"
+ ret=$maxf
fi
+ return $ret
}
# --- Change permissions on files ------------------------------------
fix_perm()
{
- # if test ! -f $1 ; then return ; fi
- chmod g+rwX $1 >> /dev/null 2>&1
- chmod o+rX $1 >> /dev/null 2>&1
- #
- # chmod g+rwX $1 >> ${redir} 2>&1
- # chmod o+rX $1 >> ${redir} 2>&1
+ local tgt=$1
+ local opt=
+ if test -d $tgt ; then opt="-R" ; fi
+ chmod ${opt} g+rwX $tgt >> /dev/null 2>&1
+ chmod ${opt} o+rX $tgt >> /dev/null 2>&1
}
# --- Check if a file is OK ------------------------------------------
fi
- mess 1 "Running runQA.sh '$inp' '$type' '$prodyear' '$prodfull' '$passid' '$r' in '$dir'"
+ mess 3 "runQA.sh '$inp' '$type' '$prodyear' '$prodfull' '$passid' '$r'"
(cd $dir
+ for i in QABase QAPlotter QARing QAStructs QATrender ; do
+ ln -s ../${i}* .
+ done
$ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/runQA.sh \
- "$inp" "$type" $prodyear "$prodfull" "$passid" "$r"
- ret=$?
- mess 2 " -> $ret")
-# (cd $dir
-# root -l -b <<EOF
-# .L RunFileQA.C
-# RunFileQA("$inp", "$out", $prodyear, "$prodletter");
-# .q
-# EOF
-# ret=$?
-# mess 2 " -> $ret"
-# # rm -f ${scr}.C
-# ) 2>> $redir
-
+ "$inp" "$type" $prodyear "$prodfull" "$passid" "$r" > runQA.log 2>&1
+ ret=$? )
+ if test ! -f $dir/trending.root ; then ret=1 ; fi
+ mess 2 " -> $ret"
+ if test $ret -ne 0 ; then
+ err "Failed to analyse $1"
+ fi
return $ret
}
local b=`echo $i | sed -e "s,${path},,"`
r=`echo $b | sed -e "s,/.*,,"`
else
- r=`basename $i .root | sed 's/trending_//'`
+ r=`basename \`dirname $i\` | sed 's/^0*//'`
fi
- printf "%3d/%3d: %s\n" $cur $max $r
+ local m=`printf "%3d/%3d: %s\n" $cur $max $r`
+ info "$m"
runs[$counter]=$r
let counter=$counter+1
}
# --- Run the final trending -----------------------------------------
-variance=0
+variance=1
make_trend()
{
local dir=$1
local ret=0
- mess 1 -n "Analysing for trend $dir ... "
+ info -n "Analysing for trend $dir ... "
(cd $dir
- echo "hadd trending.root 000*/trending.root"
+ mess 1 "hadd trending.root 000*/trending.root"
rm -f trending.root
hadd -k trending.root 000*/trending.root
- $ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/periodQA.sh trending.root
- ret=$?
- )
+ if test $? -eq 0 && test -f trending.root ; then
+ $ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/periodQA.sh trending.root
+ ret=$?
+ else
+ ret=1
+ fi
+ ) >>${redir} 2>&1
+ if test $ret -ne 0 ; then
+ err "Failed to make trending in $dir"
+ else
+ ok
+ fi
return $ret
}
-# --- Make index file ------------------------------------------------
-make_index()
+
+# --- Help output ----------------------------------------------
+usage()
{
- local dir=$1 ; shift
- local title=$1 ; shift
- local desc=$1 ; shift
- mess 1 "Making index in $dir ($title)"
-
- (cd $dir
- local date=`date`
-
- rm -f index.html
-
- cat <<EOF > index.html
-<!DOCTYPE html>
-<html>
- <head>
- <title>$title</title>
- <link rel='stylesheet' href='style.css'>
- <link rel='shortcut icon' href='fmd_favicon.png' type='image/x-png'>
- </head>
- <body>
- <h1><img style='width: 200px;' src='fmd_logo.png'> $title</h1>
-EOF
- if test ! "x$desc" = "x" ; then
- echo "<p>$desc</p>" >> index.html
- fi
- echo " <ul>" >> index.html
- for i in * ; do
- if test ! -d $i ; then continue ; fi
- echo " <li><a href='$i'>$i</a></li>" >> index.html
- done
- echo " </ul>" >> index.html
- if test "x$desc" = "x" ; then
- echo " <div class='back'><a href='../'>Back</a></div>" \
- >> index.html
- fi
- cat <<EOF >> index.html
- <div class='change'>Last update: $date</div>
- </body>
-</html>
+ cat <<EOF
+Usage: $0 [OPTIONS] -p PRODUCTION [-P PASS]
+
+Options:
+ -b,--barrel MODE Fetch barrel data [$barrel]
+ -d,--directory DIR Search custom AliEn directory [$path]
+ -f,--force Force re-run analysis [$force]
+ -h,--help This help
+ -i,--no-index Do not make index [$index]
+ -l,--log-file Log file output [$redir]
+ -L,--local Local trending_<X>.root files [$from_local]
+ -m,--max-files NUMBER Max number of files to get [$maxf]
+ -M,--max-jobs NUMBER Max number of consequtive jobs [$maxjobs]
+ -p,--production IDENTIFIER Production identifier [$prodfull]
+ -P,--pass IDENTIFIER Pass identifier [$passfull]
+ -Q,--qa-number NUMBER Custom QA id [$qanumber]
+ -R,--also-results Also get QAresults.root/run [$also_results]
+ -t,--top DIRECTORY Output directory [$top]
+ -T,--min-max Errors=min/max
+ -v,--verbose Increase verbosity [$verb]
+ -V,--variance Errors=variance [$variance]
+
+Production identifiers are of the form LHC11h, LHC11h3, or LHC11h_2.
+Pass identifers are of the form pass2, pass1_HLT, or cpass1.
+If barrel mode>0, then do not assume ESD directory.
+If barrel mode>1, then get trending_barrel.root and QAresults_barrel.root
+Option -d is for hand-made QA passes.
+If optiond -d is not specified then official QA passes are assumed.
EOF
- copy_style
- copy_aliroot_file $favicon
- copy_aliroot_file $logo
- fix_perm index.html
- fix_perm . > /dev/null 2>&1
- )
}
-# --- Pass command line options --------------------------------------
+# --- Parse command line options -------------------------------------
redir=/dev/null
maxf=-1
top=.
+index=0
while test $# -gt 0 ; do
case $1 in
- -h|--help) usage ; exit 0 ;;
- -v|--verbose) let verb=$verb+1 ;;
- -j|--jobid) jobid=$2 ; shift ;;
+ -b|--barrel) barrel=$2 ; shift ;;
+ -d|--directory) path=$2 ; shift ;;
+ -f|--force) let force=$force+1 ;;
+ -h|--help) usage ; exit 0 ;;
+ -i|--index) index=1 ;;
+ -l|--log-file) redir= ;;
+ -L|--local) from_local=1 ;;
-m|--max-files) maxf=$2 ; shift ;;
-M|--max-jobs) maxjobs=$2 ; shift ;;
- -t|--top) top=$2 ; shift ;;
- -R|--also-results) also_results=1 ;;
+ -p|--production) prodfull=$2 ; shift ; parse_prod ;;
+ -P|--pass) passfull=$2 ; shift ; parse_pass ;;
-Q|--qa-number) qanumber=$2 ; shift ;;
- -l|--log-file) redir= ;;
- -L|--local) from_local=1 ;;
+ -R|--also-results) also_results=1 ;;
+ -t|--top) top=$2 ; shift ;;
+ -T|--min-max) variance=0 ;;
+ -v|--verbose) let verb=$verb+1 ;;
-V|--variance) variance=1 ;;
- -b|--barrel) barrel=$2 ; shift ;;
- -f|--force) let force=$force+1 ;;
- -p|--production)
- prodfull=$2; shift; parse_prod ; year=20${prodyear} ;;
- -P|--pass)
- passfull=$2; shift; parse_pass ;;
- -d|--directory) path=$2 ; shift ;;
*) echo "$0: Unknown argument: $1" > /dev/stderr ; exit 1 ;;
esac
shift
done
-# --- Initial setup --------------------------------------------------
-# First, check we have a valid AliEn token, then retrieve the job
-# information to parse out the location of the files we need, and
-# finally make our output directory and check the lock
+# === Initial setup ==================================================
+# --- Check for AliEn token ------------------------------------------
check_token
-if test ! "x$jobid" = x ; then
- if test ! "x$prodfull" = "x" || test ! "x$passfull" = "x" ; then
- cat <<EOF > /dev/stderr
-Option -j ${jobid} and options -p and -P are mutually exclusive
-EOF
- exit 1
- fi
- get_job
+# --- Check settings -------------------------------------------------
+if test "x$prodfull" = "x" ; then
+ err "No production specified"
+ exit 1
+fi
+if test "x$prodpost" = "x" && test "x$passfull" = "x" ; then
+ err "No pass specified for non-MC production"
+ exit 1
+elif test "x$passfull" = "x" || test "x$passfull" = "xpassMC"; then
+ warn "No pass specified, assuming MC"
+ passfull=
+ mc=1
+fi
+
+# --- Construct output -----------------------------------------------
+proddir=
+passdir=
+store=
+year=20${prodyear}
+if test $mc -gt 0 ; then
+ proddir=${prodfull}
+ passdir=passMC
+ store=sim
else
- if test "x$prodfull" = "x" || test "x$passfull" = "x" ; then
- cat<<EOF > /dev/stderr
-When specifying prodcution and/or pass both options -p and -P _must_
-be specified.
-EOF
- exit 1
- elif test ! "x$jobid" = "x" ; then
- cat <<EOF > /dev/stderr
-Option -j and options -p ${prodfull} and -P ${passfull} are mutually exclusive
-EOF
- exit 1
+ proddir=LHC${prodyear}${prodletter}
+ store=data
+ if test "x$passno" = "x" ; then
+ err "No pass number"
+ fi
+ if test "x$passpre" != "x" ; then
+ passdir=${passpre}
fi
-fi
-
-proddir=LHC${prodyear}${prodletter}
-store=${proddir}
-if test ! "x$passno" = "x" ; then
- if test "x${passpre}" = "xv" || test "x${passpre}" = "xc"; then
- store=${store}/${passpre}pass${passno}
- else
- store=${store}/pass${passno}
+ passdir=${passdir}pass${passno}
+ if test "x$passpost" != "x" ; then
+ passdir=${passdir}_${passpost}
fi
-elif test ! "x$prodpost" = "x" ; then
- proddir=${proddir}${prodpost}
- store=${proddir}/sim
-elif test ! "x$remainder" = "x" ; then
- store=${store}/${remainder}
-fi
+ if test "x$remainder" != "x" ; then
+ passdir=${passdir}/${remainder}
+ fi
+fi
+store=${store}/${year}/${proddir}/${passdir}
if test ! "x$qanumber" = "x" && test $qanumber -gt 0 ; then
store=${store}_QA${qanumber}
fi
mkdir -p ${top}/$store
-fix_perm ${top}/${proddir}
fix_perm ${top}/$store
+# --- Check for logging ----------------------------------------------
if test "x$redir" = "x" ; then
redir=${top}/$store/qa.log
rm -f $redir
Use variance: ${variance}
Use pre-downloaded: ${from_local}
EOF
+
# --- Do a search to find our files ----------------------------------
get_filelist
-
+nf=$?
+if test $nf -le 0 ; then
+ err "No files to process"
+ exit 1
+fi
if test $maxf -gt 0 && test $maxf -lt $numf ; then
numf=$maxf
fi
# --- Copy scripts to target and compile -----------------------------
-for i in QABase.h QAPlotter.C QARing.h QAStructs.h QATrender.C \
- RunFileQA.C RunFinalQA.C ; do
+for i in QABase.h QAPlotter.C QARing.h QAStructs.h QATrender.C ; do
cp $ALICE_ROOT/PWGLF/FORWARD/analysis2/qa/$i ${store}/${i}
rm -f ${store}/`echo $i | tr '.' '_'`.{so,d}
fix_perm ${store}/${i}
gROOT->LoadMacro("QATrender.C++g");
.q
EOF
-)
+) 2>> ${redir}
mess 1 "Compiling QAPlotter.C"
(cd $store && root -l -b <<EOF
gROOT->LoadMacro("QABase.h++g");
gROOT->LoadMacro("QAPlotter.C++g");
.q
EOF
-)
+) 2>> ${redir}
(cd ${store} && for i in *.so *.d ; do fix_perm $i ; done)
# --- Now get and analyse each run -----------------------------------
make_trend ${top}/$store
# --- Make index files -----------------------------------------------
-make_index ${top}/${proddir} ${proddir}
-# make_index ${top} "QA for the FMD" \
-# "For more information see <a href='https://twiki.cern.ch/twiki/bin/viewauth/ALICE/FMDQA'>TWiki pages</a>."
-$topmk --title "QA for the FMD" \
- --description "For more information see <a href='https://twiki.cern.ch/twiki/bin/viewauth/ALICE/FMDQA'>TWiki pages</a>." \
- --link \
- --max-depth 2 \
- --output index.html
-fix_perm index.html
-copy_aliroot_file $script
-
+if test $index -gt 0 ; then
+ info -n "Making index ... "
+ desc="For more information see <a href='https://twiki.cern.ch/twiki/"
+ desc="${desc}bin/viewauth/ALICE/FMDQA'>TWiki pages</a>."
+ $topmk --title "QA for the FMD" \
+ --description "$desc" \
+ --link \
+ --max-depth 4 \
+ --output index.html
+ # >> ${redir} 2>&1
+ fix_perm index.html
+ copy_aliroot_file $script
+ ok
+fi
chmod -R g+rwX ${top}/${proddir} >> ${redir} 2>&1
+
#
# EOF
#