2 # this script runs the CPass0/CPass1 train
3 # produced OCDB updates are local
7 #run in proper mode depending on the selection
9 if [[ $# -gt 0 ]]; then
15 "CPass0") goCPass0 "$@";;
16 "CPass1") goCPass1 "$@";;
17 "ConfOCDB") goConfigureOCDBforCPass1 "$@";;
18 "MergeCPass0") goMergeCPass0 "$@";;
19 "MergeCPass1") goMergeCPass1 "$@";;
20 "CreateQAplots") goCreateQAplots "$@";;
21 "WaitForOutput") goWaitForOutput "$@";;
22 "makeSummary") goMakeSummary "$@";;
23 "submit") goSubmit "$@";;
24 "submitQA") goSubmitQA "$@";;
26 "generateMakeflow") goGenerateMakeflow "$@";;
27 "makeflow") goMakeflow "$@";;
28 #and the default: unless sourced print some info
29 *) if [[ ! "$0" =~ "bash" ]]; then
30 echo " batch: $0 \"submit\" inputList productionID [configFile=benchmark.config] [runNumber]"
31 echo " makeflow: $0 \"makeflow\" inputList productionID [configFile=benchmark.config] [runNumber]"
43 [[ -f ${setupAliROOTenvInCurrentShell} && -z ${alirootEnv} ]] && source $setupAliROOTenvInCurrentShell
53 #use the jobindex only if set and non-negative
54 if [[ -z $jobindex || $jobindex -lt 0 ]]; then
55 [[ -n "$LSB_JOBINDEX" ]] && jobindex=$LSB_JOBINDEX
56 [[ -n "$SGE_TASK_ID" ]] && jobindex=$SGE_TASK_ID
59 [[ ! -f ${inputList} && -z ${pretend} ]] && echo "input file $inputList not found, exiting..." && exit 1
60 if [[ "${inputList}" =~ \.root$ ]]; then
63 infile=`sed -ne "${jobindex}p" $inputList`
66 chunkName=${infile##*/}
67 outputDir=${targetDirectory}/${jobindex}
69 [[ ! -d $outputDir ]] && echo "cannot make $outputDir" && exit 1
71 runpath=${PWD}/rundir_cpass0_${runNumber}_${jobindex}
72 [[ -z $commonOutputPath ]] && commonOutputPath=$PWD
73 [[ $reconstructInTemporaryDir -eq 1 && -n $TMPDIR ]] && runpath=$TMPDIR
74 [[ $reconstructInTemporaryDir -eq 1 && -z $TMPDIR ]] && runpath=$(mktemp -d)
77 [[ ! -d ${runpath} ]] && echo "cannot make runpath ${runpath}" && exit 1
81 [[ -n $logToFinalDestination ]] && logOutputDir=$outputDir
82 [[ -z $dontRedirectStdOutToLog ]] && exec 1> $logOutputDir/stdout
83 [[ -z $dontRedirectStdOutToLog ]] && exec 2> $logOutputDir/stderr
86 calibDoneFile="$commonOutputPath/cpass0.job${jobindex}.run${runNumber}.done"
88 echo "#####################"
92 echo runNumber $runNumber
93 echo ocdbPath $ocdbPath
95 echo chunkName $chunkName
96 echo jobindex $jobindex
97 echo recoTriggerOptions $recoTriggerOptions
98 echo targetDirectory $targetDirectory
99 echo commonOutputPath $commonOutputPath
100 echo calibDoneFile $calibDoneFile
101 echo runpath $runpath
102 echo outputDir $outputDir
103 echo ALICE_ROOT $ALICE_ROOT
105 echo "########## ###########"
107 alirootInfo > ALICE_ROOT_svn.log
110 "$commonOutputPath/runCPass0.sh"
111 "$commonOutputPath/recCPass0.C"
112 "$commonOutputPath/runCalibTrain.C"
113 "$commonOutputPath/localOCDBaccessConfig.C"
114 "$commonOutputPath/OCDB.root"
115 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/runCPass0.sh"
116 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/recCPass0.C"
117 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/runCalibTrain.C"
120 for file in ${filesCPass0[*]}; do
121 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
124 ln -s $infile $runpath/$chunkName
126 echo "this directory ($PWD) contents:"
129 chmod u+x runCPass0.sh
131 if [[ -n $postSetUpActionCPass0 ]]; then
132 echo "running $postSetUpActionCPass0"
133 eval $postSetUpActionCPass0
137 echo "$runpath/runCPass0.sh $infile $nEvents $runNumber $ocdbPath $recoTriggerOptions"
138 if [[ -n $pretend ]]; then
139 touch AliESDfriends_v1.root
143 ./runCPass0.sh "$infile" "$nEvents" "$runNumber" "$ocdbPath" "$recoTriggerOptions"
146 #move stuff to final destination
147 echo "this directory ($PWD) contents:"
151 echo rm -f ./$chunkName
153 echo "cp --recursive $runpath/* ${outputDir}"
154 cp --recursive $runpath/* $outputDir
159 touch ${calibDoneFile}
160 [[ -f AliESDfriends_v1.root ]] && echo "calibfile ${outputDir}/AliESDfriends_v1.root" > ${calibDoneFile}
161 summarizeLogs >> ${calibDoneFile}
172 [[ -f ${setupAliROOTenvInCurrentShell} && -z ${alirootEnv} ]] && source $setupAliROOTenvInCurrentShell
182 #use the jobindex only if set and non-negative
183 if [[ -z $jobindex || $jobindex -lt 0 ]]; then
184 [[ -n "$LSB_JOBINDEX" ]] && jobindex=$LSB_JOBINDEX
185 [[ -n "$SGE_TASK_ID" ]] && jobindex=$SGE_TASK_ID
188 [[ ! -f ${inputList} && -z ${pretend} ]] && echo "input file $inputList not found, exiting..." && exit 1
189 if [[ "${inputList}" =~ \.root$ ]]; then
192 infile=`sed -ne "${jobindex}p" $inputList`
195 chunkName=${infile##*/}
196 outputDir=${targetDirectory}/${jobindex}
198 [[ ! -d $outputDir ]] && echo "cannot make $outputDir" && exit 1
200 runpath=${PWD}/rundir_cpass1_${runNumber}_${jobindex}
201 [[ -z $commonOutputPath ]] && commonOutputPath=$PWD
202 [[ $reconstructInTemporaryDir -eq 1 && -n $TMPDIR ]] && runpath=$TMPDIR
203 [[ $reconstructInTemporaryDir -eq 1 && -z $TMPDIR ]] && runpath=$(mktemp -d)
205 #init the running path
207 [[ ! -d ${runpath} ]] && echo "cannot make runpath ${runpath}" && exit 1
211 calibDoneFile="${commonOutputPath}/cpass1.job${jobindex}.run${runNumber}.done"
213 logOutputDir=$runpath
214 [[ -n $logToFinalDestination ]] && logOutputDir=$outputDir
215 [[ -z $dontRedirectStdOutToLog ]] && exec 1> $logOutputDir/stdout
216 [[ -z $dontRedirectStdOutToLog ]] && exec 2> $logOutputDir/stderr
219 echo "#####################"
222 echo nEvents $nEvents
223 echo runNumber $runNumber
224 echo ocdbPath $ocdbPath
226 echo chunkName $chunkName
227 echo jobindex $jobindex
228 echo recoTriggerOptions $recoTriggerOptions
229 echo targetDirectory $targetDirectory
230 echo commonOutputPath $commonOutputPath
231 echo calibDoneFile $calibDoneFile
232 echo runpath $runpath
233 echo outputDir $outputDir
234 echo ALICE_ROOT $ALICE_ROOT
236 echo "########## ###########"
238 alirootInfo > ALICE_ROOT_svn.log
241 "$commonOutputPath/runCPass1.sh"
242 "$commonOutputPath/recCPass1.C"
243 "$commonOutputPath/recCPass1_OuterDet.C"
244 "$commonOutputPath/runCalibTrain.C"
245 "$commonOutputPath/QAtrain_duo.C"
246 "$commonOutputPath/localOCDBaccessConfig.C"
247 "$commonOutputPath/cpass0.localOCDB.${runNumber}.tgz"
248 "$commonOutputPath/OCDB.root"
249 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/runCPass1.sh"
250 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/recCPass1.C"
251 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/recCPass1_OuterDet.C"
252 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/runCalibTrain.C"
253 "$ALICE_ROOT/ANALYSIS/macros/QAtrain_duo.C"
256 for file in ${filesCPass1[*]}; do
257 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
260 ln -s $infile $runpath/$chunkName
262 echo "this directory ($PWD) contents:"
266 if [[ -n $postSetUpActionCPass1 ]]; then
267 echo "running $postSetUpActionCPass1"
268 eval $postSetUpActionCPass1
272 #configure local OCDB storage from CPass0 (creates the localOCDBaccessConfig.C script)
273 if [[ -f cpass0.localOCDB.${runNumber}.tgz ]]; then
274 echo goConfigureOCDBforCPass1 "cpass0.localOCDB.${runNumber}.tgz"
275 goConfigureOCDBforCPass1 "cpass0.localOCDB.${runNumber}.tgz"
277 echo "WARNING: file cpass0.localOCDB.${runNumber}.tgz not found!"
281 chmod u+x runCPass1.sh
282 echo "$runpath/runCPass1.sh $infile $nEvents $runNumber $ocdbPath $recoTriggerOptions"
283 if [[ -n $pretend ]]; then
284 touch AliESDfriends_v1.root
285 touch QAresults_Barrel.root
286 touch QAresults_Outer.root
291 ./runCPass1.sh "$infile" "$nEvents" "$runNumber" "$ocdbPath" "$recoTriggerOptions"
294 #move stuff to final destination
295 echo "this directory ($PWD) contents:"
299 echo rm -f ./$chunkName
301 echo "cp --recursive ${runpath}/* ${outputDir}"
302 cp --recursive ${runpath}/* ${outputDir}
307 touch ${calibDoneFile}
308 [[ -f AliESDfriends_v1.root ]] && echo "calibfile ${outputDir}/AliESDfriends_v1.root" > ${calibDoneFile}
309 [[ -f QAresults_Barrel.root ]] && echo "qafile ${outputDir}/QAresults_Barrel.root" >> ${calibDoneFile}
310 [[ -f QAresults_Outer.root ]] && echo "qafile ${outputDir}/QAresults_Outer.root" >> ${calibDoneFile}
311 summarizeLogs >> ${calibDoneFile}
321 # find the output files and merge them
328 calibrationFilesToMergeExternal=$5
331 [[ -f ${setupAliROOTenvInCurrentShell} && -z ${alirootEnv} ]] && source $setupAliROOTenvInCurrentShell
333 runpath=${PWD}/rundir_cpass0_Merge_${runNumber}
334 [[ -z $commonOutputPath ]] && commonOutputPath=$PWD
335 [[ $reconstructInTemporaryDir -eq 1 && -n $TMPDIR ]] && runpath=$TMPDIR
336 [[ $reconstructInTemporaryDir -eq 1 && -z $TMPDIR ]] && runpath=$(mktemp -d)
339 [[ ! -d $runpath ]] && echo "not able to make the runpath $runpath" && exit 1
342 logOutputDir=$runpath
343 [[ -n $logToFinalDestination ]] && logOutputDir=$outputDir
344 [[ -z $dontRedirectStdOutToLog ]] && exec 2>&1 > $logOutputDir/mergeMakeOCDB.log
347 calibrationFilesToMerge=$calibrationFilesToMergeExternal
348 [[ -z $calibrationFilesToMerge ]] && calibrationFilesToMerge="calibrationFilesToMerge.list"
349 calibrationOutputFileName="AliESDfriends_v1.root"
350 mergingScript="mergeMakeOCDB.byComponent.sh"
351 qaFilesToMerge="qaFilesToMerge.list"
352 qaOutputFileName="QAresults*.root"
353 qaMergedOutputFileName="QAresults_merged.root"
355 echo goMergeCPass0 SETUP:
356 echo runNumber=$runNumber
357 echo outputDir=$outputDir
358 echo defaultOCDB=$defaultOCDB
359 echo calibrationFilesToMerge=$calibrationFilesToMerge
360 echo calibrationOutputFileName=$calibrationOutputFileName
361 echo mergingScript=$mergingScript
363 # copy files in case they are not already there
365 "$commonOutputPath/${calibrationFilesToMerge}"
366 "$commonOutputPath/OCDB.root"
367 "$commonOutputPath/localOCDBaccessConfig.C"
368 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.byComponent.sh"
369 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeByComponent.C"
370 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/makeOCDB.C"
371 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/merge.C"
372 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.sh"
374 for file in ${filesMergeCPass0[*]}; do
375 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
378 alirootInfo > ALICE_ROOT_svn.log
384 chmod u+x $mergingScript
386 if [[ -z ${calibrationFilesToMergeExternal} ]]; then
387 echo "find $outputDir -name $calibrationOutputFileName > $calibrationFilesToMerge"
388 find $outputDir -name $calibrationOutputFileName > $calibrationFilesToMerge
391 echo "$mergingScript $calibrationFilesToMerge ${runNumber} local://./OCDB $defaultOCDB"
392 if [[ -n $pretend ]]; then
393 touch CalibObjects.root
396 mkdir -p ./OCDB/someDetector/
397 mkdir -p ./OCDB/otherDetector/
398 touch ./OCDB/someDetector/someCalibObject_0-999999_cpass0.root
399 touch ./OCDB/otherDetector/otherCalibObject_0-999999_cpass0.root
401 ./$mergingScript $calibrationFilesToMerge ${runNumber} "local://./OCDB" $defaultOCDB
404 ### produce the output
405 #tar the produced OCDB for reuse
406 tar czf $commonOutputPath/cpass0.localOCDB.${runNumber}.tgz ./OCDB
410 #copy all to output dir
411 cp --recursive ${runpath}/* $outputDir
413 #validate merging cpass0
415 calibDoneFile="${commonOutputPath}/merge.cpass0.run${runNumber}.done"
416 touch ${calibDoneFile}
417 [[ -f CalibObjects.root ]] && echo "calibfile $outputDir/CalibObjects.root" > ${calibDoneFile}
418 summarizeLogs >> ${calibDoneFile}
427 # find the output files and merge them
434 calibrationFilesToMergeExternal=$5
435 qaFilesToMergeExternal=$6
438 rm -f $outputDir/*.log
439 rm -f $outputDir/*.root
440 rm -f $outputDir/*done
443 [[ -f ${setupAliROOTenvInCurrentShell} && -z ${alirootEnv} ]] && source $setupAliROOTenvInCurrentShell
445 runpath=${PWD}/rundir_cpass1_Merge_${runNumber}
446 [[ -z $commonOutputPath ]] && commonOutputPath=$PWD
447 [[ $reconstructInTemporaryDir -eq 1 && -n $TMPDIR ]] && runpath=$TMPDIR
448 [[ $reconstructInTemporaryDir -eq 1 && -z $TMPDIR ]] && runpath=$(mktemp -d)
451 [[ ! -d $runpath ]] && echo "not able to make the runpath $runpath" && exit 1
454 logOutputDir=$runpath
455 [[ -n $logToFinalDestination ]] && logOutputDir=$outputDir
456 [[ -z $dontRedirectStdOutToLog ]] && exec 2>&1 > $logOutputDir/mergeMakeOCDB.log
459 calibrationFilesToMerge=$calibrationFilesToMergeExternal
460 [[ -z $calibrationFilesToMerge ]] && calibrationFilesToMerge="calibrationFilesToMerge.list"
461 calibrationOutputFileName="AliESDfriends_v1.root"
462 mergingScript="mergeMakeOCDB.byComponent.sh"
463 qaFilesToMerge=$qaFilesToMergeExternal
464 [[ -z $qaFilesToMerge ]] && qaFilesToMerge="qaFilesToMerge.list"
465 qaOutputFileName="QAresults*.root"
466 qaMergedOutputFileName="QAresults_merged.root"
468 echo goMergeCPass1 SETUP:
469 echo runNumber=$runNumber
470 echo outputDir=$outputDir
471 echo defaultOCDB=$defaultOCDB
472 echo calibrationFilesToMerge=filesToMerge.list
473 echo calibrationOutputFileName=$calibrationOutputFileName
474 echo mergingScript=$mergingScript
476 # copy files in case they are not already there
478 "$commonOutputPath/${calibrationFilesToMerge}"
479 "$commonOutputPath/${qaFilesToMerge}"
480 "$commonOutputPath/OCDB.root"
481 "$commonOutputPath/localOCDBaccessConfig.C"
482 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeMakeOCDB.byComponent.sh"
483 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeByComponent.C"
484 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/makeOCDB.C"
485 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/merge.C"
486 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeMakeOCDB.sh"
488 for file in ${filesMergeCPass1[*]}; do
489 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
492 alirootInfo > ALICE_ROOT_svn.log
498 chmod u+x $mergingScript
500 if [[ -z ${calibrationFilesToMergeExternal} ]]; then
501 echo "find $outputDir -name $calibrationOutputFileName > $calibrationFilesToMerge"
502 find $outputDir -name $calibrationOutputFileName > $calibrationFilesToMerge
505 echo "$mergingScript $calibrationFilesToMerge ${runNumber} local://./OCDB $defaultOCDB"
506 if [[ -n $pretend ]]; then
507 touch CalibObjects.root
511 ./$mergingScript $calibrationFilesToMerge ${runNumber} "local://./OCDB" $defaultOCDB
514 tar czf localCPass1_${runNumber}.tgz ./OCDB
517 [[ -n ${AliAnalysisTaskFilteredTree_fLowPtTrackDownscaligF} ]] && export AliAnalysisTaskFilteredTree_fLowPtTrackDownscaligF
518 [[ -n ${AliAnalysisTaskFilteredTree_fLowPtV0DownscaligF} ]] && export AliAnalysisTaskFilteredTree_fLowPtV0DownscaligF
520 if [[ -z $qaFilesToMergeExternal ]]; then
521 echo "find $outputDir -name $qaOutputFileName > $qaFilesToMerge"
522 find $outputDir -name $qaOutputFileName > $qaFilesToMerge
525 echo aliroot -l -b -q "merge.C(\"$qaFilesToMerge\",\"\",kFALSE,\"$qaMergedOutputFileName\")"
526 if [[ -n $pretend ]]; then
527 touch $qaMergedOutputFileName
530 aliroot -l -b -q "merge.C(\"$qaFilesToMerge\",\"\",kFALSE,\"$qaMergedOutputFileName\")"
535 #copy all to output dir
536 cp --recursive ${runpath}/* ${outputDir}
538 #validate merge cpass1
540 calibDoneFile="${commonOutputPath}/merge.cpass1.run${runNumber}.done"
541 touch ${calibDoneFile}
542 [[ -f CalibObjects.root ]] && echo "calibfile $outputDir/CalibObjects.root" > ${calibDoneFile}
543 [[ -f $qaMergedOutputFileName ]] && echo "qafile $outputDir/$qaMergedOutputFileName" >> ${calibDoneFile}
544 summarizeLogs >> ${calibDoneFile}
553 configFile="benchmark.config"
554 [[ -n "$3" ]] && configFile=$3
555 configFile=$(readlink -f $configFile)
556 [[ -n $4 ]] && runNumber=$4
558 #redirect all output to submit.log
559 echo "redirecting all output to ${PWD}/submit_${productionID//"/"/_}.log"
561 exec 1>submit_${productionID//"/"/_}.log 2>&1
565 if [[ -z "$inputList" || -z "$productionID" ]]
568 echo " Usage: $0 submit inputList productionID [configFile=benchmark.config]"
573 date=`date +%Y-%m-%d_%H%M%S`
575 # check if config file is there
576 if [ ! -f $configFile ]; then
577 echo "ERROR! Config File '$configFile' not found" >&2
580 echo "Using Config File: '$configFile'"
583 # source the config file
584 # and print the configuration
586 [[ -f ${setupAliROOTenvInCurrentShell} && -z ${alirootEnv} ]] && source $setupAliROOTenvInCurrentShell
588 self=$(readlink -f "$0")
589 configPath=`dirname $self`
590 #exporting makes it available in the environment on the nodes - makes the summary output go there
591 export commonOutputPath=${baseOutputDirectory}/${productionID}
593 #[[ -z ${ALIROOT_RELEASE} ]] && ALIROOT_RELEASE=${ALICE_ROOT//"/"/"_"}
594 #ALIROOT_RELEASE_mod=${ALIROOT_RELEASE//"/"/"_"}
595 #ALIROOT_BASEDIR_mod=${ALIROOT_BASEDIR//"/"/"_"}
596 #productionID=${ALIROOT_BASEDIR_mod}_${ALIROOT_RELEASE_mod}/${productionID}
598 #convert to absolut pathnames
599 inputList=$(readlink -f "$inputList")
601 if [[ -z $runNumber ]]; then
602 listOfRuns=($(while read x; do guessRunNumber $x; done < ${inputList} | sort | uniq))
604 listOfRuns=$runNumber
607 setupAliROOTenvInCurrentShell=$(readlink -f "$setupAliROOTenvInCurrentShell")
610 echo "### BEGIN CONFIGURATION ###"
614 echo " productionID: $productionID"
615 echo " batchCommand: $batchCommand"
616 echo " setupAliROOTenvInCurrentShell: $setupAliROOTenvInCurrentShell"
617 echo " ALICE_ROOT: $ALICE_ROOT"
618 echo " ALIROOT_RELEASE: $ALICE_RELEASE"
619 echo " inputList: $inputList"
620 echo " configPath: $configPath"
621 echo " commonOutputPath: $commonOutputPath"
622 echo " defaultOCDB: $defaultOCDB"
623 echo " autoOCDB: $autoOCDB"
624 echo " recoTriggerOptions: $recoTriggerOptions"
626 echo " ${listOfRuns[*]}"
628 echo "THE TRAIN WILL RUN:"
630 if [ $runCPass0reco -eq 1 ]; then
631 echo " Pass0 - Recontruction"
634 if [ $runCPass0MergeMakeOCDB -eq 1 ]; then
635 echo " Pass0 - merging and OCDB export"
638 if [ $runCPass1reco -eq 1 ]; then
639 echo " Pass1 - Recontruction"
641 if [ $runCPass1MergeMakeOCDB -eq 1 ]; then
642 echo " Pass1 - merging and OCDB export"
647 echo " max. Events/Chunk: $nEvents"
648 echo " max. Number of Chunks per Run: $nMaxChunks"
650 echo "### END CONFIGURATION ###"
654 # check if input file is there
655 if [ ! -f $inputList ]; then
656 echo "ERROR! Input List '$inputList' not found" >&2
660 # define jobid (for dependent jobs)
661 JOBID1=p0_${productionID//"/"/_}_${date}
662 JOBID1wait=w0_${productionID//"/"/_}_${date}
663 JOBID2=m0_${productionID//"/"/_}_${date}
664 JOBID2wait=wm0_${productionID//"/"/_}_${date}
665 JOBID3=op0_${productionID//"/"/_}_${date}
666 JOBID3wait=wop0_${productionID//"/"/_}_${date}
667 JOBID4=p1_${productionID//"/"/_}_${date}
668 JOBID4wait=w1_${productionID//"/"/_}_${date}
669 JOBID5=m1_${productionID//"/"/_}_${date}
670 JOBID5wait=wm1_${productionID//"/"/_}_${date}
671 JOBID6=s1_${productionID//"/"/_}_${date}
672 JOBID6wait=ws1_${productionID//"/"/_}_${date}
673 JOBID7=QA_${productionID//"/"/_}_${date}
676 #for each run we submit one jobarray:
677 numberOfSubmittedCPass1MergingJobs=0
678 for runNumber in ${listOfRuns[*]}; do
679 [[ -z $runNumber ]] && continue
680 [[ ! ${runNumber} =~ ^[0-9]*[0-9]$ ]] && continue
681 oneInputFile=$(egrep -m1 "$runNumber\/" ${inputList})
682 currentDefaultOCDB=$defaultOCDB
683 [[ $autoOCDB -ne 0 ]] && currentDefaultOCDB=$(setYear $oneInputFile $defaultOCDB)
684 echo "submitting run $runNumber with OCDB $currentDefaultOCDB"
686 ################################################################################
687 ################################################################################
688 # run the CPass0 if requested
690 if [ $runCPass0reco -eq 1 ]; then
693 echo "starting CPass0... for run $runNumber"
696 # create directory and copy all files that are needed
697 targetDirectory="${commonOutputPath}/000${runNumber}/CPass0"
698 mkdir -p $targetDirectory
699 mkdir -p $targetDirectory/logs
701 localInputList=$targetDirectory/${inputList##*/}
702 theScript="$targetDirectory/${self##*/}"
703 cp -f $self $theScript
706 rm -f $localInputList
707 egrep "\/000$runNumber\/" $inputList >> $localInputList
708 cp -f $configFile $targetDirectory
709 [[ -f $configPath/runCPass0.sh ]] && cp -f $configPath/runCPass0.sh $targetDirectory && echo "## using local runCPass0.sh"
710 [[ -f $configPath/recCPass0.C ]] && cp -f $configPath/recCPass0.C $targetDirectory && echo "## using local recCPass0.C"
711 [[ -f $configPath/runCalibTrain.C ]] && cp -f $configPath/runCalibTrain.C $targetDirectory && echo "## using local runCalibTrain.C"
712 [[ -f $configPath/localOCDBaccessConfig.C ]] && cp -f $configPath/localOCDBaccessConfig.C $targetDirectory && echo "## using local localOCDBaccessConfig.C"
714 [[ -f $configPath/CPass0/runCPass0.sh ]] && cp -f $configPath/CPass0/runCPass0.sh $targetDirectory && echo "## using local runCPass0.sh"
715 [[ -f $configPath/CPass0/recCPass0.C ]] && cp -f $configPath/CPass0/recCPass0.C $targetDirectory && echo "## using local recCPass0.C"
716 [[ -f $configPath/CPass0/runCalibTrain.C ]] && cp -f $configPath/CPass0/runCalibTrain.C $targetDirectory && echo "## using local runCalibTrain.C"
717 [[ -f $configPath/CPass0/localOCDBaccessConfig.C ]] && cp -f $configPath/CPass0/localOCDBaccessConfig.C $targetDirectory && echo "## using local localOCDBaccessConfig.C"
719 echo "... files copied."
722 # limit nFiles to nMaxChunks
723 nFiles=`wc -l < $localInputList`
724 [[ $nFiles -eq 0 ]] && echo "list contains ZERO files! exiting..." && exit 1
725 echo "raw files in list: $nFiles"
726 if [[ $nMaxChunks -gt 0 && $nMaxChunks -le $nFiles ]]; then
729 echo "raw files to process: $nFiles"
730 [[ -z "$percentProcessedFilesToContinue" ]] && percentProcessedFilesToContinue=100
731 if [[ $percentProcessedFilesToContinue -eq 100 ]]; then
732 nFilesToWaitFor=$nFiles
734 nFilesToWaitFor=$(( $nFiles-$nFiles/(100/(100-$percentProcessedFilesToContinue)) ))
736 echo "requested success rate is $percentProcessedFilesToContinue%"
737 echo "merging will start after $nFilesToWaitFor jobs are done"
739 submit $JOBID1 1 $nFiles "" "$theScript" "CPass0 $targetDirectory $localInputList $nEvents $currentDefaultOCDB $configFile $runNumber"
741 ## submit a monitoring job that will run until a certain number of jobs are done with reconstruction
742 submit "$JOBID1wait" 1 1 "" "$theScript" "WaitForOutput ${commonOutputPath} 'cpass0.job*.run$runNumber.done' $nFilesToWaitFor $maxSecondsToWait '-maxdepth 1'"
745 fi #end running CPass0
746 ################################################################################
749 ################################################################################
750 # submit merging of CPass0, depends on the reconstruction
752 if [ $runCPass0MergeMakeOCDB -eq 1 ]; then
755 echo "submit CPass0 merging for run $runNumber"
758 targetDirectory="${commonOutputPath}/000${runNumber}/CPass0"
759 mkdir -p $targetDirectory
762 cp -f $self $targetDirectory
763 [[ -f $configPath/mergeMakeOCDB.sh ]] && cp -f $configPath/mergeMakeOCDB.sh $targetDirectory && echo "## using local mergeMakeOCDB.sh"
764 [[ -f $configPath/merge.C ]] && cp -f $configPath/merge.C $targetDirectory && echo "## using local merge.C"
765 [[ -f $configPath/mergeMakeOCDB.byComponent.sh ]] && cp -f $configPath/mergeMakeOCDB.byComponent.sh $targetDirectory && echo "## using local mergeMakeOCDB.byComponent.sh"
766 [[ -f $configPath/mergeByComponent.C ]] && cp -f $configPath/mergeByComponent.C $targetDirectory && echo "## using local mergeByComponent.C"
767 [[ -f $configPath/makeOCDB.C ]] && cp -f $configPath/makeOCDB.C $targetDirectory && echo "## using local makeOCDB.C"
769 theScript="$targetDirectory/${self##*/}"
772 echo submit $JOBID2 1 1 "$LASTJOB" "$theScript" "MergeCPass0 $targetDirectory $currentDefaultOCDB $configFile $runNumber"
773 submit $JOBID2 1 1 "$LASTJOB" "$theScript" "MergeCPass0 $targetDirectory $currentDefaultOCDB $configFile $runNumber"
779 # end of merging CPass0
780 ################################################################################
782 ################################################################################
783 ################################################################################
784 # run the CPass1 if requested
786 if [ $runCPass1reco -eq 1 ]; then
788 targetDirectory="${commonOutputPath}/000${runNumber}/CPass1"
790 # safety feature: if we are re-running for any reason we want to delete the previous output first.
791 [[ -d $targetDirectory ]] && rm -rf $targetDirectory/* && echo "removed old output at $targetDirectory/*"
793 ################################################################################
794 # for the CPass1, based on the OCDB entries produced, we need to create the script
795 # to set the specific storages to the output of CPass0
796 # submit a job that will execute after merging/OCDB export that will do it.
798 mkdir -p $targetDirectory
799 mkdir -p $targetDirectory/logs
800 cp -f $self $targetDirectory
801 theScript="$targetDirectory/${self##*/}"
804 echo submitting the OCDB specific storage config making script for run $runNumber
807 [[ -f $configPath/localOCDBaccessConfig.C ]] && cp -f $configPath/localOCDBaccessConfig.C $targetDirectory && echo "## using local localOCDBaccessConfig.C"
809 submit $JOBID3 1 1 "$LASTJOB" "$theScript" "ConfOCDB ${commonOutputPath}/000${runNumber}/CPass0/OCDB ${targetDirectory} "
811 ################################################################################
814 echo "starting CPass1... for run $runNumber"
817 # create directory and copy all files that are needed
818 mkdir -p $targetDirectory
819 mkdir -p $targetDirectory/logs
821 localInputList=$targetDirectory/${inputList##*/}
822 theScript="$targetDirectory/${self##*/}"
823 cp -f $self $theScript
826 rm -f $localInputList
827 egrep "\/000$runNumber\/" $inputList >> $localInputList
828 cp -f $configFile $targetDirectory
829 [[ -f $configPath/runCPass1.sh ]] && cp -f $configPath/runCPass1.sh $targetDirectory && echo "## using local runCPass1.sh"
830 [[ -f $configPath/recCPass1.C ]] && cp -f $configPath/recCPass1.C $targetDirectory && echo "## using local recCPass1.C"
831 [[ -f $configPath/recCPass1_OuterDet.C ]] && cp -f $configPath/recCPass1_OuterDet.C $targetDirectory && echo "## using local recCPass1_OuterDet.C"
832 [[ -f $configPath/runCalibTrain.C ]] && cp -f $configPath/runCalibTrain.C $targetDirectory && echo "## using local runCalibTrain.C"
833 [[ -f $configPath/QAtrain.C ]] && cp -f $configPath/QAtrain.C $targetDirectory && echo "## using local QAtrain.C"
834 [[ -f $configPath/QAtrain_duo.C ]] && cp -f $configPath/QAtrain_duo.C $targetDirectory && echo "## using local QAtrain_duo.C"
836 [[ -f $configPath/CPass1/runCPass1.sh ]] && cp -f $configPath/CPass1/runCPass1.sh $targetDirectory && echo "## using local runCPass1.sh"
837 [[ -f $configPath/CPass1/recCPass1.C ]] && cp -f $configPath/CPass1/recCPass1.C $targetDirectory && echo "## using local recCPass1.C"
838 [[ -f $configPath/CPass1/recCPass1_OuterDet.C ]] && cp -f $configPath/CPass1/recCPass1_OuterDet.C $targetDirectory && echo "## using local recCPass1_OuterDet.C"
839 [[ -f $configPath/CPass1/runCalibTrain.C ]] && cp -f $configPath/CPass1/runCalibTrain.C $targetDirectory && echo "## using local runCalibTrain.C"
840 [[ -f $configPath/CPass1/QAtrain.C ]] && cp -f $configPath/CPass1/QAtrain.C $targetDirectory && echo "## using local QAtrain.C"
841 [[ -f $configPath/CPass1/QAtrain_duo.C ]] && cp -f $configPath/CPass1/QAtrain_duo.C $targetDirectory && echo "## using local QAtrain_duo.C"
843 echo "... files copied."
846 # limit nFiles to nMaxChunks
847 nFiles=`wc -l < $localInputList`
848 [[ $nFiles -eq 0 ]] && echo "list contains ZERO files! exiting..." && exit 1
849 echo "raw files in list: $nFiles"
850 if [[ $nMaxChunks -gt 0 && $nMaxChunks -le $nFiles ]]; then
853 echo "raw files to process: $nFiles"
854 [[ -z "$percentProcessedFilesToContinue" ]] && percentProcessedFilesToContinue=100
855 if [[ $percentProcessedFilesToContinue -eq 100 ]]; then
856 nFilesToWaitFor=$nFiles
858 nFilesToWaitFor=$(( $nFiles-$nFiles/(100/(100-$percentProcessedFilesToContinue)) ))
860 echo "requested success rate is $percentProcessedFilesToContinue%"
861 echo "merging will start after $nFilesToWaitFor jobs are done"
863 submit $JOBID4 1 $nFiles "$LASTJOB" "$theScript" "CPass1 $targetDirectory $localInputList $nEvents $currentDefaultOCDB $configFile $runNumber"
865 ################################################################################
866 ## submit a monitoring job that will run until a certain number of jobs are done with reconstruction
867 submit "$JOBID4wait" 1 1 "$LASTJOB" "$theScript" "WaitForOutput ${commonOutputPath} 'cpass1.job*.run${runNumber}.done' $nFilesToWaitFor $maxSecondsToWait '-maxdepth 1'"
869 ################################################################################
872 fi #end running CPass1
874 ################################################################################
875 # submit merging of CPass1, depends on the reconstruction
876 if [ $runCPass1MergeMakeOCDB -eq 1 ]; then
879 echo "submit CPass1 merging for run $runNumber"
882 targetDirectory="${commonOutputPath}/000${runNumber}/CPass1"
883 mkdir -p $targetDirectory
886 cp -f $self $targetDirectory
887 [[ -f $configPath/mergeMakeOCDB.sh ]] && cp -f $configPath/mergeMakeOCDB.sh $targetDirectory && echo "## using local mergeMakeOCDB.sh"
888 [[ -f $configPath/merge.C ]] && cp -f $configPath/merge.C $targetDirectory && echo "## using local merge.C"
889 [[ -f $configPath/mergeMakeOCDB.byComponent.sh ]] && cp -f $configPath/mergeMakeOCDB.byComponent.sh $targetDirectory && echo "## using local mergeMakeOCDB.byComponent.sh"
890 [[ -f $configPath/mergeByComponent.C ]] && cp -f $configPath/mergeByComponent.C $targetDirectory && echo "## using local mergeByComponent.C"
891 [[ -f $configPath/makeOCDB.C ]] && cp -f $configPath/makeOCDB.C $targetDirectory && echo "## using local makeOCDB.C"
893 theScript="$targetDirectory/${self##*/}"
896 echo submit "$JOBID5" 1 1 "$LASTJOB" "$theScript" "MergeCPass1 $targetDirectory $currentDefaultOCDB $configFile $runNumber"
897 submit "$JOBID5" 1 1 "$LASTJOB" "$theScript" "MergeCPass1 $targetDirectory $currentDefaultOCDB $configFile $runNumber"
898 ((numberOfSubmittedCPass1MergingJobs++))
905 ################################################################################
906 ################################################################################
907 [[ -z $runMakeSummary ]] && runMakeSummary=0
908 if [ $runMakeSummary -eq 1 ]; then
910 echo "submit make a summary"
913 targetDirectory="${commonOutputPath}"
914 mkdir -p $targetDirectory
915 mkdir -p $targetDirectory/logs
916 [[ ! -f $targetDirectory/${self##*/} ]] && cp -f $self $targetDirectory
917 theScript="$targetDirectory/${self##*/}"
918 submit "$JOBID6" 1 1 "$LASTJOB" "$theScript" "MakeSummary $targetDirectory $configFile"
920 ################################################################################
922 ################################################################################
923 ################################################################################
924 if [ $runMakeQAplots -eq 1 ]; then
926 echo "submit make QA plots"
929 ## submit a monitoring job that will wait for a specified number of files to appear somewhere
930 targetDirectory="${commonOutputPath}"
931 [[ ! -f $targetDirectory/${self##*/} ]] && cp -f $self $targetDirectory
932 theScript="$targetDirectory/${self##*/}"
933 echo submit "$JOBID5wait 1 1 $theScript WaitForOutput ${commonOutputPath} 'merge.cpass1.run*.done' $numberOfSubmittedCPass1MergingJobs $maxSecondsToWait '-maxdepth 1'"
934 submit "$JOBID5wait" 1 1 "" "$theScript" "WaitForOutput ${commonOutputPath} 'merge.cpass1.run*.done' $numberOfSubmittedCPass1MergingJobs $maxSecondsToWait '-maxdepth 1'"
937 targetDirectory="${commonOutputPath}/QAplots/"
938 [[ -d $targetDirectory ]] && rm -rf $targetDirectory/*
939 mkdir -p $targetDirectory
940 mkdir -p $targetDirectory/logs
941 qaFilesDirectory="${commonOutputPath}"
942 [[ ! -f $targetDirectory/${self##*/} ]] && cp -f $self $targetDirectory
943 theScript="$targetDirectory/${self##*/}"
945 echo submit "$JOBID7" 1 1 "$LASTJOB" "$theScript" "CreateQAplots QAplots CPass1 $targetDirectory $qaFilesDirectory $qaPlotsScript $configFile"
946 submit "$JOBID7" 1 1 "$LASTJOB" "$theScript" "CreateQAplots QAplots CPass1 $targetDirectory $qaFilesDirectory $qaPlotsScript $configFile"
952 echo "jobs submitted."
960 # log filtering, script needs to take the base dir as argument
961 if [[ -x $logFilteringScript ]]; then
962 commonOutputPath=${baseOutputDirectory}/${productionID}
963 ${logFilteringScript} $commonOutputPath
966 awk 'BEGIN {nFiles=0;} /^calibfile/ {nFiles++;} END {print "cpass0 produced "nFiles" calib files";}' cpass0.job*done
967 awk 'BEGIN {nOK=0; nBAD=0;} /rec.*log OK/ {nOK++;} /rec.*log BAD/ {nBAD++;} END {print "cpass0 reco: OK: "nOK" BAD: "nBAD;}' cpass0.job*done
968 awk 'BEGIN {nOK=0; nBAD=0;} /calib.*log OK/ {nOK++;} /calib.*log BAD/ {nBAD++;} END {print "cpass0 calib: OK: "nOK" BAD: "nBAD;}' cpass0.job*done
970 awk 'BEGIN {nOK=0; nBAD=0;} /merge.*log OK/ {nOK++;} /merge.*log BAD/ {nBAD++;} END {print "cpass0 merge: OK: "nOK" BAD: "nBAD;}' merge.cpass0*done
971 awk 'BEGIN {nOK=0; nBAD=0;} /ocdb.*log OK/ {nOK++;} /ocdb.*log BAD/ {nBAD++;} END {print "cpass0 OCDB: OK: "nOK" BAD: "nBAD;}' merge.cpass0*done
973 awk 'BEGIN {nFiles=0;} /^calibfile/ {nFiles++;} END {print "cpass1 produced "nFiles" calib files";}' cpass1.job*done
974 awk 'BEGIN {nOK=0; nBAD=0;} /rec.*log OK/ {nOK++;} /rec.*log BAD/ {nBAD++;} END {print "cpass1 reco: OK: "nOK" BAD: "nBAD;}' cpass1.job*done
975 awk 'BEGIN {nOK=0; nBAD=0;} /calib.*log OK/ {nOK++;} /calib.*log BAD/ {nBAD++;} END {print "cpass1 calib: OK: "nOK" BAD: "nBAD;}' cpass1.job*done
977 awk 'BEGIN {nOK=0; nBAD=0;} /merge.*log OK/ {nOK++;} /merge.*log BAD/ {nBAD++;} END {print "cpass1 merge: OK: "nOK" BAD: "nBAD;}' merge.cpass1*done
978 awk 'BEGIN {nOK=0; nBAD=0;} /ocdb.*log OK/ {nOK++;} /ocdb.*log BAD/ {nBAD++;} END {print "cpass1 OCDB: OK: "nOK" BAD: "nBAD;}' merge.cpass1*done
980 #if set email the summary
981 [[ -n $mailSummaryTo ]] && cat $log | mail -s "benchmark $productionID done" $mailSummaryTo
988 #generate the makeflow file and run
994 [[ -z ${configFile} ]] && configFile="benchmark.config"
995 [[ ! -f ${configFile} ]] && echo "no config file found (${configFile})" && return 1
999 goGenerateMakeflow "$@" > benchmark.makeflow
1000 makeflow ${makeflowOptions} benchmark.makeflow
1003 goGenerateMakeflow()
1005 #generate the makeflow file
1011 [[ -z ${configFile} ]] && configFile="benchmark.config"
1012 [[ ! -f ${configFile} ]] && echo "no config file found (${configFile})" && return 1
1015 commonOutputPath=${baseOutputDirectory}/${productionID}
1017 #these files will be made a dependency - will be copied to the working dir of the jobs
1018 declare -a copyFiles
1021 "localOCDBaccessConfig.C"
1023 for file in ${inputFiles[*]}; do
1024 [[ -f ${file} ]] && copyFiles+=("${file}")
1027 #create the makeflow file
1028 declare -a arr_cpass1_final
1029 declare -a arr_cpass1_QA_final
1030 listOfRuns=${runNumber}
1031 [[ -z ${runNumber} ]] && listOfRuns=($(while read x; do guessRunNumber $x; done < ${inputFileList} | sort | uniq))
1033 for runNumber in ${listOfRuns[*]}; do
1034 [[ -z $runNumber ]] && continue
1035 [[ ! ${runNumber} =~ ^[0-9]*[0-9]$ ]] && continue
1038 unset arr_cpass0_outputs
1039 unset arr_cpass1_outputs
1040 declare -a arr_cpass0_outputs
1041 declare -a arr_cpass1_outputs
1042 unset arr_cpass0_outputs
1044 while read inputFile; do
1045 currentDefaultOCDB=${defaultOCDB}
1046 [[ ${autoOCDB} -ne 0 ]] && currentDefaultOCDB=$(setYear $inputFile $defaultOCDB)
1049 arr_cpass0_outputs[$jobindex]="cpass0.job${jobindex}.run${runNumber}.done"
1050 echo "${arr_cpass0_outputs[$jobindex]}: benchmark.sh ${configFile} ${copyFiles[@]}"
1051 echo " ${alirootEnv} ./benchmark.sh CPass0 ${commonOutputPath}/cpass0/000${runNumber} $inputFile $nEvents $currentDefaultOCDB $configFile $runNumber $jobindex"
1055 arr_cpass1_outputs[$jobindex]="cpass1.job${jobindex}.run${runNumber}.done"
1056 echo "${arr_cpass1_outputs[$jobindex]} : benchmark.sh ${configFile} cpass0.localOCDB.${runNumber}.tgz ${copyFiles[@]}"
1057 echo " ${alirootEnv} ./benchmark.sh CPass1 ${commonOutputPath}/cpass1/000${runNumber} $inputFile $nEvents $currentDefaultOCDB $configFile $runNumber $jobindex"
1061 done< <(grep "/000$runNumber/" $inputFileList)
1063 #CPass0 list of Calib files to merge
1064 echo "cpass0.calib.run${runNumber}.list: ${arr_cpass0_outputs[*]}"
1065 echo " awk '/^calibfile / {print "'\$2'"}' ${arr_cpass0_outputs[*]} > cpass0.calib.run${runNumber}.list"
1068 #CPass1 list of Calib/QA files to merge
1069 echo "cpass1.calib.run${runNumber}.list cpass1.QA.run${runNumber}.list: ${arr_cpass1_outputs[*]}"
1070 echo " awk '/^calibfile / {print "'\$'"2}' ${arr_cpass1_outputs[*]} > cpass1.calib.run${runNumber}.list; awk '/^qafile / {print "'\$'"2}' ${arr_cpass1_outputs[*]} > cpass1.QA.run${runNumber}.list"
1074 arr_cpass0_final[$runindex]="merge.cpass0.run${runNumber}.done"
1075 echo "cpass0.localOCDB.${runNumber}.tgz ${arr_cpass0_final[$runindex]}: cpass0.calib.run${runNumber}.list benchmark.sh ${configFile} ${copyFiles[@]}"
1076 echo " ${alirootEnv} ./benchmark.sh MergeCPass0 ${commonOutputPath}/cpass0/000${runNumber} $currentDefaultOCDB ${configFile} $runNumber cpass0.run${runNumber}.list"
1079 #CPass1 Calib/QA merging
1080 arr_cpass1_final[$runindex]="merge.cpass1.run${runNumber}.done"
1081 echo "${arr_cpass1_final[$runindex]}: cpass1.calib.run${runNumber}.list cpass1.QA.run${runNumber}.list benchmark.sh ${configFile} ${copyFiles[@]}"
1082 echo " ${alirootEnv} ./benchmark.sh MergeCPass1 ${commonOutputPath}/cpass1/000${runNumber} $currentDefaultOCDB ${configFile} $runNumber cpass1.calib.run${runNumber}.list cpass1.QA.run${runNumber}.list"
1087 #CPass1 list of final Calib/QA files
1088 echo "cpass1.QA.list cpass1.calib.list: ${arr_cpass1_final[*]}"
1089 echo " awk '/^calibfile / {print "'\$'"2}' ${arr_cpass1_final[*]} > cpass1.calib.list; awk '/^qafile / {print "'\$'"2}' ${arr_cpass1_final[*]} > cpass1.QA.list"
1093 echo "summary.log : ${arr_cpass0_outputs[*]} ${arr_cpass1_outputs[*]} ${arr_cpass1_final[*]} ${arr_cpass0_final[*]} benchmark.sh ${configFile}"
1094 echo " LOCAL ./benchmark.sh makeSummary ${configFile} |tee summary.log"
1100 [[ $# -lt 5 ]] && echo "goCreateQAplots productionID pass outputDir qaFilesDirectory qaPlotScript" && exit 1
1109 [[ -f ${setupAliROOTenvInCurrentShell} ]] && source $setupAliROOTenvInCurrentShell
1111 runpath=${PWD}/rundir_cpass0_Merge_${runNumber}
1112 [[ -z $commonOutputPath ]] && commonOutputPath=$PWD
1113 [[ $reconstructInTemporaryDir -eq 1 && -n $TMPDIR ]] && runpath=$TMPDIR
1114 [[ $reconstructInTemporaryDir -eq 1 && -z $TMPDIR ]] && runpath=$(mktemp -d)
1117 [[ ! -d $runpath ]] && echo "not able to make the runpath $runpath" && exit 1
1120 [[ -z $logOutputDir ]] && logOutputDir=$runpath
1121 [[ -z $dontRedirectStdOutToLog ]] && exec 2>&1 > $logOutputDir/makeQAplots.log
1124 [[ -z "$qaPlotsScript" ]] && echo "qaPlotsScript not defined"&&exit 1
1126 mergedQAfileList=$outputDir/mergedQAfiles.list
1127 echo "MakeListOfQAresults $qaFilesDirectory QAresults.root | grep CPass1 > $mergedQAfileList"
1128 MakeListOfQAresults $qaFilesDirectory QAresults_merged.root | grep CPass1 |tee $mergedQAfileList
1129 echo $qaPlotsScript "$productionID" "cpass1" $mergedQAfileList $outputDir
1130 $qaPlotsScript "$productionID" "cpass1" $mergedQAfileList $outputDir
1133 [[ ! -d $outputDir ]] && echo "cannot make the output dir $outputDir" && exit 1
1134 mv -f $runpath/* $outputDir
1141 [[ $# -lt 3 ]] && echo "goWaitForOutput() wrong number of arguments, exiting.." && exit 1
1144 echo numberOfFiles=$3
1145 echo maxSecondsToWait=$4
1151 echo "command to be executed: find $searchPath -name "$fileName" ${extraFindOptions}"
1152 [[ -z "$maxSecondsToWait" ]] && maxSecondsToWait=$(( 3600*12 ))
1154 n=$(find $searchPath -name "$fileName" ${extraFindOptions}| wc -l)
1155 [[ $n -gt 0 ]] && echo "found $n X $fileName"
1156 [[ $n -ge $numberOfFiles ]] && break
1157 [[ $SECONDS -gt $maxSecondsToWait ]] && break
1159 echo "DONE! exiting..."
1165 [[ $# -ne 6 ]] && echo "6 args needed, you supplied $#" && exit 1
1173 newFarm=$(which qsub|grep "^/usr/bin/qsub")
1177 if [[ -z "$newFarm" ]]
1180 # submit it (as job array)
1181 nFiles=$(( $endID-$startID+1 ))
1182 while [ $startID -le $nFiles ] ; do
1183 if [ `expr $nFiles - $startID` -gt 999 ] ; then
1184 endID=`expr $startID + 999`
1188 if [[ -z "$waitForJOBID" ]]; then
1189 echo $batchCommand -J "$JobID[$startID-$endID]" -e "$targetDirectory/logs/job_%I.err" -o "$targetDirectory/logs/job_%I.out" "$command"
1190 $batchCommand -J "$JobID[$startID-$endID]" -e "$targetDirectory/logs/job_%I.err" -o "$targetDirectory/logs/job_%I.out" "$command"
1192 echo $batchCommand -J "$JobID[$startID-$endID]" -w "ended($waitForJOBID)" -e "$targetDirectory/logs/job_%I.err" -o "$targetDirectory/logs/job_%I.out" "$command"
1193 $batchCommand -J "$JobID[$startID-$endID]" -w "ended($waitForJOBID)" -e "$targetDirectory/logs/job_%I.err" -o "$targetDirectory/logs/job_%I.out" "$command"
1195 startID=`expr $endID + 1`
1199 if [[ -z "$waitForJOBID" ]]; then
1200 echo $batchCommand -wd ${targetDirectory} -b y -V -N "$JobID" -t "$startID-$endID" -e "$targetDirectory/logs/" -o "$targetDirectory/logs/" "$command" $commandArgs
1201 $batchCommand -wd ${targetDirectory} -b y -V -N "$JobID" -t "$startID-$endID" -e "$targetDirectory/logs/" -o "$targetDirectory/logs/" "$command" $commandArgs
1203 echo $batchCommand -wd ${targetDirectory} -b y -V -N "$JobID" -t "$startID-$endID" -hold_jid "$waitForJOBID" -e "$targetDirectory/logs/" -o "$targetDirectory/logs/" "$command" $commandArgs
1204 $batchCommand -wd ${targetDirectory} -b y -V -N "$JobID" -t "$startID-$endID" -hold_jid "$waitForJOBID" -e "$targetDirectory/logs/" -o "$targetDirectory/logs/" "$command" $commandArgs
1213 exec > >(tee test.log)
1222 # save aliroot svn info
1223 [[ -z "$ALICE_ROOT" ]] && exit 1
1226 echo "\$ALICE_ROOT=$ALICE_ROOT"
1228 svn info 2>/dev/null
1231 svn diff 2>/dev/null
1236 MakeListOfQAresults()
1240 if [[ $# -eq 0 ]]; then
1241 echo "make an input file list for the qa script"
1242 echo "Usage: $0 path filename"
1249 while read entry; do
1250 runNumber=$(guessRunNumber $entry)
1251 echo "$runNumber 0 1 10 $entry"
1252 done < <(find $path -name $fileName)
1259 # $1 - year to be set
1260 # $2 - where to set the year
1261 year1=$(guessYear $1)
1262 year2=$(guessYear $2)
1264 [[ $year1 -ne $year2 && -n $year2 ]] && path=${2/\/$year2\//\/$year1\/}
1270 #guess the period from the path, pick the rightmost one
1272 declare -a path=( $1 )
1273 local dirDepth=${#path[*]}
1274 for ((x=${dirDepth}-1;x>=0;x--)); do
1275 local field=${path[${x}]}
1276 [[ ${field} =~ ^LHC[0-9][0-9][a-z]$ ]] && period=${field#000} && break
1283 #guess the year from the path, pick the rightmost one
1285 declare -a path=( $1 )
1286 local dirDepth=${#path[*]}
1287 for ((x=${dirDepth}-1;x>=0;x--)); do
1288 local field=${path[${x}]}
1289 [[ ${field} =~ ^20[0-9][0-9]$ ]] && year=${field#000} && break
1296 #guess the run number from the path, pick the rightmost one
1298 declare -a path=( $1 )
1299 local dirDepth=${#path[*]}
1300 for ((x=${dirDepth}-1;x>=0;x--)); do
1301 local field=${path[${x}]}
1302 [[ ${field} =~ ^000[0-9][0-9][0-9][0-9][0-9][0-9]$ ]] && runNumber=${field#000} && break
1309 #print a summary of logs
1317 "error while loading shared libraries"
1320 "Thread [0-9]* (Thread"
1323 for log in ${logFiles[*]}; do
1324 finallog=${outputDir%/}/${log}
1325 [[ ! -f $log ]] && continue
1327 for ((i=0; i<${#errorConditions[@]};i++)); do
1328 local tmp=$(grep -m1 -e "${errorConditions[$i]}" $log)
1329 [[ -n $tmp ]] && tmp+=" : "
1332 if [[ -z $errorSummary ]]; then
1333 #in pretend mode randomly report an error in rec.log some cases
1334 if [[ -n $pretend && "$log" == "rec.log" ]]; then
1335 [[ $(( $RANDOM%2 )) -ge 1 ]] && echo "$finallog BAD random error" || echo "$finallog OK"
1341 echo "$finallog BAD $errorSummary"
1347 spitOutLocalOCDBaccessConfig()
1350 find $1 -name "*root" | \
1353 local tmp=${line#$1}
1355 awk -v ocdb=$1 '{print " man->SetSpecificStorage(\""$1"\",\"local://"ocdb"\");"}'
1359 goConfigureOCDBforCPass1()
1362 # make a script that sets the specific storages form all the root files produced by CPass0
1363 # in this case the second argument is taken to be the path to the produced OCDB for specific storage
1364 local localOCDBpathCPass0=$1
1366 [[ -d $outputDir ]] && cd $outputDir
1368 if [[ -f $localOCDBpathCPass0 && $localOCDBpathCPass0 =~ \.tgz$ ]]; then
1369 tar xzf $localOCDBpathCPass0
1370 local localOCDBpathCPass0="./OCDB"
1374 echo creating the specific storage script
1375 echo localOCDBaccessConfig.C
1376 echo based on OCDB: $fileName
1379 local tempLocalOCDB=""
1380 if [[ -f localOCDBaccessConfig.C ]]; then
1381 tempLocalOCDB=$(mktemp)
1382 echo "egrep "SetSpecificStorage" localOCDBaccessConfig.C > $tempLocalOCDB"
1383 egrep "SetSpecificStorage" localOCDBaccessConfig.C > $tempLocalOCDB
1386 echo "localOCDBaccessConfig()" > localOCDBaccessConfig.C
1387 echo "{" >> localOCDBaccessConfig.C
1388 echo " AliCDBManager* man = AliCDBManager::Instance();" >> localOCDBaccessConfig.C
1389 spitOutLocalOCDBaccessConfig $localOCDBpathCPass0|sort|uniq >> localOCDBaccessConfig.C
1390 [[ -f "$tempLocalOCDB" ]] && cat $tempLocalOCDB >> localOCDBaccessConfig.C
1391 echo "}" >> localOCDBaccessConfig.C
1393 [[ -f "$tempLocalOCDB" ]] && rm -f $tempLocalOCDB
1395 if ! grep SetSpecificStorage localOCDBaccessConfig.C; then
1397 echo "!!!!!!! CPass0 produced no OCDB entries"