Message: Re: Reloading Geometry with Region Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

More Re: Reloading Geometry with Region 

Forum: Geometry
Re: Question Reloading Geometry with Region (Adrien MATTA)
Date: Jan 18, 01:21
From: Gabriele Cosmo <Gabriele Cosmo>

Hi Adrien,

in general, it is not advisable to clear all stores every time the geometry changes,
but rather remove/reload just the portion of the geometry affected. This because
you risk to skip some mandatory steps required and executed only at initialisation.
In this case, clearing of the physical-volume store would likely leave a dangling
pointer in the region-store for the world region, as this by default is not being
cleaned... you may need to set the new world volume explicitly, calling
G4RegionStore::SetWorldVolume(), while putting in place the new setup.


On Thu, 17 Jan 2019 07:46:47 GMT, Adrien MATTA wrote:
> Hello everyone,
> I am developing a geant4 based application (
> ). I have implemented a mechanism
> in which the user can reload the geometry between two runs, and it
> worked well until I started using G4Region (not sure if this is linked,
> but the region are associated to G4FastSimulationModel).
> I have a Clear Geometry Method that Open the geometry and Clean the
> various Store:
> void DetectorConstruction::ClearGeometry(){
>  G4GeometryManager::GetInstance()->OpenGeometry(); 
>  G4PhysicalVolumeStore::GetInstance()->Clean(); 
>  G4LogicalVolumeStore::GetInstance()->Clean();
>  G4SolidStore::GetInstance()->Clean(); 
> }
> and a RedefineGeometry Method doing:
> void DetectorConstruction::RedefineGeometry(std::string file){ 
>  ClearGeometry();
>  G4RunManager::GetRunManager()->DefineWorldVolume(Construct(file));
>  G4RunManager::GetRunManager()->GeometryHasBeenModified();   
>  G4RunManager::GetRunManager()->PhysicsHasBeenModified() ; 
>  G4RunManager::GetRunManager()->Initialize();  
> }
> The Construct method is reading an ASCII file describing the setup and
> instantiating a new world volume and putting all the detector/target
> inside.
> This methods worked flawlessly until I introduce a G4Region associated
> with the Target in which I call a G4FastSimulationModel to simulate a
> two-body reaction.
> Now I can reload the geometry and see it in my GUI, but if try to
> simulate an event I got a G4 Exception telling me: "Default world region
> should have a unique logical volume".
> I tried several things, like calling
> G4RegionStore::GetInstance()->Clean() in the clear geometry method, but
> that did not change much. I also tried to get the
> DefaultRegionForTheWorld and remove it root logical volume, but the
> exception keep showing up.
> I guess there is a simple but critical step I am missing to properly
> remove the previous world volume associated with the default world
> region. Any help would be welcome.
> Cheers, Adrien.

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Idea: Re: Reloading Geometry with Region   (Adrien MATTA - Feb 01, 08:27)
 Add Message Add Message
to: "Re: Reloading Geometry with Region"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]