ATLAS Offline Software
VertexOnTrack.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // VertexOnTrack.cxx, (c) ATLAS Detector software
8 
9 // Trk
11 #include "VxVertex/RecVertex.h"
12 
13 // Gaudi & AthenaCommon
14 #include "GaudiKernel/MsgStream.h"
15 #include <string>
16 #include <typeinfo>
17 
18 namespace {
19 const double NaN(std::numeric_limits<double>::quiet_NaN());
20 const Amg::Vector3D INVALID_VECTOR3D(NaN, NaN, NaN);
21 }
22 
23 // Constructor with parameters:
25  Amg::MatrixX&& locerr,
26  const PerigeeSurface& assocSurf)
27  : Trk::MeasurementBase(std::move(locpars), std::move(locerr))
28  , PerigeeSurfacePtrHolder(assocSurf)
29  , m_globalPosition(std::nullopt)
30 {}
31 
33  LocalParameters&& locpars,
34  Amg::MatrixX&& locerr,
36  : Trk::MeasurementBase(std::move(locpars), std::move(locerr))
37  , PerigeeSurfacePtrHolder(assocSurf.release())
38  , m_globalPosition(std::nullopt)
39 {}
40 
41 // Constructor with parameters:
43  const Trk::Perigee& perigee)
44  : Trk::MeasurementBase()
45  , PerigeeSurfacePtrHolder(perigee.associatedSurface())
46  , m_globalPosition(Amg::Vector3D(perigee.position()))
47 {
48  if ((rvertex.position() - perigee.associatedSurface().center()).mag() > 10e-5)
49  throw GaudiException(
50  "Inconsistent input data, Perigee not expressed at vertex!",
51  "Trk::VertexOnTrack",
52  StatusCode::RECOVERABLE);
53 
54  // the local parameters are by definition at (0,0)
55  Amg::Vector2D localPosition(0, 0);
56  m_localParams = Trk::LocalParameters(localPosition);
57 
58  // transform Cartesian (x,y,z) to perigee (d0,z0)
59  Amg::MatrixX jacobian(2, 3);
60  jacobian.setZero();
61  double ptInv = 1. / perigee.momentum().perp();
62  jacobian(0, 0) = -ptInv * perigee.momentum().y();
63  jacobian(0, 1) = ptInv * perigee.momentum().x();
64  jacobian(1, 2) = 1.0;
65  // the covariance on matrix of the vertex
66  const Amg::MatrixX& vtxCov = rvertex.covariancePosition();
67  // the local coordinate
68  m_localCovariance = vtxCov.similarity(jacobian);
69 }
70 
71 const Amg::Vector3D&
73 {
74  if (m_globalPosition) {
75  return *m_globalPosition;
76  }
77  return INVALID_VECTOR3D;
78 }
79 
80 MsgStream&
81 Trk::VertexOnTrack::dump(MsgStream& sl) const
82 {
83  std::string name(typeid(*this).name());
84  sl << "Concrete dump method not implemented - using base class" << std::endl;
85  sl << name << "\t local position = " << this->localParameters() << std::endl;
86  sl << name << "\t global position ( " << this->globalPosition().x() << " , "
87  << this->globalPosition().y() << " , " << this->globalPosition().z()
88  << " ) " << std::endl;
89  sl << name << "\t has Error Matrix: " << std::endl;
90  sl << this->localCovariance() << std::endl;
91  sl << name << "\t has associated surface:" << std::endl;
92  sl << this->associatedSurface() << std::endl;
93  return sl;
94 }
95 
96 std::ostream&
97 Trk::VertexOnTrack::dump(std::ostream& sl) const
98 {
99  std::string name(typeid(*this).name());
100  sl << "Concrete dump method not implemented - using base class" << std::endl;
101  sl << name << "\t local position = " << this->localParameters() << std::endl;
102  sl << name << "\t global position ( " << this->globalPosition().x() << " , "
103  << this->globalPosition().y() << " , " << this->globalPosition().z()
104  << " ) " << std::endl;
105  sl << name << "\t has Error Matrix: " << std::endl;
106  sl << this->localCovariance() << std::endl;
107  sl << name << "\t has associated surface:" << std::endl;
108  sl << this->associatedSurface() << std::endl;
109  return sl;
110 }
111 
RecVertex.h
Trk::LocalParameters
Definition: LocalParameters.h:98
Trk::VertexOnTrack::VertexOnTrack
VertexOnTrack()=default
Default Constructor for POOL.
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:29
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
Trk::SurfacePtrHolderImpl
Definition: SurfaceHolderImpl.h:79
Trk::RecVertex
Trk::RecVertex inherits from Trk::Vertex.
Definition: RecVertex.h:44
Trk::VertexOnTrack::dump
virtual MsgStream & dump(MsgStream &out) const override final
returns the some information about this VertexOnTrack.
Definition: VertexOnTrack.cxx:81
Trk::ParametersT::associatedSurface
virtual const S & associatedSurface() const override final
Access to the Surface method.
VertexOnTrack.h
Trk::Vertex::position
const Amg::Vector3D & position() const
return position of vertex
Definition: Vertex.cxx:72
Trk::MeasurementBase::m_localParams
LocalParameters m_localParams
Definition: MeasurementBase.h:111
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
python.EventInfoMgtInit.release
release
Definition: EventInfoMgtInit.py:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trk::VertexOnTrack::globalPosition
virtual const Amg::Vector3D & globalPosition() const override final
Interface method to get the global Position.
Definition: VertexOnTrack.cxx:72
Trk::SurfaceUniquePtrT
std::unique_ptr< S, SurfaceDeleter< S > > SurfaceUniquePtrT
Definition: SurfaceUniquePtrT.h:32
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::MeasurementBase::m_localCovariance
Amg::MatrixX m_localCovariance
Definition: MeasurementBase.h:112
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26