Jpp
 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 
8 #include "JDAQRoot.hh"
9 #include "JDAQPreamble.hh"
10 #include "JDAQEventHeader.hh"
11 #include "JDAQHit.hh"
12 #include "JDAQKeyHit.hh"
13 #include "JDAQTriggeredHit.hh"
14 #include "JDAQPrint.hh"
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 chronometer DAQ chronometer
55  * \param mask trigger mask
56  */
57  JDAQEvent(const JDAQChronometer& chronometer,
58  const JDAQTriggerMask& mask = JDAQTriggerMask()) :
60  JDAQEventHeader(chronometer, mask)
61  {}
62 
63 
64  /**
65  * Template const_iterator
66  */
67  template<class T>
68  class const_iterator :
70  {
71  public:
72  /**
73  * Default constructor.
74  */
76  std::vector<T>::const_iterator()
77  {}
78 
79 
80  /**
81  * Copy constructor.
82  *
83  * \param i iterator
84  */
86  std::vector<T>::const_iterator(i)
87  {}
88  };
89 
90 
91  /**
92  * Template const_reverse_iterator
93  */
94  template<class T>
97  {
98  public:
99  /**
100  * Default constructor.
101  */
104  {}
105 
106 
107  /**
108  * Copy constructor.
109  *
110  * \param i iterator
111  */
114  {}
115  };
116 
117 
118  /**
119  * Get container with hits.
120  *
121  * \return container with hits
122  */
123  template<class T>
124  const std::vector<T>& getHits() const;
125 
126 
127  /**
128  * Get container with hits.
129  *
130  * \return container with hits
131  */
132  template<class T>
134 
135 
136  /**
137  * Get begin of data.
138  *
139  * \return begin of data
140  */
141  template<class T>
142  const_iterator<T> begin() const;
143 
144 
145  /**
146  * Get end of data.
147  *
148  * \return end of data
149  */
150  template<class T>
151  const_iterator<T> end() const;
152 
153 
154  /**
155  * Get reverse begin of data.
156  *
157  * \return begin of data
158  */
159  template<class T>
160  const_reverse_iterator<T> rbegin() const;
161 
162 
163  /**
164  * Get reverse end of data.
165  *
166  * \return end of data
167  */
168  template<class T>
169  const_reverse_iterator<T> rend() const;
170 
171 
172  /**
173  * Get number of hits.
174  *
175  * \return number of hits
176  */
177  template<class T>
178  unsigned int size() const;
179 
180 
181  /**
182  * Check emptyness of hit container.
183  *
184  * \return true if empty; else false
185  */
186  template<class T>
187  bool empty() const;
188 
189 
190  /**
191  * Clear event.
192  */
193  void clear()
194  {
195  snapshotHits .clear();
196  triggeredHits.clear();
197  }
198 
199 
200  /**
201  * Add hit.
202  *
203  * \param hit hit
204  */
205  void push_back(const JDAQKeyHit& hit)
206  {
207  snapshotHits.push_back(hit);
208  }
209 
210 
211  /**
212  * Add hit.
213  *
214  * \param hit hit
215  */
216  void push_back(const JDAQTriggeredHit& hit)
217  {
218  triggeredHits.push_back(hit);
219  }
220 
221 
222  /**
223  * Get trigger mask of given hit.
224  *
225  * \param hit hit
226  * \return trigger mask
227  */
229  {
230  return hit.getTriggerMask();
231  }
232 
233 
234  /**
235  * Get trigger mask of given hit.
236  *
237  * \param hit hit
238  * \return trigger mask
239  */
241  {
243  if (*i == hit) {
244  return i->getTriggerMask();
245  }
246  }
247 
248  return JTriggerMask_t(0);
249  }
250 
251 
252  /**
253  * Print DAQ Event.
254  *
255  * \param out output stream
256  * \param lpr long print
257  * \return output stream
258  */
259  std::ostream& print(std::ostream& out, const bool lpr = false) const;
260 
261 
262  ClassDef(JDAQEvent,4);
263 
264 
265  protected:
268  };
269 
270 
271  /**
272  * Equal operator for DAQ events.
273  *
274  * \param first event
275  * \param second event
276  * \result true if first event equal to second; else false
277  */
278  bool operator==(const JDAQEvent& first,
279  const JDAQEvent& second);
280 
281 
282  /**
283  * Not-equal operator for DAQ events.
284  *
285  * \param first event
286  * \param second event
287  * \result true if first event not equal to second; else false
288  */
289  inline bool operator!=(const JDAQEvent& first,
290  const JDAQEvent& second)
291  {
292  return !(first == second);
293  }
294 
295 
296  /**
297  * Print DAQ Event.
298  *
299  * \param out output stream
300  * \param event event
301  * \return output stream
302  */
303  inline std::ostream& operator<<(std::ostream& out, const JDAQEvent& event)
304  {
305  return event.print(out, getDAQLongprint());
306  }
307 }
308 
309 #endif
JDAQTriggerMask()
Default constructor.
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.
Auxiliary class for trigger mask.
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:75
JDAQKeyHit JDAQSnapshotHit
Definition: JDAQEvent.hh:24
Template const_iterator.
Definition: JDAQEvent.hh:68
JDAQEvent()
Default constructor.
Definition: JDAQEvent.hh:45
Template const_reverse_iterator.
Definition: JDAQEvent.hh:95
std::vector< JDAQTriggeredHit > triggeredHits
Definition: JDAQEvent.hh:266
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:228
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:240
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:102
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:85
void push_back(const JDAQTriggeredHit &hit)
Add hit.
Definition: JDAQEvent.hh:216
void push_back(const JDAQKeyHit &hit)
Add hit.
Definition: JDAQEvent.hh:205
bool operator!=(const JDAQChronometer &first, const JDAQChronometer &second)
Not-equal operator for DAQ chronometers.
std::vector< JDAQSnapshotHit > snapshotHits
Definition: JDAQEvent.hh:267
bool & getDAQLongprint()
Get DAQ print option.
Definition: JDAQPrint.hh:15
JDAQEvent(const JDAQChronometer &chronometer, const JDAQTriggerMask &mask=JDAQTriggerMask())
Constructor.
Definition: JDAQEvent.hh:57
friend size_t getSizeof()
Definition of method to get size of data type.
void clear()
Clear event.
Definition: JDAQEvent.hh:193
const_reverse_iterator(const typename std::vector< T >::const_reverse_iterator &i)
Copy constructor.
Definition: JDAQEvent.hh:112