Pottu
LogicalEventSorterBase.hpp
Go to the documentation of this file.
1 
6 #ifndef H_POTTU_LOGICAL_EVENT_SORTER_BASE
7 #define H_POTTU_LOGICAL_EVENT_SORTER_BASE
8 
9 #include "ContextBase.hpp"
10 #include "DetectorEvent.hpp"
12 #include "SharedResourcePool.hpp"
13 
14 namespace pottu {
15 
31  template <class Ev, class Tr>
33  public:
35  using logical_event_handle_t = typename logical_event_pool_t::logical_event_handle_t;
36 
37 
52  LogicalEventSorterBase( const std::string &name, int triggerDeadTime, int eventDelay, int maxEventLength )
53  : _ctxh(ContextBase::getActive().createHandle(name.c_str())),
54  _eventCollector( *this, _triggerer, triggerDeadTime, eventDelay, maxEventLength )
55  {}
56 
57 
58  /*****************************************************
59  * process()
60  *****************************************************/
61  void process( std::vector<DetectorEvent> &data ) noexcept {
62  // Just for statistics... proci is automatically destroyed at
63  // the end of process().
64  auto proci = _ctxh->processInstance();
65 
66  // Creates logical events and calls methods:
67  // - constructAndProcessLogicalEvent()
68  // - onTimeOrderError()
69  // These must be available in this class!
70  _eventCollector.feed( data );
71  }
72 
73 
77  int64_t getEventMaxLength() const { return _eventCollector._maxEventLength; }
78 
79 
83  int64_t getEventDelay() const { return _eventCollector._eventDelay; }
84 
85 
89  int64_t getTriggerDeadtime() const { return _eventCollector._triggerDeadTime; }
90 
91  protected:
92 
94 
97  virtual void onTimeOrderError() noexcept = 0;
98 
108  virtual void constructAndProcessLogicalEvent( std::deque<pottu::DetectorEvent>::iterator first,
109  std::deque<pottu::DetectorEvent>::iterator last,
110  int64_t triggerTime,
111  int64_t eventStartTime, int64_t eventStopTime ) noexcept = 0;
112 
113 
119  logical_event_handle_t getNewEvent() noexcept {
120  return _logicalEventPool.get();
121  }
122 
130  ContextHandle *context() noexcept { return _ctxh; }
131 
132  // This handle just takes care of some debug printing and taking
133  // time of processing for statistics.
134  ContextHandle *_ctxh;
135 
136  // Pool for new logical events. Using pool decreases heap
137  // allocations dramatically and speeds up program.
138  logical_event_pool_t _logicalEventPool;
139 
140  // Class and instance defining the trigger condition. Used by
141  // _eventCollector.
142  Tr _triggerer;
143 
144  // Pottu class collecting DetectorEvents into logical events. Uses
145  // _triggerer.
147 
148  };
149 
150 
151 }
152 
153 
154 #endif
Handle to context used by specific class.
Definition: ContextBase.hpp:188
Event containing event information of one daq channel.
Definition: DetectorEvent.hpp:47
Class which creates the logical events from stream of detector events.
Definition: LogicalEventCollector.hpp:27
Convenience base class for user sort classes.
Definition: LogicalEventSorterBase.hpp:32
virtual void onTimeOrderError() noexcept=0
Called if the object observes a time order error. This must be implemented in the derived class.
virtual void constructAndProcessLogicalEvent(std::deque< pottu::DetectorEvent >::iterator first, std::deque< pottu::DetectorEvent >::iterator last, int64_t triggerTime, int64_t eventStartTime, int64_t eventStopTime) noexcept=0
Called if the object has found a new trigger. This must be implemented in the derived class.
ContextHandle * context() noexcept
Returns pointer to the ContextHandle.
Definition: LogicalEventSorterBase.hpp:130
int64_t getTriggerDeadtime() const
Returns the trigger dead time.
Definition: LogicalEventSorterBase.hpp:89
void process(std::vector< DetectorEvent > &data) noexcept
Uses or modifies detector events in a container.
Definition: LogicalEventSorterBase.hpp:61
logical_event_handle_t getNewEvent() noexcept
Returns new logical event.
Definition: LogicalEventSorterBase.hpp:119
int64_t getEventDelay() const
Returns the event delay.
Definition: LogicalEventSorterBase.hpp:83
LogicalEventSorterBase(const std::string &name, int triggerDeadTime, int eventDelay, int maxEventLength)
Constructor.
Definition: LogicalEventSorterBase.hpp:52
int64_t getEventMaxLength() const
Returns the maximum event length.
Definition: LogicalEventSorterBase.hpp:77
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