Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TransportationParameters Class Reference

#include <G4TransportationParameters.hh>

Public Member Functions

 ~G4TransportationParameters ()=default
 
G4bool SetNumberOfTrials (G4int val)
 
G4bool SetWarningEnergy (G4double val)
 
G4bool SetImportantEnergy (G4double val)
 
G4bool SetWarningAndImportantEnergies (G4double warnE, G4double imprtE)
 
G4int GetNumberOfTrials () const
 
G4double GetWarningEnergy () const
 
G4double GetImportantEnergy () const
 
G4bool IsMagneticMomentEnabled () const
 
G4bool EnableUseOfMagneticMoment (G4bool useMoment=true)
 
G4bool SetHighLooperThresholds ()
 
G4bool SetIntermediateLooperThresholds ()
 
G4bool SetLowLooperThresholds ()
 
G4bool SetSilenceAllLooperWarnings (G4bool val=true)
 
G4bool GetSilenceAllLooperWarnings ()
 
void ReportLockError (G4String methodName, G4bool verbose=false) const
 
void StreamInfo (std::ostream &os) const
 
void Dump () const
 

Static Public Member Functions

static G4TransportationParametersInstance ()
 
static G4bool Exists ()
 

Friends

std::ostream & operator<< (std::ostream &os, const G4TransportationParameters &)
 

Detailed Description

Definition at line 59 of file G4TransportationParameters.hh.

Constructor & Destructor Documentation

◆ ~G4TransportationParameters()

G4TransportationParameters::~G4TransportationParameters ( )
default

Member Function Documentation

◆ Dump()

void G4TransportationParameters::Dump ( ) const

Definition at line 198 of file G4TransportationParameters.cc.

199{
200 G4MUTEXLOCK(&transportParamsMutex);
202 G4MUTEXUNLOCK(&transportParamsMutex);
203}
#define G4MUTEXLOCK(mutex)
#define G4MUTEXUNLOCK(mutex)
G4GLOB_DLL std::ostream G4cout
void StreamInfo(std::ostream &os) const

◆ EnableUseOfMagneticMoment()

G4bool G4TransportationParameters::EnableUseOfMagneticMoment ( G4bool useMoment = true)

Definition at line 254 of file G4TransportationParameters.cc.

255{
256 if(IsLocked()) { return false; }
257 fUseMagneticMoment= useMoment;
258 return true;
259}

◆ Exists()

static G4bool G4TransportationParameters::Exists ( )
inlinestatic

Definition at line 97 of file G4TransportationParameters.hh.

97{ return theInstance != nullptr; }

Referenced by G4Transportation::G4Transportation().

◆ GetImportantEnergy()

G4double G4TransportationParameters::GetImportantEnergy ( ) const
inline

Definition at line 79 of file G4TransportationParameters.hh.

79{ return fImportantEnergy; }

Referenced by StreamInfo().

◆ GetNumberOfTrials()

G4int G4TransportationParameters::GetNumberOfTrials ( ) const
inline

Definition at line 77 of file G4TransportationParameters.hh.

77{ return fNumberOfTrials; }

Referenced by StreamInfo().

◆ GetSilenceAllLooperWarnings()

G4bool G4TransportationParameters::GetSilenceAllLooperWarnings ( )
inline

Definition at line 91 of file G4TransportationParameters.hh.

91{ return fSilenceLooperWarnings; }

◆ GetWarningEnergy()

G4double G4TransportationParameters::GetWarningEnergy ( ) const
inline

Definition at line 78 of file G4TransportationParameters.hh.

78{ return fWarningEnergy; }

Referenced by StreamInfo().

◆ Instance()

G4TransportationParameters * G4TransportationParameters::Instance ( )
static

Definition at line 55 of file G4TransportationParameters.cc.

56{
57 if(theInstance == nullptr) {
58 G4MUTEXLOCK(&transportParamsMutex);
59 if(theInstance == nullptr) {
60 static G4TransportationParameters manager;
61 theInstance = &manager;
62 }
63 G4MUTEXUNLOCK(&transportParamsMutex);
64 }
65 return theInstance;
66}

Referenced by G4Transportation::G4Transportation().

◆ IsMagneticMomentEnabled()

G4bool G4TransportationParameters::IsMagneticMomentEnabled ( ) const
inline

Definition at line 80 of file G4TransportationParameters.hh.

80{ return fUseMagneticMoment; }

◆ ReportLockError()

void G4TransportationParameters::ReportLockError ( G4String methodName,
G4bool verbose = false ) const

Definition at line 162 of file G4TransportationParameters.cc.

163{
164 // Report Incompatible States: GeomClosed , EventProc, (also Quit, Abort)
165 G4String namesMethodClass= G4String("G4TransportationParameters") + methodName;
166
167 auto stateManager = G4StateManager::GetStateManager();
168 auto state = stateManager->GetCurrentState();
169
171 ed << "Cannot change values of G4TransportationParameters when G4State is "
172 << stateManager->GetStateString(state) << G4endl;
173 ed << "Only the following Geant4 state are compatible: Pre_Init, Init and Idle." << G4endl;
174 if( verbose ) {
175 ed << G4endl << "Values remain as follows:" << G4endl;
176 StreamInfo( ed );
177 }
178 G4Exception( namesMethodClass,
179 "Locked, due to incompatible G4state: it not possible to change its parameters.",
180 JustWarning, ed );
181}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4endl
Definition G4ios.hh:67
static G4StateManager * GetStateManager()

Referenced by SetImportantEnergy(), SetNumberOfTrials(), SetWarningAndImportantEnergies(), and SetWarningEnergy().

◆ SetHighLooperThresholds()

G4bool G4TransportationParameters::SetHighLooperThresholds ( )

Definition at line 207 of file G4TransportationParameters.cc.

208{
209 if(IsLocked()) { return false; }
210
211 // Restores the old high values -- potentially appropriate for energy-frontier
212 // HEP experiments.
213 // Caution: All tracks with E < 100 MeV that are found to loop are
214 SetWarningEnergy( 100.0 * CLHEP::MeV ); // Warn above this energy
215 SetImportantEnergy( 250.0 * CLHEP::MeV ); // Extra trial above this En
216
217 G4int maxTrials = 10;
218 SetNumberOfTrials( maxTrials );
219
220 return true;
221}
int G4int
Definition G4Types.hh:85

◆ SetImportantEnergy()

G4bool G4TransportationParameters::SetImportantEnergy ( G4double val)

Definition at line 110 of file G4TransportationParameters.cc.

111{
112 if(IsLocked()) { ReportLockError(__func__); return false; }
113 fImportantEnergy = val;
114
115 // Consistency check -- and trial fix
116 if( fImportantEnergy < fWarningEnergy ) {
117 G4String mthd= G4String("G4TransportationParameters")+G4String(__func__);
119 ed<<"enforcing hierarchy (warning-E <= important-E): resetting important"
120 <<" energy from " << fImportantEnergy << " to " << val << G4endl;
121 G4Exception( mthd, "Enforcing Warning Energy <= Important Energy",
122 JustWarning, ed );
123
124 fWarningEnergy = fImportantEnergy;
125 }
126 return true;
127}
void ReportLockError(G4String methodName, G4bool verbose=false) const

Referenced by SetHighLooperThresholds(), and SetLowLooperThresholds().

◆ SetIntermediateLooperThresholds()

G4bool G4TransportationParameters::SetIntermediateLooperThresholds ( )

Definition at line 225 of file G4TransportationParameters.cc.

226{
227 if(IsLocked()) { return false; } // Currently must not change during loop - may relax
228
229 // Medium values -- reasonable default for an unknown application
230 fWarningEnergy= 1.0 * CLHEP::MeV; // Warn above this energy
231 fImportantEnergy= 10.0 * CLHEP::MeV; // Extra trial above this En
232 fNumberOfTrials= 10;
233 return true;
234}

◆ SetLowLooperThresholds()

G4bool G4TransportationParameters::SetLowLooperThresholds ( )

Definition at line 238 of file G4TransportationParameters.cc.

239{
240 if(IsLocked()) { return false; }
241
242 // These values were the default in Geant4 10.5 - beta
243 SetWarningEnergy( 1.0 * CLHEP::keV ); // Warn above this En
244 SetImportantEnergy( 1.0 * CLHEP::MeV ); // Extra trials above it
245
246 G4int maxTrials = 30;
247 SetNumberOfTrials( maxTrials );
248
249 return true;
250}

◆ SetNumberOfTrials()

G4bool G4TransportationParameters::SetNumberOfTrials ( G4int val)

Definition at line 83 of file G4TransportationParameters.cc.

84{
85 if(IsLocked()) { ReportLockError(__func__); return false; }
86 fNumberOfTrials = val;
87 return true;
88}

Referenced by SetHighLooperThresholds(), and SetLowLooperThresholds().

◆ SetSilenceAllLooperWarnings()

G4bool G4TransportationParameters::SetSilenceAllLooperWarnings ( G4bool val = true)

Definition at line 264 of file G4TransportationParameters.cc.

265{
266 if(IsLocked()) { return false; }
267 fSilenceLooperWarnings= val;
268 return true;
269}

◆ SetWarningAndImportantEnergies()

G4bool G4TransportationParameters::SetWarningAndImportantEnergies ( G4double warnE,
G4double imprtE )

Definition at line 131 of file G4TransportationParameters.cc.

133{
134 if(IsLocked()) {
135 ReportLockError(__func__);
136 return false;
137 }
138
139 if( warnE <= importE )
140 {
141 fWarningEnergy = warnE;
142 fImportantEnergy = importE;
143 }
144 else
145 {
146 fWarningEnergy = importE;
147 fImportantEnergy = warnE;
148
149 G4String mthd= G4String("G4TransportationParameters")+G4String(__func__);
151 ed << "To enforce hierarchy (warning-E <= important-E): "
152 << " using smaller value= " << importE << " as Warning Energy "
153 << " and larger value= " << warnE << " as Important Energy." << G4endl;
154 G4Exception( mthd, "Enforcing Warning Energy <= Important Energy",
155 JustWarning, ed );
156 }
157 return true;
158}

◆ SetWarningEnergy()

G4bool G4TransportationParameters::SetWarningEnergy ( G4double val)

Definition at line 92 of file G4TransportationParameters.cc.

93{
94 if(IsLocked()) { ReportLockError(__func__); return false; }
95 fWarningEnergy = val;
96
97 // Consistency check -- and trial fix
98 if( fWarningEnergy > fImportantEnergy ) {
99 G4cerr << "G4TransportationParameters::GetWarningEnergy enforcing warning-E <= important-E "
100 << " resetting important energy from " << fImportantEnergy
101 << " to " << val << G4endl;
102 // "Enforcing Important Energy >= Warning Energy"
103 fImportantEnergy = fWarningEnergy;
104 }
105 return true;
106}
G4GLOB_DLL std::ostream G4cerr

Referenced by SetHighLooperThresholds(), and SetLowLooperThresholds().

◆ StreamInfo()

void G4TransportationParameters::StreamInfo ( std::ostream & os) const

Definition at line 185 of file G4TransportationParameters.cc.

186{
187 auto prec = os.precision(5);
188
189 os << "Transport Parameters: " << G4endl;
190 os << " Warning energy = " << GetWarningEnergy() / CLHEP::MeV << " MeV " << G4endl;
191 os << " Important energy = " << GetImportantEnergy() / CLHEP::MeV << " MeV " << G4endl;
192 os << " Number of trials = " << GetNumberOfTrials() << G4endl;
193 os.precision(prec);
194}

Referenced by Dump(), and ReportLockError().

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const G4TransportationParameters &  )
friend

The documentation for this class was generated from the following files: