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