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