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 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 
 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 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
 74 } G4CacheValue;
 75 // #########################################################################
 76 // # Class G4IonDEDXHandler: Handler class for stopping power tables
 77 // #########################################################################
 78 
 79 class G4IonDEDXHandler {
 80  public:
 81   explicit G4IonDEDXHandler(G4VIonDEDXTable* tables,
 82           G4VIonDEDXScalingAlgorithm* algorithm,
 83           const G4String& name,
 84           G4int maxCacheSize = 5,
 85           G4bool splines = true);
 86   ~G4IonDEDXHandler();
 87 
 88   // Function checking the availability of stopping power values for a 
 89   // given ion-target combination (kinetic energy not considered) 
 90   G4bool IsApplicable(
 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
 96   G4double GetDEDX(
 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
104   G4bool BuildDEDXTable(
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
110   G4bool BuildDEDXTable(
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
125   G4double GetLowerEnergyEdge(
126             const G4ParticleDefinition*,  // Projectile (ion) 
127             const G4Material*);           // Target material 
128   
129   // Function returning the upper energy edge of stopping power tables 
130   G4double GetUpperEnergyEdge(
131             const G4ParticleDefinition*,  // Projectile (ion) 
132             const G4Material*);           // Target material 
133   
134   // Function for clearing the cache
135   void ClearCache();
136   
137   G4String GetName();
138   
139   G4IonDEDXHandler& operator=(const G4IonDEDXHandler &r) = delete;
140   G4IonDEDXHandler(const G4IonDEDXHandler&) = delete;
141 
142 private:
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 
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*> G4IonKey;
160    typedef std::map<G4IonKey, G4PhysicsVector*> DEDXTable; 
161    DEDXTable stoppingPowerTable;
162 
163    // Map of dE/dx vectors, built according to the Bragg additivity rule
164    typedef std::map<G4IonKey, G4PhysicsVector*> DEDXTableBraggRule;
165    DEDXTableBraggRule stoppingPowerTableBragg;
166 
167    // Flag indicating the usage of splines for dE/dx vectors built according
168    // to Bragg rule
169    G4bool useSplines;
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 {
179       G4CacheKey key;
180       G4CacheValue value;
181    } G4CacheEntry;
182 
183    // A cache entry list, and a map of pointers to list iterators (for faster
184    // searching)
185    typedef std::list<G4CacheEntry> CacheEntryList;
186    CacheEntryList cacheEntries;
187 
188    typedef std::map<G4CacheKey, void*> CacheIterPointerMap;
189    CacheIterPointerMap cacheKeyPointers;  
190 
191   // Function for updating the cache
192    G4CacheValue UpdateCacheValue(
193                 const G4ParticleDefinition*,  // Projectile (ion) 
194                 const G4Material*);           // Target material
195 
196    // Function for retrieving cache values
197    G4CacheValue GetCacheValue(
198                 const G4ParticleDefinition*,  // Projectile (ion) 
199                 const G4Material*);           // Target material
200 
201    // Maximum number of cache entries
202    G4int maxCacheEntries;
203 
204 };
205 
206 #endif  // G4IONDEDXHANDLER_HH
207