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

#include <G4CrossSectionDataStore.hh>

Public Member Functions

 G4CrossSectionDataStore ()
 
 ~G4CrossSectionDataStore ()
 
G4double GetCrossSection (const G4DynamicParticle *, const G4Material *)
 
G4double GetCrossSection (const G4DynamicParticle *, const G4Element *, const G4Material *)
 
G4double GetCrossSection (const G4DynamicParticle *, G4int Z, G4int A, const G4Isotope *, const G4Element *, const G4Material *)
 
G4ElementSampleZandA (const G4DynamicParticle *, const G4Material *, G4Nucleus &target)
 
void BuildPhysicsTable (const G4ParticleDefinition &)
 
void DumpPhysicsTable (const G4ParticleDefinition &)
 
void DumpHtml (const G4ParticleDefinition &, std::ofstream &)
 
void AddDataSet (G4VCrossSectionDataSet *)
 
void SetVerboseLevel (G4int value)
 

Detailed Description

Definition at line 61 of file G4CrossSectionDataStore.hh.

Constructor & Destructor Documentation

◆ G4CrossSectionDataStore()

G4CrossSectionDataStore::G4CrossSectionDataStore ( )

Definition at line 57 of file G4CrossSectionDataStore.cc.

57 :
58 nDataSetList(0), verboseLevel(0)
59{
61 currentMaterial = elmMaterial = 0;
62 currentElement = 0; //ALB 14-Aug-2012 Coverity fix.
63 matParticle = elmParticle = 0;
64 matKinEnergy = elmKinEnergy = matCrossSection = elmCrossSection = 0.0;
65}
static G4NistManager * Instance()

◆ ~G4CrossSectionDataStore()

G4CrossSectionDataStore::~G4CrossSectionDataStore ( )

Definition at line 67 of file G4CrossSectionDataStore.cc.

68{}

Member Function Documentation

◆ AddDataSet()

void G4CrossSectionDataStore::AddDataSet ( G4VCrossSectionDataSet p)
inline

◆ BuildPhysicsTable()

void G4CrossSectionDataStore::BuildPhysicsTable ( const G4ParticleDefinition aParticleType)

Definition at line 313 of file G4CrossSectionDataStore.cc.

314{
315 if (nDataSetList == 0)
316 {
317 throw G4HadronicException(__FILE__, __LINE__,
318 "G4CrossSectionDataStore: no data sets registered");
319 return;
320 }
321 for (G4int i=0; i<nDataSetList; ++i) {
322 dataSetList[i]->BuildPhysicsTable(aParticleType);
323 }
324}
int G4int
Definition: G4Types.hh:66

Referenced by G4HadronicProcess::BuildPhysicsTable().

◆ DumpHtml()

void G4CrossSectionDataStore::DumpHtml ( const G4ParticleDefinition ,
std::ofstream &  outFile 
)

Definition at line 353 of file G4CrossSectionDataStore.cc.

355{
356 // Write cross section data set info to html physics list
357 // documentation page
358
359 G4double ehi = 0;
360 G4double elo = 0;
361 for (G4int i = nDataSetList-1; i > 0; i--) {
362 elo = dataSetList[i]->GetMinKinEnergy()/GeV;
363 ehi = dataSetList[i]->GetMaxKinEnergy()/GeV;
364 outFile << " <li><b><a href=\"" << dataSetList[i]->GetName() << ".html\"> "
365 << dataSetList[i]->GetName() << "</a> from "
366 << elo << " GeV to " << ehi << " GeV </b></li>\n";
367 }
368
369 G4double defaultHi = dataSetList[0]->GetMaxKinEnergy()/GeV;
370 if (ehi < defaultHi) {
371 outFile << " <li><b><a href=\"" << dataSetList[0]->GetName() << ".html\"> "
372 << dataSetList[0]->GetName() << "</a> from "
373 << ehi << " GeV to " << defaultHi << " GeV </b></li>\n";
374 }
375}
double G4double
Definition: G4Types.hh:64

Referenced by G4HadronicProcessStore::PrintHtml().

◆ DumpPhysicsTable()

void G4CrossSectionDataStore::DumpPhysicsTable ( const G4ParticleDefinition aParticleType)

Definition at line 327 of file G4CrossSectionDataStore.cc.

328{
329 // Print out all cross section data sets used and the energies at
330 // which they apply
331
332 if (nDataSetList == 0) {
333 G4cout << "WARNING - G4CrossSectionDataStore::DumpPhysicsTable: "
334 << " no data sets registered" << G4endl;
335 return;
336 }
337
338 for (G4int i = nDataSetList-1; i >= 0; --i) {
339 G4double e1 = dataSetList[i]->GetMinKinEnergy();
340 G4double e2 = dataSetList[i]->GetMaxKinEnergy();
341 if (i < nDataSetList-1) { G4cout << " "; }
342 G4cout << std::setw(25) << dataSetList[i]->GetName() << ": Emin(GeV)= "
343 << std::setw(4) << e1/GeV << " Emax(GeV)= "
344 << e2/GeV << G4endl;
345 if (dataSetList[i]->GetName() == "G4CrossSectionPairGG") {
346 dataSetList[i]->DumpPhysicsTable(aParticleType);
347 }
348 }
349
350 G4cout << G4endl;
351}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout

Referenced by G4ChargeExchangeProcess::DumpPhysicsTable(), and G4HadronicProcess::DumpPhysicsTable().

◆ GetCrossSection() [1/3]

G4double G4CrossSectionDataStore::GetCrossSection ( const G4DynamicParticle part,
const G4Element elm,
const G4Material mat 
)

Definition at line 97 of file G4CrossSectionDataStore.cc.

100{
101 if(mat == elmMaterial && elm == currentElement &&
102 part->GetDefinition() == elmParticle &&
103 part->GetKineticEnergy() == elmKinEnergy)
104 { return elmCrossSection; }
105
106 elmMaterial = mat;
107 currentElement = elm;
108 elmParticle = part->GetDefinition();
109 elmKinEnergy = part->GetKineticEnergy();
110 elmCrossSection = 0.0;
111
112 G4int i = nDataSetList-1;
113 G4int Z = G4lrint(elm->GetZ());
114 if (dataSetList[i]->IsElementApplicable(part, Z, mat)) {
115
116 // element wise cross section
117 elmCrossSection = dataSetList[i]->GetElementCrossSection(part, Z, mat);
118
119 } else {
120 // isotope wise cross section
121 G4int nIso = elm->GetNumberOfIsotopes();
122 G4Isotope* iso = 0;
123
124 if (0 >= nIso) {
125 G4cout << " Element " << elm->GetName() << " Z= " << Z
126 << " has no isotopes " << G4endl;
127 throw G4HadronicException(__FILE__, __LINE__,
128 " Isotope vector is not defined");
129 //ALB 14-Aug-2012 Coverity fix. return elmCrossSection;
130 }
131 // user-defined isotope abundances
132 G4IsotopeVector* isoVector = elm->GetIsotopeVector();
133 G4double* abundVector = elm->GetRelativeAbundanceVector();
134
135 for (G4int j = 0; j<nIso; ++j) {
136 if(abundVector[j] > 0.0) {
137 iso = (*isoVector)[j];
138 elmCrossSection += abundVector[j]*
139 GetIsoCrossSection(part, Z, iso->GetN(), iso, elm, mat, i);
140 }
141 }
142 }
143 //G4cout << "xsec(barn)= " << xsec/barn << G4endl;
144 return elmCrossSection;
145}
std::vector< G4Isotope * > G4IsotopeVector
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:166
G4double GetZ() const
Definition: G4Element.hh:131
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:158
const G4String & GetName() const
Definition: G4Element.hh:127
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:162
G4int GetN() const
Definition: G4Isotope.hh:94
int G4lrint(double ad)
Definition: templates.hh:163

◆ GetCrossSection() [2/3]

G4double G4CrossSectionDataStore::GetCrossSection ( const G4DynamicParticle part,
const G4Material mat 
)

Definition at line 71 of file G4CrossSectionDataStore.cc.

73{
74 if(mat == currentMaterial && part->GetDefinition() == matParticle
75 && part->GetKineticEnergy() == matKinEnergy)
76 { return matCrossSection; }
77
78 currentMaterial = mat;
79 matParticle = part->GetDefinition();
80 matKinEnergy = part->GetKineticEnergy();
81 matCrossSection = 0;
82
83 G4int nElements = mat->GetNumberOfElements();
84 const G4double* nAtomsPerVolume = mat->GetVecNbOfAtomsPerVolume();
85
86 if(G4int(xsecelm.size()) < nElements) { xsecelm.resize(nElements); }
87
88 for(G4int i=0; i<nElements; ++i) {
89 matCrossSection += nAtomsPerVolume[i] *
90 GetCrossSection(part, (*mat->GetElementVector())[i], mat);
91 xsecelm[i] = matCrossSection;
92 }
93 return matCrossSection;
94}
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:189
size_t GetNumberOfElements() const
Definition: G4Material.hh:185
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:205

Referenced by GetCrossSection(), G4ChargeExchangeProcess::GetElementCrossSection(), G4HadronicProcess::GetElementCrossSection(), G4HadronicProcess::GetMeanFreePath(), and SampleZandA().

◆ GetCrossSection() [3/3]

G4double G4CrossSectionDataStore::GetCrossSection ( const G4DynamicParticle part,
G4int  Z,
G4int  A,
const G4Isotope iso,
const G4Element elm,
const G4Material mat 
)

Definition at line 187 of file G4CrossSectionDataStore.cc.

192{
193 for (G4int i = nDataSetList-1; i >= 0; --i) {
194 if (dataSetList[i]->IsIsoApplicable(part, Z, A, elm, mat) ) {
195 return dataSetList[i]->GetIsoCrossSection(part, Z, A, iso, elm, mat);
196 }
197 }
198 G4cout << "G4CrossSectionDataStore::GetCrossSection ERROR: "
199 << " no isotope cross section found"
200 << G4endl;
201 G4cout << " for " << part->GetDefinition()->GetParticleName()
202 << " off Element " << elm->GetName()
203 << " in " << mat->GetName()
204 << " Z= " << Z << " A= " << A
205 << " E(MeV)= " << part->GetKineticEnergy()/MeV << G4endl;
206 throw G4HadronicException(__FILE__, __LINE__,
207 " no applicable data set found for the isotope");
208 return 0.0;
209}
const G4String & GetName() const
Definition: G4Material.hh:177
const G4String & GetParticleName() const

◆ SampleZandA()

G4Element * G4CrossSectionDataStore::SampleZandA ( const G4DynamicParticle part,
const G4Material mat,
G4Nucleus target 
)

Definition at line 212 of file G4CrossSectionDataStore.cc.

215{
216 G4int nElements = mat->GetNumberOfElements();
217 const G4ElementVector* theElementVector = mat->GetElementVector();
218 G4Element* anElement = (*theElementVector)[0];
219
220 G4double cross = GetCrossSection(part, mat);
221
222 // zero cross section case
223 if(0.0 >= cross) { return anElement; }
224
225 // select element from a compound
226 if(1 < nElements) {
227 cross *= G4UniformRand();
228 for(G4int i=0; i<nElements; ++i) {
229 if(cross <= xsecelm[i]) {
230 anElement = (*theElementVector)[i];
231 break;
232 }
233 }
234 }
235
236 G4int Z = G4lrint(anElement->GetZ());
237 G4Isotope* iso = 0;
238
239 G4int i = nDataSetList-1;
240 if (dataSetList[i]->IsElementApplicable(part, Z, mat)) {
241
242 //----------------------------------------------------------------
243 // element-wise cross section
244 // isotope cross section is not computed
245 //----------------------------------------------------------------
246 G4int nIso = anElement->GetNumberOfIsotopes();
247 if (0 >= nIso) {
248 G4cout << " Element " << anElement->GetName() << " Z= " << Z
249 << " has no isotopes " << G4endl;
250 throw G4HadronicException(__FILE__, __LINE__,
251 " Isotope vector is not defined");
252 return anElement;
253 }
254 // isotope abundances
255 G4IsotopeVector* isoVector = anElement->GetIsotopeVector();
256 iso = (*isoVector)[0];
257
258 // more than 1 isotope
259 if(1 < nIso) {
260 iso = dataSetList[i]->SelectIsotope(anElement, part->GetKineticEnergy());
261 }
262
263 } else {
264
265 //----------------------------------------------------------------
266 // isotope-wise cross section
267 // isotope cross section is computed
268 //----------------------------------------------------------------
269 G4int nIso = anElement->GetNumberOfIsotopes();
270 cross = 0.0;
271
272 if (0 >= nIso) {
273 G4cout << " Element " << anElement->GetName() << " Z= " << Z
274 << " has no isotopes " << G4endl;
275 throw G4HadronicException(__FILE__, __LINE__,
276 " Isotope vector is not defined");
277 return anElement;
278 }
279
280 // user-defined isotope abundances
281 G4IsotopeVector* isoVector = anElement->GetIsotopeVector();
282 iso = (*isoVector)[0];
283
284 // more than 1 isotope
285 if(1 < nIso) {
286 G4double* abundVector = anElement->GetRelativeAbundanceVector();
287 if(G4int(xseciso.size()) < nIso) { xseciso.resize(nIso); }
288
289 for (G4int j = 0; j<nIso; ++j) {
290 G4double xsec = 0.0;
291 if(abundVector[j] > 0.0) {
292 iso = (*isoVector)[j];
293 xsec = abundVector[j]*
294 GetIsoCrossSection(part, Z, iso->GetN(), iso, anElement, mat, i);
295 }
296 cross += xsec;
297 xseciso[j] = cross;
298 }
299 cross *= G4UniformRand();
300 for (G4int j = 0; j<nIso; ++j) {
301 if(cross <= xseciso[j]) {
302 iso = (*isoVector)[j];
303 break;
304 }
305 }
306 }
307 }
308 target.SetIsotope(iso);
309 return anElement;
310}
std::vector< G4Element * > G4ElementVector
#define G4UniformRand()
Definition: Randomize.hh:53
void SetIsotope(const G4Isotope *iso)
Definition: G4Nucleus.hh:122

Referenced by G4HadronicProcess::PostStepDoIt(), G4HadronElasticProcess::PostStepDoIt(), and G4WHadronElasticProcess::PostStepDoIt().

◆ SetVerboseLevel()

void G4CrossSectionDataStore::SetVerboseLevel ( G4int  value)
inline

Definition at line 135 of file G4CrossSectionDataStore.hh.

136{
137 verboseLevel = value;
138}

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