Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /* 26 /* 27 * File: G4WendtFissionFragmentGenerator.hh 27 * File: G4WendtFissionFragmentGenerator.hh 28 * Author: B. Wendt (wendbryc@isu.edu) 28 * Author: B. Wendt (wendbryc@isu.edu) 29 * 29 * 30 * Created on June 21, 2013, 13:58 MST 30 * Created on June 21, 2013, 13:58 MST 31 */ 31 */ 32 32 33 #include "G4WendtFissionFragmentGenerator.hh" << 33 #include "G4ParticleHPManager.hh" 34 34 35 #include "G4FFGDebuggingMacros.hh" 35 #include "G4FFGDebuggingMacros.hh" 36 #include "G4ParticleHPManager.hh" << 36 #include "G4WendtFissionFragmentGenerator.hh" >> 37 37 #include "G4PhysicsModelCatalog.hh" 38 #include "G4PhysicsModelCatalog.hh" 38 39 39 G4ThreadLocal G4WendtFissionFragmentGenerator* << 40 G4ThreadLocal G4WendtFissionFragmentGenerator* G4WendtFissionFragmentGenerator::instance = NULL; 40 41 41 G4WendtFissionFragmentGenerator::G4WendtFissio << 42 G4WendtFissionFragmentGenerator:: >> 43 G4WendtFissionFragmentGenerator() 42 { 44 { 43 // Set the default verbosity << 45 // Set the default verbosity 44 Verbosity_ = G4FFGDefaultValues::Verbosity; << 46 Verbosity_ = G4FFGDefaultValues::Verbosity; 45 47 46 // Set the creator model ID << 48 // Set the creator model ID 47 secID = G4PhysicsModelCatalog::GetModelID("m << 49 secID = G4PhysicsModelCatalog::GetModelID( "model_NeutronHPFission" ); 48 } 50 } 49 /* 51 /* 50 G4WendtFissionFragmentGenerator* G4WendtFissio 52 G4WendtFissionFragmentGenerator* G4WendtFissionFragmentGenerator:: 51 GetInstance() 53 GetInstance() 52 { 54 { 53 //static G4WendtFissionFragmentGenerator n 55 //static G4WendtFissionFragmentGenerator newMe; 54 // 56 // 55 //return &newMe; 57 //return &newMe; 56 58 57 if ( instance == NULL) instance = new G4We 59 if ( instance == NULL) instance = new G4WendtFissionFragmentGenerator(); 58 60 59 return instance; 61 return instance; 60 } 62 } 61 */ 63 */ 62 G4HadFinalState* G4WendtFissionFragmentGenerat << 64 G4HadFinalState* G4WendtFissionFragmentGenerator:: 63 << 65 ApplyYourself(const G4HadProjectile& projectile, G4int Z, G4int A) 64 { 66 { 65 G4FFG_FUNCTIONENTER__ << 67 G4FFG_FUNCTIONENTER__ 66 68 67 G4HadFinalState* finalState = nullptr; << 69 G4HadFinalState* finalState = NULL; 68 G4DynamicParticleVector* finalParticles = nu << 70 G4DynamicParticleVector* finalParticles = NULL; 69 G4int isotope; << 71 G4int isotope; 70 std::map<const G4int, G4FissionFragmentGener << 72 std::map< const G4int, G4FissionFragmentGenerator* >::iterator fissionGenerator; 71 << 72 // Look for the first available isomer since << 73 for (unsigned int M = 0; M < 10; ++M) { << 74 isotope = G4FissionFragmentGenerator::G4Ma << 75 fissionGenerator = fissionIsotopes.find(is << 76 << 77 if (fissionGenerator != fissionIsotopes.en << 78 // Only generate particles if the genera << 79 if (fissionGenerator->second != nullptr) << 80 finalParticles = fissionGenerator->sec << 81 } << 82 73 83 break; << 74 // Look for the first available isomer since no M is provided for ApplyYourself() >> 75 for(unsigned int M = 0; M < 10; ++M) >> 76 { >> 77 isotope = G4FissionFragmentGenerator::G4MakeIsotopeCode(Z, A, M); >> 78 fissionGenerator = fissionIsotopes.find(isotope); >> 79 >> 80 if(fissionGenerator != fissionIsotopes.end()) >> 81 { >> 82 // Only generate particles if the generator was constructed >> 83 if(fissionGenerator->second) >> 84 { >> 85 finalParticles = fissionGenerator->second->G4GenerateFission(projectile); >> 86 } >> 87 >> 88 break; >> 89 } 84 } 90 } 85 } << 86 91 87 if (finalParticles != nullptr) { << 92 if(finalParticles) 88 finalState = new G4HadFinalState(); << 93 { >> 94 finalState = new G4HadFinalState(); 89 95 90 for (auto& finalParticle : *finalParticles << 96 for(unsigned int i = 0; i < finalParticles->size(); ++i) 91 finalState->AddSecondary(finalParticle, << 97 { >> 98 finalState->AddSecondary((*finalParticles)[i], secID); >> 99 } 92 } 100 } 93 } << 94 101 95 // TK modified 131108 add next line << 102 //TK modified 131108 add next line 96 // TK 160112 fix for coverity #53481 << 103 //TK 160112 fix for coverity #53481 97 if (finalState != nullptr) finalState->SetSt << 104 if ( finalState != NULL ) finalState->SetStatusChange(stopAndKill); 98 G4FFG_FUNCTIONLEAVE__ << 105 G4FFG_FUNCTIONLEAVE__ 99 return finalState; << 106 return finalState; 100 } 107 } 101 108 102 void G4WendtFissionFragmentGenerator::Initiali << 109 void G4WendtFissionFragmentGenerator:: 103 << 110 InitializeANucleus(const G4int A, const G4int Z, const G4int M, const G4String& dataDirectory) 104 << 105 { 111 { 106 // G4FFG_FUNCTIONENTER__ << 112 //G4FFG_FUNCTIONENTER__ 107 113 108 const G4int isotope = G4FissionFragmentGener << 114 const G4int isotope = G4FissionFragmentGenerator::G4MakeIsotopeCode(Z, A, M); 109 G4FFGEnumerations::MetaState metaState; << 115 G4FFGEnumerations::MetaState metaState; 110 std::pair<std::map<const G4int, G4FissionFra << 116 std::pair< std::map< const G4int, G4FissionFragmentGenerator* >::iterator, bool > newIsotope; 111 << 112 // Check to see if the isotope/isomer alread << 113 newIsotope = << 114 fissionIsotopes.insert(std::make_pair(isot << 115 << 116 if (newIsotope.second || newIsotope.first->s << 117 // Get the data file << 118 G4bool flag; << 119 G4ParticleHPDataUsed dataFile = fileNames. << 120 G4String dataFileName = dataFile.GetName() << 121 << 122 // Check if the file exists, and do not cr << 123 // G4cout << "*** Z = " << Z << "\tA = " < << 124 // FILE: " << dataFileName << G4endl; << 125 std::istringstream dataStream(std::ios::in << 126 G4ParticleHPManager::GetInstance()->GetDat << 127 if (!dataStream) { << 128 // G4FFG_FUNCTIONLEAVE__ << 129 // G4cerr << "*** Stream error" << G4en << 130 return; << 131 } << 132 117 133 // Check the data file parameters << 118 // Check to see if the isotope/isomer alread exists in the table 134 if (!flag << 119 newIsotope = fissionIsotopes.insert(std::make_pair(isotope, (G4FissionFragmentGenerator*)NULL)); 135 || (Z < 2.5 << 136 && ((G4double)abs(dataFile.GetZ() << 137 || (G4double)abs((G4int)dataFi << 138 { << 139 // G4cerr << "*** Something wrong with t << 140 // G4FFG_FUNCTIONLEAVE__ << 141 return; << 142 } << 143 120 144 auto const fissionGenerator = new G4Fissio << 121 if(newIsotope.second || newIsotope.first->second == NULL) 145 newIsotope.first->second = fissionGenerato << 122 { 146 << 123 // Get the data file 147 switch (M) { << 124 G4bool flag; 148 case 1: << 125 G4ParticleHPDataUsed dataFile = fileNames.GetName(A, Z, M, dataDirectory, "FF", flag); 149 metaState = G4FFGEnumerations::META_1; << 126 G4String dataFileName = dataFile.GetName(); 150 break; << 127 151 << 128 // Check if the file exists, and do not create a fission object if it doesn't 152 case 2: << 129 // G4cout << "*** Z = " << Z << "\tA = " << A << "\t\t\t Directory: "<< dataDirectory << " DATA FILE: " << dataFileName << G4endl; 153 metaState = G4FFGEnumerations::META_2; << 130 std::istringstream dataStream(std::ios::in); 154 break; << 131 G4ParticleHPManager::GetInstance()->GetDataStream(dataFileName, dataStream); 155 << 132 if(!dataStream) 156 default: << 133 { 157 // TODO Display a warning message here << 134 //G4FFG_FUNCTIONLEAVE__ 158 // Fall through to the ground state by << 135 // G4cerr << "*** Stream error" << G4endl; 159 case 0: << 136 return; 160 metaState = G4FFGEnumerations::GROUND_ << 137 } 161 break; << 138 162 } << 139 // Check the data file parameters 163 << 140 if(!flag 164 fissionGenerator->G4SetIsotope(isotope); << 141 || ( Z < 2.5 && ( (G4double)abs( dataFile.GetZ() - Z ) > 0.001 || (G4double)abs( (G4int)dataFile.GetA() - A ) > 0.0001 ) ) ) 165 fissionGenerator->G4SetMetaState(metaState << 142 { 166 fissionGenerator->G4SetCause(G4FFGEnumerat << 143 //G4cerr << "*** Something wrong with the data request.\tFlag :" << flag << G4endl; 167 // TODO Load all the fission data and use << 144 //G4FFG_FUNCTIONLEAVE__ 168 fissionGenerator->G4SetIncidentEnergy(G4FF << 145 return; 169 fissionGenerator->G4SetYieldType(G4FFGEnum << 146 } 170 fissionGenerator->G4SetSamplingScheme(G4FF << 147 171 << 148 G4FissionFragmentGenerator* const fissionGenerator = new G4FissionFragmentGenerator(); 172 // TODO Remove the need for forcing a load << 149 newIsotope.first->second = fissionGenerator; 173 // i.e. remove the ability to dynamic << 150 174 // that cause reload because a G4Fiss << 151 switch(M) 175 // each isotope should be loaded in t << 152 { 176 if (!fissionGenerator->InitializeFissionPr << 153 case 1: 177 // Delete if the initialization fails << 154 metaState = G4FFGEnumerations::META_1; 178 delete fissionGenerator; << 155 break; >> 156 >> 157 case 2: >> 158 metaState = G4FFGEnumerations::META_2; >> 159 break; >> 160 >> 161 default: >> 162 // TODO Display a warning message here indicating that an invalid metastate was passed in >> 163 // Fall through to the ground state by default >> 164 case 0: >> 165 metaState = G4FFGEnumerations::GROUND_STATE; >> 166 break; >> 167 } >> 168 >> 169 fissionGenerator->G4SetIsotope(isotope); >> 170 fissionGenerator->G4SetMetaState(metaState); >> 171 fissionGenerator->G4SetCause(G4FFGEnumerations::NEUTRON_INDUCED); >> 172 // TODO Load all the fission data and use the projectile energy instead >> 173 fissionGenerator->G4SetIncidentEnergy(G4FFGDefaultValues::ThermalNeutronEnergy); >> 174 fissionGenerator->G4SetYieldType(G4FFGEnumerations::INDEPENDENT); >> 175 fissionGenerator->G4SetSamplingScheme(G4FFGEnumerations::NORMAL); >> 176 >> 177 >> 178 // TODO Remove the need for forcing a load in the initialization phase, >> 179 // i.e. remove the ability to dynamically change the fission parameters >> 180 // that cause reload because a G4FissionFragmentGenerator class for >> 181 // each isotope should be loaded in the initialization phase >> 182 if(!fissionGenerator->InitializeFissionProductYieldClass(dataStream)) >> 183 { >> 184 // Delete if the initialization fails >> 185 delete fissionGenerator; 179 186 180 fissionIsotopes.erase(newIsotope.first); << 187 fissionIsotopes.erase(newIsotope.first); >> 188 } 181 } 189 } 182 } << 183 190 184 // G4FFG_FUNCTIONLEAVE__ << 191 //G4FFG_FUNCTIONLEAVE__ 185 } 192 } 186 193 187 G4WendtFissionFragmentGenerator::~G4WendtFissi << 194 G4WendtFissionFragmentGenerator:: >> 195 ~G4WendtFissionFragmentGenerator() 188 { 196 { 189 std::map<const G4int, G4FissionFragmentGener << 197 std::map< const G4int, G4FissionFragmentGenerator* >::iterator fissionGenerator; 190 198 191 for (fissionGenerator = fissionIsotopes.begi << 199 for(fissionGenerator = fissionIsotopes.begin(); fissionGenerator != fissionIsotopes.end(); ++fissionGenerator) 192 ++fissionGenerator) << 200 { 193 { << 201 delete fissionGenerator->second; 194 delete fissionGenerator->second; << 202 } 195 } << 196 } 203 } 197 204