Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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 */
22protected:
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
32public:
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{
160protected:
161 /** number of items original */
162 unsigned short numberOfItemsOrg_;
163
164public:
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 */
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 */
225template<class T> class Frame :
226 public DaqFramePreamble,
227 public std::vector<T>
228{
229public:
230 /**
231 * item type definition
232 */
233 typedef T item_type;
234
235 /**
236 * Default constructor.
237 */
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 */
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 */
285};
286
289
290
291/**
292 * Status frame
293 */
295 public Frame<Status_Item>
296{
297public:
298 /**
299 * Default constructor.
300 */
302
303 /** ROOT class definition */
305};
306
307
308/**
309 * RTS frame
310 */
312 public Frame<RTS_Item>
313{
314public:
315 /**
316 * Default constructor.
317 */
319
320 /** ROOT class definition */
322};
323
324
325/**
326 * CRM frame
327 */
329 public Frame<CRM_Item>
330{
331public:
332 /**
333 * Default constructor.
334 */
336
337 /** ROOT class definition */
339};
340
341
342/**
343 * SPE frame
344 */
346 public Frame<SPE_Item>
347{
348public:
349 /**
350 * Default constructor.
351 */
353
354 /** ROOT class definition */
356};
357
358
359/**
360 * AWF frame
361 */
363 public Frame<AWF_Item>
364{
365public:
366 /**
367 * Default constructor.
368 */
370
371 /** ROOT class definition */
373};
374
375
376/**
377 * DWF frame
378 */
380 public Frame<DWF_Item>
381{
382public:
383 /**
384 * Default constructor.
385 */
387
388 /** ROOT class definition */
390};
391
392/**
393 * Template TimeSlice
394 */
395template<class T>
397 public EventPreamble,
398 public std::vector<T>
399{
400public:
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 */
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 */
473};
474
477
480
481
482/**
483 * Status time slices
484 */
486 public TimeSlice<Status_Frame>
487{
488public:
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{
505public:
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{
522public:
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{
539public:
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{
556public:
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{
573public:
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{
590public:
591 /**
592 * Default constructor.
593 */
595
596 /**
597 * Constructor.
598 *
599 * param object time slice
600 */
601 template<class T>
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{
645public:
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 */
681inline 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 */
695inline 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 */
709inline 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 */
723inline 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
#define ClassImpT(name, template)
Definition JROOT_t.hh:38
#define ClassDefT2(name, template)
Definition JROOT_t.hh:35
const bool operator!=(const Summary_Frame &first, const DaqFramePreamble &second)
not-equal operator for summary frame and DAQ frame preamble
Definition TimeSlice.hh:709
const bool operator==(const Summary_Frame &first, const DaqFramePreamble &second)
equal operator for summary frame and DAQ frame preamble
Definition TimeSlice.hh:681
AWF frame.
Definition TimeSlice.hh:364
AWF_Frame()
Default constructor.
Definition TimeSlice.hh:369
ClassDef(AWF_Frame, 2)
ROOT class definition.
ARS Anode waveform.
Definition Ars.hh:310
AWF time slices.
Definition TimeSlice.hh:555
ClassDef(AWF_TimeSlice, 2)
ROOT class definition.
AWF_TimeSlice()
Default constructor.
Definition TimeSlice.hh:560
CRM frame.
Definition TimeSlice.hh:330
ClassDef(CRM_Frame, 2)
ROOT class definition.
CRM_Frame()
Default constructor.
Definition TimeSlice.hh:335
ARS CRM.
Definition Ars.hh:99
CRM time slices.
Definition TimeSlice.hh:521
ClassDef(CRM_TimeSlice, 2)
ROOT class definition.
CRM_TimeSlice()
Default constructor.
Definition TimeSlice.hh:526
DWF frame.
Definition TimeSlice.hh:381
DWF_Frame()
Default constructor.
Definition TimeSlice.hh:386
ClassDef(DWF_Frame, 2)
ROOT class definition.
ARS Dynode waveform.
Definition Ars.hh:327
DWF time slices.
Definition TimeSlice.hh:572
DWF_TimeSlice()
Default constructor.
Definition TimeSlice.hh:577
ClassDef(DWF_TimeSlice, 2)
ROOT class definition.
This object holds the information from the 'preamble' of a data frame.
unsigned short LCM_ID
ID of originating LCM.
unsigned short dataType
Data type code (DAQ_xxx)
unsigned short ARS_ID
ID of originating ARS.
Interface for event classes.
unsigned short numberOfItemsOrg_
number of items original
Definition TimeSlice.hh:162
friend std::ostream & operator<<(std::ostream &out, const ExtendedSummary_Frame &object)
Print ASCII.
Definition TimeSlice.hh:191
ClassDef(ExtendedSummary_Frame, 2)
ROOT class definition.
const unsigned short numberOfItemsOrg() const
get number of items original
Definition TimeSlice.hh:174
ExtendedSummary_Frame & operator+=(const ExtendedSummary_Frame &object)
operator +=
Definition TimeSlice.hh:208
ExtendedSummary_Frame()
Default constructor.
Definition TimeSlice.hh:179
void item_type
item type definition
Definition TimeSlice.hh:168
ExtendedSummary time slices.
Definition TimeSlice.hh:644
ExtendedSummary_TimeSlice()
Default constructor.
Definition TimeSlice.hh:649
ClassDef(ExtendedSummary_TimeSlice, 2)
ROOT class definition.
ExtendedSummary_TimeSlice(const TimeSlice< T > &object)
Constructor.
Definition TimeSlice.hh:657
Template Frame for ARS data.
Definition frame.hh:13
T item_type
item type definition
Definition TimeSlice.hh:233
ClassDef(Frame, 2)
ROOT class definition.
Frame< T > & operator+=(const Frame< T > &object)
operator +=
Definition TimeSlice.hh:272
Frame()
Default constructor.
Definition TimeSlice.hh:238
friend std::ostream & operator<<(std::ostream &out, const Frame &object)
Print ASCII.
Definition TimeSlice.hh:249
RTS frame.
Definition TimeSlice.hh:313
ClassDef(RTS_Frame, 2)
ROOT class definition.
RTS_Frame()
Default constructor.
Definition TimeSlice.hh:318
ARS RTS.
Definition Ars.hh:80
RTS time slices.
Definition TimeSlice.hh:504
ClassDef(RTS_TimeSlice, 2)
ROOT class definition.
RTS_TimeSlice()
Default constructor.
Definition TimeSlice.hh:509
SPE frame.
Definition TimeSlice.hh:347
ClassDef(SPE_Frame, 2)
ROOT class definition.
SPE_Frame()
Default constructor.
Definition TimeSlice.hh:352
ARS SPE.
Definition Ars.hh:139
SPE time slices.
Definition TimeSlice.hh:538
ClassDef(SPE_TimeSlice, 2)
ROOT class definition.
SPE_TimeSlice()
Default constructor.
Definition TimeSlice.hh:543
Status frame.
Definition TimeSlice.hh:296
Status_Frame()
Default constructor.
Definition TimeSlice.hh:301
ClassDef(Status_Frame, 2)
ROOT class definition.
ARS STATUS.
Definition Ars.hh:38
Status time slices.
Definition TimeSlice.hh:487
Status_TimeSlice()
Default constructor.
Definition TimeSlice.hh:492
ClassDef(Status_TimeSlice, 2)
ROOT class definition.
Summary of Frame.
Definition TimeSlice.hh:21
unsigned short numberOfItems_
number of items
Definition TimeSlice.hh:30
unsigned short lcm_id_
LCM identifier.
Definition TimeSlice.hh:24
Summary_Frame & operator+=(const Summary_Frame &object)
operator +=
Definition TimeSlice.hh:143
unsigned char data_type_
data type
Definition TimeSlice.hh:28
const unsigned short lcm_id() const
get LCM idendifier
Definition TimeSlice.hh:42
const unsigned char data_type() const
get data type
Definition TimeSlice.hh:54
unsigned char ars_id_
ARS identifier.
Definition TimeSlice.hh:26
ClassDef(Summary_Frame, 2)
ROOT class definition.
friend std::ostream & operator<<(std::ostream &out, const Summary_Frame &object)
Print ASCII.
Definition TimeSlice.hh:127
virtual ~Summary_Frame()
Virtual destructor.
Definition TimeSlice.hh:75
void item_type
item type definition
Definition TimeSlice.hh:36
const bool operator!=(const Summary_Frame &object) const
not-equal operator.
Definition TimeSlice.hh:96
Summary_Frame()
Default constructor.
Definition TimeSlice.hh:65
const unsigned short numberOfItems() const
get number of items
Definition TimeSlice.hh:60
const unsigned char ars_id() const
get ARS idendifier
Definition TimeSlice.hh:48
const bool operator==(const Summary_Frame &object)
equal operator.
Definition TimeSlice.hh:83
const bool operator<(const Summary_Frame &object) const
less than operator.
Definition TimeSlice.hh:109
Summary time slices.
Definition TimeSlice.hh:589
Summary_TimeSlice & operator+=(const TimeSlice< T > &object)
operator +=
Definition TimeSlice.hh:620
Summary_TimeSlice(const TimeSlice< T > &object)
Constructor.
Definition TimeSlice.hh:602
ClassDef(Summary_TimeSlice, 2)
ROOT class definition.
Summary_TimeSlice()
Default constructor.
Definition TimeSlice.hh:594
Template TimeSlice.
Definition TimeSlice.hh:399
T frame_type
item type definition
Definition TimeSlice.hh:401
ClassDef(TimeSlice, 2)
ROOT class definition.
TimeSlice(const EventPreamble &header)
Constructor.
Definition TimeSlice.hh:417
TimeSlice()
Default constructor.
Definition TimeSlice.hh:407
TimeSlice< T > & operator+=(const TimeSlice< T > &object)
operator +=
Definition TimeSlice.hh:446
frame_type::item_type item_type
item sub-type definition
Definition TimeSlice.hh:402
friend std::ostream & operator<<(std::ostream &out, const TimeSlice< T > &object)
Print ASCII.
Definition TimeSlice.hh:429