Jpp master_rocky-44-g75b7c4f75
the software that should make you happy
Loading...
Searching...
No Matches
JTriggerMXShower.hh
Go to the documentation of this file.
1#ifndef __JTRIGGER__JTRIGGERMXSHOWER__
2#define __JTRIGGER__JTRIGGERMXSHOWER__
3
14#include "JMath/JMathToolkit.hh"
16
17
18/**
19 * \author mdejong
20 */
21
22namespace JTRIGGER {}
23namespace JPP { using namespace JTRIGGER; }
24
25namespace JTRIGGER {
26
31
32
33 /**
34 * Module attributes.
35 */
36 struct JAttributes {
37 double Tmin_ns; //!< minimal time difference [ns]
38 double Tmax_ns; //!< maximal time difference [ns]
39 };
40
41
42 /**
43 * Set module attributes.
44 *
45 * \param first first module
46 * \param second second module
47 * \param attributes module attributes
48 */
49 inline void setAttributes(const JModule& first,
50 const JModule& second,
51 JAttributes& attributes)
52 {
53 using namespace JPP;
54
55 typedef JTriggerMXShower_t::JParameters JParameters_t;
56
57 // get trigger parameters
58
59 const JParameters_t& parameters = JParametersHelper<JParameters_t>::getParameters();
60
61 const double d = getDistance(first.getPosition(), second.getPosition());
62
63 double t1 = 0.0;
64
65 if (d <= 0.5 * parameters.DMax_m)
66 t1 = d * getIndexOfRefraction() * getInverseSpeedOfLight() + parameters.TMaxExtra_ns;
67 else if (d <= parameters.DMax_m)
68 t1 = (parameters.DMax_m - d) * getIndexOfRefraction() * getInverseSpeedOfLight() + parameters.TMaxExtra_ns;
69
70 attributes.Tmin_ns = -t1;
71 attributes.Tmax_ns = +t1;
72 }
73
74
75 /**
76 * Shower trigger.
77 */
79 public JTriggerMXShower_t,
81 {
82 public:
83
84 /**
85 * Type definition of module mapper.
86 */
88
89
90 /**
91 * Constructor.
92 *
93 * \param input trigger parameters
94 * \param detector detector;
95 */
97 const JDetector& detector) :
98 parameters(input),
100 match(parameters.DMax_m, parameters.TMaxExtra_ns)
101 {
102 using namespace JPP;
103
105
106 if (parameters.numberOfHits == 0) {
107 parameters.numberOfHits = 1;
108 }
109
110 if (parameters.numberOfHits == 1) {
111 parameters.factoryLimit = 1;
112 }
113
114 if (parameters.numberOfModules < 1) {
115 parameters.numberOfModules = 1;
116 }
117 }
118
119
120 /**
121 * Process trigger.
122 *
123 * \param inputL1 input L1 data
124 * \param inputL0 input L0 data
125 * \param out output data
126 */
127 template<class JElement_t>
128 void operator()(const JTriggerInput& inputL1,
129 const JTimeslice<JElement_t> inputL0,
130 std::back_insert_iterator<JTriggerOutput> out) const
131 {
132 typedef JTimesliceClone<JElement_t> JTimeslice_t;
133 typedef typename JTimeslice_t::value_type JFrame_t;
134 typedef typename JModuleMapper_t::container_type container_type;
135
136 if (parameters.enabled) {
137
138 JTimeslice_t clone(inputL0, mapper);
139
140 for (JTriggerInput::const_iterator root = inputL1.begin(); root != inputL1.end(); ++root) {
141
142 buffer.clear();
143
144 const container_type& zip = mapper.getList(root->getModuleID());
145
146 for (typename container_type::const_iterator mod = zip.begin(); mod != zip.end(); ++mod) {
147
148 const double Tmin = root->getT() + mod->Tmin_ns;
149 const double Tmax = root->getT() + mod->Tmax_ns;
150
151 JFrame_t& frame = clone[mod->first];
152
153 if (!frame.empty()) {
154
155 frame.fast_forward(root->getT() - TMaxEvent_ns);
156
157 for (typename JFrame_t::const_iterator i = frame.get(); *i <= Tmax; ++i) {
158
159 if (*i >= Tmin) {
160 buffer.push_back(JHitR1(frame.getModuleID(),
161 frame.getPosition(),
162 frame.getJHit(*i)));
163 }
164 }
165 }
166 }
167
168 if (distance (buffer.begin(), buffer.end()) >= parameters.numberOfHits - 1 &&
169 getNumberOfModules(buffer.begin(), buffer.end()) >= parameters.numberOfModules - 1) {
170
171 if (distance(buffer.begin(), buffer.end()) < parameters.factoryLimit) {
172
173 JTriggerInput::iterator q = clusterize(buffer.begin(), buffer.end(), match, parameters.numberOfHits - 1);
174
175 if (distance (buffer.begin(), q) >= parameters.numberOfHits - 1 &&
176 getNumberOfModules(buffer.begin(), q) >= parameters.numberOfModules - 1) {
177 *out = JEvent(inputL1.getDAQChronometer(), *root, buffer.begin(), q, this->getTriggerBit());
178 ++out;
179 }
180
181 } else {
182
183 // Anomalous large event
184
185 JEvent event(inputL1.getDAQChronometer(), *root, buffer.begin(), buffer.end(), this->getTriggerBit());
186
187 event.addTriggerBit(FACTORY_LIMIT);
188
189 *out = event;
190 ++out;
191 }
192 }
193 }
194 }
195 }
196
197 private:
203 };
204}
205
206#endif
Algorithms for hit clustering and sorting.
Data structure for detector geometry and calibration.
Match operator for Cherenkov light from shower in any direction.
Auxiliary methods for geometrical methods.
Map of associated modules in detector.
Physics constants.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Detector data structure.
Definition JDetector.hh:96
Mapper for directly addressing of associated modules in the detector data structure.
const container_type & getList(const JObjectID &id) const
Get list with module data matching given module.
Data structure for a composite optical module.
Definition JModule.hh:75
const JPosition3D & getPosition() const
Get position.
Triggered event.
Data frame with end marker.
Definition JFrame_t.hh:30
Reduced data structure for L1 hit.
Definition JHitR1.hh:35
3G match criterion.
Definition JMatch3G.hh:31
Clone of JTimeslice.
Time slice with calibrated data.
Definition JTimeslice.hh:29
Data structure for input to trigger algorithm.
void operator()(const JTriggerInput &inputL1, const JTimeslice< JElement_t > inputL0, std::back_insert_iterator< JTriggerOutput > out) const
Process trigger.
JModuleMapper< JAttributes > JModuleMapper_t
Type definition of module mapper.
std::vector< JHitR1 > buffer
JParametersHelper< JParameters > parameters
JTriggerMXShower(const JParameters &input, const JDetector &detector)
Constructor.
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
double getIndexOfRefraction()
Get average index of refraction of water corresponding to group velocity.
const double getInverseSpeedOfLight()
Get inverse speed of light.
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.
void setAttributes(const JModule &first, const JModule &second, JAttributes &attributes)
Set module attributes.
Definition root.py:1
Detector file.
Definition JHead.hh:227
Auxiliary class to match modules according maximal distance.
Module attributes.
double Tmin_ns
minimal time difference [ns]
double Tmax_ns
maximal time difference [ns]
Wrapper class to share parameters.
static const JParameters_t & getParameters()
Get latest parameters.
Shower trigger parameters.
static const int FACTORY_LIMIT
Bit indicating max nhits reached in trigger.
Definition trigger.hh:16