CMS 3D CMS Logo

DistortedMETProducer.cc
Go to the documentation of this file.
1 #include <memory>
6 
9 
10 //
11 // class declaration
12 //
14  public:
15  explicit DistortedMETProducer(const edm::ParameterSet&);
16  ~DistortedMETProducer() override;
17 
18  private:
19  void beginJob() override ;
20  void produce(edm::Event&, const edm::EventSetup&) override;
21  void endJob() override ;
22 
24  double metScaleShift_; // relative shift (0. => no shift)
25 };
26 
30 
33 
34  // What is being produced
35  produces<std::vector<reco::MET> >();
36 
37  // Input products
38  metToken_ = consumes<edm::View<reco::MET> >(pset.getUntrackedParameter<edm::InputTag> ("MetTag", edm::InputTag("met")));
39  // Distortions in MET in Gev**{-1/2}
40  metScaleShift_ = pset.getUntrackedParameter<double> ("MetScaleShift",1.e-3);
41 
42 }
43 
46 }
47 
50 }
51 
54 
57 
58  if (ev.isRealData()) return;
59 
60  // MET collection
62  if (!ev.getByToken(metToken_, metCollection)) {
63  edm::LogError("") << ">>> MET collection does not exist !!!";
64  return;
65  }
66  edm::RefToBase<reco::MET> met = metCollection->refAt(0);
67 
68  std::unique_ptr<reco::METCollection> newmetCollection (new reco::METCollection);
69 
70  double met_et = met->et() * (1. + metScaleShift_);
71  double sum_et = met->sumEt() * (1. + metScaleShift_);
72  double met_phi = met->phi();
73  double met_ex = met_et*cos(met_phi);
74  double met_ey = met_et*sin(met_phi);
75  reco::Particle::LorentzVector met_p4(met_ex, met_ey, 0., met_et);
76  reco::Particle::Point met_vtx(0.,0.,0.);
77  reco::MET* newmet = new reco::MET(sum_et, met_p4, met_vtx);
78 
79  newmetCollection->push_back(*newmet);
80 
81  ev.put(std::move(newmetCollection));
82 }
83 
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
bool ev
std::vector< reco::MET > METCollection
collection of MET objects
Definition: METCollection.h:23
bool isRealData() const
Definition: EventBase.h:62
double sumEt() const
Definition: MET.h:56
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double et() const final
transverse energy
Definition: MET.h:42
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
math::XYZPoint Point
point in the space
Definition: Particle.h:25
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
met
===> hadronic RAZOR
void produce(edm::Event &, const edm::EventSetup &) override
DistortedMETProducer(const edm::ParameterSet &)
double phi() const final
momentum azimuthal angle
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
def move(src, dest)
Definition: eostools.py:511