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

Member Function Documentation

def genericValidation.GenericValidationData.Bookkeeping (   self)

Definition at line 492 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 429 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.createConfiguration().

429  def cfgTemplate(self):
430  return configTemplates.cfgTemplate
431 
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 459 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.

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

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

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 501 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

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

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

Definition at line 495 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Definition at line 425 of file genericValidation.py.

Referenced by genericValidation.GenericValidationData.getRepMap().

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

Member Data Documentation

genericValidation.GenericValidationData.crabWorkingDir

Definition at line 474 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.