Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4INCLXXInterfaceStore.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// INCL++ intra-nuclear cascade model
27// Alain Boudard, CEA-Saclay, France
28// Joseph Cugnon, University of Liege, Belgium
29// Jean-Christophe David, CEA-Saclay, France
30// Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
31// Sylvie Leray, CEA-Saclay, France
32// Davide Mancusi, CEA-Saclay, France
33//
34#define INCLXX_IN_GEANT4_MODE 1
35
36#include "globals.hh"
37
38/** \file G4INCLXXInterfaceStore.cc
39 * \brief The G4INCLXXInterfaceStore class implementation
40 *
41 * \date 24 May 2012
42 * \author Davide Mancusi
43 */
44
47#include "G4INCLConfigEnums.hh"
48#include "G4SystemOfUnits.hh"
51#include "G4INCLXXInterface.hh"
52#include "G4INCLConfig.hh"
53#include "G4AblaInterface.hh"
55#include <vector>
56
57G4ThreadLocal G4INCLXXInterfaceStore *G4INCLXXInterfaceStore::theInstance = NULL;
58
59G4INCLXXInterfaceStore::G4INCLXXInterfaceStore() :
60 accurateProjectile(true),
61 theMaxProjMassINCL(18),
62 cascadeMinEnergyPerNucleon(1.*MeV),
63 conservationTolerance(5*MeV),
64 theINCLModel(NULL),
65 theTally(NULL),
66 nWarnings(0),
67 maxWarnings(50)
68{
69 constructINCLXXVersionName();
70 theINCLXXInterfaceMessenger = new G4INCLXXInterfaceMessenger(this);
71}
72
73G4INCLXXInterfaceStore::~G4INCLXXInterfaceStore() {
74 delete theINCLXXInterfaceMessenger;
75 delete theINCLModel;
76}
77
78void G4INCLXXInterfaceStore::DeleteModel() {
79 delete theINCLModel; theINCLModel=NULL;
80}
81
83 if(!theInstance)
84 theInstance = new G4INCLXXInterfaceStore;
85 return theInstance;
86}
87
89 delete theInstance;
90 theInstance = NULL;
91}
92
94 if(!theINCLModel) {
95 G4INCL::Config *aConfig = new G4INCL::Config(theConfig);
96 theINCLModel = new G4INCL::INCL(aConfig);
97 // ownership of the aConfig object is taken over by the INCL model engine
98 }
99 return theINCLModel;
100}
101
103 const std::string versionID = G4INCL_VERSION_ID;
104 const size_t lastDash = versionID.find_last_of("-");
105 versionName = "INCL++ " + versionID.substr(0,lastDash);
106}
107
109 return versionName;
110}
111
112
113
115 if(accurateProjectile!=b) {
116 // Parameter is changed, emit a big warning message
117 std::stringstream ss;
118 ss << "Switching from "
119 << (accurateProjectile ? "\"accurate projectile\" mode to \"accurate target\"" : "\"accurate target\" mode to \"accurate projectile\"")
120 << " mode."
121 << G4endl
122 << "Do this ONLY if you fully understand what it does!";
123 EmitBigWarning(ss.str());
124 }
125
126 // No need to delete the model for this parameter
127
128 accurateProjectile=b;
129}
130
132 const G4int theMaxClusterMass = theConfig.getClusterMaxMass();
133 if(theMaxClusterMass!=aMass) {
134 // Parameter is changed, emit a big warning message
135 std::stringstream ss;
136 ss << "Changing maximum cluster mass from "
137 << theMaxClusterMass
138 << " to "
139 << aMass
140 << "."
141 << G4endl
142 << "Do this ONLY if you fully understand what this setting does!";
143 EmitBigWarning(ss.str());
144
145 // We must delete the model object to make sure that we use the new
146 // parameter
147 DeleteModel();
148
149 theConfig.setClusterMaxMass(aMass);
150 }
151}
152
153
154
155
156G4bool G4INCLXXInterfaceStore::GetAccurateProjectile() const { return accurateProjectile; }
157
158G4double G4INCLXXInterfaceStore::GetCascadeMinEnergyPerNucleon() const { return cascadeMinEnergyPerNucleon; }
159
161 DeleteModel(); // in case the Config is modified
162 return theConfig;
163}
164
165G4double G4INCLXXInterfaceStore::GetConservationTolerance() const { return conservationTolerance; }
166
167
168
169
170G4int G4INCLXXInterfaceStore::GetMaxProjMassINCL() const { return theMaxProjMassINCL; }
171
173 if(++nWarnings<=maxWarnings) {
174 G4cout << "[INCL++] Warning: " << message << G4endl;
175 if(nWarnings==maxWarnings) {
176 G4cout << "[INCL++] INCL++ has already emitted " << maxWarnings << " warnings and will emit no more." << G4endl;
177 }
178 }
179}
180
182 // Disable the printing when global hadronic verbosity is zero
183 // (which can be issued via the UI command "/process/had/verbose 0" )
184 if ( G4HadronicParameters::Instance()->GetVerboseLevel() == 0 ) return;
185 G4cout
186 << G4endl
187 << "================================================================================"
188 << G4endl
189 << " INCL++ WARNING "
190 << G4endl
191 << message
192 << G4endl
193 << "================================================================================"
194 << G4endl
195 << G4endl;
196}
197
199 if(cascadeMinEnergyPerNucleon!=anEnergy) {
200 // Parameter is changed, emit a big warning message
201 std::stringstream ss;
202 ss << "Changing minimim cascade energy from "
203 << cascadeMinEnergyPerNucleon / MeV
204 << " to "
205 << anEnergy / MeV
206 << " MeV."
207 << G4endl
208 << "Do this ONLY if you fully understand what this setting does!";
209 EmitBigWarning(ss.str());
210 }
211
212 // No need to delete the model object
213
214 cascadeMinEnergyPerNucleon=anEnergy;
215}
216
218 conservationTolerance = aTolerance;
219}
220
222
223void G4INCLXXInterfaceStore::SetTally(G4INCLXXVInterfaceTally * const aTally) { theTally = aTally; }
224
226 if(option == "default") {
227 theConfig.init();
228 } else if(option == "incl42") {
229 const G4String message = "Changing INCL++ physics to mimic INCL4.2. Do this ONLY if you fully understand the implications!";
230 EmitBigWarning(message);
231
233 theConfig.setPionPotential(false);
236 theConfig.setBackToSpectator(false);
239 // UseRealMasses intentionally left out because it creates problems with
240 // energy conservation
241 // theConfig.setUseRealMasses(false);
243 } else {
244 G4Exception("G4INCLXXInterfaceStore::SetINCLPhysics", "INCLXX0001", FatalErrorInArgument,
245 "SetINCLPhysics argument must be one of: default, incl42"
246 );
247 }
248}
249
251 // Get hold of pointers to the INCL++ model interfaces
252 std::vector<G4HadronicInteraction *> const &interactions = G4HadronicInteractionRegistry::Instance()
254 for(std::vector<G4HadronicInteraction *>::const_iterator iInter=interactions.begin(), e=interactions.end();
255 iInter!=e; ++iInter) {
256 G4INCLXXInterface *theINCLInterface = dynamic_cast<G4INCLXXInterface*>(*iInter);
257 if(theINCLInterface) {
258 // Instantiate the ABLA model
260 G4AblaInterface *theAblaInterface = dynamic_cast<G4AblaInterface*>(interaction);
261 if(!theAblaInterface)
262 theAblaInterface = new G4AblaInterface;
263 // Couple INCL++ to ABLA
264 G4cout << "Coupling INCLXX to ABLA" << G4endl;
265 theINCLInterface->SetDeExcitation(theAblaInterface);
266 }
267 }
268}
const G4int maxWarnings
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
#define G4INCL_VERSION_ID
Messenger class for the Geant4 INCL++ interface.
Header file for the G4INCLXXInterfaceStore class.
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
std::vector< G4HadronicInteraction * > FindAllModels(const G4String &name)
G4HadronicInteraction * FindModel(const G4String &name)
static G4HadronicInteractionRegistry * Instance()
static G4HadronicParameters * Instance()
Singleton class for configuring the INCL++ Geant4 interface.
void EmitWarning(const G4String &message)
Emit a warning to G4cout.
static G4INCLXXInterfaceStore * GetInstance()
Get the singleton instance.
void SetAccurateProjectile(const G4bool b)
Setter for accurateProjectile.
void SetCascadeMinEnergyPerNucleon(const G4double anEnergy)
Setter for cascadeMinEnergyPerNucleon.
G4int GetMaxProjMassINCL() const
Getter for theMaxProjMassINCL.
G4INCL::INCL * GetINCLModel()
Get the cached INCL model engine.
void SetTally(G4INCLXXVInterfaceTally *const aTally)
Setter for the interface tally.
G4double GetConservationTolerance() const
Getter for conservationTolerance.
static void DeleteInstance()
Delete the singleton instance.
void EmitBigWarning(const G4String &message) const
Emit a BIG warning to G4cout.
G4INCL::Config & GetINCLConfig()
Getter for theConfig.
void SetConservationTolerance(const G4double aTolerance)
Setter for conservationTolerance.
G4double GetCascadeMinEnergyPerNucleon() const
Getter for cascadeMinEnergyPerNucleon.
G4INCLXXVInterfaceTally * GetTally() const
Getter for the interface tally.
void UseAblaDeExcitation()
Set ABLA V3 to be the de-excitation model to be used with INCL++.
const std::string & getINCLXXVersionName()
void SetMaxClusterMass(const G4int aMass)
Setter for the maximum cluster mass.
G4bool GetAccurateProjectile() const
Getter for accurateProjectile.
void SetINCLPhysics(const G4String &option)
Set the INCL physics.
INCL++ intra-nuclear cascade.
void SetDeExcitation(G4VPreCompoundModel *ptr)
void setClusterAlgorithm(ClusterAlgorithmType const c)
Set the clustering algorithm.
void setLocalEnergyPiType(const LocalEnergyType t)
Set the type of local energy for N-N avatars.
void setBackToSpectator(const G4bool b)
Set back-to-spectator.
G4int getClusterMaxMass() const
Get the maximum mass for production of clusters.
void setCoulombType(CoulombType const c)
Set the Coulomb-distortion algorithm.
void setPionPotential(const G4bool pionPot)
Set the type of the potential for nucleons.
void setPotentialType(PotentialType type)
Set the type of the potential for nucleons.
void setCrossSectionsType(CrossSectionsType const c)
Set the Cross Section type.
void init()
Initialise the members.
Definition: G4INCLConfig.cc:51
void setLocalEnergyBBType(const LocalEnergyType t)
Set the type of local energy for N-N avatars.
void setClusterMaxMass(const G4int m)
Set the maximum mass for production of clusters.
#define G4ThreadLocal
Definition: tls.hh:77