/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes
DybEventMgr::HybridLoop::EventBuilderAlg Class Reference
Inheritance diagram for DybEventMgr::HybridLoop::EventBuilderAlg:
Inheritance graph
[legend]
Collaboration diagram for DybEventMgr::HybridLoop::EventBuilderAlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def initialize
def finalize
def execute
def switch_mode
def collect_frames
def collect_headers
def clear_events
def locate
def build_event
def build_events
def execute_readout
def dump_cache
def execute_event

Public Attributes

 frames_location
 incsvc
 eventNumber
 branch
 events
 objects
 hei

Detailed Description

An event builder algorithm meant to drive a hybrid readout/event
execution loop.  

It is expected to be placed in the TopAlg such that all
readout-based algorithms are before it and all event-based ones
are after it.  

It flip-flops between two phases: "readout" and "event".  

In the readout phase it collects all HeaderObjects found through
the RegistrationSequence up to and including when it finds a
collection of frames to appear in the TES, by default in the
location /Event/EventBuilder/Frames.

It then builds events based on ReadoutHeaders found in each frame.
All objects that can reach one of these ReadoutHeaders via their
inputHeaders will also be added to teh event.  It then indicates
to the DybDualEventLoopMgr to switch to its event phase.

Starting with the subsequent execute() the algorithm also begins
its event phase.  In each execute(), the event's objects are
placed in the TES.  When the event cache is exhausted it wil
signal DybDualEventLoopMgr to go back to readout mode.

Note: that any non-ReadoutHeader objects that fail to be added to
an event are DROPPED.

Note: the intermediates built by the Chunker/Framer are DROPPED.

Definition at line 16 of file HybridLoop.py.


Constructor & Destructor Documentation

def DybEventMgr::HybridLoop::EventBuilderAlg::__init__ (   self,
  name = 'EventBuiderAlg',
  frames_location = '/Event/EventBuilder/Frames' 
)
Create the algorithm.  The name needs to match the one given
to the NuWa object.

Definition at line 48 of file HybridLoop.py.

00050                                                                 :
00051         '''
00052         Create the algorithm.  The name needs to match the one given
00053         to the NuWa object.
00054         '''
00055         DybPythonAlg.__init__(self,name)
00056         self.frames_location = frames_location
00057         self.incsvc = None
00058         self.eventNumber = 0
00059         self.branch = 1         # 1:2 :: readout:event
00060 
00061         self.events = []        # cache of a chunk's worth of events
00062 
00063         self.objects = HandleCache()
00064 
00065         return


Member Function Documentation

def DybEventMgr::HybridLoop::EventBuilderAlg::initialize (   self)

Definition at line 66 of file HybridLoop.py.

00067                         :
00068         sc = DybPythonAlg.initialize(self)
00069         if sc.isFailure(): return sc
00070         self.incsvc = self.svc('IIncidentSvc','IncidentSvc')
00071         return SUCCESS

def DybEventMgr::HybridLoop::EventBuilderAlg::finalize (   self)

Definition at line 72 of file HybridLoop.py.

00073                       :
00074         return DybPythonAlg.finalize(self)

def DybEventMgr::HybridLoop::EventBuilderAlg::execute (   self)

Definition at line 75 of file HybridLoop.py.

00076                      :
00077         'Call switch on branch'
00078         self.debug('Executing branch=%d' % self.branch)
00079         sc = SUCCESS
00080 
00081         if 1 == self.branch:            # readout based
00082             sc = self.execute_readout()
00083         else:                           # event based
00084             sc = self.execute_event()
00085             pass
00086         return sc

def DybEventMgr::HybridLoop::EventBuilderAlg::switch_mode (   self)
Switch modes by firing a HybridExecutionIncident.  Note, the
current execution cycle will still run its course.

Definition at line 87 of file HybridLoop.py.

00088                          :
00089         '''
00090         Switch modes by firing a HybridExecutionIncident.  Note, the
00091         current execution cycle will still run its course.
00092         '''
00093         self.branch = (self.branch % 2) + 1 # 1<-->2
00094         self.debug('switching to branch %d' % self.branch)
00095         self.hei = gbl.HybridExecutionIncident(self.branch,self.name())
00096         self.incsvc.fireIncident(self.hei)
00097         return

def DybEventMgr::HybridLoop::EventBuilderAlg::collect_frames (   self,
  frames 
)

Definition at line 98 of file HybridLoop.py.

00099                                    :
00100         'Collect the ReadoutHeaders in the frames'
00101         for frame in inputHeaders2list(frames):
00102             for roh in inputHeaders2list(frame):
00103                 #self.debug('Collecting "%s"' % hostr(roh))
00104                 self.objects.push(roh,roh.name()) # name() is right?
00105                 continue
00106             continue
00107 

def DybEventMgr::HybridLoop::EventBuilderAlg::collect_headers (   self)

Definition at line 108 of file HybridLoop.py.

00109                              :
00110         'Collect all HeaderObjects in RS, return the frames collection if found'
00111         tes = self.evtSvc()
00112         rs = tes['/Event/RegistrationSequence']
00113         assert rs, 'No RegistrationSeqence found.'
00114         regs = rs.registrations()
00115         for ind in range(rs.size()):
00116             objreg = regs[ind]
00117             path = objreg.path()
00118             if path == self.frames_location:
00119                 self.collect_frames(objreg.object())
00120             elif '/Chunk' in path:
00121                 self.debug("Not collecting %s" % path)
00122             else:
00123                 self.objects.push(objreg.object(),path)
00124             continue
00125         return tes[self.frames_location]

def DybEventMgr::HybridLoop::EventBuilderAlg::clear_events (   self)

Definition at line 126 of file HybridLoop.py.

00127                           :
00128         'Clear cached events'
00129         self.debug('There are %d objects unaccounted for:' % len(self.objects))
00130 

def DybEventMgr::HybridLoop::EventBuilderAlg::locate (   self,
  handle 
)

Definition at line 131 of file HybridLoop.py.

00132                            :
00133         "Reset the handle's location to one used to place it in the event"
00134         obj = handle.object()
00135         loc = locate_in_event(obj,handle.location())
00136         handle._loc = loc       # cheat to avoid ref count churn 
00137         return handle        

def DybEventMgr::HybridLoop::EventBuilderAlg::build_event (   self,
  roh_list 
)
Build and return one event based on a given list of
ReadoutHeaders.  The event is in the form of a list of
ObjectHandles.  The list is ordered starting with the first
readout, followed with any derived objects, then the second
readout, etc.

Definition at line 138 of file HybridLoop.py.

00139                                   :
00140         '''
00141         Build and return one event based on a given list of
00142         ReadoutHeaders.  The event is in the form of a list of
00143         ObjectHandles.  The list is ordered starting with the first
00144         readout, followed with any derived objects, then the second
00145         readout, etc.
00146         '''
00147         event = []
00148         for roh in roh_list:
00149             handle = self.objects.pop(roh)
00150             assert handle, 'Given a ReadoutHeader I do not know about: "%s"' % hostr(roh)
00151             event.append(self.locate(handle))
00152             for handle in self.objects.derived(roh):
00153                 event.append(self.locate(handle))
00154                 continue
00155             continue
00156         return event

def DybEventMgr::HybridLoop::EventBuilderAlg::build_events (   self,
  fc 
)
Build events from the collection of frame tags.

Definition at line 157 of file HybridLoop.py.

00158                              :
00159         '''
00160         Build events from the collection of frame tags.
00161         '''
00162         events = []
00163         frameTags = inputHeaders2list(fc)
00164         for frameTag in frameTags:
00165             roh_list = inputHeaders2list(frameTag)
00166             event = self.build_event(roh_list)
00167             events.append(event)
00168             continue
00169         return events

def DybEventMgr::HybridLoop::EventBuilderAlg::execute_readout (   self)

Definition at line 170 of file HybridLoop.py.

00171                              :
00172         'Readout-based execution'
00173         fc = self.collect_headers()
00174         if not fc: return SUCCESS
00175 
00176         self.events = self.build_events(fc)
00177 
00178         self.switch_mode()      # goto event-based next execute
00179         return SUCCESS

def DybEventMgr::HybridLoop::EventBuilderAlg::dump_cache (   self)

Definition at line 180 of file HybridLoop.py.

00181                         :
00182         'Dump information about the cache'
00183         self.debug('Cached %d objects at event #%d:' % (len(self.objects), self.eventNumber))
00184         for handle in self.objects.handles():
00185             self.debug('\t%s: %s' % (handle.location(), hostr(handle.object())))
00186         return

def DybEventMgr::HybridLoop::EventBuilderAlg::execute_event (   self)

Definition at line 187 of file HybridLoop.py.

00188                            :
00189         'Event-based execution'
00190         self.eventNumber += 1
00191         
00192         #self.dump_cache()
00193 
00194         event = self.events.pop(0)
00195         self.debug('Event #%d with %d objects' % (self.eventNumber,len(event)))
00196 
00197         tes = self.evtSvc()
00198         for handle in event:
00199             obj = handle.object()
00200             obj.setExecNumber(self.eventNumber)
00201             tes[handle.location()] = obj
00202         del event
00203 
00204         if not self.events:
00205             self.switch_mode()  # go to readout-based after this cycle
00206 
00207         return SUCCESS
00208     
00209 


Member Data Documentation

Definition at line 51 of file HybridLoop.py.

Definition at line 51 of file HybridLoop.py.

Definition at line 51 of file HybridLoop.py.

Definition at line 51 of file HybridLoop.py.

Definition at line 51 of file HybridLoop.py.

Definition at line 51 of file HybridLoop.py.

Definition at line 90 of file HybridLoop.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:09:08 for DybEventMgr by doxygen 1.7.4