Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:55

0001 // -*- C++ -*-
0002 //
0003 // Package:    MuonIdentification
0004 // Class:      MuonLinksProducer
0005 //
0006 //
0007 // Original Author:  Dmytro Kovalskyi
0008 //
0009 //
0010 
0011 // system include files
0012 #include <memory>
0013 
0014 // user include files
0015 #include "FWCore/Framework/interface/Frameworkfwd.h"
0016 //#include "FWCore/Framework/interface/EDProducer.h"
0017 
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/Framework/interface/EventSetup.h"
0020 
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022 
0023 #include "DataFormats/Common/interface/Handle.h"
0024 #include "DataFormats/TrackReco/interface/Track.h"
0025 #include "DataFormats/MuonReco/interface/MuonTrackLinks.h"
0026 #include "RecoMuon/MuonIdentification/plugins/MuonLinksProducer.h"
0027 
0028 #include <algorithm>
0029 
0030 MuonLinksProducer::MuonLinksProducer(const edm::ParameterSet& iConfig) {
0031   produces<reco::MuonTrackLinksCollection>();
0032   m_inputCollection = iConfig.getParameter<edm::InputTag>("inputCollection");
0033   muonToken_ = consumes<reco::MuonCollection>(m_inputCollection);
0034 }
0035 
0036 MuonLinksProducer::~MuonLinksProducer() {}
0037 
0038 void MuonLinksProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0039   auto output = std::make_unique<reco::MuonTrackLinksCollection>();
0040   edm::Handle<reco::MuonCollection> muons;
0041   iEvent.getByToken(muonToken_, muons);
0042 
0043   for (reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
0044     if (!muon->isGlobalMuon())
0045       continue;
0046     output->push_back(reco::MuonTrackLinks(muon->track(), muon->standAloneMuon(), muon->combinedMuon()));
0047   }
0048   iEvent.put(std::move(output));
0049 }