g4system
Loading...
Searching...
No Matches
g4volume.h
Go to the documentation of this file.
1#pragma once
21// c++
22#include <memory>
23
24// gemc
25#include <gemc/glogging/glogger.h>
26
27// ─── Geant4 includes ───────────────────────────────────────────────
28#include "G4FieldManager.hh"
29#include "G4LogicalVolume.hh"
30#include "G4RotationMatrix.hh"
31#include "G4ThreeVector.hh"
32#include "G4VPhysicalVolume.hh"
33#include "G4VSolid.hh"
34
52{
53public:
57 G4Volume() = default;
58
63 ~G4Volume() = default;
64
65 // ────── getters ────────────────────────────────────────────────
66
71 [[nodiscard]] G4VSolid* getSolid() const noexcept { return solidVolume; }
72
77 [[nodiscard]] G4LogicalVolume* getLogical() const noexcept { return logicalVolume; }
78
83 [[nodiscard]] G4VPhysicalVolume* getPhysical() const noexcept { return physicalVolume; }
84
92 [[nodiscard]] const G4RotationMatrix& getSolidRotation() const noexcept { return solidRotation; }
93
95 [[nodiscard]] const G4ThreeVector& getSolidTranslation() const noexcept { return solidTranslation; }
96
103 void setSolidPlacement(const G4RotationMatrix& rot, const G4ThreeVector& pos) {
104 solidRotation = rot;
105 solidTranslation = pos;
106 }
107
108 // ────── setters ────────────────────────────────────────────────
109
119 void setSolid(G4VSolid* s, const std::shared_ptr<GLogger>& log);
120
130 void setLogical(G4LogicalVolume* l, const std::shared_ptr<GLogger>& log);
131
141 void setPhysical(G4VPhysicalVolume* p, const std::shared_ptr<GLogger>& log);
142
153 void setFieldManager(G4FieldManager* fm, bool forceToAllDaughters);
154
155private:
156 // ────── data members ───────────────────────────────────────────
157
159 G4VSolid* solidVolume{nullptr};
160
162 G4RotationMatrix solidRotation;
163
165 G4ThreeVector solidTranslation;
166
168 G4LogicalVolume* logicalVolume{nullptr};
169
171 G4VPhysicalVolume* physicalVolume{nullptr};
172};
Convenience container holding a Geant4 solid, logical, and physical volume.
Definition g4volume.h:52
const G4RotationMatrix & getSolidRotation() const noexcept
Return the volume's local frame rotation, recorded at solid-creation time.
Definition g4volume.h:92
void setLogical(G4LogicalVolume *l, const std::shared_ptr< GLogger > &log)
Store a G4LogicalVolume pointer and log the assignment.
Definition g4volume.cc:16
G4VSolid * getSolid() const noexcept
Return the stored G4VSolid pointer.
Definition g4volume.h:71
void setPhysical(G4VPhysicalVolume *p, const std::shared_ptr< GLogger > &log)
Store a G4VPhysicalVolume pointer and log the assignment.
Definition g4volume.cc:22
G4VPhysicalVolume * getPhysical() const noexcept
Return the stored G4VPhysicalVolume pointer.
Definition g4volume.h:83
G4LogicalVolume * getLogical() const noexcept
Return the stored G4LogicalVolume pointer.
Definition g4volume.h:77
void setFieldManager(G4FieldManager *fm, bool forceToAllDaughters)
Attach a G4FieldManager to the stored logical volume, if present.
Definition g4volume.cc:28
~G4Volume()=default
Destructor (no-op).
void setSolidPlacement(const G4RotationMatrix &rot, const G4ThreeVector &pos)
Record the volume's local frame rotation and position.
Definition g4volume.h:103
void setSolid(G4VSolid *s, const std::shared_ptr< GLogger > &log)
Store a G4VSolid pointer and log the assignment.
Definition g4volume.cc:10
const G4ThreeVector & getSolidTranslation() const noexcept
Return the volume's local position, recorded at solid-creation time.
Definition g4volume.h:95
G4Volume()=default
Default construct an empty wrapper (all pointers set to nullptr).