@lvll98 I presume you’re asking about the target “atom type”, not position? Unfortunately, I don’t believe that’s available in a generic way. If the interaction was hadronic, then G4Isotope* G4HadronicProcess::GetTargetIsotope()
or G4Nucleus* G4HadronicProcess::GetTargetNucleus()
can get you this information.
Use code along the lines of (note the null pointer checks at each step)
G4StepPoint* post = theStep->GetPostStepPoint();
const G4VProcess* proc = (post ? post->GetProcessDefinedStep() : 0);
const G4HadronicProcess* had = dynamic_cast<G4HadronicProcess*>(proc);
G4Isotope* target = (had ? had->GetTargetIsotope() : 0);
if (target) {
G4cout << theStep->GetTrack()->GetParticleDefinition()->GetParticleName()
<< " interacted with " << target->GetName() << G4endl;
}