Pottu
LogicalEventSorter.hpp
Go to the documentation of this file.
1 
6 #ifndef H_POTTU_LOGICAL_EVENT_SORTER
7 #define H_POTTU_LOGICAL_EVENT_SORTER
8 
9 #include "ContextBase.hpp"
10 #include "DetectorEvent.hpp"
12 #include "SharedResourcePool.hpp"
13 
14 namespace pottu {
15 
37  template <class Ev, class Tr, class D>
39  public:
41  using logical_event_handle_t = typename logical_event_pool_t::logical_event_handle_t;
42 
43 
58  LogicalEventSorter( const std::string &name, int triggerDeadTime, int eventDelay, int maxEventLength )
59  : _ctxh(ContextBase::getActive().createHandle(name.c_str())),
60  _eventCollector( static_cast<D &>(*this), _triggerer, triggerDeadTime, eventDelay, maxEventLength )
61  {}
62 
63 
68  void process( std::vector<DetectorEvent> &data ) noexcept {
69  // Just for statistics... proci is automatically destroyed at
70  // the end of process().
71  auto proci = _ctxh->processInstance();
72 
73  // Creates logical events and calls methods:
74  // - constructAndProcessLogicalEvent()
75  // - onTimeOrderError()
76  // These must be available in this class!
77  _eventCollector.feed( data );
78  }
79 
83  int64_t getEventMaxLength() const { return _eventCollector._maxEventLength; }
84 
85 
89  int64_t getEventDelay() const { return _eventCollector._eventDelay; }
90 
91 
95  int64_t getTriggerDeadtime() const { return _eventCollector._triggerDeadTime; }
96 
97  protected:
103  logical_event_handle_t getNewEvent() noexcept {
104  return _logicalEventPool.get();
105  }
106 
114  ContextHandle *context() noexcept { return _ctxh; }
115 
118 
119  // Pool for new logical events. Using pool decreases heap
120  // allocations dramatically and speeds up program.
121  logical_event_pool_t _logicalEventPool;
122 
123  // Class and instance defining the trigger condition. Used by
124  // _eventCollector.
125  Tr _triggerer;
126 
127  // Pottu class collecting DetectorEvents into logical events. Uses
128  // _triggerer.
129  LogicalEventCollector<D,Tr> _eventCollector;
130 
131  };
132 
133 
134 }
135 
136 
137 #endif
Handle to context used by specific class.
Definition: ContextBase.hpp:188
void feed(const Cont &data) noexcept
Use this to feed detector event to this machine.
Definition: LogicalEventCollector.hpp:70
Convenience base class for user sort classes.
Definition: LogicalEventSorter.hpp:38
LogicalEventSorter(const std::string &name, int triggerDeadTime, int eventDelay, int maxEventLength)
Constructor.
Definition: LogicalEventSorter.hpp:58
ContextHandle * context() noexcept
Returns pointer to the ContextHandle.
Definition: LogicalEventSorter.hpp:114
int64_t getEventDelay() const
Returns the event delay.
Definition: LogicalEventSorter.hpp:89
logical_event_handle_t getNewEvent() noexcept
Returns new logical event.
Definition: LogicalEventSorter.hpp:103
int64_t getTriggerDeadtime() const
Returns the trigger dead time.
Definition: LogicalEventSorter.hpp:95
int64_t getEventMaxLength() const
Returns the maximum event length.
Definition: LogicalEventSorter.hpp:83
void process(std::vector< DetectorEvent > &data) noexcept
Feeds data to object buffers. Tests for triggers.
Definition: LogicalEventSorter.hpp:68
ContextHandle * _ctxh
Handle for the context.
Definition: LogicalEventSorter.hpp:117
Handle for a resource derived from SharedResource.
Definition: memory.hpp:43
Pool for SharedResource derived objects.
Definition: SharedResourcePool.hpp:37
Abstract baseclass for all stages which uses or modifies detector events.
Definition: StageDetectorEvent.hpp:20
Definition: mainpage.dox:6
Default context for printing and collecting statistics.
Definition: ContextBase.hpp:41