Jpp
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"
11 #include "JGeometry3D/JVector3D.hh"
12 
13 
14 /**
15  * \file
16  *
17  * Basic data structure for L1 hit.
18  * \author mdejong
19  */
20 namespace JTRIGGER {}
21 namespace JPP { using namespace JTRIGGER; }
22 
23 namespace JTRIGGER {
24 
29 
30 
31  /**
32  * Data structure for L1 hit.
33  */
34  class JHitL1 :
35  public JDAQModuleIdentifier,
36  public std::vector<JHitL0>
37  {
38  public:
39  /**
40  * Default constructor.
41  */
42  JHitL1() :
44  std::vector<JHitL0>()
45  {}
46 
47 
48  /**
49  * Constructor.
50  *
51  * \param id module identifier
52  */
55  std::vector<JHitL0>()
56  {}
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->begin());
113  }
114 
115 
116  /**
117  * Type conversion operator.
118  *
119  * \return axis
120  */
121  operator const JAxis3D& () const
122  {
123  return *(this->begin());
124  }
125 
126 
127  /**
128  * Get position.
129  *
130  * \return position
131  */
132  const JPosition3D& getPosition() const
133  {
134  return this->begin()->getPosition();
135  }
136 
137 
138  /**
139  * Get x position.
140  * The x position is taken from the first L0 hit.
141  *
142  * \return x position [m]
143  */
144  inline double getX() const
145  {
146  return this->begin()->getX();
147  }
148 
149 
150  /**
151  * Get y position.
152  * The y position is taken from the first L0 hit.
153  *
154  * \return y position [m]
155  */
156  inline double getY() const
157  {
158  return this->begin()->getY();
159  }
160 
161 
162  /**
163  * Get z position.
164  * The z position is taken from the first L0 hit.
165  *
166  * \return z position [m]
167  */
168  inline double getZ() const
169  {
170  return this->begin()->getZ();
171  }
172 
173 
174  /**
175  * Get time of hit i.
176  * Note that the time is corrected for the average time slewing.
177  *
178  * \param i index
179  * \return time [ns]
180  */
181  inline double getT(const unsigned int i) const
182  {
183  static const double t0 = 1.29; // [ns]
184 
185  return at(i).getT() - t0;
186  }
187 
188 
189  /**
190  * Get time.
191  * The time is taken from the first L0 hit corrected for time slewing.
192  *
193  * \return time [ns]
194  */
195  inline double getT() const
196  {
197  static std::vector<double> t0;
198 
199  if (t0.empty()) {
200 
201  t0.push_back(+0.00);
202  t0.push_back(+0.39);
203  t0.push_back(+0.21);
204  t0.push_back(-0.59);
205  t0.push_back(-1.15);
206  t0.push_back(-1.59);
207  t0.push_back(-1.97);
208  t0.push_back(-2.30);
209  t0.push_back(-2.56);
210  t0.push_back(-2.89);
211  t0.push_back(-3.12);
212  t0.push_back(-3.24);
213  t0.push_back(-3.56);
214  t0.push_back(-3.69);
215  t0.push_back(-4.00);
216  t0.push_back(-4.10);
217  t0.push_back(-4.16);
218  t0.push_back(-4.49);
219  t0.push_back(-4.71);
220  t0.push_back(-4.77);
221  t0.push_back(-4.81);
222  t0.push_back(-4.87);
223  t0.push_back(-4.88);
224  t0.push_back(-4.83);
225  t0.push_back(-5.21);
226  t0.push_back(-5.06);
227  t0.push_back(-5.27);
228  t0.push_back(-5.18);
229  t0.push_back(-5.24);
230  t0.push_back(-5.79);
231  t0.push_back(-6.78);
232  t0.push_back(-6.24);
233  }
234 
235  if (this->size() >= t0.size())
236  return this->begin()->getT() - t0.back();
237  else
238  return this->begin()->getT() - t0[this->size()];
239  }
240 
241 
242  /**
243  * Get overall time over threshold.
244  *
245  * \return time over threshold [ns]
246  */
247  inline double getToT() const
248  {
249  return JHit(this->begin(), this->end()).getToT();
250  }
251 
252 
253  /**
254  * Get weight.
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 #endif
JTRIGGER::JHitL1::transform_back
void transform_back(const JRotation3D &R, const JVector3D &pos)
Transform back hit.
Definition: JHitL1.hh:350
JVector3D.hh
JTRIGGER::JHitL1::add
JHitL1 & add(const JVector3D &pos)
Add position.
Definition: JHitL1.hh:271
JTRIGGER::JHitL1::getZ
double getZ() const
Get z position.
Definition: JHitL1.hh:168
JTRIGGER::JHitL1::getToT
double getToT() const
Get overall time over threshold.
Definition: JHitL1.hh:247
JGEOMETRY3D::JAxis3D
Axis object.
Definition: JAxis3D.hh:38
JTRIGGER::JHitL1::JHitL1
JHitL1(const JHitL0 &hit)
Constructor.
Definition: JHitL1.hh:64
JTRIGGER::JHitL1::getT
double getT() const
Get time.
Definition: JHitL1.hh:195
std::vector
Definition: JSTDTypes.hh:12
JTRIGGER::JHitL1::getX
double getX() const
Get x position.
Definition: JHitL1.hh:144
KM3NETDAQ::JDAQModuleIdentifier::id
int id
Definition: JDAQModuleIdentifier.hh:153
JTRIGGER::JHitL1::getT
double getT(const unsigned int i) const
Get time of hit i.
Definition: JHitL1.hh:181
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
KM3NETDAQ::JDAQModuleIdentifier::getModuleIdentifier
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
Definition: JDAQModuleIdentifier.hh:50
JTRIGGER::JHitL1::sort
const JHitL1 & sort()
Sort L0 hits.
Definition: JHitL1.hh:97
JTRIGGER::JHitL1::getW
double getW() const
Get weight.
Definition: JHitL1.hh:259
JGEOMETRY3D::JVector3D
Data structure for vector in three dimensions.
Definition: JVector3D.hh:33
JTRIGGER::JHitL1::sub
JHitL1 & sub(const JVector3D &pos)
Subtract position.
Definition: JHitL1.hh:287
JGEOMETRY3D::JPosition3D
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
JHit.hh
KM3NETDAQ::JDAQModuleIdentifier
Module identifier.
Definition: JDAQModuleIdentifier.hh:24
JGEOMETRY3D::JPosition3D::getPosition
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:129
JTRIGGER::JHitL0
Data structure for L0 hit.
Definition: JHitL0.hh:27
std
Definition: jaanetDictionary.h:36
JRotation3D.hh
JTRIGGER::JHitL1::JHitL1
JHitL1(const JDAQModuleIdentifier &id, T __begin, T __end)
Constructor.
Definition: JHitL1.hh:78
JTRIGGER::JHit
Hit data structure.
Definition: JHit.hh:22
JTRIGGER::JHitL1::getPosition
const JPosition3D & getPosition() const
Get position.
Definition: JHitL1.hh:132
JDAQModuleIdentifier.hh
JTRIGGER
Checksum.
Definition: JSupport/JSupport.hh:35
JTRIGGER::JHitL1::JHitL1
JHitL1()
Default constructor.
Definition: JHitL1.hh:42
JHitL0.hh
JTRIGGER::JHitL1::rotate_back
JHitL1 & rotate_back(const JRotation3D &R)
Rotate back hit.
Definition: JHitL1.hh:319
JTRIGGER::JHitL1
Data structure for L1 hit.
Definition: JHitL1.hh:34
JGEOMETRY3D::JRotation3D
Rotation matrix.
Definition: JRotation3D.hh:111
JTRIGGER::JHit::getToT
double getToT() const
Get calibrated time over threshold of hit.
Definition: JHit.hh:157
JTRIGGER::JHitL1::transform
void transform(const JRotation3D &R, const JVector3D &pos)
Transform hit.
Definition: JHitL1.hh:335
JTRIGGER::JHitL1::JHitL1
JHitL1(const JDAQModuleIdentifier &id)
Constructor.
Definition: JHitL1.hh:53
JTRIGGER::JHitL1::rotate
JHitL1 & rotate(const JRotation3D &R)
Rotate hit.
Definition: JHitL1.hh:303
JTRIGGER::JHitL1::getY
double getY() const
Get y position.
Definition: JHitL1.hh:156