ATLAS Offline Software
HardScatterVertexDecorator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Author: Matthew Basso (matthew.joseph.basso@cern.ch)
6 // A very simple tool for decorating vertices as hardscatter or not-hardscatter
7 
8 // Local include(s):
10 
11 // FrameWork include(s):
12 #include "AthLinks/ElementLink.h"
13 #include "StoreGate/ReadHandle.h"
15 
16 // EDM include(s):
18 
19 namespace DerivationFramework {
20 
22  {
23  // Print configuration
24  ATH_MSG_DEBUG("Initializing " << name() << "...");
25  ATH_MSG_DEBUG("Using VertexContainerName: " << m_vtxContKey);
26  ATH_MSG_DEBUG("Using HardScatterSelectionTool: " << m_vtxSelectTool);
27 
28  if (m_vtxContKey.empty()) {
29  ATH_MSG_ERROR("No xAOD::VertexContainer provided!");
30  return StatusCode::FAILURE;
31  }
32 
33  if (m_vtxSelectTool.empty()) {
34  ATH_MSG_ERROR("No InDet::IInDetHardScatterSelectionTool provided!");
35  return StatusCode::FAILURE;
36  }
37 
38  // Initialize our vertex and event info container reads
39  ATH_CHECK(m_vtxContKey.initialize());
41 
42  // Instantiate and initialize our event info decorator write
44  // Fetch our InDet::IInDetHardScatterSelectionTool
45  ATH_CHECK(m_vtxSelectTool.retrieve());
46  return StatusCode::SUCCESS;
47  }
48 
49  StatusCode HardScatterVertexDecorator::addBranches(const EventContext& ctx) const
50  {
51  ATH_MSG_DEBUG("In addBranches(...) for " << name() << "...");
52 
53 
54  // Open our vertex container
56  if (!vtxCont.isValid()) {
57  ATH_MSG_ERROR("Unable to retrieve xAOD::VertexContainer!");
58  return StatusCode::FAILURE;
59  }
60 
61  // Open our event info
63  if (!evtInfo.isValid()) {
64  ATH_MSG_ERROR("Unable to retrieve xAOD::EventInfo!");
65  return StatusCode::FAILURE;
66  }
67 
68  // Instantiate our WriteDecorHandle
70 
71  // Decorate our event info
72  evtDeco(*evtInfo) = m_vtxSelectTool->getHardScatterLink(vtxCont.get());
73 
74  return StatusCode::SUCCESS;
75  }
76 
77 } // end: namespace DerivationFramework
DerivationFramework::HardScatterVertexDecorator::m_vtxSelectTool
ToolHandle< InDet::IInDetHardScatterSelectionTool > m_vtxSelectTool
ToolHandle for the IInDetHardScatterSelectionTool.
Definition: HardScatterVertexDecorator.h:63
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::HardScatterVertexDecorator::initialize
virtual StatusCode initialize() override final
Function initialising the tool.
Definition: HardScatterVertexDecorator.cxx:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::ReadHandle::get
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
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.
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
HardScatterVertexDecorator.h
DerivationFramework::HardScatterVertexDecorator::m_evtInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
xAOD::EventInfo ReadHandleKey
Definition: HardScatterVertexDecorator.h:67
VertexContainer.h
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
DerivationFramework::HardScatterVertexDecorator::m_vtxContKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vtxContKey
ReadHandleKey for the input vertices.
Definition: HardScatterVertexDecorator.h:59
DerivationFramework::HardScatterVertexDecorator::m_evtDecoKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_evtDecoKey
WriteDecorHandleKey for the output hardscatter decoration (applied to xAOD::EventInfo)
Definition: HardScatterVertexDecorator.h:70
ReadHandle.h
Handle class for reading from StoreGate.
DerivationFramework::HardScatterVertexDecorator::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Function decorating the inputs.
Definition: HardScatterVertexDecorator.cxx:49