ATLAS Offline Software
Loading...
Searching...
No Matches
Associator_BestDeltaRZMatcher Class Referenceabstract

#include <Associator_BestMatch.h>

Inheritance diagram for Associator_BestDeltaRZMatcher:
Collaboration diagram for Associator_BestDeltaRZMatcher:

Public Types

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

Public Member Functions

 Associator_BestDeltaRZMatcher (const std::string &name, double deta=0.05, double dphi=0.05, double dzed=5)
virtual ~Associator_BestDeltaRZMatcher ()
virtual TrackAssociatorclone () override
virtual double distance (const TIDA::Track *t0, const TIDA::Track *t1) const override
virtual void match (const std::vector< TIDA::Track * > &ref, const std::vector< TIDA::Track * > &test)
virtual void match (const std::vector< T * > &s1, const std::vector< S * > &s2)=0
virtual const S * matched (T *t)
const map_typematched () const
virtual const T * revmatched (S *t)
const rmap_typerevmatched () 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_deta2
double m_dphi2
double m_dzed2
double m_d
std::string mname
map_type mmatched
rmap_type mrevmatched

Detailed Description

Definition at line 109 of file Associator_BestMatch.h.

Member Typedef Documentation

◆ map_type

template<typename T, typename S = T>
typedef std::map<T*, S*> TIDA::Associator< T, S >::map_type
inherited

Definition at line 28 of file TIDAAssociator.h.

◆ rmap_type

template<typename T, typename S = T>
typedef std::map<S*, T*> TIDA::Associator< T, S >::rmap_type
inherited

Definition at line 29 of file TIDAAssociator.h.

Constructor & Destructor Documentation

◆ Associator_BestDeltaRZMatcher()

Associator_BestDeltaRZMatcher::Associator_BestDeltaRZMatcher ( const std::string & name,
double deta = 0.05,
double dphi = 0.05,
double dzed = 5 )
inline

Definition at line 113 of file Associator_BestMatch.h.

113 :
114 Associator_BestMatcher(name, 1),
115 m_deta2(deta*deta),
116 m_dphi2(dphi*dphi),
117 m_dzed2(dzed*dzed)
118 {
119 std::cout << "Associator: Best RZ Matcher" << std::endl;
120 }
BestMatcher< TIDA::Track > Associator_BestMatcher

◆ ~Associator_BestDeltaRZMatcher()

virtual Associator_BestDeltaRZMatcher::~Associator_BestDeltaRZMatcher ( )
inlinevirtual

Definition at line 122 of file Associator_BestMatch.h.

122{ }

Member Function Documentation

◆ clear()

template<typename T, typename S = T>
void TIDA::Associator< T, S >::clear ( )
inlineinherited

Definition at line 63 of file TIDAAssociator.h.

63{ mmatched.clear(); mrevmatched.clear(); }
rmap_type mrevmatched

◆ clone()

virtual TrackAssociator * Associator_BestDeltaRZMatcher::clone ( )
inlineoverridevirtual

Implements TIDA::Associator< T, S >.

Definition at line 124 of file Associator_BestMatch.h.

124{ return new Associator_BestDeltaRZMatcher(*this); }
Associator_BestDeltaRZMatcher(const std::string &name, double deta=0.05, double dphi=0.05, double dzed=5)

◆ distance()

virtual double Associator_BestDeltaRZMatcher::distance ( const TIDA::Track * t0,
const TIDA::Track * t1 ) const
inlineoverridevirtual

Implements BestMatcher< TIDA::Track >.

Definition at line 126 of file Associator_BestMatch.h.

126 {
127 double deta = t0->eta()-t1->eta();
128 double dphi = t0->phi()-t1->phi(); if ( dphi> M_PI ) dphi-=2*M_PI; if ( dphi<-M_PI ) dphi+=2*M_PI;
129 double dzed = t0->z0()-t1->z0();
130
131 double dr = std::sqrt( deta*deta/m_deta2 + dphi*dphi/m_dphi2 + dzed*dzed/m_dzed2 );
132
133 // std::cout << "RZ matcher dr: " << dr
134 // << "\t : \t" << deta*deta/m_deta2 << "\t" << dphi*dphi/m_dphi2 << "\t" << dzed*dzed/m_dzed2 << "\t" << *t1
135 // << std::endl;
136
137 return dr;
138 }
#define M_PI
static Double_t t0
std::vector< ALFA_RawDataCollection_p1 > t1

◆ match() [1/2]

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

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 TIDA::Track * matched(TIDA::Track *t)

◆ match() [2/2]

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

◆ matched() [1/2]

template<typename T, typename S = T>
const map_type & TIDA::Associator< T, S >::matched ( ) const
inlineinherited

Definition at line 59 of file TIDAAssociator.h.

59{ return mmatched; }

◆ matched() [2/2]

template<typename T, typename S = T>
virtual const S * TIDA::Associator< T, S >::matched ( T * t)
inlinevirtualinherited

Definition at line 45 of file TIDAAssociator.h.

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

◆ matcher()

std::map< int, int > BestMatcher< TIDA::Track, TIDA::Track >::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 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 }
virtual double distance(const TIDA::Track *t0, const TIDA::Track *t1) const=0
unsigned size() const

◆ revmatched() [1/2]

template<typename T, typename S = T>
const rmap_type & TIDA::Associator< T, S >::revmatched ( ) const
inlineinherited

Definition at line 60 of file TIDAAssociator.h.

60{ return mrevmatched; }

◆ revmatched() [2/2]

template<typename T, typename S = T>
virtual const T * TIDA::Associator< T, S >::revmatched ( S * t)
inlinevirtualinherited

Definition at line 52 of file TIDAAssociator.h.

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

◆ size()

template<typename T, typename S = T>
unsigned TIDA::Associator< T, S >::size ( ) const
inlineinherited

Definition at line 66 of file TIDAAssociator.h.

66{ return mmatched.size(); }

Member Data Documentation

◆ m_d

double BestMatcher< TIDA::Track, TIDA::Track >::m_d
protectedinherited

Definition at line 171 of file BestMatcher.h.

◆ m_deta2

double Associator_BestDeltaRZMatcher::m_deta2
protected

Definition at line 142 of file Associator_BestMatch.h.

◆ m_dphi2

double Associator_BestDeltaRZMatcher::m_dphi2
protected

Definition at line 143 of file Associator_BestMatch.h.

◆ m_dzed2

double Associator_BestDeltaRZMatcher::m_dzed2
protected

Definition at line 144 of file Associator_BestMatch.h.

◆ mmatched

template<typename T, typename S = T>
map_type TIDA::Associator< T, S >::mmatched
protectedinherited

Definition at line 73 of file TIDAAssociator.h.

◆ mname

template<typename T, typename S = T>
std::string TIDA::Associator< T, S >::mname
protectedinherited

Definition at line 71 of file TIDAAssociator.h.

◆ mrevmatched

template<typename T, typename S = T>
rmap_type TIDA::Associator< T, S >::mrevmatched
protectedinherited

Definition at line 74 of file TIDAAssociator.h.


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