Geant4  10.00.p01
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 "G4OpAbsorption.hh"
42 #include "G4OpRayleigh.hh"
43 #include "G4OpMieHG.hh"
44 
45 #include "G4OpBoundaryProcess.hh"
46 
47 #include "G4OpWLS.hh"
48 #include "G4Scintillation.hh"
49 #include "G4Cerenkov.hh"
50 
51 #include "G4LossTableManager.hh"
52 #include "G4EmSaturation.hh"
53 
54 // factory
56 //
58 
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63  : G4VPhysicsConstructor(name),
64 
65  fMaxNumPhotons(100),
66  fMaxBetaChange(10.0),
67  fYieldFactor(1.),
68  fExcitationRatio(0.0),
69  fProfile("delta"),
70  fFiniteRiseTime(false),
71  fScintillationByParticleType(false)
72 {
73  verboseLevel = verbose;
75 
76  for ( G4int i=0; i<kNoProcess; i++ ) {
77  fProcessUse.push_back(true);
78  fProcessVerbose.push_back(verbose);
79  fProcessTrackSecondariesFirst.push_back(true);
80  }
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
87  delete fMessenger;
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
93 {
94 // Print all processes activation and their parameters
95 
96  for ( G4int i=0; i<kNoProcess; i++ ) {
97  G4cout << " " << G4OpticalProcessName(i) << " process: ";
98  if ( ! fProcessUse[i] ) {
99  G4cout << "not used" << G4endl;
100  }
101  else {
102  G4cout << "used" << G4endl;
103  if ( i == kCerenkov ) {
104  G4cout << " Max number of photons per step: " << fMaxNumPhotons << G4endl;
105  G4cout << " Max beta change per step: " << fMaxBetaChange << G4endl;
106  if ( fProcessTrackSecondariesFirst[kCerenkov] ) G4cout << " Track secondaries first: activated" << G4endl;
107  }
108  if ( i == kScintillation ) {
110  G4cout << " Scintillation by Particle Type: activated " << G4endl;
111  G4cout << " Yield factor: " << fYieldFactor << G4endl;
112  G4cout << " ExcitationRatio: " << fExcitationRatio << G4endl;
113  if ( fProcessTrackSecondariesFirst[kScintillation] ) G4cout << " Track secondaries first: activated" << G4endl;
114  }
115  if ( i == kWLS ) {
116  G4cout << " WLS process time profile: " << fProfile << G4endl;
117  }
118  }
119  }
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
124 #include "G4OpticalPhoton.hh"
125 
127 {
129 
130  // optical photon
132 }
133 
134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
135 
136 #include "G4Threading.hh"
137 #include "G4ParticleDefinition.hh"
138 #include "G4ProcessManager.hh"
139 
141 {
142 // Construct optical processes.
143 
144  if(verboseLevel>0)
145  G4cout <<"G4OpticalPhysics:: Add Optical Physics Processes"<< G4endl;
146 
147  // A vector of optical processes
148  std::vector<G4VProcess*> OpProcesses;
149 
150  for ( G4int i=0; i<kNoProcess; i++ ) OpProcesses.push_back(NULL);
151 
152  // Add Optical Processes
153 
154  G4OpAbsorption* OpAbsorptionProcess = new G4OpAbsorption();
155  G4OpRayleigh* OpRayleighScatteringProcess = new G4OpRayleigh();
156  G4OpMieHG* OpMieHGScatteringProcess = new G4OpMieHG();
157 
158  OpProcesses[kAbsorption] = OpAbsorptionProcess;
159  OpProcesses[kRayleigh] = OpRayleighScatteringProcess;
160  OpProcesses[kMieHG] = OpMieHGScatteringProcess;
161 
162  G4OpBoundaryProcess* OpBoundaryProcess = new G4OpBoundaryProcess();
163 
164  OpProcesses[kBoundary] = OpBoundaryProcess;
165 
166  G4OpWLS* OpWLSProcess = new G4OpWLS();
167 
168  OpProcesses[kWLS] = OpWLSProcess;
169 
170  G4ProcessManager * pManager = 0;
172 
173  if (!pManager) {
174  std::ostringstream o;
175  o << "Optical Photon without a Process Manager";
176  G4Exception("G4OpticalPhysics::ConstructProcess()","",
177  FatalException,o.str().c_str());
178  return;
179  }
180 
181  for ( G4int i=kAbsorption; i<=kWLS; i++ ) {
182  if ( fProcessUse[i] ) {
183  pManager->AddDiscreteProcess(OpProcesses[i]);
184  }
185  }
186 
187  G4Scintillation* ScintillationProcess = new G4Scintillation();
188 
189  OpProcesses[kScintillation] = ScintillationProcess;
190 
191  G4Cerenkov* CerenkovProcess = new G4Cerenkov();
192  OpProcesses[kCerenkov] = CerenkovProcess;
193 
194  // static parameters - set only for masther thread
196  {
198 
204 
205  // Use Birks Correction in the Scintillation process
207  G4Scintillation::AddSaturation(emSaturation);
208 
212  }
213 
214  aParticleIterator->reset();
215 
216  while( (*aParticleIterator)() ){
217 
218  G4ParticleDefinition* particle = aParticleIterator->value();
219  G4String particleName = particle->GetParticleName();
220 
221  pManager = particle->GetProcessManager();
222  if (!pManager) {
223  std::ostringstream o;
224  o << "Particle " << particleName << "without a Process Manager";
225  G4Exception("G4OpticalPhysics::ConstructProcess()","",
226  FatalException,o.str().c_str());
227  return; // else coverity complains for pManager use below
228  }
229 
230  if( CerenkovProcess->IsApplicable(*particle) &&
232  pManager->AddProcess(CerenkovProcess);
233  pManager->SetProcessOrdering(CerenkovProcess,idxPostStep);
234  }
235  if( ScintillationProcess->IsApplicable(*particle) &&
237  pManager->AddProcess(ScintillationProcess);
238  pManager->SetProcessOrderingToLast(ScintillationProcess,idxAtRest);
239  pManager->SetProcessOrderingToLast(ScintillationProcess,idxPostStep);
240  }
241 
242  }
243 
244  // Add verbose
245  for ( G4int i=0; i<kNoProcess; i++ ) {
246  if ( fProcessUse[i] ) OpProcesses[i]->SetVerboseLevel(fProcessVerbose[i]);
247  }
248 
249  if (verboseLevel > 1) PrintStatistics();
250  if (verboseLevel > 0)
251  G4cout << "### " << namePhysics << " physics constructed." << G4endl;
252 }
253 
255 {
257 
258  fYieldFactor = yieldFactor;
260 }
261 
263 {
265 
266  fExcitationRatio = excitationRatio;
268 }
269 
271 {
273 
274  fMaxNumPhotons = maxNumPhotons;
276 }
277 
279 {
281 
282  fMaxBetaChange = maxBetaChange;
284 }
285 
287 {
289 
290  fProfile = profile;
291  G4OpWLS::UseTimeProfile(profile);
292 }
293 
295 {
297  G4Scintillation::AddSaturation(saturation);
298 }
299 
301  SetScintillationByParticleType(G4bool scintillationByParticleType)
302 {
303  fScintillationByParticleType = scintillationByParticleType;
304  G4Scintillation::SetScintillationByParticleType(scintillationByParticleType);
305 }
306 
308  G4bool trackSecondariesFirst)
309 {
310  if ( index >= kNoProcess ) return;
311  if ( fProcessTrackSecondariesFirst[index] == trackSecondariesFirst ) return;
312  fProcessTrackSecondariesFirst[index] = trackSecondariesFirst;
313 
314  if ( index == kCerenkov )
315  G4Cerenkov::SetTrackSecondariesFirst(trackSecondariesFirst);
316  if ( index == kScintillation)
317  G4Scintillation::SetTrackSecondariesFirst(trackSecondariesFirst);
318 }
319 
321 {
322  fFiniteRiseTime = finiteRiseTime;
323  G4Scintillation::SetFiniteRiseTime(finiteRiseTime);
324 }
325 
327 {
328  // Configure the physics constructor to use/not use a selected process.
329  // This method can only be called in PreInit> phase (before execution of
330  // ConstructProcess). The process is not added to particle's process manager
331  // and so it cannot be re-activated later in Idle> phase with the command
332  // /process/activate.
333 
334  if ( index >= kNoProcess ) return;
335  if ( fProcessUse[index] == isUse ) return;
336  fProcessUse[index] = isUse;
337 }
338 
340  G4int verbose)
341 {
342  // Set new verbose level to a selected process
343 
344  if ( index >= kNoProcess ) return;
345  if ( fProcessVerbose[index] == verbose ) return;
346  fProcessVerbose[index] = verbose;
347 }
348 
349 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static void SetScintillationByParticleType(const G4bool)
static void SetMaxBetaChangePerStep(const G4double d)
Definition: G4Cerenkov.cc:148
void SetProcessVerbose(G4int, G4int)
static G4LossTableManager * Instance()
static void SetFiniteRiseTime(const G4bool state)
Number of processes, no selected process.
virtual void ConstructParticle()
G4OpticalProcessIndex
void AddScintillationSaturation(G4EmSaturation *)
static void SetTrackSecondariesFirst(const G4bool state)
Definition: G4Cerenkov.cc:143
void SetMaxBetaChangePerStep(G4double)
G4String name
Definition: TRTMaterials.hh:40
G4OpticalPhysicsMessenger * fMessenger
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
Scintillation process index.
G4bool IsApplicable(const G4ParticleDefinition &aParticleType)
Mie scattering process index.
void SetFiniteRiseTime(G4bool)
Absorption process index.
G4ProcessManager * GetProcessManager() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
void SetScintillationByParticleType(G4bool)
std::vector< G4bool > fProcessTrackSecondariesFirst
G4double fMaxBetaChange
max change of beta per step
static void UseTimeProfile(const G4String name)
Definition: G4OpWLS.cc:426
virtual void ConstructProcess()
virtual ~G4OpticalPhysics()
static void SetScintillationYieldFactor(const G4double yieldfactor)
std::vector< G4bool > fProcessUse
G4double fYieldFactor
scintillation yield factor
G4GLOB_DLL std::ostream G4cout
void SetMaxNumPhotonsPerStep(G4int)
static void AddSaturation(G4EmSaturation *)
G4bool fFiniteRiseTime
option to set a finite rise-time; Note: the G4Scintillation process expects the user to have set the ...
bool G4bool
Definition: G4Types.hh:79
#define aParticleIterator
void Configure(G4OpticalProcessIndex, G4bool)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
G4EmSaturation * EmSaturation()
G4int fMaxNumPhotons
max number of Cerenkov photons per step
G4_DECLARE_PHYSCONSTR_FACTORY(G4OpticalPhysics)
static void SetMaxNumPhotonsPerStep(const G4int NumPhotons)
Definition: G4Cerenkov.cc:153
std::vector< G4int > fProcessVerbose
G4double fExcitationRatio
scintillation excitation ratio
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
Wave Length Shifting process index.
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4bool IsWorkerThread()
Definition: G4Threading.cc:104
static void SetScintillationExcitationRatio(const G4double ratio)
static G4OpticalPhoton * OpticalPhoton()
void SetScintillationExcitationRatio(G4double)
G4String G4OpticalProcessName(G4int)
Return the name for a given optical process index.
G4OpticalPhysics(G4int verbose=0, const G4String &name="Optical")
Boundary process index.
void SetScintillationYieldFactor(G4double)
static void SetTrackSecondariesFirst(const G4bool state)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
Cerenkov process index.
void SetWLSTimeProfile(G4String)
void SetTrackSecondariesFirst(G4OpticalProcessIndex, G4bool)
#define G4endl
Definition: G4ios.hh:61
static G4OpticalPhoton * OpticalPhotonDefinition()
Rayleigh scattering process index.
double G4double
Definition: G4Types.hh:76
G4String fProfile
the WLS process time profile
void PrintStatistics() const
G4bool fScintillationByParticleType
option to allow for the light yield to be a function of particle type and deposited energy in case of...
G4bool IsApplicable(const G4ParticleDefinition &aParticleType)
Definition: G4Cerenkov.cc:132