CMS 3D CMS Logo

JetEnergyShift.cc
Go to the documentation of this file.
4 
7 
35 public:
37  explicit JetEnergyShift(const edm::ParameterSet&);
39  ~JetEnergyShift() override{};
40 
41 private:
43  void produce(edm::Event&, const edm::EventSetup&) override;
44 
45 private:
55  double scaleFactor_;
60 };
61 
63  : inputJetsToken_(consumes<std::vector<pat::Jet>>(cfg.getParameter<edm::InputTag>("inputJets"))),
64  inputMETsToken_(consumes<std::vector<pat::MET>>(cfg.getParameter<edm::InputTag>("inputMETs"))),
65  scaleFactor_(cfg.getParameter<double>("scaleFactor")),
66  jetPTThresholdForMET_(cfg.getParameter<double>("jetPTThresholdForMET")),
67  jetEMLimitForMET_(cfg.getParameter<double>("jetEMLimitForMET")) {
68  // use label of input to create label for output
69  outputJets_ = cfg.getParameter<edm::InputTag>("inputJets").label();
70  outputMETs_ = cfg.getParameter<edm::InputTag>("inputMETs").label();
71  // register products
72  produces<std::vector<pat::Jet>>(outputJets_);
73  produces<std::vector<pat::MET>>(outputMETs_);
74 }
75 
78  event.getByToken(inputJetsToken_, jets);
79 
81  event.getByToken(inputMETsToken_, mets);
82 
83  auto pJets = std::make_unique<std::vector<pat::Jet>>();
84  auto pMETs = std::make_unique<std::vector<pat::MET>>();
85 
86  double dPx = 0.;
87  double dPy = 0.;
88  double dSumEt = 0.;
89 
90  for (std::vector<pat::Jet>::const_iterator jet = jets->begin(); jet != jets->end(); ++jet) {
91  pat::Jet scaledJet = *jet;
92  scaledJet.scaleEnergy(scaleFactor_);
93  pJets->push_back(scaledJet);
94  // consider jet scale shift only if the raw jet pt and emf
95  // is above the thresholds given in the module definition
96  if (jet->correctedJet("raw").pt() > jetPTThresholdForMET_ && jet->emEnergyFraction() < jetEMLimitForMET_) {
97  dPx += scaledJet.px() - jet->px();
98  dPy += scaledJet.py() - jet->py();
99  dSumEt += scaledJet.et() - jet->et();
100  }
101  }
102 
103  // scale MET accordingly
104  pat::MET met = *(mets->begin());
105  double scaledMETPx = met.px() - dPx;
106  double scaledMETPy = met.py() - dPy;
107  pat::MET scaledMET(
108  reco::MET(met.sumEt() + dSumEt,
110  scaledMETPx, scaledMETPy, 0, sqrt(scaledMETPx * scaledMETPx + scaledMETPy * scaledMETPy)),
111  reco::MET::Point(0, 0, 0)));
112  pMETs->push_back(scaledMET);
113  event.put(std::move(pJets), outputJets_);
114  event.put(std::move(pMETs), outputMETs_);
115 }
116 
Analysis-level MET class.
Definition: MET.h:40
T getParameter(std::string const &) const
double px() const final
x coordinate of momentum vector
void scaleEnergy(double fScale) override
Scale energy and correspondingly adjust raw jec factors.
Definition: Jet.h:177
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
char const * label
double sumEt() const
Definition: MET.h:52
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Definition: Jet.py:1
double et() const final
transverse energy
Definition: MET.h:41
T sqrt(T t)
Definition: SSEVec.h:19
~JetEnergyShift() override
default destructor
void produce(edm::Event &, const edm::EventSetup &) override
rescale jet energy and recalculated MET
edm::EDGetTokenT< std::vector< pat::MET > > inputMETsToken_
met input collection
double py() const final
y coordinate of momentum vector
JetEnergyShift(const edm::ParameterSet &)
default constructor
Analysis-level calorimeter jet class.
Definition: Jet.h:77
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.
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:23
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27