How to get track starting point


I made detector and I need to get coordinates where secondary track start. I want to know how can I bring coordinates for separate each components.

Below is code I tried.

if(aTrack->GetTrackID() != 1)


if(aTrack->GetCreatorProcess()->GetProcessName() != “proptonInelastic”)


G4double positionZ = step->GetPreStepPoint()->GetPosition().z();

G4double r = positionZ;


If you want proton inelastic process, you should make sure the correct process’s name.
proptonInelastic => protonInelastic


Thank you.

I correct process name proptonInelastic -> protonInelastic and I get result.

However, still some problem is remain. I measure how many time the process occur two method. One is using my code(already fixed) and another is count manually. but in detector, result from two method is different. result from code is have more event than second method.

I found cause of problem and solve it.

It bring next step starting point not interaction point.
I change my code
G4double positionZ = step->GetPreStepPoint()->GetPosition().z();
G4double pz = aTrack->GetVertexPosition().z();

then it bring interaction point.

1 Like