ATLAS Offline Software
TrackAnalysisPlotsMgr.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "TrackAnalysisPlotsMgr.h"
14 #include "ITrackMatchingLookup.h"
16 #include "TrackParametersHelper.h"
17 
19 #include "GaudiKernel/ISvcLocator.h"
20 #include "GaudiKernel/Service.h"
21 
22 
27  const std::string& dirName,
28  const std::string& anaTag,
29  const std::string& chain,
30  PlotMgr* pParent ) :
31  PlotMgr( dirName, anaTag, pParent ),
32  m_anaTag( anaTag ), m_chain( chain ),
33  m_directory( dirName ) { }
34 
35 
40 {
41  ATH_MSG_DEBUG( "Initialising in directory: " << m_directory );
42 
44  m_trkAnaDefSvc = Gaudi::svcLocator()->service( "TrkAnaDefSvc"+m_anaTag );
45  ATH_CHECK( m_trkAnaDefSvc.isValid() );
46 
48  if( m_trkAnaDefSvc->plotTrackMultiplicities() ) {
49  m_plots_summary = std::make_unique< SummaryPlots >(
50  this, "Tracks/Multiplicities", m_anaTag,
51  m_trkAnaDefSvc->doTrigNavigation() );
52  }
53 
55  if( m_trkAnaDefSvc->plotTrackParameters() ) {
56  m_plots_trkParam_vsTest = std::make_unique< TrackParametersPlots >(
57  this, "Tracks/Parameters", m_anaTag, m_trkAnaDefSvc->testTag(),
58  ( not m_trkAnaDefSvc->isTestTruth() ) and m_trkAnaDefSvc->plotTrackParametersErrors(),
59  m_trkAnaDefSvc->plotTracksInJets() );
60  m_plots_trkParam_vsRef = std::make_unique< TrackParametersPlots >(
61  this, "Tracks/Parameters", m_anaTag, m_trkAnaDefSvc->referenceTag(),
62  ( not m_trkAnaDefSvc->isReferenceTruth() ) and m_trkAnaDefSvc->plotTrackParametersErrors(),
63  m_trkAnaDefSvc->plotTracksInJets() );
64  }
65 
67  if( m_trkAnaDefSvc->plotTrackMultiplicities() ) {
68  m_plots_nTracks_vsTest = std::make_unique< NtracksPlots >(
69  this, "Tracks/Multiplicities", m_anaTag, m_trkAnaDefSvc->testTag(),
70  m_trkAnaDefSvc->doTrigNavigation(), m_trkAnaDefSvc->hasFullPileupTruth() );
71  m_plots_nTracks_vsRef = std::make_unique< NtracksPlots >(
72  this, "Tracks/Multiplicities", m_anaTag, m_trkAnaDefSvc->referenceTag(),
73  m_trkAnaDefSvc->doTrigNavigation(), m_trkAnaDefSvc->hasFullPileupTruth() );
74  }
75 
77  if( m_trkAnaDefSvc->plotEfficiencies() ) {
78  m_plots_eff_vsTest = std::make_unique< EfficiencyPlots >(
79  this, "Tracks/Efficiencies/Purities", m_anaTag, m_trkAnaDefSvc->testTag(), false );
80  m_plots_eff_vsRef = std::make_unique< EfficiencyPlots >(
81  this, "Tracks/Efficiencies", m_anaTag, m_trkAnaDefSvc->referenceTag(), false,
82  true, m_trkAnaDefSvc->hasFullPileupTruth() );
83  if( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
84  m_plots_eff_vsTruth = std::make_unique< EfficiencyPlots >(
85  this, "Tracks/Efficiencies", m_anaTag, "truth", false );
86  }
87  }
88 
90  if( m_trkAnaDefSvc->plotTechnicalEfficiencies()) {
91  m_plots_tech_eff_vsTest = std::make_unique< EfficiencyPlots >(
92  this, "Tracks/Efficiencies/Technical/Purities", m_anaTag, m_trkAnaDefSvc->testTag(), true );
93  m_plots_tech_eff_vsRef = std::make_unique< EfficiencyPlots >(
94  this, "Tracks/Efficiencies/Technical", m_anaTag, m_trkAnaDefSvc->referenceTag(), true,
95  true, m_trkAnaDefSvc->hasFullPileupTruth() );
96  if( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
97  m_plots_tech_eff_vsTruth = std::make_unique< EfficiencyPlots >(
98  this, "Tracks/Efficiencies/Technical", m_anaTag, "truth", true );
99  }
100  }
101 
103  if( m_trkAnaDefSvc->plotResolutions() ) {
104  m_plots_resolution = std::make_unique< ResolutionPlots >(
105  this, "Tracks/Resolutions", m_anaTag,
106  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->referenceTag(),
107  m_trkAnaDefSvc->resolutionMethod() );
108  }
109 
111  if( m_trkAnaDefSvc->plotFakeRates() and m_trkAnaDefSvc->isReferenceTruth() ) {
112  m_plots_fakeRate = std::make_unique< FakeRatePlots >(
113  this, "Tracks/FakeRates", m_anaTag, m_trkAnaDefSvc->testTag(),
114  true, m_trkAnaDefSvc->hasFullPileupTruth() );
115  if ( not m_trkAnaDefSvc->unlinkedAsFakes() ) {
116  m_plots_missingTruth = std::make_unique< FakeRatePlots >(
117  this, "Tracks/FakeRates/Unlinked", m_anaTag, m_trkAnaDefSvc->testTag(),
118  true, m_trkAnaDefSvc->hasFullPileupTruth() );
119  }
120  }
121 
123  if( m_trkAnaDefSvc->plotDuplicateRates() ) {
124  m_plots_duplRate = std::make_unique< DuplicateRatePlots >(
125  this, "Tracks/Duplicates", m_anaTag, m_trkAnaDefSvc->referenceTag(),
126  true, m_trkAnaDefSvc->hasFullPileupTruth() );
127  }
128 
131  if( m_trkAnaDefSvc->plotHitsOnTracks() and not m_trkAnaDefSvc->isTestTruth() ) {
132  m_plots_hitsOnTrk_vsTest = std::make_unique< HitsOnTracksPlots >(
133  this, "Tracks/HitsOnTracks", m_anaTag,
134  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
135  true, m_trkAnaDefSvc->hasFullPileupTruth() );
136  }
137  if( m_trkAnaDefSvc->plotHitsOnTracksReference() and not m_trkAnaDefSvc->isReferenceTruth() ) {
138  m_plots_hitsOnTrk_vsRef = std::make_unique< HitsOnTracksPlots >(
139  this, "Tracks/HitsOnTracks", m_anaTag,
140  m_trkAnaDefSvc->referenceTag(), m_trkAnaDefSvc->isITk() );
141  }
143  if( m_trkAnaDefSvc->plotHitsOnMatchedTracks() and not m_trkAnaDefSvc->isTestTruth() ) {
144  m_plots_hitsOnMatchedTrk = std::make_unique< HitsOnTracksPlots >(
145  this, "Tracks/Resolutions/HitsOnTracks", m_anaTag,
146  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
147  true, m_trkAnaDefSvc->hasFullPileupTruth() );
148  m_plots_hitsOnMatchedTrk_vsRef = std::make_unique< HitsOnTracksPlots >(
149  this, "Tracks/Resolutions/HitsOnTracks", m_anaTag,
150  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->referenceTag(), m_trkAnaDefSvc->isITk() );
151  }
153  if( m_trkAnaDefSvc->plotHitsOnFakeTracks() and m_trkAnaDefSvc->isReferenceTruth() ) {
154  m_plots_hitsOnFakeTrk = std::make_unique< HitsOnTracksPlots >(
155  this, "Tracks/FakeRates/HitsOnTracks", m_anaTag,
156  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
157  true, m_trkAnaDefSvc->hasFullPileupTruth() );
158  if ( not m_trkAnaDefSvc->unlinkedAsFakes() ) {
159  m_plots_hitsOnUnlinkedTrk = std::make_unique< HitsOnTracksPlots >(
160  this, "Tracks/FakeRates/Unlinked/HitsOnTracks", m_anaTag,
161  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
162  true, m_trkAnaDefSvc->hasFullPileupTruth() );
163  }
164  }
165 
167  if( m_trkAnaDefSvc->plotOfflineElectrons() ) {
168  m_plots_offEle = std::make_unique< OfflineElectronPlots >(
169  this, "Tracks/Parameters", m_anaTag );
170  if( m_trkAnaDefSvc->plotEfficiencies() ) {
171  m_plots_eff_vsOffEle = std::make_unique< OfflineElectronPlots >(
172  this, "Tracks/Efficiencies", m_anaTag, true );
173  }
174  }
175 
177  if( m_trkAnaDefSvc->plotVertexParameters() ) {
179  m_plots_vtxParam_vsTest = std::make_unique< VertexParametersPlots >(
180  this, "Vertices/AllPrimary/Parameters", m_anaTag,
181  m_trkAnaDefSvc->testTag(),
182  not m_trkAnaDefSvc->isTestTruth() ); // do associated tracks plots for reco only
183  m_plots_vtxParam_vsRef = std::make_unique< VertexParametersPlots >(
184  this, "Vertices/AllPrimary/Parameters", m_anaTag,
185  m_trkAnaDefSvc->referenceTag(),
186  not m_trkAnaDefSvc->isReferenceTruth() ); // do associated tracks plots for reco only
187 
189  m_plots_nVtxParam_vsTest = std::make_unique< VertexParametersPlots >(
190  this, "Vertices/AllPrimary/Parameters", m_anaTag,
191  m_trkAnaDefSvc->testTag(), false,
192  true, m_trkAnaDefSvc->hasFullPileupTruth() );
193  m_plots_nVtxParam_vsRef = std::make_unique< VertexParametersPlots >(
194  this, "Vertices/AllPrimary/Parameters", m_anaTag,
195  m_trkAnaDefSvc->referenceTag(), false,
196  true, m_trkAnaDefSvc->hasFullPileupTruth() );
197  }
198 
201 
202  return StatusCode::SUCCESS;
203 }
204 
205 
210  TrackAnalysisCollections& trkAnaColls, float weight )
211 {
212  float actualMu = trkAnaColls.eventInfo() ?
213  trkAnaColls.eventInfo()->actualInteractionsPerCrossing() : -1.;
214  float truthMu = trkAnaColls.truthPileupEventContainer() ?
215  static_cast< float >( trkAnaColls.truthPileupEventContainer()->size() ) : -1.;
216 
218  if( m_trkAnaDefSvc->isTestTruth() ) {
219  ATH_CHECK( fillPlotsTest(
221  trkAnaColls.matches(),
223  truthMu, actualMu, weight ) );
224  } else {
225  ATH_CHECK( fillPlotsTest(
227  trkAnaColls.matches(),
229  truthMu, actualMu, weight ) );
230  }
231 
233  if( m_trkAnaDefSvc->isReferenceTruth() ) {
234  ATH_CHECK( fillPlotsReference(
236  trkAnaColls.matches(),
238  truthMu, actualMu, weight ) );
239  } else {
240  ATH_CHECK( fillPlotsReference(
242  trkAnaColls.matches(),
244  truthMu, actualMu, weight ) );
245  }
246 
248  if( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
249  ATH_CHECK( fillPlotsTruth(
253  trkAnaColls.matches(),
254  truthMu, actualMu, weight ) );
255  }
256 
258  std::vector< size_t > testTrackCounts = trkAnaColls.testTrackCounts();
259  std::vector< size_t > refTrackCounts = trkAnaColls.refTrackCounts();
260 
261  std::vector< size_t > testVertexCounts = trkAnaColls.testVertexCounts();
262  std::vector< size_t > refVertexCounts = trkAnaColls.refVertexCounts();
263 
264  if( m_plots_summary ) {
265  ATH_CHECK( m_plots_summary->fillPlots(
266  testTrackCounts, refTrackCounts,
267  trkAnaColls.isNewRoI(), weight ) );
268  }
269 
270  if( m_plots_nTracks_vsTest ) {
271  ATH_CHECK( m_plots_nTracks_vsTest->fillPlots(
272  testTrackCounts, testVertexCounts,
273  truthMu, actualMu, weight ) );
274  }
275 
276  if( m_plots_nTracks_vsRef ) {
277  ATH_CHECK( m_plots_nTracks_vsRef->fillPlots(
278  refTrackCounts, refVertexCounts,
279  truthMu, actualMu, weight ) );
280  }
281 
282  return StatusCode::SUCCESS;
283 }
284 
285 
289 template< typename PARTICLE, typename VERTEX >
291  const std::vector< const PARTICLE* >& particles,
292  const ITrackMatchingLookup& matches,
293  const std::vector< const VERTEX* >& vertices,
294  float truthMu, float actualMu, float weight )
295 {
297  for( const PARTICLE* particle : particles ) {
299  if( m_plots_trkParam_vsTest ) {
300  ATH_CHECK( m_plots_trkParam_vsTest->fillPlots( *particle, weight ) );
301  }
302 
304  if( m_plots_hitsOnTrk_vsTest ) {
305  ATH_CHECK( m_plots_hitsOnTrk_vsTest->fillPlots( *particle, truthMu, actualMu, weight ) );
306  }
307 
308  bool isMatched = matches.isTestMatched( *particle );
309 
311  if( m_plots_eff_vsTest ) {
312  ATH_CHECK( m_plots_eff_vsTest->fillPlots(
313  *particle, isMatched, truthMu, actualMu, weight ) );
314  }
315 
317  if( m_plots_tech_eff_vsTest ) {
318  if ( m_trkAnaDefSvc->isTestTruth() and
320  m_trkAnaDefSvc->minSilHits(),
321  m_trkAnaDefSvc->etaBins() ) ) {
322  ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
323  *particle, isMatched, truthMu, actualMu, weight ) );
324  }
325  else if ( m_trkAnaDefSvc->isReferenceTruth() ) {
326  bool isTechMatched = isMatched ?
327  nHitsSelVec( *(matches.getMatchedRefTruth( *particle )),
328  m_trkAnaDefSvc->minSilHits(),
329  m_trkAnaDefSvc->etaBins() ) : false;
330  ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
331  *particle, isTechMatched, truthMu, actualMu, weight ) );
332  }
333  else if ( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
334  const xAOD::TruthParticle* linkedTruth = getLinkedTruth(
335  *particle, m_trkAnaDefSvc->truthProbCut() );
336  bool isTechMatched = isMatched ?
337  nHitsSelVec( *linkedTruth,
338  m_trkAnaDefSvc->minSilHits(),
339  m_trkAnaDefSvc->etaBins() ) : false;
340  ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
341  *particle, isTechMatched, truthMu, actualMu, weight ) );
342  }
343  }
344 
346  if( m_plots_resolution ) {
347  if( isMatched ) {
348  if( m_trkAnaDefSvc->isReferenceTruth() ) {
349  ATH_CHECK( m_plots_resolution->fillPlots(
350  *particle, *(matches.getMatchedRefTruth( *particle )), weight ) );
351  } else {
352  ATH_CHECK( m_plots_resolution->fillPlots(
353  *particle, *(matches.getMatchedRefTrack( *particle )), weight ) );
354  }
355  }
356  }
357 
359  if( m_plots_hitsOnMatchedTrk and m_plots_hitsOnMatchedTrk_vsRef and isMatched ) {
360  ATH_CHECK( m_plots_hitsOnMatchedTrk->fillPlots( *particle, truthMu, actualMu, weight ) );
361  if( m_trkAnaDefSvc->isReferenceTruth() ) {
362  ATH_CHECK( m_plots_hitsOnMatchedTrk_vsRef->fillPlots(
363  *particle, *(matches.getMatchedRefTruth( *particle )), truthMu, actualMu, weight ) );
364  } else {
365  ATH_CHECK( m_plots_hitsOnMatchedTrk_vsRef->fillPlots(
366  *particle, *(matches.getMatchedRefTrack( *particle )), truthMu, actualMu, weight ) );
367  }
368  }
369 
371  bool isUnlinked = isUnlinkedTruth( *particle );
372  bool isFakeTruth = getTruthMatchProb( *particle ) < m_trkAnaDefSvc->truthProbCut();
373  if ( isUnlinked ) {
374  if( m_plots_missingTruth ) {
375  ATH_CHECK( m_plots_missingTruth->fillPlots( *particle, isFakeTruth, truthMu, actualMu, weight ) );
376  }
377  if( m_plots_hitsOnUnlinkedTrk ) {
378  ATH_CHECK( m_plots_hitsOnUnlinkedTrk->fillPlots( *particle, truthMu, actualMu, weight ) );
379  }
380  }
381 
382  bool doFakes = m_trkAnaDefSvc->unlinkedAsFakes() ? true : not isUnlinked;
383  if( doFakes and m_plots_fakeRate ) {
384  ATH_CHECK( m_plots_fakeRate->fillPlots( *particle, isFakeTruth, truthMu, actualMu, weight ) );
385  if( m_plots_hitsOnFakeTrk and isFakeTruth ) {
386  ATH_CHECK( m_plots_hitsOnFakeTrk->fillPlots( *particle, truthMu, actualMu, weight ) );
387  }
388  }
389 
391  if( m_trkAnaDefSvc->isTestOffline() ) {
392  if( m_plots_offEle ) {
393  ATH_CHECK( m_plots_offEle->fillPlots( *particle, false, weight ) );
394  }
395  if( m_plots_eff_vsOffEle ) {
396  ATH_CHECK( m_plots_eff_vsOffEle->fillPlots( *particle, isMatched, weight ) );
397  }
398  }
399 
400  } // close loop over particles
401 
403  int nGoodVertices(0);
404  for( const VERTEX* vertex : vertices ) {
406  if( vertexType( *vertex ) == xAOD::VxType::NoVtx ) {
407  ATH_MSG_DEBUG( "Found Dummy vertex. Skipping" );
408  continue;
409  }
410  nGoodVertices++;
411 
413  std::vector< const PARTICLE* > vtxTracks{};
414  std::vector< float > vtxTrackWeights{};
416  *vertex, vtxTracks, vtxTrackWeights,
417  particles, m_trkAnaDefSvc->useSelectedVertexTracks() ) ) {
418  ATH_MSG_WARNING( "Problem when retrieving vertex-assocciated tracks" );
419  if( not vtxTracks.empty() ) {
420  ATH_MSG_WARNING( "Invalid associated track links found. Check your input format." );
421  }
422  }
423 
425  if( m_plots_vtxParam_vsTest ) {
426  ATH_CHECK( m_plots_vtxParam_vsTest->fillPlots( *vertex, vtxTracks, vtxTrackWeights, weight ) );
427  }
428  }
429 
431  if( m_plots_nVtxParam_vsTest ) {
432  ATH_CHECK( m_plots_nVtxParam_vsTest->fillPlots( nGoodVertices, truthMu, actualMu, weight ) );
433  }
434 
435  return StatusCode::SUCCESS;
436 }
437 
438 template StatusCode
440  const std::vector< const xAOD::TrackParticle* >& particles,
441  const ITrackMatchingLookup& matches,
442  const std::vector< const xAOD::Vertex* >& vertices,
443  float truthMu, float actualMu, float weight );
444 
445 template StatusCode
447  const std::vector< const xAOD::TruthParticle* >& particles,
448  const ITrackMatchingLookup& matches,
449  const std::vector< const xAOD::TruthVertex* >& vertices,
450  float truthMu, float actualMu, float weight );
451 
452 
456 template< typename PARTICLE, typename VERTEX >
458  const std::vector< const PARTICLE* >& particles,
459  const ITrackMatchingLookup& matches,
460  const std::vector< const VERTEX* >& vertices,
461  float truthMu, float actualMu, float weight )
462 {
463 
464  for( const PARTICLE* particle : particles ) {
465 
467  if( m_plots_trkParam_vsRef ) {
468  ATH_CHECK( m_plots_trkParam_vsRef->fillPlots( *particle, weight ) );
469  }
470 
472  if( m_plots_hitsOnTrk_vsRef ) {
473  ATH_CHECK( m_plots_hitsOnTrk_vsRef->fillPlots( *particle, truthMu, actualMu, weight ) );
474  }
475 
476  bool isMatched = matches.isRefMatched( *particle );
477 
479  if( m_plots_eff_vsRef ) {
480  ATH_CHECK( m_plots_eff_vsRef->fillPlots(
481  *particle, isMatched, truthMu, actualMu, weight ) );
482  }
483 
485  if( m_plots_tech_eff_vsRef ) {
486  if( m_trkAnaDefSvc->isReferenceTruth() and
487  nHitsSelVec( *particle, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) )
488  {
489  ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
490  *particle, isMatched, truthMu, actualMu, weight ) );
491  }
492  else if ( m_trkAnaDefSvc->isTestTruth() ) {
493 
494  bool isTechMatched = false;
495 
496  if (isMatched) {
497  for ( const xAOD::TruthParticle *thisTruth : (matches.getMatchedTestTruths( *particle ))) {
498  if ( nHitsSelVec( *thisTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) ) {
499  isTechMatched = true;
500  break;
501  }
502  }
503  }
504  ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
505  *particle, isTechMatched, truthMu, actualMu, weight ) );
506  }
507 
508  else if ( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
509  const xAOD::TruthParticle* linkedTruth = getLinkedTruth(
510  *particle, m_trkAnaDefSvc->truthProbCut() );
511  bool isTechMatched = isMatched ?
512  nHitsSelVec( *linkedTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) : false;
513  ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
514  *particle, isTechMatched, truthMu, actualMu, weight ) );
515  }
516  }
517 
519  if( m_plots_duplRate ) {
520  unsigned int nMatched = m_trkAnaDefSvc->isTestTruth() ?
521  matches.getMatchedTestTruths( *particle ).size() :
522  matches.getMatchedTestTracks( *particle ).size();
523 
524  ATH_CHECK( m_plots_duplRate->fillPlots(
525  *particle, nMatched, truthMu, actualMu, weight ) );
526  }
527 
529  if( m_trkAnaDefSvc->isReferenceOffline() ) {
530  if( m_plots_offEle ) {
531  ATH_CHECK( m_plots_offEle->fillPlots( *particle, false, weight ) );
532  }
533  if( m_plots_eff_vsOffEle ) {
534  ATH_CHECK( m_plots_eff_vsOffEle->fillPlots( *particle, isMatched, weight ) );
535  }
536  }
537 
538  } // close loop over particles
539 
541  int nGoodVertices(0);
542  for( const VERTEX* vertex : vertices ) {
544  if( vertexType( *vertex ) == xAOD::VxType::NoVtx ) {
545  ATH_MSG_DEBUG( "Found Dummy vertex. Skipping" );
546  continue;
547  }
548  nGoodVertices++;
549 
551  std::vector< const PARTICLE* > vtxTracks{};
552  std::vector< float > vtxTrackWeights{};
554  *vertex, vtxTracks, vtxTrackWeights,
555  particles, m_trkAnaDefSvc->useSelectedVertexTracks() ) ) {
556  ATH_MSG_WARNING( "Problem when retrieving vertex-assocciated tracks" );
557  if( not vtxTracks.empty() ) {
558  ATH_MSG_WARNING( "Invalid associated track links found. Check your input format." );
559  }
560  }
561 
563  if( m_plots_vtxParam_vsRef ) {
564  ATH_CHECK( m_plots_vtxParam_vsRef->fillPlots( *vertex, vtxTracks, vtxTrackWeights, weight ) );
565  }
566  }
567 
569  if( m_plots_nVtxParam_vsRef ) {
570  ATH_CHECK( m_plots_nVtxParam_vsRef->fillPlots( nGoodVertices, truthMu, actualMu, weight ) );
571  }
572 
573  return StatusCode::SUCCESS;
574 }
575 
576 template StatusCode
578  const std::vector< const xAOD::TrackParticle* >& particles,
579  const ITrackMatchingLookup& matches,
580  const std::vector< const xAOD::Vertex* >& vertices,
581  float truthMu, float actualMu, float weight );
582 
583 template StatusCode
585  const std::vector< const xAOD::TruthParticle* >& particles,
586  const ITrackMatchingLookup& matches,
587  const std::vector< const xAOD::TruthVertex* >& vertices,
588  float truthMu, float actualMu, float weight );
589 
590 
595  const std::vector< const xAOD::TrackParticle* >& testTracks,
596  const std::vector< const xAOD::TrackParticle* >& refTracks,
597  const std::vector< const xAOD::TruthParticle* >& truths,
598  const ITrackMatchingLookup& matches,
599  float truthMu, float actualMu, float weight )
600 {
601 
602  for( const xAOD::TruthParticle* thisTruth : truths ) {
603 
604  bool isMatched( false ); // test track matched to reference track through EFTruthMatch method
605  bool refMatched( false ); // reference track matched to thisTruth
606 
608  for( const xAOD::TrackParticle* thisTrack : refTracks ) {
609  const xAOD::TruthParticle* linkedTruth = getLinkedTruth(
610  *thisTrack, m_trkAnaDefSvc->truthProbCut() );
611  if( not linkedTruth ) {
612  ATH_MSG_WARNING( "Unlinked track!!" );
613  continue;
614  }
615  if( thisTruth == linkedTruth ) {
616  refMatched = true;
617  break;
618  }
619  } // close loop over reference tracks
620 
622  if ( not refMatched ) continue;
623 
624  else {
625 
627  for( const xAOD::TrackParticle* thisTrack : testTracks ) {
628  const xAOD::TruthParticle* linkedTruth = getLinkedTruth(
629  *thisTrack, m_trkAnaDefSvc->truthProbCut() );
630  if( not linkedTruth ) {
631  ATH_MSG_WARNING( "Unlinked track!!" );
632  continue;
633  }
634  if( thisTruth == linkedTruth ) {
635  isMatched = matches.isTestMatched( *thisTrack ); // Check if this test is matched to reference with EFTruthMatch
636  break;
637  }
638  } // close loop over test tracks
639 
641  if( m_plots_eff_vsTruth ) {
642  ATH_CHECK( m_plots_eff_vsTruth->fillPlots(
643  *thisTruth, isMatched, truthMu, actualMu, weight ) );
644  }
645 
647  if( m_plots_tech_eff_vsTruth ) {
648  if (nHitsSelVec( *thisTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() )) {
649  ATH_CHECK( m_plots_tech_eff_vsTruth->fillPlots(
650  *thisTruth, isMatched , truthMu, actualMu, weight ) );
651  }
652  }
653  }
654  } // close loop over truth particles
655 
656  return StatusCode::SUCCESS;
657 }
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:79
IDTPM::nHitsSelVec
bool nHitsSelVec(const PARTICLE &p, const std::vector< unsigned int > &minHits, const std::vector< float > &etaBins)
Definition: OfflineObjectDecorHelper.h:107
IDTPM::getTruthMatchProb
float getTruthMatchProb(const xAOD::TrackParticle &track)
getTruthMatchProb
Definition: OfflineObjectDecorHelper.cxx:77
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
IDTPM::TrackAnalysisCollections
Definition: TrackAnalysisCollections.h:46
IDTPM::getLinkedTruth
const xAOD::TruthParticle * getLinkedTruth(const xAOD::TrackParticle &track, const float truthProbCut)
getLinkedTruth
Definition: OfflineObjectDecorHelper.cxx:85
IDTPM::ITrackMatchingLookup::getMatchedTestTruths
virtual const std::vector< const xAOD::TruthParticle * > & getMatchedTestTruths(const xAOD::TrackParticle &r) const =0
vec Truth <- Track
IDTPM::TrackAnalysisPlotsMgr::fillPlotsTruth
StatusCode fillPlotsTruth(const std::vector< const xAOD::TrackParticle * > &testTracks, const std::vector< const xAOD::TrackParticle * > &refTracks, const std::vector< const xAOD::TruthParticle * > &truths, const ITrackMatchingLookup &matches, float truthMu=0., float actualMu=0., float weight=1.0)
Fill efficiency plots w.r.t. truth (for EFTruthMatch only)
Definition: TrackAnalysisPlotsMgr.cxx:594
fillPlotsTest< xAOD::TrackParticle, xAOD::Vertex >
template StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsTest< xAOD::TrackParticle, xAOD::Vertex >(const std::vector< const xAOD::TrackParticle * > &particles, const ITrackMatchingLookup &matches, const std::vector< const xAOD::Vertex * > &vertices, float truthMu, float actualMu, float weight)
IDTPM::TrackAnalysisCollections::testVertexCounts
std::vector< size_t > testVertexCounts()
get counts vectors for TEST/REFERENCE vertex vectors at all stages
Definition: TrackAnalysisCollections.cxx:996
IDTPM::TrackAnalysisCollections::eventInfo
const xAOD::EventInfo * eventInfo()
get event info
Definition: TrackAnalysisCollections.h:200
InDetSecVtxTruthMatchUtils::isMatched
bool isMatched(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:75
IDTPM::TrackAnalysisCollections::refTruthVertexVec
const std::vector< const xAOD::TruthVertex * > & refTruthVertexVec(Stage stage=FULL)
get REFERENCE vertex vectors
Definition: TrackAnalysisCollections.cxx:963
TrackAnalysisCollections.h
Class to hold for each event collections needed in the TrkAnalsis.
PrintTrkAnaSummary.dirName
dirName
Definition: PrintTrkAnaSummary.py:275
TrackAnalysisPlotsMgr.h
class to manage (book, fill) all the plots for the processed TrackAnalysis for tracking performance v...
IDTPM::ITrackMatchingLookup::getMatchedRefTrack
virtual const xAOD::TrackParticle * getMatchedRefTrack(const xAOD::TrackParticle &t) const =0
get matched reference (1 to 1) Track -> Track
xAOD::VxType::NoVtx
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
Definition: TrackingPrimitives.h:571
IDTPM::ITrackMatchingLookup::getMatchedRefTruth
virtual const xAOD::TruthParticle * getMatchedRefTruth(const xAOD::TrackParticle &t) const =0
Track -> Truth.
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
IDTPM::TrackAnalysisPlotsMgr::fillPlotsTest
StatusCode fillPlotsTest(const std::vector< const PARTICLE * > &particles, const ITrackMatchingLookup &matches, const std::vector< const VERTEX * > &vertices, float truthMu=0., float actualMu=0., float weight=1.0)
Fill all plots w.r.t.
Definition: TrackAnalysisPlotsMgr.cxx:290
IDTPM::TrackAnalysisCollections::testTrackVec
const std::vector< const xAOD::TrackParticle * > & testTrackVec(Stage stage=FULL)
TEST = Track.
Definition: TrackAnalysisCollections.cxx:789
IDTPM::ITrackMatchingLookup::getMatchedTestTracks
virtual const std::vector< const xAOD::TrackParticle * > & getMatchedTestTracks(const xAOD::TrackParticle &r) const =0
get matched test vector (1 to 1+) vec Track <- Track
TrackParametersHelper.h
Utility methods to access track/truth particles parmeters in a consitent way in this package.
IDTPM::PlotMgr
Definition: PlotMgr.h:33
IDTPM::TrackAnalysisPlotsMgr::fillPlotsReference
StatusCode fillPlotsReference(const std::vector< const PARTICLE * > &particles, const ITrackMatchingLookup &matches, const std::vector< const VERTEX * > &vertices, float truthMu=0., float actualMu=0., float weight=1.0)
Fill all plots w.r.t.
Definition: TrackAnalysisPlotsMgr.cxx:457
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
IDTPM::TrackAnalysisCollections::testRecoVertexVec
const std::vector< const xAOD::Vertex * > & testRecoVertexVec(Stage stage=FULL)
TEST = Reco.
Definition: TrackAnalysisCollections.cxx:946
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
IDTPM::TrackAnalysisCollections::truthPileupEventContainer
const xAOD::TruthPileupEventContainer * truthPileupEventContainer()
Definition: TrackAnalysisCollections.h:202
IDTPM::ITrackMatchingLookup::isTestMatched
virtual bool isTestMatched(const xAOD::TrackParticle &t) const =0
return true if test is matched
IDTPM::TrackAnalysisCollections::matches
ITrackMatchingLookup & matches()
get track matching information
Definition: TrackAnalysisCollections.h:277
IDTPM::TrackAnalysisCollections::testTrackCounts
std::vector< size_t > testTrackCounts()
get counts vectors for TEST/REFERENCE track vectors at all stages
Definition: TrackAnalysisCollections.cxx:839
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ITrackMatchingLookup.h
Interace for TrackMatchingLookup objects (templated)
IDTPM::ITrackMatchingLookup::isRefMatched
virtual bool isRefMatched(const xAOD::TrackParticle &r) const =0
return true if reference is matched
IDTPM::TrackAnalysisCollections::testTruthVertexVec
const std::vector< const xAOD::TruthVertex * > & testTruthVertexVec(Stage stage=FULL)
get TEST vertex vectors
Definition: TrackAnalysisCollections.cxx:933
fillPlotsTest< xAOD::TruthParticle, xAOD::TruthVertex >
template StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsTest< xAOD::TruthParticle, xAOD::TruthVertex >(const std::vector< const xAOD::TruthParticle * > &particles, const ITrackMatchingLookup &matches, const std::vector< const xAOD::TruthVertex * > &vertices, float truthMu, float actualMu, float weight)
IDTPM::TrackAnalysisCollections::isNewRoI
bool isNewRoI()
check if this is a new RoI
Definition: TrackAnalysisCollections.h:174
IDTPM::TrackAnalysisCollections::refTrackCounts
std::vector< size_t > refTrackCounts()
REFERENCE.
Definition: TrackAnalysisCollections.cxx:857
IDTPM::TrackAnalysisCollections::refTrackVec
const std::vector< const xAOD::TrackParticle * > & refTrackVec(Stage stage=FULL)
TEST = Track.
Definition: TrackAnalysisCollections.cxx:819
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
IDTPM::getVertexTracksAndWeights
bool getVertexTracksAndWeights(const xAOD::Vertex &vtx, std::vector< const xAOD::TrackParticle * > &vtxTracks, std::vector< float > &vtxTrackWeights, const std::vector< const xAOD::TrackParticle * > &selTracks, bool useSelected)
getVertexTracksAndWeights
Definition: OfflineObjectDecorHelper.cxx:108
IDTPM::TrackAnalysisPlotsMgr::TrackAnalysisPlotsMgr
TrackAnalysisPlotsMgr(const std::string &dirName, const std::string &anaTag, const std::string &chain, PlotMgr *pParent=nullptr)
Constructor.
Definition: TrackAnalysisPlotsMgr.cxx:26
IDTPM::TrackAnalysisPlotsMgr::fill
StatusCode fill(TrackAnalysisCollections &trkAnaColls, float weight=1.0)
General fill method.
Definition: TrackAnalysisPlotsMgr.cxx:209
IDTPM::TrackAnalysisCollections::refVertexCounts
std::vector< size_t > refVertexCounts()
REFERENCE.
Definition: TrackAnalysisCollections.cxx:1014
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
IDTPM::TrackAnalysisCollections::InRoI
@ InRoI
Definition: TrackAnalysisCollections.h:54
IDTPM::vertexType
int vertexType(const V &v)
Definition: VertexParametersHelper.h:69
IDTPM::TrackAnalysisCollections::truthPartVec
const std::vector< const xAOD::TruthParticle * > & truthPartVec(Stage stage=FULL)
get truth/offline/trigger track vector (TEST or REFERENCE)
Definition: TrackAnalysisCollections.h:229
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
IDTPM::TrackAnalysisCollections::testTruthVec
const std::vector< const xAOD::TruthParticle * > & testTruthVec(Stage stage=FULL)
get TEST track vectors
Definition: TrackAnalysisCollections.cxx:776
fillPlotsReference< xAOD::TruthParticle, xAOD::TruthVertex >
template StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsReference< xAOD::TruthParticle, xAOD::TruthVertex >(const std::vector< const xAOD::TruthParticle * > &particles, const ITrackMatchingLookup &matches, const std::vector< const xAOD::TruthVertex * > &vertices, float truthMu, float actualMu, float weight)
IDTPM::TrackAnalysisPlotsMgr::initialize
StatusCode initialize()
initialize
Definition: TrackAnalysisPlotsMgr.cxx:39
IDTPM::PlotMgr::initialize
StatusCode initialize()
initialize
Definition: PlotMgr.cxx:37
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
OfflineObjectDecorHelper.h
Utility methods to access offline object decorations.
IDTPM::ITrackMatchingLookup
Definition: ITrackMatchingLookup.h:30
IDTPM::TrackAnalysisCollections::refRecoVertexVec
const std::vector< const xAOD::Vertex * > & refRecoVertexVec(Stage stage=FULL)
REFERENCE = Reco.
Definition: TrackAnalysisCollections.cxx:976
fillPlotsReference< xAOD::TrackParticle, xAOD::Vertex >
template StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsReference< xAOD::TrackParticle, xAOD::Vertex >(const std::vector< const xAOD::TrackParticle * > &particles, const ITrackMatchingLookup &matches, const std::vector< const xAOD::Vertex * > &vertices, float truthMu, float actualMu, float weight)
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
IDTPM::isUnlinkedTruth
bool isUnlinkedTruth(const xAOD::TrackParticle &track)
isUnlinkedTruth
Definition: OfflineObjectDecorHelper.cxx:69
xAOD::EventInfo_v1::actualInteractionsPerCrossing
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
Definition: EventInfo_v1.cxx:380
IDTPM::TrackAnalysisCollections::refTruthVec
const std::vector< const xAOD::TruthParticle * > & refTruthVec(Stage stage=FULL)
get REFERENCE track vectors
Definition: TrackAnalysisCollections.cxx:806