CMS 3D CMS Logo

offlineValidation.py
Go to the documentation of this file.
1 import os
2 import configTemplates
3 import globalDictionaries
4 from genericValidation import GenericValidationData_CTSR, ParallelValidation, ValidationWithComparison, ValidationForPresentation, ValidationWithPlots, ValidationWithPlotsSummary
5 from helperFunctions import replaceByMap, addIndex, pythonboolstring
6 from presentation import SubsectionFromList, SubsectionOnePage
7 from TkAlExceptions import AllInOneError
8 
10  configBaseName = "TkAlOfflineValidation"
11  scriptBaseName = "TkAlOfflineValidation"
12  crabCfgBaseName = "TkAlOfflineValidation"
13  resultBaseName = "AlignmentValidation"
14  outputBaseName = "AlignmentValidation"
15  defaults = {
16  "offlineModuleLevelHistsTransient": "False",
17  "offlineModuleLevelProfiles": "True",
18  "stripYResiduals": "False",
19  "maxtracks": "0",
20  }
21  deprecateddefaults = {
22  "DMRMethod":"",
23  "DMRMinimum":"",
24  "DMROptions":"",
25  "OfflineTreeBaseDir":"",
26  "SurfaceShapes":"",
27  }
28  defaults.update(deprecateddefaults)
29  mandatories = {"trackcollection"}
30  valType = "offline"
31 
32  def __init__(self, valName, alignment, config):
33  super(OfflineValidation, self).__init__(valName, alignment, config)
34 
35  for name in "offlineModuleLevelHistsTransient", "offlineModuleLevelProfiles", "stripYResiduals":
36  self.general[name] = pythonboolstring(self.general[name], name)
37 
38  for option in self.deprecateddefaults:
39  if self.general[option]:
40  raise AllInOneError("The '%s' option has been moved to the [plots:offline] section. Please specify it there."%option)
41  del self.general[option]
42 
43  if self.NJobs > 1 and self.general["offlineModuleLevelHistsTransient"] == "True":
44  msg = ("To be able to merge results when running parallel jobs,"
45  " set offlineModuleLevelHistsTransient to false.")
46  raise AllInOneError(msg)
47 
48  try:
49  self.NTracks = int(self.general["maxtracks"])
50  if self.NTracks < 0: raise ValueError
51  except ValueError:
52  raise AllInOneError("maxtracks has to be a positive integer, or 0 for no limit")
53 
54  if self.NTracks / self.NJobs != float(self.NTracks) / self.NJobs:
55  raise AllInOneError("maxtracks has to be divisible by parallelJobs")
56 
57  @property
58  def ProcessName(self):
59  return "OfflineValidator"
60 
61  @property
62  def ValidationTemplate(self):
63  return configTemplates.offlineTemplate
64 
65  @property
66  def ValidationSequence(self):
67  return configTemplates.OfflineValidationSequence
68 
69  @property
70  def FileOutputTemplate(self):
71  return configTemplates.offlineFileOutputTemplate
72 
73  def createScript(self, path):
74  return super(OfflineValidation, self).createScript(path)
75 
76  def createCrabCfg(self, path):
77  return super(OfflineValidation, self).createCrabCfg(path, self.crabCfgBaseName)
78 
79  def getRepMap(self, alignment = None):
80  repMap = super(OfflineValidation, self).getRepMap(alignment)
81  repMap.update({
82  "nEvents": self.general["maxevents"],
83  "offlineValidationMode": "Standalone",
84  "TrackCollection": self.general["trackcollection"],
85  "filetoplot": "root://eoscms//eos/cms.oO[finalResultFile]Oo.",
86  })
87 
88  return repMap
89 
90  def appendToPlots(self):
91  return ' p.loadFileList(".oO[filetoplot]Oo.", ".oO[title]Oo.", .oO[color]Oo., .oO[style]Oo.);\n'
92 
93  @classmethod
94  def initMerge(cls):
95  from plottingOptions import PlottingOptions
96  outFilePath = replaceByMap(".oO[scriptsdir]Oo./TkAlOfflineJobsMerge.C", PlottingOptions(None, cls.valType))
97  with open(outFilePath, "w") as theFile:
98  theFile.write(replaceByMap(configTemplates.mergeOfflineParJobsTemplate, {}))
99  result = super(OfflineValidation, cls).initMerge()
100  result += ("cp .oO[Alignment/OfflineValidation]Oo./scripts/merge_TrackerOfflineValidation.C .\n"
101  "rfcp .oO[mergeOfflineParJobsScriptPath]Oo. .\n")
102  return result
103 
104  def appendToMerge(self):
105  repMap = self.getRepMap()
106 
107  parameters = "root://eoscms//eos/cms" + ",root://eoscms//eos/cms".join(repMap["resultFiles"])
108 
109  mergedoutputfile = "root://eoscms//eos/cms%(finalResultFile)s"%repMap
110  return ('root -x -b -q -l "TkAlOfflineJobsMerge.C(\\\"'
111  +parameters+'\\\",\\\"'+mergedoutputfile+'\\\")"')
112 
113  @classmethod
115  return "TkAlExtendedOfflineValidation.C"
116 
117  @classmethod
119  return configTemplates.extendedValidationTemplate
120 
121  @classmethod
122  def plotsdirname(cls):
123  return "ExtendedOfflineValidation_Images"
124 
125  @classmethod
127  return "compareAlignments.cc"
128 
129  @classmethod
131  return [
132  SubsectionOnePage('chi2', r'$\chi^2$ plots'),
133  SubsectionSubdetectors('DmedianY*R_[^_]*.eps$', 'DMR'),
134  SubsectionSubdetectors('DmedianY*R.*plain.eps$', 'DMR'),
135  SubsectionSubdetectors('DmedianY*R.*split.eps$','Split DMR'),
136  SubsectionSubdetectors('DrmsNY*R_[^_]*.eps$', 'DRnR'),
137  SubsectionSubdetectors('DrmsNY*R.*plain.eps$', 'DRnR'),
138  SubsectionSubdetectors('SurfaceShape', 'Surface Shape'),
139  ]
140 
142  pageidentifiers = (
143  ("BPIX", "BPIX"),
144  ("FPIX", "FPIX"),
145  ("TIB", "TIB"),
146  ("TID", "TID"),
147  ("TOB", "TOB"),
148  ("TEC", "TEC"),
149  )
150 
152  configBaseName = "TkAlOfflineValidationDQM"
153  def __init__(self, valName, alignment, config):
154  super(OfflineValidationDQM, self).__init__(valName, alignment, config)
155  if not config.has_section("DQM"):
156  msg = "You need to have a DQM section in your configfile!"
157  raise AllInOneError(msg)
158 
159  self.__PrimaryDataset = config.get("DQM", "primaryDataset")
160  self.__firstRun = int(config.get("DQM", "firstRun"))
161  self.__lastRun = int(config.get("DQM", "lastRun"))
162 
163  def getRepMap(self, alignment = None):
164  repMap = super(OfflineValidationDQM, self).getRepMap(alignment)
165  repMap.update({
166  "workdir": os.path.expandvars(repMap["workdir"]),
167  "offlineValidationMode": "Dqm",
168  "workflow": ("/%s/TkAl%s-.oO[alignmentName]Oo._R%09i_R%09i_"
169  "ValSkim-v1/ALCARECO"
170  %(self.__PrimaryDataset,
171  datetime.datetime.now().strftime("%y"),
172  self.__firstRun, self.__lastRun)),
173  "firstRunNumber": "%i"% self.__firstRun
174  })
175  if "__" in repMap["workflow"]:
176  msg = ("the DQM workflow specefication must not contain '__'. "
177  "it is: %s"%repMap["workflow"])
178  raise AllInOneError(msg)
179  return repMap
180 
181  @property
183  return configTemplates.offlineDqmFileOutputTemplate
def getRepMap(self, alignment=None)
def pythonboolstring(string, name)
def __init__(self, valName, alignment, config)
def PlottingOptions(config, valType)
def replaceByMap(target, the_map)
— Helpers —############################
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def __init__(self, valName, alignment, config)
def getRepMap(self, alignment=None)