|
36 | 36 | #include "DataFormats/MuonReco/interface/Muon.h"
|
37 | 37 | #include "DataFormats/MuonReco/interface/MuonFwd.h"
|
38 | 38 | #include "DataFormats/METReco/interface/PFMET.h"
|
| 39 | +#include "DataFormats/MuonReco/interface/Muon.h" |
39 | 40 | #include "DataFormats/METReco/interface/CaloMETCollection.h"
|
40 | 41 | #include "DataFormats/METReco/interface/CaloMET.h"
|
41 | 42 | #include "DataFormats/PatCandidates/interface/Jet.h"
|
@@ -79,6 +80,8 @@ class L1JetRecoTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResour
|
79 | 80 | void doPFMetNoMu(edm::Handle<reco::PFMETCollection> pfMet, edm::Handle<reco::MuonCollection>);
|
80 | 81 | void doPUPPIMetNoMu(edm::Handle<reco::PFMETCollection> puppiMet, edm::Handle<reco::MuonCollection>);
|
81 | 82 |
|
| 83 | + void doZPt(edm::Handle<reco::MuonCollection>); |
| 84 | + |
82 | 85 | bool pfJetID(const reco::PFJet& jet);
|
83 | 86 | bool puppiJetID(const pat::Jet& jet);
|
84 | 87 | bool caloJetID(const reco::CaloJet& jet);
|
@@ -372,6 +375,16 @@ void L1JetRecoTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSe
|
372 | 375 | caloMetBEMissing_ = true;
|
373 | 376 | }
|
374 | 377 |
|
| 378 | + if (muons.isValid()) { |
| 379 | + doZPt(muons); |
| 380 | + |
| 381 | + } else { |
| 382 | + if (!muonsMissing_) { |
| 383 | + edm::LogWarning("MissingProduct") << "Muons not found. ZPt branch will not be filled" << std::endl; |
| 384 | + } |
| 385 | + muonsMissing_ = true; |
| 386 | + } |
| 387 | + |
375 | 388 | tree_->Fill();
|
376 | 389 | }
|
377 | 390 |
|
@@ -650,6 +663,50 @@ void L1JetRecoTreeProducer::doCaloMetBE(edm::Handle<reco::CaloMETCollection> cal
|
650 | 663 | met_data->caloSumEtBE = theMet.sumEt();
|
651 | 664 | }
|
652 | 665 |
|
| 666 | +void L1JetRecoTreeProducer::doZPt(edm::Handle<reco::MuonCollection> muons) { |
| 667 | + if (muons->size() < 2) { |
| 668 | + met_data->zPt = -999; |
| 669 | + return; |
| 670 | + } |
| 671 | + |
| 672 | + reco::Muon muon1; |
| 673 | + reco::Muon muon2; |
| 674 | + |
| 675 | + float zMass = 91.2; |
| 676 | + float diMuMass = 0; |
| 677 | + float closestDiff = 999.; |
| 678 | + bool found2PFMuons = false; |
| 679 | + |
| 680 | + for (auto it1 = muons->begin(); it1 != muons->end(); ++it1) { |
| 681 | + if (!it1->isPFMuon()) |
| 682 | + continue; |
| 683 | + for (auto it2 = std::next(it1); it2 != muons->end(); ++it2) { |
| 684 | + if (!it2->isPFMuon()) |
| 685 | + continue; |
| 686 | + if (it1->charge() != (-1 * it2->charge())) |
| 687 | + continue; |
| 688 | + |
| 689 | + found2PFMuons = true; |
| 690 | + diMuMass = (it1->p4() + it2->p4()).M(); |
| 691 | + float diff = abs(diMuMass - zMass); |
| 692 | + if (diff < closestDiff) { |
| 693 | + closestDiff = diff; |
| 694 | + muon1 = *it1; |
| 695 | + muon2 = *it2; |
| 696 | + } |
| 697 | + } |
| 698 | + } |
| 699 | + |
| 700 | + diMuMass = (muon1.p4() + muon2.p4()).M(); |
| 701 | + if (abs(diMuMass - zMass) > 30 || !found2PFMuons) { |
| 702 | + met_data->zPt = -999; |
| 703 | + return; |
| 704 | + } |
| 705 | + |
| 706 | + float zPt = (muon1.p4() + muon2.p4()).pt(); |
| 707 | + met_data->zPt = zPt; |
| 708 | +} |
| 709 | + |
653 | 710 | bool L1JetRecoTreeProducer::pfJetID(const reco::PFJet& jet) {
|
654 | 711 | bool tmp = true;
|
655 | 712 | if (std::abs(jet.eta()) <= 2.6) {
|
|
0 commit comments