ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DerivationFramework::TrackParametersKVU Class Reference

#include <TrackParametersKVU.h>

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

Public Member Functions

 TrackParametersKVU (const std::string &t, const std::string &n, const IInterface *p)
 Constructor with parameters. More...
 
virtual ~TrackParametersKVU ()=default
 Destructor. More...
 
virtual StatusCode initialize () override
 
virtual StatusCode addBranches (const EventContext &ctx) const override
 Check that the current event passes this filter. More...
 

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
 
StringProperty m_sgName {this, "DecorationPrefix", "", "decoration prefix"}
 

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 57 of file TrackParametersKVU.h.

Constructor & Destructor Documentation

◆ TrackParametersKVU()

DerivationFramework::TrackParametersKVU::TrackParametersKVU ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Constructor with parameters.

Definition at line 16 of file TrackParameterKVU.cxx.

18  :
19  base_class(t, n, p){}

◆ ~TrackParametersKVU()

virtual DerivationFramework::TrackParametersKVU::~TrackParametersKVU ( )
virtualdefault

Destructor.

Member Function Documentation

◆ addBranches()

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

Check that the current event passes this filter.

Definition at line 62 of file TrackParameterKVU.cxx.

63 {
64  // --- Get the tracks
65  //const xAOD::TrackParticleContainer* tracks = nullptr;
67  ATH_CHECK( tracks.isValid() );
68 
69  //-- for each track, update track params with vtx considered as extra measurement (choose the closest vtx)
70  if(tracks->size() !=0) {
79 
80  for (const auto track : *tracks) {
81  if(track){
82  const Trk::TrackParameters *tPerigee = &(track->perigeeParameters());
83  // --- list of new variables that will decorate the track
84  std::unique_ptr<AmgSymMatrix(5)> updateTrackCov = nullptr;
85  float updatephi = -999;
86  float updatetheta = -999;
87  float updated0 = -999;
88  float updatez0 = -999;
89  float updateqOverP = -999;
90  float updateChi2 = -999;
91  bool usedPrimaryVertex = false;
92  std::vector<float> vec;
93 
94  std::unique_ptr<const Trk::TrackParameters> trackParams = nullptr;
95  float minIP = 1000.;
96  //--- retrieve closest vertex to track
97  const xAOD::Vertex* closestVertex = nullptr;
98  int nVtx = 0;
100  if (vxContainer.isValid()) {
101  for (const xAOD::Vertex* vtx: *vxContainer) {
102  if ( (vtx->vertexType() == xAOD::VxType::PriVtx) ||
103  (vtx->vertexType() == xAOD::VxType::PileUp) ) {
104  Amg::Vector3D vtxPos(vtx->position());
105  auto vtxSurface = std::make_unique<Trk::PerigeeSurface>(vtxPos);
106  trackParams = m_extrapolator->extrapolate(ctx,*tPerigee,*vtxSurface);
107  std::unique_ptr<const Trk::ImpactParametersAndSigma> iPandSigma = nullptr;
108  iPandSigma = m_IPEstimator->estimate(trackParams.get(), vtx);
109  if(sqrt(iPandSigma->IPd0*iPandSigma->IPd0+iPandSigma->IPz0*iPandSigma->IPz0) < minIP){
110  minIP = sqrt(iPandSigma->IPd0*iPandSigma->IPd0+iPandSigma->IPz0*iPandSigma->IPz0);
111  closestVertex = vtx;
112  }
113  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);
114  ATH_MSG_VERBOSE(" d0,Delta_z0-TrackParticle:" << track->d0() <<", "<< track->z0() - vtx->z() + track->vz());
115  nVtx++;
116  }
117  }
118  }else{
119  ATH_MSG_ERROR ("Couldn't retrieve vxContainer with key: " << m_vertexContainerKey.key() );
120  return StatusCode::FAILURE;
121  } // --- end retrieve closest vertex to track
122 
123 
124  // update the track params with vtx info after linearization of track around it
125  if(closestVertex){
126  ATH_MSG_VERBOSE("Vertex selected position (x y z): " << closestVertex->position().x()<<" "<<closestVertex->position().y()<<" "<<closestVertex->position().z());
127  ATH_MSG_VERBOSE(" type: " << closestVertex->vertexType());
128  ATH_MSG_VERBOSE(" nParticles: " << closestVertex->nTrackParticles());
129  ATH_MSG_VERBOSE(" quality chi2: " << closestVertex->chiSquared() << " " << closestVertex->numberDoF());
130  Amg::Vector3D globPos(closestVertex->position());
131  auto recVtx = std::make_unique<xAOD::Vertex>();
132  recVtx->makePrivateStore(*closestVertex);
133  auto surface = std::make_unique<const Trk::PerigeeSurface>(globPos);
134  trackParams = m_extrapolator->extrapolate(ctx,*tPerigee,*surface);
135  auto linearTrack = std::make_unique<Trk::VxTrackAtVertex>(0., nullptr, nullptr, trackParams.get(), nullptr);
136  if(linearTrack){
137  ATH_MSG_VERBOSE("Linearizing track");
138  m_LinearizedTrackFactory->linearize(*linearTrack,globPos);
139  ATH_MSG_VERBOSE("Updating linearized track parameters after vertex fit. Track weight = " << linearTrack->weight());
140  m_vertexTrackUpdator->update((*linearTrack), (*recVtx));
141  ATH_MSG_VERBOSE ("track info after vertex track updator !"<<*linearTrack );
142  if(linearTrack->perigeeAtVertex()) {
143  //retrieve & store updated track param qOverP,d0, z0,theta,phi after KVU
144  updateqOverP = linearTrack->perigeeAtVertex()->parameters()[Trk::qOverP];
145  updated0 = linearTrack->perigeeAtVertex()->parameters()[Trk::d0];
146  updatez0 = linearTrack->perigeeAtVertex()->parameters()[Trk::z0];
147  updatephi = linearTrack->perigeeAtVertex()->parameters()[Trk::phi0];
148  updatetheta = linearTrack->perigeeAtVertex()->parameters()[Trk::theta];
149  //retrieve & store updated track cov matrix plus save the KVU Chi2
150  updateTrackCov = std::make_unique<AmgSymMatrix(5)>(*linearTrack->perigeeAtVertex()->covariance());
151  updateChi2 = linearTrack->trackQuality().chiSquared();
152  // store whether this used the PV or not
153  usedPrimaryVertex = closestVertex->vertexType()==xAOD::VxType::PriVtx;
154  }
155  }
156  }// --- end if closest vertex
157 
158  //decorate tracks with new updated track parameters:
159  decoratorKVUqOverP(*track) = updateqOverP;
160  decoratorKVUd0(*track) = updated0;
161  decoratorKVUz0(*track) = updatez0;
162  decoratorKVUphi(*track) = updatephi;
163  decoratorKVUtheta(*track) = updatetheta;
164  decoratorKVUChi2(*track) = updateChi2;
165  decoratorKVUusedPV(*track) = usedPrimaryVertex;
166  if (updateTrackCov){
167  Amg::compress(*updateTrackCov, vec);
168  }else{
169  vec.assign(5, 0.0);
170  }
171  decoratorKVUCovMat(*track) = vec;
172  ATH_MSG_VERBOSE("track updated.");
173  } // --- end if(track)
174  } // --- end loop tracks
175  ATH_MSG_VERBOSE("All tracks updated.");
176  }
177 
178  return StatusCode::SUCCESS;
179 }

◆ initialize()

StatusCode DerivationFramework::TrackParametersKVU::initialize ( )
overridevirtual

Definition at line 22 of file TrackParameterKVU.cxx.

23 {
24 
26  ATH_MSG_ERROR("No selection variables for the TrackParametersKVU tool!");
27  return StatusCode::FAILURE;
28  }
29 
31  ATH_CHECK(m_vertexContainerKey.initialize());
32 
41 
50 
51  ATH_CHECK(m_vertexTrackUpdator.retrieve());
52  ATH_CHECK(m_extrapolator.retrieve());
54  ATH_CHECK(m_IPEstimator.retrieve());
55 
56  ATH_MSG_DEBUG("initialize() ...");
57  ATH_MSG_DEBUG("Successfully retrieved the TrackParametersKVU tool" );
58  return StatusCode::SUCCESS;
59 }

Member Data Documentation

◆ m_extrapolator

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

Definition at line 96 of file TrackParametersKVU.h.

◆ m_IPEstimator

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

Definition at line 100 of file TrackParametersKVU.h.

◆ m_KVUChi2Key

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

Definition at line 87 of file TrackParametersKVU.h.

◆ m_KVUCovMatKey

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

Definition at line 91 of file TrackParametersKVU.h.

◆ m_KVUd0Key

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

Definition at line 81 of file TrackParametersKVU.h.

◆ m_KVUphiKey

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

Definition at line 77 of file TrackParametersKVU.h.

◆ m_KVUqOverPKey

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

Definition at line 85 of file TrackParametersKVU.h.

◆ m_KVUthetaKey

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

Definition at line 79 of file TrackParametersKVU.h.

◆ m_KVUusedPVKey

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

Definition at line 89 of file TrackParametersKVU.h.

◆ m_KVUz0Key

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

Definition at line 83 of file TrackParametersKVU.h.

◆ m_LinearizedTrackFactory

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

Definition at line 98 of file TrackParametersKVU.h.

◆ m_sgName

StringProperty DerivationFramework::TrackParametersKVU::m_sgName {this, "DecorationPrefix", "", "decoration prefix"}
private

Definition at line 103 of file TrackParametersKVU.h.

◆ m_trackContainerKey

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

Definition at line 73 of file TrackParametersKVU.h.

◆ m_vertexContainerKey

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

Definition at line 75 of file TrackParametersKVU.h.

◆ m_vertexTrackUpdator

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

Definition at line 94 of file TrackParametersKVU.h.


The documentation for this class was generated from the following files:
xAOD::Vertex_v1::nTrackParticles
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
Definition: Vertex_v1.cxx:270
Amg::compress
void compress(const AmgSymMatrix(N) &covMatrix, std::vector< float > &vec)
Definition: EventPrimitivesHelpers.h:56
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
DerivationFramework::TrackParametersKVU::m_vertexContainerKey
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerKey
Definition: TrackParametersKVU.h:75
Trk::z0
@ z0
Definition: ParamDefs.h:64
Trk::ImpactParametersAndSigma::IPd0
double IPd0
Definition: ITrackToVertexIPEstimator.h:34
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
DerivationFramework::TrackParametersKVU::m_vertexTrackUpdator
ToolHandle< Trk::IVertexTrackUpdator > m_vertexTrackUpdator
Definition: TrackParametersKVU.h:94
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::TrackParametersKVU::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: TrackParametersKVU.h:96
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
DerivationFramework::TrackParametersKVU::m_KVUqOverPKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUqOverPKey
Definition: TrackParametersKVU.h:85
xAOD::Vertex_v1::vertexType
VxType::VertexType vertexType() const
The type of the vertex.
DerivationFramework::TrackParametersKVU::m_KVUthetaKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUthetaKey
Definition: TrackParametersKVU.h:79
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
DerivationFramework::TrackParametersKVU::m_KVUChi2Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUChi2Key
Definition: TrackParametersKVU.h:87
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:727
Trk::theta
@ theta
Definition: ParamDefs.h:66
DerivationFramework::TrackParametersKVU::m_KVUCovMatKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUCovMatKey
Definition: TrackParametersKVU.h:91
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
DerivationFramework::TrackParametersKVU::m_KVUphiKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUphiKey
Definition: TrackParametersKVU.h:77
xAOD::VxType::PriVtx
@ PriVtx
Primary vertex.
Definition: TrackingPrimitives.h:572
DerivationFramework::TrackParametersKVU::m_trackContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackContainerKey
Definition: TrackParametersKVU.h:73
Trk::ImpactParametersAndSigma::IPz0
double IPz0
Definition: ITrackToVertexIPEstimator.h:35
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::ParametersBase
Definition: ParametersBase.h:55
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::VxType::PileUp
@ PileUp
Pile-up vertex.
Definition: TrackingPrimitives.h:574
Trk::d0
@ d0
Definition: ParamDefs.h:63
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
DerivationFramework::TrackParametersKVU::m_KVUz0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUz0Key
Definition: TrackParametersKVU.h:83
xAOD::Vertex_v1::numberDoF
float numberDoF() const
Returns the number of degrees of freedom of the vertex fit as float.
xAOD::Vertex_v1::chiSquared
float chiSquared() const
Returns the of the vertex fit as float.
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
DerivationFramework::TrackParametersKVU::m_LinearizedTrackFactory
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_LinearizedTrackFactory
Definition: TrackParametersKVU.h:98
DerivationFramework::TrackParametersKVU::m_KVUd0Key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUd0Key
Definition: TrackParametersKVU.h:81
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
DerivationFramework::TrackParametersKVU::m_IPEstimator
ToolHandle< Trk::ITrackToVertexIPEstimator > m_IPEstimator
Definition: TrackParametersKVU.h:100
DerivationFramework::TrackParametersKVU::m_KVUusedPVKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_KVUusedPVKey
Definition: TrackParametersKVU.h:89
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
Trk::phi0
@ phi0
Definition: ParamDefs.h:65