Go to the documentation of this file.00001 #include <memory>
00002 #include "FWCore/Framework/interface/Frameworkfwd.h"
00003 #include "FWCore/Framework/interface/MakerMacros.h"
00004 #include "FWCore/Framework/interface/EDProducer.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006
00007
00008
00009
00010 class DistortedMETProducer : public edm::EDProducer {
00011 public:
00012 explicit DistortedMETProducer(const edm::ParameterSet&);
00013 ~DistortedMETProducer();
00014
00015 private:
00016 virtual void beginJob() ;
00017 virtual void produce(edm::Event&, const edm::EventSetup&) override;
00018 virtual void endJob() ;
00019
00020 edm::InputTag metTag_;
00021 double metScaleShift_;
00022 };
00023
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025 #include "DataFormats/Common/interface/Handle.h"
00026 #include "DataFormats/Common/interface/View.h"
00027 #include "DataFormats/METReco/interface/MET.h"
00028 #include "DataFormats/METReco/interface/METFwd.h"
00029
00031 DistortedMETProducer::DistortedMETProducer(const edm::ParameterSet& pset) {
00032
00033
00034 produces<std::vector<reco::MET> >();
00035
00036
00037 metTag_ = pset.getUntrackedParameter<edm::InputTag> ("MetTag", edm::InputTag("met"));
00038
00039 metScaleShift_ = pset.getUntrackedParameter<double> ("MetScaleShift",1.e-3);
00040
00041 }
00042
00044 DistortedMETProducer::~DistortedMETProducer(){
00045 }
00046
00048 void DistortedMETProducer::beginJob() {
00049 }
00050
00052 void DistortedMETProducer::endJob(){}
00053
00055 void DistortedMETProducer::produce(edm::Event& ev, const edm::EventSetup&) {
00056
00057 if (ev.isRealData()) return;
00058
00059
00060 edm::Handle<edm::View<reco::MET> > metCollection;
00061 if (!ev.getByLabel(metTag_, metCollection)) {
00062 edm::LogError("") << ">>> MET collection does not exist !!!";
00063 return;
00064 }
00065 edm::RefToBase<reco::MET> met = metCollection->refAt(0);
00066
00067 std::auto_ptr<reco::METCollection> newmetCollection (new reco::METCollection);
00068
00069 double met_et = met->et() * (1. + metScaleShift_);
00070 double sum_et = met->sumEt() * (1. + metScaleShift_);
00071 double met_phi = met->phi();
00072 double met_ex = met_et*cos(met_phi);
00073 double met_ey = met_et*sin(met_phi);
00074 reco::Particle::LorentzVector met_p4(met_ex, met_ey, 0., met_et);
00075 reco::Particle::Point met_vtx(0.,0.,0.);
00076 reco::MET* newmet = new reco::MET(sum_et, met_p4, met_vtx);
00077
00078 newmetCollection->push_back(*newmet);
00079
00080 ev.put(newmetCollection);
00081 }
00082
00083 DEFINE_FWK_MODULE(DistortedMETProducer);