Issue using /gps/pos/confine with gdml geometry

Dear Geant4 experts,

I have a gdml geometry I have generated writting the “world” into a file via the GdmlParser. The geometry does not present any validation errors.
geometry.gdml.txt (21.9 KB)

I can print the names of all physical volumes inside the detector construction with this code:

void DetectorConstruction::PrintGeometryInfo() {
    spdlog::info("DetectorConstruction::PrintGeometryInfo - Begin");
    const int n = fWorld->GetLogicalVolume()->GetNoDaughters();
    for (int i = 0; i < n; i++) {
        G4VPhysicalVolume* volume = fWorld->GetLogicalVolume()->GetDaughter(i);
        auto name = volume->GetName();
        spdlog::info("---> {} {}", i, name);
    }
    spdlog::info("DetectorConstruction::PrintGeometryInfo - End");
}

// Output

[01:04:42][info][thread 30969]: DetectorConstruction::PrintGeometryInfo - Begin
[01:04:42][info][thread 30969]: ---> 0 Gas
[01:04:42][info][thread 30969]: ---> 1 ChamberBody
[01:04:42][info][thread 30969]: ---> 2 ChamberBackplate
[01:04:42][info][thread 30969]: ---> 3 ChamberTeflonWall
[01:04:42][info][thread 30969]: ---> 4 KaptonReadout
[01:04:42][info][thread 30969]: ---> 5 CopperReadout
[01:04:42][info][thread 30969]: ---> 6 CathodeTeflonDisk
[01:04:42][info][thread 30969]: ---> 7 CathodeWindow
[01:04:42][info][thread 30969]: ---> 8 CathodeCopperDiskFinal
[01:04:42][info][thread 30969]: ---> 9 CathodeFilling
[01:04:42][info][thread 30969]: ---> 10 Shielding
[01:04:42][info][thread 30969]: ---> 11 DetectorPipe
[01:04:42][info][thread 30969]: ---> 12 DetectorPipeFilling
[01:04:42][info][thread 30969]: DetectorConstruction::PrintGeometryInfo - End

These are (or so I think) the names of the physical volumes in the geometry.

I can’t, however, make use of the /gps/pos/confine command which takes a physical volume. It returns an error saying that the physical volume is not in the store.

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : GeomMgt1001
      issued by : G4PhysicalVolumeStore::GetVolume()
Volume NOT found in store !
        Volume Shielding NOT found in store !
        Returning NULL pointer.
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

I have also printed the physical volume names from the store just before the confine command is invoked, obtaining the following:

    cout << "DEBUGGING!" << endl;
    auto physicalVolumesMap = G4PhysicalVolumeStore::GetInstance()->GetMap();
    for (auto const& [name, physicalVolumes] : physicalVolumesMap) {
        if (physicalVolumes.size() == 1) {
            auto physicalVolume = physicalVolumes[0];
            const auto logicalName = physicalVolume->GetLogicalVolume()->GetName();
            spdlog::info("{} {}", name, physicalVolume->GetName());
        } else {
            exit(1);  // All are size 1
        }
        for (auto const& physicalVolume : physicalVolumes) {
            auto logicalName = physicalVolume->GetLogicalVolume()->GetName();
            spdlog::info("---> {}", logicalName);
        }
    }
    cout << "DEBUGGING END!" << endl;

// Output

DEBUGGING!
[01:16:00][info][thread 37315]: CathodeCopperDiskFinal0x56225192bc70_PV CathodeCopperDiskFinal
[01:16:00][info][thread 37315]: ---> CathodeCopperDiskFinal
[01:16:00][info][thread 37315]: CathodeFilling0x56225192c2a0_PV CathodeFilling
[01:16:00][info][thread 37315]: ---> CathodeFilling
[01:16:00][info][thread 37315]: CathodeTeflonDisk0x56225192a960_PV CathodeTeflonDisk
[01:16:00][info][thread 37315]: ---> CathodeTeflonDisk
[01:16:00][info][thread 37315]: CathodeWindow0x56225192ac90_PV CathodeWindow
[01:16:00][info][thread 37315]: ---> CathodeWindow
[01:16:00][info][thread 37315]: ChamberBackplate0x562251929880_PV ChamberBackplate
[01:16:00][info][thread 37315]: ---> ChamberBackplate
[01:16:00][info][thread 37315]: ChamberBody0x562251929590_PV ChamberBody
[01:16:00][info][thread 37315]: ---> ChamberBody
[01:16:00][info][thread 37315]: ChamberTeflonWall0x562251929c10_PV ChamberTeflonWall
[01:16:00][info][thread 37315]: ---> ChamberTeflonWall
[01:16:00][info][thread 37315]: CopperReadout0x56225192a100_PV CopperReadout
[01:16:00][info][thread 37315]: ---> CopperReadout
[01:16:00][info][thread 37315]: DetectorPipe0x562251930ea0_PV DetectorPipe
[01:16:00][info][thread 37315]: ---> DetectorPipe
[01:16:00][info][thread 37315]: DetectorPipeFilling0x562251930ff0_PV DetectorPipeFilling
[01:16:00][info][thread 37315]: ---> DetectorPipeFilling
[01:16:00][info][thread 37315]: Gas0x56225192ca60_PV Gas
[01:16:00][info][thread 37315]: ---> Gas
[01:16:00][info][thread 37315]: KaptonReadout0x562251929e90_PV KaptonReadout
[01:16:00][info][thread 37315]: ---> KaptonReadout
[01:16:00][info][thread 37315]: Shielding0x56225192dc90_PV Shielding
[01:16:00][info][thread 37315]: ---> Shielding
[01:16:00][info][thread 37315]: World_PV World_PV
[01:16:00][info][thread 37315]: ---> World
DEBUGGING END!

After my debugging it looks like it should work with “Shielding”. I have used the /gps/confine in the past, so I know it works. Perhaps this is an issue with the GDML?

I also tried to set the confinent volume to /gps/pos/confine Shielding0x56225192dc90_PV and in this case it seems to recognize this volume, since it doesn’t give an error. However I get

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : G4GPS001
      issued by : G4SPSPosDistribution::GenerateOne()
LoopCount = 100000
Either the source distribution >> confinement
or any confining volume may not overlap with
the source distribution or any confining volumes
may not exist

If you have set confine then this will be ignored
for this event.


*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

Even though I know for certain some positions should fall under this volume.

I am using version 11.0.0.

Edit: I think this is a bug in the latest version since I found that this works in another install (10.7.0). I will do more checks before confirming this is a bug.

Thanks.

So far it looks like a bug to me.