CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OuterDetCompatibility.cc
Go to the documentation of this file.
6 
7 using namespace std;
8 
10 {
11  if (barrel) {
12  GlobalDetRangeZPhi detRange(plane);
13  if (!checkPhi(detRange.phiRange())) return 0;
14  if (!checkZ(detRange.zRange())) return 0;
15  } else {
16  GlobalDetRangeRPhi detRange(plane);
17  if (!checkPhi(detRange.phiRange())) return 0;
18  if (!checkR(detRange.rRange())) return 0;
19  }
20  return 1;
21 }
22 
23 
25  const OuterHitPhiPrediction::Range & detPhiRange) const
26 { return rangesIntersect(detPhiRange, hitDetPhiRange, PhiLess()); }
27 
29  const Range & detRRange) const
30 { return rangesIntersect(detRRange, hitDetRRange); }
31 
33  const Range & detZRange) const
34 { return rangesIntersect(detZRange, hitDetZRange); }
35 
36 
38 {
39  float phi = hitDetPhiRange.mean();
40  float r = hitDetRRange.mean();
41  return GlobalPoint( r*cos(phi), r*sin(phi), hitDetZRange.mean() );
42 }
43 
46  const GlobalPoint & ts, const BoundPlane& plane) const
47 {
48  float x_loc = 0.;
49  float y_loc = 0.;
50  if(barrel) {
51  double radius = ts.perp();
52  GlobalVector planeNorm = plane.normalVector();
53  GlobalVector tsDir = GlobalVector( ts.x(), ts.y(),0. ).unit();
54  double ts_phi = tsDir.phi();
55  if (! hitDetPhiRange.inside(ts_phi) ) {
56  while (ts_phi >= hitDetPhiRange.max() ) ts_phi -= 2*M_PI;
57  while (ts_phi < hitDetPhiRange.min() ) ts_phi += 2*M_PI;
58  if (!hitDetPhiRange.inside(ts_phi)) return MeasurementEstimator::Local2DVector(0.,0.);
59  }
60  double cosGamma = tsDir.dot(planeNorm);
61 
62  double dx1 = loc_dist( radius, ts_phi, hitDetPhiRange.min(), cosGamma);
63  double dx2 = loc_dist( radius, ts_phi, hitDetPhiRange.max(), cosGamma);
64 
65  double ts_z = ts.z();
66  double dy1 = ts_z - hitDetZRange.min();
67  double dy2 = hitDetZRange.max() - ts_z;
68 
69  x_loc = max(dx1,dx2);
70  y_loc = max(dy1,dy2);
71 
72  // debug only
73 /*
74  double r1 = dx1 * fabs(cosGamma) / sin(ts_phi-hitDetPhiRange.min());
75  double r2 = dx2 * fabs(cosGamma) / sin(hitDetPhiRange.max()-ts_phi);
76  GlobalPoint p1( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.min());
77  GlobalPoint p2( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.min());
78  GlobalPoint p3( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.max());
79  GlobalPoint p4( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.max());
80  cout << " Local1: " << plane.toLocal(ts-p1) << endl;
81  cout << " Local2: " << plane.toLocal(ts-p2) << endl;
82  cout << " Local3: " << plane.toLocal(ts-p3) << endl;
83  cout << " Local4: " << plane.toLocal(ts-p4) << endl;
84 */
85  }
86  else {
87  LocalPoint ts_loc = plane.toLocal(ts);
88  GlobalVector planeNorm = plane.normalVector();
89 
90  double x_glob[4], y_glob[4], z_glob[4];
91  x_glob[0] = hitDetRRange.min()*cos(hitDetPhiRange.min());
92  y_glob[0] = hitDetRRange.min()*sin(hitDetPhiRange.min());
93  x_glob[1] = hitDetRRange.max()*cos(hitDetPhiRange.min());
94  y_glob[1] = hitDetRRange.max()*sin(hitDetPhiRange.min());
95  x_glob[2] = hitDetRRange.min()*cos(hitDetPhiRange.max());
96  y_glob[2] = hitDetRRange.min()*sin(hitDetPhiRange.max());
97  x_glob[3] = hitDetRRange.max()*cos(hitDetPhiRange.max());
98  y_glob[3] = hitDetRRange.max()*sin(hitDetPhiRange.max());
99 
100  for (int idx = 0; idx < 4; idx++) {
101  double dx_glob = x_glob[idx] - ts.x();
102  double dy_glob = y_glob[idx] - ts.y();
103  double dz_glob = -(dx_glob * planeNorm.x() + dy_glob*planeNorm.y()) / planeNorm.z();
104  z_glob[idx] = dz_glob + ts.z();
105  }
106 
107  for (int idx=0; idx <4; idx++) {
108  LocalPoint lp = plane.toLocal( GlobalPoint( x_glob[idx], y_glob[idx], z_glob[idx]));
109  x_loc = max(x_loc, fabs(lp.x()-ts_loc.x()));
110  y_loc = max(y_loc, fabs(lp.y()-ts_loc.y()));
111  }
112  }
113  MeasurementEstimator::Local2DVector distance(x_loc,y_loc);
114  return distance;
115 }
116 
118  double radius, double ts_phi, double range_phi, double cosGamma) const
119 {
120  double sinDphi = sin(ts_phi - range_phi);
121  double cosDphi = sqrt(1-sinDphi*sinDphi);
122  double sinGamma = sqrt(1-cosGamma*cosGamma);
123  double sinBeta = fabs(cosDphi*cosGamma - sinDphi* sinGamma);
124  return radius * fabs(sinDphi) / sinBeta;
125 }
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
Range rRange() const
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
string unit
Definition: csvLumiCalc.py:46
T sqrt(T t)
Definition: SSEVec.h:48
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
Range zRange() const
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
Range phiRange() const
Range phiRange() const
T x() const
Definition: PV3DBase.h:62
Global3DVector GlobalVector
Definition: GlobalVector.h:10
Definition: DDAxes.h:10