DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4OpticalPhotonPhysics.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
26 #ifndef DDG4_GEANT4OPTICALPHOTONPHYSICS_H
27 #define DDG4_GEANT4OPTICALPHOTONPHYSICS_H 1
28 
29 // Framework include files
30 #include <DDG4/Geant4PhysicsList.h>
31 
33 #include <G4OpAbsorption.hh>
34 #include <G4OpRayleigh.hh>
35 #include <G4OpMieHG.hh>
36 #include <G4OpBoundaryProcess.hh>
37 #include <G4ParticleDefinition.hh>
38 #include <G4ParticleTypes.hh>
39 #include <G4ParticleTable.hh>
40 #include <G4ProcessManager.hh>
41 #include <G4Version.hh>
42 
43 #if G4VERSION_NUMBER >= 1070
44 #include <G4OpticalParameters.hh>
45 #endif
46 
48 namespace dd4hep {
49 
51  namespace sim {
52 
54 
60  public:
66  Geant4OpticalPhotonPhysics(Geant4Context* ctxt, const std::string& nam)
67  : Geant4PhysicsList(ctxt, nam)
68  {
69  declareProperty("VerboseLevel", m_verbosity = 0);
70  declareProperty("BoundaryInvokeSD", m_boundaryInvokeSD = false);
71  }
73  virtual ~Geant4OpticalPhotonPhysics() = default;
75  virtual void constructProcesses(G4VUserPhysicsList* physics_list) {
76  this->Geant4PhysicsList::constructProcesses(physics_list);
77  info("+++ Constructing optical_photon processes:");
78  info("+++ G4OpAbsorption G4OpRayleigh G4OpMieHG G4OpBoundaryProcess");
79  G4ParticleTable* table = G4ParticleTable::GetParticleTable();
80  G4ParticleDefinition* particle = table->FindParticle("opticalphoton");
81  if (0 == particle) {
82  except("++ Cannot resolve 'opticalphoton' particle definition!");
83  }
84 
85  G4OpBoundaryProcess* fBoundaryProcess = new G4OpBoundaryProcess();
86  G4OpAbsorption* fAbsorptionProcess = new G4OpAbsorption();
87  G4OpRayleigh* fRayleighScatteringProcess = new G4OpRayleigh();
88  G4OpMieHG* fMieHGScatteringProcess = new G4OpMieHG();
89 
90 #if G4VERSION_NUMBER >= 1070
91  G4OpticalParameters* params = G4OpticalParameters::Instance();
92  params->SetAbsorptionVerboseLevel(m_verbosity);
93  params->SetRayleighVerboseLevel(m_verbosity);
94  params->SetMieVerboseLevel(m_verbosity);
95  params->SetBoundaryVerboseLevel(m_verbosity);
96  params->SetBoundaryInvokeSD(m_boundaryInvokeSD);
97 #else
98  fAbsorptionProcess->SetVerboseLevel(m_verbosity);
99  fRayleighScatteringProcess->SetVerboseLevel(m_verbosity);
100  fMieHGScatteringProcess->SetVerboseLevel(m_verbosity);
101  fBoundaryProcess->SetVerboseLevel(m_verbosity);
102 #if G4VERSION_NUMBER >= 1000
103  fBoundaryProcess->SetInvokeSD(m_boundaryInvokeSD);
104 #endif
105 #endif
106  G4ProcessManager* pmanager = particle->GetProcessManager();
107  pmanager->AddDiscreteProcess(fAbsorptionProcess);
108  pmanager->AddDiscreteProcess(fRayleighScatteringProcess);
109  pmanager->AddDiscreteProcess(fMieHGScatteringProcess);
110  pmanager->AddDiscreteProcess(fBoundaryProcess);
111  }
112  private:
115  };
116  }
117 }
118 #endif // DDG4_GEANT4OPTICALPHOTONPHYSICS_H
119 
120 #include <DDG4/Factories.h>
121 using namespace dd4hep::sim;
dd4hep::sim::Geant4OpticalPhotonPhysics
Geant4 physics list action to enable OpticalPhoton physics.
Definition: Geant4OpticalPhotonPhysics.cpp:59
Geant4PhysicsList.h
dd4hep::sim::Geant4OpticalPhotonPhysics::Geant4OpticalPhotonPhysics
Geant4OpticalPhotonPhysics()=delete
Default constructor.
DECLARE_GEANT4ACTION
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
Definition: Factories.h:210
dd4hep::sim::Geant4Action::info
void info(const char *fmt,...) const
Support of info messages.
Definition: Geant4Action.cpp:215
dd4hep::sim::Geant4Action::except
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
Definition: Geant4Action.cpp:256
dd4hep::sim::Geant4OpticalPhotonPhysics::m_boundaryInvokeSD
bool m_boundaryInvokeSD
Definition: Geant4OpticalPhotonPhysics.cpp:114
dd4hep::sim::Geant4OpticalPhotonPhysics::~Geant4OpticalPhotonPhysics
virtual ~Geant4OpticalPhotonPhysics()=default
Default destructor.
dd4hep::sim::Geant4Action::declareProperty
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
Definition: Geant4Action.h:366
dd4hep::sim::Geant4OpticalPhotonPhysics::Geant4OpticalPhotonPhysics
Geant4OpticalPhotonPhysics(const Geant4OpticalPhotonPhysics &)=delete
Copy constructor.
dd4hep::sim::Geant4PhysicsList
Concrete basic implementation of a Geant4 physics list action.
Definition: Geant4PhysicsList.h:41
Factories.h
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep::sim::Geant4PhysicsList::constructProcesses
virtual void constructProcesses(G4VUserPhysicsList *physics)
Callback to construct processes (uses the G4 particle table)
Definition: Geant4PhysicsList.cpp:271
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4OpticalPhotonPhysics::Geant4OpticalPhotonPhysics
Geant4OpticalPhotonPhysics(Geant4Context *ctxt, const std::string &nam)
Initializing constructor.
Definition: Geant4OpticalPhotonPhysics.cpp:66
dd4hep::sim::Geant4OpticalPhotonPhysics::m_verbosity
int m_verbosity
Definition: Geant4OpticalPhotonPhysics.cpp:113
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4OpticalPhotonPhysics::constructProcesses
virtual void constructProcesses(G4VUserPhysicsList *physics_list)
Callback to construct processes (uses the G4 particle table)
Definition: Geant4OpticalPhotonPhysics.cpp:75