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 // INCL++ intra-nuclear cascade model 26 // INCL++ intra-nuclear cascade model 27 // Alain Boudard, CEA-Saclay, France 27 // Alain Boudard, CEA-Saclay, France 28 // Joseph Cugnon, University of Liege, Belgium 28 // Joseph Cugnon, University of Liege, Belgium 29 // Jean-Christophe David, CEA-Saclay, France 29 // Jean-Christophe David, CEA-Saclay, France 30 // Pekka Kaitaniemi, CEA-Saclay, France, and H 30 // Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland 31 // Sylvie Leray, CEA-Saclay, France 31 // Sylvie Leray, CEA-Saclay, France 32 // Davide Mancusi, CEA-Saclay, France 32 // Davide Mancusi, CEA-Saclay, France 33 // 33 // 34 #define INCLXX_IN_GEANT4_MODE 1 34 #define INCLXX_IN_GEANT4_MODE 1 35 35 36 #include "globals.hh" 36 #include "globals.hh" 37 37 38 /** \file G4INCLXXInterfaceStore.cc 38 /** \file G4INCLXXInterfaceStore.cc 39 * \brief The G4INCLXXInterfaceStore class imp 39 * \brief The G4INCLXXInterfaceStore class implementation 40 * 40 * 41 * \date 24 May 2012 41 * \date 24 May 2012 42 * \author Davide Mancusi 42 * \author Davide Mancusi 43 */ 43 */ 44 44 45 #include "G4INCLXXInterfaceStore.hh" 45 #include "G4INCLXXInterfaceStore.hh" 46 #include "G4INCLXXInterfaceMessenger.hh" 46 #include "G4INCLXXInterfaceMessenger.hh" 47 #include "G4INCLConfigEnums.hh" 47 #include "G4INCLConfigEnums.hh" 48 #include "G4SystemOfUnits.hh" 48 #include "G4SystemOfUnits.hh" 49 #include "G4HadronicInteraction.hh" 49 #include "G4HadronicInteraction.hh" 50 #include "G4HadronicInteractionRegistry.hh" 50 #include "G4HadronicInteractionRegistry.hh" 51 #include "G4INCLXXInterface.hh" 51 #include "G4INCLXXInterface.hh" 52 #include "G4INCLConfig.hh" 52 #include "G4INCLConfig.hh" 53 #include "G4AblaInterface.hh" 53 #include "G4AblaInterface.hh" 54 #include "G4HadronicParameters.hh" << 55 #include <vector> 54 #include <vector> 56 55 57 G4ThreadLocal G4INCLXXInterfaceStore *G4INCLXX 56 G4ThreadLocal G4INCLXXInterfaceStore *G4INCLXXInterfaceStore::theInstance = NULL; 58 57 59 G4INCLXXInterfaceStore::G4INCLXXInterfaceStore 58 G4INCLXXInterfaceStore::G4INCLXXInterfaceStore() : 60 accurateProjectile(true), 59 accurateProjectile(true), 61 theMaxProjMassINCL(18), 60 theMaxProjMassINCL(18), 62 cascadeMinEnergyPerNucleon(1.*MeV), 61 cascadeMinEnergyPerNucleon(1.*MeV), 63 conservationTolerance(5*MeV), 62 conservationTolerance(5*MeV), 64 theINCLModel(NULL), 63 theINCLModel(NULL), 65 theTally(NULL), 64 theTally(NULL), 66 nWarnings(0), 65 nWarnings(0), 67 maxWarnings(50) 66 maxWarnings(50) 68 { 67 { 69 constructINCLXXVersionName(); 68 constructINCLXXVersionName(); 70 theINCLXXInterfaceMessenger = new G4INCLXXIn 69 theINCLXXInterfaceMessenger = new G4INCLXXInterfaceMessenger(this); 71 } 70 } 72 71 73 G4INCLXXInterfaceStore::~G4INCLXXInterfaceStor 72 G4INCLXXInterfaceStore::~G4INCLXXInterfaceStore() { 74 delete theINCLXXInterfaceMessenger; 73 delete theINCLXXInterfaceMessenger; 75 delete theINCLModel; 74 delete theINCLModel; 76 } 75 } 77 76 78 void G4INCLXXInterfaceStore::DeleteModel() { 77 void G4INCLXXInterfaceStore::DeleteModel() { 79 delete theINCLModel; theINCLModel=NULL; 78 delete theINCLModel; theINCLModel=NULL; 80 } 79 } 81 80 82 G4INCLXXInterfaceStore *G4INCLXXInterfaceStore 81 G4INCLXXInterfaceStore *G4INCLXXInterfaceStore::GetInstance() { 83 if(!theInstance) 82 if(!theInstance) 84 theInstance = new G4INCLXXInterfaceStore; 83 theInstance = new G4INCLXXInterfaceStore; 85 return theInstance; 84 return theInstance; 86 } 85 } 87 86 88 void G4INCLXXInterfaceStore::DeleteInstance() 87 void G4INCLXXInterfaceStore::DeleteInstance() { 89 delete theInstance; 88 delete theInstance; 90 theInstance = NULL; 89 theInstance = NULL; 91 } 90 } 92 91 93 G4INCL::INCL *G4INCLXXInterfaceStore::GetINCLM 92 G4INCL::INCL *G4INCLXXInterfaceStore::GetINCLModel() { 94 if(!theINCLModel) { 93 if(!theINCLModel) { 95 G4INCL::Config *aConfig = new G4INCL::Conf 94 G4INCL::Config *aConfig = new G4INCL::Config(theConfig); 96 theINCLModel = new G4INCL::INCL(aConfig); 95 theINCLModel = new G4INCL::INCL(aConfig); 97 // ownership of the aConfig object is take 96 // ownership of the aConfig object is taken over by the INCL model engine 98 } 97 } 99 return theINCLModel; 98 return theINCLModel; 100 } 99 } 101 100 102 void G4INCLXXInterfaceStore::constructINCLXXVe 101 void G4INCLXXInterfaceStore::constructINCLXXVersionName() { 103 const std::string versionID = G4INCL_VERSION 102 const std::string versionID = G4INCL_VERSION_ID; 104 const size_t lastDash = versionID.find_last_ 103 const size_t lastDash = versionID.find_last_of("-"); 105 versionName = "INCL++ " + versionID.substr(0 104 versionName = "INCL++ " + versionID.substr(0,lastDash); 106 } 105 } 107 106 108 const std::string &G4INCLXXInterfaceStore::get 107 const std::string &G4INCLXXInterfaceStore::getINCLXXVersionName() { 109 return versionName; 108 return versionName; 110 } 109 } 111 110 112 111 113 112 114 void G4INCLXXInterfaceStore::SetAccurateProjec 113 void G4INCLXXInterfaceStore::SetAccurateProjectile(const G4bool b) { 115 if(accurateProjectile!=b) { 114 if(accurateProjectile!=b) { 116 // Parameter is changed, emit a big warnin 115 // Parameter is changed, emit a big warning message 117 std::stringstream ss; 116 std::stringstream ss; 118 ss << "Switching from " 117 ss << "Switching from " 119 << (accurateProjectile ? "\"accurate pro 118 << (accurateProjectile ? "\"accurate projectile\" mode to \"accurate target\"" : "\"accurate target\" mode to \"accurate projectile\"") 120 << " mode." 119 << " mode." 121 << G4endl 120 << G4endl 122 << "Do this ONLY if you fully understand 121 << "Do this ONLY if you fully understand what it does!"; 123 EmitBigWarning(ss.str()); 122 EmitBigWarning(ss.str()); 124 } 123 } 125 124 126 // No need to delete the model for this para 125 // No need to delete the model for this parameter 127 126 128 accurateProjectile=b; 127 accurateProjectile=b; 129 } 128 } 130 129 131 void G4INCLXXInterfaceStore::SetMaxClusterMass 130 void G4INCLXXInterfaceStore::SetMaxClusterMass(const G4int aMass) { 132 const G4int theMaxClusterMass = theConfig.ge 131 const G4int theMaxClusterMass = theConfig.getClusterMaxMass(); 133 if(theMaxClusterMass!=aMass) { 132 if(theMaxClusterMass!=aMass) { 134 // Parameter is changed, emit a big warnin 133 // Parameter is changed, emit a big warning message 135 std::stringstream ss; 134 std::stringstream ss; 136 ss << "Changing maximum cluster mass from 135 ss << "Changing maximum cluster mass from " 137 << theMaxClusterMass 136 << theMaxClusterMass 138 << " to " 137 << " to " 139 << aMass 138 << aMass 140 << "." 139 << "." 141 << G4endl 140 << G4endl 142 << "Do this ONLY if you fully understand 141 << "Do this ONLY if you fully understand what this setting does!"; 143 EmitBigWarning(ss.str()); 142 EmitBigWarning(ss.str()); 144 143 145 // We must delete the model object to make 144 // We must delete the model object to make sure that we use the new 146 // parameter 145 // parameter 147 DeleteModel(); 146 DeleteModel(); 148 147 149 theConfig.setClusterMaxMass(aMass); 148 theConfig.setClusterMaxMass(aMass); 150 } 149 } 151 } 150 } 152 151 153 152 154 153 155 154 156 G4bool G4INCLXXInterfaceStore::GetAccurateProj 155 G4bool G4INCLXXInterfaceStore::GetAccurateProjectile() const { return accurateProjectile; } 157 156 158 G4double G4INCLXXInterfaceStore::GetCascadeMin 157 G4double G4INCLXXInterfaceStore::GetCascadeMinEnergyPerNucleon() const { return cascadeMinEnergyPerNucleon; } 159 158 160 G4INCL::Config &G4INCLXXInterfaceStore::GetINC 159 G4INCL::Config &G4INCLXXInterfaceStore::GetINCLConfig() { 161 DeleteModel(); // in case the Config is modi 160 DeleteModel(); // in case the Config is modified 162 return theConfig; 161 return theConfig; 163 } 162 } 164 163 165 G4double G4INCLXXInterfaceStore::GetConservati 164 G4double G4INCLXXInterfaceStore::GetConservationTolerance() const { return conservationTolerance; } 166 165 167 166 168 167 169 168 170 G4int G4INCLXXInterfaceStore::GetMaxProjMassIN 169 G4int G4INCLXXInterfaceStore::GetMaxProjMassINCL() const { return theMaxProjMassINCL; } 171 170 172 void G4INCLXXInterfaceStore::EmitWarning(const 171 void G4INCLXXInterfaceStore::EmitWarning(const G4String &message) { 173 if(++nWarnings<=maxWarnings) { 172 if(++nWarnings<=maxWarnings) { 174 G4cout << "[INCL++] Warning: " << message 173 G4cout << "[INCL++] Warning: " << message << G4endl; 175 if(nWarnings==maxWarnings) { 174 if(nWarnings==maxWarnings) { 176 G4cout << "[INCL++] INCL++ has already e 175 G4cout << "[INCL++] INCL++ has already emitted " << maxWarnings << " warnings and will emit no more." << G4endl; 177 } 176 } 178 } 177 } 179 } 178 } 180 179 181 void G4INCLXXInterfaceStore::EmitBigWarning(co 180 void G4INCLXXInterfaceStore::EmitBigWarning(const G4String &message) const { 182 // Disable the printing when global hadronic << 183 // (which can be issued via the UI command " << 184 if ( G4HadronicParameters::Instance()->GetVe << 185 G4cout 181 G4cout 186 << G4endl 182 << G4endl 187 << "====================================== 183 << "================================================================================" 188 << G4endl 184 << G4endl 189 << " INCL+ 185 << " INCL++ WARNING " 190 << G4endl 186 << G4endl 191 << message 187 << message 192 << G4endl 188 << G4endl 193 << "====================================== 189 << "================================================================================" 194 << G4endl 190 << G4endl 195 << G4endl; 191 << G4endl; 196 } 192 } 197 193 198 void G4INCLXXInterfaceStore::SetCascadeMinEner 194 void G4INCLXXInterfaceStore::SetCascadeMinEnergyPerNucleon(const G4double anEnergy) { 199 if(cascadeMinEnergyPerNucleon!=anEnergy) { 195 if(cascadeMinEnergyPerNucleon!=anEnergy) { 200 // Parameter is changed, emit a big warnin 196 // Parameter is changed, emit a big warning message 201 std::stringstream ss; 197 std::stringstream ss; 202 ss << "Changing minimim cascade energy fro 198 ss << "Changing minimim cascade energy from " 203 << cascadeMinEnergyPerNucleon / MeV 199 << cascadeMinEnergyPerNucleon / MeV 204 << " to " 200 << " to " 205 << anEnergy / MeV 201 << anEnergy / MeV 206 << " MeV." 202 << " MeV." 207 << G4endl 203 << G4endl 208 << "Do this ONLY if you fully understand 204 << "Do this ONLY if you fully understand what this setting does!"; 209 EmitBigWarning(ss.str()); 205 EmitBigWarning(ss.str()); 210 } 206 } 211 207 212 // No need to delete the model object 208 // No need to delete the model object 213 209 214 cascadeMinEnergyPerNucleon=anEnergy; 210 cascadeMinEnergyPerNucleon=anEnergy; 215 } 211 } 216 212 217 void G4INCLXXInterfaceStore::SetConservationTo 213 void G4INCLXXInterfaceStore::SetConservationTolerance(const G4double aTolerance) { 218 conservationTolerance = aTolerance; 214 conservationTolerance = aTolerance; 219 } 215 } 220 216 221 G4INCLXXVInterfaceTally *G4INCLXXInterfaceStor 217 G4INCLXXVInterfaceTally *G4INCLXXInterfaceStore::GetTally() const { return theTally; } 222 218 223 void G4INCLXXInterfaceStore::SetTally(G4INCLXX 219 void G4INCLXXInterfaceStore::SetTally(G4INCLXXVInterfaceTally * const aTally) { theTally = aTally; } 224 220 225 void G4INCLXXInterfaceStore::SetINCLPhysics(co 221 void G4INCLXXInterfaceStore::SetINCLPhysics(const G4String &option) { 226 if(option == "default") { 222 if(option == "default") { 227 theConfig.init(); 223 theConfig.init(); 228 } else if(option == "incl42") { 224 } else if(option == "incl42") { 229 const G4String message = "Changing INCL++ << 225 const G4String message = "Changing INCL++ physics to mimick INCL4.2. Do this ONLY if you fully understand the implications!"; 230 EmitBigWarning(message); 226 EmitBigWarning(message); 231 227 232 theConfig.setPotentialType(G4INCL::Constan 228 theConfig.setPotentialType(G4INCL::ConstantPotential); 233 theConfig.setPionPotential(false); 229 theConfig.setPionPotential(false); 234 theConfig.setLocalEnergyBBType(G4INCL::Nev 230 theConfig.setLocalEnergyBBType(G4INCL::NeverLocalEnergy); 235 theConfig.setLocalEnergyPiType(G4INCL::Nev 231 theConfig.setLocalEnergyPiType(G4INCL::NeverLocalEnergy); 236 theConfig.setBackToSpectator(false); 232 theConfig.setBackToSpectator(false); 237 theConfig.setClusterAlgorithm(G4INCL::NoCl 233 theConfig.setClusterAlgorithm(G4INCL::NoClusterAlgorithm); 238 theConfig.setCoulombType(G4INCL::NoCoulomb 234 theConfig.setCoulombType(G4INCL::NoCoulomb); 239 // UseRealMasses intentionally left out be 235 // UseRealMasses intentionally left out because it creates problems with 240 // energy conservation 236 // energy conservation 241 // theConfig.setUseRealMasses(false); 237 // theConfig.setUseRealMasses(false); 242 theConfig.setCrossSectionsType(G4INCL::INC 238 theConfig.setCrossSectionsType(G4INCL::INCL46CrossSections); 243 } else { 239 } else { 244 G4Exception("G4INCLXXInterfaceStore::SetIN 240 G4Exception("G4INCLXXInterfaceStore::SetINCLPhysics", "INCLXX0001", FatalErrorInArgument, 245 "SetINCLPhysics argument must 241 "SetINCLPhysics argument must be one of: default, incl42" 246 ); 242 ); 247 } 243 } 248 } 244 } 249 245 250 void G4INCLXXInterfaceStore::UseAblaDeExcitati 246 void G4INCLXXInterfaceStore::UseAblaDeExcitation() { 251 // Get hold of pointers to the INCL++ model 247 // Get hold of pointers to the INCL++ model interfaces 252 std::vector<G4HadronicInteraction *> const & 248 std::vector<G4HadronicInteraction *> const &interactions = G4HadronicInteractionRegistry::Instance() 253 ->FindAllModels(G4INCLXXInterfaceStore::Ge 249 ->FindAllModels(G4INCLXXInterfaceStore::GetInstance()->getINCLXXVersionName()); 254 for(std::vector<G4HadronicInteraction *>::co 250 for(std::vector<G4HadronicInteraction *>::const_iterator iInter=interactions.begin(), e=interactions.end(); 255 iInter!=e; ++iInter) { 251 iInter!=e; ++iInter) { 256 G4INCLXXInterface *theINCLInterface = dyna 252 G4INCLXXInterface *theINCLInterface = dynamic_cast<G4INCLXXInterface*>(*iInter); 257 if(theINCLInterface) { 253 if(theINCLInterface) { 258 // Instantiate the ABLA model 254 // Instantiate the ABLA model 259 G4HadronicInteraction *interaction = G4H 255 G4HadronicInteraction *interaction = G4HadronicInteractionRegistry::Instance()->FindModel("ABLA"); 260 G4AblaInterface *theAblaInterface = dyna 256 G4AblaInterface *theAblaInterface = dynamic_cast<G4AblaInterface*>(interaction); 261 if(!theAblaInterface) 257 if(!theAblaInterface) 262 theAblaInterface = new G4AblaInterface 258 theAblaInterface = new G4AblaInterface; 263 // Couple INCL++ to ABLA 259 // Couple INCL++ to ABLA 264 G4cout << "Coupling INCLXX to ABLA" << G 260 G4cout << "Coupling INCLXX to ABLA" << G4endl; 265 theINCLInterface->SetDeExcitation(theAbl 261 theINCLInterface->SetDeExcitation(theAblaInterface); 266 } 262 } 267 } 263 } 268 } 264 } 269 265