CMS 3D CMS Logo

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

## Events

More...

Public Member Functions

def __del__ (self)
 
def __init__ (self, inputFiles='', kwargs)
 
def __iter__ (self)
 
def eventAuxiliary (self)
 
def fileIndex (self)
 
def fileIndicies (self)
 
def getByLabel (self, args)
 
def object (self)
 
def secondaryFileIndex (self)
 
def size (self)
 
def to (self, entryIndex)
 
def toBegin (self)
 

Private Member Functions

def _createFWLiteEvent (self)
 
def _next (self)
 
def _parseOptions (self, options)
 Private Member Functions ##. More...
 
def _toBeginCode (self)
 

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 457 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 460 of file __init__.py.

460  def __init__(self, inputFiles = '', **kwargs):
461  """inputFiles => Either a single filename or a list of filenames
462  Optional arguments:
463  forceEvent => Use fwlite::Event IF there is only one file
464  maxEvents => Maximum number of events to process
465  """
466  self._veryFirstTime = True
467  self._event = 0
468  self._eventCounts = 0
469  self._maxEvents = 0
470  self._forceEvent = False
471  self._mode = None
473  if isinstance (inputFiles, list):
474  # it's a list
475  self._filenames = inputFiles[:]
476  elif isinstance (inputFiles, VarParsing):
477  # it's a VarParsing object
478  options = inputFiles
479  self._maxEvents = options.maxEvents
480  self._filenames = options.inputFiles
481  self._secondaryFilenames = options.secondaryInputFiles
482  else:
483  # it's probably a single string
484  self._filenames = [inputFiles]
485  ##############################
486  ## Parse optional arguments ##
487  ##############################
488  if 'maxEvents' in kwargs:
489  self._maxEvents = kwargs['maxEvents']
490  del kwargs['maxEvents']
491  if 'forceEvent' in kwargs:
492  self._forceEvent = kwargs['forceEvent']
493  del kwargs['forceEvent']
494  if 'options' in kwargs:
495  options = kwargs ['options']
496  self._maxEvents = options.maxEvents
497  self._filenames = options.inputFiles
498  self._secondaryFilenames = options.secondaryInputFiles
499  del kwargs['options']
500  # Since we deleted the options as we used them, that means
501  # that kwargs should be empty. If it's not, that means that
502  # somebody passed in an argument that we're not using and we
503  # should complain.
504  if len (kwargs):
505  raise RuntimeError("Unknown arguments %s" % kwargs)
506  if not self._filenames:
507  raise RuntimeError("No input files given")
508 
509 
def __init__(self, inputFiles='', kwargs)
Definition: __init__.py:460
_maxEvents
Parse optional arguments ##.
Definition: __init__.py:469
def python.Events.__del__ (   self)
(Internal) Destructor

Definition at line 624 of file __init__.py.

References python.Events._event.

624  def __del__ (self):
625  """(Internal) Destructor"""
626  # print "Goodbye cruel world, I'm leaving you today."
627  del self._event
628  # print "Goodbye, goodbye, goodbye."
629 
630 
def __del__(self)
Definition: __init__.py:624

Member Function Documentation

def python.Events.__iter__ (   self)

Definition at line 586 of file __init__.py.

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

586  def __iter__ (self):
587  return self._next()
588 
589 
def _next(self)
Definition: __init__.py:660
def __iter__(self)
Definition: __init__.py:586
def python.Events._createFWLiteEvent (   self)
private
(Internal) Creates an FWLite Event

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

631  def _createFWLiteEvent (self):
632  """(Internal) Creates an FWLite Event"""
633  self._veryFirstTime = False
634  self._toBegin = True
635  if isinstance (self._filenames[0], ROOT.TFile):
636  self._event = ROOT.fwlite.Event (self._filenames[0])
637  self._mode = 'single'
638  return self._mode
639  if len (self._filenames) == 1 and self._forceEvent:
640  self._tfile = ROOT.TFile.Open (self._filenames[0])
641  self._event = ROOT.fwlite.Event (self._tfile)
642  self._mode = 'single'
643  return self._mode
644  filenamesSVec = ROOT.vector("string") ()
645  for name in self._filenames:
646  filenamesSVec.push_back (name)
647  if self._secondaryFilenames:
648  secondarySVec = ROOT.vector("string") ()
649  for name in self._secondaryFilenames:
650  secondarySVec.push_back (name)
651  self._event = ROOT.fwlite.MultiChainEvent (filenamesSVec,
652  secondarySVec)
653  self._mode = 'multi'
654  else:
655  self._event = ROOT.fwlite.ChainEvent (filenamesSVec)
656  self._mode = 'chain'
657  return self._mode
658 
659 
def _createFWLiteEvent(self)
Definition: __init__.py:631
def python.Events._next (   self)
private
(Internal) Iterator internals

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

660  def _next (self):
661  """(Internal) Iterator internals"""
662  if self._veryFirstTime:
663  self._createFWLiteEvent()
664  if self._toBegin:
665  self._toBeginCode()
666  while not self._event.atEnd() :
667  yield self
668  self._eventCounts += 1
669  if self._maxEvents > 0 and self._eventCounts >= self._maxEvents:
670  break
671  # Have we been asked to go to the first event?
672  if self._toBegin:
673  self._toBeginCode()
674  else:
675  # if not, lets go to the next event
676  self._event.__preinc__()
677 
678 
679 
def _createFWLiteEvent(self)
Definition: __init__.py:631
def _next(self)
Definition: __init__.py:660
def _toBeginCode(self)
Definition: __init__.py:617
_maxEvents
Parse optional arguments ##.
Definition: __init__.py:469
def python.Events._parseOptions (   self,
  options 
)
private

Private Member Functions ##.

(Internal) Parse options

Definition at line 613 of file __init__.py.

613  def _parseOptions (self, options):
614  """(Internal) Parse options"""
615 
616 
def _parseOptions(self, options)
Private Member Functions ##.
Definition: __init__.py:613
def python.Events._toBeginCode (   self)
private
(Internal) Does actual work of toBegin() call

Definition at line 617 of file __init__.py.

Referenced by python.Events._next().

617  def _toBeginCode (self):
618  """(Internal) Does actual work of toBegin() call"""
619  self._toBegin = False
620  self._event.toBegin()
621  self._eventCounts = 0
622 
623 
def _toBeginCode(self)
Definition: __init__.py:617
def python.Events.eventAuxiliary (   self)
Returns eventAuxiliary object

Definition at line 529 of file __init__.py.

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

529  def eventAuxiliary (self):
530  """Returns eventAuxiliary object"""
531  if self._veryFirstTime:
532  raise RuntimeError("eventAuxiliary() called before "\
533  "toBegin() or to()")
534  return self._event.eventAuxiliary()
535 
536 
def eventAuxiliary(self)
Definition: __init__.py:529
def python.Events.fileIndex (   self)

Definition at line 590 of file __init__.py.

References python.Events._event.

Referenced by python.Events.fileIndicies().

590  def fileIndex (self):
591  if self._event:
592  return self._event.fileIndex()
593  else:
594  # default non-existant value is -1. Return something else
595  return -2
596 
597 
def fileIndex(self)
Definition: __init__.py:590
def python.Events.fileIndicies (   self)
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 542 of file __init__.py.

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

542  def getByLabel (self, *args):
543  """Calls FWLite's getByLabel. Called:
544  getByLabel (moduleLabel, handle)
545  getByLabel (moduleLabel, productInstanceLabel, handle),
546  getByLabel (moduleLabel, productInstanceLabel, processLabel, handle),
547  or
548  getByLabel ( (mL, pIL,pL), handle)
549  """
550  if self._veryFirstTime:
551  self._createFWLiteEvent()
552  length = len (args)
553  if length < 2 or length > 4:
554  # not called correctly
555  raise RuntimeError("Incorrect number of arguments")
556  # handle is always the last argument
557  argsList = list (args)
558  handle = argsList.pop()
559  if len(argsList)==1 :
560  if( isinstance (argsList[0], tuple) or
561  isinstance (argsList[0], list) ) :
562  if len (argsList[0]) > 3:
563  raise RuntimeError("getByLabel Error: label tuple has too " \
564  "many arguments '%s'" % argsList[0])
565  argsList = list(argsList[0])
566  if( isinstance(argsList[0], str) and ":" in argsList[0] ):
567  if argsList[0].count(":") > 3:
568  raise RuntimeError("getByLabel Error: label tuple has too " \
569  "many arguments '%s'" % argsList[0].split(":"))
570  argsList = argsList[0].split(":")
571  while len(argsList) < 3:
572  argsList.append ('')
573  (moduleLabel, productInstanceLabel, processLabel) = argsList
574  labelString = "'" + "', '".join(argsList) + "'"
575  if not handle._wrapper :
576  handle._resetWrapper()
577  handle._setStatus ( self._event.getByLabel( handle._typeInfoGetter(),
578  moduleLabel,
579  productInstanceLabel,
580  processLabel,
581  handle._addressOf() ),
582  labelString )
583  return handle.isValid()
584 
585 
def getByLabel(self, args)
Definition: __init__.py:542
def _createFWLiteEvent(self)
Definition: __init__.py:631
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
double split
Definition: MVATrainer.cc:139
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)
def python.Events.secondaryFileIndex (   self)

Definition at line 598 of file __init__.py.

References python.Events._event.

Referenced by python.Events.fileIndicies().

598  def secondaryFileIndex (self):
599  if self._event:
600  return self._event.secondaryFileIndex()
601  else:
602  # default non-existant value is -1. Return something else
603  return -2
604 
605 
def secondaryFileIndex(self)
Definition: __init__.py:598
def python.Events.size (   self)
Returns number of events

Definition at line 522 of file __init__.py.

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

Referenced by ntupleDataFormat._Collection.__iter__(), and ntupleDataFormat._Collection.__len__().

522  def size (self):
523  """Returns number of events"""
524  if self._veryFirstTime:
525  self._createFWLiteEvent()
526  return self._event.size()
527 
528 
def size(self)
Definition: __init__.py:522
def _createFWLiteEvent(self)
Definition: __init__.py:631
def python.Events.to (   self,
  entryIndex 
)
Jumps to event entryIndex

Definition at line 510 of file __init__.py.

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

510  def to (self, entryIndex):
511  """Jumps to event entryIndex"""
512  if self._veryFirstTime:
513  self._createFWLiteEvent()
514  return self._event.to ( long(entryIndex) )
515 
516 
def _createFWLiteEvent(self)
Definition: __init__.py:631
def to(self, entryIndex)
Definition: __init__.py:510
def python.Events.toBegin (   self)
Called to reset event loop to first event.

Definition at line 517 of file __init__.py.

517  def toBegin (self):
518  """Called to reset event loop to first event."""
519  self._toBegin = True
520 
521 
def toBegin(self)
Definition: __init__.py:517

Member Data Documentation

python.Events._event
private
python.Events._eventCounts
private

Definition at line 468 of file __init__.py.

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

python.Events._filenames
private
python.Events._forceEvent
private

Definition at line 470 of file __init__.py.

Referenced by python.Events._createFWLiteEvent().

python.Events._maxEvents
private

Parse optional arguments ##.

Definition at line 469 of file __init__.py.

Referenced by python.Events._next().

python.Events._mode
private

Definition at line 471 of file __init__.py.

Referenced by python.Events._createFWLiteEvent().

python.Events._secondaryFilenames
private

Definition at line 472 of file __init__.py.

python.Events._tfile
private

Definition at line 640 of file __init__.py.

python.Events._toBegin
private
python.Events._veryFirstTime
private