Back to home page

EIC code displayed by LXR

 
 

    


Warning, /eic-spack/spack_repo/eic/packages/geant4/G4TriangularFacet-tolerance.patch is written in an unsupported language. File is not indexed.

0001 Fix dimensionally inconsistent in-triangle tolerance in G4TriangularFacet.
0002 
0003 Backport of https://github.com/Geant4/geant4/pull/125, adapted to the
0004 code formatting used in tagged Geant4 releases (the upstream PR is based
0005 on the reformatted master branch and does not apply to releases as-is).
0006 
0007 --- a/source/geometry/solids/specific/src/G4TriangularFacet.cc
0008 +++ b/source/geometry/solids/specific/src/G4TriangularFacet.cc
0009 @@ -751,9 +751,16 @@
0010    G4double ss = fB*e - fC*d;
0011    G4double t = fB*d - fA*e;
0012  
0013 -  G4double sTolerance = (fabs(fB)+ fabs(fC) + fabs(d) + fabs(e))*kCarTolerance;
0014 -  G4double tTolerance = (fabs(fA)+ fabs(fB) + fabs(d) + fabs(e))*kCarTolerance;
0015 -  G4double detTolerance = (fabs(fA)+ fabs(fC) + 2*fabs(fB) )*kCarTolerance;
0016 +  // With pp - p0 = alpha*fE1 + beta*fE2 we have ss = alpha*fDet and
0017 +  // t = beta*fDet. The distance of pp from the edge opposite to each
0018 +  // barycentric is alpha*sqrt(fDet)/|fE2|, beta*sqrt(fDet)/|fE1| and
0019 +  // (alpha+beta-1)*sqrt(fDet)/|fE2-fE1|. Scale the tolerances so that they
0020 +  // correspond to kCarTolerance measured as a distance from the edge.
0021 +  //
0022 +  G4double sqrtDet = std::sqrt(fDet);
0023 +  G4double sTolerance = kCarTolerance * sqrtDet * fE2.mag();
0024 +  G4double tTolerance = kCarTolerance * sqrtDet * fE1.mag();
0025 +  G4double detTolerance = kCarTolerance * sqrtDet * (fE2 - fE1).mag();
0026  
0027    //if (ss < 0.0 || t < 0.0 || ss+t > fDet)
0028    if (ss < -sTolerance || t < -tTolerance || ( ss+t - fDet ) > detTolerance)