Retrieve the position in global X,Y,Z coordinates of a hit sensitive volume

Hello all

I am looking for a way to retrieve the position in global X,Y,Z coordinates of a sensitive volume (the position that would be indicated in the 3D visualization) that has just been hit by a particle (and not the position of the particle itself).

One way to go could be to access to all the physical volumes tree translation vectors and rotations :
std::vector<G4ThreeVector> translation_list; // to store list of translations
std::vector<G4RotationMatrix*> rotation_list; // to store list of rotations

// depth of the volume tree
G4int nb_depth = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistoryDepth();

for (G4int i = 0; i < nb_depth; ++i) {
translation_list.push_back (aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetTranslation(i));
rotation_list.push_back (aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetRotation(i));
}

And then combine them to reconstruct the position of the physical volume in world’s X,Y,Z space. But I don’t know how to do this combination correctly.

If there is an easier approach, I am of course very interested.

Thanks in advance for the help.
-David

Quick answer - have a look at “Local -> Global position inside DetectorConstruction” posted about a month ago.

Thanks for the help.

I also found this relevant topic from the old forum: https://hypernews.slac.stanford.edu/HyperNews/geant4/get/geometry/106/1/1.html

The solution is to get the top transform and perform an inverse transform on a null point :
G4ThreeVector origin(0.,0.,0.);
G4ThreeVector globalOrigin = aStep->GetPreStepPoint()->GetTouchableHandle()->GetHistory()->
GetTopTransform().Inverse().TransformPoint(origin);

Best regards,
-David