File indexing completed on 2024-04-06 11:58:46
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
0011
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
0040
0041
0042 const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(),
0043 caloPoint.z());
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
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
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087 const GlobalVector heightVector = trackDirection * coneHeight;
0088
0089
0090
0091 const GlobalVector caloIntersectVector(caloPoint.x(), caloPoint.y(), caloPoint.z());
0092
0093
0094 const GlobalVector coneBaseVector = heightVector + caloIntersectVector;
0095
0096
0097 const GlobalPoint coneBasePoint(coneBaseVector.x(), coneBaseVector.y(), coneBaseVector.z());
0098
0099
0100 const GlobalVector rechitVector(rechitPoint.x(), rechitPoint.y(), rechitPoint.z());
0101 const GlobalVector rechitDirection = rechitVector.unit();
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 double rechitdist = trackDirection.dot(coneBaseVector) / trackDirection.dot(rechitDirection);
0120
0121
0122
0123
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