CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ConeDefinition.h
Go to the documentation of this file.
1 #ifndef ConeDefinition_h
2 #define ConeDefinition_h
3 
6 
8 
9 inline double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint) {
10  // Simplified version of getDistInPlane
11  // Assume track direction is origin -> point of hcal intersection
12 
13  const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), caloPoint.z());
14 
15  const GlobalVector caloIntersectUnitVector = caloIntersectVector.unit();
16 
17  const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z());
18 
19  const GlobalVector rechitUnitVector = rechitVector.unit();
20  double dotprod = caloIntersectUnitVector.dot(rechitUnitVector);
21  double rechitdist = caloIntersectVector.mag() / dotprod;
22 
23  const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector;
24  const GlobalPoint effectiveRechitPoint(
25  effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z());
26 
27  GlobalVector distance_vector = effectiveRechitPoint - caloPoint;
28 
29  if (dotprod > 0.) {
30  return distance_vector.mag();
31  } else {
32  return 999999.;
33  }
34 }
35 
36 inline double getDistInPlaneTrackDir(const GlobalPoint caloPoint,
37  const GlobalVector caloVector,
38  const GlobalPoint rechitPoint) {
39  // Simplified version of getDistInPlane : no cone "within" Hcal, but
40  // don't assume track direction is origin -> point of hcal
41  // intersection.
42  const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(),
43  caloPoint.z()); //p
44 
45  const GlobalVector caloUnitVector = caloVector.unit();
46  const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z());
47  const GlobalVector rechitUnitVector = rechitVector.unit();
48  double dotprod_denominator = caloUnitVector.dot(rechitUnitVector);
49  double dotprod_numerator = caloUnitVector.dot(caloIntersectVector);
50  double rechitdist = dotprod_numerator / dotprod_denominator;
51  // double rechitdist=caloIntersectVector.dot(rechitUnitVector);
52  const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector;
53  const GlobalPoint effectiveRechitPoint(
54  effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z());
55  GlobalVector distance_vector = effectiveRechitPoint - caloPoint;
56  if (dotprod_denominator > 0. && dotprod_numerator > 0.) {
57  return distance_vector.mag();
58  } else {
59  return 999999.;
60  }
61 }
62 
63 inline double getDistInPlane(const GlobalVector trackDirection,
64  const GlobalPoint caloPoint,
65  const GlobalPoint rechitPoint,
66  double coneHeight) {
67  // The iso track candidate hits the Calo (Ecal or Hcal) at "caloPoint"
68  // with direction "trackDirection".
69 
70  // "rechitPoint" is the position of the rechit. We only care about
71  // the direction of the rechit.
72 
73  // Consider the rechitPoint as characterized by angles theta and phi
74  // wrt the origin which points at the calo cell of the rechit. In
75  // some sense the distance along the line theta/phi is arbitrary. A
76  // simplified choice might be to put the rechit at the surface of
77  // the Hcal. Our approach is to see whether/where this line
78  // intersects a cone of height "coneHeight" with vertex at caloPoint
79  // aligned with trackDirection.
80  // To that end, this function returns the distance between the
81  // center of the base of the cone and the intersection of the rechit
82  // line and the plane that contains the base of the cone. This
83  // distance is compared with the radius of the cone outside this
84  // function.
85 
86  // Make vector of length cone height along track direction
87  const GlobalVector heightVector = trackDirection * coneHeight;
88 
89  // Make vector from origin to point where iso track intersects the
90  // calorimeter.
91  const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), caloPoint.z());
92 
93  // Make vector from origin to point in center of base of cone
94  const GlobalVector coneBaseVector = heightVector + caloIntersectVector;
95 
96  // Make point in center of base of cone
97  const GlobalPoint coneBasePoint(coneBaseVector.x(), coneBaseVector.y(), coneBaseVector.z());
98 
99  // Make unit vector pointing at rechit.
100  const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z());
101  const GlobalVector rechitDirection = rechitVector.unit();
102 
103  // Find distance "r" along "rechit line" (with angles theta2 and
104  // phi2) where line intersects plane defined by base of cone.
105 
106  // Definition plane of that contains base of cone:
107  // trackDirection.x() (x - coneBaseVector.x()) +
108  // trackDirection.y() (y - coneBaseVector.y()) +
109  // trackDirection.z() (z - coneBaseVector.z()) = 0
110 
111  // Point P_{rh} where rechit line intersects plane:
112  // (rechitdist sin(theta2) cos(phi2),
113  // rechitdist sin(theta2) cos(phi2),
114  // rechitdist cos(theta2))
115 
116  // Substitute P_{rh} into equation for plane and solve for rechitdist.
117  // rechitDist turns out to be the ratio of dot products:
118 
119  double rechitdist = trackDirection.dot(coneBaseVector) / trackDirection.dot(rechitDirection);
120 
121  // Now find distance between point at center of cone base and point
122  // where the "rechit line" intersects the plane defined by the base
123  // of the cone; i.e. the effectiveRecHitPoint.
124  const GlobalVector effectiveRechitVector = rechitdist * rechitDirection;
125  const GlobalPoint effectiveRechitPoint(
126  effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z());
127 
128  GlobalVector distance_vector = effectiveRechitPoint - coneBasePoint;
129  return distance_vector.mag();
130 }
131 
132 #endif
double getDistInPlaneTrackDir(const GlobalPoint caloPoint, const GlobalVector caloVector, const GlobalPoint rechitPoint)
T y() const
Definition: PV3DBase.h:60
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:99
T mag() const
Definition: PV3DBase.h:64
double getDistInPlane(const GlobalVector trackDirection, const GlobalPoint caloPoint, const GlobalPoint rechitPoint, double coneHeight)
T z() const
Definition: PV3DBase.h:61
Vector3DBase unit() const
Definition: Vector3DBase.h:54
double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint)
Definition: ConeDefinition.h:9
T x() const
Definition: PV3DBase.h:59