19#include "BDSGlobalConstants.hh"
20#include "BDSIntegratorTeleporter.hh"
21#include "BDSPTCOneTurnMap.hh"
25#include "G4ThreeVector.hh"
26#include "G4Transform3D.hh"
28BDSIntegratorTeleporter::BDSIntegratorTeleporter(G4Mag_EqRhs* eqOfMIn,
29 G4Transform3D transformIn,
30 G4double teleporterLengthIn,
33 transform(transformIn),
34 dPos(transform.getTranslation()),
35 teleporterLength(teleporterLengthIn),
36 oneTurnMap(oneTurnMapIn)
41BDSIntegratorTeleporter::~BDSIntegratorTeleporter()
46void BDSIntegratorTeleporter::Stepper(
const G4double yIn[],
58 G4cout << __METHOD_NAME__ <<
"turnsTaken: " << turnsTaken << G4endl;
61 G4double lengthFraction = h / teleporterLength;
67 if (turnsTaken > 0 && yIn[5] > 0 && lengthFraction > 0.51 && lengthFraction < 1.1)
69 G4ThreeVector globalPos = G4ThreeVector(yIn[0], yIn[1], yIn[2]);
70 G4ThreeVector globalMom = G4ThreeVector(yIn[3], yIn[4], yIn[5]);
72 G4ThreeVector globalPosAfter;
73 G4ThreeVector globalMomAfter;
74 G4bool shouldApplyOTMToPrimary =
false;
82 G4cout << __METHOD_NAME__ <<
"applying 1 turn map" << G4endl;
86 G4double x, px, y, py, pz;
87 oneTurnMap->
GetThisTurn(x, px, y, py, pz, turnsTaken);
92 G4ThreeVector localPosition = localPosMom.
PreStepPoint();
93 G4ThreeVector outLocalMomentum = G4ThreeVector(px, py, pz);
94 G4ThreeVector outLocalPosition = G4ThreeVector(x, y, localPosition.z());
99 globalMomAfter = globalPosDir.
PostStepPoint().transform(transform.getRotation());
101 G4cout << __METHOD_NAME__ <<
"applied the map." << G4endl;
102 G4cout <<
"Applying teleporter offset: " << G4endl;
109 G4cout << __METHOD_NAME__ <<
"teleporter 3d method" << G4endl;
111 globalPosAfter = globalPos + dPos;
112 globalMomAfter = globalMom.transform(transform.getRotation());
118 G4ThreeVector localPosition = localPosMom.
PreStepPoint();
120 G4ThreeVector localPositionAfter;
121 G4ThreeVector localMomentumAfter;
122 G4ThreeVector posDelta = transform.getTranslation();
123 localPositionAfter[0] = localPosition.x() - posDelta.x();
124 localPositionAfter[1] = localPosition.y() - posDelta.y();
125 localPositionAfter[2] = localPosition.z() + h;
139 G4cout <<
"Updating coordinates in place of map application..." << G4endl;
143 G4ThreeVector localPosition = localPosMom.
PreStepPoint();
151 for (G4int i = 0; i < 3; i++)
153 yOut[i] = globalPosAfter[i];
154 yOut[i+3] = globalMomAfter[i];
163 {yOut[2] = yIn[2] + h;}
165 {yOut[2] = yIn[2] - h;}
172 G4ThreeVector inA = G4ThreeVector(yIn[0], yIn[1], yIn[2]);
173 G4ThreeVector inB = G4ThreeVector(yIn[3], yIn[4], yIn[5]);
174 G4ThreeVector outA = G4ThreeVector(yOut[0], yOut[1], yOut[2]);
175 G4ThreeVector outB = G4ThreeVector(yOut[3], yOut[4], yOut[5]);
178 G4ThreeVector localPosIn = localPosMomIn.
PreStepPoint();
180 G4ThreeVector localPosOut = localPosMomOut.
PreStepPoint();
182 std::ios_base::fmtflags ff = G4cout.flags();
183 G4cout.precision(10);
184 G4cout << __METHOD_NAME__ << G4endl;
185 G4cout <<
"h (step length) (metres) " << h / CLHEP::m << G4endl;
186 G4cout <<
"Global Input (x, y, z) " << inA / CLHEP::m << G4endl;
187 G4cout <<
"Global Input (px, py, pz) " << inB / CLHEP::m << G4endl;
188 G4cout <<
"Global Output (x, y, z) " << outA / CLHEP::m << G4endl;
189 G4cout <<
"Global Output (px, py, pz) " << outB / CLHEP::m << G4endl;
190 G4cout <<
"Local Input (x, y, z) " << localPosIn / CLHEP::m << G4endl;
191 G4cout <<
"Local Input (px, py, pz) " << localMomIn / CLHEP::m << G4endl;
192 G4cout <<
"Local Output (x, y, z) " << localPosOut / CLHEP::m << G4endl;
193 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.