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

#include <G4HadXSHelper.hh>

Static Public Member Functions

static std::vector< G4double > * FindCrossSectionMax (G4HadronicProcess *, const G4ParticleDefinition *, const G4double tmin, const G4double tmax)
 
static std::vector< G4TwoPeaksHadXS * > * FillPeaksStructure (G4HadronicProcess *, const G4ParticleDefinition *, const G4double tmin, const G4double tmax)
 

Detailed Description

Definition at line 43 of file G4HadXSHelper.hh.

Member Function Documentation

◆ FillPeaksStructure()

std::vector< G4TwoPeaksHadXS * > * G4HadXSHelper::FillPeaksStructure ( G4HadronicProcess * p,
const G4ParticleDefinition * part,
const G4double tmin,
const G4double tmax )
static

Definition at line 97 of file G4HadXSHelper.cc.

101{
102 std::vector<G4TwoPeaksHadXS*>* ptr = nullptr;
103 if(nullptr == p) { return ptr; }
104
105 /*
106 G4cout << "G4HadXSHelper::FillPeaksStructure for "
107 << p->GetProcessName() << " and " << part->GetParticleName() << G4endl;
108 */
109 const G4MaterialTable* theMatTable = G4Material::GetMaterialTable();
111 ptr = new std::vector<G4TwoPeaksHadXS*>;
112 ptr->resize(n, nullptr);
113
114 G4double e1peak, e1deep, e2peak, e2deep, e3peak;
115 G4bool isDeep = false;
116
117 G4double ee = G4Log(emax/emin);
118 G4int nbin = G4lrint(ee*scale);
119 if(nbin < 4) { nbin = 4; }
120 G4double fact = G4Exp(ee/nbin);
121
122 for (size_t i=0; i<n; ++i) {
123 auto mat = (*theMatTable)[i];
124 G4double e = emin/fact;
125
126 G4double xs = 0.0;
127 e1peak = e1deep = e2peak = e2deep = e3peak = DBL_MAX;
128 for(G4int j=0; j<=nbin; ++j) {
129 e = (j+1 < nbin) ? e*fact : emax;
130 G4double ss = p->ComputeCrossSection(part, mat, e);
131 // find out 1st peak
132 if(e1peak == DBL_MAX) {
133 if(ss >= xs) {
134 xs = ss;
135 ee = e;
136 continue;
137 } else {
138 e1peak = ee;
139 }
140 }
141 // find out the deep
142 if(e1deep == DBL_MAX) {
143 if(ss <= xs) {
144 xs = ss;
145 ee = e;
146 continue;
147 } else {
148 e1deep = ee;
149 isDeep = true;
150 }
151 }
152 // find out 2nd peak
153 if(e2peak == DBL_MAX) {
154 if(ss >= xs) {
155 xs = ss;
156 ee = e;
157 continue;
158 } else {
159 e2peak = ee;
160 }
161 }
162 if(e2deep == DBL_MAX) {
163 if(ss <= xs) {
164 xs = ss;
165 ee = e;
166 continue;
167 } else {
168 e2deep = ee;
169 break;
170 }
171 }
172 // find out 3d peak
173 if(e3peak == DBL_MAX) {
174 if(ss >= xs) {
175 xs = ss;
176 ee = e;
177 continue;
178 } else {
179 e3peak = ee;
180 }
181 }
182 }
183 G4TwoPeaksHadXS* x = (*ptr)[i];
184 if(nullptr == x) {
185 x = new G4TwoPeaksHadXS();
186 (*ptr)[i] = x;
187 }
188 x->e1peak = e1peak;
189 x->e1deep = e1deep;
190 x->e2peak = e2peak;
191 x->e2deep = e2deep;
192 x->e3peak = e3peak;
193 //G4cout << "coupleIdx=" << i << " " << e1peak << " " << e1deep
194 // << " " << e2peak << " " << e2deep << " " << e3peak << G4endl;
195 }
196 // case of no 1st peak in all vectors
197 if(!isDeep) {
198 for (auto& x : *ptr) {
199 delete x;
200 }
201 delete ptr;
202 ptr = nullptr;
203 }
204 return ptr;
205}
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition G4Exp.hh:180
G4double G4Log(G4double x)
Definition G4Log.hh:227
std::vector< G4Material * > G4MaterialTable
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4double ComputeCrossSection(const G4ParticleDefinition *, const G4Material *, const G4double kinEnergy)
static std::size_t GetNumberOfMaterials()
static G4MaterialTable * GetMaterialTable()
int G4lrint(double ad)
Definition templates.hh:134
#define DBL_MAX
Definition templates.hh:62

Referenced by G4HadronicProcess::BuildPhysicsTable().

◆ FindCrossSectionMax()

std::vector< G4double > * G4HadXSHelper::FindCrossSectionMax ( G4HadronicProcess * p,
const G4ParticleDefinition * part,
const G4double tmin,
const G4double tmax )
static

Definition at line 43 of file G4HadXSHelper.cc.

47{
48 std::vector<G4double>* ptr = nullptr;
49 if(nullptr == p || nullptr == part) { return ptr; }
50 /*
51 G4cout << "G4HadXSHelper::FindCrossSectionMax for "
52 << p->GetProcessName() << " and " << part->GetParticleName() << G4endl;
53 */
54
55 const G4MaterialTable* theMatTable = G4Material::GetMaterialTable();
57 ptr = new std::vector<G4double>;
58 ptr->resize(n, DBL_MAX);
59
60 G4bool isPeak = false;
61 G4double ee = G4Log(emax/emin);
62 G4int nbin = G4lrint(ee*scale);
63 if(nbin < 4) { nbin = 4; }
64 G4double x = G4Exp(ee/nbin);
65
66 // first loop on existing vectors
67 for (size_t i=0; i<n; ++i) {
68 auto mat = (*theMatTable)[i];
69 G4double sm = 0.0;
70 G4double em = 0.0;
71 G4double e = emin;
72 for(G4int j=0; j<=nbin; ++j) {
73 G4double sig = p->ComputeCrossSection(part, mat, e);
74 if(sig >= sm) {
75 em = e;
76 sm = sig;
77 e = (j+1 < nbin) ? e*x : emax;
78 } else {
79 isPeak = true;
80 (*ptr)[i] = em;
81 break;
82 }
83 }
84 //G4cout << i << ". em=" << em << " sm=" << sm << G4endl;
85 }
86 // there is no peak for any couple
87 if(!isPeak) {
88 delete ptr;
89 ptr = nullptr;
90 }
91 return ptr;
92}

Referenced by G4HadronicProcess::BuildPhysicsTable().


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