ATLAS Offline Software
HardScatterVertexDecorator.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 // HardScatterVertexDecorator.cxx, (c) ATLAS Detector software
8 // Author: Matthew Basso (matthew.joseph.basso@cern.ch)
9 // A very simple tool for decorating vertices as hardscatter or not-hardscatter
10 
11 // Local include(s):
13 
14 // FrameWork include(s):
15 #include "AthLinks/ElementLink.h"
19 
20 // EDM include(s):
22 
23 namespace DerivationFramework {
24 
25  HardScatterVertexDecorator::HardScatterVertexDecorator(const std::string& type, const std::string& name, const IInterface* parent) :
26  base_class(type, name, parent) {
27  }
28 
30  {
31  // Print configuration
32  ATH_MSG_DEBUG("Initializing " << name() << "...");
33  ATH_MSG_DEBUG("Using VertexContainerName: " << m_vtxContKey);
34  ATH_MSG_DEBUG("Using HardScatterDecoName: " << m_evtDecoName);
35  ATH_MSG_DEBUG("Using HardScatterSelectionTool: " << m_vtxSelectTool);
36 
37  if (m_vtxContKey.empty()) {
38  ATH_MSG_ERROR("No xAOD::VertexContainer provided!");
39  return StatusCode::FAILURE;
40  }
41 
42  if (m_evtDecoName.empty()) {
43  ATH_MSG_ERROR("Hardscatter decoration name cannot be empty!");
44  return StatusCode::FAILURE;
45  }
46 
47  if (m_vtxSelectTool.empty()) {
48  ATH_MSG_ERROR("No InDet::IInDetHardScatterSelectionTool provided!");
49  return StatusCode::FAILURE;
50  }
51 
52  // Initialize our vertex and event info container reads
53  ATH_CHECK(m_vtxContKey.initialize());
55 
56  // Instantiate and initialize our event info decorator write
59  // Fetch our InDet::IInDetHardScatterSelectionTool
60  ATH_CHECK(m_vtxSelectTool.retrieve());
61  return StatusCode::SUCCESS;
62  }
63 
65  {
66  ATH_MSG_DEBUG("In addBranches(...) for " << name() << "...");
67 
68  const EventContext& ctx = Gaudi::Hive::currentContext();
69 
70  // Open our vertex container
72  if (!vtxCont.isValid()) {
73  ATH_MSG_ERROR("Unable to retrieve xAOD::VertexContainer!");
74  return StatusCode::FAILURE;
75  }
76 
77  // Open our event info
79  if (!evtInfo.isValid()) {
80  ATH_MSG_ERROR("Unable to retrieve xAOD::EventInfo!");
81  return StatusCode::FAILURE;
82  }
83 
84  // Instantiate our WriteDecorHandle
86 
87  // Decorate our event info
88  evtDeco(*evtInfo) = m_vtxSelectTool->getHardScatterLink(vtxCont.get());
89 
90  return StatusCode::SUCCESS;
91  }
92 
93 } // end: namespace DerivationFramework
DerivationFramework::HardScatterVertexDecorator::m_vtxSelectTool
ToolHandle< InDet::IInDetHardScatterSelectionTool > m_vtxSelectTool
ToolHandle for the IInDetHardScatterSelectionTool.
Definition: HardScatterVertexDecorator.h:71
CurrentContext.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::HardScatterVertexDecorator::m_evtDecoName
Gaudi::Property< std::string > m_evtDecoName
Name of the output hardscatter decoration (applied to xAOD::EventInfo)
Definition: HardScatterVertexDecorator.h:67
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
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
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?
DerivationFramework::HardScatterVertexDecorator::addBranches
virtual StatusCode addBranches() const
Function decorating the inputs.
Definition: HardScatterVertexDecorator.cxx:64
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
HardScatterVertexDecorator.h
ReadHandle.h
Handle class for reading from StoreGate.
DerivationFramework::HardScatterVertexDecorator::m_evtInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
xAOD::EventInfo ReadHandleKey
Definition: HardScatterVertexDecorator.h:81
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:63
DerivationFramework::HardScatterVertexDecorator::m_evtDecoKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_evtDecoKey
WriteDecorHandleKey for the output hardscatter decoration (applied to xAOD::EventInfo)
Definition: HardScatterVertexDecorator.h:84
DerivationFramework::HardScatterVertexDecorator::initialize
StatusCode initialize()
Function initialising the tool.
Definition: HardScatterVertexDecorator.cxx:29
DerivationFramework::HardScatterVertexDecorator::HardScatterVertexDecorator
HardScatterVertexDecorator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: HardScatterVertexDecorator.cxx:25