Geant4-11
G4IonDEDXHandler.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28// ===========================================================================
29// GEANT4 class header file
30//
31// Class: G4IonDEDXHandler
32//
33// Author: Anton Lechner (Anton.Lechner@cern.ch)
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
57class G4Material;
58class G4PhysicsVector;
59class G4VIonDEDXTable;
61
62
63// #########################################################################
64// # Type definitions for a local cache
65// #########################################################################
66
67typedef struct CacheValue{
68 G4double energyScaling; // Scaling factor for kinetic energy
69 G4PhysicsVector* dedxVector; // dE/dx vector for current projectile-
70 // material combination
71 G4double lowerEnergyEdge; // Lower energy edge of dE/dx vector
72 G4double upperEnergyEdge; // Upper energy edge of dE/dx vector
73 G4double density; // Material density
75// #########################################################################
76// # Class G4IonDEDXHandler: Handler class for stopping power tables
77// #########################################################################
78
80 public:
81 explicit G4IonDEDXHandler(G4VIonDEDXTable* tables,
83 const G4String& name,
84 G4int maxCacheSize = 5,
85 G4bool splines = true);
87
88 // Function checking the availability of stopping power values for a
89 // given ion-target combination (kinetic energy not considered)
91 const G4ParticleDefinition*, // Projectile (ion)
92 const G4Material*); // Target material
93
94 // Function returning the stopping power of a given material for a
95 // projectile of specified energy
97 const G4ParticleDefinition*, // Projectile (ion)
98 const G4Material*, // Target material
99 G4double); // Kinetic energy of projectile
100
101
102 // Function for building stopping power vectors according to Bragg's
103 // additivity rule
105 const G4ParticleDefinition*, // Projectile (ion)
106 const G4Material*); // Target material
107
108 // Function for building stopping power vectors according to Bragg's
109 // additivity rule
111 G4int atomicNumberIon, // Atomic number of ion
112 const G4Material*); // Target material
113
114 // Function printing stopping powers for a given ion-material combination
115 // within a specified energy range
116 void PrintDEDXTable(
117 const G4ParticleDefinition*, // Projectile (ion)
118 const G4Material* , // Target material
119 G4double, // Minimum energy per nucleon
120 G4double, // Maximum energy per nucleon
121 G4int, // Number of bins
122 G4bool logScaleEnergy = true);// Logarithmic scaling of energy
123
124 // Function returning the lower energy edge of stopping power tables
126 const G4ParticleDefinition*, // Projectile (ion)
127 const G4Material*); // Target material
128
129 // Function returning the upper energy edge of stopping power tables
131 const G4ParticleDefinition*, // Projectile (ion)
132 const G4Material*); // Target material
133
134 // Function for clearing the cache
135 void ClearCache();
136
138
141
142private:
143 // ######################################################################
144 // # Stopping power table (table of stopping power vectors either built
145 // # by G4VIonDEDXTable, or by the current class (using the Bragg
146 // # addivity rule)
147 // ######################################################################
148
149 // Class which creates dE/dx vectors
151
152 // Algorithm for scaling dE/dx values
154
155 // Name associated with the dE/dx table
157
158 // Map of all dE/dx vectors
159 typedef std::pair<G4int, const G4Material*> G4IonKey;
160 typedef std::map<G4IonKey, G4PhysicsVector*> DEDXTable;
162
163 // Map of dE/dx vectors, built according to the Bragg additivity rule
164 typedef std::map<G4IonKey, G4PhysicsVector*> DEDXTableBraggRule;
166
167 // Flag indicating the usage of splines for dE/dx vectors built according
168 // to Bragg rule
170
171 // ######################################################################
172 // # "Most-recently-used" cache, to provide a faster access to physics
173 // # vectors
174 // ######################################################################
175
176 // A type definition of cache entry containing a key-value pair
177 typedef std::pair<const G4ParticleDefinition*, const G4Material*> G4CacheKey;
178 typedef struct CacheEntry {
182
183 // A cache entry list, and a map of pointers to list iterators (for faster
184 // searching)
185 typedef std::list<G4CacheEntry> CacheEntryList;
187
188 typedef std::map<G4CacheKey, void*> CacheIterPointerMap;
190
191 // Function for updating the cache
193 const G4ParticleDefinition*, // Projectile (ion)
194 const G4Material*); // Target material
195
196 // Function for retrieving cache values
198 const G4ParticleDefinition*, // Projectile (ion)
199 const G4Material*); // Target material
200
201 // Maximum number of cache entries
203
204};
205
206#endif // G4IONDEDXHANDLER_HH
struct CacheValue G4CacheValue
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
std::map< G4IonKey, G4PhysicsVector * > DEDXTable
void PrintDEDXTable(const G4ParticleDefinition *, const G4Material *, G4double, G4double, G4int, G4bool logScaleEnergy=true)
std::pair< const G4ParticleDefinition *, const G4Material * > G4CacheKey
DEDXTable stoppingPowerTable
G4IonDEDXHandler & operator=(const G4IonDEDXHandler &r)=delete
CacheIterPointerMap cacheKeyPointers
G4bool BuildDEDXTable(const G4ParticleDefinition *, const G4Material *)
std::map< G4CacheKey, void * > CacheIterPointerMap
CacheEntryList cacheEntries
struct G4IonDEDXHandler::CacheEntry G4CacheEntry
G4IonDEDXHandler(G4VIonDEDXTable *tables, G4VIonDEDXScalingAlgorithm *algorithm, const G4String &name, G4int maxCacheSize=5, G4bool splines=true)
G4bool IsApplicable(const G4ParticleDefinition *, const G4Material *)
G4VIonDEDXTable * table
std::pair< G4int, const G4Material * > G4IonKey
G4CacheValue UpdateCacheValue(const G4ParticleDefinition *, const G4Material *)
G4double GetLowerEnergyEdge(const G4ParticleDefinition *, const G4Material *)
G4VIonDEDXScalingAlgorithm * algorithm
std::list< G4CacheEntry > CacheEntryList
DEDXTableBraggRule stoppingPowerTableBragg
std::map< G4IonKey, G4PhysicsVector * > DEDXTableBraggRule
G4IonDEDXHandler(const G4IonDEDXHandler &)=delete
G4double GetUpperEnergyEdge(const G4ParticleDefinition *, const G4Material *)
G4double GetDEDX(const G4ParticleDefinition *, const G4Material *, G4double)
G4CacheValue GetCacheValue(const G4ParticleDefinition *, const G4Material *)
const char * name(G4int ptype)
G4double upperEnergyEdge
G4double lowerEnergyEdge
G4double density
G4PhysicsVector * dedxVector
G4double energyScaling