9#include <vxd/dataobjects/VxdID.h>
24 int getPart(std::istream& in)
29 if (next ==
'.') next = in.get();
31 if (next ==
'*' or in.eof()) {
37 if (next ==
'#')
return 0;
43 if (in.fail() && !in.eof()) {
44 throw std::runtime_error(
"Failed to parse Number");
57 std::istringstream in(
sensor);
60 m_id.parts.layer = getPart(in);
61 m_id.parts.ladder = getPart(in);
62 m_id.parts.sensor = getPart(in);
64 if (in.peek() ==
'#') {
66 m_id.parts.segment = getPart(in);
68 }
catch (std::runtime_error&) {
71 throw std::invalid_argument(
"Could not parse VxdID: '" +
sensor +
"'");
79 getline(in, rest,
'\0');
80 throw std::invalid_argument(
"Trailing characters after VxdID " + std::string(*
this) +
": '" + rest +
"'");
84 VxdID::operator std::string()
const
86 std::stringstream out;
87 if (m_id.parts.layer) {
88 out << m_id.parts.layer;
92 if (m_id.parts.ladder || m_id.parts.sensor) {
94 if (m_id.parts.ladder) {
95 out << m_id.parts.ladder;
100 if (m_id.parts.sensor) {
101 out <<
"." << m_id.parts.sensor;
103 if (m_id.parts.segment) {
104 out <<
"#" << m_id.parts.segment;
111 out << ((std::string)
id);
Class to uniquely identify a any structure of the PXD and SVD.
union Belle2::VxdID::@305 m_id
Union to store the ID and all components in one go.
VxdID(baseType id=0)
Constructor using the unique id.
baseType sensor
Sensor id.
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Abstract base class for different kinds of events.