CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/Calibration/HcalAlCaRecoProducers/plugins/ConeDefinition.h

Go to the documentation of this file.
00001 #ifndef ConeDefinition_h
00002 #define ConeDefinition_h
00003 
00004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00005 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00006 
00007 #include "CommonTools/UtilAlgos/interface/DeltaR.h"
00008 
00009 inline double getDistInPlaneSimple(const GlobalPoint caloPoint,
00010                             const GlobalPoint rechitPoint)
00011 {
00012 
00013   // Simplified version of getDistInPlane
00014   // Assume track direction is origin -> point of hcal intersection
00015 
00016   const GlobalVector caloIntersectVector(caloPoint.x(),
00017                                          caloPoint.y(),
00018                                          caloPoint.z());
00019 
00020   const GlobalVector caloIntersectUnitVector = caloIntersectVector.unit();
00021 
00022   const GlobalVector rechitVector(rechitPoint.x(),
00023                                   rechitPoint.y(),
00024                                   rechitPoint.z());
00025 
00026   const GlobalVector rechitUnitVector = rechitVector.unit();
00027   double dotprod = caloIntersectUnitVector.dot(rechitUnitVector);
00028   double rechitdist = caloIntersectVector.mag()/dotprod;
00029 
00030 
00031   const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector;
00032   const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(),
00033                                          effectiveRechitVector.y(),
00034                                          effectiveRechitVector.z());
00035 
00036 
00037   GlobalVector distance_vector = effectiveRechitPoint-caloPoint;
00038 
00039   if (dotprod > 0.)
00040   {
00041     return distance_vector.mag();
00042   }
00043   else
00044   {
00045     return 999999.;
00046 
00047   }
00048 
00049 }
00050 
00051 inline double getDistInPlaneTrackDir(const GlobalPoint  caloPoint,
00052                               const GlobalVector caloVector,
00053                               const GlobalPoint  rechitPoint)
00054 {
00055 
00056   // Simplified version of getDistInPlane : no cone "within" Hcal, but
00057   // don't assume track direction is origin -> point of hcal
00058   // intersection.
00059   const GlobalVector caloIntersectVector(caloPoint.x(),
00060                                          caloPoint.y(),
00061                                          caloPoint.z()); //p
00062 
00063   const GlobalVector caloUnitVector = caloVector.unit();
00064   const GlobalVector rechitVector(rechitPoint.x(),
00065                                   rechitPoint.y(),
00066                                   rechitPoint.z());
00067   const GlobalVector rechitUnitVector = rechitVector.unit();
00068   double dotprod_denominator = caloUnitVector.dot(rechitUnitVector);
00069   double dotprod_numerator   = caloUnitVector.dot(caloIntersectVector);
00070   double rechitdist = dotprod_numerator/dotprod_denominator;
00071 //  double rechitdist=caloIntersectVector.dot(rechitUnitVector);
00072   const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector;
00073   const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(),
00074                                          effectiveRechitVector.y(),
00075                                          effectiveRechitVector.z());
00076   GlobalVector distance_vector = effectiveRechitPoint-caloPoint;
00077   if (dotprod_denominator > 0. && dotprod_numerator > 0.)
00078   {
00079 
00080     return distance_vector.mag();
00081   }
00082   else
00083   {
00084     return 999999.;
00085   }
00086 }
00087 
00088 
00089 
00090 inline double getDistInPlane(const GlobalVector trackDirection,
00091                       const GlobalPoint caloPoint,
00092                       const GlobalPoint rechitPoint,
00093                       double coneHeight)
00094 {
00095 
00096   // The iso track candidate hits the Calo (Ecal or Hcal) at "caloPoint"
00097   // with direction "trackDirection".
00098 
00099   // "rechitPoint" is the position of the rechit.  We only care about
00100   // the direction of the rechit.
00101 
00102   // Consider the rechitPoint as characterized by angles theta and phi
00103   // wrt the origin which points at the calo cell of the rechit.  In
00104   // some sense the distance along the line theta/phi is arbitrary. A
00105   // simplified choice might be to put the rechit at the surface of
00106   // the Hcal.  Our approach is to see whether/where this line
00107   // intersects a cone of height "coneHeight" with vertex at caloPoint
00108   // aligned with trackDirection.
00109  // To that end, this function returns the distance between the
00110   // center of the base of the cone and the intersection of the rechit
00111   // line and the plane that contains the base of the cone.  This
00112   // distance is compared with the radius of the cone outside this
00113   // function.
00114 
00115 
00116   // Make vector of length cone height along track direction
00117   const GlobalVector heightVector = trackDirection*coneHeight;
00118 
00119   // Make vector from origin to point where iso track intersects the
00120   // calorimeter.
00121   const GlobalVector caloIntersectVector(caloPoint.x(),
00122                                          caloPoint.y(),
00123                                          caloPoint.z());
00124 
00125   // Make vector from origin to point in center of base of cone
00126   const GlobalVector coneBaseVector = heightVector+caloIntersectVector;
00127 
00128 // Make point in center of base of cone
00129   const GlobalPoint coneBasePoint(coneBaseVector.x(),
00130                                   coneBaseVector.y(),
00131                                   coneBaseVector.z());
00132 
00133   // Make unit vector pointing at rechit.
00134   const GlobalVector rechitVector(rechitPoint.x(),
00135                                   rechitPoint.y(),
00136                                   rechitPoint.z());
00137   const GlobalVector rechitDirection = rechitVector.unit();
00138 
00139   // Find distance "r" along "rechit line" (with angles theta2 and
00140   // phi2) where line intersects plane defined by base of cone.
00141 
00142   // Definition plane of that contains base of cone:
00143   // trackDirection.x() (x - coneBaseVector.x()) +
00144   // trackDirection.y() (y - coneBaseVector.y()) +
00145   // trackDirection.z() (z - coneBaseVector.z()) = 0
00146 
00147   // Point P_{rh} where rechit line intersects plane:
00148   // (rechitdist sin(theta2) cos(phi2),
00149   //  rechitdist sin(theta2) cos(phi2),
00150   //  rechitdist cos(theta2))
00151 
00152   // Substitute P_{rh} into equation for plane and solve for rechitdist.
00153   // rechitDist turns out to be the ratio of dot products:
00154 
00155   double rechitdist = trackDirection.dot(coneBaseVector)/trackDirection.dot(rechitDirection);
00156 
00157   // Now find distance between point at center of cone base and point
00158   // where the "rechit line" intersects the plane defined by the base
00159   // of the cone; i.e. the effectiveRecHitPoint.
00160   const GlobalVector effectiveRechitVector = rechitdist*rechitDirection;
00161   const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(),
00162                                          effectiveRechitVector.y(),
00163                                          effectiveRechitVector.z());
00164 
00165 
00166   GlobalVector distance_vector = effectiveRechitPoint-coneBasePoint;
00167   return distance_vector.mag();
00168 }
00169 
00170 #endif
00171