ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Associator_BestSigmaMatcher Class Referenceabstract

#include <Associator_BestMatch.h>

Inheritance diagram for Associator_BestSigmaMatcher:
Collaboration diagram for Associator_BestSigmaMatcher:

Public Types

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

Public Member Functions

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

Detailed Description

Definition at line 197 of file Associator_BestMatch.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

◆ Associator_BestSigmaMatcher()

Associator_BestSigmaMatcher::Associator_BestSigmaMatcher ( const std::string &  name,
double  dsigma = 1 
)
inline

Definition at line 201 of file Associator_BestMatch.h.

201  :
202  Associator_BestMatcher(name, dsigma)
203  {
204  std::cout << "Associator: Best Sigma Matcher" << std::endl;
205  }

◆ ~Associator_BestSigmaMatcher()

virtual Associator_BestSigmaMatcher::~Associator_BestSigmaMatcher ( )
inlinevirtual

Definition at line 207 of file Associator_BestMatch.h.

207 { }

Member Function Documentation

◆ clear()

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

Definition at line 63 of file TIDAAssociator.h.

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

◆ clone()

virtual TrackAssociator* Associator_BestSigmaMatcher::clone ( )
inlineoverridevirtual

Implements TIDA::Associator< T, T >.

Definition at line 209 of file Associator_BestMatch.h.

209 { return new Associator_BestSigmaMatcher(*this); }

◆ distance() [1/2]

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

Implemented in VertexMatcher, and VertexNewMatcher.

◆ distance() [2/2]

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

Definition at line 211 of file Associator_BestMatch.h.

211  {
212  double deta = t1->eta()-t0->eta();
213  double dphi = t1->phi()-t0->phi();
214  if ( dphi> M_PI ) dphi-=2*M_PI;
215  if ( dphi<-M_PI ) dphi+=2*M_PI;
216  double dzed = t1->z0()-t0->z0();
217 
218  // std::cout << *t0 << "\n" << *t1 << "\ndphi : " << dphi << std::endl;
219 
220  deta /= t1->deta();
221  dphi /= t1->dphi();
222  dzed /= t1->dz0();
223 
224  double dr = std::sqrt( deta*deta + dphi*dphi + dzed*dzed );
225 
226  // std::cout << "Sigma matcher dr: " << dr
227  // << "\t : \t" << deta*deta << "\t" << dphi*dphi << "\t" << dzed*dzed << "\t" << *t1
228  // << std::endl;
229 
230  return dr;
231  }

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

Definition at line 68 of file BestMatcher.h.

69  {
70  this->clear();
71 
72  std::map<int,int> matched = matcher( ref, test);
73 
74  std::map<int,int>::iterator mitr = matched.begin();
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  }

◆ match() [2/2]

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

◆ matched() [1/2]

const map_type& TIDA::Associator< T, T >::matched ( ) const
inlineinherited

Definition at line 59 of file TIDAAssociator.h.

59 { return mmatched; }

◆ matched() [2/2]

virtual const T * TIDA::Associator< T, T >::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()

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 
)
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 
99  std::multiset<matched_> m;
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 
122  std::multiset<matched_> unique;
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 
154  std::map<int, int> matches;
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  }

◆ revmatched() [1/2]

const rmap_type& TIDA::Associator< T, T >::revmatched ( ) const
inlineinherited

Definition at line 60 of file TIDAAssociator.h.

60 { return mrevmatched; }

◆ revmatched() [2/2]

virtual const T* TIDA::Associator< T, T >::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()

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
protectedinherited

Definition at line 171 of file BestMatcher.h.

◆ m_deta2

double Associator_BestSigmaMatcher::m_deta2
protected

Definition at line 235 of file Associator_BestMatch.h.

◆ m_dphi2

double Associator_BestSigmaMatcher::m_dphi2
protected

Definition at line 236 of file Associator_BestMatch.h.

◆ m_dzed2

double Associator_BestSigmaMatcher::m_dzed2
protected

Definition at line 237 of file Associator_BestMatch.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:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TIDA::Associator
Definition: TIDAAssociator.h:24
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
Associator_BestMatcher
BestMatcher< TIDA::Track > Associator_BestMatcher
Definition: Associator_BestMatch.h:28
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TIDA::Associator< T, T >::matched
const map_type & matched() const
Definition: TIDAAssociator.h:59
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
M_PI
#define M_PI
Definition: ActiveFraction.h:11
TIDA::Associator< T, T >::mmatched
map_type mmatched
Definition: TIDAAssociator.h:73
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:144
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
BestMatcher::matcher
std::map< int, int > matcher(const std::vector< Tp * > &ref, const std::vector< Tq * > &test)
Definition: BestMatcher.h:91
BestMatcher::distance
virtual double distance(const T *t0, const S *t1) const =0
Associator_BestSigmaMatcher::Associator_BestSigmaMatcher
Associator_BestSigmaMatcher(const std::string &name, double dsigma=1)
Definition: Associator_BestMatch.h:201
TIDA::Associator< T, T >::clear
void clear()
Definition: TIDAAssociator.h:63
lumiFormat.i
int i
Definition: lumiFormat.py:92
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
std::unique
DataModel_detail::iterator< DVL > unique(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of unique for DataVector/List.
Definition: DVL_algorithms.h:135
ref
const boost::regex ref(r_ef)
TIDA::Associator< T, T >::mrevmatched
rmap_type mrevmatched
Definition: TIDAAssociator.h:74
BestMatcher::m_d
double m_d
Definition: BestMatcher.h:171