CMS 3D CMS Logo

ElectronUtilities.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_EgammaElectronAlgos_ElectronUtilities_H
2 #define RecoEgamma_EgammaElectronAlgos_ElectronUtilities_H
3 
9 
10 //===============================================================
11 // Convert between flavors of points and vectors,
12 // assuming existence of x(), y() and z().
13 //===============================================================
14 
15 template <typename Type1, typename Type2>
16 void ele_convert(const Type1& obj1, Type2& obj2) {
17  obj2 = Type2(obj1.x(), obj1.y(), obj1.z());
18 }
19 
20 //===============================================================
21 // When wanting to compute and compare several characteristics of
22 // one or two points, relatively to a given origin
23 //===============================================================
24 
25 class EleRelPoint {
26 public:
27  EleRelPoint(const math::XYZPoint& p, const math::XYZPoint& origin)
28  : relP_(p.x() - origin.x(), p.y() - origin.y(), p.z() - origin.z()) {}
29  EleRelPoint(const GlobalPoint& p, const math::XYZPoint& origin)
30  : relP_(p.x() - origin.x(), p.y() - origin.y(), p.z() - origin.z()) {}
31  EleRelPoint(const math::XYZPoint& p, const GlobalPoint& origin)
32  : relP_(p.x() - origin.x(), p.y() - origin.y(), p.z() - origin.z()) {}
33  EleRelPoint(const GlobalPoint& p, const GlobalPoint& origin)
34  : relP_(p.x() - origin.x(), p.y() - origin.y(), p.z() - origin.z()) {}
35  double eta() { return relP_.eta(); }
36  double phi() { return normalizedPhi(relP_.phi()); }
37  double perp() { return std::sqrt(relP_.x() * relP_.x() + relP_.y() * relP_.y()); }
38 
39 private:
41 };
42 
44 public:
46  : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
47  relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
49  : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
50  relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
52  : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
53  relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
55  : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
56  relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
57  EleRelPointPair(const GlobalPoint& p1, const GlobalPoint& p2, const math::XYZPoint& origin)
58  : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
59  relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
60  EleRelPointPair(const math::XYZPoint& p1, const GlobalPoint& p2, const GlobalPoint& origin)
61  : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
62  relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
63  EleRelPointPair(const GlobalPoint& p1, const math::XYZPoint& p2, const GlobalPoint& origin)
64  : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
65  relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
66  EleRelPointPair(const GlobalPoint& p1, const GlobalPoint& p2, const GlobalPoint& origin)
67  : relP1_(p1.x() - origin.x(), p1.y() - origin.y(), p1.z() - origin.z()),
68  relP2_(p2.x() - origin.x(), p2.y() - origin.y(), p2.z() - origin.z()) {}
69  auto dEta() { return (relP1_.eta() - relP2_.eta()); }
70  auto dPhi() { return normalizedPhi(relP1_.barePhi() - relP2_.barePhi()); }
71  auto dZ() { return (relP1_.z() - relP2_.z()); }
72  auto dPerp() { return (relP1_.perp() - relP2_.perp()); }
73 
74 private:
77 };
78 
79 //===============================================================
80 // Low level functions for the computing of characteristics
81 // relatively to a given origin. Not meant to improve
82 // performance, but rather for the easy later localization
83 // of all such transformations.
84 //===============================================================
85 
86 template <typename PointType>
87 double relative_eta(const PointType& p, const PointType& origin) {
88  return (p - origin).eta();
89 }
90 
91 template <typename PointType>
92 double relative_phi(const PointType& p, const PointType& origin) {
93  return normalizedPhi((p - origin).phi());
94 }
95 
96 #endif
Vector3DBase
Definition: Vector3DBase.h:8
DDAxes::y
EleRelPoint::relP_
math::XYZVector relP_
Definition: ElectronUtilities.h:40
EleRelPointPair::EleRelPointPair
EleRelPointPair(const GlobalPoint &p1, const math::XYZPoint &p2, const GlobalPoint &origin)
Definition: ElectronUtilities.h:63
EleRelPoint::perp
double perp()
Definition: ElectronUtilities.h:37
ele_convert
void ele_convert(const Type1 &obj1, Type2 &obj2)
Definition: ElectronUtilities.h:16
EleRelPointPair::EleRelPointPair
EleRelPointPair(const math::XYZPoint &p1, const GlobalPoint &p2, const GlobalPoint &origin)
Definition: ElectronUtilities.h:60
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
relative_eta
double relative_eta(const PointType &p, const PointType &origin)
Definition: ElectronUtilities.h:87
EleRelPoint::EleRelPoint
EleRelPoint(const math::XYZPoint &p, const math::XYZPoint &origin)
Definition: ElectronUtilities.h:27
DDAxes::x
EleRelPointPair::dPhi
auto dPhi()
Definition: ElectronUtilities.h:70
EleRelPointPair::EleRelPointPair
EleRelPointPair(const math::XYZPoint &p1, const math::XYZPoint &p2, const GlobalPoint &origin)
Definition: ElectronUtilities.h:54
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
EleRelPoint
Definition: ElectronUtilities.h:25
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
p2
double p2[4]
Definition: TauolaWrapper.h:90
normalizedPhi
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
EleRelPointPair::dPerp
auto dPerp()
Definition: ElectronUtilities.h:72
Point3DBase< float, GlobalTag >
EleRelPointPair::dEta
auto dEta()
Definition: ElectronUtilities.h:69
EleRelPoint::EleRelPoint
EleRelPoint(const GlobalPoint &p, const GlobalPoint &origin)
Definition: ElectronUtilities.h:33
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
EleRelPointPair::EleRelPointPair
EleRelPointPair(const GlobalPoint &p1, const math::XYZPoint &p2, const math::XYZPoint &origin)
Definition: ElectronUtilities.h:48
PVValHelper::phi
Definition: PVValidationHelpers.h:69
PV3DBase::barePhi
T barePhi() const
Definition: PV3DBase.h:65
EleRelPointPair::EleRelPointPair
EleRelPointPair(const math::XYZPoint &p1, const math::XYZPoint &p2, const math::XYZPoint &origin)
Definition: ElectronUtilities.h:45
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
EleRelPointPair::EleRelPointPair
EleRelPointPair(const GlobalPoint &p1, const GlobalPoint &p2, const math::XYZPoint &origin)
Definition: ElectronUtilities.h:57
normalizedPhi.h
p1
double p1[4]
Definition: TauolaWrapper.h:89
EleRelPointPair::EleRelPointPair
EleRelPointPair(const GlobalPoint &p1, const GlobalPoint &p2, const GlobalPoint &origin)
Definition: ElectronUtilities.h:66
EleRelPointPair
Definition: ElectronUtilities.h:43
EleRelPointPair::relP2_
GlobalVector relP2_
Definition: ElectronUtilities.h:76
EleRelPointPair::EleRelPointPair
EleRelPointPair(const math::XYZPoint &p1, const GlobalPoint &p2, const math::XYZPoint &origin)
Definition: ElectronUtilities.h:51
EleRelPoint::EleRelPoint
EleRelPoint(const math::XYZPoint &p, const GlobalPoint &origin)
Definition: ElectronUtilities.h:31
EleRelPoint::eta
double eta()
Definition: ElectronUtilities.h:35
Point3D.h
GlobalVector.h
EleRelPointPair::dZ
auto dZ()
Definition: ElectronUtilities.h:71
EleRelPointPair::relP1_
GlobalVector relP1_
Definition: ElectronUtilities.h:75
Vector3D.h
GlobalPoint.h
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
EleRelPoint::phi
double phi()
Definition: ElectronUtilities.h:36
relative_phi
double relative_phi(const PointType &p, const PointType &origin)
Definition: ElectronUtilities.h:92
EleRelPoint::EleRelPoint
EleRelPoint(const GlobalPoint &p, const math::XYZPoint &origin)
Definition: ElectronUtilities.h:29