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

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

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

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

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

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

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

Definition at line 329 of file genericValidation.py.

References helperFunctions.addIndex(), entry.name, genericValidation.GenericValidation.name, alignment.Alignment.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.

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

Member Data Documentation

genericValidation.GenericValidationData.crabWorkingDir

Definition at line 376 of file genericValidation.py.

genericValidation.GenericValidationData.dataset

Definition at line 251 of file genericValidation.py.