ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4WendtFissionFragmentGenerator.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4WendtFissionFragmentGenerator.cc
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 */
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  //TK 160112 fix for coverity #53481
99  if ( finalState != NULL ) finalState->SetStatusChange(stopAndKill);
101  return finalState;
102 }
103 
105 InitializeANucleus(const G4int A, const G4int Z, const G4int M, const G4String& dataDirectory)
106 {
107 //G4FFG_FUNCTIONENTER__
108 
109  const G4int isotope = G4FissionFragmentGenerator::G4MakeIsotopeCode(Z, A, M);
111  std::pair< std::map< const G4int, G4FissionFragmentGenerator* >::iterator, bool > newIsotope;
112 
113  // Check to see if the isotope/isomer alread exists in the table
114  newIsotope = fissionIsotopes.insert(std::make_pair(isotope, (G4FissionFragmentGenerator*)NULL));
115 
116  if(newIsotope.second || newIsotope.first->second == NULL)
117  {
118  // Get the data file
119  G4bool flag;
120  G4ParticleHPDataUsed dataFile = fileNames.GetName(A, Z, M, dataDirectory, "FF", flag);
121  G4String dataFileName = dataFile.GetName();
122 
123  // Check if the file exists, and do not create a fission object if it doesn't
124  // G4cout << "*** Z = " << Z << "\tA = " << A << "\t\t\t Directory: "<< dataDirectory << " DATA FILE: " << dataFileName << G4endl;
125  std::istringstream dataStream(std::ios::in);
126  G4ParticleHPManager::GetInstance()->GetDataStream(dataFileName, dataStream);
127  if(!dataStream)
128  {
129  //G4FFG_FUNCTIONLEAVE__
130  // G4cerr << "*** Stream error" << G4endl;
131  return;
132  }
133 
134  // Check the data file parameters
135  if(!flag
136  || ( Z < 2.5 && ( (G4double)abs( dataFile.GetZ() - Z ) > 0.001 || (G4double)abs( (G4int)dataFile.GetA() - A ) > 0.0001 ) ) )
137  {
138  //G4cerr << "*** Something wrong with the data request.\tFlag :" << flag << G4endl;
139  //G4FFG_FUNCTIONLEAVE__
140  return;
141  }
142 
143  G4FissionFragmentGenerator* const fissionGenerator = new G4FissionFragmentGenerator();
144  newIsotope.first->second = fissionGenerator;
145 
146  switch(M)
147  {
148  case 1:
149  metaState = G4FFGEnumerations::META_1;
150  break;
151 
152  case 2:
153  metaState = G4FFGEnumerations::META_2;
154  break;
155 
156  default:
157  // TODO Display a warning message here indicating that an invalid metastate was passed in
158  // Fall through to the ground state by default
159  case 0:
161  break;
162  }
163 
164  fissionGenerator->G4SetIsotope(isotope);
165  fissionGenerator->G4SetMetaState(metaState);
167  // TODO Load all the fission data and use the projectile energy instead
171 
172 
173  // TODO Remove the need for forcing a load in the initialization phase,
174  // i.e. remove the ability to dynamically change the fission parameters
175  // that cause reload because a G4FissionFragmentGenerator class for
176  // each isotope should be loaded in the initialization phase
177  if(!fissionGenerator->InitializeFissionProductYieldClass(dataStream))
178  {
179  // Delete if the initialization fails
180  delete fissionGenerator;
181 
182  fissionIsotopes.erase(newIsotope.first);
183  }
184  }
185 
186 //G4FFG_FUNCTIONLEAVE__
187 }
188 
191 {
192  std::map< const G4int, G4FissionFragmentGenerator* >::iterator fissionGenerator;
193 
194  for(fissionGenerator = fissionIsotopes.begin(); fissionGenerator != fissionIsotopes.end(); ++fissionGenerator)
195  {
196  delete fissionGenerator->second;
197  }
198 }