Jpp  18.5.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JHitR1.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JHITR1__
2 #define __JTRIGGER__JHITR1__
3 
6 #include "JTrigger/JHit.hh"
7 #include "JTrigger/JHitL0.hh"
8 #include "JTrigger/JHitL1.hh"
10 
11 
12 /**
13  * \file
14  *
15  * Reduced data structure for L1 hit.
16  * \author mdejong
17  */
18 namespace JTRIGGER {}
19 namespace JPP { using namespace JTRIGGER; }
20 
21 namespace JTRIGGER {
22 
26 
27 
28  /**
29  * Reduced data structure for L1 hit.
30  */
31  class JHitR1 :
32  public JDAQModuleIdentifier,
33  public JPosition3D,
34  public JHit
35  {
36  public:
37  /**
38  * Default constructor.
39  */
40  JHitR1() :
42  JPosition3D (),
43  JHit(),
44  __n (0),
45  __w (0.0)
46  {}
47 
48 
49  /**
50  * Constructor.
51  *
52  * \param id module identifier
53  * \param pos position
54  */
56  const JPosition3D& pos) :
58  JPosition3D (pos),
59  JHit(),
60  __n (0),
61  __w (0.0)
62  {}
63 
64 
65  /**
66  * Constructor.
67  *
68  * \param id module identifier
69  * \param pos position
70  * \param hit hit
71  * \param weight weight
72  */
74  const JPosition3D& pos,
75  const JHit& hit,
76  const double weight = 1.0) :
78  JPosition3D (pos),
79  JHit(hit),
80  __n (1),
81  __w (weight)
82  {}
83 
84 
85  /**
86  * Constructor.
87  *
88  * \param hit hit
89  * \param weight weight
90  */
91  JHitR1(const JHitL0& hit,
92  const double weight = 1.0) :
94  JPosition3D (hit.getPosition()),
95  JHit (hit.getHit()),
96  __n (1),
97  __w (weight)
98  {}
99 
100 
101  /**
102  * Constructor.
103  *
104  * \param hit hit
105  */
106  JHitR1(const JHitL1& hit) :
108  JPosition3D (hit.getPosition()),
109  JHit(hit.getT(), hit.getToT()),
110  __n (hit.size()),
111  __w (hit.getW())
112  {}
113 
114 
115  /**
116  * Set hit.
117  *
118  * Note that:
119  * - JHitR1::count is set to one;
120  * - JHitR1::weight is set to given <tt>weight</tt>;
121  *
122  * \param hit hit
123  * \param weight weight
124  */
125  void set(const JHit& hit,
126  const double weight = 1.0)
127  {
128  static_cast<JHit&>(*this) = hit;
129 
130  this->__n = 1;
131  this->__w = weight;
132  }
133 
134 
135  /**
136  * Add hit.
137  *
138  * Note that:
139  * - time of this hit is set to the earliest leading edge of the two hits;
140  * - time over threshold is set to the difference between the latest trailing and earliest leading edge of two hits;
141  * - JHitR1::count is incremented by one;
142  * - JHitR1::weight is incremented by given <tt>weight</tt>;
143  *
144  * \param hit hit
145  * \param weight weight
146  * \return this hit
147  */
148  JHitR1& add(const JHit& hit,
149  const double weight = 1.0)
150  {
151  double t1 = this->t;
152  double t2 = this->t + this->tot;
153 
154  if (t1 > hit.getT()) { t1 = hit.getT(); }
155  if (t2 < hit.getT() + hit.getToT()) { t2 = hit.getT() + hit.getToT(); }
156 
157  this->t = t1;
158  this->tot = t2 - t1;
159  this->__n += 1;
160  this->__w += weight;
161 
162  return static_cast<JHitR1&>(*this);
163  }
164 
165 
166  /**
167  * Get PMT identifier.
168  * Note that the PMT address is set to -1.
169  *
170  * \return PMT identifier
171  */
173  {
174  return JDAQPMTIdentifier(this->getModuleIdentifier(), -1);
175  }
176 
177 
178  /**
179  * Get count.
180  *
181  * \return count
182  */
183  inline int getN() const
184  {
185  return __n;
186  }
187 
188 
189  /**
190  * Get weight.
191  *
192  * \return weight
193  */
194  inline double getW() const
195  {
196  return __w;
197  }
198 
199 
200  /**
201  * Auxiliary data structure for sorting of hits.
202  */
203  static const struct compare {
204  /**
205  * Compare hits by module identifier and time.
206  *
207  * \param first first hit
208  * \param second second hit
209  * \return true if first before second; else false
210  */
211  bool operator()(const JHitR1& first, const JHitR1& second) const
212  {
213  if (first.getModuleID() == second.getModuleID())
214  return first.getT() < second.getT();
215  else
216  return first.getModuleID() < second.getModuleID();
217  }
218  } compare;
219 
220 
221  protected:
222  int __n;
223  double __w;
224  };
225 }
226 
227 #endif
double getT() const
Get calibrated time of hit.
JHitR1(const JDAQModuleIdentifier &id, const JPosition3D &pos)
Constructor.
Definition: JHitR1.hh:55
int getModuleID() const
Get module identifier.
JHitR1(const JHitL0 &hit, const double weight=1.0)
Constructor.
Definition: JHitR1.hh:91
Data structure for L1 hit.
Definition: JHitL1.hh:34
JHitR1()
Default constructor.
Definition: JHitR1.hh:40
Hit data structure.
Basic data structure for time and time over threshold information of hit.
bool operator()(const JHitR1 &first, const JHitR1 &second) const
Compare hits by module identifier and time.
Definition: JHitR1.hh:211
double t
time of leading edge [ns]
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
static struct JTRIGGER::JHitR1::compare compare
Basic data structure for L0 hit.
double getToT() const
Get calibrated time over threshold of hit.
JHitR1(const JHitL1 &hit)
Constructor.
Definition: JHitR1.hh:106
void set(const JHit &hit, const double weight=1.0)
Set hit.
Definition: JHitR1.hh:125
const JHit & getHit() const
Get hit.
Auxiliary data structure for sorting of hits.
Definition: JHitR1.hh:203
JDAQPMTIdentifier getPMTIdentifier() const
Get PMT identifier.
Definition: JHitR1.hh:172
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
JHitR1 & add(const JHit &hit, const double weight=1.0)
Add hit.
Definition: JHitR1.hh:148
Data structure for L0 hit.
Definition: JHitL0.hh:27
Reduced data structure for L1 hit.
Definition: JHitR1.hh:31
double getW() const
Get weight.
Definition: JHitR1.hh:194
Data structure for position in three dimensions.
Definition: JPosition3D.hh:36
int getN() const
Get count.
Definition: JHitR1.hh:183
const JDAQModuleIdentifier & getModuleIdentifier() const
Get Module identifier.
double tot
time-over-threshold [ns]
JHitR1(const JDAQModuleIdentifier &id, const JPosition3D &pos, const JHit &hit, const double weight=1.0)
Constructor.
Definition: JHitR1.hh:73
Basic data structure for L1 hit.