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

#include <G4PenelopeSamplingData.hh>

Public Member Functions

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

Detailed Description

Definition at line 48 of file G4PenelopeSamplingData.hh.

Constructor & Destructor Documentation

◆ G4PenelopeSamplingData()

G4PenelopeSamplingData::G4PenelopeSamplingData ( G4int  npoints = 150)

Definition at line 36 of file G4PenelopeSamplingData.cc.

36 :
37 np(nPoints)
38{
39 //create vectors
40 x = new G4DataVector();
41 pac = new G4DataVector();
42 a = new G4DataVector();
43 b = new G4DataVector();
44 ITTL = new std::vector<size_t>;
45 ITTU = new std::vector<size_t>;
46}

◆ ~G4PenelopeSamplingData()

G4PenelopeSamplingData::~G4PenelopeSamplingData ( )

Definition at line 49 of file G4PenelopeSamplingData.cc.

50{
51 if (x) delete x;
52 if (pac) delete pac;
53 if (a) delete a;
54 if (b) delete b;
55 if (ITTL) delete ITTL;
56 if (ITTU) delete ITTU;
57}

Member Function Documentation

◆ AddPoint()

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

Definition at line 96 of file G4PenelopeSamplingData.cc.

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

◆ Clear()

void G4PenelopeSamplingData::Clear ( )

Definition at line 78 of file G4PenelopeSamplingData.cc.

79{
80 if (x) delete x;
81 if (pac) delete pac;
82 if (a) delete a;
83 if (b) delete b;
84 if (ITTL) delete ITTL;
85 if (ITTU) delete ITTU;
86 //create vectors
87 x = new G4DataVector();
88 pac = new G4DataVector();
89 a = new G4DataVector();
90 b = new G4DataVector();
91 ITTL = new std::vector<size_t>;
92 ITTU = new std::vector<size_t>;
93}

◆ DumpTable()

void G4PenelopeSamplingData::DumpTable ( )

Definition at line 119 of file G4PenelopeSamplingData.cc.

120{
121
122 G4cout << "*************************************************************************" << G4endl;
123 G4cout << GetNumberOfStoredPoints() << " points" << G4endl;
124 G4cout << "*************************************************************************" << G4endl;
125 for (size_t i=0;i<GetNumberOfStoredPoints();i++)
126 {
127 G4cout << i << " " << (*x)[i] << " " << (*pac)[i] << " " << (*a)[i] << " " <<
128 (*b)[i] << " " << (*ITTL)[i] << " " << (*ITTU)[i] << G4endl;
129 }
130 G4cout << "*************************************************************************" << G4endl;
131}

◆ GetA()

G4double G4PenelopeSamplingData::GetA ( size_t  index)

Definition at line 152 of file G4PenelopeSamplingData.cc.

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

◆ GetB()

G4double G4PenelopeSamplingData::GetB ( size_t  index)

Definition at line 161 of file G4PenelopeSamplingData.cc.

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

◆ GetNumberOfStoredPoints()

size_t G4PenelopeSamplingData::GetNumberOfStoredPoints ( )

Definition at line 60 of file G4PenelopeSamplingData.cc.

61{
62 size_t points = x->size();
63
64 //check everything is all right
65 if (pac->size() != points || a->size() != points ||
66 b->size() != points || ITTL->size() != points ||
67 ITTU->size() != points)
68 {
70 ed << "Data vectors look to have different dimensions !" << G4endl;
71 G4Exception("G4PenelopeSamplingData::GetNumberOfStoredPoints()","em2040",
72 FatalException,ed);
73 }
74 return points;
75}
@ 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 AddPoint(), DumpTable(), G4PenelopeRayleighModel::SampleSecondaries(), G4PenelopeRayleighModelMI::SampleSecondaries(), and SampleValue().

◆ GetPAC()

G4double G4PenelopeSamplingData::GetPAC ( size_t  index)

Definition at line 143 of file G4PenelopeSamplingData.cc.

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

◆ GetX()

G4double G4PenelopeSamplingData::GetX ( size_t  index)

Definition at line 134 of file G4PenelopeSamplingData.cc.

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

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

◆ SampleValue()

G4double G4PenelopeSamplingData::SampleValue ( G4double  rndm)

Definition at line 170 of file G4PenelopeSamplingData.cc.

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

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


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