From 12485c9736dfc87bb99dbb81b5fd3cff0983d986 Mon Sep 17 00:00:00 2001 From: Dan Guest <dguest@cern.ch> Date: Wed, 19 Mar 2025 08:43:06 +0100 Subject: [PATCH] simplify dependencies --- .../CutBookkeeperUtils/CMakeLists.txt | 5 ++--- .../CutBookkeeperUtils/src/SumWeightAlg.cxx | 22 +++++++++++-------- .../CutBookkeeperUtils/src/SumWeightAlg.h | 14 +++++------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/CMakeLists.txt b/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/CMakeLists.txt index 129753125af..b420163cc2d 100644 --- a/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/CMakeLists.txt +++ b/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/CMakeLists.txt @@ -11,9 +11,8 @@ find_package( Boost COMPONENTS json) atlas_add_library(CutBookkeeperUtilsLib Root/OriginalAodCounts.cxx LINK_LIBRARIES - GaudiKernel AthenaBaseComps - AsgServicesLib - PATInterfaces + GaudiKernel + AthenaBaseComps PMGAnalysisInterfacesLib xAODCutFlow xAODMetaData diff --git a/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/src/SumWeightAlg.cxx b/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/src/SumWeightAlg.cxx index d9cfe05521b..5ca063e80d9 100644 --- a/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/src/SumWeightAlg.cxx +++ b/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/src/SumWeightAlg.cxx @@ -75,9 +75,14 @@ SumWeightAlg::SumWeightAlg( StatusCode SumWeightAlg::initialize() { + // register with incident service + ServiceHandle<IIncidentSvc> incSvc( "IncidentSvc", name() ); + CHECK( incSvc.retrieve() ); + // remove first to make sure it's not called twice + incSvc->removeListener( this, IncidentType::BeginInputFile ); + incSvc->addListener( this, IncidentType::BeginInputFile, 0, true ); - // ANA_CHECK (requestFileExecute()); - CHECK (m_truthWeightTool.retrieve()); + CHECK(m_truthWeightTool.retrieve()); if (!m_output_svc.empty()) { ATH_CHECK(m_output_svc.retrieve()); @@ -93,11 +98,11 @@ StatusCode SumWeightAlg::execute() void SumWeightAlg::handle(const Incident& inc) { - std::cout << "handling incident" << std::endl; + // skip all incidents beyond the start of input files if (inc.type() != IncidentType::BeginInputFile) return; - // ANA_MSG_DEBUG ("Updating CutBookkeeper information"); + ATH_MSG_DEBUG("Updating CutBookkeeper information"); // Retrieve complete CutBookkeeperContainer const xAOD::CutBookkeeperContainer *completeCBC{}; @@ -110,7 +115,7 @@ void SumWeightAlg::handle(const Incident& inc) const xAOD::CutBookkeeper *allEvents{}; for (const xAOD::CutBookkeeper *cbk : *completeCBC) { - // ANA_MSG_DEBUG ("Complete cbk name: " << cbk->name() << " - stream: " << cbk->inputStream()); + ATH_MSG_DEBUG("Complete cbk name: " << cbk->name() << " - stream: " << cbk->inputStream()); if (cbk->cycle() > maxCycle && isGoodBook(*cbk)) { @@ -148,7 +153,7 @@ void SumWeightAlg::handle(const Incident& inc) std::string cbkName = "CutBookkeepers_weight_" + std::to_string(index); if (!m_inputMetaStore->contains<xAOD::CutBookkeeperContainer>(cbkName)) { - // ANA_MSG_VERBOSE("No container named " << cbkName << "available"); + ATH_MSG_VERBOSE("No container named " << cbkName << "available"); continue; } @@ -166,8 +171,7 @@ void SumWeightAlg::handle(const Incident& inc) } -StatusCode SumWeightAlg :: -finalize () +StatusCode SumWeightAlg::finalize () { std::vector<CP::SystematicSet> systematics; @@ -175,7 +179,7 @@ finalize () for (const CP::SystematicVariation &variation : m_truthWeightTool->affectingSystematics()) { auto set = CP::SystematicSet({variation}); - // ANA_MSG_DEBUG("using systematic " << set.name()); + ATH_MSG_DEBUG("using systematic " << set.name()); systematics.emplace_back(set); } diff --git a/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/src/SumWeightAlg.h b/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/src/SumWeightAlg.h index d6547296429..5f608726692 100644 --- a/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/src/SumWeightAlg.h +++ b/PhysicsAnalysis/AnalysisCommon/CutBookkeeperUtils/src/SumWeightAlg.h @@ -6,17 +6,15 @@ #define SUM_EVENT_WEIGHT_WRITER_H #include "AthenaBaseComps/AthAlgorithm.h" -#include <GaudiKernel/IIncidentListener.h> -#include <AsgServices/ServiceHandle.h> -#include <PATInterfaces/SystematicSet.h> -#include <PMGAnalysisInterfaces/IPMGTruthWeightTool.h> -#include <xAODCutFlow/CutBookkeeper.h> -#include <AsgTools/PropertyWrapper.h> +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/IIncidentListener.h" +#include "PATInterfaces/SystematicSet.h" +#include "PMGAnalysisInterfaces/IPMGTruthWeightTool.h" +#include "xAODCutFlow/CutBookkeeper.h" +#include "HDF5Utils/IH5GroupSvc.h" #include "CutBookkeeperUtils/OriginalAodCounts.h" -#include "HDF5Utils/IH5GroupSvc.h" - class SumWeightAlg final : public AthAlgorithm, public IIncidentListener -- GitLab