ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
Root
KinematicHistAlg.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 <
AsgAnalysisAlgorithms/KinematicHistAlg.h
>
13
14
#include <
RootCoreUtils/StringUtil.h
>
15
#include <TH1.h>
16
17
//
18
// method implementations
19
//
20
21
namespace
CP
22
{
23
24
StatusCode KinematicHistAlg ::
25
initialize ()
26
{
27
ANA_CHECK
(
m_inputHandle
.initialize (
m_systematicsList
));
28
ANA_CHECK
(
m_preselection
.initialize (
m_systematicsList
,
m_inputHandle
,
SG::AllowEmpty
));
29
ANA_CHECK
(
m_systematicsList
.initialize());
30
return
StatusCode::SUCCESS;
31
}
32
33
34
35
StatusCode KinematicHistAlg ::
36
execute (
const
EventContext& ctx)
37
{
38
for
(
const
auto
& sys :
m_systematicsList
.systematicsVector())
39
{
40
const
xAOD::IParticleContainer
*input =
nullptr
;
41
ANA_CHECK
(
m_inputHandle
.retrieve (input, sys, ctx));
42
43
auto
histIter =
m_hist
.find (sys);
44
if
(histIter ==
m_hist
.end())
45
{
46
std::string
name
;
47
HistGroup
group;
48
49
name
=
RCU::substitute
(
m_histPattern
.value(),
"%VAR%"
,
"multiplicity"
);
50
ANA_CHECK
(
m_systematicsList
.service().makeSystematicsName (
name
,
name
, sys));
51
ANA_CHECK
(
book
(TH1F (
name
.c_str(),
"multiplicity"
, 20, 0, 20)));
52
group.multiplicity =
hist
(
name
);
53
54
m_hist
.insert (std::make_pair (sys, group));
55
histIter =
m_hist
.find (sys);
56
assert (histIter !=
m_hist
.end());
57
}
58
59
std::size_t
count
= 0;
60
for
(std::size_t iter = 0; iter != input->size(); ++ iter)
61
{
62
const
xAOD::IParticle
*particle = (*input)[iter];
63
if
(
m_preselection
.getBool (*particle, sys))
64
{
65
while
(histIter->second.perObject.size() <=
count
)
66
{
67
std::string
name
;
68
HistSubgroup
group;
69
70
name
=
RCU::substitute
(
m_histPattern
.value(),
"%VAR%"
,
"pt"
+ std::to_string(histIter->second.perObject.size()));
71
ANA_CHECK
(
m_systematicsList
.service().makeSystematicsName (
name
,
name
, sys));
72
ANA_CHECK
(
book
(TH1F (
name
.c_str(),
"pt"
, 20, 0, 200e3)));
73
group.pt =
hist
(
name
);
74
75
name
=
RCU::substitute
(
m_histPattern
.value(),
"%VAR%"
,
"eta"
+ std::to_string(histIter->second.perObject.size()));
76
ANA_CHECK
(
m_systematicsList
.service().makeSystematicsName (
name
,
name
, sys));
77
ANA_CHECK
(
book
(TH1F (
name
.c_str(),
"eta"
, 20, -5, 5)));
78
group.eta =
hist
(
name
);
79
80
name
=
RCU::substitute
(
m_histPattern
.value(),
"%VAR%"
,
"phi"
+ std::to_string(histIter->second.perObject.size()));
81
ANA_CHECK
(
m_systematicsList
.service().makeSystematicsName (
name
,
name
, sys));
82
ANA_CHECK
(
book
(TH1F (
name
.c_str(),
"phi"
, 20, -
M_PI
,
M_PI
)));
83
group.phi =
hist
(
name
);
84
85
histIter->second.perObject.push_back (group);
86
}
87
88
HistSubgroup
& group = histIter->second.perObject[
count
];
89
90
group.pt->Fill (particle->pt());
91
group.eta->Fill (particle->eta());
92
group.phi->Fill (particle->phi());
93
count
+= 1;
94
}
95
}
96
97
histIter->second.multiplicity->Fill (
count
);
98
}
99
return
StatusCode::SUCCESS;
100
}
101
}
M_PI
#define M_PI
Definition
ActiveFraction.h:14
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
KinematicHistAlg.h
StringUtil.h
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::KinematicHistAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition
KinematicHistAlg.h:37
CP::KinematicHistAlg::m_histPattern
Gaudi::Property< std::string > m_histPattern
the pattern for histogram names
Definition
KinematicHistAlg.h:51
CP::KinematicHistAlg::m_hist
std::unordered_map< CP::SystematicSet, HistGroup > m_hist
the created histograms
Definition
KinematicHistAlg.h:74
CP::KinematicHistAlg::m_inputHandle
SysReadHandle< xAOD::IParticleContainer > m_inputHandle
the jet collection we run on
Definition
KinematicHistAlg.h:41
CP::KinematicHistAlg::m_preselection
SysReadSelectionHandle m_preselection
the preselection we apply to our input
Definition
KinematicHistAlg.h:46
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
count
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
Definition
hcg.cxx:148
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
RCU::substitute
std::string substitute(std::string_view str, std::string_view pattern, std::string_view with)
effects: substitute all occurences of "pattern" with "with" in the string "str" returns: the substitu...
Definition
StringUtil.cxx:14
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
xAOD::name
name
Definition
TriggerMenuJson_v1.cxx:29
xAOD::IParticleContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Definition
xAOD/xAODBase/xAODBase/IParticleContainer.h:32
CP::KinematicHistAlg::HistGroup
the histograms we fill per systematic
Definition
KinematicHistAlg.h:67
CP::KinematicHistAlg::HistSubgroup
the histograms we fill per systematic and object
Definition
KinematicHistAlg.h:57
Generated on
for ATLAS Offline Software by
1.17.0