Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:31

0001 #include "DataFormats/GeometrySurface/interface/DiskSectorBounds.h"
0002 
0003 using namespace std;
0004 
0005 bool DiskSectorBounds::inside(const Local3DPoint& p) const {
0006   // transform to system with local frame situated at disk center
0007   // and rotated  x/y axis
0008   Local3DPoint tmp(p.y() + theOffset, -p.x(), p.z());
0009 
0010   return ((tmp.z() >= theZmin) & (tmp.z() <= theZmax) & (tmp.perp2() >= theRmin * theRmin) &
0011           (tmp.perp2() <= theRmax * theRmax)) &&
0012          (std::abs(tmp.barePhi()) <= thePhiExtH);
0013 }
0014 
0015 bool DiskSectorBounds::inside(const Local3DPoint& p, const LocalError& err, float scale) const {
0016   if ((p.z() < theZmin) | (p.z() > theZmax))
0017     return false;
0018 
0019   Local2DPoint tmp(p.x(), p.y() + theOffset);
0020   auto perp2 = tmp.mag2();
0021   auto perp = std::sqrt(perp2);
0022 
0023   // this is not really correct, should consider also the angle of the error ellipse
0024   if (perp2 == 0)
0025     return scale * scale * err.yy() > theRmin * theRmin;
0026 
0027   LocalError tmpErr(err.xx(), err.xy(), err.yy());
0028   LocalError rotatedErr = tmpErr.rotate(tmp.x(), tmp.y());
0029   // x direction in this system is now r, phi is y
0030 
0031   float deltaR = scale * std::sqrt(rotatedErr.xx());
0032   float deltaPhi = std::atan(scale * std::sqrt(rotatedErr.yy() / perp2));
0033 
0034   float tmpPhi = std::acos(tmp.y() / perp);
0035 
0036   // the previous code (tmpPhi <= thePhiExt + deltaPhi) was wrong
0037   return ((perp >= std::max(theRmin - deltaR, 0.f)) & (perp <= theRmax + deltaR)) && (tmpPhi <= thePhiExtH + deltaPhi);
0038 }