20#include "BDSGlobalConstants.hh"
21#include "BDSIntegratorTeleporter.hh"
22#include "BDSPTCOneTurnMap.hh"
26#include "G4ThreeVector.hh"
27#include "G4Transform3D.hh"
29BDSIntegratorTeleporter::BDSIntegratorTeleporter(G4Mag_EqRhs* eqOfMIn,
30 G4Transform3D transformIn,
31 G4double teleporterLengthIn,
34 transform(transformIn),
35 dPos(transform.getTranslation()),
36 teleporterLength(teleporterLengthIn),
37 oneTurnMap(oneTurnMapIn)
42BDSIntegratorTeleporter::~BDSIntegratorTeleporter()
47void BDSIntegratorTeleporter::Stepper(
const G4double yIn[],
59 G4cout << __METHOD_NAME__ <<
"turnsTaken: " << turnsTaken << G4endl;
62 G4double lengthFraction = h / teleporterLength;
68 if (turnsTaken > 0 && yIn[5] > 0 && lengthFraction > 0.51 && lengthFraction < 1.1)
70 G4ThreeVector globalPos = G4ThreeVector(yIn[0], yIn[1], yIn[2]);
71 G4ThreeVector globalMom = G4ThreeVector(yIn[3], yIn[4], yIn[5]);
73 G4ThreeVector globalPosAfter;
74 G4ThreeVector globalMomAfter;
75 G4bool shouldApplyOTMToPrimary =
false;
83 G4cout << __METHOD_NAME__ <<
"applying 1 turn map" << G4endl;
87 G4double x, px, y, py, pz;
88 oneTurnMap->
GetThisTurn(x, px, y, py, pz, turnsTaken);
93 G4ThreeVector localPosition = localPosMom.
PreStepPoint();
94 G4ThreeVector outLocalMomentum = G4ThreeVector(px, py, pz);
95 G4ThreeVector outLocalPosition = G4ThreeVector(x, y, localPosition.z());
100 globalMomAfter = globalPosDir.
PostStepPoint().transform(transform.getRotation());
102 G4cout << __METHOD_NAME__ <<
"applied the map." << G4endl;
103 G4cout <<
"Applying teleporter offset: " << G4endl;
110 G4cout << __METHOD_NAME__ <<
"teleporter 3d method" << G4endl;
112 globalPosAfter = globalPos + dPos;
113 globalMomAfter = globalMom.transform(transform.getRotation());
119 G4ThreeVector localPosition = localPosMom.
PreStepPoint();
121 G4ThreeVector localPositionAfter;
122 G4ThreeVector localMomentumAfter;
123 G4ThreeVector posDelta = transform.getTranslation();
124 localPositionAfter[0] = localPosition.x() - posDelta.x();
125 localPositionAfter[1] = localPosition.y() - posDelta.y();
126 localPositionAfter[2] = localPosition.z() + h;
140 G4cout <<
"Updating coordinates in place of map application..." << G4endl;
144 G4ThreeVector localPosition = localPosMom.
PreStepPoint();
152 for (G4int i = 0; i < 3; i++)
154 yOut[i] = globalPosAfter[i];
155 yOut[i+3] = globalMomAfter[i];
164 {yOut[2] = yIn[2] + h;}
166 {yOut[2] = yIn[2] - h;}
173 G4ThreeVector inA = G4ThreeVector(yIn[0], yIn[1], yIn[2]);
174 G4ThreeVector inB = G4ThreeVector(yIn[3], yIn[4], yIn[5]);
175 G4ThreeVector outA = G4ThreeVector(yOut[0], yOut[1], yOut[2]);
176 G4ThreeVector outB = G4ThreeVector(yOut[3], yOut[4], yOut[5]);
179 G4ThreeVector localPosIn = localPosMomIn.
PreStepPoint();
181 G4ThreeVector localPosOut = localPosMomOut.
PreStepPoint();
183 std::ios_base::fmtflags ff = G4cout.flags();
184 G4cout.precision(10);
185 G4cout << __METHOD_NAME__ << G4endl;
186 G4cout <<
"h (step length) (metres) " << h / CLHEP::m << G4endl;
187 G4cout <<
"Global Input (x, y, z) " << inA / CLHEP::m << G4endl;
188 G4cout <<
"Global Input (px, py, pz) " << inB / CLHEP::m << G4endl;
189 G4cout <<
"Global Output (x, y, z) " << outA / CLHEP::m << G4endl;
190 G4cout <<
"Global Output (px, py, pz) " << outB / CLHEP::m << G4endl;
191 G4cout <<
"Local Input (x, y, z) " << localPosIn / CLHEP::m << G4endl;
192 G4cout <<
"Local Input (px, py, pz) " << localMomIn / CLHEP::m << G4endl;
193 G4cout <<
"Local Output (x, y, z) " << localPosOut / CLHEP::m << G4endl;
194 G4cout <<
"Local Output (px, py, pz) " << localMomOut / CLHEP::m << G4endl;
BDSStep ConvertToGlobalStep(const G4ThreeVector &localPosition, const G4ThreeVector &localDirection, const G4bool useCurvilinear=true) const
BDSStep ConvertToLocal(G4Step const *const step, G4bool useCurvilinear=true) const
static BDSGlobalConstants * Instance()
Access method.
Common functionality to BDSIM integrators.
void SetDistChord(G4double distChordIn)
Setter for distChord to private member.
static G4double thinElementLength
static G4bool currentTrackIsPrimary
const G4int nVariables
Cache of the number of variables.
G4bool threeDMethod
Whether to use full 3D transform.
Class to load and use PTC 1 turn map.
G4bool ShouldApplyToPrimary(G4double momentum, G4int turnstaken)
Decides whether or not this should be applied. Can add more.
void GetThisTurn(G4double &x, G4double &px, G4double &y, G4double &py, G4double &pz, G4int turnstaken)
Return the coordinates for this turn.
void UpdateCoordinates(G4ThreeVector localPosition, G4ThreeVector localMomentum, G4int turnstaken)
Update coordinates if the last turn is greater than the number of turns taken.
A simple class to represent the positions of a step.
G4ThreeVector PostStepPoint() const
Accessor.
G4ThreeVector PreStepPoint() const
Accessor.