ATLAS Offline Software
Loading...
Searching...
No Matches
SysListDumperAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8//
9// includes
10//
11
12#include <regex>
14#include <TH1.h>
15
16//
17// method implementations
18//
19
20namespace CP
21{
22
23 StatusCode SysListDumperAlg ::
24 initialize ()
25 {
26 if (m_histogramName.empty())
27 {
28 ANA_MSG_ERROR ("histogram name should not be empty");
29 return StatusCode::FAILURE;
30 }
31
33
34 return StatusCode::SUCCESS;
35 }
36
37
38
39 StatusCode SysListDumperAlg ::
40 execute ()
41 {
42 if (!m_firstEvent)
43 {
44 return StatusCode::SUCCESS;
45 }
46
47 m_firstEvent = false;
48
49 const std::vector<CP::SystematicSet> systematics = makeSystematicsVector (m_regex);
50
51 ANA_CHECK (book (TH1F (m_histogramName.value().c_str(), "systematics", systematics.size(), 0, systematics.size())));
53
54 int i = 1;
55 for (const auto& sys : systematics)
56 {
57 std::string name;
58 ANA_CHECK (m_systematicsService->makeSystematicsName (name, "%SYS%", sys));
59
60 histogram->GetXaxis()->SetBinLabel(i, name.c_str());
61 i++;
62 }
63
64 return StatusCode::SUCCESS;
65 }
66
67
68
69 std::vector<CP::SystematicSet> SysListDumperAlg ::
70 makeSystematicsVector (const std::string &regex) const
71 {
72 std::vector<CP::SystematicSet> inputVector = m_systematicsService->makeSystematicsVector ();
73 if (regex.empty())
74 {
75 return inputVector;
76 }
77
78 std::vector<CP::SystematicSet> systematicsVector;
79 std::regex expr (regex);
80 for (const CP::SystematicSet& sys : inputVector)
81 {
82 if (regex_match (sys.name(), expr))
83 {
84 systematicsVector.push_back (sys);
85 }
86 }
87 return systematicsVector;
88 }
89
90
91 StatusCode SysListDumperAlg ::
92 finalize ()
93 {
94 ANA_MSG_INFO("Systematics regex '" << m_regex << "' matched:");
96 ANA_MSG_INFO (" '" << mysys.name() << "'");
97 }
98 return StatusCode::SUCCESS;
99 }
100}
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
static const std::vector< std::string > systematics
std::string histogram
Definition chains.cxx:52
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
bool m_firstEvent
whether the next event will be the first event
Gaudi::Property< std::string > m_regex
the regex
std::vector< CP::SystematicSet > makeSystematicsVector(const std::string &regex) const
make the systematics vector using a regex
ServiceHandle< ISystematicsSvc > m_systematicsService
the handle for the systematics service
Gaudi::Property< std::string > m_histogramName
the name of the histogram to use
Class to wrap a set of SystematicVariations.
Select isolated Photons, Electrons and Muons.