21#include "BDSIntegratorRMatrixThin.hh"
23#include "BDSUtilities.hh"
26#include "G4Mag_EqRhs.hh"
28BDSIntegratorRMatrixThin::BDSIntegratorRMatrixThin(
BDSMagnetStrength const* strength,
30 G4double maximumRadiusIn):
32 maximumRadius(maximumRadiusIn)
34 kick1 = (*strength)[
"kick1"];
35 kick2 = (*strength)[
"kick2"];
36 kick3 = (*strength)[
"kick3"];
37 kick4 = (*strength)[
"kick4"];
38 rmat11 = (*strength)[
"rmat11"];
39 rmat12 = (*strength)[
"rmat12"];
40 rmat13 = (*strength)[
"rmat13"];
41 rmat14 = (*strength)[
"rmat14"];
42 rmat21 = (*strength)[
"rmat21"];
43 rmat22 = (*strength)[
"rmat22"];
44 rmat23 = (*strength)[
"rmat23"];
45 rmat24 = (*strength)[
"rmat24"];
46 rmat31 = (*strength)[
"rmat31"];
47 rmat32 = (*strength)[
"rmat32"];
48 rmat33 = (*strength)[
"rmat33"];
49 rmat34 = (*strength)[
"rmat34"];
50 rmat41 = (*strength)[
"rmat41"];
51 rmat42 = (*strength)[
"rmat42"];
52 rmat43 = (*strength)[
"rmat43"];
53 rmat44 = (*strength)[
"rmat44"];
56 G4cout <<
"RMatrix " << rmat11 <<
" " << rmat12 <<
" " << rmat13 <<
" " << rmat14 <<
" " << kick1 << G4endl;
57 G4cout <<
"RMatrix " << rmat21 <<
" " << rmat22 <<
" " << rmat23 <<
" " << rmat24 <<
" " << kick2 << G4endl;
58 G4cout <<
"RMatrix " << rmat31 <<
" " << rmat32 <<
" " << rmat33 <<
" " << rmat34 <<
" " << kick3 << G4endl;
59 G4cout <<
"RMatrix " << rmat41 <<
" " << rmat42 <<
" " << rmat43 <<
" " << rmat44 <<
" " << kick4 << G4endl;
63void BDSIntegratorRMatrixThin::Stepper(
const G4double yIn[],
69 for (G4int i = 0; i < 3; i++)
76 const G4double fcof =
eqOfM->FCof();
92 G4ThreeVector pos = G4ThreeVector( yIn[0], yIn[1], yIn[2]);
93 G4ThreeVector mom = G4ThreeVector(yIn[3], yIn[4], yIn[5]);
94 G4double momMag = mom.mag();
99 G4ThreeVector localMomUnit = localMom.unit();
101 G4double x0 = localPos.x();
102 G4double y0 = localPos.y();
103 G4double z0 = localPos.z();
105 G4double xp = localMomUnit.x();
106 G4double yp = localMomUnit.y();
107 G4double zp = localMomUnit.z();
118 G4double x1 = rmat11 * x0 + rmat12 * xp * CLHEP::m + rmat13 * y0 + rmat14 * yp * CLHEP::m + kick1;
119 G4double xp1 = rmat21 * x0 / CLHEP::m + rmat22 * xp + rmat23 * y0 / CLHEP::m + rmat24 * yp + kick2;
120 G4double y1 = rmat31 * x0 + rmat32 * xp * CLHEP::meter + rmat33 * y0 + rmat34 * yp * CLHEP::m + kick3;
121 G4double yp1 = rmat41 * x0 / CLHEP::m + rmat42 * xp + rmat43 * y0 / CLHEP::m + rmat44 * yp + kick4;
122 G4double z1 = z0 + h;
123 G4double zp1 = std::sqrt(1 - std::pow(xp1,2) - std::pow(yp1,2));
126 if(x1 > maximumRadius)
127 {x1 = maximumRadius;}
128 else if( x1 < -maximumRadius)
129 {x1 = -maximumRadius;}
130 if(y1 > maximumRadius)
131 {y1 = maximumRadius;}
132 else if( y1 < -maximumRadius)
133 {y1 = -maximumRadius;}
135 G4ThreeVector localPosOut = G4ThreeVector(x1, y1, z1);
136 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)