All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FastOpticalPhysics.cxx
Go to the documentation of this file.
1 // Adapted for LArSoft by Ben Jones, MIT, Nov 2012
2 //
3 // This class is based upon the default Geant4 optical physics constructor.
4 // However, for fast optical physics in LArSoft:
5 //
6 // - The default geant4 scintillation process is swapped for the LArG4 fast
7 // scintillation process
8 //
9 // - Cerenkov light (still slow) can be enabled or disabled as required
10 //
11 // - The default geant4 reflection process is swapped for a simpler
12 // custom boundary process in LArG4
13 //
14 // Parameters relating to the physics in this constructor can be set
15 // in the Utilities/LArParameters service.
16 //
17 //
18 // ********************************************************************
19 // * License and Disclaimer *
20 // * *
21 // * The Geant4 software is copyright of the Copyright Holders of *
22 // * the Geant4 Collaboration. It is provided under the terms and *
23 // * conditions of the Geant4 Software License, included in the file *
24 // * LICENSE and available at http://cern.ch/geant4/license . These *
25 // * include a list of copyright holders. *
26 // * *
27 // * Neither the authors of this software system, nor their employing *
28 // * institutes,nor the agencies providing financial support for this *
29 // * work make any representation or warranty, express or implied, *
30 // * regarding this software system or assume any liability for its *
31 // * use. Please see the license in the file LICENSE and URL above *
32 // * for the full disclaimer and the limitation of liability. *
33 // * *
34 // * This code implementation is the result of the scientific and *
35 // * technical work of the GEANT4 collaboration. *
36 // * By using, copying, modifying or distributing the software (or *
37 // * any work based on the software) you agree to acknowledge its *
38 // * use in resulting scientific publications, and indicate your *
39 // * acceptance of all terms of the Geant4 Software license. *
40 // ********************************************************************
41 //
42 
46 
49 
50 #include "messagefacility/MessageLogger/MessageLogger.h"
51 
52 #include "Geant4/G4LossTableManager.hh"
53 #include "Geant4/G4ParticleDefinition.hh"
54 #include "Geant4/G4ParticleTable.hh"
55 #include "Geant4/G4ProcessManager.hh"
56 
57 #include "Geant4/G4Alpha.hh"
58 #include "Geant4/G4AntiProton.hh"
59 #include "Geant4/G4Deuteron.hh"
60 #include "Geant4/G4Electron.hh"
61 #include "Geant4/G4Gamma.hh"
62 #include "Geant4/G4GenericIon.hh"
63 #include "Geant4/G4He3.hh"
64 #include "Geant4/G4KaonMinus.hh"
65 #include "Geant4/G4KaonPlus.hh"
66 #include "Geant4/G4MuonMinus.hh"
67 #include "Geant4/G4MuonPlus.hh"
68 #include "Geant4/G4OpticalPhoton.hh"
69 #include "Geant4/G4PionMinus.hh"
70 #include "Geant4/G4PionPlus.hh"
71 #include "Geant4/G4Positron.hh"
72 #include "Geant4/G4Proton.hh"
73 #include "Geant4/G4Triton.hh"
74 
75 #include "Geant4/G4Cerenkov.hh"
76 #include "Geant4/G4OpAbsorption.hh"
77 #include "Geant4/G4OpRayleigh.hh"
78 #include "Geant4/G4OpWLS.hh"
79 
80 namespace larg4 {
81 
82  //-----------------------------------------------------------
83  FastOpticalPhysics::FastOpticalPhysics(G4int /*verbose*/, const G4String& name)
84  : G4VPhysicsConstructor(name)
85  {
86  G4LossTableManager::Instance();
87  mf::LogInfo("FastOpticalPhysics") << "OBJECT BEING CONSTRUCTED IN OPTICAL PHYSICS";
88  }
89 
90  //-----------------------------------------------------------
91  void
93  {
94  MF_LOG_DEBUG("FastOpticalPhysics") << "PARTICLES BEING CONSTRUCTED IN FAST OPTICAL PHYSICS";
95  // optical photon
96  G4OpticalPhoton::OpticalPhotonDefinition();
97 
98  // gamma
99  G4Gamma::Gamma();
100 
101  // leptons
102  G4Electron::Electron();
103  G4Positron::Positron();
104  G4MuonPlus::MuonPlus();
105  G4MuonMinus::MuonMinus();
106 
107  // mesons
108  G4PionPlus::PionPlusDefinition();
109  G4PionMinus::PionMinusDefinition();
110  G4KaonPlus::KaonPlusDefinition();
111  G4KaonMinus::KaonMinusDefinition();
112 
113  // barions
114  G4Proton::Proton();
115  G4AntiProton::AntiProton();
116 
117  // ions
118  G4Deuteron::Deuteron();
119  G4Triton::Triton();
120  G4He3::He3();
121  G4Alpha::Alpha();
122  G4GenericIon::GenericIonDefinition();
123  }
124 
125  //-----------------------------------------------------------
126  void
128  {
129  // Add standard EM Processes
130  MF_LOG_DEBUG("FastOpticalPhysics") << "PROCESSES BEING CONSTRUCTED IN OPTICAL PHYSICS";
131 
132  fTheCerenkovProcess = new G4Cerenkov("Cerenkov");
133  fTheAbsorptionProcess = new G4OpAbsorption();
134  fTheRayleighScatteringProcess = new G4OpRayleigh();
136  fTheWLSProcess = new G4OpWLS();
137  fTheScintillationProcess = std::make_unique<OpFastScintillation>("FastScintillation");
138 
139  fTheCerenkovProcess->SetMaxNumPhotonsPerStep(700);
140  fTheCerenkovProcess->SetMaxBetaChangePerStep(10.0);
141  fTheCerenkovProcess->SetTrackSecondariesFirst(false);
142 
143  const detinfo::LArProperties* larp = lar::providerFrom<detinfo::LArPropertiesService>();
144  bool CerenkovEnabled = larp->CerenkovLightEnabled();
145 
146  mf::LogInfo("FastOpticalPhysics") << "Cerenkov enabled : " << CerenkovEnabled;
147  static G4ParticleTable* fParticleTable = G4ParticleTable::GetParticleTable();
148  G4ParticleTable::G4PTblDicIterator* aParticleIterator;
149  aParticleIterator = fParticleTable->GetIterator();
150  aParticleIterator->reset();
151  while ((*aParticleIterator)()) {
152  G4ParticleDefinition* particle = aParticleIterator->value();
153  G4ProcessManager* pmanager = particle->GetProcessManager();
154  G4String particleName = particle->GetParticleName();
155 
156  if (fTheCerenkovProcess->IsApplicable(*particle) && CerenkovEnabled) {
157  pmanager->AddProcess(fTheCerenkovProcess);
158  pmanager->SetProcessOrdering(fTheCerenkovProcess, idxPostStep);
159  }
160  if (fTheScintillationProcess->IsApplicable(*particle)) {
161  auto ptr = fTheScintillationProcess.get();
162  pmanager->AddProcess(ptr);
163  pmanager->SetProcessOrderingToLast(ptr, idxAtRest);
164  pmanager->SetProcessOrderingToLast(ptr, idxPostStep);
165  }
166 
167  if (particleName == "opticalphoton") {
168  mf::LogInfo("FastOptical") << " AddDiscreteProcess to OpticalPhoton ";
169  pmanager->AddDiscreteProcess(fTheAbsorptionProcess);
170  pmanager->AddDiscreteProcess(fTheRayleighScatteringProcess);
171  pmanager->AddDiscreteProcess(fTheBoundaryProcess);
172  pmanager->AddDiscreteProcess(fTheWLSProcess);
173  }
174  }
175  }
176 }
virtual bool CerenkovLightEnabled() const =0
Utilities related to art service access.
G4OpAbsorption * fTheAbsorptionProcess
Discrete process for reflection and diffusion at optical interfaces.
std::unique_ptr< OpFastScintillation > fTheScintillationProcess
OpBoundaryProcessSimple * fTheBoundaryProcess
G4OpRayleigh * fTheRayleighScatteringProcess
FastOpticalPhysics(G4int ver=0, const G4String &name="FastOptical")
then echo fcl name