Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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 */
18namespace JTRIGGER {}
19namespace JPP { using namespace JTRIGGER; }
20
21namespace JTRIGGER {
22
26
27
28 /**
29 * Reduced data structure for L1 hit.
30 */
31 class JHitR1 :
33 public JPosition3D,
34 public JHit
35 {
36 public:
37 /**
38 * Default constructor.
39 */
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) :
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 }
219
220
221 protected:
222 int __n;
223 double __w;
224 };
225}
226
227#endif
Basic data structure for L0 hit.
Basic data structure for L1 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 L0 hit.
Definition JHitL0.hh:31
Data structure for L1 hit.
Definition JHitL1.hh:37
Reduced data structure for L1 hit.
Definition JHitR1.hh:35
JHitR1()
Default constructor.
Definition JHitR1.hh:40
JHitR1(const JHitL0 &hit, const double weight=1.0)
Constructor.
Definition JHitR1.hh:91
JHitR1(const JDAQModuleIdentifier &id, const JPosition3D &pos)
Constructor.
Definition JHitR1.hh:55
double getW() const
Get weight.
Definition JHitR1.hh:194
JDAQPMTIdentifier getPMTIdentifier() const
Get PMT identifier.
Definition JHitR1.hh:172
void set(const JHit &hit, const double weight=1.0)
Set hit.
Definition JHitR1.hh:125
JHitR1 & add(const JHit &hit, const double weight=1.0)
Add hit.
Definition JHitR1.hh:148
static const struct JTRIGGER::JHitR1::compare compare
JHitR1(const JHitL1 &hit)
Constructor.
Definition JHitR1.hh:106
int getN() const
Get count.
Definition JHitR1.hh:183
JHitR1(const JDAQModuleIdentifier &id, const JPosition3D &pos, const JHit &hit, const double weight=1.0)
Constructor.
Definition JHitR1.hh:73
Hit data structure.
const JHit & getHit() const
Get hit.
double t
time of leading edge [ns]
double tot
time-over-threshold [ns]
double getToT() const
Get calibrated time over threshold of hit.
double getT() const
Get calibrated time 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 JHitR1.hh:203
bool operator()(const JHitR1 &first, const JHitR1 &second) const
Compare hits by module identifier and time.
Definition JHitR1.hh:211