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 458 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 461 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
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 
510 
def __init__(self, inputFiles='', kwargs)
Definition: __init__.py:461
_maxEvents
Parse optional arguments ##.
Definition: __init__.py:470
def python.Events.__del__ (   self)
(Internal) Destructor

Definition at line 625 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 
631 
def __del__(self)
Definition: __init__.py:625

Member Function Documentation

def python.Events.__iter__ (   self)

Definition at line 587 of file __init__.py.

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

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

Definition at line 632 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 
660 
def _createFWLiteEvent(self)
Definition: __init__.py:632
def python.Events._next (   self)
private
(Internal) Iterator internals

Definition at line 661 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 
680 
def _createFWLiteEvent(self)
Definition: __init__.py:632
def _next(self)
Definition: __init__.py:661
def _toBeginCode(self)
Definition: __init__.py:618
_maxEvents
Parse optional arguments ##.
Definition: __init__.py:470
def python.Events._parseOptions (   self,
  options 
)
private

Private Member Functions ##.

(Internal) Parse options

Definition at line 614 of file __init__.py.

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

Definition at line 618 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 
624 
def _toBeginCode(self)
Definition: __init__.py:618
def python.Events.eventAuxiliary (   self)
Returns eventAuxiliary object

Definition at line 530 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 
537 
def eventAuxiliary(self)
Definition: __init__.py:530
def python.Events.fileIndex (   self)

Definition at line 591 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 
598 
def fileIndex(self)
Definition: __init__.py:591
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 543 of file __init__.py.

References python.Events._createFWLiteEvent(), python.Lumis._veryFirstTime, python.Runs._veryFirstTime, python.Events._veryFirstTime, KineDebug3.count(), join(), list(), and cms::dd.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( isinstance(argsList[0], 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 
586 
std::vector< std::string_view > split(std::string_view, const char *)
def getByLabel(self, args)
Definition: __init__.py:543
def _createFWLiteEvent(self)
Definition: __init__.py:632
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
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 599 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 
606 
def secondaryFileIndex(self)
Definition: __init__.py:599
def python.Events.size (   self)
Returns number of events

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

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

Definition at line 511 of file __init__.py.

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

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

Definition at line 518 of file __init__.py.

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

Member Data Documentation

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

Definition at line 469 of file __init__.py.

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

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

Definition at line 471 of file __init__.py.

Referenced by python.Events._createFWLiteEvent().

python.Events._maxEvents
private

Parse optional arguments ##.

Definition at line 470 of file __init__.py.

Referenced by python.Events._next().

python.Events._mode
private

Definition at line 472 of file __init__.py.

Referenced by python.Events._createFWLiteEvent().

python.Events._secondaryFilenames
private

Definition at line 473 of file __init__.py.

python.Events._tfile
private

Definition at line 641 of file __init__.py.

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