Geant4 11.4.0
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
59G4OpticalParameters* G4OpticalParameters::Instance()
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 cerenkovOffloadPhotons = false;
106 cerenkovTrackSecondariesFirst = true;
107 cerenkovGeneral = false;
108 cerenkovVerboseLevel = 1;
109 cerenkovMaxPhotons = 100;
110 cerenkovMaxBetaChange = 10.;
111
112 scintByParticleType = false;
113 scintTrackInfo = false;
114 scintStackPhotons = true;
115 scintOffloadPhotons = false;
116 scintFiniteRiseTime = false;
117 scintTrackSecondariesFirst = true;
118 scintVerboseLevel = 1;
119
120 wlsTimeProfileName = "delta";
121 wlsVerboseLevel = 1;
122
123 wls2TimeProfileName = "delta";
124 wls2VerboseLevel = 1;
125
126 absorptionVerboseLevel = 1;
127
128 rayleighVerboseLevel = 1;
129
130 mieVerboseLevel = 1;
131
132 boundaryInvokeSD = false;
133 boundaryVerboseLevel = 1;
134
135 processActivation["OpRayleigh"] = true;
136 processActivation["OpBoundary"] = true;
137 processActivation["OpMieHG"] = true;
138 processActivation["OpAbsorption"] = true;
139 processActivation["OpWLS"] = true;
140 processActivation["OpWLS2"] = true;
141 processActivation["Cerenkov"] = true;
142 processActivation["Scintillation"] = true;
143 processActivation["QuasiCerenkov"] = true;
144 processActivation["QuasiScintillation"] = true;
145}
146
148{
149 if(IsLocked())
150 {
151 return;
152 }
153 verboseLevel = val;
154 SetCerenkovVerboseLevel(verboseLevel);
155 SetScintVerboseLevel(verboseLevel);
156 SetRayleighVerboseLevel(verboseLevel);
157 SetAbsorptionVerboseLevel(verboseLevel);
158 SetMieVerboseLevel(verboseLevel);
159 SetBoundaryVerboseLevel(verboseLevel);
160 SetWLSVerboseLevel(verboseLevel);
161 SetWLS2VerboseLevel(verboseLevel);
162}
163
164G4int G4OpticalParameters::GetVerboseLevel() const { return verboseLevel; }
165
167 G4bool val)
168{
169 // Configure the physics constructor to use/not use a selected process.
170 // This method can only be called in PreInit> phase (before execution of
171 // ConstructProcess). The process is not added to particle's process manager
172 // and so it cannot be re-activated later in Idle> phase with the command
173 // /process/activate.
174
175 if(IsLocked())
176 {
177 return;
178 }
179 if(processActivation[process] == val)
180 return;
181
182 // processActivation keys defined at initialisation
183 if(processActivation.find(process) != processActivation.end())
184 {
185 processActivation[process] = val;
186 }
187 else
188 {
190 ed << "Process name " << process << " out of bounds.";
191 G4Exception("G4OpticalParameters::SetProcessActivation()", "Optical013",
192 FatalException, ed);
193 }
194}
195
197{
198 return processActivation.find(process)->second;
199}
200
202{
203 if(IsLocked())
204 {
205 return;
206 }
207 cerenkovStackPhotons = val;
208}
209
211{
212 return cerenkovStackPhotons;
213}
214
216{
217 if(IsLocked())
218 {
219 return;
220 }
221 cerenkovOffloadPhotons = val;
222}
223
225{
226 return cerenkovOffloadPhotons;
227}
228
230{
231 if(IsLocked())
232 {
233 return;
234 }
235 cerenkovVerboseLevel = val;
236}
237
239{
240 return cerenkovVerboseLevel;
241}
242
244{
245 if(IsLocked())
246 {
247 return;
248 }
249 cerenkovMaxPhotons = val;
250}
251
253{
254 return cerenkovMaxPhotons;
255}
256
258{
259 if(IsLocked())
260 {
261 return;
262 }
263 cerenkovMaxBetaChange = val;
264}
265
267{
268 return cerenkovMaxBetaChange;
269}
270
272{
273 if(IsLocked())
274 {
275 return;
276 }
277 cerenkovTrackSecondariesFirst = val;
278}
279
281{
282 return cerenkovTrackSecondariesFirst;
283}
284
286{
287 if(IsLocked())
288 {
289 return;
290 }
291 cerenkovGeneral = val;
292}
293
295{
296 return cerenkovGeneral;
297}
298
300{
301 if(IsLocked())
302 {
303 return;
304 }
305 scintByParticleType = val;
306}
307
309{
310 return scintByParticleType;
311}
312
314{
315 if(IsLocked())
316 {
317 return;
318 }
319 scintTrackInfo = val;
320}
321
322G4bool G4OpticalParameters::GetScintTrackInfo() const { return scintTrackInfo; }
323
325{
326 if(IsLocked())
327 {
328 return;
329 }
330 scintTrackSecondariesFirst = val;
331}
332
334{
335 return scintTrackSecondariesFirst;
336}
337
339{
340 if(IsLocked())
341 {
342 return;
343 }
344 scintFiniteRiseTime = val;
345}
346
348{
349 return scintFiniteRiseTime;
350}
351
353{
354 if(IsLocked())
355 {
356 return;
357 }
358 scintStackPhotons = val;
359}
360
362{
363 return scintStackPhotons;
364}
365
367{
368 if(IsLocked())
369 {
370 return;
371 }
372 scintOffloadPhotons = val;
373}
374
376{
377 return scintOffloadPhotons;
378}
379
381{
382 if(IsLocked())
383 {
384 return;
385 }
386 scintVerboseLevel = val;
387}
388
390{
391 return scintVerboseLevel;
392}
393
395{
396 if(IsLocked())
397 {
398 return;
399 }
400 wlsTimeProfileName = val;
401}
402
404{
405 return wlsTimeProfileName;
406}
407
409{
410 if(IsLocked())
411 {
412 return;
413 }
414 wlsVerboseLevel = val;
415}
416
418{
419 return wlsVerboseLevel;
420}
421
423{
424 if(IsLocked())
425 {
426 return;
427 }
428 wls2TimeProfileName = val;
429}
430
432{
433 return wls2TimeProfileName;
434}
435
437{
438 if(IsLocked())
439 {
440 return;
441 }
442 wls2VerboseLevel = val;
443}
444
446{
447 return wls2VerboseLevel;
448}
449
451{
452 if(IsLocked())
453 {
454 return;
455 }
456 boundaryVerboseLevel = val;
457}
458
460{
461 return boundaryVerboseLevel;
462}
463
465{
466 if(IsLocked())
467 {
468 return;
469 }
470 boundaryInvokeSD = val;
471}
472
474{
475 return boundaryInvokeSD;
476}
477
479{
480 if(IsLocked())
481 {
482 return;
483 }
484 absorptionVerboseLevel = val;
485}
486
488{
489 return absorptionVerboseLevel;
490}
491
493{
494 if(IsLocked())
495 {
496 return;
497 }
498 rayleighVerboseLevel = val;
499}
500
502{
503 return rayleighVerboseLevel;
504}
505
507{
508 if(IsLocked())
509 {
510 return;
511 }
512 mieVerboseLevel = val;
513}
514
516{
517 return mieVerboseLevel;
518}
519
520const std::vector<std::pair<G4XRayModelType, const G4String> >&
522{
523 return xrayVolumes;
524}
525
527 G4XRayModelType type)
528{
529 if(IsLocked()) {
530 return;
531 }
532 xrayVolumes.push_back(std::make_pair(type, lvname));
533}
534
535
536void G4OpticalParameters::PrintWarning(G4ExceptionDescription& ed) const
537{
538 G4Exception("G4EmParameters", "Optical0020", JustWarning, ed);
539}
540
541void G4OpticalParameters::StreamInfo(std::ostream& os) const
542{
543 G4long prec = os.precision(5);
544 os
545 << "======================================================================="
546 << "\n";
547 os
548 << "====== Optical Physics Parameters ========"
549 << "\n";
550 os
551 << "======================================================================="
552 << "\n";
553
554 os << " Cerenkov process active: "
555 << GetProcessActivation("Cerenkov") << "\n";
556 os << " Cerenkov maximum photons per step: " << cerenkovMaxPhotons
557 << "\n";
558 os << " Cerenkov maximum beta change per step: " << cerenkovMaxBetaChange
559 << " %\n";
560 os << " Cerenkov stack photons: " << cerenkovStackPhotons
561 << "\n";
562 os << " Cerenkov track secondaries first: "
563 << cerenkovTrackSecondariesFirst << "\n";
564 os << " Scintillation process active: "
565 << GetProcessActivation("Scintillation") << "\n";
566 os << " Scintillation finite rise time: " << scintFiniteRiseTime
567 << "\n";
568 os << " Scintillation by particle type: " << scintByParticleType
569 << "\n";
570 os << " Scintillation record track info: " << scintTrackInfo << "\n";
571 os << " Scintillation stack photons: " << scintStackPhotons << "\n";
572 os << " Scintillation track secondaries first: " << scintTrackSecondariesFirst
573 << "\n";
574 os << " WLS process active: "
575 << GetProcessActivation("OpWLS") << "\n";
576 os << " WLS time profile name: " << wlsTimeProfileName
577 << "\n";
578 os << " WLS2 process active: "
579 << GetProcessActivation("OpWLS2") << "\n";
580 os << " WLS2 time profile name: " << wls2TimeProfileName
581 << "\n";
582 os << " Boundary process active: "
583 << GetProcessActivation("OpBoundary") << "\n";
584 os << " Boundary invoke sensitive detector: " << boundaryInvokeSD << "\n";
585 os << " Rayleigh process active: "
586 << GetProcessActivation("OpRayleigh") << "\n";
587 os << " MieHG process active: "
588 << GetProcessActivation("OpMieHG") << "\n";
589 os << " Absorption process active: "
590 << GetProcessActivation("OpAbsorption") << "\n";
591 os
592 << "======================================================================="
593 << "\n";
594 os.precision(prec);
595}
596
598{
599#ifdef G4MULTITHREADED
600 G4MUTEXLOCK(&opticalParametersMutex);
601#endif
603#ifdef G4MULTITHREADED
604 G4MUTEXUNLOCK(&opticalParametersMutex);
605#endif
606}
607
608std::ostream& operator<<(std::ostream& os, const G4OpticalParameters& par)
609{
610 par.StreamInfo(os);
611 return os;
612}
613
614G4bool G4OpticalParameters::IsLocked() const
615{
616 return (!G4Threading::IsMasterThread() ||
617 (fStateManager->GetCurrentState() != G4State_PreInit &&
618 fStateManager->GetCurrentState() != G4State_Init &&
619 fStateManager->GetCurrentState() != G4State_Idle));
620}
@ 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
void SetActiveVolume(const G4String &name, G4XRayModelType type)
G4bool GetBoundaryInvokeSD() const
void SetScintByParticleType(G4bool)
void SetCerenkovMaxBetaChange(G4double)
void SetScintOffloadPhotons(G4bool)
G4bool GetScintOffloadPhotons() const
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
const std::vector< std::pair< G4XRayModelType, const G4String > > & ActiveVolumes() 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)
G4bool GetCerenkovOffloadPhotons() const
void SetScintFiniteRiseTime(G4bool)
G4String GetWLSTimeProfile() const
G4bool GetScintByParticleType() const
void SetWLSTimeProfile(const G4String &)
G4bool GetScintFiniteRiseTime() const
G4bool GetScintTrackInfo() const
void SetCerenkovOffloadPhotons(G4bool)
G4bool GetCerenkovTrackSecondariesFirst() const
void SetProcessActivation(const G4String &, G4bool)
G4bool GetScintTrackSecondariesFirst() const
G4bool GetCerenkovStackPhotons() const
const G4ApplicationState & GetCurrentState() const
static G4StateManager * GetStateManager()
G4bool IsMasterThread()