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
 
 randomWorkdirPart
 
 scramarch
 
 scriptFiles
 

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

Constructor & Destructor Documentation

def genericValidation.GenericValidationData.__init__ (   self,
  valName,
  alignment,
  config,
  valType,
  addDefaults = {},
  addMandatories = [] 
)
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 194 of file genericValidation.py.

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

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

References genericValidation.GenericValidation.getRepMap(), alignment.Alignment.getRepMap(), entry.name, genericValidation.GenericValidation.name, alignment.Alignment.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, and plotscripts.SawTeethFunction.name.

363  def createCrabCfg(self, path, crabCfgBaseName):
364  """
365  Method which creates a `crab.cfg` for a validation on datasets.
366 
367  Arguments:
368  - `path`: Path at which the file will be stored.
369  - `crabCfgBaseName`: String which depends on the actual type of
370  validation calling this method.
371  """
372  crabCfgName = "crab.%s.%s.%s.cfg"%( crabCfgBaseName, self.name,
373  self.alignmentToValidate.name )
374  repMap = self.getRepMap()
375  repMap["script"] = "dummy_script.sh"
376  # repMap["crabOutputDir"] = os.path.basename( path )
377  repMap["crabWorkingDir"] = crabCfgName.split( '.cfg' )[0]
378  self.crabWorkingDir = repMap["crabWorkingDir"]
379  repMap["numberOfJobs"] = self.general["parallelJobs"]
380  repMap["cfgFile"] = self.configFiles[0]
381  repMap["queue"] = self.jobmode.split( ',' )[1].split( '-q' )[1]
382  if self.dataset.dataType() == "mc":
383  repMap["McOrData"] = "events = .oO[nEvents]Oo."
384  elif self.dataset.dataType() == "data":
385  repMap["McOrData"] = "lumis = -1"
386  if self.jobmode.split( ',' )[0] == "crab":
387  print ("For jobmode 'crab' the parameter 'maxevents' will be "
388  "ignored and all events will be processed.")
389  else:
390  raise AllInOneError("Unknown data type! Can't run in crab mode")
391  crabCfg = {crabCfgName: replaceByMap( configTemplates.crabCfgTemplate,
392  repMap ) }
393  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 348 of file genericValidation.py.

References helperFunctions.addIndex(), genericValidation.GenericValidation.configFiles, genericValidation.GenericValidation.getRepMap(), alignment.Alignment.getRepMap(), entry.name, genericValidation.GenericValidation.name, alignment.Alignment.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, plotscripts.SawTeethFunction.name, genericValidation.GenericValidation.NJobs, trackSplittingValidation.TrackSplittingValidation.scriptBaseName, monteCarloValidation.MonteCarloValidation.scriptBaseName, zMuMuValidation.ZMuMuValidation.scriptBaseName, and offlineValidation.OfflineValidation.scriptBaseName.

349  def createScript(self, path, template = configTemplates.scriptTemplate, downloadFiles=[], repMap = None, repMaps = None):
350  scriptName = "%s.%s.%s.sh"%(self.scriptBaseName, self.name,
351  self.alignmentToValidate.name )
352  if repMap is None and repMaps is None:
353  repMap = self.getRepMap()
354  repMap["CommandLine"]=""
355  for cfg in self.configFiles:
356  repMap["CommandLine"]+= repMap["CommandLineTemplate"]%{"cfgFile":addIndex(cfg, self.NJobs, ".oO[nIndex]Oo."),
357  "postProcess":""
358  }
359  scripts = {scriptName: template}
360  return GenericValidation.createScript(self, scripts, path, downloadFiles = downloadFiles,
361  repMap = repMap, repMaps = repMaps)
def genericValidation.GenericValidationData.getRepMap (   self,
  alignment = None 
)

Definition at line 330 of file genericValidation.py.

References helperFunctions.addIndex(), entry.name, genericValidation.GenericValidation.name, alignment.Alignment.name, TrackerSectorStruct.name, MuonGeometrySanityCheckPoint.name, plotscripts.SawTeethFunction.name, genericValidation.GenericValidation.NJobs, trackSplittingValidation.TrackSplittingValidation.outputBaseName, monteCarloValidation.MonteCarloValidation.outputBaseName, zMuMuValidation.ZMuMuValidation.outputBaseName, offlineValidation.OfflineValidation.outputBaseName, helperFunctions.replaceByMap(), monteCarloValidation.MonteCarloValidation.resultBaseName, trackSplittingValidation.TrackSplittingValidation.resultBaseName, zMuMuValidation.ZMuMuValidation.resultBaseName, and offlineValidation.OfflineValidation.resultBaseName.

331  def getRepMap(self, alignment = None):
332  result = GenericValidation.getRepMap(self, alignment)
333  outputfile = os.path.expandvars(replaceByMap(
334  "%s_%s_.oO[name]Oo..root" % (self.outputBaseName, self.name)
335  , result))
336  resultfile = os.path.expandvars(replaceByMap(("/store/caf/user/$USER/.oO[eosdir]Oo./" +
337  "%s_%s_.oO[name]Oo..root" % (self.resultBaseName, self.name))
338  , result))
339  result.update({
340  "resultFile": ".oO[resultFiles[.oO[nIndex]Oo.]]Oo.",
341  "resultFiles": addIndex(resultfile, self.NJobs),
342  "finalResultFile": resultfile,
343  "outputFile": ".oO[outputFiles[.oO[nIndex]Oo.]]Oo.",
344  "outputFiles": addIndex(outputfile, self.NJobs),
345  "finalOutputFile": outputfile
346  })
347  return result
def replaceByMap
— Helpers —############################

Member Data Documentation

genericValidation.GenericValidationData.crabWorkingDir

Definition at line 377 of file genericValidation.py.

genericValidation.GenericValidationData.dataset

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