ATLAS Offline Software
JetGhostMergingAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 //
8 // includes
9 //
13 
14 namespace CP
15 {
17  JetGhostMergingAlg (const std::string& name,
18  ISvcLocator* pSvcLocator)
19  : AnaAlgorithm (name, pSvcLocator)
20  {
21  }
22 
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 
44  execute ()
45  {
46  const EventContext &ctx = Gaudi::Hive::currentContext();
47 
49  if (!inputJets.isValid()) {
50  ATH_MSG_FATAL("No jet collection with name " << m_jetLocation.key() << " found in StoreGate!");
51  return StatusCode::FAILURE;
52  }
53 
54  // define GhostTrackContainer type (GTC)
55  using GTC = std::vector<ElementLink<DataVector<xAOD::IParticle> > >;
56 
57  // create the accessors for each ghost track collection
58  std::vector<SG::ReadDecorHandle<xAOD::JetContainer, GTC> > ghostTrackAccs;
59  ghostTrackAccs.reserve(m_ghostTrackKeys.size());
60  for (const auto &key: m_ghostTrackKeys) {
61  ghostTrackAccs.emplace_back(key, ctx);
62  }
63 
65 
66  for(const xAOD::Jet *jet: *inputJets) {
67  std::vector<ElementLink<xAOD::IParticleContainer>> mergedGhosts;
68  for (const auto& ghostTrackAcc: ghostTrackAccs) {
69  const GTC &ghosts = ghostTrackAcc( *jet );
70  mergedGhosts.insert(mergedGhosts.end(), ghosts.begin(), ghosts.end());
71  }
72  mergedGhostDecor(*jet) = std::move(mergedGhosts);
73  }
74  return StatusCode::SUCCESS;
75  }
76 
77 }
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
CP::JetGhostMergingAlg::m_jetLocation
SG::ReadHandleKey< xAOD::JetContainer > m_jetLocation
the jet collection we run on
Definition: JetGhostMergingAlg.h:52
CP::JetGhostMergingAlg::m_mergedGhostContainer
SG::WriteDecorHandleKey< xAOD::JetContainer > m_mergedGhostContainer
the name of the output ghost collection
Definition: JetGhostMergingAlg.h:56
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::JetGhostMergingAlg::JetGhostMergingAlg
JetGhostMergingAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: JetGhostMergingAlg.cxx:17
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
JetGhostMergingAlg.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
WriteDecorHandle.h
Handle class for adding a decoration to an object.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
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:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CP::JetGhostMergingAlg::initialize
StatusCode initialize() override
Definition: JetGhostMergingAlg.cxx:24
CP::JetGhostMergingAlg::execute
StatusCode execute() override
Definition: JetGhostMergingAlg.cxx:44
find_data.full
full
Definition: find_data.py:27
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CP::JetGhostMergingAlg::m_inputGhostTrackNames
Gaudi::Property< std::vector< std::string > > m_inputGhostTrackNames
Definition: JetGhostMergingAlg.h:65
ReadDecorHandle.h
Handle class for reading a decoration on an object.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37