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
ANA_CHECK
(
m_systematicsService
.retrieve());
33
34
return
StatusCode::SUCCESS;
35
}
36
37
38
39
StatusCode SysListDumperAlg ::
40
execute (
const
EventContext&
/*ctx*/
)
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
if
(
systematics
.empty()) {
51
return
StatusCode::SUCCESS;
52
}
53
54
ANA_CHECK
(
book
(TH1F (
m_histogramName
.value().c_str(),
"systematics"
,
systematics
.size(), 0,
systematics
.size())));
55
TH1 *
histogram
=
hist
(
m_histogramName
);
56
57
int
i = 1;
58
const
std::string sysSignatureStr{
"%SYS%"
};
59
for
(
const
SystematicSet
& sys :
systematics
)
60
{
61
std::string
name
;
62
ANA_CHECK
(
m_systematicsService
->makeSystematicsName (
name
, sysSignatureStr, sys));
63
64
histogram
->GetXaxis()->SetBinLabel(i,
name
.c_str());
65
i++;
66
}
67
68
return
StatusCode::SUCCESS;
69
}
70
71
72
73
std::vector<CP::SystematicSet> SysListDumperAlg ::
74
makeSystematicsVector (
const
std::string ®ex)
const
75
{
76
std::vector<CP::SystematicSet> inputVector =
m_systematicsService
->makeSystematicsVector ();
77
if
(regex.empty())
78
{
79
return
inputVector;
80
}
81
82
std::vector<CP::SystematicSet> systematicsVector;
83
std::regex expr (regex);
84
for
(
const
CP::SystematicSet
& sys : inputVector)
85
{
86
if
(regex_match (sys.name(), expr))
87
{
88
systematicsVector.push_back (sys);
89
}
90
}
91
return
systematicsVector;
92
}
93
94
95
StatusCode SysListDumperAlg ::
96
finalize ()
97
{
98
const
std::vector<CP::SystematicSet>
systematics
=
makeSystematicsVector
(
m_regex
);
99
if
(
systematics
.empty()) {
100
ANA_MSG_INFO
(
"systematics regex '"
<<
m_regex
.value() <<
"' did not match any systematics"
);
101
return
StatusCode::SUCCESS;
102
}
103
104
ANA_MSG_INFO
(
"Systematics regex '"
<<
m_regex
.value() <<
"' matched:"
);
105
for
(
const
CP::SystematicSet
& mysys :
systematics
) {
106
ANA_MSG_INFO
(
" '"
<< mysys.name() <<
"'"
);
107
}
108
return
StatusCode::SUCCESS;
109
}
110
}
ANA_MSG_INFO
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:290
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
systematics
static const std::vector< std::string > systematics
Definition
MuonTriggerSFFilesTest.cxx:23
SysListDumperAlg.h
histogram
std::string histogram
Definition
chains.cxx:52
AthHistogramming::book
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
Definition
AthHistogramming.h:305
AthHistogramming::hist
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
Definition
AthHistogramming.cxx:164
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:74
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
Generated on
for ATLAS Offline Software by
1.17.0