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
65 void SetDipoleField(G4double val);
66
72 void SetGradient(size_t index, G4double gradient);
73
79 G4double GetGradient(size_t index) const;
80
86 void SetQLength(size_t index, G4double length);
87
93 G4double GetQLength(size_t index) const;
94
100 void SetQDrift(size_t index, G4double drift);
101
107 G4double GetQDrift(size_t index) const;
108
113 void SetMapBFieldStatus(G4bool val);
114
115private:
121 void DefineCommands();
122
127 static void InitializeFieldToZero(G4double *bField);
128
134 G4double CalculateConstantDipoleField(G4double posY, G4double posZ) const;
135
141 static G4double CalculateFieldMapMode(G4double posY, G4double posZ);
142
148 static bool InQuadrupoleRange(G4double posX, G4double posZ);
149
157 void ApplyQuadrupoleContributions(G4double posY, G4double posX, G4double posZ, G4double *bField) const;
158
163 G4double GetQuadrupoleBegin(int index) const;
164
165 G4double ConstantDipoleBField = 0.0 * CLHEP::tesla;
166 std::array<G4double, NumQuadrupoles> gradients = {};
167 std::array<G4double, NumQuadrupoles> qlength = {};
168 std::array<G4double, NumQuadrupoles> qdrift = {};
169 std::array<G4double, NumQuadrupoles> qbegin = {};
170 std::array<G4double, NumQuadrupoles> qend = {};
171 G4bool StatusMapBField = false;
172};
173
180G4double fitFunction(G4double *x, G4double *par);
181
188G4double symmetrizedFunctionY(G4double *x, G4double *par);
189
196G4double symmetrizedFunctionS(G4double *x, G4double *par);
197
198#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
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