Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58: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 // -----------------------------------------------------------------------------
0030 
0031 #ifndef included_G4EnergyLossTables
0032 #define included_G4EnergyLossTables
0033 
0034 #include <map>
0035 #include "globals.hh"
0036 
0037 #include "G4PhysicsTable.hh"
0038 #include "G4ParticleDefinition.hh"
0039 #include "G4Material.hh"
0040 #include "G4ios.hh"
0041 
0042 //------------------------------------------------------------------------------
0043 // A utility class, containing the energy loss tables
0044 // for each particle
0045 //
0046 // Energy loss processes have to register their tables with this
0047 // class. The responsibility of creating and deleting the tables
0048 // remains with the energy loss classes.
0049 // -----------------------------------------------------------------------------
0050 //
0051 // P. Urban, 06/04/1998
0052 // L. Urban, 27/05/1988 , modifications + new functions added
0053 // L.Urban , 13/10/98 , revision
0054 // L.Urban,  26/10/98 , revision, Interpolate removed
0055 // L.Urban , 08/02/99,  cache mechanism
0056 // L.Urban , 12/04/99 , bug fixed
0057 // don't use the helper class.
0058 // It can't be hidden for Rogue Wave uses it.
0059 // 10.11.99: moved from RWT hash dictionary to STL map, G.Barrand, M.Maire
0060 // 26.10.01: all static functions movev from .icc to .cc file (mma)
0061 // 15.01.03 Add interfaces required for "cut per region" (V.Ivanchenko)
0062 // 12.03.03 Add warnings to obsolete interfaces (V.Ivanchenko)
0063 // 12.04.03 move exception to new method (V.Ivanchenko)
0064 //
0065 // -----------------------------------------------------------------------------
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0068 
0069 class G4EnergyLossTablesHelper {
0070 
0071 friend class G4EnergyLossTables;
0072   // the only instances are within the class G4EnergyLossTables
0073 
0074 public:
0075   G4EnergyLossTablesHelper();
0076 
0077 private:
0078   G4EnergyLossTablesHelper(const G4PhysicsTable* aDEDXTable,
0079                const G4PhysicsTable* aRangeTable,
0080                            const G4PhysicsTable* anInverseRangeTable,
0081                            const G4PhysicsTable* aLabTimeTable,
0082                            const G4PhysicsTable* aProperTimeTable,
0083                G4double aLowestKineticEnergy,
0084                G4double aHighestKineticEnergy,
0085                G4double aMassRatio,
0086                            G4int aNumberOfBins);
0087   // data to be stored in the dictionary
0088   const G4PhysicsTable* theDEDXTable;
0089   const G4PhysicsTable* theRangeTable;
0090   const G4PhysicsTable* theInverseRangeTable;
0091   const G4PhysicsTable* theLabTimeTable;
0092   const G4PhysicsTable* theProperTimeTable;
0093   G4double theLowestKineticEnergy;
0094   G4double theHighestKineticEnergy;
0095   G4double theMassRatio;
0096   G4int theNumberOfBins;
0097 };
0098 
0099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0100 
0101 class G4MaterialCutsCouple;
0102 
0103 class G4EnergyLossTables {
0104 
0105 public:
0106 
0107   // get the table for a given particle
0108   // (0 if the table was not found)
0109   static const G4PhysicsTable* GetDEDXTable(
0110     const G4ParticleDefinition* p);
0111   static const G4PhysicsTable* GetRangeTable(
0112     const G4ParticleDefinition* p);
0113   static const G4PhysicsTable* GetInverseRangeTable(
0114     const G4ParticleDefinition* p);
0115   static const G4PhysicsTable* GetLabTimeTable(
0116     const G4ParticleDefinition* p);
0117   static const G4PhysicsTable* GetProperTimeTable(
0118     const G4ParticleDefinition* p);
0119 
0120   // get the DEDX or the range for a given particle/energy/material
0121   static G4double GetDEDX(
0122     const G4ParticleDefinition *aParticle,
0123     G4double KineticEnergy,
0124     const G4Material *aMaterial);
0125   static G4double GetRange(
0126     const G4ParticleDefinition *aParticle,
0127     G4double KineticEnergy,
0128     const G4Material *aMaterial);
0129   static G4double GetLabTime(
0130     const G4ParticleDefinition *aParticle,
0131     G4double KineticEnergy,
0132     const G4Material *aMaterial);
0133   static G4double GetDeltaLabTime(
0134     const G4ParticleDefinition *aParticle,
0135     G4double KineticEnergyStart,
0136     G4double KineticEnergyEnd,
0137     const G4Material *aMaterial);
0138   static G4double GetProperTime(
0139     const G4ParticleDefinition *aParticle,
0140     G4double KineticEnergy,
0141     const G4Material *aMaterial);
0142   static G4double GetDeltaProperTime(
0143     const G4ParticleDefinition *aParticle,
0144     G4double KineticEnergyStart,
0145     G4double KineticEnergyEnd,
0146     const G4Material *aMaterial);
0147 
0148   static G4double GetPreciseDEDX(
0149     const G4ParticleDefinition *aParticle,
0150     G4double KineticEnergy,
0151     const G4Material *aMaterial);
0152   static G4double GetPreciseRangeFromEnergy(
0153     const G4ParticleDefinition *aParticle,
0154     G4double KineticEnergy,
0155     const G4Material *aMaterial);
0156   static G4double GetPreciseEnergyFromRange(
0157     const G4ParticleDefinition *aParticle,
0158     G4double range,
0159     const G4Material *aMaterial);
0160 
0161   // get the DEDX or the range for a given particle/energy/materialCutsCouple
0162   static G4double GetDEDX(
0163     const G4ParticleDefinition *aParticle,
0164     G4double KineticEnergy,
0165     const G4MaterialCutsCouple *couple,
0166     G4bool check = true);
0167   static G4double GetRange(
0168     const G4ParticleDefinition *aParticle,
0169     G4double KineticEnergy,
0170     const G4MaterialCutsCouple *couple,
0171     G4bool check = true);
0172 
0173   static G4double GetPreciseDEDX(
0174     const G4ParticleDefinition *aParticle,
0175     G4double KineticEnergy,
0176     const G4MaterialCutsCouple *couple);
0177   static G4double GetPreciseRangeFromEnergy(
0178     const G4ParticleDefinition *aParticle,
0179     G4double KineticEnergy,
0180     const G4MaterialCutsCouple *couple);
0181   static G4double GetPreciseEnergyFromRange(
0182     const G4ParticleDefinition *aParticle,
0183     G4double range,
0184     const G4MaterialCutsCouple *couple,
0185     G4bool check = true);
0186 
0187   // to be called only by energy loss processes
0188   static void Register(
0189     const G4ParticleDefinition* p,
0190     const G4PhysicsTable* tDEDX,
0191     const G4PhysicsTable* tRange,
0192     const G4PhysicsTable* tInverseRange,
0193     const G4PhysicsTable* tLabTime,
0194     const G4PhysicsTable* tProperTime,
0195     G4double lowestKineticEnergy,
0196     G4double highestKineticEnergy,
0197     G4double massRatio,
0198     G4int NumberOfBins);
0199 
0200 public:
0201   typedef const G4ParticleDefinition* K;
0202 
0203 private:
0204 
0205   static void CPRWarning();
0206   static void ParticleHaveNoLoss(const G4ParticleDefinition* aParticle,
0207                                  const G4String&);
0208 
0209   /*
0210   typedef std::map<K,G4EnergyLossTablesHelper,std::less<K> > helper_map;
0211   static G4ThreadLocal helper_map *dict;
0212 
0213   static G4EnergyLossTablesHelper GetTables(const G4ParticleDefinition* p);
0214 
0215   static G4ThreadLocal G4EnergyLossTablesHelper *t;
0216   static G4ThreadLocal G4EnergyLossTablesHelper *null_loss;
0217   static G4ThreadLocal G4ParticleDefinition* lastParticle ;
0218   static G4ThreadLocal G4double QQPositron ;
0219   static G4ThreadLocal G4double Chargesquare ;
0220   static G4ThreadLocal G4int oldIndex ;
0221   static G4ThreadLocal G4double rmin,rmax,Thigh ;
0222   static G4ThreadLocal G4int  let_counter;
0223   static G4ThreadLocal G4int  let_max_num_warnings;
0224   static G4ThreadLocal G4bool first_loss;
0225   */
0226   using helper_map = std::map<K, G4EnergyLossTablesHelper, std::less<K> >;
0227   static helper_map *dict;
0228 
0229   static G4EnergyLossTablesHelper GetTables(const G4ParticleDefinition* p);
0230 
0231   static G4EnergyLossTablesHelper *t;
0232   static G4EnergyLossTablesHelper *null_loss;
0233   static G4ParticleDefinition* lastParticle ;
0234   static G4double QQPositron ;
0235   static G4double Chargesquare ;
0236   static G4int oldIndex ;
0237   static G4double rmin,rmax,Thigh ;
0238   static G4int  let_counter;
0239   static G4int  let_max_num_warnings;
0240   static G4bool first_loss;
0241 
0242 };
0243 
0244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0245 
0246 #endif