Angular distro problem

Dear experts,
I’m trying to make the angular distro for secondary gammas emitted in protontherapy.
I use this piece of code in the UserSteppingAction to do it:

G4ThreeVector direction = step->GetTrack()->GetMomentumDirection();
G4double theta = acos(direction.getX());
if (PDG == 22){ h_gamma_angle_xz->Fill(theta, 1.); }

The problem is that isn’t the result as should be. Any of you have some idea of what could be happening.
Thanks in advance.

Best, Dayron

Dear Dyron,

my impression is that you would like to retrieve the angular distribution of secondary photons, when originated by a proton beam field. If I understand correctly the proton beam is along X direction. One problem I see (if this is the only code you use) is that for each step of the generated gamma, you will retrieve theta. Is this what you want? if, instead, you would like to retrieve it once for each photon, you may retrieve this information only for the first step only of the photon.

Cheers

1 Like

Thanks so much for your help!!
I followed your advice and now works
I’m taking the information but using the PostUserTrackingAction

Best, D