ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::TrackParametersKVU Class Reference

the code used in this implementation is kindly stolen from: atlasoff:: ISF/ISF_Core/ISF_Tools More...

#include <TrackParametersKVU.h>

Inheritance diagram for DerivationFramework::TrackParametersKVU:
Collaboration diagram for DerivationFramework::TrackParametersKVU:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode addBranches (const EventContext &ctx) const override
 Check that the current event passes this filter.

Private Attributes

SG::ReadHandleKey< xAOD::TrackParticleContainerm_trackContainerKey
SG::ReadHandleKey< xAOD::VertexContainerm_vertexContainerKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_KVUphiKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_KVUthetaKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_KVUd0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_KVUz0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_KVUqOverPKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_KVUChi2Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_KVUusedPVKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_KVUCovMatKey
ToolHandle< Trk::IVertexTrackUpdatorm_vertexTrackUpdator
ToolHandle< Trk::IExtrapolatorm_extrapolator
ToolHandle< Trk::IVertexLinearizedTrackFactorym_LinearizedTrackFactory
ToolHandle< Trk::ITrackToVertexIPEstimatorm_IPEstimator

Detailed Description

the code used in this implementation is kindly stolen from: atlasoff:: ISF/ISF_Core/ISF_Tools

Author
James Catmore -at- cern.ch

Definition at line 53 of file TrackParametersKVU.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::TrackParametersKVU::addBranches ( const EventContext & ctx) const
overridevirtual

Check that the current event passes this filter.

Definition at line 43 of file TrackParametersKVU.cxx.

44{
45 // --- Get the tracks
46 SG::ReadHandle<xAOD::TrackParticleContainer> tracks(m_trackContainerKey,ctx);
47 ATH_CHECK( tracks.isValid() );
48
49 //-- for each track, update track params with vtx considered as extra measurement (choose the closest vtx)
50 if(tracks->size() !=0) {
51 SG::WriteDecorHandle<xAOD::TrackParticleContainer, float> decoratorKVUphi(m_KVUphiKey, ctx);
52 SG::WriteDecorHandle<xAOD::TrackParticleContainer, float> decoratorKVUtheta(m_KVUthetaKey, ctx);
53 SG::WriteDecorHandle<xAOD::TrackParticleContainer, float> decoratorKVUd0(m_KVUd0Key, ctx);
54 SG::WriteDecorHandle<xAOD::TrackParticleContainer, float> decoratorKVUz0(m_KVUz0Key, ctx);
55 SG::WriteDecorHandle<xAOD::TrackParticleContainer, float> decoratorKVUqOverP(m_KVUqOverPKey, ctx);
56 SG::WriteDecorHandle<xAOD::TrackParticleContainer, float> decoratorKVUChi2(m_KVUChi2Key, ctx);
57 SG::WriteDecorHandle<xAOD::TrackParticleContainer, float> decoratorKVUusedPV(m_KVUusedPVKey, ctx);
58 SG::WriteDecorHandle<xAOD::TrackParticleContainer, std::vector<float>> decoratorKVUCovMat(m_KVUCovMatKey, ctx);
59
60 for (const auto track : *tracks) {
61 if(track){
62 const Trk::TrackParameters *tPerigee = &(track->perigeeParameters());
63 // --- list of new variables that will decorate the track
64 std::unique_ptr<AmgSymMatrix(5)> updateTrackCov = nullptr;
65 float updatephi = -999;
66 float updatetheta = -999;
67 float updated0 = -999;
68 float updatez0 = -999;
69 float updateqOverP = -999;
70 float updateChi2 = -999;
71 bool usedPrimaryVertex = false;
72 std::vector<float> vec;
73
74 std::unique_ptr<const Trk::TrackParameters> trackParams = nullptr;
75 float minIP = 1000.;
76 //--- retrieve closest vertex to track
77 const xAOD::Vertex* closestVertex = nullptr;
78 int nVtx = 0;
79 SG::ReadHandle<xAOD::VertexContainer> vxContainer(m_vertexContainerKey,ctx);
80 if (vxContainer.isValid()) {
81 for (const xAOD::Vertex* vtx: *vxContainer) {
82 if ( (vtx->vertexType() == xAOD::VxType::PriVtx) ||
83 (vtx->vertexType() == xAOD::VxType::PileUp) ) {
84 Amg::Vector3D vtxPos(vtx->position());
85 auto vtxSurface = std::make_unique<Trk::PerigeeSurface>(vtxPos);
86 trackParams = m_extrapolator->extrapolate(ctx,*tPerigee,*vtxSurface);
87 std::unique_ptr<const Trk::ImpactParametersAndSigma> iPandSigma = nullptr;
88 iPandSigma = m_IPEstimator->estimate(trackParams.get(), vtx);
89 if(sqrt(iPandSigma->IPd0*iPandSigma->IPd0+iPandSigma->IPz0*iPandSigma->IPz0) < minIP){
90 minIP = sqrt(iPandSigma->IPd0*iPandSigma->IPd0+iPandSigma->IPz0*iPandSigma->IPz0);
91 closestVertex = vtx;
92 }
93 ATH_MSG_VERBOSE("n vtx pos(x, y, z) IPd0 IPz0 : " << nVtx << " " << vtx->position().x() << " "<< vtx->position().y() << " "<< vtx->position().z() << " " << iPandSigma->IPd0 << " " << iPandSigma->IPz0);
94 ATH_MSG_VERBOSE(" d0,Delta_z0-TrackParticle:" << track->d0() <<", "<< track->z0() - vtx->z() + track->vz());
95 nVtx++;
96 }
97 }
98 }else{
99 ATH_MSG_ERROR ("Couldn't retrieve vxContainer with key: " << m_vertexContainerKey.key() );
100 return StatusCode::FAILURE;
101 } // --- end retrieve closest vertex to track
102
103
104 // update the track params with vtx info after linearization of track around it
105 if(closestVertex){
106 ATH_MSG_VERBOSE("Vertex selected position (x y z): " << closestVertex->position().x()<<" "<<closestVertex->position().y()<<" "<<closestVertex->position().z());
107 ATH_MSG_VERBOSE(" type: " << closestVertex->vertexType());
108 ATH_MSG_VERBOSE(" nParticles: " << closestVertex->nTrackParticles());
109 ATH_MSG_VERBOSE(" quality chi2: " << closestVertex->chiSquared() << " " << closestVertex->numberDoF());
110 Amg::Vector3D globPos(closestVertex->position());
111 auto recVtx = std::make_unique<xAOD::Vertex>();
112 recVtx->makePrivateStore(*closestVertex);
113 auto surface = std::make_unique<const Trk::PerigeeSurface>(globPos);
114 trackParams = m_extrapolator->extrapolate(ctx,*tPerigee,*surface);
115 auto linearTrack = std::make_unique<Trk::VxTrackAtVertex>(0., nullptr, nullptr, trackParams.get(), nullptr);
116 if(linearTrack){
117 ATH_MSG_VERBOSE("Linearizing track");
118 m_LinearizedTrackFactory->linearize(*linearTrack,globPos);
119 ATH_MSG_VERBOSE("Updating linearized track parameters after vertex fit. Track weight = " << linearTrack->weight());
120 m_vertexTrackUpdator->update((*linearTrack), (*recVtx));
121 ATH_MSG_VERBOSE ("track info after vertex track updator !"<<*linearTrack );
122 if(linearTrack->perigeeAtVertex()) {
123 //retrieve & store updated track param qOverP,d0, z0,theta,phi after KVU
124 updateqOverP = linearTrack->perigeeAtVertex()->parameters()[Trk::qOverP];
125 updated0 = linearTrack->perigeeAtVertex()->parameters()[Trk::d0];
126 updatez0 = linearTrack->perigeeAtVertex()->parameters()[Trk::z0];
127 updatephi = linearTrack->perigeeAtVertex()->parameters()[Trk::phi0];
128 updatetheta = linearTrack->perigeeAtVertex()->parameters()[Trk::theta];
129 //retrieve & store updated track cov matrix plus save the KVU Chi2
130 updateTrackCov = std::make_unique<AmgSymMatrix(5)>(*linearTrack->perigeeAtVertex()->covariance());
131 updateChi2 = linearTrack->trackQuality().chiSquared();
132 // store whether this used the PV or not
133 usedPrimaryVertex = closestVertex->vertexType()==xAOD::VxType::PriVtx;
134 }
135 }
136 }// --- end if closest vertex
137
138 //decorate tracks with new updated track parameters:
139 decoratorKVUqOverP(*track) = updateqOverP;
140 decoratorKVUd0(*track) = updated0;
141 decoratorKVUz0(*track) = updatez0;
142 decoratorKVUphi(*track) = updatephi;
143 decoratorKVUtheta(*track) = updatetheta;
144 decoratorKVUChi2(*track) = updateChi2;
145 decoratorKVUusedPV(*track) = usedPrimaryVertex;
146 if (updateTrackCov){
147 Amg::compress(*updateTrackCov, vec);
148 }else{
149 vec.assign(5, 0.0);
150 }
151 decoratorKVUCovMat(*track) = vec;
152 ATH_MSG_VERBOSE("track updated.");
153 } // --- end if(track)
154 } // --- end loop tracks
155 ATH_MSG_VERBOSE("All tracks updated.");
156 }
157
158 return StatusCode::SUCCESS;
159}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
std::vector< size_t > vec
#define AmgSymMatrix(dim)
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUCovMatKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUd0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUChi2Key
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_LinearizedTrackFactory
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUz0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUqOverPKey
ToolHandle< Trk::IVertexTrackUpdator > m_vertexTrackUpdator
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackContainerKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUphiKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUusedPVKey
ToolHandle< Trk::ITrackToVertexIPEstimator > m_IPEstimator
ToolHandle< Trk::IExtrapolator > m_extrapolator
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUthetaKey
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
float numberDoF() const
Returns the number of degrees of freedom of the vertex fit as float.
VxType::VertexType vertexType() const
The type of the vertex.
float chiSquared() const
Returns the of the vertex fit as float.
const Amg::Vector3D & position() const
Returns the 3-pos.
void compress(const AmgSymMatrix(N) &covMatrix, std::vector< float > &vec)
Eigen::Matrix< double, 3, 1 > Vector3D
@ phi0
Definition ParamDefs.h:65
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
ParametersBase< TrackParametersDim, Charged > TrackParameters
@ PileUp
Pile-up vertex.
@ PriVtx
Primary vertex.
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ initialize()

StatusCode DerivationFramework::TrackParametersKVU::initialize ( )
overridevirtual

Definition at line 12 of file TrackParametersKVU.cxx.

13{
14
15 if (m_trackContainerKey.empty() || m_vertexContainerKey.empty()) {
16 ATH_MSG_ERROR("No selection variables for the TrackParametersKVU tool!");
17 return StatusCode::FAILURE;
18 }
19
20 ATH_CHECK(m_trackContainerKey.initialize());
21 ATH_CHECK(m_vertexContainerKey.initialize());
22
23 ATH_CHECK(m_KVUphiKey.initialize());
24 ATH_CHECK(m_KVUthetaKey.initialize());
25 ATH_CHECK(m_KVUd0Key.initialize());
26 ATH_CHECK(m_KVUz0Key.initialize());
27 ATH_CHECK(m_KVUqOverPKey.initialize());
28 ATH_CHECK(m_KVUChi2Key.initialize());
29 ATH_CHECK(m_KVUusedPVKey.initialize());
30 ATH_CHECK(m_KVUCovMatKey.initialize());
31
33 ATH_CHECK(m_extrapolator.retrieve());
35 ATH_CHECK(m_IPEstimator.retrieve());
36
37 ATH_MSG_DEBUG("initialize() ...");
38 ATH_MSG_DEBUG("Successfully retrieved the TrackParametersKVU tool" );
39 return StatusCode::SUCCESS;
40}
#define ATH_MSG_DEBUG(x)

Member Data Documentation

◆ m_extrapolator

ToolHandle< Trk::IExtrapolator > DerivationFramework::TrackParametersKVU::m_extrapolator
private
Initial value:
{
this, "TrackExtrapolator", "Trk::Extrapolator/AtlasExtrapolator"}

Definition at line 89 of file TrackParametersKVU.h.

89 {
90 this, "TrackExtrapolator", "Trk::Extrapolator/AtlasExtrapolator"};

◆ m_IPEstimator

ToolHandle< Trk::ITrackToVertexIPEstimator> DerivationFramework::TrackParametersKVU::m_IPEstimator
private
Initial value:
{
this, "IPEstimator", "Trk::TrackToVertexIPEstimator/TrackToVertexIPEstimator"}

Definition at line 93 of file TrackParametersKVU.h.

93 {
94 this, "IPEstimator", "Trk::TrackToVertexIPEstimator/TrackToVertexIPEstimator"};

◆ m_KVUChi2Key

SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > DerivationFramework::TrackParametersKVU::m_KVUChi2Key
private
Initial value:
{
this, "KVUChi2Key", m_trackContainerKey, "KVUChi2"}

Definition at line 80 of file TrackParametersKVU.h.

80 {
81 this, "KVUChi2Key", m_trackContainerKey, "KVUChi2"};

◆ m_KVUCovMatKey

SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > DerivationFramework::TrackParametersKVU::m_KVUCovMatKey
private
Initial value:
{
this, "KVUCovMatKey", m_trackContainerKey, "KVUCovMat"}

Definition at line 84 of file TrackParametersKVU.h.

84 {
85 this, "KVUCovMatKey", m_trackContainerKey, "KVUCovMat"};

◆ m_KVUd0Key

SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > DerivationFramework::TrackParametersKVU::m_KVUd0Key
private
Initial value:
{
this, "KVUd0Key", m_trackContainerKey, "KVUd0"}

Definition at line 74 of file TrackParametersKVU.h.

74 {
75 this, "KVUd0Key", m_trackContainerKey, "KVUd0"};

◆ m_KVUphiKey

SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > DerivationFramework::TrackParametersKVU::m_KVUphiKey
private
Initial value:
{
this, "KVUphiKey", m_trackContainerKey, "KVUphi"}

Definition at line 70 of file TrackParametersKVU.h.

70 {
71 this, "KVUphiKey", m_trackContainerKey, "KVUphi"};

◆ m_KVUqOverPKey

SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > DerivationFramework::TrackParametersKVU::m_KVUqOverPKey
private
Initial value:
{
this, "KVUqOverPKey", m_trackContainerKey, "KVUqOverP"}

Definition at line 78 of file TrackParametersKVU.h.

78 {
79 this, "KVUqOverPKey", m_trackContainerKey, "KVUqOverP"};

◆ m_KVUthetaKey

SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > DerivationFramework::TrackParametersKVU::m_KVUthetaKey
private
Initial value:
{
this, "KVUthetaKey", m_trackContainerKey, "KVUtheta"}

Definition at line 72 of file TrackParametersKVU.h.

72 {
73 this, "KVUthetaKey", m_trackContainerKey, "KVUtheta"};

◆ m_KVUusedPVKey

SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > DerivationFramework::TrackParametersKVU::m_KVUusedPVKey
private
Initial value:
{
this, "KVUusedPVKey", m_trackContainerKey, "KVUusedPV"}

Definition at line 82 of file TrackParametersKVU.h.

82 {
83 this, "KVUusedPVKey", m_trackContainerKey, "KVUusedPV"};

◆ m_KVUz0Key

SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > DerivationFramework::TrackParametersKVU::m_KVUz0Key
private
Initial value:
{
this, "KVUz0Key", m_trackContainerKey, "KVUz0"}

Definition at line 76 of file TrackParametersKVU.h.

76 {
77 this, "KVUz0Key", m_trackContainerKey, "KVUz0"};

◆ m_LinearizedTrackFactory

ToolHandle< Trk::IVertexLinearizedTrackFactory > DerivationFramework::TrackParametersKVU::m_LinearizedTrackFactory
private
Initial value:
{
this, "LinearizedTrackFactory", "Trk::FullLinearizedTrackFactory/FullLinearizedTrackFactory"}

Definition at line 91 of file TrackParametersKVU.h.

91 {
92 this, "LinearizedTrackFactory", "Trk::FullLinearizedTrackFactory/FullLinearizedTrackFactory"};

◆ m_trackContainerKey

SG::ReadHandleKey< xAOD::TrackParticleContainer > DerivationFramework::TrackParametersKVU::m_trackContainerKey
private
Initial value:
{
this, "TrackParticleContainerName", "InDetDisappearingTrackParticles"}

Definition at line 66 of file TrackParametersKVU.h.

66 {
67 this, "TrackParticleContainerName", "InDetDisappearingTrackParticles"};

◆ m_vertexContainerKey

SG::ReadHandleKey< xAOD::VertexContainer > DerivationFramework::TrackParametersKVU::m_vertexContainerKey
private
Initial value:
{
this, "VertexContainerName", "PrimaryVertices"}

Definition at line 68 of file TrackParametersKVU.h.

68 {
69 this, "VertexContainerName", "PrimaryVertices"};

◆ m_vertexTrackUpdator

ToolHandle< Trk::IVertexTrackUpdator > DerivationFramework::TrackParametersKVU::m_vertexTrackUpdator
private
Initial value:
{
this, "VertexTrackUpdator", "Trk::KalmanVertexTrackUpdator"}

Definition at line 87 of file TrackParametersKVU.h.

87 {
88 this, "VertexTrackUpdator", "Trk::KalmanVertexTrackUpdator"};

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