CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
NoPileUpPFMEtProducer Class Reference

#include <NoPileUpPFMEtProducer.h>

Inheritance diagram for NoPileUpPFMEtProducer:
edm::stream::EDProducer<>

Public Member Functions

 NoPileUpPFMEtProducer (const edm::ParameterSet &)
 
 ~NoPileUpPFMEtProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

typedef std::vector< edm::InputTagvInputTag
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::string moduleLabel_
 
PFMEtSignInterfaceBasepfMEtSignInterface_
 
bool saveInputs_
 
double sfLeptonIsoCones_
 
std::string sfLeptonIsoConesName_
 
std::string sfLeptonsName_
 
double sfMEtCovMax_
 
double sfMEtCovMin_
 
double sfNoPUjetOffsetEnCorr_
 
std::string sfNoPUjetOffsetEnCorrName_
 
double sfNoPUjets_
 
std::string sfNoPUjetsName_
 
double sfNoPUunclChargedCands_
 
std::string sfNoPUunclChargedCandsName_
 
double sfPUjets_
 
std::string sfPUjetsName_
 
double sfPUunclChargedCands_
 
std::string sfPUunclChargedCandsName_
 
double sfType0Correction_
 
std::string sfType0CorrectionName_
 
double sfUnclNeutralCands_
 
std::string sfUnclNeutralCandsName_
 
edm::EDGetTokenT< reco::PUSubMETCandInfoCollectionsrcJetInfo_
 
edm::EDGetTokenT< reco::PUSubMETCandInfoCollectionsrcJetInfoLeptonMatch_
 
std::vector< edm::EDGetTokenT< reco::CandidateView > > srcLeptons_
 
edm::EDGetTokenT< reco::PFMETCollectionsrcMEt_
 
edm::InputTag srcMEtCov_
 
edm::EDGetTokenT< reco::PUSubMETCandInfoCollectionsrcPFCandInfo_
 
edm::EDGetTokenT< reco::PUSubMETCandInfoCollectionsrcPFCandInfoLeptonMatch_
 
edm::EDGetTokenT< CorrMETDatasrcType0Correction_
 
NoPileUpMEtUtilities utils_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Produce PFMET objects from no-PU jets + "unclustered" no-PU tracks + "unclustered" neutral particles ("unclustered" particles = particles not within jets)

Authors
Christian Veelken, LLR

Definition at line 30 of file NoPileUpPFMEtProducer.h.

Member Typedef Documentation

◆ vInputTag

typedef std::vector<edm::InputTag> NoPileUpPFMEtProducer::vInputTag
private

Definition at line 46 of file NoPileUpPFMEtProducer.h.

Constructor & Destructor Documentation

◆ NoPileUpPFMEtProducer()

NoPileUpPFMEtProducer::NoPileUpPFMEtProducer ( const edm::ParameterSet cfg)

Definition at line 16 of file NoPileUpPFMEtProducer.cc.

References looper::cfg, HLT_2022v15_cff::InputTag, pfMEtSignInterface_, saveInputs_, sfLeptonIsoCones_, sfLeptonIsoConesName_, sfLeptonsName_, sfMEtCovMax_, sfMEtCovMin_, sfNoPUjetOffsetEnCorr_, sfNoPUjetOffsetEnCorrName_, sfNoPUjets_, sfNoPUjetsName_, sfNoPUunclChargedCands_, sfNoPUunclChargedCandsName_, sfPUjets_, sfPUjetsName_, sfPUunclChargedCands_, sfPUunclChargedCandsName_, sfType0Correction_, sfType0CorrectionName_, sfUnclNeutralCands_, sfUnclNeutralCandsName_, srcJetInfo_, srcJetInfoLeptonMatch_, srcLeptons_, srcMEt_, srcMEtCov_, srcPFCandInfo_, srcPFCandInfoLeptonMatch_, srcType0Correction_, and verbosity_.

17  : moduleLabel_(cfg.getParameter<std::string>("@module_label")) {
18  srcMEt_ = consumes<reco::PFMETCollection>(cfg.getParameter<edm::InputTag>("srcMEt"));
19  srcMEtCov_ = edm::InputTag(); //MM, disabled for the moment until we really need it
20  //( cfg.exists("srcMEtCov") ) ?
21  // consumes<edm::Handle<> >(cfg.getParameter<edm::InputTag>("srcMEtCov")) : edm::InputTag();
22  srcJetInfo_ = consumes<reco::PUSubMETCandInfoCollection>(cfg.getParameter<edm::InputTag>("srcPUSubMETDataJet"));
24  consumes<reco::PUSubMETCandInfoCollection>(cfg.getParameter<edm::InputTag>("srcPUSubMETDataJetLeptonMatch"));
26  consumes<reco::PUSubMETCandInfoCollection>(cfg.getParameter<edm::InputTag>("srcPUSubMETDataPFCands"));
28  consumes<reco::PUSubMETCandInfoCollection>(cfg.getParameter<edm::InputTag>("srcPUSubMETDataPFCandsLeptonMatch"));
29  vInputTag srcLeptonsTags = cfg.getParameter<vInputTag>("srcLeptons");
30  for (vInputTag::const_iterator it = srcLeptonsTags.begin(); it != srcLeptonsTags.end(); it++) {
31  srcLeptons_.push_back(consumes<edm::View<reco::Candidate> >(*it));
32  }
33 
34  srcType0Correction_ = consumes<CorrMETData>(cfg.getParameter<edm::InputTag>("srcType0Correction"));
35 
36  sfNoPUjets_ = cfg.getParameter<double>("sfNoPUjets");
37  sfNoPUjetOffsetEnCorr_ = cfg.getParameter<double>("sfNoPUjetOffsetEnCorr");
38  sfPUjets_ = cfg.getParameter<double>("sfPUjets");
39  sfNoPUunclChargedCands_ = cfg.getParameter<double>("sfNoPUunclChargedCands");
40  sfPUunclChargedCands_ = cfg.getParameter<double>("sfPUunclChargedCands");
41  sfUnclNeutralCands_ = cfg.getParameter<double>("sfUnclNeutralCands");
42  sfType0Correction_ = cfg.getParameter<double>("sfType0Correction");
43  sfLeptonIsoCones_ = cfg.getParameter<double>("sfLeptonIsoCones");
44 
45  pfMEtSignInterface_ = new PFMEtSignInterfaceBase(cfg.getParameter<edm::ParameterSet>("resolution"));
46  sfMEtCovMin_ = cfg.getParameter<double>("sfMEtCovMin");
47  sfMEtCovMax_ = cfg.getParameter<double>("sfMEtCovMax");
48 
49  saveInputs_ = (cfg.exists("saveInputs")) ? cfg.getParameter<bool>("saveInputs") : false;
50 
51  verbosity_ = (cfg.exists("verbosity")) ? cfg.getParameter<int>("verbosity") : 0;
52 
53  produces<reco::PFMETCollection>();
54 
55  sfLeptonsName_ = "sumLeptons";
56  sfNoPUjetsName_ = "sumNoPUjets";
57  sfNoPUjetOffsetEnCorrName_ = "sumNoPUjetOffsetEnCorr";
58  sfPUjetsName_ = "sumPUjets";
59  sfNoPUunclChargedCandsName_ = "sumNoPUunclChargedCands";
60  sfPUunclChargedCandsName_ = "sumPUunclChargedCands";
61  sfUnclNeutralCandsName_ = "sumUnclNeutralCands";
62  sfType0CorrectionName_ = "type0Correction";
63  sfLeptonIsoConesName_ = "sumLeptonIsoCones";
64 
65  if (saveInputs_) {
66  produces<CommonMETData>(sfLeptonsName_);
67  produces<CommonMETData>(sfNoPUjetsName_);
68  produces<CommonMETData>(sfNoPUjetOffsetEnCorrName_);
69  produces<CommonMETData>(sfPUjetsName_);
70  produces<CommonMETData>(sfNoPUunclChargedCandsName_);
71  produces<CommonMETData>(sfPUunclChargedCandsName_);
72  produces<CommonMETData>(sfUnclNeutralCandsName_);
73  produces<CommonMETData>(sfType0CorrectionName_);
74  produces<CommonMETData>(sfLeptonIsoConesName_);
75  }
76  produces<double>("sfNoPU");
77 }
edm::EDGetTokenT< reco::PFMETCollection > srcMEt_
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcPFCandInfoLeptonMatch_
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcJetInfo_
std::vector< edm::EDGetTokenT< reco::CandidateView > > srcLeptons_
edm::EDGetTokenT< CorrMETData > srcType0Correction_
std::string sfNoPUunclChargedCandsName_
std::vector< edm::InputTag > vInputTag
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcJetInfoLeptonMatch_
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcPFCandInfo_
PFMEtSignInterfaceBase * pfMEtSignInterface_
std::string sfNoPUjetOffsetEnCorrName_

◆ ~NoPileUpPFMEtProducer()

NoPileUpPFMEtProducer::~NoPileUpPFMEtProducer ( )
override

Definition at line 79 of file NoPileUpPFMEtProducer.cc.

References pfMEtSignInterface_.

79 { delete pfMEtSignInterface_; }
PFMEtSignInterfaceBase * pfMEtSignInterface_

Member Function Documentation

◆ produce()

void NoPileUpPFMEtProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
overrideprivate

Definition at line 206 of file NoPileUpPFMEtProducer.cc.

References funct::abs(), addToCommonMETData(), cms::cuda::assert(), edm::View< T >::begin(), NoPileUpMEtUtilities::cleanJets(), NoPileUpMEtUtilities::cleanPFCandidates(), PFMEtSignInterfaceBase::compResolution(), computePFMEtSignificance(), HLTMuonOfflineAnalyzer_cfi::deltaR2, edm::View< T >::end(), Exception, finalizeCommonMETData(), findBestMatchingLepton(), edm::Event::getByToken(), reco::MET::getSignificanceMatrix(), initializeCommonMETData(), metsig::jet, boostedTaus_cff::jetIdx, PDWG_EXODelayedJetMET_cff::jets, reco::PUSubMETCandInfo::kChHS, reco::PUSubMETCandInfo::kChPU, reco::PUSubMETCandInfo::kHS, reco::PUSubMETCandInfo::kNeutral, edm::InputTag::label(), HLT_2022v15_cff::leptons, LogDebug, CorrMETData::mex, CorrMETData::mey, moduleLabel_, eostools::move(), zmumugammaAnalyzer_cfi::pfCandidates, pfMEtSignInterface_, reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), edm::Event::put(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), saveInputs_, scaleAndAddPFMEtSignObjects(), reco::LeafCandidate::setP4(), reco::MET::setSignificanceMatrix(), sfLeptonIsoCones_, sfLeptonIsoConesName_, sfLeptonsName_, sfMEtCovMax_, sfMEtCovMin_, sfNoPUjetOffsetEnCorr_, sfNoPUjetOffsetEnCorrName_, sfNoPUjets_, sfNoPUjetsName_, sfNoPUunclChargedCands_, sfNoPUunclChargedCandsName_, sfPUjets_, sfPUjetsName_, sfPUunclChargedCands_, sfPUunclChargedCandsName_, sfType0Correction_, sfType0CorrectionName_, sfUnclNeutralCands_, sfUnclNeutralCandsName_, mathSSE::sqrt(), srcJetInfo_, srcJetInfoLeptonMatch_, srcLeptons_, srcMEt_, srcMEtCov_, srcPFCandInfo_, srcPFCandInfoLeptonMatch_, srcType0Correction_, utils_, and trackerHitRTTI::vector.

206  {
207  LogDebug("produce") << " moduleLabel = " << moduleLabel_ << std::endl;
208 
209  // get original MET
211  evt.getByToken(srcMEt_, pfMETs);
212  if (!(pfMETs->size() == 1))
213  throw cms::Exception("NoPileUpPFMEtProducer::produce") << "Failed to find unique MET object !!\n";
214  const reco::PFMET& pfMEt_original = pfMETs->front();
215 
216  // get MET covariance matrix
217  reco::METCovMatrix pfMEtCov;
218  if (!srcMEtCov_.label().empty()) {
219  //MM manual bypass to pfMET as this case has neer been presented
220  // edm::Handle<PFMEtSignCovMatrix> pfMEtCovHandle;
221  // evt.getByToken(srcMEtCov_, pfMEtCovHandle);
222  // pfMEtCov = (*pfMEtCovHandle);
223  pfMEtCov = pfMEt_original.getSignificanceMatrix();
224  } else {
225  pfMEtCov = pfMEt_original.getSignificanceMatrix();
226  }
227 
228  // get lepton momenta
229  std::vector<reco::Candidate::LorentzVector> leptons;
230  std::vector<metsig::SigInputObj> metSignObjectsLeptons;
231  reco::Candidate::LorentzVector sumLeptonP4s;
232  for (std::vector<edm::EDGetTokenT<edm::View<reco::Candidate> > >::const_iterator srcLeptons_i = srcLeptons_.begin();
233  srcLeptons_i != srcLeptons_.end();
234  ++srcLeptons_i) {
236  evt.getByToken(*srcLeptons_i, leptons_i);
237  int leptonIdx = 0;
238  for (reco::CandidateView::const_iterator lepton = leptons_i->begin(); lepton != leptons_i->end(); ++lepton) {
239  leptons.push_back(lepton->p4());
240  metSignObjectsLeptons.push_back(pfMEtSignInterface_->compResolution(&(*lepton)));
241  sumLeptonP4s += lepton->p4();
242  ++leptonIdx;
243  }
244  }
245  LogDebug("produce") << " sum(leptons): Pt = " << sumLeptonP4s.pt() << ", eta = " << sumLeptonP4s.eta()
246  << ", phi = " << sumLeptonP4s.phi() << ","
247  << " mass = " << sumLeptonP4s.mass() << std::endl;
248 
249  // get jet and PFCandidate information
253  evt.getByToken(srcJetInfoLeptonMatch_, jetsLeptonMatch);
256  edm::Handle<reco::PUSubMETCandInfoCollection> pfCandidatesLeptonMatch;
257  evt.getByToken(srcPFCandInfoLeptonMatch_, pfCandidatesLeptonMatch);
258 
259  reco::PUSubMETCandInfoCollection jets_leptons = utils_.cleanJets(*jetsLeptonMatch, leptons, 0.5, true);
260  reco::PUSubMETCandInfoCollection pfCandidates_leptons =
261  utils_.cleanPFCandidates(*pfCandidatesLeptonMatch, leptons, 0.3, true);
262  std::vector<CommonMETData> sumJetsPlusPFCandidates_leptons(leptons.size());
263  for (std::vector<CommonMETData>::iterator sumJetsPlusPFCandidates = sumJetsPlusPFCandidates_leptons.begin();
264  sumJetsPlusPFCandidates != sumJetsPlusPFCandidates_leptons.end();
265  ++sumJetsPlusPFCandidates) {
266  initializeCommonMETData(*sumJetsPlusPFCandidates);
267  }
268  for (reco::PUSubMETCandInfoCollection::const_iterator jet = jets_leptons.begin(); jet != jets_leptons.end(); ++jet) {
269  int leptonIdx_dRmin = findBestMatchingLepton(leptons, jet->p4());
270  assert(leptonIdx_dRmin >= 0 && leptonIdx_dRmin < (int)sumJetsPlusPFCandidates_leptons.size());
271 
272  LogDebug("produce") << "jet-to-lepton match:"
273  << " jetPt = " << jet->p4().pt() << ", jetEta = " << jet->p4().eta()
274  << ", jetPhi = " << jet->p4().phi() << " leptonPt = " << leptons[leptonIdx_dRmin].pt()
275  << ", leptonEta = " << leptons[leptonIdx_dRmin].eta()
276  << ", leptonPhi = " << leptons[leptonIdx_dRmin].phi() << std::endl;
277 
278  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].mex += jet->p4().px();
279  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].mey += jet->p4().py();
280  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].sumet += jet->p4().pt();
281  }
282  for (reco::PUSubMETCandInfoCollection::const_iterator pfCandidate = pfCandidates_leptons.begin();
283  pfCandidate != pfCandidates_leptons.end();
284  ++pfCandidate) {
285  bool isWithinJet_lepton = false;
286  if (pfCandidate->isWithinJet()) {
287  for (reco::PUSubMETCandInfoCollection::const_iterator jet = jets_leptons.begin(); jet != jets_leptons.end();
288  ++jet) {
289  double dR2 = deltaR2(pfCandidate->p4(), jet->p4());
290  if (dR2 < 0.5 * 0.5)
291  isWithinJet_lepton = true;
292  }
293  }
294  if (!isWithinJet_lepton) {
295  int leptonIdx_dRmin = findBestMatchingLepton(leptons, pfCandidate->p4());
296  assert(leptonIdx_dRmin >= 0 && leptonIdx_dRmin < (int)sumJetsPlusPFCandidates_leptons.size());
297  LogDebug("produce") << "pfCandidate-to-lepton match:"
298  << " pfCandidatePt = " << pfCandidate->p4().pt()
299  << ", pfCandidateEta = " << pfCandidate->p4().eta()
300  << ", pfCandidatePhi = " << pfCandidate->p4().phi()
301  << " leptonPt = " << leptons[leptonIdx_dRmin].pt()
302  << ", leptonEta = " << leptons[leptonIdx_dRmin].eta()
303  << ", leptonPhi = " << leptons[leptonIdx_dRmin].phi() << std::endl;
304 
305  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].mex += pfCandidate->p4().px();
306  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].mey += pfCandidate->p4().py();
307  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].sumet += pfCandidate->p4().pt();
308  } else {
309  LogDebug("produce") << " pfCandidate is within jet --> skipping." << std::endl;
310  }
311  }
312  auto sumLeptons = std::make_unique<CommonMETData>();
313  initializeCommonMETData(*sumLeptons);
314  auto sumLeptonIsoCones = std::make_unique<CommonMETData>();
315  initializeCommonMETData(*sumLeptonIsoCones);
316  int leptonIdx = 0;
317  for (std::vector<CommonMETData>::iterator sumJetsPlusPFCandidates = sumJetsPlusPFCandidates_leptons.begin();
318  sumJetsPlusPFCandidates != sumJetsPlusPFCandidates_leptons.end();
319  ++sumJetsPlusPFCandidates) {
320  if (sumJetsPlusPFCandidates->sumet > leptons[leptonIdx].pt()) {
321  double leptonEnFrac = leptons[leptonIdx].pt() / sumJetsPlusPFCandidates->sumet;
322  assert(leptonEnFrac >= 0.0 && leptonEnFrac <= 1.0);
323  sumLeptons->mex += (leptonEnFrac * sumJetsPlusPFCandidates->mex);
324  sumLeptons->mey += (leptonEnFrac * sumJetsPlusPFCandidates->mey);
325  sumLeptons->sumet += (leptonEnFrac * sumJetsPlusPFCandidates->sumet);
326  double leptonIsoConeEnFrac = 1.0 - leptonEnFrac;
327  assert(leptonIsoConeEnFrac >= 0.0 && leptonIsoConeEnFrac <= 1.0);
328  sumLeptonIsoCones->mex += (leptonIsoConeEnFrac * sumJetsPlusPFCandidates->mex);
329  sumLeptonIsoCones->mey += (leptonIsoConeEnFrac * sumJetsPlusPFCandidates->mey);
330  sumLeptonIsoCones->sumet += (leptonIsoConeEnFrac * sumJetsPlusPFCandidates->sumet);
331  } else {
332  sumLeptons->mex += sumJetsPlusPFCandidates->mex;
333  sumLeptons->mey += sumJetsPlusPFCandidates->mey;
334  sumLeptons->sumet += sumJetsPlusPFCandidates->sumet;
335  }
336  ++leptonIdx;
337  }
338 
339  reco::PUSubMETCandInfoCollection jets_cleaned = utils_.cleanJets(*jets, leptons, 0.5, false);
340  reco::PUSubMETCandInfoCollection pfCandidates_cleaned = utils_.cleanPFCandidates(*pfCandidates, leptons, 0.3, false);
341 
342  auto sumNoPUjets = std::make_unique<CommonMETData>();
343  initializeCommonMETData(*sumNoPUjets);
344  std::vector<metsig::SigInputObj> metSignObjectsNoPUjets;
345  auto sumNoPUjetOffsetEnCorr = std::make_unique<CommonMETData>();
346  initializeCommonMETData(*sumNoPUjetOffsetEnCorr);
347  std::vector<metsig::SigInputObj> metSignObjectsNoPUjetOffsetEnCorr;
348  auto sumPUjets = std::make_unique<CommonMETData>();
349  initializeCommonMETData(*sumPUjets);
350  std::vector<metsig::SigInputObj> metSignObjectsPUjets;
351  int jetIdx = 0;
352  for (reco::PUSubMETCandInfoCollection::const_iterator jet = jets_cleaned.begin(); jet != jets_cleaned.end(); ++jet) {
353  if (jet->passesLooseJetId()) {
354  if (jet->type() == reco::PUSubMETCandInfo::kHS) {
355  addToCommonMETData(*sumNoPUjets, jet->p4());
356  metSignObjectsNoPUjets.push_back(jet->metSignObj());
357  float jetp = jet->p4().P();
358  float jetcorr = jet->offsetEnCorr();
359  sumNoPUjetOffsetEnCorr->mex += jetcorr * jet->p4().px() / jetp;
360  sumNoPUjetOffsetEnCorr->mey += jetcorr * jet->p4().py() / jetp;
361  sumNoPUjetOffsetEnCorr->mez += jetcorr * jet->p4().pz() / jetp;
362  sumNoPUjetOffsetEnCorr->sumet += jetcorr * jet->p4().pt() / jetp;
363  metsig::SigInputObj pfMEtSignObjectOffsetEnCorr(
364  jet->metSignObj().get_type(),
365  jet->offsetEnCorr(),
366  jet->metSignObj().get_phi(),
367  (jet->offsetEnCorr() / jet->p4().E()) * jet->metSignObj().get_sigma_e(),
368  jet->metSignObj().get_sigma_tan());
369  metSignObjectsNoPUjetOffsetEnCorr.push_back(pfMEtSignObjectOffsetEnCorr);
370  } else {
371  addToCommonMETData(*sumPUjets, jet->p4());
372  metSignObjectsPUjets.push_back(jet->metSignObj());
373  }
374  }
375  ++jetIdx;
376  }
377 
378  auto sumNoPUunclChargedCands = std::make_unique<CommonMETData>();
379  initializeCommonMETData(*sumNoPUunclChargedCands);
380  std::vector<metsig::SigInputObj> metSignObjectsNoPUunclChargedCands;
381  auto sumPUunclChargedCands = std::make_unique<CommonMETData>();
382  initializeCommonMETData(*sumPUunclChargedCands);
383  std::vector<metsig::SigInputObj> metSignObjectsPUunclChargedCands;
384  auto sumUnclNeutralCands = std::make_unique<CommonMETData>();
385  initializeCommonMETData(*sumUnclNeutralCands);
386  std::vector<metsig::SigInputObj> metSignObjectsUnclNeutralCands;
387  int pfCandIdx = 0;
388  for (reco::PUSubMETCandInfoCollection::const_iterator pfCandidate = pfCandidates_cleaned.begin();
389  pfCandidate != pfCandidates_cleaned.end();
390  ++pfCandidate) {
391  if (pfCandidate->passesLooseJetId()) {
392  if (!pfCandidate->isWithinJet()) {
393  if (pfCandidate->type() == reco::PUSubMETCandInfo::kChHS) {
394  addToCommonMETData(*sumNoPUunclChargedCands, pfCandidate->p4());
395  metSignObjectsNoPUunclChargedCands.push_back(pfCandidate->metSignObj());
396  } else if (pfCandidate->type() == reco::PUSubMETCandInfo::kChPU) {
397  addToCommonMETData(*sumPUunclChargedCands, pfCandidate->p4());
398  metSignObjectsPUunclChargedCands.push_back(pfCandidate->metSignObj());
399  } else if (pfCandidate->type() == reco::PUSubMETCandInfo::kNeutral) {
400  addToCommonMETData(*sumUnclNeutralCands, pfCandidate->p4());
401  metSignObjectsUnclNeutralCands.push_back(pfCandidate->metSignObj());
402  }
403  }
404  }
405  ++pfCandIdx;
406  }
407 
408  edm::Handle<CorrMETData> type0Correction_input;
409  evt.getByToken(srcType0Correction_, type0Correction_input);
410  auto type0Correction_output = std::make_unique<CommonMETData>();
411  initializeCommonMETData(*type0Correction_output);
412  type0Correction_output->mex = type0Correction_input->mex;
413  type0Correction_output->mey = type0Correction_input->mey;
414 
415  finalizeCommonMETData(*sumLeptons);
416  finalizeCommonMETData(*sumNoPUjetOffsetEnCorr);
417  finalizeCommonMETData(*sumNoPUjets);
418  finalizeCommonMETData(*sumPUjets);
419  finalizeCommonMETData(*sumNoPUunclChargedCands);
420  finalizeCommonMETData(*sumPUunclChargedCands);
421  finalizeCommonMETData(*sumUnclNeutralCands);
422  finalizeCommonMETData(*type0Correction_output);
423  finalizeCommonMETData(*sumLeptonIsoCones);
424 
425  double noPileUpScaleFactor =
426  (sumPUunclChargedCands->sumet > 0.)
427  ? (sumPUunclChargedCands->sumet / (sumNoPUunclChargedCands->sumet + sumPUunclChargedCands->sumet))
428  : 1.;
429  LogDebug("produce") << "noPileUpScaleFactor = " << noPileUpScaleFactor << std::endl;
430 
431  double noPileUpMEtPx =
432  -(sumLeptons->mex + sumNoPUjets->mex + sumNoPUunclChargedCands->mex +
433  noPileUpScaleFactor *
434  (sfNoPUjetOffsetEnCorr_ * sumNoPUjetOffsetEnCorr->mex + sfUnclNeutralCands_ * sumUnclNeutralCands->mex +
435  sfPUunclChargedCands_ * sumPUunclChargedCands->mex + sfPUjets_ * sumPUjets->mex)) +
436  noPileUpScaleFactor * sfType0Correction_ * type0Correction_output->mex;
437  if (sfLeptonIsoCones_ >= 0.)
438  noPileUpMEtPx -= (noPileUpScaleFactor * sfLeptonIsoCones_ * sumLeptonIsoCones->mex);
439  else
440  noPileUpMEtPx -= (std::abs(sfLeptonIsoCones_) * sumLeptonIsoCones->mex);
441  double noPileUpMEtPy =
442  -(sumLeptons->mey + sumNoPUjets->mey + sumNoPUunclChargedCands->mey +
443  noPileUpScaleFactor *
444  (sfNoPUjetOffsetEnCorr_ * sumNoPUjetOffsetEnCorr->mey + sfUnclNeutralCands_ * sumUnclNeutralCands->mey +
445  sfPUunclChargedCands_ * sumPUunclChargedCands->mey + sfPUjets_ * sumPUjets->mey)) +
446  noPileUpScaleFactor * sfType0Correction_ * type0Correction_output->mey;
447  if (sfLeptonIsoCones_ >= 0.)
448  noPileUpMEtPy -= (noPileUpScaleFactor * sfLeptonIsoCones_ * sumLeptonIsoCones->mey);
449  else
450  noPileUpMEtPy -= (std::abs(sfLeptonIsoCones_) * sumLeptonIsoCones->mey);
451  double noPileUpMEtPt = sqrt(noPileUpMEtPx * noPileUpMEtPx + noPileUpMEtPy * noPileUpMEtPy);
452  reco::Candidate::LorentzVector noPileUpMEtP4(noPileUpMEtPx, noPileUpMEtPy, 0., noPileUpMEtPt);
453 
454  reco::PFMET noPileUpMEt(pfMEt_original);
455  noPileUpMEt.setP4(noPileUpMEtP4);
456  //noPileUpMEt.setSignificanceMatrix(pfMEtCov);
457 
458  std::vector<metsig::SigInputObj> metSignObjects_scaled;
459  scaleAndAddPFMEtSignObjects(metSignObjects_scaled, metSignObjectsLeptons, 1.0, sfMEtCovMin_, sfMEtCovMax_);
461  metSignObjects_scaled, metSignObjectsNoPUjetOffsetEnCorr, sfNoPUjetOffsetEnCorr_, sfMEtCovMin_, sfMEtCovMax_);
462  scaleAndAddPFMEtSignObjects(metSignObjects_scaled, metSignObjectsNoPUjets, sfNoPUjets_, sfMEtCovMin_, sfMEtCovMax_);
464  metSignObjects_scaled, metSignObjectsPUjets, noPileUpScaleFactor * sfPUjets_, sfMEtCovMin_, sfMEtCovMax_);
466  metSignObjects_scaled, metSignObjectsNoPUunclChargedCands, sfNoPUunclChargedCands_, sfMEtCovMin_, sfMEtCovMax_);
467  scaleAndAddPFMEtSignObjects(metSignObjects_scaled,
468  metSignObjectsPUunclChargedCands,
469  noPileUpScaleFactor * sfPUunclChargedCands_,
470  sfMEtCovMin_,
471  sfMEtCovMax_);
472  scaleAndAddPFMEtSignObjects(metSignObjects_scaled,
473  metSignObjectsUnclNeutralCands,
474  noPileUpScaleFactor * sfUnclNeutralCands_,
475  sfMEtCovMin_,
476  sfMEtCovMax_);
477  reco::METCovMatrix pfMEtCov_recomputed = computePFMEtSignificance(metSignObjects_scaled);
478  noPileUpMEt.setSignificanceMatrix(pfMEtCov_recomputed);
479 
480  LogDebug("produce") << "<NoPileUpPFMEtProducer::produce>:" << std::endl
481  << " moduleLabel = " << moduleLabel_ << std::endl
482  << " PFMET: Pt = " << pfMEt_original.pt() << ", phi = " << pfMEt_original.phi() << " "
483  << "(Px = " << pfMEt_original.px() << ", Py = " << pfMEt_original.py() << ")" << std::endl
484  << " Cov:" << std::endl
485  << " " << pfMEtCov(0, 0) << " " << pfMEtCov(0, 1) << "\n " << pfMEtCov(1, 0) << " "
486  << pfMEtCov(1, 1) << std::endl
487  << " no-PU MET: Pt = " << noPileUpMEt.pt() << ", phi = " << noPileUpMEt.phi() << " "
488  << "(Px = " << noPileUpMEt.px() << ", Py = " << noPileUpMEt.py() << ")" << std::endl
489  << " Cov:" << std::endl
490  << " " << (noPileUpMEt.getSignificanceMatrix())(0, 0) << " "
491  << (noPileUpMEt.getSignificanceMatrix())(0, 1) << std::endl
492  << (noPileUpMEt.getSignificanceMatrix())(1, 0) << " "
493  << (noPileUpMEt.getSignificanceMatrix())(1, 1) << std::endl;
494 
495  // add no-PU MET object to the event
496  auto noPileUpMEtCollection = std::make_unique<reco::PFMETCollection>();
497  noPileUpMEtCollection->push_back(noPileUpMEt);
498 
499  evt.put(std::move(noPileUpMEtCollection));
500  if (saveInputs_) {
501  evt.put(std::move(sumLeptons), sfLeptonsName_);
502  evt.put(std::move(sumNoPUjetOffsetEnCorr), sfNoPUjetOffsetEnCorrName_);
503  evt.put(std::move(sumNoPUjets), sfNoPUjetsName_);
504  evt.put(std::move(sumPUjets), sfPUjetsName_);
505  evt.put(std::move(sumNoPUunclChargedCands), sfNoPUunclChargedCandsName_);
506  evt.put(std::move(sumPUunclChargedCands), sfPUunclChargedCandsName_);
507  evt.put(std::move(sumUnclNeutralCands), sfUnclNeutralCandsName_);
508  evt.put(std::move(type0Correction_output), sfType0CorrectionName_);
509  evt.put(std::move(sumLeptonIsoCones), sfLeptonIsoConesName_);
510  }
511 
512  evt.put(std::make_unique<double>(noPileUpScaleFactor), "sfNoPU");
513 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
reco::METCovMatrix getSignificanceMatrix(void) const
Definition: MET.cc:128
double pt() const final
transverse momentum
edm::EDGetTokenT< reco::PFMETCollection > srcMEt_
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcPFCandInfoLeptonMatch_
ROOT::Math::SMatrix< double, 2 > METCovMatrix
Definition: MET.h:39
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
std::string const & label() const
Definition: InputTag.h:36
assert(be >=bs)
reco::PUSubMETCandInfoCollection cleanJets(const reco::PUSubMETCandInfoCollection &, const std::vector< reco::Candidate::LorentzVector > &, double, bool)
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcJetInfo_
std::vector< edm::EDGetTokenT< reco::CandidateView > > srcLeptons_
double px() const final
x coordinate of momentum vector
int findBestMatchingLepton(const std::vector< reco::Candidate::LorentzVector > &leptons, const reco::Candidate::LorentzVector &p4_ref)
void addToCommonMETData(CommonMETData &metData, const reco::Candidate::LorentzVector &p4)
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< reco::PUSubMETCandInfo > PUSubMETCandInfoCollection
double py() const final
y coordinate of momentum vector
edm::EDGetTokenT< CorrMETData > srcType0Correction_
void finalizeCommonMETData(CommonMETData &metData)
std::string sfNoPUunclChargedCandsName_
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcJetInfoLeptonMatch_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcPFCandInfo_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
reco::PUSubMETCandInfoCollection cleanPFCandidates(const reco::PUSubMETCandInfoCollection &, const std::vector< reco::Candidate::LorentzVector > &, double, bool)
metsig::SigInputObj compResolution(const T *particle) const
const_iterator begin() const
double mey
Definition: CorrMETData.h:16
NoPileUpMEtUtilities utils_
double mex
Definition: CorrMETData.h:15
void scaleAndAddPFMEtSignObjects(std::vector< metsig::SigInputObj > &metSignObjects_scaled, const std::vector< metsig::SigInputObj > &metSignObjects, double sf, double sfMin, double sfMax)
double phi() const final
momentum azimuthal angle
const_iterator end() const
reco::METCovMatrix computePFMEtSignificance(const std::vector< metsig::SigInputObj > &metSignObjects)
def move(src, dest)
Definition: eostools.py:511
void initializeCommonMETData(CommonMETData &metData)
#define LogDebug(id)
PFMEtSignInterfaceBase * pfMEtSignInterface_
std::string sfNoPUjetOffsetEnCorrName_

Member Data Documentation

◆ moduleLabel_

std::string NoPileUpPFMEtProducer::moduleLabel_
private

◆ pfMEtSignInterface_

PFMEtSignInterfaceBase* NoPileUpPFMEtProducer::pfMEtSignInterface_
private

Definition at line 70 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), produce(), and ~NoPileUpPFMEtProducer().

◆ saveInputs_

bool NoPileUpPFMEtProducer::saveInputs_
private

Definition at line 74 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfLeptonIsoCones_

double NoPileUpPFMEtProducer::sfLeptonIsoCones_
private

Definition at line 58 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfLeptonIsoConesName_

std::string NoPileUpPFMEtProducer::sfLeptonIsoConesName_
private

Definition at line 68 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfLeptonsName_

std::string NoPileUpPFMEtProducer::sfLeptonsName_
private

Definition at line 60 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfMEtCovMax_

double NoPileUpPFMEtProducer::sfMEtCovMax_
private

Definition at line 72 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfMEtCovMin_

double NoPileUpPFMEtProducer::sfMEtCovMin_
private

Definition at line 71 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfNoPUjetOffsetEnCorr_

double NoPileUpPFMEtProducer::sfNoPUjetOffsetEnCorr_
private

Definition at line 52 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfNoPUjetOffsetEnCorrName_

std::string NoPileUpPFMEtProducer::sfNoPUjetOffsetEnCorrName_
private

Definition at line 62 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfNoPUjets_

double NoPileUpPFMEtProducer::sfNoPUjets_
private

Definition at line 51 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfNoPUjetsName_

std::string NoPileUpPFMEtProducer::sfNoPUjetsName_
private

Definition at line 61 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfNoPUunclChargedCands_

double NoPileUpPFMEtProducer::sfNoPUunclChargedCands_
private

Definition at line 54 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfNoPUunclChargedCandsName_

std::string NoPileUpPFMEtProducer::sfNoPUunclChargedCandsName_
private

Definition at line 64 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfPUjets_

double NoPileUpPFMEtProducer::sfPUjets_
private

Definition at line 53 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfPUjetsName_

std::string NoPileUpPFMEtProducer::sfPUjetsName_
private

Definition at line 63 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfPUunclChargedCands_

double NoPileUpPFMEtProducer::sfPUunclChargedCands_
private

Definition at line 55 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfPUunclChargedCandsName_

std::string NoPileUpPFMEtProducer::sfPUunclChargedCandsName_
private

Definition at line 65 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfType0Correction_

double NoPileUpPFMEtProducer::sfType0Correction_
private

Definition at line 57 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfType0CorrectionName_

std::string NoPileUpPFMEtProducer::sfType0CorrectionName_
private

Definition at line 67 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfUnclNeutralCands_

double NoPileUpPFMEtProducer::sfUnclNeutralCands_
private

Definition at line 56 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ sfUnclNeutralCandsName_

std::string NoPileUpPFMEtProducer::sfUnclNeutralCandsName_
private

Definition at line 66 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ srcJetInfo_

edm::EDGetTokenT<reco::PUSubMETCandInfoCollection> NoPileUpPFMEtProducer::srcJetInfo_
private

Definition at line 42 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ srcJetInfoLeptonMatch_

edm::EDGetTokenT<reco::PUSubMETCandInfoCollection> NoPileUpPFMEtProducer::srcJetInfoLeptonMatch_
private

Definition at line 43 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ srcLeptons_

std::vector<edm::EDGetTokenT<reco::CandidateView> > NoPileUpPFMEtProducer::srcLeptons_
private

Definition at line 47 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ srcMEt_

edm::EDGetTokenT<reco::PFMETCollection> NoPileUpPFMEtProducer::srcMEt_
private

Definition at line 40 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ srcMEtCov_

edm::InputTag NoPileUpPFMEtProducer::srcMEtCov_
private

Definition at line 41 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ srcPFCandInfo_

edm::EDGetTokenT<reco::PUSubMETCandInfoCollection> NoPileUpPFMEtProducer::srcPFCandInfo_
private

Definition at line 44 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ srcPFCandInfoLeptonMatch_

edm::EDGetTokenT<reco::PUSubMETCandInfoCollection> NoPileUpPFMEtProducer::srcPFCandInfoLeptonMatch_
private

Definition at line 45 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ srcType0Correction_

edm::EDGetTokenT<CorrMETData> NoPileUpPFMEtProducer::srcType0Correction_
private

Definition at line 49 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

◆ utils_

NoPileUpMEtUtilities NoPileUpPFMEtProducer::utils_
private

Definition at line 78 of file NoPileUpPFMEtProducer.h.

Referenced by produce().

◆ verbosity_

int NoPileUpPFMEtProducer::verbosity_
private

Definition at line 76 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer().