From 4e7257f4da80d5f5b29559ff672613c6d28004a6 Mon Sep 17 00:00:00 2001 From: Nils Erik Krumnack Date: Wed, 13 Oct 2021 15:54:54 +0200 Subject: [PATCH] Merge branch 'cp/dump' into '21.2' Fix SysListDumperAlg See merge request atlas/athena!47107 (cherry picked from commit 6c7d3c40ec48bb458487e438cf2de0111340e05b) 07f3973e Fix SysListDumperAlg --- .../AsgAnalysisAlgorithms/SysListDumperAlg.h | 12 +++++-- .../Root/SysListDumperAlg.cxx | 35 ++++++++++++++++--- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/SysListDumperAlg.h b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/SysListDumperAlg.h index ea35718fa83..a3ca251a74d 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/SysListDumperAlg.h +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/SysListDumperAlg.h @@ -9,6 +9,7 @@ #define ASG_ANALYSIS_ALGORITHMS__SYS_LIST_DUMPER_ALG_H #include +#include #include namespace CP @@ -32,10 +33,17 @@ namespace CP public: virtual ::StatusCode execute () override; + /// \brief make the systematics vector using a regex + private: + std::vector makeSystematicsVector (const std::string ®ex) const; + + /// \brief the handle for the systematics service + private: + ServiceHandle m_systematicsService {"SystematicsSvc", ""}; - /// \brief the systematics list we run + /// \brief the regex private: - SysListHandle m_systematicsList {this}; + std::string m_regex {}; /// \brief the name of the histogram to use private: diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/SysListDumperAlg.cxx b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/SysListDumperAlg.cxx index b88ee2198b9..b3dd1f1ac0c 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/SysListDumperAlg.cxx +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/SysListDumperAlg.cxx @@ -9,6 +9,7 @@ // includes // +#include #include #include @@ -23,6 +24,8 @@ namespace CP ISvcLocator* pSvcLocator) : AnaAlgorithm (name, pSvcLocator) { + declareProperty ("systematicsService", m_systematicsService, "systematics service"); + declareProperty ("systematicsRegex", m_regex, "systematics regex"); declareProperty ("histogramName", m_histogramName, "the name of the output histogram"); } @@ -37,7 +40,7 @@ namespace CP return StatusCode::FAILURE; } - ANA_CHECK (m_systematicsList.initialize()); + ANA_CHECK (m_systematicsService.retrieve()); return StatusCode::SUCCESS; } @@ -54,16 +57,16 @@ namespace CP m_firstEvent = false; - const auto& systematics = m_systematicsList.systematicsVector(); + const std::vector systematics = makeSystematicsVector (m_regex); ANA_CHECK (book (TH1F (m_histogramName.c_str(), "systematics", systematics.size(), 0, systematics.size()))); TH1 *histogram = hist (m_histogramName); int i = 1; - for (const auto& sys : m_systematicsList.systematicsVector()) + for (const auto& sys : systematics) { std::string name; - ANA_CHECK (m_systematicsList.service().makeSystematicsName (name, "%SYS%", sys)); + ANA_CHECK (m_systematicsService->makeSystematicsName (name, "%SYS%", sys)); histogram->GetXaxis()->SetBinLabel(i, name.c_str()); i++; @@ -71,4 +74,28 @@ namespace CP return StatusCode::SUCCESS; } + + + + std::vector SysListDumperAlg :: + makeSystematicsVector (const std::string ®ex) const + { + std::vector inputVector = m_systematicsService->makeSystematicsVector (); + if (regex.empty()) + { + return inputVector; + } + + std::vector systematicsVector; + std::regex expr (regex); + for (const CP::SystematicSet& sys : inputVector) + { + if (regex_match (sys.name(), expr)) + { + systematicsVector.push_back (sys); + } + } + return systematicsVector; + } + } -- GitLab