Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VelocityTable.hh
이 파일의 문서화 페이지로 가기
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 107603 2017-11-27 07:21:59Z 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"
50 
54 {
56 
57  // velocity table for massive particles used in CalculateVelocity
58  private:
59  typedef std::vector<G4double> G4VTDataVector;
60 
61  public:
62 
63  G4double Value(G4double theEnergy);
64  // Get the cross-section/energy-loss value corresponding to the
65  // given energy. An appropriate interpolation is used to calculate
66  // the value.
67 
69 
70  static void SetVelocityTableProperties(G4double t_max,
71  G4double t_min,
72  G4int nbin);
76 
77  private:
78 
81 
82  size_t FindBinLocation(G4double theEnergy) const;
83  // Find the bin# in which theEnergy belongs - pure virtual function
84 
85  G4double Interpolation() const;
86 
87  G4double edgeMin; // Energy of first point
88  G4double edgeMax; // Energy of the last point
89 
90  size_t numberOfNodes;
91 
92  G4VTDataVector dataVector; // Vector to keep the crossection/energyloss
93  G4VTDataVector binVector; // Vector to keep energy
94  G4VTDataVector secDerivative; // Vector to keep second derivatives
95 
96  G4double dBin; // Bin width - useful only for fixed binning
97  G4double baseBin; // Set this in constructor for performance
98 
99  G4double lastEnergy; // Cache the last input value
100  G4double lastValue; // Cache the last output value
101  size_t lastBin; // Cache the last bin location
102 
103  private:
104  void PrepareVelocityTable();
105 
110 };
111 
112 inline
114 {
115  // Linear interpolation is used to get the value. If the give energy
116  // is in the highest bin, no interpolation will be Done. Because
117  // there is an extra bin hidden from a user at locBin=numberOfBin,
118  // the following interpolation is valid even the current locBin=
119  // numberOfBin-1.
120 
121  G4double intplFactor = (lastEnergy-binVector[lastBin])
122  / (binVector[lastBin + 1]-binVector[lastBin]); // Interpol. factor
123 
124  return dataVector[lastBin] +
125  ( dataVector[lastBin + 1]-dataVector[lastBin] ) * intplFactor;
126 }
127 
128 #endif
129 
130 
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
G4VTDataVector binVector
static G4ThreadLocal G4VelocityTable * theInstance
G4double Value(G4double theEnergy)
static G4VelocityTable * GetVelocityTable()
G4double Interpolation() const
size_t FindBinLocation(G4double theEnergy) const
static G4double GetMinTOfVelocityTable()
static G4double GetMaxTOfVelocityTable()
void PrepareVelocityTable()
#define G4ThreadLocal
Definition: tls.hh:69
double G4double
Definition: G4Types.hh:76
std::vector< G4double > G4VTDataVector
int G4int
Definition: G4Types.hh:78
G4VTDataVector dataVector
G4VTDataVector secDerivative
static G4int GetNbinOfVelocityTable()