ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpticalPhysics.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4OpticalPhysics.cc
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 "G4OpticalPhoton.hh"
42 #include "G4OpAbsorption.hh"
43 #include "G4OpRayleigh.hh"
44 #include "G4OpMieHG.hh"
45 #include "G4OpBoundaryProcess.hh"
46 #include "G4OpWLS.hh"
47 #include "G4Scintillation.hh"
48 #include "G4Cerenkov.hh"
49 
50 #include "G4LossTableManager.hh"
51 #include "G4EmSaturation.hh"
52 
53 #include "G4ParticleDefinition.hh"
54 #include "G4ProcessManager.hh"
55 
56 // factory
59 
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 
71  : G4VPhysicsConstructor(name),
72 
73  fYieldFactor(1.),
74  fExcitationRatio(0.0),
75  fFiniteRiseTime(false),
76  fScintillationByParticleType(false),
77  fScintillationTrackInfo(false),
78  fScintillationStackPhotons(true),
79  fScintillationVerbosity(0),
80  fMaxNumPhotons(100),
81  fMaxBetaChange(10.0),
82  fCerenkovStackPhotons(true),
83  fCerenkovVerbosity(0),
84  fWLSTimeProfileName("delta"),
85  fWLSVerbosity(0),
86  fAbsorptionVerbosity(0),
87  fRayleighVerbosity(0),
88  fMieVerbosity(0),
89  fInvokeSD(true),
90  fBoundaryVerbosity(0)
91 
92 {
93  verboseLevel = verbose;
95 
96  for ( G4int i=0; i<kNoProcess; i++ ) {
97  fProcessUse.push_back(true);
98  fProcessTrackSecondariesFirst.push_back(true);
99  }
100 }
101 
102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103 
105 {
106  delete fMessenger;
107  fMessenger = nullptr;
108 }
109 
110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
111 
113 {
114 // Print all processes activation and their parameters
115 
116  for ( G4int i=0; i<kNoProcess; i++ ) {
117  G4cout << " " << G4OpticalProcessName(i) << " process: ";
118  if ( ! fProcessUse[i] ) {
119  G4cout << "not used" << G4endl;
120  }
121  else {
122  G4cout << "used" << G4endl;
123  if ( i == kCerenkov ) {
124  G4cout << " Max number of photons per step: " << fMaxNumPhotons << G4endl;
125  G4cout << " Max beta change per step: " << fMaxBetaChange << G4endl;
127  G4cout << " Track secondaries first: activated" << G4endl;
128  }
129  else {
130  G4cout << " Track secondaries first: inactivated" << G4endl;
131  }
132  }
133  if ( i == kScintillation ) {
135  G4cout << " Scintillation by Particle Type: activated " << G4endl;
136  G4cout << " Yield factor: " << fYieldFactor << G4endl;
137  G4cout << " ExcitationRatio: " << fExcitationRatio << G4endl;
139  G4cout << " Track secondaries first: activated" << G4endl;
140  }
141  else {
142  G4cout << " Track secondaries first: inactivated" << G4endl;
143  }
144  }
145  if ( i == kWLS ) {
146  G4cout << " WLS process time profile: " << fWLSTimeProfileName << G4endl;
147  }
148  }
149  }
150 }
151 
152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
153 
155 {
157 }
158 
159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
160 
162 {
163  if(verboseLevel>0)
164  G4cout <<"G4OpticalPhysics:: Add Optical Physics Processes"<< G4endl;
165 
166  // A vector of optical processes
167  std::vector<G4VProcess*> OpProcesses;
168 
169  for ( G4int i=0; i<kNoProcess; i++ ) OpProcesses.push_back(nullptr);
170 
171  // Add Optical Processes
172 
174  OpProcesses[kAbsorption] = fAbsorptionProcess;
175 
177  OpProcesses[kRayleigh] = fRayleighProcess;
178 
179  fMieProcess = new G4OpMieHG();
180  OpProcesses[kMieHG] = fMieProcess;
181 
184  OpProcesses[kBoundary] = fBoundaryProcess;
185 
186  fWLSProcess = new G4OpWLS();
188  OpProcesses[kWLS] = fWLSProcess;
189 
190  G4ProcessManager* pManager = nullptr;
192 
193  if (!pManager) {
195  ed << "Optical Photon without a Process Manager";
196  G4Exception("G4OpticalPhysics::ConstructProcess()","",
197  FatalException,ed);
198  return;
199  }
200 
201  for ( G4int i=kAbsorption; i<=kWLS; i++ ) {
202  if ( fProcessUse[i] ) {
203  pManager->AddDiscreteProcess(OpProcesses[i]);
204  }
205  }
206 
216  fScintillationProcess->AddSaturation(emSaturation);
217  OpProcesses[kScintillation] = fScintillationProcess;
218 
224  OpProcesses[kCerenkov] = fCerenkovProcess;
225 
226  auto myParticleIterator=GetParticleIterator();
227  myParticleIterator->reset();
228 
229  while( (*myParticleIterator)() ){
230 
231  G4ParticleDefinition* particle = myParticleIterator->value();
232  G4String particleName = particle->GetParticleName();
233 
234  pManager = particle->GetProcessManager();
235  if (!pManager) {
237  ed << "Particle " << particleName << "without a Process Manager";
238  G4Exception("G4OpticalPhysics::ConstructProcess()","",
239  FatalException, ed);
240  return; // else coverity complains for pManager use below
241  }
242 
243  if( fCerenkovProcess->IsApplicable(*particle) &&
245  pManager->AddProcess(fCerenkovProcess);
247  }
248  if( fScintillationProcess->IsApplicable(*particle) &&
253  }
254  if( fBoundaryProcess->IsApplicable(*particle) &&
257  }
258  }
259 
260  // Add verbose
261  for ( G4int i=0; i<kNoProcess; i++ ) {
262  if ( fProcessUse[i] ) OpProcesses[i]->SetVerboseLevel(verboseLevel);
263  }
264 
265  if (verboseLevel > 1) PrintStatistics();
266  if (verboseLevel > 0)
267  G4cout << "### " << namePhysics << " physics constructed." << G4endl;
268 }
269 
271 {
272  fYieldFactor = val;
273  if (fScintillationProcess) {
275  }
276 }
277 
279 {
280  fExcitationRatio = val;
281  if (fScintillationProcess) {
283  }
284 }
285 
287 {
289  fMaxNumPhotons = val;
290  if (fCerenkovProcess) {
292  }
293 }
294 
296 {
298  fMaxBetaChange = val;
299  if (fCerenkovProcess) {
301  }
302 }
303 
305 {
306  fCerenkovStackPhotons = val;
307  if (fCerenkovProcess) {
309  }
310 }
311 
313 {
315  if (fCerenkovProcess) {
318  }
319 }
320 
322 {
323  fCerenkovVerbosity = ver;
324  if (fCerenkovProcess) {
326  }
327 }
328 
330 {
333  if (fWLSProcess) {
335  }
336 }
337 
339 {
340  fWLSVerbosity = ver;
341  if (fWLSProcess) {
343  }
344 }
345 
347 {
349  if (fScintillationProcess) {
352  }
353 }
354 
356 {
358  if (fScintillationProcess) {
361  }
362 }
363 
365 {
367  if (fScintillationProcess) {
369  }
370 }
371 
373 {
375  if (fScintillationProcess) {
377  }
378 }
379 
381 {
382  fAbsorptionVerbosity = ver;
383  if (fAbsorptionProcess) {
385  }
386 }
387 
389 {
390  fRayleighVerbosity = ver;
391  if (fRayleighProcess) {
393  }
394 }
395 
397 {
398  fMieVerbosity = ver;
399  if (fMieProcess) {
401  }
402 }
403 
405 {
406  fBoundaryVerbosity = ver;
407  if (fBoundaryProcess) {
409  }
410 }
411 
413  G4bool trackSecondariesFirst)
414 {
415  if ( index >= kNoProcess ) return;
416  if ( fProcessTrackSecondariesFirst[index] == trackSecondariesFirst ) return;
417  fProcessTrackSecondariesFirst[index] = trackSecondariesFirst;
418 }
419 
421 {
422  fFiniteRiseTime = b;
423  if (fScintillationProcess) {
425  }
426 }
427 
429 {
430  fInvokeSD = b;
431  if (fBoundaryProcess) {
433  }
434 }
435 
437 {
438  fScintillationStackPhotons = stackingFlag;
439  if (fScintillationProcess) {
441  }
442 }
443 
445 {
446  // Configure the physics constructor to use/not use a selected process.
447  // This method can only be called in PreInit> phase (before execution of
448  // ConstructProcess). The process is not added to particle's process manager
449  // and so it cannot be re-activated later in Idle> phase with the command
450  // /process/activate.
451 
452  if ( index >= kNoProcess ) return;
453  if ( fProcessUse[index] == isUse ) return;
454  fProcessUse[index] = isUse;
455 }
456 
457 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......