gsystem
Loading...
Searching...
No Matches
gvolume.h
Go to the documentation of this file.
1#pragma once
2
3// namespace needed for the inline functions below
4#include "gutilities.h"
5#include "gbase.h"
6
7// c++
8#include <string>
9#include <utility>
10
32class GVolume : public GBase<GVolume>
33{
34public:
56 GVolume(const std::shared_ptr<GLogger>& log,
57 const std::string& system,
58 std::vector<std::string> pars,
59 const std::string& importPath = UNINITIALIZEDSTRINGQUANTITY);
60
71 explicit GVolume(const std::string& rootVolumeDefinition, const std::shared_ptr<GLogger>& log);
72
81 [[nodiscard]] virtual std::unique_ptr<GVolume> clone() const {
82 return std::make_unique<GVolume>(*this);
83 }
84
86 virtual ~GVolume() = default;
87
88private:
89 std::string system;
90 std::string name;
91 std::string motherName;
92 std::string description;
93 std::string importFilename;
94
95 // solid parameters
96 std::string type;
97 std::string parameters;
98
99 // solid visualization style
100 bool visible{};
101 int style{};
102 std::string color;
103 double opacity{};
104
105 // logical attributes
106 std::string material;
107 std::string emfield;
108
109 // physical attributes
110 std::string pos;
111 std::string rot;
112 std::string shift;
113 std::string tilt;
114 bool exist{};
115
116 std::string digitization;
117 std::string gidentity;
118
119 // special cases
120 std::string copyOf;
121 std::string solidsOpr;
122
123 int pCopyNo{};
124
125 // mirrors
126 std::string mirror;
127
128 // the map key names used in geant4 contain the system name
129 // these are assigned by gworld after all volumes are loaded
130 std::string g4name;
131 std::string g4motherName;
132
133 // variation and run number for this gvolume
134 std::string variation;
135 int runno{};
136
138 friend std::ostream& operator<<(std::ostream& stream, const GVolume&);
139
140public:
143 [[nodiscard]] std::string getSystem() const { return system; }
144 [[nodiscard]] std::string getName() const { return name; }
145 [[nodiscard]] std::string getMotherName() const { return motherName; }
146 [[nodiscard]] std::string getG4Name() const { return g4name; }
147 [[nodiscard]] std::string getG4MotherName() const { return g4motherName; }
149
158 [[nodiscard]] std::vector<double> getDetectorDimensions() const {
159 if (parameters == UNINITIALIZEDSTRINGQUANTITY) { return {0}; }
160 return gutilities::getG4NumbersFromString(parameters);
161 }
162
165 [[nodiscard]] std::string getType() const { return type; }
166 [[nodiscard]] std::string getParameters() const { return parameters; }
168
171 [[nodiscard]] std::string getMaterial() const { return material; }
172 [[nodiscard]] std::string getEMField() const { return emfield; }
174
177 [[nodiscard]] int getPCopyNo() const { return pCopyNo; }
178 [[nodiscard]] std::string_view getColor() const { return color; }
179 [[nodiscard]] double getOpacity() const { return opacity; }
180 [[nodiscard]] bool isVisible() const { return visible; }
181 [[nodiscard]] int getStyle() const { return style; }
183
186 [[nodiscard]] bool getExistence() const { return exist; }
187 [[nodiscard]] std::string getPos() const { return pos; }
188 [[nodiscard]] std::string getRot() const { return rot; }
189 [[nodiscard]] std::string getShift() const { return shift; }
190 [[nodiscard]] std::string getTilt() const { return tilt; }
192
195 [[nodiscard]] std::string getDigitization() const { return digitization; }
196 [[nodiscard]] std::string getGIdentity() const { return gidentity; }
198
201 [[nodiscard]] std::string getCopyOf() const { return copyOf; }
202 [[nodiscard]] std::string getSolidsOpr() const { return solidsOpr; }
203 [[nodiscard]] std::string getDescription() const { return description; }
205
208
216 void applyShift(std::string s) { shift = std::move(s); }
217
226 void applyTilt(std::string t) { tilt = std::move(t); }
227
236 void modifyExistence(bool e) { exist = e; }
237
239 void resetMotherName(std::string m) { motherName = std::move(m); }
240
242 void setColor(std::string c) { color = std::move(c); }
243
245 void setMaterial(std::string m) { material = std::move(m); }
246
248 void setDigitization(std::string d) { digitization = std::move(d); }
249
251 void setGIdentity(std::string g) { gidentity = std::move(g); }
253
262 std::string getImportedFile() { return importFilename; }
263
273 inline void assignG4Names(const std::string& g4n, const std::string& g4m) {
274 g4name = g4n;
275 g4motherName = g4m;
276 }
277};
std::shared_ptr< GLogger > log
Geometry volume record loaded into a GSystem.
Definition gvolume.h:33
std::string getDescription() const
Definition gvolume.h:203
void resetMotherName(std::string m)
Override the mother name (placement parent) after loading.
Definition gvolume.h:239
GVolume(const std::shared_ptr< GLogger > &log, const std::string &system, std::vector< std::string > pars, const std::string &importPath=UNINITIALIZEDSTRINGQUANTITY)
Construct a volume from a serialized parameter vector.
Definition gvolume.cc:18
std::string getRot() const
Definition gvolume.h:188
void setGIdentity(std::string g)
Override the identity string after loading.
Definition gvolume.h:251
void setColor(std::string c)
Override the color after loading.
Definition gvolume.h:242
std::string getGIdentity() const
Definition gvolume.h:196
void assignG4Names(const std::string &g4n, const std::string &g4m)
Assign Geant4 names after all volumes are loaded.
Definition gvolume.h:273
std::string getCopyOf() const
Definition gvolume.h:201
virtual ~GVolume()=default
Virtual destructor (safe deletion through base pointers).
virtual std::unique_ptr< GVolume > clone() const
Polymorphic deep-copy.
Definition gvolume.h:81
bool getExistence() const
Definition gvolume.h:186
std::string getImportedFile()
Return the import filename (path) for imported volumes.
Definition gvolume.h:262
std::string getEMField() const
Definition gvolume.h:172
std::string getPos() const
Definition gvolume.h:187
int getPCopyNo() const
Definition gvolume.h:177
std::string getShift() const
Definition gvolume.h:189
std::string getDigitization() const
Definition gvolume.h:195
std::string getName() const
Definition gvolume.h:144
void modifyExistence(bool e)
Enable or disable this volume in the final assembled world.
Definition gvolume.h:236
std::string getParameters() const
Definition gvolume.h:166
std::string getMaterial() const
Definition gvolume.h:171
void setDigitization(std::string d)
Override the digitization label after loading.
Definition gvolume.h:248
std::string getG4Name() const
Definition gvolume.h:146
void applyTilt(std::string t)
Apply an additional rotation to this volume.
Definition gvolume.h:226
void applyShift(std::string s)
Apply an additional translation to this volume.
Definition gvolume.h:216
std::string getSystem() const
Definition gvolume.h:143
void setMaterial(std::string m)
Override the material name after loading.
Definition gvolume.h:245
int getStyle() const
Definition gvolume.h:181
std::vector< double > getDetectorDimensions() const
Returns numeric detector dimensions parsed from the parameters string.
Definition gvolume.h:158
friend std::ostream & operator<<(std::ostream &stream, const GVolume &)
Stream operator used for logging volume summaries.
Definition gvolume.cc:82
bool isVisible() const
Definition gvolume.h:180
std::string getType() const
Definition gvolume.h:165
std::string_view getColor() const
Definition gvolume.h:178
double getOpacity() const
Definition gvolume.h:179
std::string getG4MotherName() const
Definition gvolume.h:147
std::string getMotherName() const
Definition gvolume.h:145
std::string getSolidsOpr() const
Definition gvolume.h:202
std::string getTilt() const
Definition gvolume.h:190
#define UNINITIALIZEDSTRINGQUANTITY
vector< double > getG4NumbersFromString(const string &vstring, bool warnIfNotUnit=false)