Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PhysicsVector Class Reference

#include <G4PhysicsVector.hh>

+ Inheritance diagram for G4PhysicsVector:

Public Member Functions

 G4PhysicsVector (G4bool spline=false)
 
 G4PhysicsVector (const G4PhysicsVector &)
 
G4PhysicsVectoroperator= (const G4PhysicsVector &)
 
G4bool operator== (const G4PhysicsVector &right) const
 
G4bool operator!= (const G4PhysicsVector &right) const
 
virtual ~G4PhysicsVector ()
 
G4double Value (G4double theEnergy, std::size_t &lastidx) const
 
G4double LogVectorValue (const G4double theEnergy, const G4double theLogEnergy) const
 
G4double Value (G4double theEnergy) const
 
G4double GetValue (G4double theEnergy, G4bool &isOutRange) const
 
G4double operator[] (const std::size_t index) const
 
G4double operator() (const std::size_t index) const
 
void PutValue (std::size_t index, G4double theValue)
 
virtual void ScaleVector (G4double factorE, G4double factorV)
 
G4double Energy (std::size_t index) const
 
G4double GetMaxEnergy () const
 
G4double GetLowEdgeEnergy (std::size_t binNumber) const
 
std::size_t GetVectorLength () const
 
std::size_t FindBin (const G4double energy, const std::size_t idx) const
 
std::size_t ComputeLogVectorBin (const G4double logenergy) const
 
void FillSecondDerivatives ()
 
void ComputeSecDerivatives ()
 
void ComputeSecondDerivatives (G4double firstPointDerivative, G4double endPointDerivative)
 
G4double FindLinearEnergy (G4double rand) const
 
G4bool IsFilledVectorExist () const
 
G4PhysicsVectorType GetType () const
 
void SetSpline (G4bool)
 
G4bool Store (std::ofstream &fOut, G4bool ascii=false) const
 
virtual G4bool Retrieve (std::ifstream &fIn, G4bool ascii=false)
 
void DumpValues (G4double unitE=1.0, G4double unitV=1.0) const
 
void SetVerboseLevel (G4int value)
 

Protected Member Functions

void DeleteData ()
 
void CopyData (const G4PhysicsVector &vec)
 
void PrintPutValueError (std::size_t index)
 

Protected Attributes

G4PhysicsVectorType type = T_G4PhysicsVector
 
G4double edgeMin = 0.0
 
G4double edgeMax = 0.0
 
G4double invdBin = 0.0
 
G4double baseBin = 0.0
 
G4int verboseLevel = 0
 
std::size_t numberOfNodes = 0
 
G4PVDataVector dataVector
 
G4PVDataVector binVector
 
G4PVDataVector secDerivative
 

Friends

std::ostream & operator<< (std::ostream &, const G4PhysicsVector &)
 

Detailed Description

Definition at line 60 of file G4PhysicsVector.hh.

Constructor & Destructor Documentation

◆ G4PhysicsVector() [1/2]

G4PhysicsVector::G4PhysicsVector ( G4bool  spline = false)
explicit

Definition at line 44 of file G4PhysicsVector.cc.

45 : useSpline(val)
46{}

◆ G4PhysicsVector() [2/2]

G4PhysicsVector::G4PhysicsVector ( const G4PhysicsVector right)

Definition at line 54 of file G4PhysicsVector.cc.

55{
56 invdBin = right.invdBin;
57 baseBin = right.baseBin;
59
60 DeleteData();
61 CopyData(right);
62}
void CopyData(const G4PhysicsVector &vec)

◆ ~G4PhysicsVector()

G4PhysicsVector::~G4PhysicsVector ( )
virtual

Definition at line 50 of file G4PhysicsVector.cc.

50{}

Member Function Documentation

◆ ComputeLogVectorBin()

std::size_t G4PhysicsVector::ComputeLogVectorBin ( const G4double  logenergy) const
inline

◆ ComputeSecDerivatives()

void G4PhysicsVector::ComputeSecDerivatives ( )

Definition at line 443 of file G4PhysicsVector.cc.

444{
445 // A simplified method of computation of second derivatives
446
447 if(3 > numberOfNodes) // cannot compute derivatives for less than 4 bins
448 {
449 useSpline = false;
450 return;
451 }
452
453 if(!SplinePossible())
454 {
455 return;
456 }
457
458 useSpline = true;
459
460 std::size_t n = numberOfNodes - 1;
461
462 for(std::size_t i = 1; i < n; ++i)
463 {
464 secDerivative[i] =
465 3.0 *
466 ((dataVector[i + 1] - dataVector[i]) / (binVector[i + 1] - binVector[i]) -
467 (dataVector[i] - dataVector[i - 1]) /
468 (binVector[i] - binVector[i - 1])) /
469 (binVector[i + 1] - binVector[i - 1]);
470 }
473}
G4PVDataVector binVector
G4PVDataVector secDerivative
std::size_t numberOfNodes
G4PVDataVector dataVector

Referenced by ComputeSecondDerivatives(), and FillSecondDerivatives().

◆ ComputeSecondDerivatives()

void G4PhysicsVector::ComputeSecondDerivatives ( G4double  firstPointDerivative,
G4double  endPointDerivative 
)

Definition at line 288 of file G4PhysicsVector.cc.

294{
295 if(4 > numberOfNodes) // cannot compute derivatives for less than 4 bins
296 {
298 return;
299 }
300
301 if(!SplinePossible())
302 {
303 return;
304 }
305
306 useSpline = true;
307
308 G4int n = numberOfNodes - 1;
309
310 G4double* u = new G4double[n];
311
312 G4double p, sig, un;
313
314 u[0] = (6.0 / (binVector[1] - binVector[0])) *
315 ((dataVector[1] - dataVector[0]) / (binVector[1] - binVector[0]) -
316 firstPointDerivative);
317
318 secDerivative[0] = -0.5;
319
320 // Decomposition loop for tridiagonal algorithm. secDerivative[i]
321 // and u[i] are used for temporary storage of the decomposed factors.
322
323 for(G4int i = 1; i < n; ++i)
324 {
325 sig =
326 (binVector[i] - binVector[i - 1]) / (binVector[i + 1] - binVector[i - 1]);
327 p = sig * (secDerivative[i - 1]) + 2.0;
328 secDerivative[i] = (sig - 1.0) / p;
329 u[i] =
330 (dataVector[i + 1] - dataVector[i]) / (binVector[i + 1] - binVector[i]) -
331 (dataVector[i] - dataVector[i - 1]) / (binVector[i] - binVector[i - 1]);
332 u[i] =
333 6.0 * u[i] / (binVector[i + 1] - binVector[i - 1]) - sig * u[i - 1] / p;
334 }
335
336 sig =
337 (binVector[n - 1] - binVector[n - 2]) / (binVector[n] - binVector[n - 2]);
338 p = sig * secDerivative[n - 2] + 2.0;
339 un = (6.0 / (binVector[n] - binVector[n - 1])) *
340 (endPointDerivative - (dataVector[n] - dataVector[n - 1]) /
341 (binVector[n] - binVector[n - 1])) -
342 u[n - 1] / p;
343 secDerivative[n] = un / (secDerivative[n - 1] + 2.0);
344
345 // The back-substitution loop for the triagonal algorithm of solving
346 // a linear system of equations.
347
348 for(G4int k = n - 1; k > 0; --k)
349 {
350 secDerivative[k] *=
351 (secDerivative[k + 1] - u[k] * (binVector[k + 1] - binVector[k - 1]) /
352 (binVector[k + 1] - binVector[k]));
353 }
354 secDerivative[0] = 0.5 * (u[0] - secDerivative[1]);
355
356 delete[] u;
357}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
void ComputeSecDerivatives()

◆ CopyData()

void G4PhysicsVector::CopyData ( const G4PhysicsVector vec)
protected

Definition at line 105 of file G4PhysicsVector.cc.

106{
107 type = vec.type;
108 edgeMin = vec.edgeMin;
109 edgeMax = vec.edgeMax;
111 useSpline = vec.useSpline;
112
113 std::size_t i;
115 for(i = 0; i < numberOfNodes; ++i)
116 {
117 dataVector[i] = (vec.dataVector)[i];
118 }
119 binVector.resize(numberOfNodes);
120 for(i = 0; i < numberOfNodes; ++i)
121 {
122 binVector[i] = (vec.binVector)[i];
123 }
124 if(0 < (vec.secDerivative).size())
125 {
127 for(i = 0; i < numberOfNodes; ++i)
128 {
129 secDerivative[i] = (vec.secDerivative)[i];
130 }
131 }
132}
G4PhysicsVectorType type

Referenced by G4PhysicsVector(), and operator=().

◆ DeleteData()

void G4PhysicsVector::DeleteData ( )
protected

Definition at line 97 of file G4PhysicsVector.cc.

98{
99 useSpline = false;
100 secDerivative.clear();
101}

Referenced by G4PhysicsVector(), and operator=().

◆ DumpValues()

void G4PhysicsVector::DumpValues ( G4double  unitE = 1.0,
G4double  unitV = 1.0 
) const

Definition at line 261 of file G4PhysicsVector.cc.

262{
263 for(std::size_t i = 0; i < numberOfNodes; ++i)
264 {
265 G4cout << binVector[i] / unitE << " " << dataVector[i] / unitV << G4endl;
266 }
267}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

Referenced by G4Cerenkov::DumpPhysicsTable(), G4Scintillation::DumpPhysicsTable(), G4OpWLS::DumpPhysicsTable(), and G4OpWLS2::DumpPhysicsTable().

◆ Energy()

G4double G4PhysicsVector::Energy ( std::size_t  index) const
inline

Referenced by G4EmCorrections::BarkasCorrection(), G4DiffuseElasticV2::BuildAngleTable(), G4KokoulinMuonNuclearXS::BuildCrossSectionTable(), G4LossTableBuilder::BuildInverseRangeTable(), G4VRangeToEnergyConverter::BuildLossTable(), G4Cerenkov::BuildPhysicsTable(), G4Scintillation::BuildPhysicsTable(), G4OpWLS::BuildPhysicsTable(), G4OpWLS2::BuildPhysicsTable(), G4LossTableBuilder::BuildRangeTable(), G4PenelopeBremsstrahlungFS::BuildScaledXSTable(), G4LossTableBuilder::BuildTableForModel(), G4JAEAElasticScatteringModel::ComputeCrossSectionPerAtom(), G4JAEAPolarizedElasticScatteringModel::ComputeCrossSectionPerAtom(), G4LivermoreComptonModel::ComputeCrossSectionPerAtom(), G4LivermorePolarizedComptonModel::ComputeCrossSectionPerAtom(), G4LivermorePolarizedRayleighModel::ComputeCrossSectionPerAtom(), G4LivermoreRayleighModel::ComputeCrossSectionPerAtom(), G4LowEPComptonModel::ComputeCrossSectionPerAtom(), G4LowEPPolarizedComptonModel::ComputeCrossSectionPerAtom(), G4PenelopeRayleighModelMI::CrossSectionPerVolume(), G4PAIModelData::CrossSectionPerVolume(), G4PAIPhotData::CrossSectionPerVolume(), G4PAIModelData::DEDXPerVolume(), G4PAIPhotData::DEDXPerVolume(), G4EmModelManager::DumpModelList(), G4EmModelManager::FillDEDXVector(), G4EmModelManager::FillLambdaVector(), G4HadElementSelector::G4HadElementSelector(), G4LivermorePhotoElectricModel::GetBindingEnergy(), G4PAIPhotData::GetPlasmonRatio(), G4PAIPhotData::Initialise(), G4PAIModelData::Initialise(), G4eeToHadronsModel::Initialise(), G4eplusTo2GammaOKVIModel::Initialise(), G4WentzelVIModel::Initialise(), G4DNABornExcitationModel2::Initialise(), G4HadronXSDataTable::Initialise(), G4NeutronCaptureXS::IsoCrossSection(), G4GDMLWriteMaterials::PropertyVectorWrite(), G4PAIPhotData::SampleAlongStepPhotonTransfer(), G4PAIPhotData::SampleAlongStepPlasmonTransfer(), G4PAIPhotData::SampleAlongStepTransfer(), G4PAIModelData::SampleAlongStepTransfer(), G4PAIPhotData::SamplePostStepPhotonTransfer(), G4PAIPhotData::SamplePostStepPlasmonTransfer(), G4PAIPhotData::SamplePostStepTransfer(), G4PAIModelData::SamplePostStepTransfer(), G4DiffuseElasticV2::SampleTableThetaCMS(), and G4VEnergyLossProcess::SetLambdaTable().

◆ FillSecondDerivatives()

void G4PhysicsVector::FillSecondDerivatives ( )

Definition at line 361 of file G4PhysicsVector.cc.

362{
363 // Computation of second derivatives using "Not-a-knot" endpoint conditions
364 // B.I. Kvasov "Methods of shape-preserving spline approximation"
365 // World Scientific, 2000
366
367 if(5 > numberOfNodes) // cannot compute derivatives for less than 4 points
368 {
370 return;
371 }
372
373 if(!SplinePossible())
374 {
375 return;
376 }
377
378 useSpline = true;
379
380 G4int n = numberOfNodes - 1;
381
382 G4double* u = new G4double[n];
383
384 G4double p, sig;
385
386 u[1] = ((dataVector[2] - dataVector[1]) / (binVector[2] - binVector[1]) -
387 (dataVector[1] - dataVector[0]) / (binVector[1] - binVector[0]));
388 u[1] = 6.0 * u[1] * (binVector[2] - binVector[1]) /
389 ((binVector[2] - binVector[0]) * (binVector[2] - binVector[0]));
390
391 // Decomposition loop for tridiagonal algorithm. secDerivative[i]
392 // and u[i] are used for temporary storage of the decomposed factors.
393
394 secDerivative[1] = (2.0 * binVector[1] - binVector[0] - binVector[2]) /
395 (2.0 * binVector[2] - binVector[0] - binVector[1]);
396
397 for(G4int i = 2; i < n - 1; ++i)
398 {
399 sig =
400 (binVector[i] - binVector[i - 1]) / (binVector[i + 1] - binVector[i - 1]);
401 p = sig * secDerivative[i - 1] + 2.0;
402 secDerivative[i] = (sig - 1.0) / p;
403 u[i] =
404 (dataVector[i + 1] - dataVector[i]) / (binVector[i + 1] - binVector[i]) -
405 (dataVector[i] - dataVector[i - 1]) / (binVector[i] - binVector[i - 1]);
406 u[i] =
407 (6.0 * u[i] / (binVector[i + 1] - binVector[i - 1])) - sig * u[i - 1] / p;
408 }
409
410 sig =
411 (binVector[n - 1] - binVector[n - 2]) / (binVector[n] - binVector[n - 2]);
412 p = sig * secDerivative[n - 3] + 2.0;
413 u[n - 1] =
414 (dataVector[n] - dataVector[n - 1]) / (binVector[n] - binVector[n - 1]) -
415 (dataVector[n - 1] - dataVector[n - 2]) /
416 (binVector[n - 1] - binVector[n - 2]);
417 u[n - 1] = 6.0 * sig * u[n - 1] / (binVector[n] - binVector[n - 2]) -
418 (2.0 * sig - 1.0) * u[n - 2] / p;
419
420 p = (1.0 + sig) + (2.0 * sig - 1.0) * secDerivative[n - 2];
421 secDerivative[n - 1] = u[n - 1] / p;
422
423 // The back-substitution loop for the triagonal algorithm of solving
424 // a linear system of equations.
425
426 for(G4int k = n - 2; k > 1; --k)
427 {
428 secDerivative[k] *=
429 (secDerivative[k + 1] - u[k] * (binVector[k + 1] - binVector[k - 1]) /
430 (binVector[k + 1] - binVector[k]));
431 }
433 (secDerivative[n - 1] - (1.0 - sig) * secDerivative[n - 2]) / sig;
434 sig = 1.0 - ((binVector[2] - binVector[1]) / (binVector[2] - binVector[0]));
435 secDerivative[1] *= (secDerivative[2] - u[1] / (1.0 - sig));
436 secDerivative[0] = (secDerivative[1] - sig * secDerivative[2]) / (1.0 - sig);
437
438 delete[] u;
439}

Referenced by G4VEnergyLossProcess::BuildDEDXTable(), G4LossTableBuilder::BuildDEDXTable(), G4LossTableBuilder::BuildInverseRangeTable(), G4VEnergyLossProcess::BuildLambdaTable(), G4LossTableBuilder::BuildRangeTable(), G4LossTableBuilder::BuildTableForModel(), and G4WentzelVIModel::Initialise().

◆ FindBin()

◆ FindLinearEnergy()

G4double G4PhysicsVector::FindLinearEnergy ( G4double  rand) const

Definition at line 542 of file G4PhysicsVector.cc.

543{
544 if(1 >= numberOfNodes)
545 {
546 return 0.0;
547 }
548 G4double y = rand * dataVector[numberOfNodes - 1];
549 std::size_t bin = std::lower_bound(dataVector.begin(), dataVector.end(), y) -
550 dataVector.begin() - 1;
551 bin = std::min(bin, numberOfNodes - 2);
552 G4double res = binVector[bin];
553 G4double del = dataVector[bin + 1] - dataVector[bin];
554 if(del > 0.0)
555 {
556 res += (y - dataVector[bin]) * (binVector[bin + 1] - res) / del;
557 }
558 return res;
559}

Referenced by G4AdjointPrimaryGenerator::SampleDistanceAlongBackRayAndComputeWeightCorrection().

◆ GetLowEdgeEnergy()

G4double G4PhysicsVector::GetLowEdgeEnergy ( std::size_t  binNumber) const

Definition at line 136 of file G4PhysicsVector.cc.

137{
138 return binVector[binNumber];
139}

Referenced by G4EMDissociation::ApplyYourself(), G4VXTRenergyLoss::BuildAngleForEnergyBank(), G4VXTRenergyLoss::BuildAngleTable(), G4DiffuseElastic::BuildAngleTable(), G4NuclNuclDiffuseElastic::BuildAngleTable(), G4hRDEnergyLoss::BuildDEDXTable(), G4VXTRenergyLoss::BuildEnergyTable(), G4VXTRenergyLoss::BuildGlobalAngleTable(), G4VLEPTSModel::BuildMeanFreePathTable(), G4VRangeToEnergyConverter::BuildRangeVector(), G4hhElastic::BuildTableT(), G4AdjointCSManager::BuildTotalSigmaTables(), G4ForwardXrayTR::BuildXrayTRtables(), G4PenelopeIonisationXSHandler::BuildXSTable(), G4VRangeToEnergyConverter::ConvertCutToKineticEnergy(), G4PenelopeRayleighModel::DumpFormFactorTable(), G4PenelopeRayleighModelMI::DumpFormFactorTable(), G4SPSRandomGenerator::GenRandEnergy(), G4SPSRandomGenerator::GenRandPhi(), G4SPSRandomGenerator::GenRandPosPhi(), G4SPSRandomGenerator::GenRandPosTheta(), G4SPSRandomGenerator::GenRandTheta(), G4SPSRandomGenerator::GenRandX(), G4SPSRandomGenerator::GenRandY(), G4SPSRandomGenerator::GenRandZ(), G4ForwardXrayTR::GetEnergyTR(), G4VXTRenergyLoss::GetMeanFreePath(), G4VXTRenergyLoss::GetXTRrandomEnergy(), G4NeutronElectronElXsc::Initialise(), G4NeutronElectronElModel::Initialise(), G4InitXscPAI::IntegralCherenkov(), G4InitXscPAI::IntegralPAIdEdx(), G4InitXscPAI::IntegralPAIxSection(), G4InitXscPAI::IntegralPlasmon(), G4PenelopeCrossSection::NormalizeShellCrossSections(), G4ForwardXrayTR::PostStepDoIt(), G4XNNElasticLowE::Print(), G4XnpElasticLowE::Print(), G4XnpTotalLowE::Print(), G4DiffuseElastic::SampleTableThetaCMS(), and G4NuclNuclDiffuseElastic::SampleTableThetaCMS().

◆ GetMaxEnergy()

◆ GetType()

G4PhysicsVectorType G4PhysicsVector::GetType ( ) const
inline

◆ GetValue()

◆ GetVectorLength()

std::size_t G4PhysicsVector::GetVectorLength ( ) const
inline

Referenced by G4LossTableBuilder::BuildDEDXTable(), G4LossTableBuilder::BuildInverseRangeTable(), G4Cerenkov::BuildPhysicsTable(), G4Scintillation::BuildPhysicsTable(), G4OpWLS::BuildPhysicsTable(), G4OpWLS2::BuildPhysicsTable(), G4LossTableBuilder::BuildRangeTable(), G4AdjointCSManager::BuildTotalSigmaTables(), G4PenelopeIonisationXSHandler::BuildXSTable(), G4JAEAElasticScatteringModel::ComputeCrossSectionPerAtom(), G4JAEAPolarizedElasticScatteringModel::ComputeCrossSectionPerAtom(), G4LivermoreComptonModel::ComputeCrossSectionPerAtom(), G4LivermoreGammaConversionModelRC::ComputeCrossSectionPerAtom(), G4LivermoreNuclearGammaConversionModel::ComputeCrossSectionPerAtom(), G4LivermorePolarizedComptonModel::ComputeCrossSectionPerAtom(), G4LivermorePolarizedGammaConversionModel::ComputeCrossSectionPerAtom(), G4LivermorePolarizedRayleighModel::ComputeCrossSectionPerAtom(), G4LivermoreRayleighModel::ComputeCrossSectionPerAtom(), G4LowEPComptonModel::ComputeCrossSectionPerAtom(), G4LowEPPolarizedComptonModel::ComputeCrossSectionPerAtom(), G4PAIModelData::CrossSectionPerVolume(), G4PAIPhotData::CrossSectionPerVolume(), G4PAIModelData::DEDXPerVolume(), G4PAIPhotData::DEDXPerVolume(), G4PenelopeRayleighModel::DumpFormFactorTable(), G4PenelopeRayleighModelMI::DumpFormFactorTable(), G4EmModelManager::DumpModelList(), G4EmModelManager::FillDEDXVector(), G4EmModelManager::FillLambdaVector(), G4SPSRandomGenerator::GenRandEnergy(), G4SPSRandomGenerator::GenRandPhi(), G4SPSRandomGenerator::GenRandPosPhi(), G4SPSRandomGenerator::GenRandPosTheta(), G4SPSRandomGenerator::GenRandTheta(), G4SPSRandomGenerator::GenRandX(), G4SPSRandomGenerator::GenRandY(), G4SPSRandomGenerator::GenRandZ(), G4SPSEneDistribution::GetArbEneWeight(), G4PenelopeCrossSection::GetHardCrossSection(), G4PenelopeCrossSection::GetNormalizedShellCrossSection(), G4PAIPhotData::GetPlasmonRatio(), G4PenelopeCrossSection::GetShellCrossSection(), G4PenelopeCrossSection::GetSoftStoppingPower(), G4PenelopeCrossSection::GetTotalCrossSection(), G4eeToHadronsModel::Initialise(), G4GDMLWriteMaterials::PropertyVectorWrite(), G4PAIPhotData::SampleAlongStepPhotonTransfer(), G4PAIPhotData::SampleAlongStepPlasmonTransfer(), G4PAIPhotData::SampleAlongStepTransfer(), G4PAIModelData::SampleAlongStepTransfer(), G4PAIPhotData::SamplePostStepPhotonTransfer(), G4PAIPhotData::SamplePostStepPlasmonTransfer(), G4PAIPhotData::SamplePostStepTransfer(), G4PAIModelData::SamplePostStepTransfer(), and G4VEnergyLossProcess::SetLambdaTable().

◆ IsFilledVectorExist()

G4bool G4PhysicsVector::IsFilledVectorExist ( ) const
inline

◆ LogVectorValue()

◆ operator!=()

G4bool G4PhysicsVector::operator!= ( const G4PhysicsVector right) const

Definition at line 90 of file G4PhysicsVector.cc.

91{
92 return (this != &right);
93}

◆ operator()()

G4double G4PhysicsVector::operator() ( const std::size_t  index) const
inline

◆ operator=()

G4PhysicsVector & G4PhysicsVector::operator= ( const G4PhysicsVector right)

Definition at line 66 of file G4PhysicsVector.cc.

67{
68 if(&right == this)
69 {
70 return *this;
71 }
72 invdBin = right.invdBin;
73 baseBin = right.baseBin;
75
76 DeleteData();
77 CopyData(right);
78 return *this;
79}

◆ operator==()

G4bool G4PhysicsVector::operator== ( const G4PhysicsVector right) const

Definition at line 83 of file G4PhysicsVector.cc.

84{
85 return (this == &right);
86}

◆ operator[]()

G4double G4PhysicsVector::operator[] ( const std::size_t  index) const
inline

◆ PrintPutValueError()

void G4PhysicsVector::PrintPutValueError ( std::size_t  index)
protected

Definition at line 563 of file G4PhysicsVector.cc.

564{
566 ed << "Vector type " << type << " length= " << numberOfNodes
567 << " an attempt to put data at index= " << index;
568 G4Exception("G4PhysicsVector::PutValue()", "gl0005", FatalException, ed,
569 "Memory overwritten");
570}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40

Referenced by G4PhysicsFreeVector::PutValue().

◆ PutValue()

void G4PhysicsVector::PutValue ( std::size_t  index,
G4double  theValue 
)
inline

◆ Retrieve()

G4bool G4PhysicsVector::Retrieve ( std::ifstream &  fIn,
G4bool  ascii = false 
)
virtual

Reimplemented in G4PhysicsLinearVector, and G4PhysicsLogVector.

Definition at line 176 of file G4PhysicsVector.cc.

177{
178 // clear properties;
179 dataVector.clear();
180 binVector.clear();
181 secDerivative.clear();
182
183 // retrieve in ascii mode
184 if(ascii)
185 {
186 // binning
187 fIn >> edgeMin >> edgeMax >> numberOfNodes;
188 if(fIn.fail() || numberOfNodes < 2)
189 {
190 return false;
191 }
192 // contents
193 G4int siz = 0;
194 fIn >> siz;
195 if(fIn.fail() || siz != G4int(numberOfNodes))
196 {
197 return false;
198 }
199
200 binVector.reserve(siz);
201 dataVector.reserve(siz);
202 G4double vBin, vData;
203
204 for(G4int i = 0; i < siz; ++i)
205 {
206 vBin = 0.;
207 vData = 0.;
208 fIn >> vBin >> vData;
209 if(fIn.fail())
210 {
211 return false;
212 }
213 binVector.push_back(vBin);
214 dataVector.push_back(vData);
215 }
216
217 // to remove any inconsistency
218 numberOfNodes = siz;
219 edgeMin = binVector[0];
221 return true;
222 }
223
224 // retrieve in binary mode
225 // binning
226 fIn.read((char*) (&edgeMin), sizeof edgeMin);
227 fIn.read((char*) (&edgeMax), sizeof edgeMax);
228 fIn.read((char*) (&numberOfNodes), sizeof numberOfNodes);
229
230 // contents
231 std::size_t size;
232 fIn.read((char*) (&size), sizeof size);
233
234 G4double* value = new G4double[2 * size];
235 fIn.read((char*) (value), 2 * size * (sizeof(G4double)));
236 if(G4int(fIn.gcount()) != G4int(2 * size * (sizeof(G4double))))
237 {
238 delete[] value;
239 return false;
240 }
241
242 binVector.reserve(size);
243 dataVector.reserve(size);
244 for(std::size_t i = 0; i < size; ++i)
245 {
246 binVector.push_back(value[2 * i]);
247 dataVector.push_back(value[2 * i + 1]);
248 }
249 delete[] value;
250
251 // to remove any inconsistency
252 numberOfNodes = size;
253 edgeMin = binVector[0];
255
256 return true;
257}

Referenced by G4PhysicsLinearVector::Retrieve(), G4PhysicsLogVector::Retrieve(), and G4PhysicsTable::RetrievePhysicsTable().

◆ ScaleVector()

void G4PhysicsVector::ScaleVector ( G4double  factorE,
G4double  factorV 
)
virtual

Reimplemented in G4PhysicsLinearVector, and G4PhysicsLogVector.

Definition at line 271 of file G4PhysicsVector.cc.

272{
273 std::size_t n = dataVector.size();
274 std::size_t i;
275 for(i = 0; i < n; ++i)
276 {
277 binVector[i] *= factorE;
278 dataVector[i] *= factorV;
279 }
280 secDerivative.clear();
281
282 edgeMin = binVector[0];
283 edgeMax = binVector[n - 1];
284}

Referenced by G4PhysicsLinearVector::ScaleVector(), and G4PhysicsLogVector::ScaleVector().

◆ SetSpline()

◆ SetVerboseLevel()

void G4PhysicsVector::SetVerboseLevel ( G4int  value)
inline

◆ Store()

G4bool G4PhysicsVector::Store ( std::ofstream &  fOut,
G4bool  ascii = false 
) const

Definition at line 143 of file G4PhysicsVector.cc.

144{
145 // Ascii mode
146 if(ascii)
147 {
148 fOut << *this;
149 return true;
150 }
151 // Binary Mode
152
153 // binning
154 fOut.write((char*) (&edgeMin), sizeof edgeMin);
155 fOut.write((char*) (&edgeMax), sizeof edgeMax);
156 fOut.write((char*) (&numberOfNodes), sizeof numberOfNodes);
157
158 // contents
159 std::size_t size = dataVector.size();
160 fOut.write((char*) (&size), sizeof size);
161
162 G4double* value = new G4double[2 * size];
163 for(std::size_t i = 0; i < size; ++i)
164 {
165 value[2 * i] = binVector[i];
166 value[2 * i + 1] = dataVector[i];
167 }
168 fOut.write((char*) (value), 2 * size * (sizeof(G4double)));
169 delete[] value;
170
171 return true;
172}

◆ Value() [1/2]

G4double G4PhysicsVector::Value ( G4double  theEnergy) const
inline

◆ Value() [2/2]

G4double G4PhysicsVector::Value ( G4double  theEnergy,
std::size_t &  lastidx 
) const

Definition at line 519 of file G4PhysicsVector.cc.

520{
521 G4double y;
522 if(theEnergy <= edgeMin)
523 {
524 lastIdx = 0;
525 y = dataVector[0];
526 }
527 else if(theEnergy >= edgeMax)
528 {
529 lastIdx = numberOfNodes - 1;
530 y = dataVector[lastIdx];
531 }
532 else
533 {
534 lastIdx = FindBin(theEnergy, lastIdx);
535 y = Interpolation(lastIdx, theEnergy);
536 }
537 return y;
538}
std::size_t FindBin(const G4double energy, const std::size_t idx) const

Referenced by G4EmCorrections::BarkasCorrection(), G4LossTableBuilder::BuildRangeTable(), G4Track::CalculateVelocityForOpticalPhoton(), G4JAEAElasticScatteringModel::ComputeCrossSectionPerAtom(), G4JAEAPolarizedElasticScatteringModel::ComputeCrossSectionPerAtom(), G4LivermoreComptonModel::ComputeCrossSectionPerAtom(), G4LivermoreGammaConversionModelRC::ComputeCrossSectionPerAtom(), G4LivermoreNuclearGammaConversionModel::ComputeCrossSectionPerAtom(), G4LivermorePolarizedComptonModel::ComputeCrossSectionPerAtom(), G4LivermorePolarizedGammaConversionModel::ComputeCrossSectionPerAtom(), G4LivermorePolarizedRayleighModel::ComputeCrossSectionPerAtom(), G4LivermoreRayleighModel::ComputeCrossSectionPerAtom(), G4LowEPComptonModel::ComputeCrossSectionPerAtom(), G4LowEPPolarizedComptonModel::ComputeCrossSectionPerAtom(), G4PenelopeGammaConversionModel::ComputeCrossSectionPerAtom(), G4PenelopePhotoElectricModel::ComputeCrossSectionPerAtom(), G4PenelopeRayleighModel::ComputeCrossSectionPerAtom(), G4PenelopeRayleighModelMI::ComputeCrossSectionPerAtom(), G4BoldyshevTripletModel::ComputeCrossSectionPerAtom(), G4eplusTo2GammaOKVIModel::ComputeCrossSectionPerAtom(), G4LivermoreGammaConversion5DModel::ComputeCrossSectionPerAtom(), G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom(), G4eeToHadronsModel::ComputeCrossSectionPerElectron(), G4VRangeToEnergyConverter::ConvertCutToKineticEnergy(), G4eplusTo2GammaOKVIModel::CrossSectionPerVolume(), G4DNABornExcitationModel2::CrossSectionPerVolume(), G4EmCorrections::EffectiveChargeCorrection(), G4eeToHadronsModel::GenerateCMPhoton(), G4Cerenkov::GetAverageNumberOfPhotons(), G4ChannelingMaterialData::GetBR(), G4FastPathHadronicCrossSection::fastPathEntry::GetCrossSection(), G4PenelopeIonisationXSHandler::GetDensityCorrection(), G4ChannelingECHARM::GetEC(), G4NeutronElectronElXsc::GetElementCrossSection(), G4KokoulinMuonNuclearXS::GetElementCrossSection(), G4PenelopeCrossSection::GetHardCrossSection(), G4OpAbsorption::GetMeanFreePath(), G4OpMieHG::GetMeanFreePath(), G4OpRayleigh::GetMeanFreePath(), G4OpWLS::GetMeanFreePath(), G4OpWLS2::GetMeanFreePath(), G4PenelopeCrossSection::GetNormalizedShellCrossSection(), G4SPSEneDistribution::GetProbability(), G4Scintillation::GetScintillationYieldByParticleType(), G4PenelopePhotoElectricModel::GetShellCrossSection(), G4PenelopeCrossSection::GetShellCrossSection(), G4PenelopeCrossSection::GetSoftStoppingPower(), G4PenelopeCrossSection::GetTotalCrossSection(), G4ElementData::GetValueForElement(), G4NeutronElectronElXsc::Initialise(), G4PAIPhotData::Initialise(), G4eeToHadronsModel::Initialise(), G4EmCorrections::KShellCorrection(), G4EmCorrections::LShellCorrection(), G4Cerenkov::PostStepDoIt(), G4OpBoundaryProcess::PostStepDoIt(), G4PenelopeBremsstrahlungAngular::PrepareTables(), G4PAIModelData::SampleAlongStepTransfer(), G4PenelopeBremsstrahlungAngular::SampleDirection(), G4PAIModelData::SamplePostStepTransfer(), G4PenelopeRayleighModel::SampleSecondaries(), G4PenelopeRayleighModelMI::SampleSecondaries(), G4eplusTo2GammaOKVIModel::SampleSecondaries(), G4VEnergyLossProcess::SetCSDARangeTable(), G4VEnergyLossProcess::SetDEDXTable(), and G4EmCorrections::ShellCorrection().

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const G4PhysicsVector pv 
)
friend

Definition at line 499 of file G4PhysicsVector.cc.

500{
501 // binning
502 G4int prec = out.precision();
503 out << std::setprecision(12) << pv.edgeMin << " " << pv.edgeMax << " "
504 << pv.numberOfNodes << G4endl;
505
506 // contents
507 out << pv.dataVector.size() << G4endl;
508 for(std::size_t i = 0; i < pv.dataVector.size(); ++i)
509 {
510 out << pv.binVector[i] << " " << pv.dataVector[i] << G4endl;
511 }
512 out << std::setprecision(prec);
513
514 return out;
515}

Member Data Documentation

◆ baseBin

◆ binVector

◆ dataVector

◆ edgeMax

◆ edgeMin

◆ invdBin

◆ numberOfNodes

◆ secDerivative

G4PVDataVector G4PhysicsVector::secDerivative
protected

◆ type

◆ verboseLevel

G4int G4PhysicsVector::verboseLevel = 0
protected

Definition at line 208 of file G4PhysicsVector.hh.

Referenced by G4PhysicsVector(), and operator=().


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