Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 
0002 #include "FWCore/Framework/interface/ESHandle.h"
0003 #include "FWCore/Framework/interface/ESProducer.h"
0004 
0005 #include "FWCore/Framework/interface/ESProducer.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0009 
0010 #include "TrackingTools/TrackFitters/interface/TrajectoryFitterRecord.h"
0011 
0012 #include "TrackingTools/TrackFitters/interface/TrajectoryFitter.h"
0013 
0014 namespace {
0015 
0016   class FlexibleKFFittingSmoother final : public TrajectoryFitter {
0017   public:
0018     ~FlexibleKFFittingSmoother() override {}
0019 
0020   private:
0021     /// constructor with predefined fitter and smoother and propagator
0022     FlexibleKFFittingSmoother(const TrajectoryFitter& standardFitter, const TrajectoryFitter& looperFitter)
0023         : theStandardFitter(standardFitter.clone()), theLooperFitter(looperFitter.clone()) {}
0024 
0025     Trajectory fitOne(const Trajectory& t, fitType type) const override { return fitter(type)->fitOne(t, type); }
0026 
0027     Trajectory fitOne(const TrajectorySeed& aSeed,
0028                       const RecHitContainer& hits,
0029                       const TrajectoryStateOnSurface& firstPredTsos,
0030                       fitType type) const override {
0031       return fitter(type)->fitOne(aSeed, hits, firstPredTsos, type);
0032     }
0033 
0034     Trajectory fitOne(const TrajectorySeed& aSeed, const RecHitContainer& hits, fitType type) const override {
0035       return fitter(type)->fitOne(aSeed, hits, type);
0036     }
0037 
0038     std::unique_ptr<TrajectoryFitter> clone() const override {
0039       return std::unique_ptr<TrajectoryFitter>(new FlexibleKFFittingSmoother(*theStandardFitter, *theLooperFitter));
0040     }
0041 
0042     // FIXME a prototype:  final inplementaiton may differ
0043     void setHitCloner(TkCloner const* hc) override {
0044       theStandardFitter->setHitCloner(hc);
0045       theLooperFitter->setHitCloner(hc);
0046     }
0047 
0048   private:
0049     const TrajectoryFitter* fitter(fitType type) const {
0050       return (type == standard) ? theStandardFitter.get() : theLooperFitter.get();
0051     }
0052 
0053     const std::unique_ptr<TrajectoryFitter> theStandardFitter;
0054     const std::unique_ptr<TrajectoryFitter> theLooperFitter;
0055 
0056     friend class FlexibleKFFittingSmootherESProducer;
0057   };
0058 
0059   class FlexibleKFFittingSmootherESProducer : public edm::ESProducer {
0060   public:
0061     FlexibleKFFittingSmootherESProducer(const edm::ParameterSet& p) {
0062       auto cc = setWhatProduced(this, p.getParameter<std::string>("ComponentName"));
0063       standardToken_ = cc.consumes(edm::ESInputTag("", p.getParameter<std::string>("standardFitter")));
0064       looperToken_ = cc.consumes(edm::ESInputTag("", p.getParameter<std::string>("looperFitter")));
0065     }
0066 
0067     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0068       edm::ParameterSetDescription desc;
0069       desc.add<std::string>("ComponentName", "FlexibleKFFittingSmoother");
0070       desc.add<std::string>("standardFitter", "KFFittingSmootherWithOutliersRejectionAndRK");
0071       desc.add<std::string>("looperFitter", "LooperFittingSmoother");
0072       descriptions.add("FlexibleKFFittingSmoother", desc);
0073     }
0074 
0075     std::unique_ptr<TrajectoryFitter> produce(const TrajectoryFitterRecord& iRecord) {
0076       return std::unique_ptr<TrajectoryFitter>(
0077           new FlexibleKFFittingSmoother(iRecord.get(standardToken_), iRecord.get(looperToken_)));
0078     }
0079 
0080   private:
0081     edm::ESGetToken<TrajectoryFitter, TrajectoryFitterRecord> standardToken_;
0082     edm::ESGetToken<TrajectoryFitter, TrajectoryFitterRecord> looperToken_;
0083   };
0084 
0085 }  // namespace
0086 
0087 #include "FWCore/Framework/interface/ModuleFactory.h"
0088 
0089 DEFINE_FWK_EVENTSETUP_MODULE(FlexibleKFFittingSmootherESProducer);