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

#include <G4AdjointCSMatrix.hh>

Public Member Functions

 G4AdjointCSMatrix (G4bool aBool)
 
 ~G4AdjointCSMatrix ()
 
void Clear ()
 
void AddData (G4double aPrimEnergy, G4double aCS, std::vector< double > *aLogSecondEnergyVector, std::vector< double > *aLogProbVector, size_t n_pro_decade=0)
 
G4bool GetData (unsigned int i, G4double &aPrimEnergy, G4double &aCS, G4double &log0, std::vector< double > *&aLogSecondEnergyVector, std::vector< double > *&aLogProbVector, std::vector< size_t > *&aLogProbVectorIndex)
 
std::vector< double > * GetLogPrimEnergyVector ()
 
std::vector< double > * GetLogCrossSectionvector ()
 
G4bool IsScatProjToProj ()
 
void Write (G4String file_name)
 
void Read (G4String file_name)
 

Detailed Description

Definition at line 49 of file G4AdjointCSMatrix.hh.

Constructor & Destructor Documentation

◆ G4AdjointCSMatrix()

G4AdjointCSMatrix::G4AdjointCSMatrix ( G4bool aBool)

Definition at line 36 of file G4AdjointCSMatrix.cc.

36{ fScatProjToProj = aBool; }

◆ ~G4AdjointCSMatrix()

G4AdjointCSMatrix::~G4AdjointCSMatrix ( )

Definition at line 39 of file G4AdjointCSMatrix.cc.

40{
41 fLogPrimEnergyVector.clear();
42 fLogCrossSectionVector.clear();
43
44 for (auto p : fLogSecondEnergyMatrix) {
45 p->clear();
46 delete p;
47 p = nullptr;
48 }
49 fLogSecondEnergyMatrix.clear();
50
51 for (auto p : fLogProbMatrix) {
52 p->clear();
53 delete p;
54 p = nullptr;
55 }
56 fLogProbMatrix.clear();
57
58 for (auto p : fLogProbMatrixIndex) {
59 if (p) {
60 p->clear();
61 delete p;
62 p = nullptr;
63 }
64 }
65 fLogProbMatrixIndex.clear();
66}

Member Function Documentation

◆ AddData()

void G4AdjointCSMatrix::AddData ( G4double aPrimEnergy,
G4double aCS,
std::vector< double > * aLogSecondEnergyVector,
std::vector< double > * aLogProbVector,
size_t n_pro_decade = 0 )

Definition at line 81 of file G4AdjointCSMatrix.cc.

85{
87
88 // At this time we consider that the energy is increasing monotically
89 fLogPrimEnergyVector.push_back(aLogPrimEnergy);
90 fLogCrossSectionVector.push_back(aLogCS);
91 fLogSecondEnergyMatrix.push_back(aLogSecondEnergyVector);
92 fLogProbMatrix.push_back(aLogProbVector);
93
94 std::vector<size_t>* aLogProbVectorIndex = nullptr;
95
96 if(n_pro_decade > 0 && !aLogProbVector->empty())
97 {
98 aLogProbVectorIndex = new std::vector<size_t>();
99 G4double dlog = std::log(10.) / n_pro_decade;
100 G4double log_val =
101 int(std::min((*aLogProbVector)[0], aLogProbVector->back()) / dlog) * dlog;
102 fLog0Vector.push_back(log_val);
103
104 // Loop checking, 07-Aug-2015, Vladimir Ivanchenko
105 while(log_val < 0.)
106 {
107 aLogProbVectorIndex->push_back(
108 theInterpolator->FindPosition(log_val, (*aLogProbVector)));
109 log_val += dlog;
110 }
111 }
112 else
113 {
114 fLog0Vector.push_back(0.);
115 }
116 fLogProbMatrixIndex.push_back(aLogProbVectorIndex);
117
118 ++fNbPrimEnergy;
119}
double G4double
Definition G4Types.hh:83
static G4AdjointInterpolator * GetInstance()
size_t FindPosition(G4double &x, std::vector< G4double > &x_vec, size_t ind_min=0, size_t ind_max=0)

◆ Clear()

void G4AdjointCSMatrix::Clear ( )

Definition at line 69 of file G4AdjointCSMatrix.cc.

70{
71 fLogPrimEnergyVector.clear();
72 fLogCrossSectionVector.clear();
73 fLogSecondEnergyMatrix.clear();
74 fLogProbMatrix.clear();
75 fLogProbMatrixIndex.clear();
76 fLog0Vector.clear();
77 fNbPrimEnergy = 0;
78}

◆ GetData()

G4bool G4AdjointCSMatrix::GetData ( unsigned int i,
G4double & aPrimEnergy,
G4double & aCS,
G4double & log0,
std::vector< double > *& aLogSecondEnergyVector,
std::vector< double > *& aLogProbVector,
std::vector< size_t > *& aLogProbVectorIndex )

Definition at line 122 of file G4AdjointCSMatrix.cc.

127{
128 if(i >= fNbPrimEnergy)
129 return false;
130 aLogPrimEnergy = fLogPrimEnergyVector[i];
131 aLogCS = fLogCrossSectionVector[i];
132 aLogSecondEnergyVector = fLogSecondEnergyMatrix[i];
133 aLogProbVector = fLogProbMatrix[i];
134 aLogProbVectorIndex = fLogProbMatrixIndex[i];
135 log0 = fLog0Vector[i];
136 return true;
137}

Referenced by G4VEmAdjointModel::SampleAdjSecEnergyFromCSMatrix().

◆ GetLogCrossSectionvector()

std::vector< double > * G4AdjointCSMatrix::GetLogCrossSectionvector ( )
inline

Definition at line 71 of file G4AdjointCSMatrix.hh.

72 {
73 return &fLogCrossSectionVector;
74 }

◆ GetLogPrimEnergyVector()

std::vector< double > * G4AdjointCSMatrix::GetLogPrimEnergyVector ( )
inline

Definition at line 66 of file G4AdjointCSMatrix.hh.

67 {
68 return &fLogPrimEnergyVector;
69 }

Referenced by G4VEmAdjointModel::SampleAdjSecEnergyFromCSMatrix().

◆ IsScatProjToProj()

G4bool G4AdjointCSMatrix::IsScatProjToProj ( )
inline

Definition at line 76 of file G4AdjointCSMatrix.hh.

76{ return fScatProjToProj; }

Referenced by G4VEmAdjointModel::SampleAdjSecEnergyFromCSMatrix().

◆ Read()

void G4AdjointCSMatrix::Read ( G4String file_name)

Definition at line 186 of file G4AdjointCSMatrix.cc.

187{
188 std::fstream FileOutput(file_name, std::ios::in);
189 size_t n1, n2;
190
191 fLogPrimEnergyVector.clear();
192 fLogCrossSectionVector.clear();
193 fLogSecondEnergyMatrix.clear();
194 fLogProbMatrix.clear();
195 FileOutput >> n1;
196 for(size_t i = 0; i < n1; ++i)
197 {
198 G4double E, CS;
199 FileOutput >> E >> CS;
200 fLogPrimEnergyVector.push_back(E);
201 fLogCrossSectionVector.push_back(CS);
202 FileOutput >> n2;
203 fLogSecondEnergyMatrix.push_back(new std::vector<G4double>());
204 fLogProbMatrix.push_back(new std::vector<G4double>());
205
206 for(size_t j = 0; j < n2; ++j)
207 {
208 G4double E1;
209 FileOutput >> E1;
210 fLogSecondEnergyMatrix[i]->push_back(E1);
211 }
212 FileOutput >> n2;
213 for(size_t j = 0; j < n2; ++j)
214 {
215 G4double prob;
216 FileOutput >> prob;
217 fLogProbMatrix[i]->push_back(prob);
218 }
219 }
220}

◆ Write()

void G4AdjointCSMatrix::Write ( G4String file_name)

Definition at line 140 of file G4AdjointCSMatrix.cc.

141{
142 std::fstream FileOutput(file_name, std::ios::out);
143 FileOutput << std::setiosflags(std::ios::scientific);
144 FileOutput << std::setprecision(6);
145 FileOutput << fLogPrimEnergyVector.size() << G4endl;
146 for(size_t i = 0; i < fLogPrimEnergyVector.size(); ++i)
147 {
148 FileOutput << std::exp(fLogPrimEnergyVector[i]) / MeV << '\t'
149 << std::exp(fLogCrossSectionVector[i]) << G4endl;
150 size_t j1 = 0;
151 FileOutput << fLogSecondEnergyMatrix[i]->size() << G4endl;
152 for(size_t j = 0; j < fLogSecondEnergyMatrix[i]->size(); ++j)
153 {
154 FileOutput << std::exp((*fLogSecondEnergyMatrix[i])[j]);
155 ++j1;
156 if(j1 < 10)
157 FileOutput << '\t';
158 else
159 {
160 FileOutput << G4endl;
161 j1 = 0;
162 }
163 }
164 if(j1 > 0)
165 FileOutput << G4endl;
166 j1 = 0;
167 FileOutput << fLogProbMatrix[i]->size() << G4endl;
168 for(size_t j = 0; j < fLogProbMatrix[i]->size(); ++j)
169 {
170 FileOutput << std::exp((*fLogProbMatrix[i])[j]);
171 ++j1;
172 if(j1 < 10)
173 FileOutput << '\t';
174 else
175 {
176 FileOutput << G4endl;
177 j1 = 0;
178 }
179 }
180 if(j1 > 0)
181 FileOutput << G4endl;
182 }
183}
#define G4endl
Definition G4ios.hh:67

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