52 G4VelocityTable::G4VelocityTable()
54 : edgeMin(0.), edgeMax(0.), numberOfNodes(0),
55 dBin(0.), baseBin(0.),
56 lastEnergy(-
DBL_MAX), lastValue(0.), lastBin(0),
57 maxT( 1000.0 ), minT( 0.0001 ), NbinT( 500 )
59 PrepareVelocityTable();
63 G4VelocityTable::~G4VelocityTable()
72 void G4VelocityTable::PrepareVelocityTable()
78 dBin = std::log10(maxT/minT)/NbinT;
79 baseBin = std::log10(minT)/dBin;
81 numberOfNodes = NbinT + 1;
82 dataVector.reserve(numberOfNodes);
83 binVector.reserve(numberOfNodes);
85 const G4double g4log10 = std::log(10.);
87 binVector.push_back(minT);
88 dataVector.push_back(0.0);
90 for (
size_t i=1; i<numberOfNodes-1; i++){
91 binVector.push_back(std::exp(g4log10*(baseBin+i)*dBin));
92 dataVector.push_back(0.0);
94 binVector.push_back(maxT);
95 dataVector.push_back(0.0);
97 edgeMin = binVector[0];
98 edgeMax = binVector[numberOfNodes-1];
100 for (
G4int i=0; i<=NbinT; i++){
102 dataVector[i]=
c_light*std::sqrt(T*(T+2.))/(T+1.0);
108 size_t G4VelocityTable::FindBinLocation(
G4double theEnergy)
const
120 return size_t( std::log10(theEnergy)/dBin - baseBin );
130 if( theEnergy == lastEnergy ) {
132 }
else if( theEnergy < lastEnergy
133 && theEnergy >= binVector[lastBin]) {
134 lastEnergy = theEnergy;
135 lastValue = Interpolation();
137 }
else if( theEnergy <= edgeMin ) {
139 lastEnergy = edgeMin;
140 lastValue = dataVector[0];
142 }
else if( theEnergy >= edgeMax ){
143 lastBin = numberOfNodes-1;
144 lastEnergy = edgeMax;
145 lastValue = dataVector[lastBin];
148 lastBin = FindBinLocation(theEnergy);
149 lastEnergy = theEnergy;
150 lastValue = Interpolation();
178 G4Exception(
"G4VelocityTable::SetVelocityTableProperties",
180 "Can modify only in PreInit or Idle state : Method ignored.");
184 if (nbin > 100 ) theInstance->NbinT = nbin;
185 if ((t_min < t_max)&&(t_min>0.)) {
186 theInstance->minT = t_min;
187 theInstance->maxT = t_max;
189 theInstance->PrepareVelocityTable();
static G4VelocityTable * GetVelocityTable()
static G4double GetMinTOfVelocityTable()
static G4StateManager * GetStateManager()
static G4int GetNbinOfVelocityTable()
G4ApplicationState GetCurrentState() const
static void SetVelocityTableProperties(G4double t_max, G4double t_min, G4int nbin)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4double GetMaxTOfVelocityTable()
G4double Value(G4double theEnergy)