Belle II Software development
vxd data objects

Classes

class  VXDElectronDeposit
 Packed class to represent energy deposit along a path in electrons. More...
 
class  VxdID
 Class to uniquely identify a any structure of the PXD and SVD. More...
 
class  VXDSimHit
 Class VXDSimHit - Geant4 simulated hit for the VXD. More...
 
class  VXDTrueHit
 Class VXDTrueHit - Records of tracks that either enter or leave the sensitive volume. More...
 

Functions

std::ostream & operator<< (std::ostream &out, const VxdID &id)
 Print id to stream by converting it to string.
 
 VxdID (const std::string &sensor)
 Construct ID from string representing the structure.
 
 operator std::string () const
 Convert to string.
 

Detailed Description

Function Documentation

◆ operator std::string()

operator std::string ( ) const

Convert to string.

Definition at line 84 of file VxdID.cc.

85 {
86 std::stringstream out;
87 if (m_id.parts.layer) {
88 out << m_id.parts.layer;
89 } else {
90 out << "*";
91 }
92 if (m_id.parts.ladder || m_id.parts.sensor) {
93 out << ".";
94 if (m_id.parts.ladder) {
95 out << m_id.parts.ladder;
96 } else {
97 out << "*";
98 }
99 }
100 if (m_id.parts.sensor) {
101 out << "." << m_id.parts.sensor;
102 }
103 if (m_id.parts.segment) {
104 out << "#" << m_id.parts.segment;
105 }
106 return out.str();
107 }
union Belle2::VxdID::@305 m_id
Union to store the ID and all components in one go.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  out,
const VxdID id 
)

Print id to stream by converting it to string.

Definition at line 109 of file VxdID.cc.

110 {
111 out << ((std::string)id);
112 return out;
113 }

◆ VxdID()

VxdID ( const std::string &  sensor)
explicit

Construct ID from string representing the structure.

Definition at line 52 of file VxdID.cc.

53 {
54 //We parse the Id from string, so set it to 0 first
55 m_id.id = 0;
56 //create a stream from the string
57 std::istringstream in(sensor);
58 try {
59 //Get all the parts
60 m_id.parts.layer = getPart(in);
61 m_id.parts.ladder = getPart(in);
62 m_id.parts.sensor = getPart(in);
63 //Check if we also have a segment specified, if so get it
64 if (in.peek() == '#') {
65 in.get();
66 m_id.parts.segment = getPart(in);
67 }
68 } catch (std::runtime_error&) {
69 //Something went wrong parsing the parts
70 m_id.id = 0;
71 throw std::invalid_argument("Could not parse VxdID: '" + sensor + "'");
72 }
73 //There is stuff left we also throw an exception as we cannot warn the user
74 //without the logging system
75 if (!in.eof()) {
76 std::string rest;
77 //Get the remainder: get everything in the stream until the next NULL
78 //character which should only occur at the end of the string.
79 getline(in, rest, '\0');
80 throw std::invalid_argument("Trailing characters after VxdID " + std::string(*this) + ": '" + rest + "'");
81 }
82 }
baseType sensor
Sensor id.
Definition: VxdID.h:128