Record deposited energy in a process class

Hi all,

for specific reasons I’m trying to score the deposited energy in a volume using a WrapperProcess class I have registered to all of the processes in my physics list.
I’m doing this using :

if(step->GetPostStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion() == sensitiveAirRegion)
G4double total = step->GetTotalEnergyDeposit();
G4double dose = total*step->GetPreStepPoint()->GetWeight();
pSteppingAction->SetEnergyVar(pSteppingAction->GetEnergyVar()+dose);

Then I sum up the GetEnergyVar in Run.
To compare this with a similar implementation that’s already part of Geant I’m using a G4MultiFunctionalDetector, also scoring the energy.

But if I compare the numbers of G4MultiFunctionalDetector and my own scoring algorithm in Run I can see that they differ. Less energy is scored in my process class than in the G4MultiFunctionalDetector map.

This can also be seen accessing the energy deposit from SteppingAction. For some processes, the step in Sepping Action has a value for the energy deposit, but if I access the step via the Wraping Process, there’s no energy at all.

As I’m quite new to Geant4, can anybody see some general misconception?

Best wishes,
Stefan

Hi,

Why use step->GetPostStepPoint() instead of
step->GetPreStepPoint() ?

I also can assume that if you have air, you have small amount of interactions. Maybe it is normal that you have low energy deposit.
So my propositions to track the problem.

  1. Try step->GetPreStepPoint()… I am not expert, but it looks more accurate
  2. What particle do you use? Try electrons (or any charged)
  3. Change material from air to Tungsten or Copper, to check if it is an issue of air or energy deposit count algorithm

P.S. I would use Sensitive Detector. It automatically loops only through steps inside your sensitive volume therefore you will not need this huge if(…) construction and code looks more simple.

best regards,
fox

Hi again,

thanks you are right, it should be the PreStepPoint!

The interactions are happening and there is an energy deposition. The problem is, if I acess step->GetTotalEnergyDeposition() in my UserSteppingAction it gives me correct values for the deposited energy. But if I do the very same thing in my G4WrapperProcess some times it won’t see any energy deposition, eg:

Event ID 1333
PROCESS IN SENSITIVE AIR REGION
MollerBhabha
process energy: 0
PROCESS IN SENSITIVE AIR REGION
MollerBhabha
process energy: 1.7952435519383e-06
step energy: 1.7952435519383e-06
PROCESS IN SENSITIVE AIR REGION
GoudsmitSaunderson
process energy: 0
PROCESS IN SENSITIVE AIR REGION
MollerBhabha
process energy: 0
step energy: 2.5556146683299e-06
PROCESS IN SENSITIVE AIR REGION
GoudsmitSaunderson
process energy: 0
PROCESS IN SENSITIVE AIR REGION
MollerBhabha
process energy: 0
step energy: 1.3641764230699e-07

Best wishes,
Stefan

Edit: I just found the problem. In the WrapperProcess the energy should not be taken from the step, as it seems the step is not updated allready at this point. So the solution ist to acess the energy via; particleChange->GetLocalEnergyDeposit().