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

#include <G4DNASamplingTable.hh>

Public Member Functions

 G4DNASamplingTable (std::size_t npoint)
 ~G4DNASamplingTable ()
void LoadData (const G4String &filename, G4double factorE, G4double scaleFactor, G4bool verbose)
G4double GetValue (G4double ekinPrimary, G4double ekinSecondary, G4int shell) const
G4double SampleCumulative (G4double ekinPrimary, G4int shell) const
 G4DNASamplingTable (const G4DNASamplingTable &copy)=delete
G4DNASamplingTableoperator= (const G4DNASamplingTable &right)=delete

Detailed Description

Definition at line 38 of file G4DNASamplingTable.hh.

Constructor & Destructor Documentation

◆ G4DNASamplingTable() [1/2]

G4DNASamplingTable::G4DNASamplingTable ( std::size_t npoint)
explicit

Definition at line 39 of file G4DNASamplingTable.cc.

40{
41 fPrimaryEnergy.reserve(npoints);
42 fSecEnergy.reserve(npoints);
43 for (G4int i=0; i<5; ++i) { (fPDF[i]).reserve(npoints); }
44}
int G4int
Definition G4Types.hh:85

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

◆ ~G4DNASamplingTable()

G4DNASamplingTable::~G4DNASamplingTable ( )

Definition at line 46 of file G4DNASamplingTable.cc.

47{
48 for (auto & p : fSecEnergy) { delete p; }
49 for (G4int i=0; i<5; ++i) {
50 for (auto & p : fPDF[i]) { delete p; }
51 }
52}

◆ G4DNASamplingTable() [2/2]

G4DNASamplingTable::G4DNASamplingTable ( const G4DNASamplingTable & copy)
delete

Member Function Documentation

◆ GetValue()

G4double G4DNASamplingTable::GetValue ( G4double ekinPrimary,
G4double ekinSecondary,
G4int shell ) const

Definition at line 108 of file G4DNASamplingTable.cc.

110{
111 std::vector<G4double>* e1{nullptr};
112 std::vector<G4double>* e2{nullptr};
113 std::vector<G4double>* s1{nullptr};
114 std::vector<G4double>* s2{nullptr};
115 G4int idx = GetIndex(fPrimaryEnergy, ekinPrimary);
116 if (idx == -1) {
117 e1 = fSecEnergy[0];
118 s1 = (fPDF[shell])[0];
119 } else if (idx > fNpoints) {
120 e1 = fSecEnergy[fNpoints];
121 s1 = (fPDF[shell])[fNpoints];
122 } else {
123 e1 = fSecEnergy[idx];
124 s1 = (fPDF[shell])[idx];
125 e2 = fSecEnergy[idx + 1];
126 s2 = (fPDF[shell])[idx + 1];
127 }
128 // edge cases
129 G4double res1 = VecInterpolation(e1, s1, ekinSec);
130 if (nullptr == e2) { return res1; }
131
132 // ordinary case
133 G4double res2 = VecInterpolation(e2, s2, ekinSec);
134 G4double res = Interpolate(fPrimaryEnergy[idx], fPrimaryEnergy[idx + 1],
135 ekinPrimary, res1, res2);
136 return res;
137}
double G4double
Definition G4Types.hh:83

◆ LoadData()

void G4DNASamplingTable::LoadData ( const G4String & filename,
G4double factorE,
G4double scaleFactor,
G4bool verbose )

Definition at line 54 of file G4DNASamplingTable.cc.

56{
57 std::ostringstream ost;
58 ost << G4EmParameters::Instance()->GetDirLEDATA() << "/" << fname;
59 std::ifstream fin(ost.str().c_str());
60 if (!fin.is_open()) {
62 ed << "File <" << ost.str().c_str() << "> is not opened!";
63 G4Exception("G4DNASamplingTable::LoadDifferential ", "em0003",
64 FatalException, ed, "");
65 return;
66 }
67
68 G4double t, e, sig;
69 G4double e0{0.0};
70 G4int ntmax{0};
71 G4int nt{0};
72 std::vector<G4double>* v = nullptr;
73 std::vector<G4double>* vPDF[5];
74 for (;;) {
75 fin >> e;
76 if (fin.eof()) { break; }
77 if (e != e0 || nullptr == v) {
78 fPrimaryEnergy.push_back(e*factE);
79 e0 = e;
80 ++fNpoints;
81 v = new std::vector<G4double>;
82 fSecEnergy.push_back(v);
83 for (G4int i=0; i<5; ++i) {
84 vPDF[i] = new std::vector<G4double>;
85 (fPDF[i]).push_back(vPDF[i]);
86 }
87 ntmax = std::max(ntmax, nt);
88 nt = 0;
89 }
90 fin >> t;
91 v->push_back(t*factE);
92 ++nt;
93 for (G4int i=0; i<5; ++i) {
94 fin >> sig;
95 sig *= fact;
96 (vPDF[i])->push_back(sig);
97 }
98 if (fin.eof()) { break; }
99 }
100 if (verbose) {
101 G4cout << "G4DNASamplingTable::LoadData from file:" << G4endl;
102 G4cout << fname << G4endl;
103 G4cout << " Nenergy= " << fNpoints << " NmaxT= " << ntmax << G4endl;
104 }
105 if (fNpoints > 0) { --fNpoints; }
106}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4EmParameters * Instance()
const G4String & GetDirLEDATA() const

◆ operator=()

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

◆ SampleCumulative()

G4double G4DNASamplingTable::SampleCumulative ( G4double ekinPrimary,
G4int shell ) const

Definition at line 191 of file G4DNASamplingTable.cc.

192{
193 std::vector<G4double>* e1{nullptr};
194 std::vector<G4double>* e2{nullptr};
195 std::vector<G4double>* s1{nullptr};
196 std::vector<G4double>* s2{nullptr};
197 G4int idx = GetIndex(fPrimaryEnergy, ekinPrimary);
198 if (idx == -1) {
199 e1 = fSecEnergy[0];
200 s1 = (fPDF[shell])[0];
201 } else if (idx > fNpoints) {
202 e1 = fSecEnergy[fNpoints];
203 s1 = (fPDF[shell])[fNpoints];
204 } else {
205 e1 = fSecEnergy[idx];
206 s1 = (fPDF[shell])[idx];
207 e2 = fSecEnergy[idx + 1];
208 s2 = (fPDF[shell])[idx + 1];
209 }
211
212 // edge cases
213 G4double res1 = VecInterpolation(s1, e1, q);
214 if (nullptr == e2) { return res1; }
215
216 // ordinary case
217 G4double res2 = VecInterpolation(s2, e2, q);
218 G4double res = Interpolate(fPrimaryEnergy[idx], fPrimaryEnergy[idx + 1],
219 ekinPrimary, res1, res2);
220 return res;
221}
#define G4UniformRand()
Definition Randomize.hh:52

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