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.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 248 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 268 of file genericValidation.py.

References genericValidation.GenericValidation.cmssw, genericValidation.GenericValidation.cmsswreleasebase, genericValidation.GenericValidation.general, createfilelist.int, and genericValidation.GenericValidation.NJobs.

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

Member Function Documentation

def genericValidation.GenericValidationData.Bookkeeping (   self)

Definition at line 489 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

489  def Bookkeeping(self):
490  return configTemplates.Bookkeeping
def genericValidation.GenericValidationData.cfgName (   self)
def genericValidation.GenericValidationData.cfgTemplate (   self)

Definition at line 426 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.createConfiguration().

426  def cfgTemplate(self):
427  return configTemplates.cfgTemplate
428 
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 456 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.

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

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

Referenced by genericValidation.GenericValidationData.getRepMap().

501  def DefinePath(self):
502  pass
503 
def genericValidation.GenericValidationData.FileOutputTemplate (   self)

Definition at line 498 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 392 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().

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

Definition at line 492 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 422 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

422  def ProcessName(self):
423  pass
424 
def genericValidation.GenericValidationData.TrackSelectionRefitting (   self)
def genericValidation.GenericValidationData.ValidationTemplate (   self)

Member Data Documentation

genericValidation.GenericValidationData.crabWorkingDir

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

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

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

Definition at line 254 of file genericValidation.py.

bool genericValidation.GenericValidationData.needParentFiles = False
static

Definition at line 253 of file genericValidation.py.

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

Definition at line 266 of file genericValidation.py.