ATLAS Offline Software
DistanceFunctor.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef DISTANCE_FUNCTOR_H
6 #define DISTANCE_FUNCTOR_H
7 
8 #include <math.h>
9 
10 template <typename T, typename U>
12 
13  public:
14  float operator()(const T *t, const U *u) const {
15  return calculateDistance(t, u);
16  }
17 
18  float distance(const T *t, const U *u) const {
19  return (*this)(t, u);
20  }
21 
22  virtual ~DistanceFunctor() {;}
23 
24  private:
25  virtual float calculateDistance(const T *t, const U *u) const = 0;
26 
27 }; // end class DistanceFunctor
28 
29 template <typename T, typename U>
30 class DeltaRDistanceFunctor : virtual public DistanceFunctor<T, U> {
31 
32  public:
33 
34  virtual ~DeltaRDistanceFunctor() {;}
35 
36  static float deltaR(const T *t, const U *u) {
37 
38  if(!t || !u)
39  return -1.;
40 
41  float phiDiff = t->phi() - u->phi();
42  while(phiDiff < -M_PI) phiDiff += 2. * M_PI;
43  while(phiDiff >= M_PI) phiDiff -= 2. * M_PI;
44  float etaDiff = t->eta() - u->eta();
45  return sqrt(phiDiff * phiDiff + etaDiff * etaDiff);
46 
47  }
48 
49  private:
50 
51  virtual float calculateDistance(const T *t, const U *u) const {
53  }
54 
55 }; // end class DeltaRDistanceFunctor
56 
57 #endif
DistanceFunctor::calculateDistance
virtual float calculateDistance(const T *t, const U *u) const =0
M_PI
#define M_PI
Definition: ActiveFraction.h:11
DeltaRDistanceFunctor
Definition: DistanceFunctor.h:30
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
DeltaRDistanceFunctor::calculateDistance
virtual float calculateDistance(const T *t, const U *u) const
Definition: DistanceFunctor.h:51
DeltaRDistanceFunctor::deltaR
static float deltaR(const T *t, const U *u)
Definition: DistanceFunctor.h:36
DistanceFunctor::~DistanceFunctor
virtual ~DistanceFunctor()
Definition: DistanceFunctor.h:22
DistanceFunctor::operator()
float operator()(const T *t, const U *u) const
Definition: DistanceFunctor.h:14
DistanceFunctor
Definition: DistanceFunctor.h:11
DistanceFunctor::distance
float distance(const T *t, const U *u) const
Definition: DistanceFunctor.h:18
DeltaRDistanceFunctor::~DeltaRDistanceFunctor
virtual ~DeltaRDistanceFunctor()
Definition: DistanceFunctor.h:34
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35