ATLAS Offline Software
Public 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 Attributes

ToolHandle< Trk::IExtrapolatorm_extrapolator {this, "Extrapolator", "Trk::Extrapolator/AtlasExtrapolator"}
 ToolHandle for Extrapolator. More...
 

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 25 of file TrackToVertex.cxx.

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

◆ ~TrackToVertex()

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

Virtual destructor.

Member Function Documentation

◆ finalize()

StatusCode TrackToVertex::finalize ( )
finaloverridevirtual

AlgTool finalize method.

Definition at line 51 of file TrackToVertex.cxx.

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

◆ GetBeamLine()

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

Use this for MT Coding.

Definition at line 41 of file TrackToVertex.cxx.

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

◆ initialize()

StatusCode TrackToVertex::initialize ( )
finaloverridevirtual

AlgTool initailize method.

Definition at line 31 of file TrackToVertex.cxx.

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

◆ 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 160 of file TrackToVertex.cxx.

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

◆ 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 58 of file TrackToVertex.cxx.

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

◆ 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 102 of file TrackToVertex.cxx.

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

◆ 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 135 of file TrackToVertex.cxx.

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

◆ 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 73 of file TrackToVertex.cxx.

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

◆ 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 78 of file TrackToVertex.cxx.

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

◆ 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 222 of file TrackToVertex.cxx.

223 {
224  ATH_MSG_WARNING(" Method not implemented!! ");
225  return {};
226  //return m_extrapolator->extrapolate(tp, *m_beamLine);
227 }

◆ 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 263 of file TrackToVertex.cxx.

265 {
266  return m_extrapolator->extrapolateTrack(ctx, trk, *beamline);
267 }

◆ 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 269 of file TrackToVertex.cxx.

271 {
272  return m_extrapolator->extrapolate(ctx, tpars, *beamline);
273 }

◆ 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 229 of file TrackToVertex.cxx.

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

Member Data Documentation

◆ m_extrapolator

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

ToolHandle for Extrapolator.

Definition at line 131 of file TrackToVertex.h.

◆ s_origin

const Amg::Vector3D TrackToVertex::s_origin
staticprivate

static origin

Definition at line 133 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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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
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:131
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
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:133
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:581
InDet::BeamSpotData::beamPos
const Amg::Vector3D & beamPos() const noexcept
Definition: BeamSpotData.h:68
Trk::SurfaceType::Perigee
@ Perigee
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
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:102
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