CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
python.Runs Class Reference

Public Member Functions

def __del__ (self)
 
def __init__ (self, inputFiles='', **kwargs)
 
def __iter__ (self)
 
def aux (self)
 
def getByLabel (self, *args)
 
def runAuxiliary (self)
 

Private Member Functions

def _createFWLiteRun (self)
 Private Member Functions ##. More...
 
def _next (self)
 

Private Attributes

 _currFilename
 
 _filenames
 
 _maxRuns
 Parse optional arguments ##. More...
 
 _run
 
 _runCounts
 
 _secondaryFilenames
 
 _tfile
 
 _veryFirstTime
 

Detailed Description

autotoc_md44

## Runs

autotoc_md46

Python interface to FWLite LuminosityBlock

Definition at line 299 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

def python.Runs.__init__ (   self,
  inputFiles = '',
**  kwargs 
)

Definition at line 301 of file __init__.py.

301  def __init__ (self, inputFiles = '', **kwargs):
302  self._run = None
303  self._runCounts = 0
304  self._tfile = None
305  self._maxRuns = 0
306  if isinstance (inputFiles, list):
307  # it's a list
308  self._filenames = inputFiles[:]
309  elif isinstance (inputFiles, VarParsing):
310  # it's a VarParsing object
311  options = inputFiles
312  self._maxRuns = options.maxEvents
313  self._filenames = options.inputFiles
314  else:
315  # it's probably a single string
316  self._filenames = [inputFiles]
317 
320  if 'maxEvents' in kwargs:
321  self._maxRuns = kwargs['maxEvents']
322  del kwargs['maxEvents']
323  if 'options' in kwargs:
324  options = kwargs ['options']
325  self._maxRuns = options.maxEvents
326  self._filenames = options.inputFiles
327  self._secondaryFilenames = options.secondaryInputFiles
328  del kwargs['options']
329  # Since we deleted the options as we used them, that means
330  # that kwargs should be empty. If it's not, that means that
331  # somebody passed in an argument that we're not using and we
332  # should complain.
333  if len (kwargs):
334  raise RuntimeError("Unknown arguments %s" % kwargs)
335  if not self._filenames:
336  raise RuntimeError("No input files given")
337  if not self._createFWLiteRun():
338  # this shouldn't happen as you are getting nothing the
339  # very first time out, but let's at least check to
340  # avoid problems.
341  raise RuntimeError("Never and information about Run")
342 
343 

◆ __del__()

def python.Runs.__del__ (   self)
(Internal) Destructor

Definition at line 344 of file __init__.py.

344  def __del__ (self):
345  """(Internal) Destructor"""
346  # print "Goodbye cruel world, I'm leaving you today."
347  del self._run
348  # print "Goodbye, goodbye, goodbye."
349 
350 

References MELaserPrim._run, and python.Runs._run.

Member Function Documentation

◆ __iter__()

def python.Runs.__iter__ (   self)

Definition at line 351 of file __init__.py.

351  def __iter__ (self):
352  return self._next()
353 
354 

References python.Lumis._next(), and python.Runs._next().

◆ _createFWLiteRun()

def python.Runs._createFWLiteRun (   self)
private

Private Member Functions ##.

(Internal) Creates an FWLite Run

Definition at line 417 of file __init__.py.

417  def _createFWLiteRun (self):
418  """(Internal) Creates an FWLite Run"""
419  # are there any files left?
420  if not self._filenames:
421  return False
422  if self._run:
423  del self._run
424  self._run = None
425  self._veryFirstTime = False
426  self._currFilename = self._filenames.pop(0)
427  #print "Opening file", self._currFilename
428  if self._tfile:
429  del self._tfile
430  self._tfile = ROOT.TFile.Open (self._currFilename)
431  self._run = ROOT.fwlite.Run (self._tfile);
432  self._run.toBegin()
433  return True
434 
435 

References python.Lumis._filenames, python.Runs._filenames, MELaserPrim._run, and python.Runs._run.

Referenced by python.Runs._next().

◆ _next()

def python.Runs._next (   self)
private
(Internal) Iterator internals

Definition at line 436 of file __init__.py.

436  def _next (self):
437  """(Internal) Iterator internals"""
438  while True:
439  if self._run.atEnd():
440  if not self._createFWLiteRun():
441  # there are no more files here, so we are done
442  break
443  yield self
444  self._runCounts += 1
445  if self._maxRuns > 0 and self._runCounts >= self._maxRuns:
446  break
447  self._run.__preinc__()
448 
449 

References python.Runs._createFWLiteRun(), python.Runs._maxRuns, MELaserPrim._run, python.Runs._run, and python.Runs._runCounts.

Referenced by python.Runs.__iter__(), and python.Events.__iter__().

◆ aux()

def python.Runs.aux (   self)

Definition at line 355 of file __init__.py.

355  def aux (self):
356  try:
357  return self._run.runAuxiliary()
358  except:
359  raise RuntimeError("Runs.aux() called on object in invalid state")
360 
361 

References MELaserPrim._run, python.Runs._run, and python.Runs.runAuxiliary().

◆ getByLabel()

def python.Runs.getByLabel (   self,
args 
)
Calls FWLite's getByLabel.  Called:
getByLabel (moduleLabel, handle)
getByLabel (moduleLabel, productInstanceLabel, handle),
getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
or
getByLabel ( (mL, pIL,pL), handle)

Definition at line 369 of file __init__.py.

369  def getByLabel (self, *args):
370  """Calls FWLite's getByLabel. Called:
371  getByLabel (moduleLabel, handle)
372  getByLabel (moduleLabel, productInstanceLabel, handle),
373  getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
374  or
375  getByLabel ( (mL, pIL,pL), handle)
376  """
377  length = len (args)
378  if length < 2 or length > 4:
379  # not called correctly
380  raise RuntimeError("Incorrect number of arguments")
381  # handle is always the last argument
382  argsList = list (args)
383  handle = argsList.pop()
384  if len(argsList)==1 :
385  if( isinstance (argsList[0], tuple) or
386  isinstance (argsList[0], list) ) :
387  if len (argsList[0]) > 3:
388  raise RuntimeError("getByLabel Error: label tuple has too " \
389  "many arguments '%s'" % argsList[0])
390  argsList = list(argsList[0])
391  if( isinstance(argsList[0], str) and ":" in argsList[0] ):
392  if argsList[0].count(":") > 3:
393  raise RuntimeError("getByLabel Error: label tuple has too " \
394  "many arguments '%s'" % argsList[0].split(":"))
395  argsList = argsList[0].split(":")
396  while len(argsList) < 3:
397  argsList.append ('')
398  (moduleLabel, productInstanceLabel, processLabel) = argsList
399  labelString = "'" + "', '".join(argsList) + "'"
400  if not handle._wrapper :
401  handle._resetWrapper()
402  handle._setStatus ( self._run.getByLabel( handle._typeInfoGetter(),
403  moduleLabel,
404  productInstanceLabel,
405  processLabel,
406  handle._addressOf() ),
407  labelString )
408  return handle.isValid()
409 
410 
411 
412 

References MELaserPrim._run, python.Runs._run, submitPVResolutionJobs.count, if(), join(), and submitPVValidationJobs.split().

◆ runAuxiliary()

def python.Runs.runAuxiliary (   self)

Definition at line 362 of file __init__.py.

362  def runAuxiliary (self):
363  try:
364  return self._run.runAuxiliary()
365  except:
366  raise RuntimeError("Runs.runAuxiliary() called on object in invalid state")
367 
368 

References MELaserPrim._run, and python.Runs._run.

Referenced by python.Runs.aux().

Member Data Documentation

◆ _currFilename

python.Runs._currFilename
private

Definition at line 426 of file __init__.py.

◆ _filenames

python.Runs._filenames
private

Definition at line 308 of file __init__.py.

Referenced by python.Events._createFWLiteEvent(), and python.Runs._createFWLiteRun().

◆ _maxRuns

python.Runs._maxRuns
private

Parse optional arguments ##.

Definition at line 305 of file __init__.py.

Referenced by python.Runs._next().

◆ _run

python.Runs._run
private

◆ _runCounts

python.Runs._runCounts
private

Definition at line 303 of file __init__.py.

Referenced by python.Runs._next().

◆ _secondaryFilenames

python.Runs._secondaryFilenames
private

Definition at line 327 of file __init__.py.

◆ _tfile

python.Runs._tfile
private

Definition at line 304 of file __init__.py.

◆ _veryFirstTime

python.Runs._veryFirstTime
private
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
if
if(0==first)
Definition: CAHitNtupletGeneratorKernelsImpl.h:48
submitPVValidationJobs.split
def split(sequence, size)
Definition: submitPVValidationJobs.py:352
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
printConversionInfo.aux
aux
Definition: printConversionInfo.py:19