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

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 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"}
 

Private Attributes

 __compares
 
 __filesToCompare
 

Detailed Description

Object representing a geometry comparison job.

Definition at line 10 of file geometryComparison.py.

Constructor & Destructor Documentation

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 cppboolstring(string, name)
def __init__(self, valName, alignment, referenceAlignment, config, copyImages=True)

Member Function Documentation

def geometryComparison.GeometryComparison.createConfiguration (   self,
  path 
)

Definition at line 114 of file geometryComparison.py.

References geometryComparison.GeometryComparison.__compares, genericValidation.GenericValidation.getRepMap(), alignment.Alignment.getRepMap(), helperFunctions.pythonboolstring(), geometryComparison.GeometryComparison.referenceAlignment, helperFunctions.replaceByMap(), and cms::dd.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 = 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 
std::vector< std::string_view > split(std::string_view, const char *)
def pythonboolstring(string, name)
def replaceByMap(target, the_map)
— Helpers —############################
def getRepMap(self, alignment=None)
def geometryComparison.GeometryComparison.createCrabCfg (   self,
  path 
)

Definition at line 305 of file geometryComparison.py.

305  def createCrabCfg(self, path):
306  msg = ("Parallelization not supported for geometry comparison. Please "
307  "choose another 'jobmode'.")
308  raise AllInOneError(msg)
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(), and cms::dd.split().

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  ### At the moment translations are images with suffix _1 and _2, rotations _3 and _4
184  ### The numeration depends on the order of the MakePlots(x, y) commands in comparisonScript.C
185  ### If comparisonScript.C is changed, check if the following lines need to be changed as well
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  resultingFile = replaceByMap(("/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./compared%s_"
260  ".oO[name]Oo..root"%name), repMap)
261  resultingFile = os.path.expandvars( resultingFile )
262  resultingFile = os.path.abspath( resultingFile )
263  resultingFile = "root://eoscms//eos/cms" + resultingFile #needs to be AFTER abspath so that it doesn't eat the //
264  self.__filesToCompare[ name ] = resultingFile
265 
266  else:
267  raise AllInOneError("Need to have DetUnit in levels!")
268 
269  repMap["CommandLine"]=""
270  repMap["CommandLine"]+= \
271  "# copy module list required for comparison script \n"
272  if repMap["moduleList"].startswith("/store"):
273  repMap["CommandLine"]+= \
274  "xrdcp root://eoscms//eos/cms.oO[moduleList]Oo. .\n"
275  elif repMap["moduleList"].startswith("root://"):
276  repMap["CommandLine"]+= \
277  "xrdcp .oO[moduleList]Oo. .\n"
278  else:
279  repMap["CommandLine"]+= \
280  "cp .oO[moduleList]Oo. .\n"
281 
282  try:
283  getCommandOutput2(replaceByMap("cd $(mktemp -d)\n.oO[CommandLine]Oo.\ncat .oO[moduleListBase]Oo.", repMap))
284  except RuntimeError:
285  raise AllInOneError(replaceByMap(".oO[moduleList]Oo. does not exist!", repMap))
286 
287  for cfg in self.configFiles:
288  # FIXME: produce this line only for enabled dbOutput
289  # postProcess = "cp .oO[workdir]Oo./*.db .oO[datadir]Oo.\n"
290  # postProcess = "cp *.db .oO[datadir]Oo.\n"
291  postProcess = ""
292  repMap["CommandLine"]+= \
293  repMap["CommandLineTemplate"]%{"cfgFile":cfg,
294  "postProcess":postProcess}
295  repMap["CommandLine"]+= ("# overall postprocessing\n"
296  ".oO[runComparisonScripts]Oo.\n"
297  )
298 
299  #~ print configTemplates.scriptTemplate
300  scripts = {scriptName: replaceByMap( configTemplates.scriptTemplate, repMap )}
301  files = {replaceByMap("TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C", repMap ): replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
302  self.createFiles(files, path)
303  return super(GeometryComparison, self).createScript(scripts, path)
304 
std::vector< std::string_view > split(std::string_view, const char *)
def getCommandOutput2(command)
def replaceByMap(target, the_map)
— Helpers —############################
def createFiles(self, fileContents, path, repMap=None, repMaps=None)
def getRepMap(self, alignment=None)
def geometryComparison.GeometryComparison.filesToCompare (   self)
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(), 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 = 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

geometryComparison.GeometryComparison.__filesToCompare
private
geometryComparison.GeometryComparison.copyImages
dictionary geometryComparison.GeometryComparison.defaults
static
Initial value:
1 = {
2  "3DSubdetector1":"1",
3  "3DSubdetector2":"2",
4  "3DTranslationalScaleFactor":"50",
5  "modulesToPlot":"all",
6  "moduleList": "/store/caf/user/cschomak/emptyModuleList.txt",
7  "useDefaultRange":"false",
8  "plotOnlyGlobal":"true",
9  "plotPng":"true",
10  "makeProfilePlots":"true",
11  "dx_min":"-99999",
12  "dx_max":"-99999",
13  "dy_min":"-99999",
14  "dy_max":"-99999",
15  "dz_min":"-99999",
16  "dz_max":"-99999",
17  "dr_min":"-99999",
18  "dr_max":"-99999",
19  "rdphi_min":"-99999",
20  "rdphi_max":"-99999",
21  "dalpha_min":"-99999",
22  "dalpha_max":"-99999",
23  "dbeta_min":"-99999",
24  "dbeta_max":"-99999",
25  "dgamma_min":"-99999",
26  "dgamma_max":"-99999",
27  "multiIOV":"False",
28  }

Definition at line 14 of file geometryComparison.py.

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

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

Definition at line 42 of file geometryComparison.py.

geometryComparison.GeometryComparison.referenceAlignment