diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/data/EffPlotsDef.json b/InnerDetector/InDetValidation/InDetTrackPerfMon/data/EffPlotsDef.json new file mode 100644 index 0000000000000000000000000000000000000000..f488e36c38174324668ae887a5c018288f2231a9 --- /dev/null +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/data/EffPlotsDef.json @@ -0,0 +1,12 @@ +{ + "eff_vs_$TRKTAG_pt" : { + "type" : "TEfficiency", + "xAxis" : { "title" : "$TRKTYPE p_{T} [GeV]", "nBins" : "100", "low" : "0.0", "high" : "100.0" }, + "yAxis" : { "title" : "Efficiency" } + }, + "eff_vs_$TRKTAG_eta" : { + "type" : "TEfficiency", + "xAxis" : { "title" : "$TRKTYPE #eta", "nBins" : "100", "low" : "-$ETAMAX", "high" : "$ETAMAX" }, + "yAxis" : { "title" : "Efficiency" } + } +} diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/data/OfflElePlotsDef.json b/InnerDetector/InDetValidation/InDetTrackPerfMon/data/OfflElePlotsDef.json new file mode 100644 index 0000000000000000000000000000000000000000..4a0c5881d3c308f611d9234ba7b53f805ff1154a --- /dev/null +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/data/OfflElePlotsDef.json @@ -0,0 +1,22 @@ +{ + "offEle_Et" : { + "type" : "TH1F", + "xAxis" : { "title" : "Offline e^{#pm} E_{T} [GeV]", "nBins" : "100", "low" : "0.0", "high" : "100.0" }, + "yAxis" : { "title" : "Entries" } + }, + "offEle_EtOverPt" : { + "type" : "TH1F", + "xAxis" : { "title" : "Offline e^{#pm} E_{T}/p_{T}", "nBins" : "100", "low" : "0.0", "high" : "10.0" }, + "yAxis" : { "title" : "Entries" } + }, + "eff_vs_offEle_Et" : { + "type" : "TEfficiency", + "xAxis" : { "title" : "Offline e^{#pm} E_{T} [GeV]", "nBins" : "100", "low" : "0.0", "high" : "100.0" }, + "yAxis" : { "title" : "Efficiency" } + }, + "eff_vs_offEle_EtOverPt" : { + "type" : "TEfficiency", + "xAxis" : { "title" : "Offline e^{#pm} E_{T}/p_{T}", "nBins" : "100", "low" : "0.0", "high" : "10.0" }, + "yAxis" : { "title" : "Efficiency" } + } +} diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/data/PlotsDefFileList_default.txt b/InnerDetector/InDetValidation/InDetTrackPerfMon/data/PlotsDefFileList_default.txt index eb1ae7a0549d5ea4cc86774eeca8159979dc6bd9..94cf9bd5018353a4ecea9c0eb211ce78759079a6 100644 --- a/InnerDetector/InDetValidation/InDetTrackPerfMon/data/PlotsDefFileList_default.txt +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/data/PlotsDefFileList_default.txt @@ -1 +1,3 @@ InDetTrackPerfMon/TrkParamPlotsDef.json +InDetTrackPerfMon/EffPlotsDef.json +InDetTrackPerfMon/OfflElePlotsDef.json diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/TrackAnalysisPlotsMgr.cxx b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/TrackAnalysisPlotsMgr.cxx index 9cb31bb3fd752a329e1f279e544ecd24b3423afd..556ff56af50ac9d1cf12836f4c28b28d4dad7b23 100644 --- a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/TrackAnalysisPlotsMgr.cxx +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/TrackAnalysisPlotsMgr.cxx @@ -52,24 +52,23 @@ StatusCode IDTPM::TrackAnalysisPlotsMgr::initialize() this, "Tracks/Parameters", m_anaTag, m_trkAnaDefSvc->referenceTag() ); } - /// TODO - To be included in later MRs /// Efficiency plots - /*if( m_trkAnaDefSvc->plotEfficiencies() ) { - m_plots_eff_vsTest = std::make_unique< InDetPerfPlot_Efficiencies >( + if( m_trkAnaDefSvc->plotEfficiencies() ) { + m_plots_eff_vsTest = std::make_unique< EfficiencyPlots >( this, "Tracks/Efficiencies", m_anaTag, m_trkAnaDefSvc->testTag() ); - m_plots_eff_vsRef = std::make_unique< InDetPerfPlot_Efficiencies >( + m_plots_eff_vsRef = std::make_unique< EfficiencyPlots >( this, "Tracks/Efficiencies", m_anaTag, m_trkAnaDefSvc->referenceTag() ); - }*/ + } /// Offline electron plots - /*if( m_trkAnaDefSvc->plotOfflineElectrons() ) { - m_plots_offEle = std::make_unique< InDetPerfPlot_OfflineElectron >( + if( m_trkAnaDefSvc->plotOfflineElectrons() ) { + m_plots_offEle = std::make_unique< OfflineElectronPlots >( this, "Tracks/Parameters", m_anaTag ); if( m_trkAnaDefSvc->plotEfficiencies() ) { - m_plots_eff_vsOffEle = std::make_unique< InDetPerfPlot_OfflineElectron >( + m_plots_eff_vsOffEle = std::make_unique< OfflineElectronPlots >( this, "Tracks/Efficiencies", m_anaTag, true ); } - }*/ + } /// intialize PlotBase ATH_CHECK( PlotMgr::initialize() ); @@ -125,15 +124,21 @@ StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsTest( } bool isMatched = matches.isTestMatched( *particle ); - if( isMatched ) { - ATH_MSG_DEBUG( "Test track is matched to a reference" ); - } - /// TODO - To be included in later MRs /// efficiency plots - /*if( m_plots_eff_vsTest ) { - ATH_CHECK( m_plots_eff_vsTest->fill( *particle, isMatched, weight ) ); - }*/ + if( m_plots_eff_vsTest ) { + ATH_CHECK( m_plots_eff_vsTest->fillPlots( *particle, isMatched, weight ) ); + } + + /// offline electron plots (Offline is always either test or reference) + if( m_trkAnaDefSvc->isTestOffline() ) { + if( m_plots_offEle ) { + ATH_CHECK( m_plots_offEle->fillPlots( *particle, false, weight ) ); + } + if( m_plots_eff_vsOffEle ) { + ATH_CHECK( m_plots_eff_vsOffEle->fillPlots( *particle, isMatched, weight ) ); + } + } } // close loop over particles @@ -166,24 +171,21 @@ StatusCode IDTPM::TrackAnalysisPlotsMgr::fillPlotsReference( } bool isMatched = matches.isRefMatched( *particle ); - if( isMatched ) { - ATH_MSG_DEBUG( "Reference track is matched to (at least) a test" ); - } - /// TODO - To be included in later MRs /// efficiency plots - /*if( m_plots_eff_vsRef ) { - ATH_CHECK( m_plots_eff_vsRef->fill( *particle, isMatched, weight ) ); - }*/ - - /// TODO - To be included in later MRs - /// offline electron plots - /*if( m_plots_offEle ) { - ATH_CHECK( m_plots_offEle->fill( *particle, false, weight ) ); + if( m_plots_eff_vsRef ) { + ATH_CHECK( m_plots_eff_vsRef->fillPlots( *particle, isMatched, weight ) ); + } + + /// offline electron plots (Offline is always either test or reference) + if( m_trkAnaDefSvc->isReferenceOffline() ) { + if( m_plots_offEle ) { + ATH_CHECK( m_plots_offEle->fillPlots( *particle, false, weight ) ); + } + if( m_plots_eff_vsOffEle ) { + ATH_CHECK( m_plots_eff_vsOffEle->fillPlots( *particle, isMatched, weight ) ); + } } - if( m_plots_eff_vsOffEle ) { - ATH_CHECK( m_plots_eff_vsOffEle->fill( *particle, isMatched, weight ) ); - }*/ } // close loop over particles diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/TrackAnalysisPlotsMgr.h b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/TrackAnalysisPlotsMgr.h index 89e8f0cc44957dff06f07627b6b8735b4676892e..d5c5fb9dd5934a632efb3b7bd34c599f58d1f572 100644 --- a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/TrackAnalysisPlotsMgr.h +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/TrackAnalysisPlotsMgr.h @@ -21,9 +21,8 @@ #include "InDetTrackPerfMon/ITrackAnalysisDefinitionSvc.h" #include "PlotMgr.h" #include "plots/TrackParametersPlots.h" -/// TODO - to be included in later MRs -//#include "InDetTrackPerfMon/InDetPerfPlot_Efficiencies.h" -//#include "InDetTrackPerfMon/InDetPerfPlot_OfflineElectron.h" +#include "plots/EfficiencyPlots.h" +#include "plots/OfflineElectronPlots.h" /// STD includes #include <string> @@ -84,17 +83,16 @@ namespace IDTPM { /// TrackAnalysis definition service to "hold" the histograms configurations/flags ITrackAnalysisDefinitionSvc* m_trkAnaDefSvc; - /// TODO - to be included in later MRs /// Plot categories /// plots w.r.t. test tracks parameters std::unique_ptr< TrackParametersPlots > m_plots_trkParam_vsTest; - //std::unique_ptr< InDetPerfPlot_Efficiencies > m_plots_eff_vsTest; + std::unique_ptr< EfficiencyPlots > m_plots_eff_vsTest; /// plots w.r.t. reference tracks parameters std::unique_ptr< TrackParametersPlots > m_plots_trkParam_vsRef; - //std::unique_ptr< InDetPerfPlot_Efficiencies > m_plots_eff_vsRef; + std::unique_ptr< EfficiencyPlots > m_plots_eff_vsRef; /// plots w.r.t. reference offline electron - //std::unique_ptr< InDetPerfPlot_OfflineElectron > m_plots_offEle; - //std::unique_ptr< InDetPerfPlot_OfflineElectron > m_plots_eff_vsOffEle; + std::unique_ptr< OfflineElectronPlots > m_plots_offEle; + std::unique_ptr< OfflineElectronPlots > m_plots_eff_vsOffEle; }; // class TrackAnalysisPlotsMgr diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/EfficiencyPlots.cxx b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/EfficiencyPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..74da8a2e223d443a29d4b13295b8fe871e3d63f1 --- /dev/null +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/EfficiencyPlots.cxx @@ -0,0 +1,80 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file EfficiencyPlots.cxx + * @author Marco Aparo <marco.aparo@cern.ch> + **/ + +/// local include(s) +#include "EfficiencyPlots.h" +#include "../TrackParmetersHelper.h" + + +/// ----------------------- +/// ----- Constructor ----- +/// ----------------------- +IDTPM::EfficiencyPlots::EfficiencyPlots( + PlotMgr* pParent, const std::string& dirName, + const std::string& anaTag, const std::string& trackType ) : + PlotMgr( dirName, anaTag, pParent ), + m_trackType( trackType ) { } + + +/// --------------------------- +/// --- Book the histograms --- +/// --------------------------- +void IDTPM::EfficiencyPlots::initializePlots() +{ + StatusCode sc = bookPlots(); + if( sc.isFailure() ) { + ATH_MSG_ERROR( "Failed to book efficiency plots" ); + } +} + + +StatusCode IDTPM::EfficiencyPlots::bookPlots() +{ + ATH_MSG_DEBUG( "Booking efficiency plots in " << getDirectory() ); + + ATH_CHECK( retrieveAndBook( m_eff_vs_pt, "eff_vs_"+m_trackType+"_pt" ) ); + ATH_CHECK( retrieveAndBook( m_eff_vs_eta, "eff_vs_"+m_trackType+"_eta" ) ); + + return StatusCode::SUCCESS; +} + + +/// ----------------------------- +/// --- Dedicated fill method --- +/// ----------------------------- +template< typename PARTICLE > +StatusCode IDTPM::EfficiencyPlots::fillPlots( + const PARTICLE& particle, bool isMatched, float weight ) +{ + /// Compute track parameters - TODO: add more... + float ppt = pT( particle ) / Gaudi::Units::GeV; + float peta = eta( particle ); + + /// Fill the histograms + ATH_CHECK( fill( m_eff_vs_pt, ppt, isMatched, weight ) ); + ATH_CHECK( fill( m_eff_vs_eta, peta, isMatched, weight ) ); + + return StatusCode::SUCCESS; +} + +template StatusCode IDTPM::EfficiencyPlots::fillPlots< xAOD::TrackParticle >( + const xAOD::TrackParticle&, bool isMatched, float weight ); + +template StatusCode IDTPM::EfficiencyPlots::fillPlots< xAOD::TruthParticle >( + const xAOD::TruthParticle&, bool isMatched, float weight ); + + +/// ------------------------- +/// ----- finalizePlots ----- +/// ------------------------- +void IDTPM::EfficiencyPlots::finalizePlots() +{ + ATH_MSG_DEBUG( "Finalising efficiency plots" ); + /// print stat here if needed +} diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/EfficiencyPlots.h b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/EfficiencyPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..7f5c036422bb19ee37ceb6495e475d3ffc1efa9c --- /dev/null +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/EfficiencyPlots.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef INDETTRACKPERFMON_PLOTS_EFFICIENCYPLOTS_H +#define INDETTRACKPERFMON_PLOTS_EFFICIENCYPLOTS_H + +/** + * @file EfficiencyPlots.h + * @author Marco Aparo <Marco.Aparo@cern.ch> + **/ + +/// local includes +#include "../PlotMgr.h" + + +namespace IDTPM { + + class EfficiencyPlots : public PlotMgr { + + public: + + /// Constructor + EfficiencyPlots( + PlotMgr* pParent, + const std::string& dirName, + const std::string& anaTag, + const std::string& trackType ); + + /// Destructor + virtual ~EfficiencyPlots() = default; + + /// Dedicated fill method (for tracks and/or truth particles) + template< typename PARTICLE > + StatusCode fillPlots( + const PARTICLE& particle, + bool isMatched, float weight ); + + /// Book the histograms + void initializePlots(); // needed to override PlotBase + StatusCode bookPlots(); + + /// Print out final stats on histograms + void finalizePlots(); + + private: + + std::string m_trackType; + + TEfficiency* m_eff_vs_pt; + TEfficiency* m_eff_vs_eta; + /// TODO - include more plots + + }; // class EfficiencyPlots + +} // namespace IDTPM + +#endif // > ! INDETTRACKPERFMON_PLOTS_EFFICIENCYPLOTS_H diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/OfflineElectronPlots.cxx b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/OfflineElectronPlots.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c3c479e4f6719342141513d6053194e740829191 --- /dev/null +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/OfflineElectronPlots.cxx @@ -0,0 +1,101 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file OfflineElectronPlots.cxx + * @author Marco Aparo <marco.aparo@cern.ch> + **/ + + +/// local include(s) +#include "OfflineElectronPlots.h" +#include "../TrackParmetersHelper.h" +#include "../OfflineObjectDecorHelper.h" + + +/// ----------------------- +/// ----- Constructor ----- +/// ----------------------- +IDTPM::OfflineElectronPlots::OfflineElectronPlots( + PlotMgr* pParent, const std::string& dirName, + const std::string& anaTag, bool doEfficiency ) : + PlotMgr( dirName, anaTag, pParent ), + m_doEfficiency( doEfficiency ) { } + + +/// --------------------------- +/// --- Book the histograms --- +/// --------------------------- +void IDTPM::OfflineElectronPlots::initializePlots() +{ + StatusCode sc = bookPlots(); + if( sc.isFailure() ) { + ATH_MSG_ERROR( "Failed to book offline electron plots" ); + } +} + + +StatusCode IDTPM::OfflineElectronPlots::bookPlots() +{ + ATH_MSG_DEBUG( "Booking offline electron plots in " << getDirectory() ); + + if( not m_doEfficiency ) { + ATH_CHECK( retrieveAndBook( m_Et, "offEle_Et" ) ); + ATH_CHECK( retrieveAndBook( m_EtOverPt, "offEle_EtOverPt" ) ); + } else { + ATH_CHECK( retrieveAndBook( m_eff_vs_Et, "eff_vs_offEle_Et" ) ); + ATH_CHECK( retrieveAndBook( m_eff_vs_EtOverPt, "eff_vs_offEle_EtOverPt" ) ); + } + + return StatusCode::SUCCESS; +} + + +/// ------------------------------ +/// --- Dedicated fill methods --- +/// ------------------------------ +StatusCode IDTPM::OfflineElectronPlots::fillPlots( + const xAOD::TrackParticle& track, + bool isMatched, float weight ) +{ + const xAOD::Electron* ele = getLinkedElectron( track ); + + if( not ele ) { + ATH_MSG_ERROR( "Electron not found" ); + return StatusCode::FAILURE; + } + + /// Compute track parameters - TODO: add more... + float ppt = pT( track ) / Gaudi::Units::GeV; + float pet = eT( *ele ) / Gaudi::Units::GeV; + + /// Fill the histograms + if( not m_doEfficiency ) { + ATH_CHECK( fill( m_Et, pet, weight ) ); + ATH_CHECK( fill( m_EtOverPt, (pet/ppt), weight ) ); + } else { + ATH_CHECK( fill( m_eff_vs_Et, pet, isMatched, weight ) ); + ATH_CHECK( fill( m_eff_vs_EtOverPt, (pet/ppt), isMatched, weight ) ); + } + + return StatusCode::SUCCESS; +} + + +StatusCode IDTPM::OfflineElectronPlots::fillPlots( + const xAOD::TruthParticle&, bool, float ) +{ + ATH_MSG_ERROR( "Fill method disabled for truth particles" ); + return StatusCode::FAILURE; +} + + +/// ------------------------- +/// ----- finalizePlots ----- +/// ------------------------- +void IDTPM::OfflineElectronPlots::finalizePlots() +{ + ATH_MSG_DEBUG( "Finalising offline electron plots" ); + /// print stat here if needed +} diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/OfflineElectronPlots.h b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/OfflineElectronPlots.h new file mode 100644 index 0000000000000000000000000000000000000000..97a7a45be2a7da911538581b35d0bb19f71a99be --- /dev/null +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/OfflineElectronPlots.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef INDETTRACKPERFMON_PLOTS_OFFLINEELECTRONPLOTS_H +#define INDETTRACKPERFMON_PLOTS_OFFLINEELECTRONPLOTS_H + +/** + * @file OfflineElectronPlots.h + * @author Marco Aparo <marco.aparo@cern.ch> + **/ + +/// local includes +#include "../PlotMgr.h" + +/// xAOD includes +#include "xAODTracking/TrackParticle.h" +#include "xAODTruth/TruthParticle.h" + + +namespace IDTPM { + + class OfflineElectronPlots : public PlotMgr { + + public: + + /// Constructor + OfflineElectronPlots( + PlotMgr* pParent, + const std::string& dirName, + const std::string& anaTag, + bool doEfficiency = false ); + + /// Destructor + virtual ~OfflineElectronPlots() = default; + + /// Book the histograms + void initializePlots(); + StatusCode bookPlots(); + + /// Dedicated fill methods + StatusCode fillPlots( + const xAOD::TrackParticle& track, + bool isMatched, float weight ); + StatusCode fillPlots( + const xAOD::TruthParticle&, bool, float ); + + /// Print out final stats on histograms + void finalizePlots(); + + private: + + bool m_doEfficiency; + + TH1* m_Et; + TH1* m_EtOverPt; + /// TODO - include more plots + + TEfficiency* m_eff_vs_Et; + TEfficiency* m_eff_vs_EtOverPt; + + }; // class OfflineElectronPlots + +} // namespace IDTPM + +#endif // > ! INDETTRACKPERFMON_PLOTS_OFFLINEELECTRONPLOTS_H diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/README.md b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/README.md index c412f3000923f3d249494a3c6dc524b55db16e3c..478519c4da32b3c6be2a5fbf3ba4516fa715125e 100644 --- a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/README.md +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/README.md @@ -4,3 +4,5 @@ This directory holds dedicated classes for each plot category in this package. Currently available categories are: - `TrackParametersPlots`: for plots regarding the basic track parameters (pT, eta, etc.). They are saved in the "Tracks/Parameters" sub-directory of the output HIST file. +- `EfficiencyPlots`: for plots regarding the efficiency with respect to the basic track parameters (pT, eta, etc.). They are saved in the "Tracks/Efficiencies" sub-directory of the output HIST file. +- `OfflineElectronPlots`: for plots regarding the parameters corresponding to the linked offline electron parameters (saved in "Tracks/Parameters") and the corresponding efficiencies (saved in "Tracks/Efficiencies"). diff --git a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/TrackParametersPlots.h b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/TrackParametersPlots.h index f5e983349457d0728dad5dd7c7f43bf1b5f3ba9b..183df757dc4312443489ee221e41e960d7b2546a 100644 --- a/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/TrackParametersPlots.h +++ b/InnerDetector/InDetValidation/InDetTrackPerfMon/src/plots/TrackParametersPlots.h @@ -30,14 +30,14 @@ namespace IDTPM { /// Destructor virtual ~TrackParametersPlots() = default; - /// Dedicated fill method (for tracks and/or truth particles) - template< typename PARTICLE > - StatusCode fillPlots( const PARTICLE& particle, float weight ); - /// Book the histograms void initializePlots(); // needed to override PlotBase StatusCode bookPlots(); + /// Dedicated fill method (for tracks and/or truth particles) + template< typename PARTICLE > + StatusCode fillPlots( const PARTICLE& particle, float weight ); + /// Print out final stats on histograms void finalizePlots();