]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGPP/QA/scripts/runQA.sh
Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / PWGPP / QA / scripts / runQA.sh
index be1cc086ddf0cc813640eadf38fc47163e42a93a..7b2810529a633efa37b4959e094adf2575908932 100755 (executable)
@@ -1,4 +1,9 @@
 #!/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
@@ -10,7 +15,7 @@ main()
     echo "  ${0##*/} configFile=runQA.config inputList=file.list outputDirectory=%det"
     return 1
   fi
+
   if ! parseConfig "$@"; then
     ${0}
     return 1
@@ -184,7 +189,8 @@ updateQA()
           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
@@ -226,7 +232,7 @@ updateQA()
       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
@@ -529,15 +535,18 @@ guessRunData()
   
   #modify the OCDB: set the year
   if [[ ${dataType} =~ sim ]]; then 
-    anchorYear=$(for x in $mcProductionMap ; do [[ "${x}" =~ ${originalPeriod} ]] && echo ${x} && break; done)
-    anchorYear=${anchorYear#*=}
+    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
@@ -547,6 +556,24 @@ guessRunData()
   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