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

Last change on this file since 1231 was 1203, checked in by garnier, 15 years ago

update CVS

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