CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
preexistingValidation.py
Go to the documentation of this file.
1 from __future__ import absolute_import
2 import os
3 from .genericValidation import GenericValidation, GenericValidationData
4 from .geometryComparison import GeometryComparison
5 from .helperFunctions import boolfromstring, getCommandOutput2, parsecolor, parsestyle
6 from .monteCarloValidation import MonteCarloValidation
7 from .offlineValidation import OfflineValidation
8 from .primaryVertexValidation import PrimaryVertexValidation
9 from .plottingOptions import PlottingOptions
10 from .TkAlExceptions import AllInOneError
11 from .trackSplittingValidation import TrackSplittingValidation
12 from .zMuMuValidation import ZMuMuValidation
13 
14 class PreexistingValidation(GenericValidation):
15  """
16  Object representing a validation that has already been run,
17  but should be included in plots.
18  """
19  defaults = {"title": ".oO[name]Oo."}
20  mandatories = {"file", "color", "style", "originalValName", "eosdirName", "multiIOV"}
21  removemandatories = {"dataset", "maxevents", "trackcollection"}
22  def __init__(self, valName, config):
23  self.general = config.getGeneral()
24  self.name = self.general["name"] = valName
25  self.config = config
26 
27  theUpdate = config.getResultingSection("preexisting"+self.valType+":"+self.name,
28  defaultDict = self.defaults,
29  demandPars = self.mandatories)
30  self.general.update(theUpdate)
31 
32  self.originalValName = self.general["originalValName"]
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  self.needsproxy = boolfromstring(self.general["needsproxy"], "needsproxy")
38  self.jobid = self.general["jobid"]
39  if self.jobid:
40  try: #make sure it's actually a valid jobid
41  output = getCommandOutput2("bjobs %(jobid)s 2>&1"%self.general)
42  if "is not found" in output: raise RuntimeError
43  except RuntimeError:
44  raise AllInOneError("%s is not a valid jobid.\nMaybe it finished already?"%self.jobid)
45 
46  knownOpts = set(self.defaults.keys())|self.mandatories|self.optionals
47  ignoreOpts = []
48  config.checkInput("preexisting"+self.valType+":"+self.name,
49  knownSimpleOptions = knownOpts,
50  ignoreOptions = ignoreOpts)
51  self.jobmode = None
52 
53  try: #initialize plotting options for this validation type
54  result = PlottingOptions(self.config, self.valType)
55  except KeyError:
56  pass
57 
58  @property
59  def filesToCompare(self):
60  return {self.defaultReferenceName: self.general["file"]}
61 
62  def getRepMap(self):
63  #do not call super
64  try:
65  result = PlottingOptions(self.config, self.valType)
66  except KeyError:
67  result = {}
68  result.update(self.general)
69  result.update({
70  "color": str(parsecolor(result["color"])),
71  "style": str(parsestyle(result["style"])),
72  })
73  return result
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  deprecateddefaults = {
86  "DMRMethod":"",
87  "DMRMinimum":"",
88  "DMROptions":"",
89  "OfflineTreeBaseDir":"",
90  "SurfaceShapes":""
91  }
92  defaults = deprecateddefaults.copy()
93  def __init__(self, valName, config):
94  super(PreexistingOfflineValidation, self).__init__(valName, config)
95  for option in self.deprecateddefaults:
96  if self.general[option]:
97  raise AllInOneError("The '%s' option has been moved to the [plots:offline] section. Please specify it there."%option)
98 
99  def getRepMap(self):
100  result = super(PreexistingOfflineValidation, self).getRepMap()
101  result.update({
102  "filetoplot": self.general["file"],
103  })
104  return result
105 
106  def appendToMerge(self, *args, **kwargs):
107  raise AllInOneError("Shouldn't be here...")
108 
110  removemandatories = {"isda","ismc","runboundary","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"}
111  def getRepMap(self):
112  result = super(PreexistingPrimaryVertexValidation, self).getRepMap()
113  result.update({
114  "filetoplot": self.general["file"],
115  })
116  return result
117 
118  def appendToMerge(self, *args, **kwargs):
119  raise AllInOneError("Shouldn't be here...")
120 
122  def appendToMerge(self, *args, **kwargs):
123  raise AllInOneError("Shouldn't be here...")
124 
126  pass
127 
128 class PreexistingZMuMuValidation(PreexistingValidation):
129  def __init__(self, *args, **kwargs):
130  raise AllInOneError("Preexisting Z->mumu validation not implemented")
131  #more complicated, it has multiple output files
132 
134  def __init__(self, *args, **kwargs):
135  raise AllInOneError("Preexisting geometry comparison not implemented")
#define str(s)