PlasmaMLPALLAS
Loading...
Searching...
No Matches
PlasmaMLPALLASMagneticField.hh
Go to the documentation of this file.
1#ifndef PlasmaMLPALLASMagneticField_h
2#define PlasmaMLPALLASMagneticField_h 1
3
30// --- Includes ---
31#include "G4MagneticField.hh"
32#include <array>
33#include <CLHEP/Units/SystemOfUnits.h>
34
36constexpr size_t NumQuadrupoles = 4;
37
45class PlasmaMLPALLASMagneticField : public G4MagneticField
46{
47public:
50
53
59 void GetFieldValue(const G4double point[4], double *bField) const override;
60
61
62 G4bool GetMapBFieldStatus() const { return StatusMapBField; }
63
68 void SetDipoleField(G4double val);
69
75 void SetGradient(size_t index, G4double gradient);
76
82 G4double GetGradient(size_t index) const;
83
89 void SetQLength(size_t index, G4double length);
90
96 G4double GetQLength(size_t index) const;
97
103 void SetQDrift(size_t index, G4double drift);
104
110 G4double GetQDrift(size_t index) const;
111
116 void SetMapBFieldStatus(G4bool val);
117
118private:
124 void DefineCommands();
125
130 static void InitializeFieldToZero(G4double *bField);
131
137 G4double CalculateConstantDipoleField(G4double posY, G4double posZ) const;
138
144 static G4double CalculateFieldMapMode(G4double posY, G4double posZ);
145
151 static bool InQuadrupoleRange(G4double posX, G4double posZ);
152
160 void ApplyQuadrupoleContributions(G4double posY, G4double posX, G4double posZ, G4double *bField) const;
161
166 G4double GetQuadrupoleBegin(int index) const;
167
168 G4double ConstantDipoleBField = 0.0 * CLHEP::tesla;
169 std::array<G4double, NumQuadrupoles> gradients = {};
170 std::array<G4double, NumQuadrupoles> qlength = {};
171 std::array<G4double, NumQuadrupoles> qdrift = {};
172 std::array<G4double, NumQuadrupoles> qbegin = {};
173 std::array<G4double, NumQuadrupoles> qend = {};
174 G4bool StatusMapBField = false;
175};
176
183G4double fitFunction(G4double *x, G4double *par);
184
191G4double symmetrizedFunctionY(G4double *x, G4double *par);
192
199G4double symmetrizedFunctionS(G4double *x, G4double *par);
200
201#endif // PlasmaMLPALLASMagneticField_h
constexpr size_t NumQuadrupoles
< Units definitions (T, mm, etc.)
Definition PlasmaMLPALLASMagneticField.hh:36
G4double fitFunction(G4double *x, G4double *par)
Fit function for magnetic field profiles.
Definition PlasmaMLPALLASMagneticField.cc:67
G4double symmetrizedFunctionS(G4double *x, G4double *par)
Symmetrized fit function along the S-axis.
Definition PlasmaMLPALLASMagneticField.cc:118
G4double symmetrizedFunctionY(G4double *x, G4double *par)
Symmetrized fit function along the Y-axis.
Definition PlasmaMLPALLASMagneticField.cc:99
Defines the magnetic field model for the PALLAS simulation.
Definition PlasmaMLPALLASMagneticField.hh:46
void SetQLength(size_t index, G4double length)
Set the length of a quadrupole.
Definition PlasmaMLPALLASMagneticField.cc:308
void SetDipoleField(G4double val)
Set the constant dipole magnetic field value.
Definition PlasmaMLPALLASMagneticField.cc:258
void SetQDrift(size_t index, G4double drift)
Set the drift distance before a quadrupole.
Definition PlasmaMLPALLASMagneticField.cc:338
G4bool GetMapBFieldStatus() const
Definition PlasmaMLPALLASMagneticField.hh:62
G4double GetQLength(size_t index) const
Get the length of a quadrupole.
Definition PlasmaMLPALLASMagneticField.cc:322
PlasmaMLPALLASMagneticField()
Constructor.
Definition PlasmaMLPALLASMagneticField.cc:47
void GetFieldValue(const G4double point[4], double *bField) const override
Compute the magnetic field at a given location.
Definition PlasmaMLPALLASMagneticField.cc:140
void SetMapBFieldStatus(G4bool val)
Enable or disable mapped magnetic field usage.
Definition PlasmaMLPALLASMagneticField.cc:268
G4double GetQDrift(size_t index) const
Get the drift distance before a quadrupole.
Definition PlasmaMLPALLASMagneticField.cc:352
void SetGradient(size_t index, G4double gradient)
Set the gradient of a quadrupole.
Definition PlasmaMLPALLASMagneticField.cc:278
~PlasmaMLPALLASMagneticField() override
Destructor.
Definition PlasmaMLPALLASMagneticField.cc:52
G4double GetGradient(size_t index) const
Get the gradient of a quadrupole.
Definition PlasmaMLPALLASMagneticField.cc:292