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