source: trunk/source/physics_lists/builders/src/G4OpticalPhysics.cc@ 1328

Last change on this file since 1328 was 1315, checked in by garnier, 15 years ago

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 8.6 KB
Line 
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:
34//
35//----------------------------------------------------------------------------
36//
37
38#include "G4OpticalPhysics.hh"
39
40#include "G4LossTableManager.hh"
41#include "G4EmSaturation.hh"
42
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44G4OpticalPhysics::G4OpticalPhysics(G4int verbose)
45 : G4VPhysicsConstructor("Optical")
46,
47 wasActivated(false),
48
49 fScintillationProcess(0),
50 fCerenkovProcess(0),
51 fOpWLSProcess(0),
52 fOpAbsorptionProcess(0),
53 fOpRayleighScatteringProcess(0),
54 fOpBoundaryProcess(0),
55 fMaxNumPhotons(100),
56 fMaxBetaChange(10.0),
57 fYieldFactor(1.),
58 fExcitationRatio(0.0),
59 fSurfaceModel(unified),
60 fProfile("delta"),
61 fTrackSecondariesFirst(true)
62{
63 verboseLevel = verbose;
64 fMessenger = new G4OpticalPhysicsMessenger(this);
65}
66
67G4OpticalPhysics::G4OpticalPhysics(G4int verbose, const G4String& name)
68 : G4VPhysicsConstructor(name),
69 wasActivated(false),
70
71 fScintillationProcess(0),
72 fCerenkovProcess(0),
73 fOpWLSProcess(0),
74 fOpAbsorptionProcess(0),
75 fOpRayleighScatteringProcess(0),
76 fOpBoundaryProcess(0),
77 fMaxNumPhotons(100),
78 fMaxBetaChange(10.0),
79 fYieldFactor(1.),
80 fExcitationRatio(0.0),
81 fSurfaceModel(unified),
82 fProfile("delta"),
83 fTrackSecondariesFirst(true)
84{
85 verboseLevel = verbose;
86 fMessenger = new G4OpticalPhysicsMessenger(this);
87}
88
89//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90
91G4OpticalPhysics::~G4OpticalPhysics()
92{
93 delete fMessenger;
94
95 if (wasActivated) {
96
97 delete fScintillationProcess;
98 delete fCerenkovProcess;
99 delete fOpWLSProcess;
100
101 delete fOpAbsorptionProcess;
102 delete fOpRayleighScatteringProcess;
103 delete fOpBoundaryProcess;
104
105 }
106}
107
108//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109
110#include "G4OpticalPhoton.hh"
111
112void G4OpticalPhysics::ConstructParticle()
113{
114/// Instantiate particles.
115
116 // optical photon
117 G4OpticalPhoton::OpticalPhotonDefinition();
118}
119
120//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121
122#include "G4ParticleDefinition.hh"
123#include "G4ProcessManager.hh"
124
125void G4OpticalPhysics::ConstructProcess()
126{
127// Construct optical processes.
128
129 if (wasActivated) return;
130
131 if(verboseLevel>0)
132 G4cout <<"G4OpticalPhysics:: Add Optical Physics Processes"<< G4endl;
133
134 // Add Optical Processes
135
136 fOpAbsorptionProcess = new G4OpAbsorption();
137 fOpRayleighScatteringProcess = new G4OpRayleigh();
138
139 fOpBoundaryProcess = new G4OpBoundaryProcess();
140 fOpBoundaryProcess->SetModel(fSurfaceModel);
141
142 fOpWLSProcess = new G4OpWLS();
143 fOpWLSProcess->UseTimeProfile(fProfile);
144
145 G4ProcessManager * pManager = 0;
146 pManager = G4OpticalPhoton::OpticalPhoton()->GetProcessManager();
147
148 if (!pManager) {
149 std::ostringstream o;
150 o << "Optical Photon without a Process Manager";
151 G4Exception("G4OpticalPhysics::ConstructProcess()","",
152 FatalException,o.str().c_str());
153 }
154
155 pManager->AddDiscreteProcess(fOpAbsorptionProcess);
156 pManager->AddDiscreteProcess(fOpRayleighScatteringProcess);
157 pManager->AddDiscreteProcess(fOpBoundaryProcess);
158 pManager->AddDiscreteProcess(fOpWLSProcess);
159
160 fScintillationProcess = new G4Scintillation();
161 fScintillationProcess->SetScintillationYieldFactor(fYieldFactor);
162 fScintillationProcess->SetScintillationExcitationRatio(fExcitationRatio);
163 fScintillationProcess->SetTrackSecondariesFirst(fTrackSecondariesFirst);
164
165 // Use Birks Correction in the Scintillation process
166
167 G4EmSaturation* emSaturation = G4LossTableManager::Instance()->EmSaturation();
168 fScintillationProcess->AddSaturation(emSaturation);
169
170 fCerenkovProcess = new G4Cerenkov();
171 fCerenkovProcess->SetMaxNumPhotonsPerStep(fMaxNumPhotons);
172 fCerenkovProcess->SetMaxBetaChangePerStep(fMaxBetaChange);
173 fCerenkovProcess->SetTrackSecondariesFirst(fTrackSecondariesFirst);
174
175 theParticleIterator->reset();
176
177 while( (*theParticleIterator)() ){
178
179 G4ParticleDefinition* particle = theParticleIterator->value();
180 G4String particleName = particle->GetParticleName();
181
182 pManager = particle->GetProcessManager();
183 if (!pManager) {
184 std::ostringstream o;
185 o << "Particle " << particleName << "without a Process Manager";
186 G4Exception("G4OpticalPhysics::ConstructProcess()","",
187 FatalException,o.str().c_str());
188 }
189
190 if(fCerenkovProcess->IsApplicable(*particle)){
191 pManager->AddProcess(fCerenkovProcess);
192 pManager->SetProcessOrdering(fCerenkovProcess,idxPostStep);
193 }
194 if(fScintillationProcess->IsApplicable(*particle)){
195 pManager->AddProcess(fScintillationProcess);
196 pManager->SetProcessOrderingToLast(fScintillationProcess,idxAtRest);
197 pManager->SetProcessOrderingToLast(fScintillationProcess,idxPostStep);
198 }
199
200 }
201
202 wasActivated = true;
203
204}
205
206void G4OpticalPhysics::SetScintillationYieldFactor(G4double yieldFactor)
207{
208/// Set the scintillation yield factor
209
210 fYieldFactor = yieldFactor;
211
212 if(fScintillationProcess)
213 fScintillationProcess->SetScintillationYieldFactor(yieldFactor);
214}
215
216void G4OpticalPhysics::SetScintillationExcitationRatio(G4double excitationRatio)
217{
218/// Set the scintillation excitation ratio
219
220 fExcitationRatio = excitationRatio;
221
222 if(fScintillationProcess)
223 fScintillationProcess->SetScintillationExcitationRatio(excitationRatio);
224}
225
226void G4OpticalPhysics::SetMaxNumPhotonsPerStep(G4int maxNumPhotons)
227{
228/// Limit step to the specified maximum number of Cherenkov photons
229
230 fMaxNumPhotons = maxNumPhotons;
231
232 if(fCerenkovProcess)
233 fCerenkovProcess->SetMaxNumPhotonsPerStep(maxNumPhotons);
234}
235
236void G4OpticalPhysics::SetMaxBetaChangePerStep(G4double maxBetaChange)
237{
238/// Limit step to the specified maximum change of beta of the parent particle
239
240 fMaxBetaChange = maxBetaChange;
241
242 if(fCerenkovProcess)
243 fCerenkovProcess->SetMaxBetaChangePerStep(maxBetaChange);
244}
245
246void G4OpticalPhysics::SetOpticalSurfaceModel(G4OpticalSurfaceModel model)
247{
248/// Set optical surface model (glisur or unified)
249
250 fSurfaceModel = model;
251
252 if(fOpBoundaryProcess)
253 fOpBoundaryProcess->SetModel(model);
254}
255
256void G4OpticalPhysics::SetWLSTimeProfile(G4String profile)
257{
258/// Set the WLS time profile (delta or exponential)
259
260 fProfile = profile;
261
262 if(fOpWLSProcess)
263 fOpWLSProcess->UseTimeProfile(fProfile);
264}
265
266void G4OpticalPhysics::AddScintillationSaturation(G4EmSaturation* saturation)
267{
268/// Adds Birks Saturation to the G4Scintillation Process
269
270 if(fScintillationProcess)
271 fScintillationProcess->AddSaturation(saturation);
272}
273
274void G4OpticalPhysics::SetTrackSecondariesFirst(G4bool trackSecondariesFirst)
275{
276 fTrackSecondariesFirst = trackSecondariesFirst;
277
278 if ( fCerenkovProcess )
279 fCerenkovProcess->SetTrackSecondariesFirst(trackSecondariesFirst);
280
281 if ( fScintillationProcess )
282 fScintillationProcess->SetTrackSecondariesFirst(trackSecondariesFirst);
283
284}
285
286//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.