ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetUncertainties
Root
PerJetFlavourUncertaintyComponent.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
JetUncertainties/PerJetFlavourUncertaintyComponent.h
"
6
#include "
JetUncertainties/Helpers.h
"
7
#include "TF1.h"
8
namespace
jet
9
{
10
12
// //
13
// Constructor/destructor/initialization //
14
// //
16
17
PerJetFlavourUncertaintyComponent::PerJetFlavourUncertaintyComponent
(
const
std::string& name)
18
:
UncertaintyComponent
(
ComponentHelper
(name),0)
19
,
m_absEta
(false)
20
,
m_labels
()
21
,
m_flavourType
(
FlavourComp
::UNKNOWN)
22
,
m_constrainZresponse
(false)
23
,
m_constrainZresponseFunc
(
"Zjet_qFrac_AntiKt4EMPFlow"
)
24
,
m_ZjetQuarkFrac
(nullptr)
25
{
26
JESUNC_NO_DEFAULT_CONSTRUCTOR
;
27
}
28
29
PerJetFlavourUncertaintyComponent::PerJetFlavourUncertaintyComponent
(
const
ComponentHelper
& component)
30
:
UncertaintyComponent
(component,1)
31
,
m_absEta
(
CompParametrization
::isAbsEta(component.parametrization))
32
,
m_labels
(component.truthLabels)
33
,
m_flavourType
(component.flavourType)
34
,
m_constrainZresponse
(component.constrainZresponse)
35
,
m_constrainZresponseFunc
(component.constrainZresponseFunc)
36
{
37
ATH_MSG_DEBUG
(
"Created PerJetFlavourUncertaintyComponent named "
<<
m_uncHistName
.Data());
38
}
39
40
PerJetFlavourUncertaintyComponent::PerJetFlavourUncertaintyComponent
(
const
PerJetFlavourUncertaintyComponent
& toCopy)
41
:
UncertaintyComponent
(toCopy)
42
,
m_absEta
(toCopy.
m_absEta
)
43
,
m_labels
(toCopy.
m_labels
)
44
,
m_flavourType
(toCopy.
m_flavourType
)
45
,
m_constrainZresponse
(toCopy.
m_constrainZresponse
)
46
,
m_constrainZresponseFunc
(toCopy.
m_constrainZresponseFunc
)
47
{
48
ATH_MSG_DEBUG
(
"Creating copy of PerJetFlavourUncertaintyComponent named "
<<
m_uncHistName
.Data());
49
}
50
51
PerJetFlavourUncertaintyComponent
*
PerJetFlavourUncertaintyComponent::clone
()
const
52
{
53
return
new
PerJetFlavourUncertaintyComponent
(*
this
);
54
}
55
56
StatusCode
PerJetFlavourUncertaintyComponent::initialize
(TFile* histFile)
57
{
58
// Call the base class first
59
if
(
UncertaintyComponent::initialize
(histFile).isFailure())
60
return
StatusCode::FAILURE;
61
62
// Ensure that the labels are sane
63
if
(
m_labels
.empty())
64
{
65
ATH_MSG_ERROR
(
"Specified a PerJetFlavourUncertaintyComponent without the associated labels to use: "
<<
getName
().
Data
());
66
return
StatusCode::FAILURE;
67
}
68
for
(
int
aLabel :
m_labels
)
69
{
70
if
(!
isSupportedLabel
(aLabel))
71
{
72
ATH_MSG_ERROR
(
"Unsupported label ID of "
<< aLabel <<
" in "
<<
getName
().
Data
());
73
return
StatusCode::FAILURE;
74
}
75
}
76
77
// Load TF1 for Z-jet gluon fraction
78
if
(
m_constrainZresponse
)
79
{
80
// Find the histogram by name
81
TObject* tmp_tf1 = histFile->Get(
m_constrainZresponseFunc
);
82
if
(!tmp_tf1)
83
{
84
ATH_MSG_ERROR
(Form(
"Histogram file does not contain a histogram named %s"
,
m_constrainZresponseFunc
.Data()));
85
return
StatusCode::FAILURE;
86
}
87
// Ensure the object is a TF1
88
m_ZjetQuarkFrac
=
dynamic_cast<
const
TF1*
>
(tmp_tf1);
89
if
(!
m_ZjetQuarkFrac
)
90
{
91
ATH_MSG_ERROR
(Form(
"Histogram file contains the expected key, but it's not a TF1* (%s)"
,
m_constrainZresponseFunc
.Data()));
92
return
StatusCode::FAILURE;
93
}
94
}
95
96
// Done checking the configuration
97
return
StatusCode::SUCCESS;
98
}
99
100
102
// //
103
// Validity and uncertainty retrieval //
104
// //
106
107
bool
PerJetFlavourUncertaintyComponent::getValidityImpl
(
const
xAOD::Jet
&
jet
,
const
xAOD::EventInfo
&)
const
108
{
109
return
!
m_validHist
? true :
getValidBool
(
m_validHist
->getValue(
jet
.pt()*
m_energyScale
,
m_absEta
? fabs(
jet
.eta()) :
jet
.eta()));
110
}
111
112
double
PerJetFlavourUncertaintyComponent::getUncertaintyImpl
(
const
xAOD::Jet
&
jet
,
const
xAOD::EventInfo
& eInfo)
const
113
{
114
return
getFlavourResponseUncertainty
(
jet
,eInfo);
115
}
116
117
double
PerJetFlavourUncertaintyComponent::getFlavourResponseUncertainty
(
const
xAOD::Jet
&
jet
,
const
xAOD::EventInfo
&)
const
118
{
119
// sigma_x = l_x * dR_x(x response modelling uncertainty)
120
// sigma_x is the flavour response uncertainty for jet type x
121
// l_x is the jet flavour label, and is 0 or 1
122
// dR_x is the response modelling uncertainty for jets of type x
123
// dR_x is typically taken as the difference in x response between Pythia and Herwig
124
125
// Check the jet label (is this uncertainty relevant?)
126
if
(!
checkTruthLabel
(
jet
))
127
return
0;
128
129
// This is a jet of the relevant type
130
// Now calculate and return the uncertainty
131
const
double
pT =
jet
.pt()*
m_energyScale
;
132
const
double
eta
=
m_absEta
? fabs(
jet
.eta()) :
jet
.eta();
133
134
FlavourComp::TypeEnum
ThisJetFlavourType =
FlavourComp::UNKNOWN
;
135
if
(
m_labels
.at(0)==21 ||
m_labels
.at(0)==0) ThisJetFlavourType =
FlavourComp::PerJetResponse_Gluon
;
136
else
if
(
m_labels
.at(0)==1 ||
m_labels
.at(0)==2 ||
m_labels
.at(0)==3) ThisJetFlavourType =
FlavourComp::PerJetResponse_LQ
;
137
else
if
(
m_labels
.at(0)==5) ThisJetFlavourType =
FlavourComp::PerJetResponse_B
;
138
else
if
(
m_labels
.at(0)==4 ) ThisJetFlavourType =
FlavourComp::PerJetResponse_C
;
139
140
// bool DoesItPass = false;
141
if
(
m_flavourType
== ThisJetFlavourType){
142
double
unc =
m_uncHist
->getValue(pT,
eta
);
143
if
(
m_constrainZresponse
){
144
if
(
m_flavourType
==
FlavourComp::PerJetResponse_Gluon
) unc *=
m_ZjetQuarkFrac
->Eval(pT);
145
if
(
m_flavourType
==
FlavourComp::PerJetResponse_LQ
) unc *= (
m_ZjetQuarkFrac
->Eval(pT)-1.0);
146
}
147
// Return the uncertainty
148
return
unc;
149
150
}
else
{
return
0;}
151
152
}
153
154
155
156
bool
PerJetFlavourUncertaintyComponent::isSupportedLabel
(
const
int
label
)
const
157
{
158
switch
(abs(
label
))
159
{
160
case
1:
// parton-label, up
161
case
2:
// parton-label, down
162
case
3:
// parton-label, strange
163
case
4:
// parton-label, charm
164
case
5:
// parton-label, bottom
165
case
21:
// parton-label, gluon
166
case
0:
// parton-label, PileUp/non-identified
167
return
true
;
168
default
:
169
return
false
;
170
}
171
}
172
173
bool
PerJetFlavourUncertaintyComponent::checkTruthLabel
(
const
xAOD::Jet
&
jet
)
const
174
{
175
static
const
SG::AuxElement::ConstAccessor<int> truthLabelAccessor (
"PartonTruthLabelID"
);
176
if
(!truthLabelAccessor.isAvailable(
jet
))
177
{
178
ATH_MSG_ERROR
(
"Unable to find PartonTruthLabelID on the jet"
);
179
return
JESUNC_ERROR_CODE
;
180
}
181
const
int
truthHighestEparton = abs(truthLabelAccessor(
jet
));
182
183
for
(
const
int
label
:
m_labels
)
184
if
(
label
== truthHighestEparton)
185
return
true
;
186
return
false
;
187
}
188
189
}
// end jet namespace
190
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
Data
@ Data
Definition
BaseObject.h:11
PerJetFlavourUncertaintyComponent.h
Helpers.h
JESUNC_ERROR_CODE
#define JESUNC_ERROR_CODE
Definition
Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:22
JESUNC_NO_DEFAULT_CONSTRUCTOR
#define JESUNC_NO_DEFAULT_CONSTRUCTOR
Definition
Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:23
jet::ComponentHelper
Definition
ConfigHelper.h:24
jet::PerJetFlavourUncertaintyComponent::m_constrainZresponseFunc
const TString m_constrainZresponseFunc
Definition
PerJetFlavourUncertaintyComponent.h:43
jet::PerJetFlavourUncertaintyComponent::m_ZjetQuarkFrac
const TF1 * m_ZjetQuarkFrac
Definition
PerJetFlavourUncertaintyComponent.h:44
jet::PerJetFlavourUncertaintyComponent::initialize
virtual StatusCode initialize(TFile *histFile)
Definition
PerJetFlavourUncertaintyComponent.cxx:56
jet::PerJetFlavourUncertaintyComponent::getUncertaintyImpl
virtual double getUncertaintyImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
Definition
PerJetFlavourUncertaintyComponent.cxx:112
jet::PerJetFlavourUncertaintyComponent::getValidityImpl
virtual bool getValidityImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
Definition
PerJetFlavourUncertaintyComponent.cxx:107
jet::PerJetFlavourUncertaintyComponent::m_constrainZresponse
const bool m_constrainZresponse
Definition
PerJetFlavourUncertaintyComponent.h:42
jet::PerJetFlavourUncertaintyComponent::m_flavourType
const FlavourComp::TypeEnum m_flavourType
Definition
PerJetFlavourUncertaintyComponent.h:41
jet::PerJetFlavourUncertaintyComponent::checkTruthLabel
bool checkTruthLabel(const xAOD::Jet &jet) const
Definition
PerJetFlavourUncertaintyComponent.cxx:173
jet::PerJetFlavourUncertaintyComponent::PerJetFlavourUncertaintyComponent
PerJetFlavourUncertaintyComponent(const ComponentHelper &component)
Definition
PerJetFlavourUncertaintyComponent.cxx:29
jet::PerJetFlavourUncertaintyComponent::clone
virtual PerJetFlavourUncertaintyComponent * clone() const
Definition
PerJetFlavourUncertaintyComponent.cxx:51
jet::PerJetFlavourUncertaintyComponent::getFlavourResponseUncertainty
double getFlavourResponseUncertainty(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
Definition
PerJetFlavourUncertaintyComponent.cxx:117
jet::PerJetFlavourUncertaintyComponent::m_absEta
const bool m_absEta
Definition
PerJetFlavourUncertaintyComponent.h:39
jet::PerJetFlavourUncertaintyComponent::m_labels
const std::vector< int > m_labels
Definition
PerJetFlavourUncertaintyComponent.h:40
jet::PerJetFlavourUncertaintyComponent::isSupportedLabel
bool isSupportedLabel(const int label) const
Definition
PerJetFlavourUncertaintyComponent.cxx:156
jet::UncertaintyComponent::m_energyScale
const float m_energyScale
Definition
UncertaintyComponent.h:55
jet::UncertaintyComponent::UncertaintyComponent
UncertaintyComponent(const ComponentHelper &component, const size_t numHist=1)
Definition
UncertaintyComponent.cxx:47
jet::UncertaintyComponent::getName
virtual TString getName() const
Definition
UncertaintyComponent.h:35
jet::UncertaintyComponent::getValidBool
virtual bool getValidBool(const double validity) const
Definition
UncertaintyComponent.cxx:301
jet::UncertaintyComponent::m_uncHistName
const TString m_uncHistName
Definition
UncertaintyComponent.h:51
jet::UncertaintyComponent::m_validHist
UncertaintyHistogram * m_validHist
Definition
UncertaintyComponent.h:61
jet::UncertaintyComponent::initialize
virtual StatusCode initialize(TFile *histFile)
Definition
UncertaintyComponent.cxx:96
jet::UncertaintyComponent::m_uncHist
UncertaintyHistogram * m_uncHist
Definition
UncertaintyComponent.h:60
label
std::string label(const std::string &format, int i)
Definition
label.h:19
jet::CompParametrization
Definition
UncertaintyEnum.h:43
jet::FlavourComp
Definition
UncertaintyEnum.h:175
jet::FlavourComp::TypeEnum
TypeEnum
Definition
UncertaintyEnum.h:177
jet::FlavourComp::PerJetResponse_LQ
@ PerJetResponse_LQ
Definition
UncertaintyEnum.h:184
jet::FlavourComp::UNKNOWN
@ UNKNOWN
Definition
UncertaintyEnum.h:178
jet::FlavourComp::PerJetResponse_B
@ PerJetResponse_B
Definition
UncertaintyEnum.h:185
jet::FlavourComp::PerJetResponse_Gluon
@ PerJetResponse_Gluon
Definition
UncertaintyEnum.h:183
jet::FlavourComp::PerJetResponse_C
@ PerJetResponse_C
Definition
UncertaintyEnum.h:186
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
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