ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
SysListDumperAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
8
//
9
// includes
10
//
11
12
#include <regex>
13
#include <
AsgAnalysisAlgorithms/SysListDumperAlg.h
>
14
#include <TH1.h>
15
16
//
17
// method implementations
18
//
19
20
namespace
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
32
try
33
{
34
std::regex expr (
m_regex
.value());
35
}
catch
(
const
std::regex_error&
e
)
36
{
37
ANA_MSG_ERROR
(
"invalid systematics regex '"
<<
m_regex
.value() <<
"': "
<<
e
.what());
38
return
StatusCode::FAILURE;
39
}
40
41
ANA_CHECK
(
m_systematicsService
.retrieve());
42
43
return
StatusCode::SUCCESS;
44
}
45
46
47
48
StatusCode SysListDumperAlg ::
49
execute (
const
EventContext&
/*ctx*/
)
50
{
51
if
(!
m_firstEvent
)
52
{
53
return
StatusCode::SUCCESS;
54
}
55
56
m_firstEvent
=
false
;
57
58
const
std::vector<CP::SystematicSet>
systematics
=
makeSystematicsVector
(
m_regex
);
59
if
(
systematics
.empty()) {
60
return
StatusCode::SUCCESS;
61
}
62
63
ANA_CHECK
(
book
(TH1F (
m_histogramName
.value().c_str(),
"systematics"
,
systematics
.size(), 0,
systematics
.size())));
64
TH1 *
histogram
=
hist
(
m_histogramName
);
65
66
int
i = 1;
67
const
std::string sysSignatureStr{
"%SYS%"
};
68
for
(
const
SystematicSet
& sys :
systematics
)
69
{
70
std::string
name
;
71
ANA_CHECK
(
m_systematicsService
->makeSystematicsName (
name
, sysSignatureStr, sys));
72
73
histogram
->GetXaxis()->SetBinLabel(i,
name
.c_str());
74
i++;
75
}
76
77
return
StatusCode::SUCCESS;
78
}
79
80
81
82
std::vector<CP::SystematicSet> SysListDumperAlg ::
83
makeSystematicsVector (
const
std::string ®ex)
const
84
{
85
std::vector<CP::SystematicSet> inputVector =
m_systematicsService
->makeSystematicsVector ();
86
if
(regex.empty())
87
{
88
return
inputVector;
89
}
90
91
std::vector<CP::SystematicSet> systematicsVector;
92
std::regex expr (regex);
93
for
(
const
CP::SystematicSet
& sys : inputVector)
94
{
95
if
(regex_match (sys.name(), expr))
96
{
97
systematicsVector.push_back (sys);
98
}
99
}
100
return
systematicsVector;
101
}
102
103
104
StatusCode SysListDumperAlg ::
105
finalize ()
106
{
107
const
std::vector<CP::SystematicSet>
systematics
=
makeSystematicsVector
(
m_regex
);
108
if
(
systematics
.empty()) {
109
ANA_MSG_INFO
(
"systematics regex '"
<<
m_regex
.value() <<
"' did not match any systematics"
);
110
return
StatusCode::SUCCESS;
111
}
112
113
ANA_MSG_INFO
(
"Systematics regex '"
<<
m_regex
.value() <<
"' matched:"
);
114
for
(
const
CP::SystematicSet
& mysys :
systematics
) {
115
ANA_MSG_INFO
(
" '"
<< mysys.name() <<
"'"
);
116
}
117
return
StatusCode::SUCCESS;
118
}
119
}
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg,...)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:295
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg,...)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:291
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:325
systematics
static const std::vector< std::string > systematics
Definition
MuonTriggerSFFilesTest.cxx:23
SysListDumperAlg.h
histogram
std::string histogram
Definition
chains.cxx:52
AthHistogramming::hist
TH1 * hist(std::string_view histName, std::string_view tDir="", std::string_view stream="")
Simplify the retrieval of registered histograms of any type.
Definition
AthHistogramming.cxx:182
AthHistogramming::book
StatusCode book(const TH1 &hist, std::string_view tDir="", std::string_view stream="")
Simplify the booking and registering (into THistSvc) of histograms.
Definition
AthHistogramming.h:297
CP::SysListDumperAlg::m_firstEvent
bool m_firstEvent
whether the next event will be the first event
Definition
SysListDumperAlg.h:51
CP::SysListDumperAlg::m_regex
Gaudi::Property< std::string > m_regex
the regex
Definition
SysListDumperAlg.h:43
CP::SysListDumperAlg::makeSystematicsVector
std::vector< CP::SystematicSet > makeSystematicsVector(const std::string ®ex) const
make the systematics vector using a regex
Definition
SysListDumperAlg.cxx:83
CP::SysListDumperAlg::m_systematicsService
ServiceHandle< ISystematicsSvc > m_systematicsService
the handle for the systematics service
Definition
SysListDumperAlg.h:39
CP::SysListDumperAlg::m_histogramName
Gaudi::Property< std::string > m_histogramName
the name of the histogram to use
Definition
SysListDumperAlg.h:47
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition
SystematicSet.h:31
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::e
setPy e
Definition
CompositeParticle_v1.cxx:166
Generated on
for ATLAS Offline Software by
1.17.0