Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
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 60 of file G4CrossSectionDataStore.hh.

Constructor & Destructor Documentation

G4CrossSectionDataStore::G4CrossSectionDataStore ( )

Definition at line 62 of file G4CrossSectionDataStore.cc.

References G4NistManager::Instance().

62  :
63  nDataSetList(0), verboseLevel(0)
64 {
65  nist = G4NistManager::Instance();
66  currentMaterial = elmMaterial = 0;
67  currentElement = 0; //ALB 14-Aug-2012 Coverity fix.
68  matParticle = elmParticle = 0;
69  matKinEnergy = elmKinEnergy = matCrossSection = elmCrossSection = 0.0;
70 }
static G4NistManager * Instance()
G4CrossSectionDataStore::~G4CrossSectionDataStore ( )

Definition at line 74 of file G4CrossSectionDataStore.cc.

75 {}

Member Function Documentation

void G4CrossSectionDataStore::AddDataSet ( G4VCrossSectionDataSet p)
inline
void G4CrossSectionDataStore::BuildPhysicsTable ( const G4ParticleDefinition aParticleType)

Definition at line 334 of file G4CrossSectionDataStore.cc.

Referenced by G4HadronicProcess::BuildPhysicsTable().

335 {
336  if (nDataSetList == 0)
337  {
338  throw G4HadronicException(__FILE__, __LINE__,
339  "G4CrossSectionDataStore: no data sets registered");
340  return;
341  }
342  for (G4int i=0; i<nDataSetList; ++i) {
343  dataSetList[i]->BuildPhysicsTable(aParticleType);
344  }
345 }
int G4int
Definition: G4Types.hh:78
void G4CrossSectionDataStore::DumpHtml ( const G4ParticleDefinition ,
std::ofstream &  outFile 
)

Definition at line 377 of file G4CrossSectionDataStore.cc.

References python.hepunit::GeV.

Referenced by G4HadronicProcessStore::PrintHtml().

379 {
380  // Write cross section data set info to html physics list
381  // documentation page
382 
383  G4double ehi = 0;
384  G4double elo = 0;
385  for (G4int i = nDataSetList-1; i > 0; i--) {
386  elo = dataSetList[i]->GetMinKinEnergy()/GeV;
387  ehi = dataSetList[i]->GetMaxKinEnergy()/GeV;
388  outFile << " <li><b><a href=\"" << dataSetList[i]->GetName() << ".html\"> "
389  << dataSetList[i]->GetName() << "</a> from "
390  << elo << " GeV to " << ehi << " GeV </b></li>\n";
391  }
392 
393  G4double defaultHi = dataSetList[0]->GetMaxKinEnergy()/GeV;
394  if (ehi < defaultHi) {
395  outFile << " <li><b><a href=\"" << dataSetList[0]->GetName() << ".html\"> "
396  << dataSetList[0]->GetName() << "</a> from "
397  << ehi << " GeV to " << defaultHi << " GeV </b></li>\n";
398  }
399 }
std::ofstream outFile
Definition: GammaRayTel.cc:68
int G4int
Definition: G4Types.hh:78
double G4double
Definition: G4Types.hh:76
void G4CrossSectionDataStore::DumpPhysicsTable ( const G4ParticleDefinition aParticleType)

Definition at line 350 of file G4CrossSectionDataStore.cc.

References G4BestUnit, G4cout, and G4endl.

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

351 {
352  // Print out all cross section data sets used and the energies at
353  // which they apply
354 
355  if (nDataSetList == 0) {
356  G4cout << "WARNING - G4CrossSectionDataStore::DumpPhysicsTable: "
357  << " no data sets registered" << G4endl;
358  return;
359  }
360 
361  for (G4int i = nDataSetList-1; i >= 0; --i) {
362  G4double e1 = dataSetList[i]->GetMinKinEnergy();
363  G4double e2 = dataSetList[i]->GetMaxKinEnergy();
364  G4cout
365  << " Cr_sctns: " << std::setw(25) << dataSetList[i]->GetName() << ": "
366  << G4BestUnit(e1, "Energy")
367  << " ---> "
368  << G4BestUnit(e2, "Energy") << "\n";
369  if (dataSetList[i]->GetName() == "G4CrossSectionPairGG") {
370  dataSetList[i]->DumpPhysicsTable(aParticleType);
371  }
372  }
373 }
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4double G4CrossSectionDataStore::GetCrossSection ( const G4DynamicParticle part,
const G4Material mat 
)

Definition at line 80 of file G4CrossSectionDataStore.cc.

References G4DynamicParticle::GetDefinition(), G4Material::GetElementVector(), G4DynamicParticle::GetKineticEnergy(), G4Material::GetNumberOfElements(), and G4Material::GetVecNbOfAtomsPerVolume().

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

82 {
83  if(mat == currentMaterial && part->GetDefinition() == matParticle
84  && part->GetKineticEnergy() == matKinEnergy)
85  { return matCrossSection; }
86 
87  currentMaterial = mat;
88  matParticle = part->GetDefinition();
89  matKinEnergy = part->GetKineticEnergy();
90  matCrossSection = 0;
91 
92  G4int nElements = mat->GetNumberOfElements();
93  const G4double* nAtomsPerVolume = mat->GetVecNbOfAtomsPerVolume();
94 
95  if(G4int(xsecelm.size()) < nElements) { xsecelm.resize(nElements); }
96 
97  for(G4int i=0; i<nElements; ++i) {
98  matCrossSection += nAtomsPerVolume[i] *
99  GetCrossSection(part, (*mat->GetElementVector())[i], mat);
100  xsecelm[i] = matCrossSection;
101  }
102  return matCrossSection;
103 }
G4double GetKineticEnergy() const
G4ParticleDefinition * GetDefinition() const
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:188
int G4int
Definition: G4Types.hh:78
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:204
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
size_t GetNumberOfElements() const
Definition: G4Material.hh:184
double G4double
Definition: G4Types.hh:76
G4double G4CrossSectionDataStore::GetCrossSection ( const G4DynamicParticle part,
const G4Element elm,
const G4Material mat 
)

Definition at line 108 of file G4CrossSectionDataStore.cc.

References G4lrint(), G4DynamicParticle::GetDefinition(), G4Element::GetIsotopeVector(), G4DynamicParticle::GetKineticEnergy(), G4Isotope::GetN(), G4Element::GetNaturalAbundanceFlag(), G4Element::GetNumberOfIsotopes(), G4Element::GetRelativeAbundanceVector(), and G4Element::GetZ().

111 {
112  if(mat == elmMaterial && elm == currentElement &&
113  part->GetDefinition() == elmParticle &&
114  part->GetKineticEnergy() == elmKinEnergy)
115  { return elmCrossSection; }
116 
117  elmMaterial = mat;
118  currentElement = elm;
119  elmParticle = part->GetDefinition();
120  elmKinEnergy = part->GetKineticEnergy();
121  elmCrossSection = 0.0;
122 
123  G4int i = nDataSetList-1;
124  G4int Z = G4lrint(elm->GetZ());
125  if (elm->GetNaturalAbundanceFlag() &&
126  dataSetList[i]->IsElementApplicable(part, Z, mat)) {
127 
128  // element wise cross section
129  elmCrossSection = dataSetList[i]->GetElementCrossSection(part, Z, mat);
130 
131  //G4cout << "Element wise " << elmParticle->GetParticleName()
132  // << " xsec(barn)= " << elmCrossSection/barn
133  // << " E(MeV)= " << elmKinEnergy/MeV
134  // << " Z= " << Z << " AbundFlag= " << elm->GetNaturalAbandancesFlag()
135  // <<G4endl;
136 
137  } else {
138  // isotope wise cross section
139  G4int nIso = elm->GetNumberOfIsotopes();
140  G4Isotope* iso = 0;
141 
142  // user-defined isotope abundances
143  G4IsotopeVector* isoVector = elm->GetIsotopeVector();
144  G4double* abundVector = elm->GetRelativeAbundanceVector();
145 
146  for (G4int j = 0; j<nIso; ++j) {
147  if(abundVector[j] > 0.0) {
148  iso = (*isoVector)[j];
149  elmCrossSection += abundVector[j]*
150  GetIsoCrossSection(part, Z, iso->GetN(), iso, elm, mat, i);
151  //G4cout << "Isotope wise " << elmParticle->GetParticleName()
152  // << " xsec(barn)= " << elmCrossSection/barn
153  // << " E(MeV)= " << elmKinEnergy/MeV
154  // << " Z= " << Z << " A= " << iso->GetN() << " j= " << j << G4endl;
155  }
156  }
157  }
158  //G4cout << " E(MeV)= " << elmKinEnergy/MeV
159  // << "xsec(barn)= " << elmCrossSection/barn <<G4endl;
160  return elmCrossSection;
161 }
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:158
G4bool GetNaturalAbundanceFlag() const
Definition: G4Element.hh:263
std::vector< G4Isotope * > G4IsotopeVector
G4double GetKineticEnergy() const
G4double GetZ() const
Definition: G4Element.hh:131
G4ParticleDefinition * GetDefinition() const
int G4int
Definition: G4Types.hh:78
G4int GetN() const
Definition: G4Isotope.hh:94
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:166
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:162
int G4lrint(double ad)
Definition: templates.hh:163
double G4double
Definition: G4Types.hh:76
G4double G4CrossSectionDataStore::GetCrossSection ( const G4DynamicParticle part,
G4int  Z,
G4int  A,
const G4Isotope iso,
const G4Element elm,
const G4Material mat 
)

Definition at line 207 of file G4CrossSectionDataStore.cc.

References G4cout, G4endl, G4DynamicParticle::GetDefinition(), G4DynamicParticle::GetKineticEnergy(), G4Element::GetName(), G4Material::GetName(), G4ParticleDefinition::GetParticleName(), and python.hepunit::MeV.

212 {
213  for (G4int i = nDataSetList-1; i >= 0; --i) {
214  if (dataSetList[i]->IsIsoApplicable(part, Z, A, elm, mat) ) {
215  return dataSetList[i]->GetIsoCrossSection(part, Z, A, iso, elm, mat);
216  }
217  }
218  G4cout << "G4CrossSectionDataStore::GetCrossSection ERROR: "
219  << " no isotope cross section found"
220  << G4endl;
221  G4cout << " for " << part->GetDefinition()->GetParticleName()
222  << " off Element " << elm->GetName()
223  << " in " << mat->GetName()
224  << " Z= " << Z << " A= " << A
225  << " E(MeV)= " << part->GetKineticEnergy()/MeV << G4endl;
226  throw G4HadronicException(__FILE__, __LINE__,
227  " no applicable data set found for the isotope");
228  return 0.0;
229 }
G4double GetKineticEnergy() const
const G4String & GetName() const
Definition: G4Material.hh:176
G4ParticleDefinition * GetDefinition() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
const G4String & GetName() const
Definition: G4Element.hh:127
G4Element * G4CrossSectionDataStore::SampleZandA ( const G4DynamicParticle part,
const G4Material mat,
G4Nucleus target 
)

Definition at line 234 of file G4CrossSectionDataStore.cc.

References G4cout, G4endl, G4lrint(), G4UniformRand, GetCrossSection(), G4Material::GetElementVector(), G4Element::GetIsotopeVector(), G4DynamicParticle::GetKineticEnergy(), G4Element::GetName(), G4Material::GetNumberOfElements(), G4Element::GetNumberOfIsotopes(), G4Element::GetRelativeAbundanceVector(), G4Element::GetZ(), and G4Nucleus::SetIsotope().

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

237 {
238  G4int nElements = mat->GetNumberOfElements();
239  const G4ElementVector* theElementVector = mat->GetElementVector();
240  G4Element* anElement = (*theElementVector)[0];
241 
242  G4double cross = GetCrossSection(part, mat);
243 
244  // select element from a compound
245  if(1 < nElements) {
246  cross *= G4UniformRand();
247  for(G4int i=0; i<nElements; ++i) {
248  if(cross <= xsecelm[i]) {
249  anElement = (*theElementVector)[i];
250  break;
251  }
252  }
253  }
254 
255  G4int Z = G4lrint(anElement->GetZ());
256  G4Isotope* iso = 0;
257 
258  G4int i = nDataSetList-1;
259  if (dataSetList[i]->IsElementApplicable(part, Z, mat)) {
260 
261  //----------------------------------------------------------------
262  // element-wise cross section
263  // isotope cross section is not computed
264  //----------------------------------------------------------------
265  G4int nIso = anElement->GetNumberOfIsotopes();
266  if (0 >= nIso) {
267  G4cout << " Element " << anElement->GetName() << " Z= " << Z
268  << " has no isotopes " << G4endl;
269  throw G4HadronicException(__FILE__, __LINE__,
270  " Isotope vector is not defined");
271  return anElement;
272  }
273  // isotope abundances
274  G4IsotopeVector* isoVector = anElement->GetIsotopeVector();
275  iso = (*isoVector)[0];
276 
277  // more than 1 isotope
278  if(1 < nIso) {
279  iso = dataSetList[i]->SelectIsotope(anElement, part->GetKineticEnergy());
280  }
281 
282  } else {
283 
284  //----------------------------------------------------------------
285  // isotope-wise cross section
286  // isotope cross section is computed
287  //----------------------------------------------------------------
288  G4int nIso = anElement->GetNumberOfIsotopes();
289  cross = 0.0;
290 
291  if (0 >= nIso) {
292  G4cout << " Element " << anElement->GetName() << " Z= " << Z
293  << " has no isotopes " << G4endl;
294  throw G4HadronicException(__FILE__, __LINE__,
295  " Isotope vector is not defined");
296  return anElement;
297  }
298 
299  // user-defined isotope abundances
300  G4IsotopeVector* isoVector = anElement->GetIsotopeVector();
301  iso = (*isoVector)[0];
302 
303  // more than 1 isotope
304  if(1 < nIso) {
305  G4double* abundVector = anElement->GetRelativeAbundanceVector();
306  if(G4int(xseciso.size()) < nIso) { xseciso.resize(nIso); }
307 
308  for (G4int j = 0; j<nIso; ++j) {
309  G4double xsec = 0.0;
310  if(abundVector[j] > 0.0) {
311  iso = (*isoVector)[j];
312  xsec = abundVector[j]*
313  GetIsoCrossSection(part, Z, iso->GetN(), iso, anElement, mat, i);
314  }
315  cross += xsec;
316  xseciso[j] = cross;
317  }
318  cross *= G4UniformRand();
319  for (G4int j = 0; j<nIso; ++j) {
320  if(cross <= xseciso[j]) {
321  iso = (*isoVector)[j];
322  break;
323  }
324  }
325  }
326  }
327  target.SetIsotope(iso);
328  return anElement;
329 }
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:158
void SetIsotope(const G4Isotope *iso)
Definition: G4Nucleus.hh:122
std::vector< G4Isotope * > G4IsotopeVector
std::vector< G4Element * > G4ElementVector
G4double GetKineticEnergy() const
G4double GetZ() const
Definition: G4Element.hh:131
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:188
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:87
G4GLOB_DLL std::ostream G4cout
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:166
G4IsotopeVector * GetIsotopeVector() const
Definition: G4Element.hh:162
int G4lrint(double ad)
Definition: templates.hh:163
#define G4endl
Definition: G4ios.hh:61
size_t GetNumberOfElements() const
Definition: G4Material.hh:184
double G4double
Definition: G4Types.hh:76
const G4String & GetName() const
Definition: G4Element.hh:127
void G4CrossSectionDataStore::SetVerboseLevel ( G4int  value)
inline

Definition at line 134 of file G4CrossSectionDataStore.hh.

135 {
136  verboseLevel = value;
137 }
const XML_Char int const XML_Char * value

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