ATLAS Offline Software
TrackMatchDeltaR.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
12 #ifndef TRIGINDETANALYSISUTILS_TRACKMATCHDELTAR_H
13 #define TRIGINDETANALYSISUTILS_TRACKMATCHDELTAR_H
14 
15 #include <iostream>
16 #include <string>
17 #include <cmath>
18 #include <map>
19 
20 
23 
24 
26 
27 public:
28 
29  TrackMatchDeltaR(const std::string& name, double R) :
31  { }
32 
34 
35  // virtual void match( const std::vector<Track*>& ref, const std::vector<Track*>& test ) {
36  virtual void match(const std::vector<TIDA::Track*>& s1,
37  const std::vector<TIDA::Track*>& s2 )
38  {
39  clear();
40 
41  const std::vector<TIDA::Track*>& ref = s1;
42  const std::vector<TIDA::Track*>& test = s2;
43 
44  // loop over reference tracks
45  for ( int i=ref.size() ; i-- ; ) {
46 
47  TIDA::Track* reftrack = ref[i];
48 
49  // find the closest track
50  TIDA::Track* tmptrack = NULL;
51  double R2min = 0;
52 
53  // loop over test tracks
54  for ( int j=test.size() ; j-- ; ) {
55 
56  TIDA::Track* testtrack = test[j];
57 
58  double R2tmp = deltaR2( reftrack, testtrack );
59 
60  // found a close track
61  if ( tmptrack==NULL || R2tmp<R2min ) {
62  R2min = R2tmp;
63  tmptrack = testtrack;
64  }
65  }
66 
67  // is this inside the delta R specification?
68  if ( tmptrack && R2min<m_R2 ) {
69  mmatched.insert( map_type::value_type(reftrack,tmptrack) );
70  mrevmatched.insert( map_type::value_type(tmptrack,reftrack) );
71 
72  std::cout << "\t\tSUTT matched " << *reftrack << "\t -> \t" << *tmptrack << "\tDr=" << R2min << std::endl;
73  }
74  }
75  }
76 
77 
78  virtual double deltaR2( const TIDA::Track* reftrack, const TIDA::Track* testtrack ) {
79  double deta = reftrack->eta()-testtrack->eta();
80  double dphi = reftrack->phi()-testtrack->phi();
81  if ( dphi> M_PI ) dphi-=2*M_PI;
82  if ( dphi<-M_PI ) dphi+=2*M_PI;
83  return deta*deta+dphi*dphi;
84  }
85 
86 private:
87 
88  double m_R2;
89 
90 };
91 
92 
93 inline std::ostream& operator<<(std::ostream& s, const TrackMatchDeltaR& /*tm*/) {
94  return s;
95 }
96 
97 
98 #endif // TRIGINDETANALYSISUTILS_TRACKMATCHDELTAR_H
TIDA::Associator
Definition: TIDAAssociator.h:24
Track.h
ReadCellNoiseFromCoolCompare.s1
s1
Definition: ReadCellNoiseFromCoolCompare.py:378
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
TrackMatchDeltaR::match
virtual void match(const std::vector< TIDA::Track * > &s1, const std::vector< TIDA::Track * > &s2)
Definition: TrackMatchDeltaR.h:36
M_PI
#define M_PI
Definition: ActiveFraction.h:11
TIDA::Associator::mmatched
map_type mmatched
Definition: TIDAAssociator.h:73
TrackMatchDeltaR::TrackMatchDeltaR
TrackMatchDeltaR(const std::string &name, double R)
Definition: TrackMatchDeltaR.h:29
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
TIDA::Associator::clear
void clear()
Definition: TIDAAssociator.h:63
lumiFormat.i
int i
Definition: lumiFormat.py:85
AnalysisUtils::Delta::R
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
Definition: AnalysisMisc.h:49
TIDA::Track::phi
double phi() const
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:47
TrackAssociator.h
operator<<
std::ostream & operator<<(std::ostream &s, const TrackMatchDeltaR &)
Definition: TrackMatchDeltaR.h:93
TrackMatchDeltaR::deltaR2
virtual double deltaR2(const TIDA::Track *reftrack, const TIDA::Track *testtrack)
Definition: TrackMatchDeltaR.h:78
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TIDA::Track::eta
double eta() const
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:46
TrackMatchDeltaR
Definition: TrackMatchDeltaR.h:25
ref
const boost::regex ref(r_ef)
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
TrackMatchDeltaR::m_R2
double m_R2
Definition: TrackMatchDeltaR.h:88
TIDA::Track
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:26
TIDA::Associator::mrevmatched
rmap_type mrevmatched
Definition: TIDAAssociator.h:74
TrackMatchDeltaR::~TrackMatchDeltaR
~TrackMatchDeltaR()
Definition: TrackMatchDeltaR.h:33