Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:48:03

0001 #ifndef ConeDefinition_h
0002 #define ConeDefinition_h
0003 
0004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0005 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0006 
0007 #include "CommonTools/UtilAlgos/interface/DeltaR.h"
0008 
0009 inline double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint) {
0010   // Simplified version of getDistInPlane
0011   // Assume track direction is origin -> point of hcal intersection
0012 
0013   const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), caloPoint.z());
0014 
0015   const GlobalVector caloIntersectUnitVector = caloIntersectVector.unit();
0016 
0017   const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z());
0018 
0019   const GlobalVector rechitUnitVector = rechitVector.unit();
0020   double dotprod = caloIntersectUnitVector.dot(rechitUnitVector);
0021   double rechitdist = caloIntersectVector.mag() / dotprod;
0022 
0023   const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector;
0024   const GlobalPoint effectiveRechitPoint(
0025       effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z());
0026 
0027   GlobalVector distance_vector = effectiveRechitPoint - caloPoint;
0028 
0029   if (dotprod > 0.) {
0030     return distance_vector.mag();
0031   } else {
0032     return 999999.;
0033   }
0034 }
0035 
0036 inline double getDistInPlaneTrackDir(const GlobalPoint caloPoint,
0037                                      const GlobalVector caloVector,
0038                                      const GlobalPoint rechitPoint) {
0039   // Simplified version of getDistInPlane : no cone "within" Hcal, but
0040   // don't assume track direction is origin -> point of hcal
0041   // intersection.
0042   const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(),
0043                                          caloPoint.z());  //p
0044 
0045   const GlobalVector caloUnitVector = caloVector.unit();
0046   const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z());
0047   const GlobalVector rechitUnitVector = rechitVector.unit();
0048   double dotprod_denominator = caloUnitVector.dot(rechitUnitVector);
0049   double dotprod_numerator = caloUnitVector.dot(caloIntersectVector);
0050   double rechitdist = dotprod_numerator / dotprod_denominator;
0051   //  double rechitdist=caloIntersectVector.dot(rechitUnitVector);
0052   const GlobalVector effectiveRechitVector = rechitdist * rechitUnitVector;
0053   const GlobalPoint effectiveRechitPoint(
0054       effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z());
0055   GlobalVector distance_vector = effectiveRechitPoint - caloPoint;
0056   if (dotprod_denominator > 0. && dotprod_numerator > 0.) {
0057     return distance_vector.mag();
0058   } else {
0059     return 999999.;
0060   }
0061 }
0062 
0063 inline double getDistInPlane(const GlobalVector trackDirection,
0064                              const GlobalPoint caloPoint,
0065                              const GlobalPoint rechitPoint,
0066                              double coneHeight) {
0067   // The iso track candidate hits the Calo (Ecal or Hcal) at "caloPoint"
0068   // with direction "trackDirection".
0069 
0070   // "rechitPoint" is the position of the rechit.  We only care about
0071   // the direction of the rechit.
0072 
0073   // Consider the rechitPoint as characterized by angles theta and phi
0074   // wrt the origin which points at the calo cell of the rechit.  In
0075   // some sense the distance along the line theta/phi is arbitrary. A
0076   // simplified choice might be to put the rechit at the surface of
0077   // the Hcal.  Our approach is to see whether/where this line
0078   // intersects a cone of height "coneHeight" with vertex at caloPoint
0079   // aligned with trackDirection.
0080   // To that end, this function returns the distance between the
0081   // center of the base of the cone and the intersection of the rechit
0082   // line and the plane that contains the base of the cone.  This
0083   // distance is compared with the radius of the cone outside this
0084   // function.
0085 
0086   // Make vector of length cone height along track direction
0087   const GlobalVector heightVector = trackDirection * coneHeight;
0088 
0089   // Make vector from origin to point where iso track intersects the
0090   // calorimeter.
0091   const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), caloPoint.z());
0092 
0093   // Make vector from origin to point in center of base of cone
0094   const GlobalVector coneBaseVector = heightVector + caloIntersectVector;
0095 
0096   // Make point in center of base of cone
0097   const GlobalPoint coneBasePoint(coneBaseVector.x(), coneBaseVector.y(), coneBaseVector.z());
0098 
0099   // Make unit vector pointing at rechit.
0100   const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z());
0101   const GlobalVector rechitDirection = rechitVector.unit();
0102 
0103   // Find distance "r" along "rechit line" (with angles theta2 and
0104   // phi2) where line intersects plane defined by base of cone.
0105 
0106   // Definition plane of that contains base of cone:
0107   // trackDirection.x() (x - coneBaseVector.x()) +
0108   // trackDirection.y() (y - coneBaseVector.y()) +
0109   // trackDirection.z() (z - coneBaseVector.z()) = 0
0110 
0111   // Point P_{rh} where rechit line intersects plane:
0112   // (rechitdist sin(theta2) cos(phi2),
0113   //  rechitdist sin(theta2) cos(phi2),
0114   //  rechitdist cos(theta2))
0115 
0116   // Substitute P_{rh} into equation for plane and solve for rechitdist.
0117   // rechitDist turns out to be the ratio of dot products:
0118 
0119   double rechitdist = trackDirection.dot(coneBaseVector) / trackDirection.dot(rechitDirection);
0120 
0121   // Now find distance between point at center of cone base and point
0122   // where the "rechit line" intersects the plane defined by the base
0123   // of the cone; i.e. the effectiveRecHitPoint.
0124   const GlobalVector effectiveRechitVector = rechitdist * rechitDirection;
0125   const GlobalPoint effectiveRechitPoint(
0126       effectiveRechitVector.x(), effectiveRechitVector.y(), effectiveRechitVector.z());
0127 
0128   GlobalVector distance_vector = effectiveRechitPoint - coneBasePoint;
0129   return distance_vector.mag();
0130 }
0131 
0132 #endif