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, ProducerED_cfi::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, PDWG_EXODelayedJetMET_cff::jets, reco::PUSubMETCandInfo::kChHS, reco::PUSubMETCandInfo::kChPU, reco::PUSubMETCandInfo::kHS, reco::PUSubMETCandInfo::kNeutral, edm::InputTag::label(), HLT_2023v12_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  for (reco::CandidateView::const_iterator lepton = leptons_i->begin(); lepton != leptons_i->end(); ++lepton) {
238  leptons.push_back(lepton->p4());
239  metSignObjectsLeptons.push_back(pfMEtSignInterface_->compResolution(&(*lepton)));
240  sumLeptonP4s += lepton->p4();
241  }
242  }
243  LogDebug("produce") << " sum(leptons): Pt = " << sumLeptonP4s.pt() << ", eta = " << sumLeptonP4s.eta()
244  << ", phi = " << sumLeptonP4s.phi() << ","
245  << " mass = " << sumLeptonP4s.mass() << std::endl;
246 
247  // get jet and PFCandidate information
251  evt.getByToken(srcJetInfoLeptonMatch_, jetsLeptonMatch);
254  edm::Handle<reco::PUSubMETCandInfoCollection> pfCandidatesLeptonMatch;
255  evt.getByToken(srcPFCandInfoLeptonMatch_, pfCandidatesLeptonMatch);
256 
257  reco::PUSubMETCandInfoCollection jets_leptons = utils_.cleanJets(*jetsLeptonMatch, leptons, 0.5, true);
258  reco::PUSubMETCandInfoCollection pfCandidates_leptons =
259  utils_.cleanPFCandidates(*pfCandidatesLeptonMatch, leptons, 0.3, true);
260  std::vector<CommonMETData> sumJetsPlusPFCandidates_leptons(leptons.size());
261  for (std::vector<CommonMETData>::iterator sumJetsPlusPFCandidates = sumJetsPlusPFCandidates_leptons.begin();
262  sumJetsPlusPFCandidates != sumJetsPlusPFCandidates_leptons.end();
263  ++sumJetsPlusPFCandidates) {
264  initializeCommonMETData(*sumJetsPlusPFCandidates);
265  }
266  for (reco::PUSubMETCandInfoCollection::const_iterator jet = jets_leptons.begin(); jet != jets_leptons.end(); ++jet) {
267  int leptonIdx_dRmin = findBestMatchingLepton(leptons, jet->p4());
268  assert(leptonIdx_dRmin >= 0 && leptonIdx_dRmin < (int)sumJetsPlusPFCandidates_leptons.size());
269 
270  LogDebug("produce") << "jet-to-lepton match:"
271  << " jetPt = " << jet->p4().pt() << ", jetEta = " << jet->p4().eta()
272  << ", jetPhi = " << jet->p4().phi() << " leptonPt = " << leptons[leptonIdx_dRmin].pt()
273  << ", leptonEta = " << leptons[leptonIdx_dRmin].eta()
274  << ", leptonPhi = " << leptons[leptonIdx_dRmin].phi() << std::endl;
275 
276  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].mex += jet->p4().px();
277  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].mey += jet->p4().py();
278  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].sumet += jet->p4().pt();
279  }
280  for (reco::PUSubMETCandInfoCollection::const_iterator pfCandidate = pfCandidates_leptons.begin();
281  pfCandidate != pfCandidates_leptons.end();
282  ++pfCandidate) {
283  bool isWithinJet_lepton = false;
284  if (pfCandidate->isWithinJet()) {
285  for (reco::PUSubMETCandInfoCollection::const_iterator jet = jets_leptons.begin(); jet != jets_leptons.end();
286  ++jet) {
287  double dR2 = deltaR2(pfCandidate->p4(), jet->p4());
288  if (dR2 < 0.5 * 0.5)
289  isWithinJet_lepton = true;
290  }
291  }
292  if (!isWithinJet_lepton) {
293  int leptonIdx_dRmin = findBestMatchingLepton(leptons, pfCandidate->p4());
294  assert(leptonIdx_dRmin >= 0 && leptonIdx_dRmin < (int)sumJetsPlusPFCandidates_leptons.size());
295  LogDebug("produce") << "pfCandidate-to-lepton match:"
296  << " pfCandidatePt = " << pfCandidate->p4().pt()
297  << ", pfCandidateEta = " << pfCandidate->p4().eta()
298  << ", pfCandidatePhi = " << pfCandidate->p4().phi()
299  << " leptonPt = " << leptons[leptonIdx_dRmin].pt()
300  << ", leptonEta = " << leptons[leptonIdx_dRmin].eta()
301  << ", leptonPhi = " << leptons[leptonIdx_dRmin].phi() << std::endl;
302 
303  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].mex += pfCandidate->p4().px();
304  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].mey += pfCandidate->p4().py();
305  sumJetsPlusPFCandidates_leptons[leptonIdx_dRmin].sumet += pfCandidate->p4().pt();
306  } else {
307  LogDebug("produce") << " pfCandidate is within jet --> skipping." << std::endl;
308  }
309  }
310  auto sumLeptons = std::make_unique<CommonMETData>();
311  initializeCommonMETData(*sumLeptons);
312  auto sumLeptonIsoCones = std::make_unique<CommonMETData>();
313  initializeCommonMETData(*sumLeptonIsoCones);
314  int leptonIdx = 0;
315  for (std::vector<CommonMETData>::iterator sumJetsPlusPFCandidates = sumJetsPlusPFCandidates_leptons.begin();
316  sumJetsPlusPFCandidates != sumJetsPlusPFCandidates_leptons.end();
317  ++sumJetsPlusPFCandidates) {
318  if (sumJetsPlusPFCandidates->sumet > leptons[leptonIdx].pt()) {
319  double leptonEnFrac = leptons[leptonIdx].pt() / sumJetsPlusPFCandidates->sumet;
320  assert(leptonEnFrac >= 0.0 && leptonEnFrac <= 1.0);
321  sumLeptons->mex += (leptonEnFrac * sumJetsPlusPFCandidates->mex);
322  sumLeptons->mey += (leptonEnFrac * sumJetsPlusPFCandidates->mey);
323  sumLeptons->sumet += (leptonEnFrac * sumJetsPlusPFCandidates->sumet);
324  double leptonIsoConeEnFrac = 1.0 - leptonEnFrac;
325  assert(leptonIsoConeEnFrac >= 0.0 && leptonIsoConeEnFrac <= 1.0);
326  sumLeptonIsoCones->mex += (leptonIsoConeEnFrac * sumJetsPlusPFCandidates->mex);
327  sumLeptonIsoCones->mey += (leptonIsoConeEnFrac * sumJetsPlusPFCandidates->mey);
328  sumLeptonIsoCones->sumet += (leptonIsoConeEnFrac * sumJetsPlusPFCandidates->sumet);
329  } else {
330  sumLeptons->mex += sumJetsPlusPFCandidates->mex;
331  sumLeptons->mey += sumJetsPlusPFCandidates->mey;
332  sumLeptons->sumet += sumJetsPlusPFCandidates->sumet;
333  }
334  ++leptonIdx;
335  }
336 
337  reco::PUSubMETCandInfoCollection jets_cleaned = utils_.cleanJets(*jets, leptons, 0.5, false);
338  reco::PUSubMETCandInfoCollection pfCandidates_cleaned = utils_.cleanPFCandidates(*pfCandidates, leptons, 0.3, false);
339 
340  auto sumNoPUjets = std::make_unique<CommonMETData>();
341  initializeCommonMETData(*sumNoPUjets);
342  std::vector<metsig::SigInputObj> metSignObjectsNoPUjets;
343  auto sumNoPUjetOffsetEnCorr = std::make_unique<CommonMETData>();
344  initializeCommonMETData(*sumNoPUjetOffsetEnCorr);
345  std::vector<metsig::SigInputObj> metSignObjectsNoPUjetOffsetEnCorr;
346  auto sumPUjets = std::make_unique<CommonMETData>();
347  initializeCommonMETData(*sumPUjets);
348  std::vector<metsig::SigInputObj> metSignObjectsPUjets;
349  for (reco::PUSubMETCandInfoCollection::const_iterator jet = jets_cleaned.begin(); jet != jets_cleaned.end(); ++jet) {
350  if (jet->passesLooseJetId()) {
351  if (jet->type() == reco::PUSubMETCandInfo::kHS) {
352  addToCommonMETData(*sumNoPUjets, jet->p4());
353  metSignObjectsNoPUjets.push_back(jet->metSignObj());
354  float jetp = jet->p4().P();
355  float jetcorr = jet->offsetEnCorr();
356  sumNoPUjetOffsetEnCorr->mex += jetcorr * jet->p4().px() / jetp;
357  sumNoPUjetOffsetEnCorr->mey += jetcorr * jet->p4().py() / jetp;
358  sumNoPUjetOffsetEnCorr->mez += jetcorr * jet->p4().pz() / jetp;
359  sumNoPUjetOffsetEnCorr->sumet += jetcorr * jet->p4().pt() / jetp;
360  metsig::SigInputObj pfMEtSignObjectOffsetEnCorr(
361  jet->metSignObj().get_type(),
362  jet->offsetEnCorr(),
363  jet->metSignObj().get_phi(),
364  (jet->offsetEnCorr() / jet->p4().E()) * jet->metSignObj().get_sigma_e(),
365  jet->metSignObj().get_sigma_tan());
366  metSignObjectsNoPUjetOffsetEnCorr.push_back(pfMEtSignObjectOffsetEnCorr);
367  } else {
368  addToCommonMETData(*sumPUjets, jet->p4());
369  metSignObjectsPUjets.push_back(jet->metSignObj());
370  }
371  }
372  }
373 
374  auto sumNoPUunclChargedCands = std::make_unique<CommonMETData>();
375  initializeCommonMETData(*sumNoPUunclChargedCands);
376  std::vector<metsig::SigInputObj> metSignObjectsNoPUunclChargedCands;
377  auto sumPUunclChargedCands = std::make_unique<CommonMETData>();
378  initializeCommonMETData(*sumPUunclChargedCands);
379  std::vector<metsig::SigInputObj> metSignObjectsPUunclChargedCands;
380  auto sumUnclNeutralCands = std::make_unique<CommonMETData>();
381  initializeCommonMETData(*sumUnclNeutralCands);
382  std::vector<metsig::SigInputObj> metSignObjectsUnclNeutralCands;
383  for (reco::PUSubMETCandInfoCollection::const_iterator pfCandidate = pfCandidates_cleaned.begin();
384  pfCandidate != pfCandidates_cleaned.end();
385  ++pfCandidate) {
386  if (pfCandidate->passesLooseJetId()) {
387  if (!pfCandidate->isWithinJet()) {
388  if (pfCandidate->type() == reco::PUSubMETCandInfo::kChHS) {
389  addToCommonMETData(*sumNoPUunclChargedCands, pfCandidate->p4());
390  metSignObjectsNoPUunclChargedCands.push_back(pfCandidate->metSignObj());
391  } else if (pfCandidate->type() == reco::PUSubMETCandInfo::kChPU) {
392  addToCommonMETData(*sumPUunclChargedCands, pfCandidate->p4());
393  metSignObjectsPUunclChargedCands.push_back(pfCandidate->metSignObj());
394  } else if (pfCandidate->type() == reco::PUSubMETCandInfo::kNeutral) {
395  addToCommonMETData(*sumUnclNeutralCands, pfCandidate->p4());
396  metSignObjectsUnclNeutralCands.push_back(pfCandidate->metSignObj());
397  }
398  }
399  }
400  }
401 
402  edm::Handle<CorrMETData> type0Correction_input;
403  evt.getByToken(srcType0Correction_, type0Correction_input);
404  auto type0Correction_output = std::make_unique<CommonMETData>();
405  initializeCommonMETData(*type0Correction_output);
406  type0Correction_output->mex = type0Correction_input->mex;
407  type0Correction_output->mey = type0Correction_input->mey;
408 
409  finalizeCommonMETData(*sumLeptons);
410  finalizeCommonMETData(*sumNoPUjetOffsetEnCorr);
411  finalizeCommonMETData(*sumNoPUjets);
412  finalizeCommonMETData(*sumPUjets);
413  finalizeCommonMETData(*sumNoPUunclChargedCands);
414  finalizeCommonMETData(*sumPUunclChargedCands);
415  finalizeCommonMETData(*sumUnclNeutralCands);
416  finalizeCommonMETData(*type0Correction_output);
417  finalizeCommonMETData(*sumLeptonIsoCones);
418 
419  double noPileUpScaleFactor =
420  (sumPUunclChargedCands->sumet > 0.)
421  ? (sumPUunclChargedCands->sumet / (sumNoPUunclChargedCands->sumet + sumPUunclChargedCands->sumet))
422  : 1.;
423  LogDebug("produce") << "noPileUpScaleFactor = " << noPileUpScaleFactor << std::endl;
424 
425  double noPileUpMEtPx =
426  -(sumLeptons->mex + sumNoPUjets->mex + sumNoPUunclChargedCands->mex +
427  noPileUpScaleFactor *
428  (sfNoPUjetOffsetEnCorr_ * sumNoPUjetOffsetEnCorr->mex + sfUnclNeutralCands_ * sumUnclNeutralCands->mex +
429  sfPUunclChargedCands_ * sumPUunclChargedCands->mex + sfPUjets_ * sumPUjets->mex)) +
430  noPileUpScaleFactor * sfType0Correction_ * type0Correction_output->mex;
431  if (sfLeptonIsoCones_ >= 0.)
432  noPileUpMEtPx -= (noPileUpScaleFactor * sfLeptonIsoCones_ * sumLeptonIsoCones->mex);
433  else
434  noPileUpMEtPx -= (std::abs(sfLeptonIsoCones_) * sumLeptonIsoCones->mex);
435  double noPileUpMEtPy =
436  -(sumLeptons->mey + sumNoPUjets->mey + sumNoPUunclChargedCands->mey +
437  noPileUpScaleFactor *
438  (sfNoPUjetOffsetEnCorr_ * sumNoPUjetOffsetEnCorr->mey + sfUnclNeutralCands_ * sumUnclNeutralCands->mey +
439  sfPUunclChargedCands_ * sumPUunclChargedCands->mey + sfPUjets_ * sumPUjets->mey)) +
440  noPileUpScaleFactor * sfType0Correction_ * type0Correction_output->mey;
441  if (sfLeptonIsoCones_ >= 0.)
442  noPileUpMEtPy -= (noPileUpScaleFactor * sfLeptonIsoCones_ * sumLeptonIsoCones->mey);
443  else
444  noPileUpMEtPy -= (std::abs(sfLeptonIsoCones_) * sumLeptonIsoCones->mey);
445  double noPileUpMEtPt = sqrt(noPileUpMEtPx * noPileUpMEtPx + noPileUpMEtPy * noPileUpMEtPy);
446  reco::Candidate::LorentzVector noPileUpMEtP4(noPileUpMEtPx, noPileUpMEtPy, 0., noPileUpMEtPt);
447 
448  reco::PFMET noPileUpMEt(pfMEt_original);
449  noPileUpMEt.setP4(noPileUpMEtP4);
450  //noPileUpMEt.setSignificanceMatrix(pfMEtCov);
451 
452  std::vector<metsig::SigInputObj> metSignObjects_scaled;
453  scaleAndAddPFMEtSignObjects(metSignObjects_scaled, metSignObjectsLeptons, 1.0, sfMEtCovMin_, sfMEtCovMax_);
455  metSignObjects_scaled, metSignObjectsNoPUjetOffsetEnCorr, sfNoPUjetOffsetEnCorr_, sfMEtCovMin_, sfMEtCovMax_);
456  scaleAndAddPFMEtSignObjects(metSignObjects_scaled, metSignObjectsNoPUjets, sfNoPUjets_, sfMEtCovMin_, sfMEtCovMax_);
458  metSignObjects_scaled, metSignObjectsPUjets, noPileUpScaleFactor * sfPUjets_, sfMEtCovMin_, sfMEtCovMax_);
460  metSignObjects_scaled, metSignObjectsNoPUunclChargedCands, sfNoPUunclChargedCands_, sfMEtCovMin_, sfMEtCovMax_);
461  scaleAndAddPFMEtSignObjects(metSignObjects_scaled,
462  metSignObjectsPUunclChargedCands,
463  noPileUpScaleFactor * sfPUunclChargedCands_,
464  sfMEtCovMin_,
465  sfMEtCovMax_);
466  scaleAndAddPFMEtSignObjects(metSignObjects_scaled,
467  metSignObjectsUnclNeutralCands,
468  noPileUpScaleFactor * sfUnclNeutralCands_,
469  sfMEtCovMin_,
470  sfMEtCovMax_);
471  reco::METCovMatrix pfMEtCov_recomputed = computePFMEtSignificance(metSignObjects_scaled);
472  noPileUpMEt.setSignificanceMatrix(pfMEtCov_recomputed);
473 
474  LogDebug("produce") << "<NoPileUpPFMEtProducer::produce>:" << std::endl
475  << " moduleLabel = " << moduleLabel_ << std::endl
476  << " PFMET: Pt = " << pfMEt_original.pt() << ", phi = " << pfMEt_original.phi() << " "
477  << "(Px = " << pfMEt_original.px() << ", Py = " << pfMEt_original.py() << ")" << std::endl
478  << " Cov:" << std::endl
479  << " " << pfMEtCov(0, 0) << " " << pfMEtCov(0, 1) << "\n " << pfMEtCov(1, 0) << " "
480  << pfMEtCov(1, 1) << std::endl
481  << " no-PU MET: Pt = " << noPileUpMEt.pt() << ", phi = " << noPileUpMEt.phi() << " "
482  << "(Px = " << noPileUpMEt.px() << ", Py = " << noPileUpMEt.py() << ")" << std::endl
483  << " Cov:" << std::endl
484  << " " << (noPileUpMEt.getSignificanceMatrix())(0, 0) << " "
485  << (noPileUpMEt.getSignificanceMatrix())(0, 1) << std::endl
486  << (noPileUpMEt.getSignificanceMatrix())(1, 0) << " "
487  << (noPileUpMEt.getSignificanceMatrix())(1, 1) << std::endl;
488 
489  // add no-PU MET object to the event
490  auto noPileUpMEtCollection = std::make_unique<reco::PFMETCollection>();
491  noPileUpMEtCollection->push_back(noPileUpMEt);
492 
493  evt.put(std::move(noPileUpMEtCollection));
494  if (saveInputs_) {
495  evt.put(std::move(sumLeptons), sfLeptonsName_);
496  evt.put(std::move(sumNoPUjetOffsetEnCorr), sfNoPUjetOffsetEnCorrName_);
497  evt.put(std::move(sumNoPUjets), sfNoPUjetsName_);
498  evt.put(std::move(sumPUjets), sfPUjetsName_);
499  evt.put(std::move(sumNoPUunclChargedCands), sfNoPUunclChargedCandsName_);
500  evt.put(std::move(sumPUunclChargedCands), sfPUunclChargedCandsName_);
501  evt.put(std::move(sumUnclNeutralCands), sfUnclNeutralCandsName_);
502  evt.put(std::move(type0Correction_output), sfType0CorrectionName_);
503  evt.put(std::move(sumLeptonIsoCones), sfLeptonIsoConesName_);
504  }
505 
506  evt.put(std::make_unique<double>(noPileUpScaleFactor), "sfNoPU");
507 }
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:536
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().