BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSFieldObjects.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSFIELDOBJECTS_H
19#define BDSFIELDOBJECTS_H
20
21#include "globals.hh" // geant4 types / globals
22#include "G4Version.hh"
23
24#include <vector>
25
26class BDSFieldInfo;
27
28class G4ChordFinder;
29class G4ElectroMagneticField;
30class G4EquationOfMotion;
31class G4Field;
32class G4FieldManager;
33class G4LogicalVolume;
34class G4MagneticField;
35class G4MagInt_Driver;
36class G4MagIntegratorStepper;
37class G4UserLimits;
38
52{
53public:
54 BDSFieldObjects() = delete;
55
58 BDSFieldObjects(const BDSFieldObjects& other) = delete;
59
61 BDSFieldObjects(const BDSFieldInfo* infoIn,
62 G4Field* fieldIn,
63 G4EquationOfMotion* equationOfMotionIn,
64 G4MagIntegratorStepper* magIntegratorStepperIn,
65 G4ChordFinder* chordFinderIn,
66 G4FieldManager* fieldManagerIn);
67
72 BDSFieldObjects(const BDSFieldInfo* infoIn,
73 G4ElectroMagneticField* fieldIn,
74 G4EquationOfMotion* equationOfMotionIn,
75 G4MagIntegratorStepper* magIntegratorStepperIn);
76
77#if G4VERSION_NUMBER > 1049
80 BDSFieldObjects(const BDSFieldInfo* infoIn,
81 G4MagneticField* fieldIn,
82 G4EquationOfMotion* equationOfMotionIn,
83 G4MagIntegratorStepper* magIntegratorStepperIn);
84#endif
85
88
90 inline const BDSFieldInfo* GetInfo() const {return info;}
91 inline G4Field* GetField() const {return field;}
92 inline G4EquationOfMotion* GetEquationOfMotion() const {return equationOfMotion;}
93 inline G4MagIntegratorStepper* GetIntegrator() const {return magIntegratorStepper;}
94 inline G4ChordFinder* GetChordFinder() const {return chordFinder;}
95 inline G4FieldManager* GetFieldManager() const {return fieldManager;}
96 inline G4MagInt_Driver* GetMagIntDriver() const {return magIntDriver;}
98
100 void AttachToVolume(G4LogicalVolume* volume,
101 G4bool penetrateToDaughterVolumes = true) const;
102
104 void AttachToVolume(const std::vector<G4LogicalVolume*>& volumes,
105 G4bool penetrateToDaughterVolumes = true) const;
106
111 void AttachUserLimitsToVolume(G4LogicalVolume* volume,
112 G4UserLimits* userLimits,
113 G4bool penetrateToDaughterVolumes = true) const;
114
115private:
118
120 G4Field* field;
121
123 G4EquationOfMotion* equationOfMotion;
124
126 G4MagIntegratorStepper* magIntegratorStepper;
127
129 G4ChordFinder* chordFinder;
130
132 G4FieldManager* fieldManager;
133
135 G4MagInt_Driver* magIntDriver;
136
139
142};
143
144#endif
All info required to build complete field of any type.
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.
void SetFieldManagerOptions()
Field manager settings.
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.
void SetFieldManagerOptionsThin()
Field manager settings for thin elements.
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.