File indexing completed on 2024-04-06 12:27:01
0001 #include <string>
0002 #include <vector>
0003
0004 #include "DataFormats/Common/interface/ValueMap.h"
0005 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0006 #include "DataFormats/MuonReco/interface/Muon.h"
0007 #include "DataFormats/TrackReco/interface/Track.h"
0008 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0009
0010 #include "FWCore/Framework/interface/stream/EDProducer.h"
0011 #include "FWCore/Framework/interface/Event.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/Frameworkfwd.h"
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016
0017 #include "RecoMuon/MuonIdentification/interface/MuonShowerInformationFiller.h"
0018
0019 class MuonShowerInformationProducer : public edm::stream::EDProducer<> {
0020 public:
0021 MuonShowerInformationProducer(const edm::ParameterSet& iConfig)
0022 : inputMuonCollection_(iConfig.getParameter<edm::InputTag>("muonCollection")),
0023 inputTrackCollection_(iConfig.getParameter<edm::InputTag>("trackCollection")) {
0024 edm::ConsumesCollector iC = consumesCollector();
0025 showerFiller_ = new MuonShowerInformationFiller(
0026 iConfig.getParameter<edm::ParameterSet>("ShowerInformationFillerParameters"), iC);
0027
0028 muonToken_ = consumes<reco::MuonCollection>(inputMuonCollection_);
0029
0030 produces<edm::ValueMap<reco::MuonShower>>().setBranchAlias("muonShowerInformation");
0031 }
0032 ~MuonShowerInformationProducer() override {
0033 if (showerFiller_)
0034 delete showerFiller_;
0035 }
0036
0037 private:
0038 void produce(edm::Event&, const edm::EventSetup&) override;
0039 edm::InputTag inputMuonCollection_;
0040 edm::InputTag inputTrackCollection_;
0041 edm::EDGetTokenT<reco::MuonCollection> muonToken_;
0042
0043 MuonShowerInformationFiller* showerFiller_;
0044 };
0045
0046 void MuonShowerInformationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0047 edm::Handle<reco::MuonCollection> muons;
0048 iEvent.getByToken(muonToken_, muons);
0049
0050
0051 std::vector<reco::MuonShower> showerInfoValues;
0052 showerInfoValues.reserve(muons->size());
0053
0054 for (reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
0055
0056 showerInfoValues.push_back(showerFiller_->fillShowerInformation(*muon, iEvent, iSetup));
0057 }
0058
0059
0060 auto outC = std::make_unique<edm::ValueMap<reco::MuonShower>>();
0061 edm::ValueMap<reco::MuonShower>::Filler fillerC(*outC);
0062 fillerC.insert(muons, showerInfoValues.begin(), showerInfoValues.end());
0063 fillerC.fill();
0064
0065
0066 iEvent.put(std::move(outC));
0067 }
0068 DEFINE_FWK_MODULE(MuonShowerInformationProducer);