From d71cfad25b3de76d1cbff8d0866043cf0fc8467c Mon Sep 17 00:00:00 2001 From: Baptiste Ravina <baptiste.ravina@cern.ch> Date: Wed, 29 May 2024 16:35:10 +0200 Subject: [PATCH] CPAlgorithm: add IOStatsAlg from TopCPToolkit CPAlgorithm: add IOStatsAlg from TopCPToolkit --- .../data/example_config.yaml | 22 ++++++------- .../python/ConfigFactory.py | 4 +++ .../AsgAnalysisAlgorithmsDict.h | 1 + .../AsgAnalysisAlgorithms/IOStatsAlg.h | 31 +++++++++++++++++++ .../AsgAnalysisAlgorithms/selection.xml | 1 + .../AsgAnalysisAlgorithms/Root/IOStatsAlg.cxx | 21 +++++++++++++ .../python/AsgAnalysisConfig.py | 13 ++++++++ .../AsgAnalysisAlgorithms_entries.cxx | 2 ++ .../Root/ComponentFactoryPreloader.cxx | 2 ++ 9 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/IOStatsAlg.h create mode 100644 PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/IOStatsAlg.cxx diff --git a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/data/example_config.yaml b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/data/example_config.yaml index 43233db3275c..ca9d5f2f79f6 100644 --- a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/data/example_config.yaml +++ b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/data/example_config.yaml @@ -62,17 +62,17 @@ TauJets: tauID: 'Tight' triggerChainsPerYear: '2015': - - 'HLT_tau25_medium1_tracktwo' - - 'HLT_tau35_medium1_tracktwo' - '2016': - - 'HLT_tau25_medium1_tracktwo' - - 'HLT_tau35_medium1_tracktwo' - '2017': - - 'HLT_tau25_medium1_tracktwo' - - 'HLT_tau35_medium1_tracktwo' - '2018': - - 'HLT_tau25_medium1_tracktwoEF_OR_mediumRNN_tracktwoMVA' - - 'HLT_tau35_medium1_tracktwoEF_OR_mediumRNN_tracktwoMVA' + - 'HLT_tau25_medium1_tracktwo' + - 'HLT_tau35_medium1_tracktwo' + '2016': + - 'HLT_tau25_medium1_tracktwo' + - 'HLT_tau35_medium1_tracktwo' + '2017': + - 'HLT_tau25_medium1_tracktwo' + - 'HLT_tau35_medium1_tracktwo' + '2018': + - 'HLT_tau25_medium1_tracktwoEF_OR_mediumRNN_tracktwoMVA' + - 'HLT_tau35_medium1_tracktwoEF_OR_mediumRNN_tracktwoMVA' PtEtaSelection: {} GeneratorLevelAnalysis: {} diff --git a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/ConfigFactory.py b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/ConfigFactory.py index c598dc45b70c..cd86a215ffab 100644 --- a/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/ConfigFactory.py +++ b/PhysicsAnalysis/Algorithms/AnalysisAlgorithmsConfig/python/ConfigFactory.py @@ -340,4 +340,8 @@ class ConfigFactory(): self.addAlgConfigBlock(algName="Output", alg=OutputAnalysisConfig, defaults={'configName': 'Output'}) + # IOStats printouts + from AsgAnalysisAlgorithms.AsgAnalysisConfig import IOStatsBlock + self.addAlgConfigBlock(algName="IOStats", alg=IOStatsBlock) + return diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithmsDict.h b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithmsDict.h index e0d262554dd5..2c7a3c2f6dd0 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithmsDict.h +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithmsDict.h @@ -41,5 +41,6 @@ #include <AsgAnalysisAlgorithms/SystObjectUnioniserAlg.h> #include <AsgAnalysisAlgorithms/TreeFillerAlg.h> #include <AsgAnalysisAlgorithms/TreeMakerAlg.h> +#include <AsgAnalysisAlgorithms/IOStatsAlg.h> #endif diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/IOStatsAlg.h b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/IOStatsAlg.h new file mode 100644 index 000000000000..30f2d3b32874 --- /dev/null +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/IOStatsAlg.h @@ -0,0 +1,31 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +/// @author Zhengcheng Tao + + +#ifndef ASG_IOSTATSALG_H +#define ASG_IOSTATSALG_H + +#include <AnaAlgorithm/AnaAlgorithm.h> +#include <AsgTools/PropertyWrapper.h> + +namespace CP { + + class IOStatsAlg final : public EL::AnaAlgorithm { + + public: + using EL::AnaAlgorithm::AnaAlgorithm; + + // finalize function: run once at the end of a job after event loop + virtual StatusCode finalize() override; + + private: + Gaudi::Property<std::string> m_printOption {this, "printOption", "Summary", "option to pass the standard ROOT printing function. Can be 'Summary', 'ByEntries' or 'ByBytes'."}; + + }; + +} // namespace + +#endif diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/selection.xml b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/selection.xml index af0a60c48c63..28c7f480d8f0 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/selection.xml +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/selection.xml @@ -34,5 +34,6 @@ <class name="CP::SystObjectUnioniserAlg" /> <class name="CP::TreeFillerAlg" /> <class name="CP::TreeMakerAlg" /> + <class name="CP::IOStatsAlg" /> </lcgdict> diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/IOStatsAlg.cxx b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/IOStatsAlg.cxx new file mode 100644 index 000000000000..16f0a7015595 --- /dev/null +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/IOStatsAlg.cxx @@ -0,0 +1,21 @@ +/* + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration +*/ + +/// @author Zhengcheng Tao + +#include <AsgAnalysisAlgorithms/IOStatsAlg.h> + +#include "xAODCore/tools/IOStats.h" +#include "xAODCore/tools/ReadStats.h" + +namespace CP { + + StatusCode IOStatsAlg::finalize() { + + xAOD::IOStats::instance().merged().Print(m_printOption.value().c_str()); + + return StatusCode::SUCCESS; + } + +} // namespace diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/python/AsgAnalysisConfig.py b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/python/AsgAnalysisConfig.py index 0a218e799d98..58ed908074c7 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/python/AsgAnalysisConfig.py +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/python/AsgAnalysisConfig.py @@ -82,6 +82,19 @@ class CommonServicesConfig (ConfigBlock) : sysDumper.histogramName = self.systematicsHistogram +class IOStatsBlock(ConfigBlock): + """Print what branches are used in analysis""" + + def __init__(self): + super(IOStatsBlock, self).__init__() + self.addOption("printOption", "Summary", type=str, + info='option to pass the standard ROOT printing function. Can be "Summary", "ByEntries" or "ByBytes".') + + def makeAlgs(self, config): + alg = config.createAlgorithm('CP::IOStatsAlg', 'IOStatsAlg') + alg.printOption = self.printOption + + class PileupReweightingBlock (ConfigBlock): """the ConfigBlock for pileup reweighting""" diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/src/components/AsgAnalysisAlgorithms_entries.cxx b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/src/components/AsgAnalysisAlgorithms_entries.cxx index c7475944fc10..36b36ce58a09 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/src/components/AsgAnalysisAlgorithms_entries.cxx +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/src/components/AsgAnalysisAlgorithms_entries.cxx @@ -37,6 +37,7 @@ #include <AsgAnalysisAlgorithms/TreeMakerAlg.h> #include "AsgAnalysisAlgorithms/SystObjectLinkerAlg.h" #include "AsgAnalysisAlgorithms/SystObjectUnioniserAlg.h" +#include "AsgAnalysisAlgorithms/IOStatsAlg.h" DECLARE_COMPONENT (CP::AsgFlagSelectionTool) DECLARE_COMPONENT (CP::AsgMaskSelectionTool) @@ -69,6 +70,7 @@ DECLARE_COMPONENT (CP::PMGTruthWeightAlg) DECLARE_COMPONENT (CP::SysListDumperAlg) DECLARE_COMPONENT (CP::TreeFillerAlg) DECLARE_COMPONENT (CP::TreeMakerAlg) +DECLARE_COMPONENT (CP::IOStatsAlg) DECLARE_COMPONENT (CP::SystObjectLinkerAlg) // Concrete classes of SystObjectUnioniserAlg DECLARE_COMPONENT (CP::SystJetUnioniserAlg) diff --git a/PhysicsAnalysis/Algorithms/ComponentFactoryPreloader/Root/ComponentFactoryPreloader.cxx b/PhysicsAnalysis/Algorithms/ComponentFactoryPreloader/Root/ComponentFactoryPreloader.cxx index 84e3ac428837..d979e2b08df9 100644 --- a/PhysicsAnalysis/Algorithms/ComponentFactoryPreloader/Root/ComponentFactoryPreloader.cxx +++ b/PhysicsAnalysis/Algorithms/ComponentFactoryPreloader/Root/ComponentFactoryPreloader.cxx @@ -38,6 +38,7 @@ #include <AsgAnalysisAlgorithms/SystObjectLinkerAlg.h> #include <AsgAnalysisAlgorithms/TreeFillerAlg.h> #include <AsgAnalysisAlgorithms/TreeMakerAlg.h> +#include <AsgAnalysisAlgorithms/IOStatsAlg.h> #include <EgammaAnalysisAlgorithms/EgammaCalibrationAndSmearingAlg.h> #include <EgammaAnalysisAlgorithms/EgammaIsGoodOQSelectionTool.h> #include <EgammaAnalysisAlgorithms/EgammaIsolationCorrectionAlg.h> @@ -151,6 +152,7 @@ namespace CP ANA_CHECK (asg::registerAlgorithmFactory<CP::TrigEventSelectionAlg>("CP::TrigEventSelectionAlg")); ANA_CHECK (asg::registerAlgorithmFactory<CP::TrigGlobalEfficiencyAlg>("CP::TrigGlobalEfficiencyAlg")); ANA_CHECK (asg::registerAlgorithmFactory<CP::VertexSelectionAlg>("CP::VertexSelectionAlg")); + ANA_CHECK (asg::registerAlgorithmFactory<CP::IOStatsAlg>("CP::IOStatsAlg")); ANA_CHECK (asg::registerToolFactory<AsgDeadHVCellRemovalTool> ("AsgDeadHVCellRemovalTool")); ANA_CHECK (asg::registerToolFactory<BTaggingSelectionTool> ("BTaggingSelectionTool")); -- GitLab