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.GenericValidationData_CTSR monteCarloValidation.MonteCarloValidation 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 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"}
 

Detailed Description

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

Definition at line 251 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 271 of file genericValidation.py.

References genericValidation.GenericValidation.cmssw, genericValidation.GenericValidation.cmsswreleasebase, dqmMemoryStats.float, genericValidation.GenericValidation.general, createfilelist.int, genericValidation.GenericValidation.NJobs, and edm.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
317 
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")
397 
def pythonboolstring(string, name)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def __init__(self, valName, alignment, config)
#define str(s)

Member Function Documentation

def genericValidation.GenericValidationData.Bookkeeping (   self)

Definition at line 495 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 432 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.createConfiguration().

432  def cfgTemplate(self):
433  return configTemplates.cfgTemplate
434 
def genericValidation.GenericValidationData.createConfiguration (   self,
  path 
)
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 462 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 )
493 
std::vector< std::string_view > split(std::string_view, const char *)
def createCrabCfg(self, path, crabCfgBaseName)
def replaceByMap(target, the_map)
— Helpers —############################
def getRepMap(self, alignment=None)
def genericValidation.GenericValidationData.createScript (   self,
  path,
  template = configTemplates.scriptTemplate,
  downloadFiles = [],
  repMap = None,
  repMaps = None 
)

Definition at line 448 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, primaryVertexValidation.PrimaryVertexValidation.scriptBaseName, trackSplittingValidation.TrackSplittingValidation.scriptBaseName, offlineValidation.OfflineValidation.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)
461 
def addIndex(filename, njobs, index=None)
def createScript(self, path, template=configTemplates.scriptTemplate, downloadFiles=[], repMap=None, repMaps=None)
def getRepMap(self, alignment=None)
def genericValidation.GenericValidationData.DefinePath (   self)

Definition at line 507 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 504 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

505  return configTemplates.FileOutputTemplate
def genericValidation.GenericValidationData.filesToCompare (   self)
def genericValidation.GenericValidationData.getRepMap (   self,
  alignment = None 
)

Definition at line 398 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, primaryVertexValidation.PrimaryVertexValidation.outputBaseName, offlineValidation.OfflineValidation.outputBaseName, trackSplittingValidation.TrackSplittingValidation.outputBaseName, zMuMuValidation.ZMuMuValidation.outputBaseName, monteCarloValidation.MonteCarloValidation.outputBaseName, overlapValidation.OverlapValidation.outputBaseName, genericValidation.GenericValidationData.ProcessName(), helperFunctions.replaceByMap(), primaryVertexValidation.PrimaryVertexValidation.resultBaseName, trackSplittingValidation.TrackSplittingValidation.resultBaseName, zMuMuValidation.ZMuMuValidation.resultBaseName, offlineValidation.OfflineValidation.resultBaseName, monteCarloValidation.MonteCarloValidation.resultBaseName, overlapValidation.OverlapValidation.resultBaseName, genericValidation.GenericValidationData.TrackSelectionRefitting(), and genericValidation.GenericValidationData.ValidationTemplate().

Referenced by 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
422 
def addIndex(filename, njobs, index=None)
def replaceByMap(target, the_map)
— Helpers —############################
def genericValidation.GenericValidationData.LoadBasicModules (   self)

Definition at line 498 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 428 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Member Data Documentation

genericValidation.GenericValidationData.crabWorkingDir

Definition at line 477 of file genericValidation.py.

genericValidation.GenericValidationData.dataset
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 258 of file genericValidation.py.

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

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

Definition at line 257 of file genericValidation.py.

bool genericValidation.GenericValidationData.needParentFiles = False
static

Definition at line 256 of file genericValidation.py.

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

Definition at line 269 of file genericValidation.py.