18 #include "GaudiKernel/ISvcLocator.h"
19 #include "GaudiKernel/Service.h"
26 const std::string& dirName,
27 const std::string& anaTag,
28 const std::string&
chain,
30 PlotMgr( dirName, anaTag, pParent ),
31 m_anaTag( anaTag ), m_chain(
chain ),
32 m_directory( dirName ) { }
40 ATH_MSG_DEBUG(
"Initialising in directory: " << m_directory );
43 m_trkAnaDefSvc = Gaudi::svcLocator()->service(
"TrkAnaDefSvc"+m_anaTag );
47 if( m_trkAnaDefSvc->plotTrackParameters() ) {
48 m_plots_trkParam_vsTest = std::make_unique< TrackParametersPlots >(
49 this,
"Tracks/Parameters", m_anaTag, m_trkAnaDefSvc->testTag() );
50 m_plots_trkParam_vsRef = std::make_unique< TrackParametersPlots >(
51 this,
"Tracks/Parameters", m_anaTag, m_trkAnaDefSvc->referenceTag() );
55 if( m_trkAnaDefSvc->plotTrackMultiplicities() ) {
56 m_plots_nTracks_test = std::make_unique< NtracksPlots >(
57 this,
"Tracks/Multiplicities", m_anaTag, m_trkAnaDefSvc->testTag(),
58 m_trkAnaDefSvc->useTrigger() and not m_trkAnaDefSvc->useEFTrigger(),
true );
59 m_plots_nTracks_ref = std::make_unique< NtracksPlots >(
60 this,
"Tracks/Multiplicities", m_anaTag, m_trkAnaDefSvc->referenceTag(),
61 m_trkAnaDefSvc->useTrigger() and not m_trkAnaDefSvc->useEFTrigger() );
65 if( m_trkAnaDefSvc->plotEfficiencies() ) {
66 m_plots_eff_vsTest = std::make_unique< EfficiencyPlots >(
67 this,
"Tracks/Efficiencies", m_anaTag, m_trkAnaDefSvc->testTag() );
68 m_plots_eff_vsRef = std::make_unique< EfficiencyPlots >(
69 this,
"Tracks/Efficiencies", m_anaTag, m_trkAnaDefSvc->referenceTag(),
true );
70 if( m_trkAnaDefSvc->matchingType() ==
"EFTruthMatch" ) {
71 m_plots_eff_vsTruth = std::make_unique< EfficiencyPlots >(
72 this,
"Tracks/Efficiencies", m_anaTag,
"truth" );
77 if( m_trkAnaDefSvc->plotTechnicalEfficiencies()) {
78 m_plots_tech_eff_vsTest = std::make_unique< EfficiencyPlots >(
79 this,
"Tracks/Efficiencies/Technical", m_anaTag, m_trkAnaDefSvc->testTag());
80 m_plots_tech_eff_vsRef = std::make_unique< EfficiencyPlots >(
81 this,
"Tracks/Efficiencies/Technical", m_anaTag, m_trkAnaDefSvc->referenceTag(),
true );
82 if( m_trkAnaDefSvc->matchingType() ==
"EFTruthMatch" ) {
83 m_plots_tech_eff_vsTruth = std::make_unique< EfficiencyPlots >(
84 this,
"Tracks/Efficiencies/Technical", m_anaTag,
"truth" );
89 if( m_trkAnaDefSvc->plotResolutions() ) {
90 m_plots_resolution = std::make_unique< ResolutionPlots >(
91 this,
"Tracks/Resolutions", m_anaTag,
92 m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->referenceTag(),
93 m_trkAnaDefSvc->resolutionMethod() );
97 if( m_trkAnaDefSvc->plotFakeRates() and m_trkAnaDefSvc->isReferenceTruth() ) {
98 m_plots_fakeRate = std::make_unique< FakeRatePlots >(
99 this,
"Tracks/FakeRates", m_anaTag, m_trkAnaDefSvc->testTag(),
true );
100 if ( not m_trkAnaDefSvc->unlinkedAsFakes() ) {
101 m_plots_missingTruth = std::make_unique< FakeRatePlots >(
102 this,
"Tracks/FakeRates/Unlinked", m_anaTag, m_trkAnaDefSvc->testTag(),
true );
107 if( m_trkAnaDefSvc->plotDuplicateRates() ) {
108 m_plots_duplRate = std::make_unique< DuplicateRatePlots >(
109 this,
"Tracks/Duplicates", m_anaTag, m_trkAnaDefSvc->referenceTag(),
true );
114 if( m_trkAnaDefSvc->plotHitsOnTracks() and not m_trkAnaDefSvc->isTestTruth() ) {
115 m_plots_hitsOnTrk_vsTest = std::make_unique< HitsOnTracksPlots >(
116 this,
"Tracks/HitsOnTracks", m_anaTag,
117 m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
true );
119 if( m_trkAnaDefSvc->plotHitsOnTracksReference() and not m_trkAnaDefSvc->isReferenceTruth() ) {
120 m_plots_hitsOnTrk_vsRef = std::make_unique< HitsOnTracksPlots >(
121 this,
"Tracks/HitsOnTracks", m_anaTag,
122 m_trkAnaDefSvc->referenceTag(), m_trkAnaDefSvc->isITk() );
125 if( m_trkAnaDefSvc->plotHitsOnMatchedTracks() and not m_trkAnaDefSvc->isTestTruth() ) {
126 m_plots_hitsOnMatchedTrk = std::make_unique< HitsOnTracksPlots >(
127 this,
"Tracks/Resolutions/HitsOnTracks", m_anaTag,
128 m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
true );
129 m_plots_hitsOnMatchedTrk_vsRef = std::make_unique< HitsOnTracksPlots >(
130 this,
"Tracks/Resolutions/HitsOnTracks", m_anaTag,
131 m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->referenceTag(), m_trkAnaDefSvc->isITk() );
134 if( m_trkAnaDefSvc->plotHitsOnFakeTracks() and m_trkAnaDefSvc->isReferenceTruth() ) {
135 m_plots_hitsOnFakeTrk = std::make_unique< HitsOnTracksPlots >(
136 this,
"Tracks/FakeRates/HitsOnTracks", m_anaTag,
137 m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
true );
138 if ( not m_trkAnaDefSvc->unlinkedAsFakes() ) {
139 m_plots_hitsOnUnlinkedTrk = std::make_unique< HitsOnTracksPlots >(
140 this,
"Tracks/FakeRates/Unlinked/HitsOnTracks", m_anaTag,
141 m_trkAnaDefSvc->testTag(), m_trkAnaDefSvc->isITk(),
true );
146 if( m_trkAnaDefSvc->plotOfflineElectrons() ) {
147 m_plots_offEle = std::make_unique< OfflineElectronPlots >(
148 this,
"Tracks/Parameters", m_anaTag );
149 if( m_trkAnaDefSvc->plotEfficiencies() ) {
150 m_plots_eff_vsOffEle = std::make_unique< OfflineElectronPlots >(
151 this,
"Tracks/Efficiencies", m_anaTag,
true );
158 return StatusCode::SUCCESS;
168 float actualMu = trkAnaColls.
eventInfo() ?
173 if( m_trkAnaDefSvc->isTestTruth() ) {
184 if( m_trkAnaDefSvc->isReferenceTruth() ) {
195 if( m_trkAnaDefSvc->matchingType() ==
"EFTruthMatch" ) {
204 if( m_plots_nTracks_test ) {
217 ATH_CHECK( m_plots_nTracks_test->fillPlots( countsTest, truthMu, actualMu,
weight ) );
220 if( m_plots_nTracks_ref ) {
233 ATH_CHECK( m_plots_nTracks_ref->fillPlots( countsRef, truthMu, actualMu,
weight ) );
236 return StatusCode::SUCCESS;
243 template<
typename PARTICLE >
245 const std::vector< const PARTICLE* >&
particles,
247 float truthMu,
float actualMu,
float weight )
252 if( m_plots_trkParam_vsTest ) {
257 if( m_plots_hitsOnTrk_vsTest ) {
264 if( m_plots_eff_vsTest ) {
265 ATH_CHECK( m_plots_eff_vsTest->fillPlots(
270 if( m_plots_tech_eff_vsTest ) {
271 if ( m_trkAnaDefSvc->isTestTruth() and
273 ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
276 else if ( m_trkAnaDefSvc->isReferenceTruth() ) {
279 ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
282 else if ( m_trkAnaDefSvc->matchingType() ==
"EFTruthMatch" ) {
284 *
particle, m_trkAnaDefSvc->truthProbCut() );
286 isReconstructable( *linkedTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) :
false;
287 ATH_CHECK( m_plots_tech_eff_vsTest->fillPlots(
293 if( m_plots_resolution ) {
295 if( m_trkAnaDefSvc->isReferenceTruth() ) {
296 ATH_CHECK( m_plots_resolution->fillPlots(
299 ATH_CHECK( m_plots_resolution->fillPlots(
306 if( m_plots_hitsOnMatchedTrk and m_plots_hitsOnMatchedTrk_vsRef and
isMatched ) {
308 if( m_trkAnaDefSvc->isReferenceTruth() ) {
309 ATH_CHECK( m_plots_hitsOnMatchedTrk_vsRef->fillPlots(
312 ATH_CHECK( m_plots_hitsOnMatchedTrk_vsRef->fillPlots(
319 if( m_plots_missingTruth ) {
321 if( m_plots_hitsOnUnlinkedTrk and isUnlinked ) {
326 bool doFakes = m_trkAnaDefSvc->unlinkedAsFakes() ? true : not isUnlinked;
327 if( doFakes and m_plots_fakeRate ) {
329 m_trkAnaDefSvc->unlinkedAsFakes() );
331 if( m_plots_hitsOnFakeTrk and
isFake ) {
337 if( m_trkAnaDefSvc->isTestOffline() ) {
338 if( m_plots_offEle ) {
341 if( m_plots_eff_vsOffEle ) {
348 return StatusCode::SUCCESS;
353 const std::vector< const xAOD::TrackParticle* >&
particles,
354 const ITrackMatchingLookup& matches,
355 float truthMu,
float actualMu,
float weight );
359 const std::vector< const xAOD::TruthParticle* >&
particles,
360 const ITrackMatchingLookup& matches,
361 float truthMu,
float actualMu,
float weight );
367 template<
typename PARTICLE >
369 const std::vector< const PARTICLE* >&
particles,
371 float truthMu,
float actualMu,
float weight )
377 if( m_plots_trkParam_vsRef ) {
382 if( m_plots_hitsOnTrk_vsRef ) {
389 if( m_plots_eff_vsRef ) {
395 if( m_plots_tech_eff_vsRef ) {
396 if( m_trkAnaDefSvc->isReferenceTruth() and
399 ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
402 else if ( m_trkAnaDefSvc->isTestTruth() ) {
404 bool isTechMatched =
false;
408 if (
isReconstructable( *thisTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) ) {
409 isTechMatched =
true;
414 ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
418 else if ( m_trkAnaDefSvc->matchingType() ==
"EFTruthMatch" ) {
420 *
particle, m_trkAnaDefSvc->truthProbCut() );
422 isReconstructable( *linkedTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() ) :
false;
423 ATH_CHECK( m_plots_tech_eff_vsRef->fillPlots(
429 if( m_plots_duplRate ) {
430 unsigned int nMatched = m_trkAnaDefSvc->isTestTruth() ?
439 if( m_trkAnaDefSvc->isReferenceOffline() ) {
440 if( m_plots_offEle ) {
443 if( m_plots_eff_vsOffEle ) {
450 return StatusCode::SUCCESS;
455 const std::vector< const xAOD::TrackParticle* >&
particles,
456 const ITrackMatchingLookup& matches,
457 float truthMu,
float actualMu,
float weight );
461 const std::vector< const xAOD::TruthParticle* >&
particles,
462 const ITrackMatchingLookup& matches,
463 float truthMu,
float actualMu,
float weight );
470 const std::vector< const xAOD::TrackParticle* >& testTracks,
471 const std::vector< const xAOD::TrackParticle* >& refTracks,
472 const std::vector< const xAOD::TruthParticle* >& truths,
474 float truthMu,
float actualMu,
float weight )
480 bool refMatched(
false );
485 *thisTrack, m_trkAnaDefSvc->truthProbCut() );
486 if( not linkedTruth ) {
490 if( thisTruth == linkedTruth ) {
497 if ( not refMatched )
continue;
504 *thisTrack, m_trkAnaDefSvc->truthProbCut() );
505 if( not linkedTruth ) {
509 if( thisTruth == linkedTruth ) {
516 if( m_plots_eff_vsTruth ) {
517 ATH_CHECK( m_plots_eff_vsTruth->fillPlots(
522 if( m_plots_tech_eff_vsTruth ) {
523 if (
isReconstructable( *thisTruth, m_trkAnaDefSvc->minSilHits(), m_trkAnaDefSvc->etaBins() )) {
524 ATH_CHECK( m_plots_tech_eff_vsTruth->fillPlots(
531 return StatusCode::SUCCESS;