Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-24 02:13:01

0001 // user includes
0002 #include "FWCore/Framework/interface/ESProducer.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/Framework/interface/ModuleFactory.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/PluginManager/interface/ModuleDef.h"
0011 #include "FWCore/Utilities/interface/InputTag.h"
0012 #include "FWCore/Utilities/interface/typelookup.h"
0013 #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h"
0014 #include "RecoTracker/Record/interface/MultiRecHitRecord.h"
0015 #include "RecoTracker/SiTrackerMRHTools/interface/GroupedDAFHitCollector.h"
0016 #include "RecoTracker/SiTrackerMRHTools/interface/MultiRecHitCollector.h"
0017 #include "RecoTracker/SiTrackerMRHTools/interface/SiTrackerMultiRecHitUpdator.h"
0018 #include "RecoTracker/SiTrackerMRHTools/interface/SimpleDAFHitCollector.h"
0019 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0020 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimatorBase.h"
0021 
0022 // system includes
0023 #include <string>
0024 #include <memory>
0025 
0026 class MultiRecHitCollectorESProducer : public edm::ESProducer {
0027 public:
0028   MultiRecHitCollectorESProducer(const edm::ParameterSet& iConfig);
0029   ~MultiRecHitCollectorESProducer() override = default;
0030   std::unique_ptr<MultiRecHitCollector> produce(const MultiRecHitRecord&);
0031 
0032 private:
0033   // es tokens
0034   edm::ESGetToken<SiTrackerMultiRecHitUpdator, MultiRecHitRecord> mrhToken;
0035   edm::ESGetToken<Propagator, CkfComponentsRecord> propAlongToken;
0036   edm::ESGetToken<Chi2MeasurementEstimatorBase, CkfComponentsRecord> chi2MeasToken;
0037   edm::ESGetToken<MeasurementTracker, CkfComponentsRecord> measToken;
0038   edm::ESGetToken<TrackerTopology, CkfComponentsRecord> topoToken;
0039   edm::ESGetToken<Propagator, CkfComponentsRecord> propOppositeToken;
0040 
0041   // configuration
0042   std::string myname_;
0043   std::string mrhupdator_;
0044   std::string propagatorAlongName_;
0045   std::string estimatorName_;
0046   std::string measurementTrackerName_;
0047   std::string mode_;
0048   bool debug_;
0049   std::string propagatorOppositeName_;
0050 };
0051 
0052 using namespace edm;
0053 
0054 MultiRecHitCollectorESProducer::MultiRecHitCollectorESProducer(const edm::ParameterSet& iConfig)
0055     : myname_(iConfig.getParameter<std::string>("ComponentName")),
0056       mrhupdator_(iConfig.getParameter<std::string>("MultiRecHitUpdator")),
0057       propagatorAlongName_(iConfig.getParameter<std::string>("propagatorAlong")),
0058       estimatorName_(iConfig.getParameter<std::string>("estimator")),
0059       measurementTrackerName_(iConfig.getParameter<std::string>("MeasurementTrackerName")),
0060       mode_(iConfig.getParameter<std::string>("Mode")),
0061       debug_(iConfig.getParameter<bool>("Debug")),
0062       propagatorOppositeName_(iConfig.getParameter<std::string>("propagatorOpposite")) {
0063   auto cc = setWhatProduced(this, myname_);
0064 
0065   mrhToken = cc.consumes();
0066   propAlongToken = cc.consumes(edm::ESInputTag("", propagatorAlongName_));
0067   chi2MeasToken = cc.consumes(edm::ESInputTag("", estimatorName_));
0068   measToken = cc.consumes(edm::ESInputTag("", measurementTrackerName_));
0069   topoToken = cc.consumes();
0070   propOppositeToken = cc.consumes(edm::ESInputTag("", propagatorOppositeName_));
0071 }
0072 
0073 std::unique_ptr<MultiRecHitCollector> MultiRecHitCollectorESProducer::produce(const MultiRecHitRecord& iRecord) {
0074   const SiTrackerMultiRecHitUpdator* mrhu = &iRecord.get(mrhToken);
0075   const Propagator* propagator = &iRecord.get(propAlongToken);
0076   const Chi2MeasurementEstimatorBase* estimator = &iRecord.get(chi2MeasToken);
0077   const MeasurementTracker* measurement = &iRecord.get(measToken);
0078   const TrackerTopology* trackerTopology = &iRecord.get(topoToken);
0079 
0080   if (mode_ == "Grouped") {
0081     const Propagator* propagatorOpposite = &iRecord.get(propOppositeToken);
0082 
0083     return std::make_unique<GroupedDAFHitCollector>(
0084         measurement, mrhu, estimator, propagator, propagatorOpposite, debug_);
0085   } else {
0086     return std::make_unique<SimpleDAFHitCollector>(trackerTopology, measurement, mrhu, estimator, propagator, debug_);
0087   }
0088 }
0089 
0090 DEFINE_FWK_EVENTSETUP_MODULE(MultiRecHitCollectorESProducer);