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->plotTrackParameters() ) {
49  m_plots_trkParam_vsTest = std::make_unique< TrackParametersPlots >(
50  this, "Tracks/Parameters", m_anaTag, m_trkAnaDefSvc->testTag() );
51  m_plots_trkParam_vsRef = std::make_unique< TrackParametersPlots >(
52  this, "Tracks/Parameters", m_anaTag, m_trkAnaDefSvc->referenceTag() );
53  }
54 
56  if( m_trkAnaDefSvc->plotTrackMultiplicities() ) {
57  m_plots_nTracks_vsTest = std::make_unique< NtracksPlots >(
58  this, "Tracks/Multiplicities", m_anaTag, m_trkAnaDefSvc->testTag(),
59  m_trkAnaDefSvc->useTrigger() and not m_trkAnaDefSvc->useEFTrigger(),
60  true, m_trkAnaDefSvc->hasFullPileupTruth() );
61  m_plots_nTracks_vsRef = std::make_unique< NtracksPlots >(
62  this, "Tracks/Multiplicities", m_anaTag, m_trkAnaDefSvc->referenceTag(),
63  m_trkAnaDefSvc->useTrigger() and not m_trkAnaDefSvc->useEFTrigger() );
64  }
65 
67  if( m_trkAnaDefSvc->plotEfficiencies() ) {
68  m_plots_eff_vsTest = std::make_unique< EfficiencyPlots >(
69  this, "Tracks/Efficiencies", m_anaTag, m_trkAnaDefSvc->testTag() );
70  m_plots_eff_vsRef = std::make_unique< EfficiencyPlots >(
71  this, "Tracks/Efficiencies", m_anaTag, m_trkAnaDefSvc->referenceTag(),
72  true, m_trkAnaDefSvc->hasFullPileupTruth() );
73  if( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
74  m_plots_eff_vsTruth = std::make_unique< EfficiencyPlots >(
75  this, "Tracks/Efficiencies", m_anaTag, "truth" );
76  }
77  }
78 
80  if( m_trkAnaDefSvc->plotTechnicalEfficiencies()) {
81  m_plots_tech_eff_vsTest = std::make_unique< EfficiencyPlots >(
82  this, "Tracks/Efficiencies/Technical", m_anaTag, m_trkAnaDefSvc->testTag());
83  m_plots_tech_eff_vsRef = std::make_unique< EfficiencyPlots >(
84  this, "Tracks/Efficiencies/Technical", m_anaTag, m_trkAnaDefSvc->referenceTag(),
85  true, m_trkAnaDefSvc->hasFullPileupTruth() );
86  if( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
87  m_plots_tech_eff_vsTruth = std::make_unique< EfficiencyPlots >(
88  this, "Tracks/Efficiencies/Technical", m_anaTag, "truth" );
89  }
90  }
91 
93  if( m_trkAnaDefSvc->plotResolutions() ) {
94  m_plots_resolution = std::make_unique< ResolutionPlots >(
95  this, "Tracks/Resolutions", m_anaTag,
96  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->referenceTag(),
97  m_trkAnaDefSvc->resolutionMethod() );
98  }
99 
101  if( m_trkAnaDefSvc->plotFakeRates() and m_trkAnaDefSvc->isReferenceTruth() ) {
102  m_plots_fakeRate = std::make_unique< FakeRatePlots >(
103  this, "Tracks/FakeRates", m_anaTag, m_trkAnaDefSvc->testTag(),
104  true, m_trkAnaDefSvc->hasFullPileupTruth() );
105  if ( not m_trkAnaDefSvc->unlinkedAsFakes() ) {
106  m_plots_missingTruth = std::make_unique< FakeRatePlots >(
107  this, "Tracks/FakeRates/Unlinked", m_anaTag, m_trkAnaDefSvc->testTag(),
108  true, m_trkAnaDefSvc->hasFullPileupTruth() );
109  }
110  }
111 
113  if( m_trkAnaDefSvc->plotDuplicateRates() ) {
114  m_plots_duplRate = std::make_unique< DuplicateRatePlots >(
115  this, "Tracks/Duplicates", m_anaTag, m_trkAnaDefSvc->referenceTag(),
116  true, m_trkAnaDefSvc->hasFullPileupTruth() );
117  }
118 
121  if( m_trkAnaDefSvc->plotHitsOnTracks() and not m_trkAnaDefSvc->isTestTruth() ) {
122  m_plots_hitsOnTrk_vsTest = std::make_unique< HitsOnTracksPlots >(
123  this, "Tracks/HitsOnTracks", m_anaTag,
124  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
125  true, m_trkAnaDefSvc->hasFullPileupTruth() );
126  }
127  if( m_trkAnaDefSvc->plotHitsOnTracksReference() and not m_trkAnaDefSvc->isReferenceTruth() ) {
128  m_plots_hitsOnTrk_vsRef = std::make_unique< HitsOnTracksPlots >(
129  this, "Tracks/HitsOnTracks", m_anaTag,
130  m_trkAnaDefSvc->referenceTag(), m_trkAnaDefSvc->isITk() );
131  }
133  if( m_trkAnaDefSvc->plotHitsOnMatchedTracks() and not m_trkAnaDefSvc->isTestTruth() ) {
134  m_plots_hitsOnMatchedTrk = std::make_unique< HitsOnTracksPlots >(
135  this, "Tracks/Resolutions/HitsOnTracks", m_anaTag,
136  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
137  true, m_trkAnaDefSvc->hasFullPileupTruth() );
138  m_plots_hitsOnMatchedTrk_vsRef = std::make_unique< HitsOnTracksPlots >(
139  this, "Tracks/Resolutions/HitsOnTracks", m_anaTag,
140  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->referenceTag(), m_trkAnaDefSvc->isITk() );
141  }
143  if( m_trkAnaDefSvc->plotHitsOnFakeTracks() and m_trkAnaDefSvc->isReferenceTruth() ) {
144  m_plots_hitsOnFakeTrk = std::make_unique< HitsOnTracksPlots >(
145  this, "Tracks/FakeRates/HitsOnTracks", m_anaTag,
146  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
147  true, m_trkAnaDefSvc->hasFullPileupTruth() );
148  if ( not m_trkAnaDefSvc->unlinkedAsFakes() ) {
149  m_plots_hitsOnUnlinkedTrk = std::make_unique< HitsOnTracksPlots >(
150  this, "Tracks/FakeRates/Unlinked/HitsOnTracks", m_anaTag,
151  m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
152  true, m_trkAnaDefSvc->hasFullPileupTruth() );
153  }
154  }
155 
157  if( m_trkAnaDefSvc->plotOfflineElectrons() ) {
158  m_plots_offEle = std::make_unique< OfflineElectronPlots >(
159  this, "Tracks/Parameters", m_anaTag );
160  if( m_trkAnaDefSvc->plotEfficiencies() ) {
161  m_plots_eff_vsOffEle = std::make_unique< OfflineElectronPlots >(
162  this, "Tracks/Efficiencies", m_anaTag, true );
163  }
164  }
165 
167  if( m_trkAnaDefSvc->plotVertexParameters() ) {
169  m_plots_vtxParam_vsTest = std::make_unique< VertexParametersPlots >(
170  this, "Vertices/AllPrimary/Parameters", m_anaTag,
171  m_trkAnaDefSvc->testTag(),
172  not m_trkAnaDefSvc->isTestTruth() ); // do associated tracks plots for reco only
173  m_plots_vtxParam_vsRef = std::make_unique< VertexParametersPlots >(
174  this, "Vertices/AllPrimary/Parameters", m_anaTag,
175  m_trkAnaDefSvc->referenceTag(),
176  not m_trkAnaDefSvc->isReferenceTruth() ); // do associated tracks plots for reco only
177 
179  m_plots_nVtxParam_vsTest = std::make_unique< VertexParametersPlots >(
180  this, "Vertices/AllPrimary/Parameters", m_anaTag,
181  m_trkAnaDefSvc->testTag(), false,
182  true, m_trkAnaDefSvc->hasFullPileupTruth() );
183  m_plots_nVtxParam_vsRef = std::make_unique< VertexParametersPlots >(
184  this, "Vertices/AllPrimary/Parameters", m_anaTag,
185  m_trkAnaDefSvc->referenceTag(), false,
186  true, m_trkAnaDefSvc->hasFullPileupTruth() );
187  }
188 
191 
192  return StatusCode::SUCCESS;
193 }
194 
195 
200  TrackAnalysisCollections& trkAnaColls, float weight )
201 {
202  float actualMu = trkAnaColls.eventInfo() ?
203  trkAnaColls.eventInfo()->actualInteractionsPerCrossing() : -1.;
204  float truthMu = trkAnaColls.truthPileupEventContainer() ?
205  static_cast< float >( trkAnaColls.truthPileupEventContainer()->size() ) : -1.;
206 
208  if( m_trkAnaDefSvc->isTestTruth() ) {
209  ATH_CHECK( fillPlotsTest(
211  trkAnaColls.matches(),
213  truthMu, actualMu, weight ) );
214  } else {
215  ATH_CHECK( fillPlotsTest(
217  trkAnaColls.matches(),
219  truthMu, actualMu, weight ) );
220  }
221 
223  if( m_trkAnaDefSvc->isReferenceTruth() ) {
224  ATH_CHECK( fillPlotsReference(
226  trkAnaColls.matches(),
228  truthMu, actualMu, weight ) );
229  } else {
230  ATH_CHECK( fillPlotsReference(
232  trkAnaColls.matches(),
234  truthMu, actualMu, weight ) );
235  }
236 
238  if( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
239  ATH_CHECK( fillPlotsTruth(
243  trkAnaColls.matches(),
244  truthMu, actualMu, weight ) );
245  }
246 
248  std::vector< size_t > testTrackCounts = trkAnaColls.testTrackCounts();
249  std::vector< size_t > refTrackCounts = trkAnaColls.refTrackCounts();
250 
251  std::vector< size_t > testVertexCounts = trkAnaColls.testVertexCounts();
252  std::vector< size_t > refVertexCounts = trkAnaColls.refVertexCounts();
253 
254  if( m_plots_nTracks_vsTest ) {
255  ATH_CHECK( m_plots_nTracks_vsTest->fillPlots(
256  testTrackCounts, testVertexCounts,
257  truthMu, actualMu, weight ) );
258  }
259 
260  if( m_plots_nTracks_vsRef ) {
261  ATH_CHECK( m_plots_nTracks_vsRef->fillPlots(
262  refTrackCounts, refVertexCounts,
263  truthMu, actualMu, weight ) );
264  }
265 
266  return StatusCode::SUCCESS;
267 }
268 
269 
273 template< typename PARTICLE, typename VERTEX >
275  const std::vector< const PARTICLE* >& particles,
276  const ITrackMatchingLookup& matches,
277  const std::vector< const VERTEX* >& vertices,
278  float truthMu, float actualMu, float weight )
279 {
281  for( const PARTICLE* particle : particles ) {
283  if( m_plots_trkParam_vsTest ) {
284  ATH_CHECK( m_plots_trkParam_vsTest->fillPlots( *particle, weight ) );
285  }
286 
288  if( m_plots_hitsOnTrk_vsTest ) {
289  ATH_CHECK( m_plots_hitsOnTrk_vsTest->fillPlots( *particle, truthMu, actualMu, weight ) );
290  }
291 
292  bool isMatched = matches.isTestMatched( *particle );
293 
295  if( m_plots_eff_vsTest ) {
296  ATH_CHECK( m_plots_eff_vsTest->fillPlots(
297  *particle, isMatched, truthMu, actualMu, weight ) );
298  }
299 
301  if( m_plots_tech_eff_vsTest ) {
302  if ( m_trkAnaDefSvc->isTestTruth() and
304  m_trkAnaDefSvc->minSilHits(),
305  m_trkAnaDefSvc->etaBins() ) ) {
306  ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
307  *particle, isMatched, truthMu, actualMu, weight ) );
308  }
309  else if ( m_trkAnaDefSvc->isReferenceTruth() ) {
310  bool isTechMatched = isMatched ?
312  m_trkAnaDefSvc->minSilHits(),
313  m_trkAnaDefSvc->etaBins() ) : false;
314  ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
315  *particle, isTechMatched, truthMu, actualMu, weight ) );
316  }
317  else if ( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
318  const xAOD::TruthParticle* linkedTruth = getLinkedTruth(
319  *particle, m_trkAnaDefSvc->truthProbCut() );
320  bool isTechMatched = isMatched ?
321  isReconstructable( *linkedTruth,
322  m_trkAnaDefSvc->minSilHits(),
323  m_trkAnaDefSvc->etaBins() ) : false;
324  ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
325  *particle, isTechMatched, truthMu, actualMu, weight ) );
326  }
327  }
328 
330  if( m_plots_resolution ) {
331  if( isMatched ) {
332  if( m_trkAnaDefSvc->isReferenceTruth() ) {
333  ATH_CHECK( m_plots_resolution->fillPlots(
334  *particle, *(matches.getMatchedRefTruth( *particle )), weight ) );
335  } else {
336  ATH_CHECK( m_plots_resolution->fillPlots(
337  *particle, *(matches.getMatchedRefTrack( *particle )), weight ) );
338  }
339  }
340  }
341 
343  if( m_plots_hitsOnMatchedTrk and m_plots_hitsOnMatchedTrk_vsRef and isMatched ) {
344  ATH_CHECK( m_plots_hitsOnMatchedTrk->fillPlots( *particle, truthMu, actualMu, weight ) );
345  if( m_trkAnaDefSvc->isReferenceTruth() ) {
346  ATH_CHECK( m_plots_hitsOnMatchedTrk_vsRef->fillPlots(
347  *particle, *(matches.getMatchedRefTruth( *particle )), truthMu, actualMu, weight ) );
348  } else {
349  ATH_CHECK( m_plots_hitsOnMatchedTrk_vsRef->fillPlots(
350  *particle, *(matches.getMatchedRefTrack( *particle )), truthMu, actualMu, weight ) );
351  }
352  }
353 
355  bool isUnlinked = isUnlinkedTruth( *particle );
356  bool notTruthMatched = getTruthMatchProb( *particle ) < 0.5;
357  if ( isUnlinked ) {
358  if( m_plots_missingTruth ) {
359  ATH_CHECK( m_plots_missingTruth->fillPlots( *particle, notTruthMatched, truthMu, actualMu, weight ) );
360  }
361  if( m_plots_hitsOnUnlinkedTrk ) {
362  ATH_CHECK( m_plots_hitsOnUnlinkedTrk->fillPlots( *particle, truthMu, actualMu, weight ) );
363  }
364  }
365 
366  bool doFakes = m_trkAnaDefSvc->unlinkedAsFakes() ? true : not isUnlinked;
367  if( doFakes and m_plots_fakeRate ) {
368  bool isFake = isFakeTruth( *particle, m_trkAnaDefSvc->truthProbCut(),
369  m_trkAnaDefSvc->unlinkedAsFakes() );
370  ATH_CHECK( m_plots_fakeRate->fillPlots( *particle, isFake, truthMu, actualMu, weight ) );
371  if( m_plots_hitsOnFakeTrk and isFake ) {
372  ATH_CHECK( m_plots_hitsOnFakeTrk->fillPlots( *particle, truthMu, actualMu, weight ) );
373  }
374  }
375 
377  if( m_trkAnaDefSvc->isTestOffline() ) {
378  if( m_plots_offEle ) {
379  ATH_CHECK( m_plots_offEle->fillPlots( *particle, false, weight ) );
380  }
381  if( m_plots_eff_vsOffEle ) {
382  ATH_CHECK( m_plots_eff_vsOffEle->fillPlots( *particle, isMatched, weight ) );
383  }
384  }
385 
386  } // close loop over particles
387 
389  int nGoodVertices(0);
390  for( const VERTEX* vertex : vertices ) {
392  if( vertexType( *vertex ) == xAOD::VxType::NoVtx ) {
393  ATH_MSG_DEBUG( "Found Dummy vertex. Skipping" );
394  continue;
395  }
396  nGoodVertices++;
397 
399  std::vector< const PARTICLE* > vtxTracks{};
400  std::vector< float > vtxTrackWeights{};
402  *vertex, vtxTracks, vtxTrackWeights,
403  particles, m_trkAnaDefSvc->useSelectedVertexTracks() ) ) {
404  ATH_MSG_WARNING( "Problem when retrieving vertex-assocciated tracks" );
405  if( not vtxTracks.empty() ) {
406  ATH_MSG_WARNING( "Invalid associated track links found. Check your input format." );
407  }
408  }
409 
411  if( m_plots_vtxParam_vsTest ) {
412  ATH_CHECK( m_plots_vtxParam_vsTest->fillPlots( *vertex, vtxTracks, vtxTrackWeights, weight ) );
413  }
414  }
415 
417  if( m_plots_nVtxParam_vsTest ) {
418  ATH_CHECK( m_plots_nVtxParam_vsTest->fillPlots( nGoodVertices, truthMu, actualMu, weight ) );
419  }
420 
421  return StatusCode::SUCCESS;
422 }
423 
424 template StatusCode
426  const std::vector< const xAOD::TrackParticle* >& particles,
427  const ITrackMatchingLookup& matches,
428  const std::vector< const xAOD::Vertex* >& vertices,
429  float truthMu, float actualMu, float weight );
430 
431 template StatusCode
433  const std::vector< const xAOD::TruthParticle* >& particles,
434  const ITrackMatchingLookup& matches,
435  const std::vector< const xAOD::TruthVertex* >& vertices,
436  float truthMu, float actualMu, float weight );
437 
438 
442 template< typename PARTICLE, typename VERTEX >
444  const std::vector< const PARTICLE* >& particles,
445  const ITrackMatchingLookup& matches,
446  const std::vector< const VERTEX* >& vertices,
447  float truthMu, float actualMu, float weight )
448 {
449 
450  for( const PARTICLE* particle : particles ) {
451 
453  if( m_plots_trkParam_vsRef ) {
454  ATH_CHECK( m_plots_trkParam_vsRef->fillPlots( *particle, weight ) );
455  }
456 
458  if( m_plots_hitsOnTrk_vsRef ) {
459  ATH_CHECK( m_plots_hitsOnTrk_vsRef->fillPlots( *particle, truthMu, actualMu, weight ) );
460  }
461 
462  bool isMatched = matches.isRefMatched( *particle );
463 
465  if( m_plots_eff_vsRef ) {
466  ATH_CHECK( m_plots_eff_vsRef->fillPlots(
467  *particle, isMatched, truthMu, actualMu, weight ) );
468  }
469 
471  if( m_plots_tech_eff_vsRef ) {
472  if( m_trkAnaDefSvc->isReferenceTruth() and
473  isReconstructable( *particle, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) )
474  {
475  ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
476  *particle, isMatched, truthMu, actualMu, weight ) );
477  }
478  else if ( m_trkAnaDefSvc->isTestTruth() ) {
479 
480  bool isTechMatched = false;
481 
482  if (isMatched) {
483  for ( const xAOD::TruthParticle *thisTruth : (matches.getMatchedTestTruths( *particle ))) {
484  if ( isReconstructable( *thisTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) ) {
485  isTechMatched = true;
486  break;
487  }
488  }
489  }
490  ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
491  *particle, isTechMatched, truthMu, actualMu, weight ) );
492  }
493 
494  else if ( m_trkAnaDefSvc->matchingType() == "EFTruthMatch" ) {
495  const xAOD::TruthParticle* linkedTruth = getLinkedTruth(
496  *particle, m_trkAnaDefSvc->truthProbCut() );
497  bool isTechMatched = isMatched ?
498  isReconstructable( *linkedTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) : false;
499  ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
500  *particle, isTechMatched, truthMu, actualMu, weight ) );
501  }
502  }
503 
505  if( m_plots_duplRate ) {
506  unsigned int nMatched = m_trkAnaDefSvc->isTestTruth() ?
507  matches.getMatchedTestTruths( *particle ).size() :
508  matches.getMatchedTestTracks( *particle ).size();
509 
510  ATH_CHECK( m_plots_duplRate->fillPlots(
511  *particle, nMatched, truthMu, actualMu, weight ) );
512  }
513 
515  if( m_trkAnaDefSvc->isReferenceOffline() ) {
516  if( m_plots_offEle ) {
517  ATH_CHECK( m_plots_offEle->fillPlots( *particle, false, weight ) );
518  }
519  if( m_plots_eff_vsOffEle ) {
520  ATH_CHECK( m_plots_eff_vsOffEle->fillPlots( *particle, isMatched, weight ) );
521  }
522  }
523 
524  } // close loop over particles
525 
527  int nGoodVertices(0);
528  for( const VERTEX* vertex : vertices ) {
530  if( vertexType( *vertex ) == xAOD::VxType::NoVtx ) {
531  ATH_MSG_DEBUG( "Found Dummy vertex. Skipping" );
532  continue;
533  }
534  nGoodVertices++;
535 
537  std::vector< const PARTICLE* > vtxTracks{};
538  std::vector< float > vtxTrackWeights{};
540  *vertex, vtxTracks, vtxTrackWeights,
541  particles, m_trkAnaDefSvc->useSelectedVertexTracks() ) ) {
542  ATH_MSG_WARNING( "Problem when retrieving vertex-assocciated tracks" );
543  if( not vtxTracks.empty() ) {
544  ATH_MSG_WARNING( "Invalid associated track links found. Check your input format." );
545  }
546  }
547 
549  if( m_plots_vtxParam_vsRef ) {
550  ATH_CHECK( m_plots_vtxParam_vsRef->fillPlots( *vertex, vtxTracks, vtxTrackWeights, weight ) );
551  }
552  }
553 
555  if( m_plots_nVtxParam_vsRef ) {
556  ATH_CHECK( m_plots_nVtxParam_vsRef->fillPlots( nGoodVertices, truthMu, actualMu, weight ) );
557  }
558 
559  return StatusCode::SUCCESS;
560 }
561 
562 template StatusCode
564  const std::vector< const xAOD::TrackParticle* >& particles,
565  const ITrackMatchingLookup& matches,
566  const std::vector< const xAOD::Vertex* >& vertices,
567  float truthMu, float actualMu, float weight );
568 
569 template StatusCode
571  const std::vector< const xAOD::TruthParticle* >& particles,
572  const ITrackMatchingLookup& matches,
573  const std::vector< const xAOD::TruthVertex* >& vertices,
574  float truthMu, float actualMu, float weight );
575 
576 
581  const std::vector< const xAOD::TrackParticle* >& testTracks,
582  const std::vector< const xAOD::TrackParticle* >& refTracks,
583  const std::vector< const xAOD::TruthParticle* >& truths,
584  const ITrackMatchingLookup& matches,
585  float truthMu, float actualMu, float weight )
586 {
587 
588  for( const xAOD::TruthParticle* thisTruth : truths ) {
589 
590  bool isMatched( false ); // test track matched to reference track through EFTruthMatch method
591  bool refMatched( false ); // reference track matched to thisTruth
592 
594  for( const xAOD::TrackParticle* thisTrack : refTracks ) {
595  const xAOD::TruthParticle* linkedTruth = getLinkedTruth(
596  *thisTrack, m_trkAnaDefSvc->truthProbCut() );
597  if( not linkedTruth ) {
598  ATH_MSG_WARNING( "Unlinked track!!" );
599  continue;
600  }
601  if( thisTruth == linkedTruth ) {
602  refMatched = true;
603  break;
604  }
605  } // close loop over reference tracks
606 
608  if ( not refMatched ) continue;
609 
610  else {
611 
613  for( const xAOD::TrackParticle* thisTrack : testTracks ) {
614  const xAOD::TruthParticle* linkedTruth = getLinkedTruth(
615  *thisTrack, m_trkAnaDefSvc->truthProbCut() );
616  if( not linkedTruth ) {
617  ATH_MSG_WARNING( "Unlinked track!!" );
618  continue;
619  }
620  if( thisTruth == linkedTruth ) {
621  isMatched = matches.isTestMatched( *thisTrack ); // Check if this test is matched to reference with EFTruthMatch
622  break;
623  }
624  } // close loop over test tracks
625 
627  if( m_plots_eff_vsTruth ) {
628  ATH_CHECK( m_plots_eff_vsTruth->fillPlots(
629  *thisTruth, isMatched, truthMu, actualMu, weight ) );
630  }
631 
633  if( m_plots_tech_eff_vsTruth ) {
634  if (isReconstructable( *thisTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() )) {
635  ATH_CHECK( m_plots_tech_eff_vsTruth->fillPlots(
636  *thisTruth, isMatched , truthMu, actualMu, weight ) );
637  }
638  }
639  }
640  } // close loop over truth particles
641 
642  return StatusCode::SUCCESS;
643 }
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
IDTPM::getTruthMatchProb
float getTruthMatchProb(const xAOD::TrackParticle &track)
getTruthMatchProb
Definition: OfflineObjectDecorHelper.cxx:53
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
IDTPM::TrackAnalysisCollections
Definition: TrackAnalysisCollections.h:46
InDetSecVtxTruthMatchUtils::isFake
bool isFake(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:60
IDTPM::getLinkedTruth
const xAOD::TruthParticle * getLinkedTruth(const xAOD::TrackParticle &track, const float truthProbCut)
getLinkedTruth
Definition: OfflineObjectDecorHelper.cxx:61
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:580
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:184
InDetSecVtxTruthMatchUtils::isMatched
bool isMatched(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:48
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.
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:570
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:189
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:274
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:443
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:186
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:261
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::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:98
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:199
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:213
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
IDTPM::isReconstructable
bool isReconstructable(const xAOD::TruthParticle &truth, const std::vector< unsigned int > &minSilHits, const std::vector< float > &etaBins)
isReconstructable
Definition: OfflineObjectDecorHelper.cxx:85
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::isFakeTruth
bool isFakeTruth(const xAOD::TrackParticle &track, const float truthProbCut, const bool unlinkedAsFakes)
isFake
Definition: OfflineObjectDecorHelper.cxx:72
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:45
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