ATLAS Offline Software
Loading...
Searching...
No Matches
Chi2TrackCompatibilityEstimator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*********************************************************************
6 Chi2TrackCompatibilityEstimator.cxx - Description in header file
7*********************************************************************/
8
10
12
14
17
18#include <cmath>
19
20namespace Trk
21{
22
24 {
25 ATH_MSG_DEBUG( "Initialize successful" );
26 return StatusCode::SUCCESS;
27 }
28
30 {
31 ATH_MSG_DEBUG( "Finalize successful" );
32 return StatusCode::SUCCESS;
33 }
34
35
40
41
42 template <class T> float Chi2TrackCompatibilityEstimator::_compatibility(T & myAtaPlane,const Amg::Vector3D & vertex) const {
43
44 ATH_MSG_VERBOSE ("Given plane: " << myAtaPlane->associatedSurface() );
45
46 //now, once you have the AtaPlane, project the actual vertex on the plane.
47 Amg::RotationMatrix3D myPlaneRotation=myAtaPlane->associatedSurface().transform().rotation();
48 Amg::Vector3D myTranslation=myAtaPlane->associatedSurface().transform().translation();
49
50 //get the x and y direction of the plane
51 Amg::Vector3D myXdirPlane=myPlaneRotation.col(0);
52 Amg::Vector3D myYdirPlane=myPlaneRotation.col(1);
53 //CLHEP::Hep3Vector myZdirPlane=myRotation.colZ();
54
55 #ifdef Chi2TrackCompatibilityEstimator_DEBUG
56 std::cout << std::setprecision(10) << "Chi2TrackCompatibilityEstimator: " << "Position is: " << vertex << std::endl;
57 std::cout << std::setprecision(10) << "Chi2TrackCompatibilityEstimator: " << "Rotation is: " << myPlaneRotation << std::endl;
58 std::cout << std::setprecision(10) << "Chi2TrackCompatibilityEstimator: " << "Norm of colX() is: " << myXdirPlane.mag() << " of colY() is: " << myYdirPlane.mag() << std::endl;
59 std::cout << std::setprecision(10) << "Chi2TrackCompatibilityEstimator: " << "Translation is: " << myTranslation << std::endl;
60 #endif
61
62 Amg::Vector3D vertexMinusCenter=vertex-myTranslation;
63
64 #ifdef Chi2TrackCompatibilityEstimator_DEBUG
65 std::cout << std::setprecision(10) << "Chi2TrackCompatibilityEstimator: " << "VertexMinusCenter: " << vertexMinusCenter << std::endl;
66 #endif
67
68 Amg::Vector2D myVertexlocXlocY;
69 myVertexlocXlocY[0]=vertexMinusCenter.dot(myXdirPlane);
70 myVertexlocXlocY[1]=vertexMinusCenter.dot(myYdirPlane);
71
72 #ifdef Chi2TrackCompatibilityEstimator_DEBUG
73 std::cout << std::setprecision(10) << "Chi2TrackCompatibilityEstimator: " << "Vertex local coordinates: " << myVertexlocXlocY << std::endl;
74 #endif
75
76 /* ******Maybe this can be still helpfull
77 //create a default xy plane
78 Plane3D trackPlane();
79
80 //rotate and traslate it according to the plane associated to MeasuredAtaPlane
81 trackPlane.transform(myAtaPlane->associatedSurface()->transform());
82
83 //now project the vertex onto the plane
84 Point3D theVertexOnPlane=trackPlane.point(Point3D(vertex.x(),vertex.y(),vertex.z()));
85
86 //now express the point found in local coordinates
87 */
88
89 const AmgSymMatrix(5) * covar = (myAtaPlane->covariance());
90 AmgSymMatrix(2) myWeightXY = (*covar).block<2,2>(0,0);
91 myWeightXY = myWeightXY.inverse().eval();
92
93 Amg::Vector2D myXY;
94 myXY[0]=myAtaPlane->parameters()[Trk::locX]-myVertexlocXlocY[0];
95 myXY[1]=myAtaPlane->parameters()[Trk::locY]-myVertexlocXlocY[1];
96
97 #ifdef Chi2TrackCompatibilityEstimator_DEBUG
98 std::cout << std::setprecision(10) << "Chi2TrackCompatibilityEstimator: " << "Parameters local coordinates: " << " x: " <<myAtaPlane->parameters()[Trk::locX] <<
99 " y: " << myAtaPlane->parameters()[Trk::locY] << std::endl;
100 std::cout << std::setprecision(10) << "Chi2TrackCompatibilityEstimator: " << "VertexToTrack coordinates: " << myXY << std::endl;
101 #endif
102
103 ATH_MSG_DEBUG ("The weight assigned to the track is " << myXY.dot(myWeightXY*myXY) );
104 ATH_MSG_VERBOSE ("coming from X: " << myXY[0] << " and error: "
105 << std::sqrt((*(myAtaPlane->covariance()))(Trk::locX,Trk::locX)));
106 ATH_MSG_VERBOSE ("and from z0: " << myXY[1] << " and error: "
107 << std::sqrt((*(myAtaPlane->covariance()))(Trk::locY,Trk::locY)));
108
109 return myXY.dot(myWeightXY*myXY);
110 }
111
112
114 {
115 //Looking for a AtaPlane object (track)
116 const Trk::AtaPlane * myAtaPlane=vtxTrack.ImpactPoint3dAtaPlane();
117 if (myAtaPlane!=nullptr && myAtaPlane->covariance()!=nullptr) {
118 return _compatibility(myAtaPlane, vertex);
119 }
120
121 //looking for a NeutralAtaPlane object (neutral)
122 const Trk::NeutralAtaPlane * myNeutralAtaPlane=vtxTrack.ImpactPoint3dNeutralAtaPlane();
123 if (myNeutralAtaPlane!=nullptr && myNeutralAtaPlane->covariance()!=nullptr){
124 return _compatibility(myNeutralAtaPlane, vertex);
125 }
126
127 ATH_MSG_WARNING( " No compatibility plane attached to the VxTrackAtVertex. Compatibility couldn't be found... 0 compatibility returned." );
128 return 100;
129 }
130}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define AmgSymMatrix(dim)
virtual float compatibility(VxTrackAtVertex &vtxTrack, const Amg::Vector3D &vertex) const override
Compatibility method returning the compatibility value.
float _compatibility(T &plane, const Amg::Vector3D &vertex) const
Compatibility method returning the compatibility value.
virtual void estimate(VxTrackAtVertex &, const Amg::Vector3D &vertex) const override
Estimate method changing the state of VxTrackAtVertex.
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
const NeutralAtaPlane * ImpactPoint3dNeutralAtaPlane(void) const
Returns ImpactPoint3dNeutralAtaPlane.
void setVtxCompatibility(const double)
const AtaPlane * ImpactPoint3dAtaPlane(void) const
Returns ImpactPoint3dAtaPlane.
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
ParametersT< NeutralParametersDim, Neutral, PlaneSurface > NeutralAtaPlane
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane