Jpp  15.0.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TimeSlice.hh
Go to the documentation of this file.
1 #ifndef __ANTARESDAQ__TIMESLICE__
2 #define __ANTARESDAQ__TIMESLICE__
3 
4 #include <ostream>
5 #include <iomanip>
6 #include <vector>
7 #include <algorithm>
8 
9 #include <TROOT.h>
10 #include <TObject.h>
11 
16 
17 
18 /**
19  * Summary of Frame
20  */
22 protected:
23  /** LCM identifier */
24  unsigned short lcm_id_;
25  /** ARS identifier */
26  unsigned char ars_id_;
27  /** data type */
28  unsigned char data_type_;
29  /** number of items */
30  unsigned short numberOfItems_;
31 
32 public:
33  /**
34  * item type definition
35  */
36  typedef void item_type;
37 
38  /**
39  * get LCM idendifier
40  * \return LCM identifier
41  */
42  const unsigned short lcm_id() const { return lcm_id_; }
43 
44  /**
45  * get ARS idendifier
46  * \return ARS identifier
47  */
48  const unsigned char ars_id() const { return ars_id_; }
49 
50  /**
51  * get data type
52  * \return data type
53  */
54  const unsigned char data_type() const { return data_type_; }
55 
56  /**
57  * get number of items
58  * \return number of items
59  */
60  const unsigned short numberOfItems() const { return numberOfItems_; }
61 
62  /**
63  * Default constructor.
64  */
66  lcm_id_(0),
67  ars_id_(0),
68  data_type_(0),
70  {}
71 
72  /**
73  * Virtual destructor.
74  */
75  virtual ~Summary_Frame() {}
76 
77  /**
78  * equal operator.
79  *
80  * \param object summary frame
81  * \return true if equals object; else false
82  */
83  const bool operator==(const Summary_Frame& object)
84  {
85  return (lcm_id_ == object.lcm_id_ &&
86  ars_id_ == object.ars_id_ &&
87  data_type_ == object.data_type_);
88  }
89 
90  /**
91  * not-equal operator.
92  *
93  * \param object summary frame
94  * \return true if not equals object; else false
95  */
96  const bool operator!=(const Summary_Frame& object) const
97  {
98  return (lcm_id_ != object.lcm_id_ ||
99  ars_id_ != object.ars_id_ ||
100  data_type_ != object.data_type_);
101  }
102 
103  /**
104  * less than operator.
105  *
106  * \param object summary frame
107  * \return true if less than object; else false
108  */
109  const bool operator<(const Summary_Frame& object) const
110  {
111  if (lcm_id_ == object.lcm_id_)
112  if (ars_id_ == object.ars_id_)
113  return data_type_ < object.data_type_;
114  else
115  return ars_id_ < object.ars_id_;
116  else
117  return lcm_id_ < object.lcm_id_;
118  }
119 
120  /**
121  * Print ASCII.
122  *
123  * \param out output stream
124  * \param object Summary frame
125  * \return output stream
126  */
127  friend std::ostream& operator<<(std::ostream& out, const Summary_Frame& object)
128  {
129  using namespace std;
130 
131  return out << setw(5) << (int) object.lcm_id_ << ' '
132  << setw(2) << (int) object.ars_id_ << ' '
133  << setw(2) << (int) object.data_type_ << ' '
134  << setw(5) << (int) object.numberOfItems_ << endl;
135  }
136 
137  /**
138  * operator +=
139  *
140  * \param object summar frame
141  * \return this summay frame
142  */
144  {
145  if (*this == object) {
146  numberOfItems_ += object.numberOfItems_;
147  }
148 
149  return *this;
150  }
151 
152  /** ROOT class definition */
154 };
155 
156 
158  public Summary_Frame
159 {
160 protected:
161  /** number of items original */
162  unsigned short numberOfItemsOrg_;
163 
164 public:
165  /**
166  * item type definition
167  */
168  typedef void item_type;
169 
170  /**
171  * get number of items original
172  * \return number of items
173  */
174  const unsigned short numberOfItemsOrg() const { return numberOfItemsOrg_; }
175 
176  /**
177  * Default constructor.
178  */
180  Summary_Frame(),
181  numberOfItemsOrg_(0)
182  {}
183 
184  /**
185  * Print ASCII.
186  *
187  * \param out output stream
188  * \param object Extended Summary frame
189  * \return output stream
190  */
191  friend std::ostream& operator<<(std::ostream& out, const ExtendedSummary_Frame& object)
192  {
193  using namespace std;
194 
195  return out << setw(5) << (int) object.lcm_id_ << ' '
196  << setw(2) << (int) object.ars_id_ << ' '
197  << setw(2) << (int) object.data_type_ << ' '
198  << setw(5) << (int) object.numberOfItems_ << ' '
199  << setw(5) << (int) object.numberOfItemsOrg_ << endl;
200  }
201 
202  /**
203  * operator +=
204  *
205  * \param object extended summary frame
206  * \return this extended summary frame
207  */
209  {
210  if (*this == object) {
211  numberOfItems_ += object.numberOfItems_;
212  numberOfItemsOrg_ += object.numberOfItemsOrg_;
213  }
214  return *this;
215  }
216 
217  /** ROOT class definition */
219 };
220 
221 
222 /**
223  * Template Frame for ARS data
224  */
225 template<class T> class Frame :
226  public DaqFramePreamble,
227  public std::vector<T>
228 {
229 public:
230  /**
231  * item type definition
232  */
233  typedef T item_type;
234 
235  /**
236  * Default constructor.
237  */
238  Frame() :
240  {}
241 
242  /**
243  * Print ASCII.
244  *
245  * \param out output stream
246  * \param object frame
247  * \return output stream
248  */
249  friend std::ostream& operator<<(std::ostream& out, const Frame& object)
250  {
251  using namespace std;
252 
253  out << static_cast<const DaqFramePreamble&>(object);
254 
255  if (!object.empty()) {
256  out << ' ' << *(object. begin());
257  out << " ... ";
258  out << ' ' << *(object.rbegin());
259  out << endl;
260  }
261 
262 
263  return out;
264  }
265 
266  /**
267  * operator +=
268  *
269  * \param object frame
270  * \return this frame
271  */
272  Frame<T>& operator+=(const Frame<T>& object)
273  {
274  if ((DaqFramePreamble&) *this == (DaqFramePreamble&) object) {
275  for (typename Frame<T>::const_iterator i = object.begin(); i != object.end(); ++i) {
276  this->insert(std::lower_bound(Frame<T>::begin(),Frame<T>::end(),*i),*i);
277  }
278  }
279 
280  return *this;
281  }
282 
283  /** ROOT class definition */
284  ClassDef(Frame, 2);
285 };
286 
288 ClassImpT(Frame,T);
289 
290 
291 /**
292  * Status frame
293  */
295  public Frame<Status_Item>
296 {
297 public:
298  /**
299  * Default constructor.
300  */
302 
303  /** ROOT class definition */
305 };
306 
307 
308 /**
309  * RTS frame
310  */
311 class RTS_Frame :
312  public Frame<RTS_Item>
313 {
314 public:
315  /**
316  * Default constructor.
317  */
319 
320  /** ROOT class definition */
321  ClassDef(RTS_Frame, 2);
322 };
323 
324 
325 /**
326  * CRM frame
327  */
328 class CRM_Frame :
329  public Frame<CRM_Item>
330 {
331 public:
332  /**
333  * Default constructor.
334  */
336 
337  /** ROOT class definition */
338  ClassDef(CRM_Frame, 2);
339 };
340 
341 
342 /**
343  * SPE frame
344  */
345 class SPE_Frame :
346  public Frame<SPE_Item>
347 {
348 public:
349  /**
350  * Default constructor.
351  */
353 
354  /** ROOT class definition */
355  ClassDef(SPE_Frame, 2);
356 };
357 
358 
359 /**
360  * AWF frame
361  */
362 class AWF_Frame :
363  public Frame<AWF_Item>
364 {
365 public:
366  /**
367  * Default constructor.
368  */
370 
371  /** ROOT class definition */
372  ClassDef(AWF_Frame, 2);
373 };
374 
375 
376 /**
377  * DWF frame
378  */
379 class DWF_Frame :
380  public Frame<DWF_Item>
381 {
382 public:
383  /**
384  * Default constructor.
385  */
387 
388  /** ROOT class definition */
389  ClassDef(DWF_Frame, 2);
390 };
391 
392 /**
393  * Template TimeSlice
394  */
395 template<class T>
396 class TimeSlice :
397  public EventPreamble,
398  public std::vector<T>
399 {
400 public:
401  typedef T frame_type; //!< item type definition
402  typedef typename frame_type::item_type item_type; //!< item sub-type definition
403 
404  /**
405  * Default constructor.
406  */
408  EventPreamble(),
409  std::vector<T>()
410  {}
411 
412  /**
413  * Constructor.
414  *
415  * \param header event preamble
416  */
417  TimeSlice(const EventPreamble& header) :
418  EventPreamble(header),
419  std::vector<T>()
420  {}
421 
422  /**
423  * Print ASCII.
424  *
425  * \param out output stream
426  * \param object time slice
427  * \return output stream
428  */
429  friend std::ostream& operator<<(std::ostream& out, const TimeSlice<T>& object)
430  {
431  out << static_cast<const EventPreamble&>(object);
432 
433  for (typename TimeSlice<T>::const_iterator i = object.begin(); i != object.end(); ++i) {
434  out << *i;
435  }
436 
437  return out;
438  }
439 
440  /**
441  * operator +=
442  *
443  * \param object time slice
444  * \return this time slice
445  */
447  {
448  if ((EventPreamble&) *this == (EventPreamble&) object) {
449 
450  typename TimeSlice<T>::const_iterator from;
451  typename TimeSlice<T>::iterator to;
452 
453  for (from = object.begin(); from != object.end(); ++from) {
454 
455  for (to = std::vector<T>::begin(); to != std::vector<T>::end(); ++to) {
456  if (*to == *from) {
457  *to += *from;
458  break;
459  }
460  }
461 
462  if (to == std::vector<T>::end()) {
463  this->push_back(*from);
464  }
465  }
466  }
467 
468  return *this;
469  }
470 
471  /** ROOT class definition */
472  ClassDef(TimeSlice, 2);
473 };
474 
477 
480 
481 
482 /**
483  * Status time slices
484  */
486  public TimeSlice<Status_Frame>
487 {
488 public:
489  /**
490  * Default constructor.
491  */
493 
494  /** ROOT class definition */
496 };
497 
498 
499 /**
500  * RTS time slices
501  */
503  public TimeSlice<RTS_Frame>
504 {
505 public:
506  /**
507  * Default constructor.
508  */
510 
511  /** ROOT class definition */
513 };
514 
515 
516 /**
517  * CRM time slices
518  */
520  public TimeSlice<CRM_Frame>
521 {
522 public:
523  /**
524  * Default constructor.
525  */
527 
528  /** ROOT class definition */
530 };
531 
532 
533 /**
534  * SPE time slices
535  */
537  public TimeSlice<SPE_Frame>
538 {
539 public:
540  /**
541  * Default constructor.
542  */
544 
545  /** ROOT class definition */
547 };
548 
549 
550 /**
551  * AWF time slices
552  */
554  public TimeSlice<AWF_Frame>
555 {
556 public:
557  /**
558  * Default constructor.
559  */
561 
562  /** ROOT class definition */
564 };
565 
566 
567 /**
568  * DWF time slices
569  */
571  public TimeSlice<DWF_Frame>
572 {
573 public:
574  /**
575  * Default constructor.
576  */
578 
579  /** ROOT class definition */
581 };
582 
583 
584 /**
585  * Summary time slices
586  */
588  public TimeSlice<Summary_Frame>
589 {
590 public:
591  /**
592  * Default constructor.
593  */
595 
596  /**
597  * Constructor.
598  *
599  * param object time slice
600  */
601  template<class T>
602  Summary_TimeSlice(const TimeSlice<T>& object) :
603  TimeSlice<Summary_Frame>((const EventPreamble&) object)
604  {
605  for (typename TimeSlice<T>::const_iterator i = object.begin(); i != object.end(); ++i) {
606  this->push_back(Summary_Frame(i->LCM_ID,
607  i->ARS_ID,
608  i->dataType,
609  i->nbItems));
610  }
611  }
612 
613  /**
614  * operator +=
615  *
616  * \param object time slice
617  * \return this summary time slice
618  */
619  template<class T>
621  {
622  if ((EventPreamble&) *this == (EventPreamble&) object) {
623  for (typename TimeSlice<T>::const_iterator i = object.begin(); i != object.end(); ++i) {
624  this->push_back(Summary_Frame(i->LCM_ID,
625  i->ARS_ID,
626  i->dataType,
627  i->nbItems));
628  }
629  }
630 
631  return *this;
632  }
633 
634  /** ROOT class definition */
636 };
637 
638 
639 /**
640  * ExtendedSummary time slices
641  */
643  public TimeSlice<ExtendedSummary_Frame>
644 {
645 public:
646  /**
647  * Default constructor.
648  */
650 
651  /**
652  * Constructor.
653  *
654  * param object time slice
655  */
656  template<class T>
659  {
660  for (typename TimeSlice<T>::const_iterator i = object.begin(); i != object.end(); ++i) {
661  this->push_back(ExtendedSummary_Frame(i->LCM_ID,
662  i->ARS_ID,
663  i->dataType,
664  i->nbItems,
665  0));
666  }
667  }
668 
669  /** ROOT class definition */
671 };
672 
673 
674 /**
675  * equal operator for summary frame and DAQ frame preamble
676  *
677  * \param first summary frame
678  * \param second DAQ frame preamble
679  * \return true if first equals second; else false
680  */
681 inline const bool operator==(const Summary_Frame& first, const DaqFramePreamble& second)
682 {
683  return (first.data_type() == second.dataType &&
684  first.lcm_id() == second.LCM_ID &&
685  first.ars_id() == second.ARS_ID);
686 }
687 
688 /**
689  * equal operator for DAQ frame preamble and summary frame
690  *
691  * \param first DAQ frame preamble
692  * \param second summary frame
693  * \return true if first equals second; else false
694  */
695 inline const bool operator==(const DaqFramePreamble& first, const Summary_Frame& second)
696 {
697  return (first.dataType == second.data_type() &&
698  first.LCM_ID == second.lcm_id() &&
699  first.ARS_ID == second.ars_id());
700 }
701 
702 /**
703  * not-equal operator for summary frame and DAQ frame preamble
704  *
705  * \param first summary frame
706  * \param second DAQ frame preamble
707  * \return true if first not equals second; else false
708  */
709 inline const bool operator!=(const Summary_Frame& first, const DaqFramePreamble& second)
710 {
711  return (first.data_type() != second.dataType ||
712  first.lcm_id() != second.LCM_ID ||
713  first.ars_id() != second.ARS_ID);
714 }
715 
716 /**
717  * not-equal operator for DAQ frame preamble and summary frame
718  *
719  * \param first DAQ frame preamble
720  * \param second summary frame
721  * \return true if first not equals second; else false
722  */
723 inline const bool operator!=(const DaqFramePreamble& first, const Summary_Frame& second)
724 {
725  return (first.dataType != second.data_type() ||
726  first.LCM_ID != second.lcm_id() ||
727  first.ARS_ID != second.ars_id());
728 }
729 
730 #endif
731 
Template TimeSlice.
Definition: TimeSlice.hh:396
AWF time slices.
Definition: TimeSlice.hh:553
ExtendedSummary_TimeSlice(const TimeSlice< T > &object)
Constructor.
Definition: TimeSlice.hh:657
const unsigned short numberOfItemsOrg() const
get number of items original
Definition: TimeSlice.hh:174
Interface for event classes.
AWF_Frame()
Default constructor.
Definition: TimeSlice.hh:369
Summary_Frame()
Default constructor.
Definition: TimeSlice.hh:65
const bool operator<(const Summary_Frame &object) const
less than operator.
Definition: TimeSlice.hh:109
RTS_TimeSlice()
Default constructor.
Definition: TimeSlice.hh:509
Summary_TimeSlice(const TimeSlice< T > &object)
Constructor.
Definition: TimeSlice.hh:602
CRM_TimeSlice()
Default constructor.
Definition: TimeSlice.hh:526
DWF_Frame()
Default constructor.
Definition: TimeSlice.hh:386
unsigned char ars_id_
ARS identifier.
Definition: TimeSlice.hh:26
DWF frame.
Definition: TimeSlice.hh:379
SPE_Frame()
Default constructor.
Definition: TimeSlice.hh:352
T item_type
item type definition
Definition: TimeSlice.hh:233
const unsigned char ars_id() const
get ARS idendifier
Definition: TimeSlice.hh:48
ARS SPE.
Definition: Ars.hh:137
ExtendedSummary_Frame()
Default constructor.
Definition: TimeSlice.hh:179
Frame()
Default constructor.
Definition: TimeSlice.hh:238
virtual ~Summary_Frame()
Virtual destructor.
Definition: TimeSlice.hh:75
const unsigned short numberOfItems() const
get number of items
Definition: TimeSlice.hh:60
frame_type::item_type item_type
item sub-type definition
Definition: TimeSlice.hh:402
AWF_TimeSlice()
Default constructor.
Definition: TimeSlice.hh:560
ARS RTS.
Definition: Ars.hh:78
CRM_Frame()
Default constructor.
Definition: TimeSlice.hh:335
#define ClassDefT2(name, template)
Definition: JRoot.hh:35
ExtendedSummary time slices.
Definition: TimeSlice.hh:642
void item_type
item type definition
Definition: TimeSlice.hh:36
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
CRM frame.
Definition: TimeSlice.hh:328
unsigned short ARS_ID
ID of originating ARS.
T frame_type
item type definition
Definition: TimeSlice.hh:401
void item_type
item type definition
Definition: TimeSlice.hh:168
RTS time slices.
Definition: TimeSlice.hh:502
const unsigned char data_type() const
get data type
Definition: TimeSlice.hh:54
friend std::ostream & operator<<(std::ostream &out, const Summary_Frame &object)
Print ASCII.
Definition: TimeSlice.hh:127
This object holds the information from the &#39;preamble&#39; of a data frame.
const bool operator==(const Summary_Frame &object)
equal operator.
Definition: TimeSlice.hh:83
TimeSlice()
Default constructor.
Definition: TimeSlice.hh:407
ExtendedSummary_Frame & operator+=(const ExtendedSummary_Frame &object)
operator +=
Definition: TimeSlice.hh:208
unsigned short lcm_id_
LCM identifier.
Definition: TimeSlice.hh:24
RTS frame.
Definition: TimeSlice.hh:311
DWF time slices.
Definition: TimeSlice.hh:570
unsigned short LCM_ID
ID of originating LCM.
Status time slices.
Definition: TimeSlice.hh:485
do set_variable OUTPUT_DIRECTORY $WORKDIR T
friend std::ostream & operator<<(std::ostream &out, const ExtendedSummary_Frame &object)
Print ASCII.
Definition: TimeSlice.hh:191
TimeSlice< T > & operator+=(const TimeSlice< T > &object)
operator +=
Definition: TimeSlice.hh:446
const bool operator!=(const Summary_Frame &object) const
not-equal operator.
Definition: TimeSlice.hh:96
Status_TimeSlice()
Default constructor.
Definition: TimeSlice.hh:492
ExtendedSummary_TimeSlice()
Default constructor.
Definition: TimeSlice.hh:649
#define ClassImpT(name, template)
Definition: JRoot.hh:38
unsigned short numberOfItems_
number of items
Definition: TimeSlice.hh:30
ClassDef(Summary_Frame, 2)
ROOT class definition.
Status_Frame()
Default constructor.
Definition: TimeSlice.hh:301
ARS CRM.
Definition: Ars.hh:97
unsigned char data_type_
data type
Definition: TimeSlice.hh:28
SPE frame.
Definition: TimeSlice.hh:345
Template Frame for ARS data.
Definition: frame.hh:12
RTS_Frame()
Default constructor.
Definition: TimeSlice.hh:318
Frame< T > & operator+=(const Frame< T > &object)
operator +=
Definition: TimeSlice.hh:272
Summary_Frame & operator+=(const Summary_Frame &object)
operator +=
Definition: TimeSlice.hh:143
Status frame.
Definition: TimeSlice.hh:294
Summary_TimeSlice()
Default constructor.
Definition: TimeSlice.hh:594
friend std::ostream & operator<<(std::ostream &out, const Frame &object)
Print ASCII.
Definition: TimeSlice.hh:249
DWF_TimeSlice()
Default constructor.
Definition: TimeSlice.hh:577
TimeSlice(const EventPreamble &header)
Constructor.
Definition: TimeSlice.hh:417
Summary time slices.
Definition: TimeSlice.hh:587
SPE time slices.
Definition: TimeSlice.hh:536
Summary of Frame.
Definition: TimeSlice.hh:21
Summary_TimeSlice & operator+=(const TimeSlice< T > &object)
operator +=
Definition: TimeSlice.hh:620
ARS Dynode waveform.
Definition: Ars.hh:325
ARS Anode waveform.
Definition: Ars.hh:308
const unsigned short lcm_id() const
get LCM idendifier
Definition: TimeSlice.hh:42
SPE_TimeSlice()
Default constructor.
Definition: TimeSlice.hh:543
CRM time slices.
Definition: TimeSlice.hh:519
AWF frame.
Definition: TimeSlice.hh:362
ARS STATUS.
Definition: Ars.hh:36
unsigned short numberOfItemsOrg_
number of items original
Definition: TimeSlice.hh:162
unsigned short dataType
Data type code (DAQ_xxx)