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

#include <G4ExtendedPhysicsVector.hh>

Public Member Functions

 G4ExtendedPhysicsVector (G4PhysicsVector *, G4int nxsec=0)
virtual ~G4ExtendedPhysicsVector ()
 G4ExtendedPhysicsVector (const G4ExtendedPhysicsVector &)=default
G4ExtendedPhysicsVectoroperator= (const G4ExtendedPhysicsVector &)=default
 G4ExtendedPhysicsVector (const G4ExtendedPhysicsVector &&)=delete
G4ExtendedPhysicsVectoroperator= (const G4ExtendedPhysicsVector &&)=delete
G4bool operator== (const G4ExtendedPhysicsVector &right) const =delete
const G4PhysicsVectorGetPhysicsVector () const
G4double Value (const G4double energy, std::size_t &lastidx) const
G4double LogLogValue (const G4double energy, std::size_t &lastidx) const
void SetDataLength (G4int dlength)
void PutPartialXSData (const std::size_t idx, const G4double *y)
G4int SampleReactionChannel (const G4double energy, const G4double rand, std::size_t &lastidx) const
G4int SampleReactionChannelLogLog (const G4double energy, const G4double rand, std::size_t &lastidx) const
void DumpValues (G4double unitE=1.0, G4double unitV=1.0) const

Detailed Description

Definition at line 44 of file G4ExtendedPhysicsVector.hh.

Constructor & Destructor Documentation

◆ G4ExtendedPhysicsVector() [1/3]

G4ExtendedPhysicsVector::G4ExtendedPhysicsVector ( G4PhysicsVector * ptr,
G4int nxsec = 0 )
explicit

Definition at line 39 of file G4ExtendedPhysicsVector.cc.

40 : totalData(ptr)
41{
42 if (nullptr == ptr)
43 {
44 if (0 < verboseLevel)
45 {
46 G4cout << "### G4ExtendedPhysicsVector with undefined G4PhysicsVector " << G4endl;
47 }
48 totalData = new G4PhysicsFreeVector(false);
49 }
50 if (nxsec > 1)
51 {
52 nPartialXS = nxsec - 1;
53 dataPartialXS = new std::vector<std::vector<G4float>* >;
54 dataPartialXS->resize((std::size_t)nPartialXS, nullptr);
55 }
56}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

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

◆ ~G4ExtendedPhysicsVector()

G4ExtendedPhysicsVector::~G4ExtendedPhysicsVector ( )
virtual

Definition at line 59 of file G4ExtendedPhysicsVector.cc.

60{
61 if (nPartialXS > 0)
62 {
63 for (auto const & p : *dataPartialXS) { delete p; }
64 delete dataPartialXS;
65 }
66 delete totalData;
67}

◆ G4ExtendedPhysicsVector() [2/3]

G4ExtendedPhysicsVector::G4ExtendedPhysicsVector ( const G4ExtendedPhysicsVector & )
default

◆ G4ExtendedPhysicsVector() [3/3]

G4ExtendedPhysicsVector::G4ExtendedPhysicsVector ( const G4ExtendedPhysicsVector && )
delete

Member Function Documentation

◆ DumpValues()

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

Definition at line 213 of file G4ExtendedPhysicsVector.cc.

214{
215 G4cout << "====== Data length " << numberOfNodes << " =====" << G4endl;
216 // e, partial cumulative normalized x-sections, total x-section
217 for (std::size_t i = 0; i < numberOfNodes; ++i)
218 {
219 G4cout << i << ". " << totalData->Energy(i) / unitE;
220 for (G4int j = 0; j < nPartialXS; ++j)
221 {
222 G4cout << " " << (*((*dataPartialXS)[i]))[j];
223 }
224 G4cout << " " << (*totalData)[i] / unitV << G4endl;
225 }
226}
int G4int
Definition G4Types.hh:85

◆ GetPhysicsVector()

const G4PhysicsVector * G4ExtendedPhysicsVector::GetPhysicsVector ( ) const
inline

Definition at line 109 of file G4ExtendedPhysicsVector.hh.

110{
111 return totalData;
112}

◆ LogLogValue()

G4double G4ExtendedPhysicsVector::LogLogValue ( const G4double energy,
std::size_t & lastidx ) const

Definition at line 99 of file G4ExtendedPhysicsVector.cc.

100{
101 G4bool interpolation = totalData->CheckIndex(e, idx);
102
103 G4double y1 = (*totalData)[idx];
104 if (interpolation)
105 {
106 G4double e1 = totalData->Energy(idx);
107 G4double e2 = totalData->Energy(idx + 1);
108 G4double y2 = (*totalData)[idx + 1];
109 if (e1 > 0.0 && e2 > e1 && y1 > 0.0 && y2 > 0.0)
110 {
111 y1 *= G4Exp(G4Log(e/e1) * G4Log(y2/y1) / G4Log(e2/e1));
112 }
113 }
114 return y1;
115}
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition G4Exp.hh:132
G4double G4Log(G4double x)
Definition G4Log.hh:169
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86

◆ operator=() [1/2]

G4ExtendedPhysicsVector & G4ExtendedPhysicsVector::operator= ( const G4ExtendedPhysicsVector && )
delete

◆ operator=() [2/2]

G4ExtendedPhysicsVector & G4ExtendedPhysicsVector::operator= ( const G4ExtendedPhysicsVector & )
default

◆ operator==()

G4bool G4ExtendedPhysicsVector::operator== ( const G4ExtendedPhysicsVector & right) const
delete

◆ PutPartialXSData()

void G4ExtendedPhysicsVector::PutPartialXSData ( const std::size_t idx,
const G4double * y )

Definition at line 118 of file G4ExtendedPhysicsVector.cc.

119{
120 if (idx >= numberOfNodes)
121 {
122 if (0 < verboseLevel)
123 {
124 G4cout << "### G4ExtendedPhysicsVector::PutPartialXSData(..) idx=" << idx
125 << " is out of range " << numberOfNodes
126 << G4endl;
127 }
128 return;
129 }
130
131 // prepare data vector, the last vector is not created
132 // because of normalisation of the sum to 1.
133 G4float sum = 0.f;
134 for (G4int i = 0; i < nPartialXS; ++i)
135 {
136 sum += (G4float)y[i];
137 (*((*dataPartialXS)[i]))[idx] = sum;
138 }
139 sum += (G4float)y[nPartialXS];
140 if (sum > 0.f)
141 {
142 sum = 1.f/sum;
143 for (G4int i = 0; i < nPartialXS; ++i)
144 {
145 (*((*dataPartialXS)[i]))[idx] *= sum;
146 }
147 }
148}
float G4float
Definition G4Types.hh:84

Referenced by G4MatUtils::BuildExtendedVector().

◆ SampleReactionChannel()

G4int G4ExtendedPhysicsVector::SampleReactionChannel ( const G4double energy,
const G4double rand,
std::size_t & lastidx ) const

Definition at line 151 of file G4ExtendedPhysicsVector.cc.

154{
155 if (nPartialXS <= 1) { return 0; }
156 G4bool interpolation = totalData->CheckIndex(e, idx);
157
158 G4double e1 = totalData->Energy(idx);
159 G4double e2 = e1;
160 if (interpolation)
161 {
162 e2 = totalData->Energy(idx + 1) - e1;
163 if (e2 <= 0.0) { interpolation = false; }
164 }
165 for (G4int i=0; i < nPartialXS; ++i)
166 {
167 G4double xs = (G4double)(*((*dataPartialXS)[i]))[idx];
168 if (interpolation)
169 {
170 G4double xs2 = (G4double)((*((*dataPartialXS)[i]))[idx + 1]) - xs;
171 xs += (e - e1) * xs2 / e2;
172 }
173 if (xs >= rand) { return i; }
174 }
175 return nPartialXS;
176}

◆ SampleReactionChannelLogLog()

G4int G4ExtendedPhysicsVector::SampleReactionChannelLogLog ( const G4double energy,
const G4double rand,
std::size_t & lastidx ) const

Definition at line 180 of file G4ExtendedPhysicsVector.cc.

183{
184 if (nPartialXS <= 1) { return 0; }
185 G4bool interpolation = totalData->CheckIndex(e, idx);
186
187 G4double e1 = totalData->Energy(idx);
188 if (e1 <= 0.0) { interpolation = false; }
189 G4double e2 = e1;
190 if (interpolation)
191 {
192 e2 = totalData->Energy(idx + 1);
193 if (e2 <= e1) { interpolation = false; }
194 e2 = G4Log(e2 / e1);
195 }
196 for (G4int i = 0; i < nPartialXS; ++i)
197 {
198 G4double xs = (G4double)(*((*dataPartialXS)[i]))[idx];
199 if (interpolation && xs > 0.0)
200 {
201 G4double xs2 = (G4double)((*((*dataPartialXS)[i]))[idx + 1]) - xs;
202 if (xs2 > 0.0)
203 {
204 xs *= G4Exp(G4Log(e / e1) * G4Log(xs2 / xs) / e2);
205 }
206 }
207 if (xs >= rand) { return i; }
208 }
209 return nPartialXS;
210}

◆ SetDataLength()

void G4ExtendedPhysicsVector::SetDataLength ( G4int dlength)

Definition at line 70 of file G4ExtendedPhysicsVector.cc.

71{
72 // this method may be applied for empty vector only
73 totalData->SetDataLength(dlength);
74 numberOfNodes = totalData->GetVectorLength();
75 if (1 < numberOfNodes)
76 {
77 idxmax = numberOfNodes - 2;
78 }
79 else
80 {
81 if (0 < verboseLevel)
82 {
83 G4cout << "### G4ExtendedPhysicsVector::SetDataLength numberOfNodes="
84 << numberOfNodes << " data structure left empty." << G4endl;
85 }
86 return;
87 }
88
89 if (nPartialXS > 0)
90 {
91 for (G4int i = 0; i < nPartialXS; ++i)
92 {
93 (*dataPartialXS)[i] = new std::vector<G4float>(numberOfNodes, 0.f);
94 }
95 }
96}

Referenced by G4MatUtils::BuildExtendedVector().

◆ Value()

G4double G4ExtendedPhysicsVector::Value ( const G4double energy,
std::size_t & lastidx ) const
inline

Definition at line 114 of file G4ExtendedPhysicsVector.hh.

115{
116 return totalData->Value(e, idx);
117}

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