BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
Associated information for the placement of a sampler. More...
#include <BDSSamplerRegistry.hh>
Public Member Functions | |
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) |
G4int | RegisterSampler (BDSSamplerPlacementRecord &info) |
std::vector< G4String > | GetNames () const |
Access all names at once. | |
std::vector< G4String > | GetUniqueNames () const |
Access all the unique names at once. | |
std::vector< G4String > | GetUniqueNamesPlane () const |
std::vector< G4String > | GetUniqueNamesCylinder () const |
std::vector< G4String > | GetUniqueNamesSphere () const |
std::vector< G4int > | GetSamplerIDsPlane () const |
std::vector< G4int > | GetSamplerIDsCylinder () const |
std::vector< G4int > | GetSamplerIDsSphere () const |
std::vector< std::pair< G4String, G4double > > | GetUniquePlaneNamesAndSPosition () const |
Access all the unique names and their corresponding s position at once. | |
G4int | NumberOfExistingSamplers () const |
Get number of registered samplers. | |
size_t | size () const |
G4bool | SafeIndex (G4int index) const |
G4String | GetName (G4int index) const |
Accessor. | |
G4String | GetNameUnique (G4int index) const |
Accessor. | |
BDSSampler * | GetSampler (G4int index) const |
Accessor. | |
G4Transform3D | GetTransform (G4int index) const |
Accessor. | |
G4Transform3D | GetTransformInverse (G4int index) const |
Accessor. | |
G4double | GetSPosition (G4int index) const |
Accessor. | |
const BDSSamplerPlacementRecord & | GetInfo (G4int index) const |
Accessor. | |
G4int | GetBeamlineIndex (G4int index) const |
Accessor. | |
std::map< std::string, double > | GetUniqueNameToRadiusCylinder () const |
For output in standard C++ types. Also in m for units. | |
std::map< std::string, double > | GetUniqueNameToRadiusSphere () const |
For output in standard C++ types. Also in m for units. | |
Static Public Member Functions | |
static BDSSamplerRegistry * | Instance () |
Accessor for registry. | |
Private Types | |
typedef std::vector< BDSSamplerPlacementRecord > | InfoVector |
Typedefs up first so we can declare public iterators. | |
Private Member Functions | |
BDSSamplerRegistry () | |
Private constructor to enforce singleton pattern. | |
Private Attributes | |
InfoVector | infos |
Storage of registered information. | |
G4int | numberOfEntries |
std::map< G4String, G4int > | existingNames |
std::set< BDSSampler * > | samplerObjects |
Cache of unique sampler objects for memory management. | |
std::map< BDSSamplerType, BDSSamplerType > | samplerTypeToCategory |
Map to reduce 'forward' sampler types to simple sampler types for keeping a record of IDs. | |
std::map< BDSSamplerType, std::vector< G4int > > | samplerIDsPerType |
Static Private Attributes | |
static BDSSamplerRegistry * | instance = nullptr |
Singleton instance. | |
typedef InfoVector::iterator | iterator |
Iterator mechanics. | |
typedef InfoVector::const_iterator | const_iterator |
Iterator mechanics. | |
iterator | begin () |
Iterator mechanics. | |
iterator | end () |
Iterator mechanics. | |
const_iterator | begin () const |
Iterator mechanics. | |
const_iterator | end () const |
Iterator mechanics. | |
G4bool | empty () const |
Iterator mechanics. | |
Associated information for the placement of a sampler.
This singleton registry stores the transform and S position for a given sampler. This may simply be a placement of the same sampler object again. It does not own the samplers. Registration of a sampler returns an unique integer that should be used as the copy number for that placement so that BDSSDSampler will find the correct information for the sampler registered here. Also, this integer is used for output purposes as a unique output identifier. Note, if a sampler is placed in the real mass world inside a component it may not be known at construction time where this will lie in the world, therefore a default identity transform and s position can be used signalling BDSSDSampler to look up the transform dynamically. The BDSSampler* registered in each case isn't currently used, so a nullptr can also be registered safely - in case BDSSDSampler is attached to an arbitrary logical volume not part of a BDSSampler instance.
This owns all BDSSampler instances.
Definition at line 58 of file BDSSamplerRegistry.hh.
typedef InfoVector::const_iterator BDSSamplerRegistry::const_iterator |
Iterator mechanics.
Definition at line 98 of file BDSSamplerRegistry.hh.
|
private |
Typedefs up first so we can declare public iterators.
Definition at line 62 of file BDSSamplerRegistry.hh.
typedef InfoVector::iterator BDSSamplerRegistry::iterator |
Iterator mechanics.
Definition at line 97 of file BDSSamplerRegistry.hh.
BDSSamplerRegistry::~BDSSamplerRegistry | ( | ) |
Definition at line 54 of file BDSSamplerRegistry.cc.
|
private |
Private constructor to enforce singleton pattern.
Definition at line 41 of file BDSSamplerRegistry.cc.
References samplerTypeToCategory.
Referenced by Instance().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Accessor.
Definition at line 113 of file BDSSamplerRegistry.hh.
References infos.
Referenced by BDSEventAction::IdentifyTrajectoriesForStorage(), BDSSDSampler::ProcessHits(), BDSSDSamplerCylinder::ProcessHits(), and BDSSDSamplerSphere::ProcessHits().
|
inline |
std::vector< G4String > BDSSamplerRegistry::GetNames | ( | ) | const |
Access all names at once.
Definition at line 97 of file BDSSamplerRegistry.cc.
References infos, and BDSSamplerPlacementRecord::Name().
|
inline |
Accessor.
Definition at line 171 of file BDSSamplerRegistry.hh.
References infos.
Referenced by BDSParallelWorldSampler::Construct().
|
inline |
|
inline |
Definition at line 132 of file BDSSamplerRegistry.hh.
|
inline |
Definition at line 131 of file BDSSamplerRegistry.hh.
|
inline |
Definition at line 133 of file BDSSamplerRegistry.hh.
|
inline |
|
inline |
|
inline |
Accessor.
Definition at line 180 of file BDSSamplerRegistry.hh.
References infos.
Referenced by BDSSDSampler::ProcessHits(), BDSSDSamplerCylinder::ProcessHits(), and BDSSDSamplerSphere::ProcessHits().
std::vector< G4String > BDSSamplerRegistry::GetUniqueNames | ( | ) | const |
Access all the unique names at once.
Definition at line 105 of file BDSSamplerRegistry.cc.
References infos, and BDSSamplerPlacementRecord::UniqueName().
std::vector< G4String > BDSSamplerRegistry::GetUniqueNamesCylinder | ( | ) | const |
Definition at line 124 of file BDSSamplerRegistry.cc.
std::vector< G4String > BDSSamplerRegistry::GetUniqueNamesPlane | ( | ) | const |
Definition at line 113 of file BDSSamplerRegistry.cc.
std::vector< G4String > BDSSamplerRegistry::GetUniqueNamesSphere | ( | ) | const |
Definition at line 135 of file BDSSamplerRegistry.cc.
std::map< std::string, double > BDSSamplerRegistry::GetUniqueNameToRadiusCylinder | ( | ) | const |
For output in standard C++ types. Also in m for units.
Definition at line 146 of file BDSSamplerRegistry.cc.
References infos, BDSSamplerPlacementRecord::Radius(), BDSSamplerPlacementRecord::Type(), and BDSSamplerPlacementRecord::UniqueName().
std::map< std::string, double > BDSSamplerRegistry::GetUniqueNameToRadiusSphere | ( | ) | const |
For output in standard C++ types. Also in m for units.
Definition at line 157 of file BDSSamplerRegistry.cc.
References infos, BDSSamplerPlacementRecord::Radius(), BDSSamplerPlacementRecord::Type(), and BDSSamplerPlacementRecord::UniqueName().
std::vector< std::pair< G4String, G4double > > BDSSamplerRegistry::GetUniquePlaneNamesAndSPosition | ( | ) | const |
Access all the unique names and their corresponding s position at once.
Definition at line 168 of file BDSSamplerRegistry.cc.
References infos, BDSSamplerPlacementRecord::SPosition(), BDSSamplerPlacementRecord::Type(), and BDSSamplerPlacementRecord::UniqueName().
|
static |
Accessor for registry.
Definition at line 34 of file BDSSamplerRegistry.cc.
References BDSSamplerRegistry(), and instance.
Referenced by BDSMultilayerScreen::AddScreenLayer(), BDSScreenLayer::AssignSampler(), BDSParallelWorldSampler::Construct(), BDSOutputROOTEventModel::Fill(), BDSEventAction::IdentifyTrajectoriesForStorage(), BDSOutputStructures::InitialiseSamplers(), BDSSDSampler::Initialize(), BDSSDSamplerCylinder::Initialize(), BDSSDSamplerSphere::Initialize(), BDSParallelWorldSampler::Place(), BDSLinkDetectorConstruction::PlaceOneComponent(), BDSLinkOpaqueBox::PlaceOutputSampler(), BDSRunAction::SetTrajectorySamplerIDs(), BDSOutputStructures::UpdateSamplerStructures(), BDSIM::~BDSIM(), and BDSIMLink::~BDSIMLink().
|
inline |
Get number of registered samplers.
Definition at line 186 of file BDSSamplerRegistry.hh.
References numberOfEntries.
Referenced by BDSMultilayerScreen::AddScreenLayer().
G4int BDSSamplerRegistry::RegisterSampler | ( | BDSSamplerPlacementRecord & | info | ) |
Definition at line 85 of file BDSSamplerRegistry.cc.
G4int BDSSamplerRegistry::RegisterSampler | ( | const G4String & | name, |
BDSSampler * | sampler, | ||
const G4Transform3D & | transform = G4Transform3D() , |
||
G4double | S = -1000 , |
||
const BDSBeamlineElement * | element = nullptr , |
||
BDSSamplerType | type = BDSSamplerType::plane , |
||
G4double | radius = 0 |
||
) |
Register a sampler. This register an instance of a sampler (note could be same sampler object again and again) with a specific placement transform. The registration returns an integer that the sampler transform, name etc can be looked up in this registry by - ie by the output. The name does not need to be unique. This registry ensures the returned integer will be unique however. Default transform is unity - ie up to developer (outside registry) to test on this and determine transform externally as can't be known at construction time. The transform is the transform the sampler is placed with in the world volume, so the inverse is required to get global to local transformation. S is global s position with unphysical default of -1m.
Definition at line 61 of file BDSSamplerRegistry.cc.
References existingNames, RegisterSampler(), and samplerObjects.
Referenced by BDSScreenLayer::AssignSampler(), BDSParallelWorldSampler::Construct(), BDSParallelWorldSampler::Place(), BDSLinkDetectorConstruction::PlaceOneComponent(), BDSLinkOpaqueBox::PlaceOutputSampler(), and RegisterSampler().
|
inline |
Definition at line 142 of file BDSSamplerRegistry.hh.
|
inline |
Definition at line 189 of file BDSSamplerRegistry.hh.
|
private |
Store the already added names to ensure that a sampler can also have a unique name for output purposes. Also store the number of times that name has been used.
Definition at line 158 of file BDSSamplerRegistry.hh.
Referenced by RegisterSampler().
|
private |
Storage of registered information.
Definition at line 65 of file BDSSamplerRegistry.hh.
Referenced by begin(), empty(), end(), GetBeamlineIndex(), GetInfo(), GetName(), GetNames(), GetNameUnique(), GetSampler(), GetSPosition(), GetTransform(), GetTransformInverse(), GetUniqueNames(), GetUniqueNameToRadiusCylinder(), GetUniqueNameToRadiusSphere(), and GetUniquePlaneNamesAndSPosition().
|
staticprivate |
|
private |
Counter for easy checking of out of bounds and incrementing. Also the index in the member vectors, so zero counting.
Definition at line 153 of file BDSSamplerRegistry.hh.
Referenced by NumberOfExistingSamplers().
|
private |
Definition at line 165 of file BDSSamplerRegistry.hh.
|
private |
Cache of unique sampler objects for memory management.
Definition at line 161 of file BDSSamplerRegistry.hh.
Referenced by RegisterSampler().
|
private |
Map to reduce 'forward' sampler types to simple sampler types for keeping a record of IDs.
Definition at line 164 of file BDSSamplerRegistry.hh.
Referenced by BDSSamplerRegistry().