Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpticalParameters.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// GEANT4 Class file
29//
30// File name: G4OpticalParameters
31//
32// Author: Daren Sawkey based on G4EmParameters
33//
34// Creation date: 14.07.2020
35//
36// Modifications:
37//
38// -------------------------------------------------------------------
39//
40//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
41//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42
46#include "G4UnitsTable.hh"
47#include "G4SystemOfUnits.hh"
48#include "G4ApplicationState.hh"
49#include "G4StateManager.hh"
50
51G4OpticalParameters* G4OpticalParameters::theInstance = nullptr;
52
53#ifdef G4MULTITHREADED
54G4Mutex G4OpticalParameters::opticalParametersMutex = G4MUTEX_INITIALIZER;
55#endif
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
58
60{
61 if(nullptr == theInstance)
62 {
63#ifdef G4MULTITHREADED
64 G4MUTEXLOCK(&opticalParametersMutex);
65 if(nullptr == theInstance)
66 {
67#endif
68 static G4OpticalParameters manager;
69 theInstance = &manager;
70#ifdef G4MULTITHREADED
71 }
72 G4MUTEXUNLOCK(&opticalParametersMutex);
73#endif
74 }
75 return theInstance;
76}
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
79
81
82//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
83
84G4OpticalParameters::G4OpticalParameters()
85{
86 theMessenger = new G4OpticalParametersMessenger(this);
87 Initialise();
88
89 fStateManager = G4StateManager::GetStateManager();
90}
91
93{
94 if(!IsLocked())
95 {
96 Initialise();
97 }
98}
99
100void G4OpticalParameters::Initialise()
101{
102 verboseLevel = 1;
103
104 cerenkovStackPhotons = true;
105 cerenkovTrackSecondariesFirst = true;
106 cerenkovVerboseLevel = 1;
107 cerenkovMaxPhotons = 100;
108 cerenkovMaxBetaChange = 10.;
109
110 scintByParticleType = false;
111 scintTrackInfo = false;
112 scintStackPhotons = true;
113 scintFiniteRiseTime = false;
114 scintTrackSecondariesFirst = true;
115 scintVerboseLevel = 1;
116
117 wlsTimeProfileName = "delta";
118 wlsVerboseLevel = 1;
119
120 wls2TimeProfileName = "delta";
121 wls2VerboseLevel = 1;
122
123 absorptionVerboseLevel = 1;
124
125 rayleighVerboseLevel = 1;
126
127 mieVerboseLevel = 1;
128
129 boundaryInvokeSD = false;
130 boundaryVerboseLevel = 1;
131
132 processActivation["OpRayleigh"] = true;
133 processActivation["OpBoundary"] = true;
134 processActivation["OpMieHG"] = true;
135 processActivation["OpAbsorption"] = true;
136 processActivation["OpWLS"] = true;
137 processActivation["OpWLS2"] = true;
138 processActivation["Cerenkov"] = true;
139 processActivation["Scintillation"] = true;
140}
141
143{
144 if(IsLocked())
145 {
146 return;
147 }
148 verboseLevel = val;
149 SetCerenkovVerboseLevel(verboseLevel);
150 SetScintVerboseLevel(verboseLevel);
151 SetRayleighVerboseLevel(verboseLevel);
152 SetAbsorptionVerboseLevel(verboseLevel);
153 SetMieVerboseLevel(verboseLevel);
154 SetBoundaryVerboseLevel(verboseLevel);
155 SetWLSVerboseLevel(verboseLevel);
156 SetWLS2VerboseLevel(verboseLevel);
157}
158
159G4int G4OpticalParameters::GetVerboseLevel() const { return verboseLevel; }
160
162 G4bool val)
163{
164 // Configure the physics constructor to use/not use a selected process.
165 // This method can only be called in PreInit> phase (before execution of
166 // ConstructProcess). The process is not added to particle's process manager
167 // and so it cannot be re-activated later in Idle> phase with the command
168 // /process/activate.
169
170 if(IsLocked())
171 {
172 return;
173 }
174 if(processActivation[process] == val)
175 return;
176
177 // processActivation keys defined at initialisation
178 if(processActivation.find(process) != processActivation.end())
179 {
180 processActivation[process] = val;
181 }
182 else
183 {
185 ed << "Process name " << process << " out of bounds.";
186 G4Exception("G4OpticalParameters::SetProcessActivation()", "Optical013",
187 FatalException, ed);
188 }
189}
190
192{
193 return processActivation.find(process)->second;
194}
195
197{
198 if(IsLocked())
199 {
200 return;
201 }
202 cerenkovStackPhotons = val;
203}
204
206{
207 return cerenkovStackPhotons;
208}
209
211{
212 if(IsLocked())
213 {
214 return;
215 }
216 cerenkovVerboseLevel = val;
217}
218
220{
221 return cerenkovVerboseLevel;
222}
223
225{
226 if(IsLocked())
227 {
228 return;
229 }
230 cerenkovMaxPhotons = val;
231}
232
234{
235 return cerenkovMaxPhotons;
236}
237
239{
240 if(IsLocked())
241 {
242 return;
243 }
244 cerenkovMaxBetaChange = val;
245}
246
248{
249 return cerenkovMaxBetaChange;
250}
251
253{
254 if(IsLocked())
255 {
256 return;
257 }
258 cerenkovTrackSecondariesFirst = val;
259}
260
262{
263 return cerenkovTrackSecondariesFirst;
264}
265
267{
268 if(IsLocked())
269 {
270 return;
271 }
272 scintByParticleType = val;
273}
274
276{
277 return scintByParticleType;
278}
279
281{
282 if(IsLocked())
283 {
284 return;
285 }
286 scintTrackInfo = val;
287}
288
289G4bool G4OpticalParameters::GetScintTrackInfo() const { return scintTrackInfo; }
290
292{
293 if(IsLocked())
294 {
295 return;
296 }
297 scintTrackSecondariesFirst = val;
298}
299
301{
302 return scintTrackSecondariesFirst;
303}
304
306{
307 if(IsLocked())
308 {
309 return;
310 }
311 scintFiniteRiseTime = val;
312}
313
315{
316 return scintFiniteRiseTime;
317}
318
320{
321 if(IsLocked())
322 {
323 return;
324 }
325 scintStackPhotons = val;
326}
327
329{
330 return scintStackPhotons;
331}
332
334{
335 if(IsLocked())
336 {
337 return;
338 }
339 scintVerboseLevel = val;
340}
341
343{
344 return scintVerboseLevel;
345}
346
348{
349 if(IsLocked())
350 {
351 return;
352 }
353 wlsTimeProfileName = val;
354}
355
357{
358 return wlsTimeProfileName;
359}
360
362{
363 if(IsLocked())
364 {
365 return;
366 }
367 wlsVerboseLevel = val;
368}
369
371{
372 return wlsVerboseLevel;
373}
374
376{
377 if(IsLocked())
378 {
379 return;
380 }
381 wls2TimeProfileName = val;
382}
383
385{
386 return wls2TimeProfileName;
387}
388
390{
391 if(IsLocked())
392 {
393 return;
394 }
395 wls2VerboseLevel = val;
396}
397
399{
400 return wls2VerboseLevel;
401}
402
404{
405 if(IsLocked())
406 {
407 return;
408 }
409 boundaryVerboseLevel = val;
410}
411
413{
414 return boundaryVerboseLevel;
415}
416
418{
419 if(IsLocked())
420 {
421 return;
422 }
423 boundaryInvokeSD = val;
424}
425
427{
428 return boundaryInvokeSD;
429}
430
432{
433 if(IsLocked())
434 {
435 return;
436 }
437 absorptionVerboseLevel = val;
438}
439
441{
442 return absorptionVerboseLevel;
443}
444
446{
447 if(IsLocked())
448 {
449 return;
450 }
451 rayleighVerboseLevel = val;
452}
453
455{
456 return rayleighVerboseLevel;
457}
458
460{
461 if(IsLocked())
462 {
463 return;
464 }
465 mieVerboseLevel = val;
466}
467
469{
470 return mieVerboseLevel;
471}
472
473void G4OpticalParameters::PrintWarning(G4ExceptionDescription& ed) const
474{
475 G4Exception("G4EmParameters", "Optical0020", JustWarning, ed);
476}
477
478void G4OpticalParameters::StreamInfo(std::ostream& os) const
479{
480 G4long prec = os.precision(5);
481 os
482 << "======================================================================="
483 << "\n";
484 os
485 << "====== Optical Physics Parameters ========"
486 << "\n";
487 os
488 << "======================================================================="
489 << "\n";
490
491 os << " Cerenkov process active: "
492 << GetProcessActivation("Cerenkov") << "\n";
493 os << " Cerenkov maximum photons per step: " << cerenkovMaxPhotons
494 << "\n";
495 os << " Cerenkov maximum beta change per step: " << cerenkovMaxBetaChange
496 << " %\n";
497 os << " Cerenkov stack photons: " << cerenkovStackPhotons
498 << "\n";
499 os << " Cerenkov track secondaries first: "
500 << cerenkovTrackSecondariesFirst << "\n";
501 os << " Scintillation process active: "
502 << GetProcessActivation("Scintillation") << "\n";
503 os << " Scintillation finite rise time: " << scintFiniteRiseTime
504 << "\n";
505 os << " Scintillation by particle type: " << scintByParticleType
506 << "\n";
507 os << " Scintillation record track info: " << scintTrackInfo << "\n";
508 os << " Scintillation stack photons: " << scintStackPhotons << "\n";
509 os << " Scintillation track secondaries first: " << scintTrackSecondariesFirst
510 << "\n";
511 os << " WLS process active: "
512 << GetProcessActivation("OpWLS") << "\n";
513 os << " WLS time profile name: " << wlsTimeProfileName
514 << "\n";
515 os << " WLS2 process active: "
516 << GetProcessActivation("OpWLS2") << "\n";
517 os << " WLS2 time profile name: " << wls2TimeProfileName
518 << "\n";
519 os << " Boundary process active: "
520 << GetProcessActivation("OpBoundary") << "\n";
521 os << " Boundary invoke sensitive detector: " << boundaryInvokeSD << "\n";
522 os << " Rayleigh process active: "
523 << GetProcessActivation("OpRayleigh") << "\n";
524 os << " MieHG process active: "
525 << GetProcessActivation("OpMieHG") << "\n";
526 os << " Absorption process active: "
527 << GetProcessActivation("OpAbsorption") << "\n";
528 os
529 << "======================================================================="
530 << "\n";
531 os.precision(prec);
532}
533
535{
536#ifdef G4MULTITHREADED
537 G4MUTEXLOCK(&opticalParametersMutex);
538#endif
540#ifdef G4MULTITHREADED
541 G4MUTEXUNLOCK(&opticalParametersMutex);
542#endif
543}
544
545std::ostream& operator<<(std::ostream& os, const G4OpticalParameters& par)
546{
547 par.StreamInfo(os);
548 return os;
549}
550
551G4bool G4OpticalParameters::IsLocked() const
552{
553 return (!G4Threading::IsMasterThread() ||
554 (fStateManager->GetCurrentState() != G4State_PreInit &&
555 fStateManager->GetCurrentState() != G4State_Init &&
556 fStateManager->GetCurrentState() != G4State_Idle));
557}
@ G4State_Init
@ G4State_Idle
@ G4State_PreInit
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
std::ostream & operator<<(std::ostream &os, const G4OpticalParameters &par)
#define G4MUTEX_INITIALIZER
#define G4MUTEXLOCK(mutex)
#define G4MUTEXUNLOCK(mutex)
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
G4GLOB_DLL std::ostream G4cout
G4bool GetBoundaryInvokeSD() const
void SetScintByParticleType(G4bool)
void SetCerenkovMaxBetaChange(G4double)
void SetCerenkovMaxPhotonsPerStep(G4int)
G4int GetCerenkovVerboseLevel() const
void SetScintTrackSecondariesFirst(G4bool)
G4int GetScintVerboseLevel() const
void StreamInfo(std::ostream &os) const
G4int GetAbsorptionVerboseLevel() const
G4bool GetScintStackPhotons() const
G4int GetBoundaryVerboseLevel() const
G4int GetRayleighVerboseLevel() const
G4int GetWLS2VerboseLevel() const
G4String GetWLS2TimeProfile() const
void SetWLS2TimeProfile(const G4String &)
G4int GetCerenkovMaxPhotonsPerStep() const
static G4OpticalParameters * Instance()
G4double GetCerenkovMaxBetaChange() const
void SetAbsorptionVerboseLevel(G4int)
G4bool GetProcessActivation(const G4String &) const
void SetCerenkovStackPhotons(G4bool)
void SetCerenkovTrackSecondariesFirst(G4bool)
void SetScintFiniteRiseTime(G4bool)
G4String GetWLSTimeProfile() const
G4bool GetScintByParticleType() const
void SetWLSTimeProfile(const G4String &)
G4bool GetScintFiniteRiseTime() const
G4bool GetScintTrackInfo() const
G4bool GetCerenkovTrackSecondariesFirst() const
void SetProcessActivation(const G4String &, G4bool)
G4bool GetScintTrackSecondariesFirst() const
G4bool GetCerenkovStackPhotons() const
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
G4bool IsMasterThread()