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 "offlineModuleLevelHistsTransient":
"False",
15 "offlineModuleLevelProfiles":
"True",
16 "stripYResiduals":
"False",
18 deprecateddefaults = {
22 "OfflineTreeBaseDir":
"",
26 mandatories = [
"trackcollection" ]
27 defaults.update(deprecateddefaults)
28 defaults.update(addDefaults)
29 mandatories += addMandatories
36 GenericValidationData.__init__(self, valName, alignment, config,
37 "offline", addDefaults=defaults,
38 addMandatories=mandatories)
40 for option
in deprecateddefaults:
42 raise AllInOneError(
"The '%s' option has been moved to the [plots:offline] section. Please specify it there."%option)
47 self.alignmentToValidate.name )
49 if self.
NJobs > 1
and self.
general[
"offlineModuleLevelHistsTransient"] ==
"True":
50 msg = (
"To be able to merge results when running parallel jobs,"
51 " set offlineModuleLevelHistsTransient to false.")
54 templateToUse = configTemplates.offlineTemplate
56 if "Cosmics" in self.
general[
"trackcollection"]:
57 Bfield = self.dataset.magneticFieldForRun()
58 if Bfield > 3.3
and Bfield < 4.3:
59 templateToUse = configTemplates.CosmicsOfflineValidation
60 print (
"B field for %s = %sT. Using the template for cosmics at 3.8T.\n"
61 "To override this behavior, specify AutoAlternates = false in the [alternateTemplates] section") % (self.dataset.name(), Bfield)
63 templateToUse = configTemplates.CosmicsAt0TOfflineValidation
64 print (
"B field for %s = %sT. Using the template for cosmics at 0T.\n"
65 "To override this behavior, specify AutoAlternates = false in the [alternateTemplates] section") % (self.dataset.name(), Bfield)
68 if "unknown " in Bfield:
69 msg = Bfield.replace(
"unknown ",
"",1)
70 elif "Bfield" is "unknown":
71 msg =
"Can't get the B field for %s." % self.dataset.name()
73 msg =
"B field for %s = %sT. This is not that close to 0T or 3.8T." % (self.dataset.name(), Bfield)
75 "To use this data, turn off the automatic alternates using AutoAlternates = false\n"
76 "in the [alternateTemplates] section, and choose the alternate template yourself.")
78 cfgs = {cfgName: templateToUse}
80 GenericValidationData.defaultReferenceName ] = repMap[
"finalResultFile"]
81 return GenericValidationData.createConfiguration(self, cfgs, path, repMap = repMap)
84 return GenericValidationData.createScript(self, path)
88 return GenericValidationData.createCrabCfg(self, path, self.
crabCfgBaseName)
91 repMap = GenericValidationData.getRepMap(self, alignment)
93 "nEvents": self.
general[
"maxevents"],
94 "TrackSelectionTemplate": configTemplates.TrackSelectionTemplate,
95 "LorentzAngleTemplate": configTemplates.LorentzAngleTemplate,
96 "offlineValidationMode":
"Standalone",
97 "offlineValidationFileOutput": configTemplates.offlineFileOutputTemplate,
98 "TrackCollection": self.
general[
"trackcollection"],
105 if no argument or "" is passed a string with an instantiation is
106 returned, else the validation is appended to the list
109 if validationsSoFar ==
"":
110 validationsSoFar = (
'PlotAlignmentValidation p("root://eoscms//eos/cms%(finalResultFile)s",'
111 '"%(title)s", %(color)s, %(style)s, .oO[bigtext]Oo.);\n')%repMap
113 validationsSoFar += (
' p.loadFileList("root://eoscms//eos/cms%(finalResultFile)s", "%(title)s",'
114 '%(color)s, %(style)s);\n')%repMap
115 return validationsSoFar
119 if no argument or "" is passed a string with an instantiation is returned,
120 else the validation is appended to the list
124 parameters =
"root://eoscms//eos/cms" +
",root://eoscms//eos/cms".
join(repMap[
"resultFiles"])
126 mergedoutputfile =
"root://eoscms//eos/cms%(finalResultFile)s"%repMap
127 validationsSoFar += (
'root -x -b -q -l "TkAlOfflineJobsMerge.C(\\\"'
128 +parameters+
'\\\",\\\"'+mergedoutputfile+
'\\\")"'
130 return validationsSoFar
133 def __init__(self, valName, alignment, config, configBaseName = "TkAlOfflineValidationDQM"):
134 OfflineValidation.__init__(self, valName, alignment, config,
135 configBaseName = configBaseName)
136 if not config.has_section(
"DQM"):
137 msg =
"You need to have a DQM section in your configfile!"
145 OfflineValidation.createConfiguration(self, path)
148 return OfflineValidation.createScript(self, path)
151 repMap = OfflineValidation.getRepMap(self, alignment)
153 "workdir": os.path.expandvars(repMap[
"workdir"]),
154 "offlineValidationMode":
"Dqm",
155 "offlineValidationFileOutput": configTemplates.offlineDqmFileOutputTemplate,
156 "workflow": (
"/%s/TkAl%s-.oO[alignmentName]Oo._R%09i_R%09i_"
157 "ValSkim-v1/ALCARECO"
159 datetime.datetime.now().strftime(
"%y"),
163 if "__" in repMap[
"workflow"]:
164 msg = (
"the DQM workflow specefication must not contain '__'. "
165 "it is: %s"%repMap[
"workflow"])
static std::string join(char **cmd)
def appendToExtendedValidation