Problem 1703

Summary: Major tracking error in G4ExtrudedSolid
Product: Geant4 Reporter: Tom Roberts <tjrob>
Component: geometry/solidsAssignee: tatiana.nikitina
Status: RESOLVED FIXED    
Severity: major CC: tjrob
Priority: P5    
Version: 10.1   
Hardware: All   
OS: All   
Attachments: tarball containing a screenshot, two modified source files from exampleB1, plus extrusion.mac to run it.

Description Tom Roberts 2014-12-17 21:03:41 CET
Created attachment 302 [details]
tarball containing a screenshot, two modified source files from exampleB1, plus extrusion.mac to run it.

Suddenly one of my regression tests is failing. It uses a
G4ExtrudedSolid combined with a UserSteppingAction that kills any track
that enters the physical volume of the solid. The error is that SOME of
the tracks that enter the physical volume are not killed, causing my
regression test to fail.

Attached is a screen shot of the Open Inventor viewer, looking from
downstream of the extrusion toward the rectangular source of the blue
beam tracks (the viewer is tilted slightly so the tracks are visible).
All beam tracks are parallel to Z. The extrusion is red, and the tracks
that hit its triangle in the upper left are not killed, but those in the
rest of the extrusion are killed properly (hence not visible). Tracks
that miss the extrusion are visible.

The root cause is that some tracks that physically intersect the G4Extrusion never enter the physical volume but go right through where it is, remaining in the World volume -- a clear navigation error. 

This fails in Geant4 version Name: geant4-10-00-patch-02 (13-June-2014)
This fails in Geant4 version Name: geant4-10-01    (5-December-2014)
This SUCCEEDS in Geant4 version Name: geant4-09-06-patch-02 (17-May-2013)
This is Mac OS X 10.9.5 (Mavericks) (that is unlikely to be important).

Curiously, using the file G4ExtrudedSolid.cc from 9.6.p02, with everything else from 10.1, it still fails. So this is likely to be subtle.

The above is all with G4beamline, which you do not want to debug. So I have attached modifications to exampleB1 that reproduce my regression test (just run extrusion.mac after building, then examine the stepping verbose for each beam track to see which volumes it traversed). The beam track launched from (100,300,0) should hit the extrusion, but doesn't. It is the only track in the triangle portion of the extrusion; tracks in the rectangular portions of the extrusion, and tracks that miss it entirely, are OK.

Defining REVERSE in B1DetectorConstruction.cc does not affect the result (it reverses the order of the vertices).
Comment 1 tatiana.nikitina 2014-12-18 16:17:44 CET
Dear Tom,

Thank you for the example, it was very easy to reproduce the problem.

There was a change in DistanceToInCandidates() in G4TessellatedSolid, this change caused reported problem.
I'm working on the fix.

Best Regards,
Tatiana
Comment 2 tatiana.nikitina 2015-01-12 09:57:48 CET
Dear Tom,

Thank you again for reporting the problem.
Fix is ready, it will be in the next Geant4 release.
Do you need a source file with fix? For which version of Geant4?

Best Regards,
Tatiana.
Comment 3 tatiana.nikitina 2015-01-21 11:21:52 CET
Dear Tom,

Error was in the triangularisation algorithm of G4ExtrudedSolid, flat triangles were constructed, then the G4TriangularFacet was reporting wrong values, last changes in G4TessellatedSolid triggered this out.

Fix in G4ExtrudedSolid is provided. Warning for flat triangels(Area==0) is added to G4TriangularFacet.

Thank you for your help,
Tatiana
Comment 4 Tom Roberts 2015-01-21 18:23:06 CET
My rather simple tests confirm this is fixed.