Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L1T: Add zPt to L1JetRecoTree in L1Ntuples #42037

Merged
merged 3 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions L1Trigger/L1TNtuples/interface/L1AnalysisRecoMetDataFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace L1Analysis {
puppi_mHt = -999.;
puppi_mHtPhi = -999.;
sumEt = -999.;
zPt = -999.;
ecalFlag = 0;
hcalFlag = 0;
}
Expand Down Expand Up @@ -72,6 +73,7 @@ namespace L1Analysis {
float puppi_Ht;
float puppi_mHt;
float puppi_mHtPhi;
float zPt;
unsigned short ecalFlag;
unsigned short hcalFlag;
};
Expand Down
57 changes: 57 additions & 0 deletions L1Trigger/L1TNtuples/plugins/L1JetRecoTreeProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"
#include "DataFormats/METReco/interface/PFMET.h"
#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/METReco/interface/CaloMETCollection.h"
#include "DataFormats/METReco/interface/CaloMET.h"
#include "DataFormats/PatCandidates/interface/Jet.h"
Expand Down Expand Up @@ -79,6 +80,8 @@ 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>);

bool pfJetID(const reco::PFJet& jet);
bool puppiJetID(const pat::Jet& jet);
bool caloJetID(const reco::CaloJet& jet);
Expand Down Expand Up @@ -372,6 +375,16 @@ void L1JetRecoTreeProducer::analyze(const edm::Event& iEvent, const edm::EventSe
caloMetBEMissing_ = true;
}

if (muons.isValid()) {
doZPt(muons);

} else {
if (!muonsMissing_) {
edm::LogWarning("MissingProduct") << "Muons not found. ZPt branch will not be filled" << std::endl;
}
muonsMissing_ = true;
}

tree_->Fill();
}

Expand Down Expand Up @@ -650,6 +663,50 @@ 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) {
met_data->zPt = -999;
return;
}

reco::Muon muon1;
reco::Muon muon2;

float zMass = 91.2;
float diMuMass = 0;
float closestDiff = 999.;
bool found2PFMuons = false;

for (auto it1 = muons->begin(); it1 != muons->end(); ++it1) {
if (!it1->isPFMuon())
continue;
for (auto it2 = std::next(it1); it2 != muons->end(); ++it2) {
if (!it2->isPFMuon())
continue;
if (it1->charge() != (-1 * it2->charge()))
continue;

found2PFMuons = true;
diMuMass = (it1->p4() + it2->p4()).M();
float diff = abs(diMuMass - zMass);
if (diff < closestDiff) {
closestDiff = diff;
muon1 = *it1;
muon2 = *it2;
}
}
}

diMuMass = (muon1.p4() + muon2.p4()).M();
if (abs(diMuMass - zMass) > 30 || !found2PFMuons) {
met_data->zPt = -999;
return;
}

float zPt = (muon1.p4() + muon2.p4()).pt();
met_data->zPt = zPt;
}

bool L1JetRecoTreeProducer::pfJetID(const reco::PFJet& jet) {
bool tmp = true;
if (std::abs(jet.eta()) <= 2.6) {
Expand Down