CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DiskSectorBounds.cc
Go to the documentation of this file.
1 #include "DiskSectorBounds.h"
2 
3 using namespace std;
4 
5 bool DiskSectorBounds::inside( const Local3DPoint& p) const {
6 
7  // transform to system with local frame situated at disk center
8  // and rotated x/y axis
9  Local3DPoint tmp( p.y()+theOffset, -p.x(), p.z());
10 
11  return
12  ( (tmp.z() >= theZmin) & (tmp.z() <= theZmax) &
13  (tmp.perp2() >= theRmin*theRmin) & (tmp.perp2() <= theRmax*theRmax)
14  ) &&
15  (std::abs(tmp.barePhi()) <= thePhiExtH);
16 }
17 
18 bool DiskSectorBounds::inside( const Local3DPoint& p, const LocalError& err, float scale) const {
19 
20  if ( (p.z() < theZmin) | (p.z() > theZmax)) return false;
21 
22  Local2DPoint tmp( p.x(), p.y()+ theOffset);
23  auto perp2 = tmp.mag2();
24  auto perp = std::sqrt(perp2);
25 
26  // this is not really correct, should consider also the angle of the error ellipse
27  if (perp2 == 0) return scale*scale*err.yy() > theRmin*theRmin;
28 
29  LocalError tmpErr( err.xx(), err.xy(), err.yy());
30  LocalError rotatedErr = tmpErr.rotate(tmp.x(), tmp.y());
31  // x direction in this system is now r, phi is y
32 
33  float deltaR = scale*std::sqrt(rotatedErr.xx());
34  float deltaPhi = std::atan( scale*std::sqrt(rotatedErr.yy()/perp2));
35 
36  float tmpPhi = std::acos( tmp.y() / perp);
37 
38  // the previous code (tmpPhi <= thePhiExt + deltaPhi) was wrong
39  return ( (perp >= std::max(theRmin-deltaR, 0.f)) & (perp <= theRmax+deltaR) )
40  && (tmpPhi <= thePhiExtH + deltaPhi) ;
41 
42 }
float xx() const
Definition: LocalError.h:24
virtual bool inside(const Local3DPoint &p) const
Determine if the point is inside the bounds.
T y() const
Definition: PV3DBase.h:63
float xy() const
Definition: LocalError.h:25
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
T perp2() const
Squared magnitude of transverse component.
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
T perp() const
Magnitude of transverse component.
LocalError rotate(float x, float y) const
Return a new LocalError, rotated by an angle defined by the direction (x,y)
Definition: LocalError.h:39
T x() const
Definition: PV3DBase.h:62