Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
G4PhysicsVector Class Reference

#include <G4PhysicsVector.hh>

Inheritance diagram for G4PhysicsVector:
G4LPhysicsFreeVector G4PhysicsFreeVector G4PhysicsLinearVector G4PhysicsLnVector G4PhysicsLogVector G4PhysicsOrderedFreeVector

Public Member Functions

 G4PhysicsVector (G4bool spline=false)
 
 G4PhysicsVector (const G4PhysicsVector &)
 
G4PhysicsVectoroperator= (const G4PhysicsVector &)
 
virtual ~G4PhysicsVector ()
 
voidoperator new (size_t)
 
void operator delete (void *)
 
G4double Value (G4double theEnergy, size_t &lastidx) const
 
G4double Value (G4double theEnergy) const
 
G4double GetValue (G4double theEnergy, G4bool &isOutRange) const
 
G4int operator== (const G4PhysicsVector &right) const
 
G4int operator!= (const G4PhysicsVector &right) const
 
G4double operator[] (const size_t binNumber) const
 
G4double operator() (const size_t binNumber) const
 
void PutValue (size_t index, G4double theValue)
 
virtual void ScaleVector (G4double factorE, G4double factorV)
 
G4double Energy (size_t index) const
 
G4double GetMaxEnergy () const
 
G4double GetLowEdgeEnergy (size_t binNumber) const
 
size_t GetVectorLength () const
 
size_t FindBin (G4double energy, size_t idx) 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)
 
virtual G4bool Store (std::ofstream &fOut, G4bool ascii=false)
 
virtual G4bool Retrieve (std::ifstream &fIn, G4bool ascii=false)
 
void SetVerboseLevel (G4int value)
 
G4int GetVerboseLevel (G4int)
 

Protected Member Functions

void DeleteData ()
 
void CopyData (const G4PhysicsVector &vec)
 

Protected Attributes

G4PhysicsVectorType type
 
G4double edgeMin
 
G4double edgeMax
 
size_t numberOfNodes
 
G4PVDataVector dataVector
 
G4PVDataVector binVector
 
G4PVDataVector secDerivative
 
G4double dBin
 
G4double baseBin
 
G4int verboseLevel
 

Friends

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

Detailed Description

Definition at line 77 of file G4PhysicsVector.hh.

Constructor & Destructor Documentation

G4PhysicsVector::G4PhysicsVector ( G4bool  spline = false)

Definition at line 63 of file G4PhysicsVector.cc.

References fpPVAllocator.

65  edgeMin(0.), edgeMax(0.), numberOfNodes(0),
66  useSpline(false),
67  dBin(0.), baseBin(0.),
68  verboseLevel(0)
69 {
71  // g4pow = G4Pow::GetInstance();
72 }
G4ThreadLocal G4Allocator< G4PhysicsVector > * fpPVAllocator
G4PhysicsVectorType type
G4PhysicsVector::G4PhysicsVector ( const G4PhysicsVector right)

Definition at line 82 of file G4PhysicsVector.cc.

References baseBin, CopyData(), dBin, DeleteData(), and verboseLevel.

83 {
84  // g4pow = G4Pow::GetInstance();
85 
86  dBin = right.dBin;
87  baseBin = right.baseBin;
88  verboseLevel = right.verboseLevel;
89 
90  DeleteData();
91  CopyData(right);
92 }
void CopyData(const G4PhysicsVector &vec)
G4PhysicsVector::~G4PhysicsVector ( )
virtual

Definition at line 76 of file G4PhysicsVector.cc.

77 {
78 }

Member Function Documentation

void G4PhysicsVector::ComputeSecDerivatives ( )

Definition at line 439 of file G4PhysicsVector.cc.

References binVector, dataVector, n, numberOfNodes, and secDerivative.

Referenced by ComputeSecondDerivatives(), and FillSecondDerivatives().

441 {
442  if(3 > numberOfNodes) // cannot compute derivatives for less than 4 bins
443  {
444  useSpline = false;
445  return;
446  }
447 
448  if(!SplinePossible()) { return; }
449 
450  useSpline = true;
451 
452  size_t n = numberOfNodes-1;
453 
454  for(size_t i=1; i<n; ++i)
455  {
456  secDerivative[i] =
457  3.0*((dataVector[i+1]-dataVector[i])/(binVector[i+1]-binVector[i]) -
458  (dataVector[i]-dataVector[i-1])/(binVector[i]-binVector[i-1]))
459  /(binVector[i+1]-binVector[i-1]);
460  }
461  secDerivative[n] = secDerivative[n-1];
463 }
G4PVDataVector dataVector
G4PVDataVector binVector
G4PVDataVector secDerivative
const G4int n
void G4PhysicsVector::ComputeSecondDerivatives ( G4double  firstPointDerivative,
G4double  endPointDerivative 
)

Definition at line 302 of file G4PhysicsVector.cc.

References binVector, ComputeSecDerivatives(), dataVector, n, numberOfNodes, and secDerivative.

308 {
309  if(4 > numberOfNodes) // cannot compute derivatives for less than 4 bins
310  {
312  return;
313  }
314 
315  if(!SplinePossible()) { return; }
316 
317  useSpline = true;
318 
319  G4int n = numberOfNodes-1;
320 
321  G4double* u = new G4double [n];
322 
323  G4double p, sig, un;
324 
325  u[0] = (6.0/(binVector[1]-binVector[0]))
326  * ((dataVector[1]-dataVector[0])/(binVector[1]-binVector[0])
327  - firstPointDerivative);
328 
329  secDerivative[0] = - 0.5;
330 
331  // Decomposition loop for tridiagonal algorithm. secDerivative[i]
332  // and u[i] are used for temporary storage of the decomposed factors.
333 
334  for(G4int i=1; i<n; ++i)
335  {
336  sig = (binVector[i]-binVector[i-1]) / (binVector[i+1]-binVector[i-1]);
337  p = sig*(secDerivative[i-1]) + 2.0;
338  secDerivative[i] = (sig - 1.0)/p;
339  u[i] = (dataVector[i+1]-dataVector[i])/(binVector[i+1]-binVector[i])
340  - (dataVector[i]-dataVector[i-1])/(binVector[i]-binVector[i-1]);
341  u[i] = 6.0*u[i]/(binVector[i+1]-binVector[i-1]) - sig*u[i-1]/p;
342  }
343 
344  sig = (binVector[n-1]-binVector[n-2]) / (binVector[n]-binVector[n-2]);
345  p = sig*secDerivative[n-2] + 2.0;
346  un = (6.0/(binVector[n]-binVector[n-1]))
347  *(endPointDerivative -
348  (dataVector[n]-dataVector[n-1])/(binVector[n]-binVector[n-1])) - u[n-1]/p;
349  secDerivative[n] = un/(secDerivative[n-1] + 2.0);
350 
351  // The back-substitution loop for the triagonal algorithm of solving
352  // a linear system of equations.
353 
354  for(G4int k=n-1; k>0; --k)
355  {
356  secDerivative[k] *=
357  (secDerivative[k+1] -
358  u[k]*(binVector[k+1]-binVector[k-1])/(binVector[k+1]-binVector[k]));
359  }
360  secDerivative[0] = 0.5*(u[0] - secDerivative[1]);
361 
362  delete [] u;
363 }
G4PVDataVector dataVector
const char * p
Definition: xmltok.h:285
int G4int
Definition: G4Types.hh:78
G4PVDataVector binVector
G4PVDataVector secDerivative
const G4int n
double G4double
Definition: G4Types.hh:76
void ComputeSecDerivatives()
void G4PhysicsVector::CopyData ( const G4PhysicsVector vec)
protected

Definition at line 132 of file G4PhysicsVector.cc.

References binVector, dataVector, edgeMax, edgeMin, numberOfNodes, secDerivative, and type.

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

133 {
134  type = vec.type;
135  edgeMin = vec.edgeMin;
136  edgeMax = vec.edgeMax;
138  useSpline = vec.useSpline;
139 
140  size_t i;
141  dataVector.clear();
142  for(i=0; i<(vec.dataVector).size(); i++){
143  dataVector.push_back( (vec.dataVector)[i] );
144  }
145  binVector.clear();
146  for(i=0; i<(vec.binVector).size(); i++){
147  binVector.push_back( (vec.binVector)[i] );
148  }
149  secDerivative.clear();
150  for(i=0; i<(vec.secDerivative).size(); i++){
151  secDerivative.push_back( (vec.secDerivative)[i] );
152  }
153 }
G4PVDataVector dataVector
G4PVDataVector binVector
G4PhysicsVectorType type
G4PVDataVector secDerivative
void G4PhysicsVector::DeleteData ( )
protected

Definition at line 124 of file G4PhysicsVector.cc.

References secDerivative.

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

125 {
126  useSpline = false;
127  secDerivative.clear();
128 }
G4PVDataVector secDerivative
G4double G4PhysicsVector::Energy ( size_t  index) const
inline
void G4PhysicsVector::FillSecondDerivatives ( )

Definition at line 367 of file G4PhysicsVector.cc.

References binVector, ComputeSecDerivatives(), dataVector, n, numberOfNodes, and secDerivative.

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

371 {
372  if(5 > numberOfNodes) // cannot compute derivatives for less than 4 points
373  {
375  return;
376  }
377 
378  if(!SplinePossible()) { return; }
379 
380  useSpline = true;
381 
382  G4int n = numberOfNodes-1;
383 
384  G4double* u = new G4double [n];
385 
386  G4double p, sig;
387 
388  u[1] = ((dataVector[2]-dataVector[1])/(binVector[2]-binVector[1]) -
389  (dataVector[1]-dataVector[0])/(binVector[1]-binVector[0]));
390  u[1] = 6.0*u[1]*(binVector[2]-binVector[1])
391  / ((binVector[2]-binVector[0])*(binVector[2]-binVector[0]));
392 
393  // Decomposition loop for tridiagonal algorithm. secDerivative[i]
394  // and u[i] are used for temporary storage of the decomposed factors.
395 
396  secDerivative[1] = (2.0*binVector[1]-binVector[0]-binVector[2])
397  / (2.0*binVector[2]-binVector[0]-binVector[1]);
398 
399  for(G4int i=2; i<n-1; ++i)
400  {
401  sig = (binVector[i]-binVector[i-1]) / (binVector[i+1]-binVector[i-1]);
402  p = sig*secDerivative[i-1] + 2.0;
403  secDerivative[i] = (sig - 1.0)/p;
404  u[i] = (dataVector[i+1]-dataVector[i])/(binVector[i+1]-binVector[i])
405  - (dataVector[i]-dataVector[i-1])/(binVector[i]-binVector[i-1]);
406  u[i] = (6.0*u[i]/(binVector[i+1]-binVector[i-1])) - sig*u[i-1]/p;
407  }
408 
409  sig = (binVector[n-1]-binVector[n-2]) / (binVector[n]-binVector[n-2]);
410  p = sig*secDerivative[n-3] + 2.0;
411  u[n-1] = (dataVector[n]-dataVector[n-1])/(binVector[n]-binVector[n-1])
412  - (dataVector[n-1]-dataVector[n-2])/(binVector[n-1]-binVector[n-2]);
413  u[n-1] = 6.0*sig*u[n-1]/(binVector[n]-binVector[n-2])
414  - (2.0*sig - 1.0)*u[n-2]/p;
415 
416  p = (1.0+sig) + (2.0*sig-1.0)*secDerivative[n-2];
417  secDerivative[n-1] = u[n-1]/p;
418 
419  // The back-substitution loop for the triagonal algorithm of solving
420  // a linear system of equations.
421 
422  for(G4int k=n-2; k>1; --k)
423  {
424  secDerivative[k] *=
425  (secDerivative[k+1] -
426  u[k]*(binVector[k+1]-binVector[k-1])/(binVector[k+1]-binVector[k]));
427  }
428  secDerivative[n] = (secDerivative[n-1] - (1.0-sig)*secDerivative[n-2])/sig;
429  sig = 1.0 - ((binVector[2]-binVector[1])/(binVector[2]-binVector[0]));
430  secDerivative[1] *= (secDerivative[2] - u[1]/(1.0-sig));
431  secDerivative[0] = (secDerivative[1] - sig*secDerivative[2])/(1.0-sig);
432 
433  delete [] u;
434 }
G4PVDataVector dataVector
const char * p
Definition: xmltok.h:285
int G4int
Definition: G4Types.hh:78
G4PVDataVector binVector
G4PVDataVector secDerivative
const G4int n
double G4double
Definition: G4Types.hh:76
void ComputeSecDerivatives()
size_t G4PhysicsVector::FindBin ( G4double  energy,
size_t  idx 
) const
inline

Referenced by Value().

G4double G4PhysicsVector::FindLinearEnergy ( G4double  rand) const

Definition at line 529 of file G4PhysicsVector.cc.

References binVector, and dataVector.

530 {
531  if(1 >= numberOfNodes) { return 0.0; }
532  size_t n1 = 0;
533  size_t n2 = numberOfNodes/2;
534  size_t n3 = numberOfNodes - 1;
535  G4double y = rand*dataVector[n3];
536  while (n1 + 1 != n3)
537  {
538  if (y > dataVector[n2])
539  { n1 = n2; }
540  else
541  { n3 = n2; }
542  n2 = (n3 + n1 + 1)/2;
543  }
544  G4double res = binVector[n1];
545  G4double del = dataVector[n3] - dataVector[n1];
546  if(del > 0.0) {
547  res += (y - dataVector[n1])*(binVector[n3] - res)/del;
548  }
549  return res;
550 }
G4PVDataVector dataVector
G4PVDataVector binVector
double G4double
Definition: G4Types.hh:76
G4double G4PhysicsVector::GetLowEdgeEnergy ( size_t  binNumber) const

Definition at line 157 of file G4PhysicsVector.cc.

References binVector.

Referenced by G4VXTRenergyLoss::BuildAngleForEnergyBank(), G4NuclNuclDiffuseElastic::BuildAngleTable(), G4DiffuseElastic::BuildAngleTable(), G4VXTRenergyLoss::BuildAngleTable(), G4PolarizedCompton::BuildAsymmetryTable(), G4eplusPolarizedAnnihilation::BuildAsymmetryTable(), G4eLowEnergyLoss::BuildDEDXTable(), G4hRDEnergyLoss::BuildDEDXTable(), G4VXTRenergyLoss::BuildEnergyTable(), G4VXTRenergyLoss::BuildGlobalAngleTable(), G4RDVeLowEnergyLoss::BuildInverseRangeTable(), G4PAIPhotonModel::BuildPAIonisationTable(), G4VRangeToEnergyConverter::BuildRangeVector(), G4AdjointCSManager::BuildTotalSigmaTables(), G4ForwardXrayTR::BuildXrayTRtables(), G4PenelopeIonisationXSHandler::BuildXSTable(), G4VRangeToEnergyConverter::ConvertCutToKineticEnergy(), G4PenelopeRayleighModel::DumpFormFactorTable(), G4SPSRandomGenerator::GenRandEnergy(), G4SPSRandomGenerator::GenRandPhi(), G4SPSRandomGenerator::GenRandPosPhi(), G4SPSRandomGenerator::GenRandPosTheta(), G4SPSRandomGenerator::GenRandTheta(), G4SPSRandomGenerator::GenRandX(), G4SPSRandomGenerator::GenRandY(), G4SPSRandomGenerator::GenRandZ(), G4PAIPhotonModel::GetAlongStepTransfer(), G4ForwardXrayTR::GetEnergyTR(), G4VXTRenergyLoss::GetMeanFreePath(), G4PAIPhotonModel::GetPostStepTransfer(), G4VXTRenergyLoss::GetXTRrandomEnergy(), G4eeToHadronsModel::Initialise(), G4InitXscPAI::IntegralCherenkov(), G4InitXscPAI::IntegralPAIdEdx(), G4InitXscPAI::IntegralPAIxSection(), G4InitXscPAI::IntegralPlasmon(), G4PenelopeCrossSection::NormalizeShellCrossSections(), G4ForwardXrayTR::PostStepDoIt(), G4XNNElasticLowE::Print(), G4XnpTotalLowE::Print(), G4XnpElasticLowE::Print(), G4NuclNuclDiffuseElastic::SampleTableThetaCMS(), and G4DiffuseElastic::SampleTableThetaCMS().

158 {
159  return binVector[binNumber];
160 }
G4PVDataVector binVector
G4double G4PhysicsVector::GetMaxEnergy ( ) const
inline
G4PhysicsVectorType G4PhysicsVector::GetType ( ) const
inline
G4double G4PhysicsVector::GetValue ( G4double  theEnergy,
G4bool isOutRange 
) const
inline
size_t G4PhysicsVector::GetVectorLength ( ) const
inline
G4int G4PhysicsVector::GetVerboseLevel ( G4int  )
inline
G4bool G4PhysicsVector::IsFilledVectorExist ( ) const
inline
void G4PhysicsVector::operator delete ( void )
inline
void* G4PhysicsVector::operator new ( size_t  )
inline
G4int G4PhysicsVector::operator!= ( const G4PhysicsVector right) const

Definition at line 117 of file G4PhysicsVector.cc.

118 {
119  return (this != &right);
120 }
G4double G4PhysicsVector::operator() ( const size_t  binNumber) const
inline
G4PhysicsVector & G4PhysicsVector::operator= ( const G4PhysicsVector right)

Definition at line 96 of file G4PhysicsVector.cc.

References baseBin, CopyData(), dBin, DeleteData(), and verboseLevel.

97 {
98  if (&right==this) { return *this; }
99  dBin = right.dBin;
100  baseBin = right.baseBin;
101  verboseLevel = right.verboseLevel;
102 
103  DeleteData();
104  CopyData(right);
105  return *this;
106 }
void CopyData(const G4PhysicsVector &vec)
G4int G4PhysicsVector::operator== ( const G4PhysicsVector right) const

Definition at line 110 of file G4PhysicsVector.cc.

111 {
112  return (this == &right);
113 }
G4double G4PhysicsVector::operator[] ( const size_t  binNumber) const
inline
void G4PhysicsVector::PutValue ( size_t  index,
G4double  theValue 
)
inline

Referenced by G4RToEConvForGamma::BuildAbsorptionLengthVector(), G4VXTRenergyLoss::BuildAngleForEnergyBank(), G4PolarizedCompton::BuildAsymmetryTable(), G4eplusPolarizedAnnihilation::BuildAsymmetryTable(), G4KokoulinMuonNuclearXS::BuildCrossSectionTable(), G4LossTableBuilder::BuildDEDXTable(), G4eLowEnergyLoss::BuildDEDXTable(), G4hRDEnergyLoss::BuildDEDXTable(), G4VXTRenergyLoss::BuildEnergyTable(), G4VXTRenergyLoss::BuildGlobalAngleTable(), G4RDVeLowEnergyLoss::BuildInverseRangeTable(), G4PAIPhotonModel::BuildLambdaVector(), G4VRangeToEnergyConverter::BuildLossTable(), G4PAIPhotonModel::BuildPAIonisationTable(), G4ChargeExchangeProcess::BuildPhysicsTable(), G4ePolarizedIonisation::BuildPhysicsTable(), G4RDVeLowEnergyLoss::BuildRangeCoeffATable(), G4RDVeLowEnergyLoss::BuildRangeCoeffBTable(), G4RDVeLowEnergyLoss::BuildRangeCoeffCTable(), G4LossTableBuilder::BuildRangeTable(), G4VRangeToEnergyConverter::BuildRangeVector(), G4LossTableBuilder::BuildTableForModel(), G4AdjointCSManager::BuildTotalSigmaTables(), G4ForwardXrayTR::BuildXrayTRtables(), G4EmModelManager::FillDEDXVector(), G4EmModelManager::FillLambdaVector(), G4XNNElasticLowE::G4XNNElasticLowE(), G4XnpElasticLowE::G4XnpElasticLowE(), G4XnpTotalLowE::G4XnpTotalLowE(), G4eeToHadronsModel::Initialise(), G4PAIPhotData::Initialise(), G4PAIModelData::Initialise(), G4InitXscPAI::IntegralCherenkov(), G4InitXscPAI::IntegralPAIdEdx(), G4InitXscPAI::IntegralPAIxSection(), G4InitXscPAI::IntegralPlasmon(), and G4VRangeToEnergyConverter::operator=().

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

Reimplemented in G4PhysicsLogVector, G4PhysicsLinearVector, and G4PhysicsLnVector.

Definition at line 197 of file G4PhysicsVector.cc.

References binVector, dataVector, edgeMax, edgeMin, G4cerr, G4endl, numberOfNodes, and secDerivative.

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

198 {
199  // clear properties;
200  dataVector.clear();
201  binVector.clear();
202  secDerivative.clear();
203 
204  // retrieve in ascii mode
205  if (ascii){
206  // binning
207  fIn >> edgeMin >> edgeMax >> numberOfNodes;
208  if (fIn.fail()) { return false; }
209  // contents
210  G4int siz=0;
211  fIn >> siz;
212  if (fIn.fail()) { return false; }
213  if (siz<=0)
214  {
215 #ifdef G4VERBOSE
216  G4cerr << "G4PhysicsVector::Retrieve():";
217  G4cerr << " Invalid vector size: " << siz << G4endl;
218 #endif
219  return false;
220  }
221 
222  binVector.reserve(siz);
223  dataVector.reserve(siz);
224  G4double vBin, vData;
225 
226  for(G4int i = 0; i < siz ; i++)
227  {
228  vBin = 0.;
229  vData= 0.;
230  fIn >> vBin >> vData;
231  if (fIn.fail()) { return false; }
232  binVector.push_back(vBin);
233  dataVector.push_back(vData);
234  }
235 
236  // to remove any inconsistency
237  numberOfNodes = siz;
238  edgeMin = binVector[0];
239  edgeMax = binVector[numberOfNodes-1];
240  return true ;
241  }
242 
243  // retrieve in binary mode
244  // binning
245  fIn.read((char*)(&edgeMin), sizeof edgeMin);
246  fIn.read((char*)(&edgeMax), sizeof edgeMax);
247  fIn.read((char*)(&numberOfNodes), sizeof numberOfNodes );
248 
249  // contents
250  size_t size;
251  fIn.read((char*)(&size), sizeof size);
252 
253  G4double* value = new G4double[2*size];
254  fIn.read((char*)(value), 2*size*(sizeof(G4double)) );
255  if (G4int(fIn.gcount()) != G4int(2*size*(sizeof(G4double))) )
256  {
257  delete [] value;
258  return false;
259  }
260 
261  binVector.reserve(size);
262  dataVector.reserve(size);
263  for(size_t i = 0; i < size; ++i)
264  {
265  binVector.push_back(value[2*i]);
266  dataVector.push_back(value[2*i+1]);
267  }
268  delete [] value;
269 
270  // to remove any inconsistency
271  numberOfNodes = size;
272  edgeMin = binVector[0];
273  edgeMax = binVector[numberOfNodes-1];
274 
275  return true;
276 }
G4PVDataVector dataVector
int G4int
Definition: G4Types.hh:78
G4PVDataVector binVector
G4PVDataVector secDerivative
const XML_Char int const XML_Char * value
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4GLOB_DLL std::ostream G4cerr
void G4PhysicsVector::ScaleVector ( G4double  factorE,
G4double  factorV 
)
virtual

Reimplemented in G4PhysicsLogVector, G4PhysicsLinearVector, and G4PhysicsLnVector.

Definition at line 281 of file G4PhysicsVector.cc.

References binVector, dataVector, edgeMax, edgeMin, n, and secDerivative.

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

282 {
283  size_t n = dataVector.size();
284  size_t i;
285  if(n > 0) {
286  for(i=0; i<n; ++i) {
287  binVector[i] *= factorE;
288  dataVector[i] *= factorV;
289  }
290  }
291  // n = secDerivative.size();
292  // if(n > 0) { for(i=0; i<n; ++i) { secDerivative[i] *= factorV; } }
293  secDerivative.clear();
294 
295  edgeMin *= factorE;
296  edgeMax *= factorE;
297 }
G4PVDataVector dataVector
G4PVDataVector binVector
G4PVDataVector secDerivative
const G4int n
void G4PhysicsVector::SetSpline ( G4bool  )
inline
void G4PhysicsVector::SetVerboseLevel ( G4int  value)
inline
G4bool G4PhysicsVector::Store ( std::ofstream &  fOut,
G4bool  ascii = false 
)
virtual

Definition at line 164 of file G4PhysicsVector.cc.

References binVector, dataVector, edgeMax, edgeMin, and numberOfNodes.

165 {
166  // Ascii mode
167  if (ascii)
168  {
169  fOut << *this;
170  return true;
171  }
172  // Binary Mode
173 
174  // binning
175  fOut.write((char*)(&edgeMin), sizeof edgeMin);
176  fOut.write((char*)(&edgeMax), sizeof edgeMax);
177  fOut.write((char*)(&numberOfNodes), sizeof numberOfNodes);
178 
179  // contents
180  size_t size = dataVector.size();
181  fOut.write((char*)(&size), sizeof size);
182 
183  G4double* value = new G4double[2*size];
184  for(size_t i = 0; i < size; ++i)
185  {
186  value[2*i] = binVector[i];
187  value[2*i+1]= dataVector[i];
188  }
189  fOut.write((char*)(value), 2*size*(sizeof (G4double)));
190  delete [] value;
191 
192  return true;
193 }
G4PVDataVector dataVector
G4PVDataVector binVector
const XML_Char int const XML_Char * value
double G4double
Definition: G4Types.hh:76
G4double G4PhysicsVector::Value ( G4double  theEnergy,
size_t &  lastidx 
) const

Definition at line 511 of file G4PhysicsVector.cc.

References dataVector, edgeMax, edgeMin, and FindBin().

Referenced by G4EmCorrections::BarkasCorrection(), G4LossTableBuilder::BuildRangeTable(), G4Track::CalculateVelocityForOpticalPhoton(), G4LivermoreRayleighModel::ComputeCrossSectionPerAtom(), G4LivermoreGammaConversionModel::ComputeCrossSectionPerAtom(), G4LivermoreComptonModel::ComputeCrossSectionPerAtom(), G4PenelopeGammaConversionModel::ComputeCrossSectionPerAtom(), G4PenelopeRayleighModel::ComputeCrossSectionPerAtom(), G4PenelopePhotoElectricModel::ComputeCrossSectionPerAtom(), G4VRangeToEnergyConverter::ConvertCutToKineticEnergy(), G4EmCorrections::EffectiveChargeCorrection(), G4PenelopeIonisationXSHandler::GetDensityCorrection(), G4NeutronElasticXS::GetElementCrossSection(), G4NeutronCaptureXS::GetElementCrossSection(), G4NeutronInelasticXS::GetElementCrossSection(), G4PenelopeCrossSection::GetHardCrossSection(), G4HadronNucleonXsc::GetKmNeutronTotXscVector(), G4HadronNucleonXsc::GetKmProtonTotXscVector(), G4HadronNucleonXsc::GetKpNeutronTotXscVector(), G4HadronNucleonXsc::GetKpProtonTotXscVector(), G4PenelopeCrossSection::GetNormalizedShellCrossSection(), G4SPSEneDistribution::GetProbability(), G4Scintillation::GetScintillationYieldByParticleType(), G4PenelopeCrossSection::GetShellCrossSection(), G4PenelopePhotoElectricModel::GetShellCrossSection(), G4PenelopeCrossSection::GetSoftStoppingPower(), G4PenelopeCrossSection::GetTotalCrossSection(), G4ElementData::GetValueForElement(), G4PAIPhotData::Initialise(), G4PAIModelData::Initialise(), G4EmCorrections::KShellCorrection(), G4EmCorrections::LShellCorrection(), G4Cerenkov::PostStepDoIt(), G4OpBoundaryProcess::PostStepDoIt(), G4PenelopeBremsstrahlungAngular::PrepareTables(), G4PenelopeBremsstrahlungAngular::SampleDirection(), G4PenelopeRayleighModel::SampleSecondaries(), G4VEnergyLossProcess::SetCSDARangeTable(), G4VEnergyLossProcess::SetDEDXTable(), and G4EmCorrections::ShellCorrection().

512 {
513  G4double y;
514  if(theEnergy <= edgeMin) {
515  lastIdx = 0;
516  y = dataVector[0];
517  } else if(theEnergy >= edgeMax) {
518  lastIdx = numberOfNodes-1;
519  y = dataVector[lastIdx];
520  } else {
521  lastIdx = FindBin(theEnergy, lastIdx);
522  y = Interpolation(lastIdx, theEnergy);
523  }
524  return y;
525 }
G4PVDataVector dataVector
size_t FindBin(G4double energy, size_t idx) const
double G4double
Definition: G4Types.hh:76
G4double G4PhysicsVector::Value ( G4double  theEnergy) const
inline

Friends And Related Function Documentation

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

Definition at line 491 of file G4PhysicsVector.cc.

492 {
493  // binning
494  out << std::setprecision(12) << pv.edgeMin << " "
495  << pv.edgeMax << " " << pv.numberOfNodes << G4endl;
496 
497  // contents
498  out << pv.dataVector.size() << G4endl;
499  for(size_t i = 0; i < pv.dataVector.size(); i++)
500  {
501  out << pv.binVector[i] << " " << pv.dataVector[i] << G4endl;
502  }
503  out << std::setprecision(6);
504 
505  return out;
506 }
G4PVDataVector dataVector
G4PVDataVector binVector
#define G4endl
Definition: G4ios.hh:61

Field Documentation

G4double G4PhysicsVector::baseBin
protected
G4PVDataVector G4PhysicsVector::binVector
protected
G4PVDataVector G4PhysicsVector::dataVector
protected
G4double G4PhysicsVector::dBin
protected
G4double G4PhysicsVector::edgeMax
protected
G4double G4PhysicsVector::edgeMin
protected
size_t G4PhysicsVector::numberOfNodes
protected
G4PVDataVector G4PhysicsVector::secDerivative
protected
G4PhysicsVectorType G4PhysicsVector::type
protected
G4int G4PhysicsVector::verboseLevel
protected

Definition at line 243 of file G4PhysicsVector.hh.

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


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