CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
genericValidation.GenericValidationData Class Reference
Inheritance diagram for genericValidation.GenericValidationData:
genericValidation.GenericValidation monteCarloValidation.MonteCarloValidation offlineValidation.OfflineValidation primaryVertexValidation.PrimaryVertexValidation trackSplittingValidation.TrackSplittingValidation zMuMuValidation.ZMuMuValidation offlineValidation.OfflineValidationDQM

Public Member Functions

def __init__
 
def createCrabCfg
 
def createScript
 
def getRepMap
 
- Public Member Functions inherited from genericValidation.GenericValidation
def __init__
 
def createConfiguration
 
def createCrabCfg
 
def createFiles
 
def createScript
 
def getCompareStrings
 
def getRepMap
 

Public Attributes

 crabWorkingDir
 
 dataset
 
- Public Attributes inherited from genericValidation.GenericValidation
 alignmentToValidate
 
 AutoAlternates
 
 cmssw
 
 cmsswreleasebase
 
 config
 
 configFiles
 
 crabConfigFiles
 
 filesToCompare
 
 general
 
 jobid
 
 jobmode
 
 name
 
 NJobs
 
 packages
 
 randomWorkdirPart
 
 scramarch
 
 scriptFiles
 
 valType
 

Additional Inherited Members

- Static Public Attributes inherited from genericValidation.GenericValidation
string defaultReferenceName = "DEFAULT"
 

Detailed Description

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

Definition at line 216 of file genericValidation.py.

Constructor & Destructor Documentation

def genericValidation.GenericValidationData.__init__ (   self,
  valName,
  alignment,
  config,
  valType,
  addDefaults = {},
  addMandatories = [],
  addneedpackages = [] 
)
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
- `valType`: String which specifies the type of validation
- `addDefaults`: Dictionary which contains default values for individual
         validations in addition to the general default values
- `addMandatories`: List which contains mandatory parameters for
            individual validations in addition to the general
            mandatory parameters

Definition at line 223 of file genericValidation.py.

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

224  addDefaults = {}, addMandatories=[], addneedpackages=[]):
225  """
226  This method adds additional items to the `self.general` dictionary
227  which are only needed for validations using datasets.
228 
229  Arguments:
230  - `valName`: String which identifies individual validation instances
231  - `alignment`: `Alignment` instance to validate
232  - `config`: `BetterConfigParser` instance which includes the
233  configuration of the validations
234  - `valType`: String which specifies the type of validation
235  - `addDefaults`: Dictionary which contains default values for individual
236  validations in addition to the general default values
237  - `addMandatories`: List which contains mandatory parameters for
238  individual validations in addition to the general
239  mandatory parameters
240  """
241 
242  defaults = {"runRange": "",
243  "firstRun": "",
244  "lastRun": "",
245  "begin": "",
246  "end": "",
247  "JSON": ""
248  }
249  defaults.update(addDefaults)
250  mandatories = [ "dataset", "maxevents" ]
251  mandatories += addMandatories
252  needpackages = addneedpackages
253  GenericValidation.__init__(self, valName, alignment, config, valType, defaults, mandatories, needpackages)
254 
255  # if maxevents is not specified, cannot calculate number of events for
256  # each parallel job, and therefore running only a single job
257  if int( self.general["maxevents"] ) == -1 and self.NJobs > 1:
258  msg = ("Maximum number of events (maxevents) not specified: "
259  "cannot use parallel jobs.")
260  raise AllInOneError(msg)
261 
262  tryPredefinedFirst = (not self.jobmode.split( ',' )[0] == "crab" and self.general["JSON"] == ""
263  and self.general["firstRun"] == "" and self.general["lastRun"] == ""
264  and self.general["begin"] == "" and self.general["end"] == "")
265 
266  if self.general["dataset"] not in globalDictionaries.usedDatasets:
267  globalDictionaries.usedDatasets[self.general["dataset"]] = {}
268 
269  if self.cmssw not in globalDictionaries.usedDatasets[self.general["dataset"]]:
270  if globalDictionaries.usedDatasets[self.general["dataset"]] != {}:
271  print ("Warning: you use the same dataset '%s' in multiple cmssw releases.\n"
272  "This is allowed, but make sure it's not a mistake") % self.general["dataset"]
273  globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw] = {False: None, True: None}
274 
275  if globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw][tryPredefinedFirst] is None:
276  dataset = Dataset(
277  self.general["dataset"], tryPredefinedFirst = tryPredefinedFirst,
278  cmssw = self.cmssw, cmsswrelease = self.cmsswreleasebase )
279  globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw][tryPredefinedFirst] = dataset
280  if tryPredefinedFirst and not dataset.predefined(): #No point finding the data twice in that case
281  globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw][False] = dataset
283  self.dataset = globalDictionaries.usedDatasets[self.general["dataset"]][self.cmssw][tryPredefinedFirst]
284  self.general["magneticField"] = self.dataset.magneticField()
285  self.general["defaultMagneticField"] = "MagneticField"
286  if self.general["magneticField"] == "unknown":
287  print "Could not get the magnetic field for this dataset."
288  print "Using the default: ", self.general["defaultMagneticField"]
289  self.general["magneticField"] = '.oO[defaultMagneticField]Oo.'
290 
291  if not self.jobmode.split( ',' )[0] == "crab":
292  try:
293  self.general["datasetDefinition"] = self.dataset.datasetSnippet(
294  jsonPath = self.general["JSON"],
295  firstRun = self.general["firstRun"],
296  lastRun = self.general["lastRun"],
297  begin = self.general["begin"],
298  end = self.general["end"],
299  parent = self.needParentFiles )
300  except AllInOneError as e:
301  msg = "In section [%s:%s]: "%(valType, self.name)
302  msg += str(e)
303  raise AllInOneError(msg)
304  else:
305  if self.dataset.predefined():
306  msg = ("For jobmode 'crab' you cannot use predefined datasets "
307  "(in your case: '%s')."%( self.dataset.name() ))
308  raise AllInOneError( msg )
309  try:
310  theUpdate = config.getResultingSection(valType+":"+self.name,
311  demandPars = ["parallelJobs"])
312  except AllInOneError as e:
313  msg = str(e)[:-1]+" when using 'jobmode: crab'."
314  raise AllInOneError(msg)
315  self.general.update(theUpdate)
316  if self.general["begin"] or self.general["end"]:
317  ( self.general["begin"],
318  self.general["end"],
319  self.general["firstRun"],
320  self.general["lastRun"] ) = self.dataset.convertTimeToRun(
321  firstRun = self.general["firstRun"],
322  lastRun = self.general["lastRun"],
323  begin = self.general["begin"],
324  end = self.general["end"],
325  shortTuple = False)
326  if self.general["begin"] == None:
327  self.general["begin"] = ""
328  if self.general["end"] == None:
329  self.general["end"] = ""
330  self.general["firstRun"] = str( self.general["firstRun"] )
331  self.general["lastRun"] = str( self.general["lastRun"] )
332  if ( not self.general["firstRun"] ) and \
333  ( self.general["end"] or self.general["lastRun"] ):
334  self.general["firstRun"] = str(
335  self.dataset.runList()[0]["run_number"])
336  if ( not self.general["lastRun"] ) and \
337  ( self.general["begin"] or self.general["firstRun"] ):
338  self.general["lastRun"] = str(
339  self.dataset.runList()[-1]["run_number"])
340  if self.general["firstRun"] and self.general["lastRun"]:
341  if int(self.general["firstRun"]) > int(self.general["lastRun"]):
342  msg = ( "The lower time/runrange limit ('begin'/'firstRun') "
343  "chosen is greater than the upper time/runrange limit "
344  "('end'/'lastRun').")
345  raise AllInOneError( msg )
346  self.general["runRange"] = (self.general["firstRun"]
347  + '-' + self.general["lastRun"])
348  try:
349  self.general["datasetDefinition"] = self.dataset.datasetSnippet(
350  jsonPath = self.general["JSON"],
351  firstRun = self.general["firstRun"],
352  lastRun = self.general["lastRun"],
353  begin = self.general["begin"],
354  end = self.general["end"],
355  crab = True )
356  except AllInOneError as e:
357  msg = "In section [%s:%s]: "%(valType, self.name)
358  msg += str( e )
359  raise AllInOneError( msg )

Member Function Documentation

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

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

393  def createCrabCfg(self, path, crabCfgBaseName):
394  """
395  Method which creates a `crab.cfg` for a validation on datasets.
396 
397  Arguments:
398  - `path`: Path at which the file will be stored.
399  - `crabCfgBaseName`: String which depends on the actual type of
400  validation calling this method.
401  """
402  crabCfgName = "crab.%s.%s.%s.cfg"%( crabCfgBaseName, self.name,
403  self.alignmentToValidate.name )
404  repMap = self.getRepMap()
405  repMap["script"] = "dummy_script.sh"
406  # repMap["crabOutputDir"] = os.path.basename( path )
407  repMap["crabWorkingDir"] = crabCfgName.split( '.cfg' )[0]
408  self.crabWorkingDir = repMap["crabWorkingDir"]
409  repMap["numberOfJobs"] = self.general["parallelJobs"]
410  repMap["cfgFile"] = self.configFiles[0]
411  repMap["queue"] = self.jobmode.split( ',' )[1].split( '-q' )[1]
412  if self.dataset.dataType() == "mc":
413  repMap["McOrData"] = "events = .oO[nEvents]Oo."
414  elif self.dataset.dataType() == "data":
415  repMap["McOrData"] = "lumis = -1"
416  if self.jobmode.split( ',' )[0] == "crab":
417  print ("For jobmode 'crab' the parameter 'maxevents' will be "
418  "ignored and all events will be processed.")
419  else:
420  raise AllInOneError("Unknown data type! Can't run in crab mode")
421  crabCfg = {crabCfgName: replaceByMap( configTemplates.crabCfgTemplate,
422  repMap ) }
423  return GenericValidation.createCrabCfg( self, crabCfg, path )
def replaceByMap
— Helpers —############################
double split
Definition: MVATrainer.cc:139
def genericValidation.GenericValidationData.createScript (   self,
  path,
  template = configTemplates.scriptTemplate,
  downloadFiles = [],
  repMap = None,
  repMaps = None 
)

Definition at line 378 of file genericValidation.py.

References helperFunctions.addIndex(), genericValidation.GenericValidation.configFiles, genericValidation.GenericValidation.getRepMap(), alignment.Alignment.getRepMap(), entry.name, geometrydata.GeometryData.name, genericValidation.GenericValidation.name, alignment.Alignment.name, TrackerSectorStruct.name, classes.MonitorData.name, MuonGeometrySanityCheckPoint.name, classes.OutputData.name, geometry.Structure.name, plotscripts.SawTeethFunction.name, genericValidation.GenericValidation.NJobs, trackSplittingValidation.TrackSplittingValidation.scriptBaseName, monteCarloValidation.MonteCarloValidation.scriptBaseName, primaryVertexValidation.PrimaryVertexValidation.scriptBaseName, zMuMuValidation.ZMuMuValidation.scriptBaseName, and offlineValidation.OfflineValidation.scriptBaseName.

379  def createScript(self, path, template = configTemplates.scriptTemplate, downloadFiles=[], repMap = None, repMaps = None):
380  scriptName = "%s.%s.%s.sh"%(self.scriptBaseName, self.name,
381  self.alignmentToValidate.name )
382  if repMap is None and repMaps is None:
383  repMap = self.getRepMap()
384  repMap["CommandLine"]=""
385  for cfg in self.configFiles:
386  repMap["CommandLine"]+= repMap["CommandLineTemplate"]%{"cfgFile":addIndex(cfg, self.NJobs, ".oO[nIndex]Oo."),
387  "postProcess":""
388  }
389  scripts = {scriptName: template}
390  return GenericValidation.createScript(self, scripts, path, downloadFiles = downloadFiles,
391  repMap = repMap, repMaps = repMaps)
def genericValidation.GenericValidationData.getRepMap (   self,
  alignment = None 
)

Definition at line 360 of file genericValidation.py.

References helperFunctions.addIndex(), entry.name, geometrydata.GeometryData.name, genericValidation.GenericValidation.name, alignment.Alignment.name, TrackerSectorStruct.name, classes.MonitorData.name, MuonGeometrySanityCheckPoint.name, classes.OutputData.name, geometry.Structure.name, plotscripts.SawTeethFunction.name, genericValidation.GenericValidation.NJobs, trackSplittingValidation.TrackSplittingValidation.outputBaseName, monteCarloValidation.MonteCarloValidation.outputBaseName, primaryVertexValidation.PrimaryVertexValidation.outputBaseName, zMuMuValidation.ZMuMuValidation.outputBaseName, offlineValidation.OfflineValidation.outputBaseName, helperFunctions.replaceByMap(), monteCarloValidation.MonteCarloValidation.resultBaseName, trackSplittingValidation.TrackSplittingValidation.resultBaseName, primaryVertexValidation.PrimaryVertexValidation.resultBaseName, zMuMuValidation.ZMuMuValidation.resultBaseName, and offlineValidation.OfflineValidation.resultBaseName.

Referenced by plottingOptions.PlottingOptionsTrackSplitting.validsubdets().

361  def getRepMap(self, alignment = None):
362  result = GenericValidation.getRepMap(self, alignment)
363  outputfile = os.path.expandvars(replaceByMap(
364  "%s_%s_.oO[name]Oo..root" % (self.outputBaseName, self.name)
365  , result))
366  resultfile = os.path.expandvars(replaceByMap(("/store/caf/user/$USER/.oO[eosdir]Oo./" +
367  "%s_%s_.oO[name]Oo..root" % (self.resultBaseName, self.name))
368  , result))
369  result.update({
370  "resultFile": ".oO[resultFiles[.oO[nIndex]Oo.]]Oo.",
371  "resultFiles": addIndex(resultfile, self.NJobs),
372  "finalResultFile": resultfile,
373  "outputFile": ".oO[outputFiles[.oO[nIndex]Oo.]]Oo.",
374  "outputFiles": addIndex(outputfile, self.NJobs),
375  "finalOutputFile": outputfile
376  })
377  return result
def replaceByMap
— Helpers —############################

Member Data Documentation

genericValidation.GenericValidationData.crabWorkingDir

Definition at line 407 of file genericValidation.py.

genericValidation.GenericValidationData.dataset

Definition at line 282 of file genericValidation.py.

Referenced by edmIntegrityCheck.IntegrityCheck.query(), production_tasks.BaseDataset.query(), production_tasks.CheckDatasetExists.run(), production_tasks.BaseDataset.run(), production_tasks.GenerateMask.run(), production_tasks.CreateJobDirectory.run(), production_tasks.SourceCFG.run(), production_tasks.FullCFG.run(), production_tasks.WriteToDatasets.run(), production_tasks.RunCMSBatch.run(), production_tasks.MonitorJobs.run(), production_tasks.CleanJobFiles.run(), and edmIntegrityCheck.IntegrityCheck.structured().