32 m_maxDistToLinPoint(0.5),
33 m_initialError(0.0001),
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);
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);
142 SeedPoint=m_SeedFinder->findSeed(perigeeList);
145 else if (IsConstraint) {
146 SeedPoint=constraint.position();
154 if (m_onlyzseed&&IsConstraint) {
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());
184 bool success=m_ImpactPoint3dEstimator->addIP3dAtaPlane(*LinTrackToAdd,SeedPoint);
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());
210 bool success = m_ImpactPoint3dEstimator->addIP3dAtaPlane(*LinTrackToAdd,SeedPoint);
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;
237 ConstraintVertex.
setPosition( constraint.position() );
242 startingCovMatrix.setIdentity();
243 startingCovMatrix = startingCovMatrix / m_initialError;
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();
290 for (std::vector<const Trk::Track*>::const_iterator trkiter=trkbegin;trkiter!=trkend;++trkiter)
294 if(((*trkiter)->perigeeParameters()->momentum() -
295 (*vtxiter).initialPerigee()->momentum()).mag()< 1
e-8 &&
296 ((*trkiter)->perigeeParameters()->position() -
297 (*vtxiter).initialPerigee()->position()).mag()< 1
e-8)
303 (*vtxiter).setOrigTrack(linkTT);
322 std::vector<Trk::VxTrackAtVertex>& myLinTracks)
const
356 bool relinearization =
false;
378 relinearization=
false;
380 relinearization=
true;
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() ) );
413 msg(
MSG::VERBOSE) <<
"Before annealing: " << iter->vtxCompatibility() <<
414 " Annealing RESULT is:" << iter->weight() <<
" at T: " <<
422 for (iter=lintracksBegin;iter!=lintracksEnd;++iter) {
429 if ( iter->weight() > 1
e-3 ) {
432 if ( iter->linState() ==
nullptr) {
440 ATH_MSG_DEBUG(
"Linearized track to Seed Point. " << *iter );
441 }
else if (relinearization) {
449 ActualSeedPosition=NewVertex;
450 ATH_MSG_DEBUG(
"Linearized track to new seed Point " << NewVertex <<
". " << *iter );
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;
473 NewVertex = ActualVertex->
position();
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() );
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,
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()) {
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.");