CMS 3D CMS Logo

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

#include <L1TPFMetNoMuProducer.h>

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

Public Member Functions

 L1TPFMetNoMuProducer (const edm::ParameterSet &ps)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Member Functions

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

Private Attributes

const edm::EDGetTokenT< reco::MuonCollectiontheMuonCollection_
 
const edm::EDGetTokenT< reco::PFMETCollectionthePFMETCollection_
 

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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 15 of file L1TPFMetNoMuProducer.h.

Constructor & Destructor Documentation

L1TPFMetNoMuProducer::L1TPFMetNoMuProducer ( const edm::ParameterSet ps)
explicit

Definition at line 6 of file L1TPFMetNoMuProducer.cc.

7  : thePFMETCollection_(consumes<reco::PFMETCollection>(
8  ps.getParameter<edm::InputTag>("pfMETCollection"))),
9  theMuonCollection_(consumes<reco::MuonCollection>(
10  ps.getParameter<edm::InputTag>("muonCollection"))) {
11  produces<reco::PFMETCollection>();
12 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::MuonCollection > theMuonCollection_
const edm::EDGetTokenT< reco::PFMETCollection > thePFMETCollection_

Member Function Documentation

void L1TPFMetNoMuProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
private

Definition at line 14 of file L1TPFMetNoMuProducer.cc.

References DEFINE_FWK_MODULE, reco::PFMET::getSpecific(), edm::HandleBase::isValid(), eostools::move(), metsig::muon, extraflags_cff::muons, reco::LeafCandidate::p4(), RecoPFMET_cff::pfMet, edm::Handle< T >::product(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::setP4(), reco::MET::sumEt(), theMuonCollection_, thePFMETCollection_, and reco::LeafCandidate::vertex().

15  {
17  event.getByToken(thePFMETCollection_, pfMet);
18 
20  event.getByToken(theMuonCollection_, muons);
21 
22  if (!pfMet.isValid()) {
23  edm::LogWarning("L1TPFMetNoMuProducer")
24  << "invalid collection for pfMet" << std::endl;
25  return;
26  }
27  if (!muons.isValid()) {
28  edm::LogWarning("L1TPFMetNoMuProducer")
29  << "invalid collection for muons" << std::endl;
30  return;
31  }
32 
33  reco::PFMET thePFMetNoMu = pfMet.product()->front();
34  double pfMetNoMuPx = thePFMetNoMu.px();
35  double pfMetNoMuPy = thePFMetNoMu.py();
36 
37  double muPx(0.), muPy(0.);
38 
39  for (auto muon = muons->begin(); muon != muons->end(); ++muon) {
40  if (muon->isPFMuon()) {
41  muPx += muon->px();
42  muPy += muon->py();
43  }
44  }
45 
46  pfMetNoMuPx += muPx;
47  pfMetNoMuPy += muPy;
48  math::XYZTLorentzVector pfMetNoMuP4(pfMetNoMuPx, pfMetNoMuPy, 0,
49  hypot(pfMetNoMuPx, pfMetNoMuPy));
50 
51  thePFMetNoMu.setP4(pfMetNoMuP4);
52 
53  std::unique_ptr<reco::PFMETCollection> product(new reco::PFMETCollection);
54  product->emplace_back(thePFMetNoMu.getSpecific(), thePFMetNoMu.sumEt(),
55  thePFMetNoMu.p4(), thePFMetNoMu.vertex());
56 
57  event.put(std::move(product));
58 }
SpecificPFMETData getSpecific() const
Definition: PFMET.h:72
double px() const final
x coordinate of momentum vector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
double sumEt() const
Definition: MET.h:56
const Point & vertex() const override
vertex position (overwritten by PF...)
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
bool isValid() const
Definition: HandleBase.h:74
T const * product() const
Definition: Handle.h:81
double py() const final
y coordinate of momentum vector
const edm::EDGetTokenT< reco::MuonCollection > theMuonCollection_
const edm::EDGetTokenT< reco::PFMETCollection > thePFMETCollection_
std::vector< reco::PFMET > PFMETCollection
collection of PFMET objects
void setP4(const LorentzVector &p4) final
set 4-momentum
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

const edm::EDGetTokenT<reco::MuonCollection> L1TPFMetNoMuProducer::theMuonCollection_
private

Definition at line 24 of file L1TPFMetNoMuProducer.h.

Referenced by produce().

const edm::EDGetTokenT<reco::PFMETCollection> L1TPFMetNoMuProducer::thePFMETCollection_
private

Definition at line 23 of file L1TPFMetNoMuProducer.h.

Referenced by produce().