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 | // $Id: G4NeutronInelasticXS.cc,v 1.4 2010/06/03 11:50:21 vnivanch Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ |
---|
28 | // |
---|
29 | // ------------------------------------------------------------------- |
---|
30 | // |
---|
31 | // GEANT4 Class file |
---|
32 | // |
---|
33 | // |
---|
34 | // File name: G4NeutronInelasticXS |
---|
35 | // |
---|
36 | // Author Ivantchenko, Geant4, 3-Aug-09 |
---|
37 | // |
---|
38 | // Modifications: |
---|
39 | // |
---|
40 | |
---|
41 | #include "G4NeutronInelasticXS.hh" |
---|
42 | #include "G4Neutron.hh" |
---|
43 | #include "G4DynamicParticle.hh" |
---|
44 | #include "G4Element.hh" |
---|
45 | #include "G4ElementTable.hh" |
---|
46 | #include "G4PhysicsLogVector.hh" |
---|
47 | #include "G4PhysicsVector.hh" |
---|
48 | #include "G4GlauberGribovCrossSection.hh" |
---|
49 | #include "G4NistManager.hh" |
---|
50 | |
---|
51 | #include <iostream> |
---|
52 | #include <fstream> |
---|
53 | #include <sstream> |
---|
54 | using namespace std; |
---|
55 | |
---|
56 | G4NeutronInelasticXS::G4NeutronInelasticXS() |
---|
57 | { |
---|
58 | verboseLevel = 0; |
---|
59 | G4cout << "G4NeutronInelasticXS::G4NeutronInelasticXS: Initialise " << G4endl; |
---|
60 | for(G4int i=0; i<93; ++i) { |
---|
61 | data[i] = 0; |
---|
62 | coeff[i]= 1.0; |
---|
63 | } |
---|
64 | ggXsection = new G4GlauberGribovCrossSection(); |
---|
65 | isInitialized = false; |
---|
66 | } |
---|
67 | |
---|
68 | G4NeutronInelasticXS::~G4NeutronInelasticXS() |
---|
69 | { |
---|
70 | for(G4int i=0; i<92; ++i) { |
---|
71 | delete data[i]; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | G4bool |
---|
76 | G4NeutronInelasticXS::IsApplicable(const G4DynamicParticle*, |
---|
77 | const G4Element*) |
---|
78 | { |
---|
79 | return true; |
---|
80 | } |
---|
81 | |
---|
82 | G4bool |
---|
83 | G4NeutronInelasticXS::IsZAApplicable(const G4DynamicParticle*, |
---|
84 | G4double /*ZZ*/, G4double /*AA*/) |
---|
85 | { |
---|
86 | return false; |
---|
87 | } |
---|
88 | |
---|
89 | |
---|
90 | G4double |
---|
91 | G4NeutronInelasticXS::GetCrossSection(const G4DynamicParticle* aParticle, |
---|
92 | const G4Element* elm, |
---|
93 | G4double) |
---|
94 | { |
---|
95 | G4double xs = 0.0; |
---|
96 | G4double ekin = aParticle->GetKineticEnergy(); |
---|
97 | |
---|
98 | G4int Z = G4int(elm->GetZ()); |
---|
99 | G4PhysicsVector* pv = data[Z]; |
---|
100 | // G4cout << "G4NeutronInelasticXS::GetCrossSection e= " << ekin << " Z= " << Z << G4endl; |
---|
101 | |
---|
102 | // element was not initialised |
---|
103 | if(!pv) { |
---|
104 | Initialise(Z); |
---|
105 | pv = data[Z]; |
---|
106 | if(!pv) return xs; |
---|
107 | } |
---|
108 | |
---|
109 | G4double e1 = pv->Energy(0); |
---|
110 | if(ekin <= e1) return xs; |
---|
111 | |
---|
112 | G4int n = pv->GetVectorLength() - 1; |
---|
113 | G4double e2 = pv->Energy(n); |
---|
114 | if(ekin <= e2) { |
---|
115 | xs = pv->Value(ekin); |
---|
116 | } else { |
---|
117 | ggXsection->GetCrossSection(aParticle, elm); |
---|
118 | xs = coeff[Z]*ggXsection->GetInelasticGlauberGribovXsc(); |
---|
119 | } |
---|
120 | |
---|
121 | if(verboseLevel > 0){ |
---|
122 | G4cout << "ekin= " << ekin << ", XSinel= " << xs << G4endl; |
---|
123 | } |
---|
124 | return xs; |
---|
125 | } |
---|
126 | |
---|
127 | |
---|
128 | void |
---|
129 | G4NeutronInelasticXS::BuildPhysicsTable(const G4ParticleDefinition& p) |
---|
130 | { |
---|
131 | G4cout << "G4NeutronInelasticXS::BuildPhysicsTable: " << G4endl; |
---|
132 | G4cout << p.GetParticleName() << G4endl; |
---|
133 | if(p.GetParticleName() != "neutron") { |
---|
134 | return; |
---|
135 | } |
---|
136 | if(isInitialized) return; |
---|
137 | isInitialized = true; |
---|
138 | |
---|
139 | |
---|
140 | // check environment variable |
---|
141 | // Build the complete string identifying the file with the data set |
---|
142 | char* path = getenv("G4NEUTRONXSDATA"); |
---|
143 | if (!path){ |
---|
144 | G4cout << "G4NEUTRONXSDATA environment variable not set" << G4endl; |
---|
145 | } |
---|
146 | |
---|
147 | G4DynamicParticle* dynParticle = |
---|
148 | new G4DynamicParticle(G4Neutron::Neutron(),G4ThreeVector(1,0,0),1); |
---|
149 | |
---|
150 | // Access to elements |
---|
151 | const G4ElementTable* theElmTable = G4Element::GetElementTable(); |
---|
152 | size_t numOfElm = G4Element::GetNumberOfElements(); |
---|
153 | if(numOfElm > 0) { |
---|
154 | for(size_t i=0; i<numOfElm; ++i) { |
---|
155 | G4int Z = G4int(((*theElmTable)[i])->GetZ()); |
---|
156 | if(Z < 1) Z = 1; |
---|
157 | else if(Z > 92) Z = 92; |
---|
158 | //G4cout << "Z= " << Z << G4endl; |
---|
159 | // Initialisation |
---|
160 | if(!data[Z]) { Initialise(Z, dynParticle, path); } |
---|
161 | } |
---|
162 | } |
---|
163 | delete dynParticle; |
---|
164 | } |
---|
165 | |
---|
166 | void |
---|
167 | G4NeutronInelasticXS::DumpPhysicsTable(const G4ParticleDefinition&) |
---|
168 | { |
---|
169 | } |
---|
170 | |
---|
171 | void |
---|
172 | G4NeutronInelasticXS::Initialise(G4int Z, G4DynamicParticle* dp, |
---|
173 | const char* p) |
---|
174 | { |
---|
175 | if(data[Z]) return; |
---|
176 | const char* path = p; |
---|
177 | if(!p) { |
---|
178 | // check environment variable |
---|
179 | // Build the complete string identifying the file with the data set |
---|
180 | path = getenv("G4NEUTRONXSDATA"); |
---|
181 | if (!path) { |
---|
182 | if(verboseLevel > 1) { |
---|
183 | G4cout << "G4NEUTRONXSDATA environment variable not set" << G4endl; |
---|
184 | } |
---|
185 | return; |
---|
186 | } |
---|
187 | } |
---|
188 | G4DynamicParticle* dynParticle = dp; |
---|
189 | if(!dp) { |
---|
190 | dynParticle = |
---|
191 | new G4DynamicParticle(G4Neutron::Neutron(),G4ThreeVector(1,0,0),1); |
---|
192 | } |
---|
193 | |
---|
194 | const G4Element* Elem = |
---|
195 | G4NistManager::Instance()->FindOrBuildElement(Z, true); |
---|
196 | |
---|
197 | // upload data from file |
---|
198 | data[Z] = new G4PhysicsLogVector(); |
---|
199 | |
---|
200 | std::ostringstream ost; |
---|
201 | ost << path << "/inelast" << Z ; |
---|
202 | std::ifstream filein(ost.str().c_str()); |
---|
203 | if (!(filein)) { |
---|
204 | G4cout << " file " << ost << " is not opened" << G4endl; |
---|
205 | }else{ |
---|
206 | if(verboseLevel > 1) { |
---|
207 | G4cout << ost << " is opened" << G4endl; |
---|
208 | } |
---|
209 | // retrieve data from DB |
---|
210 | data[Z]->Retrieve(filein, true); |
---|
211 | |
---|
212 | // smooth transition |
---|
213 | size_t n = data[Z]->GetVectorLength() - 1; |
---|
214 | G4double emax = data[Z]->Energy(n); |
---|
215 | G4double sig1 = (*data[Z])[n]; |
---|
216 | dynParticle->SetKineticEnergy(emax); |
---|
217 | ggXsection->GetCrossSection(dynParticle, Elem); |
---|
218 | G4double sig2 = ggXsection->GetInelasticGlauberGribovXsc(); |
---|
219 | if(sig2 > 0.) { coeff[Z] = sig1/sig2; } |
---|
220 | } |
---|
221 | if(!dp) { delete dynParticle; } |
---|
222 | } |
---|