Energy deposit by only gamma photons

Hi all,

I have a simulation comprising two Hpge detectors placed opposite to each other.
Source: Th-232 (I am interested in simulating the full chain)
I want to find only the energy deposited in them only due to the gamma photons.

My try to this is to modify exampleB1 stepping.cc class,

const G4DynamicParticle* theParticle = track->GetDynamicParticle();
const G4ParticleDefinition* particleDef = theParticle->GetParticleDefinition();
G4String name = particleDef->GetParticleName()
if((volume == fScoringVolume) & name == "Gamma"){
   G4double edepStep = step -> GetTotalEnergyDeposit()
   fEventAction->AddEdep(edepStep);

Is this the right way to go about it or are there better approaches to score energy deposited by a specific particle in a sensitive volume?

Thanks a lot !

You could use a sensitive detector (SD) attached to the volume. Then Geant4 will take care of the “if (volume)” automatically. You can also attach one of the built-in scorers to the volume via macro commands.

Hi,

You may want to check the examples provided by Geant4 toolkit, particularly the example B4c, which implements a Sensitive Detector.

Best,
Alvaro