Jpp  pmt_effective_area_update
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 count.
255  *
256  * \return count
257  */
258  inline int getN() const
259  {
260  return this->size();
261  }
262 
263 
264  /**
265  * Get weight.\n
266  * The weight is equal to the number of L0 hits.
267  *
268  * \return weight
269  */
270  inline double getW() const
271  {
272  return this->size();
273  }
274 
275 
276  /**
277  * Add position.
278  *
279  * \param pos position
280  * \return this hit
281  */
282  JHitL1& add(const JVector3D& pos)
283  {
284  for (iterator i = this->begin(); i != this->end(); ++i) {
285  i->add(pos);
286  }
287 
288  return *this;
289  }
290 
291 
292  /**
293  * Subtract position.
294  *
295  * \param pos position
296  * \return this hit
297  */
298  JHitL1& sub(const JVector3D& pos)
299  {
300  for (iterator i = this->begin(); i != this->end(); ++i) {
301  i->sub(pos);
302  }
303 
304  return *this;
305  }
306 
307 
308  /**
309  * Rotate hit.
310  *
311  * \param R rotation matrix
312  * \return this hit
313  */
315  {
316  for (iterator i = this->begin(); i != this->end(); ++i) {
317  i->rotate(R);
318  }
319 
320  return *this;
321  }
322 
323 
324  /**
325  * Rotate back hit.
326  *
327  * \param R rotation matrix
328  * \return this hit
329  */
331  {
332  for (iterator i = this->begin(); i != this->end(); ++i) {
333  i->rotate_back(R);
334  }
335 
336  return *this;
337  }
338 
339 
340  /**
341  * Transform hit.
342  *
343  * \param R rotation matrix
344  * \param pos position of origin (after rotation)
345  */
346  void transform(const JRotation3D& R,
347  const JVector3D& pos)
348  {
349  for (iterator i = this->begin(); i != this->end(); ++i) {
350  i->transform(R, pos);
351  }
352  }
353 
354 
355  /**
356  * Transform back hit.
357  *
358  * \param R rotation matrix
359  * \param pos position of origin (before rotation)
360  */
362  const JVector3D& pos)
363  {
364  for (iterator i = this->begin(); i != this->end(); ++i) {
365  i->transform_back(R, pos);
366  }
367  }
368  };
369 }
370 
371 #endif
double getY() const
Get y position.
Definition: JHitL1.hh:156
Data structure for L1 hit.
Definition: JHitL1.hh:34
void transform_back(const JRotation3D &R, const JVector3D &pos)
Transform back hit.
Definition: JHitL1.hh:361
JHitL1(const JDAQModuleIdentifier &id)
Constructor.
Definition: JHitL1.hh:53
Rotation matrix.
Definition: JRotation3D.hh:111
double getT(const unsigned int i) const
Get time of hit i.
Definition: JHitL1.hh:181
Hit data structure.
JHitL1()
Default constructor.
Definition: JHitL1.hh:42
const JPosition3D & getPosition() const
Get position.
Definition: JHitL1.hh:132
Basic data structure for time and time over threshold information of hit.
int getN() const
Get count.
Definition: JHitL1.hh:258
Basic data structure for L0 hit.
Axis object.
Definition: JAxis3D.hh:38
double getToT() const
Get calibrated time over threshold of hit.
void transform(const JRotation3D &R, const JVector3D &pos)
Transform hit.
Definition: JHitL1.hh:346
Data structure for vector in three dimensions.
Definition: JVector3D.hh:34
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JHitL1(const JHitL0 &hit)
Constructor.
Definition: JHitL1.hh:64
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
double getW() const
Get weight.
Definition: JHitL1.hh:270
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:43
double getZ() const
Get z position.
Definition: JHitL1.hh:168
Data structure for L0 hit.
Definition: JHitL0.hh:27
const JHitL1 & sort()
Sort L0 hits.
Definition: JHitL1.hh:97
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
JHitL1(const JDAQModuleIdentifier &id, T __begin, T __end)
Constructor.
Definition: JHitL1.hh:78
double getX() const
Get x position.
Definition: JHitL1.hh:144
JHitL1 & rotate(const JRotation3D &R)
Rotate hit.
Definition: JHitL1.hh:314
double getToT() const
Get overall time over threshold.
Definition: JHitL1.hh:247
JHitL1 & rotate_back(const JRotation3D &R)
Rotate back hit.
Definition: JHitL1.hh:330
double getT() const
Get time.
Definition: JHitL1.hh:195
JHitL1 & add(const JVector3D &pos)
Add position.
Definition: JHitL1.hh:282
JHitL1 & sub(const JVector3D &pos)
Subtract position.
Definition: JHitL1.hh:298