CMS 3D CMS Logo

L1TPFMetNoMuProducer.cc
Go to the documentation of this file.
5 
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 }
11 
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 }
52 
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
reco::PFMETCollection
std::vector< reco::PFMET > PFMETCollection
collection of PFMET objects
Definition: PFMETCollection.h:20
muon
Definition: MuonCocktails.h:17
reco::PFMET::getSpecific
SpecificPFMETData getSpecific() const
Definition: PFMET.h:74
edm
HLT enums.
Definition: AlignableModifier.h:19
PFMETCollection
Collection of PF MET.
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
reco::MET::sumEt
double sumEt() const
Definition: MET.h:56
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
L1TPFMetNoMuProducer::L1TPFMetNoMuProducer
L1TPFMetNoMuProducer(const edm::ParameterSet &ps)
Definition: L1TPFMetNoMuProducer.cc:6
edm::Handle< reco::PFMETCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition: LeafCandidate.h:142
HLT_FULL_cff.muon
muon
Definition: HLT_FULL_cff.py:11776
reco::MuonCollection
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
L1TPFMetNoMuProducer.h
RecoPFMET_cff.pfMet
pfMet
Definition: RecoPFMET_cff.py:15
L1TPFMetNoMuProducer::theMuonCollection_
const edm::EDGetTokenT< reco::MuonCollection > theMuonCollection_
Definition: L1TPFMetNoMuProducer.h:23
reco::PFMET
Definition: PFMET.h:18
edm::ParameterSet
Definition: ParameterSet.h:47
L1TPFMetNoMuProducer
Definition: L1TPFMetNoMuProducer.h:15
reco::LeafCandidate::p4
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:114
edm::EventSetup
Definition: EventSetup.h:57
reco::LeafCandidate::vertex
const Point & vertex() const override
vertex position (overwritten by PF...)
Definition: LeafCandidate.h:165
InputTag.h
reco::LeafCandidate::setP4
void setP4(const LorentzVector &p4) final
set 4-momentum
Definition: LeafCandidate.h:158
eostools.move
def move(src, dest)
Definition: eostools.py:511
L1TPFMetNoMuProducer::produce
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
Definition: L1TPFMetNoMuProducer.cc:12
Frameworkfwd.h
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
L1TPFMetNoMuProducer::thePFMETCollection_
const edm::EDGetTokenT< reco::PFMETCollection > thePFMETCollection_
Definition: L1TPFMetNoMuProducer.h:22
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition: LeafCandidate.h:140