ATLAS Offline Software
Loading...
Searching...
No Matches
HoughVtxFinderTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <vector>
8
9
11 ATH_MSG_DEBUG("Initializing ActsTrk::HoughVtxFinderTool");
12
14
15 // logger
16 m_logger = makeActsAthenaLogger(this, "Acts");
17
18 // check if vector sizes are compatible
19 if (m_absEtaRanges.size() != m_absEtaFractions.size()) {
20 ATH_MSG_ERROR("m_absEtaRanges.size() != m_absEtaFractions.size(), "
21 << m_absEtaRanges.size() << " != " << m_absEtaFractions.size());
22 return StatusCode::FAILURE;
23 }
24 if (m_rangeIterZ.size() != m_nBinsZIterZ.size() || m_rangeIterZ.size() != m_nBinsCotThetaIterZ.size()) {
25 ATH_MSG_ERROR("sizes of m_rangeIterZ, m_nBinsZIterZ.size(), and m_nBinsCotThetaIterZ.size() are not equal, "
26 << m_rangeIterZ.size() << ", " << m_nBinsZIterZ.size() << ", " << m_nBinsCotThetaIterZ.size());
27 return StatusCode::FAILURE;
28 }
29
30 // vertex finder configuration
31 m_finderCfg.targetSPs = m_targetSPs;
32 m_finderCfg.minAbsEta = m_minAbsEta;
33 m_finderCfg.maxAbsEta = m_maxAbsEta;
34 m_finderCfg.minHits = m_minHits;
35 m_finderCfg.fillNeighbours = m_fillNeighbours;
36 m_finderCfg.absEtaRanges = m_absEtaRanges;
37 m_finderCfg.absEtaFractions = m_absEtaFractions;
38 m_finderCfg.rangeIterZ = m_rangeIterZ;
39 m_finderCfg.nBinsZIterZ = m_nBinsZIterZ;
40 m_finderCfg.nBinsCotThetaIterZ = m_nBinsCotThetaIterZ;
41 m_finderCfg.binsCotThetaDecrease = m_binsCotThetaDecrease;
42 m_finderCfg.peakWidth = m_peakWidth;
43 Acts::Vector3 defVtxPos{m_defVtxPosition[0], m_defVtxPosition[1], m_defVtxPosition[2]};
44 m_finderCfg.defVtxPosition = defVtxPos;
45
46 ATH_MSG_DEBUG("Successfully initialized ActsTrk::HoughVtxFinderTool");
47 return StatusCode::SUCCESS;
48}
49
50std::pair<std::unique_ptr<xAOD::VertexContainer>, std::unique_ptr<xAOD::VertexAuxContainer>>
52 const xAOD::SpacePointContainer &spacePointContainer) const {
53 // vertex finder configuration depending on the beamspot
54 auto finderCfgBS = m_finderCfg;
55
56 if (m_useBeamSpot) {
57 // beamspot XY position for the default XY position of the vertex
59 const Trk::RecVertex &beamposition(beamSpotHandle->beamVtx());
60
61 finderCfgBS.defVtxPosition[0] = beamposition.position().x();
62 finderCfgBS.defVtxPosition[1] = beamposition.position().y();
63 // default Z position is kept the same
64
65 ATH_MSG_DEBUG("beamspot position: " << beamposition.position().x() << ", " << beamposition.position().y() << ", "
66 << beamposition.position().z());
67 }
68
69 // the output vertex containers
70 auto theVertexContainer = std::make_unique<xAOD::VertexContainer>();
71 auto theVertexAuxContainer = std::make_unique<xAOD::VertexAuxContainer>();
72 theVertexContainer->setStore(theVertexAuxContainer.get());
73
74 if (spacePointContainer.size() < m_minSPs) {
75 ATH_MSG_DEBUG("Not enough space points for vertex finding; " << spacePointContainer.size() << " < " << m_minSPs);
76 // do not attempt vertex finding
77 return std::make_pair(std::move(theVertexContainer), std::move(theVertexAuxContainer));
78 }
79
80 auto vertexFinder = std::make_unique<VertexFinder>(finderCfgBS, logger().cloneWithSuffix("Finder"));
81
82 ATH_MSG_DEBUG("default vertex position: " << vertexFinder->config().defVtxPosition[0] << ", "
83 << vertexFinder->config().defVtxPosition[1] << ", "
84 << vertexFinder->config().defVtxPosition[2]);
85
86 std::vector<SpacePoint> spacePointVector;
87 spacePointVector.reserve(spacePointContainer.size());
88 for (const auto sp : spacePointContainer) {
89 spacePointVector.emplace_back(sp);
90 }
91
92 ATH_MSG_DEBUG("Number of input space points: " << spacePointVector.size());
93 auto vtx = vertexFinder->find(spacePointVector);
94
95 if (vtx.ok()) {
96 ATH_MSG_DEBUG("Vertex position: " << (*vtx)[0] << ", " << (*vtx)[1] << ", " << (*vtx)[2]);
97 auto xAODVertex = theVertexContainer->push_back(std::make_unique<xAOD::Vertex>());
98 xAODVertex->setPosition(*vtx);
99 xAODVertex->setVertexType(xAOD::VxType::PriVtx);
100 } else {
101 ATH_MSG_DEBUG("Vertex finding failed");
102 }
103
104 return std::make_pair(std::move(theVertexContainer), std::move(theVertexAuxContainer));
105}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sp
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
UnsignedIntegerProperty m_fillNeighbours
UnsignedIntegerProperty m_minSPs
std::unique_ptr< const Acts::Logger > m_logger
logging instance
virtual StatusCode initialize() override
DoubleArrayProperty m_defVtxPosition
DoubleArrayProperty m_absEtaRanges
UnsignedIntegerProperty m_targetSPs
virtual std::pair< xAOD::VertexContainer *, xAOD::VertexAuxContainer * > findVertex(const EventContext &, const TrackCollection *) const override
UnsignedIntegerProperty m_minHits
VertexFinder::Config m_finderCfg
UnsignedIntegerArrayProperty m_nBinsCotThetaIterZ
DoubleArrayProperty m_absEtaFractions
UnsignedIntegerArrayProperty m_nBinsZIterZ
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
UnsignedIntegerProperty m_peakWidth
DoubleArrayProperty m_rangeIterZ
size_type size() const noexcept
Returns the number of elements in the collection.
Trk::RecVertex inherits from Trk::Vertex.
Definition RecVertex.h:44
const Amg::Vector3D & position() const
return position of vertex
Definition Vertex.cxx:63
static Root::TMsgLogger logger("iLumiCalc")
@ PriVtx
Primary vertex.
SpacePointContainer_v1 SpacePointContainer
Define the version of the space point container.