I have been trying for some time to build a dynamic geometry setup, i.e. changing parts of the geometry in between runs, such as the size of a volume.
I mostly followed the logic of example B5, which changes the angle of a detector with a messenger command.
However I have noticed that in my tests the geometry is not correctly updated even though I’m flagging the geometry modification with GeometryHasBeenModified().
void DetectorConstruction::SetFoilThickness(G4double thickness) {
G4ThreeVector transVec(0., 0., (thickness - foilDZ));
logicFoil->SetSolid(new G4Box("Foil", foilDX / 2, foilDY / 2, thickness / 2));
physFoil->SetTranslation(physFoil->GetObjectTranslation() + transVec / 2);
physEntranceAu->SetTranslation(physEntranceAu->GetObjectTranslation() + transVec);
physH2->SetTranslation(physH2->GetObjectTranslation() + transVec);
physDownAu->SetTranslation(physDownAu->GetObjectTranslation() + transVec);
// G4cout << "Foil Z : " << GetFoilZ() << G4endl;
// G4cout << "EntranceAu Z : " << GetEntranceAuZ() << G4endl;
// G4cout << "H2 Z : " << GetH2Z() << G4endl;
// G4cout << "DownAu Z : " << GetDownAuZ() << G4endl;
physFoil->CheckOverlaps();
physEntranceAu->CheckOverlaps();
physH2->CheckOverlaps();
physDownAu->CheckOverlaps();
foilDZ = thickness;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
By uncommenting the prints I can see that things have been updated.
But when running in MT mode, by looking at my hits I am sure that those changes where not really applied in the run, i.e. the results are unchanged. In Serial mode it works fine.
I’ve seen here that apparently dynamic geometry setups are not allowed in MT mode. But I’m confused by this because example B5 has a dynamic geometry and it is prepared for MT according to the README.
Am I missing something here?
Geant4 Version: 11.03
Operating System: Fedora 41
Compiler/Version: g++ 14.3.1
CMake Version: 3.30.8