Geant4-11
Public Member Functions | Private Attributes
G4PenelopeSamplingData Class Reference

#include <G4PenelopeSamplingData.hh>

Public Member Functions

void AddPoint (G4double x0, G4double pac0, G4double a0, G4double b0, size_t ITTL0, size_t ITTU0)
 
void Clear ()
 
void DumpTable ()
 
 G4PenelopeSamplingData (const G4PenelopeSamplingData &)=delete
 
 G4PenelopeSamplingData (G4int npoints=150)
 
G4double GetA (size_t index)
 
G4double GetB (size_t index)
 
size_t GetNumberOfStoredPoints ()
 
G4double GetPAC (size_t index)
 
G4double GetX (size_t index)
 
G4PenelopeSamplingDataoperator= (const G4PenelopeSamplingData &right)=delete
 
G4double SampleValue (G4double rndm)
 
 ~G4PenelopeSamplingData ()
 

Private Attributes

G4DataVectorfA
 
G4DataVectorfB
 
std::vector< size_t > * fITTL
 
std::vector< size_t > * fITTU
 
G4int fNP
 
G4DataVectorfPAC
 
G4DataVectorfX
 

Detailed Description

Definition at line 48 of file G4PenelopeSamplingData.hh.

Constructor & Destructor Documentation

◆ G4PenelopeSamplingData() [1/2]

G4PenelopeSamplingData::G4PenelopeSamplingData ( G4int  npoints = 150)
explicit

Definition at line 36 of file G4PenelopeSamplingData.cc.

36 :
37 fNP(nPoints)
38{
39 //create vectors
40 fX = new G4DataVector();
41 fPAC = new G4DataVector();
42 fA = new G4DataVector();
43 fB = new G4DataVector();
44 fITTL = new std::vector<size_t>;
45 fITTU = new std::vector<size_t>;
46}
std::vector< size_t > * fITTU
std::vector< size_t > * fITTL

References fA, fB, fITTL, fITTU, fPAC, and fX.

◆ ~G4PenelopeSamplingData()

G4PenelopeSamplingData::~G4PenelopeSamplingData ( )

Definition at line 49 of file G4PenelopeSamplingData.cc.

50{
51 if (fX) delete fX;
52 if (fPAC) delete fPAC;
53 if (fA) delete fA;
54 if (fB) delete fB;
55 if (fITTL) delete fITTL;
56 if (fITTU) delete fITTU;
57}

References fA, fB, fITTL, fITTU, fPAC, and fX.

◆ G4PenelopeSamplingData() [2/2]

G4PenelopeSamplingData::G4PenelopeSamplingData ( const G4PenelopeSamplingData )
delete

Member Function Documentation

◆ AddPoint()

void G4PenelopeSamplingData::AddPoint ( G4double  x0,
G4double  pac0,
G4double  a0,
G4double  b0,
size_t  ITTL0,
size_t  ITTU0 
)

Definition at line 97 of file G4PenelopeSamplingData.cc.

99{
100 fX->push_back(x0);
101 fPAC->push_back(pac0);
102 fA->push_back(a0);
103 fB->push_back(b0);
104 fITTL->push_back(ITTL0);
105 fITTU->push_back(ITTU0);
106
107 //check how many points we do have now
108 size_t nOfPoints = GetNumberOfStoredPoints();
109
110 if (nOfPoints > ((size_t)fNP))
111 {
112 G4cout << "G4PenelopeSamplingData::AddPoint() " << G4endl;
113 G4cout << "WARNING: Up to now there are " << nOfPoints << " points in the table" << G4endl;
114 G4cout << "while the anticipated (declared) number is " << fNP << G4endl;
115 }
116 return;
117}
const G4double a0
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout

References a0, fA, fB, fITTL, fITTU, fNP, fPAC, fX, G4cout, G4endl, and GetNumberOfStoredPoints().

Referenced by G4PenelopeRayleighModel::InitializeSamplingAlgorithm(), and G4PenelopeRayleighModelMI::InitializeSamplingAlgorithm().

◆ Clear()

void G4PenelopeSamplingData::Clear ( )

Definition at line 79 of file G4PenelopeSamplingData.cc.

80{
81 if (fX) delete fX;
82 if (fPAC) delete fPAC;
83 if (fA) delete fA;
84 if (fB) delete fB;
85 if (fITTL) delete fITTL;
86 if (fITTU) delete fITTU;
87 //create vectors
88 fX = new G4DataVector();
89 fPAC = new G4DataVector();
90 fA = new G4DataVector();
91 fB = new G4DataVector();
92 fITTL = new std::vector<size_t>;
93 fITTU = new std::vector<size_t>;
94}

References fA, fB, fITTL, fITTU, fPAC, and fX.

◆ DumpTable()

void G4PenelopeSamplingData::DumpTable ( )

Definition at line 120 of file G4PenelopeSamplingData.cc.

121{
122
123 G4cout << "*************************************************************************" << G4endl;
124 G4cout << GetNumberOfStoredPoints() << " points" << G4endl;
125 G4cout << "*************************************************************************" << G4endl;
126 for (size_t i=0;i<GetNumberOfStoredPoints();i++)
127 {
128 G4cout << i << " " << (*fX)[i] << " " << (*fPAC)[i] << " " << (*fA)[i] << " " <<
129 (*fB)[i] << " " << (*fITTL)[i] << " " << (*fITTU)[i] << G4endl;
130 }
131 G4cout << "*************************************************************************" << G4endl;
132}

References G4cout, G4endl, and GetNumberOfStoredPoints().

Referenced by G4PenelopeRayleighModel::InitializeSamplingAlgorithm(), and G4PenelopeRayleighModelMI::InitializeSamplingAlgorithm().

◆ GetA()

G4double G4PenelopeSamplingData::GetA ( size_t  index)

Definition at line 153 of file G4PenelopeSamplingData.cc.

154{
155 if (index < fA->size())
156 return (*fA)[index];
157 else
158 return 0;
159}

References fA.

Referenced by G4PenelopeRayleighModel::GetPMaxTable(), and G4PenelopeRayleighModelMI::GetPMaxTable().

◆ GetB()

G4double G4PenelopeSamplingData::GetB ( size_t  index)

Definition at line 162 of file G4PenelopeSamplingData.cc.

163{
164 if (index < fB->size())
165 return (*fB)[index];
166 else
167 return 0;
168}

References fB.

Referenced by G4PenelopeRayleighModel::GetPMaxTable(), and G4PenelopeRayleighModelMI::GetPMaxTable().

◆ GetNumberOfStoredPoints()

size_t G4PenelopeSamplingData::GetNumberOfStoredPoints ( )

Definition at line 61 of file G4PenelopeSamplingData.cc.

62{
63 size_t points = fX->size();
64
65 //check everything is all right
66 if (fPAC->size() != points || fA->size() != points ||
67 fB->size() != points || fITTL->size() != points ||
68 fITTU->size() != points)
69 {
71 ed << "Data vectors look to have different dimensions !" << G4endl;
72 G4Exception("G4PenelopeSamplingData::GetNumberOfStoredPoints()","em2040",
73 FatalException,ed);
74 }
75 return points;
76}
@ 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

References fA, FatalException, fB, fITTL, fITTU, fPAC, fX, G4endl, and G4Exception().

Referenced by AddPoint(), DumpTable(), G4PenelopeRayleighModel::GetPMaxTable(), G4PenelopeRayleighModelMI::GetPMaxTable(), G4PenelopeRayleighModel::SampleSecondaries(), G4PenelopeRayleighModelMI::SampleSecondaries(), and SampleValue().

◆ GetPAC()

G4double G4PenelopeSamplingData::GetPAC ( size_t  index)

Definition at line 144 of file G4PenelopeSamplingData.cc.

145{
146 if (index < fPAC->size())
147 return (*fPAC)[index];
148 else
149 return 0;
150}

References fPAC.

Referenced by G4PenelopeRayleighModel::GetPMaxTable(), and G4PenelopeRayleighModelMI::GetPMaxTable().

◆ GetX()

G4double G4PenelopeSamplingData::GetX ( size_t  index)

Definition at line 135 of file G4PenelopeSamplingData.cc.

136{
137 if (index < fX->size())
138 return (*fX)[index];
139 else
140 return 0;
141}

References fX.

Referenced by G4PenelopeRayleighModel::GetPMaxTable(), G4PenelopeRayleighModelMI::GetPMaxTable(), G4PenelopeRayleighModel::SampleSecondaries(), and G4PenelopeRayleighModelMI::SampleSecondaries().

◆ operator=()

G4PenelopeSamplingData & G4PenelopeSamplingData::operator= ( const G4PenelopeSamplingData right)
delete

◆ SampleValue()

G4double G4PenelopeSamplingData::SampleValue ( G4double  rndm)

Definition at line 171 of file G4PenelopeSamplingData.cc.

172{
173 //One passes here a random number in (0,1).
174 //Notice: it possible that is between (0,b) with b<1
175 size_t points = GetNumberOfStoredPoints();
176
177 size_t itn = (size_t) (maxRand*(points-1));
178 size_t i = (*fITTL)[itn];
179 size_t j = (*fITTU)[itn];
180
181 while ((j-i) > 1)
182 {
183 size_t k = (i+j)/2;
184 if (maxRand > (*fPAC)[k])
185 i = k;
186 else
187 j = k;
188 }
189
190 //Sampling from the rational inverse cumulative distribution
191 G4double result = 0;
192
193 G4double rr = maxRand - (*fPAC)[i];
194 if (rr > 1e-16)
195 {
196 G4double d = (*fPAC)[i+1]-(*fPAC)[i];
197 result = (*fX)[i]+
198 ((1.0+(*fA)[i]+(*fB)[i])*d*rr/
199 (d*d+((*fA)[i]*d+(*fB)[i]*rr)*rr))*((*fX)[i+1]-(*fX)[i]);
200 }
201 else
202 result = (*fX)[i];
203
204 return result;
205}
double G4double
Definition: G4Types.hh:83

References fA, fPAC, fX, and GetNumberOfStoredPoints().

Referenced by G4PenelopeRayleighModel::SampleSecondaries(), and G4PenelopeRayleighModelMI::SampleSecondaries().

Field Documentation

◆ fA

G4DataVector* G4PenelopeSamplingData::fA
private

◆ fB

G4DataVector* G4PenelopeSamplingData::fB
private

◆ fITTL

std::vector<size_t>* G4PenelopeSamplingData::fITTL
private

◆ fITTU

std::vector<size_t>* G4PenelopeSamplingData::fITTU
private

◆ fNP

G4int G4PenelopeSamplingData::fNP
private

Definition at line 79 of file G4PenelopeSamplingData.hh.

Referenced by AddPoint().

◆ fPAC

G4DataVector* G4PenelopeSamplingData::fPAC
private

◆ fX

G4DataVector* G4PenelopeSamplingData::fX
private

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