source: trunk/source/processes/electromagnetic/lowenergy/include/G4IonDEDXHandler.hh @ 1196

Last change on this file since 1196 was 1057, checked in by garnier, 15 years ago

file release beta

File size: 8.1 KB
Line 
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
48#ifndef G4IONDEDXHANDLER_HH
49#define G4IONDEDXHANDLER_HH
50
51#include "globals.hh"
52#include <vector>
53#include <utility>
54#include <list>
55#include <map>
56
57class G4ParticleDefinition;
58class G4Material;
59class G4PhysicsVector;
60class G4VIonDEDXTable;
61class G4VIonDEDXScalingAlgorithm;
62
63
64// #########################################################################
65// # Type definitions for a local cache
66// #########################################################################
67
68   typedef struct CacheValue{
69      G4double energyScaling;         // Scaling factor for kinetic energy
70      G4PhysicsVector* dedxVector;    // dE/dx vector for current projectile-
71                                      // material combination
72      G4double lowerEnergyEdge;       // Lower energy edge of dE/dx vector
73      G4double upperEnergyEdge;       // Upper energy edge of dE/dx vector
74      G4double density;               // Material density
75   } G4CacheValue;
76
77
78// #########################################################################
79// # Class G4IonDEDXHandler: Handler class for stopping power tables
80// #########################################################################
81
82class G4IonDEDXHandler {
83
84 public:
85   G4IonDEDXHandler(G4VIonDEDXTable* tables,
86                    G4VIonDEDXScalingAlgorithm* algorithm,
87                    const G4String& name,
88                    G4int maxCacheSize = 5,
89                    G4bool splines = true);
90   ~G4IonDEDXHandler();
91
92   // Function checking the availability of stopping power values for a
93   // given ion-target combination (kinetic energy not considered)
94   G4bool IsApplicable(
95              const G4ParticleDefinition*,  // Projectile (ion) 
96              const G4Material*);           // Target material             
97
98   // Function returning the stopping power of a given material for a
99   // projectile of specified energy
100   G4double GetDEDX(
101              const G4ParticleDefinition*,  // Projectile (ion) 
102              const G4Material*,            // Target material
103              G4double);                    // Kinetic energy of projectile
104
105
106   // Function for building stopping power vectors according to Bragg's
107   // additivity rule
108   G4bool BuildDEDXTable(
109              const G4ParticleDefinition*,  // Projectile (ion) 
110              const G4Material*);           // Target material
111
112   // Function for building stopping power vectors according to Bragg's
113   // additivity rule
114   G4bool BuildDEDXTable(
115              G4int atomicNumberIon,        // Atomic number of ion
116              const G4Material*);           // Target material
117
118   // Function printing stopping powers for a given ion-material combination
119   // within a specified energy range
120   void PrintDEDXTable(
121              const G4ParticleDefinition*,  // Projectile (ion) 
122              const G4Material* ,           // Target material
123              G4double,                     // Minimum energy per nucleon
124              G4double,                     // Maximum energy per nucleon
125              G4int,                        // Number of bins
126              G4bool logScaleEnergy = true);// Logarithmic scaling of energy
127
128   // Function returning the lower energy edge of stopping power tables
129   G4double GetLowerEnergyEdge(
130              const G4ParticleDefinition*,  // Projectile (ion) 
131              const G4Material*);           // Target material
132
133   // Function returning the upper energy edge of stopping power tables
134   G4double GetUpperEnergyEdge(
135              const G4ParticleDefinition*,  // Projectile (ion) 
136              const G4Material*);           // Target material
137
138   // Function for clearing the cache
139   void ClearCache();
140
141   G4String GetName();
142
143 private: 
144   // The assignment operator and the copy constructor are hidden
145   G4IonDEDXHandler& operator=(const G4IonDEDXHandler &r);
146   G4IonDEDXHandler(const G4IonDEDXHandler&);
147
148   // ######################################################################
149   // # Stopping power table (table of stopping power vectors either built
150   // # by G4VIonDEDXTable, or by the current class (using the Bragg
151   // # addivity rule)
152   // ######################################################################
153
154   // Class which creates dE/dx vectors
155   G4VIonDEDXTable* table;
156
157   // Algorithm for scaling dE/dx values
158   G4VIonDEDXScalingAlgorithm* algorithm;
159
160   // Name associated with the dE/dx table
161   G4String tableName;
162
163   // Map of all dE/dx vectors
164   typedef std::pair<G4int, const G4Material*> G4IonKey;
165   typedef std::map<G4IonKey, G4PhysicsVector*> DEDXTable; 
166   DEDXTable stoppingPowerTable;
167
168   // Map of dE/dx vectors, built according to the Bragg additivity rule
169   typedef std::map<G4IonKey, G4PhysicsVector*> DEDXTableBraggRule;
170   DEDXTableBraggRule stoppingPowerTableBragg;
171
172   // Flag indicating the usage of splines for dE/dx vectors built according
173   // to Bragg rule
174   G4bool useSplines;
175
176   // ######################################################################
177   // # "Most-recently-used" cache, to provide a faster access to physics
178   // # vectors
179   // ######################################################################
180
181   // A type definition of cache entry containing a key-value pair
182   typedef std::pair<const G4ParticleDefinition*, const G4Material*> G4CacheKey;
183   typedef struct CacheEntry {
184      G4CacheKey key;
185      G4CacheValue value;
186   } G4CacheEntry;
187
188   // A cache entry list, and a map of pointers to list iterators (for faster
189   // searching)
190   typedef std::list<G4CacheEntry> CacheEntryList;
191   CacheEntryList cacheEntries;
192
193   typedef std::map<G4CacheKey, void*> CacheIterPointerMap;
194   CacheIterPointerMap cacheKeyPointers; 
195
196   // Maximum number of cache entries
197   G4int maxCacheEntries;
198
199   // Function for updating the cache
200   G4CacheValue UpdateCacheValue(
201                const G4ParticleDefinition*,  // Projectile (ion) 
202                const G4Material*);           // Target material
203
204   // Function for retrieving cache values
205   G4CacheValue GetCacheValue(
206                const G4ParticleDefinition*,  // Projectile (ion) 
207                const G4Material*);           // Target material
208};
209
210#endif  // G4IONDEDXHANDLER_HH
Note: See TracBrowser for help on using the repository browser.