19 #include "GaudiKernel/ISvcLocator.h"
20 #include "GaudiKernel/Service.h"
27 const std::string& dirName,
28 const std::string& anaTag,
29 const std::string&
chain,
31 PlotMgr( dirName, anaTag, pParent ),
32 m_anaTag( anaTag ), m_chain(
chain ),
33 m_directory( dirName ) { }
41 ATH_MSG_DEBUG(
"Initialising in directory: " << m_directory );
44 m_trkAnaDefSvc = Gaudi::svcLocator()->service(
"TrkAnaDefSvc"+m_anaTag );
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() );
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() );
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" );
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" );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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 );
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() );
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() );
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() );
192 return StatusCode::SUCCESS;
202 float actualMu = trkAnaColls.
eventInfo() ?
208 if( m_trkAnaDefSvc->isTestTruth() ) {
213 truthMu, actualMu,
weight ) );
219 truthMu, actualMu,
weight ) );
223 if( m_trkAnaDefSvc->isReferenceTruth() ) {
228 truthMu, actualMu,
weight ) );
234 truthMu, actualMu,
weight ) );
238 if( m_trkAnaDefSvc->matchingType() ==
"EFTruthMatch" ) {
244 truthMu, actualMu,
weight ) );
249 std::vector< size_t > refTrackCounts = trkAnaColls.
refTrackCounts();
254 if( m_plots_nTracks_vsTest ) {
255 ATH_CHECK( m_plots_nTracks_vsTest->fillPlots(
256 testTrackCounts, testVertexCounts,
257 truthMu, actualMu,
weight ) );
260 if( m_plots_nTracks_vsRef ) {
261 ATH_CHECK( m_plots_nTracks_vsRef->fillPlots(
262 refTrackCounts, refVertexCounts,
263 truthMu, actualMu,
weight ) );
266 return StatusCode::SUCCESS;
273 template<
typename PARTICLE,
typename VERTEX >
275 const std::vector< const PARTICLE* >&
particles,
277 const std::vector< const VERTEX* >& vertices,
278 float truthMu,
float actualMu,
float weight )
283 if( m_plots_trkParam_vsTest ) {
288 if( m_plots_hitsOnTrk_vsTest ) {
295 if( m_plots_eff_vsTest ) {
296 ATH_CHECK( m_plots_eff_vsTest->fillPlots(
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(
309 else if ( m_trkAnaDefSvc->isReferenceTruth() ) {
312 m_trkAnaDefSvc->minSilHits(),
313 m_trkAnaDefSvc->etaBins() ) :
false;
314 ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
317 else if ( m_trkAnaDefSvc->matchingType() ==
"EFTruthMatch" ) {
319 *
particle, m_trkAnaDefSvc->truthProbCut() );
322 m_trkAnaDefSvc->minSilHits(),
323 m_trkAnaDefSvc->etaBins() ) :
false;
324 ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
330 if( m_plots_resolution ) {
332 if( m_trkAnaDefSvc->isReferenceTruth() ) {
333 ATH_CHECK( m_plots_resolution->fillPlots(
336 ATH_CHECK( m_plots_resolution->fillPlots(
343 if( m_plots_hitsOnMatchedTrk and m_plots_hitsOnMatchedTrk_vsRef and
isMatched ) {
345 if( m_trkAnaDefSvc->isReferenceTruth() ) {
346 ATH_CHECK( m_plots_hitsOnMatchedTrk_vsRef->fillPlots(
349 ATH_CHECK( m_plots_hitsOnMatchedTrk_vsRef->fillPlots(
358 if( m_plots_missingTruth ) {
361 if( m_plots_hitsOnUnlinkedTrk ) {
366 bool doFakes = m_trkAnaDefSvc->unlinkedAsFakes() ? true : not isUnlinked;
367 if( doFakes and m_plots_fakeRate ) {
369 m_trkAnaDefSvc->unlinkedAsFakes() );
371 if( m_plots_hitsOnFakeTrk and
isFake ) {
377 if( m_trkAnaDefSvc->isTestOffline() ) {
378 if( m_plots_offEle ) {
381 if( m_plots_eff_vsOffEle ) {
389 int nGoodVertices(0);
390 for(
const VERTEX*
vertex : vertices ) {
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." );
411 if( m_plots_vtxParam_vsTest ) {
417 if( m_plots_nVtxParam_vsTest ) {
418 ATH_CHECK( m_plots_nVtxParam_vsTest->fillPlots( nGoodVertices, truthMu, actualMu,
weight ) );
421 return StatusCode::SUCCESS;
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 );
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 );
442 template<
typename PARTICLE,
typename VERTEX >
444 const std::vector< const PARTICLE* >&
particles,
446 const std::vector< const VERTEX* >& vertices,
447 float truthMu,
float actualMu,
float weight )
453 if( m_plots_trkParam_vsRef ) {
458 if( m_plots_hitsOnTrk_vsRef ) {
465 if( m_plots_eff_vsRef ) {
471 if( m_plots_tech_eff_vsRef ) {
472 if( m_trkAnaDefSvc->isReferenceTruth() and
475 ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
478 else if ( m_trkAnaDefSvc->isTestTruth() ) {
480 bool isTechMatched =
false;
484 if (
isReconstructable( *thisTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) ) {
485 isTechMatched =
true;
490 ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
494 else if ( m_trkAnaDefSvc->matchingType() ==
"EFTruthMatch" ) {
496 *
particle, m_trkAnaDefSvc->truthProbCut() );
498 isReconstructable( *linkedTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) :
false;
499 ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
505 if( m_plots_duplRate ) {
506 unsigned int nMatched = m_trkAnaDefSvc->isTestTruth() ?
515 if( m_trkAnaDefSvc->isReferenceOffline() ) {
516 if( m_plots_offEle ) {
519 if( m_plots_eff_vsOffEle ) {
527 int nGoodVertices(0);
528 for(
const VERTEX*
vertex : vertices ) {
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." );
549 if( m_plots_vtxParam_vsRef ) {
555 if( m_plots_nVtxParam_vsRef ) {
556 ATH_CHECK( m_plots_nVtxParam_vsRef->fillPlots( nGoodVertices, truthMu, actualMu,
weight ) );
559 return StatusCode::SUCCESS;
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 );
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 );
581 const std::vector< const xAOD::TrackParticle* >& testTracks,
582 const std::vector< const xAOD::TrackParticle* >& refTracks,
583 const std::vector< const xAOD::TruthParticle* >& truths,
585 float truthMu,
float actualMu,
float weight )
591 bool refMatched(
false );
596 *thisTrack, m_trkAnaDefSvc->truthProbCut() );
597 if( not linkedTruth ) {
601 if( thisTruth == linkedTruth ) {
608 if ( not refMatched )
continue;
615 *thisTrack, m_trkAnaDefSvc->truthProbCut() );
616 if( not linkedTruth ) {
620 if( thisTruth == linkedTruth ) {
627 if( m_plots_eff_vsTruth ) {
628 ATH_CHECK( m_plots_eff_vsTruth->fillPlots(
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(
642 return StatusCode::SUCCESS;