LDMX Software
QIEStream.h
1#ifndef TRIGSCINT_EVENT_QIESTREAM_H
2#define TRIGSCINT_EVENT_QIESTREAM_H
3#include <Rtypes.h>
4
5//---< ROOT >---//
6
7template <uint32_t N>
8struct Mask {
9 static const uint32_t ONE{1};
10 static const uint32_t M = (ONE << N) - ONE;
11};
12template <uint8_t n>
13struct Mask8 {
14 static const uint8_t ONE{1};
15 static const uint8_t M = (ONE << n) - ONE;
16};
17
18namespace trigscint {
19
24class QIEStream {
25 public:
27 QIEStream() = default;
28
30 virtual ~QIEStream() = default;
31
35 friend std::ostream& operator<<(std::ostream& o, const QIEStream& d);
36
41 void clear(Option_t* option = "");
42
47 bool operator<(const QIEStream& rhs) const {
48 return this->chan_id_ < rhs.chan_id_;
49 }
50
54 int getChannelID() const { return chan_id_; }
55
59 uint8_t getElectronicsID() const { return electronics_id_; }
60
64 std::vector<int> getADC() const { return adcs_; }
65
69 std::vector<int> getTDC() const { return tdcs_; }
70
74 std::vector<int> getCID() const { return cids_; }
75
79 void setChannelID(const int chanid) { chan_id_ = chanid; }
80
84 void setElectronicsID(const int elecid) { electronics_id_ = elecid; }
85
90 void setADC(const std::vector<int> adc) { adcs_ = adc; }
91
96 void setTDC(const std::vector<int> tdc) { tdcs_ = tdc; }
97
102 void setCID(const std::vector<int> cid) { cids_ = cid; }
103
104 public:
105 // use these to define positions and sizes of error flags etc other header
106 // words relative to each other
107 // these simply state the order:
108 //{UTC time stamp, time stamp clock(), time since spill, triggerID, error,
109 // checksum == 0 (empty)}
110 const static int TIMESTAMP_POS{0};
111 const static int TIMESTAMP_LEN_BYTES{4};
112 const static int TIMESTAMPCLOCK_POS{TIMESTAMP_POS + TIMESTAMP_LEN_BYTES};
113 const static int TIMESTAMPCLOCK_LEN_BYTES{4};
114 const static int TIMESINCESPILL_POS{TIMESTAMPCLOCK_POS +
115 TIMESTAMPCLOCK_LEN_BYTES};
116 const static int TIMESINCESPILL_LEN_BYTES{4};
117 const static int TRIGID_POS{TIMESINCESPILL_POS + TIMESINCESPILL_LEN_BYTES};
118 const static int TRIGID_LEN_BYTES{3};
119 const static int ERROR_POS{TRIGID_POS + TRIGID_LEN_BYTES};
120 const static int ERROR_LEN_BYTES{1};
121 // and positions of error bits/flags in the errors word
122 const static int FLAG_SIZE_BITS{1};
123 const static int CRC0_ERR_POS{0};
124 const static int CRC1_ERR_POS{1};
125 const static int CID_UNSYNC_POS{2};
126 const static int CID_SKIP_POS{3};
127 const static int CHECKSUM_POS{CID_SKIP_POS + FLAG_SIZE_BITS};
128 //+ERROR_LEN_BYTES}; //included it in the error word
129 const static int CHECKSUM_SIZE_BITS{4};
130 //+ERROR_LEN_BYTES}; //included it in the error word
131 // the number of time samples making up a readout event
132 const static int NUM_SAMPLES{5};
133
134 private:
140 std::vector<int> adcs_;
142 std::vector<int> tdcs_;
144 std::vector<int> cids_;
145
146 ClassDef(QIEStream, 2);
147};
148} // namespace trigscint
149#endif
class for storing QIE output as a binary stream
Definition QIEStream.h:24
QIEStream()=default
Default constructor.
int electronics_id_
electronics ID
Definition QIEStream.h:138
void setADC(const std::vector< int > adc)
Store adcs of all time samples.
Definition QIEStream.h:90
std::vector< int > cids_
Capacitor IDs.
Definition QIEStream.h:144
std::vector< int > getTDC() const
Get TDCs of all time samples.
Definition QIEStream.h:69
std::vector< int > getCID() const
Get Cap IDs of all time samples.
Definition QIEStream.h:74
int getChannelID() const
Get channel ID.
Definition QIEStream.h:54
void clear(Option_t *option="")
A dummy function.
void setElectronicsID(const int elecid)
Store the electronics ID.
Definition QIEStream.h:84
bool operator<(const QIEStream &rhs) const
A dummy operator overloading.
Definition QIEStream.h:47
std::vector< int > getADC() const
Get ADCs of all time samples.
Definition QIEStream.h:64
std::vector< int > adcs_
Analog to Digital counts.
Definition QIEStream.h:140
void setCID(const std::vector< int > cid)
Store cids of all time samples.
Definition QIEStream.h:102
uint8_t getElectronicsID() const
Get electronics ID.
Definition QIEStream.h:59
void setChannelID(const int chanid)
Store the channel ID.
Definition QIEStream.h:79
virtual ~QIEStream()=default
Default destructor.
friend std::ostream & operator<<(std::ostream &o, const QIEStream &d)
Print ifo about the class.
std::vector< int > tdcs_
Time to Digital counts.
Definition QIEStream.h:142
int chan_id_
detector channel ID (bar nb)
Definition QIEStream.h:136
void setTDC(const std::vector< int > tdc)
Store tdcs of all time samples.
Definition QIEStream.h:96