From 1ad72e1561ea8fc0cc2445b6f6ba13538d1f3843 Mon Sep 17 00:00:00 2001 From: Andrei Gheata Date: Tue, 12 Apr 2016 15:43:01 +0200 Subject: [PATCH] Fix for cone safety when point is on the wrong side. --- geom/geom/src/TGeoCone.cxx | 4 +++- geom/geom/src/TGeoShape.cxx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/geom/geom/src/TGeoCone.cxx b/geom/geom/src/TGeoCone.cxx index 2d37de6e3c14d..aa3b877c04844 100644 --- a/geom/geom/src/TGeoCone.cxx +++ b/geom/geom/src/TGeoCone.cxx @@ -873,7 +873,9 @@ Double_t TGeoCone::Safety(const Double_t *point, Bool_t in) const saf[1] = TGeoShape::SafetySeg(r,point[2], fRmax2, fDz, fRmin2, fDz, !in); saf[2] = TGeoShape::SafetySeg(r,point[2], fRmin2, fDz, fRmin1, -fDz, !in); saf[3] = TGeoShape::SafetySeg(r,point[2], fRmax1, -fDz, fRmax2, fDz, !in); - return saf[TMath::LocMin(4,saf)]; + Double_t safety = saf[TMath::LocMin(4,saf)]; + if (safety>1.E20) safety = 0.; + return safety; } //////////////////////////////////////////////////////////////////////////////// diff --git a/geom/geom/src/TGeoShape.cxx b/geom/geom/src/TGeoShape.cxx index b742f0a55233d..228112f776059 100644 --- a/geom/geom/src/TGeoShape.cxx +++ b/geom/geom/src/TGeoShape.cxx @@ -498,7 +498,7 @@ Double_t TGeoShape::SafetySeg(Double_t r, Double_t z, Double_t r1, Double_t z1, Double_t crossp = (z2-z1)*(r-r1)-(z-z1)*(r2-r1); crossp *= (outer) ? 1. : -1.; // Positive crossp means point on the requested side of the (1,2) segment - if (crossp < 0) { + if (crossp < -TGeoShape::Tolerance()) { // if (((z-z1)*(z2-z)) > -1.E-10) return 0; if (outer) return TGeoShape::Big(); else return 0.;