G4Navigator Question

I have a G4Polycone solid named container_001 (made of copper) which cannot be written in a single equation. Enclosed within the container_001, there is a volume detector (made of liquid argon).
There is another volume detector made of liquid argon which is not enclosed in container_001 (yes they have the same name)

I want to generate optical photons and gamma rays in the detector volume only if it is enclosed in the container_001 volume.

here is a code snippet I wrote to check if the point generated is inside detector

bool isit = false;
G4ThreeVector myPoint = rpos;
G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
G4VPhysicalVolume* myVolume = theNavigator->LocateGlobalPointAndSetup(myPoint);
if(myVolume->GetName() == “detector”) isit = true;
cout << “The name of the volume is " << myVolume->GetName() << " at the position” << rpos << endl;
return isit;

Now since there are two volumes with the same name, I am unable to generate photons and gammas only in the volume enclosed in the container_001. Is there an alternate way to generate photons/gammas in the detector enclosed by container_001?

When you say, “filled with Liquid Argon”, what do you mean? Do you mean that you set the material for your foo volume? Or did you create a daughter volume which you gave the same name as some other volume?

The Navigator, by design, always gives you the final leaf volume at a location, since that is what’s relevant for tracking and interactions. If you want to see the parents of that leaf volume, you can do so using the G4Touchable which the Navigator returns.

I meant, I have a volume foo inside which is another volume of Liquid Argon and outside foo, it’s liquid argon too. I want to generate some photons and gammas in liquid argon which is inside foo

What you’ve just written is ambiguous, and not consistent with the code fragment you showed originally. Did you name both of those volumes “Liquid Argon” (which is a very confusing thing to do, an you should change it), or are you telling us what material you assigned to your volumes?

Your code fragment suggests that “Liquid Argon” is the name you assigned to your volume (or to multiple volumes?). You will find your output much easier to understand if you give each volume a unique name, and perhaps one which describes the volume’s purpose, rather than the material it’s made of.

apologies for being ambiguous. I edited my original post to make it a little more clear.

Nope. Since you’re matching by name, you need to use unique names. Why not “Inner_detector” and “Outer_detector” or something similar?

When you say “generate”, are you doing this in your PrimaryGeneratorAction? Or are you asking about turning processes on or off, or killing secondaries which were produced in that volume?

For a PrimaryGeneratorAction, you could get the volume touchable one time (or at least, during run setup), use the touchable to get global/local coordinate transforms, and use G4VSolid::Inside() in an accept/reject loop to create primaries only within the desired volume. This might even be something you could do using GPS with macro commands.