File indexing completed on 2024-04-06 12:26:46
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "RecoMET/METProducers/interface/ElseMETProducer.h"
0010
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/EventSetup.h"
0014 #include "FWCore/Framework/interface/ConsumesCollector.h"
0015
0016 #include "FWCore/Utilities/interface/InputTag.h"
0017
0018 #include "DataFormats/Math/interface/LorentzVector.h"
0019 #include "DataFormats/Math/interface/Point3D.h"
0020 #include "DataFormats/Common/interface/Handle.h"
0021 #include "DataFormats/METReco/interface/METFwd.h"
0022 #include "DataFormats/METReco/interface/MET.h"
0023 #include "DataFormats/METReco/interface/CommonMETData.h"
0024
0025 #include "RecoMET/METAlgorithms/interface/METAlgo.h"
0026
0027 #include <cstring>
0028
0029
0030 namespace cms {
0031
0032
0033 ElseMETProducer::ElseMETProducer(const edm::ParameterSet& iConfig)
0034 : inputToken_(consumes<edm::View<reco::Candidate> >(iConfig.getParameter<edm::InputTag>("src"))),
0035 globalThreshold_(iConfig.getParameter<double>("globalThreshold")) {
0036 std::string alias = iConfig.exists("alias") ? iConfig.getParameter<std::string>("alias") : "";
0037
0038 produces<reco::METCollection>().setBranchAlias(alias);
0039 }
0040
0041
0042 void ElseMETProducer::produce(edm::Event& event, const edm::EventSetup& setup) {
0043 edm::Handle<edm::View<reco::Candidate> > input;
0044 event.getByToken(inputToken_, input);
0045
0046 METAlgo algo;
0047 CommonMETData commonMETdata = algo.run(*input.product(), globalThreshold_);
0048
0049 math::XYZTLorentzVector p4(commonMETdata.mex, commonMETdata.mey, 0.0, commonMETdata.met);
0050 math::XYZPoint vtx(0, 0, 0);
0051 reco::MET met(commonMETdata.sumet, p4, vtx);
0052 auto metcoll = std::make_unique<reco::METCollection>();
0053 metcoll->push_back(met);
0054 event.put(std::move(metcoll));
0055 }
0056
0057
0058 DEFINE_FWK_MODULE(ElseMETProducer);
0059 }
0060
0061