ATLAS Offline Software
Loading...
Searching...
No Matches
TrackDensitySeedFinder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*********************************************************************
6 TrackDensitySeedFinder.cxx - Description in header file
7*********************************************************************/
8
10
12
14#include "TrkTrack/Track.h"
16
17//Amg
19
20#include <algorithm>
21
22namespace Trk
23{
24
25 TrackDensitySeedFinder::TrackDensitySeedFinder(const std::string& t, const std::string& n, const IInterface* p) :
26 base_class(t,n,p)
27 {
28 }
29
30
32 = default;
33
34
36 {
37 ATH_CHECK( m_densityEstimator.retrieve() );
38 ATH_MSG_DEBUG("Initialize successful");
39 return StatusCode::SUCCESS;
40 }
41
43 {
44 ATH_MSG_DEBUG("Finalize successful");
45 return StatusCode::SUCCESS;
46 }
47
48 Amg::Vector3D TrackDensitySeedFinder::findSeed(const std::vector<const Trk::Track*> & VectorTrk,
49 const xAOD::Vertex * constraint) const
50 {
51
52 //create perigees from track list
53 std::vector<const TrackParameters*> perigeeList;
54
55 std::vector<const Trk::Track*>::const_iterator begin=VectorTrk.begin();
56 std::vector<const Trk::Track*>::const_iterator end=VectorTrk.end();
57
58 for (std::vector<const Trk::Track*>::const_iterator iter=begin;
59 iter!=end;++iter)
60 {
61 perigeeList.push_back((*iter)->perigeeParameters());
62 }
63
64 //create seed from perigee list
65 return findSeed(perigeeList,constraint);
66 }
67
68 Amg::Vector3D TrackDensitySeedFinder::findSeed(const std::vector<const Trk::TrackParameters*> & perigeeList,
69 const xAOD::Vertex * constraint) const
70 {
71 double zResult {0.};
72 if ( !perigeeList.empty() )
73 {
74 zResult = m_densityEstimator->globalMaximum (perigeeList);
75 ATH_MSG_DEBUG("Highest density Z position found: " << zResult);
76 }
77 else
78 {
79 ATH_MSG_DEBUG("No tracks with sufficient weight; return z position = 0");
80 }
81
82 if (constraint)
83 {
84 return Amg::Vector3D(constraint->position().x(), constraint->position().y(), zResult + constraint->position().z());
85 }
86 else
87 {
88 return Amg::Vector3D(0.,0.,zResult);
89 }
90 }
91
92 // testing find seed with width
93 std::pair<Amg::Vector3D,Amg::MatrixX> TrackDensitySeedFinder::findAnalyticSeed(const std::vector<const Trk::TrackParameters*>& perigeeList, const xAOD::Vertex * constraint ) const{
94 std::pair<double,double> zResult {0.,0.};
95 if ( !perigeeList.empty() )
96 {
97 zResult = m_densityEstimator->globalMaximumWithWidth (perigeeList);
98 ATH_MSG_DEBUG("Highest density Z position found: " << zResult.first << "with width: " << zResult.second);
99 }
100 else
101 {
102 ATH_MSG_DEBUG("No tracks with sufficient weight; return z position = 0");
103 }
104
105 if (constraint)
106 {
107 Amg::Vector3D positionVector = Amg::Vector3D(constraint->position().x(), constraint->position().y(), zResult.first + constraint->position().z());
108 Amg::MatrixX covarianceMatrix = constraint->covariancePosition() ;
109
110 ATH_MSG_DEBUG("The vertex seed width is " << zResult.second);
111
112 // if no seed is found, we get a NaN here.
113 // This should not propagate through the vertex fit.
114 // The upstream code aborts if position[z] == 0, which we need to ensure.
115 // In this case, the cov matrix will not be used.
116 if(std::isnan(zResult.second)){
117 positionVector[2] = 0.;
118 }
119 else covarianceMatrix.fillSymmetric(2,2,std::pow(zResult.second,2.));
120
121 return std::make_pair(positionVector,covarianceMatrix) ;
122 }
123 else
124 {
125 Amg::Vector3D positionVector = Amg::Vector3D(0.,0.,zResult.first);
126 Amg::MatrixX covarianceMatrix;
127 for(const auto i : {0,1,2} ){
128 for(const auto j : {0,1,2}){
129 covarianceMatrix(i,j)=0;
130 }
131 }
132 return {positionVector,covarianceMatrix};
133 }
134}
135
136 std::vector<Amg::Vector3D> TrackDensitySeedFinder::findMultiSeeds(const std::vector<const Trk::Track*>& /* vectorTrk */,
137 const xAOD::Vertex * /* constraint */) const
138 {
139 //implemented to satisfy inheritance but this algorithm only supports one seed at a time
140 ATH_MSG_WARNING("Multi-seeding requested but seed finder not able to operate in that mode, returning no seeds");
141 return std::vector<Amg::Vector3D>(0);
142 }
143
144 std::vector<Amg::Vector3D> TrackDensitySeedFinder::findMultiSeeds(const std::vector<const Trk::TrackParameters*>& /* perigeeList */,
145 const xAOD::Vertex * /* constraint */) const
146 {
147 //implemented to satisfy inheritance but this algorithm only supports one seed at a time
148 ATH_MSG_WARNING("Multi-seeding requested but seed finder not able to operate in that mode, returning no seeds");
149 return std::vector<Amg::Vector3D>(0);
150 }
151
152
153}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
ToolHandle< IVertexTrackDensityEstimator > m_densityEstimator
virtual std::vector< Amg::Vector3D > findMultiSeeds(const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const override final
Finds full vector of linearization points from a vector of tracks and returns it as an Amg::Vector3D ...
TrackDensitySeedFinder(const std::string &t, const std::string &n, const IInterface *p)
virtual std::pair< Amg::Vector3D, Amg::MatrixX > findAnalyticSeed(const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const override final
virtual StatusCode initialize() override
virtual StatusCode finalize() override
virtual Amg::Vector3D findSeed(const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const override final
Finds a linearization point out of a vector of tracks and returns it as an Amg::Vector3D object.
const Amg::Vector3D & position() const
Returns the 3-pos.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
Vertex_v1 Vertex
Define the latest version of the vertex class.