Belle II Software development
VxdID.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 VXDID_H
10#define VXDID_H
11
12#include <string>
13#include <ostream>
14
15namespace Belle2 {
33 class VxdID {
34 public:
36 typedef unsigned short baseType;
37 enum {
48
50 MaxLayer = (1 << LayerBits) - 1,
52 MaxLadder = (1 << LadderBits) - 1,
54 MaxSensor = (1 << SensorBits) - 1,
56 MaxSegment = (1 << SegmentBits) - 1,
58 MaxID = (1 << Bits) - 1
59 };
60
62 // cppcheck-suppress noExplicitConstructor
64 {
65 m_id.id = id;
66 }
69 {
70 m_id.parts.layer = layer;
71 m_id.parts.ladder = ladder;
72 m_id.parts.sensor = sensor;
73 m_id.parts.segment = segment;
74 }
76 explicit VxdID(const std::string& sensor);
78 VxdID(const VxdID& b): m_id(b.m_id) {}
79
81 VxdID& operator=(const VxdID& b) { m_id = b.m_id; return *this; }
83 VxdID& operator=(baseType id) { m_id.id = id; return *this; }
85 operator baseType() const { return getID(); }
87 operator std::string() const;
89 bool operator==(const VxdID& b) const { return getID() == b.getID(); }
91 bool operator<(const VxdID& b) const { return getID() < b.getID(); }
92
94 baseType getID() const { return m_id.id; }
96 baseType getLayerNumber() const { return m_id.parts.layer; }
98 baseType getLadderNumber() const { return m_id.parts.ladder; }
100 baseType getSensorNumber() const { return m_id.parts.sensor; }
102 baseType getSegmentNumber() const { return m_id.parts.segment; }
103
105 void setID(baseType id) { m_id.id = id; }
107 void setLayerNumber(baseType layer) { m_id.parts.layer = layer; }
109 void setLadderNumber(baseType ladder) { m_id.parts.ladder = ladder; }
111 void setSensorNumber(baseType sensor) { m_id.parts.sensor = sensor; }
113 void setSegmentNumber(baseType segment) { m_id.parts.segment = segment; }
114
116 std::string __str__() const { return (std::string)(*this); }
117
118 private:
119
120 union {
121 // *INDENT-OFF*
124 struct {
134 // *INDENT-ON*
136 };
137
139 std::ostream& operator<<(std::ostream& out, const VxdID& id);
141}
142
143#endif //VXDID_H
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
void setSegmentNumber(baseType segment)
Set the sensor segment.
Definition: VxdID.h:113
std::string __str__() const
make this type printable in python with print(vxd_id)
Definition: VxdID.h:116
baseType getID() const
Get the unique id.
Definition: VxdID.h:94
baseType id
Unique id.
Definition: VxdID.h:123
struct Belle2::VxdID::@305::@306 parts
< Struct to contain all id components
baseType getSensorNumber() const
Get the sensor id.
Definition: VxdID.h:100
baseType ladder
Ladder id.
Definition: VxdID.h:130
bool operator<(const VxdID &b) const
Order by unique id.
Definition: VxdID.h:91
VxdID(const VxdID &b)
Copy constructor.
Definition: VxdID.h:78
VxdID(baseType layer, baseType ladder, baseType sensor, baseType segment=0)
Constructor using layer, ladder and sensor ids.
Definition: VxdID.h:68
VxdID & operator=(baseType id)
Assignment from baseType.
Definition: VxdID.h:83
bool operator==(const VxdID &b) const
Check for equality.
Definition: VxdID.h:89
baseType segment
Segment id.
Definition: VxdID.h:126
union Belle2::VxdID::@305 m_id
Union to store the ID and all components in one go.
baseType getSegmentNumber() const
Get the sensor segment.
Definition: VxdID.h:102
void setID(baseType id)
Set the unique id.
Definition: VxdID.h:105
unsigned short baseType
The base integer type for VxdID.
Definition: VxdID.h:36
VxdID & operator=(const VxdID &b)
Assignment operator.
Definition: VxdID.h:81
void setSensorNumber(baseType sensor)
Set the sensor id.
Definition: VxdID.h:111
void setLadderNumber(baseType ladder)
Set the ladder id.
Definition: VxdID.h:109
VxdID(baseType id=0)
Constructor using the unique id.
Definition: VxdID.h:63
@ LadderBits
Number of bits available to represent a ladder.
Definition: VxdID.h:41
@ SensorBits
Number of bits available to represent a sensor.
Definition: VxdID.h:43
@ MaxLayer
Maximum valid Layer ID.
Definition: VxdID.h:50
@ SegmentBits
Number of bits available to represent segmentation of the sensor.
Definition: VxdID.h:45
@ MaxLadder
Maximum valid Ladder ID.
Definition: VxdID.h:52
@ MaxID
Maximum value for ID.
Definition: VxdID.h:58
@ MaxSegment
Maximum valid Segment ID.
Definition: VxdID.h:56
@ LayerBits
Number of bits available to represent a layer.
Definition: VxdID.h:39
@ MaxSensor
Maximum valid Sensor ID.
Definition: VxdID.h:54
@ Bits
Total bit size of the VxdID.
Definition: VxdID.h:47
baseType sensor
Sensor id.
Definition: VxdID.h:128
baseType getLadderNumber() const
Get the ladder id.
Definition: VxdID.h:98
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
void setLayerNumber(baseType layer)
Set the layer id.
Definition: VxdID.h:107
baseType layer
Layer id.
Definition: VxdID.h:132
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Abstract base class for different kinds of events.