CMS 3D CMS Logo

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 
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")
preexistingValidation.PreexistingTrackSplittingValidation.appendToMerge
def appendToMerge(self, *args, **kwargs)
Definition: preexistingValidation.py:122
preexistingValidation.PreexistingOfflineValidation.getRepMap
def getRepMap(self)
Definition: preexistingValidation.py:99
genericValidation.GenericValidation.defaults
dictionary defaults
Definition: genericValidation.py:45
genericValidation.GenericValidation.mandatories
mandatories
Definition: genericValidation.py:44
genericValidation.GenericValidation.needsproxy
needsproxy
Definition: genericValidation.py:70
preexistingValidation.PreexistingGeometryComparison.__init__
def __init__(self, *args, **kwargs)
Definition: preexistingValidation.py:134
genericValidation.GenericValidation.jobid
jobid
Definition: genericValidation.py:62
offlineValidation.OfflineValidation
Definition: offlineValidation.py:10
preexistingValidation.PreexistingPrimaryVertexValidation.getRepMap
def getRepMap(self)
Definition: preexistingValidation.py:111
preexistingValidation.PreexistingValidation.originalValName
originalValName
Definition: preexistingValidation.py:32
trackSplittingValidation.TrackSplittingValidation
Definition: trackSplittingValidation.py:10
helperFunctions.boolfromstring
def boolfromstring(string, name)
Definition: helperFunctions.py:170
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
preexistingValidation.PreexistingMonteCarloValidation
Definition: preexistingValidation.py:125
genericValidation.GenericValidation.optionals
dictionary optionals
Definition: genericValidation.py:52
preexistingValidation.PreexistingTrackSplittingValidation
Definition: preexistingValidation.py:121
plottingOptions.PlottingOptions
def PlottingOptions(config, valType)
Definition: plottingOptions.py:240
str
#define str(s)
Definition: TestProcessor.cc:52
preexistingValidation.PreexistingValidation.title
title
Definition: preexistingValidation.py:33
preexistingValidation.PreexistingValidation.createFiles
def createFiles(self, *args, **kwargs)
Definition: preexistingValidation.py:75
helperFunctions.parsestyle
def parsestyle(style)
Definition: helperFunctions.py:136
preexistingValidation.PreexistingValidation
Definition: preexistingValidation.py:14
genericValidation.GenericValidation.general
general
Definition: genericValidation.py:58
helperFunctions.getCommandOutput2
def getCommandOutput2(command)
Definition: helperFunctions.py:52
preexistingValidation.PreexistingPrimaryVertexValidation
Definition: preexistingValidation.py:109
helperFunctions.parsecolor
def parsecolor(color)
Definition: helperFunctions.py:109
genericValidation.GenericValidation.jobmode
jobmode
Definition: genericValidation.py:68
preexistingValidation.PreexistingOfflineValidation
Definition: preexistingValidation.py:84
genericValidation.GenericValidation.name
name
Definition: genericValidation.py:56
preexistingValidation.PreexistingZMuMuValidation.__init__
def __init__(self, *args, **kwargs)
Definition: preexistingValidation.py:129
preexistingValidation.PreexistingValidation.filesToCompare
def filesToCompare(self)
Definition: preexistingValidation.py:59
preexistingValidation.PreexistingOfflineValidation.__init__
def __init__(self, valName, config)
Definition: preexistingValidation.py:93
preexistingValidation.PreexistingValidation.createScript
def createScript(self, *args, **kwargs)
Definition: preexistingValidation.py:79
preexistingValidation.PreexistingPrimaryVertexValidation.appendToMerge
def appendToMerge(self, *args, **kwargs)
Definition: preexistingValidation.py:118
preexistingValidation.PreexistingValidation.getRepMap
def getRepMap(self)
Definition: preexistingValidation.py:62
preexistingValidation.PreexistingValidation.createCrabCfg
def createCrabCfg(self, *args, **kwargs)
Definition: preexistingValidation.py:81
preexistingValidation.PreexistingOfflineValidation.appendToMerge
def appendToMerge(self, *args, **kwargs)
Definition: preexistingValidation.py:106
primaryVertexValidation.PrimaryVertexValidation
Definition: primaryVertexValidation.py:9
preexistingValidation.PreexistingValidation.__init__
def __init__(self, valName, config)
Definition: preexistingValidation.py:22
TkAlExceptions.AllInOneError
Definition: TkAlExceptions.py:1
preexistingValidation.PreexistingGeometryComparison
Definition: preexistingValidation.py:133
offlineValidation.OfflineValidation.deprecateddefaults
dictionary deprecateddefaults
Definition: offlineValidation.py:24
preexistingValidation.PreexistingValidation.createConfiguration
def createConfiguration(self, *args, **kwargs)
Definition: preexistingValidation.py:77
genericValidation.GenericValidation.defaultReferenceName
string defaultReferenceName
Definition: genericValidation.py:43
genericValidation.GenericValidation
Definition: genericValidation.py:42
update
#define update(a, b)
Definition: TrackClassifier.cc:10
genericValidation.GenericValidation.config
config
Definition: genericValidation.py:61