ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Reco::TrackToVertex Class Reference

#include <TrackToVertex.h>

Inheritance diagram for Reco::TrackToVertex:
Collaboration diagram for Reco::TrackToVertex:

Public Member Functions

 TrackToVertex (const std::string &, const std::string &, const IInterface *)
 AlgTool like constructor. More...
 
virtual ~TrackToVertex ()=default
 Virtual destructor. More...
 
virtual StatusCode initialize () override final
 AlgTool initailize method. More...
 
virtual StatusCode finalize () override final
 AlgTool finalize method. More...
 
virtual std::unique_ptr< Trk::StraightLineSurfaceGetBeamLine (const InDet::BeamSpotData *) const override final
 Use this for MT Coding. More...
 
virtual std::unique_ptr< Trk::PerigeeperigeeAtVertex (const EventContext &ctx, const Rec::TrackParticle &tp, const Amg::Vector3D &gp) const override final
 Interface method for use with TrackParticle and given vertex position. More...
 
virtual std::unique_ptr< Trk::PerigeeperigeeAtVertex (const EventContext &ctx, const xAOD::TrackParticle &tp, const Amg::Vector3D &gp) const override final
 Interface method for use with xAOD::Trackparticle and given vertex position - xAOD. More...
 
virtual std::unique_ptr< Trk::PerigeeperigeeAtVertex (const EventContext &ctx, const Rec::TrackParticle &tp) const override final
 Interface method for use with TrackParticle and default primary vertex from TrackParticle - AOD. More...
 
virtual std::unique_ptr< Trk::PerigeeperigeeAtVertex (const EventContext &ctx, const xAOD::TrackParticle &tp) const override final
 Interface method for use with TrackParticle and default primary vertex from TrackParticle - xAOD. More...
 
virtual std::unique_ptr< Trk::PerigeeperigeeAtVertex (const EventContext &ctx, const Trk::Track &trk, const Amg::Vector3D &gp) const override final
 Interface method for use with Track and given vertex position - ESD. More...
 
virtual std::unique_ptr< Trk::PerigeeperigeeAtBeamline (const EventContext &ctx, const Trk::Track &trk, const InDet::BeamSpotData *) const override final
 Interface method for use with Track and the beamline from the BeamSpotSvc - ESD. More...
 
virtual std::unique_ptr< Trk::TrackParameterstrackAtBeamline (const EventContext &ctx, const Rec::TrackParticle &tp) const override final
 Interface method for use with TrackParticle and the beamline from the BeamSpotSvc - AOD. More...
 
virtual std::unique_ptr< Trk::TrackParameterstrackAtBeamline (const EventContext &ctx, const xAOD::TrackParticle &tp, const InDet::BeamSpotData *) const override final
 Interface method for use with TrackParticle and the beamline from the BeamSpotSvc - xAOD. More...
 
virtual std::unique_ptr< Trk::TrackParameterstrackAtBeamline (const EventContext &ctx, const Trk::Track &trk, const Trk::StraightLineSurface *beamline) const override final
 Interface method for use with Track and the beamline from the BeamSpotSvc - ESD. More...
 
virtual std::unique_ptr< Trk::TrackParameterstrackAtBeamline (const EventContext &ctx, const Trk::TrackParameters &tpars, const Trk::StraightLineSurface *beamline) const override final
 Interface method for use with Track and the beamline from the BeamSpotSvc - TrackParameters
More...
 

Private Member Functions

bool startAtOriginalPerigee (const Trk::Track &track) const
 

Private Attributes

ToolHandle< Trk::IExtrapolatorm_extrapolator {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}
 ToolHandle for Extrapolator. More...
 
Gaudi::Property< bool > m_startTRTSAAtPerigee
 

Static Private Attributes

static const Amg::Vector3D s_origin
 static origin More...
 

Detailed Description

Definition at line 43 of file TrackToVertex.h.

Constructor & Destructor Documentation

◆ TrackToVertex()

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

AlgTool like constructor.

Definition at line 24 of file TrackToVertex.cxx.

24  :
25  base_class(t,n,p)
26 {
27 }

◆ ~TrackToVertex()

virtual Reco::TrackToVertex::~TrackToVertex ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ finalize()

StatusCode TrackToVertex::finalize ( )
finaloverridevirtual

AlgTool finalize method.

Definition at line 50 of file TrackToVertex.cxx.

51 {
52  ATH_MSG_DEBUG( name() << " finalize() successful");
53  return StatusCode::SUCCESS;
54 }

◆ GetBeamLine()

std::unique_ptr< Trk::StraightLineSurface > TrackToVertex::GetBeamLine ( const InDet::BeamSpotData beamSpotHandle) const
finaloverridevirtual

Use this for MT Coding.

Definition at line 40 of file TrackToVertex.cxx.

40  {
41  // get the transform
42  Amg::Transform3D beamTransform = Amg::Transform3D(Amg::AngleAxis3D(beamSpotHandle->beamTilt(0),Amg::Vector3D(0.,1.,0.)));
43  beamTransform *= Amg::AngleAxis3D(beamSpotHandle->beamTilt(1),Amg::Vector3D(1.,0.,0.));
44  beamTransform.pretranslate(beamSpotHandle->beamPos());
45  // create the new beam line
46  return std::make_unique< Trk::StraightLineSurface >(beamTransform);
47 }

◆ initialize()

StatusCode TrackToVertex::initialize ( )
finaloverridevirtual

AlgTool initailize method.

Definition at line 30 of file TrackToVertex.cxx.

31 {
32  // Get the GeometryBuilder AlgTool
33  ATH_CHECK(m_extrapolator.retrieve());
34  ATH_MSG_DEBUG( name() << " initialize() successful");
35  return StatusCode::SUCCESS;
36 }

◆ perigeeAtBeamline()

std::unique_ptr< Trk::Perigee > TrackToVertex::perigeeAtBeamline ( const EventContext &  ctx,
const Trk::Track trk,
const InDet::BeamSpotData beamspotptr 
) const
finaloverridevirtual

Interface method for use with Track and the beamline from the BeamSpotSvc - ESD.

Definition at line 161 of file TrackToVertex.cxx.

165 {
166 
167  Amg::Vector3D beamspot(s_origin);
168  float tiltx = 0.0;
169  float tilty = 0.0;
170  if (beamspotptr) {
171  beamspot = Amg::Vector3D(beamspotptr->beamVtx().position());
172  tiltx = beamspotptr->beamTilt(0);
173  tilty = beamspotptr->beamTilt(1);
174  }
175  Amg::Translation3D amgtranslation(beamspot);
176  Amg::Transform3D pAmgTransf =
177  amgtranslation * Amg::RotationMatrix3D::Identity();
178  pAmgTransf *= Amg::AngleAxis3D(tilty, Amg::Vector3D(0., 1., 0.));
179  pAmgTransf *= Amg::AngleAxis3D(tiltx, Amg::Vector3D(1., 0., 0.));
180  // preparation
181  Trk::PerigeeSurface persf(pAmgTransf);
182 
183  std::unique_ptr<Trk::Perigee> vertexPerigee;
184  std::unique_ptr<Trk::TrackParameters> extrapResult =
186  ? m_extrapolator->extrapolateTrack(ctx,track, persf)
187  : m_extrapolator->extrapolate(ctx,*(track.perigeeParameters()), persf);
188  if (extrapResult && extrapResult->surfaceType() == Trk::SurfaceType::Perigee) {
189  vertexPerigee.reset(static_cast<Trk::Perigee*>(extrapResult.release()));
190  }
191  if (!vertexPerigee) {
192  // workaround.
193  // try again using the first track parameter set, since the current extrapolator will
194  // use "the closest" track parameterset which is not necessarily the mostuseful one to
195  // start the extrapolation with.
196  const DataVector<const Trk::TrackParameters> *track_parameter_list= track.trackParameters();
197  if (track_parameter_list) {
198  for(const Trk::TrackParameters *trk_params: *track_parameter_list) {
199  if (!trk_params) {
200  continue;
201  }
202  extrapResult = m_extrapolator->extrapolate(ctx,*trk_params, persf);
203  if (extrapResult &&
204  extrapResult->surfaceType() == Trk::SurfaceType::Perigee) {
205  vertexPerigee.reset(static_cast<Trk::Perigee*>(extrapResult.release()));
206  }
207  break;
208  }
209  }
210  }
211  if (!vertexPerigee) {
212  const Trk::Perigee* trackPerigee = track.perigeeParameters();
213  if (trackPerigee && trackPerigee->associatedSurface() == persf) {
214  ATH_MSG_DEBUG("Perigee of Track is already expressed to given vertex, a "
215  "copy is returned.");
216  vertexPerigee.reset(trackPerigee->clone());
217  } else {
219  "Extrapolation to Beamline Perigee failed, NULL pointer is returned.");
220  }
221  }
222  return (vertexPerigee);
223 }

◆ perigeeAtVertex() [1/5]

std::unique_ptr< Trk::Perigee > TrackToVertex::perigeeAtVertex ( const EventContext &  ctx,
const Rec::TrackParticle tp 
) const
finaloverridevirtual

Interface method for use with TrackParticle and default primary vertex from TrackParticle - AOD.

Definition at line 57 of file TrackToVertex.cxx.

57  {
58 
59  // retrieve the reconstructed Vertex from the TrackParticle
60  const Trk::VxCandidate* vxCandidate = tp.reconstructedVertex();
61  if (vxCandidate!=nullptr) {
62  // create a global position from this
63  const Trk::RecVertex& reconVertex = vxCandidate->recVertex();
64  const Amg::Vector3D& vertexPosition = reconVertex.position();
65  Amg::Vector3D persfPosition(vertexPosition.x(), vertexPosition.y(), vertexPosition.z());
66  return(this->perigeeAtVertex(ctx, tp, persfPosition));
67  }
68  ATH_MSG_DEBUG("No reconstructed vertex found in TrackParticle, perigee will be expressed to (0.,0.,0.).");
69  return (perigeeAtVertex(ctx, tp,Trk::s_origin));
70 }

◆ perigeeAtVertex() [2/5]

std::unique_ptr< Trk::Perigee > TrackToVertex::perigeeAtVertex ( const EventContext &  ctx,
const Rec::TrackParticle tp,
const Amg::Vector3D gp 
) const
finaloverridevirtual

Interface method for use with TrackParticle and given vertex position.

  • AOD

Definition at line 101 of file TrackToVertex.cxx.

101  {
102 
103  // preparation
104  Trk::PerigeeSurface persf(gp);
105  std::unique_ptr<Trk::Perigee> vertexPerigee = nullptr;
106  // retrieve the Perigee from the track particle
107  const Trk::Perigee* trackparPerigee = tp.measuredPerigee();
108  if (trackparPerigee){
109  if ( trackparPerigee->associatedSurface() == persf)
110  {
111  ATH_MSG_DEBUG("Perigee of TrackParticle is already expressed to given vertex, a copy is returned.");
112  return std::unique_ptr<Trk::Perigee>(trackparPerigee->clone());
113  } else {
114  auto extrapResult =
115  m_extrapolator->extrapolateDirectly(ctx,*trackparPerigee, persf);
116  if (extrapResult &&
117  extrapResult->surfaceType() == Trk::SurfaceType::Perigee) {
118  vertexPerigee.reset(static_cast<Trk::Perigee*>(extrapResult.release()));
119  }
120  }
121  } else {
123  "No Perigee found in TrackParticle, a NULL pointer is returned.");
124  return nullptr;
125  }
126  if (!vertexPerigee){
128  "Extrapolation to Perigee failed, a NULL pointer is returned.");
129  }
130  return vertexPerigee;
131 }

◆ perigeeAtVertex() [3/5]

std::unique_ptr< Trk::Perigee > TrackToVertex::perigeeAtVertex ( const EventContext &  ctx,
const Trk::Track trk,
const Amg::Vector3D gp 
) const
finaloverridevirtual

Interface method for use with Track and given vertex position - ESD.

Definition at line 134 of file TrackToVertex.cxx.

134  {
135 
136  Trk::PerigeeSurface persf(gp);
137  std::unique_ptr<Trk::Perigee> vertexPerigee;
138  std::unique_ptr<Trk::TrackParameters> extrapResult =
140  ? m_extrapolator->extrapolateTrack(ctx,track, persf)
141  : m_extrapolator->extrapolate(ctx, *(track.perigeeParameters()), persf);
142  if (extrapResult && extrapResult->surfaceType() == Trk::SurfaceType::Perigee) {
143  vertexPerigee.reset( static_cast<Trk::Perigee*>(extrapResult.release()));
144  }
145  if (!vertexPerigee) {
146  const Trk::Perigee* trackPerigee = track.perigeeParameters();
147  if (trackPerigee && trackPerigee->associatedSurface() == persf) {
148  ATH_MSG_DEBUG("Perigee of Track is already expressed to given vertex, a "
149  "copy is returned.");
150  vertexPerigee.reset(trackPerigee->clone());
151  } else{
153  "Extrapolation to Perigee failed, NULL pointer is returned.");
154  }
155  }
156  return (vertexPerigee);
157 }

◆ perigeeAtVertex() [4/5]

std::unique_ptr< Trk::Perigee > TrackToVertex::perigeeAtVertex ( const EventContext &  ctx,
const xAOD::TrackParticle tp 
) const
finaloverridevirtual

Interface method for use with TrackParticle and default primary vertex from TrackParticle - xAOD.

Definition at line 72 of file TrackToVertex.cxx.

72  {
73  return perigeeAtVertex(ctx, tp, Amg::Vector3D(tp.vx(),tp.vy(),tp.vz()));
74 }

◆ perigeeAtVertex() [5/5]

std::unique_ptr< Trk::Perigee > TrackToVertex::perigeeAtVertex ( const EventContext &  ctx,
const xAOD::TrackParticle tp,
const Amg::Vector3D gp 
) const
finaloverridevirtual

Interface method for use with xAOD::Trackparticle and given vertex position - xAOD.

Definition at line 77 of file TrackToVertex.cxx.

77  {
78 
79  // preparation
80  Trk::PerigeeSurface persf(gp);
81  std::unique_ptr<Trk::Perigee> vertexPerigee;
82  // retrieve the Perigee from the track particle
83  const Trk::Perigee& trackparPerigee = tp.perigeeParameters();
84  if (trackparPerigee.associatedSurface() == persf) {
85  ATH_MSG_DEBUG("Perigee of TrackParticle is already expressed to given "
86  "vertex, a copy is returned.");
87  return std::unique_ptr<Trk::Perigee>(trackparPerigee.clone());
88  } else {
89  std::unique_ptr<Trk::TrackParameters> extrapResult =
90  m_extrapolator->extrapolateDirectly(ctx,trackparPerigee, persf);
91  if (extrapResult && extrapResult->surfaceType() == Trk::SurfaceType::Perigee) {
92  vertexPerigee.reset(static_cast<Trk::Perigee*>(extrapResult.release()));
93  }
94  }
95  if (!vertexPerigee)
97  "Extrapolation to Perigee failed, a NULL pointer is returned.");
98  return vertexPerigee;
99 }

◆ startAtOriginalPerigee()

bool Reco::TrackToVertex::startAtOriginalPerigee ( const Trk::Track track) const
inlineprivate

Definition at line 130 of file TrackToVertex.h.

130  {
131  return m_startTRTSAAtPerigee.value()
132  && track.info().patternRecognition().test(Trk::TrackInfo::TRTStandalone)
133  && track.perigeeParameters();
134  }

◆ trackAtBeamline() [1/4]

std::unique_ptr< Trk::TrackParameters > TrackToVertex::trackAtBeamline ( const EventContext &  ctx,
const Rec::TrackParticle tp 
) const
finaloverridevirtual

Interface method for use with TrackParticle and the beamline from the BeamSpotSvc - AOD.

Definition at line 225 of file TrackToVertex.cxx.

226 {
227  ATH_MSG_WARNING(" Method not implemented!! ");
228  return {};
229  //return m_extrapolator->extrapolate(tp, *m_beamLine);
230 }

◆ trackAtBeamline() [2/4]

std::unique_ptr< Trk::TrackParameters > TrackToVertex::trackAtBeamline ( const EventContext &  ctx,
const Trk::Track trk,
const Trk::StraightLineSurface beamline 
) const
finaloverridevirtual

Interface method for use with Track and the beamline from the BeamSpotSvc - ESD.

Definition at line 266 of file TrackToVertex.cxx.

268 {
269  return !startAtOriginalPerigee(trk)
270  ? m_extrapolator->extrapolateTrack(ctx, trk, *beamline)
271  : m_extrapolator->extrapolate(ctx,*(trk.perigeeParameters()), *beamline);
272 }

◆ trackAtBeamline() [3/4]

std::unique_ptr< Trk::TrackParameters > TrackToVertex::trackAtBeamline ( const EventContext &  ctx,
const Trk::TrackParameters tpars,
const Trk::StraightLineSurface beamline 
) const
finaloverridevirtual

Interface method for use with Track and the beamline from the BeamSpotSvc - TrackParameters

Definition at line 274 of file TrackToVertex.cxx.

276 {
277  return m_extrapolator->extrapolate(ctx, tpars, *beamline);
278 }

◆ trackAtBeamline() [4/4]

std::unique_ptr< Trk::TrackParameters > TrackToVertex::trackAtBeamline ( const EventContext &  ctx,
const xAOD::TrackParticle tp,
const InDet::BeamSpotData beamspotptr 
) const
finaloverridevirtual

Interface method for use with TrackParticle and the beamline from the BeamSpotSvc - xAOD.

Definition at line 232 of file TrackToVertex.cxx.

234 {
235 
236  Amg::Vector3D beamspot(s_origin);
237  float tiltx = 0.0;
238  float tilty = 0.0;
239  if (beamspotptr) {
240  beamspot = Amg::Vector3D(beamspotptr->beamVtx().position());
241  tiltx = beamspotptr->beamTilt(0);
242  tilty = beamspotptr->beamTilt(1);
243  }
244  Amg::Transform3D amgTransf;
245  Amg::Translation3D amgtranslation(beamspot);
246  amgTransf = amgtranslation * Amg::RotationMatrix3D::Identity();
247  amgTransf *= Amg::AngleAxis3D(tilty, Amg::Vector3D(0.,1.,0.));
248  amgTransf *= Amg::AngleAxis3D(tiltx, Amg::Vector3D(1.,0.,0.));
249  // preparation
250  Trk::PerigeeSurface persf(amgTransf);
251  std::unique_ptr<Trk::TrackParameters> vertexPerigee;
252  // retrieve the Perigee from the track particle
253  const Trk::Perigee& trackparPerigee = tp.perigeeParameters();
254  if ( trackparPerigee.associatedSurface() == persf) {
255  ATH_MSG_DEBUG("Perigee of TrackParticle is already expressed to given vertex, a copy is returned.");
256  return std::unique_ptr<Trk::TrackParameters>(trackparPerigee.clone());
257  } else
258  vertexPerigee = m_extrapolator->extrapolateDirectly(ctx,trackparPerigee, persf);
259  if (!vertexPerigee){
260  ATH_MSG_DEBUG("Extrapolation to Beam Line failed, a NULL pointer is returned.");
261  }
262  return vertexPerigee;
263 
264 }

Member Data Documentation

◆ m_extrapolator

ToolHandle<Trk::IExtrapolator> Reco::TrackToVertex::m_extrapolator {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}
private

ToolHandle for Extrapolator.

Definition at line 137 of file TrackToVertex.h.

◆ m_startTRTSAAtPerigee

Gaudi::Property<bool> Reco::TrackToVertex::m_startTRTSAAtPerigee
private
Initial value:
{this, "StartTRTStandaloneTracksAtOriginalPerigee", false,
"When extrapolating TRT standalone start at their original perigee which may have a more realistic covariance"}

Definition at line 138 of file TrackToVertex.h.

◆ s_origin

const Amg::Vector3D TrackToVertex::s_origin
staticprivate

static origin

Definition at line 142 of file TrackToVertex.h.


The documentation for this class was generated from the following files:
Trk::VxCandidate::recVertex
const Trk::RecVertex & recVertex(void) const
Returns a reference to reconstructed vertex.
Definition: VxCandidate.h:132
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
Reco::TrackToVertex::m_startTRTSAAtPerigee
Gaudi::Property< bool > m_startTRTSAAtPerigee
Definition: TrackToVertex.h:139
Trk::ParametersBase::surfaceType
constexpr virtual SurfaceType surfaceType() const override=0
Returns the Surface Type enum for the surface used to define the derived class.
ParticleTest.tp
tp
Definition: ParticleTest.py:25
Reco::TrackToVertex::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
ToolHandle for Extrapolator.
Definition: TrackToVertex.h:137
InDet::BeamSpotData::beamVtx
const Trk::RecVertex & beamVtx() const noexcept
Definition: BeamSpotData.h:79
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::RecVertex
Trk::RecVertex inherits from Trk::Vertex.
Definition: RecVertex.h:44
Reco::TrackToVertex::startAtOriginalPerigee
bool startAtOriginalPerigee(const Trk::Track &track) const
Definition: TrackToVertex.h:130
Trk::ParametersT::associatedSurface
virtual const S & associatedSurface() const override final
Access to the Surface method.
Reco::TrackToVertex::s_origin
static const Amg::Vector3D s_origin
static origin
Definition: TrackToVertex.h:142
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::Vertex::position
const Amg::Vector3D & position() const
return position of vertex
Definition: Vertex.cxx:72
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
InDet::BeamSpotData::beamPos
const Amg::Vector3D & beamPos() const noexcept
Definition: BeamSpotData.h:68
Trk::Track::perigeeParameters
const Perigee * perigeeParameters() const
return Perigee.
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:163
Trk::SurfaceType::Perigee
@ Perigee
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Reco::TrackToVertex::perigeeAtVertex
virtual std::unique_ptr< Trk::Perigee > perigeeAtVertex(const EventContext &ctx, const Rec::TrackParticle &tp, const Amg::Vector3D &gp) const override final
Interface method for use with TrackParticle and given vertex position.
Definition: TrackToVertex.cxx:101
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::VxCandidate
Definition: VxCandidate.h:27
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
Amg::AngleAxis3D
Eigen::AngleAxisd AngleAxis3D
Definition: GeoPrimitives.h:45
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Trk::ParametersT::clone
virtual ParametersT< DIM, T, S > * clone() const override final
Virtual clone.
InDet::BeamSpotData::beamTilt
float beamTilt(int i) const noexcept
Returns the beam sigma for the i+3-th error matrix element (the 'tilt')
Definition: BeamSpotData.h:74
Trk::TrackInfo::TRTStandalone
@ TRTStandalone
TRT Standalone.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:162