Jpp  19.1.0-rc.1
the software that should make you happy
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 
8 
9 #include "JTrigger/JEvent.hh"
10 #include "JTrigger/JMatch.hh"
11 #include "JTrigger/JBind2nd.hh"
12 #include "JTrigger/JAlgorithm.hh"
16 
17 
18 /**
19  * \author mdejong
20  */
21 
22 namespace JTRIGGER {}
23 namespace JPP { using namespace JTRIGGER; }
24 
25 namespace JTRIGGER {
26 
27  /**
28  * General purpose majority trigger.
29  */
30  class JTrigger3D :
31  public JTriggerInterface
32  {
33  public:
34  /**
35  * Trigger parameters.
36  */
37  struct JParameters
38  {
40 
41  /**
42  * Constructor.
43  *
44  * \param option enable/disable trigger
45  * \param number_of_hits minimal number of hits to trigger event
46  * \param number_of_modules minimal number of modules to trigger event
47  * \param Tmax_ns maximal time between first and last hit [ns]
48  * \param match3d 3D match operator
49  * \param factory_limit maximal number of hits to apply trigger logic (above this limit, always trigger)
50  */
51  JParameters(const bool option,
52  const int number_of_hits,
53  const int number_of_modules,
54  const double Tmax_ns,
55  const match_type& match3d,
56  const int factory_limit) :
57  enabled (option),
58  numberOfHits (number_of_hits),
59  numberOfModules(number_of_modules),
60  TMaxEvent_ns (Tmax_ns),
61  match3D (match3d.clone()),
62  factoryLimit (factory_limit)
63  {}
64 
65 
66  bool enabled;
69  double TMaxEvent_ns;
72  };
73 
74 
75  /**
76  * Constructor.
77  *
78  * \param input trigger parameters
79  */
80  JTrigger3D(const JParameters& input) :
81  parameters(input)
82  {
83  if (parameters.numberOfHits == 0) {
85  }
86 
87  if (parameters.numberOfHits == 1) {
89  }
90 
92  }
93 
94 
95  /**
96  * Process trigger.
97  *
98  * \param input input data
99  * \param out output data
100  */
101  void operator()(const JTriggerInput& input, std::back_insert_iterator<JTriggerOutput> out) const
102  {
103  using std::distance;
104 
105  if (parameters.enabled && input.size() >= (size_t) parameters.numberOfHits) {
106 
107  match_type& match3D = *parameters.match3D;
108 
109  for (JTriggerInput::const_iterator p = input.begin(), q = p; p != input.end(); ) {
110 
111  for (++q; q->getT() - p->getT() < parameters.TMaxEvent_ns; ++q) {}
112 
113  if (distance (p,q) >= parameters.numberOfHits &&
115 
116  if (distance(p,q) < parameters.factoryLimit) {
117 
118  do {
119 
120  if (distance (p,q) >= parameters.numberOfHits &&
122 
123  // copy
124 
125  JTriggerInput::iterator root = buffer.begin();
126  JTriggerInput::iterator __p = buffer.begin();
127  JTriggerInput::iterator __q = buffer.begin();
128 
129  *root = *p;
130 
131  ++__p;
132  ++__q;
133 
134  for (JTriggerInput::const_iterator i = p; ++i != q; ) {
135  if (match3D(*p,*i)) {
136  *__q = *i;
137  ++__q;
138  }
139  }
140 
141  if (distance (root,__q) >= parameters.numberOfHits &&
143 
144  __q = clusterize(__p, __q, match3D, parameters.numberOfHits - 1);
145 
146  if (distance (root,__q) >= parameters.numberOfHits &&
148  *out = JEvent(input.getDAQChronometer(), root, __q, this->getTriggerBit());
149  ++out;
150  }
151  }
152  }
153 
154  ++p;
155 
156  } while (q->getT() - p->getT() >= parameters.TMaxEvent_ns);
157 
158  } else {
159 
160  // Anomalous large event
161 
162  JEvent event(input.getDAQChronometer(), p, q, this->getTriggerBit());
163 
164  event.addTriggerBit(FACTORY_LIMIT);
165 
166  *out = event;
167  ++out;
168 
169  p = q;
170  }
171 
172  } else {
173 
174  for (++p; q->getT() - p->getT() >= parameters.TMaxEvent_ns; ++p) {}
175  }
176  }
177  }
178  }
179 
180 
181 
183 
184  private:
186  };
187 }
188 
189 #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:32
void operator()(const JTriggerInput &input, std::back_insert_iterator< JTriggerOutput > out) const
Process trigger.
Definition: JTrigger3D.hh:101
std::vector< value_type > buffer
Definition: JTrigger3D.hh:185
JTrigger3D(const JParameters &input)
Constructor.
Definition: JTrigger3D.hh:80
JParameters parameters
Definition: JTrigger3D.hh:182
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:353
Auxiliary classes and methods for triggering.
static const struct JTRIGGER::clusterize clusterize
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:51
JLANG::JSharedPointer< match_type > JMatch_t
Definition: JTrigger3D.hh:39
static const int FACTORY_LIMIT
Bit indicating max nhits reached in trigger.
Definition: trigger.hh:16