18#include "BDSSampler.hh"
19#include "BDSSamplerRegistry.hh"
22#include "G4Transform3D.hh"
24#include "CLHEP/Units/SystemOfUnits.h"
44 {BDSSamplerType::cylinder, BDSSamplerType::cylinder},
45 {BDSSamplerType::cylinderforward, BDSSamplerType::cylinder},
46 {BDSSamplerType::sphere, BDSSamplerType::sphere},
47 {BDSSamplerType::sphereforward, BDSSamplerType::sphere} };
48 samplerIDsPerType[BDSSamplerType::plane] = std::vector<G4int>();
49 samplerIDsPerType[BDSSamplerType::cylinder] = std::vector<G4int>();
50 samplerIDsPerType[BDSSamplerType::sphere] = std::vector<G4int>();
53BDSSamplerRegistry::~BDSSamplerRegistry()
62 const G4Transform3D& transform,
69 G4String uniqueName = name;
77 uniqueName = name +
"_" + std::to_string(
existingNames[name]);
86 infos.push_back(info);
98 std::vector<G4String> names;
99 for (
const auto& info :
infos)
100 {names.push_back(info.
Name());}
106 std::vector<G4String> names;
107 for (
const auto& info :
infos)
112std::vector<G4String> BDSSamplerRegistry::GetUniqueNamesPlane()
const
114 std::vector<G4String> names;
115 for (
const auto& info:
infos)
117 if (info.
Type() == BDSSamplerType::plane)
123std::vector<G4String> BDSSamplerRegistry::GetUniqueNamesCylinder()
const
125 std::vector<G4String> names;
126 for (
const auto& info:
infos)
128 if (info.
Type() == BDSSamplerType::cylinder || info.
Type() == BDSSamplerType::cylinderforward)
134std::vector<G4String> BDSSamplerRegistry::GetUniqueNamesSphere()
const
136 std::vector<G4String> names;
137 for (
const auto& info:
infos)
139 if (info.
Type() == BDSSamplerType::sphere || info.
Type() == BDSSamplerType::sphereforward)
147 std::map<std::string, double> result;
148 for (
const auto& info:
infos)
150 if (info.
Type() == BDSSamplerType::cylinder || info.
Type() == BDSSamplerType::cylinderforward)
151 {result[
static_cast<std::string
>(info.
UniqueName())] = info.
Radius()/CLHEP::m;}
158 std::map<std::string, double> result;
159 for (
const auto& info:
infos)
161 if (info.
Type() == BDSSamplerType::sphere || info.
Type() == BDSSamplerType::sphereforward)
162 {result[
static_cast<std::string
>(info.
UniqueName())] = info.
Radius()/CLHEP::m;}
169 std::vector<std::pair<G4String, G4double> > result;
170 for (
const auto& info :
infos)
172 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.