20#include "BDSIntegratorRMatrixThin.hh"
22#include "BDSUtilities.hh"
25#include "G4Mag_EqRhs.hh"
27BDSIntegratorRMatrixThin::BDSIntegratorRMatrixThin(
BDSMagnetStrength const* strength,
29 G4double maximumRadiusIn):
31 maximumRadius(maximumRadiusIn)
33 kick1 = (*strength)[
"kick1"];
34 kick2 = (*strength)[
"kick2"];
35 kick3 = (*strength)[
"kick3"];
36 kick4 = (*strength)[
"kick4"];
37 rmat11 = (*strength)[
"rmat11"];
38 rmat12 = (*strength)[
"rmat12"];
39 rmat13 = (*strength)[
"rmat13"];
40 rmat14 = (*strength)[
"rmat14"];
41 rmat21 = (*strength)[
"rmat21"];
42 rmat22 = (*strength)[
"rmat22"];
43 rmat23 = (*strength)[
"rmat23"];
44 rmat24 = (*strength)[
"rmat24"];
45 rmat31 = (*strength)[
"rmat31"];
46 rmat32 = (*strength)[
"rmat32"];
47 rmat33 = (*strength)[
"rmat33"];
48 rmat34 = (*strength)[
"rmat34"];
49 rmat41 = (*strength)[
"rmat41"];
50 rmat42 = (*strength)[
"rmat42"];
51 rmat43 = (*strength)[
"rmat43"];
52 rmat44 = (*strength)[
"rmat44"];
55 G4cout <<
"RMatrix " << rmat11 <<
" " << rmat12 <<
" " << rmat13 <<
" " << rmat14 <<
" " << kick1 << G4endl;
56 G4cout <<
"RMatrix " << rmat21 <<
" " << rmat22 <<
" " << rmat23 <<
" " << rmat24 <<
" " << kick2 << G4endl;
57 G4cout <<
"RMatrix " << rmat31 <<
" " << rmat32 <<
" " << rmat33 <<
" " << rmat34 <<
" " << kick3 << G4endl;
58 G4cout <<
"RMatrix " << rmat41 <<
" " << rmat42 <<
" " << rmat43 <<
" " << rmat44 <<
" " << kick4 << G4endl;
62void BDSIntegratorRMatrixThin::Stepper(
const G4double yIn[],
68 for (G4int i = 0; i < 3; i++)
75 const G4double fcof =
eqOfM->FCof();
91 G4ThreeVector pos = G4ThreeVector( yIn[0], yIn[1], yIn[2]);
92 G4ThreeVector mom = G4ThreeVector(yIn[3], yIn[4], yIn[5]);
93 G4double momMag = mom.mag();
98 G4ThreeVector localMomUnit = localMom.unit();
100 G4double x0 = localPos.x();
101 G4double y0 = localPos.y();
102 G4double z0 = localPos.z();
104 G4double xp = localMomUnit.x();
105 G4double yp = localMomUnit.y();
106 G4double zp = localMomUnit.z();
117 G4double x1 = rmat11 * x0 + rmat12 * xp * CLHEP::m + rmat13 * y0 + rmat14 * yp * CLHEP::m + kick1;
118 G4double xp1 = rmat21 * x0 / CLHEP::m + rmat22 * xp + rmat23 * y0 / CLHEP::m + rmat24 * yp + kick2;
119 G4double y1 = rmat31 * x0 + rmat32 * xp * CLHEP::meter + rmat33 * y0 + rmat34 * yp * CLHEP::m + kick3;
120 G4double yp1 = rmat41 * x0 / CLHEP::m + rmat42 * xp + rmat43 * y0 / CLHEP::m + rmat44 * yp + kick4;
121 G4double z1 = z0 + h;
122 G4double zp1 = std::sqrt(1 - std::pow(xp1,2) - std::pow(yp1,2));
125 if(x1 > maximumRadius)
126 {x1 = maximumRadius;}
127 else if( x1 < -maximumRadius)
128 {x1 = -maximumRadius;}
129 if(y1 > maximumRadius)
130 {y1 = maximumRadius;}
131 else if( y1 < -maximumRadius)
132 {y1 = -maximumRadius;}
134 G4ThreeVector localPosOut = G4ThreeVector(x1, y1, z1);
135 G4ThreeVector localMomUnitOut = G4ThreeVector(xp1, yp1, zp1);
BDSStep ConvertToLocal(G4Step const *const step, G4bool useCurvilinear=true) const
void AdvanceDriftMag(const G4double yIn[], const G4double h, G4double yOut[], G4double yErr[]) const
Error array [6] all 0.
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 IsFiniteStrength(G4double variable)