Problem 2472

Summary: Inconsistent G4 behavior with USolids -- surface point randomization
Product: Geant4 Reporter: Stefan Zatschler <stefan.zatschler>
Component: geometry/solidsAssignee: Gabriele Cosmo <Gabriele.Cosmo>
Status: RESOLVED INVALID    
Severity: major CC: birgit.zatschler, stefan.zatschler
Priority: P4    
Version: 10.7   
Hardware: All   
OS: All   
Attachments: Example to reproduce the points on surface randomization issues

Description Stefan Zatschler 2022-03-03 17:32:08 CET
Created attachment 752 [details]
Example to reproduce the points on surface randomization issues

We found that the behavior of Geant4 changes depending on whether the USolids/VecGeom option is enabled or not. In particular, generating surface points via calling GetPointOnSurfaces() for G4Tubs solids is affected by this. The following two issues have been seen:

1) VecGeom provides its own implementation of SamplePointOnSurface(), which Geant4 calls into from GetPointOnSurface() when USolids is enabled. It turns out that the VecGeom version of G4Tubs chooses points by using r = random(rmin, rmax). This produces a flat distribution in r and not in the area which goes as r². As a consequence the density of random surface points is larger for small radii which causes a bias towards the center of a cylinder's face. In Geant4's definition of G4Tubs this issue has been resolved long ago (version G4-9.6). We confirmed the difference for both G4-10.06.p03 and G4-10.07.p03 with and without USolids. The attachments contains plots showing the difference for G4-10.07.p03.

2) VecGeom does not use the CLHEP random engine, but instead calls the standard C++ rand() function. This is done without doing any seed initialization, so every job will get exactly the same sequence of random points from VecGeom calls. This also means that the Geant4 interface for initializing the engine or getting the engine state does not affect VecGeom at all. There are alternative random engines in VecGeom (e.g. by making use of CUDA), but the overriding of Geant4's default random engine remains the same.

Attached is a simple example demonstrating the call of GetPointOnSurface() to create N random points on the surface of a G4Tubs solid. The example was used to create the plots of 10k surface points in the attachment.

We are concerned that these issues, combined with the fact that the main LCG installation of Geant4 make use of the "experimental" USolids feature, could be affecting a broader community of Geant4 users.
Comment 1 Gabriele Cosmo 2022-03-03 17:34:39 CET
Please. submit the ticket directly in the VecGeom JIRA system. Thanks.
http://sft.its.cern.ch/jira/projects/VECGEOM
Comment 2 Stefan Zatschler 2022-03-03 18:26:54 CET
A bug report has been issued: https://sft.its.cern.ch/jira/browse/VECGEOM-597