Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:23:13

0001 #include <memory>
0002 #include "FWCore/Framework/interface/Frameworkfwd.h"
0003 #include "FWCore/Framework/interface/stream/EDProducer.h"
0004 
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/Utilities/interface/StreamID.h"
0010 
0011 #include "L1Trigger/L1TMuonBarrel/interface/L1TMuonBarrelKalmanAlgo.h"
0012 #include "L1Trigger/L1TMuonBarrel/interface/L1TMuonBarrelKalmanTrackFinder.h"
0013 #include "DataFormats/L1TMuon/interface/L1MuKBMTCombinedStub.h"
0014 #include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
0015 
0016 //
0017 // class declaration
0018 //
0019 
0020 class L1TMuonBarrelKalmanTrackProducer : public edm::stream::EDProducer<> {
0021 public:
0022   explicit L1TMuonBarrelKalmanTrackProducer(const edm::ParameterSet&);
0023   ~L1TMuonBarrelKalmanTrackProducer() override;
0024 
0025   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0026 
0027 private:
0028   void beginStream(edm::StreamID) override;
0029   void produce(edm::Event&, const edm::EventSetup&) override;
0030   void endStream() override;
0031   edm::EDGetTokenT<std::vector<L1MuKBMTCombinedStub> > src_;
0032   std::vector<int> bx_;
0033   L1TMuonBarrelKalmanAlgo* algo_;
0034   L1TMuonBarrelKalmanTrackFinder* trackFinder_;
0035 };
0036 L1TMuonBarrelKalmanTrackProducer::L1TMuonBarrelKalmanTrackProducer(const edm::ParameterSet& iConfig)
0037     : src_(consumes<std::vector<L1MuKBMTCombinedStub> >(iConfig.getParameter<edm::InputTag>("src"))),
0038       bx_(iConfig.getParameter<std::vector<int> >("bx")),
0039       algo_(new L1TMuonBarrelKalmanAlgo(iConfig.getParameter<edm::ParameterSet>("algoSettings"))),
0040       trackFinder_(new L1TMuonBarrelKalmanTrackFinder(iConfig.getParameter<edm::ParameterSet>("trackFinderSettings"))) {
0041   produces<L1MuKBMTrackBxCollection>();
0042   produces<l1t::RegionalMuonCandBxCollection>("BMTF");
0043 }
0044 
0045 L1TMuonBarrelKalmanTrackProducer::~L1TMuonBarrelKalmanTrackProducer() {
0046   if (algo_ != nullptr)
0047     delete algo_;
0048 
0049   if (trackFinder_ != nullptr)
0050     delete trackFinder_;
0051 
0052   // do anything here that needs to be done at destruction time
0053   // (e.g. close files, deallocate resources etc.)
0054 }
0055 
0056 //
0057 // member functions
0058 //
0059 
0060 // ------------ method called to produce the data  ------------
0061 void L1TMuonBarrelKalmanTrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0062   using namespace edm;
0063   Handle<std::vector<L1MuKBMTCombinedStub> > stubHandle;
0064   iEvent.getByToken(src_, stubHandle);
0065 
0066   L1MuKBMTCombinedStubRefVector stubs;
0067   for (uint i = 0; i < stubHandle->size(); ++i) {
0068     L1MuKBMTCombinedStubRef r(stubHandle, i);
0069     stubs.push_back(r);
0070   }
0071 
0072   std::unique_ptr<l1t::RegionalMuonCandBxCollection> outBMTF(new l1t::RegionalMuonCandBxCollection());
0073   std::unique_ptr<L1MuKBMTrackBxCollection> out(new L1MuKBMTrackBxCollection());
0074   outBMTF->setBXRange(bx_.front(), bx_.back());
0075   out->setBXRange(bx_.front(), bx_.back());
0076   for (const auto& bx : bx_) {
0077     L1MuKBMTrackCollection tmp = trackFinder_->process(algo_, stubs, bx);
0078     for (const auto& track : tmp) {
0079       out->push_back(bx, track);
0080       algo_->addBMTFMuon(bx, track, outBMTF);
0081     }
0082   }
0083   iEvent.put(std::move(outBMTF), "BMTF");
0084   iEvent.put(std::move(out));
0085 }
0086 
0087 // ------------ method called once each stream before processing any runs, lumis or events  ------------
0088 void L1TMuonBarrelKalmanTrackProducer::beginStream(edm::StreamID) {}
0089 
0090 // ------------ method called once each stream after processing all runs, lumis and events  ------------
0091 void L1TMuonBarrelKalmanTrackProducer::endStream() {}
0092 
0093 void L1TMuonBarrelKalmanTrackProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0094   //The following says we do not know what parameters are allowed so do no validation
0095   // Please change this to state exactly what you do use, even if it is no parameters
0096   edm::ParameterSetDescription desc;
0097   desc.setUnknown();
0098   descriptions.addDefault(desc);
0099 }
0100 
0101 //define this as a plug-in
0102 DEFINE_FWK_MODULE(L1TMuonBarrelKalmanTrackProducer);