Geant4  10.01.p01
G4VelocityTable.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 // $Id: G4VelocityTable.hh 69005 2013-04-15 09:26:47Z gcosmo $
28 //
29 //---------------------------------------------------------------
30 //
31 // G4VelocityTable.hh
32 //
33 // class description:
34 // This class keeps a table of velocity as a function of
35 // the ratio kinetic erngy and mass
36 // This class is used by G4Track::CalculateVelocity
37 //
38 //---------------------------------------------------------------
39 // created 17.Aug. 2011 H.Kurashige
40 //
41 
42 #ifndef G4VelocityTable_h
43 #define G4VelocityTable_h 1
44 
45 #include <vector>
46 #include <iostream>
47 #include "globals.hh"
48 #include "G4ios.hh"
49 
53 {
54  // velocity table for massive particles used in CalculateVelocity
55  private:
56  typedef std::vector<G4double> G4VTDataVector;
57 
58  public:
59 
60  G4double Value(G4double theEnergy);
61  // Get the cross-section/energy-loss value corresponding to the
62  // given energy. An appropriate interpolation is used to calculate
63  // the value.
64 
66 
67  static void SetVelocityTableProperties(G4double t_max,
68  G4double t_min,
69  G4int nbin);
73 
74  private:
75 
78 
79  size_t FindBinLocation(G4double theEnergy) const;
80  // Find the bin# in which theEnergy belongs - pure virtual function
81 
82  G4double Interpolation() const;
83 
84  G4double edgeMin; // Energy of first point
85  G4double edgeMax; // Energy of the last point
86 
87  size_t numberOfNodes;
88 
89  G4VTDataVector dataVector; // Vector to keep the crossection/energyloss
90  G4VTDataVector binVector; // Vector to keep energy
91  G4VTDataVector secDerivative; // Vector to keep second derivatives
92 
93  G4double dBin; // Bin width - useful only for fixed binning
94  G4double baseBin; // Set this in constructor for performance
95 
96  G4double lastEnergy; // Cache the last input value
97  G4double lastValue; // Cache the last output value
98  size_t lastBin; // Cache the last bin location
99 
100  private:
101  void PrepareVelocityTable();
102 
107 };
108 
109 inline
111 {
112  // Linear interpolation is used to get the value. If the give energy
113  // is in the highest bin, no interpolation will be Done. Because
114  // there is an extra bin hidden from a user at locBin=numberOfBin,
115  // the following interpolation is valid even the current locBin=
116  // numberOfBin-1.
117 
118  G4double intplFactor = (lastEnergy-binVector[lastBin])
119  / (binVector[lastBin + 1]-binVector[lastBin]); // Interpol. factor
120 
121  return dataVector[lastBin] +
122  ( dataVector[lastBin + 1]-dataVector[lastBin] ) * intplFactor;
123 }
124 
125 #endif
126 
127 
static G4VelocityTable * GetVelocityTable()
static G4double GetMinTOfVelocityTable()
void PrepareVelocityTable()
G4VTDataVector binVector
G4VTDataVector dataVector
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
G4VTDataVector secDerivative
size_t FindBinLocation(G4double theEnergy) const
static G4int GetNbinOfVelocityTable()
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
static G4ThreadLocal G4VelocityTable * theInstance
double G4double
Definition: G4Types.hh:76
static G4double GetMaxTOfVelocityTable()
G4double Value(G4double theEnergy)
G4double Interpolation() const
std::vector< G4double > G4VTDataVector