CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 NoPileUpPFMEtProducer (const edm::ParameterSet &)
 
 ~NoPileUpPFMEtProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::vector
< edm::InputTag
vInputTag
 

Private Member Functions

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

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::PUSubMETCandInfoCollection
srcJetInfo_
 
edm::EDGetTokenT
< reco::PUSubMETCandInfoCollection
srcJetInfoLeptonMatch_
 
std::vector< edm::EDGetTokenT
< reco::CandidateView > > 
srcLeptons_
 
edm::EDGetTokenT
< reco::PFMETCollection
srcMEt_
 
edm::InputTag srcMEtCov_
 
edm::EDGetTokenT
< reco::PUSubMETCandInfoCollection
srcPFCandInfo_
 
edm::EDGetTokenT
< reco::PUSubMETCandInfoCollection
srcPFCandInfoLeptonMatch_
 
edm::EDGetTokenT< CorrMETDatasrcType0Correction_
 
NoPileUpMEtUtilities utils_
 
int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 31 of file NoPileUpPFMEtProducer.h.

Member Typedef Documentation

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

Definition at line 50 of file NoPileUpPFMEtProducer.h.

Constructor & Destructor Documentation

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

Definition at line 16 of file NoPileUpPFMEtProducer.cc.

References edm::EDConsumerBase::consumes(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), HLT_25ns14e33_v1_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 {
19  srcMEt_ = consumes<reco::PFMETCollection>(cfg.getParameter<edm::InputTag>("srcMEt"));
20  srcMEtCov_ = edm::InputTag(); //MM, disabled for the moment until we really need it
21  //( cfg.exists("srcMEtCov") ) ?
22  // consumes<edm::Handle<> >(cfg.getParameter<edm::InputTag>("srcMEtCov")) : edm::InputTag();
23  srcJetInfo_ = consumes<reco::PUSubMETCandInfoCollection>(cfg.getParameter<edm::InputTag>("srcPUSubMETDataJet"));
24  srcJetInfoLeptonMatch_ = consumes<reco::PUSubMETCandInfoCollection>(cfg.getParameter<edm::InputTag>("srcPUSubMETDataJetLeptonMatch"));
25  srcPFCandInfo_ = consumes<reco::PUSubMETCandInfoCollection>(cfg.getParameter<edm::InputTag>("srcPUSubMETDataPFCands"));
26  srcPFCandInfoLeptonMatch_ = consumes<reco::PUSubMETCandInfoCollection>(cfg.getParameter<edm::InputTag>("srcPUSubMETDataPFCandsLeptonMatch"));
27  vInputTag srcLeptonsTags = cfg.getParameter<vInputTag>("srcLeptons");
28  for(vInputTag::const_iterator it=srcLeptonsTags.begin();it!=srcLeptonsTags.end();it++) {
29  srcLeptons_.push_back( consumes<edm::View<reco::Candidate> >( *it ) );
30  }
31 
32  srcType0Correction_ = consumes<CorrMETData>(cfg.getParameter<edm::InputTag>("srcType0Correction"));
33 
34  sfNoPUjets_ = cfg.getParameter<double>("sfNoPUjets");
35  sfNoPUjetOffsetEnCorr_ = cfg.getParameter<double>("sfNoPUjetOffsetEnCorr");
36  sfPUjets_ = cfg.getParameter<double>("sfPUjets");
37  sfNoPUunclChargedCands_ = cfg.getParameter<double>("sfNoPUunclChargedCands");
38  sfPUunclChargedCands_ = cfg.getParameter<double>("sfPUunclChargedCands");
39  sfUnclNeutralCands_ = cfg.getParameter<double>("sfUnclNeutralCands");
40  sfType0Correction_ = cfg.getParameter<double>("sfType0Correction");
41  sfLeptonIsoCones_ = cfg.getParameter<double>("sfLeptonIsoCones");
42 
44  sfMEtCovMin_ = cfg.getParameter<double>("sfMEtCovMin");
45  sfMEtCovMax_ = cfg.getParameter<double>("sfMEtCovMax");
46 
47  saveInputs_ = ( cfg.exists("saveInputs") ) ?
48  cfg.getParameter<bool>("saveInputs") : false;
49 
50  verbosity_ = ( cfg.exists("verbosity") ) ?
51  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 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::PFMETCollection > srcMEt_
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcPFCandInfoLeptonMatch_
bool exists(std::string const &parameterName) const
checks if a parameter exists
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcJetInfo_
edm::EDGetTokenT< CorrMETData > srcType0Correction_
std::string sfNoPUunclChargedCandsName_
std::vector< edm::InputTag > vInputTag
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcJetInfoLeptonMatch_
edm::EDGetTokenT< reco::PUSubMETCandInfoCollection > srcPFCandInfo_
std::vector< edm::EDGetTokenT< reco::CandidateView > > srcLeptons_
PFMEtSignInterfaceBase * pfMEtSignInterface_
std::string sfNoPUjetOffsetEnCorrName_
NoPileUpPFMEtProducer::~NoPileUpPFMEtProducer ( )

Definition at line 79 of file NoPileUpPFMEtProducer.cc.

References pfMEtSignInterface_.

80 {
81  delete pfMEtSignInterface_;
82 }
PFMEtSignInterfaceBase * pfMEtSignInterface_

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 205 of file NoPileUpPFMEtProducer.cc.

References funct::abs(), addToCommonMETData(), assert(), NoPileUpMEtUtilities::cleanJets(), NoPileUpMEtUtilities::cleanPFCandidates(), PFMEtSignInterfaceBase::compResolution(), computePFMEtSignificance(), reco::deltaR2(), edm::hlt::Exception, finalizeCommonMETData(), findBestMatchingLepton(), edm::Event::getByToken(), reco::MET::getSignificanceMatrix(), initializeCommonMETData(), metsig::jet, fwrapper::jets, reco::PUSubMETCandInfo::kChHS, reco::PUSubMETCandInfo::kChPU, reco::PUSubMETCandInfo::kHS, reco::PUSubMETCandInfo::kNeutral, edm::InputTag::label(), HLT_25ns14e33_v1_cff::leptons, LogDebug, moduleLabel_, reco::tau::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_, and utils_.

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

Member Data Documentation

std::string NoPileUpPFMEtProducer::moduleLabel_
private
PFMEtSignInterfaceBase* NoPileUpPFMEtProducer::pfMEtSignInterface_
private

Definition at line 74 of file NoPileUpPFMEtProducer.h.

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

bool NoPileUpPFMEtProducer::saveInputs_
private

Definition at line 78 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfLeptonIsoCones_
private

Definition at line 62 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

std::string NoPileUpPFMEtProducer::sfLeptonIsoConesName_
private

Definition at line 72 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

std::string NoPileUpPFMEtProducer::sfLeptonsName_
private

Definition at line 64 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfMEtCovMax_
private

Definition at line 76 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfMEtCovMin_
private

Definition at line 75 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfNoPUjetOffsetEnCorr_
private

Definition at line 56 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

std::string NoPileUpPFMEtProducer::sfNoPUjetOffsetEnCorrName_
private

Definition at line 66 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfNoPUjets_
private

Definition at line 55 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

std::string NoPileUpPFMEtProducer::sfNoPUjetsName_
private

Definition at line 65 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfNoPUunclChargedCands_
private

Definition at line 58 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

std::string NoPileUpPFMEtProducer::sfNoPUunclChargedCandsName_
private

Definition at line 68 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfPUjets_
private

Definition at line 57 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

std::string NoPileUpPFMEtProducer::sfPUjetsName_
private

Definition at line 67 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfPUunclChargedCands_
private

Definition at line 59 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

std::string NoPileUpPFMEtProducer::sfPUunclChargedCandsName_
private

Definition at line 69 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfType0Correction_
private

Definition at line 61 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

std::string NoPileUpPFMEtProducer::sfType0CorrectionName_
private

Definition at line 71 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

double NoPileUpPFMEtProducer::sfUnclNeutralCands_
private

Definition at line 60 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

std::string NoPileUpPFMEtProducer::sfUnclNeutralCandsName_
private

Definition at line 70 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

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

Definition at line 46 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

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

Definition at line 47 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

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

Definition at line 51 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

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

Definition at line 44 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

edm::InputTag NoPileUpPFMEtProducer::srcMEtCov_
private

Definition at line 45 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

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

Definition at line 48 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

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

Definition at line 49 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

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

Definition at line 53 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer(), and produce().

NoPileUpMEtUtilities NoPileUpPFMEtProducer::utils_
private

Definition at line 82 of file NoPileUpPFMEtProducer.h.

Referenced by produce().

int NoPileUpPFMEtProducer::verbosity_
private

Definition at line 80 of file NoPileUpPFMEtProducer.h.

Referenced by NoPileUpPFMEtProducer().