ATLAS Offline Software
Loading...
Searching...
No Matches
JetGhostMergingAlg.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
7//
8// includes
9//
13
14namespace CP
15{
16 JetGhostMergingAlg ::
17 JetGhostMergingAlg (const std::string& name,
18 ISvcLocator* pSvcLocator)
19 : AnaReentrantAlgorithm (name, pSvcLocator)
20 {
21 }
22
23 StatusCode JetGhostMergingAlg ::
24 initialize ()
25 {
26 // containers
27 ATH_CHECK (m_jetLocation.initialize ());
28
29 // decorators
30 ATH_CHECK (m_mergedGhostContainer.initialize ());
31
32 // accessors
34 for (const auto& ghostName: m_inputGhostTrackNames) {
35 std::string full = m_jetLocation.key() + "." + ghostName;
36 m_ghostTrackKeys.emplace_back( this, ghostName, full, "");
37 ATH_CHECK( m_ghostTrackKeys.back().initialize() );
38 }
39
40 return StatusCode::SUCCESS;
41 }
42
43 StatusCode JetGhostMergingAlg ::
44 execute (const EventContext &ctx) const
45 {
47 if (!inputJets.isValid()) {
48 ATH_MSG_FATAL("No jet collection with name " << m_jetLocation.key() << " found in StoreGate!");
49 return StatusCode::FAILURE;
50 }
51
52 // define GhostTrackContainer type (GTC)
53 using GTC = std::vector<ElementLink<DataVector<xAOD::IParticle> > >;
54
55 // create the accessors for each ghost track collection
56 std::vector<SG::ReadDecorHandle<xAOD::JetContainer, GTC> > ghostTrackAccs;
57 ghostTrackAccs.reserve(m_ghostTrackKeys.size());
58 for (const auto &key: m_ghostTrackKeys) {
59 ghostTrackAccs.emplace_back(key, ctx);
60 }
61
63
64 for(const xAOD::Jet *jet: *inputJets) {
65 std::vector<ElementLink<xAOD::IParticleContainer>> mergedGhosts;
66 for (const auto& ghostTrackAcc: ghostTrackAccs) {
67 const GTC &ghosts = ghostTrackAcc( *jet );
68 mergedGhosts.insert(mergedGhosts.end(), ghosts.begin(), ghosts.end());
69 }
70 mergedGhostDecor(*jet) = std::move(mergedGhosts);
71 }
72 return StatusCode::SUCCESS;
73 }
74
75}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
Handle class for reading a decoration on an object.
Handle class for adding a decoration to an object.
std::vector< SG::ReadDecorHandleKey< xAOD::JetContainer > > m_ghostTrackKeys
internal vector to hold the ReadDecorHandles for the difference ghosts
SG::ReadHandleKey< xAOD::JetContainer > m_jetLocation
the jet collection we run on
Gaudi::Property< std::vector< std::string > > m_inputGhostTrackNames
SG::WriteDecorHandleKey< xAOD::JetContainer > m_mergedGhostContainer
the name of the output ghost collection
AnaReentrantAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Handle class for adding a decoration to an object.
Select isolated Photons, Electrons and Muons.
Jet_v1 Jet
Definition of the current "jet version".