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 9 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 43 of file geometryComparison.py.

43  config, copyImages = True):
44  """
45  Constructor of the GeometryComparison class.
46 
47  Arguments:
48  - `valName`: String which identifies individual validation instances
49  - `alignment`: `Alignment` instance to validate
50  - `referenceAlignment`: `Alignment` instance which is compared
51  with `alignment`
52  - `config`: `BetterConfigParser` instance which includes the
53  configuration of the validations
54  - `copyImages`: Boolean which indicates whether png- and pdf-files
55  should be copied back from the batch farm
56  """
57  super(GeometryComparison, self).__init__(valName, alignment, config)
58  self.referenceAlignment = referenceAlignment
59  referenceName = "IDEAL"
60  if not self.referenceAlignment == "IDEAL":
61  referenceName = self.referenceAlignment.name
62 
63  allCompares = config.getCompares()
64  self.__compares = {}
65  self.__filesToCompare = {}
66  if valName in allCompares:
67  self.__compares[valName] = allCompares[valName]
68  else:
69  msg = ("Could not find compare section '%s' in '%s'"
70  %(valName, allCompares))
71  raise AllInOneError(msg)
72  self.copyImages = copyImages
73 
74  for name in "useDefaultRange", "plotOnlyGlobal", "plotPng":
75  self.general[name] = cppboolstring(self.general[name], name)
76 
77 
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 112 of file geometryComparison.py.

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

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

Definition at line 310 of file geometryComparison.py.

310  def createCrabCfg(self, path):
311  msg = ("Parallelization not supported for geometry comparison. Please "
312  "choose another 'jobmode'.")
313  raise AllInOneError(msg)
def geometryComparison.GeometryComparison.createScript (   self,
  path 
)

Definition at line 144 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, classes.MonitorData.name, MuonGeometrySanityCheckPoint.name, classes.OutputData.name, geometry.Structure.name, plotscripts.SawTeethFunction.name, helperFunctions.replaceByMap(), and split.

144  def createScript(self, path):
145  repMap = self.getRepMap()
146  repMap["runComparisonScripts"] = ""
147  scriptName = replaceByMap(("TkAlGeomCompare.%s..oO[name]Oo..sh"
148  %self.name), repMap)
149 
150  y_ranges = ""
151  plottedDifferences = ["dx","dy","dz","dr","rdphi","dalpha","dbeta","dgamma"]
152  for diff in plottedDifferences:
153  y_ranges += ","+repMap["%s_min"%diff]
154  y_ranges += ","+repMap["%s_max"%diff]
155 
156  for name in self.__compares:
157  if '"DetUnit"' in self.__compares[name][0].split(","):
158  repMap["outputFile"] = (".oO[name]Oo..Comparison_common"+name+".root")
159  repMap["nIndex"] = ("")
160  repMap["runComparisonScripts"] += \
161  ("rfcp .oO[Alignment/OfflineValidation]Oo."
162  "/scripts/comparisonScript.C .\n"
163  "rfcp .oO[Alignment/OfflineValidation]Oo."
164  "/scripts/GeometryComparisonPlotter.h .\n"
165  "rfcp .oO[Alignment/OfflineValidation]Oo."
166  "/scripts/GeometryComparisonPlotter.cc .\n"
167  "root -b -q 'comparisonScript.C+(\""
168  ".oO[name]Oo..Comparison_common"+name+".root\",\""
169  "./\",\".oO[modulesToPlot]Oo.\",\".oO[alignmentName]Oo.\",\".oO[reference]Oo.\",.oO[useDefaultRange]Oo.,.oO[plotOnlyGlobal]Oo.,.oO[plotPng]Oo.,.oO[makeProfilePlots]Oo."+y_ranges+")'\n"
170  "rfcp "+path+"/TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C .\n"
171  "root -l -b -q TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C+\n")
172  if self.copyImages:
173  repMap["runComparisonScripts"] += \
174  ("rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
175  ".Comparison_common"+name+"_Images\n")
176  repMap["runComparisonScripts"] += \
177  ("rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
178  ".Comparison_common"+name+"_Images/Translations\n")
179  repMap["runComparisonScripts"] += \
180  ("rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
181  ".Comparison_common"+name+"_Images/Rotations\n")
182 
183 
184  ### At the moment translations are images with suffix _1 and _2, rotations _3 and _4
185  ### The numeration depends on the order of the MakePlots(x, y) commands in comparisonScript.C
186  ### If comparisonScript.C is changed, check if the following lines need to be changed as well
187 
188  if repMap["plotPng"] == "true":
189  repMap["runComparisonScripts"] += \
190  ("find . -maxdepth 1 -name \"*_1*\" "
191  "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
192  "/.oO[name]Oo..Comparison_common"+name+"_Images/Translations/\" \n")
193  repMap["runComparisonScripts"] += \
194  ("find . -maxdepth 1 -name \"*_2*\" "
195  "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
196  "/.oO[name]Oo..Comparison_common"+name+"_Images/Translations/\" \n")
197 
198  repMap["runComparisonScripts"] += \
199  ("find . -maxdepth 1 -name \"*_3*\" "
200  "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
201  "/.oO[name]Oo..Comparison_common"+name+"_Images/Rotations/\" \n")
202  repMap["runComparisonScripts"] += \
203  ("find . -maxdepth 1 -name \"*_4*\" "
204  "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
205  "/.oO[name]Oo..Comparison_common"+name+"_Images/Rotations/\" \n")
206 
207  else:
208  repMap["runComparisonScripts"] += \
209  ("find . -maxdepth 1 -name \"*_1*\" "
210  "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
211  "/.oO[name]Oo..Comparison_common"+name+"_Images/Translations/\" \n")
212 
213  repMap["runComparisonScripts"] += \
214  ("find . -maxdepth 1 -name \"*_2*\" "
215  "-print | xargs -I {} bash -c \"rfcp {} .oO[datadir]Oo."
216  "/.oO[name]Oo..Comparison_common"+name+"_Images/Rotations/\" \n")
217 
218  repMap["runComparisonScripts"] += \
219  ("find . -maxdepth 1 -name "
220  "\"*.tex\" -print | xargs -I {} bash -c"
221  " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
222  ".Comparison_common"+name+"_Images/\" \n")
223  repMap["runComparisonScripts"] += \
224  ("find . -maxdepth 1 -name "
225  "\"TkMap_SurfDeform*.pdf\" -print | xargs -I {} bash -c"
226  " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
227  ".Comparison_common"+name+"_Images/\" \n")
228  repMap["runComparisonScripts"] += \
229  ("find . -maxdepth 1 -name "
230  "\"TkMap_SurfDeform*.png\" -print | xargs -I {} bash -c"
231  " \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
232  ".Comparison_common"+name+"_Images/\" \n")
233  repMap["runComparisonScripts"] += \
234  ("if [[ $HOSTNAME = lxplus[0-9]*[.a-z0-9]* ]]\n"
235  "then\n"
236  " rfmkdir -p .oO[workdir]Oo./.oO[name]Oo.."+name
237  +"_ArrowPlots\n"
238  "else\n"
239  " mkdir -p $CWD/TkAllInOneTool/.oO[name]Oo.."+name
240  +"_ArrowPlots\n"
241  "fi\n")
242  repMap["runComparisonScripts"] += \
243  ("rfcp .oO[Alignment/OfflineValidation]Oo."
244  "/scripts/makeArrowPlots.C "
245  ".\n"
246  "root -b -q 'makeArrowPlots.C(\""
247  ".oO[name]Oo..Comparison_common"+name
248  +".root\",\".oO[name]Oo.."
249  +name+"_ArrowPlots\")'\n")
250  repMap["runComparisonScripts"] += \
251  ("rfmkdir -p .oO[datadir]Oo./.oO[name]Oo."
252  ".Comparison_common"+name+"_Images/ArrowPlots\n")
253  repMap["runComparisonScripts"] += \
254  ("find .oO[name]Oo.."+name+"_ArrowPlots "
255  "-maxdepth 1 -name \"*.png\" -print | xargs -I {} bash "
256  "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
257  ".Comparison_common"+name+"_Images/ArrowPlots\"\n")
258  repMap["runComparisonScripts"] += \
259  ("find . "
260  "-maxdepth 1 -name \".oO[common]Oo._.oO[name]Oo..Visualization_rotated.gif\" -print | xargs -I {} bash "
261  "-c \"rfcp {} .oO[datadir]Oo./.oO[name]Oo."
262  ".Comparison_common"+name+"_Images/.oO[common]Oo._.oO[name]Oo..Visualization.gif\"\n")
263 
264  resultingFile = replaceByMap(("/store/caf/user/$USER/.oO[eosdir]Oo./compared%s_"
265  ".oO[name]Oo..root"%name), repMap)
266  resultingFile = os.path.expandvars( resultingFile )
267  resultingFile = os.path.abspath( resultingFile )
268  resultingFile = "root://eoscms//eos/cms" + resultingFile #needs to be AFTER abspath so that it doesn't eat the //
269  self.__filesToCompare[ name ] = resultingFile
270 
271  else:
272  raise AllInOneError("Need to have DetUnit in levels!")
273 
274  repMap["CommandLine"]=""
275  repMap["CommandLine"]+= \
276  "# copy module list required for comparison script \n"
277  if repMap["moduleList"].startswith("/store"):
278  repMap["CommandLine"]+= \
279  "xrdcp root://eoscms//eos/cms.oO[moduleList]Oo. .\n"
280  elif repMap["moduleList"].startswith("root://"):
281  repMap["CommandLine"]+= \
282  "xrdcp .oO[moduleList]Oo. .\n"
283  else:
284  repMap["CommandLine"]+= \
285  "rfcp .oO[moduleList]Oo. .\n"
286 
287  try:
288  getCommandOutput2(replaceByMap("cd $(mktemp -d)\n.oO[CommandLine]Oo.\ncat .oO[moduleListBase]Oo.", repMap))
289  except RuntimeError:
290  raise AllInOneError(replaceByMap(".oO[moduleList]Oo. does not exist!", repMap))
291 
292  for cfg in self.configFiles:
293  # FIXME: produce this line only for enabled dbOutput
294  # postProcess = "rfcp .oO[workdir]Oo./*.db .oO[datadir]Oo.\n"
295  # postProcess = "rfcp *.db .oO[datadir]Oo.\n"
296  postProcess = ""
297  repMap["CommandLine"]+= \
298  repMap["CommandLineTemplate"]%{"cfgFile":cfg,
299  "postProcess":postProcess}
300  repMap["CommandLine"]+= ("# overall postprocessing\n"
301  ".oO[runComparisonScripts]Oo.\n"
302  )
303 
304  #~ print configTemplates.scriptTemplate
305  scripts = {scriptName: replaceByMap( configTemplates.scriptTemplate, repMap )}
306  files = {replaceByMap("TkAl3DVisualization_.oO[common]Oo._.oO[name]Oo..C", repMap ): replaceByMap(configTemplates.visualizationTrackerTemplate, repMap )}
307  self.createFiles(files, path)
308  return super(GeometryComparison, self).createScript(scripts, path)
309 
def getCommandOutput2(command)
def replaceByMap(target, the_map)
— Helpers —############################
def createFiles(self, fileContents, path, repMap=None, repMaps=None)
def getRepMap(self, alignment=None)
double split
Definition: MVATrainer.cc:139
def geometryComparison.GeometryComparison.filesToCompare (   self)
def geometryComparison.GeometryComparison.getRepMap (   self,
  alignment = None 
)

Definition at line 78 of file geometryComparison.py.

References geometryComparison.GeometryComparison.__compares, genericValidation.GenericValidation.alignmentToValidate, and geometryComparison.GeometryComparison.referenceAlignment.

Referenced by plottingOptions.PlottingOptionsTrackSplitting.validsubdets().

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

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":"false",
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  }

Definition at line 13 of file geometryComparison.py.

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

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

Definition at line 40 of file geometryComparison.py.

geometryComparison.GeometryComparison.referenceAlignment