ATLAS Offline Software
Loading...
Searching...
No Matches
Associator_DeltaR.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
10
11
12
13#ifndef TrigInDetAnalysisUtils_Associator_DeltaR_H
14#define TrigInDetAnalysisUtils_Associator_DeltaR_H
15
16
17#include <iostream>
18#include <string>
19#include <cmath>
20#include <map>
21
24
25
26
28
29
30#if 0
31
32class Associator_DeltaR : public TrackAssociator {
33
34public:
35
36 Associator_DeltaR(const std::string& name, double deltaR) : TrackAssociator(name), m_deltaR2(deltaR*deltaR) {}
37
38 ~Associator_DeltaR() { }
39
40 virtual TrackAssociator* clone() override { return new Associator_DeltaR(*this); }
41
42 virtual void match(const std::vector<TIDA::Track*>& referenceTracks,
43 const std::vector<TIDA::Track*>& testTracks) {
44
45 // Clear previously filled association map
46 clear();
47
48 // Loop over reference tracks
49 std::vector<TIDA::Track*>::const_iterator reference, referenceEnd=referenceTracks.end();
50 for(reference=referenceTracks.begin(); reference!=referenceEnd; reference++) {
51
52 // Loop over test tracks and find the closest
53 TIDA::Track* bestMatch = NULL;
54 double bestDeltaR=1000;
55
56 std::vector<TIDA::Track*>::const_iterator test, testEnd=testTracks.end();
57 for(test=testTracks.begin(); test!=testEnd; test++) {
58
59 // Evaluate distance between reference and test tracks
60 double deta = (*reference)->eta() - (*test)->eta();
61 double dphi = (*reference)->phi() - (*test)->phi();
62 if(dphi>M_PI) dphi-=2*M_PI;
63 if(dphi<-M_PI) dphi+=2*M_PI;
64 double deltaR = deta*deta+dphi*dphi;
65
66 // Check if this is the best match so far
67 if(bestMatch==NULL || deltaR<bestDeltaR) {
68 bestDeltaR = deltaR;
69 bestMatch = (*test);
70 }
71 }
72
73 // Check if the best match is within delta R specifications
74 if(bestMatch && bestDeltaR<m_deltaR2) {
75 // Create reference->test and test->reference associations
76 mmatched.insert(map_type::value_type(*reference, bestMatch));
77 mrevmatched.insert(map_type::value_type(bestMatch, *reference));
78 }
79 }
80 }
81
82private:
83
84 double m_deltaR2;
85
86};
87#endif
88
89#endif // TrigInDetAnalysisUtils_Associator_DeltaR_H
#define M_PI
Scalar deltaR(const MatrixBase< Derived > &vec) const
TIDA::Associator< TIDA::Track > TrackAssociator
virtual Associator * clone()=0
virtual void match(const std::vector< TIDA::Track * > &s1, const std::vector< TIDA::Track * > &s2)=0