Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:17

0001 #include "RecoVertex/KinematicFitPrimitives/interface/TransientTrackKinematicParticle.h"
0002 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
0003 
0004 using namespace reco;
0005 
0006 TransientTrackKinematicParticle::TransientTrackKinematicParticle(
0007     const KinematicState& kineState,
0008     float& chiSquared,
0009     float& degreesOfFr,
0010     KinematicConstraint* lastConstraint,
0011     ReferenceCountingPointer<KinematicParticle> previousParticle,
0012     KinematicStatePropagator* pr,
0013     const TransientTrack* initialTrack) {
0014   theField = kineState.magneticField();
0015   if (previousParticle.get() == nullptr) {
0016     initState = kineState;
0017   } else {
0018     initState = previousParticle->initialState();
0019   }
0020   cState = kineState;
0021   inTrack = initialTrack;
0022   pState = previousParticle;
0023   chi2 = chiSquared;
0024   ndf = degreesOfFr;
0025   lConstraint = lastConstraint;
0026   if (pr != nullptr) {
0027     propagator = pr->clone();
0028   } else {
0029     propagator = new TrackKinematicStatePropagator();
0030   }
0031   tree = nullptr;
0032 }
0033 
0034 TransientTrackKinematicParticle::~TransientTrackKinematicParticle() { delete propagator; }
0035 
0036 bool TransientTrackKinematicParticle::operator==(const KinematicParticle& other) const {
0037   bool dc = false;
0038 
0039   //first looking if this is an object of the same type
0040   const KinematicParticle* lp = &other;
0041   const TransientTrackKinematicParticle* lPart = dynamic_cast<const TransientTrackKinematicParticle*>(lp);
0042   if (lPart != nullptr) {
0043     //then comparing particle with their initial TransientTracks
0044     if ((initialTransientTrack()) && (lPart->initialTransientTrack())) {
0045       if (initialTransientTrack() == lPart->initialTransientTrack())
0046         dc = true;
0047     } else {
0048       if (initialState() == lPart->initialState())
0049         dc = true;
0050     }
0051   }
0052   return dc;
0053 }
0054 
0055 bool TransientTrackKinematicParticle::operator==(const ReferenceCountingPointer<KinematicParticle>& other) const {
0056   bool res = false;
0057   if (*this == *other)
0058     res = true;
0059   return res;
0060 }
0061 
0062 bool TransientTrackKinematicParticle::operator!=(const KinematicParticle& other) const {
0063   if (*this == other) {
0064     return false;
0065   } else {
0066     return true;
0067   }
0068 }
0069 
0070 KinematicState TransientTrackKinematicParticle::stateAtPoint(const GlobalPoint& point) const {
0071   GlobalPoint iP = cState.kinematicParameters().position();
0072   if ((iP.x() == point.x()) && (iP.y() == point.y()) && (iP.z() == point.z())) {
0073     return cState;
0074   } else {
0075     return propagator->propagateToTheTransversePCA(cState, point);
0076   }
0077 }
0078 
0079 //FreeTrajectoryState TransientTrackKinematicParticle::initialStateFTS() const
0080 //{return initState.freeTrajectoryState();}
0081 
0082 const TransientTrack* TransientTrackKinematicParticle::initialTransientTrack() const { return inTrack; }
0083 
0084 ReferenceCountingPointer<KinematicParticle> TransientTrackKinematicParticle::refittedParticle(
0085     const KinematicState& state, float chi2, float ndf, KinematicConstraint* cons) const {
0086   TransientTrackKinematicParticle* ncp = const_cast<TransientTrackKinematicParticle*>(this);
0087   return ReferenceCountingPointer<KinematicParticle>(new TransientTrackKinematicParticle(
0088       state, chi2, ndf, cons, ReferenceCountingPointer<KinematicParticle>(ncp), propagator, initialTransientTrack()));
0089 }
0090 
0091 TransientTrackKinematicParticle::RefCountedLinearizedTrackState
0092 TransientTrackKinematicParticle::particleLinearizedTrackState(const GlobalPoint& point) const {
0093   TransientTrackKinematicParticle* cr = const_cast<TransientTrackKinematicParticle*>(this);
0094   RefCountedKinematicParticle lp = ReferenceCountingPointer<KinematicParticle>(cr);
0095   return linFactory.linearizedTrackState(point, lp);
0096 }