ATLAS Offline Software
PhysicsAnalysis
DerivationFramework
DerivationFrameworkJetEtMiss
src
PFlowAugmentationTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// PFlowAugmentationTool.cxx
8
// Author: Fabrice Balli (fabrice.balli@cern.ch), Chris Young (christopher.young@cern.ch)
9
//
10
11
#include "
PFlowAugmentationTool.h
"
12
13
#include "
StoreGate/WriteDecorHandle.h
"
14
15
namespace
DerivationFramework
{
16
17
StatusCode
PFlowAugmentationTool::initialize
()
18
{
19
20
ATH_CHECK
(
m_vertexContainer_key
.initialize());
21
ATH_CHECK
(
m_pfoContainer_key
.initialize());
22
ATH_CHECK
(
m_corrP4_ptKey
.initialize());
23
ATH_CHECK
(
m_z0Key
.initialize());
24
ATH_CHECK
(
m_vzKey
.initialize());
25
ATH_CHECK
(
m_d0Key
.initialize());
26
ATH_CHECK
(
m_thetaKey
.initialize());
27
ATH_CHECK
(
m_envWeightKey
.initialize());
28
29
return
StatusCode::SUCCESS;
30
}
31
32
StatusCode
PFlowAugmentationTool::addBranches
(
const
EventContext& ctx)
const
33
{
34
// Get the vertex.
35
const
xAOD::Vertex
*
pv
{};
36
37
auto
vertexContainer =
SG::makeHandle
(
m_vertexContainer_key
, ctx);
38
if
(!vertexContainer.isValid()){
39
ATH_MSG_WARNING
(
"Invalid xAOD::VertexContainer datahandle"
40
<<
m_vertexContainer_key
.key());
41
return
StatusCode::FAILURE;
42
}
43
auto
pvcont = vertexContainer.cptr();
44
if
( pvcont == 0 || pvcont->size()==0 ) {
45
ATH_MSG_WARNING
(
" Failed to retrieve PrimaryVertices collection"
);
46
return
StatusCode::FAILURE;
47
}
48
for
(
const
auto
vx : *pvcont) {
49
if
(vx->vertexType() ==
xAOD::VxType::PriVtx
) {
50
pv
= vx;
51
break
;
52
}
//If we have a vertex of type primary vertex
53
}
//iterate over the vertices and check their type
54
55
// Use NoVtx as fall-back in case no PV is found, but the events should be rejected by the user
56
// If there is no such then mark all CPFOs as unmatched
57
if
(
pv
==
nullptr
) {
58
ATH_MSG_DEBUG
(
"Could not find a primary vertex in this event"
);
59
for
(
auto
theVertex : *pvcont) {
60
if
(
xAOD::VxType::NoVtx
== theVertex->vertexType() ) {
61
pv
= theVertex;
62
break
;
63
}
64
}
65
if
(
nullptr
==
pv
) {
66
ATH_MSG_WARNING
(
"Found neither PriVtx nor NoVtx in this event"
);
67
}
68
}
69
70
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_corrP4_pt(
m_corrP4_ptKey
, ctx);
71
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_z0(
m_z0Key
, ctx);
72
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_vz(
m_vzKey
, ctx);
73
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_d0(
m_d0Key
, ctx);
74
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_theta(
m_thetaKey
, ctx);
75
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_envWeight(
m_envWeightKey
, ctx);
76
77
auto
pfoContainer =
SG::makeHandle
(
m_pfoContainer_key
, ctx);
78
if
(!pfoContainer.isValid()){
79
ATH_MSG_WARNING
(
"Invalid xAOD::PFOContainer datahandle"
80
<<
m_pfoContainer_key
.key());
81
return
StatusCode::FAILURE;
82
}
83
auto
cpfos = pfoContainer.cptr();
84
85
for
(
const
xAOD::FlowElement
* cpfo : *cpfos ) {
86
if
( cpfo == 0 ) {
87
ATH_MSG_WARNING
(
"Have NULL pointer to charged PFO"
);
88
continue
;
89
}
90
const
xAOD::TrackParticle
* ptrk =
dynamic_cast<
const
xAOD::TrackParticle
*
>
(cpfo->chargedObject(0));
91
if
( ptrk == 0 ) {
92
ATH_MSG_WARNING
(
"Skipping charged PFO with null track pointer."
);
93
continue
;
94
}
95
96
// decorate the track properties
97
dec_z0(*cpfo) = ptrk->
z0
();
98
dec_vz(*cpfo) = ptrk->
vz
();
99
dec_d0(*cpfo) = ptrk->
d0
();
100
dec_theta(*cpfo) = ptrk->
theta
();
101
102
//find the weights from the tool
103
float
weight
= 1.0;
104
const
static
SG::AuxElement::ConstAccessor<int>
accIsInDE(
"IsInDenseEnvironment"
);
105
if
(accIsInDE.
isAvailable
(*cpfo)){
106
ATH_CHECK
(
m_weightPFOTool
->fillWeight( *cpfo,
weight
) );
107
}
108
109
// decorate the computed variables
110
dec_corrP4_pt(*cpfo) =
weight
*cpfo->pt();
111
dec_envWeight(*cpfo) =
weight
;
112
}
113
114
return
StatusCode::SUCCESS;
115
}
116
}
DerivationFramework::PFlowAugmentationTool::m_z0Key
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_z0Key
Definition:
PFlowAugmentationTool.h:45
DerivationFramework::PFlowAugmentationTool::m_pfoContainer_key
SG::ReadHandleKey< xAOD::FlowElementContainer > m_pfoContainer_key
Definition:
PFlowAugmentationTool.h:42
xAOD::TrackParticle_v1::vz
float vz() const
The z origin for the parameters.
DerivationFramework::PFlowAugmentationTool::m_thetaKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_thetaKey
Definition:
PFlowAugmentationTool.h:48
xAOD::TrackParticle_v1::z0
float z0() const
Returns the parameter.
DerivationFramework::PFlowAugmentationTool::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition:
PFlowAugmentationTool.cxx:32
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition:
ConstAccessor.h:55
DerivationFramework::PFlowAugmentationTool::initialize
virtual StatusCode initialize() override final
Definition:
PFlowAugmentationTool.cxx:17
DerivationFramework::PFlowAugmentationTool::m_corrP4_ptKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_corrP4_ptKey
Definition:
PFlowAugmentationTool.h:44
xAOD::VxType::NoVtx
@ NoVtx
Dummy vertex. TrackParticle was not used in vertex fit.
Definition:
TrackingPrimitives.h:571
xAOD::TrackParticle_v1::d0
float d0() const
Returns the parameter.
dqt_zlumi_pandas.weight
int weight
Definition:
dqt_zlumi_pandas.py:190
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition:
ReadCondHandle.h:270
DerivationFramework::PFlowAugmentationTool::m_weightPFOTool
PublicToolHandle< CP::IWeightPFOTool > m_weightPFOTool
Definition:
PFlowAugmentationTool.h:39
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition:
StoreGate/StoreGate/WriteDecorHandle.h:100
WriteDecorHandle.h
Handle class for adding a decoration to an object.
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition:
TrackingPrimitives.h:572
ATH_CHECK
#define ATH_CHECK
Definition:
AthCheckMacros.h:40
DerivationFramework
THE reconstruction tool.
Definition:
ParticleSortingAlg.h:24
DerivationFramework::PFlowAugmentationTool::m_d0Key
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_d0Key
Definition:
PFlowAugmentationTool.h:47
DerivationFramework::PFlowAugmentationTool::m_vertexContainer_key
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainer_key
Definition:
PFlowAugmentationTool.h:41
PFlowAugmentationTool.h
DerivationFramework::PFlowAugmentationTool::m_envWeightKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_envWeightKey
Definition:
PFlowAugmentationTool.h:49
xAOD::Vertex_v1
Class describing a Vertex.
Definition:
Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition:
AthMsgStreamMacros.h:32
python.changerun.pv
pv
Definition:
changerun.py:79
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
DerivationFramework::PFlowAugmentationTool::m_vzKey
SG::WriteDecorHandleKey< xAOD::FlowElementContainer > m_vzKey
Definition:
PFlowAugmentationTool.h:46
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition:
TrackParticle_v1.h:44
xAOD::TrackParticle_v1::theta
float theta() const
Returns the parameter, which has range 0 to .
xAOD::FlowElement_v1
A detector object made of other lower level object(s)
Definition:
FlowElement_v1.h:25
Generated on Sun Nov 23 2025 21:15:54 for ATLAS Offline Software by
1.8.18