51 G4Exception(
"G4BFieldIntegrationDriver::G4BFieldIntegrationDriver",
53 "Works only with G4Mag_EqRhs");
63 std::unique_ptr<G4VIntegrationDriver> smallStepDriver,
64 std::unique_ptr<G4VIntegrationDriver> largeStepDriver)
65 : fSmallStepDriver(std::move(smallStepDriver)),
66 fLargeStepDriver(std::move(largeStepDriver)),
67 fCurrDriver(fSmallStepDriver.get()),
68 fEquation(toMagneticEquation(fCurrDriver->GetEquationOfMotion()))
70 if (fSmallStepDriver->GetEquationOfMotion()
71 != fLargeStepDriver->GetEquationOfMotion())
73 G4Exception(
"G4BFieldIntegrationDriver Constructor:",
83 const G4double radius = CurvatureRadius(yCurrent);
86 if (chordDistance < 2 * radius)
88 stepMax = std::min(stepMax, twopi * radius);
89 driver = fSmallStepDriver.get();
93 driver = fLargeStepDriver.get();
97 if (driver != fCurrDriver)
102 fCurrDriver = driver;
105 epsStep, chordDistance);
111 fEquation = toMagneticEquation(equation);
112 fSmallStepDriver->SetEquationOfMotion(equation);
113 fLargeStepDriver->SetEquationOfMotion(equation);
117G4BFieldIntegrationDriver::CurvatureRadius(
const G4FieldTrack& track)
const
121 GetFieldValue(track, field);
123 const G4double Bmag2 = field[0] * field[0]
124 + field[1] * field[1]
125 + field[2] * field[2] ;
132 const G4double fCof_inv = eplus / std::abs(fEquation->
FCof());
134 return std::sqrt(momentum2 / Bmag2) * fCof_inv;
138G4BFieldIntegrationDriver::GetFieldValue(
const G4FieldTrack& track,
150 const auto totSteps = fSmallDriverSteps + fLargeDriverSteps;
151 const auto toFraction = [&](
double value) {
return value / totSteps * 100; };
153 G4cout <<
"============= G4BFieldIntegrationDriver statistics ===========\n"
154 <<
"total steps " << totSteps <<
" "
155 <<
"smallDriverSteps " << toFraction(fSmallDriverSteps) <<
" "
156 <<
"largeDriverSteps " << toFraction(fLargeDriverSteps) <<
"\n"
157 <<
"======================================\n";
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
G4BFieldIntegrationDriver(std::unique_ptr< G4VIntegrationDriver > smallStepDriver, std::unique_ptr< G4VIntegrationDriver > largeStepDriver)
void PrintStatistics() const
virtual void SetEquationOfMotion(G4EquationOfMotion *equation) override
virtual G4double AdvanceChordLimited(G4FieldTrack &track, G4double hstep, G4double eps, G4double chordDistance) override
void GetFieldValue(const G4double Point[4], G4double Field[]) const
G4ThreeVector GetPosition() const
G4double GetLabTimeOfFlight() const
G4ThreeVector GetMomentum() const
static constexpr G4int MAX_NUMBER_OF_COMPONENTS
virtual void OnComputeStep()=0
virtual G4double AdvanceChordLimited(G4FieldTrack &track, G4double hstep, G4double eps, G4double chordDistance)=0