CMS 3D CMS Logo

JetEnergyShift.cc
Go to the documentation of this file.
4 
7 
35 
36  public:
38  explicit JetEnergyShift(const edm::ParameterSet&);
41 
42  private:
44  virtual void produce(edm::Event&, const edm::EventSetup&) override;
45 
46  private:
56  double scaleFactor_;
61 };
62 
63 
65  inputJetsToken_ (consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("inputJets"))),
66  inputMETsToken_ (consumes<std::vector<pat::MET> >(cfg.getParameter<edm::InputTag>("inputMETs"))),
67  scaleFactor_ (cfg.getParameter<double> ("scaleFactor" )),
68  jetPTThresholdForMET_(cfg.getParameter<double> ("jetPTThresholdForMET")),
69  jetEMLimitForMET_ (cfg.getParameter<double> ("jetEMLimitForMET" ))
70 {
71  // use label of input to create label for output
72  outputJets_ = cfg.getParameter<edm::InputTag>("inputJets").label();
73  outputMETs_ = cfg.getParameter<edm::InputTag>("inputMETs").label();
74  // register products
75  produces<std::vector<pat::Jet> >(outputJets_);
76  produces<std::vector<pat::MET> >(outputMETs_);
77 }
78 
79 void
81 {
83  event.getByToken(inputJetsToken_, jets);
84 
86  event.getByToken(inputMETsToken_, mets);
87 
88  auto pJets = std::make_unique<std::vector<pat::Jet>>();
89  auto pMETs = std::make_unique<std::vector<pat::MET>>();
90 
91  double dPx = 0.;
92  double dPy = 0.;
93  double dSumEt = 0.;
94 
95  for(std::vector<pat::Jet>::const_iterator jet = jets->begin(); jet != jets->end(); ++jet) {
96  pat::Jet scaledJet = *jet;
97  scaledJet.scaleEnergy( scaleFactor_ );
98  pJets->push_back( scaledJet );
99  // consider jet scale shift only if the raw jet pt and emf
100  // is above the thresholds given in the module definition
101  if(jet->correctedJet("raw").pt() > jetPTThresholdForMET_
102  && jet->emEnergyFraction() < jetEMLimitForMET_) {
103  dPx += scaledJet.px() - jet->px();
104  dPy += scaledJet.py() - jet->py();
105  dSumEt += scaledJet.et() - jet->et();
106  }
107  }
108 
109  // scale MET accordingly
110  pat::MET met = *(mets->begin());
111  double scaledMETPx = met.px() - dPx;
112  double scaledMETPy = met.py() - dPy;
113  pat::MET scaledMET(reco::MET(met.sumEt()+dSumEt, reco::MET::LorentzVector(scaledMETPx, scaledMETPy, 0, sqrt(scaledMETPx*scaledMETPx+scaledMETPy*scaledMETPy)), reco::MET::Point(0,0,0)));
114  pMETs->push_back( scaledMET );
115  event.put(std::move(pJets), outputJets_);
116  event.put(std::move(pMETs), outputMETs_);
117 }
118 
Analysis-level MET class.
Definition: MET.h:43
T getParameter(std::string const &) const
~JetEnergyShift()
default destructor
virtual void scaleEnergy(double fScale)
scale energy of the jet
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
double jetEMLimitForMET_
limit on the emf of the jet for Type1 MET corrections
std::string outputJets_
jet output collection
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: HeavyIon.h:7
virtual double et() const final
transverse energy
double sumEt() const
Definition: MET.h:56
Definition: Jet.py:1
Definition: MET.h:42
virtual double px() const final
x coordinate of momentum vector
T sqrt(T t)
Definition: SSEVec.h:18
vector< PseudoJet > jets
virtual void produce(edm::Event &, const edm::EventSetup &) override
rescale jet energy and recalculated MET
edm::EDGetTokenT< std::vector< pat::MET > > inputMETsToken_
met input collection
met
===> hadronic RAZOR
JetEnergyShift(const edm::ParameterSet &)
default constructor
Analysis-level calorimeter jet class.
Definition: Jet.h:78
HLT enums.
double scaleFactor_
scale factor for the rescaling
Plugin to shift the jet energy scale and recalculate the MET accordingly.
double jetPTThresholdForMET_
threshold on (raw!) jet pt for Type1 MET corrections
edm::EDGetTokenT< std::vector< pat::Jet > > inputJetsToken_
jet input collection
std::string outputMETs_
MET output collection.
virtual double py() const final
y coordinate of momentum vector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:23
def move(src, dest)
Definition: eostools.py:510
Definition: event.py:1
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27