ATLAS Offline Software
Associator_DeltaR.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
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 
32 class Associator_DeltaR : public TrackAssociator {
33 
34 public:
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 
82 private:
83 
84  double m_deltaR2;
85 
86 };
87 #endif
88 
89 #endif // TrigInDetAnalysisUtils_Associator_DeltaR_H
TIDA::Associator
Definition: TIDAAssociator.h:24
Track.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
reference
Definition: hcg.cxx:437
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
TIDA::Associator::clone
virtual Associator * clone()=0
TIDA::Associator::clear
void clear()
Definition: TIDAAssociator.h:63
TrackAssociator.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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::match
virtual void match(const std::vector< T * > &s1, const std::vector< S * > &s2)=0
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36