BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSFieldFactory.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2024.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef BDSFIELDFACTORY_H
20#define BDSFIELDFACTORY_H
21
22#include "BDSFieldType.hh"
23#include "BDSInterpolatorType.hh"
24#include "BDSMagnetType.hh"
25
26#include "globals.hh"
27
28#include <map>
29#include <vector>
30
31namespace GMAD
32{
33 class Field;
34 class Modulator;
35}
36
37class BDSFieldE;
38class BDSFieldEM;
39class BDSFieldInfo;
40class BDSFieldMag;
41class BDSFieldObjects;
43class BDSModulator;
47
48class G4EquationOfMotion;
49class G4MagIntegratorStepper;
50class G4Mag_EqRhs;
51
78{
79public:
81 static BDSFieldFactory* Instance();
82
84 static void SetDesignParticle(const BDSParticleDefinition* designParticleIn)
85 {designParticle = designParticleIn;}
88
90
93 const BDSMagnetStrength* scalingStrength = nullptr,
94 const G4String& scalingKey = "none");
95
99 BDSFieldInfo* GetDefinition(const G4String& name) const;
100
104 BDSModulatorInfo* GetModulatorDefinition(const G4String& modulatorName) const;
105
107 static BDSInterpolatorType DefaultInterpolatorType(G4int numberOfDimensions);
108
109private:
112 const BDSMagnetStrength* scalingStrength = nullptr,
113 const G4String& scalingKey = "none");
114
117
120
123
126 const BDSMagnetStrength* scalingStrength = nullptr,
127 const G4String& scalingKey = "none");
128
131
134 G4MagIntegratorStepper* CreateIntegratorMag(const BDSFieldInfo& info,
135 G4Mag_EqRhs* eqOfM,
136 const BDSMagnetStrength* strength);
137
140 G4MagIntegratorStepper* CreateIntegratorEM(const BDSFieldInfo& info,
141 G4EquationOfMotion* eqOfM);
142
146 G4MagIntegratorStepper* CreateIntegratorE(const BDSFieldInfo& info,
147 G4EquationOfMotion* eqOfM);
148
152
155
158
162
164 G4double GetOuterScaling(const BDSMagnetStrength* st) const;
165
167 BDSModulator* CreateModulator(const BDSModulatorInfo* modulatorRecipe,
168 const BDSFieldInfo& info) const;
169
172 G4double brho) const;
173
176
179
181 void PrepareFieldDefinitions(const std::vector<GMAD::Field>& definitions,
182 G4double defaultBRho);
183
185 void PrepareModulatorDefinitions(const std::vector<GMAD::Modulator>& definitions);
186
188 G4double ConvertToDoubleWithException(const G4String& value,
189 const G4String& parameterNameForError) const;
190
194 const G4String& fieldParameters,
195 G4double& poleTipRadius) const;
196
198 std::map<G4String, BDSFieldInfo*> parserDefinitions;
199 std::map<G4String, BDSModulatorInfo*> parserModulatorDefinitions;
200
203
206
207 G4bool useOldMultipoleOuterFields;
208};
209#endif
Interface for BDSIM electro-magnetic fields that may or may not be local.
Definition BDSFieldEM.hh:41
Interface for BDSIM electric fields that may or may not be local.
Definition BDSFieldE.hh:39
Factory that produces fields and their associated objects.
G4double GetOuterScaling(const BDSMagnetStrength *st) const
Return the parameter "outerScaling" from strength st, but default to 1.
static void SetDesignParticle(const BDSParticleDefinition *designParticleIn)
Update the internal cache of the rigidity.
void PrepareFieldDefinitions(const std::vector< GMAD::Field > &definitions, G4double defaultBRho)
Prepare all required definitions that can be used dynamically.
void PrepareModulatorDefinitions(const std::vector< GMAD::Modulator > &definitions)
Prepare all required modulator definitions that can be used dynamically.
static void SetPrimaryGeneratorAction(BDSPrimaryGeneratorAction *pgaIn)
Update the internal cache of the primary generator action.
BDSFieldObjects * CreateFieldE(const BDSFieldInfo &info)
Create an electric field.
BDSFieldObjects * CreateFieldIrregular(const BDSFieldInfo &info)
Create an irregular (special) field.
BDSFieldObjects * CreateRMatrix(const BDSFieldInfo &info)
Create special rmatrix 'field' that applies an rmatrix.
void PrepareFieldStrengthFromParameters(BDSMagnetStrength *st, const G4String &fieldParameters, G4double &poleTipRadius) const
static BDSPrimaryGeneratorAction * primaryGeneratorAction
Cache of primary generator action.
BDSModulator * CreateModulator(const BDSModulatorInfo *modulatorRecipe, const BDSFieldInfo &info) const
Create the necessary modulator.
BDSFieldE * CreateFieldERaw(const BDSFieldInfo &info)
Creat just the electric field object.
G4double ConvertToDoubleWithException(const G4String &value, const G4String &parameterNameForError) const
Convert the string 'value' to a double. Throw an exception including the parameterNameForError if it ...
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.
BDSFieldObjects * CreateParallelTransport(const BDSFieldInfo &info)
static BDSFieldFactory * instance
Instance - singleton pattern.
BDSFieldInfo * GetDefinition(const G4String &name) const
BDSFieldObjects * CreateCavityFringe(const BDSFieldInfo &info)
Create special rf cavity fringe 'field' that applies an rmatrix.
std::map< G4String, BDSFieldInfo * > parserDefinitions
BDSFieldInfo definitions prepare from parser vector of definitions.
G4MagIntegratorStepper * CreateIntegratorMag(const BDSFieldInfo &info, G4Mag_EqRhs *eqOfM, const BDSMagnetStrength *strength)
BDSFieldEM * CreateMuonCoolerField(const BDSFieldInfo &info, G4double brho) const
Create a composite muon cooler field EM field.
G4MagIntegratorStepper * CreateIntegratorE(const BDSFieldInfo &info, G4EquationOfMotion *eqOfM)
BDSFieldObjects * CreateFieldMag(const BDSFieldInfo &info, const BDSMagnetStrength *scalingStrength=nullptr, const G4String &scalingKey="none")
Create a purely magnetic field.
static BDSInterpolatorType DefaultInterpolatorType(G4int numberOfDimensions)
Suggest a default interpolator.
BDSFieldObjects * CreateFieldEM(const BDSFieldInfo &info)
Create a general EM field.
BDSFieldMag * CreateFieldMagRaw(const BDSFieldInfo &info, const BDSMagnetStrength *scalingStrength=nullptr, const G4String &scalingKey="none")
Creat just the magnetic field object.
BDSFieldFactory()
Private default constructor as singleton class.
BDSModulatorInfo * GetModulatorDefinition(const G4String &modulatorName) const
BDSFieldObjects * CreateTeleporter(const BDSFieldInfo &info)
G4MagIntegratorStepper * CreateIntegratorEM(const BDSFieldInfo &info, G4EquationOfMotion *eqOfM)
static const BDSParticleDefinition * designParticle
Cache of design particle for fields.
All info required to build complete field of any type.
Interface for static magnetic fields that may or may not be local.
A holder for all the Geant4 field related objects.
Efficient storage of magnet strengths.
Holder class for all information required to describe a modulator.
Base class for a modulator.
Wrapper for particle definition.
Generates primary particle vertices using BDSBunch.
Parser namespace for GMAD language. Combination of Geant4 and MAD.