ATLAS Offline Software
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 
20 namespace 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 
37  {
39  }
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 }
Trk::VxTrackAtVertex
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Definition: VxTrackAtVertex.h:77
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
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::Chi2TrackCompatibilityEstimator::estimate
virtual void estimate(VxTrackAtVertex &, const Amg::Vector3D &vertex) const override
Estimate method changing the state of VxTrackAtVertex.
Definition: Chi2TrackCompatibilityEstimator.cxx:38
Trk::Chi2TrackCompatibilityEstimator::finalize
virtual StatusCode finalize() override
Definition: Chi2TrackCompatibilityEstimator.cxx:31
Trk::VxTrackAtVertex::setVtxCompatibility
void setVtxCompatibility(const double)
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trk::Chi2TrackCompatibilityEstimator::_compatibility
float _compatibility(T &plane, const Amg::Vector3D &vertex) const
Compatibility method returning the compatibility value.
Definition: Chi2TrackCompatibilityEstimator.cxx:44
ParamDefs.h
Trk::VxTrackAtVertex::ImpactPoint3dNeutralAtaPlane
const NeutralAtaPlane * ImpactPoint3dNeutralAtaPlane(void) const
Returns ImpactPoint3dNeutralAtaPlane.
Trk::VxTrackAtVertex::ImpactPoint3dAtaPlane
const AtaPlane * ImpactPoint3dAtaPlane(void) const
Returns ImpactPoint3dAtaPlane.
Trk::AmgSymMatrix
AmgSymMatrix(5) &GXFTrackState
Definition: GXFTrackState.h:156
Trk::Chi2TrackCompatibilityEstimator::initialize
virtual StatusCode initialize() override
Definition: Chi2TrackCompatibilityEstimator.cxx:25
Chi2TrackCompatibilityEstimator.h
ParametersBase.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MuonR4::inverse
CalibratedSpacePoint::Covariance_t inverse(const CalibratedSpacePoint::Covariance_t &mat)
Inverts the parsed matrix.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx:65
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
VxTrackAtVertex.h
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
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
PlaneSurface.h
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
Trk::Chi2TrackCompatibilityEstimator::compatibility
virtual float compatibility(VxTrackAtVertex &vtxTrack, const Amg::Vector3D &vertex) const override
Compatibility method returning the compatibility value.
Definition: Chi2TrackCompatibilityEstimator.cxx:115