Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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