Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**\class PFMET
0002 \brief Computes the MET from a collection of PFCandidates. HF missing!
0003 
0004 \todo Add HF energy to the MET calculation (access HF towers)
0005 
0006 \author Colin Bernet
0007 \date   february 2008
0008 */
0009 
0010 #include "CommonTools/ParticleFlow/interface/PFMETAlgo.h"
0011 #include "DataFormats/METReco/interface/MET.h"
0012 #include "DataFormats/METReco/interface/METFwd.h"
0013 #include "DataFormats/Math/interface/LorentzVector.h"
0014 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0015 #include "FWCore/Framework/interface/global/EDProducer.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 #include "FWCore/Utilities/interface/Exception.h"
0020 
0021 #include <memory>
0022 #include <string>
0023 
0024 class PFMET : public edm::global::EDProducer<> {
0025 public:
0026   explicit PFMET(const edm::ParameterSet&);
0027 
0028   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0029 
0030 private:
0031   /// Input PFCandidates
0032   edm::EDGetTokenT<reco::PFCandidateCollection> tokenPFCandidates_;
0033   edm::EDPutTokenT<reco::METCollection> putToken_;
0034 
0035   pf2pat::PFMETAlgo pfMETAlgo_;
0036 };
0037 
0038 using namespace std;
0039 using namespace edm;
0040 using namespace reco;
0041 using namespace math;
0042 
0043 PFMET::PFMET(const edm::ParameterSet& iConfig) : pfMETAlgo_(iConfig) {
0044   auto inputTagPFCandidates = iConfig.getParameter<InputTag>("PFCandidates");
0045   tokenPFCandidates_ = consumes<PFCandidateCollection>(inputTagPFCandidates);
0046 
0047   putToken_ = produces<METCollection>();
0048 
0049   LogDebug("PFMET") << " input collection : " << inputTagPFCandidates;
0050 }
0051 
0052 #include "FWCore/Framework/interface/MakerMacros.h"
0053 DEFINE_FWK_MODULE(PFMET);
0054 
0055 void PFMET::produce(edm::StreamID, Event& iEvent, const EventSetup& iSetup) const {
0056   LogDebug("PFMET") << "START event: " << iEvent.id().event() << " in run " << iEvent.id().run() << endl;
0057 
0058   // get PFCandidates
0059   METCollection output{1, pfMETAlgo_.produce(iEvent.get(tokenPFCandidates_))};
0060   iEvent.emplace(putToken_, std::move(output));
0061 
0062   LogDebug("PFMET") << "STOP event: " << iEvent.id().event() << " in run " << iEvent.id().run() << endl;
0063 }