20#include "BDSIntegratorKickerThin.hh"
21#include "BDSMagnetStrength.hh"
23#include "BDSUtilities.hh"
25#include "G4Mag_EqRhs.hh"
26#include "G4ThreeVector.hh"
33 G4double minimumRadiusOfCurvatureIn):
35 hkick((*strength)[
"hkick"]),
36 vkick((*strength)[
"vkick"]),
48 (*fringeStEntr)[
"isentrance"] =
true;
49 (*fringeStExit)[
"isentrance"] =
false;
55 G4bool finiteEntrFringe =
false;
56 G4bool finiteExitFringe =
false;
58 {finiteEntrFringe =
true;}
60 {finiteExitFringe =
true;}
63 hasEntranceFringe =
false;
64 hasExitFringe =
false;
65 if (
BDS::IsFinite(fringeIntEntr->GetPolefaceAngle()) || finiteEntrFringe)
66 {hasEntranceFringe =
true;}
67 if (
BDS::IsFinite(fringeIntExit->GetPolefaceAngle()) || finiteExitFringe)
68 {hasExitFringe =
true;}
72 {rho = brhoIn/(*strength)[
"field"];}
77 hasEntranceFringe =
false;
78 hasExitFringe =
false;
84 if (!
BDS::IsFinite((*strength)[
"by"]) && ((*strength)[
"bx"] == 1.0))
85 {tiltAngle = -CLHEP::pi/2.0;}
97 const G4double fcof =
eqOfM->FCof();
114 G4ThreeVector pos = G4ThreeVector(yIn[0], yIn[1], yIn[2]);
115 G4ThreeVector mom = G4ThreeVector(yIn[3], yIn[4], yIn[5]);
122 G4ThreeVector localMomUnit = localMom.unit();
123 G4double localMomMag = localMom.mag();
135 G4double charge = fcof / std::abs(fcof);
136 G4double bendingRad =
rho * charge;
139 G4ThreeVector fringeEntrPosOut = localPos;
140 G4ThreeVector fringeEntrMomOut = localMomUnit;
153 {
fringeIntEntr->
OneStep(localPos, localMomUnit, fringeEntrPosOut, fringeEntrMomOut, bendingRad);}
155 fringeEntrMomOut *= localMomMag;
157 G4ThreeVector localPosOut;
158 G4ThreeVector localMomOut;
161 OneStep(fringeEntrPosOut, fringeEntrMomOut, localMom, h, fcof, localPosOut, localMomOut);
164 G4ThreeVector fringeExitPosOut = localPosOut;
165 G4ThreeVector fringeExitMomOut = localMomOut;
173 fringeIntExit->
OneStep(localPosOut, localMomOut.unit(), fringeExitPosOut, fringeExitMomOut, bendingRad);
178 {fringeIntExit->
OneStep(localPosOut, localMomOut, fringeExitPosOut, fringeExitMomOut, bendingRad);}
180 fringeExitMomOut *= localMomMag;
186void BDSIntegratorKickerThin::OneStep(
const G4ThreeVector& localPos,
187 const G4ThreeVector& localMomUnit,
188 const G4ThreeVector& localMom,
190 const G4double& fcof,
191 G4ThreeVector& localPosOut,
192 G4ThreeVector& localMomOut)
const
195 G4double x1 = localPos.x();
196 G4double y1 = localPos.y();
197 G4double z1 = localPos.z();
200 if (localMomUnit.z() < 0)
208 G4double px = localMom.x();
209 G4double py = localMom.y();
210 G4double pz = localMom.z();
215 G4double localMomMag = localMom.mag();
216 G4double ratio = (fcof *
brho ) / localMomMag;
218 G4double dpx = ratio *
hkick * localMomMag * factor;
219 G4double dpy = ratio *
vkick * localMomMag * factor;
223 pz -= std::abs(dpx) + std::abs(dpy);
225 localPosOut = G4ThreeVector(x1, y1, z1);
226 localMomOut = G4ThreeVector(px, py, pz);
BDSStep ConvertToLocal(G4Step const *const step, G4bool useCurvilinear=true) const
Integrator that ignores the field and uses the analytical solution for a dipole kick.
void OneStep(const G4ThreeVector &posIn, const G4ThreeVector &momUIn, G4ThreeVector &posOut, G4ThreeVector &momOut, const G4double &bendingRadius) const
void AdvanceDriftMag(const G4double yIn[], const G4double h, G4double yOut[], G4double yErr[]) const
Error array [6] all 0.
G4bool hasEntranceFringe
Cache if the fringe or pole face effects are to be applied.
G4double rho
Cache of variable.
const G4double hkick
Cache of variable.
BDSIntegratorDipoleFringe * fringeIntEntr
Separate fringe field integrators for entrance and exit fringes.
virtual void Stepper(const G4double yIn[], const G4double dydx[], const G4double h, G4double yOut[], G4double yErr[])
The stepper for integration.
const G4double vkick
Cache of variable.
G4double tiltAngle
Cache of variable.
const G4double brho
Cache of variable.
BDSIntegratorKickerThin()=delete
Private default constructor to enforce use of supplied constructor.
Common functionality to BDSIM integrators.
G4double backupStepperMomLimit
void SetDistChord(G4double distChordIn)
Setter for distChord to private member.
static G4double thinElementLength
void ConvertToGlobal(const G4ThreeVector &localPos, const G4ThreeVector &localMom, G4double yOut[], G4double yErr[], const G4double momScaling=1.0)
scaling of momentum in case localMom is a unit vector
Efficient storage of magnet strengths.
A simple class to represent the positions of a step.
G4ThreeVector PostStepPoint() const
Accessor.
G4ThreeVector PreStepPoint() const
Accessor.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())
G4bool IsFiniteStrength(G4double variable)