10 dateString=$(date +%Y-%m-%d-%H-%M)
11 [[ -z $1 ]] && echo "Usage: $0 configFile" && exit 1
12 [[ ! -f $1 ]] && echo "argument not a file" && exit 1
16 parseConfig $configFile $@
19 mkdir -p $logDirectory
20 [[ ! -d $logDirectory ]] && echo "no log dir $logDirectory" && exit 1
21 logFile="$logDirectory/${0##*/}.$dateString.log"
23 [[ ! -f ${logFile} ]] && echo "cannot write logfile $logfile" && exit 1
27 lockFile=${logDirectory}/runQA.lock
28 [[ -f ${lockFile} ]] && echo "lock ${lockFile} exists!" && exit 1
30 [[ ! -f ${lockFile} ]] && echo "cannot lock $lockFile" && exit 1
32 #be paranoid and make some full paths
33 inputList=$(readlink -f ${inputList})
34 workingDirectory=$(readlink -f ${workingDirectory})
35 mkdir -p ${workingDirectory}
36 if [[ ! -d ${workingDirectory} ]]; then
37 echo "working dir $workingDirectory does not exist and cannot be created"
40 cd ${workingDirectory}
42 [[ -z $ALICE_ROOT ]] && source $alirootEnv
43 [[ -z $ALICE_ROOT ]] && echo "ALICE_ROOT not defined" && exit 1
45 dateString=$(date +%Y-%m-%d-%H-%M)
46 echo "Start time QA process: $dateString"
48 for detectorScript in $ALICE_ROOT/PWGPP/QA/detectorQAscripts/*; do
50 [[ ! ${detectorScript} =~ .*\.sh ]] && continue
51 detector=${detectorScript%.sh}
52 detector=${detector##*/}
53 outputDir=$(substituteDetectorName ${detector} ${outputDirectory})
54 tmpRunDir=${workingDirectory}/tmpQArunDir${detector}
55 if ! mkdir -p ${tmpRunDir}; then
56 echo "cannot create the temp dir $tmpRunDir"
61 tmpPrefix=${tmpRunDir}/${outputDir}
62 echo outputDir=$outputDir
63 echo tmpPrefix=$tmpPrefix
64 echo detector=$detector
67 unset -f periodLevelQA
68 source ${detectorScript}
70 #################################################################
71 #produce the QA and trending tree for each file (run)
74 guessRunData ${qaFile}
76 runDir=${tmpPrefix}/${dataType}/${year}/${period}/${pass}/000${runNumber}
81 [[ "$qaFile" =~ .*.zip$ ]] && qaFile="${qaFile}#QAresults.root"
89 #################################################################
90 #cache which productions were (re)done
91 arrOfTouchedProductions=( $(/bin/ls -d ${tmpPrefix}/*/*/*/*) )
92 echo arrOfTouchedProductions=${arrOfTouchedProductions[@]}
94 #################################################################
95 #(re)do the merging/trending in the final destination
96 for tmpProductionDir in ${arrOfTouchedProductions[@]}; do
98 echo productionDir=${outputDir}/${tmpProductionDir#${tmpPrefix}}
99 productionDir=${outputDir}/${tmpProductionDir#${tmpPrefix}}
101 echo mkdir -p ${productionDir}
102 mkdir -p ${productionDir}
103 if [[ ! -d ${productionDir} ]]; then
104 echo "cannot make productionDir $productionDir" && return 1
107 echo mv -f ${tmpProductionDir}/* ${productionDir}
108 mv -f ${tmpProductionDir}/* ${productionDir}
110 guessRunData "${productionDir}/dummyName"
114 hadd trending.root 000*/trending.root
116 periodLevelQA trending.root
122 cd ${workingDirectory}
135 #first, source the config file
136 if [ -f ${configFile} ]; then
139 echo "config file ${configFile} not found!, skipping..."
142 #then, parse the options as they override the options from file
143 while [[ -n ${1} ]]; do
152 #guess the period from the path, pick the rightmost one
157 legoTrainRunNumber=""
160 local shortRunNumber=""
162 declare -a path=( $1 )
163 local dirDepth=$(( ${#path[*]}-1 ))
165 for ((x=${dirDepth};x>=0;x--)); do
167 [[ $((x-1)) -ge 0 ]] && local fieldPrev=${path[$((x-1))]}
168 local field=${path[${x}]}
169 local fieldNext=${path[$((x+1))]}
171 [[ ${field} =~ ^[0-9]*$ && ${fieldNext} =~ (.*\.zip$|.*\.root$) ]] && legoTrainRunNumber=${field}
172 [[ -n ${legoTrainRunNumber} && -z ${pass} ]] && pass=${fieldPrev}
173 [[ ${field} =~ ^LHC[0-9][0-9][a-z].*$ ]] && period=${field%_*}
174 [[ ${field} =~ ^000[0-9][0-9][0-9][0-9][0-9][0-9]$ ]] && runNumber=${field#000}
175 [[ ${field} =~ ^[0-9][0-9][0-9][0-9][0-9][0-9]$ ]] && shortRunNumber=${field}
176 [[ ${field} =~ ^20[0-9][0-9]$ ]] && year=${field}
177 [[ ${field} =~ ^(^sim$|^data$) ]] && dataType=${field}
180 [[ -z ${legoTrainRunNumber} ]] && pass=${path[$((dirDepth-1))]}
181 [[ "${dataType}" =~ ^sim$ ]] && pass="passMC" && runNumber=${shortRunNumber}
184 substituteDetectorName()
188 [[ ${dir} =~ \%det ]] && det=${det,,} && echo ${dir/\%det/${det}}
189 [[ ${dir} =~ \%DET ]] && det=${det} && echo ${dir/\%DET/${det}}