Geant4  10.01.p03
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 
46 #include "G4SystemOfUnits.hh"
47 
49 
51  accurateProjectile(true),
52  theMaxProjMassINCL(18),
53  cascadeMinEnergyPerNucleon(1.*MeV),
54  conservationTolerance(5*MeV),
55  theINCLModel(NULL),
56  theTally(NULL),
57  nWarnings(0),
58  maxWarnings(50)
59 {
62 }
63 
66  delete theINCLModel;
67 }
68 
70  delete theINCLModel; theINCLModel=NULL;
71 }
72 
74  if(!theInstance)
76  return theInstance;
77 }
78 
80  delete theInstance;
81  theInstance = NULL;
82 }
83 
85  if(!theINCLModel) {
86  G4INCL::Config *aConfig = new G4INCL::Config(theConfig);
87  theINCLModel = new G4INCL::INCL(aConfig);
88  // ownership of the aConfig object is taken over by the INCL model engine
89  }
90  return theINCLModel;
91 }
92 
94  const std::string versionID = G4INCL_VERSION_ID;
95  const size_t lastDash = versionID.find_last_of("-");
96  versionName = "INCL++ " + versionID.substr(0,lastDash);
97 }
98 
100  return versionName;
101 }
102 
103 
104 
106  if(accurateProjectile!=b) {
107  // Parameter is changed, emit a big warning message
108  std::stringstream ss;
109  ss << "Switching from "
110  << (accurateProjectile ? "\"accurate projectile\" mode to \"accurate target\"" : "\"accurate target\" mode to \"accurate projectile\"")
111  << " mode."
112  << G4endl
113  << "Do this ONLY if you fully understand what it does!";
114  EmitBigWarning(ss.str());
115  }
116 
117  // No need to delete the model for this parameter
118 
120 }
121 
123  const G4int theMaxClusterMass = theConfig.getClusterMaxMass();
124  if(theMaxClusterMass!=aMass) {
125  // Parameter is changed, emit a big warning message
126  std::stringstream ss;
127  ss << "Changing maximum cluster mass from "
128  << theMaxClusterMass
129  << " to "
130  << aMass
131  << "."
132  << G4endl
133  << "Do this ONLY if you fully understand what this setting does!";
134  EmitBigWarning(ss.str());
135 
136  // We must delete the model object to make sure that we use the new
137  // parameter
138  DeleteModel();
139 
141  }
142 }
143 
144 
145 
146 
148 
150 
152  DeleteModel(); // in case the Config is modified
153  return theConfig;
154 }
155 
157 
158 
159 
160 
162 
164  if(++nWarnings<=maxWarnings) {
165  G4cout << "[INCL++] Warning: " << message << G4endl;
166  if(nWarnings==maxWarnings) {
167  G4cout << "[INCL++] INCL++ has already emitted " << maxWarnings << " warnings and will emit no more." << G4endl;
168  }
169  }
170 }
171 
173  G4cout
174  << G4endl
175  << "================================================================================"
176  << G4endl
177  << " INCL++ WARNING "
178  << G4endl
179  << message
180  << G4endl
181  << "================================================================================"
182  << G4endl
183  << G4endl;
184 }
185 
187  if(cascadeMinEnergyPerNucleon!=anEnergy) {
188  // Parameter is changed, emit a big warning message
189  std::stringstream ss;
190  ss << "Changing minimim cascade energy from "
192  << " to "
193  << anEnergy / MeV
194  << " MeV."
195  << G4endl
196  << "Do this ONLY if you fully understand what this setting does!";
197  EmitBigWarning(ss.str());
198  }
199 
200  // No need to delete the model object
201 
203 }
204 
206  conservationTolerance = aTolerance;
207 }
208 
210 
212 
const G4int maxWarnings
Maximum number of warnings.
The INCL configuration object.
Definition: G4INCLConfig.hh:60
void SetConservationTolerance(const G4double aTolerance)
Setter for conservationTolerance.
static const double MeV
Definition: G4SIunits.hh:193
G4int GetMaxProjMassINCL() const
Getter for theMaxProjMassINCL.
G4double GetCascadeMinEnergyPerNucleon() const
Getter for cascadeMinEnergyPerNucleon.
#define G4INCL_VERSION_ID
void DeleteModel()
Delete the INCL model engine.
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
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
G4INCLXXVInterfaceTally * theTally
void SetCascadeMinEnergyPerNucleon(const G4double anEnergy)
Setter for cascadeMinEnergyPerNucleon.
G4INCLXXInterfaceStore()
Private constructor.
void SetTally(G4INCLXXVInterfaceTally *const aTally)
Setter for the interface tally.
G4int nWarnings
Static warning counter.
Messenger class for the Geant4 INCL++ interface.
G4bool GetAccurateProjectile() const
Getter for accurateProjectile.
G4double GetConservationTolerance() const
Getter for conservationTolerance.
#define G4endl
Definition: G4ios.hh:61
void setClusterMaxMass(const G4int m)
Set the maximum mass for production of clusters.
void EmitWarning(const G4String &message)
Emit a warning to G4cout.
G4INCLXXInterfaceMessenger * theINCLXXInterfaceMessenger
double G4double
Definition: G4Types.hh:76
void SetMaxClusterMass(const G4int aMass)
Setter for the maximum cluster mass.
static G4ThreadLocal G4INCLXXInterfaceStore * theInstance
Create a new Config object from the current options.
G4INCL::Config & GetINCLConfig()
Getter for theConfig.
G4INCLXXVInterfaceTally * GetTally() const
Getter for the interface tally.
static void DeleteInstance()
Delete the singleton instance.
~G4INCLXXInterfaceStore()
Private destructor.