LDMX Software
ZCCMOutput.h
1#ifndef TRIGSCINT_EVENT_ZCCMOUTPUT_H
2#define TRIGSCINT_EVENT_ZCCMOUTPUT_H
3
4//---< ROOT >---//
5#include "QIEStream.h" // for definitions of Mask
6#include "TObject.h"
7#include "TrigScint/Event/TrigScintQIEDigis.h"
8
9namespace trigscint {
10
16 public:
18 ZCCMOutput() = default;
19
21 virtual ~ZCCMOutput() = default;
22
26 friend std::ostream &operator<<(std::ostream &o, const ZCCMOutput &d);
27
32 void clear(Option_t *option = "");
33
38 bool operator<(const ZCCMOutput &rhs) const {
39 return this->chan_id_ < rhs.chan_id_;
40 }
41
45 int getChannelID() const { return chan_id_; }
46
50 uint8_t getElectronicsID() const { return electronics_id_; }
51
55 std::vector<int> getADC() const { return adcs_; }
56
60 std::vector<int> getTDC() const { return tdcs_; }
61
65 std::vector<int> getCID() const { return cids_; }
66
70 void setChannelID(const int chanid) { chan_id_ = chanid; }
71
75 void setElectronicsID(const int elecid) { electronics_id_ = elecid; }
76
81 void setADC(const std::vector<int> adc) { adcs_ = adc; }
82
87 void setTDC(const std::vector<int> tdc) { tdcs_ = tdc; }
88
93 void setCID(const std::vector<int> cid) { cids_ = cid; }
94
95 public:
96 /*
97 use these to define positions and sizes of error flags etc other header
98 words relative to each other.
99 these simply state the order:
100 header {16B DAQ header, 8B TS time stamp, 8B empty}{message 0}...{message
101 N-1} for each time sample, every lane each sends a message: [ 1B ADC for 6
102 channels, 2B empty, 1B TDC for 6 channels, 1B flags, 1B lane nb]; and the 1B
103 "flags" structure is: flags = 2b CID (capID), 1b CE (channel alignment?
104 error), 1b BC0, 4b empty
105 */
106 const static int DAQHEADER_POS{0};
107 const static int DAQHEADER_LEN_BYTES{16};
108 const static int TIMESTAMP_POS{DAQHEADER_POS + DAQHEADER_LEN_BYTES};
109 const static int TIMESTAMP_LEN_BYTES{8};
110 const static int EMPTY_HEADER_WORD_POS{TIMESTAMP_POS + TIMESTAMP_LEN_BYTES};
111 const static int EMPTY_HEADER_WORD_LEN_BYTES{8};
112 // this marks the start of event data (i.e. after end of event header)
113 const static int EVENTDATA_POS{EMPTY_HEADER_WORD_POS +
114 EMPTY_HEADER_WORD_LEN_BYTES};
115 /*
116 the time sample word has ADC, TDC, flags and lane:
117 one for each lane, in every time sample
118 the following positions are within this time sample word, for one lane
119 */
120 // the number of channels sets the length of the ADC and TDC streams
121 const static int NUM_CHAN_PER_LANE{6};
122 const static int ADC_SAMPLE_WORD_POS{0};
123 const static int ADC_LEN_BYTES{1 * NUM_CHAN_PER_LANE};
124 const static int EMPTY_WORD_SAMPLE_WORD_POS{ADC_SAMPLE_WORD_POS +
125 ADC_LEN_BYTES};
126 const static int EMPTY_WORD_LEN_BYTES{2};
127 const static int TDC_SAMPLE_WORD_POS{EMPTY_WORD_SAMPLE_WORD_POS +
128 EMPTY_WORD_LEN_BYTES};
129 const static int TDC_LEN_BYTES{1 * NUM_CHAN_PER_LANE};
130 const static int FLAGS_SAMPLE_WORD_POS{TDC_SAMPLE_WORD_POS + TDC_LEN_BYTES};
131 const static int FLAGS_LEN_BYTES{1};
132 const static int LANE_SAMPLE_WORD_POS{FLAGS_SAMPLE_WORD_POS +
133 FLAGS_LEN_BYTES};
134 const static int LANE_LEN_BYTES{1};
135 // and positions of error bits/flags inside the flags word
136 const static int CAPID_POS_IN_FLAG{0};
137 const static int CAPID_LEN_BITS{2};
138 const static int CE_POS_IN_FLAG{CAPID_POS_IN_FLAG + CAPID_LEN_BITS};
139 const static int CE_LEN_BITS{1};
140 const static int BC0_POS_IN_FLAG{CE_POS_IN_FLAG + CE_LEN_BITS};
141 const static int BC0_LEN_BITS{1};
142 const static int EMPTY_FLAG_WORD_POS_IN_FLAG{BC0_POS_IN_FLAG + BC0_LEN_BITS};
143 const static int EMPTY_FLAG_WORD_LEN_BITS{4};
144
145 // event data concludes the readout.
146
147 // for convenience, define the length of a message (time sample for one lane)
148 const static int SAMPLE_WORD_LEN_BYTES = ADC_LEN_BYTES + TDC_LEN_BYTES +
149 EMPTY_WORD_LEN_BYTES +
150 FLAGS_LEN_BYTES + LANE_LEN_BYTES;
151
152 private:
154 int lane_;
162 std::vector<int> adcs_;
164 std::vector<int> tdcs_;
166 std::vector<int> cids_;
167
168 ClassDef(ZCCMOutput, 1);
169};
170} // namespace trigscint
171#endif
class for storing ZCCM output as a binary output
Definition ZCCMOutput.h:15
virtual ~ZCCMOutput()=default
Default destructor.
int getChannelID() const
Get channel ID.
Definition ZCCMOutput.h:45
void setElectronicsID(const int elecid)
Store the electronics ID.
Definition ZCCMOutput.h:75
friend std::ostream & operator<<(std::ostream &o, const ZCCMOutput &d)
Print ifo about the class.
std::vector< int > getTDC() const
Get TDCs of all time samples.
Definition ZCCMOutput.h:60
void clear(Option_t *option="")
A dummy function.
void setTDC(const std::vector< int > tdc)
Store tdcs of all time samples.
Definition ZCCMOutput.h:87
ZCCMOutput()=default
Default constructor.
uint8_t getElectronicsID() const
Get electronics ID.
Definition ZCCMOutput.h:50
int lane_
detector lane ID (aka fiber)
Definition ZCCMOutput.h:154
int chan_id_
detector channel ID (bar nb)
Definition ZCCMOutput.h:158
void setChannelID(const int chanid)
Store the channel ID.
Definition ZCCMOutput.h:70
std::vector< int > cids_
Capacitor IDs.
Definition ZCCMOutput.h:166
std::vector< int > tdcs_
Time to Digital counts.
Definition ZCCMOutput.h:164
std::vector< int > getCID() const
Get Cap IDs of all time samples.
Definition ZCCMOutput.h:65
void setCID(const std::vector< int > cid)
Store cids of all time samples.
Definition ZCCMOutput.h:93
int electronics_id_
electronics ID
Definition ZCCMOutput.h:160
void setADC(const std::vector< int > adc)
Store adcs of all time samples.
Definition ZCCMOutput.h:81
int module_
detector module ID (aka pad)
Definition ZCCMOutput.h:156
std::vector< int > adcs_
Analog to Digital counts.
Definition ZCCMOutput.h:162
bool operator<(const ZCCMOutput &rhs) const
A dummy operator overloading.
Definition ZCCMOutput.h:38
std::vector< int > getADC() const
Get ADCs of all time samples.
Definition ZCCMOutput.h:55