CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions
InvariantMassFromVertex Class Reference

#include <InvariantMassFromVertex.h>

Public Types

typedef ROOT::Math::PxPyPzMVector LorentzVector
 

Public Member Functions

Measurement1D invariantMass (const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
 
Measurement1D invariantMass (const CachingVertex< 5 > &vertex, const double mass) const
 
GlobalVector momentum (const CachingVertex< 5 > &vertex) const
 
LorentzVector p4 (const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
 
LorentzVector p4 (const CachingVertex< 5 > &vertex, const double mass) const
 

Private Types

typedef
ReferenceCountingPointer
< LinearizedTrackState< 5 > > 
RefCountedLinearizedTrackState
 
typedef
ReferenceCountingPointer
< RefittedTrackState< 5 > > 
RefCountedRefittedTrackState
 
typedef
ReferenceCountingPointer
< VertexTrack< 5 > > 
RefCountedVertexTrack
 

Private Member Functions

double uncertainty (const LorentzVector &p4, const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
 

Detailed Description

Class building a resulting output tree out of the information provided by KinematicParticleVertexFitter.

Definition at line 20 of file InvariantMassFromVertex.h.

Member Typedef Documentation

typedef ROOT::Math::PxPyPzMVector InvariantMassFromVertex::LorentzVector

Definition at line 22 of file InvariantMassFromVertex.h.

Definition at line 42 of file InvariantMassFromVertex.h.

Definition at line 43 of file InvariantMassFromVertex.h.

Definition at line 41 of file InvariantMassFromVertex.h.

Member Function Documentation

Measurement1D InvariantMassFromVertex::invariantMass ( const CachingVertex< 5 > &  vertex,
const std::vector< double > &  masses 
) const

Definition at line 57 of file InvariantMassFromVertex.cc.

References LogDebug, p4(), CachingVertex< N >::tkToTkCovarianceIsAvailable(), CachingVertex< N >::tracks(), and uncertainty().

Referenced by invariantMass(), and Onia2MuMuPAT::produce().

58  {
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 }
std::vector< RefCountedVertexTrack > tracks() const
LorentzVector p4(const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
double uncertainty(const LorentzVector &p4, const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
math::XYZTLorentzVector LorentzVector
bool tkToTkCovarianceIsAvailable() const
#define LogDebug(id)
Measurement1D InvariantMassFromVertex::invariantMass ( const CachingVertex< 5 > &  vertex,
const double  mass 
) const

Definition at line 53 of file InvariantMassFromVertex.cc.

References invariantMass(), ResonanceBuilder::mass, and CachingVertex< N >::tracks().

53  {
54  return invariantMass(vertex, std::vector<double>(vertex.tracks().size(), mass));
55 }
std::vector< RefCountedVertexTrack > tracks() const
Measurement1D invariantMass(const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
GlobalVector InvariantMassFromVertex::momentum ( const CachingVertex< 5 > &  vertex) const

Definition at line 35 of file InvariantMassFromVertex.cc.

References LogDebug, CachingVertex< N >::tkToTkCovarianceIsAvailable(), and CachingVertex< N >::tracks().

Referenced by p4().

35  {
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 }
std::vector< RefCountedVertexTrack > tracks() const
bool tkToTkCovarianceIsAvailable() const
#define LogDebug(id)
InvariantMassFromVertex::LorentzVector InvariantMassFromVertex::p4 ( const CachingVertex< 5 > &  vertex,
const std::vector< double > &  masses 
) const

four-momentum Lorentz vector

Definition at line 9 of file InvariantMassFromVertex.cc.

References LogDebug, momentum(), CachingVertex< N >::tkToTkCovarianceIsAvailable(), CachingVertex< N >::tracks(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by Tau.Tau::dxy_approx(), Tau.Tau::dz(), invariantMass(), p4(), and Lepton.Lepton::p4WithFSR().

10  {
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 }
ROOT::Math::PxPyPzMVector LorentzVector
std::vector< RefCountedVertexTrack > tracks() const
T y() const
Definition: PV3DBase.h:60
T z() const
Definition: PV3DBase.h:61
GlobalVector momentum(const CachingVertex< 5 > &vertex) const
math::XYZTLorentzVector LorentzVector
bool tkToTkCovarianceIsAvailable() const
T x() const
Definition: PV3DBase.h:59
#define LogDebug(id)
InvariantMassFromVertex::LorentzVector InvariantMassFromVertex::p4 ( const CachingVertex< 5 > &  vertex,
const double  mass 
) const

four-momentum Lorentz vector

Definition at line 4 of file InvariantMassFromVertex.cc.

References ResonanceBuilder::mass, p4(), and CachingVertex< N >::tracks().

Referenced by Tau.Tau::dxy_approx(), Tau.Tau::dz(), and Lepton.Lepton::p4WithFSR().

5  {
6  return p4(vertex, std::vector<double>(vertex.tracks().size(), mass));
7 }
std::vector< RefCountedVertexTrack > tracks() const
LorentzVector p4(const CachingVertex< 5 > &vertex, const std::vector< double > &masses) const
double InvariantMassFromVertex::uncertainty ( const LorentzVector p4,
const CachingVertex< 5 > &  vertex,
const std::vector< double > &  masses 
) const
private

Definition at line 77 of file InvariantMassFromVertex.cc.

References a, funct::cos(), Exception, ResonanceBuilder::mass, phi, CachingVertex< N >::position(), rho, funct::sin(), findQualityFiles::size, mathSSE::sqrt(), funct::tan(), theta(), CachingVertex< N >::tkToTkCovariance(), CachingVertex< N >::tracks(), and z.

Referenced by invariantMass().

79  {
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 }
std::vector< RefCountedVertexTrack > tracks() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
CLHEP::HepMatrix AlgebraicMatrix
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
ROOT::Math::SVector< double, 5 > AlgebraicVector5
AlgebraicMatrixMM tkToTkCovariance(const RefCountedVertexTrack t1, const RefCountedVertexTrack t2) const
GlobalPoint position() const
double a
Definition: hdecay.h:119
tuple size
Write out results.