Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:47

0001 #ifndef CD_KFTrajectorySmoother_H_
0002 #define CD_KFTrajectorySmoother_H_
0003 
0004 /** \class KFTrajectorySmoother
0005  *  A Standard Kalman smoother. The forward fit is not redone,
0006  *  only the backward smoothing. Ported from ORCA
0007  *
0008  *  \author todorov, cerati
0009  */
0010 
0011 #include "TrackingTools/PatternTools/interface/TrajectorySmoother.h"
0012 #include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h"
0013 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0014 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0015 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
0016 #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h"
0017 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
0018 #include "TrackingTools/DetLayers/interface/DetLayerGeometry.h"
0019 
0020 class KFTrajectorySmoother final : public TrajectorySmoother {
0021 private:
0022   typedef TrajectoryStateOnSurface TSOS;
0023   typedef FreeTrajectoryState FTS;
0024   typedef TrajectoryMeasurement TM;
0025 
0026 public:
0027   KFTrajectorySmoother(const Propagator& aPropagator,
0028                        const TrajectoryStateUpdator& aUpdator,
0029                        const MeasurementEstimator& aEstimator,
0030                        float errorRescaling = 100.f,
0031                        int minHits = 3)
0032       : theAlongPropagator(nullptr),
0033         theOppositePropagator(nullptr),
0034         theUpdator(aUpdator.clone()),
0035         theEstimator(aEstimator.clone()),
0036         theErrorRescaling(errorRescaling),
0037         minHits_(minHits),
0038         // to be fixed. Why this first constructor is needed? who is using it? Can it be removed?
0039         theGeometry(nullptr) {
0040     if (!theGeometry)
0041       theGeometry = &dummyGeometry;
0042     auto p = aPropagator.clone();
0043     p->setPropagationDirection(alongMomentum);
0044     theAlongPropagator = p;
0045     p = aPropagator.clone();
0046     p->setPropagationDirection(oppositeToMomentum);
0047     theOppositePropagator = p;
0048   }
0049 
0050   KFTrajectorySmoother(const Propagator* aPropagator,
0051                        const TrajectoryStateUpdator* aUpdator,
0052                        const MeasurementEstimator* aEstimator,
0053                        float errorRescaling = 100.f,
0054                        int minHits = 3,
0055                        const DetLayerGeometry* detLayerGeometry = nullptr,
0056                        TkCloner const* hc = nullptr)
0057       : theAlongPropagator(nullptr),
0058         theOppositePropagator(nullptr),
0059         theUpdator(aUpdator->clone()),
0060         theEstimator(aEstimator->clone()),
0061         theHitCloner(hc),
0062         theErrorRescaling(errorRescaling),
0063         minHits_(minHits),
0064         theGeometry(detLayerGeometry) {
0065     if (!theGeometry)
0066       theGeometry = &dummyGeometry;
0067     auto p = aPropagator->clone();
0068     p->setPropagationDirection(alongMomentum);
0069     theAlongPropagator = p;
0070     p = aPropagator->clone();
0071     p->setPropagationDirection(oppositeToMomentum);
0072     theOppositePropagator = p;
0073   }
0074 
0075   ~KFTrajectorySmoother() override;
0076 
0077   Trajectory trajectory(const Trajectory& aTraj) const override;
0078 
0079   const Propagator* alongPropagator() const { return theAlongPropagator; }
0080   const Propagator* oppositePropagator() const { return theOppositePropagator; }
0081 
0082   const TrajectoryStateUpdator* updator() const { return theUpdator; }
0083   const MeasurementEstimator* estimator() const { return theEstimator; }
0084 
0085   KFTrajectorySmoother* clone() const override {
0086     return new KFTrajectorySmoother(
0087         theAlongPropagator, theUpdator, theEstimator, theErrorRescaling, minHits_, theGeometry, theHitCloner);
0088   }
0089 
0090   // FIXME a prototype:  final inplementaiton may differ
0091   void setHitCloner(TkCloner const* hc) override { theHitCloner = hc; }
0092 
0093 private:
0094   const DetLayerGeometry dummyGeometry;
0095   const Propagator* theAlongPropagator;
0096   const Propagator* theOppositePropagator;
0097   const TrajectoryStateUpdator* theUpdator;
0098   const MeasurementEstimator* theEstimator;
0099   TkCloner const* theHitCloner = nullptr;
0100   float theErrorRescaling;
0101   int minHits_;
0102   const DetLayerGeometry* theGeometry;
0103 };
0104 
0105 #endif  //CD_KFTrajectorySmoother_H_