Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:01

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 
0017 #include "FWCore/Framework/interface/Event.h"
0018 #include "FWCore/Framework/interface/EventSetup.h"
0019 
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 
0022 #include "DataFormats/Common/interface/Handle.h"
0023 #include "DataFormats/TrackReco/interface/Track.h"
0024 #include "DataFormats/MuonReco/interface/MuonTrackLinks.h"
0025 #include "RecoMuon/MuonIdentification/plugins/MuonLinksProducer.h"
0026 
0027 #include <algorithm>
0028 
0029 MuonLinksProducer::MuonLinksProducer(const edm::ParameterSet& iConfig) {
0030   produces<reco::MuonTrackLinksCollection>();
0031   m_inputCollection = iConfig.getParameter<edm::InputTag>("inputCollection");
0032   muonToken_ = consumes<reco::MuonCollection>(m_inputCollection);
0033 }
0034 
0035 MuonLinksProducer::~MuonLinksProducer() {}
0036 
0037 void MuonLinksProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0038   auto output = std::make_unique<reco::MuonTrackLinksCollection>();
0039   edm::Handle<reco::MuonCollection> muons;
0040   iEvent.getByToken(muonToken_, muons);
0041 
0042   for (reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
0043     if (!muon->isGlobalMuon())
0044       continue;
0045     output->push_back(reco::MuonTrackLinks(muon->track(), muon->standAloneMuon(), muon->combinedMuon()));
0046   }
0047   iEvent.put(std::move(output));
0048 }