Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4NeutronIsotopeProduction.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
27#include "G4SystemOfUnits.hh"
28
30{
31 numberOfElements = G4Element::GetNumberOfElements();
32 theData = new G4ElementIsoCrossSections<G4NeutronIsoIsoCrossSections>* [numberOfElements];
33 for (G4int i = 0; i < numberOfElements; i++) {
35 if((*(G4Element::GetElementTable()))[i]->GetZ() > 9 &&
36 (*(G4Element::GetElementTable()))[i]->GetZ() < 84) {
37 // Workaround to be fixed in G4NeutronHPNames.
38 theData[i]->Init((*(G4Element::GetElementTable()))[i]);
39 }
40 }
41 G4cout << "WARNING: G4NeutronIsotopeProduction is deprecated and will be removed with Geant4 version 10"
42 << G4endl;
43}
44
45
47{
48 for (G4int i = 0; i < numberOfElements; i++) delete theData[i];
49 if (theData) delete [] theData;
50}
51
52
55 const G4Nucleus&)
56{
57 G4IsoResult* result = 0;
58 // is applicable?
59 if (aTrack->GetDefinition() != G4Neutron::Neutron()) return result;
60 G4double incidentKE = aTrack->GetKineticEnergy();
61 if (incidentKE > 100*MeV) return result;
62
63 // get the isotope
64 const G4Material* theMaterial = aTrack->GetMaterial();
65 G4int nEleInMat = theMaterial->GetNumberOfElements();
66 for (G4int check = 0; check < nEleInMat; check++) {
67 // Workaround to be fixed in G4NeutronHPNames
68 if (theMaterial->GetElement(check)->GetZ() < 10) return result;
69 // Workaround to be fixed in G4NeutronHPNames.
70 if (theMaterial->GetElement(check)->GetZ() > 83) return result;
71 }
72 G4int index(0);
73 G4double* xSec = new G4double[nEleInMat];
74 G4double sum = 0;
75
76 for (G4int i = 0; i < nEleInMat; i++) {
77 index = theMaterial->GetElement(i)->GetIndex();
78 xSec[i] = theData[index]->GetCrossSection(incidentKE);
79 sum += xSec[i];
80 }
81
82 G4double random = G4UniformRand();
83 G4double running = 0;
84
85 for (G4int i = 0; i < nEleInMat; i++) {
86 running += xSec[i];
87 index = theMaterial->GetElement(i)->GetIndex();
88 if (random <= running/sum) break;
89 }
90
91 delete [] xSec;
92 result = theData[index]->GetProductIsotope(incidentKE);
93 return result;
94}
95
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
#define G4UniformRand()
Definition: Randomize.hh:53
G4double GetCrossSection(G4double anEnergy)
G4IsoResult * GetProductIsotope(G4double anEnergy)
void Init(const G4Element *anElement)
G4double GetZ() const
Definition: G4Element.hh:131
static size_t GetNumberOfElements()
Definition: G4Element.cc:406
size_t GetIndex() const
Definition: G4Element.hh:182
static const G4ElementTable * GetElementTable()
Definition: G4Element.cc:399
const G4Material * GetMaterial() const
const G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4Element * GetElement(G4int iel) const
Definition: G4Material.hh:201
size_t GetNumberOfElements() const
Definition: G4Material.hh:185
G4IsoResult * GetIsotope(const G4HadProjectile *aTrack, const G4Nucleus &aNucleus)
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104