3 import globalDictionaries
4 from genericValidation
import GenericValidationData
5 from helperFunctions
import replaceByMap, addIndex
6 from TkAlExceptions
import AllInOneError
10 def __init__(self, valName, alignment, config, addDefaults = {}, addMandatories = [],
11 configBaseName =
"TkAlOfflineValidation", scriptBaseName =
"TkAlOfflineValidation", crabCfgBaseName =
"TkAlOfflineValidation",
12 resultBaseName =
"AlignmentValidation", outputBaseName =
"AlignmentValidation"):
14 "DMRMethod":
"median,rmsNorm",
17 "offlineModuleLevelHistsTransient":
"False",
18 "offlineModuleLevelProfiles":
"True",
19 "OfflineTreeBaseDir":
"TrackHitFilter",
20 "SurfaceShapes":
"coarse",
21 "stripYResiduals":
"False",
23 mandatories = [
"trackcollection" ]
24 defaults.update(addDefaults)
25 mandatories += addMandatories
32 GenericValidationData.__init__(self, valName, alignment, config,
33 "offline", addDefaults=defaults,
34 addMandatories=mandatories)
38 self.alignmentToValidate.name )
40 if self.
NJobs > 1
and self.
general[
"offlineModuleLevelHistsTransient"] ==
"True":
41 msg = (
"To be able to merge results when running parallel jobs,"
42 " set offlineModuleLevelHistsTransient to false.")
45 templateToUse = configTemplates.offlineTemplate
47 if "Cosmics" in self.
general[
"trackcollection"]:
48 Bfield = self.dataset.magneticFieldForRun()
49 if Bfield > 3.3
and Bfield < 4.3:
50 templateToUse = configTemplates.CosmicsOfflineValidation
51 print (
"B field for %s = %sT. Using the template for cosmics at 3.8T.\n"
52 "To override this behavior, specify AutoAlternates = false in the [alternateTemplates] section") % (self.dataset.name(), Bfield)
54 templateToUse = configTemplates.CosmicsAt0TOfflineValidation
55 print (
"B field for %s = %sT. Using the template for cosmics at 0T.\n"
56 "To override this behavior, specify AutoAlternates = false in the [alternateTemplates] section") % (self.dataset.name(), Bfield)
59 if "unknown " in Bfield:
60 msg = Bfield.replace(
"unknown ",
"",1)
61 elif "Bfield" is "unknown":
62 msg =
"Can't get the B field for %s." % self.dataset.name()
64 msg =
"B field for %s = %sT. This is not that close to 0T or 3.8T." % (self.dataset.name(), Bfield)
66 "To use this data, turn off the automatic alternates using AutoAlternates = false\n"
67 "in the [alternateTemplates] section, and choose the alternate template yourself.")
69 cfgs = {cfgName: templateToUse}
71 GenericValidationData.defaultReferenceName ] = repMap[
"finalResultFile"]
72 return GenericValidationData.createConfiguration(self, cfgs, path, repMap = repMap)
75 return GenericValidationData.createScript(self, path)
79 return GenericValidationData.createCrabCfg(self, path, self.
crabCfgBaseName)
82 repMap = GenericValidationData.getRepMap(self, alignment)
84 "nEvents": self.
general[
"maxevents"],
85 "TrackSelectionTemplate": configTemplates.TrackSelectionTemplate,
86 "LorentzAngleTemplate": configTemplates.LorentzAngleTemplate,
87 "offlineValidationMode":
"Standalone",
88 "offlineValidationFileOutput": configTemplates.offlineFileOutputTemplate,
89 "TrackCollection": self.
general[
"trackcollection"],
96 if no argument or "" is passed a string with an instantiation is
97 returned, else the validation is appended to the list
100 if validationsSoFar ==
"":
101 validationsSoFar = (
'PlotAlignmentValidation p("root://eoscms//eos/cms%(finalResultFile)s",'
102 '"%(title)s", %(color)s, %(style)s);\n')%repMap
104 validationsSoFar += (
' p.loadFileList("root://eoscms//eos/cms%(finalResultFile)s", "%(title)s",'
105 '%(color)s, %(style)s);\n')%repMap
106 return validationsSoFar
110 if no argument or "" is passed a string with an instantiation is returned,
111 else the validation is appended to the list
115 parameters =
"root://eoscms//eos/cms" +
",root://eoscms//eos/cms".
join(repMap[
"resultFiles"])
117 mergedoutputfile =
"root://eoscms//eos/cms%(finalResultFile)s"%repMap
118 validationsSoFar += (
'root -x -b -q -l "TkAlOfflineJobsMerge.C(\\\"'
119 +parameters+
'\\\",\\\"'+mergedoutputfile+
'\\\")"'
121 return validationsSoFar
124 def __init__(self, valName, alignment, config, configBaseName = "TkAlOfflineValidationDQM"):
125 OfflineValidation.__init__(self, valName, alignment, config,
126 configBaseName = configBaseName)
127 if not config.has_section(
"DQM"):
128 msg =
"You need to have a DQM section in your configfile!"
136 OfflineValidation.createConfiguration(self, path)
139 return OfflineValidation.createScript(self, path)
142 repMap = OfflineValidation.getRepMap(self, alignment)
144 "workdir": os.path.expandvars(repMap[
"workdir"]),
145 "offlineValidationMode":
"Dqm",
146 "offlineValidationFileOutput": configTemplates.offlineDqmFileOutputTemplate,
147 "workflow": (
"/%s/TkAl%s-.oO[alignmentName]Oo._R%09i_R%09i_"
148 "ValSkim-v1/ALCARECO"
150 datetime.datetime.now().strftime(
"%y"),
154 if "__" in repMap[
"workflow"]:
155 msg = (
"the DQM workflow specefication must not contain '__'. "
156 "it is: %s"%repMap[
"workflow"])
static std::string join(char **cmd)
def appendToExtendedValidation