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 {
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 }
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 }
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; }
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; }
173 { m_id.parts.daqMode = daqMode; }
176 { m_id.parts.eventType = eventType; }
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
Class to store SVD mode information.
Definition: SVDModeByte.h:69
std::string __str__() const
make this type printable in python with print(vxd_id)
Definition: SVDModeByte.h:182
void setTriggerBin(baseType triggerBin)
Set the triggerBin id.
Definition: SVDModeByte.h:169
@ 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
baseType getID() const
Get the unique id.
Definition: SVDModeByte.h:138
baseType id
Unique id.
Definition: SVDModeByte.h:189
baseType triggerBin
Trigger time id.
Definition: SVDModeByte.h:192
void setDAQMode(baseType daqMode)
Set the daqMode id.
Definition: SVDModeByte.h:172
struct Belle2::SVDModeByte::@241::@242 parts
< Struct to contain all id components
SVDModeByte(baseType runType, baseType eventType, baseType daqMode, baseType triggerBin)
Constructor using triggerBin, daqMode etc.
Definition: SVDModeByte.h:115
baseType getRunType() const
Get the runMode id.
Definition: SVDModeByte.h:146
bool operator==(const SVDModeByte &b) const
Check for equality.
Definition: SVDModeByte.h:135
SVDModeByte & operator=(const SVDModeByte &b)
Assignment operator.
Definition: SVDModeByte.h:127
void setEventType(baseType eventType)
Set the eventType id.
Definition: SVDModeByte.h:175
baseType getEventType() const
Get the eventMode id.
Definition: SVDModeByte.h:144
baseType runType
Run type id.
Definition: SVDModeByte.h:198
union Belle2::SVDModeByte::@241 m_id
Union to store the ID and all components in one go.
void setRunType(baseType runType)
Set the runType id.
Definition: SVDModeByte.h:178
baseType daqMode
DAQ mode id.
Definition: SVDModeByte.h:194
baseType getTriggerBin() const
Get the triggerBin id.
Definition: SVDModeByte.h:140
SVDModeByte(baseType id=c_DefaultID)
Constructor using the unique id.
Definition: SVDModeByte.h:110
void setID(baseType id)
Set the unique id.
Definition: SVDModeByte.h:167
uint8_t baseType
The base integer type for SVDModeByte.
Definition: SVDModeByte.h:72
SVDModeByte & operator=(baseType id)
Assignment from baseType.
Definition: SVDModeByte.h:129
SVDModeByte(const SVDModeByte &b)
Copy constructor.
Definition: SVDModeByte.h:124
bool isZeroSuppressedRun() const
Do we have useful run type? A useful run is.
Definition: SVDModeByte.h:157
bool hasTimeFit() const
Do we have time fit information?
Definition: SVDModeByte.h:150
baseType getDAQMode() const
Get the daqMode id.
Definition: SVDModeByte.h:142
baseType eventType
Event type id.
Definition: SVDModeByte.h:196
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,...
Definition: SVDModeByte.h:106
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
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
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.