ATLAS Offline Software
Loading...
Searching...
No Matches
Resolutions.cxx
Go to the documentation of this file.
1
9
10
11
35
38
39#include "GaudiKernel/SystemOfUnits.h"
40
42
44#include "Resolutions.h"
45#include "TrackView.h"
46
47#include "MsgMacros.h"
48
49#include <set>
50
51
52
56IDTPM2::Resolutions::Resolutions( const std::string& name, ToolHandle<GenericMonitoringTool>* m )
57 : IPlotBase( name, m ), m_method(0)
58{ }
59
60
61
66{
67 MY_MSG_DEBUG << "Booking resolutions: " << name() << endmsg;
68
69 for( unsigned int i=1; i<NPARAMS; i++ ) {
70
72
76 m_significance[i] = TIDA::Histogram<float>( monTool(), "significance_"+m_paramName[i] );
77 m_corr[i] = TIDA::Histogram2D<float>( monTool(), "corr_test_vs_ref_"+m_paramName[i] );
78
79 m_resolution_vs_pt[i] = TIDA::Histogram2D<float>( monTool(), "2D", "resolution_"+m_paramName[i]+"_vs_pt" );
80 m_resolution_vs_eta[i] = TIDA::Histogram2D<float>( monTool(), "2D", "resolution_"+m_paramName[i]+"_vs_eta" );
81 m_resolution_vs_z0[i] = TIDA::Histogram2D<float>( monTool(), "@D", "resolution_"+m_paramName[i]+"_vs_z0" );
82
84 for( unsigned int j=0; j<NPARAMSOUT; j++ ) {
85
88 m_resHelper[i][j] = TIDA::Histogram<float>( monTool(), "resHelper_"+m_paramName[i]+"_vs_"+m_paramName[j] );
89 m_reswidth[i][j] = TIDA::Histogram<float>( monTool(), "resolution_"+m_paramName[i]+"_vs_"+m_paramName[j] );
90 m_resmean[i][j] = TIDA::Histogram<float>( monTool(), "resmean_"+m_paramName[i]+"_vs_"+m_paramName[j] );
91
93 m_pullHelper[i][j] = TIDA::Histogram<float>( monTool(), "pullHelper_"+m_paramName[i]+"_vs_"+m_paramName[j] );
94 m_pullmean[i][j] = TIDA::Histogram<float>( monTool(), "pullmean_"+m_paramName[i]+"_vs_"+m_paramName[j] );
95 m_pullwidth[i][j] = TIDA::Histogram<float>( monTool(), "pullwidth_"+m_paramName[i]+"_vs_"+m_paramName[j] );
96
97 } // close NPARAMSOUT loop
98 } // close NPARAMS loop
99
100}
101
102
106
108
109namespace {
110 double deltaPhi( double dphi ) {
111 while ( dphi>M_PI ) dphi -= 2*M_PI;
112 while ( dphi<-M_PI ) dphi += 2*M_PI;
113 return dphi;
114 }
115}
116
117
118void IDTPM2::Resolutions::execute( const TrackAnalysisStore& collections ) const {
119
123
124
128
129 // const std::vector<const TrackView*>& refTracks = collections.reference_tracks();
130 // const std::vector<const TrackView*>& testTracks = collections.test_tracks();
131
134 const TIDA::Associator<const TrackView>* matcher = collections.matcher();
135
136 std::array<float,NPARAMS> refP = {};
137 std::array<float,NPARAMS> refErrorP = {};
138
139 std::array<float,NPARAMS> testP = {};
140 std::array<float,NPARAMS> testErrorP = {};
141
142
144
145 const TIDA::Associator<const TrackView>::map_type& matches = matcher->matched();
146
149
150 TIDA::Associator<const TrackView>::map_type::const_iterator itr = matches.begin();
151
152 for ( ; itr!=matches.end() ; itr++ ) { //cppcheck-suppress postfixOperator
153
154 const TrackView* ref = itr->first;
155 const TrackView* test = itr->second;
156
157 // for ( size_t i=0 ; i<refTracks.size() ; i++ ) {
158
165
166 getTrackParameters( *ref, refP, refErrorP );
167 getTrackParameters( *test, testP, testErrorP );
168
174
175 for( unsigned i=1 ; i<NPARAMS ; i++ ) {
176
177 float residual = testP[i] - refP[i];
178
179 if( i==PHI ) residual = deltaPhi( testP[i] - refP[i] ); // angular difference
180
184
185 if ( testErrorP[i]!=0 ) {
186
187 float pull = residual/testErrorP[i];
188
189 float sigma_test = testErrorP[i];
190
191 float significance_test = testP[i]/testErrorP[i];
192
193 m_pull[i].Fill( pull ); // , weight );
194
199 m_significance[i].Fill( significance_test ); // , weight );
200
201 if ( i==QOVERPT ) {
205 residual = testP[i]/refP[i] - 1; // Relative q/pt resolution
206 sigma_test *= 1/std::fabs( testP[i] ); // relative q/pt error
207 }
208
209 m_sigma[i].Fill( sigma_test ); //, weight );
210
211 }
212
213 // m_corr[i].Fill( refP[i], testP[i], weight ); /// !!! 2D histograms not implemented yet - next thing to do
214
215 m_res[i].Fill( residual ); //, weight );
216
217 m_corr[i].Fill( refP[i], testP[i] );
218
219 m_resolution_vs_pt[i].Fill( ref->pt()*0.001, residual );
220 m_resolution_vs_eta[i].Fill( ref->eta(), residual );
221 m_resolution_vs_z0[i].Fill( ref->z0(), residual );
222
227 // for( unsigned int j=0; j<NPARAMSOUT; j++ ) {
228 // m_resHelper[i][j],Fill( refP[j], residual ); //, weight );
229 // m_pullHelper[i][j].Fill( refP[j], pull ); //, weight );
230 // }
231 }
232 }
233}
234
235
236
243
245
246 MY_MSG_DEBUG << "Finalising resolution plots: " << name() << endmsg;
247
248 std::string realpath = realPath( "/Resolutions/" );
249
250 std::string names[3] = { "pt", "eta", "z0" };
251
252 for( unsigned i=1 ; i<NPARAMS ; i++ ) {
253 for ( int j=0 ; j<3 ; j++ ) {
254 processResolution( realpath+"resolution_"+m_paramName[i]+"_vs_"+names[j]+"/" );
255 }
256 }
257
258#if 0
259 IDPVM::ResolutionHelper resolutionHelper;
261
265 for( unsigned int i=1; i<NPARAMS; i++ ) {
266 for( unsigned int j=0; j<NPARAMSOUT; j++ ) {
267
268 std::cout << "\t" << m_resHelper[i][j].name() << std::endl;
269 std::cout << "\t" << m_reswidth[i][j].name() << std::endl;
270 std::cout << "\t" << m_resmean[i][j].name() << std::endl;
271
272 std::cout << "\t" << m_pullHelper[i][j].name() << std::endl;
273 std::cout << "\t" << m_pullwidth[i][j].name() << std::endl;
274 std::cout << "\t" << m_pullmean[i][j].name() << std::endl;
275
276 // resolutionHelper.makeResolutions( m_resHelper[i][j], m_reswidth[i][j], m_resmean[i][j], method );
277 // resolutionHelper.makeResolutions( m_pullHelper[i][j], m_pullwidth[i][j, m_pullmean[i][j], method );
278 }
279 }
280#endif
281
282}
283
284
289 std::array<float,NPARAMS>& params,
290 std::array<float,NPARAMS>& errors ) const
291{
293
294 params.fill(0);
295
296 params[ D0 ] = p.d0();
297 params[ Z0 ] = p.z0();
298 params[ QOVERP ] = p.qOverP() * Gaudi::Units::GeV;
299 params[ QOVERPT ] = p.qOverP()*std::sin(p.theta()) * Gaudi::Units::GeV;
300 params[ THETA ] = p.theta();
301 params[ PHI ] = p.phi();
302 params[ PT ] = p.pt() / Gaudi::Units::GeV;
306 params[ Z0SIN ] = p.z0()*std::sin(p.theta());
307 params[ ETA ] = p.eta();
308 params[ INCLUSIVE ] = 1;
309
310 errors.fill(0);
311
312 if ( p.is<xAOD::TrackParticle>() ) {
315 errors[ D0 ] = p.dd0(); //error( p, Trk::d0 );
316 errors[ Z0 ] = p.dz0(); //, Trk::z0 );
317 errors[ QOVERP ] = p.dqOverP(); // p, Trk::qOverP ) * Gaudi::Units::GeV;
318
319 // errors[ QOVERPT ] = qOverPTError( p ) * Gaudi::Units::GeV;
320 errors[ QOVERPT ] = 0; // for the time being
321
322 errors[ THETA ] = p.dtheta(); // error( p, Trk::theta );
323 errors[ PHI ] = p.dphi(); // error( p, Trk::phi );
324 errors[ PT ] = p.dpt(); // pTError( p ) / Gaudi::Units::GeV;
325 // errors[ Z0SIN ] = z0SinThetaError( p ); ///
326 errors[ Z0SIN ] = 0;
327 errors[ ETA ] = p.deta(); // etaError( p );
328 errors[ INCLUSIVE ] = 0;
329 }
330}
331
332
const std::regex ref(r_ef)
#define M_PI
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define endmsg
emacs: this is -*- c++ -*-
#define MY_MSG_DEBUG
Definition MsgMacros.h:25
emacs: this is -*- c++ -*-
void processResolution(const std::string &path, bool writeflag=false)
Definition IPlotBase.h:89
ToolHandle< GenericMonitoringTool > * monTool()
mon tool
Definition IPlotBase.h:71
std::string realPath(const std::string &tag="")
This is a horrific function, has to get ALL the histograms, just to be able to work out how to get th...
Definition IPlotBase.cxx:86
const std::string & name() const
generic utilities, just in case
Definition IPlotBase.h:68
IPlotBase(const std::string &name, ToolHandle< GenericMonitoringTool > *m=0)
built from dirName and anaTag
Definition IPlotBase.h:41
TIDA::Histogram< float > m_sigma[NPARAMS]
Definition Resolutions.h:99
TIDA::Histogram< float > m_pull[NPARAMS]
Definition Resolutions.h:97
TIDA::Histogram2D< float > m_corr[NPARAMS]
void method(unsigned m=0)
Definition Resolutions.h:54
Resolutions(const std::string &name, ToolHandle< GenericMonitoringTool > *m=0)
Constructor this method should be an enum of "allowed" methods.
TIDA::Histogram< float > m_res[NPARAMS]
Definition Resolutions.h:98
TIDA::Histogram< float > m_resmean[NPARAMS][NPARAMSOUT]
TIDA::Histogram< float > m_pullmean[NPARAMS][NPARAMSOUT]
std::string m_paramName[NPARAMS]
Definition Resolutions.h:82
TIDA::Histogram2D< float > m_resolution_vs_pt[NPARAMS]
like the res{Helper,width,mean} plots above but actually make some sense
TIDA::Histogram< float > m_reswidth[NPARAMS][NPARAMSOUT]
TIDA::Histogram< float > m_pullwidth[NPARAMS][NPARAMSOUT]
TIDA::Histogram< float > m_resHelper[NPARAMS][NPARAMSOUT]
TIDA::Histogram< float > m_significance[NPARAMS]
void finalize()
Finalize resolution and bias histograms should be called from the calling montools stop() method.
void initialize()
Book the histograms.
void getTrackParameters(const TrackView &p, std::array< float, NPARAMS > &params, std::array< float, NPARAMS > &errors) const
get the track parameters
TIDA::Histogram< float > m_pullHelper[NPARAMS][NPARAMSOUT]
void execute(const TrackAnalysisStore &collections) const
this can be over ridden if need be
unsigned int m_method
probably will eventually no longer need these
Definition Resolutions.h:93
TIDA::Histogram2D< float > m_resolution_vs_eta[NPARAMS]
TIDA::Histogram2D< float > m_resolution_vs_z0[NPARAMS]
std::map< const T *, const S * > map_type
forward declaration required for function prototype
Definition TrackView.h:43
TrackParticle_v1 TrackParticle
Reference the current persistent version: