Skip to content

Commit c445773

Browse files
authored
Merge pull request #42037 from bundocka/zpt
L1T: Add zPt to L1JetRecoTree in L1Ntuples
2 parents c6c69cf + 01dab1d commit c445773

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

L1Trigger/L1TNtuples/interface/L1AnalysisRecoMetDataFormat.h

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace L1Analysis {
4242
puppi_mHt = -999.;
4343
puppi_mHtPhi = -999.;
4444
sumEt = -999.;
45+
zPt = -999.;
4546
ecalFlag = 0;
4647
hcalFlag = 0;
4748
}
@@ -72,6 +73,7 @@ namespace L1Analysis {
7273
float puppi_Ht;
7374
float puppi_mHt;
7475
float puppi_mHtPhi;
76+
float zPt;
7577
unsigned short ecalFlag;
7678
unsigned short hcalFlag;
7779
};

L1Trigger/L1TNtuples/plugins/L1JetRecoTreeProducer.cc

+57
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "DataFormats/MuonReco/interface/Muon.h"
3737
#include "DataFormats/MuonReco/interface/MuonFwd.h"
3838
#include "DataFormats/METReco/interface/PFMET.h"
39+
#include "DataFormats/MuonReco/interface/Muon.h"
3940
#include "DataFormats/METReco/interface/CaloMETCollection.h"
4041
#include "DataFormats/METReco/interface/CaloMET.h"
4142
#include "DataFormats/PatCandidates/interface/Jet.h"
@@ -79,6 +80,8 @@ class L1JetRecoTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResour
7980
void doPFMetNoMu(edm::Handle<reco::PFMETCollection> pfMet, edm::Handle<reco::MuonCollection>);
8081
void doPUPPIMetNoMu(edm::Handle<reco::PFMETCollection> puppiMet, edm::Handle<reco::MuonCollection>);
8182

83+
void doZPt(edm::Handle<reco::MuonCollection>);
84+
8285
bool pfJetID(const reco::PFJet& jet);
8386
bool puppiJetID(const pat::Jet& jet);
8487
bool caloJetID(const reco::CaloJet& jet);
@@ -372,6 +375,16 @@ void L1JetRecoTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSe
372375
caloMetBEMissing_ = true;
373376
}
374377

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+
375388
tree_->Fill();
376389
}
377390

@@ -650,6 +663,50 @@ void L1JetRecoTreeProducer::doCaloMetBE(edm::Handle<reco::CaloMETCollection> cal
650663
met_data->caloSumEtBE = theMet.sumEt();
651664
}
652665

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+
653710
bool L1JetRecoTreeProducer::pfJetID(const reco::PFJet& jet) {
654711
bool tmp = true;
655712
if (std::abs(jet.eta()) <= 2.6) {

0 commit comments

Comments
 (0)