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 //===============================================================
12 // Convert between flavors of points and vectors,
13 // assuming existence of x(), y() and z().
14 //===============================================================
15 
16 template <typename Type1, typename Type2>
17 void ele_convert( const Type1 & obj1, Type2 & obj2 )
18  { obj2 = Type2(obj1.x(),obj1.y(),obj1.z()) ; }
19 
20 
21 //===============================================================
22 // When wanting to compute and compare several characteristics of
23 // one or two points, relatively to a given origin
24 //===============================================================
25 
27  {
28  public :
29  EleRelPoint( const math::XYZPoint & p, const math::XYZPoint & origin ) : relP_(p.x()-origin.x(),p.y()-origin.y(),p.z()-origin.z()) {}
30  EleRelPoint( const GlobalPoint & p, const math::XYZPoint & origin ) : relP_(p.x()-origin.x(),p.y()-origin.y(),p.z()-origin.z()) {}
31  EleRelPoint( const math::XYZPoint & p, const GlobalPoint & origin ) : relP_(p.x()-origin.x(),p.y()-origin.y(),p.z()-origin.z()) {}
32  EleRelPoint( const GlobalPoint & p, const GlobalPoint & origin ) : relP_(p.x()-origin.x(),p.y()-origin.y(),p.z()-origin.z()) {}
33  double eta() { return relP_.eta() ; }
34  double phi() { return normalizedPhi(relP_.phi()) ; }
35  double perp() { return std::sqrt(relP_.x()*relP_.x()+relP_.y()*relP_.y()) ; }
36  private :
38  } ;
39 
41  {
42  public :
43  EleRelPointPair( const math::XYZPoint & p1, const math::XYZPoint & p2, const math::XYZPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
44  EleRelPointPair( const GlobalPoint & p1, const math::XYZPoint & p2, const math::XYZPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
45  EleRelPointPair( const math::XYZPoint & p1, const GlobalPoint & p2, const math::XYZPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
46  EleRelPointPair( const math::XYZPoint & p1, const math::XYZPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
47  EleRelPointPair( const GlobalPoint & p1, const GlobalPoint & p2, const math::XYZPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
48  EleRelPointPair( const math::XYZPoint & p1, const GlobalPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
49  EleRelPointPair( const GlobalPoint & p1, const math::XYZPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
50  EleRelPointPair( const GlobalPoint & p1, const GlobalPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
51  auto dEta() { return (relP1_.eta()-relP2_.eta()) ; }
52  auto dPhi() { return normalizedPhi(relP1_.barePhi()-relP2_.barePhi()) ; }
53  auto dZ() { return (relP1_.z()-relP2_.z()) ; }
54  auto dPerp() { return (relP1_.perp()-relP2_.perp()) ; }
55  private :
58  } ;
59 
60 
61 //===============================================================
62 // Low level functions for the computing of characteristics
63 // relatively to a given origin. Not meant to improve
64 // performance, but rather for the easy later localization
65 // of all such transformations.
66 //===============================================================
67 
68 template <typename PointType>
69 double relative_eta( const PointType & p, const PointType & origin )
70  { return (p-origin).eta() ; }
71 
72 template <typename PointType>
73 double relative_phi( const PointType & p, const PointType & origin )
74  { return normalizedPhi((p-origin).phi()) ; }
75 
76 
77 #endif
EleRelPointPair(const GlobalPoint &p1, const math::XYZPoint &p2, const GlobalPoint &origin)
EleRelPointPair(const math::XYZPoint &p1, const GlobalPoint &p2, const math::XYZPoint &origin)
EleRelPoint(const GlobalPoint &p, const math::XYZPoint &origin)
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:9
EleRelPointPair(const GlobalPoint &p1, const GlobalPoint &p2, const math::XYZPoint &origin)
EleRelPointPair(const GlobalPoint &p1, const math::XYZPoint &p2, const math::XYZPoint &origin)
EleRelPoint(const math::XYZPoint &p, const math::XYZPoint &origin)
EleRelPointPair(const math::XYZPoint &p1, const math::XYZPoint &p2, const math::XYZPoint &origin)
EleRelPointPair(const math::XYZPoint &p1, const math::XYZPoint &p2, const GlobalPoint &origin)
T sqrt(T t)
Definition: SSEVec.h:18
EleRelPointPair(const math::XYZPoint &p1, const GlobalPoint &p2, const GlobalPoint &origin)
GlobalVector relP1_
GlobalVector relP2_
double p2[4]
Definition: TauolaWrapper.h:90
EleRelPointPair(const GlobalPoint &p1, const GlobalPoint &p2, const GlobalPoint &origin)
EleRelPoint(const GlobalPoint &p, const GlobalPoint &origin)
EleRelPoint(const math::XYZPoint &p, const GlobalPoint &origin)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double relative_eta(const PointType &p, const PointType &origin)
double relative_phi(const PointType &p, const PointType &origin)
void ele_convert(const Type1 &obj1, Type2 &obj2)
double p1[4]
Definition: TauolaWrapper.h:89
math::XYZVector relP_