ATLAS Offline Software
Loading...
Searching...
No Matches
TBestMatch.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
16
17
18#ifndef TRIGIDR4MONITORING_BESTMATCH_H
19#define TRIGIDR4MONITORING_BESTMATCH_H
20
21#include <set>
22#include <map>
23#include <memory>
24
25#include <stdexcept>
26
29
30
31template<typename T, typename R=T>
32class TDeltaRMatcher : public BestMatcher<T,R> {
33
34public:
35
36 TDeltaRMatcher(const std::string& name, double d) :
37 BestMatcher<T,R>(name, d*d)
38 { }
39
40 virtual ~TDeltaRMatcher() { }
41
42 virtual std::unique_ptr<TIDA::Associator<T,R>> uclone() const override { return std::make_unique<TDeltaRMatcher<T,R>>(*this); }
43
44 virtual double distance( const T* t0, const R* t1 ) const override {
45 double deta = t0->eta()-t1->eta();
46 double dphi = t0->phi()-t1->phi();
47 if ( dphi> M_PI ) dphi-=2*M_PI;
48 if ( dphi<-M_PI ) dphi+=2*M_PI;
49 return ( deta*deta + dphi*dphi );
50 }
51
52};
53
54
55
56template<typename T, typename R=T>
57class TSecondBestpTMatcher : public BestMatcher<T,R> {
58
59public:
60
61 TSecondBestpTMatcher(const std::string& name, double d) :
62 BestMatcher<T,R>(name, d)
63 { }
64
66
67 virtual std::unique_ptr<TIDA::Associator<T,R>> uclone() const override { return std::make_unique<TSecondBestpTMatcher<T,R>>(*this); }
68
69 virtual double distance( const T* t0, const R* t1 ) const override {
70 double dpT = fabs( t0->pt() - t1->pt() );
71 return dpT/(fabs(t0->pt()));
72 }
73
74};
75
76
77
78
79template<typename T, typename R=T>
80class TDeltaRZMatcher : public BestMatcher<T,R> {
81
82public:
83
84 TDeltaRZMatcher(const std::string& name, double deta=0.05, double dphi=0.05, double dzed=5) :
85 BestMatcher<T,R>(name, 1),
86 m_deta2(deta*deta),
87 m_dphi2(dphi*dphi),
88 m_dzed2(dzed*dzed)
89 { }
90
91 virtual ~TDeltaRZMatcher() { }
92
93 virtual std::unique_ptr<TIDA::Associator<T,R>> uclone() const override { return std::make_unique<TDeltaRZMatcher<T,R>>(*this); }
94
95 virtual double distance( const T* t0, const R* t1 ) const override {
96 double deta = t0->eta()-t1->eta();
97 double dphi = t0->phi()-t1->phi(); if ( dphi> M_PI ) dphi-=2*M_PI; if ( dphi<-M_PI ) dphi+=2*M_PI;
98 double dzed = t0->z0()-t1->z0();
99
100 double dr = std::sqrt( deta*deta/m_deta2 + dphi*dphi/m_dphi2 + dzed*dzed/m_dzed2 );
101
102 return dr;
103 }
104
105protected:
106
107 double m_deta2;
108 double m_dphi2;
109 double m_dzed2;
110
111};
112
113
114
115
116template<typename T, typename R=T>
118
119public:
120
121 TDeltaRZSinThetaMatcher(const std::string& name, double deta=0.05, double dphi=0.05, double dzed=5) :
122 BestMatcher<T,R>(name, 1),
123 m_deta2(deta*deta),
124 m_dphi2(dphi*dphi),
125 m_dzed2(dzed*dzed)
126 { }
127
129
130 virtual std::unique_ptr<TIDA::Associator<T,R>> uclone() const override { return std::make_unique<TDeltaRZSinThetaMatcher<T,R>>(*this); }
131
132 virtual double distance( const T* t0, const R* t1 ) const override {
133 double theta = 2*std::atan(std::exp(-t1->eta()));
134
135 double deta = t0->eta()-t1->eta();
136 double dphi = t0->phi()-t1->phi(); if ( dphi> M_PI ) dphi-=2*M_PI; if ( dphi<-M_PI ) dphi+=2*M_PI;
137
138 double dzed = (t0->z0()-t1->z0())*std::sin(theta);
139
140 double dr = std::sqrt( deta*deta/m_deta2 + dphi*dphi/m_dphi2 + dzed*dzed/m_dzed2 );
141
142 return dr;
143 }
144
145protected:
146
147 double m_deta2;
148 double m_dphi2;
149 double m_dzed2;
150
151};
152
153
154
155template<typename T, typename R=T>
156class TSigmaMatcher : public BestMatcher<T,R> {
157
158public:
159
160 TSigmaMatcher(const std::string& name, double dsigma=1) :
161 BestMatcher<T,R>(name, dsigma)
162 { }
163
164 virtual ~TSigmaMatcher() { }
165
166 virtual std::unique_ptr<TIDA::Associator<T,R>> uclone() const override { return std::make_unique<TSigmaMatcher<T,R>>(*this); }
167
168 virtual double distance( const T* t0, const R* t1 ) const override {
169 double deta = t1->eta()-t0->eta();
170 double dphi = t1->phi()-t0->phi();
171 if ( dphi> M_PI ) dphi-=2*M_PI;
172 if ( dphi<-M_PI ) dphi+=2*M_PI;
173 double dzed = t1->z0()-t0->z0();
174
175 deta /= t1->deta();
176 dphi /= t1->dphi();
177 dzed /= t1->dz0();
178
179 double dr = std::sqrt( deta*deta + dphi*dphi + dzed*dzed );
180
181 return dr;
182 }
183
184};
185
186
187
188
189template<typename T, typename R=T>
190class TDeltaPhiMatcher : public BestMatcher<T,R> {
191
192public:
193
194 TDeltaPhiMatcher(const std::string& name, double p) :
195 BestMatcher<T,R>(name, p)
196 { }
197
198 virtual ~TDeltaPhiMatcher() { }
199
200 virtual std::unique_ptr<TIDA::Associator<T,R>> uclone() const override { return std::make_unique<TDeltaPhiMatcher<T,R>>(*this); }
201
202 virtual double distance( const T* t0, const R* t1 ) const override {
203 double dphi = t0->phi()-t1->phi();
204 if ( dphi> M_PI ) dphi-=2*M_PI;
205 if ( dphi<-M_PI ) dphi+=2*M_PI;
206 return std::fabs( dphi );
207 }
208
209};
210
211
212
213
214template<typename T, typename R=T>
215class TDeltaZMatcher : public BestMatcher<T,R> {
216
217public:
218
219 TDeltaZMatcher(const std::string& name, double p) :
220 BestMatcher<T,R>(name, p)
221 { }
222
223 virtual ~TDeltaZMatcher() { }
224
225 virtual std::unique_ptr<TIDA::Associator<T,R>> uclone() const override { return std::make_unique<TDeltaZMatcher<T,R>>(*this); }
226
227 virtual double distance( const T* t0, const R* t1 ) const override {
228 double dzed = t0->z()-t1->z();
229 return std::fabs( dzed );
230 }
231
232};
233
234
235
236#endif // TRIGIDR4MONITORING_BESTMATCH_H
#define M_PI
Scalar theta() const
theta method
truely generic template class of a best matching algorithm based on an efficient implementation of th...
static Double_t t0
BestMatcher(const std::string &name, double d)
Definition BestMatcher.h:61
virtual std::unique_ptr< TIDA::Associator< T, R > > uclone() const override
Definition TBestMatch.h:200
virtual double distance(const T *t0, const R *t1) const override
Definition TBestMatch.h:202
virtual ~TDeltaPhiMatcher()
Definition TBestMatch.h:198
TDeltaPhiMatcher(const std::string &name, double p)
Definition TBestMatch.h:194
virtual ~TDeltaRMatcher()
Definition TBestMatch.h:40
TDeltaRMatcher(const std::string &name, double d)
Definition TBestMatch.h:36
virtual std::unique_ptr< TIDA::Associator< T, R > > uclone() const override
Definition TBestMatch.h:42
virtual double distance(const T *t0, const R *t1) const override
Definition TBestMatch.h:44
virtual std::unique_ptr< TIDA::Associator< T, R > > uclone() const override
Definition TBestMatch.h:93
TDeltaRZMatcher(const std::string &name, double deta=0.05, double dphi=0.05, double dzed=5)
Definition TBestMatch.h:84
virtual double distance(const T *t0, const R *t1) const override
Definition TBestMatch.h:95
virtual ~TDeltaRZMatcher()
Definition TBestMatch.h:91
virtual ~TDeltaRZSinThetaMatcher()
Definition TBestMatch.h:128
virtual double distance(const T *t0, const R *t1) const override
Definition TBestMatch.h:132
virtual std::unique_ptr< TIDA::Associator< T, R > > uclone() const override
Definition TBestMatch.h:130
TDeltaRZSinThetaMatcher(const std::string &name, double deta=0.05, double dphi=0.05, double dzed=5)
Definition TBestMatch.h:121
virtual std::unique_ptr< TIDA::Associator< T, R > > uclone() const override
Definition TBestMatch.h:225
virtual double distance(const T *t0, const R *t1) const override
Definition TBestMatch.h:227
virtual ~TDeltaZMatcher()
Definition TBestMatch.h:223
TDeltaZMatcher(const std::string &name, double p)
Definition TBestMatch.h:219
TSecondBestpTMatcher(const std::string &name, double d)
Definition TBestMatch.h:61
virtual ~TSecondBestpTMatcher()
Definition TBestMatch.h:65
virtual std::unique_ptr< TIDA::Associator< T, R > > uclone() const override
Definition TBestMatch.h:67
virtual double distance(const T *t0, const R *t1) const override
Definition TBestMatch.h:69
virtual ~TSigmaMatcher()
Definition TBestMatch.h:164
virtual std::unique_ptr< TIDA::Associator< T, R > > uclone() const override
Definition TBestMatch.h:166
TSigmaMatcher(const std::string &name, double dsigma=1)
Definition TBestMatch.h:160
virtual double distance(const T *t0, const R *t1) const override
Definition TBestMatch.h:168