Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpticalPhysics.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: G4OpticalPhysics
30//
31// Author: P.Gumplinger 30.09.2009
32//
33// Modified: P.Gumplinger 29.09.2011
34// (based on code from I. Hrivnacova)
35//
36//----------------------------------------------------------------------------
37//
38
39#include "G4OpticalPhysics.hh"
41
42#include "G4OpAbsorption.hh"
43#include "G4OpRayleigh.hh"
44#include "G4OpMieHG.hh"
46#include "G4OpWLS.hh"
47#include "G4OpWLS2.hh"
48#include "G4Scintillation.hh"
49#include "G4Cerenkov.hh"
50
51#include "G4LossTableManager.hh"
52#include "G4EmSaturation.hh"
53
55#include "G4ProcessManager.hh"
56
57// factory
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64{
65 verboseLevel = verbose;
67}
68
69//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71{}
72
73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75{
77}
78
79//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81{
83}
84
85//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87{
88 if(verboseLevel>0)
89 G4cout <<"G4OpticalPhysics:: Add Optical Physics Processes"<< G4endl;
90
91 auto params = G4OpticalParameters::Instance();
92
93 // Add Optical Processes
94
96 if (!pManager) {
98 ed << "Optical Photon without a Process Manager";
99 G4Exception("G4OpticalPhysics::ConstructProcess()","",
100 FatalException,ed);
101 return;
102 }
103
104 G4OpAbsorption* absorption = new G4OpAbsorption();
105 if (params->GetProcessActivation("OpAbsorption")) pManager->AddDiscreteProcess(absorption);
106
107 G4OpRayleigh* rayleigh = new G4OpRayleigh();
108 if (params->GetProcessActivation("OpRayleigh")) pManager->AddDiscreteProcess(rayleigh);
109
110 G4OpMieHG* mie = new G4OpMieHG();
111 if (params->GetProcessActivation("OpMieHG")) pManager->AddDiscreteProcess(mie);
112
114 if (params->GetProcessActivation("OpBoundary")) pManager->AddDiscreteProcess(boundary);
115
116 G4OpWLS* wls = new G4OpWLS();
117 if (params->GetProcessActivation("OpWLS")) pManager->AddDiscreteProcess(wls);
118
119 G4OpWLS2* wls2 = new G4OpWLS2();
120 if (params->GetProcessActivation("OpWLS2")) pManager->AddDiscreteProcess(wls2);
121
122 G4Scintillation* scint = new G4Scintillation();
124 scint->AddSaturation(emSaturation);
125
126 G4Cerenkov* cerenkov = new G4Cerenkov();
127
128 auto myParticleIterator=GetParticleIterator();
129 myParticleIterator->reset();
130
131 while( (*myParticleIterator)() ){
132
133 G4ParticleDefinition* particle = myParticleIterator->value();
134 G4String particleName = particle->GetParticleName();
135
136 pManager = particle->GetProcessManager();
137 if (!pManager) {
139 ed << "Particle " << particleName << "without a Process Manager";
140 G4Exception("G4OpticalPhysics::ConstructProcess()","",
141 FatalException, ed);
142 return; // else coverity complains for pManager use below
143 }
144
145 if (cerenkov->IsApplicable(*particle) && params->GetProcessActivation("Cerenkov")) {
146 pManager->AddProcess(cerenkov);
147 pManager->SetProcessOrdering(cerenkov,idxPostStep);
148 }
149 if (scint->IsApplicable(*particle) && params->GetProcessActivation("Scintillation")) {
150 pManager->AddProcess(scint);
151 pManager->SetProcessOrderingToLast(scint,idxAtRest);
152 pManager->SetProcessOrderingToLast(scint,idxPostStep);
153 }
154 if (boundary->IsApplicable(*particle) && params->GetProcessActivation("OpBoundary")) {
155 pManager->SetProcessOrderingToLast(boundary,idxPostStep);
156 }
157 }
158
159
160 if (verboseLevel > 1) PrintStatistics();
161 if (verboseLevel > 0)
162 G4cout << "### " << namePhysics << " physics constructed." << G4endl;
163}
164
165// DEPRECATED
166// the methods below are kept for backwards compatibility, and are to be
167// removed in future. Please use the methods in
168// G4OpticalParameters instead.
169
172 if (index == kCerenkov) params->SetProcessActivation("Cerenkov", val);
173 else if (index == kScintillation) params->SetProcessActivation("Scintillation", val);
174 else if (index == kAbsorption) params->SetProcessActivation("Absorption", val);
175 else if (index == kRayleigh) params->SetProcessActivation("Rayleigh", val);
176 else if (index == kMieHG) params->SetProcessActivation("MieHG", val);
177 else if (index == kBoundary) params->SetProcessActivation("Boundary", val);
178 else if (index == kWLS) params->SetProcessActivation("WLS", val);
179 else if (index == kWLS2) params->SetProcessActivation("WLS2", val);
180}
181
183 if (index == kCerenkov)
185 else if (index == kScintillation)
188 ed << "Method G4OpticalPhysics::SetTrackSecondariesFirst is deprecated." << G4endl
189 << "Use G4OpticalParameters::Set[Cerenkov/Scint]TrackSecondariesFirst(G4bool) instead.";
190 PrintWarning(ed);
191}
192
193// Cerenkov
197 ed << "Method G4OpticalPhysics::SetMaxNumPhotonsPerStep is deprecated." << G4endl
198 << "Use G4OpticalParameters::SetCerenkovMaxPhotonsPerStep(G4int) instead.";
199 PrintWarning(ed);
200}
201
205 ed << "Method G4OpticalPhysics::SetMaxBetaChangePerStep is deprecated." << G4endl
206 << "Use G4OpticalParameters::SetCerenkovMaxBetaChange(G4double) instead.";
207 PrintWarning(ed);
208}
209
213 ed << "Method G4OpticalPhysics::SetCerenkovStackPhotons is deprecated." << G4endl
214 << "Use G4OpticalParameters::SetCerenkovStackPhotons(G4int) "
215 << "instead.";
216 PrintWarning(ed);
217}
218
222 ed << "Method G4OpticalPhysics::SetCerenkovTrackSecondariesFirst is deprecated." << G4endl
223 << "Use G4OpticalParameters::SetCerenkovTrackSecondariesFirst(G4int) instead.";
224 PrintWarning(ed);
225}
226
230 ed << "Method G4OpticalPhysics::SetCerenkovVerbosity is deprecated." << G4endl
231 << "Use G4OpticalParameters::SetCerenkovVerbosity(G4int) instead.";
232 PrintWarning(ed);
233}
234
235// Scintillation
239 ed << "Method G4OpticalPhysics::SetScintillationYieldFactor is deprecated." << G4endl
240 << "Use G4OpticalParameters::SetScintYieldFactor(G4double) instead.";
241 PrintWarning(ed);
242}
243
247 ed << "Method G4OpticalPhysics::SetScintillationExcitationRatio is deprecated." << G4endl
248 << "Use G4OpticalParameters::SetScintExcitationRatio(G4double) instead.";
249 PrintWarning(ed);
250}
251
255 ed << "Method G4OpticalPhysics::SetScintillationByParticleType is deprecated." << G4endl
256 << "Use G4OpticalParameters::SetScintByParticleType(G4bool) instead.";
257 PrintWarning(ed);
258}
259
263 ed << "Method G4OpticalPhysics::SetScintillationTrackInfo is deprecated." << G4endl
264 << "Use G4OpticalParameters::SetScintTrackInfo(G4bool) instead.";
265 PrintWarning(ed);
266}
267
271 ed << "Method G4OpticalPhysics::SetScintillationTrackSecondariesFirst is deprecated." << G4endl
272 << "Use G4OpticalParameters::SetScintTrackSecondariesFirst(G4bool) instead.";
273 PrintWarning(ed);
274}
275
279 ed << "Method G4OpticalPhysics::SetFiniteRiseTime is deprecated." << G4endl
280 << "Use G4OpticalParameters::SetScintFiniteRiseTime(G4bool) instead.";
281 PrintWarning(ed);
282}
283
287 ed << "Method G4OpticalPhysics::SetScintillationStackPhotons is deprecated." << G4endl
288 << "Use G4OpticalParameters::SetScintStackPhotons(G4bool) instead.";
289 PrintWarning(ed);
290}
291
295 ed << "Method G4OpticalPhysics::SetScintillationVerbosity is deprecated." << G4endl
296 << "Use G4OpticalParameters::SetScintVerboseLevel(G4int) instead.";
297 PrintWarning(ed);
298}
299
303 ed << "Method G4OpticalPhysics::SetScintillationEnhanceTimeConstants is deprecated." << G4endl
304 << "Use G4OpticalParameters::SetScintEnhancedTimeConstants(G4bool) instead.";
305 PrintWarning(ed);
306}
307
308//void AddScintillationSaturation(G4EmSaturation* );
309
310// WLS
314 ed << "Method G4OpticalPhysics::SetWLSTimeProfile is deprecated." << G4endl
315 << "Use G4OpticalParameters::SetWLSTimeProfile(G4String) instead.";
316 PrintWarning(ed);
317}
318
322 ed << "Method G4OpticalPhysics::SetWLSVerbosity is deprecated." << G4endl
323 << "Use G4OpticalParameters::SetWLSVerboseLevel(G4int) instead.";
324 PrintWarning(ed);
325}
326
327//boundary
331 ed << "Method G4OpticalPhysics::SetBoundaryVerbosity is deprecated." << G4endl
332 << "Use G4OpticalParameters::SetBoundaryVerboseLevel(G4int) instead.";
333 PrintWarning(ed);
334}
335
339 ed << "Method G4OpticalPhysics::SetInvokeSD is deprecated." << G4endl
340 << "Use G4OpticalParameters::SetBoundaryInvokeSD(G4bool) instead.";
341 PrintWarning(ed);
342}
343
347 ed << "Method G4OpticalPhysics::SetAbsorptionVerbosity is deprecated." << G4endl
348 << "Use G4OpticalParameters::SetAbsorptionVerboseLevel(G4int) instead.";
349 PrintWarning(ed);
350}
351
355 ed << "Method G4OpticalPhysics::SetRayleighVerbosity is deprecated." << G4endl
356 << "Use G4OpticalParameters::SetRayleighVerboseLevel(G4int) instead.";
357 PrintWarning(ed);
358}
359
363 ed << "Method G4OpticalPhysics::SetMieVerbosity is deprecated." << G4endl
364 << "Use G4OpticalParameters::SetMieVerboseLevel(G4int) instead.";
365 PrintWarning(ed);
366}
367
368void G4OpticalPhysics::PrintWarning(G4ExceptionDescription& ed) const {
369 G4Exception("G4OpticalPhysics", "Optical0021", JustWarning, ed);
370}
371
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
G4OpticalProcessIndex
@ kWLS
Wave Length Shifting process index.
@ kScintillation
Scintillation process index.
@ kWLS2
Second Wave Length Shifting process index.
@ kRayleigh
Rayleigh scattering process index.
@ kAbsorption
Absorption process index.
@ kBoundary
Boundary process index.
@ kCerenkov
Cerenkov process index.
@ kMieHG
Mie scattering process index.
#define G4_DECLARE_PHYSCONSTR_FACTORY(physics_constructor)
@ idxPostStep
@ idxAtRest
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override
Definition: G4Cerenkov.cc:102
static G4LossTableManager * Instance()
G4EmSaturation * EmSaturation()
virtual G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override
void SetScintByParticleType(G4bool)
void SetCerenkovMaxBetaChange(G4double)
void SetRayleighVerboseLevel(G4int)
void SetCerenkovMaxPhotonsPerStep(G4int)
void SetBoundaryInvokeSD(G4bool)
void SetBoundaryVerboseLevel(G4int)
void SetScintTrackSecondariesFirst(G4bool)
void SetScintEnhancedTimeConstants(G4bool)
void SetScintStackPhotons(G4bool)
static G4OpticalParameters * Instance()
void SetAbsorptionVerboseLevel(G4int)
void SetCerenkovStackPhotons(G4bool)
void SetCerenkovTrackSecondariesFirst(G4bool)
void SetScintFiniteRiseTime(G4bool)
void SetWLSTimeProfile(const G4String &)
void SetCerenkovVerboseLevel(G4int)
void SetScintExcitationRatio(G4double)
void SetScintYieldFactor(G4double)
void SetProcessActivation(const G4String &, G4bool)
static G4OpticalPhoton * OpticalPhotonDefinition()
static G4OpticalPhoton * OpticalPhoton()
void SetScintillationStackPhotons(G4bool)
void SetRayleighVerbosity(G4int)
void SetMaxBetaChangePerStep(G4double)
void SetScintillationYieldFactor(G4double)
void SetMieVerbosity(G4int)
void Configure(G4OpticalProcessIndex, G4bool)
void SetScintillationTrackInfo(G4bool)
void SetScintillationByParticleType(G4bool)
void SetMaxNumPhotonsPerStep(G4int)
void SetScintillationEnhancedTimeConstants(G4bool)
void SetScintillationVerbosity(G4int)
void SetCerenkovTrackSecondariesFirst(G4bool)
virtual ~G4OpticalPhysics()
void SetInvokeSD(G4bool)
void SetWLSVerbosity(G4int)
void SetTrackSecondariesFirst(G4OpticalProcessIndex, G4bool)
void SetCerenkovStackPhotons(G4bool)
virtual void ConstructProcess()
virtual void ConstructParticle()
void SetCerenkovVerbosity(G4int)
void SetWLSTimeProfile(G4String)
void SetScintillationTrackSecondariesFirst(G4bool)
void SetFiniteRiseTime(G4bool)
void SetAbsorptionVerbosity(G4int)
void SetScintillationExcitationRatio(G4double)
virtual void PrintStatistics() const
G4OpticalPhysics(G4int verbose=0, const G4String &name="Optical")
void SetBoundaryVerbosity(G4int)
G4ProcessManager * GetProcessManager() const
const G4String & GetParticleName() const
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
void AddSaturation(G4EmSaturation *sat)
G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const