Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    METProducers
0004 // Class:      MuonMET
0005 //
0006 
0007 //____________________________________________________________________________||
0008 #include "RecoMET/METProducers/interface/MuonMET.h"
0009 
0010 #include "DataFormats/METReco/interface/METCollection.h"
0011 #include "DataFormats/METReco/interface/CaloMETCollection.h"
0012 
0013 //____________________________________________________________________________||
0014 namespace cms {
0015 
0016   //____________________________________________________________________________||
0017   MuonMET::MuonMET(const edm::ParameterSet& iConfig)
0018       : alg_(), metTypeInputTag_(iConfig.getParameter<edm::InputTag>("metTypeInputTag")) {
0019     edm::InputTag muonsInputTag = iConfig.getParameter<edm::InputTag>("muonsInputTag");
0020     inputMuonToken_ = consumes<edm::View<reco::Muon> >(muonsInputTag);
0021 
0022     edm::InputTag muonDepValueMap = iConfig.getParameter<edm::InputTag>("muonMETDepositValueMapInputTag");
0023     inputValueMapMuonMetCorrToken_ = consumes<edm::ValueMap<reco::MuonMETCorrectionData> >(muonDepValueMap);
0024 
0025     edm::InputTag uncorMETInputTag = iConfig.getParameter<edm::InputTag>("uncorMETInputTag");
0026     if (metTypeInputTag_.label() == "CaloMET") {
0027       inputCaloMETToken_ = consumes<edm::View<reco::CaloMET> >(uncorMETInputTag);
0028       produces<reco::CaloMETCollection>();
0029     } else {
0030       inputMETToken_ = consumes<edm::View<reco::MET> >(uncorMETInputTag);
0031       produces<reco::METCollection>();
0032     }
0033   }
0034 
0035   MuonMET::MuonMET() : alg_() {}
0036 
0037   void MuonMET::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0038     edm::Handle<edm::View<reco::Muon> > inputMuons;
0039     iEvent.getByToken(inputMuonToken_, inputMuons);
0040 
0041     edm::Handle<edm::ValueMap<reco::MuonMETCorrectionData> > vm_muCorrData_h;
0042 
0043     iEvent.getByToken(inputValueMapMuonMetCorrToken_, vm_muCorrData_h);
0044 
0045     if (metTypeInputTag_.label() == "CaloMET") {
0046       edm::Handle<edm::View<reco::CaloMET> > inputUncorMet;
0047       iEvent.getByToken(inputCaloMETToken_, inputUncorMet);
0048       auto output = std::make_unique<reco::CaloMETCollection>();
0049       alg_.run(*(inputMuons.product()), *(vm_muCorrData_h.product()), *(inputUncorMet.product()), &*output);
0050       iEvent.put(std::move(output));
0051     } else {
0052       edm::Handle<edm::View<reco::MET> > inputUncorMet;
0053       iEvent.getByToken(inputMETToken_, inputUncorMet);
0054       auto output = std::make_unique<reco::METCollection>();
0055       alg_.run(*(inputMuons.product()), *(vm_muCorrData_h.product()), *(inputUncorMet.product()), &*output);
0056       iEvent.put(std::move(output));
0057     }
0058   }
0059   //____________________________________________________________________________||
0060   DEFINE_FWK_MODULE(MuonMET);
0061 
0062 }  // namespace cms
0063 
0064 //____________________________________________________________________________||