File indexing completed on 2024-04-06 12:04:14
0001
0002
0003 #include "DataFormats/GeometrySurface/interface/SimpleDiskBounds.h"
0004 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0005 #include <algorithm>
0006 #include <cmath>
0007
0008 SimpleDiskBounds::SimpleDiskBounds(float rmin, float rmax, float zmin, float zmax)
0009 : theRmin(rmin), theRmax(rmax), theZmin(zmin), theZmax(zmax) {
0010 if (theRmin > theRmax)
0011 std::swap(theRmin, theRmax);
0012 if (theZmin > theZmax)
0013 std::swap(theZmin, theZmax);
0014 }
0015
0016 bool SimpleDiskBounds::inside(const Local2DPoint& p, const LocalError& err) const { return Bounds::inside(p, err); }
0017
0018 Bounds* SimpleDiskBounds::clone() const { return new SimpleDiskBounds(*this); }
0019
0020 bool SimpleDiskBounds::inside(const Local3DPoint& p, const LocalError& err, float scale) const {
0021 if (p.z() < theZmin || p.z() > theZmax)
0022 return false;
0023
0024 double perp2 = p.perp2();
0025 double perp = sqrt(perp2);
0026 if (perp2 == 0)
0027 return scale * scale * (err.xx() + err.xy()) > theRmin * theRmin;
0028
0029
0030
0031
0032 float deltaR = scale * sqrt(p.x() * p.x() / perp2 * err.xx() - 2 * p.x() * p.y() / perp2 * err.xy() +
0033 p.y() * p.y() / perp2 * err.yy());
0034 return perp > std::max(theRmin - deltaR, 0.f) && perp < theRmax + deltaR;
0035 }