00001 #include <string> 00002 #include <vector> 00003 00004 #include "DataFormats/Common/interface/ValueMap.h" 00005 #include "DataFormats/MuonReco/interface/MuonFwd.h" 00006 #include "DataFormats/MuonReco/interface/Muon.h" 00007 #include "DataFormats/TrackReco/interface/Track.h" 00008 #include "DataFormats/TrackReco/interface/TrackFwd.h" 00009 00010 #include "FWCore/Framework/interface/EDProducer.h" 00011 #include "FWCore/Framework/interface/Event.h" 00012 #include "FWCore/Framework/interface/EventSetup.h" 00013 #include "FWCore/Framework/interface/Frameworkfwd.h" 00014 #include "FWCore/Framework/interface/MakerMacros.h" 00015 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00016 00017 #include "RecoMuon/MuonIdentification/interface/MuonShowerInformationFiller.h" 00018 00019 class MuonShowerInformationProducer : public edm::EDProducer { 00020 public: 00021 MuonShowerInformationProducer(const edm::ParameterSet& iConfig) : 00022 inputMuonCollection_(iConfig.getParameter<edm::InputTag>("muonCollection")), 00023 inputTrackCollection_(iConfig.getParameter<edm::InputTag>("trackCollection")), 00024 showerFiller_(iConfig.getParameter<edm::ParameterSet>("ShowerInformationFillerParameters")) 00025 { 00026 produces<edm::ValueMap<reco::MuonShower> >().setBranchAlias("muonShowerInformation"); 00027 } 00028 virtual ~MuonShowerInformationProducer() {} 00029 00030 private: 00031 virtual void produce(edm::Event&, const edm::EventSetup&); 00032 edm::InputTag inputMuonCollection_; 00033 edm::InputTag inputTrackCollection_; 00034 MuonShowerInformationFiller showerFiller_; 00035 }; 00036 00037 void 00038 MuonShowerInformationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) 00039 { 00040 edm::Handle<reco::MuonCollection> muons; 00041 iEvent.getByLabel(inputMuonCollection_, muons); 00042 00043 // reserve some space for output 00044 std::vector<reco::MuonShower> showerInfoValues; 00045 showerInfoValues.reserve(muons->size()); 00046 00047 for(reco::MuonCollection::const_iterator muon = muons->begin(); 00048 muon != muons->end(); ++muon) 00049 { 00050 // if (!muon->isGlobalMuon() && !muon->isStandAloneMuon()) continue; 00051 showerInfoValues.push_back(showerFiller_.fillShowerInformation(*muon,iEvent,iSetup)); 00052 } 00053 00054 // create and fill value map 00055 std::auto_ptr<edm::ValueMap<reco::MuonShower> > outC(new edm::ValueMap<reco::MuonShower>()); 00056 edm::ValueMap<reco::MuonShower>::Filler fillerC(*outC); 00057 fillerC.insert(muons, showerInfoValues.begin(), showerInfoValues.end()); 00058 fillerC.fill(); 00059 00060 // put value map into event 00061 iEvent.put(outC); 00062 } 00063 DEFINE_FWK_MODULE(MuonShowerInformationProducer);