ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetUncertainties
Root
PileupUncertaintyComponent.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
JetUncertainties/PileupUncertaintyComponent.h
"
6
#include "
JetUncertainties/Helpers.h
"
7
8
#include "TFile.h"
9
10
namespace
jet
11
{
12
14
// //
15
// Constructor/destructor/initialization //
16
// //
18
19
PileupUncertaintyComponent::PileupUncertaintyComponent
(
const
std::string& name)
20
:
UncertaintyComponent
(
ComponentHelper
(name),0)
21
,
m_pileupType
(
PileupComp
::UNKNOWN)
22
,
m_refNPV
(-1)
23
,
m_refMu
(-1)
24
,
m_refNPVHist
(nullptr)
25
,
m_refMuHist
(nullptr)
26
,
m_absEta
(false)
27
,
m_secondUncName
(
""
)
28
,
m_secondUncHist
(nullptr)
29
,
m_refType
(
PileupRef_UNKNOWN
)
30
,
m_secondRefType
(
PileupRef_UNKNOWN
)
31
{
32
JESUNC_NO_DEFAULT_CONSTRUCTOR
;
33
}
34
35
PileupUncertaintyComponent::PileupUncertaintyComponent
(
const
ComponentHelper
& component,
36
const
float
refNPV,
37
const
float
refMu
38
)
39
:
UncertaintyComponent
(component,component.pileupType ==
PileupComp
::PtTerm ? 2 : 1)
40
,
m_pileupType
(component.pileupType)
41
,
m_refNPV
(refNPV)
42
,
m_refMu
(refMu)
43
,
m_refNPVHist
(nullptr)
44
,
m_refMuHist
(nullptr)
45
,
m_absEta
(
CompParametrization
::isAbsEta(component.parametrization))
46
,
m_secondUncName
(component.uncNames.
size
()>1?component.uncNames.at(1):
""
)
47
,
m_secondUncHist
(nullptr)
48
,
m_refType
(
PileupRef_UNKNOWN
)
49
,
m_secondRefType
(
PileupRef_UNKNOWN
)
50
{
51
ATH_MSG_DEBUG
(
"Created PileupUncertaintyComponent named"
<<
m_uncHistName
.Data());
52
53
// Ensure that the pileup type and ref values are sensible
54
if
(
m_pileupType
==
PileupComp::UNKNOWN
)
55
ATH_MSG_FATAL
(
"Pileup type is UNKNOWN: "
<<
m_uncHistName
.Data());
56
if
(
m_refNPV
<= 0 ||
m_refMu
<= 0)
57
ATH_MSG_FATAL
(Form(
"Unexpected pileup reference values. (NPV,mu)=(%.1f,%.1f) for %s"
,
m_refNPV
,
m_refMu
,
m_uncHistName
.Data()));
58
}
59
60
PileupUncertaintyComponent::PileupUncertaintyComponent
(
const
ComponentHelper
& component,
61
const
UncertaintyHistogram
* refNPV,
62
const
UncertaintyHistogram
* refMu
63
)
64
:
UncertaintyComponent
(component,component.pileupType ==
PileupComp
::PtTerm ? 2 : 1)
65
,
m_pileupType
(component.pileupType)
66
,
m_refNPV
(-1)
67
,
m_refMu
(-1)
68
,
m_refNPVHist
(refNPV)
69
,
m_refMuHist
(refMu)
70
,
m_absEta
(
CompParametrization
::isAbsEta(component.parametrization))
71
,
m_secondUncName
(component.uncNames.
size
()>1?component.uncNames.at(1):
""
)
72
,
m_secondUncHist
(nullptr)
73
,
m_refType
(
PileupRef_UNKNOWN
)
74
,
m_secondRefType
(
PileupRef_UNKNOWN
)
75
{
76
ATH_MSG_DEBUG
(
"Created PileupUncertaintyComponent named"
<<
m_uncHistName
.Data());
77
78
// Ensure that the pileup type and ref values are sensible
79
if
(
m_pileupType
==
PileupComp::UNKNOWN
)
80
ATH_MSG_FATAL
(
"Pileup type is UNKNOWN: "
<<
m_uncHistName
.Data());
81
if
(!
m_refNPV
|| !
m_refMu
)
82
ATH_MSG_FATAL
(Form(
"Unexpected pileup reference values. (NPV,mu)=(%s,%s) for %s"
,
m_refNPVHist
?
"OK"
:
"NULL"
,
m_refMuHist
?
"OK"
:
"NULL"
,
m_uncHistName
.Data()));
83
}
84
85
PileupUncertaintyComponent::PileupUncertaintyComponent
(
const
ComponentHelper
& component,
86
const
UncertaintyHistogram
* refNPV,
87
const
float
refMu
88
)
89
:
UncertaintyComponent
(component,component.pileupType ==
PileupComp
::PtTerm ? 2 : 1)
90
,
m_pileupType
(component.pileupType)
91
,
m_refNPV
(-1)
92
,
m_refMu
(refMu)
93
,
m_refNPVHist
(refNPV)
94
,
m_refMuHist
(nullptr)
95
,
m_absEta
(
CompParametrization
::isAbsEta(component.parametrization))
96
,
m_secondUncName
(component.uncNames.
size
()>1?component.uncNames.at(1):
""
)
97
,
m_secondUncHist
(nullptr)
98
,
m_refType
(
PileupRef_UNKNOWN
)
99
,
m_secondRefType
(
PileupRef_UNKNOWN
)
100
{
101
ATH_MSG_DEBUG
(
"Created PileupUncertaintyComponent named"
<<
m_uncHistName
.Data());
102
103
// Ensure that the pileup type and ref values are sensible
104
if
(
m_pileupType
==
PileupComp::UNKNOWN
)
105
ATH_MSG_FATAL
(
"Pileup type is UNKNOWN: "
<<
m_uncHistName
.Data());
106
if
(!
m_refNPV
||
m_refMu
<= 0)
107
ATH_MSG_FATAL
(Form(
"Unexpected pileup reference values. (NPV,mu)=(%s,%.1f) for %s"
,
m_refNPVHist
?
"OK"
:
"NULL"
,
m_refMu
,
m_uncHistName
.Data()));
108
}
109
110
PileupUncertaintyComponent::PileupUncertaintyComponent
(
const
ComponentHelper
& component,
111
const
float
refNPV,
112
const
UncertaintyHistogram
* refMu
113
)
114
:
UncertaintyComponent
(component,component.pileupType ==
PileupComp
::PtTerm ? 2 : 1)
115
,
m_pileupType
(component.pileupType)
116
,
m_refNPV
(refNPV)
117
,
m_refMu
(-1)
118
,
m_refNPVHist
(nullptr)
119
,
m_refMuHist
(refMu)
120
,
m_absEta
(
CompParametrization
::isAbsEta(component.parametrization))
121
,
m_secondUncName
(component.uncNames.
size
()>1?component.uncNames.at(1):
""
)
122
,
m_secondUncHist
(nullptr)
123
,
m_refType
(
PileupRef_UNKNOWN
)
124
,
m_secondRefType
(
PileupRef_UNKNOWN
)
125
{
126
ATH_MSG_DEBUG
(
"Created PileupUncertaintyComponent named"
<<
m_uncHistName
.Data());
127
128
// Ensure that the pileup type and ref values are sensible
129
if
(
m_pileupType
==
PileupComp::UNKNOWN
)
130
ATH_MSG_FATAL
(
"Pileup type is UNKNOWN: "
<<
m_uncHistName
.Data());
131
if
(
m_refNPV
<= 0 || !
m_refMu
)
132
ATH_MSG_FATAL
(Form(
"Unusual pileup reference values. (NPV,mu)=(%.1f,%s) for %s"
,
m_refNPV
,
m_refMuHist
?
"OK"
:
"NULL"
,
m_uncHistName
.Data()));
133
}
134
135
PileupUncertaintyComponent::PileupUncertaintyComponent
(
const
PileupUncertaintyComponent
& toCopy)
136
:
UncertaintyComponent
(toCopy)
137
,
m_pileupType
(toCopy.
m_pileupType
)
138
,
m_refNPV
(toCopy.
m_refNPV
)
139
,
m_refMu
(toCopy.
m_refMu
)
140
,
m_refNPVHist
(toCopy.
m_refNPVHist
)
141
,
m_refMuHist
(toCopy.
m_refMuHist
)
142
,
m_absEta
(toCopy.
m_absEta
)
143
,
m_secondUncName
(toCopy.
m_secondUncName
)
144
,
m_secondUncHist
(nullptr)
145
,
m_refType
(toCopy.
m_refType
)
146
,
m_secondRefType
(toCopy.
m_secondRefType
)
147
{
148
ATH_MSG_DEBUG
(Form(
"Creating copy of PileupUncertaintyComponent named %s"
,
m_uncHistName
.Data()));
149
if
(toCopy.
m_secondUncHist
)
150
m_secondUncHist
=
new
UncertaintyHistogram
(*toCopy.
m_secondUncHist
);
151
}
152
153
PileupUncertaintyComponent
*
PileupUncertaintyComponent::clone
()
const
154
{
155
return
new
PileupUncertaintyComponent
(*
this
);
156
}
157
158
PileupUncertaintyComponent::~PileupUncertaintyComponent
()
159
{
160
JESUNC_SAFE_DELETE
(
m_secondUncHist
);
161
}
162
163
StatusCode
PileupUncertaintyComponent::initialize
(TFile* histFile)
164
{
165
// Call the base class first
166
if
(
UncertaintyComponent::initialize
(histFile).isFailure())
167
return
StatusCode::FAILURE;
168
169
170
// Then ensure that the number of histograms matches what is expected for Pileup components
171
if
(
m_pileupType
==
PileupComp::OffsetNPV
&&
m_secondUncName
!=
""
)
172
{
173
ATH_MSG_ERROR
(
"Expected a single histogram for OffsetNPV: "
<<
getName
().
Data
());
174
return
StatusCode::FAILURE;
175
}
176
else
if
(
m_pileupType
==
PileupComp::OffsetMu
&&
m_secondUncName
!=
""
)
177
{
178
ATH_MSG_ERROR
(
"Expected a single histogram for OffsetMu: "
<<
getName
().
Data
());
179
return
StatusCode::FAILURE;
180
}
181
else
if
(
m_pileupType
==
PileupComp::PtTerm
&&
m_secondUncName
==
""
)
182
{
183
ATH_MSG_ERROR
(
"Expected two histograms for PtTerm: "
<<
getName
().
Data
());
184
return
StatusCode::FAILURE;
185
}
186
187
// Get the reference types
188
if
(
m_pileupType
==
PileupComp::OffsetNPV
)
189
m_refType
=
PileupRef_NPV
;
190
else
if
(
m_pileupType
==
PileupComp::OffsetMu
)
191
m_refType
=
PileupRef_MU
;
192
else
if
(
m_pileupType
==
PileupComp::RhoTopology
)
193
m_refType
=
PileupRef_NONE
;
194
else
if
(
m_pileupType
==
PileupComp::PtTerm
)
195
{
196
if
(
m_uncHistName
.Contains(
"NPV"
,TString::kIgnoreCase) &&
m_secondUncName
.Contains(
"Mu"
,TString::kIgnoreCase))
197
{
198
m_refType
=
PileupRef_NPV
;
199
m_secondRefType
=
PileupRef_MU
;
200
}
201
else
if
(
m_uncHistName
.Contains(
"Mu"
,TString::kIgnoreCase) &&
m_secondUncName
.Contains(
"NPV"
,TString::kIgnoreCase))
202
{
203
m_refType
=
PileupRef_MU
;
204
m_secondRefType
=
PileupRef_NPV
;
205
}
206
else
207
{
208
ATH_MSG_ERROR
(
"Unexpected histogram naming scheme for PtTerm"
);
209
return
StatusCode::FAILURE;
210
}
211
}
212
213
// Create the second histogram if applicable
214
if
(
m_pileupType
==
PileupComp::PtTerm
)
215
{
216
m_secondUncHist
=
new
UncertaintyHistogram
(
m_secondUncName
,
m_interpolate
);
217
if
(!
m_secondUncHist
)
218
{
219
ATH_MSG_ERROR
(
"Failed to create second uncertainty histogram for component: "
<<
getName
().
Data
());
220
return
StatusCode::FAILURE;
221
}
222
if
(
m_secondUncHist
->initialize(histFile).isFailure())
return
StatusCode::FAILURE;
223
}
224
225
return
StatusCode::SUCCESS;
226
}
227
229
// //
230
// Validity and uncertainty retrieval //
231
// //
233
234
bool
PileupUncertaintyComponent::getValidityImpl
(
const
xAOD::Jet
&
jet
,
const
xAOD::EventInfo
&)
const
235
{
236
return
!
m_validHist
? true :
getValidBool
(
m_validHist
->getValue(
jet
.pt()*
m_energyScale
,
m_absEta
? fabs(
jet
.eta()) :
jet
.eta()));
237
}
238
239
double
PileupUncertaintyComponent::getUncertaintyImpl
(
const
xAOD::Jet
&
jet
,
const
xAOD::EventInfo
& eInfo)
const
240
{
241
double
unc =
getPileupWeight
(
jet
,eInfo,
m_refType
)*
m_uncHist
->getValue(
jet
.pt()*
m_energyScale
,
m_absEta
? fabs(
jet
.eta()) :
jet
.eta());
242
if
(
m_secondUncHist
) unc +=
getPileupWeight
(
jet
,eInfo,
m_secondRefType
)*
m_secondUncHist
->getValue(
jet
.pt()*
m_energyScale
,
m_absEta
? fabs(
jet
.eta()) :
jet
.eta());
243
244
return
unc;
245
}
246
247
double
PileupUncertaintyComponent::getPileupWeight
(
const
xAOD::Jet
&
jet
,
const
xAOD::EventInfo
& eInfo,
const
PileupRefType
refType)
const
248
{
249
static
const
SG::AuxElement::Accessor<float> accNPV(
"NPV"
);
250
251
double
weight;
252
const
float
mu = eInfo.
averageInteractionsPerCrossing
();
253
const
float
NPV = accNPV.isAvailable(eInfo) ? accNPV(eInfo) : -1;
254
255
if
(NPV <= 0)
256
{
257
ATH_MSG_ERROR
(
"Unexpected number of primary vertices, does EventInfo contain NPV? (NPV="
<<NPV<<
")"
);
258
return
JESUNC_ERROR_CODE
;
259
}
260
261
if
(refType ==
PileupRef_NPV
)
262
weight = NPV - (
m_refNPVHist
?
m_refNPVHist
->getValue(fabs(
jet
.eta())):
m_refNPV
);
263
else
if
(refType ==
PileupRef_MU
)
264
weight = mu - (
m_refMuHist
?
m_refMuHist
->getValue(fabs(
jet
.eta())):
m_refMu
);
265
else
if
(refType ==
PileupRef_NONE
)
266
weight = 1;
267
else
268
{
269
ATH_MSG_ERROR
(Form(
"Unknown pileup referencetype for component %s"
,
getName
().
Data
()));
270
return
JESUNC_ERROR_CODE
;
271
}
272
273
return
weight;
274
}
275
276
277
}
// end jet namespace
278
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
Data
@ Data
Definition
BaseObject.h:11
PileupUncertaintyComponent.h
Helpers.h
JESUNC_ERROR_CODE
#define JESUNC_ERROR_CODE
Definition
Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:23
JESUNC_NO_DEFAULT_CONSTRUCTOR
#define JESUNC_NO_DEFAULT_CONSTRUCTOR
Definition
Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:24
JESUNC_SAFE_DELETE
#define JESUNC_SAFE_DELETE(T)
Definition
Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:25
size
size_t size() const
Number of registered mappings.
jet::ComponentHelper
Definition
ConfigHelper.h:24
jet::PileupUncertaintyComponent::PileupRefType
PileupRefType
Definition
PileupUncertaintyComponent.h:53
jet::PileupUncertaintyComponent::PileupRef_UNKNOWN
@ PileupRef_UNKNOWN
Definition
PileupUncertaintyComponent.h:53
jet::PileupUncertaintyComponent::PileupRef_MU
@ PileupRef_MU
Definition
PileupUncertaintyComponent.h:53
jet::PileupUncertaintyComponent::PileupRef_NPV
@ PileupRef_NPV
Definition
PileupUncertaintyComponent.h:53
jet::PileupUncertaintyComponent::PileupRef_NONE
@ PileupRef_NONE
Definition
PileupUncertaintyComponent.h:53
jet::PileupUncertaintyComponent::initialize
virtual StatusCode initialize(TFile *histFile)
Definition
PileupUncertaintyComponent.cxx:163
jet::PileupUncertaintyComponent::getUncertaintyImpl
virtual double getUncertaintyImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
Definition
PileupUncertaintyComponent.cxx:239
jet::PileupUncertaintyComponent::m_absEta
const bool m_absEta
Definition
PileupUncertaintyComponent.h:61
jet::PileupUncertaintyComponent::PileupUncertaintyComponent
PileupUncertaintyComponent(const ComponentHelper &component, const float refNPV, const float refMu)
Definition
PileupUncertaintyComponent.cxx:35
jet::PileupUncertaintyComponent::m_refNPVHist
const UncertaintyHistogram * m_refNPVHist
Definition
PileupUncertaintyComponent.h:59
jet::PileupUncertaintyComponent::m_secondRefType
PileupRefType m_secondRefType
Definition
PileupUncertaintyComponent.h:66
jet::PileupUncertaintyComponent::m_refNPV
const float m_refNPV
Definition
PileupUncertaintyComponent.h:57
jet::PileupUncertaintyComponent::m_secondUncHist
UncertaintyHistogram * m_secondUncHist
Definition
PileupUncertaintyComponent.h:64
jet::PileupUncertaintyComponent::~PileupUncertaintyComponent
virtual ~PileupUncertaintyComponent()
Definition
PileupUncertaintyComponent.cxx:158
jet::PileupUncertaintyComponent::m_refMu
const float m_refMu
Definition
PileupUncertaintyComponent.h:58
jet::PileupUncertaintyComponent::m_refMuHist
const UncertaintyHistogram * m_refMuHist
Definition
PileupUncertaintyComponent.h:60
jet::PileupUncertaintyComponent::getPileupWeight
double getPileupWeight(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo, const PileupRefType refType) const
Definition
PileupUncertaintyComponent.cxx:247
jet::PileupUncertaintyComponent::getValidityImpl
virtual bool getValidityImpl(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
Definition
PileupUncertaintyComponent.cxx:234
jet::PileupUncertaintyComponent::m_secondUncName
const TString m_secondUncName
Definition
PileupUncertaintyComponent.h:62
jet::PileupUncertaintyComponent::clone
virtual PileupUncertaintyComponent * clone() const
Definition
PileupUncertaintyComponent.cxx:153
jet::PileupUncertaintyComponent::m_refType
PileupRefType m_refType
Definition
PileupUncertaintyComponent.h:65
jet::PileupUncertaintyComponent::m_pileupType
const PileupComp::TypeEnum m_pileupType
Definition
PileupUncertaintyComponent.h:56
jet::UncertaintyComponent::m_interpolate
const Interpolate::TypeEnum m_interpolate
Definition
UncertaintyComponent.h:56
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
jet::UncertaintyHistogram
Definition
UncertaintyHistogram.h:25
xAOD::EventInfo_v1::averageInteractionsPerCrossing
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
Definition
EventInfo_v1.cxx:397
jet::CompParametrization
Definition
UncertaintyEnum.h:43
jet::PileupComp
Definition
UncertaintyEnum.h:161
jet::PileupComp::OffsetNPV
@ OffsetNPV
Definition
UncertaintyEnum.h:165
jet::PileupComp::PtTerm
@ PtTerm
Definition
UncertaintyEnum.h:167
jet::PileupComp::UNKNOWN
@ UNKNOWN
Definition
UncertaintyEnum.h:164
jet::PileupComp::RhoTopology
@ RhoTopology
Definition
UncertaintyEnum.h:168
jet::PileupComp::OffsetMu
@ OffsetMu
Definition
UncertaintyEnum.h:166
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