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

Adding jet efficiency and purity plots #34580

Closed
wants to merge 6 commits into from
Closed
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
1 change: 1 addition & 0 deletions Validation/RecoParticleFlow/plugins/OffsetAnalyzerDQM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ void OffsetAnalyzerDQM::analyze(const edm::Event& iEvent, const edm::EventSetup&
int npv = 0;
for (unsigned int i = 0; i < nPVall; i++) {
const auto& pv = vertexHandle->at(i);
th1dPlots["pv_z"].fill(pv.z());

if (!pv.isFake() && pv.ndof() >= 4 && fabs(pv.z()) <= 24.0 && fabs(pv.position().rho()) <= 2.0) {
npv++;
Expand Down
202 changes: 199 additions & 3 deletions Validation/RecoParticleFlow/plugins/PFJetAnalyzerDQM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,18 @@ class PFJetAnalyzerDQM : public DQMEDAnalyzer {
std::vector<Plot1DInBin> jetResponsePlots;
std::vector<Plot1DInBin> jetResponsePlots_noJEC;
std::vector<Plot1DInBinVariable> genJetPlots;
std::vector<Plot1DInBinVariable> genJetPlots_matched;
std::vector<Plot1DInBinVariable> genJetPlots_unmatched;
std::vector<Plot1DInBinVariable> recoJetPlots;
std::vector<Plot1DInBinVariable> recoJetPlots_matched;
std::vector<Plot1DInBinVariable> recoJetPlots_unmatched;

// Is this data or MC?
bool isMC;

float jetDeltaR;

bool genJetsOn;
bool genJetsOn, recoJetsOn;

std::string jetCollectionName;

Expand All @@ -133,6 +138,11 @@ class PFJetAnalyzerDQM : public DQMEDAnalyzer {
void fillJetResponse(edm::View<pat::Jet>& recoJetCollection, edm::View<reco::Jet>& genJetCollection);
void prepareJetResponsePlots(const std::vector<edm::ParameterSet>& genjet_plots_pset);
void prepareGenJetPlots(const std::vector<edm::ParameterSet>& genjet_plots_pset);
void prepareGenJetMatchedPlots(const std::vector<edm::ParameterSet>& genjet_plots_pset);
void prepareGenJetUnmatchedPlots(const std::vector<edm::ParameterSet>& genjet_plots_pset);
void prepareRecoJetPlots(const std::vector<edm::ParameterSet>& recojet_plots_pset);
void prepareRecoJetMatchedPlots(const std::vector<edm::ParameterSet>& recojet_plots_pset);
void prepareRecoJetUnmatchedPlots(const std::vector<edm::ParameterSet>& recojet_plots_pset);
};

void PFJetAnalyzerDQM::prepareJetResponsePlots(const std::vector<edm::ParameterSet>& response_plots) {
Expand Down Expand Up @@ -188,6 +198,121 @@ void PFJetAnalyzerDQM::prepareGenJetPlots(const std::vector<edm::ParameterSet>&
}
}

void PFJetAnalyzerDQM::prepareGenJetMatchedPlots(const std::vector<edm::ParameterSet>& genjet_plots_pset) {
for (auto& pset : genjet_plots_pset) {
const auto name = pset.getParameter<std::string>("name") + "_matched";
const auto title = "Matched " + pset.getParameter<std::string>("title");

//Low and high edges of the eta bins for jets to pass to be filled into this histogram
const auto ptbins_d = pset.getParameter<std::vector<double>>("ptBins");
std::vector<float> ptbins(ptbins_d.begin(), ptbins_d.end());

const auto etabin_low = pset.getParameter<double>("etaBinLow");
const auto etabin_high = pset.getParameter<double>("etaBinHigh");

genJetPlots_matched.push_back(Plot1DInBinVariable(
name,
title,
std::make_unique<TH1F>(name.c_str(), title.c_str(), static_cast<int>(ptbins.size()) - 1, ptbins.data()),
0.0,
0.0,
etabin_low,
etabin_high));
}
}

void PFJetAnalyzerDQM::prepareGenJetUnmatchedPlots(const std::vector<edm::ParameterSet>& genjet_plots_pset) {
for (auto& pset : genjet_plots_pset) {
const auto name = pset.getParameter<std::string>("name") + "_unmatched";
const auto title = "Unmatched " + pset.getParameter<std::string>("title");

//Low and high edges of the eta bins for jets to pass to be filled into this histogram
const auto ptbins_d = pset.getParameter<std::vector<double>>("ptBins");
std::vector<float> ptbins(ptbins_d.begin(), ptbins_d.end());

const auto etabin_low = pset.getParameter<double>("etaBinLow");
const auto etabin_high = pset.getParameter<double>("etaBinHigh");

genJetPlots_unmatched.push_back(Plot1DInBinVariable(
name,
title,
std::make_unique<TH1F>(name.c_str(), title.c_str(), static_cast<int>(ptbins.size()) - 1, ptbins.data()),
0.0,
0.0,
etabin_low,
etabin_high));
}
}

void PFJetAnalyzerDQM::prepareRecoJetPlots(const std::vector<edm::ParameterSet>& recojet_plots_pset) {
for (auto& pset : recojet_plots_pset) {
const auto name = pset.getParameter<std::string>("name");
const auto title = pset.getParameter<std::string>("title");

//Low and high edges of the eta bins for jets to pass to be filled into this histogram
const auto ptbins_d = pset.getParameter<std::vector<double>>("ptBins");
std::vector<float> ptbins(ptbins_d.begin(), ptbins_d.end());

const auto etabin_low = pset.getParameter<double>("etaBinLow");
const auto etabin_high = pset.getParameter<double>("etaBinHigh");

recoJetPlots.push_back(Plot1DInBinVariable(
name,
title,
std::make_unique<TH1F>(name.c_str(), title.c_str(), static_cast<int>(ptbins.size()) - 1, ptbins.data()),
0.0,
0.0,
etabin_low,
etabin_high));
}
}

void PFJetAnalyzerDQM::prepareRecoJetMatchedPlots(const std::vector<edm::ParameterSet>& recojet_plots_pset) {
for (auto& pset : recojet_plots_pset) {
const auto name = pset.getParameter<std::string>("name") + "_matched";
const auto title = "Matched " + pset.getParameter<std::string>("title");

//Low and high edges of the eta bins for jets to pass to be filled into this histogram
const auto ptbins_d = pset.getParameter<std::vector<double>>("ptBins");
std::vector<float> ptbins(ptbins_d.begin(), ptbins_d.end());

const auto etabin_low = pset.getParameter<double>("etaBinLow");
const auto etabin_high = pset.getParameter<double>("etaBinHigh");

recoJetPlots_matched.push_back(Plot1DInBinVariable(
name,
title,
std::make_unique<TH1F>(name.c_str(), title.c_str(), static_cast<int>(ptbins.size()) - 1, ptbins.data()),
0.0,
0.0,
etabin_low,
etabin_high));
}
}

void PFJetAnalyzerDQM::prepareRecoJetUnmatchedPlots(const std::vector<edm::ParameterSet>& recojet_plots_pset) {
for (auto& pset : recojet_plots_pset) {
const auto name = pset.getParameter<std::string>("name") + "_unmatched";
const auto title = "Unmatched " + pset.getParameter<std::string>("title");

//Low and high edges of the eta bins for jets to pass to be filled into this histogram
const auto ptbins_d = pset.getParameter<std::vector<double>>("ptBins");
std::vector<float> ptbins(ptbins_d.begin(), ptbins_d.end());

const auto etabin_low = pset.getParameter<double>("etaBinLow");
const auto etabin_high = pset.getParameter<double>("etaBinHigh");

recoJetPlots_unmatched.push_back(Plot1DInBinVariable(
name,
title,
std::make_unique<TH1F>(name.c_str(), title.c_str(), static_cast<int>(ptbins.size()) - 1, ptbins.data()),
0.0,
0.0,
etabin_low,
etabin_high));
}
}

PFJetAnalyzerDQM::PFJetAnalyzerDQM(const edm::ParameterSet& iConfig) {
recoJetsLabel = iConfig.getParameter<edm::InputTag>("recoJetCollection");
genJetsLabel = iConfig.getParameter<edm::InputTag>("genJetCollection");
Expand All @@ -200,13 +325,21 @@ PFJetAnalyzerDQM::PFJetAnalyzerDQM(const edm::ParameterSet& iConfig) {

//for turn genJet on/off
genJetsOn = iConfig.getParameter<bool>("genJetsOn");
recoJetsOn = iConfig.getParameter<bool>("recoJetsOn");

//Create all jet response plots in bins of genjet pt and eta
const auto& response_plots = iConfig.getParameter<std::vector<edm::ParameterSet>>("responsePlots");
prepareJetResponsePlots(response_plots);

const auto& genjet_plots = iConfig.getParameter<std::vector<edm::ParameterSet>>("genJetPlots");
prepareGenJetPlots(genjet_plots);
prepareGenJetMatchedPlots(genjet_plots);
prepareGenJetUnmatchedPlots(genjet_plots);

const auto& recojet_plots = iConfig.getParameter<std::vector<edm::ParameterSet>>("recoJetPlots");
prepareRecoJetPlots(recojet_plots);
prepareRecoJetMatchedPlots(recojet_plots);
prepareRecoJetUnmatchedPlots(recojet_plots);

recoJetsToken = consumes<edm::View<pat::Jet>>(recoJetsLabel);
genJetsToken = consumes<edm::View<reco::Jet>>(genJetsLabel);
Expand All @@ -215,7 +348,37 @@ PFJetAnalyzerDQM::PFJetAnalyzerDQM(const edm::ParameterSet& iConfig) {
void PFJetAnalyzerDQM::fillJetResponse(edm::View<pat::Jet>& recoJetCollection, edm::View<reco::Jet>& genJetCollection) {
//match gen jets to reco jets, require minimum jetDeltaR, choose closest, do not try to match charge
std::vector<int> matchIndices;
std::vector<int> matchIndicesReco;
PFB::match(genJetCollection, recoJetCollection, matchIndices, false, jetDeltaR);
PFB::match(recoJetCollection, genJetCollection, matchIndicesReco, false, jetDeltaR);

//Fill recojet pt if recoJetOn
for (unsigned int i = 0; i < recoJetCollection.size(); i++) {
const auto& recoJet = recoJetCollection.at(i);
const auto pt_reco = recoJet.pt();
const auto eta_reco = abs(recoJet.eta());
const int iMatch_reco = matchIndicesReco[i];
if (recoJetsOn) {
for (auto& plot : recoJetPlots) {
if (plot.isInEtaBin(eta_reco)) {
plot.fill(pt_reco);
}
}
if (iMatch_reco != -1) {
for (auto& plot : recoJetPlots_matched) {
if (plot.isInEtaBin(eta_reco)) {
plot.fill(pt_reco);
}
}
} else {
for (auto& plot : recoJetPlots_unmatched) {
if (plot.isInEtaBin(eta_reco)) {
plot.fill(pt_reco);
}
}
}
}
}

for (unsigned int i = 0; i < genJetCollection.size(); i++) {
const auto& genJet = genJetCollection.at(i);
Expand All @@ -231,6 +394,21 @@ void PFJetAnalyzerDQM::fillJetResponse(edm::View<pat::Jet>& recoJetCollection, e
}
}
}
if (recoJetsOn) {
if (iMatch != -1) {
for (auto& plot : genJetPlots_matched) {
if (plot.isInEtaBin(eta_gen)) {
plot.fill(pt_gen);
}
}
} else {
for (auto& plot : genJetPlots_unmatched) {
if (plot.isInEtaBin(eta_gen)) {
plot.fill(pt_gen);
}
}
}
}

//If gen jet had a matched reco jet
if (iMatch != -1) {
Expand Down Expand Up @@ -263,12 +441,31 @@ void PFJetAnalyzerDQM::bookHistograms(DQMStore::IBooker& booker, edm::Run const&
for (auto& plot : jetResponsePlots) {
plot.book(booker);
}

//Book plots for noJEC
booker.setCurrentFolder("ParticleFlow/JetResponse/" + jetCollectionName + "/noJEC/");
for (auto& plot : jetResponsePlots_noJEC) {
plot.book(booker);
}

if (recoJetsOn) {
booker.setCurrentFolder("ParticleFlow/JetResponse/" + jetCollectionName + "/noJEC/");
for (auto& plot : genJetPlots_matched) {
plot.book(booker);
}
for (auto& plot : genJetPlots_unmatched) {
plot.book(booker);
}
booker.setCurrentFolder("ParticleFlow/JetResponse/" + jetCollectionName + "/JEC/");
for (auto& plot : recoJetPlots) {
plot.book(booker);
}
for (auto& plot : recoJetPlots_matched) {
plot.book(booker);
}
for (auto& plot : recoJetPlots_unmatched) {
plot.book(booker);
}
}
//Book plots for gen-jet pt spectra
if (genJetsOn) {
booker.setCurrentFolder("ParticleFlow/GenJets/");
Expand All @@ -277,7 +474,6 @@ void PFJetAnalyzerDQM::bookHistograms(DQMStore::IBooker& booker, edm::Run const&
}
}
}

void PFJetAnalyzerDQM::analyze(const edm::Event& iEvent, const edm::EventSetup&) {
edm::Handle<edm::View<pat::Jet>> recoJetCollectionHandle;
iEvent.getByToken(recoJetsToken, recoJetCollectionHandle);
Expand Down
Loading