DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4ScintillationPhysics.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_GEANT4SCINTILLATIONPHYSICS_H
25 #define DDG4_GEANT4SCINTILLATIONPHYSICS_H 1
26 
28 #include <DDG4/Geant4PhysicsList.h>
29 
31 #include <G4Version.hh>
32 #include <G4ParticleTableIterator.hh>
33 #include <G4ParticleDefinition.hh>
34 #include <G4LossTableManager.hh>
35 #include <G4ProcessManager.hh>
36 #include <G4ParticleTypes.hh>
37 #include <G4ParticleTable.hh>
38 #include <G4EmSaturation.hh>
39 #include <G4Threading.hh>
40 
41 #if G4VERSION_NUMBER >= 1070
42 #include <G4OpticalParameters.hh>
43 
45 #if G4VERSION_NUMBER == 110000
46 #include <G4OpticalParameters.hh>
47 #pragma message("Geant4 version 11 beta: temporary fix to be removed!")
48 void G4OpticalParameters::SetScintExcitationRatio(double) {}
49 void G4OpticalParameters::SetScintYieldFactor(double) {}
50 #endif
51 
52 #endif
53 
54 #include <G4Scintillation.hh>
55 
57 namespace dd4hep {
58 
60  namespace sim {
61 
63 
69  public:
75  Geant4ScintillationPhysics(Geant4Context* ctxt, const std::string& nam)
76  : Geant4PhysicsList(ctxt, nam)
77  {
78  declareProperty("ScintillationYieldFactor", m_scintillationYieldFactor = 1.0);
79  declareProperty("ScintillationExcitationRatio", m_scintillationExcitationRatio = 1.0);
80  declareProperty("FiniteRiseTime", m_finiteRiseTime = false);
81  declareProperty("TrackSecondariesFirst", m_trackSecondariesFirst = false);
82  declareProperty("StackPhotons", m_stackPhotons = true);
83  declareProperty("ByParticleType", m_byParticleType = false);
84  declareProperty("TrackInfo", m_trackInfo = false);
85  declareProperty("VerboseLevel", m_verbosity = 0);
86  declareProperty("BoundaryInvokeSD", m_boundaryInvokeSD = false);
87  declareProperty("WLSTimeProfile", m_WLSTimeProfile);
88  declareProperty("WLS2TimeProfile", m_WLS2TimeProfile);
89  declareProperty("CerenkovMaxPhotonsPerStep", m_CerenkovMaxPhotonsPerStep = -1);
90  declareProperty("CerenkovMaxBetaChange", m_CerenkovMaxBetaChange = -1.0);
91  declareProperty("ScintEnhancedTimeConstants", m_ScintEnhancedTimeConstants=false);
92  }
94  virtual ~Geant4ScintillationPhysics() = default;
96  virtual void constructProcesses(G4VUserPhysicsList* physics_list) {
97  this->Geant4PhysicsList::constructProcesses(physics_list);
98  info("+++ Constructing: yield:%f excitation:%f finite rise-time:%s "
99  "stack photons:%s track secondaries:%s",
101  yes_no(m_finiteRiseTime), yes_no(m_stackPhotons),
102  yes_no(m_trackSecondariesFirst));
103  G4Scintillation* process = new G4Scintillation(name());
104 #if G4VERSION_NUMBER >= 1070
105  G4OpticalParameters* params = G4OpticalParameters::Instance();
106 #if G4VERSION_NUMBER >= 1100
107  if ( m_CerenkovMaxPhotonsPerStep > 0 )
108  params->SetCerenkovMaxPhotonsPerStep(m_CerenkovMaxPhotonsPerStep);
109  if ( m_CerenkovMaxBetaChange > 0e0 )
110  params->SetCerenkovMaxBetaChange(m_CerenkovMaxBetaChange);
111  if ( !m_WLSTimeProfile.empty() )
112  params->SetWLSTimeProfile(m_WLS2TimeProfile);
113  if ( !m_WLS2TimeProfile.empty() )
114  params->SetWLS2TimeProfile(m_WLS2TimeProfile);
115  params->SetBoundaryInvokeSD(m_boundaryInvokeSD);
116 #endif
117  params->SetScintVerboseLevel(m_verbosity);
118  params->SetScintFiniteRiseTime(m_finiteRiseTime);
119  params->SetScintStackPhotons(m_stackPhotons);
120  params->SetScintTrackSecondariesFirst(m_trackSecondariesFirst);
121  params->SetScintByParticleType(m_byParticleType);
122  params->SetScintTrackInfo(m_trackInfo);
123 #else
124  process->SetVerboseLevel(m_verbosity);
125  process->SetFiniteRiseTime(m_finiteRiseTime);
126 #if G4VERSION_NUMBER >= 1030
127  process->SetStackPhotons(m_stackPhotons);
128 #endif
129  process->SetTrackSecondariesFirst(m_trackSecondariesFirst);
130 #if G4VERSION_NUMBER == 110000
131  // params->SetScintEnhancedTimeConstants(m_ScintEnhancedTimeConstants);
134  process->SetScintillationYieldFactor(m_scintillationYieldFactor);
135  process->SetScintillationExcitationRatio(m_scintillationExcitationRatio);
136 #endif
137 #if G4VERSION_NUMBER >= 940
138  process->SetScintillationByParticleType(m_byParticleType);
139 #endif
140 #if G4VERSION_NUMBER >= 1030
141  process->SetScintillationTrackInfo(m_trackInfo);
142 #endif
143 #endif
144  // Use Birks Correction in the Scintillation process
145  if ( G4Threading::IsMasterThread() ) {
146  G4EmSaturation* emSaturation =
147  G4LossTableManager::Instance()->EmSaturation();
148  process->AddSaturation(emSaturation);
149  }
150 
151  auto pit = G4ParticleTable::GetParticleTable()->GetIterator();
152  pit->reset();
153  while( (*pit)() ){
154  G4ParticleDefinition* particle = pit->value();
155  if (process->IsApplicable(*particle)) {
156  G4ProcessManager* pmanager = particle->GetProcessManager();
157  pmanager->AddProcess(process);
158  pmanager->SetProcessOrdering(process,idxPostStep);
159  }
160  }
161  }
162 
163  private:
168 
170  int m_verbosity { 0 };
172  bool m_stackPhotons { true };
174  bool m_finiteRiseTime { false };
176  bool m_trackSecondariesFirst { false };
178  bool m_byParticleType { false };
180  bool m_trackInfo { false };
181 
183  bool m_boundaryInvokeSD { false };
185  std::string m_WLSTimeProfile { };
187  std::string m_WLS2TimeProfile { };
189  double m_CerenkovMaxBetaChange { -1.0 };
194  };
195  }
196 }
197 #endif // DDG4_GEANT4SCINTILLATIONPHYSICS_H
198 
199 #include <DDG4/Factories.h>
200 using namespace dd4hep::sim;
dd4hep::sim::Geant4ScintillationPhysics::m_scintillationExcitationRatio
double m_scintillationExcitationRatio
G4 11 beta, then disappeared....
Definition: Geant4ScintillationPhysics.cpp:167
dd4hep::sim::Geant4ScintillationPhysics::m_ScintEnhancedTimeConstants
bool m_ScintEnhancedTimeConstants
G4OpticalParameters: "ScintEnhancedTimeConstants".
Definition: Geant4ScintillationPhysics.cpp:193
dd4hep::sim::Geant4ScintillationPhysics::m_WLSTimeProfile
std::string m_WLSTimeProfile
G4OpticalParameters: "WLSTimeProfile".
Definition: Geant4ScintillationPhysics.cpp:185
dd4hep::sim::Geant4ScintillationPhysics::constructProcesses
virtual void constructProcesses(G4VUserPhysicsList *physics_list)
Callback to construct processes (uses the G4 particle table)
Definition: Geant4ScintillationPhysics.cpp:96
dd4hep::sim::Geant4ScintillationPhysics::Geant4ScintillationPhysics
Geant4ScintillationPhysics(Geant4Context *ctxt, const std::string &nam)
Initializing constructor.
Definition: Geant4ScintillationPhysics.cpp:75
dd4hep::sim::Geant4ScintillationPhysics::Geant4ScintillationPhysics
Geant4ScintillationPhysics()=delete
Default constructor.
Geant4PhysicsList.h
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::Geant4ScintillationPhysics::m_boundaryInvokeSD
bool m_boundaryInvokeSD
G4OpticalParameters: "BoundaryInvokeSD".
Definition: Geant4ScintillationPhysics.cpp:183
dd4hep::sim::Geant4Action::declareProperty
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
Definition: Geant4Action.h:366
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4ScintillationPhysics::m_WLS2TimeProfile
std::string m_WLS2TimeProfile
G4OpticalParameters: "WLS2TimeProfile";.
Definition: Geant4ScintillationPhysics.cpp:187
dd4hep::sim::Geant4ScintillationPhysics::m_CerenkovMaxBetaChange
double m_CerenkovMaxBetaChange
G4OpticalParameters: "CerenkovMaxBetaChange".
Definition: Geant4ScintillationPhysics.cpp:189
dd4hep::sim::Geant4ScintillationPhysics::m_verbosity
int m_verbosity
G4OpticalParameters: "VerboseLevel".
Definition: Geant4ScintillationPhysics.cpp:170
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::sim::Geant4ScintillationPhysics::m_finiteRiseTime
bool m_finiteRiseTime
G4OpticalParameters: "ScintFiniteRiseTime".
Definition: Geant4ScintillationPhysics.cpp:174
dd4hep::sim::Geant4ScintillationPhysics::m_scintillationYieldFactor
double m_scintillationYieldFactor
G4 11 beta, then disappeared....
Definition: Geant4ScintillationPhysics.cpp:165
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4ScintillationPhysics::m_byParticleType
bool m_byParticleType
G4OpticalParameters: "ScintByParticleType".
Definition: Geant4ScintillationPhysics.cpp:178
dd4hep::sim::Geant4ScintillationPhysics::m_CerenkovMaxPhotonsPerStep
int m_CerenkovMaxPhotonsPerStep
G4OpticalParameters: "CerenkovMaxPhotonsPerStep".
Definition: Geant4ScintillationPhysics.cpp:191
dd4hep::sim::Geant4ScintillationPhysics::m_trackSecondariesFirst
bool m_trackSecondariesFirst
G4OpticalParameters: "ScintTrackSecondariesFirst".
Definition: Geant4ScintillationPhysics.cpp:176
dd4hep::sim::Geant4ScintillationPhysics::~Geant4ScintillationPhysics
virtual ~Geant4ScintillationPhysics()=default
Default destructor.
dd4hep::sim::Geant4ScintillationPhysics::m_stackPhotons
bool m_stackPhotons
G4OpticalParameters: "CerenkovStackPhotons".
Definition: Geant4ScintillationPhysics.cpp:172
dd4hep::sim::Geant4ScintillationPhysics::m_trackInfo
bool m_trackInfo
G4OpticalParameters: "ScintTrackInfo".
Definition: Geant4ScintillationPhysics.cpp:180
Geant4ScintillationPhysics
PhysicsConstructor for Scintillation physics.
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4ScintillationPhysics::Geant4ScintillationPhysics
Geant4ScintillationPhysics(const Geant4ScintillationPhysics &)=delete
Copy constructor.