Geant4  10.01.p02
G4NeutronHPFFFissionFS.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 // neutron_hp -- source file
27 // J.P. Wellisch, Nov-1996
28 // A prototype of the low energy neutron transport model.
29 //
31 #include "G4NeutronHPManager.hh"
32 #include "G4SystemOfUnits.hh"
33 
35 {
36  std::map<G4int,std::map<G4double,std::map<G4int,G4double >* >* >::iterator it = FissionProductYieldData.begin();
37  while ( it != FissionProductYieldData.end() ) {
38  std::map<G4double,std::map<G4int,G4double>* >* firstLevel = it->second;
39  if ( firstLevel ) {
40  std::map<G4double,std::map<G4int,G4double>*>::iterator it2 = firstLevel->begin();
41  while ( it2 != firstLevel->end() ) {
42  delete it2->second;
43  it2->second = 0;
44  firstLevel->erase(it2);
45  it2=firstLevel->begin();
46  }
47  }
48  delete firstLevel;
49  it->second = 0;
50  FissionProductYieldData.erase(it);
51  it = FissionProductYieldData.begin();
52  }
53 
54  std::map< G4int , std::map< G4double , G4int >* >::iterator ii = mMTInterpolation.begin();
55  while ( ii != mMTInterpolation.end() ) {
56  delete ii->second;
57  mMTInterpolation.erase(ii);
58  ii = mMTInterpolation.begin();
59  }
60 }
61 
63 {
64  //G4cout << "G4NeutronHPFFFissionFS::Init" << G4endl;
65  G4String aString = "FF";
66 
67  G4String tString = dirName;
68  G4bool dbool;
69  G4NeutronHPDataUsed aFile = theNames.GetName(static_cast<G4int>(A), static_cast<G4int>(Z), M, tString, aString , dbool);
70  G4String filename = aFile.GetName();
71  theBaseA = aFile.GetA();
72  theBaseZ = aFile.GetZ();
73 
74 //3456
75  if ( !dbool || ( Z < 2.5 && ( std::abs(theBaseZ-Z)>0.0001 || std::abs(theBaseA-A)>0.0001) ) )
76  {
77  hasAnyData = false;
78  hasFSData = false;
79  hasXsec = false;
80  return; // no data for exactly this isotope.
81  }
82  //std::ifstream theData(filename, std::ios::in);
83  std::istringstream theData(std::ios::in);
85  G4double dummy;
86  if ( !theData )
87  {
88  //theData.close();
89  hasFSData = false;
90  hasXsec = false;
91  hasAnyData = false;
92  return; // no data for this FS for this isotope
93  }
94 
95 
96  hasFSData = true;
97  // MT Energy FPS Yield
98  //std::map< int , std::map< double , std::map< int , double >* >* > FisionProductYieldData;
99  while ( theData.good() )
100  {
101  G4int iMT, iMF;
102  G4int imax;
103  //Reading the data
104  // MT MF AWR
105  theData >> iMT >> iMF >> dummy;
106  // nBlock
107  theData >> imax;
108  //if ( !theData.good() ) continue;
109  // Ei FPS Yield
110  std::map< G4double , std::map< G4int , G4double >* >* mEnergyFSPData = new std::map< G4double , std::map< G4int , G4double >* >;
111 
112  std::map< G4double , G4int >* mInterporation = new std::map< G4double , G4int >;
113  for ( G4int i = 0 ; i <= imax ; i++ )
114  {
115 
116  G4double YY=0.0;
117  G4double Ei;
118  G4int jmax;
119  G4int ip;
120  // energy of incidence neutron
121  theData >> Ei;
122  // Number of data set followings
123  theData >> jmax;
124  // interpolation scheme
125  theData >> ip;
126  mInterporation->insert( std::pair<G4double,G4int>(Ei*eV,ip) );
127  // nNumber nIP
128  std::map<G4int,G4double>* mFSPYieldData = new std::map<G4int,G4double>;
129  for ( G4int j = 0 ; j < jmax ; j++ )
130  {
131  G4int FSP;
132  G4int mFSP;
133  G4double Y;
134  theData >> FSP >> mFSP >> Y;
135  G4int k = FSP*100+mFSP;
136  YY = YY + Y;
137  //if ( iMT == 454 )G4cout << iMT << " " << i << " " << j << " " << k << " " << Y << " " << YY << G4endl;
138  mFSPYieldData->insert( std::pair<G4int,G4double>( k , YY ) );
139  }
140  mEnergyFSPData->insert( std::pair<G4double,std::map<G4int,G4double>*>(Ei*eV,mFSPYieldData) );
141  }
142 
143  FissionProductYieldData.insert( std::pair< G4int , std::map< G4double , std::map< G4int , G4double >* >* > (iMT,mEnergyFSPData));
144  mMTInterpolation.insert( std::pair<G4int,std::map<G4double,G4int>*> (iMT,mInterporation) );
145  }
146  //theData.close();
147 }
148 
150 {
151  G4DynamicParticleVector * aResult;
152 // G4cout <<"G4NeutronHPFFFissionFS::ApplyYourself +"<<G4endl;
153  aResult = G4NeutronHPFissionBaseFS::ApplyYourself(nNeutrons);
154  return aResult;
155 }
156 
158 {
159  //G4cout << "G4NeutronHPFFFissionFS::GetAFissionFragment " << G4endl;
160 
161  G4double rand =G4UniformRand();
162  //G4cout << rand << G4endl;
163 
164  std::map< G4double , std::map< G4int , G4double >* >* mEnergyFSPData = FissionProductYieldData.find( 454 )->second;
165 
166  //It is not clear that the treatment of the scheme 2 on two-dimensional interpolation.
167  //So, here just use the closest energy point array of yield data.
168  //TK120531
169  G4double key_energy = DBL_MAX;
170  if ( mEnergyFSPData->size() == 1 )
171  {
172  key_energy = mEnergyFSPData->begin()->first;
173  }
174  else
175  {
176  //Find closest energy point
177  G4double Dmin=DBL_MAX;
178  G4int i = 0;
179  for ( std::map< G4double , std::map< G4int , G4double >* >::iterator it = mEnergyFSPData->begin() ;
180  it != mEnergyFSPData->end() ; it++ )
181  {
182  G4double e = (it->first);
183  G4double d = std::fabs ( energy - e );
184  if ( d < Dmin )
185  {
186  Dmin = d;
187  key_energy = e;
188  }
189  i++;
190  }
191  }
192 
193  std::map<G4int,G4double>* mFSPYieldData = (*mEnergyFSPData)[key_energy];
194 
195  G4int ifrag=0;
196  G4double ceilling = mFSPYieldData->rbegin()->second; // Because of numerical accuracy, this is not always 2
197  for ( std::map<G4int,G4double>::iterator it = mFSPYieldData->begin() ; it != mFSPYieldData->end() ; it++ )
198  {
199  //if ( ( rand - it->second/ceilling ) < 1.0e-6 ) std::cout << rand - it->second/ceilling << std::endl;
200  if ( rand <= it->second/ceilling )
201  {
202  //G4cout << it->first << " " << it->second/ceilling << G4endl;
203  ifrag = it->first;
204  break;
205  }
206  }
207 
208  fragZ = ifrag/100000;
209  fragA = (ifrag%100000)/100;
210  fragM = (ifrag%100);
211 
212  //G4cout << fragZ << " " << fragA << " " << fragM << G4endl;
213 }
static G4NeutronHPManager * GetInstance()
G4DynamicParticleVector * ApplyYourself(G4int Prompt)
G4DynamicParticleVector * ApplyYourself(G4int nNeutrons)
void GetDataStream(G4String, std::istringstream &iss)
G4NeutronHPDataUsed GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
int G4int
Definition: G4Types.hh:78
std::map< G4int, std::map< G4double, std::map< G4int, G4double > * > * > FissionProductYieldData
#define G4UniformRand()
Definition: Randomize.hh:93
void Init(G4double A, G4double Z, G4int M, G4String &dirName, G4String &aFSType)
bool G4bool
Definition: G4Types.hh:79
std::map< G4int, std::map< G4double, G4int > * > mMTInterpolation
static const double second
Definition: G4SIunits.hh:138
std::vector< G4DynamicParticle * > G4DynamicParticleVector
void GetAFissionFragment(G4double, G4int &, G4int &, G4int &)
static const G4double A[nN]
const G4int jmax
static const double eV
Definition: G4SIunits.hh:194
G4double energy(const ThreeVector &p, const G4double m)
static const G4int imax
double G4double
Definition: G4Types.hh:76
#define DBL_MAX
Definition: templates.hh:83