Skip to content

Commit

Permalink
Merge pull request #42466 from bundocka/addPtZjetcut
Browse files Browse the repository at this point in the history
L1T: add puppi jet requirement for filling zpt in L1Ntuples
  • Loading branch information
cmsbuild authored Aug 4, 2023
2 parents 9bd8b0a + 8e21748 commit a5b91a1
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions L1Trigger/L1TNtuples/plugins/L1JetRecoTreeProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class L1JetRecoTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResour
void doPFMetNoMu(edm::Handle<reco::PFMETCollection> pfMet, edm::Handle<reco::MuonCollection>);
void doPUPPIMetNoMu(edm::Handle<reco::PFMETCollection> puppiMet, edm::Handle<reco::MuonCollection>);

void doZPt(edm::Handle<reco::MuonCollection>);
void doZPt(edm::Handle<reco::MuonCollection> muons, edm::Handle<std::vector<pat::Jet> > corrPuppiJets);

bool pfJetID(const reco::PFJet& jet);
bool puppiJetID(const pat::Jet& jet);
Expand Down Expand Up @@ -129,7 +129,6 @@ class L1JetRecoTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResour
bool puppiMetMissing_;
bool caloMetMissing_;
bool caloMetBEMissing_;

bool muonsMissing_;
};

Expand Down Expand Up @@ -376,8 +375,15 @@ void L1JetRecoTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSe
}

if (muons.isValid()) {
doZPt(muons);
if (puppiJets.isValid()) {
doZPt(muons, corrPuppiJets);

} else {
if (!puppiJetsMissing_) {
edm::LogWarning("MissingProduct") << "PUPPIJets not found. Branch will not be filled" << std::endl;
}
puppiJetsMissing_ = true;
}
} else {
if (!muonsMissing_) {
edm::LogWarning("MissingProduct") << "Muons not found. ZPt branch will not be filled" << std::endl;
Expand Down Expand Up @@ -663,8 +669,20 @@ void L1JetRecoTreeProducer::doCaloMetBE(edm::Handle<reco::CaloMETCollection> cal
met_data->caloSumEtBE = theMet.sumEt();
}

void L1JetRecoTreeProducer::doZPt(edm::Handle<reco::MuonCollection> muons) {
if (muons->size() < 2) {
void L1JetRecoTreeProducer::doZPt(edm::Handle<reco::MuonCollection> muons,
edm::Handle<std::vector<pat::Jet> > corrPuppiJets) {
bool passPuppiJetPtCut = false;

for (auto it = corrPuppiJets->begin(); it != corrPuppiJets->end(); ++it) {
if (!puppiJetID(*it))
continue;
if (it->muonEnergyFraction() > 0.5 || it->chargedEmEnergyFraction() > 0.5)
continue;
if (it->pt() > 30)
passPuppiJetPtCut = true;
}

if (!passPuppiJetPtCut || muons->size() < 2) {
met_data->zPt = -999;
return;
}
Expand Down

0 comments on commit a5b91a1

Please sign in to comment.