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 echo "dir ${outputDir}" >> ${calibDoneFile}
312 summarizeLogs >> ${calibDoneFile}
322 # find the output files and merge them
329 calibrationFilesToMergeExternal=$5
332 [[ -f ${setupAliROOTenvInCurrentShell} && -z ${alirootEnv} ]] && source $setupAliROOTenvInCurrentShell
334 runpath=${PWD}/rundir_cpass0_Merge_${runNumber}
335 [[ -z $commonOutputPath ]] && commonOutputPath=$PWD
336 [[ $reconstructInTemporaryDir -eq 1 && -n $TMPDIR ]] && runpath=$TMPDIR
337 [[ $reconstructInTemporaryDir -eq 1 && -z $TMPDIR ]] && runpath=$(mktemp -d)
340 [[ ! -d $runpath ]] && echo "not able to make the runpath $runpath" && exit 1
343 logOutputDir=$runpath
344 [[ -n $logToFinalDestination ]] && logOutputDir=$outputDir
345 [[ -z $dontRedirectStdOutToLog ]] && exec 2>&1 > $logOutputDir/mergeMakeOCDB.log
348 calibrationFilesToMerge=$calibrationFilesToMergeExternal
349 [[ -z $calibrationFilesToMerge ]] && calibrationFilesToMerge="calibrationFilesToMerge.list"
350 calibrationOutputFileName="AliESDfriends_v1.root"
351 mergingScript="mergeMakeOCDB.byComponent.sh"
352 qaFilesToMerge="qaFilesToMerge.list"
353 qaOutputFileName="QAresults*.root"
354 qaMergedOutputFileName="QAresults_merged.root"
356 echo goMergeCPass0 SETUP:
357 echo runNumber=$runNumber
358 echo outputDir=$outputDir
359 echo defaultOCDB=$defaultOCDB
360 echo calibrationFilesToMerge=$calibrationFilesToMerge
361 echo calibrationOutputFileName=$calibrationOutputFileName
362 echo mergingScript=$mergingScript
364 # copy files in case they are not already there
366 "$commonOutputPath/${calibrationFilesToMerge}"
367 "$commonOutputPath/OCDB.root"
368 "$commonOutputPath/localOCDBaccessConfig.C"
369 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.byComponent.sh"
370 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeByComponent.C"
371 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/makeOCDB.C"
372 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/merge.C"
373 "$ALICE_ROOT/PWGPP/CalibMacros/CPass0/mergeMakeOCDB.sh"
375 for file in ${filesMergeCPass0[*]}; do
376 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
379 alirootInfo > ALICE_ROOT_svn.log
385 chmod u+x $mergingScript
387 if [[ -z ${calibrationFilesToMergeExternal} ]]; then
388 echo "find $outputDir -name $calibrationOutputFileName > $calibrationFilesToMerge"
389 find $outputDir -name $calibrationOutputFileName > $calibrationFilesToMerge
392 echo "$mergingScript $calibrationFilesToMerge ${runNumber} local://./OCDB $defaultOCDB"
393 if [[ -n $pretend ]]; then
394 touch CalibObjects.root
397 mkdir -p ./OCDB/someDetector/
398 mkdir -p ./OCDB/otherDetector/
399 touch ./OCDB/someDetector/someCalibObject_0-999999_cpass0.root
400 touch ./OCDB/otherDetector/otherCalibObject_0-999999_cpass0.root
402 ./$mergingScript $calibrationFilesToMerge ${runNumber} "local://./OCDB" $defaultOCDB
405 ### produce the output
406 #tar the produced OCDB for reuse
407 tar czf $commonOutputPath/cpass0.localOCDB.${runNumber}.tgz ./OCDB
411 #copy all to output dir
412 cp --recursive ${runpath}/* $outputDir
414 #validate merging cpass0
416 calibDoneFile="${commonOutputPath}/merge.cpass0.run${runNumber}.done"
417 touch ${calibDoneFile}
418 [[ -f CalibObjects.root ]] && echo "calibfile $outputDir/CalibObjects.root" > ${calibDoneFile}
419 summarizeLogs >> ${calibDoneFile}
428 # find the output files and merge them
435 calibrationFilesToMergeExternal=$5
436 qaFilesToMergeExternal=$6
439 rm -f $outputDir/*.log
440 rm -f $outputDir/*.root
441 rm -f $outputDir/*done
444 [[ -f ${setupAliROOTenvInCurrentShell} && -z ${alirootEnv} ]] && source $setupAliROOTenvInCurrentShell
446 runpath=${PWD}/rundir_cpass1_Merge_${runNumber}
447 [[ -z $commonOutputPath ]] && commonOutputPath=$PWD
448 [[ $reconstructInTemporaryDir -eq 1 && -n $TMPDIR ]] && runpath=$TMPDIR
449 [[ $reconstructInTemporaryDir -eq 1 && -z $TMPDIR ]] && runpath=$(mktemp -d)
452 [[ ! -d $runpath ]] && echo "not able to make the runpath $runpath" && exit 1
455 logOutputDir=$runpath
456 [[ -n $logToFinalDestination ]] && logOutputDir=$outputDir
457 [[ -z $dontRedirectStdOutToLog ]] && exec 2>&1 > $logOutputDir/mergeMakeOCDB.log
460 calibrationFilesToMerge=$calibrationFilesToMergeExternal
461 [[ -z $calibrationFilesToMerge ]] && calibrationFilesToMerge="calibrationFilesToMerge.list"
462 calibrationOutputFileName="AliESDfriends_v1.root"
463 mergingScript="mergeMakeOCDB.byComponent.sh"
464 qaFilesToMerge=$qaFilesToMergeExternal
465 [[ -z $qaFilesToMerge ]] && qaFilesToMerge="qaFilesToMerge.list"
466 qaOutputFileName="QAresults*.root"
467 qaMergedOutputFileName="QAresults_merged.root"
469 echo goMergeCPass1 SETUP:
470 echo runNumber=$runNumber
471 echo outputDir=$outputDir
472 echo defaultOCDB=$defaultOCDB
473 echo calibrationFilesToMerge=filesToMerge.list
474 echo calibrationOutputFileName=$calibrationOutputFileName
475 echo mergingScript=$mergingScript
477 # copy files in case they are not already there
479 "$commonOutputPath/${calibrationFilesToMerge}"
480 "$commonOutputPath/${qaFilesToMerge}"
481 "$commonOutputPath/OCDB.root"
482 "$commonOutputPath/localOCDBaccessConfig.C"
483 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeMakeOCDB.byComponent.sh"
484 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeByComponent.C"
485 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/makeOCDB.C"
486 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/merge.C"
487 "$ALICE_ROOT/PWGPP/CalibMacros/CPass1/mergeMakeOCDB.sh"
489 for file in ${filesMergeCPass1[*]}; do
490 [[ ! -f ${file##*/} && -f ${file} ]] && echo "copying ${file}" && cp -f ${file} .
493 alirootInfo > ALICE_ROOT_svn.log
499 chmod u+x $mergingScript
501 if [[ -z ${calibrationFilesToMergeExternal} ]]; then
502 echo "find $outputDir -name $calibrationOutputFileName > $calibrationFilesToMerge"
503 find $outputDir -name $calibrationOutputFileName > $calibrationFilesToMerge
506 echo "$mergingScript $calibrationFilesToMerge ${runNumber} local://./OCDB $defaultOCDB"
507 if [[ -n $pretend ]]; then
508 touch CalibObjects.root
512 ./$mergingScript $calibrationFilesToMerge ${runNumber} "local://./OCDB" $defaultOCDB
515 tar czf localCPass1_${runNumber}.tgz ./OCDB
518 [[ -n ${AliAnalysisTaskFilteredTree_fLowPtTrackDownscaligF} ]] && export AliAnalysisTaskFilteredTree_fLowPtTrackDownscaligF
519 [[ -n ${AliAnalysisTaskFilteredTree_fLowPtV0DownscaligF} ]] && export AliAnalysisTaskFilteredTree_fLowPtV0DownscaligF
521 if [[ -z $qaFilesToMergeExternal ]]; then
522 echo "find $outputDir -name $qaOutputFileName > $qaFilesToMerge"
523 find $outputDir -name $qaOutputFileName > $qaFilesToMerge
526 echo aliroot -l -b -q "merge.C(\"$qaFilesToMerge\",\"\",kFALSE,\"$qaMergedOutputFileName\")"
527 if [[ -n $pretend ]]; then
528 touch $qaMergedOutputFileName
531 aliroot -l -b -q "merge.C(\"$qaFilesToMerge\",\"\",kFALSE,\"$qaMergedOutputFileName\")"
536 #copy all to output dir
537 cp --recursive ${runpath}/* ${outputDir}
539 #validate merge cpass1
541 calibDoneFile="${commonOutputPath}/merge.cpass1.run${runNumber}.done"
542 touch ${calibDoneFile}
543 [[ -f CalibObjects.root ]] && echo "calibfile $outputDir/CalibObjects.root" > ${calibDoneFile}
544 [[ -f $qaMergedOutputFileName ]] && echo "qafile $outputDir/$qaMergedOutputFileName" >> ${calibDoneFile}
545 echo "dir ${outputDir}" >> ${calibDoneFile}
546 summarizeLogs >> ${calibDoneFile}
556 # log filtering, script needs to take the base dir as argument
557 if [[ -x $logFilteringScript ]]; then
558 commonOutputPath=${baseOutputDirectory}/${productionID}
559 ${logFilteringScript} $commonOutputPath
562 awk 'BEGIN {nFiles=0;} /^calibfile/ {nFiles++;} END {print "cpass0 produced "nFiles" calib files";}' cpass0.job*done
563 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
564 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
566 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
567 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
569 awk 'BEGIN {nFiles=0;} /^calibfile/ {nFiles++;} END {print "cpass1 produced "nFiles" calib files";}' cpass1.job*done
570 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
571 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
573 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
574 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
576 #if set email the summary
577 [[ -n $mailSummaryTo ]] && cat $log | mail -s "benchmark $productionID done" $mailSummaryTo
584 #generate the makeflow file and run
590 [[ -z ${configFile} ]] && configFile="benchmark.config"
591 [[ ! -f ${configFile} ]] && echo "no config file found (${configFile})" && return 1
595 goGenerateMakeflow "$@" > benchmark.makeflow
596 makeflow ${makeflowOptions} benchmark.makeflow
601 #generate the makeflow file
607 [[ -z ${configFile} ]] && configFile="benchmark.config"
608 [[ ! -f ${configFile} ]] && echo "no config file found (${configFile})" && return 1
611 commonOutputPath=${baseOutputDirectory}/${productionID}
613 #these files will be made a dependency - will be copied to the working dir of the jobs
617 "localOCDBaccessConfig.C"
619 for file in ${inputFiles[*]}; do
620 [[ -f ${file} ]] && copyFiles+=("${file}")
623 #create the makeflow file
624 declare -a arr_cpass1_final
625 declare -a arr_cpass1_QA_final
626 listOfRuns=${runNumber}
627 [[ -z ${runNumber} ]] && listOfRuns=($(while read x; do guessRunNumber $x; done < ${inputFileList} | sort | uniq))
629 for runNumber in ${listOfRuns[*]}; do
630 [[ -z $runNumber ]] && continue
631 [[ ! ${runNumber} =~ ^[0-9]*[0-9]$ ]] && continue
634 unset arr_cpass0_outputs
635 unset arr_cpass1_outputs
636 declare -a arr_cpass0_outputs
637 declare -a arr_cpass1_outputs
638 unset arr_cpass0_outputs
640 while read inputFile; do
641 currentDefaultOCDB=${defaultOCDB}
642 [[ ${autoOCDB} -ne 0 ]] && currentDefaultOCDB=$(setYear $inputFile $defaultOCDB)
645 arr_cpass0_outputs[$jobindex]="cpass0.job${jobindex}.run${runNumber}.done"
646 echo "${arr_cpass0_outputs[$jobindex]}: benchmark.sh ${configFile} ${copyFiles[@]}"
647 echo " ${alirootEnv} ./benchmark.sh CPass0 ${commonOutputPath}/cpass0/000${runNumber} $inputFile $nEvents $currentDefaultOCDB $configFile $runNumber $jobindex"
651 arr_cpass1_outputs[$jobindex]="cpass1.job${jobindex}.run${runNumber}.done"
652 echo "${arr_cpass1_outputs[$jobindex]} : benchmark.sh ${configFile} cpass0.localOCDB.${runNumber}.tgz ${copyFiles[@]}"
653 echo " ${alirootEnv} ./benchmark.sh CPass1 ${commonOutputPath}/cpass1/000${runNumber} $inputFile $nEvents $currentDefaultOCDB $configFile $runNumber $jobindex"
657 done< <(grep "/000$runNumber/" $inputFileList)
659 #CPass0 list of Calib files to merge
660 echo "cpass0.calib.run${runNumber}.list: ${arr_cpass0_outputs[*]}"
661 echo " awk '/^calibfile / {print "'\$2'"}' ${arr_cpass0_outputs[*]} > cpass0.calib.run${runNumber}.list"
664 #CPass1 list of Calib/QA files to merge
665 # the trick is to have the string "Stage" in the file name of the list of directories with QA output to trigger
666 # the production of the trending tree (only then the task->Finish() will be called in QAtrain_duo.C, on the grid
667 # this corresponds to the last merging stage)
668 echo "cpass1.calib.run${runNumber}.list cpass1.QA.run${runNumber}.lastMergingStage.list: ${arr_cpass1_outputs[*]}"
669 echo " awk '/^calibfile / {print "'\$'"2}' ${arr_cpass1_outputs[*]} > cpass1.calib.run${runNumber}.list; awk '/^dir / {print "'\$'"2}' ${arr_cpass1_outputs[*]} > cpass1.QA.run${runNumber}.lastMergingStage.list"
673 arr_cpass0_final[$runindex]="merge.cpass0.run${runNumber}.done"
674 echo "cpass0.localOCDB.${runNumber}.tgz ${arr_cpass0_final[$runindex]}: cpass0.calib.run${runNumber}.list benchmark.sh ${configFile} ${copyFiles[@]}"
675 echo " ${alirootEnv} ./benchmark.sh MergeCPass0 ${commonOutputPath}/cpass0/000${runNumber} $currentDefaultOCDB ${configFile} $runNumber cpass0.run${runNumber}.list"
678 #CPass1 Calib/QA merging
679 arr_cpass1_final[$runindex]="merge.cpass1.run${runNumber}.done"
680 echo "${arr_cpass1_final[$runindex]}: cpass1.calib.run${runNumber}.list cpass1.QA.run${runNumber}.lastMergingStage.list benchmark.sh ${configFile} ${copyFiles[@]}"
681 echo " ${alirootEnv} ./benchmark.sh MergeCPass1 ${commonOutputPath}/cpass1/000${runNumber} $currentDefaultOCDB ${configFile} $runNumber cpass1.calib.run${runNumber}.list cpass1.QA.run${runNumber}.lastMergingStage.list"
686 #CPass1 list of final Calib/QA files
687 echo "cpass1.QA.list cpass1.calib.list: ${arr_cpass1_final[*]}"
688 echo " awk '/^calibfile / {print "'\$'"2}' ${arr_cpass1_final[*]} > cpass1.calib.list; awk '/^qafile / {print "'\$'"2}' ${arr_cpass1_final[*]} > cpass1.QA.list"
692 echo "summary.log : ${arr_cpass0_outputs[*]} ${arr_cpass1_outputs[*]} ${arr_cpass1_final[*]} ${arr_cpass0_final[*]} benchmark.sh ${configFile}"
693 echo " LOCAL ./benchmark.sh makeSummary ${configFile} |tee summary.log"
699 [[ $# -lt 5 ]] && echo "goCreateQAplots productionID pass outputDir qaFilesDirectory qaPlotScript" && exit 1
708 [[ -f ${setupAliROOTenvInCurrentShell} ]] && source $setupAliROOTenvInCurrentShell
710 runpath=${PWD}/rundir_cpass0_Merge_${runNumber}
711 [[ -z $commonOutputPath ]] && commonOutputPath=$PWD
712 [[ $reconstructInTemporaryDir -eq 1 && -n $TMPDIR ]] && runpath=$TMPDIR
713 [[ $reconstructInTemporaryDir -eq 1 && -z $TMPDIR ]] && runpath=$(mktemp -d)
716 [[ ! -d $runpath ]] && echo "not able to make the runpath $runpath" && exit 1
719 [[ -z $logOutputDir ]] && logOutputDir=$runpath
720 [[ -z $dontRedirectStdOutToLog ]] && exec 2>&1 > $logOutputDir/makeQAplots.log
723 [[ -z "$qaPlotsScript" ]] && echo "qaPlotsScript not defined"&&exit 1
725 mergedQAfileList=$outputDir/mergedQAfiles.list
726 echo "MakeListOfQAresults $qaFilesDirectory QAresults.root | grep CPass1 > $mergedQAfileList"
727 MakeListOfQAresults $qaFilesDirectory QAresults_merged.root | grep CPass1 |tee $mergedQAfileList
728 echo $qaPlotsScript "$productionID" "cpass1" $mergedQAfileList $outputDir
729 $qaPlotsScript "$productionID" "cpass1" $mergedQAfileList $outputDir
732 [[ ! -d $outputDir ]] && echo "cannot make the output dir $outputDir" && exit 1
733 mv -f $runpath/* $outputDir
740 [[ $# -lt 3 ]] && echo "goWaitForOutput() wrong number of arguments, exiting.." && exit 1
743 echo numberOfFiles=$3
744 echo maxSecondsToWait=$4
750 echo "command to be executed: find $searchPath -name "$fileName" ${extraFindOptions}"
751 [[ -z "$maxSecondsToWait" ]] && maxSecondsToWait=$(( 3600*12 ))
753 n=$(find $searchPath -name "$fileName" ${extraFindOptions}| wc -l)
754 [[ $n -gt 0 ]] && echo "found $n X $fileName"
755 [[ $n -ge $numberOfFiles ]] && break
756 [[ $SECONDS -gt $maxSecondsToWait ]] && break
758 echo "DONE! exiting..."
764 [[ $# -ne 6 ]] && echo "6 args needed, you supplied $#" && exit 1
772 newFarm=$(which qsub|grep "^/usr/bin/qsub")
776 if [[ -z "$newFarm" ]]
779 # submit it (as job array)
780 nFiles=$(( $endID-$startID+1 ))
781 while [ $startID -le $nFiles ] ; do
782 if [ `expr $nFiles - $startID` -gt 999 ] ; then
783 endID=`expr $startID + 999`
787 if [[ -z "$waitForJOBID" ]]; then
788 echo $batchCommand -J "$JobID[$startID-$endID]" -e "$targetDirectory/logs/job_%I.err" -o "$targetDirectory/logs/job_%I.out" "$command"
789 $batchCommand -J "$JobID[$startID-$endID]" -e "$targetDirectory/logs/job_%I.err" -o "$targetDirectory/logs/job_%I.out" "$command"
791 echo $batchCommand -J "$JobID[$startID-$endID]" -w "ended($waitForJOBID)" -e "$targetDirectory/logs/job_%I.err" -o "$targetDirectory/logs/job_%I.out" "$command"
792 $batchCommand -J "$JobID[$startID-$endID]" -w "ended($waitForJOBID)" -e "$targetDirectory/logs/job_%I.err" -o "$targetDirectory/logs/job_%I.out" "$command"
794 startID=`expr $endID + 1`
798 if [[ -z "$waitForJOBID" ]]; then
799 echo $batchCommand -wd ${targetDirectory} -b y -V -N "$JobID" -t "$startID-$endID" -e "$targetDirectory/logs/" -o "$targetDirectory/logs/" "$command" $commandArgs
800 $batchCommand -wd ${targetDirectory} -b y -V -N "$JobID" -t "$startID-$endID" -e "$targetDirectory/logs/" -o "$targetDirectory/logs/" "$command" $commandArgs
802 echo $batchCommand -wd ${targetDirectory} -b y -V -N "$JobID" -t "$startID-$endID" -hold_jid "$waitForJOBID" -e "$targetDirectory/logs/" -o "$targetDirectory/logs/" "$command" $commandArgs
803 $batchCommand -wd ${targetDirectory} -b y -V -N "$JobID" -t "$startID-$endID" -hold_jid "$waitForJOBID" -e "$targetDirectory/logs/" -o "$targetDirectory/logs/" "$command" $commandArgs
812 exec > >(tee test.log)
821 # save aliroot svn info
822 [[ -z "$ALICE_ROOT" ]] && exit 1
825 echo "\$ALICE_ROOT=$ALICE_ROOT"
835 MakeListOfQAresults()
839 if [[ $# -eq 0 ]]; then
840 echo "make an input file list for the qa script"
841 echo "Usage: $0 path filename"
849 runNumber=$(guessRunNumber $entry)
850 echo "$runNumber 0 1 10 $entry"
851 done < <(find $path -name $fileName)
858 # $1 - year to be set
859 # $2 - where to set the year
860 year1=$(guessYear $1)
861 year2=$(guessYear $2)
863 [[ $year1 -ne $year2 && -n $year2 ]] && path=${2/\/$year2\//\/$year1\/}
869 #guess the period from the path, pick the rightmost one
871 declare -a path=( $1 )
872 local dirDepth=${#path[*]}
873 for ((x=${dirDepth}-1;x>=0;x--)); do
874 local field=${path[${x}]}
875 [[ ${field} =~ ^LHC[0-9][0-9][a-z]$ ]] && period=${field#000} && break
882 #guess the year from the path, pick the rightmost one
884 declare -a path=( $1 )
885 local dirDepth=${#path[*]}
886 for ((x=${dirDepth}-1;x>=0;x--)); do
887 local field=${path[${x}]}
888 [[ ${field} =~ ^20[0-9][0-9]$ ]] && year=${field#000} && break
895 #guess the run number from the path, pick the rightmost one
897 declare -a path=( $1 )
898 local dirDepth=${#path[*]}
899 for ((x=${dirDepth}-1;x>=0;x--)); do
900 local field=${path[${x}]}
901 [[ ${field} =~ ^000[0-9][0-9][0-9][0-9][0-9][0-9]$ ]] && runNumber=${field#000} && break
908 #print a summary of logs
916 "error while loading shared libraries"
919 "Thread [0-9]* (Thread"
922 for log in ${logFiles[*]}; do
923 finallog=${outputDir%/}/${log}
924 [[ ! -f $log ]] && continue
926 for ((i=0; i<${#errorConditions[@]};i++)); do
927 local tmp=$(grep -m1 -e "${errorConditions[$i]}" $log)
928 [[ -n $tmp ]] && tmp+=" : "
931 if [[ -z $errorSummary ]]; then
932 #in pretend mode randomly report an error in rec.log some cases
933 if [[ -n $pretend && "$log" == "rec.log" ]]; then
934 [[ $(( $RANDOM%2 )) -ge 1 ]] && echo "$finallog BAD random error" || echo "$finallog OK"
940 echo "$finallog BAD $errorSummary"
946 spitOutLocalOCDBaccessConfig()
949 find $1 -name "*root" | \
954 awk -v ocdb=$1 '{print " man->SetSpecificStorage(\""$1"\",\"local://"ocdb"\");"}'
958 goConfigureOCDBforCPass1()
961 # make a script that sets the specific storages form all the root files produced by CPass0
962 # in this case the second argument is taken to be the path to the produced OCDB for specific storage
963 local localOCDBpathCPass0=$1
965 [[ -d $outputDir ]] && cd $outputDir
967 if [[ -f $localOCDBpathCPass0 && $localOCDBpathCPass0 =~ \.tgz$ ]]; then
968 tar xzf $localOCDBpathCPass0
969 local localOCDBpathCPass0="./OCDB"
973 echo creating the specific storage script
974 echo localOCDBaccessConfig.C
975 echo based on OCDB: $fileName
978 local tempLocalOCDB=""
979 if [[ -f localOCDBaccessConfig.C ]]; then
980 tempLocalOCDB=$(mktemp)
981 echo "egrep "SetSpecificStorage" localOCDBaccessConfig.C > $tempLocalOCDB"
982 egrep "SetSpecificStorage" localOCDBaccessConfig.C > $tempLocalOCDB
985 echo "localOCDBaccessConfig()" > localOCDBaccessConfig.C
986 echo "{" >> localOCDBaccessConfig.C
987 echo " AliCDBManager* man = AliCDBManager::Instance();" >> localOCDBaccessConfig.C
988 spitOutLocalOCDBaccessConfig $localOCDBpathCPass0|sort|uniq >> localOCDBaccessConfig.C
989 [[ -f "$tempLocalOCDB" ]] && cat $tempLocalOCDB >> localOCDBaccessConfig.C
990 echo "}" >> localOCDBaccessConfig.C
992 [[ -f "$tempLocalOCDB" ]] && rm -f $tempLocalOCDB
994 if ! grep SetSpecificStorage localOCDBaccessConfig.C; then
996 echo "!!!!!!! CPass0 produced no OCDB entries"
1005 configFile="benchmark.config"
1006 [[ -n "$3" ]] && configFile=$3
1007 configFile=$(readlink -f $configFile)
1008 [[ -n $4 ]] && runNumber=$4
1010 #redirect all output to submit.log
1011 echo "redirecting all output to ${PWD}/submit_${productionID//"/"/_}.log"
1013 exec 1>submit_${productionID//"/"/_}.log 2>&1
1017 if [[ -z "$inputList" || -z "$productionID" ]]
1020 echo " Usage: $0 submit inputList productionID [configFile=benchmark.config]"
1025 date=`date +%Y-%m-%d_%H%M%S`
1027 # check if config file is there
1028 if [ ! -f $configFile ]; then
1029 echo "ERROR! Config File '$configFile' not found" >&2
1032 echo "Using Config File: '$configFile'"
1035 # source the config file
1036 # and print the configuration
1038 [[ -f ${setupAliROOTenvInCurrentShell} && -z ${alirootEnv} ]] && source $setupAliROOTenvInCurrentShell
1040 self=$(readlink -f "$0")
1041 configPath=`dirname $self`
1042 #exporting makes it available in the environment on the nodes - makes the summary output go there
1043 export commonOutputPath=${baseOutputDirectory}/${productionID}
1045 #[[ -z ${ALIROOT_RELEASE} ]] && ALIROOT_RELEASE=${ALICE_ROOT//"/"/"_"}
1046 #ALIROOT_RELEASE_mod=${ALIROOT_RELEASE//"/"/"_"}
1047 #ALIROOT_BASEDIR_mod=${ALIROOT_BASEDIR//"/"/"_"}
1048 #productionID=${ALIROOT_BASEDIR_mod}_${ALIROOT_RELEASE_mod}/${productionID}
1050 #convert to absolut pathnames
1051 inputList=$(readlink -f "$inputList")
1053 if [[ -z $runNumber ]]; then
1054 listOfRuns=($(while read x; do guessRunNumber $x; done < ${inputList} | sort | uniq))
1056 listOfRuns=$runNumber
1059 setupAliROOTenvInCurrentShell=$(readlink -f "$setupAliROOTenvInCurrentShell")
1062 echo "### BEGIN CONFIGURATION ###"
1066 echo " productionID: $productionID"
1067 echo " batchCommand: $batchCommand"
1068 echo " setupAliROOTenvInCurrentShell: $setupAliROOTenvInCurrentShell"
1069 echo " ALICE_ROOT: $ALICE_ROOT"
1070 echo " ALIROOT_RELEASE: $ALICE_RELEASE"
1071 echo " inputList: $inputList"
1072 echo " configPath: $configPath"
1073 echo " commonOutputPath: $commonOutputPath"
1074 echo " defaultOCDB: $defaultOCDB"
1075 echo " autoOCDB: $autoOCDB"
1076 echo " recoTriggerOptions: $recoTriggerOptions"
1078 echo " ${listOfRuns[*]}"
1080 echo "THE TRAIN WILL RUN:"
1082 if [ $runCPass0reco -eq 1 ]; then
1083 echo " Pass0 - Recontruction"
1086 if [ $runCPass0MergeMakeOCDB -eq 1 ]; then
1087 echo " Pass0 - merging and OCDB export"
1090 if [ $runCPass1reco -eq 1 ]; then
1091 echo " Pass1 - Recontruction"
1093 if [ $runCPass1MergeMakeOCDB -eq 1 ]; then
1094 echo " Pass1 - merging and OCDB export"
1099 echo " max. Events/Chunk: $nEvents"
1100 echo " max. Number of Chunks per Run: $nMaxChunks"
1102 echo "### END CONFIGURATION ###"
1106 # check if input file is there
1107 if [ ! -f $inputList ]; then
1108 echo "ERROR! Input List '$inputList' not found" >&2
1112 # define jobid (for dependent jobs)
1113 JOBID1=p0_${productionID//"/"/_}_${date}
1114 JOBID1wait=w0_${productionID//"/"/_}_${date}
1115 JOBID2=m0_${productionID//"/"/_}_${date}
1116 JOBID2wait=wm0_${productionID//"/"/_}_${date}
1117 JOBID3=op0_${productionID//"/"/_}_${date}
1118 JOBID3wait=wop0_${productionID//"/"/_}_${date}
1119 JOBID4=p1_${productionID//"/"/_}_${date}
1120 JOBID4wait=w1_${productionID//"/"/_}_${date}
1121 JOBID5=m1_${productionID//"/"/_}_${date}
1122 JOBID5wait=wm1_${productionID//"/"/_}_${date}
1123 JOBID6=s1_${productionID//"/"/_}_${date}
1124 JOBID6wait=ws1_${productionID//"/"/_}_${date}
1125 JOBID7=QA_${productionID//"/"/_}_${date}
1128 #for each run we submit one jobarray:
1129 numberOfSubmittedCPass1MergingJobs=0
1130 for runNumber in ${listOfRuns[*]}; do
1131 [[ -z $runNumber ]] && continue
1132 [[ ! ${runNumber} =~ ^[0-9]*[0-9]$ ]] && continue
1133 oneInputFile=$(egrep -m1 "$runNumber\/" ${inputList})
1134 currentDefaultOCDB=$defaultOCDB
1135 [[ $autoOCDB -ne 0 ]] && currentDefaultOCDB=$(setYear $oneInputFile $defaultOCDB)
1136 echo "submitting run $runNumber with OCDB $currentDefaultOCDB"
1138 ################################################################################
1139 ################################################################################
1140 # run the CPass0 if requested
1142 if [ $runCPass0reco -eq 1 ]; then
1145 echo "starting CPass0... for run $runNumber"
1148 # create directory and copy all files that are needed
1149 targetDirectory="${commonOutputPath}/000${runNumber}/CPass0"
1150 mkdir -p $targetDirectory
1151 mkdir -p $targetDirectory/logs
1153 localInputList=$targetDirectory/${inputList##*/}
1154 theScript="$targetDirectory/${self##*/}"
1155 cp -f $self $theScript
1156 chmod u+x $theScript
1158 rm -f $localInputList
1159 egrep "\/000$runNumber\/" $inputList >> $localInputList
1160 cp -f $configFile $targetDirectory
1161 [[ -f $configPath/runCPass0.sh ]] && cp -f $configPath/runCPass0.sh $targetDirectory && echo "## using local runCPass0.sh"
1162 [[ -f $configPath/recCPass0.C ]] && cp -f $configPath/recCPass0.C $targetDirectory && echo "## using local recCPass0.C"
1163 [[ -f $configPath/runCalibTrain.C ]] && cp -f $configPath/runCalibTrain.C $targetDirectory && echo "## using local runCalibTrain.C"
1164 [[ -f $configPath/localOCDBaccessConfig.C ]] && cp -f $configPath/localOCDBaccessConfig.C $targetDirectory && echo "## using local localOCDBaccessConfig.C"
1166 [[ -f $configPath/CPass0/runCPass0.sh ]] && cp -f $configPath/CPass0/runCPass0.sh $targetDirectory && echo "## using local runCPass0.sh"
1167 [[ -f $configPath/CPass0/recCPass0.C ]] && cp -f $configPath/CPass0/recCPass0.C $targetDirectory && echo "## using local recCPass0.C"
1168 [[ -f $configPath/CPass0/runCalibTrain.C ]] && cp -f $configPath/CPass0/runCalibTrain.C $targetDirectory && echo "## using local runCalibTrain.C"
1169 [[ -f $configPath/CPass0/localOCDBaccessConfig.C ]] && cp -f $configPath/CPass0/localOCDBaccessConfig.C $targetDirectory && echo "## using local localOCDBaccessConfig.C"
1171 echo "... files copied."
1174 # limit nFiles to nMaxChunks
1175 nFiles=`wc -l < $localInputList`
1176 [[ $nFiles -eq 0 ]] && echo "list contains ZERO files! exiting..." && exit 1
1177 echo "raw files in list: $nFiles"
1178 if [[ $nMaxChunks -gt 0 && $nMaxChunks -le $nFiles ]]; then
1181 echo "raw files to process: $nFiles"
1182 [[ -z "$percentProcessedFilesToContinue" ]] && percentProcessedFilesToContinue=100
1183 if [[ $percentProcessedFilesToContinue -eq 100 ]]; then
1184 nFilesToWaitFor=$nFiles
1186 nFilesToWaitFor=$(( $nFiles-$nFiles/(100/(100-$percentProcessedFilesToContinue)) ))
1188 echo "requested success rate is $percentProcessedFilesToContinue%"
1189 echo "merging will start after $nFilesToWaitFor jobs are done"
1191 submit $JOBID1 1 $nFiles "" "$theScript" "CPass0 $targetDirectory $localInputList $nEvents $currentDefaultOCDB $configFile $runNumber"
1193 ## submit a monitoring job that will run until a certain number of jobs are done with reconstruction
1194 submit "$JOBID1wait" 1 1 "" "$theScript" "WaitForOutput ${commonOutputPath} 'cpass0.job*.run$runNumber.done' $nFilesToWaitFor $maxSecondsToWait '-maxdepth 1'"
1197 fi #end running CPass0
1198 ################################################################################
1201 ################################################################################
1202 # submit merging of CPass0, depends on the reconstruction
1204 if [ $runCPass0MergeMakeOCDB -eq 1 ]; then
1207 echo "submit CPass0 merging for run $runNumber"
1210 targetDirectory="${commonOutputPath}/000${runNumber}/CPass0"
1211 mkdir -p $targetDirectory
1214 cp -f $self $targetDirectory
1215 [[ -f $configPath/mergeMakeOCDB.sh ]] && cp -f $configPath/mergeMakeOCDB.sh $targetDirectory && echo "## using local mergeMakeOCDB.sh"
1216 [[ -f $configPath/merge.C ]] && cp -f $configPath/merge.C $targetDirectory && echo "## using local merge.C"
1217 [[ -f $configPath/mergeMakeOCDB.byComponent.sh ]] && cp -f $configPath/mergeMakeOCDB.byComponent.sh $targetDirectory && echo "## using local mergeMakeOCDB.byComponent.sh"
1218 [[ -f $configPath/mergeByComponent.C ]] && cp -f $configPath/mergeByComponent.C $targetDirectory && echo "## using local mergeByComponent.C"
1219 [[ -f $configPath/makeOCDB.C ]] && cp -f $configPath/makeOCDB.C $targetDirectory && echo "## using local makeOCDB.C"
1221 theScript="$targetDirectory/${self##*/}"
1222 chmod u+x $theScript
1224 echo submit $JOBID2 1 1 "$LASTJOB" "$theScript" "MergeCPass0 $targetDirectory $currentDefaultOCDB $configFile $runNumber"
1225 submit $JOBID2 1 1 "$LASTJOB" "$theScript" "MergeCPass0 $targetDirectory $currentDefaultOCDB $configFile $runNumber"
1231 # end of merging CPass0
1232 ################################################################################
1234 ################################################################################
1235 ################################################################################
1236 # run the CPass1 if requested
1238 if [ $runCPass1reco -eq 1 ]; then
1240 targetDirectory="${commonOutputPath}/000${runNumber}/CPass1"
1242 # safety feature: if we are re-running for any reason we want to delete the previous output first.
1243 [[ -d $targetDirectory ]] && rm -rf $targetDirectory/* && echo "removed old output at $targetDirectory/*"
1245 ################################################################################
1246 # for the CPass1, based on the OCDB entries produced, we need to create the script
1247 # to set the specific storages to the output of CPass0
1248 # submit a job that will execute after merging/OCDB export that will do it.
1250 mkdir -p $targetDirectory
1251 mkdir -p $targetDirectory/logs
1252 cp -f $self $targetDirectory
1253 theScript="$targetDirectory/${self##*/}"
1256 echo submitting the OCDB specific storage config making script for run $runNumber
1259 [[ -f $configPath/localOCDBaccessConfig.C ]] && cp -f $configPath/localOCDBaccessConfig.C $targetDirectory && echo "## using local localOCDBaccessConfig.C"
1261 submit $JOBID3 1 1 "$LASTJOB" "$theScript" "ConfOCDB ${commonOutputPath}/000${runNumber}/CPass0/OCDB ${targetDirectory} "
1263 ################################################################################
1266 echo "starting CPass1... for run $runNumber"
1269 # create directory and copy all files that are needed
1270 mkdir -p $targetDirectory
1271 mkdir -p $targetDirectory/logs
1273 localInputList=$targetDirectory/${inputList##*/}
1274 theScript="$targetDirectory/${self##*/}"
1275 cp -f $self $theScript
1276 chmod u+x $theScript
1278 rm -f $localInputList
1279 egrep "\/000$runNumber\/" $inputList >> $localInputList
1280 cp -f $configFile $targetDirectory
1281 [[ -f $configPath/runCPass1.sh ]] && cp -f $configPath/runCPass1.sh $targetDirectory && echo "## using local runCPass1.sh"
1282 [[ -f $configPath/recCPass1.C ]] && cp -f $configPath/recCPass1.C $targetDirectory && echo "## using local recCPass1.C"
1283 [[ -f $configPath/recCPass1_OuterDet.C ]] && cp -f $configPath/recCPass1_OuterDet.C $targetDirectory && echo "## using local recCPass1_OuterDet.C"
1284 [[ -f $configPath/runCalibTrain.C ]] && cp -f $configPath/runCalibTrain.C $targetDirectory && echo "## using local runCalibTrain.C"
1285 [[ -f $configPath/QAtrain.C ]] && cp -f $configPath/QAtrain.C $targetDirectory && echo "## using local QAtrain.C"
1286 [[ -f $configPath/QAtrain_duo.C ]] && cp -f $configPath/QAtrain_duo.C $targetDirectory && echo "## using local QAtrain_duo.C"
1288 [[ -f $configPath/CPass1/runCPass1.sh ]] && cp -f $configPath/CPass1/runCPass1.sh $targetDirectory && echo "## using local runCPass1.sh"
1289 [[ -f $configPath/CPass1/recCPass1.C ]] && cp -f $configPath/CPass1/recCPass1.C $targetDirectory && echo "## using local recCPass1.C"
1290 [[ -f $configPath/CPass1/recCPass1_OuterDet.C ]] && cp -f $configPath/CPass1/recCPass1_OuterDet.C $targetDirectory && echo "## using local recCPass1_OuterDet.C"
1291 [[ -f $configPath/CPass1/runCalibTrain.C ]] && cp -f $configPath/CPass1/runCalibTrain.C $targetDirectory && echo "## using local runCalibTrain.C"
1292 [[ -f $configPath/CPass1/QAtrain.C ]] && cp -f $configPath/CPass1/QAtrain.C $targetDirectory && echo "## using local QAtrain.C"
1293 [[ -f $configPath/CPass1/QAtrain_duo.C ]] && cp -f $configPath/CPass1/QAtrain_duo.C $targetDirectory && echo "## using local QAtrain_duo.C"
1295 echo "... files copied."
1298 # limit nFiles to nMaxChunks
1299 nFiles=`wc -l < $localInputList`
1300 [[ $nFiles -eq 0 ]] && echo "list contains ZERO files! exiting..." && exit 1
1301 echo "raw files in list: $nFiles"
1302 if [[ $nMaxChunks -gt 0 && $nMaxChunks -le $nFiles ]]; then
1305 echo "raw files to process: $nFiles"
1306 [[ -z "$percentProcessedFilesToContinue" ]] && percentProcessedFilesToContinue=100
1307 if [[ $percentProcessedFilesToContinue -eq 100 ]]; then
1308 nFilesToWaitFor=$nFiles
1310 nFilesToWaitFor=$(( $nFiles-$nFiles/(100/(100-$percentProcessedFilesToContinue)) ))
1312 echo "requested success rate is $percentProcessedFilesToContinue%"
1313 echo "merging will start after $nFilesToWaitFor jobs are done"
1315 submit $JOBID4 1 $nFiles "$LASTJOB" "$theScript" "CPass1 $targetDirectory $localInputList $nEvents $currentDefaultOCDB $configFile $runNumber"
1317 ################################################################################
1318 ## submit a monitoring job that will run until a certain number of jobs are done with reconstruction
1319 submit "$JOBID4wait" 1 1 "$LASTJOB" "$theScript" "WaitForOutput ${commonOutputPath} 'cpass1.job*.run${runNumber}.done' $nFilesToWaitFor $maxSecondsToWait '-maxdepth 1'"
1321 ################################################################################
1324 fi #end running CPass1
1326 ################################################################################
1327 # submit merging of CPass1, depends on the reconstruction
1328 if [ $runCPass1MergeMakeOCDB -eq 1 ]; then
1331 echo "submit CPass1 merging for run $runNumber"
1334 targetDirectory="${commonOutputPath}/000${runNumber}/CPass1"
1335 mkdir -p $targetDirectory
1338 cp -f $self $targetDirectory
1339 [[ -f $configPath/mergeMakeOCDB.sh ]] && cp -f $configPath/mergeMakeOCDB.sh $targetDirectory && echo "## using local mergeMakeOCDB.sh"
1340 [[ -f $configPath/merge.C ]] && cp -f $configPath/merge.C $targetDirectory && echo "## using local merge.C"
1341 [[ -f $configPath/mergeMakeOCDB.byComponent.sh ]] && cp -f $configPath/mergeMakeOCDB.byComponent.sh $targetDirectory && echo "## using local mergeMakeOCDB.byComponent.sh"
1342 [[ -f $configPath/mergeByComponent.C ]] && cp -f $configPath/mergeByComponent.C $targetDirectory && echo "## using local mergeByComponent.C"
1343 [[ -f $configPath/makeOCDB.C ]] && cp -f $configPath/makeOCDB.C $targetDirectory && echo "## using local makeOCDB.C"
1345 theScript="$targetDirectory/${self##*/}"
1346 chmod u+x $theScript
1348 echo submit "$JOBID5" 1 1 "$LASTJOB" "$theScript" "MergeCPass1 $targetDirectory $currentDefaultOCDB $configFile $runNumber"
1349 submit "$JOBID5" 1 1 "$LASTJOB" "$theScript" "MergeCPass1 $targetDirectory $currentDefaultOCDB $configFile $runNumber"
1350 ((numberOfSubmittedCPass1MergingJobs++))
1357 ################################################################################
1358 ################################################################################
1359 [[ -z $runMakeSummary ]] && runMakeSummary=0
1360 if [ $runMakeSummary -eq 1 ]; then
1362 echo "submit make a summary"
1365 targetDirectory="${commonOutputPath}"
1366 mkdir -p $targetDirectory
1367 mkdir -p $targetDirectory/logs
1368 [[ ! -f $targetDirectory/${self##*/} ]] && cp -f $self $targetDirectory
1369 theScript="$targetDirectory/${self##*/}"
1370 submit "$JOBID6" 1 1 "$LASTJOB" "$theScript" "MakeSummary $targetDirectory $configFile"
1372 ################################################################################
1374 ################################################################################
1375 ################################################################################
1376 if [ $runMakeQAplots -eq 1 ]; then
1378 echo "submit make QA plots"
1381 ## submit a monitoring job that will wait for a specified number of files to appear somewhere
1382 targetDirectory="${commonOutputPath}"
1383 [[ ! -f $targetDirectory/${self##*/} ]] && cp -f $self $targetDirectory
1384 theScript="$targetDirectory/${self##*/}"
1385 echo submit "$JOBID5wait 1 1 $theScript WaitForOutput ${commonOutputPath} 'merge.cpass1.run*.done' $numberOfSubmittedCPass1MergingJobs $maxSecondsToWait '-maxdepth 1'"
1386 submit "$JOBID5wait" 1 1 "" "$theScript" "WaitForOutput ${commonOutputPath} 'merge.cpass1.run*.done' $numberOfSubmittedCPass1MergingJobs $maxSecondsToWait '-maxdepth 1'"
1389 targetDirectory="${commonOutputPath}/QAplots/"
1390 [[ -d $targetDirectory ]] && rm -rf $targetDirectory/*
1391 mkdir -p $targetDirectory
1392 mkdir -p $targetDirectory/logs
1393 qaFilesDirectory="${commonOutputPath}"
1394 [[ ! -f $targetDirectory/${self##*/} ]] && cp -f $self $targetDirectory
1395 theScript="$targetDirectory/${self##*/}"
1397 echo submit "$JOBID7" 1 1 "$LASTJOB" "$theScript" "CreateQAplots QAplots CPass1 $targetDirectory $qaFilesDirectory $qaPlotsScript $configFile"
1398 submit "$JOBID7" 1 1 "$LASTJOB" "$theScript" "CreateQAplots QAplots CPass1 $targetDirectory $qaFilesDirectory $qaPlotsScript $configFile"
1404 echo "jobs submitted."