Back to home page

EIC code displayed by LXR

 
 

    


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

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 // G4ChordFinder
0027 //
0028 // Class description:
0029 //
0030 // A class that provides RK integration of motion ODE (as does g4magtr)
0031 // and also has a method that returns an Approximate point on the curve 
0032 // near to a (chord) point.
0033 
0034 // Author: J.Apostolakis - Design and implementation - 25.02.1997
0035 // -------------------------------------------------------------------
0036 #ifndef G4CHORDFINDER_HH
0037 #define G4CHORDFINDER_HH
0038 
0039 #include "G4VIntegrationDriver.hh"
0040 #include "G4MagIntegratorStepper.hh"
0041 
0042 #include <memory>
0043 
0044 class G4VFSALIntegrationStepper;
0045 
0046 class G4MagneticField;
0047 class G4CachedMagneticField;
0048 class G4HelixHeum;
0049 
0050 class G4ChordFinder
0051 {
0052    public:  // with description
0053 
0054       explicit G4ChordFinder( G4VIntegrationDriver* pIntegrationDriver );
0055         // The most flexible constructor, which allows the user to specify
0056         // any type of field, equation, stepper and integration driver.
0057 
0058       enum kIntegrationType { kDefaultDriverType=0, kFSALStepperType=1, 
0059          kTemplatedStepperType, kRegularStepperType, kBfieldDriverType, kQss2DriverType, kQss3DriverType };
0060 
0061       G4ChordFinder( G4MagneticField* itsMagField,
0062                      G4double         stepMinimum = 1.0e-2, // * mm 
0063                      G4MagIntegratorStepper* pItsStepper = nullptr,
0064                      // G4bool           useHigherEfficiencyStepper = true,
0065                      G4int            stepperDriverChoice = kTemplatedStepperType );
0066         // A constructor that creates defaults for all "children" classes.
0067         //
0068         // The type of equation of motion is fixed.
0069         // A default type of stepper (Dormand Prince since release 10.4) is used,
0070         // and the corresponding integration driver.
0071         // Except if 'useFSAL' is set (true), which provides a FSAL stepper
0072         // and its corresponding specialised (templated) driver.
0073 
0074     virtual ~G4ChordFinder();
0075 
0076       G4ChordFinder(const G4ChordFinder&) = delete;
0077       G4ChordFinder& operator=(const G4ChordFinder&) = delete;
0078         // Copy constructor and assignment operator not allowed.
0079 
0080       inline G4double AdvanceChordLimited( G4FieldTrack& yCurrent,
0081                                            G4double stepInitial,
0082                                            G4double epsStep_Relative,
0083                                      const G4ThreeVector& latestSafetyOrigin,
0084                                            G4double lasestSafetyRadius);
0085         // Uses ODE solver's driver to find the endpoint that satisfies 
0086         // the chord criterion: that d_chord < delta_chord
0087         // -> Returns Length of Step taken.
0088      
0089       G4FieldTrack ApproxCurvePointS( const G4FieldTrack&  curveAPointVelocity,
0090                                       const G4FieldTrack&  curveBPointVelocity,
0091                                       const G4FieldTrack&  ApproxCurveV,
0092                                       const G4ThreeVector& currentEPoint,
0093                                       const G4ThreeVector& currentFPoint,
0094                                       const G4ThreeVector& PointG,
0095                                             G4bool first,  G4double epsStep);
0096  
0097       G4FieldTrack ApproxCurvePointV( const G4FieldTrack&  curveAPointVelocity,
0098                                       const G4FieldTrack&  curveBPointVelocity,
0099                                       const G4ThreeVector& currentEPoint,
0100                                             G4double       epsStep);
0101 
0102       inline G4double InvParabolic( const G4double xa, const G4double ya,
0103                                     const G4double xb, const G4double yb,
0104                                     const G4double xc, const G4double yc );
0105 
0106       inline G4double  GetDeltaChord() const;
0107       inline void      SetDeltaChord(G4double newval);
0108 
0109       inline void SetIntegrationDriver(G4VIntegrationDriver* IntegrationDriver);
0110       inline G4VIntegrationDriver* GetIntegrationDriver();
0111         // Access and set Driver.
0112 
0113       inline void ResetStepEstimate();
0114         // Clear internal state (last step estimate)
0115 
0116       inline G4int SetVerbose( G4int newvalue=1); 
0117         // Set verbosity and return old value
0118 
0119       void OnComputeStep(const G4FieldTrack* track);
0120 
0121       friend std::ostream&
0122              operator<<( std::ostream& os, const G4ChordFinder& cf);
0123 
0124       static void SetVerboseConstruction(G4bool v=true) { gVerboseCtor=v;}
0125         // Verbosity for contructor
0126    protected:   // .........................................................
0127 
0128       void     PrintDchordTrial(G4int    noTrials, 
0129                                 G4double stepTrial, 
0130                                 G4double oldStepTrial, 
0131                                 G4double dChordStep);
0132 
0133       static G4bool gVerboseCtor;  // Verbosity for contructor
0134 
0135    private:  // ............................................................
0136 
0137       //  Constants
0138       //  ---------------------
0139       const G4double fDefaultDeltaChord;  // SET in G4ChordFinder.cc = 0.25 mm
0140 
0141       //  PARAMETERS 
0142       //  ---------------------
0143       G4double  fDeltaChord;               //  Maximum miss distance 
0144 
0145       G4int fStatsVerbose = 0;  // if > 0, print Statistics in destructor
0146 
0147       //  DEPENDENT Objects
0148       //  ---------------------
0149       G4VIntegrationDriver*      fIntgrDriver = nullptr;
0150       G4MagIntegratorStepper*    fRegularStepperOwned = nullptr;
0151       G4MagIntegratorStepper*    fNewFSALStepperOwned = nullptr;
0152       std::unique_ptr<G4HelixHeum> fLongStepper;
0153       G4CachedMagneticField*     fCachedField = nullptr;
0154    // G4VFSALIntegrationStepper* fOldFSALStepperOwned = nullptr;
0155       G4EquationOfMotion*        fEquation = nullptr;  
0156 };
0157 
0158 // Inline function implementation:
0159 
0160 #include "G4ChordFinder.icc"
0161 
0162 #endif  // G4CHORDFINDER_HH