Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JTrigger3D.hh
Go to the documentation of this file.
1#ifndef __JTRIGGER__JTRIGGER3D__
2#define __JTRIGGER__JTRIGGER3D__
3
4#include <vector>
5#include <iterator>
6#include <memory>
7
8#include "JTrigger/JEvent.hh"
9#include "JTrigger/JMatch.hh"
10#include "JTrigger/JBind2nd.hh"
15
16
17/**
18 * \author mdejong
19 */
20
21namespace JTRIGGER {}
22namespace JPP { using namespace JTRIGGER; }
23
24namespace JTRIGGER {
25
26 /**
27 * General purpose majority trigger.
28 */
29 class JTrigger3D :
31 {
32 public:
33 /**
34 * Trigger parameters.
35 */
37 {
38 typedef std::shared_ptr<match_type> JMatch_t;
39
40 /**
41 * Constructor.
42 *
43 * \param option enable/disable trigger
44 * \param number_of_hits minimal number of hits to trigger event
45 * \param number_of_modules minimal number of modules to trigger event
46 * \param Tmax_ns maximal time between first and last hit [ns]
47 * \param match3d 3D match operator
48 * \param factory_limit maximal number of hits to apply trigger logic (above this limit, always trigger)
49 */
50 JParameters(const bool option,
51 const int number_of_hits,
52 const int number_of_modules,
53 const double Tmax_ns,
54 const match_type& match3d,
55 const int factory_limit) :
56 enabled (option),
57 numberOfHits (number_of_hits),
58 numberOfModules(number_of_modules),
59 TMaxEvent_ns (Tmax_ns),
60 match3D (match3d.clone()),
61 factoryLimit (factory_limit)
62 {}
63
64
65 bool enabled;
71 };
72
73
74 /**
75 * Constructor.
76 *
77 * \param input trigger parameters
78 */
79 JTrigger3D(const JParameters& input) :
80 parameters(input)
81 {
82 if (parameters.numberOfHits == 0) {
83 parameters.numberOfHits = 1;
84 }
85
87 parameters.factoryLimit = 1;
88 }
89
91 }
92
93
94 /**
95 * Process trigger.
96 *
97 * \param input input data
98 * \param out output data
99 */
100 void operator()(const JTriggerInput& input, std::back_insert_iterator<JTriggerOutput> out) const
101 {
102 using std::distance;
103
104 if (parameters.enabled && input.size() >= (size_t) parameters.numberOfHits) {
105
106 match_type& match3D = *parameters.match3D;
107
108 for (JTriggerInput::const_iterator p = input.begin(), q = p; p != input.end(); ) {
109
110 for (++q; q->getT() - p->getT() < parameters.TMaxEvent_ns; ++q) {}
111
112 if (distance (p,q) >= parameters.numberOfHits &&
114
115 if (distance(p,q) < parameters.factoryLimit) {
116
117 do {
118
119 if (distance (p,q) >= parameters.numberOfHits &&
121
122 // copy
123
124 JTriggerInput::iterator root = buffer.begin();
125 JTriggerInput::iterator __p = buffer.begin();
126 JTriggerInput::iterator __q = buffer.begin();
127
128 *root = *p;
129
130 ++__p;
131 ++__q;
132
133 for (JTriggerInput::const_iterator i = p; ++i != q; ) {
134 if (match3D(*p,*i)) {
135 *__q = *i;
136 ++__q;
137 }
138 }
139
140 if (distance (root,__q) >= parameters.numberOfHits &&
142
143 __q = clusterize(__p, __q, match3D, parameters.numberOfHits - 1);
144
145 if (distance (root,__q) >= parameters.numberOfHits &&
147 *out = JEvent(input.getDAQChronometer(), root, __q, this->getTriggerBit());
148 ++out;
149 }
150 }
151 }
152
153 ++p;
154
155 } while (q->getT() - p->getT() >= parameters.TMaxEvent_ns);
156
157 } else {
158
159 // Anomalous large event
160
161 JEvent event(input.getDAQChronometer(), p, q, this->getTriggerBit());
162
163 event.addTriggerBit(FACTORY_LIMIT);
164
165 *out = event;
166 ++out;
167
168 p = q;
169 }
170
171 } else {
172
173 for (++p; q->getT() - p->getT() >= parameters.TMaxEvent_ns; ++p) {}
174 }
175 }
176 }
177 }
178
179
180
182
183 private:
185 };
186}
187
188#endif
Algorithms for hit clustering and sorting.
Base class for match operations for cluster and hit-preprocessing methods.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Triggered event.
Function object interface for hit matching.
Definition JMatch.hh:27
General purpose majority trigger.
Definition JTrigger3D.hh:31
void operator()(const JTriggerInput &input, std::back_insert_iterator< JTriggerOutput > out) const
Process trigger.
std::vector< value_type > buffer
JTrigger3D(const JParameters &input)
Constructor.
Definition JTrigger3D.hh:79
JParameters parameters
Data structure for input to trigger algorithm.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JFIT::JEvent JEvent
Definition JHistory.hh:454
if((p==this->begin() &&this->getDistance(x,(p++) ->getX()) > distance_type::precision)||(p==this->end() &&this->getDistance((--p) ->getX(), x) > distance_type::precision))
Template base class for polynomial interpolations with polynomial result.
Definition JPolint.hh:775
Auxiliary classes and methods for triggering.
JHitIterator_t clusterize(JHitIterator_t __begin, JHitIterator_t __end, const JMatch_t &match, const int Nmin=1)
Partition data according given binary match operator.
Definition JAlgorithm.hh:38
static const JModuleCounter getNumberOfModules
Function object to count unique modules.
Definition root.py:1
JParameters(const bool option, const int number_of_hits, const int number_of_modules, const double Tmax_ns, const match_type &match3d, const int factory_limit)
Constructor.
Definition JTrigger3D.hh:50
std::shared_ptr< match_type > JMatch_t
Definition JTrigger3D.hh:38
static const int FACTORY_LIMIT
Bit indicating max nhits reached in trigger.
Definition trigger.hh:18