CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
preexistingValidation.py
Go to the documentation of this file.
1 import os
2 from genericValidation import GenericValidation, GenericValidationData
3 from geometryComparison import GeometryComparison
4 from helperFunctions import getCommandOutput2, parsecolor, parsestyle
5 from monteCarloValidation import MonteCarloValidation
6 from offlineValidation import OfflineValidation
7 from TkAlExceptions import AllInOneError
8 from trackSplittingValidation import TrackSplittingValidation
9 from zMuMuValidation import ZMuMuValidation
10 
12  """
13  Object representing a validation that has already been run,
14  but should be included in plots.
15  """
16  def __init__(self, valName, config, valType,
17  addDefaults = {}, addMandatories=[]):
18  self.name = valName
19  self.general = config.getGeneral()
20  self.config = config
21  self.filesToCompare = {}
22 
23  defaults = {"title": self.name}
24  defaults.update(addDefaults)
25  mandatories = ["file", "color", "style"]
26  mandatories += addMandatories
27 
28  theUpdate = config.getResultingSection("preexisting"+valType+":"+self.name,
29  defaultDict = defaults,
30  demandPars = mandatories)
31  self.general.update(theUpdate)
32 
33  self.title = self.general["title"]
34  if "|" in self.title or "," in self.title or '"' in self.title:
35  msg = "The characters '|', '\"', and ',' cannot be used in the alignment title!"
36  raise AllInOneError(msg)
37 
38  self.filesToCompare[GenericValidationData.defaultReferenceName] = \
39  self.general["file"]
40 
41  knownOpts = defaults.keys()+mandatories
42  ignoreOpts = []
43  config.checkInput("preexisting"+valType+":"+self.name,
44  knownSimpleOptions = knownOpts,
45  ignoreOptions = ignoreOpts)
46  self.jobmode = None
47 
48  def getRepMap(self):
49  result = self.general
50  result.update({
51  "color": str(parsecolor(result["color"])),
52  "style": str(parsestyle(result["style"])),
53  })
54  return result
55 
56  def getCompareStrings( self, requestId = None, plain = False ):
57  result = {}
58  repMap = self.getRepMap()
59  for validationId in self.filesToCompare:
60  repMap["file"] = self.filesToCompare[ validationId ]
61  if repMap["file"].startswith( "/castor/" ):
62  repMap["file"] = "rfio:%(file)s"%repMap
63  elif repMap["file"].startswith( "/store/" ):
64  repMap["file"] = "root://eoscms.cern.ch//eos/cms%(file)s"%repMap
65  if plain:
66  result[validationId]=repMap["file"]
67  else:
68  result[validationId]= "%(file)s=%(title)s|%(color)s|%(style)s"%repMap
69  if requestId == None:
70  return result
71  else:
72  if not "." in requestId:
73  requestId += ".%s"%GenericValidation.defaultReferenceName
74  if not requestId.split(".")[-1] in result:
75  msg = ("could not find %s in reference Objects!"
76  %requestId.split(".")[-1])
77  raise AllInOneError(msg)
78  return result[ requestId.split(".")[-1] ]
79 
80  def createFiles(self, *args, **kwargs):
81  raise AllInOneError("Shouldn't be here...")
82  def createConfiguration(self, *args, **kwargs):
83  pass
84  def createScript(self, *args, **kwargs):
85  raise AllInOneError("Shouldn't be here...")
86  def createCrabCfg(self, *args, **kwargs):
87  raise AllInOneError("Shouldn't be here...")
88 
90  def __init__(self, valName, config,
91  addDefaults = {}, addMandatories=[]):
92  defaults = {}
93  deprecateddefaults = {
94  "DMRMethod":"",
95  "DMRMinimum":"",
96  "DMROptions":"",
97  "OfflineTreeBaseDir":"",
98  "SurfaceShapes":""
99  }
100  defaults.update(deprecateddefaults)
101  defaults.update(addDefaults)
102  PreexistingValidation.__init__(self, valName, config, "offline",
103  defaults, addMandatories)
104  for option in deprecateddefaults:
105  if self.general[option]:
106  raise AllInOneError("The '%s' option has been moved to the [plots:offline] section. Please specify it there."%option)
107 
108  def appendToExtendedValidation( self, validationsSoFar = "" ):
109  """
110  if no argument or "" is passed a string with an instantiation is
111  returned, else the validation is appended to the list
112  """
113  repMap = self.getRepMap()
114  repMap["file"] = self.getCompareStrings("OfflineValidation", plain = True)
115  if validationsSoFar == "":
116  validationsSoFar = ('PlotAlignmentValidation p("%(file)s",'
117  '"%(title)s", %(color)s, %(style)s, .oO[bigtext]Oo.);\n')%repMap
118  else:
119  validationsSoFar += (' p.loadFileList("%(file)s", "%(title)s",'
120  '%(color)s, %(style)s);\n')%repMap
121  return validationsSoFar
122 
124  def __init__(self, valName, config,
125  addDefaults = {}, addMandatories=[]):
126  defaults = {"subdetector": "BPIX"}
127  defaults.update(addDefaults)
128  PreexistingValidation.__init__(self, valName, config, "split",
129  defaults, addMandatories)
130  def appendToExtendedValidation( self, validationsSoFar = "" ):
131  """
132  if no argument or "" is passed a string with an instantiation is
133  returned, else the validation is appended to the list
134  """
135  repMap = self.getRepMap()
136  comparestring = self.getCompareStrings("TrackSplittingValidation")
137  if validationsSoFar != "":
138  validationsSoFar += ',"\n "'
139  validationsSoFar += comparestring
140  return validationsSoFar
141 
143  def __init__(self, valName, config,
144  addDefaults = {}, addMandatories=[]):
145  PreexistingValidation.__init__(self, valName, config, "mcValidate",
146  addDefaults, addMandatories)
147 
149  def __init__(self, *args, **kwargs):
150  raise AllInOneError("Preexisting Z->mumu validation not implemented")
151  #more complicated, it has multiple output files
152 
154  def __init__(self, *args, **kwargs):
155  raise AllInOneError("Preexisting geometry comparison not implemented")