2 #include benchmark.config
4 # this script runs the CPass0/CPass1 train
5 # produced OCDB updates are local
9 #run in proper mode depending on the selection
10 if [[ $# -lt 1 ]]; then
11 if [[ ! "${0}" =~ "bash" ]]; then
13 echo " ${0} \"run\" productionID inputList configFile [extraOpts]"
14 echo "uses a batch system (SGE):"
15 echo " ${0} \"submit\" productionID inputList configFile [extraOpts]"
16 echo "extraOpts if non-empty override the config file, e.g.:"
17 echo " ${0} submit test1 benchmark.list benchmark.config runNumber=169123 nEvents=10"
22 #define some aliases - default is to call one of the functions directly
27 "CPass0") goCPass0 "$@";;
28 "CPass1") goCPass1 "$@";;
29 "MakeLocalOCDBaccessConfig") goMakeLocalOCDBaccessConfig "$@";;
30 "MergeCPass0") goMergeCPass0 "$@";;
31 "MergeCPass1") goMergeCPass1 "$@";;
32 "MakeFilteredTrees") goMakeFilteredTrees "$@";;
33 "MakeSummary") goMakeSummary "$@";;
34 "run") goSubmitMakeflow "$@";;
35 "submit") goSubmitBatch "$@";;
37 "GenerateMakeflow") goGenerateMakeflow "$@";;
38 "PrintValues") goPrintValues "$@";;
39 "CreateQAplots") goCreateQAplots "$@";;
40 "WaitForOutput") goWaitForOutput "$@";;
41 "Merge") goMerge "$@";;
51 #generate one raw chunk in current directory
52 SEED=${JOB_ID}${SGE_TASK_ID}
53 export CONFIG_SEED=${SEED}
57 if [[ -n ${pretend} ]]; then
61 if [[ -f sim.C && -f Config.C ]] ; then
62 time aliroot -b -q -x sim.C\(${runNumber},\"${OCDBpath}\",${nEventsim}\) >sim.log 2>&1
63 mv syswatch.log simwatch.log
80 if ! parseConfig ${configFile} "$@"; then return 1; fi
82 #record the working directory provided by the batch system
83 batchWorkingDirectory=${PWD}
85 #use the jobindex only if set and non-negative
86 if [[ -z ${jobindex} || ${jobindex} -lt 0 ]]; then
87 [[ -n "${LSB_JOBINDEX}" ]] && jobindex=${LSB_JOBINDEX}
88 [[ -n "${SGE_TASK_ID}" ]] && jobindex=${SGE_TASK_ID}
89 if [[ -z ${jobindex} ]]; then
95 [[ -z ${commonOutputPath} ]] && commonOutputPath=${PWD}
96 doneFile="${commonOutputPath}/meta/cpass0.job${jobindex}.run${runNumber}.done"
97 [[ -n ${useProfilingCommand} ]] && doneFile="${commonOutputPath}/meta/profiling.cpass0.job${jobindex}.run${runNumber}.done"
99 [[ -f ${alirootSource} && -z ${ALICE_ROOT} ]] && source ${alirootSource}
101 if [[ -n ${ALIROOT_FORCE_COREDUMP} ]]; then
103 export ALIROOT_FORCE_COREDUMP
106 #the contents of this is stored in the tree and used later (e.g. AliAnalysisTaskPIDResponse)!
107 #at the QA stage the pass number is guessed from the path stored here.
109 #Packages= ;OutputDir= ;LPMPass= ;TriggerAlias= ;LPMRunNumber= ;LPMProductionType= ;LPMInteractionType= ;LPMProductionTag= ;LPMAnchorRun= ;LPMAnchorProduction= ;LPMAnchorYear=
110 export PRODUCTION_METADATA="OutputDir=cpass0"
112 if [[ "${inputList}" =~ \.root$ ]]; then
115 infile=$(sed -ne "${jobindex}p" ${inputList} | egrep '\s*\w*/\w*')
117 chunkName=${infile##*/}
119 outputDir=${targetDirectory}/${jobindex}_${chunkName%.*}
120 mkdir -p ${outputDir}
121 if [[ ! -d ${outputDir} ]]; then
123 echo "cannot make ${outputDir}" >> ${doneFile}
127 #runpath=${PWD}/rundir_cpass0_${runNumber}_${jobindex}
129 #[[ ${reconstructInTemporaryDir} -eq 1 && -n ${TMPDIR} ]] && runpath=${TMPDIR}
130 [[ ${reconstructInTemporaryDir} -eq 1 ]] && runpath=$(mktemp -d -t cpass0.XXXXXX)
132 if [[ ! -d ${runpath} ]]; then
134 echo "cannot make runpath ${runpath}" >> ${doneFile}
137 if ! cd ${runpath}; then
139 echo "PWD=$PWD is not the runpath=${runpath}" >> ${doneFile}
143 #runCPassX/C expects the raw chunk to be linked in the run dir
144 #despite it being accessed by the full path
145 ln -s ${infile} ${runpath}/${chunkName}
148 if [[ -n ${generateMC} ]]; then
150 outputDirMC=${commonOutputPath}/000${runNumber}/sim/${jobindex}
151 simrunpath=${outputDirMC}
152 #[[ ${simulateInTemporaryDir} -eq 1 && -n ${TMPDIR} ]] && simrunpath=${TMPDIR}
153 [[ ${simulateInTemporaryDir} -eq 1 ]] && simrunpath=$(mktemp -d -t cpass0MC.XXXXXX)
154 mkdir -p ${outputDirMC}
155 mkdir -p ${simrunpath}
156 if cd ${simrunpath}; then
159 "${batchWorkingDirectory}/sim.C"
160 "${batchWorkingDirectory}/rec.C"
161 "${batchWorkingDirectory}/Config.C"
162 "${batchWorkingDirectory}/OCDB_*.root"
164 for file in ${filesMC[*]}; do
165 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
168 generateMC ${runNumber} ${ocdbPath} ${nEvents}
170 [[ ! "${simrunpath}" =~ "${outputDirMC}" ]] && mv * ${outputDirMC} #TODO check if it works
173 ln -s ${outputDirMC}/* ${runpath}/
175 inputList=${outputDirMC}/galice.root #TODO not valid outside shell !!!
181 if [[ ! -f ${inputList} && -z ${pretend} ]]; then
183 echo "input file ${inputList} not found, exiting..." >> ${doneFile}
187 logOutputDir=${runpath}
188 [[ -n ${logToFinalDestination} ]] && logOutputDir=${outputDir}
189 [[ -z ${dontRedirectStdOutToLog} ]] && exec &> ${logOutputDir}/stdout
190 #[[ -z ${dontRedirectStdOutToLog} ]] && exec 2> ${logOutputDir}/stderr
193 echo "#####################"
196 echo nEvents ${nEvents}
197 echo runNumber ${runNumber}
198 echo ocdbPath ${ocdbPath}
199 echo infile ${infile}
200 echo chunkName ${chunkName}
201 echo jobindex ${jobindex}
202 echo recoTriggerOptions ${recoTriggerOptions}
203 echo targetDirectory ${targetDirectory}
204 echo commonOutputPath ${commonOutputPath}
205 echo doneFile ${doneFile}
206 echo batchWorkingDirectory=$batchWorkingDirectory
207 echo runpath ${runpath}
208 echo outputDir ${outputDir}
210 echo ALICE_ROOT ${ALICE_ROOT}
211 echo "########## ###########"
213 alirootInfo > ALICE_ROOT.log
216 "${batchWorkingDirectory}/runCPass0.sh"
217 "${batchWorkingDirectory}/recCPass0.C"
218 "${batchWorkingDirectory}/runCalibTrain.C"
219 "${batchWorkingDirectory}/localOCDBaccessConfig.C"
220 "${batchWorkingDirectory}/OCDB.root"
221 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass0/runCPass0.sh"
222 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass0/recCPass0.C"
223 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass0/runCalibTrain.C"
226 for file in ${filesCPass0[*]}; do
227 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
228 [[ ${file##*/} =~ .*\.sh ]] && chmod +x ${file##*/}
231 echo "this directory (${PWD}) contents:"
234 chmod u+x runCPass0.sh
236 sed -i '/.*root .*\.C/ s|\s*,\s*|,|g' *.sh
238 if [[ -n ${postSetUpActionCPass0} ]]; then
239 echo "running ${postSetUpActionCPass0}"
240 eval ${postSetUpActionCPass0}
244 echo "${runpath}/runCPass0.sh ${infile} ${nEvents} ${runNumber} ${ocdbPath} ${recoTriggerOptions}"
245 if [[ -n ${pretend} ]]; then
246 sleep ${pretendDelay}
248 touch AliESDfriends.root
249 touch AliESDfriends_v1.root
253 echo ./runCPass0.sh "${infile}" "${nEvents}" "${runNumber}" "${ocdbPath}" "${recoTriggerOptions}"
254 ./runCPass0.sh "${infile}" "${nEvents}" "${runNumber}" "${ocdbPath}" "${recoTriggerOptions}"
257 #move stuff to final destination
258 echo "this directory (${PWD}) contents:"
262 echo rm -f ./${chunkName}
264 echo "cp -R ${runpath}/* ${outputDir}"
265 cp -p -R ${runpath}/* ${outputDir}
271 echo "dir ${outputDir}" >> ${doneFile}
272 if summarizeLogs >> ${doneFile}; then
273 [[ -f ${outputDirMC}/galice.root ]] && echo "sim ${outputDirMC}/galice.root" >> ${doneFile}
274 [[ -f AliESDfriends_v1.root ]] && echo "calibfile ${outputDir}/AliESDfriends_v1.root" >> ${doneFile}
275 [[ -f AliESDs.root ]] && echo "esd ${outputDir}/AliESDs.root" >> ${doneFile}
278 [[ "${runpath}" != "${outputDir}" ]] && rm -rf ${runpath} && echo "removing ${runpath}"
295 if ! parseConfig ${configFile} "$@"; then return 1; fi
297 #record the working directory provided by the batch system
298 batchWorkingDirectory=${PWD}
300 #use the jobindex only if set and non-negative
301 if [[ -z ${jobindex} || ${jobindex} -lt 0 ]]; then
302 [[ -n "${LSB_JOBINDEX}" ]] && jobindex=${LSB_JOBINDEX}
303 [[ -n "${SGE_TASK_ID}" ]] && jobindex=${SGE_TASK_ID}
304 if [[ -z ${jobindex} ]]; then
310 [[ -z ${commonOutputPath} ]] && commonOutputPath=${PWD}
311 doneFile="${commonOutputPath}/meta/cpass1.job${jobindex}.run${runNumber}.done"
312 [[ -n ${useProfilingCommand} ]] && doneFile="${commonOutputPath}/meta/profiling.cpass1.job${jobindex}.run${runNumber}.done"
314 [[ -f ${alirootSource} && -z ${ALICE_ROOT} ]] && source ${alirootSource}
316 if [[ -n ${ALIROOT_FORCE_COREDUMP} ]]; then
318 export ALIROOT_FORCE_COREDUMP
321 #the contents of this is stored in the tree and used later (e.g. AliAnalysisTaskPIDResponse)!
322 #at the QA stage the pass number is guessed from the path stored here.
324 #Packages= ;OutputDir= ;LPMPass= ;TriggerAlias= ;LPMRunNumber= ;LPMProductionType= ;LPMInteractionType= ;LPMProductionTag= ;LPMAnchorRun= ;LPMAnchorProduction= ;LPMAnchorYear=
325 export PRODUCTION_METADATA="OutputDir=cpass1"
327 if [[ ! -f ${inputList} && -z ${pretend} ]]; then
329 echo "input file ${inputList} not found, exiting..." >> ${doneFile}
332 if [[ "${inputList}" =~ \.root$ ]]; then
335 infile=$(sed -ne "${jobindex}p" ${inputList} | egrep '\s*\w*/\w*')
337 chunkName=${infile##*/}
339 outputDir=${targetDirectory}/${jobindex}_${chunkName%.*}
340 mkdir -p ${outputDir}
341 if [[ ! -d ${outputDir} ]];then
343 echo "cannot make ${outputDir}" >> ${doneFile}
347 #runpath=${PWD}/rundir_cpass1_${runNumber}_${jobindex}
349 #[[ ${reconstructInTemporaryDir} -eq 1 && -n ${TMPDIR} ]] && runpath=${TMPDIR}
350 [[ ${reconstructInTemporaryDir} -eq 1 ]] && runpath=$(mktemp -d -t cpass1.XXXXXX)
353 if [[ "${infile}" =~ galice\.root ]]; then
354 ln -s ${inputList%/*}/* ${runpath}
358 #init the running path
360 if [[ ! -d ${runpath} ]]; then
362 echo "cannot make runpath ${runpath}" >> ${doneFile}
365 if ! cd ${runpath}; then
367 echo "PWD=$PWD is not the runpath=${runpath}" >> ${doneFile}
371 #this is needed for runCPass1.sh
372 ln -s ${infile} ${runpath}/${chunkName}
374 logOutputDir=${runpath}
375 [[ -n ${logToFinalDestination} ]] && logOutputDir=${outputDir}
376 [[ -z ${dontRedirectStdOutToLog} ]] && exec &> ${logOutputDir}/stdout
377 #[[ -z ${dontRedirectStdOutToLog} ]] && exec 2> ${logOutputDir}/stderr
380 echo "#####################"
383 echo nEvents ${nEvents}
384 echo runNumber ${runNumber}
385 echo ocdbPath ${ocdbPath}
386 echo infile ${infile}
387 echo chunkName ${chunkName}
388 echo jobindex ${jobindex}
389 echo recoTriggerOptions ${recoTriggerOptions}
390 echo targetDirectory ${targetDirectory}
391 echo commonOutputPath ${commonOutputPath}
392 echo doneFile ${doneFile}
393 echo runpath ${runpath}
394 echo outputDir ${outputDir}
395 echo batchWorkingDirectory ${batchWorkingDirectory}
396 echo ALICE_ROOT ${ALICE_ROOT}
398 echo "########## ###########"
400 alirootInfo > ALICE_ROOT.log
403 "${batchWorkingDirectory}/runCPass1.sh"
404 "${batchWorkingDirectory}/recCPass1.C"
405 "${batchWorkingDirectory}/recCPass1_OuterDet.C"
406 "${batchWorkingDirectory}/runCalibTrain.C"
407 "${batchWorkingDirectory}/QAtrain_duo.C"
408 "${batchWorkingDirectory}/localOCDBaccessConfig.C"
409 "${batchWorkingDirectory}/${configFile}"
410 "${commonOutputPath}/meta/cpass0.localOCDB.${runNumber}.tgz"
411 "${batchWorkingDirectory}/OCDB.root"
412 "${trustedQAtrainMacro}"
413 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass1/runCPass1.sh"
414 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass1/recCPass1.C"
415 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass1/recCPass1_OuterDet.C"
416 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass1/runCalibTrain.C"
417 "${ALICE_ROOT}/ANALYSIS/macros/QAtrain_duo.C"
420 for file in "${filesCPass1[@]}"; do
421 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
422 [[ ${file##*/} =~ .*\.sh ]] && echo "making ${file##*/} executable" && chmod +x ${file##*/}
425 echo "this directory (${PWD}) contents:"
429 #remove spaces around commas from calls to root
430 sed -i '/.*root .*\.C/ s|\s*,\s*|,|g' *.sh
432 if [[ -n ${postSetUpActionCPass1} ]]; then
433 echo "running ${postSetUpActionCPass1}"
434 eval ${postSetUpActionCPass1}
438 #configure local OCDB storage from CPass0 (creates the localOCDBaccessConfig.C script)
439 if [[ -f cpass0.localOCDB.${runNumber}.tgz ]]; then
440 echo goMakeLocalOCDBaccessConfig "cpass0.localOCDB.${runNumber}.tgz"
441 goMakeLocalOCDBaccessConfig "cpass0.localOCDB.${runNumber}.tgz"
443 echo "WARNING: file cpass0.localOCDB.${runNumber}.tgz not found!"
446 if [[ ! $(/bin/ls -1 OCDB/*/*/*/*.root 2>/dev/null) ]]; then
448 echo "cpass0 produced no calibration! exiting..." >> ${doneFile}
452 #create the Barrel and OuterDet directories for CPass1 and link the local OCDB directory
453 #there to make the localOCDBaccessConfig.C file work, since it may point to the OCDB
454 #entries using a relative path, e.g. local://./OCDB
455 echo "linking the OCDB/ for Barrel and OuterDet directories"
456 mkdir Barrel OuterDet
458 ln -s ../OCDB Barrel/OCDB
459 ln -s ../OCDB OuterDet/OCDB
462 #the following option enables the filtering task inside the QAtrain_duo.C
463 [[ -n $runESDfiltering ]] && export QA_TaskFilteredTree=1
464 #set the downscaling factors during the filtering fro expert QA (overrides the previous values)
465 if [[ -n ${filteringFactorHighPt} ]]; then
466 export AliAnalysisTaskFilteredTree_fLowPtTrackDownscaligF=${filteringFactorHighPt}
468 if [[ -n ${filteringFactorV0s} ]]; then
469 export AliAnalysisTaskFilteredTree_fLowPtV0DownscaligF=${filteringFactorV0s}
473 chmod u+x runCPass1.sh
474 echo "${runpath}/runCPass1.sh ${infile} ${nEvents} ${runNumber} ${ocdbPath} ${recoTriggerOptions}"
475 if [[ -n ${pretend} ]]; then
476 sleep ${pretendDelay}
477 touch AliESDs_Barrel.root
478 touch AliESDfriends_Barrel.root
479 touch AliESDfriends_v1.root
480 touch QAresults_barrel.root
481 touch EventStat_temp_barrel.root
483 touch AliESDs_Outer.root
484 touch AliESDfriends_Outer.root
485 touch QAresults_outer.root
486 touch EventStat_temp_outer.root
490 touch filtering.log FilterEvents_Trees.root
492 ./runCPass1.sh "${infile}" "${nEvents}" "${runNumber}" "${ocdbPath}" "${recoTriggerOptions}"
494 [[ ! -f AliESDs_Barrel.root && -f Barrel/AliESDs.root ]] && mv Barrel/AliESDs.root AliESDs_Barrel.root
495 [[ ! -f AliESDfriends_Barrel.root && -f Barrel/AliESDfriends.root ]] && mv Barrel/AliESDfriends.root AliESDfriends_Barrel.root
496 [[ ! -f AliESDfriends_v1.root && -f Barrel/AliESDfriends_v1.root ]] && mv Barrel/AliESDfriends_v1.root .
497 [[ ! -f QAresults_barrel.root && -f Barrel/QAresults_barrel.root ]] && mv Barrel/QAresults_barrel.root .
498 [[ ! -f AliESDs_Outer.root && -f OuterDet/AliESDs.root ]] && mv OuterDet/AliESDs.root AliESDs_Outer.root
499 [[ ! -f AliESDfriends_Outer.root && -f OuterDet/AliESDfriends.root ]] && mv OuterDet/AliESDfriends.root AliESDfriends_Outer.root
500 [[ ! -f QAresults_outer.root && -f OuterDet/QAresults_outer.root ]] && mv OuterDet/QAresults_outer.root .
501 [[ ! -f FilterEvents_Trees.root && -f Barrel/FilterEvents_Trees.root ]] && mv Barrel/FilterEvents_Trees.root .
503 #make the filtered tree (if requested and not already produced by QA
504 [[ -f AliESDs_Barrel.root ]] && echo "AliESDs_Barrel.root" > filtered.list
505 if [[ -n ${runESDfiltering} && ! -f FilterEvents_Trees.root && -f filtered.list ]]; then
506 goMakeFilteredTrees ${PWD} ${runNumber} "${PWD}/filtered.list" ${filteringFactorHighPt} ${filteringFactorV0s} ${ocdbPath} 1000000 0 10000000 0 ${configFile} AliESDs_Barrel.root "${extraOpts[@]}" >filtering.log
513 ##handle possible crashes in QA (happens often in trunk)
514 ##rerun QA with a trusted aliroot version
515 #if [[ $(validateLog qa_barrel.log) ]]; then
516 # echo "qa_barrel.log not validated!"
518 #if [[ ! -f QAresults_barrel.root && -f ${setupTrustedAliROOTenvInCurrentShell} || $(validateLog qa_barrel.log) ]]; then
519 # echo "WARNING: using trusted QA aliroot ${ALICE_ROOT}"
520 # source ${setupTrustedAliROOTenvInCurrentShell}
522 # rm QAresults_barrel.root
523 # rm EventStat_temp_barrel.root
525 # [[ ! -f AliESDs.root ]] && ln -s ../AliESDs_Barrel.root AliESDs.root
526 # [[ ! -f AliESDfriends.root ]] && ln -s ../AliESDfriends_Barrel.root AliESDfriends.root
527 # if [[ -n ${trustedQAtrainMacro} ]]; then
528 # eval "cp ${trustedQAtrainMacro} QAtrain_duo_trusted.C"
530 # echo executing aliroot -b -q "QAtrain_duo_trusted.C(\"_barrel\",${runNumber},\"wn.xml\",0,\"${ocdbPath}\")"
531 # time aliroot -b -q "QAtrain_duo.C(\"_barrel\",${runNumber},\"wn.xml\",0,\"${ocdbPath}\")" &> ../qa_barrel_trusted.log
535 #move stuff to final destination
536 echo "this directory (${PWD}) contents:"
538 echo rm -f ./${chunkName}
540 echo "cp -R ${runpath}/* ${outputDir}"
541 cp -pf -R ${runpath}/* ${outputDir}
547 echo "dir ${outputDir}" >> ${doneFile}
548 if summarizeLogs >> ${doneFile}; then
549 [[ -f AliESDs_Barrel.root ]] && echo "esd ${outputDir}/AliESDs_Barrel.root" >> ${doneFile}
550 [[ -f AliESDfriends_v1.root ]] && echo "calibfile ${outputDir}/AliESDfriends_v1.root" >> ${doneFile}
551 [[ -f QAresults_Barrel.root ]] && echo "qafile ${outputDir}/QAresults_Barrel.root" >> ${doneFile}
552 [[ -f QAresults_Outer.root ]] && echo "qafile ${outputDir}/QAresults_Outer.root" >> ${doneFile}
553 [[ -f QAresults_barrel.root ]] && echo "qafile ${outputDir}/QAresults_barrel.root" >> ${doneFile}
554 [[ -f QAresults_outer.root ]] && echo "qafile ${outputDir}/QAresults_outer.root" >> ${doneFile}
555 [[ -f FilterEvents_Trees.root ]] && echo "filteredTree ${outputDir}/FilterEvents_Trees.root" >> ${doneFile}
557 if grep "qa_outer.log.*OK" ${doneFile} > /dev/null; then
558 [[ -f QAresults_Outer.root ]] && echo "qafile ${outputDir}/QAresults_Outer.root" >> ${doneFile}
559 [[ -f QAresults_outer.root ]] && echo "qafile ${outputDir}/QAresults_outer.root" >> ${doneFile}
561 if grep "qa_barrel.log.*OK" ${doneFile} > /dev/null; then
562 [[ -f QAresults_Barrel.root ]] && echo "qafile ${outputDir}/QAresults_Barrel.root" >> ${doneFile}
563 [[ -f QAresults_barrel.root ]] && echo "qafile ${outputDir}/QAresults_barrel.root" >> ${doneFile}
565 if grep "filtering.log.*OK" ${doneFile} > /dev/null; then
566 [[ -f FilterEvents_Trees.root ]] && echo "filteredTree ${outputDir}/FilterEvents_Trees.root" >> ${doneFile}
570 [[ "${runpath}" != "${outputDir}" ]] && rm -rf ${runpath}
578 # find the output files and merge them
585 calibrationFilesToMerge=${5} #can be a non-existent file, will then be produced on the fly
587 if ! parseConfig ${configFile} "$@"; then return 1; fi
589 #record the working directory provided by the batch system
590 batchWorkingDirectory=${PWD}
592 [[ -z ${commonOutputPath} ]] && commonOutputPath=${PWD}
593 doneFile="${commonOutputPath}/meta/merge.cpass0.run${runNumber}.done"
598 [[ -f ${alirootSource} && -z ${ALICE_ROOT} ]] && source ${alirootSource}
600 #runpath=${PWD}/rundir_cpass0_Merge_${runNumber}
602 #[[ ${reconstructInTemporaryDir} -eq 1 && -n ${TMPDIR} ]] && runpath=${TMPDIR}
603 [[ ${reconstructInTemporaryDir} -eq 1 ]] && runpath=$(mktemp -d -t mergeCPass0.XXXXXX)
606 if [[ ! -d ${runpath} ]]; then
608 echo "not able to make the runpath ${runpath}" >> ${doneFile}
611 if ! cd ${runpath}; then
613 echo "PWD=$PWD is not the runpath=${runpath}" >> ${doneFile}
617 logOutputDir=${runpath}
618 [[ -n ${logToFinalDestination} ]] && logOutputDir=${outputDir}
619 [[ -z ${dontRedirectStdOutToLog} ]] && exec &> ${logOutputDir}/stdout
622 mergingScript="mergeMakeOCDB.byComponent.sh"
624 echo goMergeCPass0 SETUP:
625 echo runNumber=${runNumber}
626 echo outputDir=${outputDir}
627 echo ocdbStorage=${ocdbStorage}
628 echo calibrationFilesToMerge=${calibrationFilesToMerge}
629 echo mergingScript=${mergingScript}
630 echo commonOutputPath=${commonOutputPath}
631 echo runpath=${runpath}
633 # copy files in case they are not already there
635 "${batchWorkingDirectory}/${calibrationFilesToMerge}"
636 "${batchWorkingDirectory}/OCDB.root"
637 "${batchWorkingDirectory}/localOCDBaccessConfig.C"
638 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.byComponent.sh"
639 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass0/mergeByComponent.C"
640 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass0/makeOCDB.C"
641 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass0/merge.C"
642 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.sh"
644 for file in ${filesMergeCPass0[*]}; do
645 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
646 [[ ${file##*/} =~ .*\.sh ]] && chmod +x ${file##*/}
649 sed -i '/.*root .*\.C/ s|\s*,\s*|,|g' *.sh
651 alirootInfo > ALICE_ROOT.log
661 chmod u+x ${mergingScript}
663 if [[ ! -f ${calibrationFilesToMerge} ]]; then
664 echo "/bin/ls -1 ${outputDir}/*/AliESDfriends_v1.root > ${calibrationFilesToMerge}"
665 /bin/ls -1 ${outputDir}/*/AliESDfriends_v1.root 2>/dev/null > ${calibrationFilesToMerge}
668 echo "${mergingScript} ${calibrationFilesToMerge} ${runNumber} local://./OCDB ${ocdbStorage}"
669 if [[ -n ${pretend} ]]; then
670 sleep ${pretendDelay}
671 touch CalibObjects.root
675 mkdir -p ./OCDB/TPC/Calib/TimeGain/
676 mkdir -p ./OCDB/TPC/Calib/TimeDrift/
677 echo "some calibration" >> ./OCDB/TPC/Calib/TimeGain/someCalibObject_0-999999_cpass0.root
678 echo "some calibration" >> ./OCDB/TPC/Calib/TimeDrift/otherCalibObject_0-999999_cpass0.root
680 ./${mergingScript} ${calibrationFilesToMerge} ${runNumber} "local://./OCDB" ${ocdbStorage} >> "mergeMakeOCDB.log"
682 #produce the calib trees for expert QA (dcsTime.root)
683 goMakeLocalOCDBaccessConfig ./OCDB
684 echo aliroot -b -q "${ALICE_ROOT}/PWGPP/TPC/macros/CalibSummary.C(${runNumber},\"${ocdbStorage}\")"
685 aliroot -b -q "${ALICE_ROOT}/PWGPP/TPC/macros/CalibSummary.C(${runNumber},\"${ocdbStorage}\")"
688 ### produce the output
689 #tar the produced OCDB for reuse
690 tar czf ${commonOutputPath}/meta/cpass0.localOCDB.${runNumber}.tgz ./OCDB
694 #copy all to output dir
695 cp -pf -R ${runpath}/* ${outputDir}
697 if [[ -n ${generateMC} ]]; then
698 goPrintValues sim ${commonOutputPath}/meta/sim.run${runNumber}.list ${commonOutputPath}/meta/cpass0.job*.run${runNumber}.done
701 #validate merging cpass0
704 echo "dir ${outputDir}" >> ${doneFile}
705 if summarizeLogs >> ${doneFile}; then
706 [[ -f CalibObjects.root ]] && echo "calibfile ${outputDir}/CalibObjects.root" >> ${doneFile}
707 [[ -f dcsTime.root ]] && echo "dcsTree ${outputDir}/dcsTime.root" >> ${doneFile}
710 [[ "${runpath}" != "${outputDir}" ]] && rm -rf ${runpath}
717 # find the output files and merge them
724 calibrationFilesToMerge=${5}
726 filteredFilesToMerge=${7}
728 if ! parseConfig ${configFile} "$@"; then return 1; fi
730 #record the working directory provided by the batch system
731 batchWorkingDirectory=${PWD}
733 [[ -z ${commonOutputPath} ]] && commonOutputPath=${PWD}
734 doneFile="${commonOutputPath}/meta/merge.cpass1.run${runNumber}.done"
740 rm -f ${outputDir}/*.log
741 rm -f ${outputDir}/*.root
742 rm -f ${outputDir}/*done
744 [[ -f ${alirootSource} && -z ${ALICE_ROOT} ]] && source ${alirootSource}
746 #runpath=${PWD}/rundir_cpass1_Merge_${runNumber}
748 #[[ ${reconstructInTemporaryDir} -eq 1 && -n ${TMPDIR} ]] && runpath=${TMPDIR}
749 [[ ${reconstructInTemporaryDir} -eq 1 ]] && runpath=$(mktemp -d -t mergeCPass1.XXXXXX)
752 if [[ ! -d ${runpath} ]]; then
754 echo "not able to make the runpath ${runpath}" >> ${doneFile}
757 if ! cd ${runpath}; then
759 echo "PWD=$PWD is not the runpath=${runpath}" >> ${doneFile}
763 logOutputDir=${runpath}
764 [[ -n ${logToFinalDestination} ]] && logOutputDir=${outputDir}
765 [[ -z ${dontRedirectStdOutToLog} ]] && exec &> ${logOutputDir}/mergeMakeOCDB.log
768 calibrationOutputFileName='AliESDfriends_v1.root'
769 qaOutputFileName='QAresults*.root'
770 mergingScript="mergeMakeOCDB.byComponent.sh"
771 #important to have the string "Stage.txt" in the filename to trigger the merging
772 #it has to be a list of directories containing the files
773 qaMergedOutputFileName="QAresults_merged.root"
775 echo goMergeCPass1 SETUP:
776 echo runNumber=${runNumber}
777 echo outputDir=${outputDir}
778 echo ocdbStorage=${ocdbStorage}
779 echo calibrationFilesToMerge=$calibrationFilesToMerge
780 echo qaFilesToMerge=$qaFilesToMerge
781 echo calibrationOutputFileName=${calibrationOutputFileName}
782 echo mergingScript=${mergingScript}
784 # copy files in case they are not already there
786 "${batchWorkingDirectory}/${calibrationFilesToMerge}"
787 "${batchWorkingDirectory}/${qaFilesToMerge}"
788 "${batchWorkingDirectory}/OCDB.root"
789 "${batchWorkingDirectory}/localOCDBaccessConfig.C"
790 "${commonOutputPath}/meta/cpass0.localOCDB.${runNumber}.tgz"
791 "${batchWorkingDirectory}/QAtrain_duo.C"
792 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass1/mergeMakeOCDB.byComponent.sh"
793 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass1/mergeByComponent.C"
794 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass1/makeOCDB.C"
795 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass1/merge.C"
796 "${ALICE_ROOT}/PWGPP/CalibMacros/CPass1/mergeMakeOCDB.sh"
797 "${trustedQAtrainMacro}"
798 "${ALICE_ROOT}/ANALYSIS/macros/QAtrain_duo.C"
800 for file in ${filesMergeCPass1[*]}; do
801 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
802 [[ ${file##*/} =~ .*\.sh ]] && chmod +x ${file##*/}
805 sed -i '/.*root .*\.C/ s|\s*,\s*|,|g' *.sh
807 #configure local OCDB storage from CPass0 (creates the localOCDBaccessConfig.C script)
808 if [[ -f cpass0.localOCDB.${runNumber}.tgz ]]; then
809 echo goMakeLocalOCDBaccessConfig "cpass0.localOCDB.${runNumber}.tgz"
810 goMakeLocalOCDBaccessConfig "cpass0.localOCDB.${runNumber}.tgz"
812 echo "WARNING: file cpass0.localOCDB.${runNumber}.tgz not found!"
815 alirootInfo > ALICE_ROOT.log
821 chmod u+x ${mergingScript}
824 #if not provided, create the lists of files to merge
825 if [[ ! -f ${filteredFilesToMerge} ]]; then
826 echo "/bin/ls -1 ${outputDir}/*/FilterEvents_Trees.root > ${filteredFilesToMerge}"
827 /bin/ls -1 ${outputDir}/*/FilterEvents_Trees.root 2>/dev/null > ${filteredFilesToMerge}
829 if [[ ! -f ${calibrationFilesToMerge} ]]; then
830 echo "/bin/ls -1 ${outputDir}/*/AliESDfriends_v1.root > ${calibrationFilesToMerge}"
831 /bin/ls -1 ${outputDir}/*/AliESDfriends_v1.root 2>/dev/null > ${calibrationFilesToMerge}
833 if [[ ! -f ${qaFilesToMerge} ]]; then
834 #find the files, but only store the directories (QAtrain_duo.C requires this)
835 echo "/bin/ls -1 ${outputDir}/*/QAresults*.root | while read x; do echo ${x%/*}; done | sort | uniq > ${qaFilesToMerge}"
836 /bin/ls -1 ${outputDir}/*/QAresults*.root | while read x; do echo ${x%/*}; done | sort | uniq > ${qaFilesToMerge}
839 echo "${mergingScript} ${calibrationFilesToMerge} ${runNumber} local://./OCDB ${ocdbStorage}"
840 if [[ -n ${pretend} ]]; then
841 sleep ${pretendDelay}
843 touch cpass1.localOCDB.${runNumber}.tgz
844 touch ${qaMergedOutputFileName}
847 touch FilterEvents_Trees.root
848 touch CalibObjects.root
850 touch ${qaMergedOutputFileName}
853 ./${mergingScript} ${calibrationFilesToMerge} ${runNumber} "local://./OCDB" ${ocdbStorage}
855 #merge QA (and filtered trees)
856 [[ -n ${AliAnalysisTaskFilteredTree_fLowPtTrackDownscaligF} ]] && export AliAnalysisTaskFilteredTree_fLowPtTrackDownscaligF
857 [[ -n ${AliAnalysisTaskFilteredTree_fLowPtV0DownscaligF} ]] && export AliAnalysisTaskFilteredTree_fLowPtV0DownscaligF
859 #echo aliroot -l -b -q "merge.C(\"${qaFilesToMerge}\",\"\",kFALSE,\"${qaMergedOutputFileName}\")"
860 echo aliroot -b -q "QAtrain_duo.C(\"_barrel\",${runNumber},\"${qaFilesToMerge}\",1,\"${ocdbStorage}\")"
861 #aliroot -l -b -q "merge.C(\"${qaFilesToMerge}\",\"\",kFALSE,\"${qaMergedOutputFileName}\")"
862 aliroot -b -q "QAtrain_duo.C(\"_barrel\",${runNumber},\"${qaFilesToMerge}\",1,\"${ocdbStorage}\")" > mergeQA.log
863 mv QAresults_barrel.root ${qaMergedOutputFileName}
864 mv trending_barrel.root trending.root
866 #merge filtered trees
867 echo aliroot -l -b -q "merge.C(\"${qaFilesToMerge}\",\"\",kFALSE,\"${qaMergedOutputFileName}\")"
868 aliroot -l -b -q "merge.C(\"${filteredFilesToMerge}\",\"\",kFALSE,\"FilterEvents_Trees.root\")" > mergeFilteredTrees.log
870 #produce the calib trees for expert QA
871 echo aliroot -b -q "${ALICE_ROOT}/PWGPP/TPC/macros/CalibSummary.C(${runNumber},\"${ocdbStorage}\")"
872 aliroot -b -q "${ALICE_ROOT}/PWGPP/TPC/macros/CalibSummary.C(${runNumber},\"${ocdbStorage}\")" > calibTree.log
875 tar czf ${commonOutputPath}/meta/cpass1.localOCDB.${runNumber}.tgz ./OCDB
879 #copy all to output dir
880 cp -pf -R ${runpath}/* ${outputDir}
882 #validate merge cpass1
885 echo "dir ${outputDir}" >> ${doneFile}
886 if summarizeLogs >> ${doneFile}; then
887 [[ -f CalibObjects.root ]] && echo "calibfile ${outputDir}/CalibObjects.root" >> ${doneFile}
888 [[ -f ${qaMergedOutputFileName} ]] && echo "qafile ${outputDir}/${qaMergedOutputFileName}" >> ${doneFile}
889 [[ -f trending.root ]] && echo "trendingfile ${outputDir}/trending.root" >> ${doneFile}
890 [[ -f dcsTime.root ]] && echo "dcsTree ${outputDir}/dcsTime.root" >> ${doneFile}
891 [[ -f FilterEvents_Trees.root ]] && echo "filteredTree ${outputDir}/FilterEvents_Trees.root" >> ${doneFile}
893 if grep "mergeQA.log.*OK" ${doneFile} > /dev/null; then
894 [[ -f ${qaMergedOutputFileName} ]] && echo "qafile ${outputDir}/${qaMergedOutputFileName}" >> ${doneFile}
896 if grep "mergeFilteredTrees.log.*OK" ${doneFile} > /dev/null; then
897 [[ -f FilterEvents_Trees.root ]] && echo "filteredTree ${outputDir}/FilterEvents_Trees.root" >> ${doneFile}
901 [[ "${runpath}" != "${outputDir}" ]] && rm -rf ${runpath}
907 #generic root merge using CPass1 merge.C script
910 configFile=${3-"benchmark.config"}
912 if ! parseConfig ${configFile} "$@"; then return 1; fi
914 #record the working directory provided by the batch system
915 batchWorkingDirectory=${PWD}
917 [[ ! -f ${inputList} ]] && echo "inputList ${inputList} does not exist!" && return 1
918 [[ ! -f ${configFile} ]] && echo "configFile ${configFile} does not exist!" && return 1
920 [[ -f ${alirootSource} && -z ${ALICE_ROOT} ]] && source ${alirootSource}
922 aliroot -b -q "${ALICE_ROOT}/PWGPP/CalibMacros/CPass0/merge.C(\"${inputList}\",\"\",kFALSE,\"${outputFile}\")" > merge_${inputList}.log
934 if ! parseConfig ${configFile} "${extraOpts[@]}"; then return 1; fi
936 #record the working directory provided by the batch system
937 batchWorkingDirectory=${PWD}
939 [[ -z ${configFile} ]] && configFile="benchmark.config"
940 [[ ! -f ${configFile} ]] && echo "no config file found (${configFile})" && return 1
942 if [[ ! $(which makeflow &>/dev/null) && -n ${makeflowPath} ]]; then
943 echo "setting the makflow path from the config: "
944 echo " export PATH=${makeflowPath}:${PATH}"
945 export PATH=${makeflowPath}:${PATH}
948 #create the common output dir and the meta dir
949 commonOutputPath=${baseOutputDirectory}/${productionID}
950 if [[ -d ${commonOutputPath} ]]; then
951 echo "output dir ${commonOutputPath} exists!"
954 mkdir -p ${commonOutputPath}
956 mkdir -p ${commonOutputPath}/meta
959 #if which greadlink; then self=$(greadlink -f "${0}"); fi
961 #for reference copy the setup to the output dir
962 cp ${self} ${commonOutputPath}
963 cp ${configFile} ${commonOutputPath}
964 cp ${inputFileList} ${commonOutputPath}
966 #submit - use makeflow if available, fall back to old stuff when makeflow not there
967 if which makeflow; then
968 goGenerateMakeflow ${productionID} ${inputFileList} ${configFile} "${extraOpts[@]}" commonOutputPath=${commonOutputPath} > benchmark.makeflow
969 cp benchmark.makeflow ${commonOutputPath}
970 makeflow ${makeflowOptions} benchmark.makeflow
979 #generate the makeflow file
980 [[ $# -lt 3 ]] && echo "args: id inputFileList configFile" && return 1
987 #batch systems/makeflow sometimes handle spaces in arguments poorly, so encode them
988 for (( i=0;i<${#extraOpts[@]};i++ )); do
989 extraOpts[i]=$(encSpaces "${extraOpts[i]}")
991 extraOpts+=("encodedSpaces=1")
993 if ! parseConfig ${configFile} "${extraOpts[@]}" &>/dev/null; then return 1; fi
996 if [[ -z ${commonOutputPath} ]]; then
997 commonOutputPath=${baseOutputDirectory}/${productionID}
998 extraOpts=( "${extraOpts[@]}" "commonOutputPath=${commonOutputPath}" )
1001 #record the working directory provided by the batch system
1002 batchWorkingDirectory=${PWD}
1004 [[ -z ${configFile} ]] && configFile="benchmark.config"
1005 [[ ! -f ${configFile} ]] && echo "no config file found (${configFile})" && return 1
1007 #these files will be made a dependency - will be copied to the working dir of the jobs
1008 declare -a copyFiles
1011 "localOCDBaccessConfig.C"
1015 "recCPass1_OuterDet.C"
1020 for file in ${inputFiles[*]}; do
1021 [[ -f ${file} ]] && copyFiles+=("${file}")
1024 #create the makeflow file
1025 [[ -n ${batchFlags} ]] && echo "BATCH_OPTIONS = ${batchFlags}"
1026 declare -A arr_cpass0_merged arr_cpass1_merged
1027 declare -A arr_cpass0_calib_list arr_cpass1_calib_list
1028 declare -A arr_cpass1_QA_list arr_cpass1_ESD_list arr_cpass1_filtered_list
1029 declare -A arr_cpass0_profiled_outputs
1030 declare -A listOfRuns
1031 [[ -n ${runNumber} ]] && listOfRuns[${runNumber}]=1
1032 while read x; do tmpRun=$(guessRunNumber ${x}); [[ -n ${tmpRun} ]] && listOfRuns[${tmpRun}]=1; done < ${inputFileList}
1033 for runNumber in "${!listOfRuns[@]}"; do
1034 [[ -z ${runNumber} ]] && continue
1035 [[ ! ${runNumber} =~ ^[0-9]*[0-9]$ ]] && continue
1037 unset arr_cpass0_outputs
1038 unset arr_cpass1_outputs
1039 declare -a arr_cpass0_outputs
1040 declare -a arr_cpass1_outputs
1044 while read inputFile; do
1045 currentDefaultOCDB=${defaultOCDB}
1046 [[ -z ${autoOCDB} ]] && autoOCDB=1
1047 if [[ ${autoOCDB} -ne 0 ]]; then
1048 currentDefaultOCDB=$(setYear ${inputFile} ${defaultOCDB})
1052 arr_cpass0_outputs[${jobindex}]="${commonOutputPath}/meta/cpass0.job${jobindex}.run${runNumber}.done"
1053 echo "${arr_cpass0_outputs[${jobindex}]} : benchmark.sh ${configFile} ${copyFiles[@]}"
1054 echo " ${alirootEnv} ./benchmark.sh CPass0 ${commonOutputPath}/000${runNumber}/cpass0 ${inputFile} ${nEvents} ${currentDefaultOCDB} ${configFile} ${runNumber} ${jobindex} ${extraOpts[@]}"" "
1057 arr_cpass1_outputs[${jobindex}]="${commonOutputPath}/meta/cpass1.job${jobindex}.run${runNumber}.done"
1058 echo "${arr_cpass1_outputs[${jobindex}]} : benchmark.sh ${configFile} ${commonOutputPath}/meta/cpass0.localOCDB.${runNumber}.tgz ${copyFiles[@]}"
1059 echo " ${alirootEnv} ./benchmark.sh CPass1 ${commonOutputPath}/000${runNumber}/cpass1 ${inputFile} ${nEvents} ${currentDefaultOCDB} ${configFile} ${runNumber} ${jobindex} ${extraOpts[@]}"" "
1062 done< <(grep "/000${runNumber}/" ${inputFileList})
1064 #CPass0 list of Calib files to merge
1065 arr_cpass0_calib_list[${runNumber}]="${commonOutputPath}/meta/cpass0.calib.run${runNumber}.list"
1066 echo "${arr_cpass0_calib_list[${runNumber}]} : benchmark.sh ${arr_cpass0_outputs[*]}"
1067 echo " ./benchmark.sh PrintValues calibfile ${arr_cpass0_calib_list[${runNumber}]} ${arr_cpass0_outputs[*]}"
1071 arr_cpass0_merged[${runNumber}]="${commonOutputPath}/meta/merge.cpass0.run${runNumber}.done"
1072 echo "${commonOutputPath}/meta/cpass0.localOCDB.${runNumber}.tgz ${arr_cpass0_merged[${runNumber}]} : benchmark.sh ${configFile} ${arr_cpass0_calib_list[${runNumber}]} ${copyFiles[@]}"
1073 echo " ${alirootEnv} ./benchmark.sh MergeCPass0 ${commonOutputPath}/000${runNumber}/cpass0 ${currentDefaultOCDB} ${configFile} ${runNumber} ${arr_cpass0_calib_list[${runNumber}]} ${extraOpts[@]}"" "
1075 #CPass1 list of Calib/QA/ESD/filtered files
1076 # the trick with QA is to have the string "Stage.txt" in the file name of the list of directories with QA output to trigger
1077 # the production of the QA trending tree (only then the task->Finish() will be called in QAtrain_duo.C, on the grid
1078 # this corresponds to the last merging stage)
1079 arr_cpass1_QA_list[${runNumber}]="${commonOutputPath}/meta/cpass1.QA.run${runNumber}.lastMergingStage.txt.list"
1080 echo "${arr_cpass1_QA_list[${runNumber}]}: benchmark.sh ${arr_cpass1_outputs[*]}"
1081 echo " ./benchmark.sh PrintValues dir ${arr_cpass1_QA_list[${runNumber}]} ${arr_cpass1_outputs[*]}"
1083 arr_cpass1_calib_list[${runNumber}]="${commonOutputPath}/meta/cpass1.calib.run${runNumber}.list"
1084 echo "${arr_cpass1_calib_list[${runNumber}]} : benchmark.sh ${arr_cpass1_outputs[*]}"
1085 echo " ./benchmark.sh PrintValues calibfile ${arr_cpass1_calib_list[${runNumber}]} ${arr_cpass1_outputs[*]};"
1087 arr_cpass1_ESD_list[${runNumber}]="${commonOutputPath}/meta/cpass1.ESD.run${runNumber}.list"
1088 echo "${arr_cpass1_ESD_list[${runNumber}]} : benchmark.sh ${arr_cpass1_outputs[*]}"
1089 echo " ./benchmark.sh PrintValues esd ${arr_cpass1_ESD_list[${runNumber}]} ${arr_cpass1_outputs[*]}"
1091 arr_cpass1_filtered_list[${runNumber}]="${commonOutputPath}/meta/cpass1.filtered.run${runNumber}.list"
1092 echo "${arr_cpass1_filtered_list[${runNumber}]} : benchmark.sh ${arr_cpass1_outputs[*]}"
1093 echo " ./benchmark.sh PrintValues filteredTree ${arr_cpass1_filtered_list[${runNumber}]} ${arr_cpass1_outputs[*]}"
1097 arr_cpass1_merged[${runNumber}]="${commonOutputPath}/meta/merge.cpass1.run${runNumber}.done"
1098 echo "${commonOutputPath}/meta/cpass1.localOCDB.${runNumber}.tgz ${arr_cpass1_merged[${runNumber}]} : benchmark.sh ${configFile} ${arr_cpass1_calib_list[${runNumber}]} ${arr_cpass1_QA_list[${runNumber}]} ${copyFiles[@]}"
1099 echo " ${alirootEnv} ./benchmark.sh MergeCPass1 ${commonOutputPath}/000${runNumber}/cpass1 ${currentDefaultOCDB} ${configFile} ${runNumber} ${arr_cpass1_calib_list[${runNumber}]} ${arr_cpass1_QA_list[${runNumber}]} ${arr_cpass1_filtered_list[${runNumber}]} ${extraOpts[@]}"" "
1101 #CPass0 wrapped in a profiling tool (valgrind,....)
1102 if [[ -n ${profilingCommand} ]]; then
1103 inputFile=$(grep -m1 "${runNumber}/" ${inputFileList})
1104 [[ -z ${nEventsProfiling} ]] && nEventsProfiling=2
1105 currentDefaultOCDB=$(setYear ${inputFile} ${defaultOCDB})
1106 jobindex="profiling"
1108 arr_cpass0_profiled_outputs[${runNumber}]="${commonOutputPath}/meta/profiling.cpass0.job${jobindex}.run${runNumber}.done"
1109 echo "${arr_cpass0_profiled_outputs[${runNumber}]} : benchmark.sh ${configFile} ${copyFiles[@]}"
1110 profilingCommand=$(encSpaces "${profilingCommand}")
1111 echo " ${alirootEnv} ./benchmark.sh CPass0 ${commonOutputPath}/000${runNumber}/${jobindex} ${inputFile} ${nEventsProfiling} ${currentDefaultOCDB} ${configFile} ${runNumber} ${jobindex} ${extraOpts[@]} useProfilingCommand=${profilingCommand}"
1117 echo "${commonOutputPath}/summary.log : benchmark.sh ${configFile} ${arr_cpass1_merged[*]}"
1118 echo " ${alirootEnv} ./benchmark.sh MakeSummary ${configFile} ${extraOpts[@]}"
1126 #print the values given the key from any number of files (store in output file on second argument)
1127 if [[ $# -lt 3 ]]; then
1128 echo "goPrintValues key outputFile inputFiles"
1129 echo "if outputFile is \"-\" dont redirect to a file"
1134 [[ ${outputFile} =~ "-" ]] && outputFile=""
1135 shift 2 #remove 2 first arguments from arg list to only pass the input files to awk
1136 awk -v key=${key} '$0 ~ key" " {print $2}' "$@" | tee ${outputFile}
1143 mergedQAfileList=${1}
1148 if ! parseConfig ${configFile} "$@"; then return 1; fi
1150 #record the working directory provided by the batch system
1151 batchWorkingDirectory=${PWD}
1153 [[ -f ${alirootSource} && -z ${ALICE_ROOT} ]] && source ${alirootSource}
1155 [[ -z ${logOutputDir} ]] && logOutputDir=${PWD}
1156 [[ -z ${dontRedirectStdOutToLog} ]] && exec &> ${logOutputDir}/makeQAplots.log
1160 mkdir -p ${outputDir}
1162 [[ ! "${PWD}" =~ "${outputDir}" ]] && echo "PWD is not equal to outputDir=${outputDir}" && cd ${olddir} && return 1
1164 if [[ -z ${pretend} ]]; then
1165 ${ALICE_ROOT}/PWGPP/QA/scripts/runQA.sh inputList="${mergedQAfileList}" inputListHighPtTrees="${filteringList}" ocdbStorage=${defaultOCDB}
1167 touch pretendCreateQAplots.done
1181 # save aliroot repository info
1182 [[ -z "${ALICE_ROOT}" ]] && return 1
1184 echo "\${ALICE_ROOT}=${ALICE_ROOT}"
1185 echo "\${ROOTSYS}=${ROOTSYS}"
1186 echo "\${PATH}=${PATH}"
1187 echo "\${LD_LIBRARY_PATH}=${LD_LIBRARY_PATH}"
1193 currentBranch=$(git rev-parse --abbrev-ref HEAD)
1197 git diff ${currentBranch}
1205 # ${1} - year to be set
1206 # ${2} - where to set the year
1207 year1=$(guessYear ${1})
1208 year2=$(guessYear ${2})
1210 [[ ${year1} -ne ${year2} && -n ${year2} && -n ${year1} ]] && path=${2/\/${year2}\//\/${year1}\/}
1217 #guess the period from the path, pick the rightmost one
1219 declare -a path=( ${1} )
1220 local dirDepth=${#path[*]}
1221 for ((x=${dirDepth}-1;x>=0;x--)); do
1222 local field=${path[${x}]}
1223 [[ ${field} =~ ^LHC[0-9][0-9][a-z]$ ]] && period=${field} && break
1231 #guess the year from the path, pick the rightmost one
1233 declare -a path=( ${1} )
1234 local dirDepth=${#path[*]}
1235 for ((x=${dirDepth}-1;x>=0;x--)); do
1236 local field=${path[${x}]}
1237 [[ ${field} =~ ^20[0-9][0-9]$ ]] && year=${field} && break
1245 #guess the run number from the path, pick the rightmost one
1246 #works for /path/foo/000123456/bar/...
1247 #and /path/foo.run123456.bar
1249 declare -a path=( ${1} )
1250 local dirDepth=${#path[*]}
1251 for ((x=${dirDepth}-1;x>=0;x--)); do
1252 local field=${path[${x}]}
1253 field=${field/run/000}
1254 [[ ${field} =~ [0-9][0-9][0-9][0-9][0-9][0-9]$ ]] && runNumber=${field#000} && break
1266 'error while loading shared libraries'
1269 'Thread [0-9]* (Thread'
1272 '\.C.*error:.*\.h: No such file'
1278 'rocVoltage out of range:'
1282 local errorSummary=""
1283 local warningSummary=""
1285 for ((i=0; i<${#errorConditions[@]};i++)); do
1286 local tmp=$(grep -m1 -e "${errorConditions[${i}]}" ${log})
1287 [[ -n ${tmp} ]] && tmp+=" : "
1288 errorSummary+=${tmp}
1291 for ((i=0; i<${#warningConditions[@]};i++)); do
1292 local tmp=$(grep -m1 -e "${warningConditions[${i}]}" ${log})
1293 [[ -n ${tmp} ]] && tmp+=" : "
1294 warningSummary+=${tmp}
1297 if [[ -n ${errorSummary} ]]; then
1298 echo "${errorSummary}"
1302 if [[ -n ${warningSummary} ]]; then
1303 echo "${warningSummary}"
1312 #print a summary of logs
1321 for log in ${logFiles[*]}; do
1322 finallog=${PWD%/}/${log}
1323 [[ ! -f ${log} ]] && continue
1324 errorSummary=$(validateLog ${log})
1326 if [[ ${validationStatus} -eq 0 ]]; then
1327 #in pretend mode randomly report an error in rec.log some cases
1328 if [[ -n ${pretend} && "${log}" == "rec.log" ]]; then
1329 #[[ $(( ${RANDOM}%2 )) -ge 1 ]] && echo "${finallog} BAD random error" || echo "${finallog} OK"
1330 echo "${finallog} OK"
1332 echo "${finallog} OK"
1334 elif [[ ${validationStatus} -eq 1 ]]; then
1335 echo "${finallog} BAD ${errorSummary}"
1337 elif [[ ${validationStatus} -eq 2 ]]; then
1338 echo "${finallog} OK MWAH ${errorSummary}"
1346 gdb --batch --quiet -ex "bt" -ex "quit" aliroot ${x} > stacktrace_${x//\//_}.log
1347 done < <(/bin/ls ${PWD}/*/core 2>/dev/null; /bin/ls ${PWD}/core 2>/dev/null)
1352 spitOutLocalOCDBaccessConfig()
1355 #find ${1} -name "*root" | \
1356 /bin/ls -1 ${1}/*/*/*/*.root 2>/dev/null | \
1359 local tmp=${line#${1}}
1361 awk -v ocdb=${1} '{print " man->SetSpecificStorage(\""$1"\",\"local://"ocdb"\");"}'
1366 goMakeLocalOCDBaccessConfig()
1369 # make a script that sets the specific storages form all the root files produced by CPass0
1370 local localOCDBpathCPass0=${1}
1371 local OCDBpathPrefix=${2}
1372 [[ -z ${OCDBpathPrefix} ]] && OCDBpathPrefix="."
1374 if [[ -f ${localOCDBpathCPass0} && ${localOCDBpathCPass0} =~ \.tgz$ ]]; then
1375 tar xzf ${localOCDBpathCPass0}
1376 local localOCDBpathCPass0="${OCDBpathPrefix}/OCDB"
1380 echo creating the specific storage script
1381 echo localOCDBaccessConfig.C
1382 echo based on OCDB: ${localOCDBaccessConfig}
1385 local tempLocalOCDB=""
1386 if [[ -f localOCDBaccessConfig.C ]]; then
1387 tempLocalOCDB=$(mktemp -t tempLocalOCDB.XXXXXX)
1388 echo "egrep "SetSpecificStorage" localOCDBaccessConfig.C > ${tempLocalOCDB}"
1389 egrep "SetSpecificStorage" localOCDBaccessConfig.C > ${tempLocalOCDB}
1392 echo "localOCDBaccessConfig()" > localOCDBaccessConfig.C
1393 echo "{" >> localOCDBaccessConfig.C
1394 echo " AliCDBManager* man = AliCDBManager::Instance();" >> localOCDBaccessConfig.C
1395 spitOutLocalOCDBaccessConfig ${localOCDBpathCPass0}|sort|uniq >> localOCDBaccessConfig.C
1396 [[ -f "${tempLocalOCDB}" ]] && cat ${tempLocalOCDB} >> localOCDBaccessConfig.C
1397 echo "}" >> localOCDBaccessConfig.C
1399 [[ -f "${tempLocalOCDB}" ]] && rm -f ${tempLocalOCDB}
1401 if ! grep SetSpecificStorage localOCDBaccessConfig.C; then
1403 echo "!!!!!!! CPass0 produced no OCDB entries"
1409 goMakeFilteredTrees()
1413 #get path to input list
1415 #get scale number for tracks
1417 #get scale number for V0s
1419 #get OCDB path (optional)
1421 #get max number of files
1422 maxFiles=${7-"1000000"}
1423 #get offset of first file
1425 #get max number of events
1426 maxEvents=${9-"30000000"}
1427 #get offset of first event
1428 offsetEvent=${10-"0"}
1429 configFile=${11-"benchmark.config"}
1430 esdFileName=${12-"AliESDs_Barrel.root"}
1432 if ! parseConfig ${configFile} "$@"; then return 1; fi
1434 #record the working directory provided by the batch system
1435 batchWorkingDirectory=${PWD}
1437 [[ -z ${commonOutputPath} ]] && commonOutputPath=${PWD}
1438 doneFile=${commonOutputPath}/meta/filtering.cpass1.run${runNumber}.done
1440 cat > filtering.log << EOF
1441 goMakeFilteredTrees config:
1443 outputDir=${outputDir}
1444 commonOutputPath=${commonOutputPath}
1445 ALICE_ROOT=${ALICE_ROOT}
1447 offsetEvent=$offsetEvent
1448 configFile=$configFile
1449 esdFileName=$esdFileName
1450 inputListfiles=$inputListfiles
1454 #runpath=${outputDir}
1455 #[[ ${reconstructInTemporaryDir} -eq 1 && -n ${TMPDIR} ]] && runpath=${TMPDIR}
1456 #[[ ${reconstructInTemporaryDir} -eq 1 ]] && runpath=$(mktemp -d -t goMakeFilteredTrees.XXXXXX)
1457 #mkdir -p ${outputDir}
1458 #mkdir -p ${runpath}
1459 #if ! cd ${runpath}; then
1460 # echo "PWD=$PWD is not the runpath=${runpath}"
1465 if [[ -z ${pretend} ]];then
1466 aliroot -l -b -q "${ALICE_ROOT}/PWGPP/macros/runFilteringTask.C(\"${inputListfiles}\",${filterT},${filterV},\"${OCDBpath}\",${maxFiles},${offsetFile},${maxEvents},${offsetEvent},\"${esdFileName}\")" &>> filtering.log
1468 sleep ${pretendDelay}
1469 touch filtering.log FilterEvents_Trees.root
1474 summarizeLogs >> ${doneFile}
1476 #echo mv -f * ${outputDir}
1477 #mv -f * ${outputDir}
1478 #[[ -f ${outputDir}/FilterEvents_Trees.root ]] && echo "filteredTree ${outputDir}/FilterEvents_Trees.root" >> ${doneFile}
1479 #cd ${commonOutputPath}
1480 #[[ "${runpath}" != "${outputDir}" ]] && rm -rf ${runpath}
1488 [[ $# -lt 5 ]] && echo "at least 5 args needed, you supplied $#" && return 1
1495 local commandArgs=("$@")
1497 #add quote strings around the extra arguments
1498 for ((i=0; i<${#commandArgs[@]}; i++)); do
1499 commandArgs[i]=\"${commandArgs[i]}\"
1502 [[ -z ${waitForJOBID} ]] && waitForJOBID=0
1504 newFarm=$(which qsub|grep "^/usr/bin/qsub")
1508 if [[ -z "${newFarm}" ]]
1511 # submit it (as job array)
1512 nFiles=$(( ${endID}-${startID}+1 ))
1513 while [ ${startID} -le ${nFiles} ] ; do
1514 if [ $(expr ${nFiles} - ${startID}) -gt 999 ] ; then
1515 endID=$(expr ${startID} + 999)
1519 if [[ ${waitForJOBID} -eq 0 ]]; then
1520 echo ${batchCommand} ${batchFlags} -J "${JobID}[${startID}-${endID}]" -e "${commonOutputPath}/logs/job_%I.err" -o "${commonOutputPath}/logs/job_%I.out" "${command}"
1521 ${batchCommand} ${batchFlags} -J "${JobID}[${startID}-${endID}]" -e "${commonOutputPath}/logs/job_%I.err" -o "${commonOutputPath}/logs/job_%I.out" "${command}"
1523 echo ${batchCommand} ${batchFlags} -J "${JobID}[${startID}-${endID}]" -w "ended(${waitForJOBID})" -e "${commonOutputPath}/logs/job_%I.err" -o "${commonOutputPath}/logs/job_%I.out" "${command}"
1524 ${batchCommand} ${batchFlags} -J "${JobID}[${startID}-${endID}]" -w "ended(${waitForJOBID})" -e "${commonOutputPath}/logs/job_%I.err" -o "${commonOutputPath}/logs/job_%I.out" "${command}"
1526 startID=$(expr ${endID} + 1)
1530 if [[ ${waitForJOBID} =~ "000" ]]; then
1531 echo ${batchCommand} ${batchFlags} -wd ${commonOutputPath} -b y -v commonOutputPath -N "${JobID}" -t "${startID}-${endID}" -e "${commonOutputPath}/logs/" -o "${commonOutputPath}/logs/" "${command}" "${commandArgs[@]}"
1532 ${batchCommand} ${batchFlags} -wd ${commonOutputPath} -b y -v commonOutputPath -N "${JobID}" -t "${startID}-${endID}" -e "${commonOutputPath}/logs/" -o "${commonOutputPath}/logs/" "${command}" "${commandArgs[@]}"
1534 echo ${batchCommand} ${batchFlags} -wd ${commonOutputPath} -b y -v commonOutputPath -N "${JobID}" -t "${startID}-${endID}" -hold_jid "${waitForJOBID}" -e "${commonOutputPath}/logs/" -o "${commonOutputPath}/logs/" "${command}" "${commandArgs[@]}"
1535 ${batchCommand} ${batchFlags} -wd ${commonOutputPath} -b y -v commonOutputPath -N "${JobID}" -t "${startID}-${endID}" -hold_jid "${waitForJOBID}" -e "${commonOutputPath}/logs/" -o "${commonOutputPath}/logs/" "${command}" "${commandArgs[@]}"
1543 if [[ $# -lt 3 ]]; then
1545 echo " ${0} submit fileList productionID configFile"
1551 configFile=${3:-"benchmark.config"}
1552 #if which greadlink; then configFile=$(greadlink -f ${configFile}); fi
1555 if ! parseConfig ${configFile} "${extraOpts[@]}"; then return 1; fi
1557 #batch systems/makeflow sometimes handle spaces in arguments poorly, so encode them
1558 for (( i=0;i<${#extraOpts[@]};i++ )); do
1559 extraOpts[i]=$(encSpaces "${extraOpts[i]}")
1561 extraOpts+=("encodedSpaces=1")
1563 #record the working directory provided by the batch system
1564 batchWorkingDirectory=${PWD}
1566 #redirect all output to submit.log
1567 echo "redirecting all output to ${PWD}/submit_${productionID//"/"/_}.log"
1569 exec 1>submit_${productionID//"/"/_}.log 2>&1
1572 echo ${0}" submit $*"
1573 if [[ -z "${inputList}" || -z "${productionID}" ]]
1576 echo " Usage: ${0} submit inputList productionID [configFile=benchmark.config]"
1581 # check if config file is there
1582 if [ ! -f ${configFile} ]; then
1583 echo "ERROR! Config File '${configFile}' not found" >&2
1586 echo "Using Config File: '${configFile}'"
1589 [[ ! -f ${alirootEnv} ]] && echo "alirootEnv script ${alirootEnv} not found!..." && return 1
1591 #move the script, config and some other stuff to ${commonOutputPath} first, then use them from there
1593 #if which greadlink; then self=$(greadlink -f "${0}"); fi
1594 configPath=$(dirname ${configFile})
1595 export commonOutputPath=${baseOutputDirectory}/${productionID}
1597 mkdir -p ${commonOutputPath}
1598 mkdir -p ${commonOutputPath}/logs
1599 mkdir -p ${commonOutputPath}/meta
1601 cp ${self} ${commonOutputPath}
1602 cp ${configFile} ${commonOutputPath}
1603 cp ${inputList} ${commonOutputPath}
1604 self=${commonOutputPath}/${self##*/}
1606 configFile=${commonOutputPath}/${configFile##*/}
1607 inputList=${commonOutputPath}/${inputList##*/}
1609 #convert to absolut pathnames
1610 #if which greadlink; then inputList=$(greadlink -f "${inputList}"); fi
1612 if [[ -z ${runNumber} ]]; then
1613 listOfRuns=($(while read x; do guessRunNumber ${x}; done < ${inputList} | sort | uniq))
1615 listOfRuns=${runNumber}
1618 #if which greadlink; then alirootSource=$(greadlink -f "${alirootSource}"); fi
1621 echo "### BEGIN CONFIGURATION ###"
1625 echo " productionID: ${productionID}"
1626 echo " batchCommand: ${batchCommand}"
1627 echo " batchFlags: ${batchFlags}"
1628 echo " alirootEnv: ${alirootEnv}"
1629 ${alirootEnv} echo ' ALICE_ROOT: ${ALICE_ROOT}'
1630 ${alirootEnv} echo ' ALIROOT_RELEASE: ${ALICE_RELEASE}'
1631 echo " inputList: ${inputList}"
1632 echo " configPath: ${configPath}"
1633 echo " commonOutputPath: ${commonOutputPath}"
1634 echo " defaultOCDB: ${defaultOCDB}"
1635 echo " autoOCDB: ${autoOCDB}"
1636 echo " recoTriggerOptions: ${recoTriggerOptions}"
1638 echo " ${listOfRuns[*]}"
1640 echo "THE TRAIN WILL RUN:"
1642 if [ ${runCPass0reco} -eq 1 ]; then
1643 echo " Pass0 - Recontruction"
1646 if [ ${runCPass0MergeMakeOCDB} -eq 1 ]; then
1647 echo " Pass0 - merging and OCDB export"
1650 if [ ${runCPass1reco} -eq 1 ]; then
1651 echo " Pass1 - Recontruction"
1653 if [ ${runCPass1MergeMakeOCDB} -eq 1 ]; then
1654 echo " Pass1 - merging and OCDB export"
1659 echo " max. Events/Chunk: ${nEvents}"
1660 echo " max. Number of Chunks per Run: ${nMaxChunks}"
1662 echo "### END CONFIGURATION ###"
1666 # check if input file is there
1667 if [ ! -f ${inputList} ]; then
1668 echo "ERROR! Input List '${inputList}' not found" >&2
1672 # define jobid (for dependent jobs)
1673 date=$(date +%Y_%m_%d_%H%M%S)
1674 #for each run we submit one jobarray:
1675 for runNumber in ${listOfRuns[*]}; do
1677 [[ -z ${runNumber} ]] && continue
1678 [[ ! ${runNumber} =~ ^[0-9]*[0-9]$ ]] && continue
1680 JOBpostfix="${productionID//"/"/_}_${runNumber}_${date}"
1681 JOBID1="p0_${JOBpostfix}"
1682 JOBID1wait="w0_${JOBpostfix}"
1683 JOBID2="m0_${JOBpostfix}"
1684 JOBID2wait="wm0_${JOBpostfix}"
1685 JOBID3="op0_${JOBpostfix}"
1686 JOBID3wait="wop0_${JOBpostfix}"
1687 JOBID4="p1_${JOBpostfix}"
1688 JOBID4wait="w1_${JOBpostfix}"
1689 JOBID5="m1_${JOBpostfix}"
1690 JOBID5wait="wm1_${JOBpostfix}"
1691 JOBID6="s1_${JOBpostfix}"
1692 JOBID6wait="ws1_${JOBpostfix}"
1693 JOBID7="QA_${JOBpostfix}"
1694 JOBmakeESDlistCPass1="lp1_${JOBpostfix}"
1695 JOBfilterESDcpass1="fp1_${JOBpostfix}"
1698 oneInputFile=$(egrep -m1 "${runNumber}/" ${inputList})
1700 currentDefaultOCDB=${defaultOCDB}
1701 [[ -z ${autoOCDB} ]] && autoOCDB=1
1702 if [[ ${autoOCDB} -ne 0 ]]; then
1703 currentDefaultOCDB=$(setYear ${oneInputFile} ${defaultOCDB})
1706 echo "submitting run ${runNumber} with OCDB ${currentDefaultOCDB}"
1708 ###############################################################################
1709 #run one chunk with valgrind:
1710 if [[ -n ${profilingCommand} ]]; then
1711 [[ -z ${nEventsProfiling} ]] && nEventsProfiling=2
1712 [[ -z ${profilingCommand} ]] && profilingCommand="/usr/bin/valgrind --tool=callgrind --num-callers=40 -v --trace-children=yes"
1713 submit "profile-${JOBpostfix}" 1 1 000 "${alirootEnv} ${self}" CPass0 ${commonOutputPath}/000${runNumber}/${jobindex} ${oneInputFile} ${nEventsProfiling} ${currentDefaultOCDB} ${configFile} ${runNumber} ${jobindex} useProfilingCommand=$(encSpaces "${profilingCommand}") "${extraOpts[@]}"
1716 ################################################################################
1717 ################################################################################
1718 # run the CPass0 if requested
1720 if [ ${runCPass0reco} -eq 1 ]; then
1723 echo "starting CPass0... for run ${runNumber}"
1726 # create directory and copy all files that are needed
1727 targetDirectory="${commonOutputPath}/000${runNumber}/cpass0"
1728 mkdir -p ${targetDirectory}
1731 "${configPath}/runCPass0.sh"
1732 "${configPath}/recCPass0.C"
1733 "${configPath}/runCalibTrain.C"
1734 "${configPath}/localOCDBaccessConfig.C"
1735 "${configPath}/OCDB*.root"
1736 "${configPath}/sim.C"
1737 "${configPath}/rec.C"
1738 "${configPath}/Config.C"
1740 for file in ${filesCPass0[*]}; do
1741 [[ -f ${file} ]] && echo "copying ${file}" && cp -f ${file} ${commonOutputPath}
1744 localInputList=${targetDirectory}/${inputList##*/}
1745 [[ ! -f ${localInputList} ]] && egrep "\/000${runNumber}\/" ${inputList} > ${localInputList}
1746 # limit nFiles to nMaxChunks
1747 nFiles=$(wc -l < ${localInputList})
1748 [[ ${nFiles} -eq 0 ]] && echo "list contains ZERO files! exiting..." && return 1
1749 echo "raw files in list: ${nFiles}"
1750 if [[ ${nMaxChunks} -gt 0 && ${nMaxChunks} -le ${nFiles} ]]; then
1751 nFiles=${nMaxChunks}
1753 echo "raw files to process: ${nFiles}"
1754 [[ -z "${percentProcessedFilesToContinue}" ]] && percentProcessedFilesToContinue=100
1755 if [[ ${percentProcessedFilesToContinue} -eq 100 ]]; then
1756 nFilesToWaitFor=${nFiles}
1758 nFilesToWaitFor=$(( ${nFiles}-${nFiles}/(100/(100-${percentProcessedFilesToContinue})) ))
1760 echo "requested success rate is ${percentProcessedFilesToContinue}%"
1761 echo "merging will start after ${nFilesToWaitFor} jobs are done"
1763 submit ${JOBID1} 1 ${nFiles} 000 "${alirootEnv} ${self}" CPass0 ${targetDirectory} ${localInputList} ${nEvents} ${currentDefaultOCDB} ${configFile} ${runNumber} -1 "${extraOpts[@]}"
1765 ## submit a monitoring job that will run until a certain number of jobs are done with reconstruction
1766 submit "${JOBID1wait}" 1 1 000 "${alirootEnv} ${self}" WaitForOutput ${commonOutputPath} "meta/cpass0.job*.run${runNumber}.done" ${nFilesToWaitFor} ${maxSecondsToWait}
1767 LASTJOB=${JOBID1wait}
1769 fi #end running CPass0
1770 ################################################################################
1773 ################################################################################
1774 # submit merging of CPass0, depends on the reconstruction
1776 if [ ${runCPass0MergeMakeOCDB} -eq 1 ]; then
1779 echo "submit CPass0 merging for run ${runNumber}"
1782 targetDirectory="${commonOutputPath}/000${runNumber}/cpass0"
1783 mkdir -p ${targetDirectory}
1787 "${configPath}/OCDB.root"
1788 "${configPath}/mergeMakeOCDB.byComponent.sh"
1789 "${configPath}/mergeMakeOCDB.sh"
1790 "${configPath}/localOCDBaccessConfig.C"
1791 "${configPath}/mergeByComponent.C"
1792 "${configPath}/makeOCDB.C"
1793 "${configPath}/merge.C"
1795 for file in ${filesMergeCPass0[*]}; do
1796 [[ -f ${file} ]] && echo "copying ${file}" && cp -f ${file} ${commonOutputPath}
1799 submit ${JOBID2} 1 1 "${LASTJOB}" "${alirootEnv} ${self}" MergeCPass0 ${targetDirectory} ${currentDefaultOCDB} ${configFile} ${runNumber} cpass0.calib.run${runNumber}.list "${extraOpts[@]}"
1802 if [[ -n ${generateMC} ]]; then
1803 submit "mrl${JOBpostfix}" 1 1 "${LASTJOB}" "${alirootEnv} ${self}" PrintValues sim ${commonOutputPath}/meta/sim.run${runNumber}.list ${commonOutputPath}/meta/cpass0.job*.run${runNumber}.done
1804 LASTJOB="mrl${JOBpostfix}"
1809 # end of merging CPass0
1810 ################################################################################
1812 ################################################################################
1813 ################################################################################
1814 # run the CPass1 if requested
1816 if [ ${runCPass1reco} -eq 1 ]; then
1818 targetDirectory="${commonOutputPath}/000${runNumber}/cpass1"
1819 rm -f ${commonOutputPath}/meta/cpass1.job*.run${runNumber}.done
1821 # safety feature: if we are re-running for any reason we want to delete the previous output first.
1822 [[ -d ${targetDirectory} ]] && rm -rf ${targetDirectory}/* && echo "removed old output at ${targetDirectory}/*"
1825 echo "starting CPass1... for run ${runNumber}"
1828 # create directory and copy all files that are needed
1829 mkdir -p ${targetDirectory}
1832 "${configPath}/runCPass1.sh"
1833 "${configPath}/recCPass1.C"
1834 "${configPath}/recCPass1_OuterDet.C"
1835 "${configPath}/runCalibTrain.C"
1836 "${configPath}/QAtrain_duo.C"
1837 "${configPath}/localOCDBaccessConfig.C"
1838 "${configPath}/OCDB.root"
1840 for file in ${filesCPass1[*]}; do
1841 [[ -f ${file} ]] && echo "copying ${file}" && cp -f ${file} ${commonOutputPath}
1844 if [[ -n ${generateMC} ]]; then
1845 localInputList=${commonOutputPath}/meta/sim.run${runNumber}.list
1847 localInputList=${targetDirectory}/${inputList##*/}
1848 [[ ! -f ${localInputList} ]] && egrep "\/000${runNumber}\/" ${inputList} > ${localInputList}
1850 # limit nFiles to nMaxChunks
1851 nFiles=$(wc -l < ${localInputList})
1852 [[ ${nFiles} -eq 0 ]] && echo "list contains ZERO files! continuing..." && continue
1853 echo "raw files in list: ${nFiles}"
1854 if [[ ${nMaxChunks} -gt 0 && ${nMaxChunks} -le ${nFiles} ]]; then
1855 nFiles=${nMaxChunks}
1857 echo "raw files to process: ${nFiles}"
1858 [[ -z "${percentProcessedFilesToContinue}" ]] && percentProcessedFilesToContinue=100
1859 if [[ ${percentProcessedFilesToContinue} -eq 100 ]]; then
1860 nFilesToWaitFor=${nFiles}
1862 nFilesToWaitFor=$(( ${nFiles}-${nFiles}/(100/(100-${percentProcessedFilesToContinue})) ))
1864 echo "requested success rate is ${percentProcessedFilesToContinue}%"
1865 echo "merging will start after ${nFilesToWaitFor} jobs are done"
1867 submit ${JOBID4} 1 ${nFiles} "${LASTJOB}" "${alirootEnv} ${self}" CPass1 ${targetDirectory} ${localInputList} ${nEvents} ${currentDefaultOCDB} ${configFile} ${runNumber} -1 "${extraOpts[@]}"
1869 ################################################################################
1870 ## submit a monitoring job that will run until a certain number of jobs are done with reconstruction
1871 submit "${JOBID4wait}" 1 1 "${LASTJOB}" "${alirootEnv} ${self}" WaitForOutput ${commonOutputPath} "meta/cpass1.job*.run${runNumber}.done" ${nFilesToWaitFor} ${maxSecondsToWait}
1872 LASTJOB=${JOBID4wait}
1873 ################################################################################
1876 fi #end running CPass1
1878 ################################################################################
1879 # submit merging of CPass1, depends on the reconstruction
1880 if [ ${runCPass1MergeMakeOCDB} -eq 1 ]; then
1883 echo "submit CPass1 merging for run ${runNumber}"
1886 targetDirectory="${commonOutputPath}/000${runNumber}/cpass1"
1887 rm -f ${commonOutputPath}/meta/merge.cpass1.run${runNumber}.done
1888 mkdir -p ${targetDirectory}
1892 "${configPath}/OCDB.root"
1893 "${configPath}/localOCDBaccessConfig.C"
1894 "${configPath}/mergeMakeOCDB.byComponent.sh"
1895 "${configPath}/mergeByComponent.C"
1896 "${configPath}/makeOCDB.C"
1897 "${configPath}/merge.C"
1898 "${configPath}/mergeMakeOCDB.sh"
1899 "${configPath}/QAtrain_duo.C"
1901 for file in ${filesMergeCPass1[*]}; do
1902 [[ -f ${file} ]] && echo "copying ${file}" && cp -f ${file} ${commonOutputPath}
1905 submit "${JOBID5}" 1 1 "${LASTJOB}" "${alirootEnv} ${self}" MergeCPass1 ${targetDirectory} ${currentDefaultOCDB} ${configFile} ${runNumber} cpass1.calib.run${runNumber}.list cpass1.QA.run${runNumber}.lastMergingStage.txt.list cpass1.filtered.run${runNumber}.list "${extraOpts[@]}"
1910 ###############################
1911 #if [ ${runESDfiltering} -eq 1 ]; then
1912 # rm -f ${commonOutputPath}/cpass1.ESD.run${runNumber}.list
1913 # rm -f ${commonOutputPath}/meta/filtering.cpass1.run*.done
1915 # echo submitting filtering for run ${runNumber}
1917 # submit "${JOBmakeESDlistCPass1}" 1 1 "${LASTJOB}" "${self}" PrintValues esd ${commonOutputPath}/meta/cpass1.ESD.run${runNumber}.list ${commonOutputPath}/meta/cpass1.job*.run${runNumber}.done
1918 # submit "${JOBfilterESDcpass1}" 1 1 "${JOBmakeESDlistCPass1}" "${alirootEnv} ${self}" MakeFilteredTrees ${commonOutputPath}/000${runNumber}/cpass1 ${runNumber} ${commonOutputPath}/meta/cpass1.ESD.run${runNumber}.list ${filteringFactorHighPt} ${filteringFactorV0s} ${currentDefaultOCDB} 1000000 0 10000000 0 ${configFile} AliESDs_Barrel.root "${extraOpts[@]}"
1919 # LASTJOB=${JOBfilterESDcpass1}
1924 #################################################################################
1925 #################################################################################
1926 #if [ ${runESDfiltering} -eq 1 ]; then
1927 # submit "${JOBID5wait}" 1 1 "${LASTJOB}" "${self}" WaitForOutput ${commonOutputPath} "meta/filtering.cpass1.run*.done" "${#listOfRuns[@]}" ${maxSecondsToWait}
1929 submit "${JOBID5wait}" 1 1 "${LASTJOB}" "${self}" WaitForOutput ${commonOutputPath} "meta/merge.cpass1.run*.done" ${#listOfRuns[@]} ${maxSecondsToWait}
1931 LASTJOB=${JOBID5wait}
1933 #################################################################################
1935 echo "submit make a summary"
1938 submit "${JOBID6}" 1 1 "${LASTJOB}" "${alirootEnv} ${self}" MakeSummary ${configFile}
1940 #################################################################################
1944 echo "jobs submitted."
1951 [[ $# -lt 3 ]] && echo "goWaitForOutput() wrong number of arguments, exiting.." && return 1
1952 echo searchPath=${1}
1954 echo numberOfFiles=${3}
1955 echo maxSecondsToWait=${4}
1959 maxSecondsToWait=${4}
1960 echo "command to be executed: /bin/ls -1 ${searchPath}/${fileName}"
1961 [[ -z "${maxSecondsToWait}" ]] && maxSecondsToWait=$(( 3600*12 ))
1963 n=$(/bin/ls -1 ${searchPath}/${fileName} 2>/dev/null | wc -l)
1964 [[ ${n} -gt 0 ]] && echo "found ${n} X ${fileName}"
1965 [[ ${n} -ge ${numberOfFiles} ]] && break
1966 [[ ${SECONDS} -gt ${maxSecondsToWait} ]] && echo "timeout of ${maxSecondsToWait}s!" && break
1969 echo "DONE! exiting..."
1979 if ! ls -1 ${inputFiles} &>/dev/null; then echo "the files dont exist!: ${inputFiles}"; return 1; fi
1981 runNumber=$(guessRunNumber ${x})
1982 [[ -z ${runNumber} ]] && echo "run number cannot be guessed for ${x}" && continue
1983 awk -v run=${runNumber} -v i=${i} 'NR > 1 {print run" "$0} NR==1 && i==0 {print "run/I:"$0}' ${x}
1985 done < <(ls -1 ${inputFiles}) > ${outputFile}
1989 goMakeMergedSummaryTree()
1991 # create list of calibration entries
1992 # takes no arguments, just run it in the base output
1993 # directory with the following files in the working directory
1995 # Calibration file lists:
1996 # cpass0.dcsTree.list, cpass1.dcsTree.list
1997 # QA trending root file:
2000 # Production infoo ascii files:
2001 # summary_pass0.tree
2002 # summary_pass1.tree
2005 [[ ! -f cpass0.dcsTree.list ]] && echo "no cpass0.dcsTree.list" && return 1
2006 [[ ! -f cpass1.dcsTree.list ]] && echo "no cpass1.dcsTree.list" && return 1
2007 [[ ! -f trending.root ]] && echo "no trending.root" && return 1
2008 [[ ! -f summary_pass0.tree ]] && echo "no summary_pass0.tree" && return 1
2009 [[ ! -f summary_pass1.tree ]] && echo "no summary_pass1.tree" && return 1
2011 #first, dump the C macro to file
2012 cat << EOF > mergeTree.C
2014 // Merge summary information
2015 // Following files are expected to be in the working directory
2017 // Calibration file lists:
2018 // cpass0.dcsTree.list, cpass1.dcsTree.list
2019 // QA trending root file:
2022 // Production infoo ascii files:
2023 // summary_pass0.tree
2024 // summary_pass1.tree
2030 // Calibration values dump
2032 //Printf("MakeTreeFromList cpass0.dcsTree.list");
2033 AliXRDPROOFtoolkit::MakeTreeFromList("Calib.TPC.CPass0.root", "dcs","dcs","cpass0.dcsTree.list",1);
2034 //Printf("MakeTreeFromList cpass1.dcsTree.list");
2035 AliXRDPROOFtoolkit::MakeTreeFromList("Calib.TPC.CPass1.root", "dcs","dcs","cpass1.dcsTree.list",1);
2037 // Calibration status dump
2039 TFile *fprod = TFile::Open("fproduction.root","recreate");
2041 //Printf("reading summary_pass0.tree");
2042 tree0.ReadFile("summary_pass0.tree");
2043 //Printf("reading summary_pass1.tree");
2044 tree1.ReadFile("summary_pass1.tree");
2045 tree0.Write("CPass0");
2046 tree1.Write("CPass1");
2051 TString stringSetup="";
2052 stringSetup+="1#QA.TPC#run#SummaryTPCQA/tpcQA#trending.root+"; //
2053 stringSetup+="1#Calib.TPC.CPass0#run#dcs#Calib.TPC.CPass0.root+"; //
2054 stringSetup+="1#Calib.TPC.CPass1#run#dcs#Calib.TPC.CPass1.root+"; //
2056 stringSetup+="1#CPass0#runnumber#CPass0#fproduction.root+"; //
2057 stringSetup+="1#CPass1#runnumber#CPass1#fproduction.root+"; //
2059 //Printf("stringSetup: %s", stringSetup.Data());
2060 AliXRDPROOFtoolkit::JoinTreesIndex("outAll.root","joinAll","run",stringSetup.Data(), 1);
2064 aliroot -b -q "mergeTree.C" > mergeTrees.log
2070 # make stacktrace processing in case of standard root crash log
2071 # input is a (list of) text files with the stack trace (either gdb aoutput
2072 # produced with e.g. gdb --batch --quiet -ex "bt" -ex "quit" aliroot core, or the root crash log), output is a TTree formatted table.
2074 # benchmark.sh stackTraceTree /foo/*/rec.log
2077 print "frame/I:method/C:line/C:cpass/I:aliroot/I";
2082 /There was a crash/ {read=1;}
2083 /The lines below might hint at the cause of the crash/ {read=0;}
2085 if ($3 ~ /Ali*/) aliroot=1; else aliroot=0;
2087 if ($NF!="" && RT!="" && $3!="") print RT" "$3" "$NF" "0" "aliroot
2094 #all the final stuff goes in here for ease of use:
2105 if ! parseConfig ${configFile} "${extraOpts[@]}"; then return 1; fi
2107 #if which greadlink; then configFile=$(greadlink -f ${configFile}); fi
2109 #record the working directory provided by the batch system
2110 batchWorkingDirectory=${PWD}
2112 [[ -f ${alirootSource} && -z ${ALICE_ROOT} ]] && source ${alirootSource}
2114 [[ ! -f ${configFile} ]] && echo "no config file ${configFile}!" && return
2116 [[ -z ${commonOutputPath} ]] && commonOutputPath=${PWD}
2118 #copy some useful stuff
2119 #and go to the commonOutputPath
2120 cp ${configFile} ${commonOutputPath}
2121 cd ${commonOutputPath}
2123 exec &> >(tee ${log})
2125 #summarize the global stuff
2126 echo "env script: ${alirootSource} ${alirootEnv}"
2127 echo "\$ALICE_ROOT=${ALICE_ROOT}"
2128 echo "commonOutputPath=${commonOutputPath}"
2130 #summarize the stacktraces
2131 stackTraceTree 000*/cpass0/*/stacktrace* > stacktrace_cpass0.tree
2132 stackTraceTree 000*/cpass1/*/stacktrace* > stacktrace_cpass1.tree
2134 echo total numbers for the production:
2136 awk 'BEGIN {nFiles=0;nCore=0;}
2137 /^calibfile/ {nFiles++;}
2138 /core dumped/ {nCore++i;}
2139 END {print "cpass0 produced "nFiles" calib files, "nCore" core files";}' meta/cpass0.job*done 2>/dev/null
2140 awk 'BEGIN {nOK=0; nBAD=0; }
2141 /\/rec.log OK/ {nOK++;}
2142 /\/rec.log BAD/ {nBAD++;}
2143 /stderr BAD/ {if ($0 ~ /rec.log/){nBAD++;}}
2144 END {print "cpass0 reco: OK: "nOK"\tBAD: "nBAD;}' meta/cpass0.job*done 2>/dev/null
2145 awk 'BEGIN {nOK=0; nBAD=0; }
2146 /\/calib.log OK/ {nOK++;}
2147 /\/calib.log BAD/ {nBAD++;}
2148 END {print "cpass0 calib: OK: "nOK"\tBAD: "nBAD;}' meta/cpass0.job*done 2>/dev/null
2150 awk 'BEGIN {nOK=0; nBAD=0; }
2151 /merge.log OK/ {nOK++;}
2152 /merge.log BAD/ {nBAD++;}
2153 END {print "cpass0 merge: OK: "nOK"\tBAD: "nBAD;}' meta/merge.cpass0*done 2>/dev/null
2154 awk 'BEGIN {nOK=0; nBAD=0; }
2155 /ocdb.log OK/ {nOK++;}
2156 /ocdb.log BAD/ {nBAD++;}
2157 END {print "cpass0 OCDB: OK: "nOK"\tBAD: "nBAD;}' meta/merge.cpass0*done 2>/dev/null
2160 awk 'BEGIN {nFiles=0;nCore=0;}
2161 /^calibfile/ {nFiles++;}
2162 /core dumped/ {nCore++;}
2163 END {print "cpass1 produced "nFiles" calib files, "nCore" core files";}' meta/cpass1.job*done 2>/dev/null
2164 awk 'BEGIN {nOK=0; nBAD=0; }
2165 /\/rec.log OK/ {nOK++;}
2166 /\/rec.log BAD/ {nBAD++;}
2167 /stderr BAD/ {if ($0 ~ /rec.log/){nBAD++;}}
2168 END {print "cpass1 reco: OK: "nOK"\tBAD: "nBAD;}' meta/cpass1.job*done 2>/dev/null
2169 awk 'BEGIN {nOK=0; nBAD=0; }
2170 /\/calib.log OK/ {nOK++;}
2171 /\/calib.log BAD/ {nBAD++;}
2172 END {print "cpass1 calib: OK: "nOK"\tBAD: "nBAD;}' meta/cpass1.job*done 2>/dev/null
2174 awk 'BEGIN {nOK=0; nBAD=0; }
2175 /merge.log OK/ {nOK++;}
2176 /merge.log BAD/ {nBAD++;}
2177 END {print "cpass1 merge: OK: "nOK"\tBAD: "nBAD;}' meta/merge.cpass1*done 2>/dev/null
2178 awk 'BEGIN {nOK=0; nBAD=0; }
2179 /ocdb.log OK/ {nOK++;}
2180 /ocdb.log BAD/ {nBAD++;}
2181 END {print "cpass1 OCDB: OK: "nOK"\tBAD: "nBAD;}' meta/merge.cpass1*done 2>/dev/null
2185 /bin/ls -1 meta/merge.cpass0.run*.done | while read x
2187 dir=$(goPrintValues calibfile - ${x})
2188 runNumber=$(guessRunNumber ${dir})
2189 [[ -z ${runNumber} ]] && continue
2191 if $(/bin/ls meta/cpass0.job*.run${runNumber}.done &> /dev/null); then
2193 awk 'BEGIN {nOKrec=0;nBADrec=0;nOKcalib=0;nBADcalib=0;nOKstderr=0;nBADstderr=0;}
2194 /\/rec.log OK/ {nOKrec++;}
2195 /\/rec.log BAD/ {nBADrec++;}
2196 /stderr BAD/ {if ($0 ~ /rec.log/) {nBADrec++;} nBADstderr++;}
2197 /stderr OK/ {nOKstderr++;}
2198 /\/calib.log OK/ {nOKcalib++;}
2199 /\/calib.log BAD/ {nBADcalib++}
2200 END {print ""nOKrec" "nBADrec" "nOKstderr" "nBADstderr" "nOKcalib" "nBADcalib;}' meta/cpass0.job*.run${runNumber}.done 2>/dev/null
2204 if $(/bin/ls meta/cpass1.job*.run${runNumber}.done &>/dev/null); then
2206 awk 'BEGIN {nOKrec=0;nBADrec=0;nOKcalib=0;nBADcalib=0;nOKstderr=0;nBADstderr=0;nQAbarrelOK=0;nQAbarrelBAD=0;nQAouterOK=0;nQAouterBAD=0;}
2207 /\/rec.log OK/ {nOKrec++;}
2208 /\/rec.log BAD/ {nBADrec++;}
2209 /stderr BAD/ {if ($0 ~ /rec.log/) nBADrec++;nBADstderr++;}
2210 /stderr OK/ {nOKstderr++;}
2211 /\/calib.log OK/ {nOKcalib++;}
2212 /\/calib.log BAD/ {nBADcalib++}
2213 /\/qa_barrel.log OK/ {nQAbarrelOK++;}
2214 /\/qa_barrel.log BAD/ {nQAbarrelBAD++;}
2215 /\/qa_outer.log OK/ {nQAouterOK++;}
2216 /\/qa_outer.log BAD/ {nQAouterBAD++;}
2217 END {print ""nOKrec" "nBADrec" "nOKstderr" "nBADstderr" "nOKcalib" "nBADcalib" "nQAbarrelOK" "nQAbarrelBAD" "nQAouterOK" "nQAouterBAD;}' meta/cpass1.job*.run${runNumber}.done 2>/dev/null
2221 statusOCDBcpass0=$(awk '/ocdb.log/ {print $2} ' ${x} 2>/dev/null)
2222 statusOCDBcpass1=$(awk '/ocdb.log/ {print $2}' ${x/cpass0/cpass1} 2>/dev/null)
2223 statusQA=$(awk '/mergeMakeOCDB.log/ {print $2}' ${x/cpass0/cpass1} 2>/dev/null)
2225 printf "%s\t ocdb.log cpass0: %s\t ocdb.log cpass1: %s\tqa.log:%s\t| cpass0: rec:%s/%s stderr:%s/%s calib:%s/%s cpass1: rec:%s/%s stderr:%s/%s calib:%s/%s QAbarrel:%s/%s QAouter:%s/%s\n" ${runNumber} ${statusOCDBcpass0} ${statusOCDBcpass1} ${statusQA} ${statusCPass0[0]} ${statusCPass0[1]} ${statusCPass0[2]} ${statusCPass0[3]} ${statusCPass0[4]} ${statusCPass0[5]} ${statusCPass1[0]} ${statusCPass1[1]} ${statusCPass1[2]} ${statusCPass1[3]} ${statusCPass1[4]} ${statusCPass1[5]} ${statusCPass1[6]} ${statusCPass1[7]} ${statusCPass1[8]} ${statusCPass1[9]}
2228 #make lists with output files - QA, trending, filtering and calibration
2229 ### wait for the merging of all runs to be over ###
2231 goPrintValues qafile qa.list ${commonOutputPath}/meta/merge.cpass1.run*.done &>/dev/null
2233 goPrintValues calibfile calib.list ${commonOutputPath}/meta/merge.cpass1.run*.done &>/dev/null
2235 goPrintValues trendingfile trending.list ${commonOutputPath}/meta/merge.cpass1.run*.done &>/dev/null
2236 rm -f filtering.list
2237 goPrintValues filteredTree filtering.list ${commonOutputPath}/meta/merge.cpass1.run*.done &>/dev/null
2238 rm -f cpass0.dcsTree.list
2239 goPrintValues dcsTree cpass0.dcsTree.list ${commonOutputPath}/meta/merge.cpass0.run*.done &>/dev/null
2240 rm -f cpass1.dcsTree.list
2241 goPrintValues dcsTree cpass1.dcsTree.list ${commonOutputPath}/meta/merge.cpass1.run*.done &>/dev/null
2244 rm -f ${commonOutputPath}/trending_merged.root
2245 goMerge trending.list ${commonOutputPath}/trending.root ${configFile} "${extraOpts[@]}" &> mergeTrending.log
2247 goMakeSummaryTree ${commonOutputPath} 0
2248 goMakeSummaryTree ${commonOutputPath} 1
2250 goCreateQAplots "${PWD}/qa.list" "${productionID}" "QAplots" "${configFile}" "${extraOpts[@]}" filteringList="${PWD}/filtering.list" &>createQAplots.log
2252 #make a merged summary tree out of the QA trending, dcs trees and log summary trees
2253 goMakeMergedSummaryTree
2255 #if set, email the summary
2256 [[ -n ${MAILTO} ]] && cat ${log} | mail -s "benchmark ${productionID} done" ${MAILTO}
2263 if [[ $# -lt 1 ]] ; then
2266 #1. define vars/arrays
2267 DIR=${1} #use input or exec in current dir
2268 pass=${2-"0"} #pass from input
2269 outfile="summary_pass${pass}.tree"
2271 test -f ${outfile} && : >${outfile}
2272 errfile=${outfile/tree/err}
2273 test -f ${errfile} && : >${errfile}
2275 declare -a counterString=(TOFevents TOFtracks TPCevents TPCtracks TRDevents TRDtracks T0events SDDevents SDDtracks MeanVertexevents)
2276 Ncounter=${#counterString[@]}
2278 declare -a statusString=(TRDStatus TOFStatus TPCStatus T0Status MeanVertexStatus)
2279 Nstatus=${#statusString[@]}
2282 declare -a ratesString=(rec stderr calib qa_barrel qa_outer)
2283 Nrates=${#ratesString[@]}
2285 runs=( $(ls -1 ${DIR}/meta/merge.cpass0* | while read x; do guessRunNumber $x; done) )
2288 echo -n runnumber/I >>${outfile}
2289 echo -n :cpass${pass}status/I >>${outfile}
2290 echo -n :cpass${pass}QAstatus/I >>${outfile}
2291 for i in ${ratesString[@]}; do
2292 echo -n :${i}OK/I >>${outfile}
2293 echo -n :${i}BAD/I >>${outfile}
2296 for i in ${counterString[@]} ${statusString[@]} ; do
2297 echo -n :${i}/I >>${outfile}
2299 Ncolumns=$((2 + 2*Nrates + Ncounter + Nstatus))
2304 for runnumber in ${runs[@]} ; do
2308 filejob="${DIR}/meta/cpass${pass}.job*.run${runnumber}.done"
2309 filemerge="${DIR}/meta/merge.cpass${pass}.run${runnumber}.done"
2310 fileOCDB=$(grep /ocdb.log ${filemerge} | awk '{print $1}')
2311 if ! $(/bin/ls ${filemerge} &>/dev/null) ; then
2312 echo "${filemerge} does not exist!" >>${errfile}
2314 elif ! $(/bin/ls ${filejob} &>/dev/null) ; then
2315 echo "${filejob} does not exist!" >>${errfile}
2316 echo -n ${runnumber} >> ${outfile}
2317 for i in $(seq ${Ncolumns}) ; do
2318 echo -n "-1" >> ${outfile}
2323 echo -n ${runnumber} >> ${outfile}
2324 #pass0status= grep '/ocdb.log' ${filemerge} | cut -d' ' -f2 | tr OK x1 | tr BAD xx0 | tr -d 'x'
2325 passStatus=$(grep '/ocdb.log' ${filemerge} | grep OK | wc -l)
2326 echo -n " ${passStatus}" >> ${outfile}
2327 qaStatus=$(grep '/mergeMakeOCDB.log' ${filemerge} | grep OK | wc -l)
2328 echo -n " ${qaStatus}" >> ${outfile}
2332 for i in $(seq 0 $((${Nrates}-1))) ; do
2333 var1=$(grep "/${ratesString[${i}]}.log" ${filejob} | grep OK | wc -l)
2334 var2=$(grep "/${ratesString[${i}]}.log" ${filejob} | grep BAD | wc -l)
2336 if [[ ${ratesString[${i}]} == "stderr" ]] ; then
2337 var1=$(grep "stderr" ${filejob} | grep OK | wc -l)
2338 var2=$(grep "stderr" ${filejob} | grep "rec.log" | grep BAD | wc -l)
2340 echo -n " ${var1}" >> ${outfile}
2341 echo -n " ${var2}" >> ${outfile}
2344 if [[ -f ${fileOCDB} ]] ; then
2346 for i in $(seq 0 $((${Ncounter}-1))) ; do
2347 var1=$(grep Monalisa ${fileOCDB} | grep ${counterString[${i}]} | cut -f2)
2348 echo -n " ${var1:-"-1"}" >> ${outfile}
2352 for i in $(seq 0 $((${Nstatus}-1))) ; do
2353 var1=$(grep "calibration status=" ${fileOCDB} | grep ${statusString[${i}]/Status/} | cut -d'=' -f2)
2354 echo -n " ${var1:-"-1"}" >> ${outfile}
2372 defaultOCDB="raw://"
2374 #makeflowPath="/hera/alice/aux/cctools/bin"
2375 #makeflowOptions="-T wq -N alice -d all -C ali-copilot.cern.ch:9097"
2376 #makeflowOptions="-T wq -N alice -C ali-copilot.cern.ch:9097"
2378 #batchCommand="/usr/bin/qsub"
2379 batchFlags="-b y -cwd -l h_rt=24:0:0,h_rss=4G "
2380 baseOutputDirectory="$PWD/output"
2381 #alirootEnv="/cvmfs/alice.cern.ch/bin/alienv setenv AliRoot/v5-04-34-AN -c"
2382 #alirootEnv="/home/mkrzewic/alisoft/balice_master.sh"
2383 #trustedQAtrainMacro='/hera/alice/mkrzewic/gsisvn/Calibration/QAtrain_duo.C'
2384 reconstructInTemporaryDir=0
2385 recoTriggerOptions="\"\""
2386 percentProcessedFilesToContinue=100
2387 maxSecondsToWait=$(( 3600*24 ))
2390 postSetUpActionCPass0=""
2391 postSetUpActionCPass1=""
2393 runCPass0MergeMakeOCDB=1
2395 runCPass1MergeMakeOCDB=1
2397 filteringFactorHighPt=1e2
2398 filteringFactorV0s=1e1
2401 #dontRedirectStdOutToLog=1
2402 logToFinalDestination=1
2403 ALIROOT_FORCE_COREDUMP=1
2406 #first, source the config file
2407 if [ -f ${configFile} ]; then
2408 source ${configFile}
2410 echo "config file ${configFile} not found!"
2415 for opt in "${args[@]}"; do
2416 [[ "${opt}" =~ encodedSpaces=.* ]] && encodedSpaces=1 && echo "encodedSpaces!" && break
2419 #then, parse the options as they override the options from file
2420 for opt in "${args[@]}"; do
2421 [[ -z ${opt} ]] && continue
2422 [[ -n ${encodedSpaces} ]] && opt="$(decSpaces ${opt})"
2423 [[ "${opt}" =~ ^[[:space:]]*$ ]] && continue
2424 if [[ ! "${opt}" =~ .*=.* ]]; then
2425 echo "badly formatted option \"${opt}\" should be: option=value, stopping..."
2428 local var="${opt%%=*}"
2429 local value="${opt#*=}"
2430 echo "${var}=${value}"
2431 export ${var}="${value}"
2435 [[ -z ${alirootEnv} ]] && echo "alirootEnv not defined!" && return 1
2437 #export the aliroot function if defined to override normal behaviour
2438 [[ $(type -t aliroot) =~ "function" ]] && export -f aliroot
2446 if [[ -n ${useProfilingCommand} ]]; then
2447 profilerLogFile="cpu.txt"
2448 [[ "${args}" =~ rec ]] && profilerLogFile="cpu_rec.txt"
2449 [[ "${args}}" =~ Calib ]] && profilerLogFile="cpu_calib.txt"
2450 echo running "${useProfilingCommand} aliroot ${args} &> ${profilerLogFile}"
2451 ${useProfilingCommand} aliroot "${args[@]}" &> ${profilerLogFile}
2453 #to prevent an infinite recursion use "command aliroot" to disable
2454 #aliases and functions
2455 echo running command aliroot "${args[@]}"
2456 command aliroot "${args[@]}"
2463 #guess the period from the path, pick the rightmost one
2468 legoTrainRunNumber=""
2471 local shortRunNumber=""
2473 declare -a path=( $1 )
2474 local dirDepth=$(( ${#path[*]}-1 ))
2476 #for ((x=${dirDepth};x>=0;x--)); do
2477 for ((x=0;x<=${dirDepth};x++)); do
2479 [[ $((x-1)) -ge 0 ]] && local fieldPrev=${path[$((x-1))]}
2480 local field=${path[${x}]}
2481 local fieldNext=${path[$((x+1))]}
2483 [[ ${field} =~ ^[0-9]*$ && ${fieldNext} =~ (.*\.zip$|.*\.root$) ]] && legoTrainRunNumber=${field}
2484 [[ -n ${legoTrainRunNumber} && -z ${pass} ]] && pass=${fieldPrev}
2485 [[ ${field} =~ ^LHC[0-9][0-9][a-z].*$ ]] && period=${field%_*}
2486 [[ ${field} =~ ^000[0-9][0-9][0-9][0-9][0-9][0-9]$ ]] && runNumber=${field#000}
2487 [[ ${field} =~ ^[0-9][0-9][0-9][0-9][0-9][0-9]$ ]] && shortRunNumber=${field}
2488 [[ ${field} =~ ^20[0-9][0-9]$ ]] && year=${field}
2489 [[ ${field} =~ ^(^sim$|^data$) ]] && dataType=${field}
2492 [[ -z ${legoTrainRunNumber} ]] && pass=${path[$((dirDepth-1))]}
2493 [[ "${dataType}" =~ ^sim$ ]] && pass="passMC" && runNumber=${shortRunNumber}
2495 #if [[ -z ${dataType} || -z ${year} || -z ${period} || -z ${runNumber}} || -z ${pass} ]];
2496 if [[ -z ${runNumber}} ]];
2507 #these functions encode strings to and from a space-less form
2508 #use when spaces are not well handled (e.g. in arguments to
2509 #commands in makeflow files, etc.
2510 encSpaces()(echo "${1// /@@@@}")
2511 decSpaces()(echo "${1//@@@@/ }")