Back to home page

EIC code displayed by LXR

 
 

    


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

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 // GEANT4 class header file
0029 //
0030 // Class:                G4IonParametrisedLossModel
0031 //
0032 // Base class:           G4VEmModel (utils)
0033 // 
0034 // Author:               Anton Lechner (Anton.Lechner@cern.ch)
0035 //
0036 // First implementation: 10. 11. 2008
0037 //
0038 // Modifications: 03. 02. 2009 - Bug fix iterators (AL)
0039 //                11. 03. 2009 - Introduced new table handler(G4IonDEDXHandler)
0040 //                               and modified method to add/remove tables 
0041 //                               (tables are now built in init. phase),
0042 //                               Minor bug fix in ComputeDEDXPerVolume (AL) 
0043 //                12. 11. 2009 - Added function for switching off scaling 
0044 //                               of heavy ions from ICRU 73 data
0045 //                20. 11. 2009 - Added set-method for energy loss limit (AL)
0046 //                24. 11. 2009 - Bug fix: Range calculation corrected if same 
0047 //                               materials appears with different cuts in diff.
0048 //                               regions (added UpdateRangeCache function and
0049 //                               modified BuildRangeVector, ComputeLossForStep
0050 //                               functions accordingly, added new cache param.,
0051 //                               changed typdef of IonMatCouple).
0052 //                             - Removed GetRange function (AL)  
0053 //
0054 // Class description:
0055 //    Model for computing the energy loss of ions by employing a 
0056 //    parameterisation of dE/dx tables (default ICRU 73 tables). For 
0057 //    ion-material combinations and/or projectile energies not covered 
0058 //    by this model, the G4BraggIonModel and G4BetheBloch models are
0059 //    employed.
0060 //
0061 // Comments:
0062 //
0063 // =========================================================================== 
0064 
0065 
0066 #ifndef G4IONPARAMETRISEDLOSSMODEL_HH
0067 #define G4IONPARAMETRISEDLOSSMODEL_HH
0068 
0069 #include <iomanip>
0070 #include <list>
0071 #include <map>
0072 #include <utility>
0073 #include <CLHEP/Units/PhysicalConstants.h>
0074 
0075 #include "G4VEmModel.hh"
0076 #include "G4EmCorrections.hh"
0077 #include "G4IonDEDXHandler.hh"
0078 
0079 class G4BraggIonModel;
0080 class G4BetheBlochModel;
0081 class G4ParticleChangeForLoss;
0082 class G4VIonDEDXTable;
0083 class G4VIonDEDXScalingAlgorithm;
0084 class G4PhysicsFreeVector;
0085 class G4MaterialCutsCouple;
0086 
0087 typedef std::list<G4IonDEDXHandler*> LossTableList;
0088 typedef std::pair<const G4ParticleDefinition*, 
0089                   const G4MaterialCutsCouple*> IonMatCouple;
0090 
0091 class G4IonParametrisedLossModel : public G4VEmModel {
0092 
0093  public:
0094    explicit G4IonParametrisedLossModel(const G4ParticleDefinition* particle = nullptr,
0095                        const G4String& name = "ParamICRU73");
0096 
0097    virtual ~G4IonParametrisedLossModel();
0098 
0099   void Initialise(
0100           const G4ParticleDefinition*, // Projectile
0101           const G4DataVector&) override; // Cut energies
0102 
0103   G4double MinEnergyCut(
0104             const G4ParticleDefinition*,  // Projectile
0105             const G4MaterialCutsCouple*) override;
0106   
0107   G4double ComputeCrossSectionPerAtom(
0108                       const G4ParticleDefinition*, // Projectile
0109                       G4double,  // Kinetic energy of projectile
0110                       G4double,  // Atomic number
0111                       G4double,  // Mass number
0112                       G4double,  // Energy cut for secondary prod.
0113                       G4double) override; // Maximum energy of secondaries
0114   
0115   G4double CrossSectionPerVolume(
0116                                  const G4Material*,  // Target material
0117                  const G4ParticleDefinition*, // Projectile
0118                  G4double,  // Kinetic energy
0119                  G4double,  // Energy cut for secondary prod.
0120                  G4double) override; // Maximum energy of secondaries
0121                  
0122   G4double ComputeDEDXPerVolume(
0123                 const G4Material*, // Target material
0124                 const G4ParticleDefinition*, // Projectile
0125                 G4double,  // Kinetic energy of projectile
0126                 G4double) override; // Energy cut for secondary prod.
0127   
0128    // Function, which computes the continuous energy loss (due to electronic
0129    // stopping) for a given pre-step energy and step length by using
0130    // range vs energy (and energy vs range) tables  
0131    G4double ComputeLossForStep(
0132                                  const G4MaterialCutsCouple*, // Mat-cuts couple
0133                  const G4ParticleDefinition*, // Projectile
0134                  G4double,  // Kinetic energy of projectile
0135                  G4double); // Length of current step
0136 
0137    // Function, which computes the mean energy transfer rate to delta rays 
0138    inline G4double DeltaRayMeanEnergyTransferRate(
0139                                  const G4Material*, // Target Material
0140                      const G4ParticleDefinition*, // Projectile
0141                  G4double,  // Kinetic energy of projectile
0142                  G4double); // Energy cut for secondary prod.
0143 
0144 
0145    void SampleSecondaries(std::vector<G4DynamicParticle*>*,
0146               const G4MaterialCutsCouple*,
0147               const G4DynamicParticle*,
0148               G4double,  // Energy cut for secondary prod.
0149               G4double) override; // Maximum energy of secondaries
0150 
0151    G4double GetChargeSquareRatio(
0152                                  const G4ParticleDefinition*, // Projectile
0153                  const G4Material*,  // Target Material
0154                  G4double) override; // Kinetic energy of projectile
0155 
0156    G4double GetParticleCharge(
0157                   const G4ParticleDefinition*, // Projectile
0158                   const G4Material*,  // Target Material
0159                   G4double) override; // Kinetic energy of projectile 
0160 
0161    void CorrectionsAlongStep(
0162                              const G4MaterialCutsCouple*,// Mat.-Cut couple
0163                  const G4DynamicParticle*,   // Dyn. particle
0164                              const G4double&,            // Length of current step
0165                  G4double&) override;        // Energy loss in current step
0166 
0167    // Function which allows to add additional stopping power tables
0168    // in combination with a scaling algorithm, which may depend on dynamic
0169    // information like the current particle energy (the table and scaling 
0170    // algorithm are used via a handler class, which performs e.g.caching or
0171    // which applies the scaling of energy and dE/dx values)
0172    G4bool AddDEDXTable(const G4String& name,
0173                      G4VIonDEDXTable* table, 
0174                      G4VIonDEDXScalingAlgorithm* algorithm = nullptr); 
0175 
0176    G4bool RemoveDEDXTable(const G4String& name); 
0177 
0178    // Function which allows to switch off scaling of stopping powers of heavy
0179    // ions from existing ICRU 73 data
0180    // void DeactivateICRU73Scaling();
0181 
0182    // Function checking the applicability of physics tables to ion-material
0183    // combinations (Note: the energy range of tables is not checked)
0184    inline LossTableList::iterator IsApplicable(
0185                       const G4ParticleDefinition*,  // Projectile (ion) 
0186                       const G4Material*);           // Target material
0187 
0188    // Function printing a dE/dx table for a given ion-material combination
0189    // and a specified energy grid 
0190    void PrintDEDXTable(
0191                       const G4ParticleDefinition*,  // Projectile (ion) 
0192                       const G4Material*, // Absorber material
0193                       G4double,          // Minimum energy per nucleon
0194                       G4double,          // Maximum energy per nucleon
0195                       G4int,             // Number of bins
0196                       G4bool);           // Logarithmic scaling of energy
0197 
0198    // Function printing a dE/dx table for a given ion-material combination
0199    // and a specified energy grid 
0200    void PrintDEDXTableHandlers(
0201                       const G4ParticleDefinition*,  // Projectile (ion) 
0202                       const G4Material*, // Absorber material
0203                       G4double,          // Minimum energy per nucleon
0204                       G4double,          // Maximum energy per nucleon
0205                       G4int,             // Number of bins
0206                       G4bool);           // Logarithmic scaling of energy
0207    
0208    // Function for setting energy loss limit for stopping power integration
0209    inline void SetEnergyLossLimit(G4double ionEnergyLossLimit); 
0210 
0211  protected:
0212    G4double MaxSecondaryEnergy(const G4ParticleDefinition*,
0213                    G4double) override;   // Kinetic energy of projectile
0214 
0215  private:
0216    // Function which updates parameters concerning the dE/dx calculation
0217    // (the parameters are only updated if the particle, the material or 
0218    // the associated energy cut has changed)
0219    void UpdateDEDXCache(
0220                   const G4ParticleDefinition*,   // Projectile (ion) 
0221                   const G4Material*,             // Target material
0222                   G4double cutEnergy);           // Energy cut
0223 
0224    // Function which updates parameters concerning the range calculation
0225    // (the parameters are only updated if the particle, the material or 
0226    // the associated energy cut has changed)
0227    void UpdateRangeCache(
0228                   const G4ParticleDefinition*,   // Projectile (ion) 
0229                   const G4MaterialCutsCouple*);  // Target material
0230 
0231    // Function, which updates parameters concering particle properties
0232    inline void UpdateCache(
0233                   const G4ParticleDefinition*);  // Projectile (ion) 
0234  
0235    // Function, which builds range vs energy (and energy vs range) vectors
0236    // for a given particle, material and energy cut   
0237    void BuildRangeVector(
0238                   const G4ParticleDefinition*,   // Projectile (ion) 
0239                   const G4MaterialCutsCouple*);  // Material cuts couple
0240 
0241    // Assignment operator and copy constructor are hidden:
0242    G4IonParametrisedLossModel & operator=(
0243                               const G4IonParametrisedLossModel &right);
0244    G4IonParametrisedLossModel(const G4IonParametrisedLossModel &);
0245    
0246    // ######################################################################
0247    // # Models and dE/dx tables for computing the energy loss 
0248    // # 
0249    // ######################################################################
0250 
0251    // G4BraggIonModel and G4BetheBlochModel are used for ion-target
0252    // combinations and/or projectile energies not covered by parametrisations
0253    // adopted by this model:
0254    G4BraggIonModel* braggIonModel;
0255    G4BetheBlochModel* betheBlochModel;
0256 
0257    // List of dE/dx tables plugged into the model
0258    LossTableList lossTableList;
0259 
0260    // ######################################################################
0261    // # Maps of Range vs Energy and Energy vs Range vectors
0262    // # 
0263    // ######################################################################
0264 
0265    typedef std::map<IonMatCouple, G4PhysicsFreeVector*> RangeEnergyTable; 
0266    RangeEnergyTable r;
0267 
0268    typedef std::map<IonMatCouple, G4PhysicsFreeVector*> EnergyRangeTable; 
0269    EnergyRangeTable E;
0270 
0271    // ######################################################################
0272    // # Energy grid definitions (e.g. used for computing range-energy 
0273    // # tables)
0274    // ######################################################################
0275 
0276    G4double lowerEnergyEdgeIntegr;
0277    G4double upperEnergyEdgeIntegr;
0278 
0279    size_t nmbBins;
0280    size_t nmbSubBins;
0281 
0282    // ######################################################################
0283    // # Particle change for loss
0284    // # 
0285    // ######################################################################
0286 
0287    // Pointer to particle change object, which is used to set e.g. the
0288    // energy loss and secondary delta-electron
0289    // used indicating if model is initialized  
0290    G4ParticleChangeForLoss* particleChangeLoss;
0291 
0292    // ######################################################################
0293    // # Corrections and energy loss limit
0294    // # 
0295    // ######################################################################
0296    
0297    // Pointer to an G4EmCorrections object, which is used to compute the
0298    // effective ion charge, and other corrections (like high order corrections
0299    // to stopping powers) 
0300    G4EmCorrections* corrections;
0301 
0302    // Corrections factor for effective charge, computed for each particle
0303    // step
0304    G4double corrFactor;
0305 
0306    // Parameter indicating the maximal fraction of kinetic energy, which
0307    // a particle may loose along a step, in order that the simple relation
0308    // (dE/dx)*l can still be applied to compute the energy loss (l = step 
0309    // length)
0310    G4double energyLossLimit;
0311 
0312    // ######################################################################
0313    // # Cut energies and properties of generic ion
0314    // # 
0315    // ######################################################################
0316 
0317    // Vector containing the current cut energies (the vector index matches
0318    // the material-cuts couple index):
0319    G4DataVector cutEnergies;
0320 
0321    // Pointer to generic ion and mass of generic ion
0322    const G4ParticleDefinition* genericIon;
0323    G4double genericIonPDGMass;
0324 
0325    // ######################################################################
0326    // # "Most-recently-used" cache parameters
0327    // #
0328    // ######################################################################
0329 
0330    // Cached key (particle) and value information for a faster 
0331    // access of particle-related information
0332    const G4ParticleDefinition* cacheParticle; // Key: Current projectile
0333    G4double cacheMass;                        // Projectile mass
0334    G4double cacheElecMassRatio;               // Electron-mass ratio
0335    G4double cacheChargeSquare;                // Charge squared
0336 
0337    // Cached parameters needed during range computations:
0338    const G4ParticleDefinition* rangeCacheParticle; // Key: 1) Current ion,
0339    const G4MaterialCutsCouple* rangeCacheMatCutsCouple; // 2) Mat-cuts-couple
0340    G4PhysicsVector* rangeCacheEnergyRange;         // Energy vs range vector
0341    G4PhysicsVector* rangeCacheRangeEnergy;         // Range vs energy vector
0342 
0343    // Cached parameters needed during dE/dx computations:
0344    const G4ParticleDefinition* dedxCacheParticle; // Key: 1) Current ion,
0345    const G4Material* dedxCacheMaterial;           //      2) material and
0346    G4double dedxCacheEnergyCut;                   //      3) cut energy 
0347    LossTableList::iterator dedxCacheIter;         // Responsible dE/dx table
0348    G4double dedxCacheTransitionEnergy;      // Transition energy between
0349                                             // parameterization and 
0350                                             // Bethe-Bloch model
0351    G4double dedxCacheTransitionFactor;      // Factor for smoothing the dE/dx
0352                                             // values in the transition region
0353    G4double dedxCacheGenIonMassRatio;       // Ratio of generic ion mass       
0354                                             // and current particle mass
0355    G4bool isInitialised;
0356 };
0357 
0358 
0359 #include "G4IonParametrisedLossModel.icc"
0360 
0361 #endif