Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:38

0001 #ifndef CD_KFTrajectoryFitter_H_
0002 #define CD_KFTrajectoryFitter_H_
0003 
0004 /** \class KFTrajectoryFitter
0005  *  A Standard Kalman fit. Ported from ORCA
0006  *
0007  *  \author todorov, cerati
0008  */
0009 
0010 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0011 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0012 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
0013 #include "TrackingTools/PatternTools/interface/TrajectoryStateUpdator.h"
0014 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0015 #include "TrackingTools/TrackFitters/interface/TrajectoryFitter.h"
0016 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
0017 #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h"
0018 #include "TrackingTools/DetLayers/interface/DetLayerGeometry.h"
0019 
0020 #include <memory>
0021 
0022 class KFTrajectoryFitter final : public TrajectoryFitter {
0023 private:
0024   typedef TrajectoryStateOnSurface TSOS;
0025   typedef FreeTrajectoryState FTS;
0026   typedef TrajectoryMeasurement TM;
0027 
0028 public:
0029   // backward compatible (too many places it uses as such...)
0030   KFTrajectoryFitter(const Propagator& aPropagator,
0031                      const TrajectoryStateUpdator& aUpdator,
0032                      const MeasurementEstimator& aEstimator,
0033                      int minHits = 3,
0034                      const DetLayerGeometry* detLayerGeometry = nullptr,
0035                      TkCloner const* hc = nullptr)
0036       : thePropagator(aPropagator.clone()),
0037         theUpdator(aUpdator.clone()),
0038         theEstimator(aEstimator.clone()),
0039         theHitCloner(hc),
0040         theGeometry(detLayerGeometry),
0041         minHits_(minHits),
0042         owner(true) {
0043     if (!theGeometry)
0044       theGeometry = &dummyGeometry;
0045     // FIXME. Why this first constructor is needed? who is using it? Can it be removed?
0046     // it is uses in many many places
0047   }
0048 
0049   KFTrajectoryFitter(const Propagator* aPropagator,
0050                      const TrajectoryStateUpdator* aUpdator,
0051                      const MeasurementEstimator* aEstimator,
0052                      int minHits = 3,
0053                      const DetLayerGeometry* detLayerGeometry = nullptr,
0054                      TkCloner const* hc = nullptr)
0055       : thePropagator(aPropagator),
0056         theUpdator(aUpdator),
0057         theEstimator(aEstimator),
0058         theHitCloner(hc),
0059         theGeometry(detLayerGeometry),
0060         minHits_(minHits),
0061         owner(false) {
0062     if (!theGeometry)
0063       theGeometry = &dummyGeometry;
0064   }
0065 
0066   KFTrajectoryFitter(KFTrajectoryFitter const&) = delete;
0067 
0068   ~KFTrajectoryFitter() override {
0069     if (owner) {
0070       delete thePropagator;
0071       delete theUpdator;
0072       delete theEstimator;
0073     }
0074   }
0075 
0076   Trajectory fitOne(const Trajectory& aTraj, fitType) const override;
0077   Trajectory fitOne(const TrajectorySeed& aSeed, const RecHitContainer& hits, fitType) const override;
0078 
0079   Trajectory fitOne(const TrajectorySeed& aSeed,
0080                     const RecHitContainer& hits,
0081                     const TSOS& firstPredTsos,
0082                     fitType) const override;
0083 
0084   const Propagator* propagator() const { return thePropagator; }
0085   const TrajectoryStateUpdator* updator() const { return theUpdator; }
0086   const MeasurementEstimator* estimator() const { return theEstimator; }
0087 
0088   std::unique_ptr<TrajectoryFitter> clone() const override {
0089     return owner ? std::unique_ptr<TrajectoryFitter>(new KFTrajectoryFitter(
0090                        *thePropagator, *theUpdator, *theEstimator, minHits_, theGeometry, theHitCloner))
0091                  : std::unique_ptr<TrajectoryFitter>(new KFTrajectoryFitter(
0092                        thePropagator, theUpdator, theEstimator, minHits_, theGeometry, theHitCloner));
0093   }
0094 
0095   // FIXME a prototype: final inplementaiton may differ
0096   void setHitCloner(TkCloner const* hc) override { theHitCloner = hc; }
0097 
0098 private:
0099   static const DetLayerGeometry dummyGeometry;
0100   const Propagator* thePropagator;
0101   const TrajectoryStateUpdator* theUpdator;
0102   const MeasurementEstimator* theEstimator;
0103   TkCloner const* theHitCloner = nullptr;
0104   const DetLayerGeometry* theGeometry;
0105   int minHits_;
0106   bool owner;
0107 };
0108 
0109 #endif  //CD_KFTrajectoryFitter_H_