![]() |
![]() |
################## ## ## ############ ## ## ## ## 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 ##. | |
def | _toBeginCode |
Private Attributes | |
_event | |
_eventCounts | |
_filenames | |
_forceEvent | |
_maxEvents | |
Parse optional arguments ##. | |
_mode | |
_secondaryFilenames | |
_tfile | |
_toBegin | |
_veryFirstTime |
################## ## ## ############ ## ## ## ## Events ## ## ## ## ############ ## ## ################## ##
Python interface to FWLite ChainEvent class
Definition at line 435 of file __init__.py.
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 438 of file __init__.py.
00439 : 00440 """inputFiles => Either a single filename or a list of filenames 00441 Optional arguments: 00442 forceEvent => Use fwlite::Event IF there is only one file 00443 maxEvents => Maximum number of events to process 00444 """ 00445 self._veryFirstTime = True 00446 self._event = 0 00447 self._eventCounts = 0 00448 self._maxEvents = 0 00449 self._forceEvent = False 00450 self._mode = None 00451 self._secondaryFilenames = None 00452 if isinstance (inputFiles, list): 00453 # it's a list 00454 self._filenames = inputFiles[:] 00455 elif isinstance (inputFiles, VarParsing): 00456 # it's a VarParsing object 00457 options = inputFiles 00458 self._maxEvents = options.maxEvents 00459 self._filenames = options.inputFiles 00460 self._secondaryFilenames = options.secondaryInputFiles 00461 else: 00462 # it's probably a single string 00463 self._filenames = [inputFiles] 00464 ############################## 00465 ## Parse optional arguments ## 00466 ############################## 00467 if kwargs.has_key ('maxEvents'): 00468 self._maxEvents = kwargs['maxEvents'] 00469 del kwargs['maxEvents'] 00470 if kwargs.has_key ('forceEvent'): 00471 self._forceEvent = kwargs['forceEvent'] 00472 del kwargs['forceEvent'] 00473 if kwargs.has_key ('options'): 00474 options = kwargs ['options'] 00475 self._maxEvents = options.maxEvents 00476 self._filenames = options.inputFiles 00477 self._secondaryFilenames = options.secondaryInputFiles 00478 del kwargs['options'] 00479 # Since we deleted the options as we used them, that means 00480 # that kwargs should be empty. If it's not, that means that 00481 # somebody passed in an argument that we're not using and we 00482 # should complain. 00483 if len (kwargs): 00484 raise RuntimeError, "Unknown arguments %s" % kwargs 00485 if not self._filenames: 00486 raise RuntimeError, "No input files given" 00487
def python::Events::__del__ | ( | self | ) |
(Internal) Destructor
Definition at line 595 of file __init__.py.
def python::Events::__iter__ | ( | self | ) |
Definition at line 557 of file __init__.py.
def python::Events::_createFWLiteEvent | ( | self | ) | [private] |
(Internal) Creates an FWLite Event
Definition at line 602 of file __init__.py.
00603 : 00604 """(Internal) Creates an FWLite Event""" 00605 self._veryFirstTime = False 00606 self._toBegin = True 00607 if isinstance (self._filenames[0], ROOT.TFile): 00608 self._event = ROOT.fwlite.Event (self._filenames[0]) 00609 self._mode = 'single' 00610 return self._mode 00611 if len (self._filenames) == 1 and self._forceEvent: 00612 self._tfile = ROOT.TFile.Open (self._filenames[0]) 00613 self._event = ROOT.fwlite.Event (self._tfile) 00614 self._mode = 'single' 00615 return self._mode 00616 filenamesSVec = ROOT.vector("string") () 00617 for name in self._filenames: 00618 filenamesSVec.push_back (name) 00619 if self._secondaryFilenames: 00620 secondarySVec = ROOT.vector("string") () 00621 for name in self._secondaryFilenames: 00622 secondarySVec.push_back (name) 00623 self._event = ROOT.fwlite.MultiChainEvent (filenamesSVec, 00624 secondarySVec) 00625 self._mode = 'multi' 00626 else: 00627 self._event = ROOT.fwlite.ChainEvent (filenamesSVec) 00628 self._mode = 'chain' 00629 return self._mode 00630
def python::Events::_next | ( | self | ) | [private] |
(Internal) Iterator internals
Definition at line 631 of file __init__.py.
00632 : 00633 """(Internal) Iterator internals""" 00634 if self._veryFirstTime: 00635 self._createFWLiteEvent() 00636 if self._toBegin: 00637 self._toBeginCode() 00638 while not self._event.atEnd() : 00639 yield self 00640 self._eventCounts += 1 00641 if self._maxEvents > 0 and self._eventCounts >= self._maxEvents: 00642 break 00643 # Have we been asked to go to the first event? 00644 if self._toBegin: 00645 self._toBeginCode() 00646 else: 00647 # if not, lets go to the next event 00648 self._event.__preinc__() 00649 00650
def python::Events::_parseOptions | ( | self, | |
options | |||
) | [private] |
def python::Events::_toBeginCode | ( | self | ) | [private] |
(Internal) Does actual work of toBegin() call
Definition at line 588 of file __init__.py.
def python::Events::eventAuxiliary | ( | self | ) |
Returns eventAuxiliary object
Definition at line 507 of file __init__.py.
def python::Events::fileIndex | ( | self | ) |
Definition at line 561 of file __init__.py.
def python::Events::fileIndicies | ( | self | ) |
Definition at line 577 of file __init__.py.
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 520 of file __init__.py.
00521 : 00522 """Calls FWLite's getByLabel. Called: 00523 getByLabel (moduleLabel, handle) 00524 getByLabel (moduleLabel, productInstanceLabel, handle), 00525 getByLabel (moduleLabel, productInstanceLabel, processLabel, handle), 00526 or 00527 getByLabel ( (mL, pIL,pL), handle) 00528 """ 00529 if self._veryFirstTime: 00530 self._createFWLiteEvent() 00531 length = len (args) 00532 if length < 2 or length > 4: 00533 # not called correctly 00534 raise RuntimeError, "Incorrect number of arguments" 00535 # handle is always the last argument 00536 argsList = list (args) 00537 handle = argsList.pop() 00538 if len(argsList)==1 and \ 00539 ( isinstance (argsList[0], tuple) or 00540 isinstance (argsList[0], list) ) : 00541 if len (argsList) > 3: 00542 raise RuntimeError, "getByLabel Error: label tuple has too " \ 00543 "many arguments '%s'" % argsList[0] 00544 argsList = list(argsList[0]) 00545 while len(argsList) < 3: 00546 argsList.append ('') 00547 (moduleLabel, productInstanceLabel, processLabel) = argsList 00548 labelString = "'" + "', '".join(argsList) + "'" 00549 handle._setStatus ( self._event.getByLabel( handle._typeInfoGetter(), 00550 moduleLabel, 00551 productInstanceLabel, 00552 processLabel, 00553 handle._addressOf() ), 00554 labelString ) 00555 return handle.isValid() 00556
def python::Events::object | ( | self | ) |
Returns event object
Definition at line 515 of file __init__.py.
def python::Events::secondaryFileIndex | ( | self | ) |
Definition at line 569 of file __init__.py.
def python::Events::size | ( | self | ) |
Returns number of events
Definition at line 500 of file __init__.py.
def python::Events::to | ( | self, | |
entryIndex | |||
) |
Jumps to event entryIndex
Definition at line 488 of file __init__.py.
def python::Events::toBegin | ( | self | ) |
Called to reset event loop to first event.
Definition at line 495 of file __init__.py.
python::Events::_event [private] |
Definition at line 442 of file __init__.py.
python::Events::_eventCounts [private] |
Definition at line 442 of file __init__.py.
python::Events::_filenames [private] |
Definition at line 442 of file __init__.py.
python::Events::_forceEvent [private] |
Definition at line 442 of file __init__.py.
python::Events::_maxEvents [private] |
Parse optional arguments ##.
Definition at line 442 of file __init__.py.
python::Events::_mode [private] |
Definition at line 442 of file __init__.py.
python::Events::_secondaryFilenames [private] |
Definition at line 442 of file __init__.py.
python::Events::_tfile [private] |
Definition at line 602 of file __init__.py.
python::Events::_toBegin [private] |
Definition at line 495 of file __init__.py.
python::Events::_veryFirstTime [private] |
Definition at line 442 of file __init__.py.