ATLAS Offline Software
Loading...
Searching...
No Matches
ObjectMatching.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef OBJECT_MATCHING_H
6#define OBJECT_MATCHING_H
7
9
11#include "CxxUtils/fpcompare.h"
12
13#include <vector>
14
19
21
22 public:
23
25 virtual ~ObjectMatching() { ; };
26
31 template <typename T, typename U>
32 float distance(
33 const T *t,
34 const U *u,
35 const DistanceFunctor<T, U> *metric) const;
36
37 // default metric version - uses deltaR matching and so no metric
38 // need be supplied
39 template <typename T, typename U>
40 float distance(
41 const T *t,
42 const U *u) const;
49 template <typename T, typename U>
50 std::vector<const T*> matchToObjects(
51 const U* matchObject,
52 const std::vector<const T*> &targetObjects,
53 float maxDistance,
54 const DistanceFunctor<T, U> *metric) const;
55
56 // default metric version - uses deltaR matching and so no metric
57 // need be supplied
58 template <typename T, typename U>
59 std::vector<const T*> matchToObjects(
60 const U* matchObject,
61 const std::vector<const T*> &targetObjects,
62 float maxDistance = 0.1) const;
63
64 // similar matching functions for data vectors instead of std vectors
65 template <typename T, typename U>
66 std::vector<const T*> matchToObjects(
67 const U* matchObject,
68 const DataVector<T> &targetObjects,
69 float maxDistance,
70 const DistanceFunctor<T, U> *metric) const;
71
72 template <typename T, typename U>
73 std::vector<const T*> matchToObjects(
74 const U* matchObject,
75 const DataVector<T> &targetObjects,
76 float maxDistance = 0.1) const;
77
78 template <typename T, typename U>
80 const U* matchObject,
81 const std::vector<const T*> &targetObjects,
82 float maxDistance,
83 const DistanceFunctor<T, U> *metric) const;
84
85 template <typename T, typename U>
87 const U* matchObject,
88 const std::vector<const T*> &targetObjects,
89 float maxDistance) const;
90
98 template <typename T, typename U>
99 const T* matchToObject(
100 const U *matchObject,
101 const std::vector<const T*> &targetObjects,
102 float maxDistance,
103 const DistanceFunctor<T, U> *metric) const;
104
105 // default metric version - uses deltaR matching and so no metric
106 // need be supplied
107 template <typename T, typename U>
109 const U *matchObject,
110 const std::vector<const T*> &targetObjects,
111 float maxDistance = 0.1) const;
112
113 // similar functions for data vectors rather than std::vectors
114 template <typename T, typename U>
116 const U *matchObject,
117 const DataVector<T> &targetObjects,
118 float maxDistance,
119 const DistanceFunctor<T, U> *metric) const;
120
121 template <typename T, typename U>
123 const U *matchObject,
124 const DataVector<T> &targetObjects,
125 float maxDistance = 0.1) const;
126
127 protected:
128
129 // returns factory held default metric (deltaR)
130 template <typename T, typename U>
132
133 private:
134
135 // functor for sorting by distance relative to a base object
136 // with a given metric
137 template <typename T, typename U>
139 public:
140 DistanceCompare(const U *baseObject, const DistanceFunctor<T, U> *m) {
141 m_metric = m;
142 m_baseObject = baseObject;
143 }
144 virtual bool operator()(const T *x, const T *y) {
145 // see Control/CxxUtils/fpcompare.h for explanation of
146 // why this is required
149 };
150 private:
151 const U *m_baseObject;
153 };
154
155
156}; // end ObjectMatching declaration
157
159
160#endif
An STL vector of pointers that by default owns its pointed-to elements.
#define y
#define x
Derived DataVector<T>.
Definition DataVector.h:795
DistanceCompare(const U *baseObject, const DistanceFunctor< T, U > *m)
virtual bool operator()(const T *x, const T *y)
const DistanceFunctor< T, U > * m_metric
bool anyMatch(const U *matchObject, const std::vector< const T * > &targetObjects, float maxDistance, const DistanceFunctor< T, U > *metric) const
const DistanceFunctor< T, U > * prepareMetric() const
bool anyMatch(const U *matchObject, const std::vector< const T * > &targetObjects, float maxDistance) const
std::vector< const T * > matchToObjects(const U *matchObject, const std::vector< const T * > &targetObjects, float maxDistance, const DistanceFunctor< T, U > *metric) const
matchToObjects returns the objects of type T from the supplied vector that match to matchObject,...
std::vector< const T * > matchToObjects(const U *matchObject, const DataVector< T > &targetObjects, float maxDistance, const DistanceFunctor< T, U > *metric) const
const T * matchToObject(const U *matchObject, const DataVector< T > &targetObjects, float maxDistance=0.1) const
std::vector< const T * > matchToObjects(const U *matchObject, const DataVector< T > &targetObjects, float maxDistance=0.1) const
float distance(const T *t, const U *u, const DistanceFunctor< T, U > *metric) const
distance returns the distance between the two supplied objects using metric, if available,...
const T * matchToObject(const U *matchObject, const std::vector< const T * > &targetObjects, float maxDistance, const DistanceFunctor< T, U > *metric) const
matchToObject returns the object of type T from the suppled vector that best matches matchObject acco...
virtual ~ObjectMatching()
float distance(const T *t, const U *u) const
const T * matchToObject(const U *matchObject, const std::vector< const T * > &targetObjects, float maxDistance=0.1) const
const T * matchToObject(const U *matchObject, const DataVector< T > &targetObjects, float maxDistance, const DistanceFunctor< T, U > *metric) const
std::vector< const T * > matchToObjects(const U *matchObject, const std::vector< const T * > &targetObjects, float maxDistance=0.1) const
Workaround x86 precision issues for FP inequality comparisons.
bool less(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition fpcompare.h:166