ATLAS Offline Software
PFMatchInterfaces.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*
6  * PFMatchInterfaces.h
7  *
8  * Created on: 03.04.2014
9  * Author: tlodd
10  */
11 
12 #ifndef PFMATCHINTERFACES_H_
13 #define PFMATCHINTERFACES_H_
14 
15 #include <vector>
16 #include <cassert>
17 
18 #include "eflowRec/eflowUtil.h"
20 
21 namespace PFMatch {
22 
24 #define TrackLayer eflowCalo
25 
26 /* The track and cluster abstract interface classes */
27 
28 class ITrack {
29 protected:
30  ITrack() { }
31 public:
32  virtual ~ITrack() { }
33 
35 };
36 
37 class ICluster {
38 protected:
39  ICluster() { }
40 public:
41  virtual ~ICluster () { }
42 
43  virtual double eta() const = 0;
44  virtual double phi() const = 0;
45  virtual double etaMean() const = 0;
46  virtual double phiMean() const = 0;
47  virtual double etaVariance() const = 0;
48  virtual double phiVariance() const = 0;
49  virtual bool calVarianceStatus() const = 0;
50  //set functions
51  virtual void etaMean(double) = 0;
52  virtual void phiMean(double) = 0;
53  virtual void etaVariance(double) = 0;
54  virtual void phiVariance(double) = 0;
55  virtual void setCalVarianceStatus() = 0;
56  //
57  virtual unsigned int nCells() const = 0;
58  virtual const std::vector<double>& cellPhi() const = 0;
59  virtual const std::vector<double>& cellEta() const = 0;
60 };
61 
62 
63 /* Position base class */
64 
65 class IPosition {
66 protected:
67  IPosition() { }
68 public:
69  virtual ~IPosition() { }
70 };
71 
72 
73 /* PositionProvider dummy base class */
74 
76 protected:
78 public:
79  virtual ~IPositionProvider() { }
80 };
81 
82 /* PositionProviderInterface */
83 
84 template <class ObjectType, class PositionType>
86 protected:
88 
89 public:
90  virtual ~PositionProvider() {}
91  virtual PositionType getPosition(ObjectType* cluster) const = 0;
92 
93 };
94 
95 template <class PositionType>
96 class ClusterPositionProvider: public PositionProvider<ICluster, PositionType> { };
97 
98 template <class PositionType>
99 class TrackPositionProvider: public PositionProvider<ITrack, PositionType> { };
100 
101 /* Distance calculator interface */
102 
103 template<class TrackPositionType, class ClusterPositionType>
105 protected:
107 public:
108  virtual ~DistanceCalculator() { }
109 
110  virtual double distanceBetween(const TrackPositionType& position1, const ClusterPositionType& position2) const = 0;
111 };
112 
113 
114 /* The distance provider */
115 
117 protected:
119 public:
120  virtual ~IDistanceProvider() { }
121 
122  virtual double distanceBetween(ITrack* track, ICluster* cluster) const = 0;
123 };
124 
125 template<class TrackPositionType, class ClusterPositionType>
127 public:
128  DistanceProvider(std::unique_ptr<IPositionProvider> trackPosition,
129  std::unique_ptr<IPositionProvider> clusterPosition,
130  std::unique_ptr<DistanceCalculator<TrackPositionType, ClusterPositionType> > distanceCalculator):
131  // dynamic_cast to ensure that the right distance provider classes are received
132  m_trackPosition(dynamic_cast<TrackPositionProvider<TrackPositionType>*>(trackPosition.release())),
133  m_clusterPosition(dynamic_cast<ClusterPositionProvider<ClusterPositionType>*>(clusterPosition.release())),
134  m_distanceCalculator(std::move(distanceCalculator)) {
135  // in debug builds we check the pointer validity here to catch a problem early on
136  assert(m_trackPosition.get());
137  assert(m_clusterPosition.get());
138  assert(m_distanceCalculator.get());
139  }
140  virtual ~DistanceProvider() {}
141 
142  double distanceBetween(ITrack* track, ICluster* cluster) const {
143  TrackPositionProvider<TrackPositionType>* trackPositionProvider = m_trackPosition.get();
144  ClusterPositionProvider<ClusterPositionType>* clusterPositionProvider = m_clusterPosition.get();
145  return m_distanceCalculator->distanceBetween(trackPositionProvider->getPosition(track),clusterPositionProvider->getPosition(cluster));
146  }
147 
148 private:
149  std::unique_ptr<TrackPositionProvider<TrackPositionType> > m_trackPosition;
150  std::unique_ptr<ClusterPositionProvider<ClusterPositionType> > m_clusterPosition;
151  std::unique_ptr<DistanceCalculator<TrackPositionType, ClusterPositionType> > m_distanceCalculator;
152 };
153 
154 
155 }
156 
157 #endif /* PFMATCHINTERFACES_H_ */
eflowCaloRegions.h
PFMatch::ICluster::etaMean
virtual double etaMean() const =0
PFMatch::IDistanceProvider
Definition: PFMatchInterfaces.h:116
eflowUtil.h
PFMatch::ITrack::~ITrack
virtual ~ITrack()
Definition: PFMatchInterfaces.h:32
PFMatch::ICluster::cellEta
virtual const std::vector< double > & cellEta() const =0
PFMatch::ClusterPositionProvider
Definition: PFMatchInterfaces.h:96
PFMatch::ICluster::phiVariance
virtual void phiVariance(double)=0
ObjectType
ObjectType
Definition: BaseObject.h:11
PFMatch::DistanceProvider::distanceBetween
double distanceBetween(ITrack *track, ICluster *cluster) const
Definition: PFMatchInterfaces.h:142
PFMatch::ITrack::ITrack
ITrack()
Definition: PFMatchInterfaces.h:30
PFMatch::TrackPositionProvider
Definition: PFMatchInterfaces.h:99
eflowEtaPhiPosition
Definition: eflowUtil.h:85
PFMatch::ICluster::etaVariance
virtual double etaVariance() const =0
PFMatch::ICluster::etaVariance
virtual void etaVariance(double)=0
PFMatch::LayerType
eflowCalo::LAYER LayerType
Definition: PFMatchInterfaces.h:23
PFMatch::IDistanceProvider::~IDistanceProvider
virtual ~IDistanceProvider()
Definition: PFMatchInterfaces.h:120
PFMatch::IPositionProvider::~IPositionProvider
virtual ~IPositionProvider()
Definition: PFMatchInterfaces.h:79
PFMatch::DistanceCalculator
Definition: PFMatchInterfaces.h:104
PFMatch::ICluster::ICluster
ICluster()
Definition: PFMatchInterfaces.h:39
PFMatch::PositionProvider::~PositionProvider
virtual ~PositionProvider()
Definition: PFMatchInterfaces.h:90
PFMatch::DistanceCalculator::distanceBetween
virtual double distanceBetween(const TrackPositionType &position1, const ClusterPositionType &position2) const =0
PFMatch::IPositionProvider
Definition: PFMatchInterfaces.h:75
PFMatch::ICluster
Definition: PFMatchInterfaces.h:37
PFMatch::ICluster::phiMean
virtual double phiMean() const =0
PFMatch::ITrack
Definition: PFMatchInterfaces.h:28
PFMatch::IDistanceProvider::IDistanceProvider
IDistanceProvider()
Definition: PFMatchInterfaces.h:118
PFMatch::IDistanceProvider::distanceBetween
virtual double distanceBetween(ITrack *track, ICluster *cluster) const =0
PFMatch::ICluster::etaMean
virtual void etaMean(double)=0
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
PFMatch::ICluster::phiMean
virtual void phiMean(double)=0
PFMatch::DistanceProvider::~DistanceProvider
virtual ~DistanceProvider()
Definition: PFMatchInterfaces.h:140
PFMatch::PositionProvider::getPosition
virtual PositionType getPosition(ObjectType *cluster) const =0
PFMatch::PositionProvider
Definition: PFMatchInterfaces.h:85
PFMatch::ITrack::etaPhiInLayer
virtual eflowEtaPhiPosition etaPhiInLayer(LayerType layer) const =0
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:24
PFMatch::IPositionProvider::IPositionProvider
IPositionProvider()
Definition: PFMatchInterfaces.h:77
PFMatch
Definition: PFMatchDistance.h:17
PFMatch::DistanceProvider::m_trackPosition
std::unique_ptr< TrackPositionProvider< TrackPositionType > > m_trackPosition
Definition: PFMatchInterfaces.h:149
PFMatch::ICluster::~ICluster
virtual ~ICluster()
Definition: PFMatchInterfaces.h:41
PFMatch::IPosition::IPosition
IPosition()
Definition: PFMatchInterfaces.h:67
eflowCalo::LAYER
LAYER
Definition: eflowCaloRegions.h:36
PFMatch::ICluster::phi
virtual double phi() const =0
PFMatch::ICluster::calVarianceStatus
virtual bool calVarianceStatus() const =0
PFMatch::ICluster::nCells
virtual unsigned int nCells() const =0
PFMatch::ICluster::setCalVarianceStatus
virtual void setCalVarianceStatus()=0
PFMatch::DistanceCalculator::DistanceCalculator
DistanceCalculator()
Definition: PFMatchInterfaces.h:106
PFMatch::DistanceProvider::DistanceProvider
DistanceProvider(std::unique_ptr< IPositionProvider > trackPosition, std::unique_ptr< IPositionProvider > clusterPosition, std::unique_ptr< DistanceCalculator< TrackPositionType, ClusterPositionType > > distanceCalculator)
Definition: PFMatchInterfaces.h:128
PFMatch::IPosition
Definition: PFMatchInterfaces.h:65
PFMatch::IPosition::~IPosition
virtual ~IPosition()
Definition: PFMatchInterfaces.h:69
PFMatch::ICluster::cellPhi
virtual const std::vector< double > & cellPhi() const =0
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
PFMatch::PositionProvider::PositionProvider
PositionProvider()
Definition: PFMatchInterfaces.h:87
PFMatch::DistanceProvider::m_distanceCalculator
std::unique_ptr< DistanceCalculator< TrackPositionType, ClusterPositionType > > m_distanceCalculator
Definition: PFMatchInterfaces.h:151
PFMatch::DistanceCalculator::~DistanceCalculator
virtual ~DistanceCalculator()
Definition: PFMatchInterfaces.h:108
PFMatch::DistanceProvider
Definition: PFMatchInterfaces.h:126
PFMatch::ICluster::phiVariance
virtual double phiVariance() const =0
PFMatch::DistanceProvider::m_clusterPosition
std::unique_ptr< ClusterPositionProvider< ClusterPositionType > > m_clusterPosition
Definition: PFMatchInterfaces.h:150
PFMatch::ICluster::eta
virtual double eta() const =0