ATLAS Offline Software
GNNVertexFitterAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GNNVertexFitterAlg.h"
6 #include "xAODJet/JetContainer.h"
9 
10 namespace Rec {
11 
12 GNNVertexFitterAlg::GNNVertexFitterAlg(const std::string &name, ISvcLocator *pSvcLocator)
13  : AthReentrantAlgorithm(name, pSvcLocator), m_VtxTool("Rec::GNNVertexFitterTool/VtxTool", this) {
14  declareProperty("VtxTool", m_VtxTool, "The GNN Vtxing Tool");
15 }
16 
18 
19  // Retrieving the tool
20  ATH_CHECK(m_VtxTool.retrieve());
21 
22  // Initializing Keys
23  ATH_CHECK(m_inJetsKey.initialize());
24  ATH_CHECK(m_outVertexKey.initialize());
25  ATH_CHECK(m_pvContainerKey.initialize());
26 
27  return StatusCode::SUCCESS;
28 }
29 
30 StatusCode GNNVertexFitterAlg::execute(const EventContext &ctx) const {
31 
32  ATH_MSG_DEBUG("In GNNVertexFitterAlg::execute()");
33 
34  // Extract Jets
36  if (!inJetContainer.isValid()) {
37  ATH_MSG_WARNING("No xAOD::JetContainer named " << m_inJetsKey.key() << " found in StoreGate");
38  return StatusCode::FAILURE;
39  }
40 
41  // Write new GNN Vertice Container
43  if (outVertexContainer.record(std::make_unique<xAOD::VertexContainer>(), std::make_unique<xAOD::VertexAuxContainer>())
44  .isFailure()) {
45  ATH_MSG_ERROR("Storegate record of VertexContainer failed.");
46  return StatusCode::FAILURE;
47  }
48 
49  const xAOD::Vertex *pv = nullptr;
50  //-- Extract Primary Vertices
52  if (!pv_cont.isValid()) {
53  ATH_MSG_ERROR("No Primary Vertices container found in TDS");
54  return StatusCode::FAILURE;
55  } else {
56  //-- Extract PV itself
57  for (auto v : *pv_cont) {
58  if (v->vertexType() == xAOD::VxType::PriVtx) {
59  pv = v;
60  break;
61  }
62  }
63  }
64  if (!pv) pv = pv_cont->front();
65 
66  // Perform a Vertex fit
67  ATH_CHECK(m_VtxTool->fitAllVertices(inJetContainer.ptr(), outVertexContainer.ptr(), *pv, ctx));
68 
69  return StatusCode::SUCCESS;
70 }
71 
73  ATH_MSG_DEBUG("GNNVertexFitter::finalize()");
74  return StatusCode::SUCCESS;
75 }
76 
77 } // namespace Rec
Rec::GNNVertexFitterAlg::finalize
StatusCode finalize() override
Definition: GNNVertexFitterAlg.cxx:72
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
GNNVertexFitterAlg.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
Rec::GNNVertexFitterAlg::GNNVertexFitterAlg
GNNVertexFitterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: GNNVertexFitterAlg.cxx:12
Rec::GNNVertexFitterAlg::m_inJetsKey
SG::ReadHandleKey< xAOD::JetContainer > m_inJetsKey
Definition: GNNVertexFitterAlg.h:26
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Rec
Name: MuonSpContainer.h Package : offline/Reconstruction/MuonIdentification/muonEvent.
Definition: FakeTrackBuilder.h:10
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Rec::GNNVertexFitterAlg::initialize
StatusCode initialize() override
Definition: GNNVertexFitterAlg.cxx:17
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:571
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
Rec::GNNVertexFitterAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition: GNNVertexFitterAlg.cxx:30
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Rec::GNNVertexFitterAlg::m_pvContainerKey
SG::ReadHandleKey< xAOD::VertexContainer > m_pvContainerKey
Definition: GNNVertexFitterAlg.h:32
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::ReadHandle::ptr
const_pointer_type ptr()
Dereference the pointer.
python.PyAthena.v
v
Definition: PyAthena.py:157
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
VertexContainer.h
Rec::GNNVertexFitterAlg::m_VtxTool
ToolHandle< Rec::GNNVertexFitterTool > m_VtxTool
Definition: GNNVertexFitterAlg.h:24
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
JetContainer.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Rec::GNNVertexFitterAlg::m_outVertexKey
SG::WriteHandleKey< xAOD::VertexContainer > m_outVertexKey
Definition: GNNVertexFitterAlg.h:28
python.changerun.pv
pv
Definition: changerun.py:81
VertexAuxContainer.h