Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:58

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4BFieldIntegrationDriver
0027 //
0028 // Class description:
0029 //
0030 // Specialized integration driver for pure magnetic field
0031 
0032 // Author: D.Sorokin
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     //[[deprecated("will be removed")]]
0072     void GetDerivatives(const G4FieldTrack& track,
0073                               G4double dydx[]) const override
0074     {
0075       fCurrDriver->GetDerivatives(track, dydx);
0076     }
0077 
0078     //[[deprecated("will be removed")]]
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     //[[deprecated("use GetEquationOfMotion() instead of GetStepper()->GetEquationOfMotion()")]]
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     // Write out the parameters / state of the driver
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