Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
47 #include "G4INCLConfigEnums.hh"
48 #include "G4SystemOfUnits.hh"
49 #include "G4HadronicInteraction.hh"
51 #include "G4INCLXXInterface.hh"
52 #include "G4INCLConfig.hh"
53 #include "G4AblaInterface.hh"
54 #include <vector>
55 
56 G4ThreadLocal G4INCLXXInterfaceStore *G4INCLXXInterfaceStore::theInstance = NULL;
57 
58 G4INCLXXInterfaceStore::G4INCLXXInterfaceStore() :
59  accurateProjectile(true),
60  theMaxProjMassINCL(18),
61  cascadeMinEnergyPerNucleon(1.*MeV),
62  conservationTolerance(5*MeV),
63  theINCLModel(NULL),
64  theTally(NULL),
65  nWarnings(0),
66  maxWarnings(50)
67 {
68  constructINCLXXVersionName();
69  theINCLXXInterfaceMessenger = new G4INCLXXInterfaceMessenger(this);
70 }
71 
72 G4INCLXXInterfaceStore::~G4INCLXXInterfaceStore() {
73  delete theINCLXXInterfaceMessenger;
74  delete theINCLModel;
75 }
76 
77 void G4INCLXXInterfaceStore::DeleteModel() {
78  delete theINCLModel; theINCLModel=NULL;
79 }
80 
82  if(!theInstance)
83  theInstance = new G4INCLXXInterfaceStore;
84  return theInstance;
85 }
86 
88  delete theInstance;
89  theInstance = NULL;
90 }
91 
93  if(!theINCLModel) {
94  G4INCL::Config *aConfig = new G4INCL::Config(theConfig);
95  theINCLModel = new G4INCL::INCL(aConfig);
96  // ownership of the aConfig object is taken over by the INCL model engine
97  }
98  return theINCLModel;
99 }
100 
102  const std::string versionID = G4INCL_VERSION_ID;
103  const size_t lastDash = versionID.find_last_of("-");
104  versionName = "INCL++ " + versionID.substr(0,lastDash);
105 }
106 
108  return versionName;
109 }
110 
111 
112 
114  if(accurateProjectile!=b) {
115  // Parameter is changed, emit a big warning message
116  std::stringstream ss;
117  ss << "Switching from "
118  << (accurateProjectile ? "\"accurate projectile\" mode to \"accurate target\"" : "\"accurate target\" mode to \"accurate projectile\"")
119  << " mode."
120  << G4endl
121  << "Do this ONLY if you fully understand what it does!";
122  EmitBigWarning(ss.str());
123  }
124 
125  // No need to delete the model for this parameter
126 
127  accurateProjectile=b;
128 }
129 
131  const G4int theMaxClusterMass = theConfig.getClusterMaxMass();
132  if(theMaxClusterMass!=aMass) {
133  // Parameter is changed, emit a big warning message
134  std::stringstream ss;
135  ss << "Changing maximum cluster mass from "
136  << theMaxClusterMass
137  << " to "
138  << aMass
139  << "."
140  << G4endl
141  << "Do this ONLY if you fully understand what this setting does!";
142  EmitBigWarning(ss.str());
143 
144  // We must delete the model object to make sure that we use the new
145  // parameter
146  DeleteModel();
147 
148  theConfig.setClusterMaxMass(aMass);
149  }
150 }
151 
152 
153 
154 
155 G4bool G4INCLXXInterfaceStore::GetAccurateProjectile() const { return accurateProjectile; }
156 
157 G4double G4INCLXXInterfaceStore::GetCascadeMinEnergyPerNucleon() const { return cascadeMinEnergyPerNucleon; }
158 
160  DeleteModel(); // in case the Config is modified
161  return theConfig;
162 }
163 
164 G4double G4INCLXXInterfaceStore::GetConservationTolerance() const { return conservationTolerance; }
165 
166 
167 
168 
169 G4int G4INCLXXInterfaceStore::GetMaxProjMassINCL() const { return theMaxProjMassINCL; }
170 
172  if(++nWarnings<=maxWarnings) {
173  G4cout << "[INCL++] Warning: " << message << G4endl;
174  if(nWarnings==maxWarnings) {
175  G4cout << "[INCL++] INCL++ has already emitted " << maxWarnings << " warnings and will emit no more." << G4endl;
176  }
177  }
178 }
179 
181  G4cout
182  << G4endl
183  << "================================================================================"
184  << G4endl
185  << " INCL++ WARNING "
186  << G4endl
187  << message
188  << G4endl
189  << "================================================================================"
190  << G4endl
191  << G4endl;
192 }
193 
195  if(cascadeMinEnergyPerNucleon!=anEnergy) {
196  // Parameter is changed, emit a big warning message
197  std::stringstream ss;
198  ss << "Changing minimim cascade energy from "
199  << cascadeMinEnergyPerNucleon / MeV
200  << " to "
201  << anEnergy / MeV
202  << " MeV."
203  << G4endl
204  << "Do this ONLY if you fully understand what this setting does!";
205  EmitBigWarning(ss.str());
206  }
207 
208  // No need to delete the model object
209 
210  cascadeMinEnergyPerNucleon=anEnergy;
211 }
212 
214  conservationTolerance = aTolerance;
215 }
216 
218 
219 void G4INCLXXInterfaceStore::SetTally(G4INCLXXVInterfaceTally * const aTally) { theTally = aTally; }
220 
222  if(option == "default") {
223  theConfig.init();
224  } else if(option == "incl42") {
225  const G4String message = "Changing INCL++ physics to mimick INCL4.2. Do this ONLY if you fully understand the implications!";
226  EmitBigWarning(message);
227 
229  theConfig.setPionPotential(false);
232  theConfig.setBackToSpectator(false);
235  // UseRealMasses intentionally left out because it creates problems with
236  // energy conservation
237  // theConfig.setUseRealMasses(false);
239  } else {
240  G4Exception("G4INCLXXInterfaceStore::SetINCLPhysics", "INCLXX0001", FatalErrorInArgument,
241  "SetINCLPhysics argument must be one of: default, incl42"
242  );
243  }
244 }
245 
247  // Get hold of pointers to the INCL++ model interfaces
248  std::vector<G4HadronicInteraction *> const &interactions = G4HadronicInteractionRegistry::Instance()
250  for(std::vector<G4HadronicInteraction *>::const_iterator iInter=interactions.begin(), e=interactions.end();
251  iInter!=e; ++iInter) {
252  G4INCLXXInterface *theINCLInterface = dynamic_cast<G4INCLXXInterface*>(*iInter);
253  if(theINCLInterface) {
254  // Instantiate the ABLA model
256  G4AblaInterface *theAblaInterface = dynamic_cast<G4AblaInterface*>(interaction);
257  if(!theAblaInterface)
258  theAblaInterface = new G4AblaInterface;
259  // Couple INCL++ to ABLA
260  G4cout << "Coupling INCLXX to ABLA" << G4endl;
261  theINCLInterface->SetDeExcitation(theAblaInterface);
262  }
263  }
264 }
void SetConservationTolerance(const G4double aTolerance)
Setter for conservationTolerance.
G4int GetMaxProjMassINCL() const
Getter for theMaxProjMassINCL.
G4double GetCascadeMinEnergyPerNucleon() const
Getter for cascadeMinEnergyPerNucleon.
#define G4INCL_VERSION_ID
void UseAblaDeExcitation()
Set ABLA V3 to be the de-excitation model to be used with INCL++.
std::vector< G4HadronicInteraction * > FindAllModels(const G4String &name)
const std::string & getINCLXXVersionName()
G4int getClusterMaxMass() const
Get the maximum mass for production of clusters.
#define G4ThreadLocal
Definition: tls.hh:89
void EmitBigWarning(const G4String &message) const
Emit a BIG warning to G4cout.
int G4int
Definition: G4Types.hh:78
Header file for the G4INCLXXInterfaceStore class.
INCL++ intra-nuclear cascade.
void setLocalEnergyBBType(const LocalEnergyType t)
Set the type of local energy for N-N avatars.
void SetAccurateProjectile(const G4bool b)
Setter for accurateProjectile.
static G4INCLXXInterfaceStore * GetInstance()
Get the singleton instance.
Singleton class for configuring the INCL++ Geant4 interface.
G4GLOB_DLL std::ostream G4cout
G4INCL::INCL * GetINCLModel()
Get the cached INCL model engine.
bool G4bool
Definition: G4Types.hh:79
void setLocalEnergyPiType(const LocalEnergyType t)
Set the type of local energy for N-N avatars.
void SetCascadeMinEnergyPerNucleon(const G4double anEnergy)
Setter for cascadeMinEnergyPerNucleon.
void setClusterAlgorithm(ClusterAlgorithmType const c)
Set the clustering algorithm.
void SetINCLPhysics(const G4String &option)
Set the INCL physics.
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetTally(G4INCLXXVInterfaceTally *const aTally)
Setter for the interface tally.
G4HadronicInteraction * FindModel(const G4String &name)
void setCoulombType(CoulombType const c)
Set the Coulomb-distortion algorithm.
void init()
Initialise the members.
Definition: G4INCLConfig.cc:51
void setPotentialType(PotentialType type)
Set the type of the potential for nucleons.
static G4HadronicInteractionRegistry * Instance()
Messenger class for the Geant4 INCL++ interface.
G4bool GetAccurateProjectile() const
Getter for accurateProjectile.
G4double GetConservationTolerance() const
Getter for conservationTolerance.
void SetDeExcitation(G4VPreCompoundModel *ptr)
#define G4endl
Definition: G4ios.hh:61
void setClusterMaxMass(const G4int m)
Set the maximum mass for production of clusters.
static constexpr double MeV
Definition: G4SIunits.hh:214
void setPionPotential(const G4bool pionPot)
Set the type of the potential for nucleons.
void EmitWarning(const G4String &message)
Emit a warning to G4cout.
double G4double
Definition: G4Types.hh:76
void setBackToSpectator(const G4bool b)
Set back-to-spectator.
void SetMaxClusterMass(const G4int aMass)
Setter for the maximum cluster mass.
void setCrossSectionsType(CrossSectionsType const c)
Set the Cross Section type.
G4INCL::Config & GetINCLConfig()
Getter for theConfig.
G4INCLXXVInterfaceTally * GetTally() const
Getter for the interface tally.
static void DeleteInstance()
Delete the singleton instance.