Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JDAQEvent.hh
Go to the documentation of this file.
1#ifndef __JDAQEVENT__
2#define __JDAQEVENT__
3
4#include <ostream>
5#include <iomanip>
6#include <vector>
7
15
16
17/**
18 * \author mdejong
19 */
20
21namespace KM3NETDAQ {
22
23
25
26
27 /**
28 * DAQ Event.
29 */
30 class JDAQEvent :
31 public JDAQPreamble,
32 public JDAQEventHeader
33 {
34 public:
35
37
38 friend size_t getSizeof(const JDAQEvent&);
40 friend JWriter& operator<<(JWriter&, const JDAQEvent&);
41
42 /**
43 * Default constructor.
44 */
49
50
51 /**
52 * Constructor.
53 *
54 * \param header header
55 */
56 JDAQEvent(const JDAQEventHeader& header) :
58 JDAQEventHeader(header)
59 {}
60
61
62 /**
63 * Template const_iterator
64 */
65 template<class T>
67 public std::vector<T>::const_iterator
68 {
69 public:
70 /**
71 * Default constructor.
72 */
76
77
78 /**
79 * Copy constructor.
80 *
81 * \param i iterator
82 */
86 };
87
88
89 /**
90 * Template const_reverse_iterator
91 */
92 template<class T>
94 public std::vector<T>::const_reverse_iterator
95 {
96 public:
97 /**
98 * Default constructor.
99 */
103
104
105 /**
106 * Copy constructor.
107 *
108 * \param i iterator
109 */
113 };
114
115
116 /**
117 * Get container with hits.
118 *
119 * \return container with hits
120 */
121 template<class T>
122 const std::vector<T>& getHits() const;
123
124
125 /**
126 * Get container with hits.
127 *
128 * \return container with hits
129 */
130 template<class T>
132
133
134 /**
135 * Get begin of data.
136 *
137 * \return begin of data
138 */
139 template<class T>
141
142
143 /**
144 * Get end of data.
145 *
146 * \return end of data
147 */
148 template<class T>
150
151
152 /**
153 * Get reverse begin of data.
154 *
155 * \return begin of data
156 */
157 template<class T>
159
160
161 /**
162 * Get reverse end of data.
163 *
164 * \return end of data
165 */
166 template<class T>
168
169
170 /**
171 * Get number of hits.
172 *
173 * \return number of hits
174 */
175 template<class T>
176 unsigned int size() const;
177
178
179 /**
180 * Check emptyness of hit container.
181 *
182 * \return true if empty; else false
183 */
184 template<class T>
185 bool empty() const;
186
187
188 /**
189 * Clear event.
190 */
191 void clear()
192 {
193 snapshotHits .clear();
194 triggeredHits.clear();
195 }
196
197
198 /**
199 * Add hit.
200 *
201 * \param hit hit
202 */
203 void push_back(const JDAQKeyHit& hit)
204 {
205 snapshotHits.push_back(hit);
206 }
207
208
209 /**
210 * Add hit.
211 *
212 * \param hit hit
213 */
215 {
216 triggeredHits.push_back(hit);
217 }
218
219
220 /**
221 * Get trigger mask of given hit.
222 *
223 * \param hit hit
224 * \return trigger mask
225 */
227 {
228 return hit.getTriggerMask();
229 }
230
231
232 /**
233 * Get trigger mask of given hit.
234 *
235 * \param hit hit
236 * \return trigger mask
237 */
239 {
240 for (std::vector<JDAQTriggeredHit>::const_iterator i = triggeredHits.begin(); i != triggeredHits.end(); ++i) {
241 if (*i == hit) {
242 return i->getTriggerMask();
243 }
244 }
245
246 return JTriggerMask_t(0);
247 }
248
249
250 /**
251 * Print DAQ Event.
252 *
253 * \param out output stream
254 * \param lpr long print
255 * \return output stream
256 */
257 std::ostream& print(std::ostream& out, const bool lpr = false) const;
258
259
261
262
263 protected:
266 };
267
268
269 /**
270 * Equal operator for DAQ events.
271 *
272 * \param first event
273 * \param second event
274 * \result true if first event equal to second; else false
275 */
276 bool operator==(const JDAQEvent& first,
277 const JDAQEvent& second);
278
279
280 /**
281 * Not-equal operator for DAQ events.
282 *
283 * \param first event
284 * \param second event
285 * \result true if first event not equal to second; else false
286 */
287 inline bool operator!=(const JDAQEvent& first,
288 const JDAQEvent& second)
289 {
290 return !(first == second);
291 }
292
293
294 /**
295 * Print DAQ Event.
296 *
297 * \param out output stream
298 * \param event event
299 * \return output stream
300 */
301 inline std::ostream& operator<<(std::ostream& out, const JDAQEvent& event)
302 {
303 return event.print(out, getDAQLongprint());
304 }
305
306
307 /**
308 * Get time difference between two events.
309 *
310 * \param first event
311 * \param second event
312 * \result time difference [s]
313 */
314 inline double getTimeDifference(const JDAQEvent& first, const JDAQEvent& second);
315}
316
317#endif
Interface for binary input.
Interface for binary output.
Template const_iterator.
Definition JDAQEvent.hh:68
const_iterator(const typename std::vector< T >::const_iterator &i)
Copy constructor.
Definition JDAQEvent.hh:83
const_iterator()
Default constructor.
Definition JDAQEvent.hh:73
Template const_reverse_iterator.
Definition JDAQEvent.hh:95
const_reverse_iterator(const typename std::vector< T >::const_reverse_iterator &i)
Copy constructor.
Definition JDAQEvent.hh:110
static JTriggerMask_t getTriggerMask(const JDAQTriggeredHit &hit)
Get trigger mask of given hit.
Definition JDAQEvent.hh:226
JTriggerMask_t getTriggerMask(const JDAQSnapshotHit &hit) const
Get trigger mask of given hit.
Definition JDAQEvent.hh:238
const std::vector< T > & getHits() const
Get container with hits.
friend JReader & operator>>(JReader &, JDAQEvent &)
Read DAQ event from input.
const_iterator< T > end() const
Get end of data.
void clear()
Clear event.
Definition JDAQEvent.hh:191
std::vector< T > & getHits()
Get container with hits.
friend JWriter & operator<<(JWriter &, const JDAQEvent &)
Write DAQ event to output.
unsigned int size() const
Get number of hits.
JDAQEvent(const JDAQEventHeader &header)
Constructor.
Definition JDAQEvent.hh:56
const_reverse_iterator< T > rend() const
Get reverse end of data.
const_iterator< T > begin() const
Get begin of data.
std::vector< JDAQSnapshotHit > snapshotHits
Definition JDAQEvent.hh:265
bool empty() const
Check emptyness of hit container.
std::ostream & print(std::ostream &out, const bool lpr=false) const
Print DAQ Event.
void push_back(const JDAQTriggeredHit &hit)
Add hit.
Definition JDAQEvent.hh:214
void push_back(const JDAQKeyHit &hit)
Add hit.
Definition JDAQEvent.hh:203
friend size_t getSizeof(const JDAQEvent &)
Get size of object.
JDAQEvent()
Default constructor.
Definition JDAQEvent.hh:45
ClassDef(JDAQEvent, 4)
std::vector< JDAQTriggeredHit > triggeredHits
Definition JDAQEvent.hh:264
const_reverse_iterator< T > rbegin() const
Get reverse begin of data.
JTriggerMask_t getTriggerMask() const
Get trigger mask.
bool operator==(const Head &first, const Head &second)
Equal operator.
Definition JHead.hh:1801
bool operator!=(const JTag &first, const JTag &second)
Not equal operator for JTag.
Definition JTag.hh:291
KM3NeT DAQ data structures and auxiliaries.
Definition DataQueue.cc:39
JDAQKeyHit JDAQSnapshotHit
Definition JDAQEvent.hh:24
double getTimeDifference(const JDAQChronometer &first, const JDAQChronometer &second)
Get time difference between two chronometers.
unsigned long long int JTriggerMask_t
Type definition of trigger mask.
JWriter & operator<<(JWriter &out, const JDAQChronometer &chronometer)
Write DAQ chronometer to output.
bool & getDAQLongprint()
Get DAQ print option.
Definition JDAQPrint.hh:15
Auxiliary class for a DAQ type holder.