test
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.
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 1;
17 }
18 
19 
21  const OuterHitPhiPrediction::Range & detPhiRange) const
22 { return rangesIntersect(detPhiRange, hitDetPhiRange, PhiLess()); }
23 
25  const Range & detRRange) const
26 { return rangesIntersect(detRRange, hitDetRRange); }
27 
29  const Range & detZRange) const
30 { return rangesIntersect(detZRange, hitDetZRange); }
31 
32 
34 {
35  float phi = hitDetPhiRange.mean();
36  float r = hitDetRRange.mean();
37  return GlobalPoint( r*cos(phi), r*sin(phi), hitDetZRange.mean() );
38 }
39 
42  const GlobalPoint & ts, const BoundPlane& plane) const
43 {
44  float x_loc = 0.;
45  float y_loc = 0.;
46  if(barrel) {
47  double radius = ts.perp();
48  GlobalVector planeNorm = plane.normalVector();
49  GlobalVector tsDir = GlobalVector( ts.x(), ts.y(),0. ).unit();
50  double ts_phi = tsDir.phi();
51  if (! hitDetPhiRange.inside(ts_phi) ) {
52  while (ts_phi >= hitDetPhiRange.max() ) ts_phi -= 2*M_PI;
53  while (ts_phi < hitDetPhiRange.min() ) ts_phi += 2*M_PI;
54  if (!hitDetPhiRange.inside(ts_phi)) return MeasurementEstimator::Local2DVector(0.,0.);
55  }
56  double cosGamma = tsDir.dot(planeNorm);
57 
58  double dx1 = loc_dist( radius, ts_phi, hitDetPhiRange.min(), cosGamma);
59  double dx2 = loc_dist( radius, ts_phi, hitDetPhiRange.max(), cosGamma);
60 
61  double ts_z = ts.z();
62  double dy1 = ts_z - hitDetZRange.min();
63  double dy2 = hitDetZRange.max() - ts_z;
64 
65  x_loc = max(dx1,dx2);
66  y_loc = max(dy1,dy2);
67 
68  // debug only
69 /*
70  double r1 = dx1 * fabs(cosGamma) / sin(ts_phi-hitDetPhiRange.min());
71  double r2 = dx2 * fabs(cosGamma) / sin(hitDetPhiRange.max()-ts_phi);
72  GlobalPoint p1( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.min());
73  GlobalPoint p2( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.min());
74  GlobalPoint p3( r1* cos(hitDetPhiRange.min()), r1 * sin(hitDetPhiRange.min()), hitDetZRange.max());
75  GlobalPoint p4( r2* cos(hitDetPhiRange.max()), r2 * sin(hitDetPhiRange.max()), hitDetZRange.max());
76  cout << " Local1: " << plane.toLocal(ts-p1) << endl;
77  cout << " Local2: " << plane.toLocal(ts-p2) << endl;
78  cout << " Local3: " << plane.toLocal(ts-p3) << endl;
79  cout << " Local4: " << plane.toLocal(ts-p4) << endl;
80 */
81  }
82  else {
83  LocalPoint ts_loc = plane.toLocal(ts);
84  GlobalVector planeNorm = plane.normalVector();
85 
86  double x_glob[4], y_glob[4], z_glob[4];
87  x_glob[0] = hitDetRRange.min()*cos(hitDetPhiRange.min());
88  y_glob[0] = hitDetRRange.min()*sin(hitDetPhiRange.min());
89  x_glob[1] = hitDetRRange.max()*cos(hitDetPhiRange.min());
90  y_glob[1] = hitDetRRange.max()*sin(hitDetPhiRange.min());
91  x_glob[2] = hitDetRRange.min()*cos(hitDetPhiRange.max());
92  y_glob[2] = hitDetRRange.min()*sin(hitDetPhiRange.max());
93  x_glob[3] = hitDetRRange.max()*cos(hitDetPhiRange.max());
94  y_glob[3] = hitDetRRange.max()*sin(hitDetPhiRange.max());
95 
96  for (int idx = 0; idx < 4; idx++) {
97  double dx_glob = x_glob[idx] - ts.x();
98  double dy_glob = y_glob[idx] - ts.y();
99  double dz_glob = -(dx_glob * planeNorm.x() + dy_glob*planeNorm.y()) / planeNorm.z();
100  z_glob[idx] = dz_glob + ts.z();
101  }
102 
103  for (int idx=0; idx <4; idx++) {
104  LocalPoint lp = plane.toLocal( GlobalPoint( x_glob[idx], y_glob[idx], z_glob[idx]));
105  x_loc = max(x_loc, fabs(lp.x()-ts_loc.x()));
106  y_loc = max(y_loc, fabs(lp.y()-ts_loc.y()));
107  }
108  }
110  return distance;
111 }
112 
114  double radius, double ts_phi, double range_phi, double cosGamma) const
115 {
116  double sinDphi = sin(ts_phi - range_phi);
117  double cosDphi = sqrt(1-sinDphi*sinDphi);
118  double sinGamma = sqrt(1-cosGamma*cosGamma);
119  double sinBeta = fabs(cosDphi*cosGamma - sinDphi* sinGamma);
120  return radius * fabs(sinDphi) / sinBeta;
121 }
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
string unit
Definition: csvLumiCalc.py:46
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
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
Geom::Phi< T > phi() const
T x() const
Definition: PV3DBase.h:62
Global3DVector GlobalVector
Definition: GlobalVector.h:10