Geant4-11
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends
G4VelocityTable Class Reference

#include <G4VelocityTable.hh>

Public Member Functions

G4double Value (G4double theEnergy)
 

Static Public Member Functions

static G4double GetMaxTOfVelocityTable ()
 
static G4double GetMinTOfVelocityTable ()
 
static G4int GetNbinOfVelocityTable ()
 
static G4VelocityTableGetVelocityTable ()
 
static void SetVelocityTableProperties (G4double t_max, G4double t_min, G4int nbin)
 

Private Types

using G4VTDataVector = std::vector< G4double >
 

Private Member Functions

std::size_t FindBinLocation (G4double theEnergy) const
 
 G4VelocityTable ()
 
G4double Interpolation () const
 
void PrepareVelocityTable ()
 
 ~G4VelocityTable ()
 

Private Attributes

G4double baseBin = 0.0
 
G4VTDataVector binVector
 
G4VTDataVector dataVector
 
G4double dBin = 0.0
 
G4double edgeMax = 0.0
 
G4double edgeMin = 0.0
 
std::size_t lastBin = 0
 
G4double lastEnergy = -DBL_MAX
 
G4double lastValue = 0.0
 
G4double maxT = 1000.0
 
G4double minT = 0.0001
 
G4int NbinT = 500
 
std::size_t numberOfNodes = 0
 
G4VTDataVector secDerivative
 

Static Private Attributes

static G4ThreadLocal G4VelocityTabletheInstance = nullptr
 

Friends

class G4ThreadLocalSingleton< G4VelocityTable >
 

Detailed Description

Definition at line 46 of file G4VelocityTable.hh.

Member Typedef Documentation

◆ G4VTDataVector

using G4VelocityTable::G4VTDataVector = std::vector<G4double>
private

Definition at line 50 of file G4VelocityTable.hh.

Constructor & Destructor Documentation

◆ G4VelocityTable()

G4VelocityTable::G4VelocityTable ( )
private

Definition at line 43 of file G4VelocityTable.cc.

44{
46}
void PrepareVelocityTable()

References PrepareVelocityTable().

◆ ~G4VelocityTable()

G4VelocityTable::~G4VelocityTable ( )
private

Definition at line 49 of file G4VelocityTable.cc.

50{
51 dataVector.clear();
52 binVector.clear();
53}
G4VTDataVector dataVector
G4VTDataVector binVector

References binVector, and dataVector.

Member Function Documentation

◆ FindBinLocation()

std::size_t G4VelocityTable::FindBinLocation ( G4double  theEnergy) const
private

Definition at line 93 of file G4VelocityTable.cc.

94{
95 // For G4PhysicsLogVector, FindBinLocation is implemented using
96 // a simple arithmetic calculation.
97 //
98 // Because this is a virtual function, it is accessed through a
99 // pointer to the G4PhysicsVector object for most usages. In this
100 // case, 'inline' will not be invoked. However, there is a possibility
101 // that the user access to the G4PhysicsLogVector object directly and
102 // not through pointers or references. In this case, the 'inline' will
103 // be invoked. (See R.B.Murray, "C++ Strategies and Tactics", Chap.6.6)
104
105 // const G4double g4log10 = G4Log(10.);
106 return std::size_t(G4Log(theEnergy) / dBin - baseBin);
107}
G4double G4Log(G4double x)
Definition: G4Log.hh:226

References baseBin, dBin, and G4Log().

◆ GetMaxTOfVelocityTable()

G4double G4VelocityTable::GetMaxTOfVelocityTable ( )
static

Definition at line 193 of file G4VelocityTable.cc.

194{
195 return GetVelocityTable()->maxT;
196}
static G4VelocityTable * GetVelocityTable()

References GetVelocityTable(), and maxT.

◆ GetMinTOfVelocityTable()

G4double G4VelocityTable::GetMinTOfVelocityTable ( )
static

Definition at line 199 of file G4VelocityTable.cc.

200{
201 return GetVelocityTable()->minT;
202}

References GetVelocityTable(), and minT.

◆ GetNbinOfVelocityTable()

G4int G4VelocityTable::GetNbinOfVelocityTable ( )
static

Definition at line 205 of file G4VelocityTable.cc.

206{
207 return GetVelocityTable()->NbinT;
208}

References GetVelocityTable(), and NbinT.

◆ GetVelocityTable()

G4VelocityTable * G4VelocityTable::GetVelocityTable ( )
static

◆ Interpolation()

G4double G4VelocityTable::Interpolation ( ) const
inlineprivate

Definition at line 108 of file G4VelocityTable.hh.

109{
110 // Linear interpolation is used to get the value. If the give energy
111 // is in the highest bin, no interpolation will be Done. Because
112 // there is an extra bin hidden from a user at locBin=numberOfBin,
113 // the following interpolation is valid even the current locBin=
114 // numberOfBin-1.
115
116 G4double intplFactor =
118 (binVector[lastBin + 1] - binVector[lastBin]); // Interpol. factor
119
120 return dataVector[lastBin] +
121 (dataVector[lastBin + 1] - dataVector[lastBin]) * intplFactor;
122}
double G4double
Definition: G4Types.hh:83
std::size_t lastBin

Referenced by Value().

◆ PrepareVelocityTable()

void G4VelocityTable::PrepareVelocityTable ( )
private

Definition at line 56 of file G4VelocityTable.cc.

57{
58 // const G4double g4log10 = std::log(10.);
59
60 dataVector.clear();
61 binVector.clear();
62 dBin = G4Log(maxT / minT) / NbinT;
64
65 numberOfNodes = NbinT + 1;
67 binVector.reserve(numberOfNodes);
68
69 binVector.push_back(minT);
70 dataVector.push_back(0.0);
71
72 for(std::size_t i = 1; i < numberOfNodes - 1; ++i)
73 {
74 binVector.push_back(G4Exp((baseBin + i) * dBin));
75 dataVector.push_back(0.0);
76 }
77 binVector.push_back(maxT);
78 dataVector.push_back(0.0);
79
80 edgeMin = binVector[0];
82
83 for(G4int i = 0; i <= NbinT; ++i)
84 {
85 G4double T = binVector[i];
86 dataVector[i] = c_light * std::sqrt(T * (T + 2.)) / (T + 1.0);
87 }
88
89 return;
90}
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:179
int G4int
Definition: G4Types.hh:85
std::size_t numberOfNodes
float c_light
Definition: hepunit.py:256

References baseBin, binVector, source.hepunit::c_light, dataVector, dBin, edgeMax, edgeMin, G4Exp(), G4Log(), maxT, minT, NbinT, and numberOfNodes.

Referenced by G4VelocityTable(), and SetVelocityTableProperties().

◆ SetVelocityTableProperties()

void G4VelocityTable::SetVelocityTableProperties ( G4double  t_max,
G4double  t_min,
G4int  nbin 
)
static

Definition at line 162 of file G4VelocityTable.cc.

164{
165 if(theInstance == nullptr)
166 {
168 }
169
171 G4ApplicationState currentState = stateManager->GetCurrentState();
172
173 // check if state is outside event loop
174 if(!(currentState == G4State_Idle || currentState == G4State_PreInit))
175 {
176 G4Exception("G4VelocityTable::SetVelocityTableProperties()", "Track101",
178 "Can modify only in PreInit or Idle state : Method ignored.");
179 return;
180 }
181
182 if(nbin > 100)
183 theInstance->NbinT = nbin;
184 if((t_min < t_max) && (t_min > 0.))
185 {
186 theInstance->minT = t_min;
187 theInstance->maxT = t_max;
188 }
190}
G4ApplicationState
@ G4State_Idle
@ G4State_PreInit
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()

References G4Exception(), G4State_Idle, G4State_PreInit, G4StateManager::GetCurrentState(), G4StateManager::GetStateManager(), GetVelocityTable(), JustWarning, maxT, minT, NbinT, PrepareVelocityTable(), and theInstance.

◆ Value()

G4double G4VelocityTable::Value ( G4double  theEnergy)

Definition at line 110 of file G4VelocityTable.cc.

111{
112 // Use cache for speed up - check if the value 'theEnergy' is same as the
113 // last call. If it is same, then use the last bin location. Also the
114 // value 'theEnergy' lies between the last energy and low edge of of the
115 // bin of last call, then the last bin location is used
116
117 if(theEnergy == lastEnergy)
118 {
119 }
120 else if(theEnergy < lastEnergy && theEnergy >= binVector[lastBin])
121 {
122 lastEnergy = theEnergy;
124 }
125 else if(theEnergy <= edgeMin)
126 {
127 lastBin = 0;
130 }
131 else if(theEnergy >= edgeMax)
132 {
136 }
137 else
138 {
139 lastBin = (std::size_t)(G4Log(theEnergy) / dBin - baseBin);
141 {
142 --lastBin;
143 } // VI: fix possible precision lost
144 lastEnergy = theEnergy;
146 }
147 return lastValue;
148}
G4double Interpolation() const

References baseBin, binVector, dataVector, dBin, edgeMax, edgeMin, G4Log(), Interpolation(), lastBin, lastEnergy, lastValue, and numberOfNodes.

Friends And Related Function Documentation

◆ G4ThreadLocalSingleton< G4VelocityTable >

friend class G4ThreadLocalSingleton< G4VelocityTable >
friend

Definition at line 108 of file G4VelocityTable.hh.

Field Documentation

◆ baseBin

G4double G4VelocityTable::baseBin = 0.0
private

Definition at line 91 of file G4VelocityTable.hh.

Referenced by FindBinLocation(), PrepareVelocityTable(), and Value().

◆ binVector

G4VTDataVector G4VelocityTable::binVector
private

Definition at line 87 of file G4VelocityTable.hh.

Referenced by PrepareVelocityTable(), Value(), and ~G4VelocityTable().

◆ dataVector

G4VTDataVector G4VelocityTable::dataVector
private

Definition at line 86 of file G4VelocityTable.hh.

Referenced by PrepareVelocityTable(), Value(), and ~G4VelocityTable().

◆ dBin

G4double G4VelocityTable::dBin = 0.0
private

Definition at line 90 of file G4VelocityTable.hh.

Referenced by FindBinLocation(), PrepareVelocityTable(), and Value().

◆ edgeMax

G4double G4VelocityTable::edgeMax = 0.0
private

Definition at line 82 of file G4VelocityTable.hh.

Referenced by PrepareVelocityTable(), and Value().

◆ edgeMin

G4double G4VelocityTable::edgeMin = 0.0
private

Definition at line 81 of file G4VelocityTable.hh.

Referenced by PrepareVelocityTable(), and Value().

◆ lastBin

std::size_t G4VelocityTable::lastBin = 0
private

Definition at line 95 of file G4VelocityTable.hh.

Referenced by Value().

◆ lastEnergy

G4double G4VelocityTable::lastEnergy = -DBL_MAX
private

Definition at line 93 of file G4VelocityTable.hh.

Referenced by Value().

◆ lastValue

G4double G4VelocityTable::lastValue = 0.0
private

Definition at line 94 of file G4VelocityTable.hh.

Referenced by Value().

◆ maxT

G4double G4VelocityTable::maxT = 1000.0
private

◆ minT

G4double G4VelocityTable::minT = 0.0001
private

◆ NbinT

G4int G4VelocityTable::NbinT = 500
private

◆ numberOfNodes

std::size_t G4VelocityTable::numberOfNodes = 0
private

Definition at line 84 of file G4VelocityTable.hh.

Referenced by PrepareVelocityTable(), and Value().

◆ secDerivative

G4VTDataVector G4VelocityTable::secDerivative
private

Definition at line 88 of file G4VelocityTable.hh.

◆ theInstance

G4ThreadLocal G4VelocityTable * G4VelocityTable::theInstance = nullptr
staticprivate

Definition at line 97 of file G4VelocityTable.hh.

Referenced by GetVelocityTable(), and SetVelocityTableProperties().


The documentation for this class was generated from the following files: