304 if(len(validations) == 0):
305 raise AllInOneError(
"Cowardly refusing to merge nothing!")
307 config = validations[0].config
308 repMap = config.getGeneral()
311 "CompareAlignments":
"",
312 "RunExtendedOfflineValidation":
"",
313 "RunTrackSplitPlot":
"",
314 "MergeZmumuPlots":
"",
315 "RunPrimaryVertexPlot":
"",
316 "CMSSW_BASE": os.environ[
"CMSSW_BASE"],
317 "SCRAM_ARCH": os.environ[
"SCRAM_ARCH"],
318 "CMSSW_RELEASE_BASE": os.environ[
"CMSSW_RELEASE_BASE"],
322 for validation
in validations:
323 for referenceName
in validation.filesToCompare:
324 validationName =
"%s.%s"%(validation.__class__.__name__, referenceName)
325 validationName = validationName.split(
".%s"%GenericValidation.defaultReferenceName )[0]
326 validationName = validationName.split(
"Preexisting")[-1]
327 if validationName
in comparisonLists:
328 comparisonLists[ validationName ].
append( validation )
330 comparisonLists[ validationName ] = [ validation ]
334 repMap[
"haddLoop"] =
"mergeRetCode=0\n" 335 repMap[
"rmUnmerged"] = (
"if [[ mergeRetCode -eq 0 ]]; then\n" 336 " echo -e \\n\"Merging succeeded, removing original files.\"\n")
337 repMap[
"copyMergeScripts"] =
"" 338 repMap[
"mergeParallelFilePrefixes"] =
"" 342 for validationType
in comparisonLists:
343 for validation
in comparisonLists[validationType]:
344 if isinstance(validation, PreexistingValidation)
or validation.NJobs == 1:
346 if validationType
not in anythingToMerge:
347 anythingToMerge += [validationType]
348 repMap[
"haddLoop"] +=
'\n\n\n\necho -e "\n\nMerging results from %s jobs"\n\n' % validationType
349 repMap[
"haddLoop"] = validation.appendToMerge(repMap[
"haddLoop"])
350 repMap[
"haddLoop"] +=
"tmpMergeRetCode=${?}\n" 351 repMap[
"haddLoop"] += (
"if [[ tmpMergeRetCode -eq 0 ]]; then " 353 +validation.getRepMap()[
"finalOutputFile"]
354 +
" root://eoscms//eos/cms" 355 +validation.getRepMap()[
"finalResultFile"]
357 repMap[
"haddLoop"] += (
"if [[ ${tmpMergeRetCode} -gt ${mergeRetCode} ]]; then " 358 "mergeRetCode=${tmpMergeRetCode}; fi\n")
359 for f
in validation.getRepMap()[
"outputFiles"]:
360 longName = os.path.join(
"/store/caf/user/$USER/",
361 validation.getRepMap()[
"eosdir"], f)
362 repMap[
"rmUnmerged"] +=
" $eos rm "+longName+
"\n" 363 repMap[
"rmUnmerged"] += (
"else\n" 364 " echo -e \\n\"WARNING: Merging failed, unmerged" 365 " files won't be deleted.\\n" 366 "(Ignore this warning if merging was done earlier)\"\n" 369 if "OfflineValidation" in anythingToMerge:
370 repMap[
"mergeOfflineParJobsScriptPath"] = os.path.join(path,
"TkAlOfflineJobsMerge.C")
373 repMap[
"mergeOfflineParJobsScriptPath"] )
374 repMap[
"copyMergeScripts"] += (
"cp .oO[Alignment/OfflineValidation]Oo./scripts/merge_TrackerOfflineValidation.C .\n" 375 "rfcp %s .\n" % repMap[
"mergeOfflineParJobsScriptPath"])
376 repMap_offline = repMap.copy()
378 repMap[
"copyMergeScripts"] = \
379 replaceByMap(repMap[
"copyMergeScripts"], repMap_offline)
384 repMap[
"DownloadData"] +=
replaceByMap( configTemplates.mergeParallelResults, repMap )
386 repMap[
"DownloadData"] =
"" 388 if "OfflineValidation" in comparisonLists:
389 repMap[
"extendedValScriptPath"] = os.path.join(path,
"TkAlExtendedOfflineValidation.C")
391 repMap[
"extendedValScriptPath"],
393 repMap_offline = repMap.copy()
395 repMap[
"RunExtendedOfflineValidation"] = \
396 replaceByMap(configTemplates.extendedValidationExecution, repMap_offline)
398 if "TrackSplittingValidation" in comparisonLists:
399 repMap[
"trackSplitPlotScriptPath"] = \
400 os.path.join(path,
"TkAlTrackSplitPlot.C")
402 repMap[
"trackSplitPlotScriptPath"] )
403 repMap_split = repMap.copy()
405 repMap[
"RunTrackSplitPlot"] = \
406 replaceByMap(configTemplates.trackSplitPlotExecution, repMap_split)
408 if "ZMuMuValidation" in comparisonLists:
409 repMap[
"mergeZmumuPlotsScriptPath"] = \
410 os.path.join(path,
"TkAlMergeZmumuPlots.C")
412 repMap[
"mergeZmumuPlotsScriptPath"] )
413 repMap_zMuMu = repMap.copy()
415 repMap[
"MergeZmumuPlots"] = \
416 replaceByMap(configTemplates.mergeZmumuPlotsExecution, repMap_zMuMu)
418 if "PrimaryVertexValidation" in comparisonLists:
419 repMap[
"PrimaryVertexPlotScriptPath"] = \
420 os.path.join(path,
"TkAlPrimaryVertexValidationPlot.C")
423 repMap[
"PrimaryVertexPlotScriptPath"] )
424 repMap_PVVal = repMap.copy()
426 repMap[
"RunPrimaryVertexPlot"] = \
427 replaceByMap(configTemplates.PrimaryVertexPlotExecution, repMap_PVVal)
429 repMap[
"CompareAlignments"] =
"#run comparisons" 430 if "OfflineValidation" in comparisonLists:
431 compareStrings = [ val.getCompareStrings(
"OfflineValidation")
for val
in comparisonLists[
"OfflineValidation"] ]
432 compareStringsPlain = [ val.getCompareStrings(
"OfflineValidation", plain=
True)
for val
in comparisonLists[
"OfflineValidation"] ]
434 repMap_offline = repMap.copy()
436 repMap_offline.update({
"validationId":
"OfflineValidation",
437 "compareStrings":
" , ".
join(compareStrings),
438 "compareStringsPlain":
" ".
join(compareStringsPlain) })
440 repMap[
"CompareAlignments"] += \
441 replaceByMap(configTemplates.compareAlignmentsExecution, repMap_offline)
443 filePath = os.path.join(path,
"TkAlMerge.sh")
444 theFile = open( filePath,
"w" )
445 theFile.write(
replaceByMap( configTemplates.mergeTemplate, repMap ) )
447 os.chmod(filePath,0o755)
def createMergeZmumuPlotsScript(zMuMuValidationList, outFilePath)
def createExtendedValidationScript(offlineValidationList, outFilePath, resultPlotFile)
def createMergeScript(path, validations)
def createOfflineParJobsMergeScript(offlineValidationList, outFilePath)
def PlottingOptions(config, valType)
def replaceByMap(target, the_map)
— Helpers —############################
static std::string join(char **cmd)
def createPrimaryVertexPlotScript(PrimaryVertexValidationList, outFilePath)
def createTrackSplitPlotScript(trackSplittingValidationList, outFilePath)