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 
EDProducer.h
reco::LeafCandidate::Point
math::XYZPoint Point
point in the space
Definition: LeafCandidate.h:27
JetEnergyShift::produce
void produce(edm::Event &, const edm::EventSetup &) override
rescale jet energy and recalculated MET
Definition: JetEnergyShift.cc:76
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
JetEnergyShift::jetEMLimitForMET_
double jetEMLimitForMET_
limit on the emf of the jet for Type1 MET corrections
Definition: JetEnergyShift.cc:59
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
singleTopDQM_cfi.mets
mets
Definition: singleTopDQM_cfi.py:43
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
JetEnergyShift
Plugin to shift the jet energy scale and recalculate the MET accordingly.
Definition: JetEnergyShift.cc:34
reco::MET
Definition: MET.h:41
MakerMacros.h
pat::Jet
Analysis-level calorimeter jet class.
Definition: Jet.h:77
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Jet
Definition: Jet.py:1
JetEnergyShift::outputMETs_
std::string outputMETs_
MET output collection.
Definition: JetEnergyShift.cc:53
pat::Jet::scaleEnergy
void scaleEnergy(double fScale) override
Scale energy and correspondingly adjust raw jec factors.
Definition: Jet.h:177
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition: LeafCandidate.h:142
JetEnergyShift::inputJetsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > inputJetsToken_
jet input collection
Definition: JetEnergyShift.cc:47
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
pat::MET
Analysis-level MET class.
Definition: MET.h:40
JetEnergyShift::~JetEnergyShift
~JetEnergyShift() override
default destructor
Definition: JetEnergyShift.cc:39
edm::EventSetup
Definition: EventSetup.h:58
pat
Definition: HeavyIon.h:7
MET.h
Jet.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
looper.cfg
cfg
Definition: looper.py:296
JetEnergyShift::jetPTThresholdForMET_
double jetPTThresholdForMET_
threshold on (raw!) jet pt for Type1 MET corrections
Definition: JetEnergyShift.cc:57
reco::LeafCandidate::et
double et() const final
transverse energy
Definition: LeafCandidate.h:127
JetEnergyShift::outputJets_
std::string outputJets_
jet output collection
Definition: JetEnergyShift.cc:51
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
metsig::jet
Definition: SignAlgoResolutions.h:47
JetEnergyShift::JetEnergyShift
JetEnergyShift(const edm::ParameterSet &)
default constructor
Definition: JetEnergyShift.cc:62
JetEnergyShift::scaleFactor_
double scaleFactor_
scale factor for the rescaling
Definition: JetEnergyShift.cc:55
MET
edm::EDProducer
Definition: EDProducer.h:35
JetEnergyShift::inputMETsToken_
edm::EDGetTokenT< std::vector< pat::MET > > inputMETsToken_
met input collection
Definition: JetEnergyShift.cc:49
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition: LeafCandidate.h:140
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
reco::LeafCandidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:23