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  self.jobmode = None
46 
47  def getRepMap(self):
48  result = self.general
49  return result
50 
51  def getCompareStrings( self, requestId = None, plain = False ):
52  result = {}
53  repMap = self.getRepMap()
54  for validationId in self.filesToCompare:
55  repMap["file"] = self.filesToCompare[ validationId ]
56  if repMap["file"].startswith( "/castor/" ):
57  repMap["file"] = "rfio:%(file)s"%repMap
58  elif repMap["file"].startswith( "/store/" ):
59  repMap["file"] = "root://eoscms.cern.ch//eos/cms%(file)s"%repMap
60  if plain:
61  result[validationId]=repMap["file"]
62  else:
63  result[validationId]= "%(file)s=%(title)s|%(color)s|%(style)s"%repMap
64  if requestId == None:
65  return result
66  else:
67  if not "." in requestId:
68  requestId += ".%s"%GenericValidation.defaultReferenceName
69  if not requestId.split(".")[-1] in result:
70  msg = ("could not find %s in reference Objects!"
71  %requestId.split(".")[-1])
72  raise AllInOneError(msg)
73  return result[ requestId.split(".")[-1] ]
74 
75  def createFiles(self, *args, **kwargs):
76  raise AllInOneError("Shouldn't be here...")
77  def createConfiguration(self, *args, **kwargs):
78  pass
79  def createScript(self, *args, **kwargs):
80  raise AllInOneError("Shouldn't be here...")
81  def createCrabCfg(self, *args, **kwargs):
82  raise AllInOneError("Shouldn't be here...")
83 
85  def __init__(self, valName, config,
86  addDefaults = {}, addMandatories=[]):
87  defaults = {
88  "DMRMethod":"median,rmsNorm",
89  "DMRMinimum":"30",
90  "DMROptions":"",
91  "OfflineTreeBaseDir":"TrackHitFilter",
92  "SurfaceShapes":"coarse",
93  }
94  defaults.update(addDefaults)
95  PreexistingValidation.__init__(self, valName, config, "offline",
96  defaults, addMandatories)
97  def appendToExtendedValidation( self, validationsSoFar = "" ):
98  """
99  if no argument or "" is passed a string with an instantiation is
100  returned, else the validation is appended to the list
101  """
102  repMap = self.getRepMap()
103  repMap["file"] = self.getCompareStrings("OfflineValidation", plain = True)
104  if validationsSoFar == "":
105  validationsSoFar = ('PlotAlignmentValidation p("%(file)s",'
106  '"%(title)s", %(color)s, %(style)s);\n')%repMap
107  else:
108  validationsSoFar += (' p.loadFileList("%(file)s", "%(title)s",'
109  '%(color)s, %(style)s);\n')%repMap
110  return validationsSoFar
111 
113  def __init__(self, valName, config,
114  addDefaults = {}, addMandatories=[]):
115  PreexistingValidation.__init__(self, valName, config, "split",
116  addDefaults, addMandatories)
117  def appendToExtendedValidation( self, validationsSoFar = "" ):
118  """
119  if no argument or "" is passed a string with an instantiation is
120  returned, else the validation is appended to the list
121  """
122  repMap = self.getRepMap()
123  comparestring = self.getCompareStrings("TrackSplittingValidation")
124  if validationsSoFar != "":
125  validationsSoFar += ',"\n "'
126  validationsSoFar += comparestring
127  return validationsSoFar
128 
130  def __init__(self, valName, config,
131  addDefaults = {}, addMandatories=[]):
132  PreexistingValidation.__init__(self, valName, config, "mcValidate",
133  addDefaults, addMandatories)
134 
136  def __init__(self, *args, **kwargs):
137  raise AllInOneError("Preexisting Z->mumu validation not implemented")
138  #more complicated, it has multiple output files
139 
141  def __init__(self, *args, **kwargs):
142  raise AllInOneError("Preexisting geometry comparison not implemented")