How to let nested volumes inherit the world region

Let’s say I have a simple geometry with three nested volumes world / Volume1 / Volume2. That is, Volume1 is a daughter of world and Volume2 is a daughter of Volume1. Now I want to assign a different region to Volume1 so I can change the production cuts in that region. BUT I want Volume2 to stay in the default world region (because e.g. I have G4UserLimits attached to that region.

As I understand, if I attach a new region to Volume1, Volume2 will inherit it. So I thought the following would do what I wanted:

G4Region* region1= G4RegionStore::GetInstance()->FindOrCreateRegion("region1");
l_volume1->SetRegion(region1);
region1->AddRootLogicalVolume(l_region1);
//set cuts, etc for region1

G4Region* defaultRegion = G4RegionStore::GetInstance()->GetRegion("DefaultRegionForTheWorld");
l_volume2->SetRegion(defaultRegion);
defaultRegion->AddRootLogicalVolume(l_volume2);

But that segfaults during the run (happens to be in G4UrbanMscModel::ComputeTruePathLengthLimit). I guess this is because the world region is special somehow?

Is this is a weird bug, or am I misunderstanding how regions are supposed to be applied? Is there a a a way to accomplish this, or achieve similar results?

Hi,

To better understand what the problem is, could you please try the following for me?

  1. Create a new region (say region2) and assign it to l_volume2.
  2. You don’t need to set cuts for region2. If a region does not have cuts specified, it inherits cuts from the world default region (not from the mother region1). But if you set user limits to default region, set the same limits to region2.

Does this work?

Thanks for your feedback!

This is what I ended up doing, but it’s far from ideal. In addition to the UserLimits, I also have to treat all regions if I change the EM physics list per region, atomic deexcitation, etc.

DefaultRegionForTheWorld is treated somewhat differently. You can use “region2” to all root logical volumes except the world.