CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 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 Member Functions

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

Private Attributes

const edm::EDGetTokenT
< reco::MuonCollection
theMuonCollection_
 
const edm::EDGetTokenT
< reco::PFMETCollection
thePFMETCollection_
 

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

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>(ps.getParameter<edm::InputTag>("pfMETCollection"))),
8  theMuonCollection_(consumes<reco::MuonCollection>(ps.getParameter<edm::InputTag>("muonCollection"))) {
9  produces<reco::PFMETCollection>();
10 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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 
)
overrideprivate

Definition at line 12 of file L1TPFMetNoMuProducer.cc.

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

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

Member Data Documentation

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

Definition at line 23 of file L1TPFMetNoMuProducer.h.

Referenced by produce().

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

Definition at line 22 of file L1TPFMetNoMuProducer.h.

Referenced by produce().