test
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 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.

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

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

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().

587  def __iter__ (self):
588  return self._next()
589 
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().

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

661  def _next (self):
662  """(Internal) Iterator internals"""
663  if self._veryFirstTime:
664  self._createFWLiteEvent()
665  if self._toBegin:
666  self._toBeginCode()
667  while not self._event.atEnd() :
668  yield self
669  self._eventCounts += 1
670  if self._maxEvents > 0 and self._eventCounts >= self._maxEvents:
671  break
672  # Have we been asked to go to the first event?
673  if self._toBegin:
674  self._toBeginCode()
675  else:
676  # if not, lets go to the next event
677  self._event.__preinc__()
678 
679 
def _createFWLiteEvent
Definition: __init__.py:631
def _toBeginCode
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.

614  def _parseOptions (self, options):
615  """(Internal) Parse options"""
616 
def _parseOptions
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().

618  def _toBeginCode (self):
619  """(Internal) Does actual work of toBegin() call"""
620  self._toBegin = False
621  self._event.toBegin()
622  self._eventCounts = 0
623 
def _toBeginCode
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.

530  def eventAuxiliary (self):
531  """Returns eventAuxiliary object"""
532  if self._veryFirstTime:
533  raise RuntimeError("eventAuxiliary() called before "\
534  "toBegin() or to()")
535  return self._event.eventAuxiliary()
536 
def eventAuxiliary
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().

591  def fileIndex (self):
592  if self._event:
593  return self._event.fileIndex()
594  else:
595  # default non-existant value is -1. Return something else
596  return -2
597 
def python.Events.fileIndicies (   self)

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

607  def fileIndicies (self):
608  return (self.fileIndex(), self.secondaryFileIndex())
609 
def fileIndicies
Definition: __init__.py:606
def secondaryFileIndex
Definition: __init__.py:598
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(), reco.if(), join(), list(), and split.

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

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

538  def object (self):
539  """Returns event object"""
540  return self._event
541 
def python.Events.secondaryFileIndex (   self)

Definition at line 598 of file __init__.py.

References python.Events._event.

Referenced by python.Events.fileIndicies().

599  def secondaryFileIndex (self):
600  if self._event:
601  return self._event.secondaryFileIndex()
602  else:
603  # default non-existant value is -1. Return something else
604  return -2
605 
def secondaryFileIndex
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.

523  def size (self):
524  """Returns number of events"""
525  if self._veryFirstTime:
526  self._createFWLiteEvent()
527  return self._event.size()
528 
def _createFWLiteEvent
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.

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

Definition at line 517 of file __init__.py.

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

Member Data Documentation

python.Events._event
private

Definition at line 467 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 468 of file __init__.py.

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

python.Events._filenames
private

Definition at line 475 of file __init__.py.

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

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

python.Events._tfile
private

Definition at line 640 of file __init__.py.

python.Events._toBegin
private

Definition at line 519 of file __init__.py.

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

python.Events._veryFirstTime
private

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