CMS 3D CMS Logo

TwoBodyDecayTrajectoryState.cc
Go to the documentation of this file.
1 
4 
7 
9 
13 
15 
17 
18 using namespace std;
19 
21  const TwoBodyDecay& tbd,
22  double particleMass,
23  const MagneticField* magField,
24  bool propagateErrors)
25  : theValidityFlag(false),
26  theParticleMass(particleMass),
27  theParameters(tbd.decayParameters()),
28  theDerivatives(AlgebraicMatrix(nLocalParam, nDecayParam), AlgebraicMatrix(nLocalParam, nDecayParam)),
29  theOriginalTsos(tsos),
30  thePrimaryMass(tbd.primaryMass()),
31  thePrimaryWidth(tbd.primaryWidth()) {
32  construct(magField, propagateErrors);
33 }
34 
36  theOriginalTsos.first.rescaleError(scale);
37  theOriginalTsos.second.rescaleError(scale);
38  theRefittedTsos.first.rescaleError(scale);
39  theRefittedTsos.second.rescaleError(scale);
40 }
41 
42 void TwoBodyDecayTrajectoryState::construct(const MagneticField* magField, bool propagateErrors) {
43  // construct global trajectory parameters at the starting point
45  pair<AlgebraicVector, AlgebraicVector> secondaryMomenta = tbdDecayModel.cartesianSecondaryMomenta(theParameters);
46 
50 
51  GlobalVector p1(secondaryMomenta.first[0], secondaryMomenta.first[1], secondaryMomenta.first[2]);
52 
53  GlobalVector p2(secondaryMomenta.second[0], secondaryMomenta.second[1], secondaryMomenta.second[2]);
54 
55  GlobalTrajectoryParameters gtp1(vtx, p1, theOriginalTsos.first.charge(), magField);
56  FreeTrajectoryState fts1(gtp1);
57 
58  GlobalTrajectoryParameters gtp2(vtx, p2, theOriginalTsos.second.charge(), magField);
59  FreeTrajectoryState fts2(gtp2);
60 
61  // contruct derivatives at the starting point
63  pair<AlgebraicMatrix, AlgebraicMatrix> derivatives = tbdDerivatives.derivatives(theParameters);
64 
65  AlgebraicMatrix deriv1(6, 9, 0);
66  deriv1.sub(1, 1, AlgebraicMatrix(3, 3, 1));
67  deriv1.sub(4, 4, derivatives.first);
68 
69  AlgebraicMatrix deriv2(6, 9, 0);
70  deriv2.sub(1, 1, AlgebraicMatrix(3, 3, 1));
71  deriv2.sub(4, 4, derivatives.second);
72 
73  // compute errors of initial states
74  if (propagateErrors) {
75  setError(fts1, deriv1);
76  setError(fts2, deriv2);
77  }
78 
79  // propgate states and derivatives from the starting points to the end points
80  bool valid1 = propagateSingleState(
81  fts1, gtp1, deriv1, theOriginalTsos.first.surface(), magField, theRefittedTsos.first, theDerivatives.first);
82 
83  bool valid2 = propagateSingleState(
84  fts2, gtp2, deriv2, theOriginalTsos.second.surface(), magField, theRefittedTsos.second, theDerivatives.second);
85 
86  theValidityFlag = valid1 && valid2;
87 
88  return;
89 }
90 
92  const GlobalTrajectoryParameters& gtp,
93  const AlgebraicMatrix& startDeriv,
94  const Surface& surface,
95  const MagneticField* magField,
97  AlgebraicMatrix& endDeriv) const {
99 
100  // propagate state
101  pair<TrajectoryStateOnSurface, double> tsosWithPath = propagator.propagateWithPath(fts, surface);
102 
103  // check if propagation was successful
104  if (!tsosWithPath.first.isValid())
105  return false;
106 
107  // jacobian for transformation from cartesian to curvilinear frame at the starting point
108  JacobianCartesianToCurvilinear cartToCurv(gtp);
109  const AlgebraicMatrix56& matCartToCurv = cartToCurv.jacobian();
110 
111  // jacobian in curvilinear frame for propagation from the starting point to the end point
113  gtp, tsosWithPath.first.globalPosition(), tsosWithPath.first.globalMomentum(), tsosWithPath.second);
114  const AlgebraicMatrix55& matCurvJac = curvJac.jacobian();
115 
116  // jacobian for transformation from curvilinear to local frame at the end point
117  JacobianCurvilinearToLocal curvToLoc(surface, tsosWithPath.first.localParameters(), *magField);
118  const AlgebraicMatrix55& matCurvToLoc = curvToLoc.jacobian();
119 
120  AlgebraicMatrix56 tmpDeriv = matCurvToLoc * matCurvJac * matCartToCurv;
121  AlgebraicMatrix hepMatDeriv(asHepMatrix(tmpDeriv));
122  //AlgebraicMatrix hepMatDeriv = asHepMatrix< 5, 6 >( tmpDeriv );
123 
124  // replace original state with new state
125  tsos = tsosWithPath.first;
126 
127  // propagate derivative matrix
128  endDeriv = hepMatDeriv * startDeriv;
129 
130  return true;
131 }
132 
134  AlgebraicSymMatrix ftsCartesianError(theParameters.covariance().similarity(derivative));
135  fts.setCartesianError(asSMatrix<6>(ftsCartesianError));
136 }
CLHEP::HepMatrix asHepMatrix(const ROOT::Math::SMatrix< double, N1, N2, typename ROOT::Math::MatRepStd< double, N1, N2 > > &rm)
Definition: Migration.h:60
bool propagateSingleState(const FreeTrajectoryState &fts, const GlobalTrajectoryParameters &gtp, const AlgebraicMatrix &startDeriv, const Surface &surface, const MagneticField *magField, TrajectoryStateOnSurface &tsos, AlgebraicMatrix &endDeriv) const
Derivative< X, A >::type derivative(const A &_)
Definition: Derivative.h:18
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
const Derivatives & derivatives(void) const
TwoBodyDecayTrajectoryState(const TsosContainer &tsos, const TwoBodyDecay &tbd, double particleMass, const MagneticField *magField, bool propagateErrors=false)
ROOT::Math::SMatrix< double, 5, 6, ROOT::Math::MatRepStd< double, 5, 6 > > AlgebraicMatrix56
const AlgebraicMatrix56 & jacobian() const
CLHEP::HepMatrix AlgebraicMatrix
void setCartesianError(const CartesianTrajectoryError &err)
const AlgebraicMatrix55 & jacobian() const
std::pair< TrajectoryStateOnSurface, TrajectoryStateOnSurface > TsosContainer
void setError(FreeTrajectoryState &fts, AlgebraicMatrix &derivative) const
void construct(const MagneticField *magField, bool propagateErrors)
CLHEP::HepSymMatrix AlgebraicSymMatrix
const AlgebraicSymMatrix & covariance(void) const
Get error matrix.
const std::pair< AlgebraicMatrix, AlgebraicMatrix > derivatives(const TwoBodyDecay &tbd) const
const std::pair< AlgebraicVector, AlgebraicVector > cartesianSecondaryMomenta(const AlgebraicVector &param)
const AlgebraicMatrix55 & jacobian() const