Problem 2145

Summary: G4LogicalVolume null FieldManager propagation
Product: Geant4 Reporter: Jason Brodsky <brodsky3>
Component: geometry/managementAssignee: Gabriele Cosmo <Gabriele.Cosmo>
Status: RESOLVED FIXED    
Severity: minor    
Priority: P4    
Version: 10.5   
Hardware: All   
OS: All   

Description Jason Brodsky 2019-03-08 00:39:38 CET
https://github.com/Geant4/geant4/blame/master/source/geometry/management/src/G4LogicalVolume.cc#L307

At this line, when a daughter volume is added, the daughter recursively inherits the mother's FieldManager.

In a simulation with no FieldManager, every placement will recursively (re)set the FieldManager of every logical volume in the whole tree to 0. But, the FieldManager is 0 by default, and doesn't need to be set to 0 again.

This causes a slowdown during geometry setup when any mother has a large number of daughters. The work-per-daughter is small (setting a single pointer to 0, when it is already 0), but it can be done many times.

Line 307 should be changed to only propagate the FieldManager when the FieldManager is not 0. Alternatively, Line 265 could be changed to the same effect.
Comment 1 Gabriele Cosmo 2019-03-08 13:41:59 CET
Thanks for reporting this. A fix has now been introduced in the development branch and will be made available in the next patch release.