]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGPP/QA/scripts/runQA.sh
explicitly return a return code
[u/mrichter/AliRoot.git] / PWGPP / QA / scripts / runQA.sh
index 339fba079887b4ed420568eb1aa6182d699d10d2..b141870dce0ae04e4a278dc9a7d9a3f6d1f7ef4b 100755 (executable)
@@ -34,6 +34,7 @@ main()
   fi
 
   updateQA "$@"
+  return 0
 }
 
 updateQA()
@@ -327,16 +328,23 @@ updateQA()
 
   #remove lock
   rm -f ${lockFile}
+  return 0
 }
 
 executePlanB()
 {
   #in case of emergency
-  if [[ -n ${MAILTO} ]]; then 
+  #first check if we have the email of the detector expert defined,
+  #if yes, append to the mailing list
+  local mailTo=${MAILTO}
+  local detExpertEmailVar="MAILTO_${detector}"
+  [[ -n "${!detExpertEmailVar}" ]] && mailTo+=" ${!detExpertEmailVar}"
+  if [[ -n ${mailTo} ]]; then 
     echo
-    echo "trouble detected, sending email to ${MAILTO}"
-    cat ${logSummary} | mail -s "qa in need of assistance" ${MAILTO}
+    echo "trouble detected, sending email to ${mailTo}"
+    cat ${logSummary} | mail -s "${detector} QA in need of assistance" ${mailTo}
   fi
+  return 0
 }
 
 validate()
@@ -490,6 +498,7 @@ parseConfig()
     echo "${var}=${value}"
     export ${var}="${value}"
   done
+  return 0
 }
 
 guessRunData()
@@ -535,22 +544,43 @@ 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
-  else
-    #ALL OK
-    return 0
   fi
+  
+  #ALL OK
+  return 0
+}
+
+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()
@@ -559,6 +589,7 @@ substituteDetectorName()
   local dir=$2
   [[ ${dir} =~ \%det ]] && det=${det,,} && echo ${dir/\%det/${det}}
   [[ ${dir} =~ \%DET ]] && det=${det} && echo ${dir/\%DET/${det}}
+  return 0
 }
 
 get_realpath() 
@@ -676,6 +707,8 @@ hostInfo(){
         echo
         echo
         echo
+  
+  return 0
 }
 
 main "$@"