BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
BDSSamplerRegistry Class Reference

Associated information for the placement of a sampler. More...

#include <BDSSamplerRegistry.hh>

Collaboration diagram for BDSSamplerRegistry:
Collaboration graph

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.
 

Detailed Description

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.

Author
Laurie Nevay

Definition at line 57 of file BDSSamplerRegistry.hh.

Member Typedef Documentation

◆ const_iterator

typedef InfoVector::const_iterator BDSSamplerRegistry::const_iterator

Iterator mechanics.

Definition at line 97 of file BDSSamplerRegistry.hh.

◆ InfoVector

Typedefs up first so we can declare public iterators.

Definition at line 61 of file BDSSamplerRegistry.hh.

◆ iterator

typedef InfoVector::iterator BDSSamplerRegistry::iterator

Iterator mechanics.

Definition at line 96 of file BDSSamplerRegistry.hh.

Constructor & Destructor Documentation

◆ ~BDSSamplerRegistry()

BDSSamplerRegistry::~BDSSamplerRegistry ( )

Definition at line 53 of file BDSSamplerRegistry.cc.

◆ BDSSamplerRegistry()

BDSSamplerRegistry::BDSSamplerRegistry ( )
private

Private constructor to enforce singleton pattern.

Definition at line 40 of file BDSSamplerRegistry.cc.

References samplerTypeToCategory.

Referenced by Instance().

Here is the caller graph for this function:

Member Function Documentation

◆ begin() [1/2]

iterator BDSSamplerRegistry::begin ( )
inline

Iterator mechanics.

Definition at line 98 of file BDSSamplerRegistry.hh.

References infos.

◆ begin() [2/2]

const_iterator BDSSamplerRegistry::begin ( ) const
inline

Iterator mechanics.

Definition at line 100 of file BDSSamplerRegistry.hh.

References infos.

◆ empty()

G4bool BDSSamplerRegistry::empty ( ) const
inline

Iterator mechanics.

Definition at line 102 of file BDSSamplerRegistry.hh.

References infos.

◆ end() [1/2]

iterator BDSSamplerRegistry::end ( )
inline

Iterator mechanics.

Definition at line 99 of file BDSSamplerRegistry.hh.

References infos.

◆ end() [2/2]

const_iterator BDSSamplerRegistry::end ( ) const
inline

Iterator mechanics.

Definition at line 101 of file BDSSamplerRegistry.hh.

References infos.

◆ GetBeamlineIndex()

G4int BDSSamplerRegistry::GetBeamlineIndex ( G4int  index) const
inline

Accessor.

Definition at line 191 of file BDSSamplerRegistry.hh.

References infos.

◆ GetInfo()

const BDSSamplerPlacementRecord & BDSSamplerRegistry::GetInfo ( G4int  index) const
inline

Accessor.

Definition at line 112 of file BDSSamplerRegistry.hh.

References infos.

Referenced by BDSEventAction::IdentifyTrajectoriesForStorage(), BDSSDSampler::ProcessHits(), BDSSDSamplerCylinder::ProcessHits(), and BDSSDSamplerSphere::ProcessHits().

Here is the caller graph for this function:

◆ GetName()

G4String BDSSamplerRegistry::GetName ( G4int  index) const
inline

Accessor.

Definition at line 167 of file BDSSamplerRegistry.hh.

References infos.

◆ GetNames()

std::vector< G4String > BDSSamplerRegistry::GetNames ( ) const

Access all names at once.

Definition at line 96 of file BDSSamplerRegistry.cc.

References infos, and BDSSamplerPlacementRecord::Name().

Here is the call graph for this function:

◆ GetNameUnique()

G4String BDSSamplerRegistry::GetNameUnique ( G4int  index) const
inline

Accessor.

Definition at line 170 of file BDSSamplerRegistry.hh.

References infos.

Referenced by BDSParallelWorldSampler::Construct().

Here is the caller graph for this function:

◆ GetSampler()

BDSSampler * BDSSamplerRegistry::GetSampler ( G4int  index) const
inline

Accessor.

Definition at line 173 of file BDSSamplerRegistry.hh.

References infos.

◆ GetSamplerIDsCylinder()

std::vector< G4int > BDSSamplerRegistry::GetSamplerIDsCylinder ( ) const
inline

Definition at line 131 of file BDSSamplerRegistry.hh.

◆ GetSamplerIDsPlane()

std::vector< G4int > BDSSamplerRegistry::GetSamplerIDsPlane ( ) const
inline

Definition at line 130 of file BDSSamplerRegistry.hh.

◆ GetSamplerIDsSphere()

std::vector< G4int > BDSSamplerRegistry::GetSamplerIDsSphere ( ) const
inline

Definition at line 132 of file BDSSamplerRegistry.hh.

◆ GetSPosition()

G4double BDSSamplerRegistry::GetSPosition ( G4int  index) const
inline

Accessor.

Definition at line 182 of file BDSSamplerRegistry.hh.

References infos.

◆ GetTransform()

G4Transform3D BDSSamplerRegistry::GetTransform ( G4int  index) const
inline

Accessor.

Definition at line 176 of file BDSSamplerRegistry.hh.

References infos.

◆ GetTransformInverse()

G4Transform3D BDSSamplerRegistry::GetTransformInverse ( G4int  index) const
inline

Accessor.

Definition at line 179 of file BDSSamplerRegistry.hh.

References infos.

Referenced by BDSSDSampler::ProcessHits(), BDSSDSamplerCylinder::ProcessHits(), and BDSSDSamplerSphere::ProcessHits().

Here is the caller graph for this function:

◆ GetUniqueNames()

std::vector< G4String > BDSSamplerRegistry::GetUniqueNames ( ) const

Access all the unique names at once.

Definition at line 104 of file BDSSamplerRegistry.cc.

References infos, and BDSSamplerPlacementRecord::UniqueName().

Here is the call graph for this function:

◆ GetUniqueNamesCylinder()

std::vector< G4String > BDSSamplerRegistry::GetUniqueNamesCylinder ( ) const

Definition at line 123 of file BDSSamplerRegistry.cc.

◆ GetUniqueNamesPlane()

std::vector< G4String > BDSSamplerRegistry::GetUniqueNamesPlane ( ) const

Definition at line 112 of file BDSSamplerRegistry.cc.

◆ GetUniqueNamesSphere()

std::vector< G4String > BDSSamplerRegistry::GetUniqueNamesSphere ( ) const

Definition at line 134 of file BDSSamplerRegistry.cc.

◆ GetUniqueNameToRadiusCylinder()

std::map< std::string, double > BDSSamplerRegistry::GetUniqueNameToRadiusCylinder ( ) const

For output in standard C++ types. Also in m for units.

Definition at line 145 of file BDSSamplerRegistry.cc.

References infos, BDSSamplerPlacementRecord::Radius(), BDSSamplerPlacementRecord::Type(), and BDSSamplerPlacementRecord::UniqueName().

Here is the call graph for this function:

◆ GetUniqueNameToRadiusSphere()

std::map< std::string, double > BDSSamplerRegistry::GetUniqueNameToRadiusSphere ( ) const

For output in standard C++ types. Also in m for units.

Definition at line 156 of file BDSSamplerRegistry.cc.

References infos, BDSSamplerPlacementRecord::Radius(), BDSSamplerPlacementRecord::Type(), and BDSSamplerPlacementRecord::UniqueName().

Here is the call graph for this function:

◆ GetUniquePlaneNamesAndSPosition()

std::vector< std::pair< G4String, G4double > > BDSSamplerRegistry::GetUniquePlaneNamesAndSPosition ( ) const

Access all the unique names and their corresponding s position at once.

Definition at line 167 of file BDSSamplerRegistry.cc.

References infos, BDSSamplerPlacementRecord::SPosition(), BDSSamplerPlacementRecord::Type(), and BDSSamplerPlacementRecord::UniqueName().

Here is the call graph for this function:

◆ Instance()

BDSSamplerRegistry * BDSSamplerRegistry::Instance ( )
static

◆ NumberOfExistingSamplers()

G4int BDSSamplerRegistry::NumberOfExistingSamplers ( ) const
inline

Get number of registered samplers.

Definition at line 185 of file BDSSamplerRegistry.hh.

References numberOfEntries.

Referenced by BDSMultilayerScreen::AddScreenLayer().

Here is the caller graph for this function:

◆ RegisterSampler() [1/2]

G4int BDSSamplerRegistry::RegisterSampler ( BDSSamplerPlacementRecord &  info)

Definition at line 84 of file BDSSamplerRegistry.cc.

◆ RegisterSampler() [2/2]

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 60 of file BDSSamplerRegistry.cc.

References existingNames, RegisterSampler(), and samplerObjects.

Referenced by BDSScreenLayer::AssignSampler(), BDSParallelWorldSampler::Construct(), BDSParallelWorldSampler::Place(), BDSLinkDetectorConstruction::PlaceOneComponent(), BDSLinkOpaqueBox::PlaceOutputSampler(), and RegisterSampler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SafeIndex()

G4bool BDSSamplerRegistry::SafeIndex ( G4int  index) const
inline

Definition at line 141 of file BDSSamplerRegistry.hh.

◆ size()

size_t BDSSamplerRegistry::size ( ) const
inline

Definition at line 188 of file BDSSamplerRegistry.hh.

Field Documentation

◆ existingNames

std::map<G4String, G4int> BDSSamplerRegistry::existingNames
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 157 of file BDSSamplerRegistry.hh.

Referenced by RegisterSampler().

◆ infos

InfoVector BDSSamplerRegistry::infos
private

◆ instance

BDSSamplerRegistry * BDSSamplerRegistry::instance = nullptr
staticprivate

Singleton instance.

Definition at line 148 of file BDSSamplerRegistry.hh.

Referenced by Instance().

◆ numberOfEntries

G4int BDSSamplerRegistry::numberOfEntries
private

Counter for easy checking of out of bounds and incrementing. Also the index in the member vectors, so zero counting.

Definition at line 152 of file BDSSamplerRegistry.hh.

Referenced by NumberOfExistingSamplers().

◆ samplerIDsPerType

std::map<BDSSamplerType, std::vector<G4int> > BDSSamplerRegistry::samplerIDsPerType
private

Definition at line 164 of file BDSSamplerRegistry.hh.

◆ samplerObjects

std::set<BDSSampler*> BDSSamplerRegistry::samplerObjects
private

Cache of unique sampler objects for memory management.

Definition at line 160 of file BDSSamplerRegistry.hh.

Referenced by RegisterSampler().

◆ samplerTypeToCategory

std::map<BDSSamplerType, BDSSamplerType> BDSSamplerRegistry::samplerTypeToCategory
private

Map to reduce 'forward' sampler types to simple sampler types for keeping a record of IDs.

Definition at line 163 of file BDSSamplerRegistry.hh.

Referenced by BDSSamplerRegistry().


The documentation for this class was generated from the following files: