62 m_helper(
"Trk::JetFitterHelper", this),
63 m_updator(
"Trk::KalmanVertexOnJetAxisUpdator", this),
64 m_smoother(
"Trk::KalmanVertexOnJetAxisSmoother", this),
65 m_minDistanceFinder(
"Trk::TrkDistanceFinderNeutralCharged/TrkDistanceFinderNeutralCharged", this),
81 declareInterface< JetFitterRoutines >(
this) ;
95 AthAlgTool::initialize().ignore();
111 return StatusCode::SUCCESS;
117 ATH_MSG_DEBUG (
"initializingToMinDistancesToJetAxis is now implemented! Will converge faster!!! Neutrals are fully supported...");
130 auto const sinRecJetTheta = std::sin(recPosition[
Trk::jet_theta]);
131 auto const sinRecJetPhi = std::sin(recPosition[
Trk::jet_phi]);
132 auto const cosRecJetTheta = std::cos(recPosition[
Trk::jet_theta]);
133 auto const cosRecJetPhi = std::cos(recPosition[
Trk::jet_phi]);
135 auto const absRecJetTheta = std::abs(recPosition[
Trk::jet_theta]);
136 auto const abssinRecJetTheta = std::abs(sinRecJetTheta);
137 auto const abscosRecJetTheta = std::abs(cosRecJetTheta);
140 sinRecJetPhi*sinRecJetTheta,
146 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate->
getVerticesOnJetAxis();
148 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
149 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
151 if (associatedVertices.empty()) {
155 std::stringstream
msg;
157 throw std::runtime_error(
msg.str());
161 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
163 if (myVertex!=
nullptr) {
165 const std::vector<VxTrackAtVertex*> & tracksAtVertex=myVertex->
getTracksAtVertex();
166 if (tracksAtVertex.size()>1) {
167 ATH_MSG_DEBUG(
"Warning in JetFitterInitializationHelper.Number of tracks at vertex is bigger than one, "
168 <<
"even during initialization phase. Skipping this vertex (already initialized)..." );
170 else if (tracksAtVertex.empty())
172 ATH_MSG_WARNING(
"No track at vertex. Internal fitter error. Contact author (GP) ... " );
178 ATH_MSG_VERBOSE(
" pointer to initialPerigee: " << tracksAtVertex[0]->initialPerigee() );
185 double distOnAxis=-999.;
186 std::pair<Amg::Vector3D,double>
result;
190 double R=distOnAxis*sinRecJetTheta;
191 double Z=distOnAxis*cosRecJetTheta;
196 if (absRecJetTheta>1e-8)
198 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, R=" << R <<
", setting to R= " <<
m_maxR );
199 distOnAxis=
m_maxR /abssinRecJetTheta;
203 Z=distOnAxis*cosRecJetTheta;
206 if (abscosRecJetTheta>1e-8)
208 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, Z=" << Z <<
", setting to Z= " <<
m_maxZ );
209 distOnAxis=
m_maxZ / cosRecJetTheta;
213 linPositions[numRow(myVertex->
getNumVertex())]=distOnAxis;
221 ATH_MSG_DEBUG (
"initializingToMinDistancesToJetAxis for vertex number... " <<
222 myVertex->
getNumVertex() <<
" to distance " << distOnAxis <<
223 " distance to axis " <<
result.second);
226 else if (
dynamic_cast<const Trk::NeutralPerigee*
>((tracksAtVertex[0]->initialPerigee()))!=
nullptr)
228 double distOnAxis=-999.;
229 std::pair<Amg::Vector3D,double>
result;
238 double R=distOnAxis*sinRecJetTheta;
239 double Z=distOnAxis*cosRecJetTheta;
244 if (absRecJetTheta>1e-8)
246 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, R=" << R <<
", setting to R= " <<
m_maxR );
247 distOnAxis=
m_maxR / abssinRecJetTheta;
251 Z=distOnAxis*cosRecJetTheta;
254 if (abscosRecJetTheta>1e-8)
256 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, Z=" << Z <<
", setting to Z= " <<
m_maxZ );
257 distOnAxis=
m_maxZ / cosRecJetTheta;
261 linPositions[numRow(myVertex->
getNumVertex())]=distOnAxis;
262 ATH_MSG_DEBUG(
"initializingToMinDistancesToJetAxis for vertex from NEUTRAL number... " <<
264 distOnAxis <<
" distance to axis " <<
result.second );
269 ATH_MSG_WARNING(
"Could not cast to neither CHARGED or NEUTRAL! This error is not FATAL" );
273 ATH_MSG_WARNING(
"Warning in JetFitterInitializationHelper.Inconsistency found. Pointer to VxVertexOnJetAxis should be different from zero. Skipping track..." );
274 throw (
"Warning in JetFitterInitializationHelper.Inconsistency found. Pointer to VxVertexOnJetAxis should be different from zero. Skipping track...");
281 ATH_MSG_DEBUG (
"No Associated Vertices found! no initialization to minimum distance is possible.");
286 int num_maxiterations,
287 bool treat_sign_flip,
288 int num_signflip_maxiterations,
289 double deltachi2_convergence)
const {
293 if (!isInitialized) {
294 ATH_MSG_DEBUG (
"JetFitter found the candidate was not correctly initialized. Not proceeding with the fitt...");
302 int num_iteration_signflip=0;
303 double lastchi2=-99.;
304 bool converged=
false;
306 if (treat_sign_flip) {
323 num_iteration_signflip+=1;
331 auto const absActLastChi2 = std::abs(actualchi2-lastchi2);
333#ifdef JetFitterRoutines_DEBUG
334 ATH_MSG_DEBUG(
" last chi2 " << lastchi2 <<
" actual chi2 " << actualchi2 <<
" difference " <<
335 absActLastChi2<<
" < " << deltachi2_convergence <<
" ? " <<
" ndf " << myFitQuality.
numberDoF() );
338 if (absActLastChi2<deltachi2_convergence) {
349 }
while ((!converged)&&num_iteration_signflip<num_signflip_maxiterations);
353 ATH_MSG_VERBOSE(
" For sign flip treatment there was convergence after " << num_iteration_signflip );
358#ifdef JetFitterRoutines_DEBUG
392 auto const absActLastChi2 = std::abs(actualchi2-lastchi2);
395#ifdef JetFitterRoutines_DEBUG
396 ATH_MSG_DEBUG(
" without sign flip: last chi2 " << lastchi2 <<
" actual chi2 " << actualchi2 <<
" difference " <<
397 absActLastChi2 <<
" < " << deltachi2_convergence <<
" ? " <<
" ndf " << myFitQuality.
numberDoF() );
401 if (absActLastChi2<deltachi2_convergence) {
411 }
while ((!converged)&&num_iteration<num_maxiterations);
414 ATH_MSG_VERBOSE(
" Fit without sign flip treatment there was convergence after " << num_iteration );
418 #ifdef JetFitterRoutines_DEBUG
422 if (num_iteration>=num_maxiterations)
424 ATH_MSG_DEBUG(
"There wasn't convergence in JetFitter after: " << num_maxiterations );
432 if (myDebugInfo!=
nullptr) {
452 const std::vector<VxTrackAtVertex*> & primaryVectorTracks=myPrimary->
getTracksAtVertex();
454 const std::vector<VxTrackAtVertex*>::const_iterator primaryVectorTracksBegin=primaryVectorTracks.begin();
455 const std::vector<VxTrackAtVertex*>::const_iterator primaryVectorTracksEnd=primaryVectorTracks.end();
457 for (std::vector<VxTrackAtVertex*>::const_iterator primaryVectorIter=primaryVectorTracksBegin;
458 primaryVectorIter!=primaryVectorTracksEnd;++primaryVectorIter) {
463 m_updator->add(*primaryVectorIter,myPrimary,myJetCandidate);
465 m_updator->addWithFastUpdate(*primaryVectorIter,myPrimary,myJetCandidate);
478 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate->
getVerticesOnJetAxis();
480 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
481 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
483 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
487 const std::vector<VxTrackAtVertex*> & tracksAtVertex=(*VtxIter)->getTracksAtVertex();
489 const std::vector<VxTrackAtVertex*>::const_iterator TracksBegin=tracksAtVertex.begin();
490 const std::vector<VxTrackAtVertex*>::const_iterator TracksEnd=tracksAtVertex.end();
492 for (std::vector<VxTrackAtVertex*>::const_iterator TrackVectorIter=TracksBegin;
493 TrackVectorIter!=TracksEnd;++TrackVectorIter) {
498 m_updator->add(*TrackVectorIter,*VtxIter,myJetCandidate);
500 m_updator->addWithFastUpdate(*TrackVectorIter,*VtxIter,myJetCandidate);
521 m_smoother->fastUpdate(myPrimary,myJetCandidate);
524 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate->
getVerticesOnJetAxis();
526 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
527 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
529 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
533 m_smoother->fastUpdate(*VtxIter,myJetCandidate);
547 if (myPrimary==
nullptr) {
548 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!");
559 const std::vector<VxTrackAtVertex*>& primaryVectorTracks =
562 sizeprimary = primaryVectorTracks.size();
564 ok = (std::find(primaryVectorTracks.begin(),
565 primaryVectorTracks.end(),
566 nullptr) == primaryVectorTracks.end());
569 "proceeding with the fit!");
578 const std::vector<VxVertexOnJetAxis*>& tracksOfVertex =
582 return (pVertex ==
nullptr) or (pVertex->getNumVertex() < 0);
585 (std::find_if(tracksOfVertex.begin(), tracksOfVertex.end(), badVertex) ==
586 tracksOfVertex.end());
589 "One of the VxTrackAtVertex is a null pointer or uninitialized. Not "
590 "proceeding with the fit!");
598 if (tracksOfVertex.empty()&&sizeprimary==0) {
599 ATH_MSG_DEBUG(
"No tracks at primary, no tracks on jet axis. Not proceeding with the fit!" );
608 if (
static_cast<unsigned int>(tracksOfVertex.size()+5)!=
static_cast<unsigned int>(myPosition.rows())) {
610 <<
" components while " << tracksOfVertex.size()+5
611 <<
" are expected. Not proceeding with the fit " );
617 if (myPosition.rows()!=myErrorMatrix.rows()) {
618 ATH_MSG_WARNING (
"The dimension of the position vector and the covariance matrix does not match. Not performing fit...");
623 for (
int i=0;i<myPosition.rows();i++) {
624 if (std::abs(myErrorMatrix(i,i))<1e-20) {
625 ATH_MSG_WARNING (
"Value of cov matrix component n. " << i <<
" has a value smaller than 1e-8. Not considered as possible. Not performing fit...");
645 if (firstVertex==PrimaryVertex) {
648 if (secondVertex==PrimaryVertex) {
677 m_helper->performKalmanConstraintToBePrimaryVertex(copyOfRecVertexPositions,
694 ATH_MSG_WARNING (
" In the compatibility estimation chi2: " <<
chi2 <<
" ndf " << ndf <<
" giving back 0 prob ");
695 return std::pair<double,bool>(0,isshifted);
698 return std::pair<double,bool>(TMath::Prob(
chi2,(
int)std::floor(ndf+0.5)),isshifted);
710 double oldchi2=copyOfRecVertexQuality.
chiSquared();
711 double oldndf=copyOfRecVertexQuality.
numberDoF();
723 m_helper->performKalmanConstraintToMergeVertices(copyOfRecVertexPositions,
729 bool isshifted=std::pow((phinew-phiold)/phierr,2)+std::pow((thetanew-thetaold)/thetaerr,2)>
m_maxDRshift*
m_maxDRshift;
741 ATH_MSG_WARNING (
"In the compatibility estimation chi2: " <<
chi2 <<
" ndf " << ndf <<
" giving back 0 prob");
742 return std::pair<double,bool>(0,isshifted);
745 return std::pair<double,bool>(TMath::Prob(
chi2,(
int)std::floor(ndf+0.5)),isshifted);
753 int num_maxiterations,
754 bool treat_sign_flip,
755 int num_signflip_maxiterations,
756 double deltachi2_convergence)
const {
759 if (firstVertex==
nullptr||secondVertex==
nullptr||myJetCandidate==
nullptr) {
760 ATH_MSG_WARNING (
"zero pointer given to the full probability estimation. No estimation performed, zero prob returned ");
770 std::map<const VxVertexOnJetAxis*,VxVertexOnJetAxis*> oldToNewVtxPointers;
773 const std::vector<VxVertexOnJetAxis*> vectorOfOldJetCand=myJetCandidate->
getVerticesOnJetAxis();
774 const std::vector<VxVertexOnJetAxis*> vectorOfNewJetCand=newJetCandidate.
getVerticesOnJetAxis();
779 if (primaryOfFirst==
nullptr||primaryOfSecond==
nullptr) {
780 ATH_MSG_WARNING (
"Empty primary vertex found when estimating fullProbOfMerging. 0 prob returned.");
784 oldToNewVtxPointers[primaryOfFirst]=primaryOfSecond;
786 unsigned int sizeOfVertices=vectorOfOldJetCand.size();
787 if (vectorOfNewJetCand.size()!=sizeOfVertices) {
788 ATH_MSG_WARNING (
"Old and new track of vertices do not match during fullProbOfMerging. 0 prob returned.");
792 for (
unsigned int s=0;s<sizeOfVertices;s++) {
795 if (pointer1==
nullptr||pointer2==
nullptr) {
796 ATH_MSG_WARNING (
"One of the pointers of the original or copied vector of vertices is empty during fullProbOfMerging. Skipping it...");
798 oldToNewVtxPointers[pointer1]=pointer2;
806 if (newFirstVertex==
nullptr||newSecondVertex==
nullptr) {
807 ATH_MSG_WARNING (
"No correspondence to the given firstVertex or secondVertex in fullProbOfMerging. Returning 0 prob.");
820 num_signflip_maxiterations,
821 deltachi2_convergence);
825#ifdef JetFitterRoutines_DEBUG
835 int num_maxiterations,
836 bool treat_sign_flip,
837 int num_signflip_maxiterations,
838 double deltachi2_convergence,
839 double threshold_probability)
const {
844 num_signflip_maxiterations,
845 deltachi2_convergence,
846 threshold_probability);
855 bool fullcomputation,
856 int num_maxiterations,
857 bool treat_sign_flip,
858 int num_signflip_maxiterations,
859 double deltachi2_convergence,
860 double threshold_probability)
const {
862 if (myJetCandidate==
nullptr) {
863 ATH_MSG_WARNING(
"VxJetCandidate provided is a zero pointer. No compatibility table calculated." );
869 if (clusteringTablePtr!=
nullptr) {
870 delete clusteringTablePtr;
874 double highestprobability(0.);
878 if (primaryVertex==
nullptr) {
879 ATH_MSG_WARNING(
"VxJetCandidate provided has no primary vertex. No compatibility table calculated." );
888 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=tracksOnJetAxis.begin();
889 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=tracksOnJetAxis.end();
891 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;
892 VtxIter!=VtxEnd;++VtxIter) {
900 (*VtxIter)->getNumVertex() <<
" is " << fastProbabilityAndNonLinearity.first);
902#ifdef JetFitterRoutines_DEBUG2
903 ATH_MSG_DEBUG(
"Fast probability of merging between primary and " <<
904 (*VtxIter)->getNumVertex() <<
" is " << fastProbabilityAndNonLinearity.first <<
" and is max DR " <<
905 fastProbabilityAndNonLinearity.second );
908 if (fullcomputation) {
909 if (fastProbabilityAndNonLinearity.first>threshold_probability) {
910 if (fastProbabilityAndNonLinearity.first>highestprobability/100.&&fastProbabilityAndNonLinearity.second) {
913 myJetCandidate,num_maxiterations,
915 num_signflip_maxiterations,
916 deltachi2_convergence);
919#ifdef JetFitterRoutines_DEBUG2
920 ATH_MSG_DEBUG(
"Full probability of merging with primary is " << fullProbability );
923 ATH_MSG_DEBUG (
"Full probability of merging with primary is " << fullProbability);
928 if (fullProbability>highestprobability) {
929 highestprobability=fullProbability;
931 (*VtxIter)->setCompatibilityToPrimaryVtx(fullProbability);
934 (*VtxIter)->setCompatibilityToPrimaryVtx(fastProbabilityAndNonLinearity.first);
937 (*VtxIter)->setCompatibilityToPrimaryVtx(fastProbabilityAndNonLinearity.first);
940 if (fastProbabilityAndNonLinearity.first>threshold_probability) {
942 if (fastProbabilityAndNonLinearity.first>highestprobability) {
943 highestprobability=fastProbabilityAndNonLinearity.first;
946 (*VtxIter)->setCompatibilityToPrimaryVtx(fastProbabilityAndNonLinearity.first);
952 for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator VtxIter2=VtxBegin;
953 VtxIter2!=VtxEnd;++VtxIter2) {
954 for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator VtxIter1=VtxBegin;
955 VtxIter1!=VtxIter2;++VtxIter1) {
963 ATH_MSG_VERBOSE (
"Fast probability of merging between vtx n " << (*VtxIter1)->getNumVertex()<<
964 " and " << (*VtxIter2)->getNumVertex() <<
" is " <<
965 fastProbabilityAndNonLinearity.first <<
" and is max DR " <<
966 fastProbabilityAndNonLinearity.second);
968#ifdef JetFitterRoutines_DEBUG2
969 ATH_MSG_DEBUG(
"Fast probability of merging between vtx n " << (*VtxIter1)->getNumVertex() <<
" and " <<
970 (*VtxIter2)->getNumVertex() <<
" is " << fastProbabilityAndNonLinearity.first <<
" and is max DR " <<
971 fastProbabilityAndNonLinearity.second );
973 if (fullcomputation) {
974 if (fastProbabilityAndNonLinearity.first>threshold_probability) {
975 if (fastProbabilityAndNonLinearity.first>highestprobability/100.&&fastProbabilityAndNonLinearity.second) {
977 myJetCandidate,num_maxiterations,
979 num_signflip_maxiterations,
980 deltachi2_convergence);
983#ifdef JetFitterRoutines_DEBUG2
984 ATH_MSG_DEBUG(
"Full probability of merging is " << fullProbability );
987 ATH_MSG_VERBOSE (
"Full probability of merging is " << fullProbability);
992 if (fullProbability>highestprobability) {
993 highestprobability=fullProbability;
1000 if (fastProbabilityAndNonLinearity.first>threshold_probability) {
1002 if (fastProbabilityAndNonLinearity.first>highestprobability) {
1003 highestprobability=fastProbabilityAndNonLinearity.first;
1015 ATH_MSG_WARNING (
"YOU ARE deleting the primary vertex. This is not possible... ");
1029 Amg::VectorX reducedRecPositions=deleteRowFromVector(recPosition,numbVertex);
1030 Amg::VectorX reducedLinPositions=deleteRowFromVector(linPosition,numbVertex);
1031 Amg::VectorX reducedConstraintPositions=deleteRowFromVector(constraintPosition,numbVertex);
1032 Amg::MatrixX reducedCovPositions=deleteRowFromSymMatrix(covPosition,numbVertex);
1033 Amg::MatrixX reducedConstraintCovPositions=deleteRowFromSymMatrix(covConstraintPosition,numbVertex);
1036 reducedCovPositions,
1039 reducedConstraintCovPositions,
1048 std::vector<VxTrackAtVertex*>* tracksAtJetCandidate(myJetCandidate->
vxTrackAtVertex());
1054 const std::vector<VxTrackAtVertex*> & tracksAtVtx(vertexToDelete->
getTracksAtVertex());
1056 const std::vector<VxTrackAtVertex*>::const_iterator TracksAtVtxBegin=tracksAtVtx.begin();
1057 const std::vector<VxTrackAtVertex*>::const_iterator TracksAtVtxEnd=tracksAtVtx.end();
1059 int numberOfTracksBefore=tracksAtJetCandidate->size();
1060 int numberOfTracksToDelete=tracksAtVtx.size();
1062 for (std::vector<VxTrackAtVertex*>::const_iterator TracksAtVtxIter=TracksAtVtxBegin;
1063 TracksAtVtxIter!=TracksAtVtxEnd;
1064 ++TracksAtVtxIter) {
1067 std::vector<VxTrackAtVertex*>::iterator TracksBegin=tracksAtJetCandidate->begin();
1068 std::vector<VxTrackAtVertex*>::iterator TracksEnd=tracksAtJetCandidate->end();
1069 for (std::vector<VxTrackAtVertex*>::iterator TracksIter=TracksBegin;TracksIter!=TracksEnd;) {
1071 if (*TracksIter==*TracksAtVtxIter) {
1073 TracksIter=tracksAtJetCandidate->erase(TracksIter);
1076 TracksEnd=tracksAtJetCandidate->end();
1084 if (numberOfTracksBefore-numberOfTracksToDelete!=(
int)myJetCandidate->
vxTrackAtVertex()->size()) {
1085 ATH_MSG_DEBUG(
" MISMATCH in JetFitterRoutines: the jetcandidate had: " << numberOfTracksBefore <<
" tracks " <<
1086 " and " << numberOfTracksToDelete <<
" to delete = " << myJetCandidate->
vxTrackAtVertex()->size() <<
" tracks left! " );
1092 std::vector<VxVertexOnJetAxis*> copyOfVerticesAtJetCandidate=myJetCandidate->
getVerticesOnJetAxis();
1094 const std::vector<VxVertexOnJetAxis*>::iterator VerticesBegin=copyOfVerticesAtJetCandidate.begin();
1095 std::vector<VxVertexOnJetAxis*>::iterator VerticesEnd=copyOfVerticesAtJetCandidate.end();
1102 for (std::vector<VxVertexOnJetAxis*>::iterator VerticesIter=VerticesBegin;VerticesIter!=VerticesEnd;) {
1103 if ((*VerticesIter)==vertexToDelete) {
1104 delete *VerticesIter;
1105 VerticesIter=copyOfVerticesAtJetCandidate.erase(VerticesIter);
1106 VerticesEnd=copyOfVerticesAtJetCandidate.end();
1115 ATH_MSG_WARNING(
"Could not find the vertex to delete... Very strange... Check!!! " );
1132 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate.
getVerticesOnJetAxis();
1133 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
1134 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
1136 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
1138 if (myVertex!=
nullptr) {
1140 double distOnAxis=linPositions[numRow(myVertex->
getNumVertex())];
1142 auto const sinLinJetTheta = std::sin(linPositions[
Trk::jet_theta]);
1143 auto const cosLinJetTheta = std::cos(linPositions[
Trk::jet_theta]);
1145 auto const absLinJetTheta = std::abs(linPositions[
Trk::jet_theta]);
1146 auto const abssinLinJetTheta = std::abs(sinLinJetTheta);
1147 auto const abscosLinJetTheta = std::abs(cosLinJetTheta);
1149 double R=distOnAxis*sinLinJetTheta;
1150 double Z=distOnAxis*cosLinJetTheta;
1153 if (absLinJetTheta>1e-8)
1155 ATH_MSG_DEBUG (
" Closest distance of track to jet axis is outside ID envelope, R=" << R <<
", setting to R= " <<
m_maxR);
1156 distOnAxis=
m_maxR / abssinLinJetTheta;
1160 Z=distOnAxis*cosLinJetTheta;
1163 if (abscosLinJetTheta>1e-8)
1165 ATH_MSG_DEBUG(
" Closest distance of track to jet axis is outside ID envelope, Z=" << Z <<
", setting to Z= " <<
m_maxZ );
1166 distOnAxis=
m_maxZ / cosLinJetTheta;
1170 linPositions[numRow(myVertex->
getNumVertex())]=distOnAxis;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(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