File indexing completed on 2025-01-30 09:17:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DDG4/Geant4StepHandler.h>
0016 #include <DDSegmentation/Segmentation.h>
0017 #include <DD4hep/DD4hepUnits.h>
0018 #include <CLHEP/Units/SystemOfUnits.h>
0019
0020
0021 #include <G4Version.hh>
0022
0023 namespace units = dd4hep;
0024 using namespace dd4hep::sim;
0025
0026
0027 const char* Geant4StepHandler::stepStatus(G4StepStatus status) {
0028 switch (status) {
0029
0030 case fWorldBoundary:
0031 return "WorldBoundary";
0032
0033 case fGeomBoundary:
0034 return "GeomBoundary";
0035
0036 case fAtRestDoItProc:
0037 return "AtRestDoItProc";
0038
0039 case fAlongStepDoItProc:
0040 return "AlongStepDoItProc";
0041
0042 case fPostStepDoItProc:
0043 return "PostStepDoItProc";
0044
0045 case fUserDefinedLimit:
0046 return "UserDefinedLimit";
0047
0048 case fExclusivelyForcedProc:
0049 return "ExclusivelyForcedProc";
0050
0051 case fUndefined:
0052 default:
0053 return "Undefined";
0054 };
0055 }
0056
0057
0058 const char* Geant4StepHandler::preStepStatus() const {
0059 return stepStatus(pre ? pre->GetStepStatus() : fUndefined);
0060 }
0061
0062
0063 const char* Geant4StepHandler::postStepStatus() const {
0064 return stepStatus(post ? post->GetStepStatus() : fUndefined);
0065 }
0066
0067
0068 double Geant4StepHandler::birkAttenuation() const {
0069 #if G4VERSION_NUMBER >= 1001
0070 static G4EmSaturation s_emSaturation(1);
0071 #else
0072 static G4EmSaturation s_emSaturation();
0073 s_emSaturation.SetVerbose(1);
0074 #endif
0075
0076 #if G4VERSION_NUMBER >= 1030
0077 static bool s_initialised = false;
0078 if(not s_initialised) {
0079 s_emSaturation.InitialiseG4Saturation();
0080 s_initialised = true;
0081 }
0082 #endif
0083
0084 double energyDeposition = step->GetTotalEnergyDeposit();
0085 double length = step->GetStepLength();
0086 double niel = step->GetNonIonizingEnergyDeposit();
0087 const G4Track* trk = step->GetTrack();
0088 const G4ParticleDefinition* particle = trk->GetDefinition();
0089 const G4MaterialCutsCouple* couple = trk->GetMaterialCutsCouple();
0090 double engyVis = s_emSaturation.VisibleEnergyDeposition(particle,
0091 couple,
0092 length,
0093 energyDeposition,
0094 niel);
0095 return engyVis;
0096 }