ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
JetAnalysisAlgorithms
Root
JetGhostMergingAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
//
8
// includes
9
//
10
#include <
JetAnalysisAlgorithms/JetGhostMergingAlg.h
>
11
#include <
AsgDataHandles/WriteDecorHandle.h
>
12
#include <
AsgDataHandles/ReadDecorHandle.h
>
13
14
namespace
CP
15
{
16
StatusCode JetGhostMergingAlg ::
17
initialize ()
18
{
19
// containers
20
ATH_CHECK
(
m_jetLocation
.initialize ());
21
22
// decorators
23
ATH_CHECK
(
m_mergedGhostContainer
.initialize ());
24
25
// accessors
26
m_ghostTrackKeys
.reserve(
m_inputGhostTrackNames
.size());
27
for
(
const
auto
& ghostName:
m_inputGhostTrackNames
) {
28
m_ghostTrackKeys
.emplace_back(
this
, ghostName,
m_jetLocation
, ghostName,
""
);
29
ATH_CHECK
(
m_ghostTrackKeys
.back().initialize() );
30
}
31
32
return
StatusCode::SUCCESS;
33
}
34
35
StatusCode JetGhostMergingAlg ::
36
execute (
const
EventContext &ctx)
const
37
{
38
SG::ReadHandle<xAOD::JetContainer>
inputJets(
m_jetLocation
,ctx);
39
if
(!inputJets.
isValid
()) {
40
ATH_MSG_FATAL
(
"No jet collection with name "
<<
m_jetLocation
.key() <<
" found in StoreGate!"
);
41
return
StatusCode::FAILURE;
42
}
43
44
// define GhostTrackContainer type (GTC)
45
using
GTC = std::vector<ElementLink<DataVector<xAOD::IParticle>>>;
46
47
// create the accessors for each ghost track collection
48
std::vector<SG::ReadDecorHandle<xAOD::JetContainer, GTC>> ghostTrackAccs;
49
ghostTrackAccs.reserve(
m_ghostTrackKeys
.size());
50
for
(
const
auto
&key:
m_ghostTrackKeys
) {
51
ghostTrackAccs.emplace_back(key, ctx);
52
}
53
54
SG::WriteDecorHandle<xAOD::JetContainer, GTC >
mergedGhostDecor(
m_mergedGhostContainer
, ctx);
55
56
for
(
const
xAOD::Jet
*
jet
: *inputJets) {
57
std::vector<ElementLink<xAOD::IParticleContainer>> mergedGhosts;
58
std::size_t nGhosts = 0;
59
for
(
const
auto
& ghostTrackAcc: ghostTrackAccs) {
60
nGhosts += ghostTrackAcc( *jet ).size();
61
}
62
mergedGhosts.reserve(nGhosts);
63
for
(
const
auto
& ghostTrackAcc: ghostTrackAccs) {
64
const
GTC &ghosts = ghostTrackAcc( *
jet
);
65
mergedGhosts.insert(mergedGhosts.end(), ghosts.begin(), ghosts.end());
66
}
67
mergedGhostDecor(*
jet
) = std::move(mergedGhosts);
68
}
69
return
StatusCode::SUCCESS;
70
}
71
72
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x,...)
Definition
AthMsgStreamMacros.h:48
ReadDecorHandle.h
Handle class for reading a decoration on an object.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
JetGhostMergingAlg.h
CP::JetGhostMergingAlg::m_ghostTrackKeys
std::vector< SG::ReadDecorHandleKey< xAOD::JetContainer > > m_ghostTrackKeys
internal vector to hold the ReadDecorHandles for the difference ghosts
Definition
JetGhostMergingAlg.h:60
CP::JetGhostMergingAlg::m_jetLocation
SG::ReadHandleKey< xAOD::JetContainer > m_jetLocation
the jet collection we run on
Definition
JetGhostMergingAlg.h:50
CP::JetGhostMergingAlg::m_inputGhostTrackNames
Gaudi::Property< std::vector< std::string > > m_inputGhostTrackNames
Definition
JetGhostMergingAlg.h:63
CP::JetGhostMergingAlg::m_mergedGhostContainer
SG::WriteDecorHandleKey< xAOD::JetContainer > m_mergedGhostContainer
the name of the output ghost collection
Definition
JetGhostMergingAlg.h:54
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:66
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
CP
Select isolated Photons, Electrons and Muons.
Definition
Control/xAODRootAccess/xAODRootAccess/TEvent.h:27
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
Generated on
for ATLAS Offline Software by
1.17.0