ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::AdaptiveVertexFitter Class Reference

#include <AdaptiveVertexFitter.h>

Inheritance diagram for Trk::AdaptiveVertexFitter:
Collaboration diagram for Trk::AdaptiveVertexFitter:

Public Member Functions

virtual StatusCode initialize () override
 AdaptiveVertexFitter (const std::string &t, const std::string &n, const IInterface *p)
 default constructor due to Athena interface
virtual ~AdaptiveVertexFitter ()
 destructor
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &vectorNeut, const Amg::Vector3D &startingPoint) const override
 Interface for xAOD::TrackParticle with starting point.
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const Amg::Vector3D &startingPoint) const override
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &vectorNeut, const xAOD::Vertex &constraint) const override
 Interface for xAOD::TrackParticle with vertex constraint the position of the constraint is ALWAYS the starting point.
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const xAOD::Vertex &constraint) const override
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList, const Amg::Vector3D &startingPoint) const override
 Interface for MeasuredPerigee with starting point.
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const Amg::Vector3D &startingPoint) const override
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList, const xAOD::Vertex &constraint) const override
 Interface for MeasuredPerigee with vertex constraint.
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex &constraint) const override
xAOD::Vertexfit (const std::vector< const Trk::Track * > &Vectortrk, const xAOD::Vertex &constraint, const Amg::Vector3D &startingPoint) const
 fit providing vector of tracks, constraint and startingPoint
xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList, const xAOD::Vertex &constraint, const Amg::Vector3D &startingPoint) const
 fit providing vector of ParametersBase, constraint and startingPoint
xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex &constraint, const Amg::Vector3D &startingPoint) const
xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList) const override
 fit providing vector of TrackParameters and NeutralParameters
xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList) const override
xAOD::Vertexfit (const std::vector< const Trk::TrackParticleBase * > &perigeeList) const
 fit providing vector of TrackParticleBase
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const Amg::Vector3D &startingPoint) const
 Interface for xAOD::TrackParticle with starting point Event Context aware interface.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &vectorNeu, const Amg::Vector3D &startingPoint) const
 Interface for xAOD::TrackParticle and xAOD::NeutralParticle with starting point.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &vectorNeu, const xAOD::Vertex &constraint) const
 Interface for xAOD::TrackParticle and xAOD::NeutralParticle with vertex constraint the position of the constraint is ALWAYS the starting point Event Context aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const xAOD::Vertex &constraint) const
 Interface for xAOD::TrackParticle with vertex constraint the position of the constraint is ALWAYS the starting point Event Context aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList, const Amg::Vector3D &startingPoint) const
 Interface for TrackParameters and NeutralParameters with starting point Event Context aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const Amg::Vector3D &startingPoint) const
 Interface for TrackParameters with starting point Event Context aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList, const xAOD::Vertex &constraint) const
 Interface for TrackParameters and NeutralParameters with vertex constraint the position of the constraint is ALWAYS the starting point EventContext aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex &constraint) const
 Interface for TrackParameters with vertex constraint the position of the constraint is ALWAYS the starting point EventContext aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList) const
 Fit method using the VertexSeedFinder to estimate initial position of the vertex and taking it as a first linearization point (in iterative fitters).
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList) const
 Fit method using the VertexSeedFinder to estimate initial position of the vertex and taking it as a first linearization point (in iterative fitters).

Private Member Functions

xAOD::Vertex_fit (const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList=std::vector< const Trk::NeutralParameters * >(), const xAOD::Vertex &constraint=xAOD::Vertex(), const Amg::Vector3D &startingPoint=Amg::Vector3D(), bool IsConstraint=false, bool IsStartingPoint=false) const
 Internal method for fitting a list of TrackParameters and NeutralParameters, with or without constraint and starting point.
xAOD::Vertex_fit (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex &constraint=xAOD::Vertex(), const Amg::Vector3D &startingPoint=Amg::Vector3D(), bool IsConstraint=false, bool IsStartingPoint=false) const
xAOD::Vertex_fit (const std::vector< const Trk::Track * > &VectorTrk, const xAOD::Vertex &constraint=xAOD::Vertex(), const Amg::Vector3D &startingPoint=Amg::Vector3D(), bool IsConstraint=false, bool IsStartingPoint=false) const
 Internal method for fitting a list of Tracks, with or without constraint and starting point.
xAOD::Vertexdothefit (const xAOD::Vertex &ConstraintVertex, const Amg::Vector3D &SeedVertex, std::vector< VxTrackAtVertex > &myLinTracks) const
 Internal method, called by the two _fit internal functions, in order to perform the fit, after having initialized the input (constraint + seed).

Private Attributes

ToolHandle< Trk::IVertexSeedFinderm_SeedFinder
ToolHandle< Trk::IVertexLinearizedTrackFactorym_LinearizedTrackFactory
ToolHandle< Trk::IVertexTrackCompatibilityEstimatorm_TrackCompatibilityEstimator
ToolHandle< Trk::IImpactPoint3dEstimatorm_ImpactPoint3dEstimator
ToolHandle< Trk::IVertexUpdatorm_VertexUpdator
ToolHandle< Trk::IVertexSmootherm_VertexSmoother
ToolHandle< Trk::IVertexAnnealingMakerm_AnnealingMaker
long int m_maxIterations
 Number of maximum iterations.
double m_maxDistToLinPoint
 Maximum distance of linearization point of track to actual fitted vertex before needing to relinearize (in mm)
double m_initialError
 Initial error in form of diagonal elements of the inverse of the covariance matrix (name is misleading: take the error, square it and initialize the variable with its inverse)
bool m_onlyzseed
 Variable is true if seeding has to be performed only on the z direction.
bool m_doSmoothing
 True if smoothing after fit iterations has to be performed: otherwise the Smoother AlgoTool provided to the fitter will be ignored.

Detailed Description

Author
N. Giacinto Piacquadio (Freiburg ATLAS Group)

This class implements a vertexing fitting algorithm which is adaptive and robust, quite insensitive to the presence of outliers.

The vertex algorithm is based on the typical Kalman-Filtering approach, with the difference that the inverse of the covariance matrices of the track parameters of the tracks which enter the fit are reweighted according to the probability of the tracks to be compatible with the vertex to be fit. In this way outliers/tracks which do not belong to the vertex are smoothly rejected.

Since the estimation of the vertex position during the first fit iterations is not particularly good and the compatiblity estimation of the tracks not always reliable, an annealing technique is also implemented, in order to make the rejection of outliers soft in the beginning and harder towards the end of the fit (for this the Annealing Maker class is responsible: as a default the Temperature of this thermodinamical procedure is lowered according to few predefined steps)

For greater modularity the algorithm is divided into 6 modules (AlgTools in Athena):

  1. SeedFinder
  2. LinearizedTrackFactory
  3. TrackCompatibilityEstimator 3b. ImpactPoint3dEstimator
  4. VertexUpdator
  5. VertexSmoother plus another one, which is responsible for letting the temperature go down (the so called "annealing technique")
  6. AnnealingMaker

This kind of algorithm was implemented for the first time by CMS: for information about the theoretical motivations a good reference is Wolfgang Waltenberger's PhD Thesis and many of the calculations implemented have been extensively shown in theoretical & experimental papers by Fruehwirth, Waltenberger, Strandlie et al.


Changes:

David Shope david.nosp@m..ric.nosp@m.hard..nosp@m.shop.nosp@m.e@cer.nosp@m.n.ch (2016-04-19) EDM Migration to xAOD - from Trk::VxCandidate to xAOD::Vertex, from Trk::RecVertex to xAOD::Vertex, from Trk::Vertex to Amg::Vector3D

Definition at line 86 of file AdaptiveVertexFitter.h.

Constructor & Destructor Documentation

◆ AdaptiveVertexFitter()

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

default constructor due to Athena interface

Definition at line 29 of file AdaptiveVertexFitter.cxx.

29 :
30 base_class(t,n,p),
33 m_initialError(0.0001),
34 m_onlyzseed(false),
35 m_doSmoothing(true)
36 {
37 declareProperty("MaxIterations", m_maxIterations);
38 declareProperty("MaxDistToLinPoint", m_maxDistToLinPoint);
39 declareProperty("InitialError",m_initialError);
40 declareProperty("onlyzseed",m_onlyzseed);
41 declareProperty("DoSmoothing",m_doSmoothing);
42 declareInterface<IVertexFitter>(this);
43 }
double m_initialError
Initial error in form of diagonal elements of the inverse of the covariance matrix (name is misleadin...
bool m_doSmoothing
True if smoothing after fit iterations has to be performed: otherwise the Smoother AlgoTool provided ...
bool m_onlyzseed
Variable is true if seeding has to be performed only on the z direction.
double m_maxDistToLinPoint
Maximum distance of linearization point of track to actual fitted vertex before needing to relineariz...
long int m_maxIterations
Number of maximum iterations.

◆ ~AdaptiveVertexFitter()

Trk::AdaptiveVertexFitter::~AdaptiveVertexFitter ( )
virtualdefault

destructor

Member Function Documentation

◆ _fit() [1/3]

xAOD::Vertex * Trk::AdaptiveVertexFitter::_fit ( const std::vector< const Trk::Track * > & VectorTrk,
const xAOD::Vertex & constraint = xAOD::Vertex(),
const Amg::Vector3D & startingPoint = Amg::Vector3D(),
bool IsConstraint = false,
bool IsStartingPoint = false ) const
private

Internal method for fitting a list of Tracks, with or without constraint and starting point.

Definition at line 257 of file AdaptiveVertexFitter.cxx.

263 { // initialized to false
264
265 ATH_MSG_DEBUG("Called Adaptive vertex with Trk::Track. N. Tracks = " << VectorTrk.size());
266
267 std::vector<const Trk::TrackParameters*> perigeeList;
268 for (const auto *iter : VectorTrk) {
269 if (std::isnan(iter->perigeeParameters()->parameters()[Trk::d0])) {
270 continue;
271 }
272 perigeeList.push_back(iter->perigeeParameters());
273 }
274
275 xAOD::Vertex * FittedVertex = _fit(perigeeList,constraint,startingPoint,IsConstraint,IsStartingPoint);
276
277 if (FittedVertex==nullptr) {
278 return FittedVertex;
279 }
280
281 //these following lines are really absurd... Why has this to be the case... <19-06-2006>
282 //We need a link which can be dynamically to a Track or a TrackParticle....... )-:
283
284 const std::vector<const Trk::Track*>::const_iterator trkbegin=VectorTrk.begin();
285 const std::vector<const Trk::Track*>::const_iterator trkend=VectorTrk.end();
286
287 const std::vector<VxTrackAtVertex>::iterator vtxbegin=FittedVertex->vxTrackAtVertex().begin();
288 const std::vector<VxTrackAtVertex>::iterator vtxend=FittedVertex->vxTrackAtVertex().end();
289
290 for (std::vector<const Trk::Track*>::const_iterator trkiter=trkbegin;trkiter!=trkend;++trkiter)
291 {
292 for (std::vector<Trk::VxTrackAtVertex>::iterator vtxiter=vtxbegin;vtxiter!=vtxend;++vtxiter)
293 {
294 if(((*trkiter)->perigeeParameters()->momentum() -
295 (*vtxiter).initialPerigee()->momentum()).mag()< 1e-8 &&
296 ((*trkiter)->perigeeParameters()->position() -
297 (*vtxiter).initialPerigee()->position()).mag()< 1e-8)
298 {
299
300 ElementLink<TrackCollection> link;
301 link.setElement(*trkiter);
302 LinkToTrack * linkTT = new LinkToTrack(link);
303 (*vtxiter).setOrigTrack(linkTT);
304 }
305 }
306 }
307
308 //*******************************************************************
309 // TODO: Starting from a vector of Trk::Tracks, can't store
310 // separately from the vxTrackAtVertex vector the links to the
311 // original tracks in xAOD::Vertex (only links to xAOD::TrackParticles and
312 // xAOD::NeutralParticles can be stored)
313 //*******************************************************************
314
315 return FittedVertex;
316 }
#define ATH_MSG_DEBUG(x)
xAOD::Vertex * _fit(const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList=std::vector< const Trk::NeutralParameters * >(), const xAOD::Vertex &constraint=xAOD::Vertex(), const Amg::Vector3D &startingPoint=Amg::Vector3D(), bool IsConstraint=false, bool IsStartingPoint=false) const
Internal method for fitting a list of TrackParameters and NeutralParameters, with or without constrai...
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
@ d0
Definition ParamDefs.h:63
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ _fit() [2/3]

xAOD::Vertex * Trk::AdaptiveVertexFitter::_fit ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList = std::vector<const Trk::NeutralParameters*>(),
const xAOD::Vertex & constraint = xAOD::Vertex(),
const Amg::Vector3D & startingPoint = Amg::Vector3D(),
bool IsConstraint = false,
bool IsStartingPoint = false ) const
private

Internal method for fitting a list of TrackParameters and NeutralParameters, with or without constraint and starting point.

Definition at line 113 of file AdaptiveVertexFitter.cxx.

120 {
121
122 //check the number of tracks
123 if ( (perigeeList.size() + neutralPerigeeList.size())<2 && !IsConstraint ) {
124 msg(MSG::WARNING) << "Not enough tracks (>2) to fit in this event (without constraint)." << endmsg;
125 return nullptr;
126 }
127 if ((perigeeList.size() + neutralPerigeeList.size())<1 && IsConstraint) {
128 msg(MSG::WARNING) << "Not enough tracks (>1) to fit in this event (with constraint)." << endmsg;
129 return nullptr;
130 }
131
132
133 Amg::Vector3D SeedPoint;
134 //now find the best point for seeding and linearization of the tracks
135 if (IsStartingPoint) {
136 SeedPoint=startingPoint;
137 } else {
138 if (perigeeList.size()>1) {
139 if (IsConstraint) {
140 SeedPoint=m_SeedFinder->findSeed(perigeeList,&constraint);
141 } else {
142 SeedPoint=m_SeedFinder->findSeed(perigeeList);
143 }
144 }
145 else if (IsConstraint) {
146 SeedPoint=constraint.position();
147 }
148 else {
149 SeedPoint.setZero();
150 }
151 }
152
153 //in case m_onlyzseed is on, just use only the z component given by the seed finder
154 if (m_onlyzseed&&IsConstraint) {
155 SeedPoint=constraint.position();
156 }
157
158
159 //now create a Global Position with the linearized track and the linearization point
160 //which in this case is taken from the found seed for the vertex
161 //use the linPoint to linearize tracks
162
163 std::vector<VxTrackAtVertex> theLinTracks;
164
165 std::vector<const Trk::TrackParameters*>::const_iterator perigeesBegin=perigeeList.begin();
166 std::vector<const Trk::TrackParameters*>::const_iterator perigeesEnd=perigeeList.end();
167
168 ATH_MSG_DEBUG("Inside fitter with track perigee parameters.");
169 ATH_MSG_DEBUG("Seed point: " << SeedPoint);
170 int myDebugNTrk(0);
171
172 for (std::vector<const Trk::TrackParameters*>::const_iterator perigeesIter=perigeesBegin;perigeesIter!=perigeesEnd;++perigeesIter) {
173 // const MeasuredPerigee* castToMP=dynamic_cast<const MeasuredPerigee*>(*perigeesIter);
174 // if (castToMP==0) {
175 // msg << MSG::ERROR << "Cast to MeasuredPerigee not successfull. Treatment of neutrals not supported. Skipping track..." << endmsg;
176 // continue;
177 // }
178
179 ATH_MSG_DEBUG("Track #" << myDebugNTrk++ << ". TrackParameters: x = " << (*perigeesIter)->position().x() << ", y = "<< (*perigeesIter)->position().y() <<", z = "<< (*perigeesIter)->position().z() << ". Covariance: " << *(*perigeesIter)->covariance());
180
181 VxTrackAtVertex* LinTrackToAdd = new VxTrackAtVertex(0., nullptr, nullptr, (*perigeesIter), nullptr); //TODO: Must think now about when to delete this memory! -David S.
182
183 //m_LinearizedTrackFactory->linearize(*LinTrackToAdd,SeedPoint); why linearize it? maybe you don't need it at all!!!!! <19-05-2006>
184 bool success=m_ImpactPoint3dEstimator->addIP3dAtaPlane(*LinTrackToAdd,SeedPoint);
185 if (!success)
186 {
187 msg(MSG::DEBUG) << "Adding compatibility to vertex information failed. Newton distance finder didn't converge..." << endmsg;
188 }
189
190 theLinTracks.push_back(*LinTrackToAdd);
191
192 delete LinTrackToAdd; //TODO: is here ok?
193
194 }
195
196 std::vector<const Trk::NeutralParameters*>::const_iterator neutralPerigeesBegin=neutralPerigeeList.begin();
197 std::vector<const Trk::NeutralParameters*>::const_iterator neutralPerigeesEnd =neutralPerigeeList.end();
198
199 ATH_MSG_DEBUG("Inside fitter with neutral perigee parameters.");
200 ATH_MSG_DEBUG("Seed point: " << SeedPoint);
201 int myDebugNNeutral(0);
202 for (std::vector<const Trk::NeutralParameters*>::const_iterator neutralPerigeesIter=neutralPerigeesBegin;neutralPerigeesIter!=neutralPerigeesEnd;++neutralPerigeesIter) {
203
204 ATH_MSG_DEBUG("Neutral #" << myDebugNNeutral++ << ". NeutralParameters: x = " << (*neutralPerigeesIter)->position().x() << ", y = "<< (*neutralPerigeesIter)->position().y() <<", z = "<< (*neutralPerigeesIter)->position().z());
205 ATH_MSG_DEBUG(" Covariance: " << *(*neutralPerigeesIter)->covariance());
206 ATH_MSG_DEBUG(" Momentum: x = " << (*neutralPerigeesIter)->momentum().x() << ", y = "<< (*neutralPerigeesIter)->momentum().y() <<", z = "<< (*neutralPerigeesIter)->momentum().z());
207
208 VxTrackAtVertex* LinTrackToAdd = new VxTrackAtVertex(0., nullptr, nullptr, nullptr, (*neutralPerigeesIter) ); //TODO: Must think now about when to delete this memory! -David S.
209
210 bool success = m_ImpactPoint3dEstimator->addIP3dAtaPlane(*LinTrackToAdd,SeedPoint);
211 if (!success)
212 {
213 msg(MSG::DEBUG) << "Adding compatibility to vertex information failed. Newton distance finder didn't converge..." << endmsg;
214 }
215
216 theLinTracks.push_back(*LinTrackToAdd);
217
218 delete LinTrackToAdd; //TODO: is here ok?
219 }
220
221
222
223 //Initialize the vertex seed with an arbitrary great error matrix (just starting point,
224 //not really prior information in it)
225 if(msgLvl(MSG::VERBOSE))
226 {
227 msg(MSG::VERBOSE) << "Error at the beginning is set to " << m_initialError << endmsg;
228 }
229
230
231
232
233 xAOD::Vertex ConstraintVertex;
234 ConstraintVertex.makePrivateStore();
235 //use the previous prior vertex info for the initial vertex if there
236 if (IsConstraint ) {
237 ConstraintVertex.setPosition( constraint.position() );
238 ConstraintVertex.setCovariancePosition( constraint.covariancePosition() );
239 ConstraintVertex.setFitQuality( 0., 0. );
240 } else {
241 AmgSymMatrix(3) startingCovMatrix;
242 startingCovMatrix.setIdentity();
243 startingCovMatrix = startingCovMatrix / m_initialError;
244 //now initialize with starting position and covariance matrix
245 ConstraintVertex.setPosition( SeedPoint );
246 ConstraintVertex.setCovariancePosition( startingCovMatrix );
247 ConstraintVertex.setFitQuality( 0., -3. );
248 }
249
250 //now put the linearizedtracks into VxTrackAtVertex
251 return dothefit(ConstraintVertex,SeedPoint,theLinTracks);
252
253
254 }
#define endmsg
#define AmgSymMatrix(dim)
void makePrivateStore()
Create a new (empty) private store for this object.
ToolHandle< Trk::IImpactPoint3dEstimator > m_ImpactPoint3dEstimator
ToolHandle< Trk::IVertexSeedFinder > m_SeedFinder
xAOD::Vertex * dothefit(const xAOD::Vertex &ConstraintVertex, const Amg::Vector3D &SeedVertex, std::vector< VxTrackAtVertex > &myLinTracks) const
Internal method, called by the two _fit internal functions, in order to perform the fit,...
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
const Amg::Vector3D & position() const
Returns the 3-pos.
Eigen::Matrix< double, 3, 1 > Vector3D
MsgStream & msg
Definition testRead.cxx:32

◆ _fit() [3/3]

xAOD::Vertex * Trk::AdaptiveVertexFitter::_fit ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex & constraint = xAOD::Vertex(),
const Amg::Vector3D & startingPoint = Amg::Vector3D(),
bool IsConstraint = false,
bool IsStartingPoint = false ) const
private

Definition at line 591 of file AdaptiveVertexFitter.cxx.

595 {
596 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
597 return _fit(perigeeList, neutralPerigeeList, constraint, startingPoint, IsConstraint, IsStartingPoint);
598 }

◆ dothefit()

xAOD::Vertex * Trk::AdaptiveVertexFitter::dothefit ( const xAOD::Vertex & ConstraintVertex,
const Amg::Vector3D & SeedVertex,
std::vector< VxTrackAtVertex > & myLinTracks ) const
private

Internal method, called by the two _fit internal functions, in order to perform the fit, after having initialized the input (constraint + seed).

The real fit happens here.

Definition at line 319 of file AdaptiveVertexFitter.cxx.

323 {
324
325 //now reset the annealing maker
327 m_AnnealingMaker->reset(astate);
328
329 //Count the steps for the fit and the number of relinearizations needed in the fit
330 int num_steps(0);
331
332
333 xAOD::Vertex* ActualVertex = new xAOD::Vertex();
334 ActualVertex->makePrivateStore(); // xAOD::VertexContainer will take ownership of AuxStore when ActualVertex is added to it
335 ActualVertex->setPosition( ConstraintVertex.position() );
336 ActualVertex->setCovariancePosition( ConstraintVertex.covariancePosition() / m_AnnealingMaker->getWeight(astate, 1.) );
337 ActualVertex->setFitQuality( ConstraintVertex.chiSquared(), ConstraintVertex.numberDoF() );
338 ActualVertex->vxTrackAtVertex() = myLinTracks;
339 ActualVertex->setVertexType(xAOD::VxType::NotSpecified); // to mimic the initialization present in the old EDM constructor
340
341 Amg::Vector3D NewVertex = SeedVertex;
342
343 Amg::Vector3D ActualSeedPosition = SeedVertex;
344
345 if(msgLvl(MSG::VERBOSE))
346 {
347 msg(MSG::VERBOSE) << "Num max of steps is " << m_maxIterations << endmsg;
348 msg(MSG::VERBOSE) << "m_AnnealingMaker->isEquilibrium() is " << m_AnnealingMaker->isEquilibrium(astate) << endmsg;
349 }
350
351 std::vector<Trk::VxTrackAtVertex>::iterator lintracksBegin = ActualVertex->vxTrackAtVertex().begin();
352 std::vector<Trk::VxTrackAtVertex>::iterator lintracksEnd = ActualVertex->vxTrackAtVertex().end();
353
354 std::vector<Trk::VxTrackAtVertex>::iterator iter;
355
356 bool relinearization = false;
357
358 do {
359
360 ActualVertex->setPosition( ConstraintVertex.position() );
361 ActualVertex->setCovariancePosition( ConstraintVertex.covariancePosition() / m_AnnealingMaker->getWeight(astate, 1.) );
362 ActualVertex->setFitQuality( ConstraintVertex.chiSquared(), ConstraintVertex.numberDoF() );
363
364 if(msgLvl(MSG::DEBUG))
365 {
366 msg(MSG::DEBUG) << "Correction applied to constraint weight is: " << m_AnnealingMaker->getWeight(astate, 1.) << endmsg;
367 }
368
369 //To reweight here through an extrapolation is not ideal, but maybe I'll change this in the future...
370 if(msgLvl(MSG::DEBUG))
371 {
372 msg(MSG::DEBUG) << "New fit step: step number " << num_steps << endmsg;
373 }
374
375 //consider relinearization if you are too far away from the old lin point
376
377
378 relinearization=false;
379 if ( (ActualSeedPosition - SeedVertex).perp() > m_maxDistToLinPoint ) {
380 relinearization=true;
381 if(msgLvl(MSG::DEBUG))
382 {
383 msg(MSG::DEBUG) << "Actual vertex too far away from linearization point: have to linearize tracks again" << endmsg;
384 }
385
386 //collect all measured perigees
387
388 for (iter=lintracksBegin;iter!=lintracksEnd;++iter) {
389 //m_LinearizedTrackFactory->linearize(*iter,ActualPosition);
390 bool success=m_ImpactPoint3dEstimator->addIP3dAtaPlane(*iter,NewVertex);
391 if (!success)
392 {
393 msg(MSG::DEBUG) << "Adding compatibility to vertex information failed. Newton distance finder didn't converge..." << endmsg;
394 }
395 }
396
397 }
398
399
400 lintracksBegin=ActualVertex->vxTrackAtVertex().begin();
401 lintracksEnd=ActualVertex->vxTrackAtVertex().end();
402
403 //now reweight tracks (find chi2 compatibility with actual vertex position)
404 for (iter=lintracksBegin;iter!=lintracksEnd;++iter) {
405
406 //estimate the compatibility of the track to the vertex and store it in iter->linState()->m_vtxCompatibility
407 m_TrackCompatibilityEstimator->estimate(*iter,NewVertex);
408
409 //use the obtained estimate and ask the Annealing Maker what is the corresponding weight at the actual temperature step
410 iter->setWeight( m_AnnealingMaker->getWeight( astate, iter->vtxCompatibility() ) );
411 if(msgLvl(MSG::VERBOSE))
412 {
413 msg(MSG::VERBOSE) << "Before annealing: " << iter->vtxCompatibility() <<
414 " Annealing RESULT is:" << iter->weight() << " at T: " <<
415 m_AnnealingMaker->actualTemp(astate) << endmsg;
416 }
417
418
419 }
420
421 //now update with all the tracks info
422 for (iter=lintracksBegin;iter!=lintracksEnd;++iter) {
423 if(msgLvl(MSG::VERBOSE))
424 {
425 msg(MSG::VERBOSE) << "Updating vertex with a new track" << endmsg;
426 }
427 try {
428
429 if ( iter->weight() > 1e-3 ) {
430 //now take care if linearization has been done at least once
431 //or if vertex has changed so much so that you need relinearization!
432 if ( iter->linState() == nullptr) {
433 //linearization has not been done so far: do it now!
434 if(msgLvl(MSG::VERBOSE))
435 {
436 msg(MSG::VERBOSE) << "Linearizing track for the first time" << endmsg;
437 }
438
439 m_LinearizedTrackFactory->linearize( *iter, ActualVertex->position() );
440 ATH_MSG_DEBUG( "Linearized track to Seed Point. " << *iter );
441 } else if (relinearization) {
442 //do it again in case of updated vertex too far from previous one
443 if(msgLvl(MSG::VERBOSE))
444 {
445 msg(MSG::VERBOSE) << "Relinearizing track " << endmsg;
446 }
447
448 m_LinearizedTrackFactory->linearize( *iter, NewVertex );
449 ActualSeedPosition=NewVertex;
450 ATH_MSG_DEBUG("Linearized track to new seed Point " << NewVertex << ". " << *iter );
451 }
452 ActualVertex=m_VertexUpdator->add(*ActualVertex,*iter);
453 } else {
454 if(msgLvl(MSG::VERBOSE))
455 {
456 msg(MSG::VERBOSE) << "Weight lower than 1e-3, so the track will not be considered anymore" << endmsg;
457 }
458
459 }
460 } catch (...) {
461 msg(MSG::WARNING) << "You have just lost a track" << endmsg;
462 }
463 }
464
465 //show some info about the position
466 if(msgLvl(MSG::DEBUG))
467 {
468 msg(MSG::DEBUG) << "New position x: " << ActualVertex->position().x() << " y: " << ActualVertex->position().y()
469 << " z: " << ActualVertex->position().z() << endmsg;
470 }
471
472
473 NewVertex = ActualVertex->position();
474
475 //now go one step down in the annealing process (lower the temperature - single step)
476 if(msgLvl(MSG::VERBOSE))
477 {
478 msg(MSG::VERBOSE) << "Now calling one step of annealing" << endmsg;
479 }
480
481 m_AnnealingMaker->anneal(astate);
482 num_steps+=1;
483
484 //continue to fit until max iteration number has been reached or "thermal equilibrium"
485 //has been obtained in the annealing process
486
487 } while (num_steps<m_maxIterations && !(m_AnnealingMaker->isEquilibrium(astate)) );
488
489 //Here smooth the vertex (refitting of the track)
490
491 //without smoothing... for the moment...
492 if(m_doSmoothing) {
493 m_VertexSmoother->smooth(*ActualVertex);
494 } else {
495 for (iter=lintracksBegin;iter!=lintracksEnd;++iter) {
496 // const MeasuredPerigee* castToMP=dynamic_cast<const MeasuredPerigee*>(iter->initialPerigee());
497 // if (castToMP==0) {
498 // msg(MSG::WARNING) << "Couldn't cast a track to MeasuredPerigee to smooth it. Neutrals not supported. " <<
499 // " Skipping track. .. " << endmsg;
500 // continue;
501 // }
502 if ( iter->initialPerigee() )
503 iter->setPerigeeAtVertex( ( iter->initialPerigee() )->clone() );
504 else if ( iter->initialNeutralPerigee() )
505 iter->setPerigeeAtVertex( ( iter->initialNeutralPerigee() )->clone() );
506 }
507 }
508
509 if(msgLvl(MSG::DEBUG))
510 {
511 msg(MSG::DEBUG) << "chi2: " << ActualVertex->chiSquared()
512 << "the ndf of the vertex is at fit end: " << ActualVertex->numberDoF() << endmsg;
513 }
514
515
516 //Give back all info into the ActualVertex xAOD::Vertex
517 return ActualVertex;
518 }
Scalar perp() const
perp method - perpendicular length
ToolHandle< Trk::IVertexTrackCompatibilityEstimator > m_TrackCompatibilityEstimator
ToolHandle< Trk::IVertexSmoother > m_VertexSmoother
ToolHandle< Trk::IVertexAnnealingMaker > m_AnnealingMaker
ToolHandle< Trk::IVertexUpdator > m_VertexUpdator
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_LinearizedTrackFactory
void setVertexType(VxType::VertexType vType)
Set the type of the vertex.
float numberDoF() const
Returns the number of degrees of freedom of the vertex fit as float.
float chiSquared() const
Returns the of the vertex fit as float.
@ NotSpecified
Default value, no explicit type set.

◆ fit() [1/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList ) const
inline

Fit method using the VertexSeedFinder to estimate initial position of the vertex and taking it as a first linearization point (in iterative fitters).

EventContext aware method.

Definition at line 215 of file IVertexFitter.h.

218 {
219 (void)(ctx);
220 return std::unique_ptr<xAOD::Vertex>(fit(perigeeList));
221 }
virtual xAOD::Vertex * fit(const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &vectorNeut, const Amg::Vector3D &startingPoint) const override
Interface for xAOD::TrackParticle with starting point.

◆ fit() [2/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const Amg::Vector3D & startingPoint ) const
inline

Interface for TrackParameters with starting point Event Context aware method.

Definition at line 154 of file IVertexFitter.h.

158 {
159 (void)(ctx);
160 return std::unique_ptr<xAOD::Vertex>(fit(perigeeList, startingPoint));
161 }

◆ fit() [3/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList ) const
inline

Fit method using the VertexSeedFinder to estimate initial position of the vertex and taking it as a first linearization point (in iterative fitters).

EventContext aware method.

Definition at line 200 of file IVertexFitter.h.

204 {
205 (void)(ctx);
206 return std::unique_ptr<xAOD::Vertex>(fit(perigeeList, neutralPerigeeList));
207 }

◆ fit() [4/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList,
const Amg::Vector3D & startingPoint ) const
inline

Interface for TrackParameters and NeutralParameters with starting point Event Context aware method.

Definition at line 138 of file IVertexFitter.h.

143 {
144 (void)(ctx);
145 return std::unique_ptr<xAOD::Vertex>(
146 fit(perigeeList, neutralPerigeeList, startingPoint));
147 }

◆ fit() [5/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList,
const xAOD::Vertex & constraint ) const
inline

Interface for TrackParameters and NeutralParameters with vertex constraint the position of the constraint is ALWAYS the starting point EventContext aware method.

Definition at line 169 of file IVertexFitter.h.

174 {
175 (void)(ctx);
176 return std::unique_ptr<xAOD::Vertex>(
177 fit(perigeeList, neutralPerigeeList, constraint));
178 }

◆ fit() [6/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex & constraint ) const
inline

Interface for TrackParameters with vertex constraint the position of the constraint is ALWAYS the starting point EventContext aware method.

Definition at line 185 of file IVertexFitter.h.

189 {
190 (void)(ctx);
191 return std::unique_ptr<xAOD::Vertex>(fit(perigeeList, constraint));
192 }

◆ fit() [7/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const Amg::Vector3D & startingPoint ) const
inline

Interface for xAOD::TrackParticle with starting point Event Context aware interface.

Definition at line 77 of file IVertexFitter.h.

81 {
82 (void)(ctx);
83 return std::unique_ptr<xAOD::Vertex>(fit(vectorTrk, startingPoint));
84 }

◆ fit() [8/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & vectorNeu,
const Amg::Vector3D & startingPoint ) const
inline

Interface for xAOD::TrackParticle and xAOD::NeutralParticle with starting point.

Event Context aware method

Definition at line 91 of file IVertexFitter.h.

96 {
97 (void)(ctx);
98 return std::unique_ptr<xAOD::Vertex>(
99 fit(vectorTrk, vectorNeu, startingPoint));
100 }

◆ fit() [9/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & vectorNeu,
const xAOD::Vertex & constraint ) const
inline

Interface for xAOD::TrackParticle and xAOD::NeutralParticle with vertex constraint the position of the constraint is ALWAYS the starting point Event Context aware method.

Definition at line 108 of file IVertexFitter.h.

113 {
114 (void)(ctx);
115 return std::unique_ptr<xAOD::Vertex>(fit(vectorTrk, vectorNeu, constraint));
116 }

◆ fit() [10/24]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const xAOD::Vertex & constraint ) const
inline

Interface for xAOD::TrackParticle with vertex constraint the position of the constraint is ALWAYS the starting point Event Context aware method.

Definition at line 124 of file IVertexFitter.h.

128 {
129 (void)(ctx);
130 return std::unique_ptr<xAOD::Vertex>(fit(vectorTrk, constraint));
131 }

◆ fit() [11/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::Track * > & Vectortrk,
const xAOD::Vertex & constraint,
const Amg::Vector3D & startingPoint ) const

fit providing vector of tracks, constraint and startingPoint

◆ fit() [12/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & perigeeList) const
override

Definition at line 585 of file AdaptiveVertexFitter.cxx.

586 {
587 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
588 return fit(perigeeList,neutralPerigeeList);
589 }

◆ fit() [13/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const Amg::Vector3D & startingPoint ) const
overridevirtual

Definition at line 558 of file AdaptiveVertexFitter.cxx.

561 {
562 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
563 return fit(perigeeList, neutralPerigeeList, startingPoint);
564 }

◆ fit() [14/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList ) const
override

fit providing vector of TrackParameters and NeutralParameters

Definition at line 550 of file AdaptiveVertexFitter.cxx.

553 {
554 return _fit(perigeeList,neutralPerigeeList,xAOD::Vertex(),Amg::Vector3D(),false,false);
555 }

◆ fit() [15/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList,
const Amg::Vector3D & startingPoint ) const
overridevirtual

Interface for MeasuredPerigee with starting point.

Definition at line 521 of file AdaptiveVertexFitter.cxx.

525 {
526
527 return _fit(perigeeList,neutralPerigeeList,xAOD::Vertex(),startingPoint,false,true);
528 }

◆ fit() [16/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList,
const xAOD::Vertex & constraint ) const
overridevirtual

Interface for MeasuredPerigee with vertex constraint.

Definition at line 531 of file AdaptiveVertexFitter.cxx.

535 {
536 return _fit(perigeeList,neutralPerigeeList,constraint,Amg::Vector3D::Zero(),true);
537 }

◆ fit() [17/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList,
const xAOD::Vertex & constraint,
const Amg::Vector3D & startingPoint ) const

fit providing vector of ParametersBase, constraint and startingPoint

Definition at line 540 of file AdaptiveVertexFitter.cxx.

545 {
546 return _fit(perigeeList,neutralPerigeeList,constraint,startingPoint,true,true);
547 }

◆ fit() [18/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex & constraint ) const
overridevirtual

Definition at line 567 of file AdaptiveVertexFitter.cxx.

570 {
571 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
572 return fit(perigeeList, neutralPerigeeList, constraint);
573 }

◆ fit() [19/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex & constraint,
const Amg::Vector3D & startingPoint ) const

Definition at line 576 of file AdaptiveVertexFitter.cxx.

580 {
581 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
582 return fit(perigeeList, neutralPerigeeList, constraint, startingPoint);
583 }

◆ fit() [20/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const Trk::TrackParticleBase * > & perigeeList) const

fit providing vector of TrackParticleBase

◆ fit() [21/24]

virtual xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const Amg::Vector3D & startingPoint ) const
inlineoverridevirtual

Definition at line 116 of file AdaptiveVertexFitter.h.

118 {
119 return fit(vectorTrk, std::vector<const xAOD::NeutralParticle*>(), startingPoint);
120 };

◆ fit() [22/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & vectorNeut,
const Amg::Vector3D & startingPoint ) const
overridevirtual

Interface for xAOD::TrackParticle with starting point.

Definition at line 604 of file AdaptiveVertexFitter.cxx.

608 {
609
610 if (vectorTrk.empty()) {
611 msg(MSG::INFO) << "Empty vector of tracks passed" << endmsg;
612 return nullptr;
613 }
614
615 if (vectorNeut.empty()) {
616 msg(MSG::VERBOSE) << "Empty vector of neutrals passed" << endmsg;
617 }
618
619 // making a list of perigee out of the vector of tracks
620 std::vector<const Trk::TrackParameters*> measuredPerigees;
621
622 for (const auto *i : vectorTrk) {
623 const Trk::TrackParameters* tmpMeasPer = &(i->perigeeParameters());
624
625 if (tmpMeasPer != nullptr)
626 measuredPerigees.push_back(tmpMeasPer);
627 else
628 msg(MSG::INFO)
629 << "Failed to dynamic_cast this track parameters to perigee"
630 << endmsg; // TODO: Failed to implicit cast the perigee parameters to
631 // track parameters?
632 }
633
634 // making a list of perigee out of the vector of neutrals
635 std::vector<const Trk::NeutralParameters*> measuredNeutralPerigees;
636
637 for (const auto *i : vectorNeut) {
638 const Trk::NeutralParameters* tmpMeasPer = &(i->perigeeParameters());
639
640 if (tmpMeasPer != nullptr)
641 measuredNeutralPerigees.push_back(tmpMeasPer);
642 else
643 msg(MSG::INFO)
644 << "Failed to dynamic_cast this neutral parameters to perigee"
645 << endmsg; // TODO: Failed to implicit cast the perigee parameters to
646 // neutral parameters?
647 }
648
649 xAOD::Vertex* fittedVertex = _fit(measuredPerigees,
650 measuredNeutralPerigees,
651 xAOD::Vertex(),
652 startingPoint,
653 false,
654 true);
655
656 // assigning the input tracks to the fitted vertex through VxTrackAtVertices
657 if (fittedVertex == nullptr) {
658 return fittedVertex;
659 }
660
661 if (fittedVertex
662 ->vxTrackAtVertexAvailable()) // TODO: I don't think
663 // vxTrackAtVertexAvailable() does the
664 // same thing as a null pointer check!
665 {
666 if (!fittedVertex->vxTrackAtVertex().empty()) {
667 for (unsigned int i = 0; i < vectorTrk.size(); ++i) {
668
669 LinkToXAODTrackParticle* linkTT = new LinkToXAODTrackParticle();
670 const xAOD::TrackParticleContainer* cont =
671 dynamic_cast<const xAOD::TrackParticleContainer*>(
672 vectorTrk[i]->container());
673 if (cont) {
674 if (!linkTT->toIndexedElement(*cont, vectorTrk[i]->index())) {
675 msg(MSG::WARNING)
676 << "Failed to set the EL for this particle correctly" << endmsg;
677 }
678 } else {
679 msg(MSG::WARNING)
680 << "Failed to identify a container for this TP" << endmsg;
681 } // end of the dynamic cast check
682
683 // vxtrackatvertex takes ownership!
684 (fittedVertex->vxTrackAtVertex())[i].setOrigTrack(linkTT);
685 } // end of loop for setting orig tracks in.
686
687 for (unsigned int i = 0; i < vectorNeut.size(); ++i) {
688 LinkToXAODNeutralParticle* linkTT = new LinkToXAODNeutralParticle();
690 dynamic_cast<const xAOD::NeutralParticleContainer*>(
691 vectorNeut[i]->container());
692 if (cont) {
693 if (!linkTT->toIndexedElement(*cont, vectorNeut[i]->index())) {
694 msg(MSG::WARNING)
695 << "Failed to set the EL for this particle correctly" << endmsg;
696 }
697 } else {
698 msg(MSG::WARNING)
699 << "Failed to identify a container for this TP" << endmsg;
700 } // end of the dynamic cast check
701
702 // vxtrackatvertex takes ownership!
703 (fittedVertex->vxTrackAtVertex())[i + vectorTrk.size()].setOrigTrack(
704 linkTT);
705 } // end of loop for setting orig neutrals in.
706
707 } // end of protection against unsuccessfull updates (no tracks were
708 // added)
709 } // end of vector of tracks check
710
711 // now set links to xAOD::TrackParticles directly in the xAOD::Vertex
712 unsigned int VTAVsize = fittedVertex->vxTrackAtVertex().size();
713 for (unsigned int i = 0; i < VTAVsize; ++i) {
714 Trk::VxTrackAtVertex* VTAV = &(fittedVertex->vxTrackAtVertex().at(i));
715 // TODO: Will this pointer really hold 0 if no VxTrackAtVertex is found?
716 if (not VTAV) {
717 ATH_MSG_WARNING(" Trying to set link to xAOD::TrackParticle. The "
718 "VxTrackAtVertex is not found");
719 continue;
720 }
721
722 Trk::ITrackLink* trklink = VTAV->trackOrParticleLink();
723
724 // See if the trklink is to an xAOD::TrackParticle
725 Trk::LinkToXAODTrackParticle* linkToXAODTP =
726 dynamic_cast<Trk::LinkToXAODTrackParticle*>(trklink);
727 if (linkToXAODTP) {
728
729 // Now set the new link to the xAOD vertex
730 fittedVertex->addTrackAtVertex(*linkToXAODTP, VTAV->weight());
731
732 } else {
733
734 // See if the trklink is to an xAOD::NeutralParticle
735 Trk::LinkToXAODNeutralParticle* linkToXAODTPneutral =
736 dynamic_cast<Trk::LinkToXAODNeutralParticle*>(trklink);
737 if (!linkToXAODTPneutral) {
739 "Skipping track. Trying to set link to something else than "
740 "xAOD::TrackParticle or xAOD::NeutralParticle.");
741 } else {
742 // Now set the newlink to the new xAOD vertex
743 fittedVertex->addNeutralAtVertex(*linkToXAODTPneutral,
744 VTAV->weight());
745 }
746 }
747 } // end of loop
748
749 return fittedVertex;
750
751 }//end of the xAOD starting point fit method
#define ATH_MSG_WARNING(x)
void addTrackAtVertex(const ElementLink< TrackParticleContainer > &tr, float weight=1.0)
Add a new track to the vertex.
void addNeutralAtVertex(const ElementLink< NeutralParticleContainer > &tr, float weight=1.0)
Add a new neutral to the vertex.
ParametersBase< NeutralParametersDim, Neutral > NeutralParameters
ParametersBase< TrackParametersDim, Charged > TrackParameters
NeutralParticleContainer_v1 NeutralParticleContainer
Definition of the current "NeutralParticle container version".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".

◆ fit() [23/24]

xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & vectorNeut,
const xAOD::Vertex & constraint ) const
overridevirtual

Interface for xAOD::TrackParticle with vertex constraint the position of the constraint is ALWAYS the starting point.

Definition at line 754 of file AdaptiveVertexFitter.cxx.

758 {
759
760 if(vectorTrk.empty())
761 {
762 msg(MSG::INFO)<<"Empty vector of tracks passed"<<endmsg;
763 return nullptr;
764 }
765
766 if(vectorNeut.empty())
767 {
768 msg(MSG::INFO)<<"Empty vector of neutrals passed"<<endmsg;
769 }
770
771 //making a list of perigee out of the vector of tracks
772 std::vector<const Trk::TrackParameters*> measuredPerigees;
773
774 for(const auto *i : vectorTrk)
775 {
776 const Trk::TrackParameters * tmpMeasPer = &(i->perigeeParameters());
777
778 if(tmpMeasPer!=nullptr) measuredPerigees.push_back(tmpMeasPer);
779 else msg(MSG::INFO)<<"Failed to dynamic_cast this track parameters to perigee"<<endmsg; //TODO: Failed to implicit cast the perigee parameters to track parameters?
780 }
781
782 //making a list of perigee out of the vector of neutrals
783 std::vector<const Trk::NeutralParameters*> measuredNeutralPerigees;
784
785 for(const auto *i : vectorNeut)
786 {
787 const Trk::NeutralParameters * tmpMeasPer = &(i->perigeeParameters());
788
789 if(tmpMeasPer!=nullptr) measuredNeutralPerigees.push_back(tmpMeasPer);
790 else msg(MSG::INFO)<<"Failed to dynamic_cast this neutral parameters to perigee"<<endmsg; //TODO: Failed to implicit cast the perigee parameters to neutral parameters?
791 }
792
793
794 xAOD::Vertex* fittedVertex = _fit(measuredPerigees, measuredNeutralPerigees, constraint, Amg::Vector3D(),true);
795
796
797 //assigning the input tracks to the fitted vertex through VxTrackAtVertices
798 {
799 if( fittedVertex->vxTrackAtVertexAvailable() ) // TODO: I don't think vxTrackAtVertexAvailable() does the same thing as a null pointer check
800 {
801 if(!fittedVertex->vxTrackAtVertex().empty())
802 {
803 for(unsigned int i = 0; i <vectorTrk.size(); ++i)
804 {
805
806 LinkToXAODTrackParticle* linkTT = new LinkToXAODTrackParticle();
807 const xAOD::TrackParticleContainer* cont = dynamic_cast< const xAOD::TrackParticleContainer* >( vectorTrk[ i ]->container() );
808 if( cont )
809 {
810 if( ! linkTT->toIndexedElement( *cont, vectorTrk[ i ]->index() ) )
811 {
812 msg(MSG::WARNING)<<"Failed to set the EL for this particle correctly"<<endmsg;
813 }
814 } else {
815 msg(MSG::WARNING)<<"Failed to identify a container for this TP"<<endmsg;
816 }//end of the dynamic cast check
817
818
819 // vxtrackatvertex takes ownership!
820 ( fittedVertex->vxTrackAtVertex() )[i].setOrigTrack(linkTT);
821 }//end of loop for setting orig tracks in.
822
823 for(unsigned int i = 0; i <vectorNeut.size(); ++i)
824 {
825 LinkToXAODNeutralParticle* linkTT = new LinkToXAODNeutralParticle();
826 const xAOD::NeutralParticleContainer* cont = dynamic_cast< const xAOD::NeutralParticleContainer* >( vectorNeut[ i ]->container() );
827 if( cont )
828 {
829 if( ! linkTT->toIndexedElement( *cont, vectorNeut[ i ]->index() ) )
830 {
831 msg(MSG::WARNING)<<"Failed to set the EL for this particle correctly"<<endmsg;
832 }
833 } else {
834 msg(MSG::WARNING)<<"Failed to identify a container for this NP"<<endmsg;
835 }//end of the dynamic cast check
836
837 // vxtrackatvertex takes ownership!
838 ( fittedVertex->vxTrackAtVertex() )[vectorTrk.size()+i].setOrigTrack(linkTT);
839 }//end of loop for setting orig neutrals in.
840
841 }//end of protection against unsuccessfull updates (no tracks were added)
842 }//end of vector of tracks check
843 }
844
845
846 //now set links to xAOD::TrackParticles directly in the xAOD::Vertex
847 unsigned int VTAVsize = fittedVertex->vxTrackAtVertex().size();
848 for (unsigned int i = 0 ; i < VTAVsize ; ++i)
849 {
850 Trk::VxTrackAtVertex* VTAV = &( fittedVertex->vxTrackAtVertex().at(i) );
851 //TODO: Will this pointer really hold 0 if no VxTrackAtVertex is found?
852 if (not VTAV){
853 ATH_MSG_WARNING (" Trying to set link to xAOD::TrackParticle. The VxTrackAtVertex is not found");
854 continue;
855 }
856
857 Trk::ITrackLink* trklink = VTAV->trackOrParticleLink();
858
859 // See if the trklink is to an xAOD::TrackParticle
860 Trk::LinkToXAODTrackParticle* linkToXAODTP = dynamic_cast<Trk::LinkToXAODTrackParticle*>(trklink);
861 if (linkToXAODTP)
862 {
863
864 //Now set the new link to the xAOD vertex
865 fittedVertex->addTrackAtVertex(*linkToXAODTP, VTAV->weight());
866
867 } else {
868
869 // See if the trklink is to an xAOD::NeutralParticle
870 Trk::LinkToXAODNeutralParticle* linkToXAODTPneutral = dynamic_cast<Trk::LinkToXAODNeutralParticle*>(trklink);
871 if (!linkToXAODTPneutral) {
872 ATH_MSG_WARNING ("Skipping track. Trying to set link to something else than xAOD::TrackParticle or xAOD::NeutralParticle.");
873 } else {
874 //Now set the new link to the new xAOD vertex
875 fittedVertex->addNeutralAtVertex(*linkToXAODTPneutral, VTAV->weight());
876 }
877
878 }
879 } //end of loop
880
881 return fittedVertex;
882
883 }//end of the xAOD constrained fit method
bool vxTrackAtVertexAvailable() const
Check if VxTrackAtVertices are attached to the object.

◆ fit() [24/24]

virtual xAOD::Vertex * Trk::AdaptiveVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const xAOD::Vertex & constraint ) const
inlineoverridevirtual

Definition at line 129 of file AdaptiveVertexFitter.h.

131 {
132 return fit(vectorTrk, std::vector<const xAOD::NeutralParticle*>(), constraint);
133 };

◆ initialize()

StatusCode Trk::AdaptiveVertexFitter::initialize ( )
overridevirtual

Definition at line 47 of file AdaptiveVertexFitter.cxx.

48 {
49 StatusCode s = AlgTool::initialize();
50 if (s.isFailure())
51 {
52 msg(MSG::FATAL) << "AlgTool::initialize() failed" << endmsg;
53 return StatusCode::FAILURE;
54 }
55 if ( m_SeedFinder.retrieve().isFailure() ) {
56 msg(MSG::FATAL) << "Failed to retrieve tool " << m_SeedFinder << endmsg;
57 return StatusCode::FAILURE;
58 }
59 msg(MSG::INFO) << "Retrieved tool " << m_SeedFinder << endmsg;
60
61
62 if ( m_LinearizedTrackFactory.retrieve().isFailure() ) {
63 msg(MSG::FATAL) << "Failed to retrieve tool " << m_LinearizedTrackFactory << endmsg;
64 return StatusCode::FAILURE;
65 }
66 msg(MSG::INFO) << "Retrieved tool " << m_LinearizedTrackFactory << endmsg;
67
68
69 if ( m_TrackCompatibilityEstimator.retrieve().isFailure() ) {
70 msg(MSG::FATAL) << "Failed to retrieve tool " << m_TrackCompatibilityEstimator << endmsg;
71 return StatusCode::FAILURE;
72 }
73 msg(MSG::INFO) << "Retrieved tool " << m_TrackCompatibilityEstimator << endmsg;
74
75
76 if ( m_ImpactPoint3dEstimator.retrieve().isFailure() ) {
77 msg(MSG::FATAL) << "Failed to retrieve tool " << m_ImpactPoint3dEstimator << endmsg;
78 return StatusCode::FAILURE;
79 }
80 msg(MSG::INFO) << "Retrieved tool " << m_ImpactPoint3dEstimator << endmsg;
81
82
83 if ( m_VertexUpdator.retrieve().isFailure() ) {
84 msg(MSG::FATAL) << "Failed to retrieve tool " << m_VertexUpdator << endmsg;
85 return StatusCode::FAILURE;
86 }
87 msg(MSG::INFO) << "Retrieved tool " << m_VertexUpdator << endmsg;
88
89
90 //loading smoother in case required
92 {
93 if ( m_VertexSmoother.retrieve().isFailure() ) {
94 msg(MSG::FATAL) << "Failed to retrieve tool " << m_VertexSmoother << endmsg;
95 return StatusCode::FAILURE;
96 }
97 msg(MSG::INFO) << "Retrieved tool " << m_VertexSmoother << endmsg;
98
99 }//end of smoothing options
100
101 if ( m_AnnealingMaker.retrieve().isFailure() ) {
102 msg(MSG::FATAL) << "Failed to retrieve tool " << m_AnnealingMaker << endmsg;
103 return StatusCode::FAILURE;
104 }
105 msg(MSG::INFO) << "Retrieved tool " << m_AnnealingMaker << endmsg;
106
107
108 return StatusCode::SUCCESS;
109 }
::StatusCode StatusCode
StatusCode definition for legacy code.

Member Data Documentation

◆ m_AnnealingMaker

ToolHandle<Trk::IVertexAnnealingMaker> Trk::AdaptiveVertexFitter::m_AnnealingMaker
private
Initial value:
{
this,
"AnnealingMaker",
"Trk::DetAnnealingMaker"
}

Definition at line 254 of file AdaptiveVertexFitter.h.

254 {
255 this,
256 "AnnealingMaker",
257 "Trk::DetAnnealingMaker"
258 };

◆ m_doSmoothing

bool Trk::AdaptiveVertexFitter::m_doSmoothing
private

True if smoothing after fit iterations has to be performed: otherwise the Smoother AlgoTool provided to the fitter will be ignored.

Definition at line 294 of file AdaptiveVertexFitter.h.

◆ m_ImpactPoint3dEstimator

ToolHandle<Trk::IImpactPoint3dEstimator> Trk::AdaptiveVertexFitter::m_ImpactPoint3dEstimator
private
Initial value:
{
this,
"ImpactPoint3dEstimator",
"Trk::ImpactPoint3dEstimator/ImpactPoint3dEstimator"
}

Definition at line 241 of file AdaptiveVertexFitter.h.

241 {
242 this,
243 "ImpactPoint3dEstimator",
244 "Trk::ImpactPoint3dEstimator/ImpactPoint3dEstimator"
245 };

◆ m_initialError

double Trk::AdaptiveVertexFitter::m_initialError
private

Initial error in form of diagonal elements of the inverse of the covariance matrix (name is misleading: take the error, square it and initialize the variable with its inverse)

Definition at line 279 of file AdaptiveVertexFitter.h.

◆ m_LinearizedTrackFactory

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

Definition at line 232 of file AdaptiveVertexFitter.h.

232 {
233 this,
234 "LinearizedTrackFactory",
235 "Trk::FullLinearizedTrackFactory"
236 };

◆ m_maxDistToLinPoint

double Trk::AdaptiveVertexFitter::m_maxDistToLinPoint
private

Maximum distance of linearization point of track to actual fitted vertex before needing to relinearize (in mm)

Definition at line 271 of file AdaptiveVertexFitter.h.

◆ m_maxIterations

long int Trk::AdaptiveVertexFitter::m_maxIterations
private

Number of maximum iterations.

Definition at line 264 of file AdaptiveVertexFitter.h.

◆ m_onlyzseed

bool Trk::AdaptiveVertexFitter::m_onlyzseed
private

Variable is true if seeding has to be performed only on the z direction.

In this case, as a guess of the initial position in the transverse plane, the x and y position of the beam spot are used.

Definition at line 287 of file AdaptiveVertexFitter.h.

◆ m_SeedFinder

ToolHandle<Trk::IVertexSeedFinder> Trk::AdaptiveVertexFitter::m_SeedFinder
private
Initial value:
{
this,
"SeedFinder",
"Trk::CrossDistancesSeedFinder"
}

Definition at line 227 of file AdaptiveVertexFitter.h.

227 {
228 this,
229 "SeedFinder",
230 "Trk::CrossDistancesSeedFinder"
231 };

◆ m_TrackCompatibilityEstimator

ToolHandle<Trk::IVertexTrackCompatibilityEstimator> Trk::AdaptiveVertexFitter::m_TrackCompatibilityEstimator
private
Initial value:
{ this,
"TrackCompatibilityEstimato",
"Trk::Chi2TrackCompatibilityEstimator" }

Definition at line 238 of file AdaptiveVertexFitter.h.

238 { this,
239 "TrackCompatibilityEstimato",
240 "Trk::Chi2TrackCompatibilityEstimator" };

◆ m_VertexSmoother

ToolHandle<Trk::IVertexSmoother> Trk::AdaptiveVertexFitter::m_VertexSmoother
private
Initial value:
{
this,
"VertexSmoother",
"Trk::DummyVertexSmoother"
}

Definition at line 249 of file AdaptiveVertexFitter.h.

249 {
250 this,
251 "VertexSmoother",
252 "Trk::DummyVertexSmoother"
253 };

◆ m_VertexUpdator

ToolHandle<Trk::IVertexUpdator> Trk::AdaptiveVertexFitter::m_VertexUpdator
private
Initial value:
{ this,
"VertexUpdator",
"Trk::KalmanVertexUpdator" }

Definition at line 246 of file AdaptiveVertexFitter.h.

246 { this,
247 "VertexUpdator",
248 "Trk::KalmanVertexUpdator" };

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