CMS 3D CMS Logo

MuonMETcorrInputProducer.cc
Go to the documentation of this file.
2 
6 
8  : moduleLabel_(cfg.getParameter<std::string>("@module_label"))
9 {
10  token_ = consumes<reco::MuonCollection>(cfg.getParameter<edm::InputTag>("src"));
11  muonCorrectionMapToken_ = consumes<edm::ValueMap<reco::MuonMETCorrectionData> >(cfg.getParameter<edm::InputTag>("srcMuonCorrections"));
12 
13  produces<CorrMETData>();
14 }
15 
17 {
18 // nothing to be done yet...
19 }
20 
22 {
23  std::unique_ptr<CorrMETData> unclEnergySum(new CorrMETData());
24 
26  evt.getByToken(token_, muons);
27 
28  typedef edm::ValueMap<reco::MuonMETCorrectionData> MuonMETCorrectionMap;
29  edm::Handle<MuonMETCorrectionMap> muonCorrections;
30  evt.getByToken(muonCorrectionMapToken_, muonCorrections);
31 
32 //--- sum muon corrections.
33 //
34 // NOTE: MET = -(jets + muon corrections + "unclustered energy"),
35 // so "unclustered energy" = -(MET + jets + muons),
36 // i.e. muon corrections enter the sum of "unclustered energy" with negative sign.
37 //
38  int numMuons = muons->size();
39  for ( int muonIndex = 0; muonIndex < numMuons; ++muonIndex ) {
40  const reco::Muon& muon = muons->at(muonIndex);
41 
42  reco::MuonRef muonRef(muons, muonIndex);
43 
44  reco::MuonMETCorrectionData muonCorrection = (*muonCorrections)[muonRef];
45  if ( muonCorrection.type() != reco::MuonMETCorrectionData::NotUsed ) {
46  unclEnergySum->mex -= muon.px();
47  unclEnergySum->mey -= muon.py();
48  unclEnergySum->sumet -= muon.pt();
49  }
50  }
51 
52 //--- add sum of muon corrections to the event
53  evt.put(std::move(unclEnergySum));
54 }
55 
57 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
edm::EDGetTokenT< reco::MuonCollection > token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
double px() const final
x coordinate of momentum vector
double pt() const final
transverse momentum
MuonMETcorrInputProducer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< edm::ValueMap< reco::MuonMETCorrectionData > > muonCorrectionMapToken_
double py() const final
y coordinate of momentum vector
a MET correction term
Definition: CorrMETData.h:14
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511