CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes
genericValidation.GenericValidationData Class Reference
Inheritance diagram for genericValidation.GenericValidationData:
genericValidation.GenericValidation genericValidation.ValidationMetaClass genericValidation.GenericValidationData_CTSR

Public Member Functions

def __init__
 
def Bookkeeping
 
def cfgName
 
def cfgTemplate
 
def createConfiguration
 
def createCrabCfg
 
def createScript
 
def DefinePath
 
def FileOutputTemplate
 
def filesToCompare
 
def getRepMap
 
def LoadBasicModules
 
def ProcessName
 
def TrackSelectionRefitting
 
def ValidationTemplate
 
- Public Member Functions inherited from genericValidation.GenericValidation
def __init__
 
def createConfiguration
 
def createCrabCfg
 
def createFiles
 
def createScript
 
def filesToCompare
 
def getCompareStrings
 
def getRepMap
 
- Public Member Functions inherited from genericValidation.ValidationMetaClass
def __new__
 

Public Attributes

 crabWorkingDir
 
 dataset
 
- Public Attributes inherited from genericValidation.GenericValidation
 alignmentToValidate
 
 AutoAlternates
 
 cmssw
 
 cmsswreleasebase
 
 config
 
 configFiles
 
 crabConfigFiles
 
 general
 
 jobid
 
 jobmode
 
 name
 
 needsproxy
 
 NJobs
 
 packages
 
 randomWorkdirPart
 
 scramarch
 
 scriptFiles
 

Static Public Attributes

dictionary defaults
 
dictionary mandatories = {"dataset", "maxevents"}
 
 needParentFiles = False
 
dictionary optionals = {"magneticfield"}
 
- Static Public Attributes inherited from genericValidation.GenericValidation
string defaultReferenceName = "DEFAULT"
 
dictionary defaults
 
tuple mandatories = set()
 
dictionary needpackages = {"Alignment/OfflineValidation"}
 
dictionary optionals = {"jobmode"}
 
- Static Public Attributes inherited from genericValidation.ValidationMetaClass
list dicts = ["defaults"]
 
list sets = ["mandatories", "optionals", "needpackages"]
 

Detailed Description

Subclass of `GenericValidation` which is the base for validations using
datasets.

Definition at line 250 of file genericValidation.py.

Constructor & Destructor Documentation

def genericValidation.GenericValidationData.__init__ (   self,
  valName,
  alignment,
  config 
)
This method adds additional items to the `self.general` dictionary
which are only needed for validations using datasets.

Arguments:
- `valName`: String which identifies individual validation instances
- `alignment`: `Alignment` instance to validate
- `config`: `BetterConfigParser` instance which includes the
    configuration of the validations

Definition at line 270 of file genericValidation.py.

References genericValidation.GenericValidation.cmssw, genericValidation.GenericValidation.cmsswreleasebase, genericValidation.GenericValidation.general, genericValidation.GenericValidation.NJobs, and print().

271  def __init__(self, valName, alignment, config):
272  """
273  This method adds additional items to the `self.general` dictionary
274  which are only needed for validations using datasets.
275 
276  Arguments:
277  - `valName`: String which identifies individual validation instances
278  - `alignment`: `Alignment` instance to validate
279  - `config`: `BetterConfigParser` instance which includes the
280  configuration of the validations
281  """
282 
283  super(GenericValidationData, self).__init__(valName, alignment, config)
284 
285  # if maxevents is not specified, cannot calculate number of events for
286  # each parallel job, and therefore running only a single job
287  if int( self.general["maxevents"] ) < 0 and self.NJobs > 1:
288  msg = ("Maximum number of events (maxevents) not specified: "
289  "cannot use parallel jobs.")
290  raise AllInOneError(msg)
291  if int( self.general["maxevents"] ) / self.NJobs != float( self.general["maxevents"] ) / self.NJobs:
292  msg = ("maxevents has to be divisible by parallelJobs")
293  raise AllInOneError(msg)
294 
295  tryPredefinedFirst = (not self.jobmode.split( ',' )[0] == "crab" and self.general["JSON"] == ""
296  and self.general["firstRun"] == "" and self.general["lastRun"] == ""
297  and self.general["begin"] == "" and self.general["end"] == "")
298 
299  if self.general["dataset"] not in globalDictionaries.usedDatasets:
300  globalDictionaries.usedDatasets[self.general["dataset"]] = {}
301 
302  if self.cmssw not in globalDictionaries.usedDatasets[self.general["dataset"]]:
303  if globalDictionaries.usedDatasets[self.general["dataset"]] != {}:
304  print(("Warning: you use the same dataset '%s' in multiple cmssw releases.\n"
305  "This is allowed, but make sure it's not a mistake") % self.general["dataset"])
306  globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw] = {False: None, True: None}
307 
308  Bfield = self.general.get("magneticfield", None)
309  if globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw][tryPredefinedFirst] is None:
310  dataset = Dataset(
311  self.general["dataset"], tryPredefinedFirst = tryPredefinedFirst,
312  cmssw = self.cmssw, cmsswrelease = self.cmsswreleasebase, magneticfield = Bfield,
313  dasinstance = self.general["dasinstance"])
314  globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw][tryPredefinedFirst] = dataset
315  if tryPredefinedFirst and not dataset.predefined(): #No point finding the data twice in that case
316  globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw][False] = dataset
318  self.dataset = globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw][tryPredefinedFirst]
319  self.general["magneticField"] = self.dataset.magneticField()
320  self.general["defaultMagneticField"] = "MagneticField"
321  if self.general["magneticField"] == "unknown":
322  print("Could not get the magnetic field for this dataset.")
323  print("Using the default: ", self.general["defaultMagneticField"])
324  self.general["magneticField"] = '.oO[defaultMagneticField]Oo.'
325 
326  if not self.jobmode.split( ',' )[0] == "crab":
327  try:
328  self.general["datasetDefinition"] = self.dataset.datasetSnippet(
329  jsonPath = self.general["JSON"],
330  firstRun = self.general["firstRun"],
331  lastRun = self.general["lastRun"],
332  begin = self.general["begin"],
333  end = self.general["end"],
334  parent = self.needParentFiles )
335  except AllInOneError as e:
336  msg = "In section [%s:%s]: "%(self.valType, self.name)
337  msg += str(e)
338  raise AllInOneError(msg)
339  else:
340  if self.dataset.predefined():
341  msg = ("For jobmode 'crab' you cannot use predefined datasets "
342  "(in your case: '%s')."%( self.dataset.name() ))
343  raise AllInOneError( msg )
344  try:
345  theUpdate = config.getResultingSection(self.valType+":"+self.name,
346  demandPars = ["parallelJobs"])
347  except AllInOneError as e:
348  msg = str(e)[:-1]+" when using 'jobmode: crab'."
349  raise AllInOneError(msg)
350  self.general.update(theUpdate)
351  if self.general["begin"] or self.general["end"]:
352  ( self.general["begin"],
353  self.general["end"],
354  self.general["firstRun"],
355  self.general["lastRun"] ) = self.dataset.convertTimeToRun(
356  firstRun = self.general["firstRun"],
357  lastRun = self.general["lastRun"],
358  begin = self.general["begin"],
359  end = self.general["end"],
360  shortTuple = False)
361  if self.general["begin"] == None:
362  self.general["begin"] = ""
363  if self.general["end"] == None:
364  self.general["end"] = ""
365  self.general["firstRun"] = str( self.general["firstRun"] )
366  self.general["lastRun"] = str( self.general["lastRun"] )
367  if ( not self.general["firstRun"] ) and \
368  ( self.general["end"] or self.general["lastRun"] ):
369  self.general["firstRun"] = str(
370  self.dataset.runList()[0]["run_number"])
371  if ( not self.general["lastRun"] ) and \
372  ( self.general["begin"] or self.general["firstRun"] ):
373  self.general["lastRun"] = str(
374  self.dataset.runList()[-1]["run_number"])
375  if self.general["firstRun"] and self.general["lastRun"]:
376  if int(self.general["firstRun"]) > int(self.general["lastRun"]):
377  msg = ( "The lower time/runrange limit ('begin'/'firstRun') "
378  "chosen is greater than the upper time/runrange limit "
379  "('end'/'lastRun').")
380  raise AllInOneError( msg )
381  self.general["runRange"] = (self.general["firstRun"]
382  + '-' + self.general["lastRun"])
383  try:
384  self.general["datasetDefinition"] = self.dataset.datasetSnippet(
385  jsonPath = self.general["JSON"],
386  firstRun = self.general["firstRun"],
387  lastRun = self.general["lastRun"],
388  begin = self.general["begin"],
389  end = self.general["end"],
390  crab = True )
391  except AllInOneError as e:
392  msg = "In section [%s:%s]: "%(self.valType, self.name)
393  msg += str( e )
394  raise AllInOneError( msg )
395 
396  self.general["usepixelqualityflag"] = pythonboolstring(self.general["usepixelqualityflag"], "usepixelqualityflag")
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)

Member Function Documentation

def genericValidation.GenericValidationData.Bookkeeping (   self)

Definition at line 494 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

495  def Bookkeeping(self):
return configTemplates.Bookkeeping
def genericValidation.GenericValidationData.cfgName (   self)

Definition at line 423 of file genericValidation.py.

References primaryVertexResolution.PrimaryVertexResolution.configBaseName, primaryVertexValidation.PrimaryVertexValidation.configBaseName, offlineValidation.OfflineValidation.configBaseName, zMuMuValidation.ZMuMuValidation.configBaseName, trackSplittingValidation.TrackSplittingValidation.configBaseName, monteCarloValidation.MonteCarloValidation.configBaseName, overlapValidation.OverlapValidation.configBaseName, offlineValidation.OfflineValidationDQM.configBaseName, AlignableObjectId::entry.name, alignment.Alignment.name, genericValidation.GenericValidation.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, classes.MonitorData.name, classes.OutputData.name, geometry.Structure.name, and plotscripts.SawTeethFunction.name.

Referenced by genericValidation.GenericValidationData.createConfiguration().

424  def cfgName(self):
425  return "%s.%s.%s_cfg.py"%( self.configBaseName, self.name,
self.alignmentToValidate.name )
def genericValidation.GenericValidationData.cfgTemplate (   self)

Definition at line 431 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.createConfiguration().

432  def cfgTemplate(self):
433  return configTemplates.cfgTemplate
def genericValidation.GenericValidationData.createConfiguration (   self,
  path 
)

Definition at line 442 of file genericValidation.py.

References genericValidation.GenericValidationData.cfgName(), Mpslibclass.jobdatabase.cfgTemplate, genericValidation.GenericValidationData.cfgTemplate(), genericValidation.GenericValidation.getRepMap(), and alignment.Alignment.getRepMap().

443  def createConfiguration(self, path ):
444  repMap = self.getRepMap()
445  cfgs = {self.cfgName: self.cfgTemplate}
446  super(GenericValidationData, self).createConfiguration(cfgs, path, repMap=repMap)
def genericValidation.GenericValidationData.createCrabCfg (   self,
  path,
  crabCfgBaseName 
)
Method which creates a `crab.cfg` for a validation on datasets.

Arguments:
- `path`: Path at which the file will be stored.
- `crabCfgBaseName`: String which depends on the actual type of
             validation calling this method.

Definition at line 461 of file genericValidation.py.

References genericValidation.GenericValidation.getRepMap(), alignment.Alignment.getRepMap(), AlignableObjectId::entry.name, alignment.Alignment.name, genericValidation.GenericValidation.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, classes.MonitorData.name, classes.OutputData.name, geometry.Structure.name, and plotscripts.SawTeethFunction.name.

462  def createCrabCfg(self, path, crabCfgBaseName):
463  """
464  Method which creates a `crab.cfg` for a validation on datasets.
465 
466  Arguments:
467  - `path`: Path at which the file will be stored.
468  - `crabCfgBaseName`: String which depends on the actual type of
469  validation calling this method.
470  """
471  crabCfgName = "crab.%s.%s.%s.cfg"%( crabCfgBaseName, self.name,
472  self.alignmentToValidate.name )
473  repMap = self.getRepMap()
474  repMap["script"] = "dummy_script.sh"
475  # repMap["crabOutputDir"] = os.path.basename( path )
476  repMap["crabWorkingDir"] = crabCfgName.split( '.cfg' )[0]
477  self.crabWorkingDir = repMap["crabWorkingDir"]
478  repMap["numberOfJobs"] = self.general["parallelJobs"]
479  repMap["cfgFile"] = self.configFiles[0]
480  repMap["queue"] = self.jobmode.split( ',' )[1].split( '-q' )[1]
481  if self.dataset.dataType() == "mc":
482  repMap["McOrData"] = "events = .oO[nEvents]Oo."
483  elif self.dataset.dataType() == "data":
484  repMap["McOrData"] = "lumis = -1"
485  if self.jobmode.split( ',' )[0] == "crab":
486  print ("For jobmode 'crab' the parameter 'maxevents' will be "
487  "ignored and all events will be processed.")
488  else:
489  raise AllInOneError("Unknown data type! Can't run in crab mode")
490  crabCfg = {crabCfgName: replaceByMap( configTemplates.crabCfgTemplate,
491  repMap ) }
492  return super(GenericValidationData, self).createCrabCfg( crabCfg, path )
def replaceByMap
— Helpers —############################
def genericValidation.GenericValidationData.createScript (   self,
  path,
  template = configTemplates.scriptTemplate,
  downloadFiles = [],
  repMap = None,
  repMaps = None 
)

Definition at line 447 of file genericValidation.py.

References helperFunctions.addIndex(), genericValidation.GenericValidation.configFiles, genericValidation.GenericValidation.getRepMap(), alignment.Alignment.getRepMap(), AlignableObjectId::entry.name, alignment.Alignment.name, genericValidation.GenericValidation.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, classes.MonitorData.name, classes.OutputData.name, geometry.Structure.name, plotscripts.SawTeethFunction.name, genericValidation.GenericValidation.NJobs, primaryVertexResolution.PrimaryVertexResolution.scriptBaseName, primaryVertexValidation.PrimaryVertexValidation.scriptBaseName, offlineValidation.OfflineValidation.scriptBaseName, trackSplittingValidation.TrackSplittingValidation.scriptBaseName, zMuMuValidation.ZMuMuValidation.scriptBaseName, monteCarloValidation.MonteCarloValidation.scriptBaseName, and overlapValidation.OverlapValidation.scriptBaseName.

448  def createScript(self, path, template = configTemplates.scriptTemplate, downloadFiles=[], repMap = None, repMaps = None):
449  scriptName = "%s.%s.%s.sh"%(self.scriptBaseName, self.name,
450  self.alignmentToValidate.name )
451  if repMap is None and repMaps is None:
452  repMap = self.getRepMap()
453  repMap["CommandLine"]=""
454  for cfg in self.configFiles:
455  repMap["CommandLine"]+= repMap["CommandLineTemplate"]%{"cfgFile":addIndex(cfg, self.NJobs, ".oO[nIndex]Oo."),
456  "postProcess":""
457  }
458  scripts = {scriptName: template}
459  return super(GenericValidationData, self).createScript(scripts, path, downloadFiles = downloadFiles,
460  repMap = repMap, repMaps = repMaps)
def genericValidation.GenericValidationData.DefinePath (   self)

Definition at line 506 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

507  def DefinePath(self):
508  pass
def genericValidation.GenericValidationData.FileOutputTemplate (   self)

Definition at line 503 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

504  def FileOutputTemplate(self):
return configTemplates.FileOutputTemplate
def genericValidation.GenericValidationData.filesToCompare (   self)

Definition at line 439 of file genericValidation.py.

References genericValidation.GenericValidation.defaultReferenceName, genericValidation.GenericValidation.getRepMap(), and alignment.Alignment.getRepMap().

440  def filesToCompare(self):
441  return {self.defaultReferenceName: self.getRepMap()["finalResultFile"]}
def genericValidation.GenericValidationData.getRepMap (   self,
  alignment = None 
)

Definition at line 397 of file genericValidation.py.

References helperFunctions.addIndex(), genericValidation.GenericValidationData.Bookkeeping(), genericValidation.GenericValidationData.DefinePath(), genericValidation.GenericValidationData.FileOutputTemplate(), genericValidation.GenericValidationData.LoadBasicModules(), AlignableObjectId::entry.name, alignment.Alignment.name, genericValidation.GenericValidation.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, classes.MonitorData.name, classes.OutputData.name, geometry.Structure.name, plotscripts.SawTeethFunction.name, genericValidation.GenericValidation.NJobs, primaryVertexResolution.PrimaryVertexResolution.outputBaseName, primaryVertexValidation.PrimaryVertexValidation.outputBaseName, offlineValidation.OfflineValidation.outputBaseName, zMuMuValidation.ZMuMuValidation.outputBaseName, trackSplittingValidation.TrackSplittingValidation.outputBaseName, monteCarloValidation.MonteCarloValidation.outputBaseName, overlapValidation.OverlapValidation.outputBaseName, genericValidation.GenericValidationData.ProcessName(), helperFunctions.replaceByMap(), primaryVertexResolution.PrimaryVertexResolution.resultBaseName, primaryVertexValidation.PrimaryVertexValidation.resultBaseName, offlineValidation.OfflineValidation.resultBaseName, trackSplittingValidation.TrackSplittingValidation.resultBaseName, zMuMuValidation.ZMuMuValidation.resultBaseName, monteCarloValidation.MonteCarloValidation.resultBaseName, overlapValidation.OverlapValidation.resultBaseName, genericValidation.GenericValidationData.TrackSelectionRefitting(), and genericValidation.GenericValidationData.ValidationTemplate().

Referenced by overlapValidation.OverlapValidation.appendToMerge(), trackSplittingValidation.TrackSplittingValidation.appendToMerge(), primaryVertexResolution.PrimaryVertexResolution.appendToMerge(), primaryVertexValidation.PrimaryVertexValidation.appendToMerge(), offlineValidation.OfflineValidation.appendToMerge(), overlapValidation.OverlapValidation.appendToPlots(), trackSplittingValidation.TrackSplittingValidation.appendToPlots(), primaryVertexResolution.PrimaryVertexResolution.appendToPlots(), primaryVertexValidation.PrimaryVertexValidation.appendToPlots(), zMuMuValidation.ZMuMuValidation.appendToPlots(), geometryComparison.GeometryComparison.createConfiguration(), geometryComparison.GeometryComparison.createScript(), zMuMuValidation.ZMuMuValidation.filesToCompare(), and plottingOptions.PlottingOptionsTrackSplitting.validsubdets().

398  def getRepMap(self, alignment = None):
399  result = super(GenericValidationData, self).getRepMap(alignment)
400  outputfile = os.path.expandvars(replaceByMap(
401  "%s_%s_.oO[name]Oo..root" % (self.outputBaseName, self.name)
402  , result))
403  resultfile = os.path.expandvars(replaceByMap(("/store/group/alca_trackeralign/AlignmentValidation/.oO[eosdir]Oo./" +
404  "%s_%s_.oO[name]Oo..root" % (self.resultBaseName, self.name))
405  , result))
406  result.update({
407  "resultFile": ".oO[resultFiles[.oO[nIndex]Oo.]]Oo.",
408  "resultFiles": addIndex(resultfile, self.NJobs),
409  "finalResultFile": resultfile,
410  "outputFile": ".oO[outputFiles[.oO[nIndex]Oo.]]Oo.",
411  "outputFiles": addIndex(outputfile, self.NJobs),
412  "finalOutputFile": outputfile,
413  "ProcessName": self.ProcessName,
414  "Bookkeeping": self.Bookkeeping,
415  "LoadBasicModules": self.LoadBasicModules,
416  "TrackSelectionRefitting": self.TrackSelectionRefitting,
417  "ValidationConfig": self.ValidationTemplate,
418  "FileOutputTemplate": self.FileOutputTemplate,
419  "DefinePath": self.DefinePath,
420  })
421  return result
def replaceByMap
— Helpers —############################
def genericValidation.GenericValidationData.LoadBasicModules (   self)

Definition at line 497 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

498  def LoadBasicModules(self):
return configTemplates.LoadBasicModules
def genericValidation.GenericValidationData.ProcessName (   self)

Definition at line 427 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

428  def ProcessName(self):
429  pass
def genericValidation.GenericValidationData.TrackSelectionRefitting (   self)

Definition at line 500 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

501  def TrackSelectionRefitting(self):
pass
def genericValidation.GenericValidationData.ValidationTemplate (   self)

Definition at line 435 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

436  def ValidationTemplate(self):
437  pass

Member Data Documentation

genericValidation.GenericValidationData.crabWorkingDir

Definition at line 476 of file genericValidation.py.

genericValidation.GenericValidationData.dataset

Definition at line 317 of file genericValidation.py.

Referenced by edmIntegrityCheck.IntegrityCheck.query(), production_tasks.BaseDataset.query(), production_tasks.CheckDatasetExists.run(), production_tasks.BaseDataset.run(), production_tasks.GenerateMask.run(), production_tasks.CreateJobDirectory.run(), production_tasks.SourceCFG.run(), production_tasks.FullCFG.run(), production_tasks.WriteToDatasets.run(), production_tasks.RunCMSBatch.run(), production_tasks.MonitorJobs.run(), production_tasks.CleanJobFiles.run(), and edmIntegrityCheck.IntegrityCheck.structured().

dictionary genericValidation.GenericValidationData.defaults
static
Initial value:
1 = {
2  "runRange": "",
3  "firstRun": "",
4  "lastRun": "",
5  "begin": "",
6  "end": "",
7  "JSON": "",
8  "dasinstance": "prod/global",
9  "ttrhbuilder":"WithAngleAndTemplate",
10  "usepixelqualityflag": "True",
11  }

Definition at line 257 of file genericValidation.py.

Referenced by tree.Tree.reset(), and tree.Tree.var().

dictionary genericValidation.GenericValidationData.mandatories = {"dataset", "maxevents"}
static

Definition at line 256 of file genericValidation.py.

genericValidation.GenericValidationData.needParentFiles = False
static

Definition at line 255 of file genericValidation.py.

dictionary genericValidation.GenericValidationData.optionals = {"magneticfield"}
static

Definition at line 268 of file genericValidation.py.