Jpp  18.3.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
21 namespace 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&);
39  friend JReader& operator>>(JReader&, JDAQEvent&);
40  friend JWriter& operator<<(JWriter&, const JDAQEvent&);
41 
42  /**
43  * Default constructor.
44  */
48  {}
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>
66  class const_iterator :
68  {
69  public:
70  /**
71  * Default constructor.
72  */
74  std::vector<T>::const_iterator()
75  {}
76 
77 
78  /**
79  * Copy constructor.
80  *
81  * \param i iterator
82  */
84  std::vector<T>::const_iterator(i)
85  {}
86  };
87 
88 
89  /**
90  * Template const_reverse_iterator
91  */
92  template<class T>
95  {
96  public:
97  /**
98  * Default constructor.
99  */
102  {}
103 
104 
105  /**
106  * Copy constructor.
107  *
108  * \param i iterator
109  */
112  {}
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>
140  const_iterator<T> begin() const;
141 
142 
143  /**
144  * Get end of data.
145  *
146  * \return end of data
147  */
148  template<class T>
149  const_iterator<T> end() const;
150 
151 
152  /**
153  * Get reverse begin of data.
154  *
155  * \return begin of data
156  */
157  template<class T>
158  const_reverse_iterator<T> rbegin() const;
159 
160 
161  /**
162  * Get reverse end of data.
163  *
164  * \return end of data
165  */
166  template<class T>
167  const_reverse_iterator<T> rend() const;
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  */
214  void push_back(const JDAQTriggeredHit& hit)
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  {
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 
260  ClassDef(JDAQEvent,4);
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
JDAQEvent(const JDAQEventHeader &header)
Constructor.
Definition: JDAQEvent.hh:56
bool operator==(const JDAQChronometer &first, const JDAQChronometer &second)
Equal operator for DAQ chronometers.
DAQ key hit.
Definition: JDAQKeyHit.hh:19
Interface for binary output.
JTriggerMask_t getTriggerMask() const
Get trigger mask.
Auxiliary class for a DAQ type holder.
bool empty() const
Check emptyness of hit container.
friend JWriter & operator<<(JWriter &, const JDAQEvent &)
Write DAQ event to output.
Definition: JDAQEventIO.hh:64
const_iterator()
Default constructor.
Definition: JDAQEvent.hh:73
JDAQKeyHit JDAQSnapshotHit
Definition: JDAQEvent.hh:24
Template const_iterator.
Definition: JDAQEvent.hh:66
JDAQEvent()
Default constructor.
Definition: JDAQEvent.hh:45
Template const_reverse_iterator.
Definition: JDAQEvent.hh:93
std::vector< JDAQTriggeredHit > triggeredHits
Definition: JDAQEvent.hh:264
unsigned int size() const
Get number of hits.
JWriter & operator<<(JWriter &out, const JDAQChronometer &chronometer)
Write DAQ chronometer to output.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
std::ostream & print(std::ostream &out, const bool lpr=false) const
Print DAQ Event.
static JTriggerMask_t getTriggerMask(const JDAQTriggeredHit &hit)
Get trigger mask of given hit.
Definition: JDAQEvent.hh:226
const_iterator< T > end() const
Get end of data.
unsigned long long int JTriggerMask_t
Type definition of trigger mask.
const std::vector< T > & getHits() const
Get container with hits.
const_iterator< T > begin() const
Get begin of data.
JTriggerMask_t getTriggerMask(const JDAQSnapshotHit &hit) const
Get trigger mask of given hit.
Definition: JDAQEvent.hh:238
double getTimeDifference(const JDAQChronometer &first, const JDAQChronometer &second)
Get time difference between two chronometers.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
ClassDef(JDAQEvent, 4)
const_reverse_iterator< T > rbegin() const
Get reverse begin of data.
Interface for binary input.
const_reverse_iterator()
Default constructor.
Definition: JDAQEvent.hh:100
const_reverse_iterator< T > rend() const
Get reverse end of data.
friend JReader & operator>>(JReader &, JDAQEvent &)
Read DAQ event from input.
Definition: JDAQEventIO.hh:43
const_iterator(const typename std::vector< T >::const_iterator &i)
Copy constructor.
Definition: JDAQEvent.hh:83
void push_back(const JDAQTriggeredHit &hit)
Add hit.
Definition: JDAQEvent.hh:214
void push_back(const JDAQKeyHit &hit)
Add hit.
Definition: JDAQEvent.hh:203
bool operator!=(const JDAQChronometer &first, const JDAQChronometer &second)
Not-equal operator for DAQ chronometers.
std::vector< JDAQSnapshotHit > snapshotHits
Definition: JDAQEvent.hh:265
bool & getDAQLongprint()
Get DAQ print option.
Definition: JDAQPrint.hh:15
friend size_t getSizeof()
Definition of method to get size of data type.
void clear()
Clear event.
Definition: JDAQEvent.hh:191
const_reverse_iterator(const typename std::vector< T >::const_reverse_iterator &i)
Copy constructor.
Definition: JDAQEvent.hh:110