ATLAS Offline Software
Trk2DDistanceFinder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*********************************************************************
6  Trk2DDistanceFinder.cxx - Description in header file
7 *********************************************************************/
8 
9 //#define SEEDNEWTONTRKDISTANCEFINDER_DEBUG
10 
11 
18 #include "TrkTrack/Track.h"
21 #include <cmath>
22 
23 
24 namespace Trk
25 {
26 
27 
28  Trk2DDistanceFinder::Trk2DDistanceFinder(const std::string& t, const std::string& n, const IInterface* p) :
29  base_class(t,n,p),
30  m_2ddistanceseeder("Trk::Trk2dDistanceSeeder"),
31  m_numberOfMinimizationFailures(0)
32  {
33  declareProperty("Trk2dDistanceSeeder", m_2ddistanceseeder);
34  }
35 
37 
39  {
40 
41  //initialize number of failures to 0
43 
45  ATH_CHECK( m_2ddistanceseeder.retrieve() );
46  ATH_MSG_DEBUG( "Initialize successful" );
47  return StatusCode::SUCCESS;
48  }
49 
51  {
52  ATH_MSG_DEBUG( "Finalize successful. Number of failed minimizations: " << m_numberOfMinimizationFailures << ". Few per events is OK!" );
53  return StatusCode::SUCCESS;
54  }
55 
56 
59  std::optional<ITrkDistanceFinder::TwoPoints>
61  const Trk::Perigee & b) const
62  {
63  std::pair<PointOnTrack,PointOnTrack> minpoints;
65 
66  try {
67  minpoints=m_2ddistanceseeder->GetSeed(TwoTracks(a,b), &points);
68  } catch (...) {
69  ATH_MSG_WARNING( "Problem with 2d analytic minimum distance finder" );
71  return std::nullopt;
72  }
73 
74 
75 #ifdef SEEDNEWTONTRKDISTANCEFINDER_DEBUG
76  ATH_MSG_DEBUG( "Returned a_phi " << minpoints.first.getPhiPoint() );
77  ATH_MSG_DEBUG( "Returned b_phi " << minpoints.second.getPhiPoint() );
78 #endif
79 
80  return points;
81 
82  }
83 
85  std::optional<ITrkDistanceFinder::TwoPoints>
87  const Trk::Track & b) const
88  {
89  if (std::isnan(a.perigeeParameters()->parameters()[Trk::d0])||std::isnan(b.perigeeParameters()->parameters()[Trk::d0])) {
90  ATH_MSG_ERROR( "Nan parameters in tracks. Cannot use them" );
91  return std::nullopt;
92  }
93 
94  return CalculateMinimumDistance(*(a.perigeeParameters()),*(b.perigeeParameters()));
95  }
96 
97 } // namespace Trk
98 
TrackParameters.h
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
initialize
void initialize()
Definition: run_EoverP.cxx:894
TrackParticleBase.h
Trk::TwoPoints
std::pair< Amg::Vector3D, Amg::Vector3D > TwoPoints
Definition: SeedFinderParamDefs.h:20
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ParamDefs.h
Trk::Trk2DDistanceFinder::~Trk2DDistanceFinder
virtual ~Trk2DDistanceFinder()
Track.h
GeoPrimitives.h
Trk::Trk2DDistanceFinder::m_numberOfMinimizationFailures
std::atomic< int > m_numberOfMinimizationFailures
Definition: Trk2DDistanceFinder.h:62
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
Trk::Trk2DDistanceFinder::initialize
virtual StatusCode initialize() override
Definition: Trk2DDistanceFinder.cxx:40
Trk2DDistanceFinder.h
Trk2dDistanceSeeder.h
Trk::Trk2DDistanceFinder::CalculateMinimumDistance
virtual std::optional< TwoPoints > CalculateMinimumDistance(const Trk::Perigee &, const Trk::Perigee &) const override final
method to do the calculation starting from two MeasuredPerigees
Definition: Trk2DDistanceFinder.cxx:62
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EventPrimitives.h
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::d0
@ d0
Definition: ParamDefs.h:63
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SeedFinderParamDefs.h
Trk::Trk2DDistanceFinder::finalize
virtual StatusCode finalize() override
Definition: Trk2DDistanceFinder.cxx:52
Trk::Trk2DDistanceFinder::Trk2DDistanceFinder
Trk2DDistanceFinder(const std::string &t, const std::string &n, const IInterface *p)
Definition: Trk2DDistanceFinder.cxx:30
a
TList * a
Definition: liststreamerinfos.cxx:10
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::Trk2DDistanceFinder::m_2ddistanceseeder
ToolHandle< Trk2dDistanceSeeder > m_2ddistanceseeder
Definition: Trk2DDistanceFinder.h:61
jobOptions.points
points
Definition: jobOptions.GenevaPy8_Zmumu.py:97
Trk::TwoTracks
Definition: TwoTracks.h:15