CMS 3D CMS Logo

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 boolfromstring, getCommandOutput2, parsecolor, parsestyle
5 from monteCarloValidation import MonteCarloValidation
6 from offlineValidation import OfflineValidation
7 from primaryVertexValidation import PrimaryVertexValidation
8 from plottingOptions import PlottingOptions
9 from TkAlExceptions import AllInOneError
10 from trackSplittingValidation import TrackSplittingValidation
11 from zMuMuValidation import ZMuMuValidation
12 
14  """
15  Object representing a validation that has already been run,
16  but should be included in plots.
17  """
18  defaults = {"title": ".oO[name]Oo."}
19  mandatories = {"file", "color", "style"}
20  removemandatories = {"dataset", "maxevents", "trackcollection"}
21  def __init__(self, valName, config):
22  self.general = config.getGeneral()
23  self.name = self.general["name"] = valName
24  self.config = config
25 
26  theUpdate = config.getResultingSection("preexisting"+self.valType+":"+self.name,
27  defaultDict = self.defaults,
28  demandPars = self.mandatories)
29  self.general.update(theUpdate)
30 
31  self.title = self.general["title"]
32  if "|" in self.title or "," in self.title or '"' in self.title:
33  msg = "The characters '|', '\"', and ',' cannot be used in the alignment title!"
34  raise AllInOneError(msg)
35  self.needsproxy = boolfromstring(self.general["needsproxy"], "needsproxy")
36  self.jobid = self.general["jobid"]
37  if self.jobid:
38  try: #make sure it's actually a valid jobid
39  output = getCommandOutput2("bjobs %(jobid)s 2>&1"%self.general)
40  if "is not found" in output: raise RuntimeError
41  except RuntimeError:
42  raise AllInOneError("%s is not a valid jobid.\nMaybe it finished already?"%self.jobid)
43 
44  knownOpts = set(self.defaults.keys())|self.mandatories|self.optionals
45  ignoreOpts = []
46  config.checkInput("preexisting"+self.valType+":"+self.name,
47  knownSimpleOptions = knownOpts,
48  ignoreOptions = ignoreOpts)
49  self.jobmode = None
50 
51  try: #initialize plotting options for this validation type
52  result = PlottingOptions(self.config, self.valType)
53  except KeyError:
54  pass
55 
56  @property
57  def filesToCompare(self):
58  return {self.defaultReferenceName: self.general["file"]}
59 
60  def getRepMap(self):
61  #do not call super
62  try:
63  result = PlottingOptions(self.config, self.valType)
64  except KeyError:
65  result = {}
66  result.update(self.general)
67  result.update({
68  "color": str(parsecolor(result["color"])),
69  "style": str(parsestyle(result["style"])),
70  })
71  return result
72 
73  def createFiles(self, *args, **kwargs):
74  raise AllInOneError("Shouldn't be here...")
75  def createConfiguration(self, *args, **kwargs):
76  pass
77  def createScript(self, *args, **kwargs):
78  raise AllInOneError("Shouldn't be here...")
79  def createCrabCfg(self, *args, **kwargs):
80  raise AllInOneError("Shouldn't be here...")
81 
83  deprecateddefaults = {
84  "DMRMethod":"",
85  "DMRMinimum":"",
86  "DMROptions":"",
87  "OfflineTreeBaseDir":"",
88  "SurfaceShapes":""
89  }
90  defaults = deprecateddefaults.copy()
91  def __init__(self, valName, config):
92  super(PreexistingOfflineValidation, self).__init__(valName, config)
93  for option in self.deprecateddefaults:
94  if self.general[option]:
95  raise AllInOneError("The '%s' option has been moved to the [plots:offline] section. Please specify it there."%option)
96 
97  def getRepMap(self):
98  result = super(PreexistingOfflineValidation, self).getRepMap()
99  result.update({
100  "filetoplot": self.general["file"],
101  })
102  return result
103 
104  def appendToMerge(self, *args, **kwargs):
105  raise AllInOneError("Shouldn't be here...")
106 
108  removemandatories = {"isda","ismc","runboundary","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"}
109  def getRepMap(self):
110  result = super(PreexistingPrimaryVertexValidation, self).getRepMap()
111  result.update({
112  "filetoplot": self.general["file"],
113  })
114  return result
115 
116  def appendToMerge(self, *args, **kwargs):
117  raise AllInOneError("Shouldn't be here...")
118 
120  def appendToMerge(self, *args, **kwargs):
121  raise AllInOneError("Shouldn't be here...")
122 
124  pass
125 
126 class PreexistingZMuMuValidation(PreexistingValidation):
127  def __init__(self, *args, **kwargs):
128  raise AllInOneError("Preexisting Z->mumu validation not implemented")
129  #more complicated, it has multiple output files
130 
132  def __init__(self, *args, **kwargs):
133  raise AllInOneError("Preexisting geometry comparison not implemented")
def parsestyle(style)
def getCommandOutput2(command)
def PlottingOptions(config, valType)
def boolfromstring(string, name)
def parsecolor(color)
#define str(s)