CMS 3D CMS Logo

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