19#include "BDSSampler.hh"
20#include "BDSSamplerRegistry.hh"
23#include "G4Transform3D.hh"
25#include "CLHEP/Units/SystemOfUnits.h"
45 {BDSSamplerType::cylinder, BDSSamplerType::cylinder},
46 {BDSSamplerType::cylinderforward, BDSSamplerType::cylinder},
47 {BDSSamplerType::sphere, BDSSamplerType::sphere},
48 {BDSSamplerType::sphereforward, BDSSamplerType::sphere} };
49 samplerIDsPerType[BDSSamplerType::plane] = std::vector<G4int>();
50 samplerIDsPerType[BDSSamplerType::cylinder] = std::vector<G4int>();
51 samplerIDsPerType[BDSSamplerType::sphere] = std::vector<G4int>();
54BDSSamplerRegistry::~BDSSamplerRegistry()
63 const G4Transform3D& transform,
70 G4String uniqueName = name;
78 uniqueName = name +
"_" + std::to_string(
existingNames[name]);
87 infos.push_back(info);
99 std::vector<G4String> names;
100 for (
const auto& info :
infos)
101 {names.push_back(info.
Name());}
107 std::vector<G4String> names;
108 for (
const auto& info :
infos)
113std::vector<G4String> BDSSamplerRegistry::GetUniqueNamesPlane()
const
115 std::vector<G4String> names;
116 for (
const auto& info:
infos)
118 if (info.
Type() == BDSSamplerType::plane)
124std::vector<G4String> BDSSamplerRegistry::GetUniqueNamesCylinder()
const
126 std::vector<G4String> names;
127 for (
const auto& info:
infos)
129 if (info.
Type() == BDSSamplerType::cylinder || info.
Type() == BDSSamplerType::cylinderforward)
135std::vector<G4String> BDSSamplerRegistry::GetUniqueNamesSphere()
const
137 std::vector<G4String> names;
138 for (
const auto& info:
infos)
140 if (info.
Type() == BDSSamplerType::sphere || info.
Type() == BDSSamplerType::sphereforward)
148 std::map<std::string, double> result;
149 for (
const auto& info:
infos)
151 if (info.
Type() == BDSSamplerType::cylinder || info.
Type() == BDSSamplerType::cylinderforward)
152 {result[
static_cast<std::string
>(info.
UniqueName())] = info.
Radius()/CLHEP::m;}
159 std::map<std::string, double> result;
160 for (
const auto& info:
infos)
162 if (info.
Type() == BDSSamplerType::sphere || info.
Type() == BDSSamplerType::sphereforward)
163 {result[
static_cast<std::string
>(info.
UniqueName())] = info.
Radius()/CLHEP::m;}
170 std::vector<std::pair<G4String, G4double> > result;
171 for (
const auto& info :
infos)
173 if (info.
Type() == BDSSamplerType::plane)
A class that holds a fully constructed BDSAcceleratorComponent as well as any information relevant to...
Information about a registered sampler.
BDSSamplerType Type() const
Accessor.
G4String Name() const
Accessor.
G4double SPosition() const
Accessor.
G4String UniqueName() const
Accessor.
G4double Radius() const
Accessor.
Associated information for the placement of a sampler.
std::vector< std::pair< G4String, G4double > > GetUniquePlaneNamesAndSPosition() const
Access all the unique names and their corresponding s position at once.
std::map< BDSSamplerType, BDSSamplerType > samplerTypeToCategory
Map to reduce 'forward' sampler types to simple sampler types for keeping a record of IDs.
std::map< std::string, double > GetUniqueNameToRadiusSphere() const
For output in standard C++ types. Also in m for units.
std::map< G4String, G4int > existingNames
static BDSSamplerRegistry * Instance()
Accessor for registry.
std::vector< G4String > GetUniqueNames() const
Access all the unique names at once.
InfoVector infos
Storage of registered information.
static BDSSamplerRegistry * instance
Singleton instance.
std::vector< G4String > GetNames() const
Access all names at once.
BDSSamplerRegistry()
Private constructor to enforce singleton pattern.
std::set< BDSSampler * > samplerObjects
Cache of unique sampler objects for memory management.
G4int RegisterSampler(const G4String &name, BDSSampler *sampler, const G4Transform3D &transform=G4Transform3D(), G4double S=-1000, const BDSBeamlineElement *element=nullptr, BDSSamplerType type=BDSSamplerType::plane, G4double radius=0)
std::map< std::string, double > GetUniqueNameToRadiusCylinder() const
For output in standard C++ types. Also in m for units.
Base class and registry of sampler instances.