ATLAS Offline Software
Associator_DeltaEtaPhi.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
11 
14 
15 #ifndef TrigInDetAnalysisUtils_Associator_DeltaEtaPhi_H
16 #define TrigInDetAnalysisUtils_Associator_DeltaEtaPhi_H
17 
18 
19 #include <iostream>
20 #include <string>
21 #include <cmath>
22 #include <map>
23 
26 
27 
29 
30 public:
31 
33 
35 
36  virtual TrackAssociator* clone() override { return new Associator_DeltaEtaPhi(*this); }
37 
38  virtual void match(const std::vector<TIDA::Track*>& referenceTracks,
39  const std::vector<TIDA::Track*>& testTracks) {
40 
41  // Clear previously filled association map
42  clear();
43 
44 
45  // Loop over reference tracks
46  std::vector<TIDA::Track*>::const_iterator reference, referenceEnd=referenceTracks.end();
47  for(reference=referenceTracks.begin(); reference!=referenceEnd; reference++) {
48 
49  // std::cout << "Offline = " << (*reference)->eta() << " " << (*reference)->phi() << " " << (*reference)->pT() << std::endl;
50 
51  // Loop over test tracks and find the closest
52  TIDA::Track* bestMatch = NULL;
53  double bestDeltaR=1000;
54 
55  std::vector<TIDA::Track*>::const_iterator test, testEnd=testTracks.end();
56  for(test=testTracks.begin(); test!=testEnd; test++) {
57 
58  // Evaluate distance between reference and test tracks
59  double deta = (*reference)->eta() - (*test)->eta();
60  double dphi = (*reference)->phi() - (*test)->phi();
61  if(dphi>M_PI) dphi-=2*M_PI;
62  if(dphi<-M_PI) dphi+=2*M_PI;
63 
64  if (fabs(deta)>m_deltaEta || fabs(dphi)>m_deltaPhi) continue;
65 
66  double deltaR = (deta*deta)/(m_deltaEta*m_deltaEta)+(dphi*dphi)/(m_deltaPhi*m_deltaPhi);
67 
68  // Check if this is the best match so far
69  if(bestMatch==NULL || deltaR<bestDeltaR) {
70  bestDeltaR = deltaR;
71  bestMatch = (*test);
72  }
73  }
74 
75  // Check if the best match is within delta R specifications
76  if(bestMatch) {
77  // Create reference->test and test->reference associations
78  mmatched.insert(map_type::value_type(*reference, bestMatch));
79  mrevmatched.insert(map_type::value_type(bestMatch, *reference));
80  //std::cout << "Matched = " << bestMatch->eta() << " "<< bestMatch->phi() << " " << bestMatch->pT() << std::endl;
81  }
82  }
83  }
84 
85 private:
86 
87  double m_deltaEta;
88  double m_deltaPhi;
89 
90 };
91 
92 
93 #endif // TrigInDetAnalysisUtils_Associator_DeltaEtaPhi_H
94 
TIDA::Associator
Definition: TIDAAssociator.h:24
Track.h
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
Associator_DeltaEtaPhi
Fixme: needs to be replaced by something inheriting from BestMatcher.
Definition: Associator_DeltaEtaPhi.h:28
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Associator_DeltaEtaPhi::match
virtual void match(const std::vector< TIDA::Track * > &referenceTracks, const std::vector< TIDA::Track * > &testTracks)
Definition: Associator_DeltaEtaPhi.h:38
TIDA::Associator::mmatched
map_type mmatched
Definition: TIDAAssociator.h:73
reference
Definition: hcg.cxx:437
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:144
Associator_DeltaEtaPhi::Associator_DeltaEtaPhi
Associator_DeltaEtaPhi(const std::string &name, double deltaEta, double deltaPhi)
Definition: Associator_DeltaEtaPhi.h:32
TIDA::Associator::clear
void clear()
Definition: TIDAAssociator.h:63
P4Helpers::deltaEta
double deltaEta(const I4Momentum &p1, const I4Momentum &p2)
Computes efficiently .
Definition: P4Helpers.h:53
TrackAssociator.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Associator_DeltaEtaPhi::clone
virtual TrackAssociator * clone() override
Definition: Associator_DeltaEtaPhi.h:36
Associator_DeltaEtaPhi::~Associator_DeltaEtaPhi
~Associator_DeltaEtaPhi()
Definition: Associator_DeltaEtaPhi.h:34
Associator_DeltaEtaPhi::m_deltaEta
double m_deltaEta
Definition: Associator_DeltaEtaPhi.h:87
dq_make_web_display.reference
reference
Definition: dq_make_web_display.py:44
TIDA::Track
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:26
TIDA::Associator::mrevmatched
rmap_type mrevmatched
Definition: TIDAAssociator.h:74
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
Associator_DeltaEtaPhi::m_deltaPhi
double m_deltaPhi
Definition: Associator_DeltaEtaPhi.h:88