diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/SysListDumperAlg.h b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/SysListDumperAlg.h index ea35718fa83e9efa66e65b7003355df80a72adae..a3ca251a74d6a44a42b70dfa774670a6e9a82c79 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 b88ee2198b95929f0e9dbc2a5be82bdefb322de3..b3dd1f1ac0c3e27ee030f4da2528a20aac0d5fe4 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; + } + }