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.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 "G4WendtFissionFragmentGenerator.hh"
 34 
 35 #include "G4FFGDebuggingMacros.hh"
 36 #include "G4ParticleHPManager.hh"
 37 #include "G4PhysicsModelCatalog.hh"
 38 
 39 G4ThreadLocal G4WendtFissionFragmentGenerator* G4WendtFissionFragmentGenerator::instance = nullptr;
 40 
 41 G4WendtFissionFragmentGenerator::G4WendtFissionFragmentGenerator()
 42 {
 43   // Set the default verbosity
 44   Verbosity_ = G4FFGDefaultValues::Verbosity;
 45 
 46   // Set the creator model ID
 47   secID = G4PhysicsModelCatalog::GetModelID("model_NeutronHPFission");
 48 }
 49 /*
 50 G4WendtFissionFragmentGenerator* G4WendtFissionFragmentGenerator::
 51 GetInstance()
 52 {
 53     //static G4WendtFissionFragmentGenerator newMe;
 54     //
 55     //return &newMe;
 56 
 57     if ( instance == NULL) instance = new G4WendtFissionFragmentGenerator();
 58 
 59     return instance;
 60 }
 61 */
 62 G4HadFinalState* G4WendtFissionFragmentGenerator::ApplyYourself(const G4HadProjectile& projectile,
 63                                                                 G4int Z, G4int A)
 64 {
 65   G4FFG_FUNCTIONENTER__
 66 
 67   G4HadFinalState* finalState = nullptr;
 68   G4DynamicParticleVector* finalParticles = nullptr;
 69   G4int isotope;
 70   std::map<const G4int, G4FissionFragmentGenerator*>::iterator fissionGenerator;
 71 
 72   // Look for the first available isomer since no M is provided for ApplyYourself()
 73   for (unsigned int M = 0; M < 10; ++M) {
 74     isotope = G4FissionFragmentGenerator::G4MakeIsotopeCode(Z, A, M);
 75     fissionGenerator = fissionIsotopes.find(isotope);
 76 
 77     if (fissionGenerator != fissionIsotopes.end()) {
 78       // Only generate particles if the generator was constructed
 79       if (fissionGenerator->second != nullptr) {
 80         finalParticles = fissionGenerator->second->G4GenerateFission(projectile);
 81       }
 82 
 83       break;
 84     }
 85   }
 86 
 87   if (finalParticles != nullptr) {
 88     finalState = new G4HadFinalState();
 89 
 90     for (auto& finalParticle : *finalParticles) {
 91       finalState->AddSecondary(finalParticle, secID);
 92     }
 93   }
 94 
 95   // TK modified 131108 add next line
 96   // TK 160112 fix for coverity #53481
 97   if (finalState != nullptr) finalState->SetStatusChange(stopAndKill);
 98   G4FFG_FUNCTIONLEAVE__
 99   return finalState;
100 }
101 
102 void G4WendtFissionFragmentGenerator::InitializeANucleus(const G4int A, const G4int Z,
103                                                          const G4int M,
104                                                          const G4String& dataDirectory)
105 {
106   // G4FFG_FUNCTIONENTER__
107 
108   const G4int isotope = G4FissionFragmentGenerator::G4MakeIsotopeCode(Z, A, M);
109   G4FFGEnumerations::MetaState metaState;
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 =
114     fissionIsotopes.insert(std::make_pair(isotope, (G4FissionFragmentGenerator*)nullptr));
115 
116   if (newIsotope.second || newIsotope.first->second == NULL) {
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
124     // FILE: " << dataFileName << G4endl;
125     std::istringstream dataStream(std::ios::in);
126     G4ParticleHPManager::GetInstance()->GetDataStream(dataFileName, dataStream);
127     if (!dataStream) {
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
136             && ((G4double)abs(dataFile.GetZ() - Z) > 0.001
137                 || (G4double)abs((G4int)dataFile.GetA() - A) > 0.0001)))
138     {
139       // G4cerr << "*** Something wrong with the data request.\tFlag :" << flag << G4endl;
140       // G4FFG_FUNCTIONLEAVE__
141       return;
142     }
143 
144     auto const fissionGenerator = new G4FissionFragmentGenerator();
145     newIsotope.first->second = fissionGenerator;
146 
147     switch (M) {
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:
160         metaState = G4FFGEnumerations::GROUND_STATE;
161         break;
162     }
163 
164     fissionGenerator->G4SetIsotope(isotope);
165     fissionGenerator->G4SetMetaState(metaState);
166     fissionGenerator->G4SetCause(G4FFGEnumerations::NEUTRON_INDUCED);
167     // TODO Load all the fission data and use the projectile energy instead
168     fissionGenerator->G4SetIncidentEnergy(G4FFGDefaultValues::ThermalNeutronEnergy);
169     fissionGenerator->G4SetYieldType(G4FFGEnumerations::INDEPENDENT);
170     fissionGenerator->G4SetSamplingScheme(G4FFGEnumerations::NORMAL);
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       // Delete if the initialization fails
178       delete fissionGenerator;
179 
180       fissionIsotopes.erase(newIsotope.first);
181     }
182   }
183 
184   // G4FFG_FUNCTIONLEAVE__
185 }
186 
187 G4WendtFissionFragmentGenerator::~G4WendtFissionFragmentGenerator()
188 {
189   std::map<const G4int, G4FissionFragmentGenerator*>::iterator fissionGenerator;
190 
191   for (fissionGenerator = fissionIsotopes.begin(); fissionGenerator != fissionIsotopes.end();
192        ++fissionGenerator)
193   {
194     delete fissionGenerator->second;
195   }
196 }
197