Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:14

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