ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
10namespace Rec {
11
12GNNVertexFitterAlg::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
30StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
StatusCode initialize() override
SG::ReadHandleKey< xAOD::JetContainer > m_inJetsKey
GNNVertexFitterAlg(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode finalize() override
SG::WriteHandleKey< xAOD::VertexContainer > m_outVertexKey
StatusCode execute(const EventContext &ctx) const override
ToolHandle< Rec::GNNVertexFitterTool > m_VtxTool
SG::ReadHandleKey< xAOD::VertexContainer > m_pvContainerKey
const_pointer_type ptr()
Dereference the pointer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
Gaudi Tools.
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.