43G4VelocityTable::G4VelocityTable()
45 PrepareVelocityTable();
49G4VelocityTable::~G4VelocityTable()
56void G4VelocityTable::PrepareVelocityTable()
62 dBin =
G4Log(maxT / minT) / NbinT;
63 baseBin =
G4Log(minT) / dBin;
65 numberOfNodes = NbinT + 1;
66 dataVector.reserve(numberOfNodes);
67 binVector.reserve(numberOfNodes);
69 binVector.push_back(minT);
70 dataVector.push_back(0.0);
72 for(std::size_t i = 1; i < numberOfNodes - 1; ++i)
74 binVector.push_back(
G4Exp((baseBin + i) * dBin));
75 dataVector.push_back(0.0);
77 binVector.push_back(maxT);
78 dataVector.push_back(0.0);
80 edgeMin = binVector[0];
81 edgeMax = binVector[numberOfNodes - 1];
83 for(
G4int i = 0; i <= NbinT; ++i)
86 dataVector[i] = c_light * std::sqrt(T * (T + 2.)) / (T + 1.0);
93std::size_t G4VelocityTable::FindBinLocation(
G4double theEnergy)
const
106 return std::size_t(
G4Log(theEnergy) / dBin - baseBin);
117 if(theEnergy == lastEnergy)
120 else if(theEnergy < lastEnergy && theEnergy >= binVector[lastBin])
122 lastEnergy = theEnergy;
123 lastValue = Interpolation();
125 else if(theEnergy <= edgeMin)
128 lastEnergy = edgeMin;
129 lastValue = dataVector[0];
131 else if(theEnergy >= edgeMax)
133 lastBin = numberOfNodes - 1;
134 lastEnergy = edgeMax;
135 lastValue = dataVector[lastBin];
139 lastBin = (std::size_t)(
G4Log(theEnergy) / dBin - baseBin);
140 if(lastBin == numberOfNodes)
144 lastEnergy = theEnergy;
145 lastValue = Interpolation();
153 if(theInstance ==
nullptr)
165 if(theInstance ==
nullptr)
176 G4Exception(
"G4VelocityTable::SetVelocityTableProperties()",
"Track101",
178 "Can modify only in PreInit or Idle state : Method ignored.");
183 theInstance->NbinT = nbin;
184 if((t_min < t_max) && (t_min > 0.))
186 theInstance->minT = t_min;
187 theInstance->maxT = t_max;
189 theInstance->PrepareVelocityTable();
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
G4double G4Log(G4double x)
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
static G4VelocityTable * GetVelocityTable()
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
G4double Value(G4double theEnergy)
static G4double GetMaxTOfVelocityTable()
static G4double GetMinTOfVelocityTable()
static G4int GetNbinOfVelocityTable()