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