CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/RecoVertex/KinematicFitPrimitives/src/VirtualKinematicParticle.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KinematicFitPrimitives/interface/VirtualKinematicParticle.h"
00002 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00003 
00004 VirtualKinematicParticle::VirtualKinematicParticle
00005         (const KinematicState& kineState, float& chiSquared, float& degreesOfFr,
00006          KinematicConstraint * lastConstraint,
00007          ReferenceCountingPointer<KinematicParticle> previousParticle,
00008          KinematicStatePropagator * pr)
00009 {
00010   theField = kineState.magneticField();
00011  if(previousParticle.get() == 0)
00012  {
00013   initState = kineState;
00014  }else{initState = previousParticle->initialState();}
00015  cState = kineState;
00016  pState = previousParticle;
00017  chi2 = chiSquared;
00018  ndf = degreesOfFr;
00019  lConstraint = lastConstraint;
00020  if(pr != 0)
00021  {
00022   propagator = pr->clone();
00023  }else{
00024   propagator = new TrackKinematicStatePropagator();
00025  }
00026  tree = 0;
00027 }
00028 
00029 VirtualKinematicParticle::~VirtualKinematicParticle()
00030 {delete propagator;}
00031 
00032 bool VirtualKinematicParticle::operator==(const KinematicParticle& other)const
00033 {
00034  bool dc = false;
00035 
00036 //first looking if this is an object of the same type
00037  const  KinematicParticle * lp = &other;
00038  const VirtualKinematicParticle * lPart = dynamic_cast<const VirtualKinematicParticle * >(lp);
00039  if(lPart != 0 && initialState() == lPart->initialState()) dc = true;
00040  return dc;
00041 }
00042 
00043 bool VirtualKinematicParticle::operator==(const ReferenceCountingPointer<KinematicParticle>& other) const
00044 {
00045  bool res = false;
00046  if(*this == *other) res = true;
00047  return res;
00048 }
00049 
00050 bool VirtualKinematicParticle::operator!=(const KinematicParticle& other)const
00051 {
00052  if (*this == other){
00053   return false;
00054  }else{return true;}
00055 }
00056 
00057 KinematicState VirtualKinematicParticle::stateAtPoint(const GlobalPoint& point)const
00058 {
00059  GlobalPoint iP = cState.kinematicParameters().position();
00060  if((iP.x() == point.x())&&(iP.y() == point.y())&&(iP.z() == point.z()))
00061  {
00062   return cState ;
00063  }else{return propagator->propagateToTheTransversePCA(cState,point);} }
00064 
00065 RefCountedKinematicParticle VirtualKinematicParticle::refittedParticle(const KinematicState& state,
00066                                                        float chi2, float ndf, KinematicConstraint * cons)const
00067 {
00068  VirtualKinematicParticle * ncp = const_cast<VirtualKinematicParticle * >(this);
00069  ReferenceCountingPointer<KinematicParticle> current = ReferenceCountingPointer<KinematicParticle>(ncp);
00070  return ReferenceCountingPointer<KinematicParticle>(new VirtualKinematicParticle(state,chi2,ndf,cons,current,
00071                                                                                                 propagator));
00072 }
00073 
00074 VirtualKinematicParticle::RefCountedLinearizedTrackState
00075 VirtualKinematicParticle::particleLinearizedTrackState(const GlobalPoint& point)const
00076 {
00077  VirtualKinematicParticle * cr = const_cast<VirtualKinematicParticle * >(this);
00078  RefCountedKinematicParticle lp = ReferenceCountingPointer<KinematicParticle>(cr);
00079  return linFactory.linearizedTrackState(point,lp);
00080 }