G4IonDEDXHandler.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 //
00028 // ===========================================================================
00029 // GEANT4 class header file
00030 //
00031 // Class:                G4IonDEDXHandler
00032 //
00033 // Author:               Anton Lechner (Anton.Lechner@cern.ch)
00034 //
00035 // First implementation: 11. 03. 2009
00036 //
00037 // Modifications: 
00038 //
00039 //
00040 // Class description:
00041 //    Ion dE/dx table handler. 
00042 //
00043 // Comments:
00044 //
00045 // =========================================================================== 
00046 
00047 
00048 #ifndef G4IONDEDXHANDLER_HH
00049 #define G4IONDEDXHANDLER_HH
00050 
00051 #include "globals.hh"
00052 #include <vector>
00053 #include <utility>
00054 #include <list>
00055 #include <map>
00056 
00057 class G4ParticleDefinition;
00058 class G4Material;
00059 class G4PhysicsVector;
00060 class G4VIonDEDXTable;
00061 class G4VIonDEDXScalingAlgorithm;
00062 
00063 
00064 // #########################################################################
00065 // # Type definitions for a local cache
00066 // #########################################################################
00067 
00068    typedef struct CacheValue{
00069       G4double energyScaling;         // Scaling factor for kinetic energy
00070       G4PhysicsVector* dedxVector;    // dE/dx vector for current projectile-
00071                                       // material combination
00072       G4double lowerEnergyEdge;       // Lower energy edge of dE/dx vector
00073       G4double upperEnergyEdge;       // Upper energy edge of dE/dx vector
00074       G4double density;               // Material density
00075    } G4CacheValue;
00076 
00077 
00078 // #########################################################################
00079 // # Class G4IonDEDXHandler: Handler class for stopping power tables
00080 // #########################################################################
00081 
00082 class G4IonDEDXHandler {
00083 
00084  public:
00085    G4IonDEDXHandler(G4VIonDEDXTable* tables,
00086                     G4VIonDEDXScalingAlgorithm* algorithm,
00087                     const G4String& name,
00088                     G4int maxCacheSize = 5,
00089                     G4bool splines = true);
00090    ~G4IonDEDXHandler();
00091 
00092    // Function checking the availability of stopping power values for a 
00093    // given ion-target combination (kinetic energy not considered) 
00094    G4bool IsApplicable(
00095               const G4ParticleDefinition*,  // Projectile (ion) 
00096               const G4Material*);           // Target material             
00097 
00098    // Function returning the stopping power of a given material for a
00099    // projectile of specified energy
00100    G4double GetDEDX(
00101               const G4ParticleDefinition*,  // Projectile (ion) 
00102               const G4Material*,            // Target material 
00103               G4double);                    // Kinetic energy of projectile
00104 
00105 
00106    // Function for building stopping power vectors according to Bragg's
00107    // additivity rule
00108    G4bool BuildDEDXTable(
00109               const G4ParticleDefinition*,  // Projectile (ion) 
00110               const G4Material*);           // Target material 
00111 
00112    // Function for building stopping power vectors according to Bragg's
00113    // additivity rule
00114    G4bool BuildDEDXTable(
00115               G4int atomicNumberIon,        // Atomic number of ion 
00116               const G4Material*);           // Target material 
00117 
00118    // Function printing stopping powers for a given ion-material combination
00119    // within a specified energy range 
00120    void PrintDEDXTable(
00121               const G4ParticleDefinition*,  // Projectile (ion) 
00122               const G4Material* ,           // Target material
00123               G4double,                     // Minimum energy per nucleon
00124               G4double,                     // Maximum energy per nucleon
00125               G4int,                        // Number of bins
00126               G4bool logScaleEnergy = true);// Logarithmic scaling of energy
00127 
00128    // Function returning the lower energy edge of stopping power tables
00129    G4double GetLowerEnergyEdge(
00130               const G4ParticleDefinition*,  // Projectile (ion) 
00131               const G4Material*);           // Target material 
00132 
00133    // Function returning the upper energy edge of stopping power tables 
00134    G4double GetUpperEnergyEdge(
00135               const G4ParticleDefinition*,  // Projectile (ion) 
00136               const G4Material*);           // Target material 
00137 
00138    // Function for clearing the cache
00139    void ClearCache();
00140 
00141    G4String GetName();
00142 
00143  private: 
00144    // The assignment operator and the copy constructor are hidden
00145    G4IonDEDXHandler& operator=(const G4IonDEDXHandler &r);
00146    G4IonDEDXHandler(const G4IonDEDXHandler&);
00147 
00148    // ######################################################################
00149    // # Stopping power table (table of stopping power vectors either built
00150    // # by G4VIonDEDXTable, or by the current class (using the Bragg 
00151    // # addivity rule)
00152    // ######################################################################
00153 
00154    // Class which creates dE/dx vectors 
00155    G4VIonDEDXTable* table;
00156 
00157    // Algorithm for scaling dE/dx values
00158    G4VIonDEDXScalingAlgorithm* algorithm;
00159 
00160    // Name associated with the dE/dx table
00161    G4String tableName;
00162 
00163    // Map of all dE/dx vectors
00164    typedef std::pair<G4int, const G4Material*> G4IonKey;
00165    typedef std::map<G4IonKey, G4PhysicsVector*> DEDXTable; 
00166    DEDXTable stoppingPowerTable;
00167 
00168    // Map of dE/dx vectors, built according to the Bragg additivity rule
00169    typedef std::map<G4IonKey, G4PhysicsVector*> DEDXTableBraggRule;
00170    DEDXTableBraggRule stoppingPowerTableBragg;
00171 
00172    // Flag indicating the usage of splines for dE/dx vectors built according
00173    // to Bragg rule
00174    G4bool useSplines;
00175 
00176    // ######################################################################
00177    // # "Most-recently-used" cache, to provide a faster access to physics 
00178    // # vectors
00179    // ######################################################################
00180 
00181    // A type definition of cache entry containing a key-value pair
00182    typedef std::pair<const G4ParticleDefinition*, const G4Material*> G4CacheKey;
00183    typedef struct CacheEntry {
00184       G4CacheKey key;
00185       G4CacheValue value;
00186    } G4CacheEntry;
00187 
00188    // A cache entry list, and a map of pointers to list iterators (for faster
00189    // searching)
00190    typedef std::list<G4CacheEntry> CacheEntryList;
00191    CacheEntryList cacheEntries;
00192 
00193    typedef std::map<G4CacheKey, void*> CacheIterPointerMap;
00194    CacheIterPointerMap cacheKeyPointers;  
00195 
00196    // Maximum number of cache entries
00197    G4int maxCacheEntries;
00198 
00199    // Function for updating the cache
00200    G4CacheValue UpdateCacheValue(
00201                 const G4ParticleDefinition*,  // Projectile (ion) 
00202                 const G4Material*);           // Target material
00203 
00204    // Function for retrieving cache values
00205    G4CacheValue GetCacheValue(
00206                 const G4ParticleDefinition*,  // Projectile (ion) 
00207                 const G4Material*);           // Target material
00208 };
00209 
00210 #endif  // G4IONDEDXHANDLER_HH

Generated on Mon May 27 17:48:39 2013 for Geant4 by  doxygen 1.4.7