File indexing completed on 2024-04-06 12:24:46
0001 #ifndef RecoEgamma_EgammaElectronAlgos_ElectronUtilities_H
0002 #define RecoEgamma_EgammaElectronAlgos_ElectronUtilities_H
0003
0004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0005 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0006 #include "DataFormats/Math/interface/Point3D.h"
0007 #include "DataFormats/Math/interface/Vector3D.h"
0008 #include "DataFormats/Math/interface/normalizedPhi.h"
0009
0010
0011
0012
0013
0014
0015 template <typename Type1, typename Type2>
0016 void ele_convert(const Type1& obj1, Type2& obj2) {
0017 obj2 = Type2(obj1.x(), obj1.y(), obj1.z());
0018 }
0019
0020
0021
0022
0023
0024
0025 class EleRelPoint {
0026 public:
0027 EleRelPoint(const math::XYZPoint& p, const math::XYZPoint& origin)
0028 : relP_(p.x() - origin.x(), p.y() - origin.y(), p.z() - origin.z()) {}
0029 EleRelPoint(const GlobalPoint& p, const math::XYZPoint& origin)
0030 : relP_(p.x() - origin.x(), p.y() - origin.y(), p.z() - origin.z()) {}
0031 EleRelPoint(const math::XYZPoint& p, const GlobalPoint& origin)
0032 : relP_(p.x() - origin.x(), p.y() - origin.y(), p.z() - origin.z()) {}
0033 EleRelPoint(const GlobalPoint& p, const GlobalPoint& origin)
0034 : relP_(p.x() - origin.x(), p.y() - origin.y(), p.z() - origin.z()) {}
0035 double eta() { return relP_.eta(); }
0036 double phi() { return normalizedPhi(relP_.phi()); }
0037 double perp() { return std::sqrt(relP_.x() * relP_.x() + relP_.y() * relP_.y()); }
0038
0039 private:
0040 math::XYZVector relP_;
0041 };
0042
0043 class EleRelPointPair {
0044 public:
0045 EleRelPointPair(const math::XYZPoint& p1, const math::XYZPoint& p2, const math::XYZPoint& origin)
0046 : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
0047 relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
0048 EleRelPointPair(const GlobalPoint& p1, const math::XYZPoint& p2, const math::XYZPoint& origin)
0049 : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
0050 relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
0051 EleRelPointPair(const math::XYZPoint& p1, const GlobalPoint& p2, const math::XYZPoint& origin)
0052 : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
0053 relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
0054 EleRelPointPair(const math::XYZPoint& p1, const math::XYZPoint& p2, const GlobalPoint& origin)
0055 : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
0056 relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
0057 EleRelPointPair(const GlobalPoint& p1, const GlobalPoint& p2, const math::XYZPoint& origin)
0058 : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
0059 relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
0060 EleRelPointPair(const math::XYZPoint& p1, const GlobalPoint& p2, const GlobalPoint& origin)
0061 : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
0062 relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
0063 EleRelPointPair(const GlobalPoint& p1, const math::XYZPoint& p2, const GlobalPoint& origin)
0064 : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
0065 relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
0066 EleRelPointPair(const GlobalPoint& p1, const GlobalPoint& p2, const GlobalPoint& origin)
0067 : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
0068 relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
0069 auto dEta() { return (relP1_.eta() - relP2_.eta()); }
0070 auto dPhi() { return normalizedPhi(relP1_.barePhi() - relP2_.barePhi()); }
0071 auto dZ() { return (relP1_.z() - relP2_.z()); }
0072 auto dPerp() { return (relP1_.perp() - relP2_.perp()); }
0073
0074 private:
0075 GlobalVector relP1_;
0076 GlobalVector relP2_;
0077 };
0078
0079
0080
0081
0082
0083
0084
0085
0086 template <typename PointType>
0087 double relative_eta(const PointType& p, const PointType& origin) {
0088 return (p - origin).eta();
0089 }
0090
0091 template <typename PointType>
0092 double relative_phi(const PointType& p, const PointType& origin) {
0093 return normalizedPhi((p - origin).phi());
0094 }
0095
0096 #endif