CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Alignment/ReferenceTrajectories/src/TwoBodyDecayTrajectoryState.cc

Go to the documentation of this file.
00001 
00002 #include "Alignment/ReferenceTrajectories/interface/TwoBodyDecayTrajectoryState.h"
00003 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h" 
00004 
00005 #include "Alignment/TwoBodyDecay/interface/TwoBodyDecayModel.h"
00006 #include "Alignment/TwoBodyDecay/interface/TwoBodyDecayDerivatives.h"
00007 
00008 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00009 
00010 #include "TrackingTools/AnalyticalJacobians/interface/AnalyticalCurvilinearJacobian.h"
00011 #include "TrackingTools/AnalyticalJacobians/interface/JacobianCurvilinearToLocal.h"
00012 #include "TrackingTools/AnalyticalJacobians/interface/JacobianCartesianToCurvilinear.h"
00013 
00014 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00015 
00016 #include "DataFormats/CLHEP/interface/Migration.h"
00017 
00018 using namespace std;
00019 
00020 
00021 TwoBodyDecayTrajectoryState::TwoBodyDecayTrajectoryState( const TsosContainer & tsos,
00022                                                           const TwoBodyDecay & tbd,
00023                                                           double particleMass,
00024                                                           const MagneticField* magField )
00025   : theValidityFlag( false ),
00026     theParticleMass( particleMass ),
00027     theParameters( tbd.decayParameters() ),
00028     theDerivatives( AlgebraicMatrix( nLocalParam, nDecayParam ), AlgebraicMatrix( nLocalParam, nDecayParam ) ),
00029     theOriginalTsos( tsos )
00030 {
00031   construct( magField );
00032 }
00033 
00034 
00035 TwoBodyDecayTrajectoryState::TwoBodyDecayTrajectoryState( const TsosContainer & tsos,
00036                                                           const TwoBodyDecayParameters & param,
00037                                                           double particleMass,
00038                                                           const MagneticField* magField )
00039   : theValidityFlag( false ),
00040     theParticleMass( particleMass ),
00041     theParameters( param ),
00042     theDerivatives( AlgebraicMatrix( 5, 9 ), AlgebraicMatrix( 5, 9 ) ),
00043     theOriginalTsos( tsos )
00044 {
00045   construct( magField );
00046 }
00047 
00048 
00049 void TwoBodyDecayTrajectoryState::construct( const MagneticField* magField )
00050 {
00051   // construct global trajectory parameters at the starting point
00052   TwoBodyDecayModel tbdDecayModel( theParameters[TwoBodyDecayParameters::mass], theParticleMass );
00053   pair< AlgebraicVector, AlgebraicVector > secondaryMomenta = tbdDecayModel.cartesianSecondaryMomenta( theParameters );
00054 
00055   GlobalPoint vtx( theParameters[TwoBodyDecayParameters::x],
00056                    theParameters[TwoBodyDecayParameters::y],
00057                    theParameters[TwoBodyDecayParameters::z] );
00058 
00059   GlobalVector p1( secondaryMomenta.first[0],
00060                    secondaryMomenta.first[1],
00061                    secondaryMomenta.first[2] );
00062 
00063   GlobalVector p2( secondaryMomenta.second[0],
00064                    secondaryMomenta.second[1],
00065                    secondaryMomenta.second[2] );
00066 
00067   GlobalTrajectoryParameters gtp1( vtx, p1, theOriginalTsos.first.charge(), magField );
00068   GlobalTrajectoryParameters gtp2( vtx, p2, theOriginalTsos.second.charge(), magField );
00069 
00070   // contruct derivatives at the starting point
00071   TwoBodyDecayDerivatives tbdDerivatives( theParameters[TwoBodyDecayParameters::mass], theParticleMass );
00072   pair< AlgebraicMatrix, AlgebraicMatrix > derivatives = tbdDerivatives.derivatives( theParameters );
00073 
00074   AlgebraicMatrix deriv1( 6, 9, 0 );
00075   deriv1.sub( 1, 1, AlgebraicMatrix( 3, 3, 1 ) );
00076   deriv1.sub( 4, 4, derivatives.first );
00077 
00078   AlgebraicMatrix deriv2( 6, 9, 0 );
00079   deriv2.sub( 1, 1, AlgebraicMatrix( 3, 3, 1 ) );
00080   deriv2.sub( 4, 4, derivatives.second );
00081 
00082   // propgate states and derivatives from the starting points to the end points
00083   bool valid1 = propagateSingleState( gtp1, deriv1, theOriginalTsos.first.surface(), magField,
00084                                       theRefittedTsos.first, theDerivatives.first );
00085 
00086   bool valid2 = propagateSingleState( gtp2, deriv2, theOriginalTsos.second.surface(), magField,
00087                                       theRefittedTsos.second, theDerivatives.second );
00088 
00089   theValidityFlag = valid1 && valid2;
00090 
00091   return;
00092 }
00093 
00094 
00095 bool TwoBodyDecayTrajectoryState::propagateSingleState( const GlobalTrajectoryParameters & gtp,
00096                                                         const AlgebraicMatrix & startDeriv,
00097                                                         const Surface & surface,
00098                                                         const MagneticField* magField,
00099                                                         TrajectoryStateOnSurface & tsos,
00100                                                         AlgebraicMatrix & endDeriv )
00101 {
00102   AnalyticalPropagator propagator( magField );
00103 
00104   // propagate state
00105   pair< TrajectoryStateOnSurface, double > tsosWithPath = propagator.propagateWithPath( FreeTrajectoryState( gtp ), surface );
00106 
00107   // check if propagation was successful
00108   if ( !tsosWithPath.first.isValid() ) return false;
00109 
00110   // jacobian for transformation from cartesian to curvilinear frame at the starting point
00111   JacobianCartesianToCurvilinear cartToCurv( gtp );
00112   const AlgebraicMatrix56& matCartToCurv = cartToCurv.jacobian();
00113 
00114   // jacobian in curvilinear frame for propagation from the starting point to the end point
00115   AnalyticalCurvilinearJacobian curvJac( gtp, tsosWithPath.first.globalPosition(),
00116                                          tsosWithPath.first.globalMomentum(),
00117                                          tsosWithPath.second );
00118   const AlgebraicMatrix55& matCurvJac = curvJac.jacobian();
00119 
00120   // jacobian for transformation from curvilinear to local frame at the end point
00121   JacobianCurvilinearToLocal curvToLoc( surface, tsosWithPath.first.localParameters(), *magField );
00122   const AlgebraicMatrix55& matCurvToLoc = curvToLoc.jacobian();
00123 
00124   AlgebraicMatrix56 tmpDeriv = matCurvToLoc*matCurvJac*matCartToCurv;
00125   AlgebraicMatrix hepMatDeriv( asHepMatrix( tmpDeriv ) );
00126   //AlgebraicMatrix hepMatDeriv = asHepMatrix< 5, 6 >( tmpDeriv );
00127 
00128   // replace original state with new state
00129   tsos = tsosWithPath.first;
00130 
00131   // propagate derivative matrix
00132   endDeriv = hepMatDeriv*startDeriv;
00133 
00134   return true;
00135 }