ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::SeedNewtonTrkDistanceFinder Class Referencefinal

Algotool which calculates the distance between the two tracks, using: the distance finder you specify, which is an object of type NewtonTrkDistanceFinderAlgo, and using a starting position on the tracks given by Trk2dDistanceSeeder. More...

#include <SeedNewtonTrkDistanceFinder.h>

Inheritance diagram for Trk::SeedNewtonTrkDistanceFinder:
Collaboration diagram for Trk::SeedNewtonTrkDistanceFinder:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode finalize () override
 SeedNewtonTrkDistanceFinder (const std::string &t, const std::string &n, const IInterface *p)
virtual ~SeedNewtonTrkDistanceFinder ()
virtual std::optional< TwoPointsCalculateMinimumDistance (const Trk::Perigee &, const Trk::Perigee &) const override final
 method to do the calculation starting from two Perigees
virtual std::optional< TwoPointsCalculateMinimumDistance (const Trk::Track &, const Trk::Track &) const override final
 method to do the calculation starting from two tracks

Private Attributes

ToolHandle< Trk2dDistanceSeederm_2ddistanceseeder
ToolHandle< NewtonTrkDistanceFinderm_distancefinder
std::atomic< int > m_numberOfMinimizationFailures

Detailed Description

Algotool which calculates the distance between the two tracks, using: the distance finder you specify, which is an object of type NewtonTrkDistanceFinderAlgo, and using a starting position on the tracks given by Trk2dDistanceSeeder.

The class NewtonTrkDistanceFinderAlgo is based on a Newton minimization procedure, which finds the twodimensional point (position on first and second track) on which the derivatives of the distance is zero.

To avoid maxima the algorithm is initialized with two initial points on the two tracks, which are obtained using the Trk2dDistanceSeeder AlgoTool. This tool finds the point on minimum distance on the transverse plane, which is analitically well defined (intersection of two circles). In case of double intersection different possibilities were considered, at the end I found reasonably good to choose the intersection point where the tracks are nearest in the z coordinate...

Author
Giaci.nosp@m.nto..nosp@m.Piacq.nosp@m.uadi.nosp@m.o@phy.nosp@m.sik..nosp@m.uni-f.nosp@m.reib.nosp@m.urg.d.nosp@m.e

Definition at line 44 of file SeedNewtonTrkDistanceFinder.h.

Constructor & Destructor Documentation

◆ SeedNewtonTrkDistanceFinder()

Trk::SeedNewtonTrkDistanceFinder::SeedNewtonTrkDistanceFinder ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 27 of file SeedNewtonTrkDistanceFinder.cxx.

27 :
28 base_class(t,n,p),
29 m_2ddistanceseeder("Trk::Trk2dDistanceSeeder"),
30 m_distancefinder("Trk::NewtonTrkDistanceFinder"),
32 {
33 declareProperty("Trk2dDistanceSeeder", m_2ddistanceseeder);
34 declareProperty("TrkDistanceFinderImplementation", m_distancefinder);
35 }
ToolHandle< Trk2dDistanceSeeder > m_2ddistanceseeder
ToolHandle< NewtonTrkDistanceFinder > m_distancefinder

◆ ~SeedNewtonTrkDistanceFinder()

Trk::SeedNewtonTrkDistanceFinder::~SeedNewtonTrkDistanceFinder ( )
virtualdefault

Member Function Documentation

◆ CalculateMinimumDistance() [1/2]

std::optional< ITrkDistanceFinder::TwoPoints > Trk::SeedNewtonTrkDistanceFinder::CalculateMinimumDistance ( const Trk::Perigee & a,
const Trk::Perigee & b ) const
finaloverridevirtual

method to do the calculation starting from two Perigees

method to do the calculation starting from two MeasuredPerigees

If successful, returns the points on the two tracks at minimum distance.

return value is true if calculation is successfull

Definition at line 63 of file SeedNewtonTrkDistanceFinder.cxx.

65 {
66 //defragmenting the meory: local variable instead of private data member
67 std::pair<PointOnTrack,PointOnTrack> minpoints;
68
69 //try first to get the minimum directly with the Newton method
70 auto ret = m_distancefinder->GetClosestPoints(a,b);
71 if (std::holds_alternative<TwoPoints>(ret)) {
72 return std::get<TwoPoints>(ret);
73 }
74 ATH_MSG_DEBUG( "Problem with Newton finder: " <<
75 std::get<std::string>(ret) );
76 minpoints = m_2ddistanceseeder->GetSeed(TwoTracks(a,b));
77 ret = m_distancefinder->GetClosestPoints(minpoints);
78 if (std::holds_alternative<TwoPoints>(ret)) {
79 return std::get<TwoPoints>(ret);
80 }
81 ATH_MSG_DEBUG( "Problem with Newton finder, even after 2d seeder: no minimum between tracks found" << std::get<std::string>(ret));
83
84 return std::nullopt;
85 }
#define ATH_MSG_DEBUG(x)
static Double_t a

◆ CalculateMinimumDistance() [2/2]

std::optional< ITrkDistanceFinder::TwoPoints > Trk::SeedNewtonTrkDistanceFinder::CalculateMinimumDistance ( const Trk::Track & a,
const Trk::Track & b ) const
finaloverridevirtual

method to do the calculation starting from two tracks

Definition at line 90 of file SeedNewtonTrkDistanceFinder.cxx.

92 {
93 if (std::isnan(a.perigeeParameters()->parameters()[Trk::d0])||std::isnan(b.perigeeParameters()->parameters()[Trk::d0])) {
94 ATH_MSG_ERROR( "Nan parameters in tracks. Cannot use them" );
95 return std::nullopt;
96 }
97
98 return CalculateMinimumDistance(*(a.perigeeParameters()),*(b.perigeeParameters()));
99
100 }
#define ATH_MSG_ERROR(x)
virtual std::optional< TwoPoints > CalculateMinimumDistance(const Trk::Perigee &, const Trk::Perigee &) const override final
method to do the calculation starting from two Perigees
@ d0
Definition ParamDefs.h:63

◆ finalize()

StatusCode Trk::SeedNewtonTrkDistanceFinder::finalize ( )
overridevirtual

Definition at line 52 of file SeedNewtonTrkDistanceFinder.cxx.

53 {
54
55 ATH_MSG_DEBUG( "Finalize successful. Number of failed minimizations: " << m_numberOfMinimizationFailures << ". Few per events is OK!" );
56 return StatusCode::SUCCESS;
57 }

◆ initialize()

StatusCode Trk::SeedNewtonTrkDistanceFinder::initialize ( )
overridevirtual

Definition at line 39 of file SeedNewtonTrkDistanceFinder.cxx.

40 {
41
42 //initialize number of failures to 0
44
45 ATH_CHECK( AlgTool::initialize() );
46 ATH_CHECK( m_2ddistanceseeder.retrieve() );
47 ATH_CHECK( m_distancefinder.retrieve() );
48 ATH_MSG_DEBUG( "Initialize successful" );
49 return StatusCode::SUCCESS;
50 }
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_2ddistanceseeder

ToolHandle<Trk2dDistanceSeeder> Trk::SeedNewtonTrkDistanceFinder::m_2ddistanceseeder
private

Definition at line 66 of file SeedNewtonTrkDistanceFinder.h.

◆ m_distancefinder

ToolHandle<NewtonTrkDistanceFinder> Trk::SeedNewtonTrkDistanceFinder::m_distancefinder
private

Definition at line 67 of file SeedNewtonTrkDistanceFinder.h.

◆ m_numberOfMinimizationFailures

std::atomic<int> Trk::SeedNewtonTrkDistanceFinder::m_numberOfMinimizationFailures
mutableprivate

Definition at line 68 of file SeedNewtonTrkDistanceFinder.h.


The documentation for this class was generated from the following files: