Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JHitL1.hh
Go to the documentation of this file.
1#ifndef __JTRIGGER__JHITL1__
2#define __JTRIGGER__JHITL1__
3
4#include <vector>
5#include <algorithm>
6
8#include "JTrigger/JHit.hh"
9#include "JTrigger/JHitL0.hh"
12
13
14/**
15 * \file
16 *
17 * Basic data structure for L1 hit.
18 * \author mdejong
19 */
20namespace JTRIGGER {}
21namespace JPP { using namespace JTRIGGER; }
22
23namespace JTRIGGER {
24
29
30
31 /**
32 * Data structure for L1 hit.
33 */
34 class JHitL1 :
36 public std::vector<JHitL0>
37 {
38 public:
39 /**
40 * Default constructor.
41 */
46
47
48 /**
49 * Constructor.
50 *
51 * \param id module identifier
52 */
57
58
59 /**
60 * Constructor.
61 *
62 * \param hit hit
63 */
64 JHitL1(const JHitL0& hit) :
66 std::vector<JHitL0>(1, hit)
67 {}
68
69
70 /**
71 * Constructor.
72 *
73 * \param id module identifier
74 * \param __begin begin of L0 hits
75 * \param __end end of L0 hits
76 */
77 template<class T>
79 T __begin,
80 T __end) :
82 {
83 for (T i = __begin; i != __end; ++i) {
84 this->push_back(*i);
85 }
86
87 this->sort();
88 }
89
90
91 /**
92 * Sort L0 hits.
93 * Following the default sort operation, the time slewing implemented in method getT() is applicaple.
94 *
95 * \return this hit
96 */
97 const JHitL1& sort()
98 {
99 std::sort(this->begin(), this->end(), std::less<JHit>());
100
101 return *this;
102 }
103
104
105 /**
106 * Type conversion operator.
107 *
108 * \return position
109 */
110 operator const JPosition3D& () const
111 {
112 return this->getPosition();
113 }
114
115
116 /**
117 * Get position.
118 *
119 * \return position
120 */
122 {
123 return this->begin()->getPosition();
124 }
125
126
127 /**
128 * Get x position.
129 * The x position is taken from the first L0 hit.
130 *
131 * \return x position [m]
132 */
133 inline double getX() const
134 {
135 return this->begin()->getX();
136 }
137
138
139 /**
140 * Get y position.
141 * The y position is taken from the first L0 hit.
142 *
143 * \return y position [m]
144 */
145 inline double getY() const
146 {
147 return this->begin()->getY();
148 }
149
150
151 /**
152 * Get z position.
153 * The z position is taken from the first L0 hit.
154 *
155 * \return z position [m]
156 */
157 inline double getZ() const
158 {
159 return this->begin()->getZ();
160 }
161
162
163 /**
164 * Get time of hit i.
165 * Note that the time is corrected for the average time slewing.
166 *
167 * \param i index
168 * \return time [ns]
169 */
170 inline double getT(const unsigned int i) const
171 {
172 static const double t0 = 1.29; // [ns]
173
174 return at(i).getT() - t0;
175 }
176
177
178 /**
179 * Get time.
180 * The time is taken from the first L0 hit corrected for time slewing.
181 *
182 * \return time [ns]
183 */
184 inline double getT() const
185 {
186 static std::vector<double> t0;
187
188 if (t0.empty()) {
189
190 t0.push_back(+0.00);
191 t0.push_back(+0.39);
192 t0.push_back(+0.21);
193 t0.push_back(-0.59);
194 t0.push_back(-1.15);
195 t0.push_back(-1.59);
196 t0.push_back(-1.97);
197 t0.push_back(-2.30);
198 t0.push_back(-2.56);
199 t0.push_back(-2.89);
200 t0.push_back(-3.12);
201 t0.push_back(-3.24);
202 t0.push_back(-3.56);
203 t0.push_back(-3.69);
204 t0.push_back(-4.00);
205 t0.push_back(-4.10);
206 t0.push_back(-4.16);
207 t0.push_back(-4.49);
208 t0.push_back(-4.71);
209 t0.push_back(-4.77);
210 t0.push_back(-4.81);
211 t0.push_back(-4.87);
212 t0.push_back(-4.88);
213 t0.push_back(-4.83);
214 t0.push_back(-5.21);
215 t0.push_back(-5.06);
216 t0.push_back(-5.27);
217 t0.push_back(-5.18);
218 t0.push_back(-5.24);
219 t0.push_back(-5.79);
220 t0.push_back(-6.78);
221 t0.push_back(-6.24);
222 }
223
224 if (this->size() >= t0.size())
225 return this->begin()->getT() - t0.back();
226 else
227 return this->begin()->getT() - t0[this->size()];
228 }
229
230
231 /**
232 * Get overall time over threshold.
233 *
234 * \return time over threshold [ns]
235 */
236 inline double getToT() const
237 {
238 return JHit(this->begin(), this->end()).getToT();
239 }
240
241
242 /**
243 * Get count.
244 *
245 * \return count
246 */
247 inline int getN() const
248 {
249 return this->size();
250 }
251
252
253 /**
254 * Get weight.\n
255 * The weight is equal to the number of L0 hits.
256 *
257 * \return weight
258 */
259 inline double getW() const
260 {
261 return this->size();
262 }
263
264
265 /**
266 * Add position.
267 *
268 * \param pos position
269 * \return this hit
270 */
271 JHitL1& add(const JVector3D& pos)
272 {
273 for (iterator i = this->begin(); i != this->end(); ++i) {
274 i->add(pos);
275 }
276
277 return *this;
278 }
279
280
281 /**
282 * Subtract position.
283 *
284 * \param pos position
285 * \return this hit
286 */
287 JHitL1& sub(const JVector3D& pos)
288 {
289 for (iterator i = this->begin(); i != this->end(); ++i) {
290 i->sub(pos);
291 }
292
293 return *this;
294 }
295
296
297 /**
298 * Rotate hit.
299 *
300 * \param R rotation matrix
301 * \return this hit
302 */
304 {
305 for (iterator i = this->begin(); i != this->end(); ++i) {
306 i->rotate(R);
307 }
308
309 return *this;
310 }
311
312
313 /**
314 * Rotate back hit.
315 *
316 * \param R rotation matrix
317 * \return this hit
318 */
320 {
321 for (iterator i = this->begin(); i != this->end(); ++i) {
322 i->rotate_back(R);
323 }
324
325 return *this;
326 }
327
328
329 /**
330 * Transform hit.
331 *
332 * \param R rotation matrix
333 * \param pos position of origin (after rotation)
334 */
335 void transform(const JRotation3D& R,
336 const JVector3D& pos)
337 {
338 for (iterator i = this->begin(); i != this->end(); ++i) {
339 i->transform(R, pos);
340 }
341 }
342
343
344 /**
345 * Transform back hit.
346 *
347 * \param R rotation matrix
348 * \param pos position of origin (before rotation)
349 */
351 const JVector3D& pos)
352 {
353 for (iterator i = this->begin(); i != this->end(); ++i) {
354 i->transform_back(R, pos);
355 }
356 }
357
358
359 /**
360 * Auxiliary data structure for sorting of hits.
361 */
362 static const struct compare {
363 /**
364 * Compare hits by module identifier and time.
365 *
366 * \param first first hit
367 * \param second second hit
368 * \return true if first before second; else false
369 */
370 bool operator()(const JHitL1& first, const JHitL1& second) const
371 {
372 if (first.getModuleID() == second.getModuleID())
373 return first.getT() < second.getT();
374 else
375 return first.getModuleID() < second.getModuleID();
376 }
378 };
379}
380
381#endif
Basic data structure for L0 hit.
Basic data structure for time and time over threshold information of hit.
Data structure for position in three dimensions.
const JPosition3D & getPosition() const
Get position.
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
Data structure for L0 hit.
Definition JHitL0.hh:31
Data structure for L1 hit.
Definition JHitL1.hh:37
JHitL1 & rotate_back(const JRotation3D &R)
Rotate back hit.
Definition JHitL1.hh:319
double getToT() const
Get overall time over threshold.
Definition JHitL1.hh:236
const JPosition3D & getPosition() const
Get position.
Definition JHitL1.hh:121
JHitL1(const JHitL0 &hit)
Constructor.
Definition JHitL1.hh:64
double getT() const
Get time.
Definition JHitL1.hh:184
double getZ() const
Get z position.
Definition JHitL1.hh:157
JHitL1(const JDAQModuleIdentifier &id, T __begin, T __end)
Constructor.
Definition JHitL1.hh:78
double getW() const
Get weight.
Definition JHitL1.hh:259
JHitL1(const JDAQModuleIdentifier &id)
Constructor.
Definition JHitL1.hh:53
double getY() const
Get y position.
Definition JHitL1.hh:145
static const struct JTRIGGER::JHitL1::compare compare
JHitL1 & sub(const JVector3D &pos)
Subtract position.
Definition JHitL1.hh:287
JHitL1()
Default constructor.
Definition JHitL1.hh:42
void transform_back(const JRotation3D &R, const JVector3D &pos)
Transform back hit.
Definition JHitL1.hh:350
double getT(const unsigned int i) const
Get time of hit i.
Definition JHitL1.hh:170
JHitL1 & add(const JVector3D &pos)
Add position.
Definition JHitL1.hh:271
void transform(const JRotation3D &R, const JVector3D &pos)
Transform hit.
Definition JHitL1.hh:335
int getN() const
Get count.
Definition JHitL1.hh:247
const JHitL1 & sort()
Sort L0 hits.
Definition JHitL1.hh:97
double getX() const
Get x position.
Definition JHitL1.hh:133
JHitL1 & rotate(const JRotation3D &R)
Rotate hit.
Definition JHitL1.hh:303
Hit data structure.
double getToT() const
Get calibrated time over threshold of hit.
int getModuleID() const
Get module identifier.
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for triggering.
Auxiliary data structure for sorting of hits.
Definition JHitL1.hh:362
bool operator()(const JHitL1 &first, const JHitL1 &second) const
Compare hits by module identifier and time.
Definition JHitL1.hh:370