Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-20 02:47:05

0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/global/EDProducer.h"
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0011 
0012 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelFitter.h"
0013 #include "RecoPixelVertexing/PixelTrackFitting/interface/KFBasedPixelFitter.h"
0014 
0015 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0016 #include "TrackingTools/Records/interface/TransientRecHitRecord.h"
0017 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0018 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0019 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0020 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0021 
0022 class KFBasedPixelFitterProducer : public edm::global::EDProducer<> {
0023 public:
0024   explicit KFBasedPixelFitterProducer(const edm::ParameterSet& iConfig);
0025   ~KFBasedPixelFitterProducer() override {}
0026 
0027   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0028 
0029 private:
0030   void produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const override;
0031 
0032   edm::EDGetTokenT<reco::BeamSpot> theBeamSpotToken;
0033   const edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theTTRHBuilderToken;
0034   const edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropagatorToken;
0035   const edm::ESGetToken<Propagator, TrackingComponentsRecord> thePropagatorOppositeToken;
0036   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> theTrackerToken;
0037   const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theFieldToken;
0038   const edm::EDPutTokenT<PixelFitter> thePutToken;
0039 };
0040 
0041 KFBasedPixelFitterProducer::KFBasedPixelFitterProducer(const edm::ParameterSet& iConfig)
0042     : theTTRHBuilderToken(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("TTRHBuilder")))),
0043       thePropagatorToken(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("propagator")))),
0044       thePropagatorOppositeToken(esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("propagator")))),
0045       theTrackerToken(esConsumes()),
0046       theFieldToken(esConsumes()),
0047       thePutToken(produces()) {
0048   if (iConfig.getParameter<bool>("useBeamSpotConstraint")) {
0049     theBeamSpotToken = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpotConstraint"));
0050   }
0051 }
0052 
0053 void KFBasedPixelFitterProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0054   edm::ParameterSetDescription desc;
0055 
0056   desc.add<bool>("useBeamSpotConstraint", true);
0057   desc.add<edm::InputTag>("beamSpotConstraint", edm::InputTag("offlineBeamSpot"));
0058   desc.add<std::string>("propagator", "PropagatorWithMaterial");
0059   desc.add<std::string>("propagatorOpposite", "PropagatorWithMaterialOpposite");
0060   desc.add<std::string>("TTRHBuilder", "PixelTTRHBuilderWithoutAngle");
0061 
0062   descriptions.add("kfBasedPixelFitter", desc);
0063 }
0064 
0065 void KFBasedPixelFitterProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0066   const reco::BeamSpot* beamspot = nullptr;
0067   if (!theBeamSpotToken.isUninitialized()) {
0068     edm::Handle<reco::BeamSpot> hbs;
0069     iEvent.getByToken(theBeamSpotToken, hbs);
0070     beamspot = hbs.product();
0071   }
0072 
0073   iEvent.emplace(thePutToken,
0074                  std::make_unique<KFBasedPixelFitter>(&iSetup.getData(thePropagatorToken),
0075                                                       &iSetup.getData(thePropagatorOppositeToken),
0076                                                       &iSetup.getData(theTTRHBuilderToken),
0077                                                       &iSetup.getData(theTrackerToken),
0078                                                       &iSetup.getData(theFieldToken),
0079                                                       beamspot));
0080 }
0081 
0082 DEFINE_FWK_MODULE(KFBasedPixelFitterProducer);