42 declareInterface<IVertexFitter>(
this);
49 StatusCode s = AlgTool::initialize();
52 msg(MSG::FATAL) <<
"AlgTool::initialize() failed" <<
endmsg;
53 return StatusCode::FAILURE;
57 return StatusCode::FAILURE;
64 return StatusCode::FAILURE;
71 return StatusCode::FAILURE;
78 return StatusCode::FAILURE;
85 return StatusCode::FAILURE;
95 return StatusCode::FAILURE;
103 return StatusCode::FAILURE;
108 return StatusCode::SUCCESS;
114 const std::vector<const Trk::TrackParameters*>& perigeeList,
115 const std::vector<const Trk::NeutralParameters*>& neutralPerigeeList,
119 bool IsStartingPoint)
const
123 if ( (perigeeList.size() + neutralPerigeeList.size())<2 && !IsConstraint ) {
124 msg(MSG::WARNING) <<
"Not enough tracks (>2) to fit in this event (without constraint)." <<
endmsg;
127 if ((perigeeList.size() + neutralPerigeeList.size())<1 && IsConstraint) {
128 msg(MSG::WARNING) <<
"Not enough tracks (>1) to fit in this event (with constraint)." <<
endmsg;
135 if (IsStartingPoint) {
136 SeedPoint=startingPoint;
138 if (perigeeList.size()>1) {
140 SeedPoint=
m_SeedFinder->findSeed(perigeeList,&constraint);
145 else if (IsConstraint) {
146 SeedPoint=constraint.position();
155 SeedPoint=constraint.position();
163 std::vector<VxTrackAtVertex> theLinTracks;
165 std::vector<const Trk::TrackParameters*>::const_iterator perigeesBegin=perigeeList.begin();
166 std::vector<const Trk::TrackParameters*>::const_iterator perigeesEnd=perigeeList.end();
168 ATH_MSG_DEBUG(
"Inside fitter with track perigee parameters.");
172 for (std::vector<const Trk::TrackParameters*>::const_iterator perigeesIter=perigeesBegin;perigeesIter!=perigeesEnd;++perigeesIter) {
179 ATH_MSG_DEBUG(
"Track #" << myDebugNTrk++ <<
". TrackParameters: x = " << (*perigeesIter)->position().x() <<
", y = "<< (*perigeesIter)->position().y() <<
", z = "<< (*perigeesIter)->position().z() <<
". Covariance: " << *(*perigeesIter)->covariance());
187 msg(MSG::DEBUG) <<
"Adding compatibility to vertex information failed. Newton distance finder didn't converge..." <<
endmsg;
190 theLinTracks.push_back(*LinTrackToAdd);
192 delete LinTrackToAdd;
196 std::vector<const Trk::NeutralParameters*>::const_iterator neutralPerigeesBegin=neutralPerigeeList.begin();
197 std::vector<const Trk::NeutralParameters*>::const_iterator neutralPerigeesEnd =neutralPerigeeList.end();
199 ATH_MSG_DEBUG(
"Inside fitter with neutral perigee parameters.");
201 int myDebugNNeutral(0);
202 for (std::vector<const Trk::NeutralParameters*>::const_iterator neutralPerigeesIter=neutralPerigeesBegin;neutralPerigeesIter!=neutralPerigeesEnd;++neutralPerigeesIter) {
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());
213 msg(MSG::DEBUG) <<
"Adding compatibility to vertex information failed. Newton distance finder didn't converge..." <<
endmsg;
216 theLinTracks.push_back(*LinTrackToAdd);
218 delete LinTrackToAdd;
225 if(msgLvl(MSG::VERBOSE))
237 ConstraintVertex.
setPosition( constraint.position() );
242 startingCovMatrix.setIdentity();
251 return dothefit(ConstraintVertex,SeedPoint,theLinTracks);
258 const std::vector<const Trk::Track*>& VectorTrk,
262 bool IsStartingPoint)
const
265 ATH_MSG_DEBUG(
"Called Adaptive vertex with Trk::Track. N. Tracks = " << VectorTrk.size());
267 std::vector<const Trk::TrackParameters*> perigeeList;
268 for (
const auto *iter : VectorTrk) {
269 if (std::isnan(iter->perigeeParameters()->parameters()[
Trk::d0])) {
272 perigeeList.push_back(iter->perigeeParameters());
275 xAOD::Vertex * FittedVertex =
_fit(perigeeList,constraint,startingPoint,IsConstraint,IsStartingPoint);
277 if (FittedVertex==
nullptr) {
284 const std::vector<const Trk::Track*>::const_iterator trkbegin=VectorTrk.begin();
285 const std::vector<const Trk::Track*>::const_iterator trkend=VectorTrk.end();
287 const std::vector<VxTrackAtVertex>::iterator vtxbegin=FittedVertex->
vxTrackAtVertex().begin();
288 const std::vector<VxTrackAtVertex>::iterator vtxend=FittedVertex->
vxTrackAtVertex().end();
290 for (std::vector<const Trk::Track*>::const_iterator trkiter=trkbegin;trkiter!=trkend;++trkiter)
292 for (std::vector<Trk::VxTrackAtVertex>::iterator vtxiter=vtxbegin;vtxiter!=vtxend;++vtxiter)
294 if(((*trkiter)->perigeeParameters()->momentum() -
295 (*vtxiter).initialPerigee()->momentum()).mag()< 1e-8 &&
296 ((*trkiter)->perigeeParameters()->position() -
297 (*vtxiter).initialPerigee()->position()).mag()< 1e-8)
303 (*vtxiter).setOrigTrack(linkTT);
322 std::vector<Trk::VxTrackAtVertex>& myLinTracks)
const
345 if(msgLvl(MSG::VERBOSE))
351 std::vector<Trk::VxTrackAtVertex>::iterator lintracksBegin = ActualVertex->
vxTrackAtVertex().begin();
352 std::vector<Trk::VxTrackAtVertex>::iterator lintracksEnd = ActualVertex->
vxTrackAtVertex().end();
354 std::vector<Trk::VxTrackAtVertex>::iterator iter;
356 bool relinearization =
false;
364 if(msgLvl(MSG::DEBUG))
370 if(msgLvl(MSG::DEBUG))
372 msg(MSG::DEBUG) <<
"New fit step: step number " << num_steps <<
endmsg;
378 relinearization=
false;
380 relinearization=
true;
381 if(msgLvl(MSG::DEBUG))
383 msg(MSG::DEBUG) <<
"Actual vertex too far away from linearization point: have to linearize tracks again" <<
endmsg;
388 for (iter=lintracksBegin;iter!=lintracksEnd;++iter) {
393 msg(MSG::DEBUG) <<
"Adding compatibility to vertex information failed. Newton distance finder didn't converge..." <<
endmsg;
404 for (iter=lintracksBegin;iter!=lintracksEnd;++iter) {
410 iter->setWeight(
m_AnnealingMaker->getWeight( astate, iter->vtxCompatibility() ) );
411 if(msgLvl(MSG::VERBOSE))
413 msg(MSG::VERBOSE) <<
"Before annealing: " << iter->vtxCompatibility() <<
414 " Annealing RESULT is:" << iter->weight() <<
" at T: " <<
422 for (iter=lintracksBegin;iter!=lintracksEnd;++iter) {
423 if(msgLvl(MSG::VERBOSE))
425 msg(MSG::VERBOSE) <<
"Updating vertex with a new track" <<
endmsg;
429 if ( iter->weight() > 1e-3 ) {
432 if ( iter->linState() ==
nullptr) {
434 if(msgLvl(MSG::VERBOSE))
436 msg(MSG::VERBOSE) <<
"Linearizing track for the first time" <<
endmsg;
440 ATH_MSG_DEBUG(
"Linearized track to Seed Point. " << *iter );
441 }
else if (relinearization) {
443 if(msgLvl(MSG::VERBOSE))
445 msg(MSG::VERBOSE) <<
"Relinearizing track " <<
endmsg;
449 ActualSeedPosition=NewVertex;
450 ATH_MSG_DEBUG(
"Linearized track to new seed Point " << NewVertex <<
". " << *iter );
454 if(msgLvl(MSG::VERBOSE))
456 msg(MSG::VERBOSE) <<
"Weight lower than 1e-3, so the track will not be considered anymore" <<
endmsg;
461 msg(MSG::WARNING) <<
"You have just lost a track" <<
endmsg;
466 if(msgLvl(MSG::DEBUG))
468 msg(MSG::DEBUG) <<
"New position x: " << ActualVertex->
position().x() <<
" y: " << ActualVertex->
position().y()
473 NewVertex = ActualVertex->
position();
476 if(msgLvl(MSG::VERBOSE))
478 msg(MSG::VERBOSE) <<
"Now calling one step of annealing" <<
endmsg;
495 for (iter=lintracksBegin;iter!=lintracksEnd;++iter) {
502 if ( iter->initialPerigee() )
503 iter->setPerigeeAtVertex( ( iter->initialPerigee() )->clone() );
504 else if ( iter->initialNeutralPerigee() )
505 iter->setPerigeeAtVertex( ( iter->initialNeutralPerigee() )->clone() );
509 if(msgLvl(MSG::DEBUG))
512 <<
"the ndf of the vertex is at fit end: " << ActualVertex->
numberDoF() <<
endmsg;
522 const std::vector<const Trk::TrackParameters*>& perigeeList,
523 const std::vector<const Trk::NeutralParameters*>& neutralPerigeeList,
527 return _fit(perigeeList,neutralPerigeeList,
xAOD::Vertex(),startingPoint,
false,
true);
532 const std::vector<const Trk::TrackParameters*>& perigeeList,
533 const std::vector<const Trk::NeutralParameters*>& neutralPerigeeList,
536 return _fit(perigeeList,neutralPerigeeList,constraint,Amg::Vector3D::Zero(),
true);
541 const std::vector<const Trk::TrackParameters*>& perigeeList,
542 const std::vector<const Trk::NeutralParameters*>& neutralPerigeeList,
546 return _fit(perigeeList,neutralPerigeeList,constraint,startingPoint,
true,
true);
551 const std::vector<const Trk::TrackParameters*>& perigeeList,
552 const std::vector<const Trk::NeutralParameters*>& neutralPerigeeList)
const
559 const std::vector<const Trk::TrackParameters*>& perigeeList,
562 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
563 return fit(perigeeList, neutralPerigeeList, startingPoint);
568 const std::vector<const Trk::TrackParameters*>& perigeeList,
571 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
572 return fit(perigeeList, neutralPerigeeList, constraint);
577 const std::vector<const Trk::TrackParameters*>& perigeeList,
581 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
582 return fit(perigeeList, neutralPerigeeList, constraint, startingPoint);
587 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
588 return fit(perigeeList,neutralPerigeeList);
595 bool IsStartingPoint)
const {
596 const std::vector<const Trk::NeutralParameters*> neutralPerigeeList;
597 return _fit(perigeeList, neutralPerigeeList, constraint, startingPoint, IsConstraint, IsStartingPoint);
605 const std::vector<const xAOD::TrackParticle*>& vectorTrk,
606 const std::vector<const xAOD::NeutralParticle*>& vectorNeut,
610 if (vectorTrk.empty()) {
611 msg(MSG::INFO) <<
"Empty vector of tracks passed" <<
endmsg;
615 if (vectorNeut.empty()) {
616 msg(MSG::VERBOSE) <<
"Empty vector of neutrals passed" <<
endmsg;
620 std::vector<const Trk::TrackParameters*> measuredPerigees;
622 for (
const auto *i : vectorTrk) {
625 if (tmpMeasPer !=
nullptr)
626 measuredPerigees.push_back(tmpMeasPer);
629 <<
"Failed to dynamic_cast this track parameters to perigee"
635 std::vector<const Trk::NeutralParameters*> measuredNeutralPerigees;
637 for (
const auto *i : vectorNeut) {
640 if (tmpMeasPer !=
nullptr)
641 measuredNeutralPerigees.push_back(tmpMeasPer);
644 <<
"Failed to dynamic_cast this neutral parameters to perigee"
650 measuredNeutralPerigees,
657 if (fittedVertex ==
nullptr) {
662 ->vxTrackAtVertexAvailable())
667 for (
unsigned int i = 0; i < vectorTrk.size(); ++i) {
672 vectorTrk[i]->container());
676 <<
"Failed to set the EL for this particle correctly" <<
endmsg;
680 <<
"Failed to identify a container for this TP" <<
endmsg;
687 for (
unsigned int i = 0; i < vectorNeut.size(); ++i) {
691 vectorNeut[i]->container());
695 <<
"Failed to set the EL for this particle correctly" <<
endmsg;
699 <<
"Failed to identify a container for this TP" <<
endmsg;
713 for (
unsigned int i = 0; i < VTAVsize; ++i) {
718 "VxTrackAtVertex is not found");
737 if (!linkToXAODTPneutral) {
739 "Skipping track. Trying to set link to something else than "
740 "xAOD::TrackParticle or xAOD::NeutralParticle.");
755 const std::vector<const xAOD::TrackParticle*>& vectorTrk,
756 const std::vector<const xAOD::NeutralParticle*>& vectorNeut,
760 if(vectorTrk.empty())
762 msg(MSG::INFO)<<
"Empty vector of tracks passed"<<
endmsg;
766 if(vectorNeut.empty())
768 msg(MSG::INFO)<<
"Empty vector of neutrals passed"<<
endmsg;
772 std::vector<const Trk::TrackParameters*> measuredPerigees;
774 for(
const auto *i : vectorTrk)
778 if(tmpMeasPer!=
nullptr) measuredPerigees.push_back(tmpMeasPer);
779 else msg(MSG::INFO)<<
"Failed to dynamic_cast this track parameters to perigee"<<
endmsg;
783 std::vector<const Trk::NeutralParameters*> measuredNeutralPerigees;
785 for(
const auto *i : vectorNeut)
789 if(tmpMeasPer!=
nullptr) measuredNeutralPerigees.push_back(tmpMeasPer);
790 else msg(MSG::INFO)<<
"Failed to dynamic_cast this neutral parameters to perigee"<<
endmsg;
803 for(
unsigned int i = 0; i <vectorTrk.size(); ++i)
812 msg(MSG::WARNING)<<
"Failed to set the EL for this particle correctly"<<
endmsg;
815 msg(MSG::WARNING)<<
"Failed to identify a container for this TP"<<
endmsg;
823 for(
unsigned int i = 0; i <vectorNeut.size(); ++i)
831 msg(MSG::WARNING)<<
"Failed to set the EL for this particle correctly"<<
endmsg;
834 msg(MSG::WARNING)<<
"Failed to identify a container for this NP"<<
endmsg;
838 ( fittedVertex->
vxTrackAtVertex() )[vectorTrk.size()+i].setOrigTrack(linkTT);
848 for (
unsigned int i = 0 ; i < VTAVsize ; ++i)
853 ATH_MSG_WARNING (
" Trying to set link to xAOD::TrackParticle. The VxTrackAtVertex is not found");
871 if (!linkToXAODTPneutral) {
872 ATH_MSG_WARNING (
"Skipping track. Trying to set link to something else than xAOD::TrackParticle or xAOD::NeutralParticle.");
Scalar perp() const
perp method - perpendicular length
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
ElementLink implementation for ROOT usage.
bool setElement(ElementType element)
Set to point to an element.
bool toIndexedElement(BaseConstReference data, index_type elemID, IProxyDict *sg=0)
Set the link to an element given by index and pointer to container.
void makePrivateStore()
Create a new (empty) private store for this object.
virtual ~AdaptiveVertexFitter()
destructor
ToolHandle< Trk::IVertexTrackCompatibilityEstimator > m_TrackCompatibilityEstimator
double m_initialError
Initial error in form of diagonal elements of the inverse of the covariance matrix (name is misleadin...
ToolHandle< Trk::IImpactPoint3dEstimator > m_ImpactPoint3dEstimator
bool m_doSmoothing
True if smoothing after fit iterations has to be performed: otherwise the Smoother AlgoTool provided ...
AdaptiveVertexFitter(const std::string &t, const std::string &n, const IInterface *p)
default constructor due to Athena interface
bool m_onlyzseed
Variable is true if seeding has to be performed only on the z direction.
ToolHandle< Trk::IVertexSmoother > m_VertexSmoother
virtual StatusCode initialize() override
ToolHandle< Trk::IVertexAnnealingMaker > m_AnnealingMaker
ToolHandle< Trk::IVertexSeedFinder > m_SeedFinder
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.
ToolHandle< Trk::IVertexUpdator > m_VertexUpdator
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...
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_LinearizedTrackFactory
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,...
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.
An abstract class which is meant to represent an element link to the Trk::Track or Trk::TrackParticle...
unsigned int AnnealingState
AUTO - An Undocumented Tracking Object.
Element link to XAOD NeutralParticle.
Element link to XAOD TrackParticle.
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
double weight(void) const
Information about the weight of track in fit (given back by annealing): weight=ndf/2.
const ITrackLink * trackOrParticleLink(void) const
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
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.
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.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
bool vxTrackAtVertexAvailable() const
Check if VxTrackAtVertices are attached to the object.
float chiSquared() const
Returns the of the vertex fit as float.
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
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
Ensure that the ATLAS eigen extensions are properly loaded.
ParametersBase< NeutralParametersDim, Neutral > NeutralParameters
ParametersBase< TrackParametersDim, Charged > TrackParameters
@ NotSpecified
Default value, no explicit type set.
NeutralParticleContainer_v1 NeutralParticleContainer
Definition of the current "NeutralParticle container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".