DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4CerenkovPhysics.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 
24 #ifndef DDG4_GEANT4CERENKOVPHYSICS_H
25 #define DDG4_GEANT4CERENKOVPHYSICS_H 1
26 
28 #include <DDG4/Geant4PhysicsList.h>
29 
31 #include <G4ParticleTableIterator.hh>
32 #include <G4ParticleDefinition.hh>
33 #include <G4ParticleTypes.hh>
34 #include <G4ParticleTable.hh>
35 #include <G4ProcessManager.hh>
36 #include <G4Version.hh>
37 
38 #if G4VERSION_NUMBER >= 1070
39 #include <G4OpticalParameters.hh>
40 #endif
41 
42 #include <G4Cerenkov.hh>
43 
45 namespace dd4hep {
46 
48  namespace sim {
49 
51 
57  public:
63  Geant4CerenkovPhysics(Geant4Context* ctxt, const std::string& nam)
64  : Geant4PhysicsList(ctxt, nam)
65  {
66  declareProperty("MaxNumPhotonsPerStep", m_maxNumPhotonsPerStep = 0);
67  declareProperty("MaxBetaChangePerStep", m_maxBetaChangePerStep = 0.0);
68  declareProperty("TrackSecondariesFirst", m_trackSecondariesFirst = false);
69  declareProperty("StackPhotons", m_stackPhotons = true);
70  declareProperty("VerboseLevel", m_verbosity = 0);
71  }
73  virtual ~Geant4CerenkovPhysics() = default;
75  virtual void constructProcesses(G4VUserPhysicsList* physics_list) {
76  this->Geant4PhysicsList::constructProcesses(physics_list);
77  info("+++ Constructing: maxNumPhotonsPerStep:%d maxBeta:%f "
78  "track secondaries:%s stack photons:%s track secondaries:%s",
80  yes_no(m_trackSecondariesFirst), yes_no(m_stackPhotons),
81  yes_no(m_trackSecondariesFirst));
82  G4Cerenkov* process = new G4Cerenkov(name());
83 #if G4VERSION_NUMBER >= 1070
84  G4OpticalParameters* params = G4OpticalParameters::Instance();
85  params->SetCerenkovVerboseLevel(m_verbosity);
86  params->SetCerenkovMaxPhotonsPerStep(m_maxNumPhotonsPerStep);
87  params->SetCerenkovMaxBetaChange(m_maxBetaChangePerStep);
88  params->SetCerenkovTrackSecondariesFirst(m_trackSecondariesFirst);
89  params->SetCerenkovStackPhotons(m_stackPhotons);
90 #else
91  process->SetVerboseLevel(m_verbosity);
92  process->SetMaxNumPhotonsPerStep(m_maxNumPhotonsPerStep);
93  process->SetMaxBetaChangePerStep(m_maxBetaChangePerStep);
94  process->SetTrackSecondariesFirst(m_trackSecondariesFirst);
95 #if G4VERSION_NUMBER > 1030
96  process->SetStackPhotons(m_stackPhotons);
97 #endif
98 #endif
99  auto pit = G4ParticleTable::GetParticleTable()->GetIterator();
100  pit->reset();
101  while( (*pit)() ){
102  G4ParticleDefinition* particle = pit->value();
103  if (process->IsApplicable(*particle)) {
104  G4ProcessManager* pmanager = particle->GetProcessManager();
105  pmanager->AddProcess(process);
106  pmanager->SetProcessOrdering(process,idxPostStep);
107  }
108  }
109  }
110 
111  private:
117  };
118  }
119 }
120 #endif // DDG4_GEANT4CERENKOVPHYSICS_H
121 
122 #include <DDG4/Factories.h>
123 using namespace dd4hep::sim;
dd4hep::sim::Geant4CerenkovPhysics::constructProcesses
virtual void constructProcesses(G4VUserPhysicsList *physics_list)
Callback to construct processes (uses the G4 particle table)
Definition: Geant4CerenkovPhysics.cpp:75
dd4hep::sim::Geant4CerenkovPhysics::~Geant4CerenkovPhysics
virtual ~Geant4CerenkovPhysics()=default
Default destructor.
Geant4PhysicsList.h
DECLARE_GEANT4ACTION
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
Definition: Factories.h:210
dd4hep::sim::Geant4CerenkovPhysics::Geant4CerenkovPhysics
Geant4CerenkovPhysics(Geant4Context *ctxt, const std::string &nam)
Initializing constructor.
Definition: Geant4CerenkovPhysics.cpp:63
dd4hep::sim::Geant4CerenkovPhysics::Geant4CerenkovPhysics
Geant4CerenkovPhysics(const Geant4CerenkovPhysics &)=delete
Copy constructor.
dd4hep::sim::Geant4Action::info
void info(const char *fmt,...) const
Support of info messages.
Definition: Geant4Action.cpp:215
dd4hep::sim::Geant4CerenkovPhysics::Geant4CerenkovPhysics
Geant4CerenkovPhysics()=delete
Default constructor.
dd4hep::sim::Geant4CerenkovPhysics::m_stackPhotons
bool m_stackPhotons
Definition: Geant4CerenkovPhysics.cpp:116
dd4hep::sim::Geant4CerenkovPhysics::m_verbosity
int m_verbosity
Definition: Geant4CerenkovPhysics.cpp:114
dd4hep::sim::Geant4Action::declareProperty
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
Definition: Geant4Action.h:366
dd4hep::sim::Geant4CerenkovPhysics::m_maxBetaChangePerStep
double m_maxBetaChangePerStep
Definition: Geant4CerenkovPhysics.cpp:112
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4CerenkovPhysics::m_maxNumPhotonsPerStep
int m_maxNumPhotonsPerStep
Definition: Geant4CerenkovPhysics.cpp:113
Geant4CerenkovPhysics
PhysicsConstructor for Cerenkov physics.
dd4hep::sim::Geant4PhysicsList
Concrete basic implementation of a Geant4 physics list action.
Definition: Geant4PhysicsList.h:41
dd4hep::sim::Geant4CerenkovPhysics::m_trackSecondariesFirst
bool m_trackSecondariesFirst
Definition: Geant4CerenkovPhysics.cpp:115
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::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201