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 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 249 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 269 of file genericValidation.py.

References genericValidation.GenericValidation.cmssw, genericValidation.GenericValidation.cmsswreleasebase, objects.autophobj.float, genericValidation.GenericValidation.general, betterConfigParser.BetterConfigParser.general, createfilelist.int, genericValidation.GenericValidation.NJobs, and edm.print().

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

Referenced by genericValidation.GenericValidationData.getRepMap().

493  def Bookkeeping(self):
494  return configTemplates.Bookkeeping
def genericValidation.GenericValidationData.cfgName (   self)
def genericValidation.GenericValidationData.cfgTemplate (   self)

Definition at line 430 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.createConfiguration().

430  def cfgTemplate(self):
431  return configTemplates.cfgTemplate
432 
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 460 of file genericValidation.py.

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

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

Definition at line 446 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, classes.MonitorData.name, MuonGeometrySanityCheckPoint.name, classes.OutputData.name, geometry.Structure.name, plotscripts.SawTeethFunction.name, genericValidation.GenericValidation.NJobs, primaryVertexValidation.PrimaryVertexValidation.scriptBaseName, zMuMuValidation.ZMuMuValidation.scriptBaseName, trackSplittingValidation.TrackSplittingValidation.scriptBaseName, offlineValidation.OfflineValidation.scriptBaseName, and monteCarloValidation.MonteCarloValidation.scriptBaseName.

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

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 502 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 396 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, classes.MonitorData.name, MuonGeometrySanityCheckPoint.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, genericValidation.GenericValidationData.ProcessName(), helperFunctions.replaceByMap(), primaryVertexValidation.PrimaryVertexValidation.resultBaseName, zMuMuValidation.ZMuMuValidation.resultBaseName, trackSplittingValidation.TrackSplittingValidation.resultBaseName, offlineValidation.OfflineValidation.resultBaseName, monteCarloValidation.MonteCarloValidation.resultBaseName, genericValidation.GenericValidationData.TrackSelectionRefitting(), and genericValidation.GenericValidationData.ValidationTemplate().

Referenced by plottingOptions.PlottingOptionsTrackSplitting.validsubdets().

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

Definition at line 496 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 426 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

426  def ProcessName(self):
427  pass
428 
def genericValidation.GenericValidationData.TrackSelectionRefitting (   self)
def genericValidation.GenericValidationData.ValidationTemplate (   self)

Member Data Documentation

genericValidation.GenericValidationData.crabWorkingDir

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

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

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

Definition at line 255 of file genericValidation.py.

bool genericValidation.GenericValidationData.needParentFiles = False
static

Definition at line 254 of file genericValidation.py.

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

Definition at line 267 of file genericValidation.py.