Jpp 20.0.0-rc.8
the software that should make you happy
Loading...
Searching...
No Matches
JPMTSimulator.hh
Go to the documentation of this file.
1#ifndef __JDETECTOR__JPMTSIMULATOR__
2#define __JDETECTOR__JPMTSIMULATOR__
3
4#include <vector>
5#include <algorithm>
6#include <limits>
7
8#include "JLang/JStatus.hh"
9
13
14
15/**
16 * \author mdejong
17 */
18
19namespace JDETECTOR {}
20namespace JPP { using namespace JDETECTOR; }
21
22namespace JDETECTOR {
23
24 using JLANG::JStatus;
25
26
27 /**
28 * Data structure for single photo-electron.
29 */
31 /**
32 * Default constructor.
33 */
35 t_ns(0.0)
36 {}
37
38
39 /**
40 * Constructor.
41 *
42 * \param __t_ns time [ns]
43 */
44 JPhotoElectron(const double __t_ns) :
45 t_ns(__t_ns)
46 {}
47
48
49 /**
50 * Get end marker.
51 *
52 * \return latest possible photo-electron
53 */
55 {
56 return JPhotoElectron(std::numeric_limits<double>::max());
57 }
58
59
60 double t_ns; //!< time [ns]
61 };
62
63
64 /**
65 * Less than operator for photo-elecrons.
66 *
67 * \param first first photo-electron
68 * \param second second photo-electron
69 * \return true if first photo-electron earlier than second; else false
70 */
71 inline bool operator<(const JPhotoElectron& first, const JPhotoElectron& second)
72 {
73 return first.t_ns < second.t_ns;
74 }
75
76
77 /**
78 * Data structure for PMT analogue signal.
79 */
80 struct JPMTSignal {
81 /**
82 * Default constructor.
83 */
85 t_ns(0.0),
86 npe (0)
87 {}
88
89
90 /**
91 * Constructor.
92 *
93 * \param __t_ns time [ns]
94 * \param __npe number of photo-electrons
95 */
96 JPMTSignal(const double __t_ns,
97 const int __npe) :
98 t_ns(__t_ns),
99 npe (__npe)
100 {}
101
102
103 double t_ns; //!< time [ns]
104 int npe; //!< number of photo-electrons
105 };
106
107
108 /**
109 * Less than operator for PMT signals.
110 *
111 * \param first first PMT signal
112 * \param second second PMT signal
113 * \return true if first PMT signal earlier than second; else false
114 */
115 inline bool operator<(const JPMTSignal& first, const JPMTSignal& second)
116 {
117 return first.t_ns < second.t_ns;
118 }
119
120
121 /**
122 * Data structure for PMT digital pulse.
123 */
124 struct JPMTPulse {
125 /**
126 * Default constructor.
127 */
129 t_ns (0.0),
130 tot_ns(0.0)
131 {}
132
133
134 /**
135 * Constructor.
136 *
137 * \param __t_ns time [ns]
138 * \param __tot_ns time-over-threshold [ns]
139 */
140 JPMTPulse(const double __t_ns,
141 const double __tot_ns) :
142 t_ns (__t_ns),
143 tot_ns(__tot_ns)
144 {}
145
146
147 double t_ns; //!< time [ns]
148 double tot_ns; //!< time-over-threshold [ns]
149 };
150
151
152 /**
153 * Less than operator for PMT pulses.
154 *
155 * \param first first PMT pulse
156 * \param second second PMT pulse
157 * \return true if first PMT pulse earlier than second; else false
158 */
159 inline bool operator<(const JPMTPulse& first, const JPMTPulse& second)
160 {
161 return first.t_ns < second.t_ns;
162 }
163
164
165 /**
166 * Template data structure for PMT I/O.
167 */
168 template<class JElement_t>
169 class JPMTData :
170 public std::vector<JElement_t>
171 {
172 public:
173
175 typedef typename std::vector<JElement_t>::const_iterator const_iterator;
177 typedef typename std::vector<JElement_t>::const_reverse_iterator const_reverse_iterator;
178
179
180 /**
181 * Default constructor.
182 */
184 std::vector<JElement_t>()
185 {}
186
187
188 /**
189 * Sort.
190 */
191 void sort()
192 {
193 std::sort(this->begin(), this->end());
194 }
195
196
197 /**
198 * Insert element whilst maintaining order.
199 *
200 * \param element element
201 */
202 void insert(const JElement_t& element)
203 {
204 iterator i = std::lower_bound(this->begin(), this->end(), element);
205
207 }
208 };
209
210
211
212 /**
213 * Data structure for PMT data corresponding to a detector module.
214 */
216 public std::vector< JPMTData<JPMTSignal> >
217 {
218 public:
219 /**
220 * Default constructor.
221 */
223 std::vector< JPMTData<JPMTSignal> >()
224 {}
225
226
227 /**
228 * Reset buffers.
229 *
230 * \param size number of buffers
231 */
232 void reset(size_t size)
233 {
234 this->resize(size);
235
236 for (iterator i = this->begin(); i != this->end(); ++i) {
237 i->clear();
238 }
239 }
240 };
241
242
243 /**
244 * Interface for PMT simulation.
245 * The input buffer consists of a sorted array of PMT analogue signals JDETECTOR::JPMTSignal and
246 * the output of an array of PMT digital pulses JDETECTOR::JPMTPulse.
247 */
249 protected:
250 /**
251 * Default constructor.
252 */
255
256
257 public:
258 /**
259 * Virtual destructor.
260 */
262 {}
263
264
265 /**
266 * Process hits.
267 *
268 * \param id PMT identifier
269 * \param calibration PMT calibration
270 * \param status PMT status
271 * \param input PMT signals
272 * \param output PMT pulses
273 */
274 virtual void processHits(const JPMTIdentifier& id,
275 const JCalibration& calibration,
276 const JStatus& status,
277 const JPMTData<JPMTSignal>& input,
278 JPMTData<JPMTPulse>& output) const = 0;
279 };
280
281
282 /**
283 * Get time range (i.e.\ earliest and latest hit time) of PMT data.
284 *
285 * \param input PMT data
286 * \return time range
287 */
288 template<class T>
290 {
292
293 for (typename JPMTData<T>::const_iterator hit = input.begin(); hit != input.end(); ++hit) {
294 range.include(hit->t_ns);
295 }
296
297 return range;
298 }
299
300
301 /**
302 * Get time range (i.e.\ earlist and latest hit time) of module data.
303 *
304 * \param input module data
305 * \return time range
306 */
308 {
310
311 for (JModuleData::const_iterator frame = input.begin(); frame != input.end(); ++frame) {
312 for (JModuleData::value_type::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
313 range.include(hit->t_ns);
314 }
315 }
316
317 return range;
318 }
319}
320
321#endif
Time calibration (including definition of sign of time offset).
Data structure for time calibration.
Data structure for PMT data corresponding to a detector module.
JModuleData()
Default constructor.
void reset(size_t size)
Reset buffers.
Template data structure for PMT I/O.
std::vector< JElement_t >::iterator iterator
std::vector< JElement_t >::const_reverse_iterator const_reverse_iterator
JPMTData()
Default constructor.
std::vector< JElement_t >::const_iterator const_iterator
std::vector< JElement_t >::reverse_iterator reverse_iterator
void insert(const JElement_t &element)
Insert element whilst maintaining order.
Interface for PMT simulation.
virtual void processHits(const JPMTIdentifier &id, const JCalibration &calibration, const JStatus &status, const JPMTData< JPMTSignal > &input, JPMTData< JPMTPulse > &output) const =0
Process hits.
JPMTSimulator()
Default constructor.
virtual ~JPMTSimulator()
Virtual destructor.
static JRange< double, std::less< double > > DEFAULT_RANGE()
Definition JRange.hh:555
range_type & include(argument_type x)
Include given value to range.
Definition JRange.hh:397
file Auxiliary data structures and methods for detector calibration.
Definition JAnchor.hh:12
bool operator<(const JAnchor &first, const JAnchor &second)
Sort anchors in ascending distance from (0,0).
Definition JAnchor.hh:99
JTimeRange getTimeRange(const JTimeRange &timeRange, const JModule &module)
Get de-calibrated time range.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Data structure for PMT digital pulse.
double t_ns
time [ns]
JPMTPulse(const double __t_ns, const double __tot_ns)
Constructor.
JPMTPulse()
Default constructor.
double tot_ns
time-over-threshold [ns]
Data structure for PMT analogue signal.
JPMTSignal(const double __t_ns, const int __npe)
Constructor.
int npe
number of photo-electrons
JPMTSignal()
Default constructor.
Data structure for single photo-electron.
JPhotoElectron(const double __t_ns)
Constructor.
JPhotoElectron()
Default constructor.
static JPhotoElectron getEndMarker()
Get end marker.
Auxiliary class for handling status.
Definition JStatus.hh:31