ATLAS Offline Software
OverlapLinkHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Local includes
7 
8 namespace ORUtils
9 {
10 
11  //---------------------------------------------------------------------------
12  // Constructor
13  //---------------------------------------------------------------------------
14  OverlapLinkHelper::OverlapLinkHelper(const std::string& linkLabel)
15  : m_linkDecorator(linkLabel),
16  m_linkAccessor(linkLabel)
17  {}
18 
19  //---------------------------------------------------------------------------
20  // Link p1 to p2
21  //---------------------------------------------------------------------------
23  (const xAOD::IParticle& p1, const xAOD::IParticle& p2) const
24  {
25  const xAOD::IParticleContainer* overlapContainer =
26  static_cast<const xAOD::IParticleContainer*>( p2.container() );
27  m_linkDecorator(p1) = ort::objLink_t(*overlapContainer, p2.index());
28  return StatusCode::SUCCESS;
29  }
30 
31  //---------------------------------------------------------------------------
32  // Retrieve an overlap-linked particle or null.
33  //---------------------------------------------------------------------------
35  (const xAOD::IParticle& p) const
36  {
37  // Check if the decoration is present and valid
39  auto& link = m_linkAccessor(p);
40  if(link.isValid()) return *link;
41  }
42  return nullptr;
43  }
44 
45 } // namespace ORUtils
ort::objLink_t
ElementLink< xAOD::IParticleContainer > objLink_t
Overlap object link.
Definition: OverlapRemovalDefs.h:37
ORUtils::OverlapLinkHelper::OverlapLinkHelper
OverlapLinkHelper(const std::string &linkLabel)
Constructor.
Definition: OverlapLinkHelper.cxx:14
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ORUtils::OverlapLinkHelper::m_linkDecorator
ort::objLinkDecorator_t m_linkDecorator
Object link decorator.
Definition: OverlapLinkHelper.h:53
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
ORUtils
Definition: AltMuJetOverlapTool.h:20
ORUtils::OverlapLinkHelper::getObjectLink
const xAOD::IParticle * getObjectLink(const xAOD::IParticle &p) const
Retrieve an overlap-linked particle.
Definition: OverlapLinkHelper.cxx:35
OverlapLinkHelper.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
ORUtils::OverlapLinkHelper::addObjectLink
StatusCode addObjectLink(const xAOD::IParticle &p1, const xAOD::IParticle &p2) const
Decorate p1 with an overlap object link to p2.
Definition: OverlapLinkHelper.cxx:23
ORUtils::OverlapLinkHelper::m_linkAccessor
ort::objLinkAccessor_t m_linkAccessor
Corresponding object link accessor (for reading only)
Definition: OverlapLinkHelper.h:55
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.