test
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 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
 
 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 206 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 213 of file genericValidation.py.

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

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

383  def createCrabCfg(self, path, crabCfgBaseName):
384  """
385  Method which creates a `crab.cfg` for a validation on datasets.
386 
387  Arguments:
388  - `path`: Path at which the file will be stored.
389  - `crabCfgBaseName`: String which depends on the actual type of
390  validation calling this method.
391  """
392  crabCfgName = "crab.%s.%s.%s.cfg"%( crabCfgBaseName, self.name,
393  self.alignmentToValidate.name )
394  repMap = self.getRepMap()
395  repMap["script"] = "dummy_script.sh"
396  # repMap["crabOutputDir"] = os.path.basename( path )
397  repMap["crabWorkingDir"] = crabCfgName.split( '.cfg' )[0]
398  self.crabWorkingDir = repMap["crabWorkingDir"]
399  repMap["numberOfJobs"] = self.general["parallelJobs"]
400  repMap["cfgFile"] = self.configFiles[0]
401  repMap["queue"] = self.jobmode.split( ',' )[1].split( '-q' )[1]
402  if self.dataset.dataType() == "mc":
403  repMap["McOrData"] = "events = .oO[nEvents]Oo."
404  elif self.dataset.dataType() == "data":
405  repMap["McOrData"] = "lumis = -1"
406  if self.jobmode.split( ',' )[0] == "crab":
407  print ("For jobmode 'crab' the parameter 'maxevents' will be "
408  "ignored and all events will be processed.")
409  else:
410  raise AllInOneError("Unknown data type! Can't run in crab mode")
411  crabCfg = {crabCfgName: replaceByMap( configTemplates.crabCfgTemplate,
412  repMap ) }
413  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 368 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, monteCarloValidation.MonteCarloValidation.scriptBaseName, trackSplittingValidation.TrackSplittingValidation.scriptBaseName, zMuMuValidation.ZMuMuValidation.scriptBaseName, and offlineValidation.OfflineValidation.scriptBaseName.

369  def createScript(self, path, template = configTemplates.scriptTemplate, downloadFiles=[], repMap = None, repMaps = None):
370  scriptName = "%s.%s.%s.sh"%(self.scriptBaseName, self.name,
371  self.alignmentToValidate.name )
372  if repMap is None and repMaps is None:
373  repMap = self.getRepMap()
374  repMap["CommandLine"]=""
375  for cfg in self.configFiles:
376  repMap["CommandLine"]+= repMap["CommandLineTemplate"]%{"cfgFile":addIndex(cfg, self.NJobs, ".oO[nIndex]Oo."),
377  "postProcess":""
378  }
379  scripts = {scriptName: template}
380  return GenericValidation.createScript(self, scripts, path, downloadFiles = downloadFiles,
381  repMap = repMap, repMaps = repMaps)
def genericValidation.GenericValidationData.getRepMap (   self,
  alignment = None 
)

Definition at line 350 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, zMuMuValidation.ZMuMuValidation.outputBaseName, offlineValidation.OfflineValidation.outputBaseName, helperFunctions.replaceByMap(), trackSplittingValidation.TrackSplittingValidation.resultBaseName, monteCarloValidation.MonteCarloValidation.resultBaseName, zMuMuValidation.ZMuMuValidation.resultBaseName, and offlineValidation.OfflineValidation.resultBaseName.

Referenced by plottingOptions.PlottingOptionsTrackSplitting.validsubdets().

351  def getRepMap(self, alignment = None):
352  result = GenericValidation.getRepMap(self, alignment)
353  outputfile = os.path.expandvars(replaceByMap(
354  "%s_%s_.oO[name]Oo..root" % (self.outputBaseName, self.name)
355  , result))
356  resultfile = os.path.expandvars(replaceByMap(("/store/caf/user/$USER/.oO[eosdir]Oo./" +
357  "%s_%s_.oO[name]Oo..root" % (self.resultBaseName, self.name))
358  , result))
359  result.update({
360  "resultFile": ".oO[resultFiles[.oO[nIndex]Oo.]]Oo.",
361  "resultFiles": addIndex(resultfile, self.NJobs),
362  "finalResultFile": resultfile,
363  "outputFile": ".oO[outputFiles[.oO[nIndex]Oo.]]Oo.",
364  "outputFiles": addIndex(outputfile, self.NJobs),
365  "finalOutputFile": outputfile
366  })
367  return result
def replaceByMap
— Helpers —############################

Member Data Documentation

genericValidation.GenericValidationData.crabWorkingDir

Definition at line 397 of file genericValidation.py.

genericValidation.GenericValidationData.dataset

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