LDMX Software
PtrRetrieval.h
1#ifndef SIMCORE_PTRRETRIEVAL_H
2#define SIMCORE_PTRRETRIEVAL_H
3
4//----------------//
5// C++ StdLib //
6//----------------//
7#include <string>
8
9//------------//
10// Geant4 //
11//------------//
12#include "G4Gamma.hh"
13#include "G4LogicalVolume.hh"
14#include "G4LogicalVolumeStore.hh"
15#include "G4ParticleDefinition.hh"
16#include "G4PhysicalVolumeStore.hh"
17#include "G4ProcessManager.hh"
18#include "G4Region.hh"
19#include "G4RegionStore.hh"
20#include "G4VPhysicalVolume.hh"
21
22namespace simcore {
23namespace g4user {
24namespace ptrretrieval {
25
32inline const G4VProcess* getProcess(const G4ParticleDefinition* particle,
33 const std::string& processName) {
34 if (!particle) return nullptr;
35
36 const auto manager = particle->GetProcessManager();
37 if (!manager) return nullptr;
38
39 const auto processes = manager->GetProcessList();
40 for (int i = 0; i < processes->size(); ++i) {
41 const auto process = (*processes)[i];
42 if (process->GetProcessName().find(processName) != std::string::npos) {
43 return process;
44 }
45 }
46 return nullptr;
47}
48
53inline const G4VProcess* getPhotonuclearProcess() {
54 return getProcess(G4Gamma::Definition(), "photonNuclear");
55}
56
72inline G4Region* getRegion(const std::string& name) {
73 G4Region* region = G4RegionStore::GetInstance()->GetRegion(name);
74 if (!region) {
75 return nullptr;
76 }
77 return region;
78}
79
85inline G4VPhysicalVolume* getPhysicalVolume(const std::string& name) {
86 auto* volume = G4PhysicalVolumeStore::GetInstance()->GetVolume(name);
87 if (!volume) {
88 return nullptr;
89 }
90 return volume;
91}
92
98inline G4LogicalVolume* getLogicalVolume(const std::string& name) {
99 auto* volume = G4LogicalVolumeStore::GetInstance()->GetVolume(name);
100 if (!volume) {
101 return nullptr;
102 }
103 return volume;
104}
105
114inline G4Material* getMaterial(const std::string& name) {
115 auto* material = G4Material::GetMaterial(name);
116 if (!material) {
117 return nullptr;
118 }
119 return material;
120}
121
122} // namespace ptrretrieval
123} // namespace g4user
124} // namespace simcore
125#endif // SIMCORE_PTRRETRIEVAL_H
This namespace is meant to contain all the standard user actions that allow a Geant4 user to interfac...
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...