Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:09:13

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 //
0027 // ----------------------------------------------------------------------------
0028 //
0029 // GEANT4 Class header file
0030 //
0031 // File name:     G4GoudsmitSaundersonMscModel
0032 //
0033 // Author:        Mihaly Novak / (Omrane Kadri)
0034 //
0035 // Creation date: 20.02.2009
0036 //
0037 // Modifications:
0038 // 04.03.2009 V.Ivanchenko cleanup and format according to Geant4 EM style
0039 // 12.05.2010 O.Kadri: adding Qn1 and Qn12 as private doubles
0040 // 18.05.2015 M. Novak provide PLERIMINARYY version of updated class.
0041 //            All algorithms of the class were revised and updated, new methods added.
0042 //            A new version of Kawrakow-Bielajew Goudsmit-Saunderson MSC model
0043 //            based on the screened Rutherford DCS for elastic scattering of
0044 //            electrons/positrons has been introduced[1,2]. The corresponding MSC
0045 //            angular distributions over a 2D parameter grid have been recomputed
0046 //            and the CDFs are now stored in a variable transformed (smooth) form[2,3]
0047 //            together with the corresponding rational interpolation parameters.
0048 //            These angular distributions are handled by the new
0049 //            G4GoudsmitSaundersonTable class that is responsible to sample if
0050 //            it was no, single, few or multiple scattering case and delivers the
0051 //            angular deflection (i.e. cos(theta) and sin(theta)).
0052 //            Two screening options are provided:
0053 //             - if fgIsUsePWATotalXsecData=TRUE i.e. SetOptionPWAScreening(TRUE)
0054 //               was called before initialisation: screening parameter value A is
0055 //               determined such that the first transport coefficient G1(A)
0056 //               computed according to the screened Rutherford DCS for elastic
0057 //               scattering will reproduce the one computed from the PWA elastic
0058 //               and first transport mean free paths[4].
0059 //             - if fgIsUsePWATotalXsecData=FALSE i.e. default value or
0060 //               SetOptionPWAScreening(FALSE) was called before initialisation:
0061 //               screening parameter value A is computed according to Moliere's
0062 //               formula (by using material dependent parameters \chi_cc2 and b_c
0063 //               precomputed for each material used at initialization in
0064 //               G4GoudsmitSaundersonTable) [3]
0065 //            Elastic and first trasport mean free paths are used consistently.
0066 //            The new version is self-consistent, several times faster, more
0067 //            robust and accurate compared to the earlier version.
0068 //            Spin effects as well as a more accurate energy loss correction and
0069 //            computations of Lewis moments will be implemented later on.
0070 //            [1] A.F.Bielajew, NIMB 111 (1996) 195-208
0071 //            [2] I.Kawrakow, A.F.Bielajew, NIMB 134(1998) 325-336
0072 //            [3] I.Kawrakow, E.Mainegra-Hing, D.W.O.Rogers, F.Tessier,B.R.B.Walters,
0073 //                NRCC Report PIRS-701 (2013)
0074 //            [4] F.Salvat, A.Jablonski, C.J. Powell, CPC 165(2005) 157-190
0075 // 02.09.2015 M. Novak: first version of new step limit is provided.
0076 //            fUseSafetyPlus corresponds to Urban fUseSafety (default)
0077 //            fUseDistanceToBoundary corresponds to Urban fUseDistanceToBoundary
0078 //            fUseSafety  corresponds to EGSnrc error-free stepping algorithm
0079 //            Range factor can be significantly higher at each case than in Urban.
0080 // 23.08.2017 M. Novak: added corrections to account spin effects (Mott-correction).
0081 //            It can be activated by setting the fIsMottCorrection flag to be true
0082 //            before initialization using the SetOptionMottCorrection() public method.
0083 //            The fMottCorrection member is responsible to handle pre-computed Mott
0084 //            correction (rejection) functions obtained by numerically computing
0085 //            Goudsmit-Saunderson agnular distributions based on a DCS accounting spin
0086 //            effects and screening corrections. The DCS used to compute the accurate
0087 //            GS angular distributions is: DCS_{cor} = DCS_{SR}x[ DCS_{R}/DCS_{Mott}] where :
0088 //               # DCS_{SR} is the relativistic Screened-Rutherford DCS (first Born approximate
0089 //                 solution of the Klein-Gordon i.e. relativistic Schrodinger equation =>
0090 //                 scattering of spinless e- on exponentially screened Coulomb potential)
0091 //                 note: the default (without using Mott-correction) GS angular distributions
0092 //                 are based on this DCS_{SR} with Moliere's screening parameter!
0093 //               # DCS_{R} is the Rutherford DCS which is the same as above but without
0094 //                 screening
0095 //               # DCS_{Mott} is the Mott DCS i.e. solution of the Dirac equation with a bare
0096 //                 Coulomb potential i.e. scattering of particles with spin (e- or e+) on a
0097 //                 point-like unscreened Coulomb potential
0098 //               # moreover, the screening parameter of the DCS_{cor} was determined such that
0099 //                 the DCS_{cor} with this corrected screening parameter reproduce the first
0100 //                 transport cross sections obtained from the corresponding most accurate DCS
0101 //                 (i.e. from elsepa [4])
0102 //            Unlike the default GS, the Mott-corrected angular distributions are particle type
0103 //            (different for e- and e+ <= the DCS_{Mott} and the screening correction) and target
0104 //            (Z and material) dependent.
0105 // 02.02.2018 M. Novak: implemented CrossSectionPerVolume interface method (used only for testing)
0106 // 26.10.2025 M. Novak: the model has only its accurate stepping and boundary crossing algorithms
0107 //            left as the only option that ensures the expected precision, especially when activating
0108 //            its Mott correction option (that also activates the screeing and scattering power
0109 //            corrections). The model has been used for describing e-/e+ MSC (below 100 MeV kinetic)
0110 //            energy in the option4, Penelope and Livermore EM physics constructors since Geant4 10.6.
0111 //
0112 //
0113 // Class description:
0114 //   Kawrakow-Bielajew Goudsmit-Saunderson MSC model based on the screened Rutherford DCS
0115 //   for elastic scattering of e-/e+. Option, to include Mott correction, is also available
0116 //   that also activates the screening and scattering power corrections leading to the most
0117 //   precise settings of the model. With the accurate electron stepping and boundary crossing
0118 //   algorithm the model provides very precise e-/e+ simulation and tracking independently
0119 //   from the target material and geometrical configurations similarly to EGSnrc. All details
0120 //   are available in the corresponding technical note (M. Novak: https://arxiv.org/abs/2410.13361).
0121 //
0122 // References:
0123 //   M. Novak: https://arxiv.org/abs/2410.13361
0124 //
0125 // -----------------------------------------------------------------------------
0126 
0127 #ifndef G4GoudsmitSaundersonMscModel_h
0128 #define G4GoudsmitSaundersonMscModel_h 1
0129 
0130 #include <CLHEP/Units/SystemOfUnits.h>
0131 
0132 #include "G4VMscModel.hh"
0133 #include "G4PhysicsTable.hh"
0134 #include "G4MaterialCutsCouple.hh"
0135 #include "globals.hh"
0136 
0137 
0138 class G4DataVector;
0139 class G4ParticleChangeForMSC;
0140 class G4LossTableManager;
0141 class G4GoudsmitSaundersonTable;
0142 class G4GSPWACorrections;
0143 
0144 class G4GoudsmitSaundersonMscModel : public G4VMscModel
0145 {
0146 public:
0147 
0148   G4GoudsmitSaundersonMscModel(const G4String& nam = "GoudsmitSaunderson");
0149 
0150   ~G4GoudsmitSaundersonMscModel() override;
0151 
0152   void Initialise(const G4ParticleDefinition*, const G4DataVector&) override;
0153 
0154   void InitialiseLocal(const G4ParticleDefinition* p, G4VEmModel* masterModel) override;
0155 
0156   G4ThreeVector& SampleScattering(const G4ThreeVector&, G4double safety) override;
0157 
0158   G4double ComputeTruePathLengthLimit(const G4Track& track, G4double& currentMinimalStep) override;
0159 
0160   G4double ComputeGeomPathLength(G4double truePathLength) override;
0161 
0162   G4double ComputeTrueStepLength(G4double geomStepLength) override;
0163 
0164   // method to compute first transport cross section per Volume (i.e. macroscropic first transport cross section; this
0165   // method is used only for testing and not during a normal simulation)
0166   G4double CrossSectionPerVolume(const G4Material*, const G4ParticleDefinition*, G4double kineticEnergy, G4double cutEnergy = 0.0, G4double maxEnergy = DBL_MAX) override;
0167 
0168   void     StartTracking(G4Track*) override;
0169 
0170   void     SampleMSC();
0171 
0172   G4double GetTransportMeanFreePath(const G4ParticleDefinition*, G4double);
0173 
0174   void SetOptionPWACorrection(G4bool opt)    { fIsUsePWACorrection = opt; }
0175 
0176   G4bool GetOptionPWACorrection() const      { return fIsUsePWACorrection; }
0177 
0178   void   SetOptionMottCorrection(G4bool opt) { fIsUseMottCorrection = opt; }
0179 
0180   G4bool GetOptionMottCorrection() const     { return fIsUseMottCorrection; }
0181 
0182   void   SetOptionOptimisation(G4bool opt) { fIsUseOptimisation = opt; }
0183 
0184   G4bool GetOptionOptimisation() const     { return fIsUseOptimisation; }
0185 
0186   G4GoudsmitSaundersonTable* GetGSTable()          { return fGSTable; }
0187 
0188   G4GSPWACorrections*        GetPWACorrection()    { return fPWACorrection; }
0189 
0190   //  hide assignment operator
0191   G4GoudsmitSaundersonMscModel & operator=(const  G4GoudsmitSaundersonMscModel &right) = delete;
0192   G4GoudsmitSaundersonMscModel(const  G4GoudsmitSaundersonMscModel&) = delete;
0193 
0194 private:
0195   inline void     SetParticle(const G4ParticleDefinition* p);
0196 
0197   inline G4double GetLambda(G4double);
0198 
0199   G4double GetTransportMeanFreePathOnly(const G4ParticleDefinition*,G4double);
0200 
0201 private:
0202 
0203   G4double currentKinEnergy;
0204   G4double currentRange;
0205   G4double presafety;
0206   G4int    currentMaterialIndex;
0207   //
0208   const G4ParticleDefinition* particle;
0209   G4ParticleChangeForMSC*     fParticleChange;
0210   const G4MaterialCutsCouple* currentCouple;
0211 
0212   G4GoudsmitSaundersonTable*  fGSTable;
0213   G4GSPWACorrections*         fPWACorrection;
0214 
0215   G4bool   fIsUsePWACorrection;
0216   G4bool   fIsUseMottCorrection;
0217   G4bool   fIsUseOptimisation;
0218   //
0219   G4double fLambda0; // elastic mean free path
0220   G4double fLambda1; // first transport mean free path
0221   G4double fScrA;    // screening parameter
0222   G4double fG1;      // first transport coef.
0223   // in case of Mott-correction
0224   G4double fMCtoScrA;
0225   G4double fMCtoQ1;
0226   G4double fMCtoG2PerG1;
0227   //
0228   G4double fTheTrueStepLenght;
0229   G4double fTheZPathLenght;
0230   //
0231   G4ThreeVector fTheDisplacementVector;
0232   G4ThreeVector fTheNewDirection;
0233   //
0234   G4bool fIsEndedUpOnBoundary;
0235   G4bool fIsMultipleScattering;
0236   G4bool fIsSingleScattering;
0237   G4bool fIsNoScatteringInMSC;
0238   G4bool fIsSimplified;
0239 };
0240 
0241 ////////////////////////////////////////////////////////////////////////////////
0242 inline
0243 void G4GoudsmitSaundersonMscModel::SetParticle(const G4ParticleDefinition* p)
0244 {
0245   if (p != particle) {
0246     particle = p;
0247   }
0248 }
0249 
0250 #endif