LDMX Software
ZCCMOutput.h
1#ifndef TRIGSCINT_EVENT_ZCCMOUTPUT_H
2#define TRIGSCINT_EVENT_ZCCMOUTPUT_H
3
4#include <Rtypes.h>
5
6#include <cstdint>
7#include <ostream>
8#include <vector>
9
10namespace trigscint {
11
17 public:
19 ZCCMOutput() = default;
20
22 virtual ~ZCCMOutput() = default;
23
27 friend std::ostream& operator<<(std::ostream& o, const ZCCMOutput& d);
28
33 void clear(Option_t* option = "");
34
39 bool operator<(const ZCCMOutput& rhs) const {
40 return this->chan_id_ < rhs.chan_id_;
41 }
42
46 int getChannelID() const { return chan_id_; }
47
51 uint8_t getElectronicsID() const { return electronics_id_; }
52
56 std::vector<int> getADC() const { return adcs_; }
57
61 std::vector<int> getTDC() const { return tdcs_; }
62
66 std::vector<int> getCID() const { return cids_; }
67
71 void setChannelID(const int chanid) { chan_id_ = chanid; }
72
76 void setElectronicsID(const int elecid) { electronics_id_ = elecid; }
77
82 void setADC(const std::vector<int> adc) { adcs_ = adc; }
83
88 void setTDC(const std::vector<int> tdc) { tdcs_ = tdc; }
89
94 void setCID(const std::vector<int> cid) { cids_ = cid; }
95
96 public:
103 const static int TIMESTAMP_POS{0};
104 const static int TIMESTAMP_LEN_BYTES{8};
105 const static int EMPTY_HEADER_WORD_POS{TIMESTAMP_POS + TIMESTAMP_LEN_BYTES};
106 const static int EMPTY_HEADER_WORD_LEN_BYTES{8};
107 // this marks the start of event data (i.e. after end of event header)
108 const static int EVENTDATA_POS{EMPTY_HEADER_WORD_POS +
109 EMPTY_HEADER_WORD_LEN_BYTES};
110 /*
111 the time sample word has ADC, TDC, flags and lane:
112 one for each lane, in every time sample
113 the following positions are within this time sample word, for one lane
114 */
115 // the number of channels sets the length of the ADC and TDC streams
116 const static int NUM_CHAN_PER_LANE{6};
117 const static int ADC_SAMPLE_WORD_POS{0};
118 const static int ADC_LEN_BYTES{1 * NUM_CHAN_PER_LANE};
119 const static int EMPTY_WORD_SAMPLE_WORD_POS{ADC_SAMPLE_WORD_POS +
120 ADC_LEN_BYTES};
121 const static int EMPTY_WORD_LEN_BYTES{2};
122 const static int TDC_SAMPLE_WORD_POS{EMPTY_WORD_SAMPLE_WORD_POS +
123 EMPTY_WORD_LEN_BYTES};
124 const static int TDC_LEN_BYTES{1 * NUM_CHAN_PER_LANE};
125 const static int FLAGS_SAMPLE_WORD_POS{TDC_SAMPLE_WORD_POS + TDC_LEN_BYTES};
126 const static int FLAGS_LEN_BYTES{1};
127 const static int LANE_SAMPLE_WORD_POS{FLAGS_SAMPLE_WORD_POS +
128 FLAGS_LEN_BYTES};
129 const static int LANE_LEN_BYTES{1};
130 // and positions of error bits/flags inside the flags word
131 const static int CAPID_POS_IN_FLAG{0};
132 const static int CAPID_LEN_BITS{2};
133 const static int CE_POS_IN_FLAG{CAPID_POS_IN_FLAG + CAPID_LEN_BITS};
134 const static int CE_LEN_BITS{1};
135 const static int BC0_POS_IN_FLAG{CE_POS_IN_FLAG + CE_LEN_BITS};
136 const static int BC0_LEN_BITS{1};
137 const static int EMPTY_FLAG_WORD_POS_IN_FLAG{BC0_POS_IN_FLAG + BC0_LEN_BITS};
138 const static int EMPTY_FLAG_WORD_LEN_BITS{4};
139
140 // event data concludes the readout.
141
142 // for convenience, define the length of a message (time sample for one lane)
143 const static int SAMPLE_WORD_LEN_BYTES = ADC_LEN_BYTES + TDC_LEN_BYTES +
144 EMPTY_WORD_LEN_BYTES +
145 FLAGS_LEN_BYTES + LANE_LEN_BYTES;
146
147 private:
149 int lane_;
157 std::vector<int> adcs_;
159 std::vector<int> tdcs_;
161 std::vector<int> cids_;
162
163 ClassDef(ZCCMOutput, 1);
164};
165} // namespace trigscint
166#endif
class for storing ZCCM output as a binary output
Definition ZCCMOutput.h:16
virtual ~ZCCMOutput()=default
Default destructor.
int getChannelID() const
Get channel ID.
Definition ZCCMOutput.h:46
void setElectronicsID(const int elecid)
Store the electronics ID.
Definition ZCCMOutput.h:76
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:61
void clear(Option_t *option="")
A dummy function.
void setTDC(const std::vector< int > tdc)
Store tdcs of all time samples.
Definition ZCCMOutput.h:88
ZCCMOutput()=default
Default constructor.
uint8_t getElectronicsID() const
Get electronics ID.
Definition ZCCMOutput.h:51
int lane_
detector lane ID (aka fiber)
Definition ZCCMOutput.h:149
int chan_id_
detector channel ID (bar nb)
Definition ZCCMOutput.h:153
void setChannelID(const int chanid)
Store the channel ID.
Definition ZCCMOutput.h:71
std::vector< int > cids_
Capacitor IDs.
Definition ZCCMOutput.h:161
std::vector< int > tdcs_
Time to Digital counts.
Definition ZCCMOutput.h:159
std::vector< int > getCID() const
Get Cap IDs of all time samples.
Definition ZCCMOutput.h:66
void setCID(const std::vector< int > cid)
Store cids of all time samples.
Definition ZCCMOutput.h:94
int electronics_id_
electronics ID
Definition ZCCMOutput.h:155
void setADC(const std::vector< int > adc)
Store adcs of all time samples.
Definition ZCCMOutput.h:82
int module_
detector module ID (aka pad)
Definition ZCCMOutput.h:151
std::vector< int > adcs_
Analog to Digital counts.
Definition ZCCMOutput.h:157
bool operator<(const ZCCMOutput &rhs) const
A dummy operator overloading.
Definition ZCCMOutput.h:39
std::vector< int > getADC() const
Get ADCs of all time samples.
Definition ZCCMOutput.h:56
static const int TIMESTAMP_POS
for each time sample, every lane each sends a message: [ 1B ADC for 6 channels, 2B empty,...
Definition ZCCMOutput.h:103