Hi there, I am looking to get the coordinates of the first interaction for the particles I generate.
I am using the B1Example as template so I figured I would have to call a funtion in the B1StepingAction that returns the position of the particle as soon as it starts to interact (deposit energy) with the scoring volume. Is this asumption correct?? If so, does such function exis and is there an example that uses it??
Thank you in advance for your time.
The SteppingAction is called for every step of every particle. So what you can do is implement in the SteppingAction a test on the G4Step: look to see that the post-step point is in your volume, and that the pre-step point has a status of “fGeomBoundary”. That will tell you that this is the first step in the volume of interest.
Thank you for your answer @mkelsey. I have written this bit of code into my stepping action and it seems to work just fine.
// get the status of the pre step point
G4StepStatus PreStepStatus = step->GetPreStepPoint()->GetStepStatus();
// get the volume of the post step point
G4LogicalVolume* PostStepPoint = step->GetPostStepPoint()->GetTouchableHandle()
// Check if
if ((PreStepStatus == fGeomBoundary) && (PostStepPoint == fScoringVolume))
G4cout<< " Position " << step->GetPostStepPoint()->GetPosition().x() << G4endl;