template<typename T, typename S = T>
class BestMatcher< T, S >
Definition at line 29 of file BestMatcher.h.
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.
99 std::multiset<matched_>
m;
101 for (
unsigned int i=0 ;
i<
ref.size() ;
i++ ) {
103 for (
unsigned int j=0 ; j<
test.size() ; j++ ) {
106 m.insert( matched_(
d,
i, j) );
115 std::vector<bool> refused(
ref.size(),
false );
116 std::vector<bool> testused(
test.size(),
false );
122 std::multiset<matched_>
unique;
128 for ( ; mitr!=
m.end() ; mitr++ ) {
130 int rind = mitr->first();
131 int tind = mitr->second();
133 if ( refused[rind] )
continue;
134 if ( testused[tind] )
continue;
136 refused[rind] =
true;
137 testused[tind] =
true;
141 chi2 += (mitr->d()*mitr->d());
154 std::map<int, int> matches;
158 while ( mitr!=
unique.end() ) {
159 matches.insert( std::map<int, int>::value_type( mitr->first(), mitr->second() ) );