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 | // |
---|
26 | // neutron_hp -- source file |
---|
27 | // J.P. Wellisch, Nov-1996 |
---|
28 | // A prototype of the low energy neutron transport model. |
---|
29 | // |
---|
30 | // 070523 bug fix for G4FPE_DEBUG on by A. Howard ( and T. Koi) |
---|
31 | // |
---|
32 | #include "G4NeutronHPCapture.hh" |
---|
33 | #include "G4NeutronHPCaptureFS.hh" |
---|
34 | #include "G4NeutronHPDeExGammas.hh" |
---|
35 | #include "G4ParticleTable.hh" |
---|
36 | #include "G4IonTable.hh" |
---|
37 | |
---|
38 | G4NeutronHPCapture::G4NeutronHPCapture() |
---|
39 | :G4HadronicInteraction("NeutronHPCapture") |
---|
40 | { |
---|
41 | SetMinEnergy( 0.0 ); |
---|
42 | SetMaxEnergy( 20.*MeV ); |
---|
43 | // G4cout << "Capture : start of construction!!!!!!!!"<<G4endl; |
---|
44 | if(!getenv("G4NEUTRONHPDATA")) |
---|
45 | throw G4HadronicException(__FILE__, __LINE__, "Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files."); |
---|
46 | dirName = getenv("G4NEUTRONHPDATA"); |
---|
47 | G4String tString = "/Capture/"; |
---|
48 | dirName = dirName + tString; |
---|
49 | numEle = G4Element::GetNumberOfElements(); |
---|
50 | // G4cout << "+++++++++++++++++++++++++++++++++++++++++++++++++"<<G4endl; |
---|
51 | // G4cout <<"Disname="<<dirName<<" numEle="<<numEle<<G4endl; |
---|
52 | theCapture = new G4NeutronHPChannel[numEle]; |
---|
53 | // G4cout <<"G4NeutronHPChannel constructed"<<G4endl; |
---|
54 | G4NeutronHPCaptureFS * theFS = new G4NeutronHPCaptureFS; |
---|
55 | for (G4int i=0; i<numEle; i++) |
---|
56 | { |
---|
57 | // G4cout << "initializing theCapture "<<i<<" "<< numEle<<G4endl; |
---|
58 | theCapture[i].Init((*(G4Element::GetElementTable()))[i], dirName); |
---|
59 | theCapture[i].Register(theFS); |
---|
60 | } |
---|
61 | delete theFS; |
---|
62 | // G4cout << "-------------------------------------------------"<<G4endl; |
---|
63 | // G4cout << "Leaving G4NeutronHPCapture::G4NeutronHPCapture"<<G4endl; |
---|
64 | } |
---|
65 | |
---|
66 | G4NeutronHPCapture::~G4NeutronHPCapture() |
---|
67 | { |
---|
68 | delete [] theCapture; |
---|
69 | // G4cout << "Leaving G4NeutronHPCapture::~G4NeutronHPCapture"<<G4endl; |
---|
70 | } |
---|
71 | |
---|
72 | #include "G4NeutronHPThermalBoost.hh" |
---|
73 | G4HadFinalState * G4NeutronHPCapture::ApplyYourself(const G4HadProjectile& aTrack, G4Nucleus& ) |
---|
74 | { |
---|
75 | if(getenv("NeutronHPCapture")) G4cout <<" ####### G4NeutronHPCapture called"<<G4endl; |
---|
76 | const G4Material * theMaterial = aTrack.GetMaterial(); |
---|
77 | G4int n = theMaterial->GetNumberOfElements(); |
---|
78 | G4int index = theMaterial->GetElement(0)->GetIndex(); |
---|
79 | if(n!=1) |
---|
80 | { |
---|
81 | xSec = new G4double[n]; |
---|
82 | G4double sum=0; |
---|
83 | G4int i; |
---|
84 | const G4double * NumAtomsPerVolume = theMaterial->GetVecNbOfAtomsPerVolume(); |
---|
85 | G4double rWeight; |
---|
86 | G4NeutronHPThermalBoost aThermalE; |
---|
87 | for (i=0; i<n; i++) |
---|
88 | { |
---|
89 | index = theMaterial->GetElement(i)->GetIndex(); |
---|
90 | rWeight = NumAtomsPerVolume[i]; |
---|
91 | xSec[i] = theCapture[index].GetXsec(aThermalE.GetThermalEnergy(aTrack, |
---|
92 | theMaterial->GetElement(i), |
---|
93 | theMaterial->GetTemperature())); |
---|
94 | xSec[i] *= rWeight; |
---|
95 | sum+=xSec[i]; |
---|
96 | } |
---|
97 | G4double random = G4UniformRand(); |
---|
98 | G4double running = 0; |
---|
99 | for (i=0; i<n; i++) |
---|
100 | { |
---|
101 | running += xSec[i]; |
---|
102 | index = theMaterial->GetElement(i)->GetIndex(); |
---|
103 | //if(random<=running/sum) break; |
---|
104 | if( sum == 0 || random <= running/sum ) break; |
---|
105 | } |
---|
106 | if(i==n) i=std::max(0, n-1); |
---|
107 | delete [] xSec; |
---|
108 | } |
---|
109 | return theCapture[index].ApplyYourself(aTrack); |
---|
110 | } |
---|