ATLAS Offline Software
PhysicsAnalysis
DerivationFramework
DerivationFrameworkJetEtMiss
src
PFlowAugmentationTool.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// PFlowAugmentationTool.cxx, (c) ATLAS Detector software
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
PFlowAugmentationTool::PFlowAugmentationTool
(
const
std::string&
t
,
18
const
std::string&
n
,
19
const
IInterface*
p
) :
20
base_class(
t
,
n
,
p
),
21
m_weightPFOTool(
"CP::WeightPFOTool/WeightPFOTool"
)
22
{
23
declareProperty(
"WeightPFOTool"
,
m_weightPFOTool
);
24
}
25
26
StatusCode
PFlowAugmentationTool::initialize
()
27
{
28
29
ATH_CHECK
(
m_vertexContainer_key
.initialize());
30
ATH_CHECK
(
m_pfoContainer_key
.initialize());
31
ATH_CHECK
(
m_corrP4_ptKey
.initialize());
32
ATH_CHECK
(
m_z0Key
.initialize());
33
ATH_CHECK
(
m_vzKey
.initialize());
34
ATH_CHECK
(
m_d0Key
.initialize());
35
ATH_CHECK
(
m_thetaKey
.initialize());
36
ATH_CHECK
(
m_envWeightKey
.initialize());
37
38
return
StatusCode::SUCCESS;
39
}
40
41
StatusCode
PFlowAugmentationTool::finalize
()
42
{
43
return
StatusCode::SUCCESS;
44
}
45
46
StatusCode
PFlowAugmentationTool::addBranches
()
const
47
{
48
49
// Get the vertex.
50
const
xAOD::Vertex
*
pv
(0);
51
52
auto
vertexContainer =
SG::makeHandle
(
m_vertexContainer_key
);
53
if
(!vertexContainer.isValid()){
54
ATH_MSG_WARNING
(
"Invalid xAOD::VertexContainer datahandle"
55
<<
m_vertexContainer_key
.key());
56
return
StatusCode::FAILURE;
57
}
58
auto
pvcont = vertexContainer.cptr();
59
if
( pvcont == 0 || pvcont->size()==0 ) {
60
ATH_MSG_WARNING
(
" Failed to retrieve PrimaryVertices collection"
);
61
return
StatusCode::FAILURE;
62
}
63
for
(
const
auto
vx : *pvcont) {
64
if
(vx->vertexType() ==
xAOD::VxType::PriVtx
) {
65
pv
= vx;
66
break
;
67
}
//If we have a vertex of type primary vertex
68
}
//iterate over the vertices and check their type
69
70
// Use NoVtx as fall-back in case no PV is found, but the events should be rejected by the user
71
// If there is no such then mark all CPFOs as unmatched
72
if
(
pv
==
nullptr
) {
73
ATH_MSG_DEBUG
(
"Could not find a primary vertex in this event"
);
74
for
(
auto
theVertex : *pvcont) {
75
if
(
xAOD::VxType::NoVtx
== theVertex->vertexType() ) {
76
pv
= theVertex;
77
break
;
78
}
79
}
80
if
(
nullptr
==
pv
) {
81
ATH_MSG_WARNING
(
"Found neither PriVtx nor NoVtx in this event"
);
82
}
83
}
84
85
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_corrP4_pt(
m_corrP4_ptKey
);
86
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_z0(
m_z0Key
);
87
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_vz(
m_vzKey
);
88
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_d0(
m_d0Key
);
89
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_theta(
m_thetaKey
);
90
SG::WriteDecorHandle<xAOD::FlowElementContainer,float>
dec_envWeight(
m_envWeightKey
);
91
92
auto
pfoContainer =
SG::makeHandle
(
m_pfoContainer_key
);
93
if
(!pfoContainer.isValid()){
94
ATH_MSG_WARNING
(
"Invalid xAOD::PFOContainer datahandle"
95
<<
m_pfoContainer_key
.key());
96
return
StatusCode::FAILURE;
97
}
98
auto
cpfos = pfoContainer.cptr();
99
100
for
(
const
xAOD::FlowElement
* cpfo : *cpfos ) {
101
if
( cpfo == 0 ) {
102
ATH_MSG_WARNING
(
"Have NULL pointer to charged PFO"
);
103
continue
;
104
}
105
const
xAOD::TrackParticle
* ptrk =
dynamic_cast<
const
xAOD::TrackParticle
*
>
(cpfo->chargedObject(0));
106
if
( ptrk == 0 ) {
107
ATH_MSG_WARNING
(
"Skipping charged PFO with null track pointer."
);
108
continue
;
109
}
110
111
// decorate the track properties
112
dec_z0(*cpfo) = ptrk->
z0
();
113
dec_vz(*cpfo) = ptrk->
vz
();
114
dec_d0(*cpfo) = ptrk->
d0
();
115
dec_theta(*cpfo) = ptrk->
theta
();
116
117
//find the weights from the tool
118
float
weight
= 1.0;
119
const
static
SG::AuxElement::ConstAccessor<int>
accIsInDE(
"IsInDenseEnvironment"
);
120
if
(accIsInDE.
isAvailable
(*cpfo)){
121
ATH_CHECK
(
m_weightPFOTool
->fillWeight( *cpfo,
weight
) );
122
}
123
124
// decorate the computed variables
125
dec_corrP4_pt(*cpfo) =
weight
*cpfo->pt();
126
dec_envWeight(*cpfo) =
weight
;
127
}
128
129
return
StatusCode::SUCCESS;
130
}
131
}
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::initialize
StatusCode initialize()
Definition:
PFlowAugmentationTool.cxx:26
DerivationFramework::PFlowAugmentationTool::finalize
StatusCode finalize()
Definition:
PFlowAugmentationTool.cxx:41
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition:
ConstAccessor.h:55
read_hist_ntuple.t
t
Definition:
read_hist_ntuple.py:5
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
DerivationFramework::PFlowAugmentationTool::PFlowAugmentationTool
PFlowAugmentationTool(const std::string &t, const std::string &n, const IInterface *p)
Definition:
PFlowAugmentationTool.cxx:17
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:274
python.utils.AtlRunQueryDQUtils.p
p
Definition:
AtlRunQueryDQUtils.py:209
beamspotman.n
n
Definition:
beamspotman.py:729
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_weightPFOTool
ToolHandle< CP::IWeightPFOTool > m_weightPFOTool
Definition:
PFlowAugmentationTool.h:39
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
Retrieval tool.
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:43
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
DerivationFramework::PFlowAugmentationTool::addBranches
virtual StatusCode addBranches() const
Definition:
PFlowAugmentationTool.cxx:46
Generated on Tue Sep 2 2025 21:18:25 for ATLAS Offline Software by
1.8.18