File indexing completed on 2025-01-18 09:57:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef G4BFIELD_INTEGRATION_DRIVER_HH
0035 #define G4BFIELD_INTEGRATION_DRIVER_HH
0036
0037 #include "G4VIntegrationDriver.hh"
0038 #include "G4Mag_EqRhs.hh"
0039
0040 #include <memory>
0041
0042 class G4BFieldIntegrationDriver : public G4VIntegrationDriver
0043 {
0044 public:
0045
0046 G4BFieldIntegrationDriver(
0047 std::unique_ptr<G4VIntegrationDriver> smallStepDriver,
0048 std::unique_ptr<G4VIntegrationDriver> largeStepDriver);
0049
0050 G4BFieldIntegrationDriver(const G4BFieldIntegrationDriver &) = delete;
0051 const G4BFieldIntegrationDriver& operator =(const G4BFieldIntegrationDriver &) = delete;
0052
0053 G4double AdvanceChordLimited(G4FieldTrack& track,
0054 G4double hstep,
0055 G4double eps,
0056 G4double chordDistance) override;
0057
0058 G4bool AccurateAdvance(G4FieldTrack& track,
0059 G4double hstep,
0060 G4double eps,
0061 G4double hinitial = 0) override
0062 {
0063 return fCurrDriver->AccurateAdvance(track, hstep, eps, hinitial);
0064 }
0065
0066 G4bool DoesReIntegrate() const override
0067 {
0068 return fCurrDriver->DoesReIntegrate();
0069 }
0070
0071
0072 void GetDerivatives(const G4FieldTrack& track,
0073 G4double dydx[]) const override
0074 {
0075 fCurrDriver->GetDerivatives(track, dydx);
0076 }
0077
0078
0079 void GetDerivatives(const G4FieldTrack& track,
0080 G4double dydx[],
0081 G4double field[]) const override
0082 {
0083 fCurrDriver->GetDerivatives(track, dydx, field);
0084 }
0085
0086 void SetEquationOfMotion(G4EquationOfMotion* equation) override;
0087
0088 G4EquationOfMotion* GetEquationOfMotion() override
0089 {
0090 return fCurrDriver->GetEquationOfMotion();
0091 }
0092
0093
0094 const G4MagIntegratorStepper* GetStepper() const override
0095 {
0096 return fCurrDriver->GetStepper();
0097 }
0098
0099 G4MagIntegratorStepper* GetStepper() override
0100 {
0101 return fCurrDriver->GetStepper();
0102 }
0103
0104 G4double ComputeNewStepSize(G4double errMaxNorm,
0105 G4double hstepCurrent) override
0106 {
0107 return fCurrDriver->ComputeNewStepSize(errMaxNorm, hstepCurrent);
0108 }
0109
0110 void SetVerboseLevel(G4int level) override
0111 {
0112 fSmallStepDriver->SetVerboseLevel(level);
0113 fLargeStepDriver->SetVerboseLevel(level);
0114 }
0115
0116 G4int GetVerboseLevel() const override
0117 {
0118 return fCurrDriver->GetVerboseLevel();
0119 }
0120
0121 void OnComputeStep(const G4FieldTrack* track) override
0122 {
0123 fSmallStepDriver->OnComputeStep(track);
0124 fLargeStepDriver->OnComputeStep(track);
0125 }
0126
0127 void OnStartTracking() override
0128 {
0129 fSmallStepDriver->OnStartTracking();
0130 fLargeStepDriver->OnStartTracking();
0131 }
0132
0133 void StreamInfo( std::ostream& os ) const override
0134 {
0135 os << "Small Step Driver Info: " << std::endl;
0136 fSmallStepDriver->StreamInfo(os);
0137 os << "Large Step Driver Info: " << std::endl;
0138 fLargeStepDriver->StreamInfo(os);
0139 }
0140
0141
0142 void PrintStatistics() const;
0143
0144 private:
0145
0146 G4double CurvatureRadius(const G4FieldTrack& track) const;
0147
0148 void GetFieldValue(const G4FieldTrack& track,
0149 G4double Field[] ) const;
0150
0151 std::unique_ptr<G4VIntegrationDriver> fSmallStepDriver;
0152 std::unique_ptr<G4VIntegrationDriver> fLargeStepDriver;
0153 G4VIntegrationDriver* fCurrDriver = nullptr;
0154 G4Mag_EqRhs* fEquation = nullptr;
0155
0156 G4int fSmallDriverSteps = 0;
0157 G4int fLargeDriverSteps = 0;
0158 };
0159
0160 #endif