CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Alignment/TwoBodyDecay/src/TwoBodyDecayModel.cc

Go to the documentation of this file.
00001 
00002 #include "Alignment/TwoBodyDecay/interface/TwoBodyDecayModel.h"
00003 
00004 
00005 TwoBodyDecayModel::TwoBodyDecayModel( double mPrimary, double mSecondary ) :
00006   thePrimaryMass( mPrimary ), theSecondaryMass( mSecondary ) {}
00007 
00008 
00009 TwoBodyDecayModel::~TwoBodyDecayModel() {}
00010 
00011 
00012 AlgebraicMatrix TwoBodyDecayModel::rotationMatrix( double px, double py, double pz )
00013 {
00014   // compute transverse and absolute momentum
00015   double pT2 = px*px + py*py;
00016   double p2 = pT2 + pz*pz;
00017   double pT = sqrt( pT2 );
00018   double p = sqrt( p2 );
00019 
00020   AlgebraicMatrix rotMat( 3, 3 );
00021 
00022   // compute rotation matrix
00023   rotMat[0][0] = px*pz/pT/p;
00024   rotMat[0][1] = -py/pT;
00025   rotMat[0][2] = px/p;
00026 
00027   rotMat[1][0] = py*pz/pT/p;
00028   rotMat[1][1] = px/pT;
00029   rotMat[1][2] = py/p;
00030 
00031   rotMat[2][0] = -pT/p;
00032   rotMat[2][1] = 0.;
00033   rotMat[2][2] = pz/p;
00034 
00035   return rotMat;
00036 }
00037 
00038 
00039 AlgebraicMatrix TwoBodyDecayModel::curvilinearToCartesianJacobian( double rho, double theta, double phi, double zMagField )
00040 {
00041   double q = ( ( rho < 0 ) ? -1. : 1. );
00042   double conv = q*zMagField;
00043 
00044   double stheta = sin( theta );
00045   double ctheta = cos( theta );
00046   double sphi = sin( phi );
00047   double cphi = cos( phi );
00048 
00049   AlgebraicMatrix curv2cart( 3, 3 );
00050 
00051   curv2cart[0][0] = -rho*cphi;
00052   curv2cart[0][1] = -rho*sphi;
00053   curv2cart[0][2] = 0.;
00054 
00055   curv2cart[1][0] = cphi*stheta*ctheta;
00056   curv2cart[1][1] = sphi*stheta*ctheta;
00057   curv2cart[1][2] = -stheta*stheta;
00058 
00059   curv2cart[2][0] = -sphi;
00060   curv2cart[2][1] = cphi;
00061   curv2cart[2][2] = 0.;
00062 
00063   curv2cart *= rho/conv;
00064 
00065   return curv2cart;
00066 }
00067 
00068 
00069 AlgebraicMatrix TwoBodyDecayModel::curvilinearToCartesianJacobian( AlgebraicVector curv, double zMagField )
00070 {
00071   return this->curvilinearToCartesianJacobian( curv[0], curv[1], curv[2], zMagField );
00072 }
00073 
00074 
00075 AlgebraicVector TwoBodyDecayModel::convertCurvilinearToCartesian( AlgebraicVector curv, double zMagField )
00076 {
00077   double rt = fabs( zMagField/curv[0] );
00078 
00079   AlgebraicVector cart( 3 );
00080   cart[0] = rt*cos( curv[2] );
00081   cart[1] = rt*sin( curv[2] );
00082   cart[2] = rt/tan( curv[1] );
00083 
00084   return cart;
00085 }
00086 
00087 
00088 const std::pair< AlgebraicVector, AlgebraicVector > TwoBodyDecayModel::cartesianSecondaryMomenta( const AlgebraicVector & param )
00089 {
00090   double px = param[TwoBodyDecayParameters::px];
00091   double py = param[TwoBodyDecayParameters::py];
00092   double pz = param[TwoBodyDecayParameters::pz];
00093   double theta = param[TwoBodyDecayParameters::theta];
00094   double phi = param[TwoBodyDecayParameters::phi];
00095 
00096   // compute transverse and absolute momentum
00097   double pT2 = px*px + py*py;
00098   double p2 = pT2 + pz*pz;
00099   double p = sqrt( p2 );
00100 
00101   double sphi = sin( phi );
00102   double cphi = cos( phi );
00103   double stheta = sin( theta );
00104   double ctheta = cos( theta );
00105 
00106   // some constants from kinematics
00107   double c1 = 0.5*thePrimaryMass/theSecondaryMass;
00108   double c2 = sqrt( c1*c1 - 1. );
00109   double c3 = 0.5*c2*ctheta/c1;
00110   double c4 = sqrt( p2 + thePrimaryMass*thePrimaryMass );
00111 
00112   // momentum of decay particle 1 in the primary's boosted frame
00113   AlgebraicMatrix pplus( 3, 1 );
00114   pplus[0][0] = theSecondaryMass*c2*stheta*cphi;
00115   pplus[1][0] = theSecondaryMass*c2*stheta*sphi;
00116   pplus[2][0] = 0.5*p + c3*c4;
00117 
00118   // momentum of decay particle 2 in the primary's boosted frame
00119   AlgebraicMatrix pminus( 3, 1 );
00120   pminus[0][0] = -pplus[0][0];
00121   pminus[1][0] = -pplus[1][0];
00122   pminus[2][0] = 0.5*p - c3*c4;
00123 
00124   AlgebraicMatrix rotMat = rotationMatrix( px, py, pz );
00125 
00126   return std::make_pair( rotMat*pplus, rotMat*pminus );
00127 }
00128 
00129 
00130 const std::pair< AlgebraicVector, AlgebraicVector > TwoBodyDecayModel::cartesianSecondaryMomenta( const TwoBodyDecay & tbd )
00131 {
00132   return cartesianSecondaryMomenta( tbd.parameters() );
00133 }
00134 
00135 const std::pair< AlgebraicVector, AlgebraicVector > TwoBodyDecayModel::cartesianSecondaryMomenta( const TwoBodyDecayParameters & tbdparam )
00136 {
00137   return cartesianSecondaryMomenta( tbdparam.parameters() );
00138 }