Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
28 // Davide Mancusi, CEA
29 // Alain Boudard, CEA
30 // Sylvie Leray, CEA
31 // Joseph Cugnon, University of Liege
32 //
33 #define INCLXX_IN_GEANT4_MODE 1
34 
35 #include "globals.hh"
36 
37 /** \file G4INCLXXInterfaceStore.cc
38  * \brief The G4INCLXXInterfaceStore class implementation
39  *
40  * \date 24 May 2012
41  * \author Davide Mancusi
42  */
43 
45 #include "G4SystemOfUnits.hh"
46 
47 G4ThreadLocal G4INCLXXInterfaceStore *G4INCLXXInterfaceStore::theInstance = NULL;
48 
49 G4INCLXXInterfaceStore::G4INCLXXInterfaceStore() :
50  accurateProjectile(true),
51  theMaxProjMassINCL(18),
52  cascadeMinEnergyPerNucleon(1.*MeV),
53  conservationTolerance(5*MeV),
54  theINCLModel(NULL),
55  nWarnings(0),
56  maxWarnings(50)
57 {
58  constructINCLXXVersionName();
59  theINCLXXInterfaceMessenger = new G4INCLXXInterfaceMessenger(this);
60 }
61 
62 G4INCLXXInterfaceStore::~G4INCLXXInterfaceStore() {
63  delete theINCLXXInterfaceMessenger;
64  delete theINCLModel;
65 }
66 
67 void G4INCLXXInterfaceStore::DeleteModel() {
68  delete theINCLModel; theINCLModel=NULL;
69 }
70 
72  if(!theInstance)
73  theInstance = new G4INCLXXInterfaceStore;
74  return theInstance;
75 }
76 
78  delete theInstance;
79  theInstance = NULL;
80 }
81 
83  if(!theINCLModel) {
84  G4INCL::Config *aConfig = new G4INCL::Config(theConfig);
85  theINCLModel = new G4INCL::INCL(aConfig);
86  // ownership of the aConfig object is taken over by the INCL model engine
87  }
88  return theINCLModel;
89 }
90 
92  const std::string versionID = G4INCL_VERSION_ID;
93  const size_t lastDash = versionID.find_last_of("-");
94  versionName = "INCL++ " + versionID.substr(0,lastDash);
95 }
96 
98  return versionName;
99 }
100 
101 
102 
104  if(accurateProjectile!=b) {
105  // Parameter is changed, emit a big warning message
106  std::stringstream ss;
107  ss << "Switching from "
108  << (accurateProjectile ? "\"accurate projectile\" mode to \"accurate target\"" : "\"accurate target\" mode to \"accurate projectile\"")
109  << " mode."
110  << G4endl
111  << "Do this ONLY if you fully understand what it does!";
112  EmitBigWarning(ss.str());
113  }
114 
115  // No need to delete the model for this parameter
116 
117  accurateProjectile=b;
118 }
119 
121  const G4int theMaxClusterMass = theConfig.getClusterMaxMass();
122  if(theMaxClusterMass!=aMass) {
123  // Parameter is changed, emit a big warning message
124  std::stringstream ss;
125  ss << "Changing maximum cluster mass from "
126  << theMaxClusterMass
127  << " to "
128  << aMass
129  << "."
130  << G4endl
131  << "Do this ONLY if you fully understand what this setting does!";
132  EmitBigWarning(ss.str());
133 
134  // We must delete the model object to make sure that we use the new
135  // parameter
136  DeleteModel();
137 
138  theConfig.setClusterMaxMass(aMass);
139  }
140 }
141 
142 
143 
144 
145 G4bool G4INCLXXInterfaceStore::GetAccurateProjectile() const { return accurateProjectile; }
146 
147 G4double G4INCLXXInterfaceStore::GetCascadeMinEnergyPerNucleon() const { return cascadeMinEnergyPerNucleon; }
148 
150 
151 G4double G4INCLXXInterfaceStore::GetConservationTolerance() const { return conservationTolerance; }
152 
153 
154 
155 
156 G4int G4INCLXXInterfaceStore::GetMaxProjMassINCL() const { return theMaxProjMassINCL; }
157 
159  if(++nWarnings<=maxWarnings) {
160  G4cout << "[INCL++] Warning: " << message << G4endl;
161  if(nWarnings==maxWarnings) {
162  G4cout << "[INCL++] INCL++ has already emitted " << maxWarnings << " warnings and will emit no more." << G4endl;
163  }
164  }
165 }
166 
168  G4cout
169  << G4endl
170  << "================================================================================"
171  << G4endl
172  << " INCL++ WARNING "
173  << G4endl
174  << message
175  << G4endl
176  << "================================================================================"
177  << G4endl
178  << G4endl;
179 }
180 
182  if(cascadeMinEnergyPerNucleon!=anEnergy) {
183  // Parameter is changed, emit a big warning message
184  std::stringstream ss;
185  ss << "Changing minimim cascade energy from "
186  << cascadeMinEnergyPerNucleon / MeV
187  << " to "
188  << anEnergy / MeV
189  << " MeV."
190  << G4endl
191  << "Do this ONLY if you fully understand what this setting does!";
192  EmitBigWarning(ss.str());
193  }
194 
195  // No need to delete the model object
196 
197  cascadeMinEnergyPerNucleon=anEnergy;
198 }
199 
201  conservationTolerance = aTolerance;
202 }
203 
void SetConservationTolerance(const G4double aTolerance)
Setter for conservationTolerance.
G4int GetMaxProjMassINCL() const
Getter for theMaxProjMassINCL.
G4double GetCascadeMinEnergyPerNucleon() const
Getter for cascadeMinEnergyPerNucleon.
#define G4INCL_VERSION_ID
const std::string & getINCLXXVersionName()
G4int getClusterMaxMass() const
Get the maximum mass for production of clusters.
#define G4ThreadLocal
Definition: tls.hh:52
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
void SetCascadeMinEnergyPerNucleon(const G4double anEnergy)
Setter for cascadeMinEnergyPerNucleon.
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.
double G4double
Definition: G4Types.hh:76
void SetMaxClusterMass(const G4int aMass)
Setter for the maximum cluster mass.
G4INCL::Config & GetINCLConfig()
Getter for theConfig.
static void DeleteInstance()
Delete the singleton instance.