Belle II Software development
PXDDAQDHEStatus.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <vxd/dataobjects/VxdID.h>
12#include <pxd/dataobjects/PXDDAQDHPStatus.h>
13#include <pxd/dataobjects/PXDErrorFlags.h>
14
15
16namespace Belle2 {
23 typedef std::tuple<uint8_t, uint16_t, uint8_t> PXDDAQDHPComMode;
24 using Belle2::PXD::PXDError::PXDErrorFlags;
25 using Belle2::PXD::PXDError::EPXDErrNr;
26
34 class PXDDAQDHEStatus final {
35 public:
36
41
49 PXDDAQDHEStatus(VxdID id, int dheid, const PXDErrorFlags& mask, unsigned short tg,
50 unsigned short fn) : m_errorMask(mask), m_critErrorMask(0), m_usable(true), m_sensorID(id), m_dheID(dheid),
52 {}
53
55 virtual ~PXDDAQDHEStatus() {};
56
60 bool isUsable() const { return m_usable; }
61
64 void markUnusable() { m_usable = false; m_errorMask[EPXDErrNr::c_nrUNUSABLE_DATA] = true;}
65
69 void setErrorMask(const PXDErrorFlags& mask) { m_errorMask = mask; }
73 PXDErrorFlags getErrorMask(void) const { return m_errorMask; }
74
78 void setCritErrorMask(const PXDErrorFlags& mask) { m_critErrorMask = mask; }
79
83 PXDErrorFlags getCritErrorMask(void) const { return m_critErrorMask; }
84
90 void Decide(void) {m_usable = (m_errorMask & m_critErrorMask) == PXDErrorFlags(0) && !m_errorMask[EPXDErrNr::c_nrUNUSABLE_DATA];}
91
93 void setDHEID(VxdID id, int dheid) { m_sensorID = id; m_dheID = dheid;};
95 unsigned short getDHEID(void) const { return m_dheID;};
97 VxdID getSensorID(void) const { return m_sensorID;};
98
100 void setCounters(uint32_t raw, uint32_t red) {m_rawCount = raw; m_redCount = red;};
102 void getCounters(uint32_t& raw, uint32_t& red) const { raw = m_rawCount; red = m_redCount;};
104 uint32_t getRawCnt(void) const { return m_rawCount;};
106 uint32_t getRedCnt(void) const { return m_redCount;};
108 void setTriggerGate(unsigned int tg) { m_triggerGate = tg;};
110 unsigned short getTriggerGate(void) const { return m_triggerGate;};
112 unsigned short getStartRow(void) const { return m_triggerGate * 4;};
114 void setFrameNr(unsigned int fn) { m_frameNr = fn;};
116 unsigned short getFrameNr(void) const { return m_frameNr;};
117
118
120 unsigned short getDHPFoundMask(void) { return m_dhp_found_mask;};
122 void setDHPFoundMask(unsigned short dhpmask) { m_dhp_found_mask = dhpmask;};
123
125 void setEndErrorInfo(uint32_t e) { m_errorinfo = e;};
127 uint32_t getEndErrorInfo(void) const { return m_errorinfo;};
128
132 void addDHP(PXDDAQDHPStatus& daqdhp) { m_pxdDHP.push_back(daqdhp);};
133
138 template<class ...Args> PXDDAQDHPStatus& newDHP(Args&& ... params)
139 {
140 /*return*/ m_pxdDHP.emplace_back(std::forward<Args>(params)...);
141 return m_pxdDHP.back();
142 }
143
145 std::vector<PXDDAQDHPStatus>::iterator begin() { return m_pxdDHP.begin(); };
147 std::vector<PXDDAQDHPStatus>::iterator end() { return m_pxdDHP.end(); };
148
150 std::vector<PXDDAQDHPStatus>::const_iterator cbegin() const { return m_pxdDHP.cbegin(); };
152 std::vector<PXDDAQDHPStatus>::const_iterator cend() const { return m_pxdDHP.cend(); };
154 PXDDAQDHPStatus& dhp_back() { return m_pxdDHP.back(); };
156 size_t dhp_size() const { return m_pxdDHP.size(); };
157
161 auto addCM(PXDDAQDHPComMode& daqcm) { return m_commode.push_back(daqcm);};
162
164 std::vector<PXDDAQDHPComMode>::iterator cm_begin() { return m_commode.begin(); };
166 std::vector<PXDDAQDHPComMode>::iterator cm_end() { return m_commode.end(); };
168 PXDDAQDHPComMode& cm_back() { return m_commode.back(); };
170 size_t cm_size() const { return m_commode.size(); };
172 int get_cm_dhp(int i) const { return std::get<0>(m_commode[i]); };
174 int get_cm_row(int i) const { return std::get<1>(m_commode[i]); };
176 int get_cm_value(int i) const { return std::get<2>(m_commode[i]); };
177
178 private:
179 PXDErrorFlags m_errorMask;
180 PXDErrorFlags m_critErrorMask;
181 bool m_usable;
183 unsigned short m_sensorID;
184 unsigned short m_dheID;
185 unsigned short m_triggerGate;
186 unsigned short m_frameNr;
187 unsigned short m_dhp_found_mask;
188 uint32_t m_rawCount;
189 uint32_t m_redCount;
190 uint32_t m_errorinfo;
193 std::vector< PXDDAQDHPStatus> m_pxdDHP;
194
196 std::vector < PXDDAQDHPComMode> m_commode;
197
200
201 }; // class PXDDAQDHEStatus
202
204} // end namespace Belle2
The PXD DAQ DHE Status class.
std::vector< PXDDAQDHPComMode > m_commode
Vector of Common Mode informations belonging to this event.
unsigned short getStartRow(void) const
get Trigger Start Row
PXDDAQDHPStatus & newDHP(Args &&... params)
New DHP information.
void setDHPFoundMask(unsigned short dhpmask)
set Mask for found DHPs with valid data
void markUnusable()
Mark Data in DHE as Unusable.
void setCritErrorMask(const PXDErrorFlags &mask)
Set Critical Error bit mask.
void setDHEID(VxdID id, int dheid)
Set VxdID and DHE ID of sensor.
void setErrorMask(const PXDErrorFlags &mask)
Set Error bit mask.
PXDErrorFlags m_critErrorMask
critical error mask
unsigned short m_sensorID
Sensor ID.
size_t cm_size() const
Returns number of Common Mode blocks in this event.
std::vector< PXDDAQDHPStatus >::iterator begin()
iterator-based iteration for DHPs
void setFrameNr(unsigned int fn)
set Readout Frame number
PXDDAQDHPComMode & cm_back()
Returns last Common Mode for this event.
uint32_t m_redCount
reduced byte count for monitoring
int get_cm_dhp(int i) const
Returns CM DHP ID at position i.
PXDErrorFlags getCritErrorMask(void) const
Return Critical Error bit mask.
uint32_t getRawCnt(void) const
Set Raw Data counter for reduction calculation.
PXDDAQDHEStatus(VxdID id, int dheid, const PXDErrorFlags &mask, unsigned short tg, unsigned short fn)
constructor setting the error mask, dheid, raw and reduced data counters, ...
std::vector< PXDDAQDHPComMode >::iterator cm_end()
iterator-based iteration for Common Mode
ClassDef(PXDDAQDHEStatus, 8)
necessary for ROOT
int get_cm_row(int i) const
Returns CM row at position i.
PXDErrorFlags getErrorMask(void) const
Return Error bit mask.
std::vector< PXDDAQDHPStatus >::iterator end()
iterator-based iteration for DHPs
std::vector< PXDDAQDHPComMode >::iterator cm_begin()
iterator-based iteration for Common Mode
PXDErrorFlags m_errorMask
errors found in this DHE/sensor
unsigned short m_dheID
DHE ID as delivered by DAQ.
void Decide(void)
Calculate the usability decision If any of the critical bits is set in the error mask the PXD data fr...
PXDDAQDHEStatus()
Default constructor for the ROOT IO.
uint32_t m_errorinfo
erroinfo from the DHE END
std::vector< PXDDAQDHPStatus >::const_iterator cend() const
const iterator-based iteration for DHPs
int get_cm_value(int i) const
Returns CM value at position i.
unsigned short getDHPFoundMask(void)
get Mask for found DHPs with valid data
unsigned short getTriggerGate(void) const
get Trigger Gate
auto addCM(PXDDAQDHPComMode &daqcm)
Add Common Mode information.
PXDDAQDHPStatus & dhp_back()
Returns PXDDAQDHPStatus for the last DHP.
void setEndErrorInfo(uint32_t e)
set erroinfo from the DHE END
uint32_t m_rawCount
raw byte count for monitoring
unsigned short m_dhp_found_mask
Mask for DHP with valid data.
virtual ~PXDDAQDHEStatus()
destructor
void setTriggerGate(unsigned int tg)
set Trigger Gate
unsigned short getFrameNr(void) const
get Readout Frame number
std::vector< PXDDAQDHPStatus > m_pxdDHP
Vector of DHP informations belonging to this event.
void addDHP(PXDDAQDHPStatus &daqdhp)
Add DHP information.
uint32_t getRedCnt(void) const
Set Reduced Data counter for reduction calculation.
size_t dhp_size() const
Returns number of DHPs.
std::vector< PXDDAQDHPStatus >::const_iterator cbegin() const
const iterator-based iteration for DHPs
unsigned short m_triggerGate
Trigger Gate ("Startrow") from DHE header.
void getCounters(uint32_t &raw, uint32_t &red) const
Get Data counters for reduction calculation.
VxdID getSensorID(void) const
Get VxdID of sensor.
unsigned short m_frameNr
Frame number (low bits) from DHE header.
unsigned short getDHEID(void) const
Get DHE ID of sensor.
void setCounters(uint32_t raw, uint32_t red)
Set Data counters for reduction calculation.
bool isUsable() const
Return Usability of data.
uint32_t getEndErrorInfo(void) const
get erroinfo from the DHE END
bool m_usable
data is useable.
The PXD DAQ DHP Status class.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
std::tuple< uint8_t, uint16_t, uint8_t > PXDDAQDHPComMode
tuple of Chip ID (2 bit), Row (10 bit), Common Mode (6 bit)
Abstract base class for different kinds of events.