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"}
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.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  self.needsproxy = boolfromstring(self.general["needsproxy"], "needsproxy")
37  self.jobid = self.general["jobid"]
38  if self.jobid:
39  try: #make sure it's actually a valid jobid
40  output = getCommandOutput2("bjobs %(jobid)s 2>&1"%self.general)
41  if "is not found" in output: raise RuntimeError
42  except RuntimeError:
43  raise AllInOneError("%s is not a valid jobid.\nMaybe it finished already?"%self.jobid)
44 
45  knownOpts = set(self.defaults.keys())|self.mandatories|self.optionals
46  ignoreOpts = []
47  config.checkInput("preexisting"+self.valType+":"+self.name,
48  knownSimpleOptions = knownOpts,
49  ignoreOptions = ignoreOpts)
50  self.jobmode = None
51 
52  try: #initialize plotting options for this validation type
53  result = PlottingOptions(self.config, self.valType)
54  except KeyError:
55  pass
56 
57  @property
58  def filesToCompare(self):
59  return {self.defaultReferenceName: self.general["file"]}
60 
61  def getRepMap(self):
62  #do not call super
63  try:
64  result = PlottingOptions(self.config, self.valType)
65  except KeyError:
66  result = {}
67  result.update(self.general)
68  result.update({
69  "color": str(parsecolor(result["color"])),
70  "style": str(parsestyle(result["style"])),
71  })
72  return result
73 
74  def createFiles(self, *args, **kwargs):
75  raise AllInOneError("Shouldn't be here...")
76  def createConfiguration(self, *args, **kwargs):
77  pass
78  def createScript(self, *args, **kwargs):
79  raise AllInOneError("Shouldn't be here...")
80  def createCrabCfg(self, *args, **kwargs):
81  raise AllInOneError("Shouldn't be here...")
82 
84  deprecateddefaults = {
85  "DMRMethod":"",
86  "DMRMinimum":"",
87  "DMROptions":"",
88  "OfflineTreeBaseDir":"",
89  "SurfaceShapes":""
90  }
91  defaults = deprecateddefaults.copy()
92  def __init__(self, valName, config):
93  super(PreexistingOfflineValidation, self).__init__(valName, config)
94  for option in self.deprecateddefaults:
95  if self.general[option]:
96  raise AllInOneError("The '%s' option has been moved to the [plots:offline] section. Please specify it there."%option)
97 
98  def getRepMap(self):
99  result = super(PreexistingOfflineValidation, self).getRepMap()
100  result.update({
101  "filetoplot": self.general["file"],
102  })
103  return result
104 
105  def appendToMerge(self, *args, **kwargs):
106  raise AllInOneError("Shouldn't be here...")
107 
109  removemandatories = {"isda","ismc","runboundary","vertexcollection","lumilist","ptCut","etaCut","runControl","numberOfBins"}
110  def getRepMap(self):
111  result = super(PreexistingPrimaryVertexValidation, self).getRepMap()
112  result.update({
113  "filetoplot": self.general["file"],
114  })
115  return result
116 
117  def appendToMerge(self, *args, **kwargs):
118  raise AllInOneError("Shouldn't be here...")
119 
121  def appendToMerge(self, *args, **kwargs):
122  raise AllInOneError("Shouldn't be here...")
123 
125  pass
126 
127 class PreexistingZMuMuValidation(PreexistingValidation):
128  def __init__(self, *args, **kwargs):
129  raise AllInOneError("Preexisting Z->mumu validation not implemented")
130  #more complicated, it has multiple output files
131 
133  def __init__(self, *args, **kwargs):
134  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)