Belle II Software development
SVDModeByte.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#ifndef SVDMODEBYTE_H
10#define SVDMODEBYTE_H
11
12#include <cstdint>
13#include <string>
14#include <ostream>
15
16namespace Belle2 {
21
22 // NB: I replaced enums with constexpressions here, since GCC complains
23 // (falsely, clang does not) about structure sizes, and the warnings can
24 // not be suppressed due to an error in GCC (July 2017).
25
32 namespace SVDRunType {
33 constexpr uint8_t
34 raw = 0,
38 }
39
45 namespace SVDEventType {
46 constexpr uint8_t
49 }
50
56 namespace SVDDAQModeType {
57 constexpr uint8_t
61 }
62
70 public:
72 typedef uint8_t baseType;
73 enum {
84
90 MaxDAQMode = (1 << DAQModeBits) - 1,
94 MaxRunType = (1 << RunTypeBits) - 1,
96 MaxID = (1 << Bits) - 1,
97
98 };
99
106 static const baseType c_DefaultID;
107
109 // cppcheck-suppress noExplicitConstructor
111 {
112 m_id.id = id;
113 }
114
117 {
118 m_id.parts.triggerBin = triggerBin;
119 m_id.parts.daqMode = daqMode;
120 m_id.parts.eventType = eventType;
121 m_id.parts.runType = runType;
122 }
123
125
127 SVDModeByte& operator=(const SVDModeByte& b) { m_id = b.m_id; return *this; }
129 SVDModeByte& operator=(baseType id) { m_id.id = id; return *this; }
131 operator baseType() const { return getID(); }
133 operator std::string() const;
135 bool operator==(const SVDModeByte& b) const { return getID() == b.getID(); }
136
138 baseType getID() const { return m_id.id; }
140 baseType getTriggerBin() const { return m_id.parts.triggerBin; }
142 baseType getDAQMode() const { return m_id.parts.daqMode; }
144 baseType getEventType() const { return m_id.parts.eventType; }
146 baseType getRunType() const { return m_id.parts.runType; }
147
148 // Some useful getters
150 bool hasTimeFit() const
151 { return m_id.parts.runType == SVDRunType::zero_suppressed_timefit; }
152
158 {
159 return (
160 (m_id.parts.runType == SVDRunType::zero_suppressed)
161 ||
163 );
164 }
165
167 void setID(baseType id) { m_id.id = id; }
170 { m_id.parts.triggerBin = triggerBin; }
171
173 { m_id.parts.daqMode = daqMode; }
174
176 { m_id.parts.eventType = eventType; }
177
179 { m_id.parts.runType = runType; }
180
182 std::string __str__() const { return (std::string)(*this); }
183
184 private:
185
186 // NB: the awful indentation is due to fixstyle.
187 union {
190 struct {
201 };
202
204 std::ostream& operator<<(std::ostream& out, const SVDModeByte& id);
206} // namespace Belle2
207
208#endif //SVDMODEBYTE_H
@ DAQModeBits
Number of bits available to represent DAQ Mode.
Definition SVDModeByte.h:77
@ MaxEventType
Maximum available event type ID.
Definition SVDModeByte.h:92
@ TriggerBinBits
Number of bits available to represent a triggerBin.
Definition SVDModeByte.h:75
@ MaxID
Maximum value for ID.
Definition SVDModeByte.h:96
@ MaxGoodTriggerBin
Maximum valid trigger time ID.
Definition SVDModeByte.h:88
@ MaxDAQMode
Maximum available DAQ mode ID.
Definition SVDModeByte.h:90
@ MaxTriggerTime
Maximum available trigger time ID.
Definition SVDModeByte.h:86
@ EventTypeBits
Number of bits available to represent event type.
Definition SVDModeByte.h:79
@ RunTypeBits
Number of bits available to represent run type.
Definition SVDModeByte.h:81
@ Bits
Total bit size of the SVDModeByte.
Definition SVDModeByte.h:83
@ MaxRunType
Maximum available run type ID.
Definition SVDModeByte.h:94
std::string __str__() const
make this type printable in python with print(vxd_id)
void setTriggerBin(baseType triggerBin)
Set the triggerBin id.
baseType getID() const
Get the unique id.
baseType id
Unique id.
baseType triggerBin
Trigger time id.
void setDAQMode(baseType daqMode)
Set the daqMode id.
SVDModeByte(baseType runType, baseType eventType, baseType daqMode, baseType triggerBin)
Constructor using triggerBin, daqMode etc.
baseType getRunType() const
Get the runMode id.
bool operator==(const SVDModeByte &b) const
Check for equality.
SVDModeByte & operator=(const SVDModeByte &b)
Assignment operator.
void setEventType(baseType eventType)
Set the eventType id.
baseType getEventType() const
Get the eventMode id.
baseType runType
Run type id.
union Belle2::SVDModeByte::@125334236146173133224113354173312072207356317302 m_id
Union to store the ID and all components in one go.
void setRunType(baseType runType)
Set the runType id.
baseType daqMode
DAQ mode id.
baseType getTriggerBin() const
Get the triggerBin id.
SVDModeByte(baseType id=c_DefaultID)
Constructor using the unique id.
struct Belle2::SVDModeByte::@125334236146173133224113354173312072207356317302::@120141217374112167064211251307021245077320076325 parts
< Struct to contain all id components
void setID(baseType id)
Set the unique id.
uint8_t baseType
The base integer type for SVDModeByte.
Definition SVDModeByte.h:72
SVDModeByte & operator=(baseType id)
Assignment from baseType.
SVDModeByte(const SVDModeByte &b)
Copy constructor.
bool isZeroSuppressedRun() const
Do we have useful run type?
bool hasTimeFit() const
Do we have time fit information?
baseType getDAQMode() const
Get the daqMode id.
baseType eventType
Event type id.
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
static const baseType c_DefaultID
Default / non-informative id 10010111 = 151 Run type: zero-suppressed, 2 Event type: global run,...
2+3 bit: 00 1-sample, 01 3-sample, 10 6-sample
Definition SVDModeByte.h:56
constexpr uint8_t daq_3samples
three samples per strip
Definition SVDModeByte.h:59
constexpr uint8_t daq_1sample
one sample per strip
Definition SVDModeByte.h:58
constexpr uint8_t daq_6samples
six samples per strip
Definition SVDModeByte.h:60
Event Type, 3 bits, separated into 1+2 bits:
Definition SVDModeByte.h:45
constexpr uint8_t global_run
global run
Definition SVDModeByte.h:47
constexpr uint8_t local_run
local run - should never happen
Definition SVDModeByte.h:48
Run type, 2-bits: 00 raw, 01 transparent, 10 zero-suppressed, 11 zero-suppressed + hit time finding.
Definition SVDModeByte.h:32
constexpr uint8_t zero_suppressed
Definition SVDModeByte.h:36
constexpr uint8_t raw
00.
Definition SVDModeByte.h:34
constexpr uint8_t zero_suppressed_timefit
Definition SVDModeByte.h:37
constexpr uint8_t transparent
01.
Definition SVDModeByte.h:35
Abstract base class for different kinds of events.