CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
geometryComparison.GeometryComparison Class Reference
Inheritance diagram for geometryComparison.GeometryComparison:
genericValidation.GenericValidation genericValidation.ValidationMetaClass

Public Member Functions

def __init__ (self, valName, alignment, referenceAlignment, config, copyImages=True)
 
def createConfiguration (self, path)
 
def createCrabCfg (self, path)
 
def createScript (self, path)
 
def filesToCompare (self)
 
def getRepMap (self, alignment=None)
 
- Public Member Functions inherited from genericValidation.GenericValidation
def __init__ (self, valName, alignment, config)
 
def createConfiguration (self, fileContents, path, schedule=None, repMap=None, repMaps=None)
 
def createCrabCfg (self, fileContents, path)
 
def createFiles (self, fileContents, path, repMap=None, repMaps=None)
 
def createScript (self, fileContents, path, downloadFiles=[], repMap=None, repMaps=None)
 
def filesToCompare (self)
 
def getCompareStrings (self, requestId=None, plain=False)
 
def getRepMap (self, alignment=None)
 
- Public Member Functions inherited from genericValidation.ValidationMetaClass
def __new__ (cls, clsname, bases, dct)
 

Public Attributes

 copyImages
 
 referenceAlignment
 
- Public Attributes inherited from genericValidation.GenericValidation
 alignmentToValidate
 
 AutoAlternates
 
 cmssw
 
 cmsswreleasebase
 
 config
 
 configFiles
 
 crabConfigFiles
 
 general
 
 jobid
 
 jobmode
 
 name
 
 needsproxy
 
 NJobs
 
 packages
 
 randomWorkdirPart
 
 scramarch
 
 scriptFiles
 

Static Public Attributes

dictionary defaults
 
dictionary mandatories = {"levels", "dbOutput"}
 
string valType = "compare"
 
- Static Public Attributes inherited from genericValidation.GenericValidation
string defaultReferenceName = "DEFAULT"
 
dictionary defaults
 
 mandatories = set()
 
dictionary needpackages = {"Alignment/OfflineValidation"}
 
dictionary optionals = {"jobmode"}
 
- Static Public Attributes inherited from genericValidation.ValidationMetaClass
list dicts = ["defaults"]
 
list sets = ["mandatories", "optionals", "needpackages"]
 

Private Attributes

 __compares
 
 __filesToCompare
 

Detailed Description

Object representing a geometry comparison job.

Definition at line 10 of file geometryComparison.py.

Constructor & Destructor Documentation

◆ __init__()

def geometryComparison.GeometryComparison.__init__ (   self,
  valName,
  alignment,
  referenceAlignment,
  config,
  copyImages = True 
)
Constructor of the GeometryComparison class.

Arguments:
- `valName`: String which identifies individual validation instances
- `alignment`: `Alignment` instance to validate
- `referenceAlignment`: `Alignment` instance which is compared
                with `alignment`
- `config`: `BetterConfigParser` instance which includes the
    configuration of the validations
- `copyImages`: Boolean which indicates whether png- and pdf-files
        should be copied back from the batch farm

Definition at line 45 of file geometryComparison.py.

45  config, copyImages = True):
46  """
47  Constructor of the GeometryComparison class.
48 
49  Arguments:
50  - `valName`: String which identifies individual validation instances
51  - `alignment`: `Alignment` instance to validate
52  - `referenceAlignment`: `Alignment` instance which is compared
53  with `alignment`
54  - `config`: `BetterConfigParser` instance which includes the
55  configuration of the validations
56  - `copyImages`: Boolean which indicates whether png- and pdf-files
57  should be copied back from the batch farm
58  """
59  super(GeometryComparison, self).__init__(valName, alignment, config)
60  self.referenceAlignment = referenceAlignment
61  referenceName = "IDEAL"
62  if not self.referenceAlignment == "IDEAL":
63  referenceName = self.referenceAlignment.name
64 
65  allCompares = config.getCompares()
66  self.__compares = {}
67  self.__filesToCompare = {}
68  if valName in allCompares:
69  self.__compares[valName] = allCompares[valName]
70  else:
71  msg = ("Could not find compare section '%s' in '%s'"
72  %(valName, allCompares))
73  raise AllInOneError(msg)
74  self.copyImages = copyImages
75 
76  for name in "useDefaultRange", "plotOnlyGlobal", "plotPng":
77  self.general[name] = cppboolstring(self.general[name], name)
78 
79 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
def cppboolstring(string, name)

Member Function Documentation

◆ createConfiguration()

def geometryComparison.GeometryComparison.createConfiguration (   self,
  path 
)

Definition at line 114 of file geometryComparison.py.

References geometryComparison.GeometryComparison.__compares, genericValidation.GenericValidation.alignmentToValidate, genericValidation.GenericValidation.getRepMap(), alignment.Alignment.getRepMap(), helperFunctions.pythonboolstring(), geometryComparison.GeometryComparison.referenceAlignment, helperFunctions.replaceByMap(), and submitPVValidationJobs.split().

114  def createConfiguration(self, path ):
115  # self.__compares
116  repMap = self.getRepMap()
117  cfgFileName = "TkAlCompareToNTuple.%s_cfg.py"%(
118  self.alignmentToValidate.name)
119  cfgs = {cfgFileName: configTemplates.intoNTuplesTemplate}
120  repMaps = {cfgFileName: repMap}
121  if not self.referenceAlignment == "IDEAL":
122  referenceRepMap = self.getRepMap( self.referenceAlignment )
123  cfgFileName = "TkAlCompareToNTuple.%s_cfg.py"%(
124  self.referenceAlignment.name )
125  cfgs[cfgFileName] = configTemplates.intoNTuplesTemplate
126  repMaps[cfgFileName] = referenceRepMap
127 
128  cfgSchedule = list(cfgs.keys())
129  for common in self.__compares:
130  repMap.update({
131  "levels": self.__compares[common][0],
132  "dbOutput": pythonboolstring(self.__compares[common][1], "dbOutput")
133  })
134  if self.__compares[common][1].split()[0] == "true":
135  repMap["dbOutputService"] = configTemplates.dbOutputTemplate
136  else:
137  repMap["dbOutputService"] = ""
138  cfgName = replaceByMap(("TkAlCompareCommon.oO[common]Oo.."
139  ".oO[name]Oo._cfg.py"),repMap)
140  cfgs[cfgName] = configTemplates.compareTemplate
141  repMaps[cfgName] = repMap
142 
143  cfgSchedule.append( cfgName )
144  super(GeometryComparison, self).createConfiguration(cfgs, path, cfgSchedule, repMaps = repMaps)
145 
def pythonboolstring(string, name)
def replaceByMap(target, the_map)
— Helpers —############################

◆ createCrabCfg()

def geometryComparison.GeometryComparison.createCrabCfg (   self,
  path 
)

Definition at line 337 of file geometryComparison.py.

337  def createCrabCfg(self, path):
338  msg = ("Parallelization not supported for geometry comparison. Please "
339  "choose another 'jobmode'.")
340  raise AllInOneError(msg)
341 

◆ createScript()

def geometryComparison.GeometryComparison.createScript (   self,
  path 
)

Definition at line 146 of file geometryComparison.py.

References geometryComparison.GeometryComparison.__compares, geometryComparison.GeometryComparison.__filesToCompare, genericValidation.GenericValidation.configFiles, geometryComparison.GeometryComparison.copyImages, genericValidation.GenericValidation.createFiles(), helperFunctions.getCommandOutput2(), genericValidation.GenericValidation.getRepMap(), alignment.Alignment.getRepMap(), AlignableObjectId::entry.name, alignment.Alignment.name, genericValidation.GenericValidation.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, classes.MonitorData.name, classes.OutputData.name, geometry.Structure.name, plotscripts.SawTeethFunction.name, helperFunctions.replaceByMap(), submitPVValidationJobs.split(), and str.

146  def createScript(self, path):
147  repMap = self.getRepMap()
148  repMap["runComparisonScripts"] = ""
149  scriptName = replaceByMap(("TkAlGeomCompare.%s..oO[name]Oo..sh"
150  %self.name), repMap)
151 
152  y_ranges = ""
153  plottedDifferences = ["dx","dy","dz","dr","rdphi","dalpha","dbeta","dgamma"]
154  for diff in plottedDifferences:
155  y_ranges += ","+repMap["%s_min"%diff]
156  y_ranges += ","+repMap["%s_max"%diff]
157 
158  for name in self.__compares:
159  if '"DetUnit"' in self.__compares[name][0].split(","):
160  repMap["outputFile"] = (".oO[name]Oo..Comparison_common"+name+".root")
161  repMap["nIndex"] = ("")
162  repMap["runComparisonScripts"] += \
163  ("cp .oO[Alignment/OfflineValidation]Oo."
164  "/scripts/comparisonScript.C .\n"
165  "cp .oO[Alignment/OfflineValidation]Oo."
166  "/scripts/GeometryComparisonPlotter.h .\n"
167  "cp .oO[Alignment/OfflineValidation]Oo."
168  "/scripts/GeometryComparisonPlotter.cc .\n"
169  "root -b -q 'comparisonScript.C+(\""
170  ".oO[name]Oo..Comparison_common"+name+".root\",\""
171  "./\",\".oO[modulesToPlot]Oo.\",\".oO[alignmentName]Oo.\",\".oO[reference]Oo.\",.oO[useDefaultRange]Oo.,.oO[plotOnlyGlobal]Oo.,.oO[plotPng]Oo.,.oO[makeProfilePlots]Oo."+y_ranges+")'\n"
172  "cp "+path+"/TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C .\n"
173  "root -l -b -q TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C+\n")
174  if self.copyImages:
175  repMap["runComparisonScripts"] += \
176  ("mkdir -p .oO[datadir]Oo./.oO[name]Oo."
177  ".Comparison_common"+name+"_Images/Translations\n")
178  repMap["runComparisonScripts"] += \
179  ("mkdir -p .oO[datadir]Oo./.oO[name]Oo."
180  ".Comparison_common"+name+"_Images/Rotations\n")
181 
182 
183 
186 
187  if repMap["plotPng"] == "true":
188  repMap["runComparisonScripts"] += \
189  ("find . -maxdepth 1 -name \"*_1*\" "
190  "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo."
191  "/.oO[name]Oo..Comparison_common"+name+"_Images/Translations/\" \n")
192  repMap["runComparisonScripts"] += \
193  ("find . -maxdepth 1 -name \"*_2*\" "
194  "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo."
195  "/.oO[name]Oo..Comparison_common"+name+"_Images/Translations/\" \n")
196 
197  repMap["runComparisonScripts"] += \
198  ("find . -maxdepth 1 -name \"*_3*\" "
199  "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo."
200  "/.oO[name]Oo..Comparison_common"+name+"_Images/Rotations/\" \n")
201  repMap["runComparisonScripts"] += \
202  ("find . -maxdepth 1 -name \"*_4*\" "
203  "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo."
204  "/.oO[name]Oo..Comparison_common"+name+"_Images/Rotations/\" \n")
205 
206  else:
207  repMap["runComparisonScripts"] += \
208  ("find . -maxdepth 1 -name \"*_1*\" "
209  "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo."
210  "/.oO[name]Oo..Comparison_common"+name+"_Images/Translations/\" \n")
211 
212  repMap["runComparisonScripts"] += \
213  ("find . -maxdepth 1 -name \"*_2*\" "
214  "-print | xargs -I {} bash -c \"cp {} .oO[datadir]Oo."
215  "/.oO[name]Oo..Comparison_common"+name+"_Images/Rotations/\" \n")
216 
217  repMap["runComparisonScripts"] += \
218  ("find . -maxdepth 1 -name "
219  "\"*.tex\" -print | xargs -I {} bash -c"
220  " \"cp {} .oO[datadir]Oo./.oO[name]Oo."
221  ".Comparison_common"+name+"_Images/\" \n")
222  repMap["runComparisonScripts"] += \
223  ("find . -maxdepth 1 -name "
224  "\"TkMap_SurfDeform*.pdf\" -print | xargs -I {} bash -c"
225  " \"cp {} .oO[datadir]Oo./.oO[name]Oo."
226  ".Comparison_common"+name+"_Images/\" \n")
227  repMap["runComparisonScripts"] += \
228  ("find . -maxdepth 1 -name "
229  "\"TkMap_SurfDeform*.png\" -print | xargs -I {} bash -c"
230  " \"cp {} .oO[datadir]Oo./.oO[name]Oo."
231  ".Comparison_common"+name+"_Images/\" \n")
232  repMap["runComparisonScripts"] += \
233  ("cp .oO[Alignment/OfflineValidation]Oo."
234  "/macros/makeArrowPlots.C "
235  ".\n"
236  "root -b -q 'makeArrowPlots.C(\""
237  ".oO[name]Oo..Comparison_common"+name
238  +".root\",\".oO[name]Oo.."
239  +name+"_ArrowPlots\")'\n")
240  repMap["runComparisonScripts"] += \
241  ("mkdir -p .oO[datadir]Oo./.oO[name]Oo."
242  ".Comparison_common"+name+"_Images/ArrowPlots\n")
243  repMap["runComparisonScripts"] += \
244  ("find .oO[name]Oo.."+name+"_ArrowPlots "
245  "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash "
246  "-c \"cp {} .oO[datadir]Oo./.oO[name]Oo."
247  ".Comparison_common"+name+"_Images/ArrowPlots\"\n")
248  repMap["runComparisonScripts"] += \
249  ("find .oO[name]Oo.."+name+"_ArrowPlots "
250  "-maxdepth 1 -name \"*.pdf\" -print | xargs -I {} bash "
251  "-c \"cp {} .oO[datadir]Oo./.oO[name]Oo."
252  ".Comparison_common"+name+"_Images/ArrowPlots\"\n")
253  repMap["runComparisonScripts"] += \
254  ("find . "
255  "-maxdepth 1 -name \".oO[common]Oo._.oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash "
256  "-c \"cp {} .oO[datadir]Oo./.oO[name]Oo."
257  ".Comparison_common"+name+"_Images/.oO[common]Oo._.oO[name]Oo..Visualization.gif\"\n")
258 
259  # TkAlMap inFile=tree.root compAl=UL2018 refAl=StartGeom savePNG=True TkVersion=phase1 outDir=./test_plots/tanh colPal=2
260  range_str = ''
261  plottedDifferences = ["dx","dy","dz","dr","rdphi","dalpha","dbeta","dgamma"]
262  for diff in plottedDifferences:
263  range_str += diff+'_range=['+str(repMap[diff+'_min'])+','+str(repMap[diff+'_max'])+'];'
264  repMap["runComparisonScripts"] += \
265  ("mkdir -p .oO[datadir]Oo./.oO[name]Oo."
266  ".Comparison_common"+name+"_Images/TkAlMapPlots\n")
267  repMap["runComparisonScripts"] += \
268  ("python .oO[Alignment/OfflineValidation]Oo./python/runGCPTkAlMap.py -b "
269  "inFile=.oO[name]Oo..Comparison_common"+name+".root "
270  "refAl=\".oO[reference]Oo.\" "
271  "compAl=\".oO[alignmentName]Oo.\" "
272  "savePNG=True "
273  "TkVersion=\"phase0\" "
274  "colPal=2 "
275  "defRanges=\""+range_str+"\" "
276  "outDir=.oO[datadir]Oo./.oO[name]Oo..Comparison_common"+name+"_Images/TkAlMapPlots\n")
277  #"outDir=.oO[name]Oo.."+name+"_TkMapPlots "
278  #"useDefaultRanges=.oO[useDefaultRange]Oo. "+range_str+"\n")
279 
280  # Copy root file for check
281  repMap["runComparisonScripts"] += \
282  ("cp .oO[name]Oo..Comparison_common"+name+".root "
283  ".oO[datadir]Oo./.oO[name]Oo..Comparison_common"+name+"_Images/TkAlMapPlots/GCP.root\n")
284  #repMap["runComparisonScripts"] += \
285  # ("cp .oO[alignmentName]Oo.ROOTGeometry.root "
286  # ".oO[datadir]Oo./.oO[name]Oo..Comparison_common"+name+"_Images/TkAlMapPlots/comparedGeometry.root\n")
287 
288  resultingFile = replaceByMap(("/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./compared%s_"
289  ".oO[name]Oo..root"%name), repMap)
290  resultingFile = os.path.expandvars( resultingFile )
291  resultingFile = os.path.abspath( resultingFile )
292  resultingFile = "root://eoscms//eos/cms" + resultingFile #needs to be AFTER abspath so that it doesn't eat the //
293  self.__filesToCompare[ name ] = resultingFile
294 
295  else:
296  raise AllInOneError("Need to have DetUnit in levels!")
297 
298  repMap["CommandLine"]=""
299  repMap["CommandLine"]+= \
300  "# copy module list required for comparison script \n"
301  if repMap["moduleList"].startswith("/store"):
302  repMap["CommandLine"]+= \
303  "xrdcp root://eoscms//eos/cms.oO[moduleList]Oo. .\n"
304  elif repMap["moduleList"].startswith("root://"):
305  repMap["CommandLine"]+= \
306  "xrdcp .oO[moduleList]Oo. .\n"
307  elif repMap["moduleList"].startswith("./CREATE_NEW/"):
308  repMap["CommandLine"]+= \
309  "touch .oO[moduleListBase]Oo.\n"
310  else:
311  repMap["CommandLine"]+= \
312  "cp .oO[moduleList]Oo. .\n"
313 
314  try:
315  getCommandOutput2(replaceByMap("cd $(mktemp -d)\n.oO[CommandLine]Oo.\ncat .oO[moduleListBase]Oo.", repMap))
316  except RuntimeError:
317  raise AllInOneError(replaceByMap(".oO[moduleList]Oo. does not exist!", repMap))
318 
319  for cfg in self.configFiles:
320  # FIXME: produce this line only for enabled dbOutput
321  # postProcess = "cp .oO[workdir]Oo./*.db .oO[datadir]Oo.\n"
322  # postProcess = "cp *.db .oO[datadir]Oo.\n"
323  postProcess = ""
324  repMap["CommandLine"]+= \
325  repMap["CommandLineTemplate"]%{"cfgFile":cfg,
326  "postProcess":postProcess}
327  repMap["CommandLine"]+= ("# overall postprocessing\n"
328  ".oO[runComparisonScripts]Oo.\n"
329  )
330 
331  #~ print configTemplates.scriptTemplate
332  scripts = {scriptName: replaceByMap( configTemplates.scriptTemplate, repMap )}
333  files = {replaceByMap("TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C", repMap ): replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
334  self.createFiles(files, path)
335  return super(GeometryComparison, self).createScript(scripts, path)
336 
def getCommandOutput2(command)
def replaceByMap(target, the_map)
— Helpers —############################
#define str(s)

◆ filesToCompare()

def geometryComparison.GeometryComparison.filesToCompare (   self)

Definition at line 111 of file geometryComparison.py.

References geometryComparison.GeometryComparison.__filesToCompare.

111  def filesToCompare(self):
112  return self.__filesToCompare
113 

◆ getRepMap()

def geometryComparison.GeometryComparison.getRepMap (   self,
  alignment = None 
)

Definition at line 80 of file geometryComparison.py.

References geometryComparison.GeometryComparison.__compares, genericValidation.GenericValidation.alignmentToValidate, helperFunctions.clean_name(), relativeConstraints.keys, and geometryComparison.GeometryComparison.referenceAlignment.

Referenced by plottingOptions.PlottingOptionsTrackSplitting.validsubdets().

80  def getRepMap(self, alignment = None):
81  if alignment == None:
82  alignment = self.alignmentToValidate
83  repMap = super(GeometryComparison, self).getRepMap( alignment )
84  referenceName = "IDEAL"
85  referenceTitle = "IDEAL"
86  if not self.referenceAlignment == "IDEAL":
87  referenceName = self.referenceAlignment.name
88  referenceTitle = self.referenceAlignment.title
89 
90  assert len(self.__compares) == 1 #? not sure how it can be anything else, but just in case
91  common = list(self.__compares.keys())[0]
92 
93  repMap.update({
94  "common": clean_name(common),
95  "comparedGeometry": (".oO[alignmentName]Oo."
96  "ROOTGeometry.root"),
97  "referenceGeometry": "IDEAL", # will be replaced later
98  # if not compared to IDEAL
99  "reference": clean_name(referenceName),
100  "referenceTitle": referenceTitle,
101  "alignmentTitle": self.alignmentToValidate.title,
102  "moduleListBase": os.path.basename(repMap["moduleList"]),
103  })
104  if not referenceName == "IDEAL":
105  repMap["referenceGeometry"] = (".oO[reference]Oo."
106  "ROOTGeometry.root")
107  repMap["name"] += "_vs_.oO[reference]Oo."
108  return repMap
109 

Member Data Documentation

◆ __compares

◆ __filesToCompare

geometryComparison.GeometryComparison.__filesToCompare
private

◆ copyImages

geometryComparison.GeometryComparison.copyImages

◆ defaults

dictionary geometryComparison.GeometryComparison.defaults
static
Initial value:
= {
"3DSubdetector1":"1",
"3DSubdetector2":"2",
"3DTranslationalScaleFactor":"50",
"modulesToPlot":"all",
"moduleList": "./CREATE_NEW/emptyModuleList.txt",
"useDefaultRange":"false",
"plotOnlyGlobal":"true",
"plotPng":"true",
"makeProfilePlots":"true",
"dx_min":"-99999",
"dx_max":"-99999",
"dy_min":"-99999",
"dy_max":"-99999",
"dz_min":"-99999",
"dz_max":"-99999",
"dr_min":"-99999",
"dr_max":"-99999",
"rdphi_min":"-99999",
"rdphi_max":"-99999",
"dalpha_min":"-99999",
"dalpha_max":"-99999",
"dbeta_min":"-99999",
"dbeta_max":"-99999",
"dgamma_min":"-99999",
"dgamma_max":"-99999",
"multiIOV":"False",
}

Definition at line 14 of file geometryComparison.py.

Referenced by tree.Tree.reset(), and tree.Tree.var().

◆ mandatories

dictionary geometryComparison.GeometryComparison.mandatories = {"levels", "dbOutput"}
static

Definition at line 42 of file geometryComparison.py.

◆ referenceAlignment

geometryComparison.GeometryComparison.referenceAlignment

◆ valType