Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:33

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Vertexing/TrackDensityVertexFinder.hpp"
0010 
0011 Acts::Result<std::vector<Acts::Vertex>> Acts::TrackDensityVertexFinder::find(
0012     const std::vector<InputTrack>& trackVector,
0013     const VertexingOptions& vertexingOptions,
0014     IVertexFinder::State& /*state*/) const {
0015   GaussianTrackDensity::State densityState(trackVector.size());
0016 
0017   // Calculate z seed position
0018   auto zAndWidthRes = m_cfg.trackDensityEstimator.globalMaximumWithWidth(
0019       densityState, trackVector);
0020   if (!zAndWidthRes.ok()) {
0021     return zAndWidthRes.error();
0022   }
0023   const auto& zAndWidthOpt = *zAndWidthRes;
0024   if (!zAndWidthOpt) {
0025     return std::vector<Vertex>();
0026   }
0027   const auto& zAndWidth = *zAndWidthOpt;
0028 
0029   double z = zAndWidth.first;
0030 
0031   // Calculate seed position
0032   // Note: constraint position is (0,0,0) if no constraint provided
0033   Vector4 seedPos =
0034       vertexingOptions.constraint.fullPosition() + Vector4(0., 0., z, 0.);
0035 
0036   Vertex returnVertex = Vertex(seedPos);
0037 
0038   SquareMatrix4 seedCov = vertexingOptions.constraint.fullCovariance();
0039 
0040   // Check if a constraint is provided and set the new z position constraint
0041   if (seedCov != SquareMatrix4::Zero() && std::isnormal(zAndWidth.second)) {
0042     seedCov(eZ, eZ) = zAndWidth.second * zAndWidth.second;
0043   }
0044 
0045   returnVertex.setFullCovariance(seedCov);
0046 
0047   return std::vector<Vertex>{returnVertex};
0048 }