Geant4  10.02
G4WendtFissionFragmentGenerator.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 /*
27  * File: G4WendtFissionFragmentGenerator.hh
28  * Author: B. Wendt (wendbryc@isu.edu)
29  *
30  * Created on June 21, 2013, 13:58 MST
31  */
32 
33 #include "G4ParticleHPManager.hh"
34 
35 #include "G4FFGDebuggingMacros.hh"
37 
39 
42 {
43  // Set the default verbosity
45 }
46 /*
47 G4WendtFissionFragmentGenerator* G4WendtFissionFragmentGenerator::
48 GetInstance()
49 {
50  //static G4WendtFissionFragmentGenerator newMe;
51  //
52  //return &newMe;
53 
54  if ( instance == NULL) instance = new G4WendtFissionFragmentGenerator();
55 
56  return instance;
57 }
58 */
60 ApplyYourself(const G4HadProjectile& projectile, G4int Z, G4int A)
61 {
63 
64  G4HadFinalState* finalState = NULL;
65  G4DynamicParticleVector* finalParticles = NULL;
66  G4int isotope;
67  std::map< const G4int, G4FissionFragmentGenerator* >::iterator fissionGenerator;
68 
69  // Look for the first available isomer since no M is provided for ApplyYourself()
70  for(unsigned int M = 0; M < 10; ++M)
71  {
73  fissionGenerator = fissionIsotopes.find(isotope);
74 
75  if(fissionGenerator != fissionIsotopes.end())
76  {
77  // Only generate particles if the generator was constructed
78  if(fissionGenerator->second)
79  {
80  finalParticles = fissionGenerator->second->G4GenerateFission(projectile);
81  }
82 
83  break;
84  }
85  }
86 
87  if(finalParticles)
88  {
89  finalState = new G4HadFinalState();
90 
91  for(unsigned int i = 0; i < finalParticles->size(); ++i)
92  {
93  finalState->AddSecondary((*finalParticles)[i]);
94  }
95  }
96 
97  //TK modified 131108 add next line
98  finalState->SetStatusChange(stopAndKill);
100  return finalState;
101 }
102 
104 InitializeANucleus(const G4int A, const G4int Z, const G4int M, const G4String& dataDirectory)
105 {
106 //G4FFG_FUNCTIONENTER__
107 
108  const G4int isotope = G4FissionFragmentGenerator::G4MakeIsotopeCode(Z, A, M);
110  std::pair< std::map< const G4int, G4FissionFragmentGenerator* >::iterator, bool > newIsotope;
111 
112  // Check to see if the isotope/isomer alread exists in the table
113  newIsotope = fissionIsotopes.insert(std::make_pair(isotope, (G4FissionFragmentGenerator*)NULL));
114 
115  if(newIsotope.second || newIsotope.first->second == NULL)
116  {
117  // Get the data file
118  G4bool flag;
119  G4ParticleHPDataUsed dataFile = fileNames.GetName(A, Z, M, dataDirectory, "FF", flag);
120  G4String dataFileName = dataFile.GetName();
121 
122  // Check if the file exists, and do not create a fission object if it doesn't
123  // G4cout << "*** Z = " << Z << "\tA = " << A << "\t\t\t Directory: "<< dataDirectory << " DATA FILE: " << dataFileName << G4endl;
124  std::istringstream dataStream(std::ios::in);
125  G4ParticleHPManager::GetInstance()->GetDataStream(dataFileName, dataStream);
126  if(!dataStream)
127  {
128  //G4FFG_FUNCTIONLEAVE__
129  // G4cerr << "*** Stream error" << G4endl;
130  return;
131  }
132 
133  // Check the data file parameters
134  if(!flag
135  || ( Z < 2.5 && ( (G4double)abs( dataFile.GetZ() - Z ) > 0.001 || (G4double)abs( (G4int)dataFile.GetA() - A ) > 0.0001 ) ) )
136  {
137  //G4cerr << "*** Something wrong with the data request.\tFlag :" << flag << G4endl;
138  //G4FFG_FUNCTIONLEAVE__
139  return;
140  }
141 
142  G4FissionFragmentGenerator* const fissionGenerator = new G4FissionFragmentGenerator();
143  newIsotope.first->second = fissionGenerator;
144 
145  switch(M)
146  {
147  case 1:
148  metaState = G4FFGEnumerations::META_1;
149  break;
150 
151  case 2:
152  metaState = G4FFGEnumerations::META_2;
153  break;
154 
155  default:
156  // TODO Display a warning message here indicating that an invalid metastate was passed in
157  // Fall through to the ground state by default
158  case 0:
160  break;
161  }
162 
163  fissionGenerator->G4SetIsotope(isotope);
164  fissionGenerator->G4SetMetaState(metaState);
166  // TODO Load all the fission data and use the projectile energy instead
170 
171 
172  // TODO Remove the need for forcing a load in the initialization phase,
173  // i.e. remove the ability to dynamically change the fission parameters
174  // that cause reload because a G4FissionFragmentGenerator class for
175  // each isotope should be loaded in the initialization phase
176  if(!fissionGenerator->InitializeFissionProductYieldClass(dataStream))
177  {
178  // Delete if the initialization fails
179  delete fissionGenerator;
180 
181  fissionIsotopes.erase(newIsotope.first);
182  }
183  }
184 
185 //G4FFG_FUNCTIONLEAVE__
186 }
187 
190 {
191  std::map< const G4int, G4FissionFragmentGenerator* >::iterator fissionGenerator;
192 
193  for(fissionGenerator = fissionIsotopes.begin(); fissionGenerator != fissionIsotopes.end(); ++fissionGenerator)
194  {
195  delete fissionGenerator->second;
196  }
197 }
static G4ParticleHPManager * GetInstance()
G4HadFinalState * ApplyYourself(const G4HadProjectile &projectile, G4int Z, G4int A)
MetaState
ENDF format provides for 3 isomers - 1 ground state and 2 meta states.
G4FissionFragmentGenerator is the front end class to be used by the user for handling all fission eve...
void G4SetSamplingScheme(G4FFGEnumerations::FissionSamplingScheme NewScheme)
Set the sampling scheme.
void G4SetYieldType(G4FFGEnumerations::YieldType WhichYieldType)
Sets the ENDF yield type to be used for the data.
void G4SetMetaState(G4FFGEnumerations::MetaState WhichMetaState)
Sets the metastable state of the fission isotope.
void GetDataStream(G4String, std::istringstream &iss)
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
static G4int G4MakeIsotopeCode(G4int Z, G4int A, G4int M)
Converts the Z, A and M of an isotope into an integer representation.
bool InitializeFissionProductYieldClass(std::istringstream &dataFile)
Initializes a new G4FPY...Dist class based on the class descriptor variables of G4FissionFragmentGene...
void InitializeANucleus(const G4int A, const G4int Z, const G4int M, const G4String &dataDirectory)
double A(double temperature)
bool G4bool
Definition: G4Types.hh:79
std::vector< G4DynamicParticle * > G4DynamicParticleVector
void G4SetIsotope(G4int WhichIsotope)
Sets the fission isotope.
std::map< const G4int, G4FissionFragmentGenerator * > fissionIsotopes
A map of all the fission isotopes loaded at initialization.
void G4SetCause(G4FFGEnumerations::FissionCause WhichCause)
Sets the cause of fission event.
void G4SetIncidentEnergy(G4double WhatIncidentEnergy)
Sets the incident energy, if any, of the particle that cause fission.
#define G4FFG_FUNCTIONLEAVE__
G4ParticleHPDataUsed GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
double G4double
Definition: G4Types.hh:76
static const G4double ThermalNeutronEnergy
The energy of thermal neutrons.
#define G4FFG_FUNCTIONENTER__
static const G4FFGEnumerations::Verbosity Verbosity
Verbosity for the entire package.
static G4ThreadLocal G4WendtFissionFragmentGenerator * instance