#!/bin/bash
+if [ ${BASH_VERSINFO} -lt 4 ]; then
+ echo "bash version >= 4 needed, you have ${BASH_VERSION}, exiting..."
+ exit 1
+fi
+
main()
{
if [[ -z $1 ]]; then
echo " ${0##*/} configFile=runQA.config inputList=file.list outputDirectory=%det"
return 1
fi
-
+
if ! parseConfig "$@"; then
${0}
return 1
echo "logFile = $logFile"
#check lock
- lockFile=${logDirectory}/runQA.lock
+ lockFile=${workingDirectory}/runQA.lock
[[ -f ${lockFile} ]] && echo "lock ${lockFile} exists!" | tee ${logFile} && return 1
touch ${lockFile}
[[ ! -f ${lockFile} ]] && echo "cannot lock $lockFile" | tee ${logFile} && return 1
fi
logSummary=${logDirectory}/summary-${detector}-${dateString}.log
+ hostInfo >> ${logSummary}
outputDir=$(substituteDetectorName ${detector} ${outputDirectory})
tmpDetectorRunDir=${workingDirectory}/tmpQAtmpRunDir${detector}-${dateString}
if ! mkdir -p ${tmpDetectorRunDir}; then
echo "could not guess run data from ${qaFile}"
continue
fi
+ echo "anchorYear for ${originalPeriod} is: ${anchorYear}"
tmpProductionDir=${tmpPrefix}/${dataType}/${year}/${period}/${pass}
tmpRunDir=${tmpProductionDir}/000${runNumber}
if [[ "$qaFile" =~ .*.zip$ ]]; then
if unzip -l ${qaFile} | egrep "QAresults.root" &>/dev/null; then
qaFile="${qaFile}#QAresults.root"
+ elif unzip -l ${qaFile} | egrep "QAresults_barrel.root" &>/dev/null; then
+ qaFile="${qaFile}#QAresults_barrel.root"
else
qaFile=""
fi
aliroot -b -q -l "$ALICE_ROOT/PWGPP/macros/simpleTrending.C(\"${qaFile}\",${runNumber},\"${detector}\",\"trending.root\",\"trending\",\"recreate\")" 2>&1 | tee -a runLevelQA.log
fi
if [[ -f trending.root ]]; then
- arrOfTouchedProductions[${tmpProductionDir}]=1
+ #cache the touched production + an example file to guarantee consistent run data parsing
+ arrOfTouchedProductions[${tmpProductionDir}]="${qaFile%\#*}"
else
echo "trending.root not created"
fi
for dir in ${tmpProductionDir}/000*; do
echo
oldRunDir=${outputDir}/${dir#${tmpPrefix}}
- if ! guessRunData "${dir}/dummyName"; then
+ if ! guessRunData "${arrOfTouchedProductions[${tmpProductionDir}]}"; then
echo "could not guess run data from ${dir}"
continue
fi
if [[ -n ${MAILTO} ]]; then
echo
echo "trouble detected, sending email to ${MAILTO}"
-
- grep BAD ${logSummary} | mail -s "qa in need of assistance" ${MAILTO}
+ cat ${logSummary} | mail -s "qa in need of assistance" ${MAILTO}
fi
}
#check logs
local logstatus=0
for log in ${dir}/${logFiles[*]}; do
- finallog=${PWD%/}/${log}
[[ ! -f ${log} ]] && continue
errorSummary=$(validateLog ${log})
validationStatus=$?
if [[ ${validationStatus} -eq 0 ]]; then
#in pretend mode randomly report an error in rec.log some cases
if [[ -n ${pretend} && "${log}" == "rec.log" ]]; then
- [[ $(( ${RANDOM}%2 )) -ge 1 ]] && echo "${finallog} BAD random error" || echo "${finallog} OK"
+ [[ $(( ${RANDOM}%2 )) -ge 1 ]] && echo "${log} BAD random error" || echo "${log} OK"
else
- echo "${finallog} OK"
+ echo "${log} OK"
fi
elif [[ ${validationStatus} -eq 1 ]]; then
- echo "${finallog} BAD ${errorSummary}"
+ echo "${log} BAD ${errorSummary}"
elif [[ ${validationStatus} -eq 2 ]]; then
- echo "${finallog} OK MWAH ${errorSummary}"
+ echo "${log} OK MWAH ${errorSummary}"
fi
done
dataType=""
originalPass=""
originalPeriod=""
+ anchorYear=""
- local shortRunNumber=""
+ shortRunNumber=""
oldIFS=${IFS}
local IFS="/"
declare -a path=( $1 )
(( i++ ))
done
originalPass=${pass}
+ [[ -n ${shortRunNumber} && "${legoTrainRunNumber}" =~ ${shortRunNumber} ]] && legoTrainRunNumber=""
[[ -z ${legoTrainRunNumber} ]] && pass=${path[$((dirDepth-1))]}
- [[ "${dataType}" =~ ^sim$ ]] && pass="passMC" && runNumber=${shortRunNumber} && originalPass=""
+ [[ "${dataType}" =~ ^sim$ ]] && pass="passMC" && runNumber=${shortRunNumber} && originalPass="" #for MC not from lego, the runnumber is identified as lego train number, thus needs to be nulled
[[ -n ${legoTrainRunNumber} ]] && pass+="_lego${legoTrainRunNumber}"
#modify the OCDB: set the year
- ocdbStorage=$(setYear ${year} ${ocdbStorage})
+ if [[ ${dataType} =~ sim ]]; then
+ anchorYear=$(run2year $runNumber)
+ if [[ -z "${anchorYear}" ]]; then
+ echo "WARNING: anchorYear not available for this production: ${originalPeriod}, runNumber: ${runNumber}. Cannot set the OCDB."
+ return 1
+ fi
+ ocdbStorage=$(setYear ${anchorYear} ${ocdbStorage})
+ else
+ ocdbStorage=$(setYear ${year} ${ocdbStorage})
+ fi
#if [[ -z ${dataType} || -z ${year} || -z ${period} || -z ${runNumber}} || -z ${pass} ]];
- if [[ -z ${runNumber}} ]]
+ if [[ -z ${runNumber} ]]
then
#error condition
return 1
fi
}
+run2year()
+{
+ #for a given run print the year.
+ #the run-year table is ${runMap} (a string)
+ #defined in the config file
+ #one line per year, format: year runMin runMax
+ local run=$1
+ [[ -z ${run} ]] && return 1
+ local year=""
+ local runMin=""
+ local runMax=""
+ while read year runMin runMax; do
+ [[ -z ${year} || -z ${runMin} || -z ${runMax} ]] && continue
+ [[ ${run} -ge ${runMin} && ${run} -le ${runMax} ]] && echo ${year} && break
+ done < <(echo "${runMap}")
+ return 0
+}
+
substituteDetectorName()
{
local det=$1
return 0
}
+hostInfo(){
+#
+# Hallo world - Print AliRoot/Root/Alien system info
+#
+
+#
+# HOST info
+#
+ echo --------------------------------------
+ echo
+ echo HOSTINFO
+ echo
+ echo HOSTINFO HOSTNAME" "$HOSTNAME
+ echo HOSTINFO DATE" "`date`
+ echo HOSTINFO gccpath" "`which gcc`
+ echo HOSTINFO gcc version" "`gcc --version | grep gcc`
+ echo --------------------------------------
+
+#
+# ROOT info
+#
+ echo --------------------------------------
+ echo
+ echo ROOTINFO
+ echo
+ echo ROOTINFO ROOT" "`which root`
+ echo ROOTINFO VERSION" "`root-config --version`
+ echo
+ echo --------------------------------------
+
+
+#
+# ALIROOT info
+#
+ echo --------------------------------------
+ echo
+ echo ALIROOTINFO
+ echo
+ echo ALIROOTINFO ALIROOT" "`which aliroot`
+ echo ALIROOTINFO VERSION" "`echo $ALICE_LEVEL`
+ echo ALIROOTINFO TARGET" "`echo $ALICE_TARGET`
+ echo
+ echo --------------------------------------
+
+#
+# Alien info
+#
+#echo --------------------------------------
+#echo
+#echo ALIENINFO
+#for a in `alien --printenv`; do echo ALIENINFO $a; done
+#echo
+#echo --------------------------------------
+
+#
+# Local Info
+#
+ echo PWD `pwd`
+ echo Dir
+ ls -al
+ echo
+ echo
+ echo
+}
+
main "$@"