ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetSubStructureMomentTools
src
Validator.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
JetSubStructureMomentTools/Validator.h
"
6
#include "
xAODJet/Jet.h
"
7
#include "
xAODJet/JetContainer.h
"
8
#include <TFile.h>
9
#include <TH1.h>
10
11
using namespace
std
;
12
13
Validator::Validator
(
const
std::string& name) :
14
AsgTool
(name),
15
m_histSvc
(
"THistSvc"
, name)
16
{
17
declareProperty
(
"InputContainer"
,
m_InputContainer
=
""
);
18
declareProperty
(
"FloatMoments"
,
m_FloatMoments
);
19
}
20
21
22
StatusCode
Validator::initialize
()
23
{
24
ATH_CHECK
(
m_histSvc
.retrieve() );
25
return
StatusCode::SUCCESS;
26
}
27
28
29
int
Validator::execute
()
const
30
{
31
// Get leading jet
32
const
xAOD::JetContainer
* jets =
nullptr
;
33
if
(!
evtStore
()->
contains<xAOD::JetContainer>
(
m_InputContainer
)) {
34
ATH_MSG_ERROR
(
"Unable to retrieve jets from collection: "
<<
m_InputContainer
);
35
return
1;
36
}
37
jets =
evtStore
()->retrieve<
const
xAOD::JetContainer
>(
m_InputContainer
);
38
if
(!jets)[[
unlikely
]]{
39
ATH_MSG_ERROR
(
"'jets' pointer is nullptr."
);
40
return
1;
41
}
42
if
(jets->empty())
return
0;
43
const
xAOD::Jet
*
jet
= jets->at(0);
// This assumes the container is sorted
44
45
// Loop over float moments
46
for
(
unsigned
int
i=0; i<
m_FloatMoments
.size(); i++) {
47
TH1 *outputHist{};
48
if
(
m_histSvc
->exists(
"/JetSubstructureMoments/"
+
m_FloatMoments
[i])) {
49
m_histSvc
->getHist(
"/JetSubstructureMoments/"
+
m_FloatMoments
[i], outputHist).ignore();
50
}
51
else
{
52
unsigned
int
nbins = 100;
53
float
xlow = 0, xhigh = 1.0;
54
if
(
m_FloatMoments
[i].
find
(
"Split"
) != string::npos ||
55
m_FloatMoments
[i] ==
"pt"
) {
56
nbins = 1000;
57
xhigh = 2000000;
58
}
59
else
if
(
m_FloatMoments
[i].
find
(
"Pull"
) != string::npos) {
60
if
(
m_FloatMoments
[i].
find
(
"PullMag"
) != string::npos) {
61
xhigh = 0.1;
62
nbins = 100;
63
}
64
else
{
65
xlow = -10;
66
xhigh = 10;
67
nbins = 200;
68
}
69
}
70
else
if
(
m_FloatMoments
[i].
find
(
"ShowerDeconstruction"
) != string::npos) {
71
xlow = -10;
72
xhigh = 10;
73
nbins = 100;
74
}
75
76
outputHist =
new
TH1F(
m_FloatMoments
[i].c_str(),
""
, nbins, xlow, xhigh);
77
StatusCode
sc
=
m_histSvc
->regHist(
"/JetSubstructureMoments/"
+
m_FloatMoments
[i], outputHist);
78
if
(
sc
.isFailure()) {
79
ATH_MSG_ERROR
(
"Unable to register histogram"
);
80
return
1;
81
}
82
}
83
84
if
(
m_FloatMoments
[i] ==
"pt"
) {
85
outputHist->Fill(
jet
->pt());
86
}
87
else
{
88
outputHist->Fill(
jet
->getAttribute<
float
>(
m_FloatMoments
[i].c_str()));
89
}
90
}
91
92
return
0;
93
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
Jet.h
JetContainer.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
Validator.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
Validator::m_InputContainer
std::string m_InputContainer
Definition
Validator.h:29
Validator::m_FloatMoments
std::vector< std::string > m_FloatMoments
Definition
Validator.h:30
Validator::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition
Validator.h:31
Validator::Validator
Validator(const std::string &name)
Definition
Validator.cxx:13
Validator::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
Validator.cxx:22
Validator::execute
virtual int execute() const override
Method to be called for each event.
Definition
Validator.cxx:29
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
std
STL namespace.
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
unlikely
#define unlikely(x)
Definition
pythonic_coracool.cxx:9
Generated on
for ATLAS Offline Software by
1.17.0