63 m_helper(
"Trk::JetFitterHelper", this),
64 m_updator(
"Trk::KalmanVertexOnJetAxisUpdator", this),
65 m_smoother(
"Trk::KalmanVertexOnJetAxisSmoother", this),
66 m_minDistanceFinder(
"Trk::TrkDistanceFinderNeutralCharged/TrkDistanceFinderNeutralCharged", this),
82 declareInterface< JetFitterRoutines >(
this) ;
96 AthAlgTool::initialize().ignore();
112 return StatusCode::SUCCESS;
118 ATH_MSG_DEBUG (
"initializingToMinDistancesToJetAxis is now implemented! Will converge faster!!! Neutrals are fully supported...");
131 auto const sinRecJetTheta = std::sin(recPosition[
Trk::jet_theta]);
132 auto const sinRecJetPhi = std::sin(recPosition[
Trk::jet_phi]);
133 auto const cosRecJetTheta = std::cos(recPosition[
Trk::jet_theta]);
134 auto const cosRecJetPhi = std::cos(recPosition[
Trk::jet_phi]);
136 auto const absRecJetTheta = std::abs(recPosition[
Trk::jet_theta]);
137 auto const abssinRecJetTheta = std::abs(sinRecJetTheta);
138 auto const abscosRecJetTheta = std::abs(cosRecJetTheta);
141 sinRecJetPhi*sinRecJetTheta,
147 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate->
getVerticesOnJetAxis();
149 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
150 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
152 if (associatedVertices.empty()) {
155 if (!readHandle.
isValid() or !fieldCondObj) {
156 std::stringstream
msg;
158 throw std::runtime_error(
msg.str());
162 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
164 if (myVertex!=
nullptr) {
166 const std::vector<VxTrackAtVertex*> & tracksAtVertex=myVertex->
getTracksAtVertex();
167 if (tracksAtVertex.size()>1) {
168 ATH_MSG_DEBUG(
"Warning in JetFitterInitializationHelper.Number of tracks at vertex is bigger than one, "
169 <<
"even during initialization phase. Skipping this vertex (already initialized)..." );
171 else if (tracksAtVertex.empty())
173 ATH_MSG_WARNING(
"No track at vertex. Internal fitter error. Contact author (GP) ... " );
179 ATH_MSG_VERBOSE(
" pointer to initialPerigee: " << tracksAtVertex[0]->initialPerigee() );
186 double distOnAxis=-999.;
187 std::pair<Amg::Vector3D,double> result;
191 double R=distOnAxis*sinRecJetTheta;
192 double Z=distOnAxis*cosRecJetTheta;
197 if (absRecJetTheta>1e-8)
199 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, R=" << R <<
", setting to R= " <<
m_maxR );
200 distOnAxis=
m_maxR /abssinRecJetTheta;
204 Z=distOnAxis*cosRecJetTheta;
207 if (abscosRecJetTheta>1e-8)
209 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, Z=" << Z <<
", setting to Z= " <<
m_maxZ );
210 distOnAxis=
m_maxZ / cosRecJetTheta;
214 linPositions[numRow(myVertex->
getNumVertex())]=distOnAxis;
222 ATH_MSG_DEBUG (
"initializingToMinDistancesToJetAxis for vertex number... " <<
223 myVertex->
getNumVertex() <<
" to distance " << distOnAxis <<
224 " distance to axis " << result.second);
227 else if (
dynamic_cast<const Trk::NeutralPerigee*
>((tracksAtVertex[0]->initialPerigee()))!=
nullptr)
229 double distOnAxis=-999.;
230 std::pair<Amg::Vector3D,double> result;
239 double R=distOnAxis*sinRecJetTheta;
240 double Z=distOnAxis*cosRecJetTheta;
245 if (absRecJetTheta>1e-8)
247 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, R=" << R <<
", setting to R= " <<
m_maxR );
248 distOnAxis=
m_maxR / abssinRecJetTheta;
252 Z=distOnAxis*cosRecJetTheta;
255 if (abscosRecJetTheta>1e-8)
257 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, Z=" << Z <<
", setting to Z= " <<
m_maxZ );
258 distOnAxis=
m_maxZ / cosRecJetTheta;
262 linPositions[numRow(myVertex->
getNumVertex())]=distOnAxis;
263 ATH_MSG_DEBUG(
"initializingToMinDistancesToJetAxis for vertex from NEUTRAL number... " <<
265 distOnAxis <<
" distance to axis " << result.second );
270 ATH_MSG_WARNING(
"Could not cast to neither CHARGED or NEUTRAL! This error is not FATAL" );
274 ATH_MSG_WARNING(
"Warning in JetFitterInitializationHelper.Inconsistency found. Pointer to VxVertexOnJetAxis should be different from zero. Skipping track..." );
275 throw (
"Warning in JetFitterInitializationHelper.Inconsistency found. Pointer to VxVertexOnJetAxis should be different from zero. Skipping track...");
282 ATH_MSG_DEBUG (
"No Associated Vertices found! no initialization to minimum distance is possible.");
287 int num_maxiterations,
288 bool treat_sign_flip,
289 int num_signflip_maxiterations,
290 double deltachi2_convergence)
const {
294 if (!isInitialized) {
295 ATH_MSG_DEBUG (
"JetFitter found the candidate was not correctly initialized. Not proceeding with the fitt...");
303 int num_iteration_signflip=0;
304 double lastchi2=-99.;
305 bool converged=
false;
307 if (treat_sign_flip) {
324 num_iteration_signflip+=1;
332 auto const absActLastChi2 = std::abs(actualchi2-lastchi2);
334#ifdef JetFitterRoutines_DEBUG
335 ATH_MSG_DEBUG(
" last chi2 " << lastchi2 <<
" actual chi2 " << actualchi2 <<
" difference " <<
336 absActLastChi2<<
" < " << deltachi2_convergence <<
" ? " <<
" ndf " << myFitQuality.
numberDoF() );
339 if (absActLastChi2<deltachi2_convergence) {
350 }
while ((!converged)&&num_iteration_signflip<num_signflip_maxiterations);
354 ATH_MSG_VERBOSE(
" For sign flip treatment there was convergence after " << num_iteration_signflip );
359#ifdef JetFitterRoutines_DEBUG
393 auto const absActLastChi2 = std::abs(actualchi2-lastchi2);
396#ifdef JetFitterRoutines_DEBUG
397 ATH_MSG_DEBUG(
" without sign flip: last chi2 " << lastchi2 <<
" actual chi2 " << actualchi2 <<
" difference " <<
398 absActLastChi2 <<
" < " << deltachi2_convergence <<
" ? " <<
" ndf " << myFitQuality.
numberDoF() );
402 if (absActLastChi2<deltachi2_convergence) {
412 }
while ((!converged)&&num_iteration<num_maxiterations);
415 ATH_MSG_VERBOSE(
" Fit without sign flip treatment there was convergence after " << num_iteration );
419 #ifdef JetFitterRoutines_DEBUG
423 if (num_iteration>=num_maxiterations)
425 ATH_MSG_DEBUG(
"There wasn't convergence in JetFitter after: " << num_maxiterations );
433 if (myDebugInfo!=
nullptr) {
453 const std::vector<VxTrackAtVertex*> & primaryVectorTracks=myPrimary->
getTracksAtVertex();
455 const std::vector<VxTrackAtVertex*>::const_iterator primaryVectorTracksBegin=primaryVectorTracks.begin();
456 const std::vector<VxTrackAtVertex*>::const_iterator primaryVectorTracksEnd=primaryVectorTracks.end();
458 for (std::vector<VxTrackAtVertex*>::const_iterator primaryVectorIter=primaryVectorTracksBegin;
459 primaryVectorIter!=primaryVectorTracksEnd;++primaryVectorIter) {
464 m_updator->add(*primaryVectorIter,myPrimary,myJetCandidate);
466 m_updator->addWithFastUpdate(*primaryVectorIter,myPrimary,myJetCandidate);
479 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate->
getVerticesOnJetAxis();
481 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
482 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
484 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
488 const std::vector<VxTrackAtVertex*> & tracksAtVertex=(*VtxIter)->getTracksAtVertex();
490 const std::vector<VxTrackAtVertex*>::const_iterator TracksBegin=tracksAtVertex.begin();
491 const std::vector<VxTrackAtVertex*>::const_iterator TracksEnd=tracksAtVertex.end();
493 for (std::vector<VxTrackAtVertex*>::const_iterator TrackVectorIter=TracksBegin;
494 TrackVectorIter!=TracksEnd;++TrackVectorIter) {
499 m_updator->add(*TrackVectorIter,*VtxIter,myJetCandidate);
501 m_updator->addWithFastUpdate(*TrackVectorIter,*VtxIter,myJetCandidate);
522 m_smoother->fastUpdate(myPrimary,myJetCandidate);
525 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate->
getVerticesOnJetAxis();
527 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
528 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
530 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
534 m_smoother->fastUpdate(*VtxIter,myJetCandidate);
548 if (myPrimary==
nullptr) {
549 ATH_MSG_WARNING(
"No primary vertex found in VxJetCandidate class. Initialization was not done correctly..." );
555 ATH_MSG_WARNING(
"Numvertex of primary vertex not correctly initialized. "
556 "Not proceeding with the fit!");
560 const std::vector<VxTrackAtVertex*>& primaryVectorTracks =
563 sizeprimary = primaryVectorTracks.size();
564 ok = std::ranges::none_of(primaryVectorTracks,[](
const auto* track) {
return track ==
nullptr; });
566 ATH_MSG_WARNING(
"At least one of the VxTrackAtVertex is a null pointer. Not "
567 "proceeding with the fit!");
575 const std::vector<VxVertexOnJetAxis*>& tracksOfVertex =
579 return (pVertex ==
nullptr) or (pVertex->getNumVertex() < 0);
582 (std::find_if(tracksOfVertex.begin(), tracksOfVertex.end(), badVertex) ==
583 tracksOfVertex.end());
586 "One of the VxTrackAtVertex is a null pointer or uninitialized. Not "
587 "proceeding with the fit!");
595 if (tracksOfVertex.empty()&&sizeprimary==0) {
596 ATH_MSG_DEBUG(
"No tracks at primary, no tracks on jet axis. Not proceeding with the fit!" );
605 if (
static_cast<unsigned int>(tracksOfVertex.size()+5)!=
static_cast<unsigned int>(myPosition.rows())) {
607 <<
" components while " << tracksOfVertex.size()+5
608 <<
" are expected. Not proceeding with the fit " );
614 if (myPosition.rows()!=myErrorMatrix.rows()) {
615 ATH_MSG_WARNING (
"The dimension of the position vector and the covariance matrix does not match. Not performing fit...");
620 for (
int i=0;i<myPosition.rows();i++) {
621 if (std::abs(myErrorMatrix(i,i))<1e-20) {
622 ATH_MSG_WARNING (
"Value of cov matrix component n. " << i <<
" has a value smaller than 1e-8. Not considered as possible. Not performing fit...");
642 if (firstVertex==PrimaryVertex) {
645 if (secondVertex==PrimaryVertex) {
674 m_helper->performKalmanConstraintToBePrimaryVertex(copyOfRecVertexPositions,
691 ATH_MSG_WARNING (
" In the compatibility estimation chi2: " <<
chi2 <<
" ndf " << ndf <<
" giving back 0 prob ");
692 return std::pair<double,bool>(0,isshifted);
695 return std::pair<double,bool>(TMath::Prob(
chi2,(
int)std::floor(ndf+0.5)),isshifted);
707 double oldchi2=copyOfRecVertexQuality.
chiSquared();
708 double oldndf=copyOfRecVertexQuality.
numberDoF();
720 m_helper->performKalmanConstraintToMergeVertices(copyOfRecVertexPositions,
726 bool isshifted=std::pow((phinew-phiold)/phierr,2)+std::pow((thetanew-thetaold)/thetaerr,2)>
m_maxDRshift*
m_maxDRshift;
738 ATH_MSG_WARNING (
"In the compatibility estimation chi2: " <<
chi2 <<
" ndf " << ndf <<
" giving back 0 prob");
739 return std::pair<double,bool>(0,isshifted);
742 return std::pair<double,bool>(TMath::Prob(
chi2,(
int)std::floor(ndf+0.5)),isshifted);
750 int num_maxiterations,
751 bool treat_sign_flip,
752 int num_signflip_maxiterations,
753 double deltachi2_convergence)
const {
756 if (firstVertex==
nullptr||secondVertex==
nullptr||myJetCandidate==
nullptr) {
757 ATH_MSG_WARNING (
"zero pointer given to the full probability estimation. No estimation performed, zero prob returned ");
767 std::map<const VxVertexOnJetAxis*,VxVertexOnJetAxis*> oldToNewVtxPointers;
770 const std::vector<VxVertexOnJetAxis*> vectorOfOldJetCand=myJetCandidate->
getVerticesOnJetAxis();
771 const std::vector<VxVertexOnJetAxis*> vectorOfNewJetCand=newJetCandidate.
getVerticesOnJetAxis();
776 if (primaryOfFirst==
nullptr||primaryOfSecond==
nullptr) {
777 ATH_MSG_WARNING (
"Empty primary vertex found when estimating fullProbOfMerging. 0 prob returned.");
781 oldToNewVtxPointers[primaryOfFirst]=primaryOfSecond;
783 unsigned int sizeOfVertices=vectorOfOldJetCand.size();
784 if (vectorOfNewJetCand.size()!=sizeOfVertices) {
785 ATH_MSG_WARNING (
"Old and new track of vertices do not match during fullProbOfMerging. 0 prob returned.");
789 for (
unsigned int s=0;s<sizeOfVertices;s++) {
792 if (pointer1==
nullptr||pointer2==
nullptr) {
793 ATH_MSG_WARNING (
"One of the pointers of the original or copied vector of vertices is empty during fullProbOfMerging. Skipping it...");
795 oldToNewVtxPointers[pointer1]=pointer2;
803 if (newFirstVertex==
nullptr||newSecondVertex==
nullptr) {
804 ATH_MSG_WARNING (
"No correspondence to the given firstVertex or secondVertex in fullProbOfMerging. Returning 0 prob.");
817 num_signflip_maxiterations,
818 deltachi2_convergence);
822#ifdef JetFitterRoutines_DEBUG
832 int num_maxiterations,
833 bool treat_sign_flip,
834 int num_signflip_maxiterations,
835 double deltachi2_convergence,
836 double threshold_probability)
const {
841 num_signflip_maxiterations,
842 deltachi2_convergence,
843 threshold_probability);
852 bool fullcomputation,
853 int num_maxiterations,
854 bool treat_sign_flip,
855 int num_signflip_maxiterations,
856 double deltachi2_convergence,
857 double threshold_probability)
const {
859 if (myJetCandidate==
nullptr) {
860 ATH_MSG_WARNING(
"VxJetCandidate provided is a zero pointer. No compatibility table calculated." );
866 if (clusteringTablePtr!=
nullptr) {
867 delete clusteringTablePtr;
871 double highestprobability(0.);
875 if (primaryVertex==
nullptr) {
876 ATH_MSG_WARNING(
"VxJetCandidate provided has no primary vertex. No compatibility table calculated." );
885 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=tracksOnJetAxis.begin();
886 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=tracksOnJetAxis.end();
888 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;
889 VtxIter!=VtxEnd;++VtxIter) {
897 (*VtxIter)->getNumVertex() <<
" is " << fastProbabilityAndNonLinearity.first);
899#ifdef JetFitterRoutines_DEBUG2
900 ATH_MSG_DEBUG(
"Fast probability of merging between primary and " <<
901 (*VtxIter)->getNumVertex() <<
" is " << fastProbabilityAndNonLinearity.first <<
" and is max DR " <<
902 fastProbabilityAndNonLinearity.second );
905 if (fullcomputation) {
906 if (fastProbabilityAndNonLinearity.first>threshold_probability) {
907 if (fastProbabilityAndNonLinearity.first>highestprobability/100.&&fastProbabilityAndNonLinearity.second) {
910 myJetCandidate,num_maxiterations,
912 num_signflip_maxiterations,
913 deltachi2_convergence);
916#ifdef JetFitterRoutines_DEBUG2
917 ATH_MSG_DEBUG(
"Full probability of merging with primary is " << fullProbability );
920 ATH_MSG_DEBUG (
"Full probability of merging with primary is " << fullProbability);
925 if (fullProbability>highestprobability) {
926 highestprobability=fullProbability;
928 (*VtxIter)->setCompatibilityToPrimaryVtx(fullProbability);
931 (*VtxIter)->setCompatibilityToPrimaryVtx(fastProbabilityAndNonLinearity.first);
934 (*VtxIter)->setCompatibilityToPrimaryVtx(fastProbabilityAndNonLinearity.first);
937 if (fastProbabilityAndNonLinearity.first>threshold_probability) {
939 if (fastProbabilityAndNonLinearity.first>highestprobability) {
940 highestprobability=fastProbabilityAndNonLinearity.first;
943 (*VtxIter)->setCompatibilityToPrimaryVtx(fastProbabilityAndNonLinearity.first);
949 for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator VtxIter2=VtxBegin;
950 VtxIter2!=VtxEnd;++VtxIter2) {
951 for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator VtxIter1=VtxBegin;
952 VtxIter1!=VtxIter2;++VtxIter1) {
960 ATH_MSG_VERBOSE (
"Fast probability of merging between vtx n " << (*VtxIter1)->getNumVertex()<<
961 " and " << (*VtxIter2)->getNumVertex() <<
" is " <<
962 fastProbabilityAndNonLinearity.first <<
" and is max DR " <<
963 fastProbabilityAndNonLinearity.second);
965#ifdef JetFitterRoutines_DEBUG2
966 ATH_MSG_DEBUG(
"Fast probability of merging between vtx n " << (*VtxIter1)->getNumVertex() <<
" and " <<
967 (*VtxIter2)->getNumVertex() <<
" is " << fastProbabilityAndNonLinearity.first <<
" and is max DR " <<
968 fastProbabilityAndNonLinearity.second );
970 if (fullcomputation) {
971 if (fastProbabilityAndNonLinearity.first>threshold_probability) {
972 if (fastProbabilityAndNonLinearity.first>highestprobability/100.&&fastProbabilityAndNonLinearity.second) {
974 myJetCandidate,num_maxiterations,
976 num_signflip_maxiterations,
977 deltachi2_convergence);
980#ifdef JetFitterRoutines_DEBUG2
981 ATH_MSG_DEBUG(
"Full probability of merging is " << fullProbability );
984 ATH_MSG_VERBOSE (
"Full probability of merging is " << fullProbability);
989 if (fullProbability>highestprobability) {
990 highestprobability=fullProbability;
997 if (fastProbabilityAndNonLinearity.first>threshold_probability) {
999 if (fastProbabilityAndNonLinearity.first>highestprobability) {
1000 highestprobability=fastProbabilityAndNonLinearity.first;
1012 ATH_MSG_WARNING (
"YOU ARE deleting the primary vertex. This is not possible... ");
1026 Amg::VectorX reducedRecPositions=deleteRowFromVector(recPosition,numbVertex);
1027 Amg::VectorX reducedLinPositions=deleteRowFromVector(linPosition,numbVertex);
1028 Amg::VectorX reducedConstraintPositions=deleteRowFromVector(constraintPosition,numbVertex);
1029 Amg::MatrixX reducedCovPositions=deleteRowFromSymMatrix(covPosition,numbVertex);
1030 Amg::MatrixX reducedConstraintCovPositions=deleteRowFromSymMatrix(covConstraintPosition,numbVertex);
1033 reducedCovPositions,
1036 reducedConstraintCovPositions,
1045 std::vector<VxTrackAtVertex*>* tracksAtJetCandidate(myJetCandidate->
vxTrackAtVertex());
1051 const std::vector<VxTrackAtVertex*> & tracksAtVtx(vertexToDelete->
getTracksAtVertex());
1053 const std::vector<VxTrackAtVertex*>::const_iterator TracksAtVtxBegin=tracksAtVtx.begin();
1054 const std::vector<VxTrackAtVertex*>::const_iterator TracksAtVtxEnd=tracksAtVtx.end();
1056 int numberOfTracksBefore=tracksAtJetCandidate->size();
1057 int numberOfTracksToDelete=tracksAtVtx.size();
1059 for (std::vector<VxTrackAtVertex*>::const_iterator TracksAtVtxIter=TracksAtVtxBegin;
1060 TracksAtVtxIter!=TracksAtVtxEnd;
1061 ++TracksAtVtxIter) {
1064 std::vector<VxTrackAtVertex*>::iterator TracksBegin=tracksAtJetCandidate->begin();
1065 std::vector<VxTrackAtVertex*>::iterator TracksEnd=tracksAtJetCandidate->end();
1066 for (std::vector<VxTrackAtVertex*>::iterator TracksIter=TracksBegin;TracksIter!=TracksEnd;) {
1068 if (*TracksIter==*TracksAtVtxIter) {
1070 TracksIter=tracksAtJetCandidate->erase(TracksIter);
1073 TracksEnd=tracksAtJetCandidate->end();
1081 if (numberOfTracksBefore-numberOfTracksToDelete!=(
int)myJetCandidate->
vxTrackAtVertex()->size()) {
1082 ATH_MSG_DEBUG(
" MISMATCH in JetFitterRoutines: the jetcandidate had: " << numberOfTracksBefore <<
" tracks " <<
1083 " and " << numberOfTracksToDelete <<
" to delete = " << myJetCandidate->
vxTrackAtVertex()->size() <<
" tracks left! " );
1089 std::vector<VxVertexOnJetAxis*> copyOfVerticesAtJetCandidate=myJetCandidate->
getVerticesOnJetAxis();
1091 const std::vector<VxVertexOnJetAxis*>::iterator VerticesBegin=copyOfVerticesAtJetCandidate.begin();
1092 std::vector<VxVertexOnJetAxis*>::iterator VerticesEnd=copyOfVerticesAtJetCandidate.end();
1099 for (std::vector<VxVertexOnJetAxis*>::iterator VerticesIter=VerticesBegin;VerticesIter!=VerticesEnd;) {
1100 if ((*VerticesIter)==vertexToDelete) {
1101 delete *VerticesIter;
1102 VerticesIter=copyOfVerticesAtJetCandidate.erase(VerticesIter);
1103 VerticesEnd=copyOfVerticesAtJetCandidate.end();
1112 ATH_MSG_WARNING(
"Could not find the vertex to delete... Very strange... Check!!! " );
1129 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate.
getVerticesOnJetAxis();
1130 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
1131 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
1133 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
1135 if (myVertex!=
nullptr) {
1137 double distOnAxis=linPositions[numRow(myVertex->
getNumVertex())];
1139 auto const sinLinJetTheta = std::sin(linPositions[
Trk::jet_theta]);
1140 auto const cosLinJetTheta = std::cos(linPositions[
Trk::jet_theta]);
1142 auto const absLinJetTheta = std::abs(linPositions[
Trk::jet_theta]);
1143 auto const abssinLinJetTheta = std::abs(sinLinJetTheta);
1144 auto const abscosLinJetTheta = std::abs(cosLinJetTheta);
1146 double R=distOnAxis*sinLinJetTheta;
1147 double Z=distOnAxis*cosLinJetTheta;
1150 if (absLinJetTheta>1e-8)
1152 ATH_MSG_DEBUG (
" Closest distance of track to jet axis is outside ID envelope, R=" << R <<
", setting to R= " <<
m_maxR);
1153 distOnAxis=
m_maxR / abssinLinJetTheta;
1157 Z=distOnAxis*cosLinJetTheta;
1160 if (abscosLinJetTheta>1e-8)
1162 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, Z=" << Z <<
", setting to Z= " <<
m_maxZ );
1163 distOnAxis=
m_maxZ / cosLinJetTheta;
1167 linPositions[numRow(myVertex->
getNumVertex())]=distOnAxis;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h).
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
double chiSquared() const
returns the of the overall track fit
ToolHandle< TrkDistanceFinderNeutralNeutral > m_minDistanceFinderNeutral
std::pair< double, bool > fastProbabilityOfMerging(const VxVertexOnJetAxis *, const VxVertexOnJetAxis *, const VxJetCandidate *) const
Calculates in a very fast way the probability two vertices along the jet axis to be compatible with e...
ToolHandle< KalmanVertexOnJetAxisUpdator > m_updator
ToolHandle< TrkDistanceFinderNeutralCharged > m_minDistanceFinder
std::pair< double, bool > fastProbabilityOfMergingWithPrimary(const VxVertexOnJetAxis *otherVertex, const VxJetCandidate *myJetCandidate) const
Internal method to calculate fast probability of merging, for merging with primary vertex.
ToolHandle< KalmanVertexOnJetAxisSmoother > m_smoother
JetFitterRoutines(const std::string &t, const std::string &n, const IInterface *p)
Constructor.
std::pair< double, bool > fastProbabilityOfMergingNoPrimary(const VxVertexOnJetAxis *, const VxVertexOnJetAxis *, const VxJetCandidate *myJetCandidate) const
Internal method to calculate fast probability of merging, for merging with non primary vertex.
void smoothAllVertices(VxJetCandidate *myJetCandidate) const
triggers the smoothing of all vertices (the tracks in the fit are updated using the constraint provid...
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCacheCondObjInputKey
virtual StatusCode initialize() override
void fillTableWithFastProbOfMerging(VxJetCandidate *myJetCandidate) const
The VxClusteringTable of the VxJetCandidate provided in input is created, computing all the needed pr...
void fillTableWithProbOfMerging(VxJetCandidate *myJetCandidate, bool fullcomputation, int num_maxiterations=20, bool treat_sign_flip=true, int num_signflip_maxiterations=10, double deltachi2_convergence=1e-2, double threshold_probability=1e-3) const
Internal method to fill the VxClusteringTable of the VxJetCandidate object, independently on if the f...
void updateAllVertices(VxJetCandidate *myJetCandidate) const
One iteration of the Kalman Updated of all tracks to the actual fit is performed.
~JetFitterRoutines()
Destructor.
bool checkJetCandidate(VxJetCandidate *) const
Internal method to provide a check if the VxJetCandidate has been initialized in a consistent way.
double fullProbabilityOfMerging(const VxVertexOnJetAxis *firstVertex, const VxVertexOnJetAxis *secondVertex, const VxJetCandidate *myJetCandidate, int num_maxiterations=20, bool treat_sign_flip=true, int num_signflip_maxiterations=10, double deltachi2_convergence=1e-2) const
Calculates in a complete way the probability two vertices along the jet axis to be compatible with ea...
void fillTableWithFullProbOfMerging(VxJetCandidate *myJetCandidate, int num_maxiterations=20, bool treat_sign_flip=true, int num_signflip_maxiterations=10, double deltachi2_convergence=1e-3, double threshold_probability=1e-5) const
The VxClusteringTable of the VxJetCandidate provided in input is created, computing all the needed pr...
void initializeToMinDistancesToJetAxis(VxJetCandidate *) const
This method provides the initialization of all the tracks in the fit to the position of minimum dista...
bool m_noPrimaryVertexRefit
void performTheFit(VxJetCandidate *myJetCandidate, int num_maxiterations=30, bool treat_sign_flip=true, int num_signflip_maxiterations=30, double deltachi2_convergence=0.001) const
This is the method where the fit is actually done.
void deleteVertexFromJetCandidate(VxVertexOnJetAxis *vertexToDelete, VxJetCandidate *myJetCandidate) const
Deltes a vertex from the VxJetCandidate, doing everything is needed to preserve the internal coherenc...
ToolHandle< JetFitterInitializationHelper > m_initializationHelper
void copyRecoPositionsToLinearizationPositions(VxJetCandidate &myJetCandidate) const
Method to copy new reco positions to linearization positions after checking new positions are inside ...
ToolHandle< JetFitterHelper > m_helper
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
Amg::MatrixX const & covariancePosition() const
return the covDeltaV matrix of the vertex fit
const Trk::FitQuality & fitQuality() const
Fit quality access method.
VertexPositions class to represent and store a vertex.
void setPosition(const Amg::VectorX &)
const Amg::VectorX & position() const
return position of vertex
std::vector< Trk::VxTrackAtVertex * > * vxTrackAtVertex(void)
Unconst pointer to the vector of tracks Required by some of the vertex fitters.
void setCompatibilityOfTo(const PairOfVxVertexOnJetAxis &, float)
Set compatibility of a new pair of tracks.
Trk::VxClusteringTable *& getClusteringTable(void)
void setLinearizationVertexPositions(const Trk::VertexPositions &)
const Trk::VertexPositions & getLinearizationVertexPositions() const
void setVerticesOnJetAxis(const std::vector< VxVertexOnJetAxis * > &)
const std::vector< VxVertexOnJetAxis * > & getVerticesOnJetAxis(void) const
const Trk::RecVertexPositions & getConstraintVertexPositions() const
const VxVertexOnJetAxis * getPrimaryVertex(void) const
void setConstraintVertexPositions(const Trk::RecVertexPositions &)
Trk::VxJetFitterDebugInfo *& getDebugInfo(void)
const Trk::RecVertexPositions & getRecVertexPositions() const
void setRecVertexPositions(const Trk::RecVertexPositions &)
void setSignFlipNumFitIterations(int num)
void setNumFitIterations(int num)
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
VxVertexOnJetAxis inherits from Vertex.
const Trk::FitQuality & fitQuality() const
Fit quality access method.
int getNumVertex(void) const
Get Method for NumVertex.
const std::vector< VxTrackAtVertex * > & getTracksAtVertex(void) const
get Tracks At Vertex Method
void setCompatibilityToPrimaryVtx(float)
set compatibility to the primary vertex
double chi2(TH1 *h0, TH1 *h1)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Ensure that the ATLAS eigen extensions are properly loaded.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersT< NeutralParametersDim, Neutral, PerigeeSurface > NeutralPerigee
@ jet_zv
position x,y,z of primary vertex