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#pragma once
10
11#include <string>
12#include <ostream>
13
14namespace Belle2 {
32 class VxdID {
33 public:
35 typedef unsigned short baseType;
36 enum {
47
49 MaxLayer = (1 << LayerBits) - 1,
51 MaxLadder = (1 << LadderBits) - 1,
53 MaxSensor = (1 << SensorBits) - 1,
55 MaxSegment = (1 << SegmentBits) - 1,
57 MaxID = (1 << Bits) - 1
58 };
59
61 // cppcheck-suppress noExplicitConstructor
63 {
64 m_id.id = id;
65 }
66
68 {
69 m_id.parts.layer = layer;
70 m_id.parts.ladder = ladder;
71 m_id.parts.sensor = sensor;
72 m_id.parts.segment = segment;
73 }
74
75 explicit VxdID(const std::string& sensor);
77 VxdID(const VxdID& b): m_id(b.m_id) {}
78
80 VxdID& operator=(const VxdID& b) { m_id = b.m_id; return *this; }
82 VxdID& operator=(baseType id) { m_id.id = id; return *this; }
84 operator baseType() const { return getID(); }
86 operator std::string() const;
88 bool operator==(const VxdID& b) const { return getID() == b.getID(); }
90 bool operator<(const VxdID& b) const { return getID() < b.getID(); }
91
93 baseType getID() const { return m_id.id; }
95 baseType getLayerNumber() const { return m_id.parts.layer; }
97 baseType getLadderNumber() const { return m_id.parts.ladder; }
99 baseType getSensorNumber() const { return m_id.parts.sensor; }
101 baseType getSegmentNumber() const { return m_id.parts.segment; }
102
104 void setID(baseType id) { m_id.id = id; }
106 void setLayerNumber(baseType layer) { m_id.parts.layer = layer; }
108 void setLadderNumber(baseType ladder) { m_id.parts.ladder = ladder; }
110 void setSensorNumber(baseType sensor) { m_id.parts.sensor = sensor; }
112 void setSegmentNumber(baseType segment) { m_id.parts.segment = segment; }
113
115 std::string __str__() const { return (std::string)(*this); }
116
117 private:
118
119 union {
120 // *INDENT-OFF*
123 struct {
133 // *INDENT-ON*
135 };
136
138 std::ostream& operator<<(std::ostream& out, const VxdID& id);
140}
void setSegmentNumber(baseType segment)
Set the sensor segment.
Definition VxdID.h:112
std::string __str__() const
make this type printable in python with print(vxd_id)
Definition VxdID.h:115
baseType getID() const
Get the unique id.
Definition VxdID.h:93
baseType id
Unique id.
Definition VxdID.h:122
baseType getSensorNumber() const
Get the sensor id.
Definition VxdID.h:99
baseType ladder
Ladder id.
Definition VxdID.h:129
bool operator<(const VxdID &b) const
Order by unique id.
Definition VxdID.h:90
VxdID(const VxdID &b)
Copy constructor.
Definition VxdID.h:77
union Belle2::VxdID::@143023104105136016013021064024205015372005120247 m_id
Union to store the ID and all components in one go.
VxdID(baseType layer, baseType ladder, baseType sensor, baseType segment=0)
Constructor using layer, ladder and sensor ids.
Definition VxdID.h:67
VxdID & operator=(baseType id)
Assignment from baseType.
Definition VxdID.h:82
bool operator==(const VxdID &b) const
Check for equality.
Definition VxdID.h:88
baseType segment
Segment id.
Definition VxdID.h:125
@ LadderBits
Number of bits available to represent a ladder.
Definition VxdID.h:40
@ SensorBits
Number of bits available to represent a sensor.
Definition VxdID.h:42
@ MaxLayer
Maximum valid Layer ID.
Definition VxdID.h:49
@ SegmentBits
Number of bits available to represent segmentation of the sensor.
Definition VxdID.h:44
@ MaxLadder
Maximum valid Ladder ID.
Definition VxdID.h:51
@ MaxID
Maximum value for ID.
Definition VxdID.h:57
@ MaxSegment
Maximum valid Segment ID.
Definition VxdID.h:55
@ LayerBits
Number of bits available to represent a layer.
Definition VxdID.h:38
@ MaxSensor
Maximum valid Sensor ID.
Definition VxdID.h:53
@ Bits
Total bit size of the VxdID.
Definition VxdID.h:46
baseType getSegmentNumber() const
Get the sensor segment.
Definition VxdID.h:101
void setID(baseType id)
Set the unique id.
Definition VxdID.h:104
unsigned short baseType
The base integer type for VxdID.
Definition VxdID.h:35
VxdID & operator=(const VxdID &b)
Assignment operator.
Definition VxdID.h:80
struct Belle2::VxdID::@143023104105136016013021064024205015372005120247::@320010243252030131307025213014252054365164133356 parts
< Struct to contain all id components
void setSensorNumber(baseType sensor)
Set the sensor id.
Definition VxdID.h:110
void setLadderNumber(baseType ladder)
Set the ladder id.
Definition VxdID.h:108
VxdID(baseType id=0)
Constructor using the unique id.
Definition VxdID.h:62
baseType sensor
Sensor id.
Definition VxdID.h:127
baseType getLadderNumber() const
Get the ladder id.
Definition VxdID.h:97
baseType getLayerNumber() const
Get the layer id.
Definition VxdID.h:95
void setLayerNumber(baseType layer)
Set the layer id.
Definition VxdID.h:106
baseType layer
Layer id.
Definition VxdID.h:131
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Abstract base class for different kinds of events.