CMS 3D CMS Logo

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