| Summary: | Stuck track when rounding error near tolerances | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Jonas Hahnfeld <jonas.hahnfeld> |
| Component: | geometry/solids | Assignee: | Evgueni.Tcherniaev |
| Status: | RESOLVED INVALID | ||
| Severity: | minor | CC: | Gabriele.Cosmo, John.Apostolakis |
| Priority: | P4 | ||
| Version: | 10.7 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | reduced example for the original G4Tubs and a G4Box | ||
|
Description
Jonas Hahnfeld
2021-07-15 17:44:10 CEST
Hi Jonas, I've checked that if to pass the same points to DistanceToIn() and DistanceToOut() the the methods correctly return different values: From cms2018.gdml: DistanceToOut: 0 DistanceToIn: 0 DistanceToOut(pDistanceToOut) : 0 DistanceToIn (pDistanceToOut): 9e+99 DistanceToOut(pDistanceToIn) : 6.80713e-10 DistanceToIn (pDistanceToIn): 0 box DistanceToOut: 0 DistanceToIn: 0 DistanceToOut(pDistanceToOut) : 0 DistanceToIn (pDistanceToOut): 9e+99 DistanceToOut(pDistanceToIn) : 6.80713e-10 DistanceToIn (pDistanceToIn): 0 So, there is nothing to fix in the code of G4Tubs/G4Box. The bug is in passing "slightly different points to DistanceToOut and DistanceToIn". Evgueni > So, there is nothing to fix in the code of G4Tubs/G4Box. The bug is in passing "slightly different points to DistanceToOut and DistanceToIn".
Ideally yes, but with floating point arithmetic you can easily get rounding errors at some point when applying the transformations. That's exactly what is happening here, the global point is the same for the two code paths leading to DistanceToOut / DistanceToIn:
in TECPetalCont8F
-> transform global point local point in TECPetalCont8F
-> when sampling DistanceToIn for TECICBCont8F2: transform local point in TECPetalCont8F to local point in TECICBCont8F2
-> DistanceToIn returns 0, so move into the daughter volume
in TECICBCont8F2
-> transform global point to local point in TECICBCont8F2 (directly)
-> DistanceToOut returns 0, so leave the volume again
It is a problem of the code that transforms the same point to the same local space by two different paths, but expects the same return values from DistanceToIn/Out. In reality it is two different points, which are located differently relative to the solids: pDistanceToOut is on Surface, pDistanceToIn is Inside. The solids work correctly for both of the points, the problem should be fixed in the navigation code. |