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