ATLAS Offline Software
Loading...
Searching...
No Matches
BestMatcher< T, S > Class Template Referenceabstract

#include <BestMatcher.h>

Inheritance diagram for BestMatcher< T, S >:
Collaboration diagram for BestMatcher< T, S >:

Classes

class  matched_
 internal class to store the matching paramter for a pair, and in the indices of the pair More...

Public Types

typedef std::map< T *, T * > map_type
typedef std::map< T *, T * > rmap_type

Public Member Functions

 BestMatcher (const std::string &name, double d)
virtual ~BestMatcher ()
virtual void match (const std::vector< T * > &ref, const std::vector< S * > &test)
virtual double distance (const T *t0, const S *t1) const =0
virtual Associatorclone ()=0
virtual void match (const std::vector< T * > &s1, const std::vector< T * > &s2)=0
virtual const T * matched (T *t)
virtual const T * revmatched (T *t)
void clear ()
unsigned size () const

Protected Member Functions

template<typename Tp, typename Tq>
std::map< int, int > matcher (const std::vector< Tp * > &ref, const std::vector< Tq * > &test)

Protected Attributes

double m_d
std::string mname
map_type mmatched
rmap_type mrevmatched

Detailed Description

template<typename T, typename S = T>
class BestMatcher< T, S >

Definition at line 29 of file BestMatcher.h.

Member Typedef Documentation

◆ map_type

typedef std::map<T*, T*> TIDA::Associator< T, T >::map_type
inherited

Definition at line 28 of file TIDAAssociator.h.

◆ rmap_type

typedef std::map<T*, T*> TIDA::Associator< T, T >::rmap_type
inherited

Definition at line 29 of file TIDAAssociator.h.

Constructor & Destructor Documentation

◆ BestMatcher()

template<typename T, typename S = T>
BestMatcher< T, S >::BestMatcher ( const std::string & name,
double d )
inline

Definition at line 61 of file BestMatcher.h.

◆ ~BestMatcher()

template<typename T, typename S = T>
virtual BestMatcher< T, S >::~BestMatcher ( )
inlinevirtual

Definition at line 65 of file BestMatcher.h.

Member Function Documentation

◆ clear()

void TIDA::Associator< T, T >::clear ( )
inlineinherited

Definition at line 63 of file TIDAAssociator.h.

◆ clone()

virtual Associator * TIDA::Associator< T, T >::clone ( )
pure virtualinherited

◆ distance()

◆ match() [1/2]

template<typename T, typename S = T>
virtual void BestMatcher< T, S >::match ( const std::vector< T * > & ref,
const std::vector< S * > & test )
inlinevirtual

Definition at line 68 of file BestMatcher.h.

◆ match() [2/2]

virtual void TIDA::Associator< T, T >::match ( const std::vector< T * > & s1,
const std::vector< T * > & s2 )
pure virtualinherited

◆ matched()

virtual const T * TIDA::Associator< T, T >::matched ( T * t)
inlinevirtualinherited

Definition at line 45 of file TIDAAssociator.h.

◆ matcher()

template<typename T, typename S = T>
template<typename Tp, typename Tq>
std::map< int, int > BestMatcher< T, S >::matcher ( const std::vector< Tp * > & ref,
const std::vector< Tq * > & test )
inlineprotected

inserting into a multimatch sorts them into order as they are added so you get the list of best matches imediately NB: probably quicker to add them to a vector and then sort them afterward

now go through from best to worst, adding to another sorted set only the matches that do not use tracks already used by a better matching pair already found

set of unique track pairings NB: for some reason, using the multiset is faster than using a vector, even though we are only iterating through it later

hooray!! now print out the answer, make a map etc this isn't technically needed, could just use the set of "matched" objects, but hey ho

Definition at line 91 of file BestMatcher.h.

98
100
101 for (unsigned int i=0 ; i<ref.size() ; i++ ) {
102
103 for (unsigned int j=0 ; j<test.size() ; j++ ) {
104 double d = distance(ref[i], test[j]);
105 if ( d<m_d ){
106 m.insert( matched_(d, i, j) );
107 }
108 }
109 }
110
114
115 std::vector<bool> refused( ref.size(), false );
116 std::vector<bool> testused( test.size(), false );
117
123
124 typename std::multiset<matched_>::iterator mitr = m.begin();
125
126 double chi2 = 0;
127
128 for ( ; mitr!=m.end() ; ++mitr ) {
129
130 int rind = mitr->first();
131 int tind = mitr->second();
132
133 if ( refused[rind] ) continue;
134 if ( testused[tind] ) continue;
135
136 refused[rind] = true;
137 testused[tind] = true;
138
139 unique.insert( *mitr );
140
141 chi2 += (mitr->d()*mitr->d());
142
143 }
144
145
146 // std::cout << "chi2 of matches " << chi2 << std::endl;
147
151
152 // std::cout << "\nmatched" << std::endl;
153
155
156
157 mitr = unique.begin();
158 while ( mitr!=unique.end() ) {
159 matches.insert( std::map<int, int>::value_type( mitr->first(), mitr->second() ) );
160 // std::cout << "\tbest match " << *mitr << "\t" << ref[mitr->first()] << "\t" << test[mitr->second()] << std::endl;
161 ++mitr;
162 }
163
164 return matches;
165
166 }
internal class to store the matching paramter for a pair, and in the indices of the pair
Definition BestMatcher.h:36
virtual double distance(const T *t0, const S *t1) const =0
unsigned size() const

◆ revmatched()

virtual const T * TIDA::Associator< T, T >::revmatched ( T * t)
inlinevirtualinherited

Definition at line 52 of file TIDAAssociator.h.

52 {
54 if ( titr != mrevmatched.end() ) return titr->second;
55 else return 0;
56 }

◆ size()

unsigned TIDA::Associator< T, T >::size ( ) const
inlineinherited

Definition at line 66 of file TIDAAssociator.h.

66{ return mmatched.size(); }

Member Data Documentation

◆ m_d

template<typename T, typename S = T>
double BestMatcher< T, S >::m_d
protected

Definition at line 171 of file BestMatcher.h.

◆ mmatched

map_type TIDA::Associator< T, T >::mmatched
protectedinherited

Definition at line 73 of file TIDAAssociator.h.

◆ mname

std::string TIDA::Associator< T, T >::mname
protectedinherited

Definition at line 71 of file TIDAAssociator.h.

◆ mrevmatched

rmap_type TIDA::Associator< T, T >::mrevmatched
protectedinherited

Definition at line 74 of file TIDAAssociator.h.


The documentation for this class was generated from the following file: