CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 23 of file InvariantMassFromVertex.h.

Definition at line 49 of file InvariantMassFromVertex.h.

Definition at line 50 of file InvariantMassFromVertex.h.

Definition at line 48 of file InvariantMassFromVertex.h.

Member Function Documentation

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

Definition at line 71 of file InvariantMassFromVertex.cc.

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

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

73 {
74 
75  // Check that tkToTkCovarianceIsAvailable
76  if (!vertex.tkToTkCovarianceIsAvailable()) {
77  LogDebug("InvariantMassFromVertex")
78  << "Fit failed: vertex has not been smoothed\n";
79  return Measurement1D(0.,0.);
80  }
81  if (vertex.tracks().size() != masses.size()) {
82  LogDebug("InvariantMassFromVertex")
83  << "Vector of masses does not have the same size as tracks in vertex\n";
84  return Measurement1D(0.,0.);
85  }
86 
87  LorentzVector totalP4 = p4(vertex, masses);
88  double u = uncertainty(totalP4, vertex, masses);
89  // std::cout << u<<std::endl;
90  return Measurement1D(totalP4.M(), u );
91 
92 }
#define LogDebug(id)
std::vector< RefCountedVertexTrack > tracks() const
math::XYZTLorentzVector LorentzVector
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
bool tkToTkCovarianceIsAvailable() const
Measurement1D InvariantMassFromVertex::invariantMass ( const CachingVertex< 5 > &  vertex,
const double  mass 
) const

Definition at line 64 of file InvariantMassFromVertex.cc.

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

66 {
67  return invariantMass(vertex, std::vector<double>(vertex.tracks().size(), mass));
68 }
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 42 of file InvariantMassFromVertex.cc.

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

Referenced by p4().

43 {
44  GlobalVector momentum_;
45 
46  // Check that tkToTkCovarianceIsAvailable
47  if (!vertex.tkToTkCovarianceIsAvailable()) {
48  LogDebug("InvariantMassFromVertex")
49  << "Fit failed: vertex has not been smoothed\n";
50  return momentum_;
51  }
52 
53  std::vector<RefCountedVertexTrack> refTracks = vertex.tracks();
54  std::vector<RefCountedVertexTrack>::const_iterator i_s = refTracks.begin();
55 
56  for( ;i_s !=refTracks.end() ; ++i_s) {
57  momentum_ += (**i_s).refittedState()->freeTrajectoryState().momentum();
58  }
59  return momentum_;
60 
61 }
#define LogDebug(id)
std::vector< RefCountedVertexTrack > tracks() const
bool tkToTkCovarianceIsAvailable() const
InvariantMassFromVertex::LorentzVector InvariantMassFromVertex::p4 ( const CachingVertex< 5 > &  vertex,
const std::vector< double > &  masses 
) const

four-momentum Lorentz vector

Definition at line 11 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().

13 {
14 
15  LorentzVector totalP4;
16 
17  // Check that tkToTkCovarianceIsAvailable
18  if (!vertex.tkToTkCovarianceIsAvailable()) {
19  LogDebug("InvariantMassFromVertex")
20  << "Fit failed: vertex has not been smoothed\n";
21  return totalP4;
22  }
23 
24  if (vertex.tracks().size() != masses.size()) {
25  LogDebug("InvariantMassFromVertex")
26  << "Vector of masses does not have the same size as tracks in vertex\n";
27  return totalP4;
28  }
29 
30 
31  std::vector<RefCountedVertexTrack> refTracks = vertex.tracks();
32  std::vector<RefCountedVertexTrack>::const_iterator i_s = refTracks.begin();
33  std::vector<double>::const_iterator i_m = masses.begin();
34 
35  for( ;i_s !=refTracks.end() && i_m != masses.end(); ++i_s, ++i_m) {
36  GlobalVector momentum = (**i_s).refittedState()->freeTrajectoryState().momentum();
37  totalP4 += LorentzVector(momentum.x(), momentum.y(), momentum.z(), *i_m);
38  }
39  return totalP4;
40 }
#define LogDebug(id)
ROOT::Math::PxPyPzMVector LorentzVector
std::vector< RefCountedVertexTrack > tracks() const
math::XYZTLorentzVector LorentzVector
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
GlobalVector momentum(const CachingVertex< 5 > &vertex) const
bool tkToTkCovarianceIsAvailable() const
T x() const
Definition: PV3DBase.h:62
InvariantMassFromVertex::LorentzVector InvariantMassFromVertex::p4 ( const CachingVertex< 5 > &  vertex,
const double  mass 
) const

four-momentum Lorentz vector

Definition at line 5 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().

7 {
8  return p4(vertex, std::vector<double>(vertex.tracks().size(), mass));
9 }
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 96 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().

98 {
99  std::vector<RefCountedVertexTrack> refTracks = vertex.tracks();
100  int size = refTracks.size();
101  AlgebraicMatrix cov(3*size,3*size);
102  AlgebraicMatrix jac(1,3*size);
103 
104  double energy_total = totalP4.E();
105 
106  std::vector<RefCountedVertexTrack>::const_iterator rt_i = refTracks.begin();
107  std::vector<double>::const_iterator i_m = masses.begin();
108 
109  int i_int = 0;
110  for( ;rt_i !=refTracks.end() && i_m != masses.end(); ++rt_i, ++i_m) {
111 
112  double a;
113  AlgebraicVector5 param = (**rt_i).refittedState()->parameters(); // rho, theta, phi,tr_im, z_im
114  double rho = param[0];
115  double theta = param[1];
116  double phi = param[2];
117  double mass = *i_m;
118 
119  if ((**rt_i).linearizedTrack()->charge()!=0) {
120  a = -(**rt_i).refittedState()->freeTrajectoryState().parameters().magneticFieldInInverseGeV(vertex.position()).z()
121  * (**rt_i).refittedState()->freeTrajectoryState().parameters ().charge();
122  if (a==0.) throw cms::Exception("InvariantMassFromVertex", "Field is 0");
123  } else {
124  a = 1;
125  }
126 
127  double energy_local = sqrt(a*a/(rho*rho)*(1+1/(tan(theta)*tan(theta))) + mass*mass);
128 
129  jac(1,i_int*3+1) = (-(energy_total/energy_local*a*a/(rho*rho*rho*sin(theta)*sin(theta)) )
130  + totalP4.X()*a/(rho*rho)*cos(phi) + totalP4.Y()*a/(rho*rho)*sin(phi)
131  + totalP4.Z()*a/(rho*rho*tan(theta)) )/totalP4.M(); //dm / drho
132 
133  jac(1,i_int*3+2) = (-(energy_total/energy_local*a*a/(rho*rho*sin(theta)*sin(theta)*tan(theta)) )
134  + totalP4.Z()*a/(rho*sin(theta)*sin(theta)) )/totalP4.M();//dm d theta
135 
136  jac(1,i_int*3+3) = ( totalP4.X()*sin(phi) - totalP4.Y()*cos(phi) )*a/(rho*totalP4.M()); //dm/dphi
137 
138  // momentum corellatons: diagonal elements of the matrix
139  cov.sub(i_int*3 + 1, i_int*3 + 1,asHepMatrix<6>((**rt_i).fullCovariance()).sub(4,6));
140 
141  //off diagonal elements: track momentum - track momentum corellations
142 
143  int j_int = 0;
144  for(std::vector<RefCountedVertexTrack>::const_iterator rt_j = refTracks.begin(); rt_j != refTracks.end(); rt_j++) {
145  if(i_int < j_int) {
146  AlgebraicMatrix i_k_cov_m = asHepMatrix<3,3>(vertex.tkToTkCovariance((*rt_i),(*rt_j)));
147  cov.sub(i_int*3 + 1, j_int*3 + 1,i_k_cov_m);
148  cov.sub(j_int*3 + 1, i_int*3 + 1,i_k_cov_m.T());
149  }
150  j_int++;
151  }
152  i_int++;
153  }
154 // std::cout<<"jac"<<jac<<std::endl;
155 // std::cout<<"cov"<<cov<<std::endl;
156 // std::cout << "final result"<<(jac*cov*jac.T())<<std::endl;
157 
158  return sqrt((jac*cov*jac.T())(1,1));
159 }
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:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
AlgebraicMatrixMM tkToTkCovariance(const RefCountedVertexTrack t1, const RefCountedVertexTrack t2) const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
GlobalPoint position() const
double a
Definition: hdecay.h:121
tuple size
Write out results.