Get material from position

Hello!
Let us assume that I have built my detector in the class derived from G4VUserDetectorConstruction.
So far so good.

Then I would like to get which material is present at random point X,Y,Z. Does Geant4 provide a method to easily get this piece of information?
Notice that I want to know the material before any particle is generated.

Our Geant4 version is 10.6

Best regards
Giorgio

g4navigator is your keyword

1 Like

Can you elaborate a bit more? If you have an idea it would be nice!

EDIT: Sorry! my comment, was not related to the OP, but to weller’s answer, which I thought was an answer to my question.

Did you follow the link? What you’ve asked for is implemented exactly.

Maybe @cdreisbach would have liked the name of the method in G4Navigator implementing that specific feature. I would not mind either tbh

It’s not built into G4Navigator. You write code; you write exactly the code which was already spelled out in the linked post. Use the navigator to get the volume (placement) at the specified coordinates, and then you query the volume (exactly the same way you created the volume in your geometry, but in reverse order) to determine the material.

1 Like

@mkelsey Thank you for the clarification. If I understand that snippet correctly, it seems pretty straightforward. I hope it is so for @cdreisbach too.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.