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 <gemc/guts/gutilities.h>
5#include <gemc/gbase/gbase.h>
6
7// c++
8#include <string>
9#include <utility>
10
33class GVolume : public GBase<GVolume>
34{
35public:
58 GVolume(const std::shared_ptr<GLogger>& log,
59 const std::string& system,
60 std::vector<std::string> pars,
61 const std::string& importPath = UNINITIALIZEDSTRINGQUANTITY);
62
73 explicit GVolume(const std::string& rootVolumeDefinition, const std::shared_ptr<GLogger>& log);
74
83 [[nodiscard]] virtual std::unique_ptr<GVolume> clone() const {
84 return std::make_unique<GVolume>(*this);
85 }
86
88 virtual ~GVolume() = default;
89
90private:
91 std::string system;
92 std::string name;
93 std::string motherName;
94 std::string description;
95 std::string importFilename;
96
97 // solid parameters
98 std::string type;
99 std::string parameters;
100
101 // solid visualization style
102 bool visible{};
103 int style{};
104 std::string color;
105 double opacity{};
106
107 // logical attributes
108 std::string material;
109 std::string emfield;
110
111 // physical attributes
112 std::string pos;
113 std::string rot;
114 std::string g4placementType;
115 std::string shift;
116 std::string tilt;
117 bool exist{};
118
119 std::string digitization;
120 std::string gidentity;
121
122 // special cases
123 std::string copyOf;
124 std::string solidsOpr;
125
126 int pCopyNo{};
127
128 // mirrors
129 std::string mirror;
130
131 // the map key names used in geant4 contain the system name
132 // these are assigned by gworld after all volumes are loaded
133 std::string g4name;
134 std::string g4motherName;
135
136 // variation and run number for this gvolume
137 std::string variation;
138 int runno{};
139
141 friend std::ostream& operator<<(std::ostream& stream, const GVolume&);
142
143public:
146 [[nodiscard]] std::string getSystem() const { return system; }
147 [[nodiscard]] std::string getName() const { return name; }
148 [[nodiscard]] std::string getMotherName() const { return motherName; }
149 [[nodiscard]] std::string getG4Name() const { return g4name; }
150 [[nodiscard]] std::string getG4MotherName() const { return g4motherName; }
152
161 [[nodiscard]] std::vector<double> getDetectorDimensions() const {
162 if (parameters == UNINITIALIZEDSTRINGQUANTITY) { return {0}; }
163 return gutilities::getG4NumbersFromString(parameters);
164 }
165
168 [[nodiscard]] std::string getType() const { return type; }
169 [[nodiscard]] std::string getParameters() const { return parameters; }
171
174 [[nodiscard]] std::string getMaterial() const { return material; }
175 [[nodiscard]] std::string getEMField() const { return emfield; }
177
180 [[nodiscard]] int getPCopyNo() const { return pCopyNo; }
181 [[nodiscard]] std::string_view getColor() const { return color; }
182 [[nodiscard]] double getOpacity() const { return opacity; }
183 [[nodiscard]] bool isVisible() const { return visible; }
184 [[nodiscard]] int getStyle() const { return style; }
186
189 [[nodiscard]] bool getExistence() const { return exist; }
190 [[nodiscard]] std::string getPos() const { return pos; }
191 [[nodiscard]] std::string getRot() const { return rot; }
192 [[nodiscard]] std::string getG4PlacementType() const { return g4placementType; }
193 [[nodiscard]] std::string getShift() const { return shift; }
194 [[nodiscard]] std::string getTilt() const { return tilt; }
196
199 [[nodiscard]] std::string getDigitization() const { return digitization; }
200 [[nodiscard]] std::string getGIdentity() const { return gidentity; }
202
205 [[nodiscard]] std::string getCopyOf() const { return copyOf; }
206 [[nodiscard]] std::string getSolidsOpr() const { return solidsOpr; }
207 [[nodiscard]] std::string getDescription() const { return description; }
209
212
220 void applyShift(std::string s) { shift = std::move(s); }
221
230 void applyTilt(std::string t) { tilt = std::move(t); }
231
240 void modifyExistence(bool e) { exist = e; }
241
243 void resetMotherName(std::string m) { motherName = std::move(m); }
244
246 void setColor(std::string c) { color = std::move(c); }
247
249 void setMaterial(std::string m) { material = std::move(m); }
250
252 void setDigitization(std::string d) { digitization = std::move(d); }
253
255 void setGIdentity(std::string g) { gidentity = std::move(g); }
257
266 std::string getImportedFile() { return importFilename; }
267
277 inline void assignG4Names(const std::string& g4n, const std::string& g4m) {
278 g4name = g4n;
279 g4motherName = g4m;
280 }
281};
std::shared_ptr< GLogger > log
Geometry volume record loaded into a GSystem.
Definition gvolume.h:34
std::string getDescription() const
Definition gvolume.h:207
void resetMotherName(std::string m)
Override the mother name (placement parent) after loading.
Definition gvolume.h:243
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:191
void setGIdentity(std::string g)
Override the identity string after loading.
Definition gvolume.h:255
void setColor(std::string c)
Override the color after loading.
Definition gvolume.h:246
std::string getGIdentity() const
Definition gvolume.h:200
void assignG4Names(const std::string &g4n, const std::string &g4m)
Assign Geant4 names after all volumes are loaded.
Definition gvolume.h:277
std::string getCopyOf() const
Definition gvolume.h:205
virtual ~GVolume()=default
Virtual destructor (safe deletion through base pointers).
virtual std::unique_ptr< GVolume > clone() const
Polymorphic deep-copy.
Definition gvolume.h:83
bool getExistence() const
Definition gvolume.h:189
std::string getImportedFile()
Return the import filename (path) for imported volumes.
Definition gvolume.h:266
std::string getEMField() const
Definition gvolume.h:175
std::string getPos() const
Definition gvolume.h:190
int getPCopyNo() const
Definition gvolume.h:180
std::string getShift() const
Definition gvolume.h:193
std::string getDigitization() const
Definition gvolume.h:199
std::string getG4PlacementType() const
Definition gvolume.h:192
std::string getName() const
Definition gvolume.h:147
void modifyExistence(bool e)
Enable or disable this volume in the final assembled world.
Definition gvolume.h:240
std::string getParameters() const
Definition gvolume.h:169
std::string getMaterial() const
Definition gvolume.h:174
void setDigitization(std::string d)
Override the digitization label after loading.
Definition gvolume.h:252
std::string getG4Name() const
Definition gvolume.h:149
void applyTilt(std::string t)
Apply an additional rotation to this volume.
Definition gvolume.h:230
void applyShift(std::string s)
Apply an additional translation to this volume.
Definition gvolume.h:220
std::string getSystem() const
Definition gvolume.h:146
void setMaterial(std::string m)
Override the material name after loading.
Definition gvolume.h:249
int getStyle() const
Definition gvolume.h:184
std::vector< double > getDetectorDimensions() const
Returns numeric detector dimensions parsed from the parameters string.
Definition gvolume.h:161
friend std::ostream & operator<<(std::ostream &stream, const GVolume &)
Stream operator used for logging volume summaries.
Definition gvolume.cc:90
bool isVisible() const
Definition gvolume.h:183
std::string getType() const
Definition gvolume.h:168
std::string_view getColor() const
Definition gvolume.h:181
double getOpacity() const
Definition gvolume.h:182
std::string getG4MotherName() const
Definition gvolume.h:150
std::string getMotherName() const
Definition gvolume.h:148
std::string getSolidsOpr() const
Definition gvolume.h:206
std::string getTilt() const
Definition gvolume.h:194
#define UNINITIALIZEDSTRINGQUANTITY
vector< double > getG4NumbersFromString(const string &vstring, bool warnIfNotUnit=false)