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