ATLAS Offline Software
Loading...
Searching...
No Matches
TrackMatchDeltaR.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
10
11
12#ifndef TRIGINDETANALYSISUTILS_TRACKMATCHDELTAR_H
13#define TRIGINDETANALYSISUTILS_TRACKMATCHDELTAR_H
14
15#include <iostream>
16#include <string>
17#include <cmath>
18#include <map>
19
20
23
24
26
27public:
28
29 TrackMatchDeltaR(const std::string& name, double R) :
30 TrackAssociator(name), m_R2(R*R)
31 { }
32
34
35 // virtual void match( const std::vector<Track*>& ref, const std::vector<Track*>& test ) {
36 virtual void match(const std::vector<TIDA::Track*>& s1,
37 const std::vector<TIDA::Track*>& s2 )
38 {
39 clear();
40
41 const std::vector<TIDA::Track*>& ref = s1;
42 const std::vector<TIDA::Track*>& test = s2;
43
44 // loop over reference tracks
45 for ( int i=ref.size() ; i-- ; ) {
46
47 TIDA::Track* reftrack = ref[i];
48
49 // find the closest track
50 TIDA::Track* tmptrack = NULL;
51 double R2min = 0;
52
53 // loop over test tracks
54 for ( int j=test.size() ; j-- ; ) {
55
56 TIDA::Track* testtrack = test[j];
57
58 double R2tmp = deltaR2( reftrack, testtrack );
59
60 // found a close track
61 if ( tmptrack==NULL || R2tmp<R2min ) {
62 R2min = R2tmp;
63 tmptrack = testtrack;
64 }
65 }
66
67 // is this inside the delta R specification?
68 if ( tmptrack && R2min<m_R2 ) {
69 mmatched.insert( map_type::value_type(reftrack,tmptrack) );
70 mrevmatched.insert( map_type::value_type(tmptrack,reftrack) );
71
72 std::cout << "\t\tSUTT matched " << *reftrack << "\t -> \t" << *tmptrack << "\tDr=" << R2min << std::endl;
73 }
74 }
75 }
76
77
78 virtual double deltaR2( const TIDA::Track* reftrack, const TIDA::Track* testtrack ) {
79 double deta = reftrack->eta()-testtrack->eta();
80 double dphi = reftrack->phi()-testtrack->phi();
81 if ( dphi> M_PI ) dphi-=2*M_PI;
82 if ( dphi<-M_PI ) dphi+=2*M_PI;
83 return deta*deta+dphi*dphi;
84 }
85
86private:
87
88 double m_R2;
89
90};
91
92
93inline std::ostream& operator<<(std::ostream& s, const TrackMatchDeltaR& /*tm*/) {
94 return s;
95}
96
97
98#endif // TRIGINDETANALYSISUTILS_TRACKMATCHDELTAR_H
const boost::regex ref(r_ef)
#define M_PI
TIDA::Associator< TIDA::Track > TrackAssociator
std::ostream & operator<<(std::ostream &s, const TrackMatchDeltaR &)
virtual double deltaR2(const TIDA::Track *reftrack, const TIDA::Track *testtrack)
virtual void match(const std::vector< TIDA::Track * > &s1, const std::vector< TIDA::Track * > &s2)
TrackMatchDeltaR(const std::string &name, double R)