Problem 2362

Summary: G4Polyhedra Cubic volume returns zero for large volumes
Product: Geant4 Reporter: John Apostolakis <John.Apostolakis>
Component: geometry/solidsAssignee: Evgueni.Tcherniaev
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 10.7   
Hardware: All   
OS: All   

Description John Apostolakis 2021-04-19 10:38:13 CEST
A number of polyhedra volumes get zero answers from GetCubicVolume, where one would expect a large value.

The polyhedra were read in from a GDML file.  Here are some examples:

<polyhedra aunit="deg" deltaphi="360" lunit="mm" name="HE-2015" numsides="18" startphi="-10">
      <zplane rmax="1884.78096473568" rmin="1712.1025151065" z="3895.58332167509"/>
      <zplane rmax="2000.23386421665" rmin="1750.10555600822" z="3982.58332167509"/>
      <zplane rmax="2000.23386421665" rmin="399.901864137493" z="3982.58332167509"/>
      <zplane rmax="2639" rmin="447.946463235772" z="4463.92813036315"/>
      <zplane rmax="2639" rmin="518.330308365406" z="5169.08332167509"/>
      <zplane rmax="2459" rmin="518.330308365406" z="5169.08332167509"/>
      <zplane rmax="2459" rmin="553.065326141482" z="5517.08332167509"/>
      <zplane rmax="2459" rmin="553.065326141482" z="5541"/>
</polyhedra>

A second is

<polyhedra aunit="deg" deltaphi="360" lunit="mm" name="HBHalf" numsides="18" startphi="-10">
      <zplane rmax="2876.5" rmin="1775" z="0"/>
      <zplane rmax="2876.5" rmin="1775" z="3082.38960788158"/>
      <zplane rmax="2876.5" rmin="1927.5" z="3347.59523616437"/>
      <zplane rmax="2876.5" rmin="1927.5" z="3637.30401099388"/>
      <zplane rmax="2876.5" rmin="2027.2" z="3825.60477036838"/>
      <zplane rmax="2876.5" rmin="2281.19004836548" z="4017"/>
      <zplane rmax="2754.5" rmin="2281.19004836548" z="4017"/>
      <zplane rmax="2754.5" rmin="2699.20916717591" z="4332"/>
    </polyhedra>

and a third

    <polyhedra aunit="deg" deltaphi="360" lunit="mm" name="HB" numsides="18" startphi="-10">
      <zplane rmax="2754.5" rmin="2699.20916717591" z="-4332"/>
      <zplane rmax="2754.5" rmin="2281.19004836548" z="-4017"/>
      <zplane rmax="2876.5" rmin="2281.19004836548" z="-4017"/>
      <zplane rmax="2876.5" rmin="2027.2" z="-3825.60477036838"/>
      <zplane rmax="2876.5" rmin="1927.5" z="-3637.30401099388"/>
      <zplane rmax="2876.5" rmin="1927.5" z="-3347.59523616437"/>
      <zplane rmax="2876.5" rmin="1775" z="-3082.38960788158"/>
      <zplane rmax="2876.5" rmin="1775" z="0"/>
      <zplane rmax="2876.5" rmin="1775" z="3082.38960788158"/>
      <zplane rmax="2876.5" rmin="1927.5" z="3347.59523616437"/>
      <zplane rmax="2876.5" rmin="1927.5" z="3637.30401099388"/>
      <zplane rmax="2876.5" rmin="2027.2" z="3825.60477036838"/>
      <zplane rmax="2876.5" rmin="2281.19004836548" z="4017"/>
      <zplane rmax="2754.5" rmin="2281.19004836548" z="4017"/>
      <zplane rmax="2754.5" rmin="2699.20916717591" z="4332"/>
    </polyhedra>

For reference, calling the Capacity method for the same solids in VecGeom gives finite answers:

ERROR> Capacities of Geant4 solid and VecGeom solid DIFFER  for volumes:
   HB      of type G4Polyhedra :  G4 gives 0 VG gives 129157605855 
   HBHalf  of type G4Polyhedra :  G4 gives 0 VG gives  64578802927.7
   HE-2015 of type G4Polyhedra :  G4 gives 0 VG gives  30072688562.7
Comment 1 Evgueni.Tcherniaev 2021-04-19 17:56:17 CEST
Incorrect value returned by the GetCubibVolume() method caused by a bug in the calculation of the startPhi & endPhi class members at the construction time in case of negative input parameter phiStart. All those polyhedra start at negative phi and have deltaphi=360 degrees.