CMS 3D CMS Logo

OuterDetCompatibility.cc
Go to the documentation of this file.
4 
5 using namespace std;
6 
8 {
9  if (barrel) {
10  if (!checkPhi(plane.phiSpan())) return false;
11  if (!checkZ(plane.zSpan())) return false;
12  } else {
13  if (!checkPhi(plane.phiSpan())) return false;
14  if (!checkR(plane.rSpan())) return false;
15  }
16  return true;
17 }
18 
19 
21  const OuterHitPhiPrediction::Range & detPhiRange) const
22 { return rangesIntersect(detPhiRange, hitDetPhiRange,
23  [](auto x, auto y){ return Geom::phiLess(x,y); }); }
24 
26  const Range & detRRange) const
27 { return rangesIntersect(detRRange, hitDetRRange); }
28 
30  const Range & detZRange) const
31 { return rangesIntersect(detZRange, hitDetZRange); }
32 
33 
35 {
36  float phi = hitDetPhiRange.mean();
37  float r = hitDetRRange.mean();
38  return GlobalPoint( r*cos(phi), r*sin(phi), hitDetZRange.mean() );
39 }
40 
43  const GlobalPoint & ts, const BoundPlane& plane) const
44 {
45  float x_loc = 0.;
46  float y_loc = 0.;
47  if(barrel) {
48  double radius = ts.perp();
49  GlobalVector planeNorm = plane.normalVector();
50  GlobalVector tsDir = GlobalVector( ts.x(), ts.y(),0. ).unit();
51  double ts_phi = tsDir.phi();
52  if (! hitDetPhiRange.inside(ts_phi) ) {
53  while (ts_phi >= hitDetPhiRange.max() ) ts_phi -= 2*M_PI;
54  while (ts_phi < hitDetPhiRange.min() ) ts_phi += 2*M_PI;
55  if (!hitDetPhiRange.inside(ts_phi)) return MeasurementEstimator::Local2DVector(0.,0.);
56  }
57  double cosGamma = tsDir.dot(planeNorm);
58 
59  double dx1 = loc_dist( radius, ts_phi, hitDetPhiRange.min(), cosGamma);
60  double dx2 = loc_dist( radius, ts_phi, hitDetPhiRange.max(), cosGamma);
61 
62  double ts_z = ts.z();
63  double dy1 = ts_z - hitDetZRange.min();
64  double dy2 = hitDetZRange.max() - ts_z;
65 
66  x_loc = max(dx1,dx2);
67  y_loc = max(dy1,dy2);
68 
69  // debug only
70 /*
71  double r1 = dx1 * fabs(cosGamma) / sin(ts_phi-hitDetPhiRange.min());
72  double r2 = dx2 * fabs(cosGamma) / sin(hitDetPhiRange.max()-ts_phi);
73  GlobalPoint p1( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.min());
74  GlobalPoint p2( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.min());
75  GlobalPoint p3( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.max());
76  GlobalPoint p4( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.max());
77  cout << " Local1: " << plane.toLocal(ts-p1) << endl;
78  cout << " Local2: " << plane.toLocal(ts-p2) << endl;
79  cout << " Local3: " << plane.toLocal(ts-p3) << endl;
80  cout << " Local4: " << plane.toLocal(ts-p4) << endl;
81 */
82  }
83  else {
84  LocalPoint ts_loc = plane.toLocal(ts);
85  GlobalVector planeNorm = plane.normalVector();
86 
87  double x_glob[4], y_glob[4], z_glob[4];
88  x_glob[0] = hitDetRRange.min()*cos(hitDetPhiRange.min());
89  y_glob[0] = hitDetRRange.min()*sin(hitDetPhiRange.min());
90  x_glob[1] = hitDetRRange.max()*cos(hitDetPhiRange.min());
91  y_glob[1] = hitDetRRange.max()*sin(hitDetPhiRange.min());
92  x_glob[2] = hitDetRRange.min()*cos(hitDetPhiRange.max());
93  y_glob[2] = hitDetRRange.min()*sin(hitDetPhiRange.max());
94  x_glob[3] = hitDetRRange.max()*cos(hitDetPhiRange.max());
95  y_glob[3] = hitDetRRange.max()*sin(hitDetPhiRange.max());
96 
97  for (int idx = 0; idx < 4; idx++) {
98  double dx_glob = x_glob[idx] - ts.x();
99  double dy_glob = y_glob[idx] - ts.y();
100  double dz_glob = -(dx_glob * planeNorm.x() + dy_glob*planeNorm.y()) / planeNorm.z();
101  z_glob[idx] = dz_glob + ts.z();
102  }
103 
104  for (int idx=0; idx <4; idx++) {
105  LocalPoint lp = plane.toLocal( GlobalPoint( x_glob[idx], y_glob[idx], z_glob[idx]));
106  x_loc = max(x_loc, fabs(lp.x()-ts_loc.x()));
107  y_loc = max(y_loc, fabs(lp.y()-ts_loc.y()));
108  }
109  }
111  return distance;
112 }
113 
115  double radius, double ts_phi, double range_phi, double cosGamma) const
116 {
117  double sinDphi = sin(ts_phi - range_phi);
118  double cosDphi = sqrt(1-sinDphi*sinDphi);
119  double sinGamma = sqrt(1-cosGamma*cosGamma);
120  double sinBeta = fabs(cosDphi*cosGamma - sinDphi* sinGamma);
121  return radius * fabs(sinDphi) / sinBeta;
122 }
GlobalPoint center() const
bool operator()(const BoundPlane &plane) const
MeasurementEstimator::Local2DVector maximalLocalDisplacement(const TrajectoryStateOnSurface &ts, const BoundPlane &plane) const
T perp() const
Definition: PV3DBase.h:72
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
double loc_dist(double radius, double ts_phi, double range_phi, double cosGamma) const
T y() const
Definition: PV3DBase.h:63
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
bool checkZ(const Range &detZRange) const
bool checkPhi(const OuterHitPhiPrediction::Range &detPhiRange) const
T sqrt(T t)
Definition: SSEVec.h:18
bool rangesIntersect(const Range &a, const Range &b)
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool checkR(const Range &detRRange) const
#define M_PI
bool phiLess(float phi1, float phi2)
Definition: VectorUtil.h:23
T x() const
Definition: PV3DBase.h:62
Global3DVector GlobalVector
Definition: GlobalVector.h:10