40 declareInterface< JetFitterHelper >(
this) ;
55 std::vector<VxTrackAtVertex*> tracksOfSecondVertex(second.getTracksAtVertex());
57 const std::vector<VxTrackAtVertex*>& tracksOfFirstVertex(first.getTracksAtVertex());
59 const std::vector<VxTrackAtVertex*>::const_iterator tracksBegin=tracksOfFirstVertex.begin();
60 const std::vector<VxTrackAtVertex*>::const_iterator tracksEnd=tracksOfFirstVertex.end();
62 for (std::vector<VxTrackAtVertex*>::const_iterator tracksIter=tracksBegin;
63 tracksIter!=tracksEnd;
66 if (*tracksIter!=
nullptr) {
68 tracksOfSecondVertex.push_back(*tracksIter);
71 ATH_MSG_WARNING(
" addTracksOfFirstVertexToSecondVertex method found an empty pointer for a track of the first vertex. Skipping it..." );
77 second.setTracksAtVertex(std::move(tracksOfSecondVertex));
88 if (position.rows()!=Ckm1.rows()) {
89 ATH_MSG_WARNING (
"Error in performKalmanConstraintToBePrimaryVertex method:" <<
90 " covariance matrix of size " << Ckm1.rows() <<
91 " and vector of VertexPositions do not match. Not performing " <<
92 "any constraint... ");
105 if(Rk_km1.determinant()==0) {
106 ATH_MSG_WARNING (
"The Rk_k-1 matrix inversion will fail - det(Rk)=0 detected."
107 " Constraint to primary vertex failed...");
117 ConstraintInOldPosition(0)=position[numbRow];
119 Amg::VectorX newPosition=position-Kk*ConstraintInOldPosition;
121 Amg::MatrixX newCovPosition=Ckm1-Kk*(2*Gk*Ckm1-Rk_km1*Kk.transpose());
123 double newChi2=positionToUpdate.
fitQuality().
chiSquared()+Rk_km1_inverse.similarityT(ConstraintInOldPosition).determinant();
140 if (position.rows()!=Ckm1.rows()) {
141 ATH_MSG_WARNING(
"Error in performKalmanConstraintToBePrimaryVertex method: " <<
142 "covariance matrix dim " << Ckm1.rows() <<
" and vector of " <<
143 "VertexPositions dim " << position.rows() <<
" do not match."<<
144 " Not performing any constraint... ");
148 int numbRow1(numRow(vertexToConstraint1.
getNumVertex()));
149 int numbRow2(numRow(vertexToConstraint2.
getNumVertex()));
157 AmgMatrix(1,1) Rk_km1=Ckm1.similarity(Gk);
159 if(Rk_km1.determinant() ==0) {
160 ATH_MSG_WARNING (
"The Rk_k-1 matrix inversion will fail - Rk_k=0 detected."
161 " Constraint to primary vertex failed...");
164 AmgMatrix(1,1) Rk_km1_inverse=Rk_km1.inverse();
171 ConstraintInOldPosition(0)=position[numbRow1]-position[numbRow2];
173 Amg::VectorX newPosition=position-Kk*ConstraintInOldPosition;
175 Amg::MatrixX newCovPosition=Ckm1-Kk*(2*Gk*Ckm1-Rk_km1*Kk.transpose());
177 double newChi2=positionToUpdate.
fitQuality().
chiSquared()+Rk_km1_inverse.similarityT(ConstraintInOldPosition).determinant();
211 if (covPosition(numbVertex1,numbVertex1)!=0&&covPosition(numbVertex2,numbVertex2)!=0) {
212 linPosition(numbVertex1)=(recPosition(numbVertex1)/covPosition(numbVertex1,numbVertex1)+
213 recPosition(numbVertex2)/covPosition(numbVertex2,numbVertex2))/
214 (1./covPosition(numbVertex1,numbVertex1)+1./covPosition(numbVertex2,numbVertex2));
216 ATH_MSG_WARNING (
"one of the vertices to merge has error on position 0. should not happen, however: --> proceeding...");
220 Amg::VectorX reducedRecPositions=deleteRowFromVector(recPosition,numbVertex2);
221 Amg::VectorX reducedLinPositions=deleteRowFromVector(linPosition,numbVertex2);
222 Amg::VectorX reducedConstraintPositions=deleteRowFromVector(constraintPosition,numbVertex2);
223 Amg::MatrixX reducedCovPositions=deleteRowFromSymMatrix(covPosition,numbVertex2);
224 Amg::MatrixX reducedConstraintCovPositions=deleteRowFromSymMatrix(covConstraintPosition,numbVertex2);
230 reducedConstraintCovPositions,
238 std::vector<VxVertexOnJetAxis*> copyOfVerticesAtJetCandidate=myJetCandidate.
getVerticesOnJetAxis();
240 const std::vector<VxVertexOnJetAxis*>::iterator VerticesBegin=copyOfVerticesAtJetCandidate.begin();
241 std::vector<VxVertexOnJetAxis*>::iterator VerticesEnd=copyOfVerticesAtJetCandidate.end();
245 for (std::vector<VxVertexOnJetAxis*>::iterator VerticesIter=VerticesBegin;VerticesIter!=VerticesEnd;) {
246 if ((*VerticesIter)==&vertex2) {
247 delete *VerticesIter;
248 VerticesIter=copyOfVerticesAtJetCandidate.erase(VerticesIter);
249 VerticesEnd=copyOfVerticesAtJetCandidate.end();
257 ATH_MSG_WARNING (
"Could not find second vertex from which a cluster was created to delete it... Very strange... Check!!! ");
272 if (primaryVertexPtr==
nullptr) {
273 ATH_MSG_WARNING (
"Pointer to the primary vertex is 0. No merging with primary vertex possible.");
289 int numbVertex2=numRow(
vertex.getNumVertex());
292 Amg::VectorX reducedRecPositions=deleteRowFromVector(recPosition,numbVertex2);
293 Amg::VectorX reducedLinPositions=deleteRowFromVector(linPosition,numbVertex2);
294 Amg::VectorX reducedConstraintPositions=deleteRowFromVector(constraintPosition,numbVertex2);
295 Amg::MatrixX reducedCovPositions=deleteRowFromSymMatrix(covPosition,numbVertex2);
296 Amg::MatrixX reducedConstraintCovPositions=deleteRowFromSymMatrix(covConstraintPosition,numbVertex2);
302 reducedConstraintCovPositions,
309 std::vector<VxVertexOnJetAxis*> copyOfVerticesAtJetCandidate=myJetCandidate.
getVerticesOnJetAxis();
311 const std::vector<VxVertexOnJetAxis*>::iterator VerticesBegin=copyOfVerticesAtJetCandidate.begin();
312 std::vector<VxVertexOnJetAxis*>::iterator VerticesEnd=copyOfVerticesAtJetCandidate.end();
316 for (std::vector<VxVertexOnJetAxis*>::iterator VerticesIter=VerticesBegin;VerticesIter!=VerticesEnd;) {
317 if ((*VerticesIter)==&
vertex) {
318 delete *VerticesIter;
319 VerticesIter=copyOfVerticesAtJetCandidate.erase(VerticesIter);
320 VerticesEnd=copyOfVerticesAtJetCandidate.end();
328 ATH_MSG_WARNING (
"Could not find second vertex from which a cluster with the primary vertex was created to delete it... Very strange... Check!!! ");
#define ATH_MSG_WARNING(x)
#define AmgMatrix(rows, cols)
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
void performKalmanConstraintToBePrimaryVertex(RecVertexPositions &positionToUpdate, const VxVertexOnJetAxis &vertexToConstraint) const
Performs a Kalman Update constraining the VxVertexOnJetAxis specified to be merged with the primary v...
void mergeVertexToPrimaryInJetCandidate(VxVertexOnJetAxis &vertex, VxJetCandidate &myJetCandidate) const
Modifies the VxJetCandidate provided, merging the provided VxVertexOnJetAxis into the primary vertex.
~JetFitterHelper()
Destructor.
JetFitterHelper(const std::string &t, const std::string &n, const IInterface *p)
Constructor.
VxVertexOnJetAxis & mergeVerticesInJetCandidate(VxVertexOnJetAxis &vertex1, VxVertexOnJetAxis &vertex2, VxJetCandidate &myJetCandidate) const
Modifies the VxJetCandidate provided, merging the two provided VxVertexOnJetAxis into a single vertex...
void addTracksOfFirstVertexToSecondVertex(const VxVertexOnJetAxis &first, VxVertexOnJetAxis &second) const
Adds tracks from the second VxVertexOnJetAxis to the first one.
void performKalmanConstraintToMergeVertices(RecVertexPositions &positionToUpdate, const VxVertexOnJetAxis &vertexToConstraint1, const VxVertexOnJetAxis &vertexToConstraint2) const
Performs a Kalman Update constraining the two VxVertexOnJetAxis specified to be merged.
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.
const Amg::VectorX & position() const
return position of vertex
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
void setPrimaryVertex(const VxVertexOnJetAxis *)
const VxVertexOnJetAxis * getPrimaryVertex(void) const
void setConstraintVertexPositions(const Trk::RecVertexPositions &)
const Trk::RecVertexPositions & getRecVertexPositions() const
void setRecVertexPositions(const Trk::RecVertexPositions &)
VxVertexOnJetAxis inherits from Vertex.
int getNumVertex(void) const
Get Method for NumVertex.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Ensure that the ATLAS eigen extensions are properly loaded.