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) :
27  declareInterface<DerivationFramework::IAugmentationTool>(this);
28  }
29 
31  {
32  // Print configuration
33  ATH_MSG_DEBUG("Initializing " << name() << "...");
34  ATH_MSG_DEBUG("Using VertexContainerName: " << m_vtxContKey);
35  ATH_MSG_DEBUG("Using HardScatterDecoName: " << m_evtDecoName);
36  ATH_MSG_DEBUG("Using HardScatterSelectionTool: " << m_vtxSelectTool);
37 
38  if (m_vtxContKey.empty()) {
39  ATH_MSG_ERROR("No xAOD::VertexContainer provided!");
40  return StatusCode::FAILURE;
41  }
42 
43  if (m_evtDecoName.empty()) {
44  ATH_MSG_ERROR("Hardscatter decoration name cannot be empty!");
45  return StatusCode::FAILURE;
46  }
47 
48  if (m_vtxSelectTool.empty()) {
49  ATH_MSG_ERROR("No InDet::IInDetHardScatterSelectionTool provided!");
50  return StatusCode::FAILURE;
51  }
52 
53  // Initialize our vertex and event info container reads
54  ATH_CHECK(m_vtxContKey.initialize());
56 
57  // Instantiate and initialize our event info decorator write
60  // Fetch our InDet::IInDetHardScatterSelectionTool
61  ATH_CHECK(m_vtxSelectTool.retrieve());
62  return StatusCode::SUCCESS;
63  }
64 
66  {
67  ATH_MSG_DEBUG("In addBranches(...) for " << name() << "...");
68 
69  const EventContext& ctx = Gaudi::Hive::currentContext();
70 
71  // Open our vertex container
73  if (!vtxCont.isValid()) {
74  ATH_MSG_ERROR("Unable to retrieve xAOD::VertexContainer!");
75  return StatusCode::FAILURE;
76  }
77 
78  // Open our event info
80  if (!evtInfo.isValid()) {
81  ATH_MSG_ERROR("Unable to retrieve xAOD::EventInfo!");
82  return StatusCode::FAILURE;
83  }
84 
85  // Instantiate our WriteDecorHandle
87 
88  // Decorate our event info
89  evtDeco(*evtInfo) = m_vtxSelectTool->getHardScatterLink(vtxCont.get());
90 
91  return StatusCode::SUCCESS;
92  }
93 
94 } // end: namespace DerivationFramework
DerivationFramework::HardScatterVertexDecorator::m_vtxSelectTool
ToolHandle< InDet::IInDetHardScatterSelectionTool > m_vtxSelectTool
ToolHandle for the IInDetHardScatterSelectionTool.
Definition: HardScatterVertexDecorator.h:73
CurrentContext.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::HardScatterVertexDecorator::m_evtDecoName
Gaudi::Property< std::string > m_evtDecoName
Name of the output hardscatter decoration (applied to xAOD::EventInfo)
Definition: HardScatterVertexDecorator.h:69
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
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:65
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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:83
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.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
DerivationFramework::HardScatterVertexDecorator::m_vtxContKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vtxContKey
ReadHandleKey for the input vertices.
Definition: HardScatterVertexDecorator.h:65
DerivationFramework::HardScatterVertexDecorator::m_evtDecoKey
SG::WriteDecorHandleKey< xAOD::EventInfo > m_evtDecoKey
WriteDecorHandleKey for the output hardscatter decoration (applied to xAOD::EventInfo)
Definition: HardScatterVertexDecorator.h:86
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::HardScatterVertexDecorator::initialize
StatusCode initialize()
Function initialising the tool.
Definition: HardScatterVertexDecorator.cxx:30
DerivationFramework::HardScatterVertexDecorator::HardScatterVertexDecorator
HardScatterVertexDecorator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: HardScatterVertexDecorator.cxx:25