File indexing completed on 2023-03-17 10:49:58
0001 #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
0002 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0003 #include <cmath>
0004
0005 RectangularPlaneBounds::RectangularPlaneBounds(float w, float h, float t)
0006 : halfWidth(w), halfLength(h), halfThickness(t) {}
0007
0008 RectangularPlaneBounds::~RectangularPlaneBounds() {}
0009
0010 bool RectangularPlaneBounds::inside(const Local3DPoint& p, const LocalError& err, float scale) const {
0011 if ((scale >= 0) && inside(p))
0012 return true;
0013 return std::abs(p.z()) < halfThickness && (std::abs(p.x()) < halfWidth + std::sqrt(err.xx()) * scale) &&
0014 (std::abs(p.y()) < halfLength + std::sqrt(err.yy()) * scale);
0015 }
0016
0017 bool RectangularPlaneBounds::inside(const Local2DPoint& p, const LocalError& err, float scale) const {
0018 if ((scale >= 0) && inside(p))
0019 return true;
0020 return (std::abs(p.x()) < halfWidth + std::sqrt(err.xx()) * scale) &&
0021 (std::abs(p.y()) < halfLength + std::sqrt(err.yy()) * scale);
0022 }
0023
0024 float RectangularPlaneBounds::significanceInside(const Local3DPoint& p, const LocalError& err) const {
0025 return std::max((std::abs(p.x()) - halfWidth) / std::sqrt(err.xx()),
0026 (std::abs(p.y()) - halfLength) / std::sqrt(err.yy()));
0027 }
0028
0029 std::pair<bool, bool> RectangularPlaneBounds::inout(const Local3DPoint& p, const LocalError& err, float scale) const {
0030 float xl = std::abs(p.x()) - std::sqrt(err.xx()) * scale;
0031 float xh = std::abs(p.x()) + std::sqrt(err.xx()) * scale;
0032 bool inx = xl < halfWidth;
0033 bool outx = xh > halfWidth;
0034
0035 float yl = std::abs(p.y()) - std::sqrt(err.yy()) * scale;
0036 float yh = std::abs(p.y()) + std::sqrt(err.yy()) * scale;
0037 bool iny = yl < halfLength;
0038 bool outy = yh > halfLength;
0039
0040 return std::pair<bool, bool>(inx && iny, outx || outy);
0041 }
0042
0043 Bounds* RectangularPlaneBounds::clone() const { return new RectangularPlaneBounds(*this); }