CMS 3D CMS Logo

InvariantMassFromVertex.cc
Go to the documentation of this file.
3 
5  const double mass) const {
6  return p4(vertex, std::vector<double>(vertex.tracks().size(), mass));
7 }
8 
10  const std::vector<double>& masses) const {
11  LorentzVector totalP4;
12 
13  // Check that tkToTkCovarianceIsAvailable
14  if (!vertex.tkToTkCovarianceIsAvailable()) {
15  LogDebug("InvariantMassFromVertex") << "Fit failed: vertex has not been smoothed\n";
16  return totalP4;
17  }
18 
19  if (vertex.tracks().size() != masses.size()) {
20  LogDebug("InvariantMassFromVertex") << "Vector of masses does not have the same size as tracks in vertex\n";
21  return totalP4;
22  }
23 
24  std::vector<RefCountedVertexTrack> refTracks = vertex.tracks();
25  std::vector<RefCountedVertexTrack>::const_iterator i_s = refTracks.begin();
26  std::vector<double>::const_iterator i_m = masses.begin();
27 
28  for (; i_s != refTracks.end() && i_m != masses.end(); ++i_s, ++i_m) {
29  GlobalVector momentum = (**i_s).refittedState()->freeTrajectoryState().momentum();
30  totalP4 += LorentzVector(momentum.x(), momentum.y(), momentum.z(), *i_m);
31  }
32  return totalP4;
33 }
34 
36  GlobalVector momentum_;
37 
38  // Check that tkToTkCovarianceIsAvailable
39  if (!vertex.tkToTkCovarianceIsAvailable()) {
40  LogDebug("InvariantMassFromVertex") << "Fit failed: vertex has not been smoothed\n";
41  return momentum_;
42  }
43 
44  std::vector<RefCountedVertexTrack> refTracks = vertex.tracks();
45  std::vector<RefCountedVertexTrack>::const_iterator i_s = refTracks.begin();
46 
47  for (; i_s != refTracks.end(); ++i_s) {
48  momentum_ += (**i_s).refittedState()->freeTrajectoryState().momentum();
49  }
50  return momentum_;
51 }
52 
54  return invariantMass(vertex, std::vector<double>(vertex.tracks().size(), mass));
55 }
56 
58  const std::vector<double>& masses) const {
59  // Check that tkToTkCovarianceIsAvailable
60  if (!vertex.tkToTkCovarianceIsAvailable()) {
61  LogDebug("InvariantMassFromVertex") << "Fit failed: vertex has not been smoothed\n";
62  return Measurement1D(0., 0.);
63  }
64  if (vertex.tracks().size() != masses.size()) {
65  LogDebug("InvariantMassFromVertex") << "Vector of masses does not have the same size as tracks in vertex\n";
66  return Measurement1D(0., 0.);
67  }
68 
69  LorentzVector totalP4 = p4(vertex, masses);
70  double u = uncertainty(totalP4, vertex, masses);
71  // std::cout << u<<std::endl;
72  return Measurement1D(totalP4.M(), u);
73 }
74 
75 //method returning the full covariance matrix
76 //of new born kinematic particle
78  const CachingVertex<5>& vertex,
79  const std::vector<double>& masses) const {
80  std::vector<RefCountedVertexTrack> refTracks = vertex.tracks();
81  int size = refTracks.size();
82  AlgebraicMatrix cov(3 * size, 3 * size);
83  AlgebraicMatrix jac(1, 3 * size);
84 
85  double energy_total = totalP4.E();
86 
87  std::vector<RefCountedVertexTrack>::const_iterator rt_i = refTracks.begin();
88  std::vector<double>::const_iterator i_m = masses.begin();
89 
90  int i_int = 0;
91  for (; rt_i != refTracks.end() && i_m != masses.end(); ++rt_i, ++i_m) {
92  double a;
93  AlgebraicVector5 param = (**rt_i).refittedState()->parameters(); // rho, theta, phi,tr_im, z_im
94  double rho = param[0];
95  double theta = param[1];
96  double phi = param[2];
97  double mass = *i_m;
98 
99  if ((**rt_i).linearizedTrack()->charge() != 0) {
100  a = -(**rt_i).refittedState()->freeTrajectoryState().parameters().magneticFieldInInverseGeV(vertex.position()).z() *
101  (**rt_i).refittedState()->freeTrajectoryState().parameters().charge();
102  if (a == 0.)
103  throw cms::Exception("InvariantMassFromVertex", "Field is 0");
104  } else {
105  a = 1;
106  }
107 
108  double energy_local = sqrt(a * a / (rho * rho) * (1 + 1 / (tan(theta) * tan(theta))) + mass * mass);
109 
110  jac(1, i_int * 3 + 1) = (-(energy_total / energy_local * a * a / (rho * rho * rho * sin(theta) * sin(theta))) +
111  totalP4.X() * a / (rho * rho) * cos(phi) + totalP4.Y() * a / (rho * rho) * sin(phi) +
112  totalP4.Z() * a / (rho * rho * tan(theta))) /
113  totalP4.M(); //dm / drho
114 
115  jac(1, i_int * 3 + 2) =
116  (-(energy_total / energy_local * a * a / (rho * rho * sin(theta) * sin(theta) * tan(theta))) +
117  totalP4.Z() * a / (rho * sin(theta) * sin(theta))) /
118  totalP4.M(); //dm d theta
119 
120  jac(1, i_int * 3 + 3) = (totalP4.X() * sin(phi) - totalP4.Y() * cos(phi)) * a / (rho * totalP4.M()); //dm/dphi
121 
122  // momentum corellatons: diagonal elements of the matrix
123  cov.sub(i_int * 3 + 1, i_int * 3 + 1, asHepMatrix<6>((**rt_i).fullCovariance()).sub(4, 6));
124 
125  //off diagonal elements: track momentum - track momentum corellations
126 
127  int j_int = 0;
128  for (std::vector<RefCountedVertexTrack>::const_iterator rt_j = refTracks.begin(); rt_j != refTracks.end(); rt_j++) {
129  if (i_int < j_int) {
130  AlgebraicMatrix i_k_cov_m = asHepMatrix<3, 3>(vertex.tkToTkCovariance((*rt_i), (*rt_j)));
131  cov.sub(i_int * 3 + 1, j_int * 3 + 1, i_k_cov_m);
132  cov.sub(j_int * 3 + 1, i_int * 3 + 1, i_k_cov_m.T());
133  }
134  j_int++;
135  }
136  i_int++;
137  }
138  // std::cout<<"jac"<<jac<<std::endl;
139  // std::cout<<"cov"<<cov<<std::endl;
140  // std::cout << "final result"<<(jac*cov*jac.T())<<std::endl;
141 
142  return sqrt((jac * cov * jac.T())(1, 1));
143 }
Vector3DBase
Definition: Vector3DBase.h:8
InvariantMassFromVertex::LorentzVector
ROOT::Math::PxPyPzMVector LorentzVector
Definition: InvariantMassFromVertex.h:22
Measurement1D
Definition: Measurement1D.h:11
MessageLogger.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
CachingVertex< 5 >
InvariantMassFromVertex::p4
LorentzVector p4(const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
Definition: InvariantMassFromVertex.cc:9
InvariantMassFromVertex::uncertainty
double uncertainty(const LorentzVector &p4, const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
Definition: InvariantMassFromVertex.cc:77
InvariantMassFromVertex::momentum
GlobalVector momentum(const CachingVertex< 5 > &vertex) const
Definition: InvariantMassFromVertex.cc:35
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
InvariantMassFromVertex::invariantMass
Measurement1D invariantMass(const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
Definition: InvariantMassFromVertex.cc:57
InvariantMassFromVertex.h
DDAxes::rho
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
a
double a
Definition: hdecay.h:119
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
AlgebraicVector5
ROOT::Math::SVector< double, 5 > AlgebraicVector5
Definition: AlgebraicROOTObjects.h:14
particleFlowDisplacedVertex_cfi.masses
masses
Definition: particleFlowDisplacedVertex_cfi.py:80
DDAxes::phi
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
Exception
Definition: hltDiff.cc:246
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443