20#include "BDSFieldBuilder.hh"
21#include "BDSFieldFactory.hh"
22#include "BDSFieldInfo.hh"
23#include "BDSFieldObjects.hh"
25#include "G4LogicalVolume.hh"
39BDSFieldBuilder::~BDSFieldBuilder()
46 size_t defaultSize = 30;
47 infos.reserve(defaultSize);
48 lvs.reserve(defaultSize);
53 const std::vector<G4LogicalVolume*>& logicalVolumes,
54 const G4bool propagateToDaughters,
56 const G4String& scalingKey)
61 G4cout << __METHOD_NAME__ <<
"Registering info: " << info
63 for (
auto vol : logicalVolumes)
64 {G4cout << vol->GetName() <<
" ";}
67 infos.push_back(info);
68 lvs.push_back(logicalVolumes);
70 if (info->AutoScale())
72 G4int index = (G4int)
infos.size() - 1;
80 G4LogicalVolume* logicalVolume,
81 const G4bool propagateToDaughters,
83 const G4String& scalingKey)
85 std::vector<G4LogicalVolume*> lvsForThisInfo = {logicalVolume};
89 magnetStrengthForScaling,
94 const std::set<G4LogicalVolume*>& logicalVolumes,
95 const G4bool propagateToDaughters,
97 const G4String& scalingKey)
100 std::vector<G4LogicalVolume*> lvsForThisInfo;
101 for (
auto lv : logicalVolumes)
102 {lvsForThisInfo.push_back(lv);}
105 propagateToDaughters,
106 magnetStrengthForScaling,
110std::vector<BDSFieldObjects*> BDSFieldBuilder::CreateAndAttachAll()
112 std::vector<BDSFieldObjects*> fields;
113 fields.reserve(
infos.size());
114 for (G4int i = 0; i < (G4int)
infos.size(); i++)
128 fields.push_back(field);
Register for all fields to be built and volumes to be attached to.
std::map< G4int, G4String > scalingKeys
Optional register of scaling strengths and keys.
std::vector< const BDSFieldInfo * > infos
Register of components to build.
std::map< G4int, const BDSMagnetStrength * > scalingStrengths
Optional register of scaling strengths and keys.
std::vector< G4bool > propagators
Register of components to build.
void RegisterFieldForConstruction(const BDSFieldInfo *info, G4LogicalVolume *logicalVolume, const G4bool propagateToDaughters=false, const BDSMagnetStrength *magnetStrengthForScaling=nullptr, const G4String &scalingKey="none")
std::vector< std::vector< G4LogicalVolume * > > lvs
Register of components to build.
static BDSFieldBuilder * instance
Singleton instance.
BDSFieldBuilder()
Private default constructor to enforce singleton pattern.
static BDSFieldBuilder * Instance()
Singleton pattern accessor.
static BDSFieldFactory * Instance()
Public accessor method for singleton pattern.
BDSFieldObjects * CreateField(const BDSFieldInfo &info, const BDSMagnetStrength *scalingStrength=nullptr, const G4String &scalingKey="none")
Main interface to field factory.
All info required to build complete field of any type.
G4bool AutoScale() const
Accessor.
A holder for all the Geant4 field related objects.
void AttachToVolume(G4LogicalVolume *volume, G4bool penetrateToDaughterVolumes=true) const
Interface to easily attach to logical volume.
Efficient storage of magnet strengths.