Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4NeutronHPJENDLHEData.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//
26// Class Description
27// Cross-section data set for a high precision (based on JENDL_HE evaluated data
28// libraries) description of elastic scattering 20 MeV ~ 3 GeV;
29// Class Description - End
30
31// 15-Nov-06 First Implementation is done by T. Koi (SLAC/SCCS)
32
34#include "G4SystemOfUnits.hh"
36#include "G4ElementTable.hh"
37#include "G4NeutronHPData.hh"
38
40{
41
42 G4bool result = true;
43 G4double eKin = aP->GetKineticEnergy();
44 //if(eKin>20*MeV||aP->GetDefinition()!=G4Neutron::Neutron()) result = false;
45 if ( eKin < 20*MeV || 3*GeV < eKin || aP->GetDefinition()!=G4Neutron::Neutron() )
46 {
47 result = false;
48 }
49// Element Check
50 else if ( !(vElement[ anE->GetIndex() ]) ) result = false;
51
52 return result;
53
54}
55
56
57
59{
60 ;
61}
62
63
64
66:G4VCrossSectionDataSet( "JENDLHE"+reaction+"CrossSection" )
67{
68 reactionName = reaction;
69 BuildPhysicsTable( *pd );
70}
71
72
73
75{
76 ;
77 //delete theCrossSections;
78}
79
80
81
83{
84
85// if ( &aP != G4Neutron::Neutron() )
86// throw G4HadronicException(__FILE__, __LINE__, "Attempt to use NeutronHP data for particles other than neutrons!!!");
87 particleName = aP.GetParticleName();
88
89 G4String baseName = getenv( "G4NEUTRONHPDATA" );
90 G4String dirName = baseName+"/JENDL_HE/"+particleName+"/"+reactionName ;
91 G4String aFSType = "/CrossSection/";
92 G4NeutronHPNames theNames;
93
94 G4String filename;
95
96// Create JENDL_HE data
97// Create map element or isotope
98
99 size_t numberOfElements = G4Element::GetNumberOfElements();
100 //theCrossSections = new G4PhysicsTable( numberOfElements );
101
102 // make a PhysicsVector for each element
103
104 static const G4ElementTable *theElementTable = G4Element::GetElementTable();
105 vElement.clear();
106 vElement.resize( numberOfElements );
107 for ( size_t i = 0; i < numberOfElements; ++i )
108 {
109
110 G4Element* theElement = (*theElementTable)[i];
111 vElement[i] = false;
112
113 // isotope
114 G4int nIso = (*theElementTable)[i]->GetNumberOfIsotopes();
115 G4int Z = static_cast<G4int> ((*theElementTable)[i]->GetZ());
116 if ( nIso!=0 )
117 {
118 G4bool found_at_least_one = false;
119 for ( G4int i1 = 0; i1 < nIso; i1++ )
120 {
121 G4int A = theElement->GetIsotope(i1)->GetN();
122
123 if ( isThisNewIsotope( Z , A ) )
124 {
125
126 std::stringstream ss;
127 ss << dirName << aFSType << Z << "_" << A << "_" << theNames.GetName( Z-1 );
128 filename = ss.str();
129 std::fstream file;
130 file.open ( filename , std::fstream::in );
131 G4int dummy;
132 file >> dummy;
133 if ( file.good() )
134 {
135
136 //G4cout << "Found file for Z=" << Z << ", A=" << A << ", as " << filename << G4endl;
137 found_at_least_one = true;
138
139 // read the file
140 G4PhysicsVector* aPhysVec = readAFile ( &file );
141
142 //Regist
143
144 registAPhysicsVector( Z , A , aPhysVec );
145
146 }
147 else
148 {
149 //G4cout << "No file for "<< reactionType << " Z=" << Z << ", A=" << A << G4endl;
150 }
151
152 file.close();
153
154 }
155 else
156 {
157 found_at_least_one = TRUE;
158 }
159 }
160
161 if ( found_at_least_one ) vElement[i] = true;
162
163 }
164 else
165 {
166 G4StableIsotopes theStableOnes;
167 G4int first = theStableOnes.GetFirstIsotope( Z );
168 G4bool found_at_least_one = FALSE;
169 for ( G4int i1 = 0; i1 < theStableOnes.GetNumberOfIsotopes( static_cast<G4int>(theElement->GetZ() ) ); i1++)
170 {
171 G4int A = theStableOnes.GetIsotopeNucleonCount( first+i1 );
172
173 if ( isThisNewIsotope( Z , A ) )
174 {
175
176 std::stringstream ss;
177 ss << dirName << aFSType << Z << "_" << A << "_" << theNames.GetName( Z-1 );
178 filename = ss.str();
179
180 std::fstream file;
181 file.open ( filename , std::fstream::in );
182 G4int dummy;
183 file >> dummy;
184 if ( file.good() )
185 {
186 //G4cout << "Found file for Z=" << Z << ", A=" << A << ", as " << filename << G4endl;
187 found_at_least_one = TRUE;
188 //Read the file
189
190 G4PhysicsVector* aPhysVec = readAFile ( &file );
191
192 //Regist the PhysicsVector
193 registAPhysicsVector( Z , A , aPhysVec );
194
195 }
196 else
197 {
198 //G4cout << "No file for "<< reactionType << " Z=" << Z << ", A=" << A << G4endl;
199 }
200
201 file.close();
202 }
203 else
204 {
205 found_at_least_one = TRUE;
206 }
207 }
208
209 if ( found_at_least_one ) vElement[i] = true;
210
211 }
212
213 }
214
215}
216
217
218
220{
221 if(&aP!=G4Neutron::Neutron())
222 throw G4HadronicException(__FILE__, __LINE__, "Attempt to use NeutronHP data for particles other than neutrons!!!");
223// G4cout << "G4NeutronHPJENDLHEData::DumpPhysicsTable still to be implemented"<<G4endl;
224}
225
226
227
230// aTemp
231{
232
233 // Primary energy >20MeV
234 // Thus
235 // Not take account of Doppler broadening
236 // also
237 // Not take account of Target thermal motions
238
239 G4double result = 0;
240
241 G4double ek = aP->GetKineticEnergy();
242
243 G4int nIso = anE->GetNumberOfIsotopes();
244 G4int Z = static_cast<G4int> ( anE->GetZ() );
245 if ( nIso!=0 )
246 {
247 for ( G4int i1 = 0; i1 < nIso; i1++ )
248 {
249
250 G4int A = anE->GetIsotope(i1)->GetN();
251 G4double frac = anE->GetRelativeAbundanceVector()[ i1 ]; // This case do NOT request "*perCent".
252
253 result += frac * getXSfromThisIsotope( Z , A , ek );
254 //G4cout << reactionType << " XS in barn " << Z << " " << A << " " << frac << " " << getXSfromThisIsotope( Z , A , ek )/barn << G4endl;
255
256 }
257 }
258 else
259 {
260
261 G4StableIsotopes theStableOnes;
262 G4int first = theStableOnes.GetFirstIsotope( Z );
263 for ( G4int i1 = 0; i1 < theStableOnes.GetNumberOfIsotopes( static_cast<G4int>(anE->GetZ() ) ); i1++)
264 {
265
266 G4int A = theStableOnes.GetIsotopeNucleonCount( first+i1 );
267 G4double frac = theStableOnes.GetAbundance( first+i1 )*perCent; // This case request "*perCent".
268
269 result += frac * getXSfromThisIsotope( Z , A , ek );
270 //G4cout << reactionType << " XS in barn " << Z << " " << A << " " << frac << " " << getXSfromThisIsotope( Z , A , ek )/barn << G4endl;
271
272 }
273 }
274 return result;
275
276}
277
278
279
280G4PhysicsVector* G4NeutronHPJENDLHEData::readAFile ( std::fstream* file )
281{
282
283 G4int dummy;
284 G4int len;
285 *file >> dummy;
286 *file >> len;
287
288 std::vector< G4double > v_e;
289 std::vector< G4double > v_xs;
290
291 for ( G4int i = 0 ; i < len ; i++ )
292 {
293 G4double e;
294 G4double xs;
295
296 *file >> e;
297 *file >> xs;
298 // data are written in eV and barn.
299 v_e.push_back( e*eV );
300 v_xs.push_back( xs*barn );
301 }
302
303 G4LPhysicsFreeVector* aPhysVec = new G4LPhysicsFreeVector( static_cast< size_t >( len ) , v_e.front() , v_e.back() );
304
305 for ( G4int i = 0 ; i < len ; i++ )
306 {
307 aPhysVec->PutValues( static_cast< size_t >( i ) , v_e[ i ] , v_xs[ i ] );
308 }
309
310 return aPhysVec;
311}
312
313
314
315G4bool G4NeutronHPJENDLHEData::isThisInMap( G4int z , G4int a )
316{
317 if ( mIsotope.find ( z ) == mIsotope.end() ) return false;
318 if ( mIsotope.find ( z ) -> second->find ( a ) == mIsotope.find ( z ) -> second->end() ) return false;
319 return true;
320}
321
322
323
324void G4NeutronHPJENDLHEData::registAPhysicsVector( G4int Z , G4int A , G4PhysicsVector* aPhysVec )
325{
326
327 std::pair< G4int , G4PhysicsVector* > aPair = std::pair < G4int , G4PhysicsVector* > ( A , aPhysVec );
328
329 std::map < G4int , std::map< G4int , G4PhysicsVector* >* >::iterator itm;
330 itm = mIsotope.find ( Z );
331 if ( itm != mIsotope.end() )
332 {
333 itm->second->insert ( aPair );
334 }
335 else
336 {
337 std::map< G4int , G4PhysicsVector* >* aMap = new std::map< G4int , G4PhysicsVector* >;
338 aMap->insert ( aPair );
339 mIsotope.insert( std::pair< G4int , std::map< G4int , G4PhysicsVector* >* > ( Z , aMap ) );
340 }
341
342}
343
344
345
346G4double G4NeutronHPJENDLHEData::getXSfromThisIsotope( G4int Z , G4int A , G4double ek )
347{
348
349 G4double aXSection = 0.0;
350 G4bool outOfRange;
351
352 G4PhysicsVector* aPhysVec;
353 if ( mIsotope.find ( Z )->second->find ( A ) != mIsotope.find ( Z )->second->end() )
354 {
355
356 aPhysVec = mIsotope.find ( Z )->second->find ( A )->second;
357 aXSection = aPhysVec->GetValue( ek , outOfRange );
358
359 }
360 else
361 {
362
363 //Select closest one in the same Z
364 std::map < G4int , G4PhysicsVector* >::iterator it;
365 G4int delta0 = 99; // no mean for 99
366 for ( it = mIsotope.find ( Z )->second->begin() ; it != mIsotope.find ( Z )->second->end() ; it++ )
367 {
368 G4int delta = std::abs( A - it->first );
369 if ( delta < delta0 ) delta0 = delta;
370 }
371
372 // Randomize of selection larger or smaller than A
373 if ( G4UniformRand() < 0.5 ) delta0 *= -1;
374 G4int A1 = A + delta0;
375 if ( mIsotope.find ( Z )->second->find ( A1 ) != mIsotope.find ( Z )->second->end() )
376 {
377 aPhysVec = mIsotope.find ( Z )->second->find ( A1 )->second;
378 }
379 else
380 {
381 A1 = A - delta0;
382 aPhysVec = mIsotope.find ( Z )->second->find ( A1 )->second;
383 }
384
385 aXSection = aPhysVec->GetValue( ek , outOfRange );
386 // X^(2/3) factor
387 aXSection *= std::pow ( 1.0*A/ A1 , 2.0 / 3.0 );
388
389 }
390
391 return aXSection;
392}
std::vector< G4Element * > G4ElementTable
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4UniformRand()
Definition: Randomize.hh:53
G4double GetKineticEnergy() const
G4double * GetRelativeAbundanceVector() const
Definition: G4Element.hh:166
G4double GetZ() const
Definition: G4Element.hh:131
static size_t GetNumberOfElements()
Definition: G4Element.cc:406
const G4Isotope * GetIsotope(G4int iso) const
Definition: G4Element.hh:169
size_t GetIndex() const
Definition: G4Element.hh:182
size_t GetNumberOfIsotopes() const
Definition: G4Element.hh:158
static const G4ElementTable * GetElementTable()
Definition: G4Element.cc:399
G4int GetN() const
Definition: G4Isotope.hh:94
void PutValues(size_t binNumber, G4double binValue, G4double dataValue)
G4double GetCrossSection(const G4DynamicParticle *, const G4Element *, G4double aT)
void BuildPhysicsTable(const G4ParticleDefinition &)
void DumpPhysicsTable(const G4ParticleDefinition &)
G4bool IsApplicable(const G4DynamicParticle *, const G4Element *)
G4NeutronHPDataUsed GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
const G4String & GetParticleName() const
G4double GetValue(G4double theEnergy, G4bool &isOutRange)
G4double GetAbundance(G4int number)
G4int GetFirstIsotope(G4int Z)
G4int GetNumberOfIsotopes(G4int Z)
G4int GetIsotopeNucleonCount(G4int number)
#define TRUE
Definition: globals.hh:55
#define FALSE
Definition: globals.hh:52