Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 // 28 // =========================================== 29 // GEANT4 class header file 30 // 31 // Class: G4IonDEDXHandler 32 // 33 // Author: Anton Lechner (Anton. 34 // 35 // First implementation: 11. 03. 2009 36 // 37 // Modifications: 38 // 39 // 40 // Class description: 41 // Ion dE/dx table handler. 42 // 43 // Comments: 44 // 45 // =========================================== 46 47 #ifndef G4IONDEDXHANDLER_HH 48 #define G4IONDEDXHANDLER_HH 49 50 #include "globals.hh" 51 #include <vector> 52 #include <utility> 53 #include <list> 54 #include <map> 55 56 class G4ParticleDefinition; 57 class G4Material; 58 class G4PhysicsVector; 59 class G4VIonDEDXTable; 60 class G4VIonDEDXScalingAlgorithm; 61 62 63 // ########################################### 64 // # Type definitions for a local cache 65 // ########################################### 66 67 typedef struct CacheValue{ 68 G4double energyScaling; // Scaling f 69 G4PhysicsVector* dedxVector; // dE/dx vec 70 // material combination 71 G4double lowerEnergyEdge; // Lower ene 72 G4double upperEnergyEdge; // Upper ene 73 G4double density; // Material 74 } G4CacheValue; 75 // ########################################### 76 // # Class G4IonDEDXHandler: Handler class for 77 // ########################################### 78 79 class G4IonDEDXHandler { 80 public: 81 explicit G4IonDEDXHandler(G4VIonDEDXTable* t 82 G4VIonDEDXScalingAlgorithm* algorith 83 const G4String& name, 84 G4int maxCacheSize = 5, 85 G4bool splines = true); 86 ~G4IonDEDXHandler(); 87 88 // Function checking the availability of sto 89 // given ion-target combination (kinetic ene 90 G4bool IsApplicable( 91 const G4ParticleDefinition*, // Pro 92 const G4Material*); // Tar 93 94 // Function returning the stopping power of 95 // projectile of specified energy 96 G4double GetDEDX( 97 const G4ParticleDefinition*, // Projec 98 const G4Material*, // Target 99 G4double); // Kineti 100 101 102 // Function for building stopping power vect 103 // additivity rule 104 G4bool BuildDEDXTable( 105 const G4ParticleDefinition*, // Project 106 const G4Material*); // Target 107 108 // Function for building stopping power vect 109 // additivity rule 110 G4bool BuildDEDXTable( 111 G4int atomicNumberIon, // Atomic 112 const G4Material*); // Target 113 114 // Function printing stopping powers for a g 115 // within a specified energy range 116 void PrintDEDXTable( 117 const G4ParticleDefinition*, // Pro 118 const G4Material* , // Tar 119 G4double, // Min 120 G4double, // Max 121 G4int, // Num 122 G4bool logScaleEnergy = true);// Log 123 124 // Function returning the lower energy edge 125 G4double GetLowerEnergyEdge( 126 const G4ParticleDefinition*, // P 127 const G4Material*); // T 128 129 // Function returning the upper energy edge 130 G4double GetUpperEnergyEdge( 131 const G4ParticleDefinition*, // P 132 const G4Material*); // T 133 134 // Function for clearing the cache 135 void ClearCache(); 136 137 G4String GetName(); 138 139 G4IonDEDXHandler& operator=(const G4IonDEDXH 140 G4IonDEDXHandler(const G4IonDEDXHandler&) = 141 142 private: 143 // ######################################## 144 // # Stopping power table (table of stoppin 145 // # by G4VIonDEDXTable, or by the current 146 // # addivity rule) 147 // ######################################## 148 149 // Class which creates dE/dx vectors 150 G4VIonDEDXTable* table; 151 152 // Algorithm for scaling dE/dx values 153 G4VIonDEDXScalingAlgorithm* algorithm; 154 155 // Name associated with the dE/dx table 156 G4String tableName; 157 158 // Map of all dE/dx vectors 159 typedef std::pair<G4int, const G4Material*> 160 typedef std::map<G4IonKey, G4PhysicsVector* 161 DEDXTable stoppingPowerTable; 162 163 // Map of dE/dx vectors, built according to 164 typedef std::map<G4IonKey, G4PhysicsVector* 165 DEDXTableBraggRule stoppingPowerTableBragg; 166 167 // Flag indicating the usage of splines for 168 // to Bragg rule 169 G4bool useSplines; 170 171 // ######################################## 172 // # "Most-recently-used" cache, to provide 173 // # vectors 174 // ######################################## 175 176 // A type definition of cache entry contain 177 typedef std::pair<const G4ParticleDefinitio 178 typedef struct CacheEntry { 179 G4CacheKey key; 180 G4CacheValue value; 181 } G4CacheEntry; 182 183 // A cache entry list, and a map of pointer 184 // searching) 185 typedef std::list<G4CacheEntry> CacheEntryL 186 CacheEntryList cacheEntries; 187 188 typedef std::map<G4CacheKey, void*> CacheIt 189 CacheIterPointerMap cacheKeyPointers; 190 191 // Function for updating the cache 192 G4CacheValue UpdateCacheValue( 193 const G4ParticleDefinition*, 194 const G4Material*); 195 196 // Function for retrieving cache values 197 G4CacheValue GetCacheValue( 198 const G4ParticleDefinition*, 199 const G4Material*); 200 201 // Maximum number of cache entries 202 G4int maxCacheEntries; 203 204 }; 205 206 #endif // G4IONDEDXHANDLER_HH 207