ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
EventCutFlowHistAlg.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 <
AsgAnalysisAlgorithms/EventCutFlowHistAlg.h
>
13
14
#include <TH1.h>
15
16
//
17
// method implementations
18
//
19
20
namespace
CP
21
{
22
23
StatusCode EventCutFlowHistAlg ::
24
initialize ()
25
{
26
ANA_CHECK
(
m_eventInfoHandle
.initialize (
m_systematicsList
));
27
ANA_CHECK
(
m_preselection
.initialize (
m_systematicsList
,
m_eventInfoHandle
,
SG::AllowEmpty
));
28
ANA_CHECK
(
m_selections
.initialize (
m_systematicsList
,
m_eventInfoHandle
));
29
ANA_CHECK
(
m_systematicsList
.initialize());
30
31
// Total label
32
m_labels
.push_back (
"total"
);
33
// Individual labels
34
for
(
size_t
i{}; i <
m_selections
.size(); i++) {
35
std::string
label
=
m_selections
.at(i).getSelectionName();
36
// Check if the string ends with "_%SYS%"
37
if
(
label
.size() >= 6 &&
label
.substr(
label
.size() - 6) ==
"_%SYS%"
) {
38
// Remove "_%SYS%" from the end of the string
39
label
.erase(
label
.size() - 6);
40
}
41
m_labels
.push_back (std::move(
label
));
42
m_allCutsNum
++;
43
}
44
assert (
m_allCutsNum
+1 ==
m_labels
.size());
45
46
return
StatusCode::SUCCESS;
47
}
48
49
StatusCode EventCutFlowHistAlg ::
50
execute (
const
EventContext& ctx)
51
{
52
for
(
const
auto
& sys :
m_systematicsList
.systematicsVector())
53
{
54
const
xAOD::EventInfo
*evtInfo =
nullptr
;
55
ANA_CHECK
(
m_eventInfoHandle
.retrieve (evtInfo, sys, ctx));
56
57
auto
histIter =
m_hist
.find (sys);
58
if
(histIter ==
m_hist
.end())
59
{
60
std::string
name
;
61
ANA_CHECK
(
m_systematicsList
.service().makeSystematicsName (
name
,
m_histPattern
, sys));
62
63
std::string title =
m_histTitle
.value();
64
if
(!sys.empty())
65
title +=
" ("
+ sys.name() +
")"
;
66
ANA_CHECK
(
book
(TH1F (
name
.c_str(), title.c_str(),
m_allCutsNum
+1, 0,
m_allCutsNum
+1)));
67
68
m_hist
.insert (std::make_pair (sys,
hist
(
name
)));
69
histIter =
m_hist
.find (sys);
70
assert (histIter !=
m_hist
.end());
71
72
for
(
unsigned
i = 0; i <
m_allCutsNum
+1; i++)
73
{
74
histIter->second->GetXaxis()->SetBinLabel(i + 1,
m_labels
[i].c_str());
75
}
76
}
77
78
if
(
m_preselection
.getBool (*evtInfo, sys)) {
79
unsigned
cutIndex = 1;
80
histIter->second->Fill (0);
81
for
(
size_t
i{}; i <
m_selections
.size(); i++) {
82
if
(
m_selections
.at(i).getBool (*evtInfo, sys)) {
83
histIter->second->Fill (cutIndex);
84
}
85
cutIndex++;
86
}
87
}
88
}
89
return
StatusCode::SUCCESS;
90
}
91
}
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:325
EventCutFlowHistAlg.h
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::EventCutFlowHistAlg::m_labels
std::vector< std::string > m_labels
histogram bin labels
Definition
EventCutFlowHistAlg.h:69
CP::EventCutFlowHistAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition
EventCutFlowHistAlg.h:33
CP::EventCutFlowHistAlg::m_histTitle
Gaudi::Property< std::string > m_histTitle
the histogram title to use
Definition
EventCutFlowHistAlg.h:51
CP::EventCutFlowHistAlg::m_selections
SysReadSelectionHandleArray m_selections
the input object selections for which to create a cutflow
Definition
EventCutFlowHistAlg.h:55
CP::EventCutFlowHistAlg::m_hist
std::unordered_map< CP::SystematicSet, TH1 * > m_hist
the created histograms
Definition
EventCutFlowHistAlg.h:65
CP::EventCutFlowHistAlg::m_eventInfoHandle
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the jet collection we run on
Definition
EventCutFlowHistAlg.h:37
CP::EventCutFlowHistAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition
EventCutFlowHistAlg.h:42
CP::EventCutFlowHistAlg::m_histPattern
Gaudi::Property< std::string > m_histPattern
the pattern for histogram names
Definition
EventCutFlowHistAlg.h:47
CP::EventCutFlowHistAlg::m_allCutsNum
unsigned m_allCutsNum
the total number of cuts configured (needed to configure histograms)
Definition
EventCutFlowHistAlg.h:61
label
std::string label(const std::string &format, int i)
Definition
label.h:19
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:29
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
Generated on
for ATLAS Offline Software by
1.17.0