Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4HadronicParameters.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//
27//---------------------------------------------------------------------------
28//
29// ClassName: G4HadronicParameters
30//
31// Author: 2018 Alberto Ribon
32//
33// Description: Singleton to keep global hadronic parameters.
34//
35// Modified:
36//
37//----------------------------------------------------------------------------
38
41#include "G4ApplicationState.hh"
42#include "G4StateManager.hh"
44#include "G4Threading.hh"
45#include "G4AutoLock.hh"
46#include "G4UnitsTable.hh"
47
48G4HadronicParameters* G4HadronicParameters::sInstance = nullptr;
49
50namespace {
51 G4Mutex paramMutex = G4MUTEX_INITIALIZER;
52}
53
54
55G4HadronicParameters* G4HadronicParameters::Instance() {
56 if ( sInstance == nullptr ) {
57 G4AutoLock l(&paramMutex);
58 if ( sInstance == nullptr ) {
59 static G4HadronicParameters theHadronicParametersObject;
60 sInstance = &theHadronicParametersObject;
61 }
62 l.unlock();
63 }
64 return sInstance;
65}
66
67
69 delete fMessenger;
70}
71
72
73G4HadronicParameters::G4HadronicParameters() {
74 fMaxEnergy = 100.0*CLHEP::TeV;
75 fMinEnergyTransitionFTF_Cascade = 3.0*CLHEP::GeV;
76 fMaxEnergyTransitionFTF_Cascade = 6.0*CLHEP::GeV;
77 fMinEnergyTransitionQGS_FTF = 12.0*CLHEP::GeV;
78 fMaxEnergyTransitionQGS_FTF = 25.0*CLHEP::GeV;
79 fMinEnergyINCLXX_Pbar = 0.0*CLHEP::GeV;
80 fMaxEnergyINCLXX_Pbar = 10.0*CLHEP::GeV;
81 fEnergyThresholdForHeavyHadrons = 1.1*CLHEP::GeV;
82 fMessenger = new G4HadronicParametersMessenger( this );
83
84 // read environment variables
85 fReportLevel = G4GetEnv<G4int>("G4Hadronic_epReportLevel", 0);
86 const char* ep1 = std::getenv("G4Hadronic_epCheckRelativeLevel");
87 if(nullptr != ep1) { fRelativeDiff = std::strtod(ep1, 0); }
88 const char* ep2 = std::getenv("G4Hadronic_epCheckAbsoluteLevel");
89 if(nullptr != ep2) { fAbsoluteDiff = std::strtod(ep2, 0); }
90 const char* v = G4FindDataDir("G4PARTICLEXSDATA");
91 if(nullptr != v) {
92 fDirPARTICLEXS = G4String(v);
93 } else {
94 if(1 < fVerboseLevel) {
96 ed << "Environment variable G4PARTICLEXSDATA is not defined or "
97 << " it is pointing out to not existing directory";
98 G4Exception("G4LevelReader::LevelManager(..)","had014",
99 JustWarning, ed, "Check file path");
100 }
101 }
102 const char* x = std::getenv("G4PhysListDocDir");
103 if(nullptr != x) { fPhysListDocDir = G4String(x); }
104 const char* y = std::getenv("G4PhysListName");
105 if(nullptr != y) { fPhysListName = G4String(y); }
106 const char* z = std::getenv("BINARY_CASCADE_DEBUG");
107 if(nullptr != z) { fBinaryDebug = true; }
108}
109
110
111G4bool G4HadronicParameters::IsLocked() const {
112 return ( ! G4Threading::IsMasterThread() ||
113 G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit );
114}
115
116
117void G4HadronicParameters::StreamInfo( std::ostream& os ) const {
118 G4long prec = os.precision(5);
119
120 // Lambda function to convert boolean to "true"/"false" string
121 auto boolToString = [](G4bool value) -> const char* {
122 return value ? "true" : "false";
123 };
124
125 os << "=======================================================================" << "\n";
126 os << "====== Hadronic Physics Parameters ========" << "\n";
127 os << "=======================================================================" << "\n";
128 os << "Maximum energy for hadronic physics "
129 << G4BestUnit(fMaxEnergy, "Energy") << "\n";
130 os << "Energy threshold for heavy hadrons "
131 << G4BestUnit(fEnergyThresholdForHeavyHadrons, "Energy") << "\n";
132 os << "Neutron kinetic energy threshold for SVT algorithm ";
133 if (fNeutronEkinThresholdForSVT < 0.0) {
134 os <<"not set" << "\n";
135 } else {
136 os << G4BestUnit(fNeutronEkinThresholdForSVT, "Energy") << "\n";
137 }
138 os << "Time threshold for radioactive decays ";
139 if (fTimeThresholdForRadioactiveDecays < 0.0) {
140 os << "not set" << "\n";
141 } else {
142 os << G4BestUnit(fTimeThresholdForRadioactiveDecays, "Time") << "\n";
143 }
144
145 os << "=======================================================================" << "\n";
146 os << "====== Model Transition Regions ========" << "\n";
147 os << "=======================================================================" << "\n";
148 os << "FTF to Cascade transition region "
149 << G4BestUnit(fMinEnergyTransitionFTF_Cascade, "Energy") << " - "
150 << G4BestUnit(fMaxEnergyTransitionFTF_Cascade, "Energy") << "\n";
151 os << "QGS to FTF transition region "
152 << G4BestUnit(fMinEnergyTransitionQGS_FTF, "Energy") << " - "
153 << G4BestUnit(fMaxEnergyTransitionQGS_FTF, "Energy") << "\n";
154 os << "INCLXX antiproton model energy range "
155 << G4BestUnit(fMinEnergyINCLXX_Pbar, "Energy") << " - "
156 << G4BestUnit(fMaxEnergyINCLXX_Pbar, "Energy") << "\n";
157
158 os << "=======================================================================" << "\n";
159 os << "====== Cross Section Factors ========" << "\n";
160 os << "=======================================================================" << "\n";
161 os << "Apply cross section factors " << boolToString(fApplyFactorXS) << "\n";
162 os << "Nucleon inelastic cross section factor " << fXSFactorNucleonInelastic << "\n";
163 os << "Nucleon elastic cross section factor " << fXSFactorNucleonElastic << "\n";
164 os << "Pion inelastic cross section factor " << fXSFactorPionInelastic << "\n";
165 os << "Pion elastic cross section factor " << fXSFactorPionElastic << "\n";
166 os << "Hadron inelastic cross section factor " << fXSFactorHadronInelastic << "\n";
167 os << "Hadron elastic cross section factor " << fXSFactorHadronElastic << "\n";
168 os << "EM cross section factor " << fXSFactorEM << "\n";
169 os << "For XS neutron cross sections use detailed R-data " << fUseRFilesForXS << "\n";
170
171 os << "=======================================================================" << "\n";
172 os << "====== Process Control Parameters ========" << "\n";
173 os << "=======================================================================" << "\n";
174 os << "Enable integral method for inelastic cross sections " << boolToString(fEnableIntegralInelasticXS) << "\n";
175 os << "Enable integral method for elastic cross sections " << boolToString(fEnableIntegralElasticXS) << "\n";
176 os << "Enable diffraction dissociation for B > 10 " << boolToString(fEnableDiffDissociationForBGreater10) << "\n";
177 os << "Enable neutron general process " << boolToString(fNeutronGeneral) << "\n";
178 os << "Enable NUDEX gamma de-excitation " << boolToString(fEnableNUDEX) << "\n";
179 os << "Enable coherent charge exchange " << boolToString(fChargeExchange) << "\n";
180
181 os << "=======================================================================" << "\n";
182 os << "====== Particle Production Control ========" << "\n";
183 os << "=======================================================================" << "\n";
184 os << "Enable B/C particles " << boolToString(fEnableBC) << "\n";
185 os << "Enable hyper-nuclei " << boolToString(fEnableHyperNuclei) << "\n";
186 os << "Enable cosmic ray coalescence " << boolToString(fEnableCRCoalescence) << "\n";
187
188 os << "=======================================================================" << "\n";
189 os << "====== Model Control Parameters ========" << "\n";
190 os << "=======================================================================" << "\n";
191 os << "PT table type for URR neutrons ";
192 // A ternary operation can't be used here as it leads to a C2445 error on Windows with C++20 and newer
193 if (fTypeTablePT.empty()) {
194 os << "not set" << "\n";
195 } else {
196 os << fTypeTablePT << "\n";
197 }
198 os << "Bertini angular emissions as in G4 11.2 " << boolToString(fBertiniAngularEmissionsAs11_2) << "\n";
199 os << "Bertini nuclei model as in G4 11.2 " << boolToString(fBertiniNucleiModelAs11_2) << "\n";
200 os << "Bertini overall behavior as in G4 11.2 " << boolToString(IsBertiniAs11_2()) << "\n";
201
202 os << "=======================================================================" << "\n";
203 os << "====== Debugging Options ========" << "\n";
204 os << "=======================================================================" << "\n";
205 os << "Verbose level " << fVerboseLevel << "\n";
206 os << "Binary cascade debug " << boolToString(fBinaryDebug) << "\n";
207 os << "Environment reporting level " << fReportLevel << "\n";
208 if (fRelativeDiff < DBL_MAX) {
209 os << "Environment relative difference level " << fRelativeDiff << "\n";
210 }
211 if (fAbsoluteDiff < DBL_MAX) {
212 os << "Environment absolute difference level " << fAbsoluteDiff << "\n";
213 }
214
215 os << "=======================================================================" << G4endl;
216 os.precision(prec);
217}
218
219
223
224
226 if ( ! IsLocked() && val > 0.0 ) {
227 fMaxEnergy = val;
228 }
229}
230
231
233 if ( ! IsLocked() && val > 0.0 ) {
234 fMinEnergyTransitionFTF_Cascade = val;
235 }
236}
237
238
240 if ( ! IsLocked() && val > fMinEnergyTransitionFTF_Cascade ) {
241 fMaxEnergyTransitionFTF_Cascade = val;
242 }
243}
244
245
247 if ( ! IsLocked() && val > 0.0 ) {
248 fMinEnergyTransitionQGS_FTF = val;
249 }
250}
251
252
254 if ( ! IsLocked() && val > fMinEnergyTransitionQGS_FTF ) {
255 fMaxEnergyTransitionQGS_FTF = val;
256 }
257}
258
259
261 if ( ! IsLocked() && val >= 0.0 ) {
262 fMinEnergyINCLXX_Pbar = val;
263 }
264}
265
266
268 if ( ! IsLocked() && val > fMinEnergyINCLXX_Pbar ) {
269 fMaxEnergyINCLXX_Pbar = val;
270 }
271}
272
273
275 if ( ! IsLocked() ) fEnableBC = val;
276}
277
278
280 if ( ! IsLocked() ) fEnableHyperNuclei = val;
281}
282
283
285 if ( ! IsLocked() && val >= 0 ) fVerboseLevel = val;
286}
287
288
290 if ( ! IsLocked() && val >= 0 && val < 5*CLHEP::GeV ) {
291 fEnergyThresholdForHeavyHadrons = val;
292 }
293}
294
295
297 if ( ! IsLocked() && std::abs(val - 1.0) < fXSFactorLimit ) {
298 fXSFactorNucleonInelastic = val;
299 }
300}
301
302
304 if ( ! IsLocked() && std::abs(val - 1.0) < fXSFactorLimit ) {
305 fXSFactorNucleonElastic = val;
306 }
307}
308
309
311 if ( ! IsLocked() && std::abs(val - 1.0) < fXSFactorLimit ) {
312 fXSFactorPionInelastic = val;
313 }
314}
315
316
318 if ( ! IsLocked() && std::abs(val - 1.0) < fXSFactorLimit ) {
319 fXSFactorPionElastic = val;
320 }
321}
322
323
325 if ( ! IsLocked() && std::abs(val - 1.0) < fXSFactorLimit ) {
326 fXSFactorHadronInelastic = val;
327 }
328}
329
330
332 if ( ! IsLocked() && std::abs(val - 1.0) < fXSFactorLimit ) {
333 fXSFactorHadronElastic = val;
334 }
335}
336
337
339 if ( ! IsLocked() && std::abs(val - 1.0) < fXSFactorLimit ) {
340 fXSFactorEM = val;
341 }
342}
343
344
346 // This setting works only after initialization (i.e. for G4State_Idle,
347 // whereas it does not work for G4State_PreInit).
348 if ( G4Threading::IsMasterThread() && val > 0.0 ) {
349 fNeutronEkinThresholdForSVT = val;
350 }
351}
352
353
355 // This setting works only before initialization
356 // (else, if used after initialization, it will be ignored).
357 if ( G4Threading::IsMasterThread() && val > 0.0 ) {
358 fTimeThresholdForRadioactiveDecays = val;
359 }
360}
361
362
364 if ( ! IsLocked() ) fApplyFactorXS = val;
365}
366
367
369 if ( ! IsLocked() ) fEnableCRCoalescence = val;
370}
371
372
374 if ( ! IsLocked() ) fEnableIntegralInelasticXS = val;
375}
376
377
379 if ( ! IsLocked() ) fEnableIntegralElasticXS = val;
380}
381
382
384 if ( ! IsLocked() ) fEnableDiffDissociationForBGreater10 = val;
385}
386
387
389 if ( ! IsLocked() ) fNeutronGeneral = val;
390}
391
392
394 if ( ! IsLocked() ) fEnableNUDEX = val;
395}
396
397
399 if ( ! IsLocked() ) fTypeTablePT = typeTablePT;
400}
401
402
404 if ( ! IsLocked() ) fChargeExchange = val;
405}
406
407
409 if ( ! IsLocked() ) {
410 fBertiniAngularEmissionsAs11_2 = val;
411 fBertiniNucleiModelAs11_2 = val;
412 }
413}
414
415
417 if ( ! IsLocked() ) fBertiniAngularEmissionsAs11_2 = val;
418}
419
420
422 if ( ! IsLocked() ) fBertiniNucleiModelAs11_2 = val;
423}
424
425
427 if ( ! IsLocked() ) fUseRFilesForXS = val;
428}
@ G4State_PreInit
G4TemplateAutoLock< G4Mutex > G4AutoLock
_Tp G4GetEnv(const std::string &env_id, _Tp _default=_Tp())
const char * G4FindDataDir(const char *)
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4BestUnit(a, b)
#define G4MUTEX_INITIALIZER
std::mutex G4Mutex
double G4double
Definition G4Types.hh:83
long G4long
Definition G4Types.hh:87
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
void SetEnableIntegralElasticXS(G4bool val)
void SetEnableDiffDissociationForBGreater10(G4bool val)
void SetEnableNUDEX(G4bool val)
void StreamInfo(std::ostream &os) const
void SetEnableCoherentChargeExchange(G4bool val)
static G4HadronicParameters * Instance()
void SetBertiniAngularEmissionsAs11_2(G4bool val)
void SetNeutronKineticEnergyThresholdForSVT(const G4double val)
void SetXSFactorNucleonInelastic(G4double val)
void SetEnableIntegralInelasticXS(G4bool val)
void SetXSFactorPionInelastic(G4double val)
void SetTypeTablePT(const G4String &typeTablePT)
void SetVerboseLevel(const G4int val)
void SetXSFactorPionElastic(G4double val)
void SetTimeThresholdForRadioactiveDecay(const G4double val)
void SetEnableHyperNuclei(G4bool val)
void SetMaxEnergyINCLXX_Pbar(const G4double val)
void SetMaxEnergy(const G4double val)
void SetApplyFactorXS(G4bool val)
void SetEnergyThresholdForHeavyHadrons(G4double val)
void SetMinEnergyTransitionQGS_FTF(const G4double val)
void SetMinEnergyTransitionFTF_Cascade(const G4double val)
void SetEnableBCParticles(G4bool val)
void SetXSFactorHadronElastic(G4double val)
void SetXSFactorEM(G4double val)
void SetEnableCRCoalescence(G4bool val)
void SetMaxEnergyTransitionQGS_FTF(const G4double val)
void SetMinEnergyINCLXX_Pbar(const G4double val)
void SetXSFactorHadronInelastic(G4double val)
void SetBertiniNucleiModelAs11_2(G4bool val)
void SetEnableNeutronGeneralProcess(G4bool val)
void SetXSFactorNucleonElastic(G4double val)
void SetMaxEnergyTransitionFTF_Cascade(const G4double val)
void SetUseRFilesForXS(G4bool val)
void SetBertiniAs11_2(G4bool val)
static G4StateManager * GetStateManager()
G4bool IsMasterThread()
#define DBL_MAX
Definition templates.hh:62