CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/RecoBTag/BTagTools/src/SignedDecayLength3D.cc

Go to the documentation of this file.
00001 #include <string>
00002 
00003 #include "RecoBTag/BTagTools/interface/SignedDecayLength3D.h"
00004 
00005 #include "DataFormats/GeometrySurface/interface/Line.h"
00006 
00007 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00008 #include "TrackingTools/GeomPropagators/interface/AnalyticalTrajectoryExtrapolatorToLine.h"
00009 #include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"
00010 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00011 
00012 #include "CLHEP/Vector/ThreeVector.h"
00013 #include "CLHEP/Vector/LorentzVector.h"
00014 #include "CLHEP/Matrix/Vector.h"
00015 
00016 using namespace std;
00017 using namespace reco;
00018 
00019 pair<bool,Measurement1D> SignedDecayLength3D::apply(const TransientTrack & transientTrack,
00020                  const GlobalVector & direction, const  Vertex & vertex)  {
00021 
00022   double theError=0.;
00023   bool theIsValid;
00024 
00025   //TrajectoryStateOnSurface TSOS = (aRecTrack).impactPointStateOnSurface();
00026   TrajectoryStateOnSurface TSOS = transientTrack.impactPointState();
00027   FreeTrajectoryState * FTS = TSOS.freeTrajectoryState();
00028 
00029   TrajectoryStateOnSurface theTSOS = closestApproachToJet(*FTS, vertex, direction,transientTrack.field());
00030   theIsValid= theTSOS.isValid();
00031 
00032   if(theIsValid){
00033     GlobalVector J = direction.unit();
00034     GlobalPoint vertexPosition(vertex.x(),vertex.y(),vertex.z());
00035   
00036     double theValue = J.dot(theTSOS.globalPosition()-vertexPosition);
00037 
00038     //error calculation
00039 
00040     AlgebraicVector3 j;
00041     j[0] = J.x();
00042     j[1] = J.y();
00043     j[2] = J.z();
00044     AlgebraicVector6 jj;
00045     jj[0] = J.x();
00046     jj[1] = J.y();
00047     jj[2] = J.z();
00048     jj[3] =0.;
00049     jj[4] =0.;
00050     jj[5] =0.;
00051     double E1 = ROOT::Math::Similarity(jj,theTSOS.cartesianError().matrix());
00052   //  double E2 = (aJet.vertex().positionError().matrix()).similarity(j);
00053     double E2 = ROOT::Math::Similarity(j,vertex.covariance());
00054 
00055     theError = sqrt(E1+E2);
00056     
00057 
00058 //cout<< "Error ="<< theError<<endl;
00059     Measurement1D A(theValue, theError);
00060     return pair<bool,Measurement1D>(theIsValid,A);
00061   }else{
00062     return pair<bool,Measurement1D>(theIsValid,Measurement1D(0.,0.));
00063   }// endif (isValid)
00064 }// end constructor declaration
00065 
00066 
00067 TrajectoryStateOnSurface SignedDecayLength3D::closestApproachToJet(const FreeTrajectoryState & aFTS,const Vertex & vertex, const GlobalVector& aJetDirection,const MagneticField * field) {
00068 
00069   GlobalVector J =aJetDirection.unit();
00070 
00071   Line::PositionType pos(GlobalPoint(vertex.x(),vertex.y(),vertex.z()));
00072   Line::DirectionType dir(J);
00073   Line Jet(pos,dir);
00074 
00075   AnalyticalTrajectoryExtrapolatorToLine TETL(field);
00076 
00077   return TETL.extrapolate(aFTS, Jet);
00078 }