CMS 3D CMS Logo

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

## Events

More...

Public Member Functions

def __del__
 
def __init__
 
def __iter__
 
def eventAuxiliary
 
def fileIndex
 
def fileIndicies
 
def getByLabel
 
def object
 
def secondaryFileIndex
 
def size
 
def to
 
def toBegin
 

Private Member Functions

def _createFWLiteEvent
 
def _next
 
def _parseOptions
 Private Member Functions ##. More...
 
def _toBeginCode
 

Private Attributes

 _event
 
 _eventCounts
 
 _filenames
 
 _forceEvent
 
 _maxEvents
 Parse optional arguments ##. More...
 
 _mode
 
 _secondaryFilenames
 
 _tfile
 
 _toBegin
 
 _veryFirstTime
 

Detailed Description

## Events

Python interface to FWLite ChainEvent class

Definition at line 437 of file __init__.py.

Constructor & Destructor Documentation

def python.Events.__init__ (   self,
  inputFiles = '',
  kwargs 
)
inputFiles    => Either a single filename or a list of filenames
Optional arguments:
forceEvent  => Use fwlite::Event IF there is only one file
maxEvents   => Maximum number of events to process

Definition at line 440 of file __init__.py.

441  def __init__(self, inputFiles = '', **kwargs):
442  """inputFiles => Either a single filename or a list of filenames
443  Optional arguments:
444  forceEvent => Use fwlite::Event IF there is only one file
445  maxEvents => Maximum number of events to process
446  """
447  self._veryFirstTime = True
448  self._event = 0
449  self._eventCounts = 0
450  self._maxEvents = 0
451  self._forceEvent = False
452  self._mode = None
453  self._secondaryFilenames = None
454  if isinstance (inputFiles, list):
455  # it's a list
456  self._filenames = inputFiles[:]
457  elif isinstance (inputFiles, VarParsing):
458  # it's a VarParsing object
459  options = inputFiles
460  self._maxEvents = options.maxEvents
461  self._filenames = options.inputFiles
462  self._secondaryFilenames = options.secondaryInputFiles
463  else:
464  # it's probably a single string
465  self._filenames = [inputFiles]
466  ##############################
467  ## Parse optional arguments ##
468  ##############################
469  if kwargs.has_key ('maxEvents'):
470  self._maxEvents = kwargs['maxEvents']
471  del kwargs['maxEvents']
472  if kwargs.has_key ('forceEvent'):
473  self._forceEvent = kwargs['forceEvent']
474  del kwargs['forceEvent']
475  if kwargs.has_key ('options'):
476  options = kwargs ['options']
477  self._maxEvents = options.maxEvents
478  self._filenames = options.inputFiles
479  self._secondaryFilenames = options.secondaryInputFiles
480  del kwargs['options']
481  # Since we deleted the options as we used them, that means
482  # that kwargs should be empty. If it's not, that means that
483  # somebody passed in an argument that we're not using and we
484  # should complain.
485  if len (kwargs):
486  raise RuntimeError, "Unknown arguments %s" % kwargs
487  if not self._filenames:
488  raise RuntimeError, "No input files given"
489 
_maxEvents
Parse optional arguments ##.
Definition: __init__.py:449
def python.Events.__del__ (   self)
(Internal) Destructor

Definition at line 597 of file __init__.py.

References python.Events._event.

598  def __del__ (self):
599  """(Internal) Destructor"""
600  # print "Goodbye cruel world, I'm leaving you today."
601  del self._event
602  # print "Goodbye, goodbye, goodbye."
603 

Member Function Documentation

def python.Events.__iter__ (   self)

Definition at line 559 of file __init__.py.

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

560  def __iter__ (self):
561  return self._next()
562 
def python.Events._createFWLiteEvent (   self)
private
(Internal) Creates an FWLite Event

Definition at line 604 of file __init__.py.

References python.Events._event, python.Lumis._filenames, python.Runs._filenames, python.Events._filenames, python.Events._forceEvent, python.Events._mode, python.Events._toBegin, python.Lumis._veryFirstTime, python.Runs._veryFirstTime, and python.Events._veryFirstTime.

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

605  def _createFWLiteEvent (self):
606  """(Internal) Creates an FWLite Event"""
607  self._veryFirstTime = False
608  self._toBegin = True
609  if isinstance (self._filenames[0], ROOT.TFile):
610  self._event = ROOT.fwlite.Event (self._filenames[0])
611  self._mode = 'single'
612  return self._mode
613  if len (self._filenames) == 1 and self._forceEvent:
614  self._tfile = ROOT.TFile.Open (self._filenames[0])
615  self._event = ROOT.fwlite.Event (self._tfile)
616  self._mode = 'single'
617  return self._mode
618  filenamesSVec = ROOT.vector("string") ()
619  for name in self._filenames:
620  filenamesSVec.push_back (name)
621  if self._secondaryFilenames:
622  secondarySVec = ROOT.vector("string") ()
623  for name in self._secondaryFilenames:
624  secondarySVec.push_back (name)
625  self._event = ROOT.fwlite.MultiChainEvent (filenamesSVec,
626  secondarySVec)
627  self._mode = 'multi'
628  else:
629  self._event = ROOT.fwlite.ChainEvent (filenamesSVec)
630  self._mode = 'chain'
631  return self._mode
632 
def _createFWLiteEvent
Definition: __init__.py:604
def python.Events._next (   self)
private
(Internal) Iterator internals

Definition at line 633 of file __init__.py.

References python.Events._createFWLiteEvent(), python.Events._eventCounts, python.Events._maxEvents, python.Events._toBegin, python.Events._toBeginCode(), python.Lumis._veryFirstTime, python.Runs._veryFirstTime, and python.Events._veryFirstTime.

Referenced by python.Events.__iter__().

634  def _next (self):
635  """(Internal) Iterator internals"""
636  if self._veryFirstTime:
637  self._createFWLiteEvent()
638  if self._toBegin:
639  self._toBeginCode()
640  while not self._event.atEnd() :
641  yield self
642  self._eventCounts += 1
643  if self._maxEvents > 0 and self._eventCounts >= self._maxEvents:
644  break
645  # Have we been asked to go to the first event?
646  if self._toBegin:
647  self._toBeginCode()
648  else:
649  # if not, lets go to the next event
650  self._event.__preinc__()
651 
652 
def _createFWLiteEvent
Definition: __init__.py:604
def _toBeginCode
Definition: __init__.py:590
_maxEvents
Parse optional arguments ##.
Definition: __init__.py:449
def python.Events._parseOptions (   self,
  options 
)
private

Private Member Functions ##.

(Internal) Parse options

Definition at line 586 of file __init__.py.

587  def _parseOptions (self, options):
588  """(Internal) Parse options"""
589 
def _parseOptions
Private Member Functions ##.
Definition: __init__.py:586
def python.Events._toBeginCode (   self)
private
(Internal) Does actual work of toBegin() call

Definition at line 590 of file __init__.py.

Referenced by python.Events._next().

591  def _toBeginCode (self):
592  """(Internal) Does actual work of toBegin() call"""
593  self._toBegin = False
594  self._event.toBegin()
595  self._eventCounts = 0
596 
def _toBeginCode
Definition: __init__.py:590
def python.Events.eventAuxiliary (   self)
Returns eventAuxiliary object

Definition at line 509 of file __init__.py.

References python.Lumis._veryFirstTime, python.Runs._veryFirstTime, and python.Events._veryFirstTime.

510  def eventAuxiliary (self):
511  """Returns eventAuxiliary object"""
512  if self._veryFirstTime:
513  raise RuntimeError, "eventAuxiliary() called before "\
514  "toBegin() or to()"
515  return self._event.eventAuxiliary()
516 
def eventAuxiliary
Definition: __init__.py:509
def python.Events.fileIndex (   self)

Definition at line 563 of file __init__.py.

References python.Events._event.

Referenced by python.Events.fileIndicies().

564  def fileIndex (self):
565  if self._event:
566  return self._event.fileIndex()
567  else:
568  # default non-existant value is -1. Return something else
569  return -2
570 
def python.Events.fileIndicies (   self)

Definition at line 579 of file __init__.py.

References fwlite::LuminosityBlockBase.fileIndex(), fwlite::RunBase.fileIndex(), fwlite::EventBase.fileIndex(), fwlite::ChainEvent.fileIndex(), fwlite::MultiChainEvent.fileIndex(), python.Events.fileIndex(), fwlite::LuminosityBlockBase.secondaryFileIndex(), fwlite::RunBase.secondaryFileIndex(), fwlite::EventBase.secondaryFileIndex(), fwlite::MultiChainEvent.secondaryFileIndex(), and python.Events.secondaryFileIndex().

580  def fileIndicies (self):
581  return (self.fileIndex(), self.secondaryFileIndex())
582 
def fileIndicies
Definition: __init__.py:579
def secondaryFileIndex
Definition: __init__.py:571
def python.Events.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 522 of file __init__.py.

References python.Events._createFWLiteEvent(), python.Lumis._veryFirstTime, python.Runs._veryFirstTime, python.Events._veryFirstTime, join(), and list().

523  def getByLabel (self, *args):
524  """Calls FWLite's getByLabel. Called:
525  getByLabel (moduleLabel, handle)
526  getByLabel (moduleLabel, productInstanceLabel, handle),
527  getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
528  or
529  getByLabel ( (mL, pIL,pL), handle)
530  """
531  if self._veryFirstTime:
532  self._createFWLiteEvent()
533  length = len (args)
534  if length < 2 or length > 4:
535  # not called correctly
536  raise RuntimeError, "Incorrect number of arguments"
537  # handle is always the last argument
538  argsList = list (args)
539  handle = argsList.pop()
540  if len(argsList)==1 and \
541  ( isinstance (argsList[0], tuple) or
542  isinstance (argsList[0], list) ) :
543  if len (argsList) > 3:
544  raise RuntimeError, "getByLabel Error: label tuple has too " \
545  "many arguments '%s'" % argsList[0]
546  argsList = list(argsList[0])
547  while len(argsList) < 3:
548  argsList.append ('')
549  (moduleLabel, productInstanceLabel, processLabel) = argsList
550  labelString = "'" + "', '".join(argsList) + "'"
551  handle._setStatus ( self._event.getByLabel( handle._typeInfoGetter(),
552  moduleLabel,
553  productInstanceLabel,
554  processLabel,
555  handle._addressOf() ),
556  labelString )
557  return handle.isValid()
558 
def _createFWLiteEvent
Definition: __init__.py:604
def getByLabel
Definition: __init__.py:522
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def python.Events.object (   self)
Returns event object

Definition at line 517 of file __init__.py.

References python.Events._event.

Referenced by Vispa.Views.LineDecayView.LineDecayContainer.createObject(), Vispa.Views.LineDecayView.LineDecayContainer.delete(), Vispa.Views.LineDecayView.DecayLine.delete(), Vispa.Views.LineDecayView.LineDecayContainer.mouseReleaseEvent(), and Vispa.Views.BoxDecayView.BoxDecayContainer.toggleCollapse().

518  def object (self):
519  """Returns event object"""
520  return self._event
521 
def python.Events.secondaryFileIndex (   self)

Definition at line 571 of file __init__.py.

References python.Events._event.

Referenced by python.Events.fileIndicies().

572  def secondaryFileIndex (self):
573  if self._event:
574  return self._event.secondaryFileIndex()
575  else:
576  # default non-existant value is -1. Return something else
577  return -2
578 
def secondaryFileIndex
Definition: __init__.py:571
def python.Events.size (   self)
Returns number of events

Definition at line 502 of file __init__.py.

References python.Events._createFWLiteEvent(), python.Lumis._veryFirstTime, python.Runs._veryFirstTime, and python.Events._veryFirstTime.

503  def size (self):
504  """Returns number of events"""
505  if self._veryFirstTime:
506  self._createFWLiteEvent()
507  return self._event.size()
508 
def _createFWLiteEvent
Definition: __init__.py:604
def python.Events.to (   self,
  entryIndex 
)
Jumps to event entryIndex

Definition at line 490 of file __init__.py.

References python.Events._createFWLiteEvent(), python.Lumis._veryFirstTime, python.Runs._veryFirstTime, and python.Events._veryFirstTime.

491  def to (self, entryIndex):
492  """Jumps to event entryIndex"""
493  if self._veryFirstTime:
494  self._createFWLiteEvent()
495  return self._event.to ( long(entryIndex) )
496 
def _createFWLiteEvent
Definition: __init__.py:604
def python.Events.toBegin (   self)
Called to reset event loop to first event.

Definition at line 497 of file __init__.py.

498  def toBegin (self):
499  """Called to reset event loop to first event."""
500  self._toBegin = True
501 

Member Data Documentation

python.Events._event
private

Definition at line 447 of file __init__.py.

Referenced by python.Events.__del__(), python.Events._createFWLiteEvent(), python.Events.fileIndex(), python.Events.object(), and python.Events.secondaryFileIndex().

python.Events._eventCounts
private

Definition at line 448 of file __init__.py.

Referenced by python.Events._next(), and python.Events._toBeginCode().

python.Events._filenames
private

Definition at line 455 of file __init__.py.

Referenced by cfg-viewer.unscheduled._calcFilenames(), and python.Events._createFWLiteEvent().

python.Events._forceEvent
private

Definition at line 450 of file __init__.py.

Referenced by python.Events._createFWLiteEvent().

python.Events._maxEvents
private

Parse optional arguments ##.

Definition at line 449 of file __init__.py.

Referenced by python.Events._next().

python.Events._mode
private

Definition at line 451 of file __init__.py.

Referenced by argparse.FileType.__call__(), python.rootplot.argparse.FileType.__call__(), argparse.FileType.__repr__(), python.rootplot.argparse.FileType.__repr__(), and python.Events._createFWLiteEvent().

python.Events._secondaryFilenames
private

Definition at line 452 of file __init__.py.

python.Events._tfile
private

Definition at line 613 of file __init__.py.

python.Events._toBegin
private

Definition at line 499 of file __init__.py.

Referenced by python.Events._createFWLiteEvent(), python.Events._next(), and python.Events._toBeginCode().

python.Events._veryFirstTime
private

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