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 bool propagateErrors )
00026 : theValidityFlag( false ),
00027 theParticleMass( particleMass ),
00028 theParameters( tbd.decayParameters() ),
00029 theDerivatives( AlgebraicMatrix( nLocalParam, nDecayParam ), AlgebraicMatrix( nLocalParam, nDecayParam ) ),
00030 theOriginalTsos( tsos ),
00031 thePrimaryMass( tbd.primaryMass() ),
00032 thePrimaryWidth( tbd.primaryWidth() )
00033 {
00034 construct( magField, propagateErrors );
00035 }
00036
00037
00038 void TwoBodyDecayTrajectoryState::rescaleError( double scale )
00039 {
00040 theOriginalTsos.first.rescaleError( scale );
00041 theOriginalTsos.second.rescaleError( scale );
00042 theRefittedTsos.first.rescaleError( scale );
00043 theRefittedTsos.second.rescaleError( scale );
00044 }
00045
00046
00047 void TwoBodyDecayTrajectoryState::construct( const MagneticField* magField,
00048 bool propagateErrors )
00049 {
00050
00051 TwoBodyDecayModel tbdDecayModel( theParameters[TwoBodyDecayParameters::mass], theParticleMass );
00052 pair< AlgebraicVector, AlgebraicVector > secondaryMomenta = tbdDecayModel.cartesianSecondaryMomenta( theParameters );
00053
00054 GlobalPoint vtx( theParameters[TwoBodyDecayParameters::x],
00055 theParameters[TwoBodyDecayParameters::y],
00056 theParameters[TwoBodyDecayParameters::z] );
00057
00058 GlobalVector p1( secondaryMomenta.first[0],
00059 secondaryMomenta.first[1],
00060 secondaryMomenta.first[2] );
00061
00062 GlobalVector p2( secondaryMomenta.second[0],
00063 secondaryMomenta.second[1],
00064 secondaryMomenta.second[2] );
00065
00066 GlobalTrajectoryParameters gtp1( vtx, p1, theOriginalTsos.first.charge(), magField );
00067 FreeTrajectoryState fts1( gtp1 );
00068
00069 GlobalTrajectoryParameters gtp2( vtx, p2, theOriginalTsos.second.charge(), magField );
00070 FreeTrajectoryState fts2( gtp2 );
00071
00072
00073 TwoBodyDecayDerivatives tbdDerivatives( theParameters[TwoBodyDecayParameters::mass], theParticleMass );
00074 pair< AlgebraicMatrix, AlgebraicMatrix > derivatives = tbdDerivatives.derivatives( theParameters );
00075
00076 AlgebraicMatrix deriv1( 6, 9, 0 );
00077 deriv1.sub( 1, 1, AlgebraicMatrix( 3, 3, 1 ) );
00078 deriv1.sub( 4, 4, derivatives.first );
00079
00080 AlgebraicMatrix deriv2( 6, 9, 0 );
00081 deriv2.sub( 1, 1, AlgebraicMatrix( 3, 3, 1 ) );
00082 deriv2.sub( 4, 4, derivatives.second );
00083
00084
00085 if ( propagateErrors ) {
00086 setError( fts1, deriv1 );
00087 setError( fts2, deriv2 );
00088 }
00089
00090
00091
00092 bool valid1 = propagateSingleState( fts1, gtp1, deriv1, theOriginalTsos.first.surface(),
00093 magField, theRefittedTsos.first, theDerivatives.first );
00094
00095 bool valid2 = propagateSingleState( fts2, gtp2, deriv2, theOriginalTsos.second.surface(),
00096 magField, theRefittedTsos.second, theDerivatives.second );
00097
00098 theValidityFlag = valid1 && valid2;
00099
00100 return;
00101 }
00102
00103
00104 bool TwoBodyDecayTrajectoryState::propagateSingleState( const FreeTrajectoryState & fts,
00105 const GlobalTrajectoryParameters & gtp,
00106 const AlgebraicMatrix & startDeriv,
00107 const Surface & surface,
00108 const MagneticField* magField,
00109 TrajectoryStateOnSurface & tsos,
00110 AlgebraicMatrix & endDeriv ) const
00111 {
00112 AnalyticalPropagator propagator( magField );
00113
00114
00115 pair< TrajectoryStateOnSurface, double > tsosWithPath = propagator.propagateWithPath( fts, surface );
00116
00117
00118 if ( !tsosWithPath.first.isValid() ) return false;
00119
00120
00121 JacobianCartesianToCurvilinear cartToCurv( gtp );
00122 const AlgebraicMatrix56& matCartToCurv = cartToCurv.jacobian();
00123
00124
00125 AnalyticalCurvilinearJacobian curvJac( gtp, tsosWithPath.first.globalPosition(),
00126 tsosWithPath.first.globalMomentum(),
00127 tsosWithPath.second );
00128 const AlgebraicMatrix55& matCurvJac = curvJac.jacobian();
00129
00130
00131 JacobianCurvilinearToLocal curvToLoc( surface, tsosWithPath.first.localParameters(), *magField );
00132 const AlgebraicMatrix55& matCurvToLoc = curvToLoc.jacobian();
00133
00134 AlgebraicMatrix56 tmpDeriv = matCurvToLoc*matCurvJac*matCartToCurv;
00135 AlgebraicMatrix hepMatDeriv( asHepMatrix( tmpDeriv ) );
00136
00137
00138
00139 tsos = tsosWithPath.first;
00140
00141
00142 endDeriv = hepMatDeriv*startDeriv;
00143
00144 return true;
00145 }
00146
00147
00148 void TwoBodyDecayTrajectoryState::setError( FreeTrajectoryState& fts,
00149 AlgebraicMatrix& derivative ) const
00150 {
00151 AlgebraicSymMatrix ftsCartesianError( theParameters.covariance().similarity( derivative ) );
00152 fts.setCartesianError( asSMatrix<6>( ftsCartesianError ) );
00153 }