ATLAS Offline Software
TrackMatchDeltaRCosmic.h
Go to the documentation of this file.
1 /* emacs: this is -*- c++ -*- */
15 #ifndef TRIGINDETANALYSISUTILS_TRACKMATCHDELTARCOSMIC_H
16 #define TRIGINDETANALYSISUTILS_TRACKMATCHDELTARCOSMIC_H
17 
18 #include <iostream>
19 #include <string>
20 #include <cmath>
21 #include <map>
22 
23 
26 
27 
29 
30 public:
31 
32  TrackMatchDeltaRCosmic(const std::string& name, double R) :
34  { }
35 
37 
38  // virtual void match( const std::vector<Track*>& ref, const std::vector<Track*>& test ) {
39  virtual void match(const std::vector<TIDA::Track*>& s1,
40  const std::vector<TIDA::Track*>& s2 )
41  {
42  clear();
43 
44  const std::vector<TIDA::Track*>& ref = s1;
45  const std::vector<TIDA::Track*>& test = s2;
46 
47  // loop over reference tracks
48  for ( int i=ref.size() ; i-- ; ) {
49 
50  TIDA::Track* reftrack = ref[i];
51 
52  // find the closest track
53  TIDA::Track* tmptrack = NULL;
54  double R2min = 0;
55 
56  // loop over test tracks
57  for ( int j=test.size() ; j-- ; ) {
58 
59  TIDA::Track* testtrack = test[j];
60 
61  double R2tmp = deltaR2( reftrack, testtrack );
62  double R2PItmp = deltaR2PI( reftrack, testtrack );
63 
64  if ( R2PItmp<R2tmp ) R2tmp = R2PItmp;
65 
66  // found a close track
67  if ( tmptrack==NULL || R2tmp<R2min ) {
68  R2min = R2tmp;
69  tmptrack = testtrack;
70  }
71  }
72 
73  // is this inside the delta R specification?
74  if ( tmptrack && R2min<m_R2 ) {
75  mmatched.insert( map_type::value_type(reftrack,tmptrack) );
76  mrevmatched.insert( map_type::value_type(tmptrack,reftrack) );
77 
78  std::cout << "\t\tSUTT matched " << *reftrack << "\t -> \t" << *tmptrack << "\tDr=" << R2min << std::endl;
79  }
80  }
81  }
82 
83 
84  virtual double deltaR2PI( const TIDA::Track* reftrack, const TIDA::Track* testtrack ) {
85  double deta = reftrack->eta()+testtrack->eta();
86  double dphi = reftrack->phi()-testtrack->phi()-M_PI;
87  if ( dphi> M_PI ) dphi-=2*M_PI;
88  if ( dphi<-M_PI ) dphi+=2*M_PI;
89  return deta*deta+dphi*dphi;
90  }
91 
92  virtual double deltaR2( const TIDA::Track* reftrack, const TIDA::Track* testtrack ) {
93  double deta = reftrack->eta()-testtrack->eta();
94  double dphi = reftrack->phi()-testtrack->phi();
95  if ( dphi> M_PI ) dphi-=2*M_PI;
96  if ( dphi<-M_PI ) dphi+=2*M_PI;
97  return deta*deta+dphi*dphi;
98  }
99 
100 private:
101 
102  double m_R2;
103 
104 };
105 
106 
107 inline std::ostream& operator<<(std::ostream& s, const TrackMatchDeltaRCosmic& /*tm*/) {
108  return s;
109 }
110 
111 
112 #endif // TRIGINDETANALYSISUTILS_TRACKMATCHDELTARCOSMIC_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
M_PI
#define M_PI
Definition: ActiveFraction.h:11
TIDA::Associator::mmatched
map_type mmatched
Definition: TIDAAssociator.h:73
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
operator<<
std::ostream & operator<<(std::ostream &s, const TrackMatchDeltaRCosmic &)
Definition: TrackMatchDeltaRCosmic.h:107
TrackMatchDeltaRCosmic
Definition: TrackMatchDeltaRCosmic.h:28
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
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
TrackMatchDeltaRCosmic::deltaR2
virtual double deltaR2(const TIDA::Track *reftrack, const TIDA::Track *testtrack)
Definition: TrackMatchDeltaRCosmic.h:92
TrackMatchDeltaRCosmic::deltaR2PI
virtual double deltaR2PI(const TIDA::Track *reftrack, const TIDA::Track *testtrack)
Definition: TrackMatchDeltaRCosmic.h:84
TrackMatchDeltaRCosmic::~TrackMatchDeltaRCosmic
~TrackMatchDeltaRCosmic()
Definition: TrackMatchDeltaRCosmic.h:36
ref
const boost::regex ref(r_ef)
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
TrackMatchDeltaRCosmic::match
virtual void match(const std::vector< TIDA::Track * > &s1, const std::vector< TIDA::Track * > &s2)
Definition: TrackMatchDeltaRCosmic.h:39
TIDA::Track
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:26
TrackMatchDeltaRCosmic::m_R2
double m_R2
Definition: TrackMatchDeltaRCosmic.h:102
TrackMatchDeltaRCosmic::TrackMatchDeltaRCosmic
TrackMatchDeltaRCosmic(const std::string &name, double R)
Definition: TrackMatchDeltaRCosmic.h:32
TIDA::Associator::mrevmatched
rmap_type mrevmatched
Definition: TIDAAssociator.h:74