Jpp test-rotations-old
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
11#include "Jeep/JStatus.hh"
12
13
14/**
15 * \author mdejong
16 */
17
18namespace JDETECTOR {}
19namespace JPP { using namespace JDETECTOR; }
20
21namespace JDETECTOR {
22
23 using JEEP::JStatus;
24
25
26 /**
27 * Data structure for single photo-electron.
28 */
30 /**
31 * Default constructor.
32 */
34 t_ns(0.0)
35 {}
36
37
38 /**
39 * Constructor.
40 *
41 * \param __t_ns time [ns]
42 */
43 JPhotoElectron(const double __t_ns) :
44 t_ns(__t_ns)
45 {}
46
47
48 /**
49 * Get end marker.
50 *
51 * \return latest possible photo-electron
52 */
54 {
55 return JPhotoElectron(std::numeric_limits<double>::max());
56 }
57
58
59 double t_ns; //!< time [ns]
60 };
61
62
63 /**
64 * Less than operator for photo-elecrons.
65 *
66 * \param first first photo-electron
67 * \param second second photo-electron
68 * \return true if first photo-electron earlier than second; else false
69 */
70 inline bool operator<(const JPhotoElectron& first, const JPhotoElectron& second)
71 {
72 return first.t_ns < second.t_ns;
73 }
74
75
76 /**
77 * Data structure for PMT analogue signal.
78 */
79 struct JPMTSignal {
80 /**
81 * Default constructor.
82 */
84 t_ns(0.0),
85 npe (0)
86 {}
87
88
89 /**
90 * Constructor.
91 *
92 * \param __t_ns time [ns]
93 * \param __npe number of photo-electrons
94 */
95 JPMTSignal(const double __t_ns,
96 const int __npe) :
97 t_ns(__t_ns),
98 npe (__npe)
99 {}
100
101
102 double t_ns; //!< time [ns]
103 int npe; //!< number of photo-electrons
104 };
105
106
107 /**
108 * Less than operator for PMT signals.
109 *
110 * \param first first PMT signal
111 * \param second second PMT signal
112 * \return true if first PMT signal earlier than second; else false
113 */
114 inline bool operator<(const JPMTSignal& first, const JPMTSignal& second)
115 {
116 return first.t_ns < second.t_ns;
117 }
118
119
120 /**
121 * Data structure for PMT digital pulse.
122 */
123 struct JPMTPulse {
124 /**
125 * Default constructor.
126 */
128 t_ns (0.0),
129 tot_ns(0.0)
130 {}
131
132
133 /**
134 * Constructor.
135 *
136 * \param __t_ns time [ns]
137 * \param __tot_ns time-over-threshold [ns]
138 */
139 JPMTPulse(const double __t_ns,
140 const double __tot_ns) :
141 t_ns (__t_ns),
142 tot_ns(__tot_ns)
143 {}
144
145
146 double t_ns; //!< time [ns]
147 double tot_ns; //!< time-over-threshold [ns]
148 };
149
150
151 /**
152 * Less than operator for PMT pulses.
153 *
154 * \param first first PMT pulse
155 * \param second second PMT pulse
156 * \return true if first PMT pulse earlier than second; else false
157 */
158 inline bool operator<(const JPMTPulse& first, const JPMTPulse& second)
159 {
160 return first.t_ns < second.t_ns;
161 }
162
163
164 /**
165 * Template data structure for PMT I/O.
166 */
167 template<class JElement_t>
168 class JPMTData :
169 public std::vector<JElement_t>
170 {
171 public:
172
174 typedef typename std::vector<JElement_t>::const_iterator const_iterator;
176 typedef typename std::vector<JElement_t>::const_reverse_iterator const_reverse_iterator;
177
178
179 /**
180 * Default constructor.
181 */
183 std::vector<JElement_t>()
184 {}
185
186
187 /**
188 * Sort.
189 */
190 void sort()
191 {
192 std::sort(this->begin(), this->end());
193 }
194
195
196 /**
197 * Insert element whilst maintaining order.
198 *
199 * \param element element
200 */
201 void insert(const JElement_t& element)
202 {
203 iterator i = std::lower_bound(this->begin(), this->end(), element);
204
206 }
207 };
208
209
210
211 /**
212 * Data structure for PMT data corresponding to a detector module.
213 */
215 public std::vector< JPMTData<JPMTSignal> >
216 {
217 public:
218 /**
219 * Default constructor.
220 */
222 std::vector< JPMTData<JPMTSignal> >()
223 {}
224
225
226 /**
227 * Reset buffers.
228 *
229 * \param size number of buffers
230 */
231 void reset(size_t size)
232 {
233 this->resize(size);
234
235 for (iterator i = this->begin(); i != this->end(); ++i) {
236 i->clear();
237 }
238 }
239 };
240
241
242 /**
243 * Interface for PMT simulation.
244 * The input buffer consists of a sorted array of PMT analogue signals JDETECTOR::JPMTSignal and
245 * the output of an array of PMT digital pulses JDETECTOR::JPMTPulse.
246 */
248 protected:
249 /**
250 * Default constructor.
251 */
254
255
256 public:
257 /**
258 * Virtual destructor.
259 */
261 {}
262
263
264 /**
265 * Process hits.
266 *
267 * \param id PMT identifier
268 * \param calibration PMT calibration
269 * \param status PMT status
270 * \param input PMT signals
271 * \param output PMT pulses
272 */
273 virtual void processHits(const JPMTIdentifier& id,
274 const JCalibration& calibration,
275 const JStatus& status,
276 const JPMTData<JPMTSignal>& input,
277 JPMTData<JPMTPulse>& output) const = 0;
278 };
279
280
281 /**
282 * Get time range (i.e.\ earliest and latest hit time) of PMT data.
283 *
284 * \param input PMT data
285 * \return time range
286 */
287 template<class T>
289 {
291
292 for (typename JPMTData<T>::const_iterator hit = input.begin(); hit != input.end(); ++hit) {
293 range.include(hit->t_ns);
294 }
295
296 return range;
297 }
298
299
300 /**
301 * Get time range (i.e.\ earlist and latest hit time) of module data.
302 *
303 * \param input module data
304 * \return time range
305 */
307 {
309
310 for (JModuleData::const_iterator frame = input.begin(); frame != input.end(); ++frame) {
311 for (JModuleData::value_type::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) {
312 range.include(hit->t_ns);
313 }
314 }
315
316 return range;
317 }
318}
319
320#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:39