CMS 3D CMS Logo

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 monteCarloValidation.MonteCarloValidation primaryVertexResolution.PrimaryVertexResolution zMuMuValidation.ZMuMuValidation offlineValidation.OfflineValidation overlapValidation.OverlapValidation primaryVertexValidation.PrimaryVertexValidation trackSplittingValidation.TrackSplittingValidation offlineValidation.OfflineValidationDQM preexistingValidation.PreexistingOfflineValidation preexistingValidation.PreexistingPrimaryVertexValidation preexistingValidation.PreexistingTrackSplittingValidation

Public Member Functions

def __init__ (self, valName, alignment, config)
 
def Bookkeeping (self)
 
def cfgName (self)
 
def cfgTemplate (self)
 
def createConfiguration (self, path)
 
def createCrabCfg (self, path, crabCfgBaseName)
 
def createScript (self, path, template=configTemplates.scriptTemplate, downloadFiles=[], repMap=None, repMaps=None)
 
def DefinePath (self)
 
def FileOutputTemplate (self)
 
def filesToCompare (self)
 
def getRepMap (self, alignment=None)
 
def LoadBasicModules (self)
 
def ProcessName (self)
 
def TrackSelectionRefitting (self)
 
def ValidationTemplate (self)
 
- Public Member Functions inherited from genericValidation.GenericValidation
def __init__ (self, valName, alignment, config)
 
def createConfiguration (self, fileContents, path, schedule=None, repMap=None, repMaps=None)
 
def createCrabCfg (self, fileContents, path)
 
def createFiles (self, fileContents, path, repMap=None, repMaps=None)
 
def createScript (self, fileContents, path, downloadFiles=[], repMap=None, repMaps=None)
 
def filesToCompare (self)
 
def getCompareStrings (self, requestId=None, plain=False)
 
def getRepMap (self, alignment=None)
 
- Public Member Functions inherited from genericValidation.ValidationMetaClass
def __new__ (cls, clsname, bases, dct)
 

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"}
 
bool needParentFiles = False
 
dictionary optionals = {"magneticfield"}
 
- Static Public Attributes inherited from genericValidation.GenericValidation
string defaultReferenceName = "DEFAULT"
 
dictionary defaults
 
 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

◆ __init__()

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, nano_mu_digi_cff.float, genericValidation.GenericValidation.general, createfilelist.int, genericValidation.GenericValidation.jobmode, genericValidation.GenericValidation.NJobs, print(), and submitPVValidationJobs.split().

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

Member Function Documentation

◆ Bookkeeping()

def genericValidation.GenericValidationData.Bookkeeping (   self)

Definition at line 494 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

494  def Bookkeeping(self):
495  return configTemplates.Bookkeeping

◆ cfgName()

def genericValidation.GenericValidationData.cfgName (   self)

◆ cfgTemplate()

def genericValidation.GenericValidationData.cfgTemplate (   self)

Definition at line 431 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.createConfiguration().

431  def cfgTemplate(self):
432  return configTemplates.cfgTemplate
433 

◆ createConfiguration()

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().

442  def createConfiguration(self, path ):
443  repMap = self.getRepMap()
444  cfgs = {self.cfgName: self.cfgTemplate}
445  super(GenericValidationData, self).createConfiguration(cfgs, path, repMap=repMap)
446 

◆ createCrabCfg()

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.alignmentToValidate, 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.

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

◆ createScript()

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.alignmentToValidate, 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.

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

◆ DefinePath()

def genericValidation.GenericValidationData.DefinePath (   self)

Definition at line 506 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

506  def DefinePath(self):
507  pass
508 

◆ FileOutputTemplate()

def genericValidation.GenericValidationData.FileOutputTemplate (   self)

Definition at line 503 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

503  def FileOutputTemplate(self):
504  return configTemplates.FileOutputTemplate

◆ filesToCompare()

def genericValidation.GenericValidationData.filesToCompare (   self)

Definition at line 439 of file genericValidation.py.

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

439  def filesToCompare(self):
440  return {self.defaultReferenceName: self.getRepMap()["finalResultFile"]}
441 

◆ getRepMap()

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 plottingOptions.PlottingOptionsTrackSplitting.validsubdets().

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

◆ LoadBasicModules()

def genericValidation.GenericValidationData.LoadBasicModules (   self)

Definition at line 497 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

497  def LoadBasicModules(self):
498  return configTemplates.LoadBasicModules

◆ ProcessName()

def genericValidation.GenericValidationData.ProcessName (   self)

Definition at line 427 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

427  def ProcessName(self):
428  pass
429 
def ProcessName(process)
Definition: CustomConfigs.py:6

◆ TrackSelectionRefitting()

def genericValidation.GenericValidationData.TrackSelectionRefitting (   self)

Definition at line 500 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

500  def TrackSelectionRefitting(self):
501  pass

◆ ValidationTemplate()

def genericValidation.GenericValidationData.ValidationTemplate (   self)

Definition at line 435 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

435  def ValidationTemplate(self):
436  pass
437 

Member Data Documentation

◆ crabWorkingDir

genericValidation.GenericValidationData.crabWorkingDir

Definition at line 476 of file genericValidation.py.

◆ dataset

genericValidation.GenericValidationData.dataset

◆ defaults

dictionary genericValidation.GenericValidationData.defaults
static
Initial value:
= {
"runRange": "",
"firstRun": "",
"lastRun": "",
"begin": "",
"end": "",
"JSON": "",
"dasinstance": "prod/global",
"ttrhbuilder":"WithAngleAndTemplate",
"usepixelqualityflag": "True",
}

Definition at line 257 of file genericValidation.py.

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

◆ mandatories

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

Definition at line 256 of file genericValidation.py.

◆ needParentFiles

bool genericValidation.GenericValidationData.needParentFiles = False
static

Definition at line 255 of file genericValidation.py.

◆ optionals

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

Definition at line 268 of file genericValidation.py.