CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Static Private Member Functions

SignedImpactParameter3D Class Reference

#include <SignedImpactParameter3D.h>

List of all members.

Public Member Functions

std::pair< bool, Measurement1Dapply (const reco::TransientTrack &, const GlobalVector &direction, const reco::Vertex &vertex) const
int id () const
 SignedImpactParameter3D ()

Static Public Member Functions

static std::pair< double,
Measurement1D
distanceWithJetAxis (const reco::TransientTrack &transientTrack, const GlobalVector &direction, const reco::Vertex &vertex)

Static Private Member Functions

static TrajectoryStateOnSurface closestApproachToJet (const FreeTrajectoryState &, const reco::Vertex &, const GlobalVector &, const MagneticField *)
static GlobalVector distance (const TrajectoryStateOnSurface &, const reco::Vertex &, const GlobalVector &)

Detailed Description

Threedimensional track impact parameter signed according to the jet direction

Definition at line 13 of file SignedImpactParameter3D.h.


Constructor & Destructor Documentation

SignedImpactParameter3D::SignedImpactParameter3D ( ) [inline]

Definition at line 19 of file SignedImpactParameter3D.h.

{};

Member Function Documentation

pair< bool, Measurement1D > SignedImpactParameter3D::apply ( const reco::TransientTrack transientTrack,
const GlobalVector direction,
const reco::Vertex vertex 
) const

Definition at line 17 of file SignedImpactParameter3D.cc.

References funct::A, abs, TrajectoryStateOnSurface::cartesianError(), IPTools::closestApproachToJet(), gather_cfg::cout, reco::Vertex::covariance(), funct::D, Vector3DBase< T, FrameTag >::dot(), reco::TransientTrack::field(), TrajectoryStateOnSurface::freeTrajectoryState(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), reco::TransientTrack::impactPointState(), TrajectoryStateOnSurface::isValid(), PV3DBase< T, PVType, FrameType >::mag(), CartesianTrajectoryError::matrix(), reco::Vertex::position(), mathSSE::sqrt(), Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), reco::Vertex::x(), PV3DBase< T, PVType, FrameType >::y(), reco::Vertex::y(), PV3DBase< T, PVType, FrameType >::z(), and reco::Vertex::z().

Referenced by ImpactParameterAlgorithm::tag().

       {

  double theValue=0.;
  double theError=0.;
  bool   theIsValid=false;

  TrajectoryStateOnSurface TSOS = transientTrack.impactPointState();
  
  if ( !TSOS.isValid() ) {
    cout << "====>>>> SignedImpactParameter3D::apply : TSOS not valid = " << TSOS.isValid() << endl ;
    return pair<bool,Measurement1D>(theIsValid,Measurement1D(0.,0.)) ;
   }
  
  FreeTrajectoryState * FTS = TSOS.freeTrajectoryState();

  GlobalVector JetDirection(direction);
  
  TrajectoryStateOnSurface theTSOS = closestApproachToJet(*FTS, vertex, JetDirection,transientTrack.field());
  theIsValid= theTSOS.isValid();

  if(theIsValid){
    
    GlobalVector D = distance(theTSOS, vertex, JetDirection);
    GlobalVector J = JetDirection.unit();
    GlobalPoint vertexPosition(vertex.x(),vertex.y(),vertex.z());
    double theDistanceAlongJetAxis = J.dot(theTSOS.globalPosition()-vertexPosition);
    theValue = D.mag()*(theDistanceAlongJetAxis/abs(theDistanceAlongJetAxis));


    GlobalVector DD = D.unit();
    GlobalPoint T0 = theTSOS.globalPosition();
    GlobalVector T1 = theTSOS.globalMomentum(); 
    GlobalVector TT1 = T1.unit();
    GlobalVector Xi(T0.x()-vertex.position().x(),T0.y()-vertex.position().y(),T0.z()-vertex.position().z());

    
    AlgebraicVector6 deriv;
    AlgebraicVector3 deriv_v;
    
    deriv_v[0] = - DD.x();
    deriv_v[1] = - DD.y();
    deriv_v[2] = - DD.z();

    deriv[0] = DD.x();
    deriv[1] = DD.y();
    deriv[2] = DD.z();
    deriv[3] =  - (TT1.dot(Xi)*DD.x())/T1.mag();
    deriv[4] =  - (TT1.dot(Xi)*DD.y())/T1.mag();
    deriv[5] =  - (TT1.dot(Xi)*DD.z())/T1.mag();

    double E1 = ROOT::Math::Similarity(deriv , theTSOS.cartesianError().matrix());
    double E2 = ROOT::Math::Similarity(deriv_v , vertex.covariance());
//    double E2 = RecoVertex::convertError(vertex.covariance()).matrix().similarity(deriv_v);
//    double E2 = 0.; // no vertex error because of stupid use of hundreds of different types for same thing 
    theError = sqrt(E1+E2);

    Measurement1D A(theValue, theError);

    return pair<bool,Measurement1D>(theIsValid,A);
  }
  else {
    return pair<bool,Measurement1D>(theIsValid,Measurement1D(0.,0.));
  }// endif (isValid)
}
TrajectoryStateOnSurface SignedImpactParameter3D::closestApproachToJet ( const FreeTrajectoryState aFTS,
const reco::Vertex vertex,
const GlobalVector aJetDirection,
const MagneticField field 
) [static, private]
GlobalVector SignedImpactParameter3D::distance ( const TrajectoryStateOnSurface aTSOS,
const reco::Vertex vertex,
const GlobalVector aJetDirection 
) [static, private]

Definition at line 99 of file SignedImpactParameter3D.cc.

References funct::D, TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), csvLumiCalc::unit, reco::Vertex::x(), X, reco::Vertex::y(), and reco::Vertex::z().

                                                                                                                                                 {

  Line::PositionType pos2(aTSOS.globalPosition());
  Line::DirectionType dir2((aTSOS.globalMomentum()).unit());
  Line T(pos2,dir2);
  
  GlobalPoint  X = GlobalPoint(vertex.x(),vertex.y(),vertex.z()); // aVertex.position();

  GlobalVector D = T.distance(X);

  return D;
}
pair< double, Measurement1D > SignedImpactParameter3D::distanceWithJetAxis ( const reco::TransientTrack transientTrack,
const GlobalVector direction,
const reco::Vertex vertex 
) [static]

Return a pair: first is the decay length second is the distance of the track from jet axis

Definition at line 112 of file SignedImpactParameter3D.cc.

References IPTools::closestApproachToJet(), gather_cfg::cout, Vector3DBase< T, FrameTag >::cross(), dir, Line::distance(), Vector3DBase< T, FrameTag >::dot(), reco::TransientTrack::field(), TrajectoryStateOnSurface::freeTrajectoryState(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), reco::TransientTrack::impactPointState(), TrajectoryStateOnSurface::isValid(), metsig::jet, mag(), P, pos, Line::position(), ExpressReco_HICollisions_FallBack::track, csvLumiCalc::unit, Vector3DBase< T, FrameTag >::unit(), CommonMethods::weight(), PV3DBase< T, PVType, FrameType >::x(), reco::Vertex::x(), PV3DBase< T, PVType, FrameType >::y(), reco::Vertex::y(), PV3DBase< T, PVType, FrameType >::z(), and reco::Vertex::z().

                                                                                                                                                           {
  double theDistanceAlongJetAxis(0.);
  double theDistanceToJetAxis(0.);
  double  theLDist_err(0.);
  TrajectoryStateOnSurface TSOS = track.impactPointState();

  if ( !TSOS.isValid() ) {
    cout << "====>>>> SignedImpactParameter3D::distanceWithJetAxis : TSOS not valid = " << TSOS.isValid() << endl ;
    return pair<double,Measurement1D> (theDistanceAlongJetAxis,Measurement1D(theDistanceToJetAxis,theLDist_err));
  }
  
  FreeTrajectoryState * FTS = TSOS.freeTrajectoryState();

  GlobalVector jetDirection(direction);

  //
  // Check whether the track has been used in the vertex
  //

  //FIXME
  float weight=0.;//vertex.trackWeight(aRecTrack);

  TrajectoryStateOnSurface stateAtOrigin = track.impactPointState(); 
  TrajectoryStateOnSurface aTSOS = closestApproachToJet(*FTS, vertex, jetDirection, track.field());
  bool isValid= stateAtOrigin.isValid();
  //  bool IsValid= aTSOS.isValid();

  if(isValid){
    
    //get the Track line at origin
    Line::PositionType pos(stateAtOrigin.globalPosition());
    Line::DirectionType dir((stateAtOrigin.globalMomentum()).unit());
    Line track(pos,dir);
    // get the Jet  line 
   // Vertex vertex(vertex);
    GlobalVector jetVector = jetDirection.unit();    
    Line::PositionType pos2(GlobalPoint(vertex.x(),vertex.y(),vertex.z()));
    Line::DirectionType dir2(jetVector);
    Line jet(pos2,dir2);
    // now compute the distance between the two lines
    // If the track has been used to refit the Primary vertex then sign it positively, otherwise negative

    theDistanceToJetAxis = (jet.distance(track)).mag();
    if (weight<1) theDistanceToJetAxis= -theDistanceToJetAxis;

    // ... and the flight distance along the Jet axis.
    GlobalPoint  V = jet.position();    
    GlobalVector Q = dir - jetVector.dot(dir) * jetVector;
    GlobalVector P = jetVector - jetVector.dot(dir) * dir;
    theDistanceAlongJetAxis = P.dot(V-pos)/Q.dot(dir);

    //
    // get the covariance matrix of the vertex and compute the error on theDistanceToJetAxis
    //
    

    // build the vector of closest approach between lines

    GlobalVector H((jetVector.cross(dir).unit()));
    
    CLHEP::HepVector Hh(3);
    Hh[0] = H.x();
    Hh[1] = H.y();
    Hh[2] = H.z();
    
  //  theLDist_err = sqrt(vertexError.similarity(Hh));

    //    cout << "distance to jet axis : "<< theDistanceToJetAxis <<" and error : "<< theLDist_err<<endl;
    // Now the impact parameter ...

/*    GlobalPoint T0 = track.position();
    GlobalVector D = (T0-V)- (T0-V).dot(dir) * dir;
    double IP = D.mag();    
    GlobalVector Dold = distance(aTSOS, aJet.vertex(), jetDirection);
    double IPold = Dold.mag();
*/



  }
  Measurement1D DTJA(theDistanceToJetAxis,theLDist_err);
  
  return pair<double,Measurement1D> (theDistanceAlongJetAxis,DTJA);
}
int SignedImpactParameter3D::id ( void  ) const [inline]

Definition at line 23 of file SignedImpactParameter3D.h.

{return 2;}