ATLAS Offline Software
Loading...
Searching...
No Matches
IDTPM2::TOfflineTruthMatcher< T, R > Class Template Referenceabstract

#include <OfflineTruthMatcher.h>

Inheritance diagram for IDTPM2::TOfflineTruthMatcher< T, R >:
Collaboration diagram for IDTPM2::TOfflineTruthMatcher< T, R >:

Public Types

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

Public Member Functions

 TOfflineTruthMatcher (const std::string &name, double d)
virtual ~TOfflineTruthMatcher ()
virtual std::unique_ptr< TIDA::Associator< T, R > > uclone () const override
virtual double distance (const T *t0, const R *t1) const override
virtual void match (const std::vector< T * > &ref, const std::vector< T * > &test)
virtual void match (const std::vector< T * > &s1, const std::vector< T * > &s2)=0
virtual double distance (const T *t0, const T *t1) const=0
virtual const T * matched (T *t) const
virtual const T * revmatched (T *t) const
void clear ()
unsigned size () const

Protected Member Functions

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 R = T>
class IDTPM2::TOfflineTruthMatcher< T, R >

Definition at line 72 of file OfflineTruthMatcher.h.

Member Typedef Documentation

◆ map_type

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

Definition at line 30 of file TIDAAssociator.h.

◆ rmap_type

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

Definition at line 31 of file TIDAAssociator.h.

Constructor & Destructor Documentation

◆ TOfflineTruthMatcher()

template<typename T, typename R = T>
IDTPM2::TOfflineTruthMatcher< T, R >::TOfflineTruthMatcher ( const std::string & name,
double d )
inline

Definition at line 76 of file OfflineTruthMatcher.h.

76 :
78 }
BestMatcher(const std::string &name, double d)
Definition BestMatcher.h:61

◆ ~TOfflineTruthMatcher()

template<typename T, typename R = T>
virtual IDTPM2::TOfflineTruthMatcher< T, R >::~TOfflineTruthMatcher ( )
inlinevirtual

Definition at line 80 of file OfflineTruthMatcher.h.

80{ }

Member Function Documentation

◆ clear()

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

Definition at line 65 of file TIDAAssociator.h.

65{ mmatched.clear(); mrevmatched.clear(); }

◆ distance() [1/2]

virtual double BestMatcher< T, T >::distance ( const T * t0,
const T * t1 ) const
pure virtualinherited

◆ distance() [2/2]

template<typename T, typename R = T>
virtual double IDTPM2::TOfflineTruthMatcher< T, R >::distance ( const T * t0,
const R * t1 ) const
inlineoverridevirtual

Definition at line 84 of file OfflineTruthMatcher.h.

84 {
86 if ( tp && tp.truthMatch() == t0->template as<xAOD::TruthParticle>() ) return tp.discriminant();
88 }

◆ match() [1/2]

virtual void BestMatcher< T, T >::match ( const std::vector< T * > & ref,
const std::vector< T * > & test )
inlinevirtualinherited

Implements TIDA::Associator< T, T >.

Definition at line 68 of file BestMatcher.h.

69 {
70 this->clear();
71
73
75 while ( mitr!=matched.end() ) {
76 this->mmatched.insert( typename TIDA::Associator<T,S>::map_type::value_type( ref[mitr->first], test[mitr->second]) );
77 this->mrevmatched.insert( typename TIDA::Associator<S,T>::map_type::value_type( test[mitr->second], ref[mitr->first] ) );
78 ++mitr;
79 }
80
81 }
std::map< int, int > matcher(const std::vector< Tp * > &ref, const std::vector< Tq * > &test)
Definition BestMatcher.h:91
virtual const T * matched(T *t) const

◆ 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) const
inlinevirtualinherited

Definition at line 47 of file TIDAAssociator.h.

47 {
48 typename map_type::const_iterator titr = mmatched.find(t);
49 if ( titr != mmatched.end() ) return titr->second;
50 else return 0;
51 }

◆ matcher()

std::map< int, int > BestMatcher< T, T >::matcher ( const std::vector< Tp * > & ref,
const std::vector< Tq * > & test )
inlineprotectedinherited

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.

91 {
92
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 for ( ; mitr!=m.end() ; ++mitr ) {
127
128 int rind = mitr->first();
129 int tind = mitr->second();
130
131 if ( refused[rind] ) continue;
132 if ( testused[tind] ) continue;
133
134 refused[rind] = true;
135 testused[tind] = true;
136
137 unique.insert( *mitr );
138 }
139
140
141 // std::cout << "chi2 of matches " << chi2 << std::endl;
142
146
147 // std::cout << "\nmatched" << std::endl;
148
150
151
152 mitr = unique.begin();
153 while ( mitr!=unique.end() ) {
154 matches.insert( std::map<int, int>::value_type( mitr->first(), mitr->second() ) );
155 // std::cout << "\tbest match " << *mitr << "\t" << ref[mitr->first()] << "\t" << test[mitr->second()] << std::endl;
156 ++mitr;
157 }
158
159 return matches;
160
161 }
virtual double distance(const T *t0, const T *t1) const=0
unsigned size() const

◆ revmatched()

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

Definition at line 54 of file TIDAAssociator.h.

54 {
55 typename rmap_type::const_iterator titr = mrevmatched.find(t);
56 if ( titr != mrevmatched.end() ) return titr->second;
57 else return 0;
58 }

◆ size()

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

Definition at line 68 of file TIDAAssociator.h.

68{ return mmatched.size(); }

◆ uclone()

template<typename T, typename R = T>
virtual std::unique_ptr< TIDA::Associator< T, R > > IDTPM2::TOfflineTruthMatcher< T, R >::uclone ( ) const
inlineoverridevirtual

Implements TIDA::Associator< T, T >.

Definition at line 82 of file OfflineTruthMatcher.h.

Member Data Documentation

◆ m_d

double BestMatcher< T, T >::m_d
protectedinherited

Definition at line 166 of file BestMatcher.h.

◆ mmatched

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

Definition at line 75 of file TIDAAssociator.h.

◆ mname

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

Definition at line 73 of file TIDAAssociator.h.

◆ mrevmatched

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

Definition at line 76 of file TIDAAssociator.h.


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