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