BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSFieldObjects.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
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 BDSFIELDOBJECTS_H
20#define BDSFIELDOBJECTS_H
21
22#include "globals.hh" // geant4 types / globals
23#include "G4Version.hh"
24
25#include <vector>
26
27class BDSFieldInfo;
28
29class G4ChordFinder;
30class G4ElectroMagneticField;
31class G4EquationOfMotion;
32class G4Field;
33class G4FieldManager;
34class G4LogicalVolume;
35class G4MagneticField;
36class G4MagInt_Driver;
37class G4MagIntegratorStepper;
38class G4UserLimits;
39
53{
54public:
55 BDSFieldObjects() = delete;
56
59 BDSFieldObjects(const BDSFieldObjects& other) = delete;
60
62 BDSFieldObjects(const BDSFieldInfo* infoIn,
63 G4Field* fieldIn,
64 G4EquationOfMotion* equationOfMotionIn,
65 G4MagIntegratorStepper* magIntegratorStepperIn,
66 G4ChordFinder* chordFinderIn,
67 G4FieldManager* fieldManagerIn);
68
73 BDSFieldObjects(const BDSFieldInfo* infoIn,
74 G4ElectroMagneticField* fieldIn,
75 G4EquationOfMotion* equationOfMotionIn,
76 G4MagIntegratorStepper* magIntegratorStepperIn);
77
78#if G4VERSION_NUMBER > 1049
81 BDSFieldObjects(const BDSFieldInfo* infoIn,
82 G4MagneticField* fieldIn,
83 G4EquationOfMotion* equationOfMotionIn,
84 G4MagIntegratorStepper* magIntegratorStepperIn);
85#endif
86
89
91 inline const BDSFieldInfo* GetInfo() const {return info;}
92 inline G4Field* GetField() const {return field;}
93 inline G4EquationOfMotion* GetEquationOfMotion() const {return equationOfMotion;}
94 inline G4MagIntegratorStepper* GetIntegrator() const {return magIntegratorStepper;}
95 inline G4ChordFinder* GetChordFinder() const {return chordFinder;}
96 inline G4FieldManager* GetFieldManager() const {return fieldManager;}
97 inline G4MagInt_Driver* GetMagIntDriver() const {return magIntDriver;}
99
101 void AttachToVolume(G4LogicalVolume* volume,
102 G4bool penetrateToDaughterVolumes = true) const;
103
105 void AttachToVolume(const std::vector<G4LogicalVolume*>& volumes,
106 G4bool penetrateToDaughterVolumes = true) const;
107
112 void AttachUserLimitsToVolume(G4LogicalVolume* volume,
113 G4UserLimits* userLimits,
114 G4bool penetrateToDaughterVolumes = true) const;
115
116private:
119
121 G4Field* field;
122
124 G4EquationOfMotion* equationOfMotion;
125
127 G4MagIntegratorStepper* magIntegratorStepper;
128
130 G4ChordFinder* chordFinder;
131
133 G4FieldManager* fieldManager;
134
136 G4MagInt_Driver* magIntDriver;
137};
138
139#endif
All info required to build complete field of any type.
Definition: BDSFieldInfo.hh:65
A holder for all the Geant4 field related objects.
G4FieldManager * GetFieldManager() const
Accessor.
G4ChordFinder * GetChordFinder() const
Accessor.
void AttachToVolume(G4LogicalVolume *volume, G4bool penetrateToDaughterVolumes=true) const
Interface to easily attach to logical volume.
G4MagInt_Driver * GetMagIntDriver() const
Accessor.
G4MagIntegratorStepper * GetIntegrator() const
Accessor.
~BDSFieldObjects()
Destructor deletes all objects apart from the magnetic field.
G4FieldManager * fieldManager
Field manager.
BDSFieldObjects(const BDSFieldObjects &other)=delete
G4Field * field
Reference to field this instance is based on.
const BDSFieldInfo * info
The complete information required to build this field.
G4MagIntegratorStepper * magIntegratorStepper
Stepper, selectable depending on smoothness of the field etc.
G4Field * GetField() const
Accessor.
G4ChordFinder * chordFinder
Chord manager.
G4EquationOfMotion * GetEquationOfMotion() const
Accessor.
const BDSFieldInfo * GetInfo() const
Accessor.
G4EquationOfMotion * equationOfMotion
Equation of motion, typically G4Mag_UsualEqRhs instance.
void AttachUserLimitsToVolume(G4LogicalVolume *volume, G4UserLimits *userLimits, G4bool penetrateToDaughterVolumes=true) const
G4MagInt_Driver * magIntDriver
EM field integrator driver (optional) - only for EM fields.