ATLAS Offline Software
TrackEfficiency.cxx
Go to the documentation of this file.
1 
13 
14 // #include "Resplot/Effplot.h"
15 // #include "Resplot/Resplot.h"
16 
17 #include <cmath>
18 
19 
21  // book the histograms
22 
23 #if 0
24  double limits[23] = { 0, 500, 1000, 1500, 2000, 2500,
25  3000, 4000, 5000, 6000, 7000, 8000,
26  10000, 12000, 14000, 16000, 20000, 25000,
27  30000, 35000, 40000, 50000, 60000 };
28 #endif
29 
30 
31 #if 0
32  double limits[13] = { 0, 1000, 2000, 3000, 5000, 7000,
33  10000, 14000, 20000, 30000, 40000, 60000, 100000 };
34 
35  double limits2[24] = { 0, 1000, 2000, 3000, 5000, 7000, 8000, 8500, 9000, 9500,
36  10000, 10500, 11000, 11500, 12000, 12500, 13000, 13500, 14000,
37  20000, 30000, 40000, 60000, 100000 };
38 #endif
39 
40  double limits2[18] = { 0, 1000, 2000, 3000, 5000, 7000,
41  8000, 9000, 10000, 11000, 12000, 13000,
42  14000, 20000, 30000, 40000, 60000, 100000 };
43 
44  std::vector<double> limits;
45  for ( int i=0 ; i<18 ; i++ ) limits.push_back(limits2[i]);
46 
47 #if 0
48  // efficiencies
49  effvsPT = new Effplot( "efficiency vs pt", limits );
50  effvseta = new Effplot( "efficiency vs eta", 8, -3, 3);
51  effvsphi = new Effplot( "efficiency vs phi", 8, -M_PI, M_PI );
52  // effvsd0 = new Effplot( "efficiency vs d0", 20, -100, 100 );
53  effvsd0 = new Effplot( "efficiency vs d0", 200, -200, 200 );
54 
55  // resolutions
56  iptvipt = new Resplot( "resolution ipt vs ipt", 20, -0.2, 0.2, 21, -0.01, 0.01);
57 
58  ptvpt = new Resplot( "resolution pt vs pt", limits, 41, -10, 10 );
59  phivpt = new Resplot( "resolution phi vs pt", limits, 41, -0.01, 0.01 );
60  etavpt = new Resplot( "resolution eta vs pt", limits, 41, -0.01, 0.01 );
61  z0vpt = new Resplot( "resolution z0 vs pt", limits, 41, -1, 1 );
62  d0vpt = new Resplot( "resolution d0 vs pt", limits, 61, -0.3, 0.3 );
63 
64  ptveta = new Resplot( "resolution pt vs eta", 12, -3, 3, 41, -10, 10);
65  iptveta = new Resplot( "resolution ipt vs eta", 12, -3, 3, 41, -0.01, 0.01);
66  phiveta = new Resplot( "resolution phi vs eta", 12, -3, 3, 41, -0.01, 0.01);
67  etaveta = new Resplot( "resolution eta vs eta", 12, -3, 3, 41, -0.01, 0.01);
68  z0veta = new Resplot( "resolution z vs eta", 12, -3, 3, 41, -1, 1);
69 
70  z0vz0 = new Resplot( "resolution z vs z", 40, -200, 200, 41, -1, 1);
71  d0vd0 = new Resplot( "resolution d0 vs d0", 20, -5, 5, 61, -0.3, 0.3);
72 #endif
73 
74 }
75 
76 
77 
78 void TrackEfficiency::execute( const std::vector<TIDA::Track*>& reftracks,
79  const std::vector<TIDA::Track*>& /*testtracks*/,
80  TrackAssociator* matcher )
81 {
82  std::cout << "execute() " << name() << std::endl;
83 
84  // for ( int i=0 ; i<reftracks.size() ; i++ ) std::cout << i << " " << *reftracks[i] << " ref" << std::endl;
85  // for ( int i=0 ; i<testtracks.size() ; i++ ) std::cout << i << " " << *testtracks[i] << " tst" << std::endl;
86 
87  // for an efficiency, we want at most 1 matching reco track
88  // for each true track
89  // for a purity, we want at most 1 true track for each
90  // reconstructed track
91  // for a resolution we only want to consider matched pairs
92  // of tracks
93 
94  // this is an efficiency
95  for ( unsigned i=reftracks.size() ; i-- ; ) {
96 
97  // get the matched reco track for this true track if
98  // there is one - returns NULL if no matching track
99 
100  // std::cout << i << " " << *reftracks[i] << std::endl;
101 
102  const TIDA::Track* matchedreco = matcher->matched(reftracks[i]);
103 
104  std::cout << "\t\tSUTT Analysis " << name() << "\t" << i << " " << *reftracks[i] << " -> ";
105 
106  if ( matchedreco ) {
107 
108  std::cout << *matchedreco << std::endl;
109 
110  // convert pt in MeV to GeV
111  double pTt = reftracks[i]->pT()/1000; // convert to GeV
112  double pTr = matchedreco->pT()/1000; // convert to GeV
113 
114 #if 0
115  effvsPT->Fill( reftracks[i]->pT() );
116  effvseta->Fill( reftracks[i]->eta() );
117  effvsphi->Fill( reftracks[i]->phi() );
118  effvsd0->Fill( reftracks[i]->a0() );
119 
120 
121  // fill the plots
122  iptvipt->Fill( 1/pTt, 1/pTt-1/pTr );
123  ptvpt->Fill( reftracks[i]->pT(), pTt-pTr );
124 
125  phivpt->Fill( reftracks[i]->pT(), reftracks[i]->phi()-matchedreco->phi() );
126  etavpt->Fill( reftracks[i]->pT(), reftracks[i]->eta()-matchedreco->eta() );
127  z0vpt->Fill( reftracks[i]->pT(), reftracks[i]->z0()-matchedreco->z0() );
128  d0vpt->Fill( reftracks[i]->pT(), reftracks[i]->a0()-matchedreco->a0() );
129 
130  ptveta->Fill( reftracks[i]->eta(), pTt-pTr);
131  iptveta->Fill( reftracks[i]->eta(), 1/pTt-1/pTr);
132  phiveta->Fill( reftracks[i]->eta(), reftracks[i]->phi()-matchedreco->phi() );
133  etaveta->Fill( reftracks[i]->eta(), reftracks[i]->eta()-matchedreco->eta() );
134  z0veta->Fill( reftracks[i]->eta(), reftracks[i]->z0()-matchedreco->z0() );
135 
136  z0vz0->Fill( reftracks[i]->z0(), reftracks[i]->z0()-matchedreco->z0() );
137  d0vd0->Fill( reftracks[i]->a0(), reftracks[i]->a0()-matchedreco->a0() );
138 #endif
139 
140  std::cout << "SUTT pt res "
141  << "\tpt=" << reftracks[i]->pT()
142  << "\tpTr=" << pTt
143  << "\t1/pTt=" << 1/pTt
144  << "\tDpT=" << pTt-pTr
145  << "\tD1/pT=" << 1/pTt-1/pTr
146  << std::endl;
147 
148  }
149  else {
150  std::cout << " NULL" << std::endl;
151 #if 0
152 
153  effvsPT->FillTrueOnly( reftracks[i]->pT() );
154  effvseta->FillTrueOnly( reftracks[i]->eta() );
155  effvsphi->FillTrueOnly( reftracks[i]->phi() );
156  effvsd0->FillTrueOnly( reftracks[i]->a0() );
157 #endif
158 
159  }
160  }
161 
162 
163 
164 }
165 
166 
167 
169  // sort out all the histograms and write them out
170  std::cout << "SUTT TrackEfficiency::finalise() " << name() << std::endl;
171 
172 #if 0
173  gDirectory->pwd();
174  Directory d(name());
175  d.push();
176  effvsPT->Finalise();
177  effvseta->Finalise(Effplot::FitQuad);
178  effvsphi->Finalise(Effplot::FitQuad);
179  effvsd0->Finalise(Effplot::FitQuad);
180  effvsPT->Write();
181  effvseta->Write();
182  effvsphi->Write();
183  effvsd0->Write();
184 
185  iptvipt->Finalise();
186  ptvpt->Finalise();
187 
188  phivpt->Finalise();
189  etavpt->Finalise();
190  z0vpt->Finalise();
191  d0vpt->Finalise();
192 
193  ptveta->Finalise();
194  iptveta->Finalise();
195  phiveta->Finalise();
196  etaveta->Finalise();
197  z0veta->Finalise();
198 
199  z0vz0->Finalise();
200  d0vd0->Finalise();
201 
202  // maybe put a Write() call into Finalise() ???
203  iptvipt->Write();
204  ptvpt->Write();
205 
206  phivpt->Write();
207  etavpt->Write();
208  z0vpt->Write();
209  d0vpt->Write();
210 
211  ptveta->Write();
212  iptveta->Write();
213  phiveta->Write();
214  etaveta->Write();
215  z0veta->Write();
216 
217  z0vz0->Write();
218  d0vd0->Write();
219 
220 
221  d.pop();
222 
223 #endif
224 }
225 
TIDA::Associator
Definition: TIDAAssociator.h:24
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
Track.h
TrackEfficiency.h
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TIDA::Track::a0
double a0() const
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:49
TrackEfficiency::finalise
virtual void finalise()
Definition: TrackEfficiency.cxx:168
Directory
Definition: Directory.h:29
M_PI
#define M_PI
Definition: ActiveFraction.h:11
TIDA::Track::pT
double pT() const
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:50
TIDA::Track::z0
double z0() const
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:48
TIDA::Associator::matched
virtual const S * matched(T *t)
Definition: TIDAAssociator.h:45
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrackEfficiency::execute
virtual void execute(const std::vector< TIDA::Track * > &tracks1, const std::vector< TIDA::Track * > &tracks2, TrackAssociator *matcher)
Definition: TrackEfficiency.cxx:78
TrackAnalysis::name
std::string name() const
return identifier
Definition: TrackAnalysis.h:52
Resplot
Definition: Resplot.h:50
TIDA::Track::phi
double phi() const
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:47
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
a0
double a0
Definition: globals.cxx:27
TIDA::Track::eta
double eta() const
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:46
TIDA::Track
Definition: Trigger/TrigAnalysis/TrigInDetAnalysis/TrigInDetAnalysis/Track.h:26
TrackEfficiency::initialise
virtual void initialise()
standard operation interface
Definition: TrackEfficiency.cxx:20