File indexing completed on 2024-04-06 12:04:14
0001
0002
0003 #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
0004 #include "DataFormats/GeometrySurface/interface/LocalError.h"
0005 #include <cmath>
0006
0007 TrapezoidalPlaneBounds::TrapezoidalPlaneBounds(float be, float te, float a, float t)
0008 : hbotedge(be), htopedge(te), hapothem(a), hthickness(t) {
0009
0010
0011
0012 offset = a * (te + be) / (te - be);
0013 tan_a = te / std::abs(offset + a);
0014 }
0015
0016 int TrapezoidalPlaneBounds::yAxisOrientation() const { return (hbotedge > htopedge) ? -1 : 1; }
0017
0018 bool TrapezoidalPlaneBounds::inside(const Local2DPoint& p) const {
0019 return (std::abs(p.y()) < hapothem) && (std::abs(p.x()) < tan_a * std::abs(p.y() + offset));
0020 }
0021
0022 bool TrapezoidalPlaneBounds::inside(const Local3DPoint& p) const {
0023 return ((std::abs(p.y()) < hapothem) && (std::abs(p.z()) < hthickness)) &&
0024 std::abs(p.x()) < tan_a * std::abs(p.y() + offset);
0025 }
0026
0027 bool TrapezoidalPlaneBounds::inside(const Local3DPoint& p, const LocalError& err, float scale) const {
0028 if (scale >= 0 && inside(p))
0029 return true;
0030
0031 TrapezoidalPlaneBounds tmp(hbotedge + std::sqrt(err.xx()) * scale,
0032 htopedge + std::sqrt(err.xx()) * scale,
0033 hapothem + std::sqrt(err.yy()) * scale,
0034 hthickness);
0035 return tmp.inside(p);
0036 }
0037
0038 bool TrapezoidalPlaneBounds::inside(const Local2DPoint& p, const LocalError& err, float scale) const {
0039 return Bounds::inside(p, err, scale);
0040 }
0041
0042 float TrapezoidalPlaneBounds::significanceInside(const Local3DPoint& p, const LocalError& err) const {
0043 return std::max((std::abs(p.y()) - hapothem) / std::sqrt(err.yy()),
0044 (std::abs(p.x()) - tan_a * std::abs(p.y() + offset)) / std::sqrt(err.xx()));
0045 }
0046
0047 Bounds* TrapezoidalPlaneBounds::clone() const { return new TrapezoidalPlaneBounds(*this); }
0048
0049 const std::array<const float, 4> TrapezoidalPlaneBounds::parameters() const {
0050
0051 std::array<const float, 4> vec{{hbotedge, htopedge, hthickness, hapothem}};
0052 return vec;
0053 }