CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes
genericValidation.GenericValidation Class Reference
Inheritance diagram for genericValidation.GenericValidation:
genericValidation.GenericValidationData geometryComparison.GeometryComparison preexistingValidation.PreexistingValidation monteCarloValidation.MonteCarloValidation offlineValidation.OfflineValidation primaryVertexValidation.PrimaryVertexValidation trackSplittingValidation.TrackSplittingValidation zMuMuValidation.ZMuMuValidation preexistingValidation.PreexistingGeometryComparison preexistingValidation.PreexistingMonteCarloValidation preexistingValidation.PreexistingOfflineValidation preexistingValidation.PreexistingTrackSplittingValidation preexistingValidation.PreexistingZMuMuValidation

Public Member Functions

def __init__
 
def createConfiguration
 
def createCrabCfg
 
def createFiles
 
def createScript
 
def getCompareStrings
 
def getRepMap
 

Public Attributes

 alignmentToValidate
 
 AutoAlternates
 
 cmssw
 
 cmsswreleasebase
 
 config
 
 configFiles
 
 crabConfigFiles
 
 filesToCompare
 
 general
 
 jobid
 
 jobmode
 
 name
 
 NJobs
 
 packages
 
 randomWorkdirPart
 
 scramarch
 
 scriptFiles
 
 valType
 

Static Public Attributes

string defaultReferenceName = "DEFAULT"
 

Detailed Description

Definition at line 12 of file genericValidation.py.

Constructor & Destructor Documentation

def genericValidation.GenericValidation.__init__ (   self,
  valName,
  alignment,
  config,
  valType,
  addDefaults = {},
  addMandatories = [],
  addneedpackages = [] 
)

Definition at line 15 of file genericValidation.py.

15 
16  addDefaults = {}, addMandatories=[], addneedpackages=[]):
17  import random
18  self.name = valName
19  self.valType = valType
20  self.alignmentToValidate = alignment
21  self.general = config.getGeneral()
22  self.randomWorkdirPart = "%0i"%random.randint(1,10e9)
23  self.configFiles = []
24  self.filesToCompare = {}
25  self.config = config
26 
27  defaults = {
28  "jobmode": self.general["jobmode"],
29  "cmssw": os.environ['CMSSW_BASE'],
30  "parallelJobs": "1",
31  "jobid": "",
32  }
33  defaults.update(addDefaults)
34  mandatories = []
35  mandatories += addMandatories
36  needpackages = ["Alignment/OfflineValidation"]
37  needpackages += addneedpackages
38  theUpdate = config.getResultingSection(valType+":"+self.name,
39  defaultDict = defaults,
40  demandPars = mandatories)
41  self.general.update(theUpdate)
42  self.jobmode = self.general["jobmode"]
43  self.NJobs = int(self.general["parallelJobs"])
44 
45  # limit maximum number of parallel jobs to 40
46  # (each output file is approximately 20MB)
47  maximumNumberJobs = 40
48  if self.NJobs > maximumNumberJobs:
49  msg = ("Maximum allowed number of parallel jobs "
50  +str(maximumNumberJobs)+" exceeded!!!")
51  raise AllInOneError(msg)
52 
53  self.jobid = self.general["jobid"]
54  if self.jobid:
55  try: #make sure it's actually a valid jobid
56  output = getCommandOutput2("bjobs %(jobid)s 2>&1"%self.general)
57  if "is not found" in output: raise RuntimeError
58  except RuntimeError:
59  raise AllInOneError("%s is not a valid jobid.\nMaybe it finished already?"%self.jobid)
60 
61  self.cmssw = self.general["cmssw"]
62  badcharacters = r"\'"
63  for character in badcharacters:
64  if character in self.cmssw:
65  raise AllInOneError("The bad characters " + badcharacters + " are not allowed in the cmssw\n"
66  "path name. If you really have it in such a ridiculously named location,\n"
67  "try making a symbolic link somewhere with a decent name.")
68  try:
69  os.listdir(self.cmssw)
70  except OSError:
71  raise AllInOneError("Your cmssw release " + self.cmssw + ' does not exist')
72 
73  if self.cmssw == os.environ["CMSSW_BASE"]:
74  self.scramarch = os.environ["SCRAM_ARCH"]
75  self.cmsswreleasebase = os.environ["CMSSW_RELEASE_BASE"]
76  else:
77  command = ("cd '" + self.cmssw + "' && eval `scramv1 ru -sh 2> /dev/null`"
78  ' && echo "$CMSSW_BASE\n$SCRAM_ARCH\n$CMSSW_RELEASE_BASE"')
79  commandoutput = getCommandOutput2(command).split('\n')
80  self.cmssw = commandoutput[0]
81  self.scramarch = commandoutput[1]
82  self.cmsswreleasebase = commandoutput[2]
83 
84  self.packages = {}
85  for package in needpackages:
86  for placetolook in self.cmssw, self.cmsswreleasebase:
87  pkgpath = os.path.join(placetolook, "src", package)
88  if os.path.exists(pkgpath):
89  self.packages[package] = pkgpath
90  break
91  else:
92  raise AllInOneError("Package {} does not exist in {} or {}!".format(package, self.cmssw, self.cmsswreleasebase))
93 
94  self.AutoAlternates = True
95  if config.has_option("alternateTemplates","AutoAlternates"):
96  try:
97  self.AutoAlternates = json.loads(config.get("alternateTemplates","AutoAlternates").lower())
98  except ValueError:
99  raise AllInOneError("AutoAlternates needs to be true or false, not %s" % config.get("alternateTemplates","AutoAlternates"))
100 
101  knownOpts = defaults.keys()+mandatories
102  ignoreOpts = []
103  config.checkInput(valType+":"+self.name,
104  knownSimpleOptions = knownOpts,
105  ignoreOptions = ignoreOpts)
double split
Definition: MVATrainer.cc:139

Member Function Documentation

def genericValidation.GenericValidation.createConfiguration (   self,
  fileContents,
  path,
  schedule = None,
  repMap = None,
  repMaps = None 
)

Definition at line 180 of file genericValidation.py.

References genericValidation.GenericValidation.configFiles.

181  def createConfiguration(self, fileContents, path, schedule = None, repMap = None, repMaps = None):
182  self.configFiles = GenericValidation.createFiles(self, fileContents,
183  path, repMap = repMap, repMaps = repMaps)
184  if not schedule == None:
185  schedule = [os.path.join( path, cfgName) for cfgName in schedule]
186  for cfgName in schedule:
187  if not cfgName in self.configFiles:
188  msg = ("scheduled %s missing in generated configfiles: %s"
189  %(cfgName, self.configFiles))
190  raise AllInOneError(msg)
191  for cfgName in self.configFiles:
192  if not cfgName in schedule:
193  msg = ("generated configuration %s not scheduled: %s"
194  %(cfgName, schedule))
195  raise AllInOneError(msg)
196  self.configFiles = schedule
197  return self.configFiles
def genericValidation.GenericValidation.createCrabCfg (   self,
  fileContents,
  path 
)

Definition at line 206 of file genericValidation.py.

References genericValidation.GenericValidation.NJobs.

207  def createCrabCfg(self, fileContents, path ):
208  if self.NJobs > 1:
209  msg = ("jobmode 'crab' not supported for parallel validation."
210  " Please set parallelJobs = 1.")
211  raise AllInOneError(msg)
212  self.crabConfigFiles = GenericValidation.createFiles(self, fileContents,
213  path)
214  return self.crabConfigFiles
215 
def genericValidation.GenericValidation.createFiles (   self,
  fileContents,
  path,
  repMap = None,
  repMaps = None 
)
repMap: single map for all files
   repMaps: a dict, with the filenames as the keys

Definition at line 157 of file genericValidation.py.

References helperFunctions.addIndex(), genericValidation.GenericValidation.NJobs, and helperFunctions.replaceByMap().

158  def createFiles(self, fileContents, path, repMap = None, repMaps = None):
159  """repMap: single map for all files
160  repMaps: a dict, with the filenames as the keys"""
161  if repMap is not None and repMaps is not None:
162  raise AllInOneError("createFiles can only take repMap or repMaps (or neither), not both")
163  result = []
164  for fileName in fileContents:
165  filePath = os.path.join(path, fileName)
166  result.append(filePath)
167 
168  for (i, filePathi) in enumerate(addIndex(filePath, self.NJobs)):
169  theFile = open( filePathi, "w" )
170  fileContentsi = fileContents[ fileName ]
171  if repMaps is not None:
172  repMap = repMaps[fileName]
173  if repMap is not None:
174  repMap.update({"nIndex": str(i)})
175  fileContentsi = replaceByMap(fileContentsi, repMap)
176  theFile.write( fileContentsi )
177  theFile.close()
178 
179  return result
def replaceByMap
— Helpers —############################
def genericValidation.GenericValidation.createScript (   self,
  fileContents,
  path,
  downloadFiles = [],
  repMap = None,
  repMaps = None 
)

Definition at line 198 of file genericValidation.py.

199  def createScript(self, fileContents, path, downloadFiles=[], repMap = None, repMaps = None):
200  self.scriptFiles = GenericValidation.createFiles(self, fileContents,
201  path, repMap = repMap, repMaps = repMaps)
202  for script in self.scriptFiles:
203  for scriptwithindex in addIndex(script, self.NJobs):
204  os.chmod(scriptwithindex,0o755)
205  return self.scriptFiles
def genericValidation.GenericValidation.getCompareStrings (   self,
  requestId = None,
  plain = False 
)

Definition at line 133 of file genericValidation.py.

References genericValidation.GenericValidation.filesToCompare.

Referenced by trackSplittingValidation.TrackSplittingValidation.appendToExtendedValidation(), preexistingValidation.PreexistingOfflineValidation.appendToExtendedValidation(), and preexistingValidation.PreexistingTrackSplittingValidation.appendToExtendedValidation().

134  def getCompareStrings( self, requestId = None, plain = False ):
135  result = {}
136  repMap = self.alignmentToValidate.getRepMap()
137  for validationId in self.filesToCompare:
138  repMap["file"] = self.filesToCompare[ validationId ]
139  if repMap["file"].startswith( "/castor/" ):
140  repMap["file"] = "rfio:%(file)s"%repMap
141  elif repMap["file"].startswith( "/store/" ):
142  repMap["file"] = "root://eoscms.cern.ch//eos/cms%(file)s"%repMap
143  if plain:
144  result[validationId]=repMap["file"]
145  else:
146  result[validationId]= "%(file)s=%(title)s|%(color)s|%(style)s"%repMap
147  if requestId == None:
148  return result
149  else:
150  if not "." in requestId:
151  requestId += ".%s"%GenericValidation.defaultReferenceName
152  if not requestId.split(".")[-1] in result:
153  msg = ("could not find %s in reference Objects!"
154  %requestId.split(".")[-1])
155  raise AllInOneError(msg)
156  return result[ requestId.split(".")[-1] ]
def genericValidation.GenericValidation.getRepMap (   self,
  alignment = None 
)

Definition at line 106 of file genericValidation.py.

References genericValidation.GenericValidation.alignmentToValidate, genericValidation.GenericValidation.cmssw, genericValidation.GenericValidation.cmsswreleasebase, geometry.Alignables.config, genericValidation.GenericValidation.config, genericValidation.GenericValidation.general, genericValidation.GenericValidation.packages, plottingOptions.PlottingOptions(), genericValidation.GenericValidation.randomWorkdirPart, genericValidation.GenericValidation.scramarch, and genericValidation.GenericValidation.valType.

Referenced by trackSplittingValidation.TrackSplittingValidation.appendToExtendedValidation(), zMuMuValidation.ZMuMuValidation.appendToExtendedValidation(), primaryVertexValidation.PrimaryVertexValidation.appendToExtendedValidation(), offlineValidation.OfflineValidation.appendToExtendedValidation(), preexistingValidation.PreexistingOfflineValidation.appendToExtendedValidation(), preexistingValidation.PreexistingTrackSplittingValidation.appendToExtendedValidation(), trackSplittingValidation.TrackSplittingValidation.appendToMerge(), primaryVertexValidation.PrimaryVertexValidation.appendToMerge(), offlineValidation.OfflineValidation.appendToMerge(), trackSplittingValidation.TrackSplittingValidation.createConfiguration(), monteCarloValidation.MonteCarloValidation.createConfiguration(), primaryVertexValidation.PrimaryVertexValidation.createConfiguration(), offlineValidation.OfflineValidation.createConfiguration(), zMuMuValidation.ZMuMuValidation.createConfiguration(), geometryComparison.GeometryComparison.createConfiguration(), genericValidation.GenericValidationData.createCrabCfg(), geometryComparison.GeometryComparison.createScript(), genericValidation.GenericValidationData.createScript(), preexistingValidation.PreexistingValidation.getCompareStrings(), and plottingOptions.PlottingOptionsTrackSplitting.validsubdets().

107  def getRepMap(self, alignment = None):
108  if alignment == None:
109  alignment = self.alignmentToValidate
110  try:
111  result = PlottingOptions(self.config, self.valType)
112  except KeyError:
113  result = {}
114  result.update(alignment.getRepMap())
115  result.update( self.general )
116  result.update({
117  "workdir": os.path.join(self.general["workdir"],
118  self.randomWorkdirPart),
119  "datadir": self.general["datadir"],
120  "logdir": self.general["logdir"],
121  "CommandLineTemplate": ("#run configfile and post-proccess it\n"
122  "cmsRun %(cfgFile)s\n"
123  "%(postProcess)s "),
124  "CMSSW_BASE": self.cmssw,
125  "SCRAM_ARCH": self.scramarch,
126  "CMSSW_RELEASE_BASE": self.cmsswreleasebase,
127  "alignmentName": alignment.name,
128  "condLoad": alignment.getConditions(),
129  "condLoad": alignment.getConditions(),
130  })
131  result.update(self.packages)
132  return result

Member Data Documentation

genericValidation.GenericValidation.alignmentToValidate

Definition at line 19 of file genericValidation.py.

Referenced by primaryVertexValidation.PrimaryVertexValidation.getRepMap(), zMuMuValidation.ZMuMuValidation.getRepMap(), geometryComparison.GeometryComparison.getRepMap(), and genericValidation.GenericValidation.getRepMap().

genericValidation.GenericValidation.AutoAlternates

Definition at line 93 of file genericValidation.py.

Referenced by offlineValidation.OfflineValidation.createConfiguration().

genericValidation.GenericValidation.cmssw

Definition at line 60 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.__init__(), plottingOptions.BasePlottingOptions.getRepMap(), genericValidation.GenericValidation.getRepMap(), and trackSplittingValidation.TrackSplittingValidation.validsubdets().

genericValidation.GenericValidation.cmsswreleasebase

Definition at line 74 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.__init__(), plottingOptions.BasePlottingOptions.getRepMap(), genericValidation.GenericValidation.getRepMap(), and trackSplittingValidation.TrackSplittingValidation.validsubdets().

genericValidation.GenericValidation.config

Definition at line 24 of file genericValidation.py.

Referenced by genericValidation.GenericValidation.getRepMap(), DTNoiseCalibration.DTNoiseCalibration.initCrab(), DTTTrigProd.DTTTrigProd.initCrab(), DTDQMValidation.DTDQMValidation.initCrab(), DTTTrigValid.DTTTrigValid.initCrab(), DTAnalysisResiduals.DTAnalysisResiduals.initCrab(), DTResidualCalibration.DTResidualCalibration.initCrab(), DTVDriftMeanTimerCalibration.DTVDriftMeanTimerCalibration.initCrab(), DTVDriftSegmentCalibration.DTVDriftSegmentCalibration.initCrab(), DTT0DBValidation.DTT0DBValidation.initProcess(), DTDqm.DTDqm.initProcess(), DTDQMMerge.DTDQMMerge.initProcess(), DTVDriftMeanTimerCalibration.DTVDriftMeanTimerCalibration.initProcess(), DTTTrigProd.DTTTrigProd.initProcess(), DTAnalysisResiduals.DTAnalysisResiduals.initProcess(), DTVDriftSegmentCalibration.DTVDriftSegmentCalibration.initProcess(), DTDQMHarvesting.DTDQMHarvesting.initProcess(), DTNoiseCalibration.DTNoiseCalibration.initProcess(), DTResidualCalibration.DTResidualCalibration.initProcess(), DTTTrigValid.DTTTrigValid.initProcess(), DTDQMValidation.DTDQMValidation.initProcess(), and DTCalibrationWorker.DTCalibrationWorker.run().

genericValidation.GenericValidation.configFiles

Definition at line 22 of file genericValidation.py.

Referenced by genericValidation.GenericValidation.createConfiguration(), geometryComparison.GeometryComparison.createScript(), and genericValidation.GenericValidationData.createScript().

genericValidation.GenericValidation.crabConfigFiles

Definition at line 211 of file genericValidation.py.

string genericValidation.GenericValidation.defaultReferenceName = "DEFAULT"
static

Definition at line 13 of file genericValidation.py.

genericValidation.GenericValidation.filesToCompare

Definition at line 23 of file genericValidation.py.

Referenced by trackSplittingValidation.TrackSplittingValidation.createConfiguration(), monteCarloValidation.MonteCarloValidation.createConfiguration(), primaryVertexValidation.PrimaryVertexValidation.createConfiguration(), offlineValidation.OfflineValidation.createConfiguration(), zMuMuValidation.ZMuMuValidation.createConfiguration(), geometryComparison.GeometryComparison.createScript(), preexistingValidation.PreexistingValidation.getCompareStrings(), and genericValidation.GenericValidation.getCompareStrings().

genericValidation.GenericValidation.general

Definition at line 20 of file genericValidation.py.

Referenced by preexistingValidation.PreexistingOfflineValidation.__init__(), plottingOptions.PlottingOptionsTrackSplitting.__init__(), genericValidation.GenericValidationData.__init__(), offlineValidation.OfflineValidation.createConfiguration(), trackSplittingValidation.TrackSplittingValidation.getRepMap(), monteCarloValidation.MonteCarloValidation.getRepMap(), preexistingValidation.PreexistingValidation.getRepMap(), primaryVertexValidation.PrimaryVertexValidation.getRepMap(), zMuMuValidation.ZMuMuValidation.getRepMap(), offlineValidation.OfflineValidation.getRepMap(), plottingOptions.BasePlottingOptions.getRepMap(), and genericValidation.GenericValidation.getRepMap().

genericValidation.GenericValidation.jobid

Definition at line 52 of file genericValidation.py.

genericValidation.GenericValidation.jobmode

Definition at line 41 of file genericValidation.py.

genericValidation.GenericValidation.name

Definition at line 17 of file genericValidation.py.

Referenced by ElectronMVAID.ElectronMVAID.__call__(), dirstructure.Directory.__create_pie_image(), dqm_interfaces.DirID.__eq__(), BeautifulSoup.Tag.__eq__(), dirstructure.Directory.__get_full_path(), dirstructure.Comparison.__get_img_name(), dataset.Dataset.__getDataType(), dataset.Dataset.__getFileInfoList(), cuy.divideElement.__init__(), cuy.plotElement.__init__(), cuy.additionElement.__init__(), cuy.superimposeElement.__init__(), cuy.graphElement.__init__(), dirstructure.Comparison.__make_image(), core.autovars.NTupleVariable.__repr__(), core.autovars.NTupleObjectType.__repr__(), core.autovars.NTupleObject.__repr__(), core.autovars.NTupleCollection.__repr__(), dirstructure.Directory.__repr__(), dqm_interfaces.DirID.__repr__(), dirstructure.Comparison.__repr__(), config.Service.__setattr__(), config.CFG.__str__(), counter.Counter.__str__(), average.Average.__str__(), BeautifulSoup.Tag.__str__(), BeautifulSoup.SoupStrainer.__str__(), core.autovars.NTupleObjectType.addSubObjects(), core.autovars.NTupleObjectType.addVariables(), core.autovars.NTupleObjectType.allVars(), dirstructure.Directory.calcStats(), trackSplittingValidation.TrackSplittingValidation.createConfiguration(), monteCarloValidation.MonteCarloValidation.createConfiguration(), primaryVertexValidation.PrimaryVertexValidation.createConfiguration(), offlineValidation.OfflineValidation.createConfiguration(), zMuMuValidation.ZMuMuValidation.createConfiguration(), genericValidation.GenericValidationData.createCrabCfg(), geometryComparison.GeometryComparison.createScript(), genericValidation.GenericValidationData.createScript(), validation.Sample.digest(), python.rootplot.utilities.Hist.divide(), python.rootplot.utilities.Hist.divide_wilson(), TreeCrawler.Package.dump(), core.autovars.NTupleVariable.fillBranch(), core.autovars.NTupleObject.fillBranches(), core.autovars.NTupleCollection.fillBranchesScalar(), core.autovars.NTupleCollection.fillBranchesVector(), core.autovars.NTupleCollection.get_cpp_declaration(), core.autovars.NTupleCollection.get_cpp_wrapper_class(), core.autovars.NTupleCollection.get_py_wrapper_class(), utils.StatisticalTest.get_status(), production_tasks.Task.getname(), dataset.CMSDataset.getPrimaryDatasetEntries(), dataset.PrivateDataset.getPrimaryDatasetEntries(), primaryVertexValidation.PrimaryVertexValidation.getRepMap(), zMuMuValidation.ZMuMuValidation.getRepMap(), genericValidation.GenericValidationData.getRepMap(), VIDSelectorBase.VIDSelectorBase.initialize(), personalPlayback.Applet.log(), core.autovars.NTupleVariable.makeBranch(), core.autovars.NTupleObject.makeBranches(), core.autovars.NTupleCollection.makeBranchesScalar(), core.autovars.NTupleCollection.makeBranchesVector(), dirstructure.Directory.print_report(), dataset.BaseDataset.printInfo(), dataset.Dataset.printInfo(), production_tasks.MonitorJobs.run(), BeautifulSoup.SoupStrainer.searchTag(), python.rootplot.utilities.Hist.TGraph(), python.rootplot.utilities.Hist.TH1F(), Vispa.Views.PropertyView.Property.valueChanged(), counter.Counter.write(), and average.Average.write().

genericValidation.GenericValidation.NJobs

Definition at line 42 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.__init__(), offlineValidation.OfflineValidation.createConfiguration(), genericValidation.GenericValidation.createCrabCfg(), genericValidation.GenericValidation.createFiles(), genericValidation.GenericValidationData.createScript(), and genericValidation.GenericValidationData.getRepMap().

genericValidation.GenericValidation.packages

Definition at line 83 of file genericValidation.py.

Referenced by genericValidation.GenericValidation.getRepMap().

genericValidation.GenericValidation.randomWorkdirPart

Definition at line 21 of file genericValidation.py.

Referenced by plottingOptions.BasePlottingOptions.getRepMap(), and genericValidation.GenericValidation.getRepMap().

genericValidation.GenericValidation.scramarch

Definition at line 73 of file genericValidation.py.

Referenced by plottingOptions.BasePlottingOptions.getRepMap(), and genericValidation.GenericValidation.getRepMap().

genericValidation.GenericValidation.scriptFiles

Definition at line 199 of file genericValidation.py.

genericValidation.GenericValidation.valType

Definition at line 18 of file genericValidation.py.

Referenced by genericValidation.GenericValidation.getRepMap().