CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
VertexDistance3D Class Reference

#include <VertexDistance3D.h>

Inheritance diagram for VertexDistance3D:
VertexDistance

Public Member Functions

VertexDistance3Dclone () const override
 
virtual float compatibility (const reco::Vertex &, const reco::Vertex &) const
 
virtual float compatibility (const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const=0
 
virtual float compatibility (const VertexState &, const VertexState &) const
 
virtual float compatibility (const reco::Vertex &, const VertexState &) const
 
virtual float compatibility (const VertexState &, const reco::Vertex &) const
 
Measurement1D distance (const reco::Vertex &, const VertexState &) const
 
virtual Measurement1D distance (const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const=0
 
Measurement1D distance (const VertexState &, const reco::Vertex &) const
 
Measurement1D distance (const VertexState &, const VertexState &) const
 
Measurement1D distance (const reco::Vertex &, const reco::Vertex &) const
 
Measurement1D signedDistance (const reco::Vertex &primVtx, const reco::Vertex &secVtx, const GlobalVector &momentum) const override
 
 VertexDistance3D ()
 
- Public Member Functions inherited from VertexDistance
virtual float compatibility (const reco::Vertex &, const reco::Vertex &) const
 
virtual float compatibility (const VertexState &, const VertexState &) const
 
virtual float compatibility (const reco::Vertex &, const VertexState &) const
 
virtual float compatibility (const VertexState &, const reco::Vertex &) const
 
Measurement1D distance (const reco::Vertex &, const reco::Vertex &) const
 
Measurement1D distance (const VertexState &, const VertexState &) const
 
Measurement1D distance (const reco::Vertex &, const VertexState &) const
 
Measurement1D distance (const VertexState &, const reco::Vertex &) const
 
virtual ~VertexDistance ()
 

Private Member Functions

float compatibility (const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
 
Measurement1D distance (const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
 

Private Attributes

AlgebraicSymMatrix33 theNullMatrix
 

Additional Inherited Members

Detailed Description

Computes the distance and chi-squared compatibility between two vertices with their 3D positions.

Definition at line 13 of file VertexDistance3D.h.

Constructor & Destructor Documentation

◆ VertexDistance3D()

VertexDistance3D::VertexDistance3D ( )
inline

Definition at line 17 of file VertexDistance3D.h.

Referenced by clone().

17 {}

Member Function Documentation

◆ clone()

VertexDistance3D* VertexDistance3D::clone ( void  ) const
inlineoverridevirtual

Implements VertexDistance.

Definition at line 31 of file VertexDistance3D.h.

References VertexDistance3D().

31 { return new VertexDistance3D(*this); }

◆ compatibility() [1/6]

float VertexDistance::compatibility

Definition at line 51 of file VertexDistance.cc.

51  {
52  return compatibility(GlobalPoint(Basic3DVector<float>(vtx1.position())),
53  GlobalError(vtx1.covariance()),
54  GlobalPoint(Basic3DVector<float>(vtx2.position())),
55  GlobalError(vtx2.covariance()));
56 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
float compatibility(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override

◆ compatibility() [2/6]

float VertexDistance::compatibility

Definition at line 44 of file VertexDistance.cc.

44  {
45  return compatibility(vtx1.position(),
46  vtx1.error(),
47  GlobalPoint(Basic3DVector<float>(vtx2.position())),
48  GlobalError(vtx2.covariance()));
49 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
float compatibility(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override

◆ compatibility() [3/6]

virtual float VertexDistance::compatibility

◆ compatibility() [4/6]

float VertexDistance::compatibility

Definition at line 33 of file VertexDistance.cc.

33  {
34  return compatibility(vtx1.position(), vtx1.error(), vtx2.position(), vtx2.error());
35 }
float compatibility(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override

◆ compatibility() [5/6]

float VertexDistance::compatibility

Definition at line 37 of file VertexDistance.cc.

37  {
38  return compatibility(GlobalPoint(Basic3DVector<float>(vtx1.position())),
39  GlobalError(vtx1.covariance()),
40  vtx2.position(),
41  vtx2.error());
42 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
float compatibility(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override

◆ compatibility() [6/6]

float VertexDistance3D::compatibility ( const GlobalPoint vtx1Position,
const GlobalError vtx1PositionError,
const GlobalPoint vtx2Position,
const GlobalError vtx2PositionError 
) const
overrideprivatevirtual

Implements VertexDistance.

Definition at line 38 of file VertexDistance3D.cc.

References change_name::diff, relativeConstraints::error, Exception, and GlobalErrorBase< T, ErrorWeightType >::matrix().

Referenced by DiMuonVertexMonitor::analyze(), and DiMuonVertexValidation::analyze().

41  {
42  // error matrix of residuals
43  AlgebraicSymMatrix33 err1 = vtx1PositionError.matrix();
44  AlgebraicSymMatrix33 err2 = vtx2PositionError.matrix();
45  AlgebraicSymMatrix33 error = err1 + err2;
46  if (error == theNullMatrix)
47  return FLT_MAX;
48 
49  // position residuals
50  GlobalVector diff = vtx2Position - vtx1Position;
51  AlgebraicVector3 vDiff;
52  vDiff[0] = diff.x();
53  vDiff[1] = diff.y();
54  vDiff[2] = diff.z();
55 
56  // Invert error matrix of residuals
57  bool ifail = !error.InvertChol();
58  if (ifail) {
59  throw cms::Exception("VertexDistance3D::matrix inversion problem");
60  }
61 
62  return ROOT::Math::Similarity(error, vDiff);
63 }
AlgebraicSymMatrix33 theNullMatrix
const AlgebraicSymMatrix33 matrix() const
ROOT::Math::SVector< double, 3 > AlgebraicVector3
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33

◆ distance() [1/6]

virtual Measurement1D VertexDistance::distance

◆ distance() [2/6]

Measurement1D VertexDistance::distance

Definition at line 8 of file VertexDistance.cc.

8  {
9  return distance(vtx1.position(), vtx1.error(), vtx2.position(), vtx2.error());
10 }
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override

◆ distance() [3/6]

Measurement1D VertexDistance::distance

Definition at line 19 of file VertexDistance.cc.

19  {
20  return distance(vtx1.position(),
21  vtx1.error(),
22  GlobalPoint(Basic3DVector<float>(vtx2.position())),
23  GlobalError(vtx2.covariance()));
24 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override

◆ distance() [4/6]

Measurement1D VertexDistance::distance

Definition at line 26 of file VertexDistance.cc.

26  {
27  return distance(GlobalPoint(Basic3DVector<float>(vtx1.position())),
28  GlobalError(vtx1.covariance()),
29  GlobalPoint(Basic3DVector<float>(vtx2.position())),
30  GlobalError(vtx2.covariance()));
31 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override

◆ distance() [5/6]

Measurement1D VertexDistance::distance

Definition at line 12 of file VertexDistance.cc.

12  {
13  return distance(GlobalPoint(Basic3DVector<float>(vtx1.position())),
14  GlobalError(vtx1.covariance()),
15  vtx2.position(),
16  vtx2.error());
17 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override

◆ distance() [6/6]

Measurement1D VertexDistance3D::distance ( const GlobalPoint vtx1Position,
const GlobalError vtx1PositionError,
const GlobalPoint vtx2Position,
const GlobalError vtx2PositionError 
) const
overrideprivatevirtual

Implements VertexDistance.

Definition at line 17 of file VertexDistance3D.cc.

References change_name::diff, submitPVResolutionJobs::err, relativeConstraints::error, GlobalErrorBase< T, ErrorWeightType >::matrix(), and mathSSE::sqrt().

Referenced by DiMuonVertexMonitor::analyze(), DiMuonVertexValidation::analyze(), DiElectronVertexValidation::analyze(), AlignmentTrackFromVertexSelector::findClosestVertex(), DiMuonVertexMonitor::findClosestVertex(), StandaloneTrackMonitor::findClosestVertex(), DiMuonVertexValidation::findClosestVertex(), PF_PU_AssoMapAlgos::GetCleanedKshort(), PF_PU_AssoMapAlgos::GetCleanedLambda(), PF_PU_AssoMapAlgos::GetCleanedNI(), VertexMerging::mergeVertex(), btagbtvdeep::mindistsvpfcand(), TracksClusteringFromDisplacedSeed::nearTracks(), TemplatedVertexMerger< VTX >::produce(), VertexTableProducer::produce(), BJetEnergyRegressionVarProducer< T >::produce(), TemplatedInclusiveVertexFinder< InputContainer, VTX >::produce(), IPProducer< Container, Base, Helper >::produce(), TrackVertexArbitration< VTX >::trackVertexArbitrator(), and btagbtvdeep::vertexD3d().

20  {
21  AlgebraicSymMatrix33 error = vtx1PositionError.matrix() + vtx2PositionError.matrix();
22  GlobalVector diff = vtx1Position - vtx2Position;
23  AlgebraicVector3 vDiff;
24  vDiff[0] = diff.x();
25  vDiff[1] = diff.y();
26  vDiff[2] = diff.z();
27 
28  double dist = diff.mag();
29 
30  double err2 = ROOT::Math::Similarity(error, vDiff);
31  double err = 0.;
32  if (dist != 0)
33  err = sqrt(err2) / dist;
34 
35  return Measurement1D(dist, err);
36 }
T sqrt(T t)
Definition: SSEVec.h:19
const AlgebraicSymMatrix33 matrix() const
ROOT::Math::SVector< double, 3 > AlgebraicVector3
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33

◆ signedDistance()

Measurement1D VertexDistance3D::signedDistance ( const reco::Vertex primVtx,
const reco::Vertex secVtx,
const GlobalVector momentum 
) const
overridevirtual

The signed distance is computed using a vector from the primary to the secondary vertex and a given reference vector. The sign is determined by the scalar product of the vector connecting the vertices and the reference vector: if the scalar product is greater than zero, the sign is +1, else -1

Implements VertexDistance.

Definition at line 6 of file VertexDistance3D.cc.

References change_name::diff, HLT_2024v14_cff::distance, Measurement1D::error(), reco::Vertex::position(), Measurement1D::value(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by DeepBoostedJetTagInfoProducer::fillSVFeatures(), and ParticleNetFeatureEvaluator::fillSVFeatures().

8  {
9  Measurement1D unsignedDistance = distance(vtx1, vtx2);
10  Basic3DVector<float> diff = Basic3DVector<float>(vtx2.position()) - Basic3DVector<float>(vtx1.position());
11  // Basic3DVector<float> (vtx2 - vtx1);
12  if ((momentum.x() * diff.x() + momentum.y() * diff.y() * momentum.z() * diff.z()) < 0)
13  return Measurement1D(-1.0 * unsignedDistance.value(), unsignedDistance.error());
14  return unsignedDistance;
15 }
T z() const
Definition: PV3DBase.h:61
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
double value() const
Definition: Measurement1D.h:25
double error() const
Definition: Measurement1D.h:27

Member Data Documentation

◆ theNullMatrix

AlgebraicSymMatrix33 VertexDistance3D::theNullMatrix
private

Definition at line 36 of file VertexDistance3D.h.