CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SecondaryVertex.cc
Go to the documentation of this file.
1 #include <cmath>
2 
3 #include <Math/Functions.h>
4 #include <Math/SVector.h>
5 #include <Math/SMatrix.h>
6 
10 
12 
13 using namespace reco;
14 
17  const GlobalVector &direction, bool withPVError)
18 {
19  typedef ROOT::Math::SVector<double, 2> SVector2;
20  typedef ROOT::Math::SMatrix<double, 2, 2,
21  ROOT::Math::MatRepSym<double, 2> > SMatrixSym2;
22 
23  SMatrixSym2 cov = sv.covariance().Sub<SMatrixSym2>(0, 0);
24  if (withPVError)
25  cov += pv.covariance().Sub<SMatrixSym2>(0, 0);
26 
27  SVector2 vector(sv.position().X() - pv.position().X(),
28  sv.position().Y() - pv.position().Y());
29 
30  double dist = ROOT::Math::Mag(vector);
31  double error = ROOT::Math::Similarity(cov, vector);
32  if (error > 0.0 && dist > 1.0e-9)
33  error = std::sqrt(error) / dist;
34  else
35  error = -1.0;
36 
37  if ((vector[0] * direction.x() +
38  vector[1] * direction.y()) < 0.0)
39  dist = -dist;
40 
41  return Measurement1D(dist, error);
42 }
43 
46  const GlobalVector &direction, bool withPVError)
47 {
48  typedef ROOT::Math::SVector<double, 3> SVector3;
49  typedef ROOT::Math::SMatrix<double, 3, 3,
50  ROOT::Math::MatRepSym<double, 3> > SMatrixSym3;
51 
52  SMatrixSym3 cov = sv.covariance();
53  if (withPVError)
54  cov += pv.covariance();
55 
56  SVector3 vector(sv.position().X() - pv.position().X(),
57  sv.position().Y() - pv.position().Y(),
58  sv.position().Z() - pv.position().Z());
59 
60  double dist = ROOT::Math::Mag(vector);
61  double error = ROOT::Math::Similarity(cov, vector);
62  if (error > 0.0 && dist > 1.0e-9)
63  error = std::sqrt(error) / dist;
64  else
65  error = -1.0;
66 
67  if ((vector[0] * direction.x() +
68  vector[1] * direction.y() +
69  vector[2] * direction.z()) < 0.0)
70  dist = -dist;
71 
72  return Measurement1D(dist, error);
73 }
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:123
const Point & position() const
position
Definition: Vertex.h:106
static Measurement1D computeDist2d(const reco::Vertex &pv, const reco::Vertex &sv, const GlobalVector &direction, bool withPVError)
T sqrt(T t)
Definition: SSEVec.h:48
static Measurement1D computeDist3d(const reco::Vertex &pv, const reco::Vertex &sv, const GlobalVector &direction, bool withPVError)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::GlobalCoordinateSystemTag > GlobalVector
vector in glovbal coordinate system
Definition: Vector3D.h:27
Error error() const
return SMatrix
Definition: Vertex.h:129