Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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"
40
41#include "G4Cerenkov.hh"
42#include "G4EmSaturation.hh"
43#include "G4LossTableManager.hh"
44#include "G4OpAbsorption.hh"
46#include "G4OpRayleigh.hh"
47#include "G4OpMieHG.hh"
49#include "G4OpWLS.hh"
50#include "G4OpWLS2.hh"
52#include "G4ProcessManager.hh"
53#include "G4Scintillation.hh"
54
55// factory
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62{
63 verboseLevel = verbose;
65}
66
67//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69
70//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72{
74}
75
76//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78{
80}
81
82//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84{
85 if(verboseLevel > 0)
86 G4cout << "G4OpticalPhysics:: Add Optical Physics Processes" << G4endl;
87
88 auto params = G4OpticalParameters::Instance();
89
90 // Add Optical Processes
91
92 G4ProcessManager* pManager =
94 if(!pManager)
95 {
97 ed << "Optical Photon without a Process Manager";
98 G4Exception("G4OpticalPhysics::ConstructProcess()", "", FatalException, ed);
99 return;
100 }
101
102 G4OpAbsorption* absorption = new G4OpAbsorption();
103 if(params->GetProcessActivation("OpAbsorption"))
104 pManager->AddDiscreteProcess(absorption);
105
106 G4OpRayleigh* rayleigh = new G4OpRayleigh();
107 if(params->GetProcessActivation("OpRayleigh"))
108 pManager->AddDiscreteProcess(rayleigh);
109
110 G4OpMieHG* mie = new G4OpMieHG();
111 if(params->GetProcessActivation("OpMieHG"))
112 pManager->AddDiscreteProcess(mie);
113
115 if(params->GetProcessActivation("OpBoundary"))
116 pManager->AddDiscreteProcess(boundary);
117
118 G4OpWLS* wls = new G4OpWLS();
119 if(params->GetProcessActivation("OpWLS"))
120 pManager->AddDiscreteProcess(wls);
121
122 G4OpWLS2* wls2 = new G4OpWLS2();
123 if(params->GetProcessActivation("OpWLS2"))
124 pManager->AddDiscreteProcess(wls2);
125
126 G4Scintillation* scint = new G4Scintillation();
128 scint->AddSaturation(emSaturation);
129
130 G4Cerenkov* cerenkov = new G4Cerenkov();
131
132 auto myParticleIterator = GetParticleIterator();
133 myParticleIterator->reset();
134
135 while((*myParticleIterator)())
136 {
137 G4ParticleDefinition* particle = myParticleIterator->value();
138 G4String particleName = particle->GetParticleName();
139
140 pManager = particle->GetProcessManager();
141 if(!pManager)
142 {
144 ed << "Particle " << particleName << "without a Process Manager";
145 G4Exception("G4OpticalPhysics::ConstructProcess()", "", FatalException,
146 ed);
147 return; // else coverity complains for pManager use below
148 }
149
150 if(cerenkov->IsApplicable(*particle) &&
151 params->GetProcessActivation("Cerenkov"))
152 {
153 pManager->AddProcess(cerenkov);
154 pManager->SetProcessOrdering(cerenkov, idxPostStep);
155 }
156 if(scint->IsApplicable(*particle) &&
157 params->GetProcessActivation("Scintillation"))
158 {
159 pManager->AddProcess(scint);
160 pManager->SetProcessOrderingToLast(scint, idxAtRest);
161 pManager->SetProcessOrderingToLast(scint, idxPostStep);
162 }
163 if(boundary->IsApplicable(*particle) &&
164 params->GetProcessActivation("OpBoundary"))
165 {
166 pManager->SetProcessOrderingToLast(boundary, idxPostStep);
167 }
168 }
169
170 if(verboseLevel > 1)
172 if(verboseLevel > 0)
173 G4cout << "### " << namePhysics << " physics constructed." << G4endl;
174}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4_DECLARE_PHYSCONSTR_FACTORY(physics_constructor)
@ idxPostStep
@ idxAtRest
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:122
static G4LossTableManager * Instance()
G4EmSaturation * EmSaturation()
virtual G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override
static G4OpticalParameters * Instance()
static G4OpticalPhoton * OpticalPhotonDefinition()
static G4OpticalPhoton * OpticalPhoton()
void ConstructProcess() override
~G4OpticalPhysics() override
void ConstructParticle() override
void PrintStatistics() const
G4OpticalPhysics(G4int verbose=0, const G4String &name="Optical")
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