Geant4_10
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 
45 #include "G4SystemOfUnits.hh"
46 
47 G4ThreadLocal G4INCLXXInterfaceStore *G4INCLXXInterfaceStore::theInstance = NULL;
48 
49 G4INCLXXInterfaceStore::G4INCLXXInterfaceStore() :
50  accurateProjectile(true),
51  theMaxClusterMassDefault(8),
52  theMaxClusterMass(theMaxClusterMassDefault),
53  theMaxProjMassINCL(18),
54  cascadeMinEnergyPerNucleon(1.*MeV),
55  conservationTolerance(5*MeV),
56  theINCLModel(NULL),
57  nWarnings(0),
58  maxWarnings(50)
59 {
60  constructINCLXXVersionName();
61  theINCLXXInterfaceMessenger = new G4INCLXXInterfaceMessenger(this);
62 }
63 
64 G4INCLXXInterfaceStore::~G4INCLXXInterfaceStore() {
65  delete theINCLXXInterfaceMessenger;
66  delete theINCLModel;
67 }
68 
70  if(!theInstance)
71  theInstance = new G4INCLXXInterfaceStore;
72  return theInstance;
73 }
74 
76  delete theInstance;
77  theInstance = NULL;
78 }
79 
81  if(!theINCLModel) {
82  G4INCL::Config *theConfig = new G4INCL::Config;
83  theConfig->setClusterMaxMass(theMaxClusterMass);
84  theINCLModel = new G4INCL::INCL(theConfig);
85  // ownership of the Config object is taken over by the INCL model engine
86  }
87  return theINCLModel;
88 }
89 
91  const std::string versionID = G4INCL_VERSION_ID;
92  const size_t lastDash = versionID.find_last_of("-");
93  versionName = "INCL++ " + versionID.substr(0,lastDash);
94 }
95 
97  return versionName;
98 }
99 
100 
101 
103  if(accurateProjectile!=b) {
104  // Parameter is changed, emit a big warning message
105  std::stringstream ss;
106  ss << "Switching from "
107  << (accurateProjectile ? "\"accurate projectile\" mode to \"accurate target\"" : "\"accurate target\" mode to \"accurate projectile\"")
108  << " mode."
109  << G4endl
110  << "Do this ONLY if you fully understand what it does!";
111  EmitBigWarning(ss.str());
112  }
113 
114  // No need to delete the model for this parameter
115 
116  accurateProjectile=b;
117 }
118 
120  if(theMaxClusterMass!=aMass) {
121  // Parameter is changed, emit a big warning message
122  std::stringstream ss;
123  ss << "Changing maximum cluster mass from "
124  << theMaxClusterMass
125  << " to "
126  << aMass
127  << "."
128  << G4endl
129  << "Do this ONLY if you fully understand what this setting does!";
130  EmitBigWarning(ss.str());
131  }
132 
133  // We must delete the model object to make sure that we use the new
134  // parameter
135  DeleteModel();
136 
137  theMaxClusterMass=aMass;
138 }
139 
140 
141 
142 
143 G4bool G4INCLXXInterfaceStore::GetAccurateProjectile() const { return accurateProjectile; }
144 
145 G4double G4INCLXXInterfaceStore::GetCascadeMinEnergyPerNucleon() const { return cascadeMinEnergyPerNucleon; }
146 
147 G4int G4INCLXXInterfaceStore::GetMaxClusterMass() const { return theMaxClusterMass; }
148 
149 G4double G4INCLXXInterfaceStore::GetConservationTolerance() const { return conservationTolerance; }
150 
151 
152 
153 
154 G4int G4INCLXXInterfaceStore::GetMaxProjMassINCL() const { return theMaxProjMassINCL; }
155 
157  if(++nWarnings<=maxWarnings) {
158  G4cout << "[INCL++] Warning: " << message << G4endl;
159  if(nWarnings==maxWarnings) {
160  G4cout << "[INCL++] INCL++ has already emitted " << maxWarnings << " warnings and will emit no more." << G4endl;
161  }
162  }
163 }
164 
166  G4cout
167  << G4endl
168  << "================================================================================"
169  << G4endl
170  << " INCL++ WARNING "
171  << G4endl
172  << message
173  << G4endl
174  << "================================================================================"
175  << G4endl
176  << G4endl;
177 }
178 
180  if(cascadeMinEnergyPerNucleon!=anEnergy) {
181  // Parameter is changed, emit a big warning message
182  std::stringstream ss;
183  ss << "Changing minimim cascade energy from "
184  << cascadeMinEnergyPerNucleon / MeV
185  << " to "
186  << anEnergy / MeV
187  << " MeV."
188  << G4endl
189  << "Do this ONLY if you fully understand what this setting does!";
190  EmitBigWarning(ss.str());
191  }
192 
193  // No need to delete the model object
194 
195  cascadeMinEnergyPerNucleon=anEnergy;
196 }
197 
199  conservationTolerance = aTolerance;
200 }
201 
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()
#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.
tuple b
Definition: test.py:12
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.
G4int GetMaxClusterMass() const
Getter for ClusterMaxMass.
void EmitWarning(const G4String &message)
Emit a warning to G4cout.
double G4double
Definition: G4Types.hh:76
void SetMaxClusterMass(const G4int aMass)
Setter for theMaxClusterMass.
static void DeleteInstance()
Delete the singleton instance.