CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimpleDiskBounds.cc
Go to the documentation of this file.
1 
2 
5 #include <algorithm>
6 #include <cmath>
7 
8 SimpleDiskBounds::SimpleDiskBounds( float rmin, float rmax, float zmin, float zmax) :
9  theRmin(rmin), theRmax(rmax), theZmin(zmin), theZmax(zmax) {
10  if ( theRmin > theRmax) std::swap( theRmin, theRmax);
11  if ( theZmin > theZmax) std::swap( theZmin, theZmax);
12 }
13 
14 bool SimpleDiskBounds::inside( const Local3DPoint& p) const {
15  return p.z() > theZmin && p.z() < theZmax &&
16  p.perp() > theRmin && p.perp() < theRmax;
17 }
18 
19 bool SimpleDiskBounds::inside( const Local2DPoint& p, const LocalError& err) const {
20  return Bounds::inside(p,err);
21 }
22 
24  return new SimpleDiskBounds(*this);
25 }
26 
27 
28 
29 bool SimpleDiskBounds::inside( const Local3DPoint& p, const LocalError& err, float scale) const
30 {
31  if (p.z() < theZmin || p.z() > theZmax) return false; // check the easy part first
32 
33  double perp2 = p.perp2();
34  double perp = sqrt(perp2);
35  if (perp2 == 0) return scale*scale*(err.xx() + err.xy()) > theRmin*theRmin;
36 
37  // rotated error along p.x(),p.y()
38  // equivalent to (but faster than) err.rotate(p.x(),p.y()).xx()
39  // since we don't need all matrix elements
40  float deltaR = scale * sqrt( p.x()*p.x()/perp2 * err.xx() -
41  2*p.x()*p.y()/perp2 * err.xy() +
42  p.y()*p.y()/perp2 * err.yy());
43  return perp > std::max(theRmin-deltaR, 0.f) && perp < theRmax+deltaR;
44 }
float xx() const
Definition: LocalError.h:24
T perp() const
Definition: PV3DBase.h:72
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
T y() const
Definition: PV3DBase.h:63
T perp2() const
Definition: PV3DBase.h:71
float xy() const
Definition: LocalError.h:25
float yy() const
Definition: LocalError.h:26
const T & max(const T &a, const T &b)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
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.
T perp() const
Magnitude of transverse component.
tuple clone
Definition: statics.py:58
Definition: Bounds.h:22
T x() const
Definition: PV3DBase.h:62