9#include <simulation/kernel/ExtEnergyLoss.h>
10#include <simulation/kernel/EnergyLossForExtrapolator.h>
12#include <G4ErrorPropagatorData.hh>
14#include <framework/logging/Logger.h>
18using namespace Belle2::Simulation;
21 : G4VContinuousProcess(processName, type), m_energyLossForExtrapolator(NULL)
23 B2DEBUG(200,
"ExtEnergyLoss is created");
46 aParticleChange.Initialize(aTrack);
48 G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
50 G4double kinEnergyStart = aTrack.GetKineticEnergy();
51 G4double step_length = aStep.GetStepLength();
53 const G4Material* aMaterial = aTrack.GetMaterial();
54 const G4ParticleDefinition* aParticleDef = aTrack.GetDynamicParticle()->GetDefinition();
55 G4double kinEnergyEnd = kinEnergyStart;
57 if (g4edata->GetMode() == G4ErrorMode(G4ErrorMode_PropBackwards)) {
62 G4double kinEnergyHalfStep = (kinEnergyStart + kinEnergyEnd) * 0.5;
64 B2DEBUG(200,
"ExtEnergyLoss::AlongStepDoIt() BWD end " << kinEnergyEnd <<
" halfstep " << kinEnergyHalfStep);
71 kinEnergyEnd = kinEnergyStart - (kinEnergyHalfStep - kinEnergyEnd);
72 }
else if (g4edata->GetMode() == G4ErrorMode(G4ErrorMode_PropForwards)) {
78 G4double kinEnergyHalfStep = (kinEnergyStart + kinEnergyEnd) * 0.5;
79 B2DEBUG(200,
"ExtEnergyLoss::AlongStepDoIt() FWD end " << kinEnergyEnd <<
" halfstep " << kinEnergyHalfStep);
86 kinEnergyEnd = kinEnergyStart - (kinEnergyHalfStep - kinEnergyEnd);
89 G4double edepo = kinEnergyEnd - kinEnergyStart;
91 B2DEBUG(300,
"ExtEnergyLoss::AlongStepDoIt() Estart= " << kinEnergyStart <<
" Eend " << kinEnergyEnd
92 <<
" Ediff " << -edepo <<
" step= " << step_length <<
" mate= " << aMaterial->GetName()
93 <<
" particle= " << aParticleDef->GetParticleName());
95 aParticleChange.ClearDebugFlag();
96 aParticleChange.ProposeLocalEnergyDeposit(edepo);
97 aParticleChange.SetNumberOfSecondaries(0);
99 aParticleChange.ProposeEnergy(kinEnergyEnd);
101 return &aParticleChange;
106 G4double currentMinimumStep,
109 G4double step = DBL_MAX;
111 G4double kinEnergyStart = aTrack.GetKineticEnergy();
112 G4double kinEnergyLoss = kinEnergyStart;
113 const G4Material* aMaterial = aTrack.GetMaterial();
114 const G4ParticleDefinition* aParticleDef = aTrack.GetDynamicParticle()->GetDefinition();
115 G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
116 if (g4edata->GetMode() == G4ErrorMode(G4ErrorMode_PropBackwards)) {
117 kinEnergyLoss = - kinEnergyStart +
119 }
else if (g4edata->GetMode() == G4ErrorMode(G4ErrorMode_PropForwards)) {
120 kinEnergyLoss = kinEnergyStart -
123 B2DEBUG(300,
"ExtEnergyLoss::GetContinuousStepLimit() currentMinimumStep " << currentMinimumStep
124 <<
" kinEnergyLoss " << kinEnergyLoss <<
" kinEnergyStart " << kinEnergyStart);
125 if (kinEnergyLoss / kinEnergyStart >
m_StepLimit) {
126 step =
m_StepLimit / (kinEnergyLoss / kinEnergyStart) * currentMinimumStep;
127 B2DEBUG(300,
"ExtEnergyLoss::GetContinuousStepLimit() limiting Step " << step
128 <<
" energy loss fraction " << kinEnergyLoss / kinEnergyStart <<
" > " <<
m_StepLimit);
G4double GetContinuousStepLimit(const G4Track &, G4double, G4double, G4double &)
Gets step limit for the particle being swum.
EnergyLossForExtrapolator * m_energyLossForExtrapolator
Pointer to the geant4e-specific energy-loss and mult-scat class.
G4double m_StepLimit
Step limit for this process (fraction of KE that could be lost in one step)
G4VParticleChange * AlongStepDoIt(const G4Track &, const G4Step &)
Apply energy loss process along the step.
virtual ~ExtEnergyLoss()
destructor
ExtEnergyLoss(const G4String &processName="ExtEnergyLoss", G4ProcessType aType=fElectromagnetic)
constructor
Abstract base class for different kinds of events.