CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
python.Runs Class Reference

## Runs

More...

Public Member Functions

def __del__
 
def __init__
 
def __iter__
 
def aux
 
def getByLabel
 
def runAuxiliary
 

Private Member Functions

def _createFWLiteRun
 Private Member Functions ##. More...
 
def _next
 

Private Attributes

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

Detailed Description

## Runs

Python interface to FWLite LuminosityBlock

Definition at line 299 of file __init__.py.

Constructor & Destructor Documentation

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

Definition at line 301 of file __init__.py.

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

Definition at line 344 of file __init__.py.

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

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

Member Function Documentation

def python.Runs.__iter__ (   self)

Definition at line 351 of file __init__.py.

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

352  def __iter__ (self):
353  return self._next()
354 
def __iter__
Definition: __init__.py:351
def python.Runs._createFWLiteRun (   self)
private

Private Member Functions ##.

(Internal) Creates an FWLite Run

Definition at line 417 of file __init__.py.

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

Referenced by python.Runs._next().

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

Definition at line 436 of file __init__.py.

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

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

437  def _next (self):
438  """(Internal) Iterator internals"""
439  while True:
440  if self._run.atEnd():
441  if not self._createFWLiteRun():
442  # there are no more files here, so we are done
443  break
444  yield self
445  self._runCounts += 1
446  if self._maxRuns > 0 and self._runCounts >= self._maxRuns:
447  break
448  self._run.__preinc__()
449 
_maxRuns
Parse optional arguments ##.
Definition: __init__.py:305
def _createFWLiteRun
Private Member Functions ##.
Definition: __init__.py:417
def python.Runs.aux (   self)

Definition at line 355 of file __init__.py.

356  def aux (self):
357  try:
358  return self._run.runAuxiliary()
359  except:
360  raise RuntimeError("Runs.aux() called on object in invalid state")
361 
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.

References submitPVResolutionJobs.count, if(), join(), and submitPVValidationJobs.split().

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

Definition at line 362 of file __init__.py.

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

Member Data Documentation

python.Runs._currFilename
private

Definition at line 426 of file __init__.py.

python.Runs._filenames
private

Definition at line 308 of file __init__.py.

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

python.Runs._maxRuns
private

Parse optional arguments ##.

Definition at line 305 of file __init__.py.

Referenced by python.Runs._next().

python.Runs._run
private

Definition at line 302 of file __init__.py.

Referenced by python.Runs.__del__(), and python.Runs._createFWLiteRun().

python.Runs._runCounts
private

Definition at line 303 of file __init__.py.

Referenced by python.Runs._next().

python.Runs._secondaryFilenames
private

Definition at line 327 of file __init__.py.

python.Runs._tfile
private

Definition at line 304 of file __init__.py.

python.Runs._veryFirstTime
private

Definition at line 425 of file __init__.py.

Referenced by python.Events._createFWLiteEvent(), python.Events._next(), python.Events.eventAuxiliary(), python.Events.getByLabel(), python.Events.size(), and python.Events.to().