Skip to content

Commit

Permalink
Merge pull request #44565 from nurfikri89/portFrom141XTo140X_nano_nHa…
Browse files Browse the repository at this point in the history
…dronsInGenJets

[NanoAOD] Backport of #44479 (Add number of B & C hadrons for GenJetAK8 and GenJet) to 14_0_X
  • Loading branch information
cmsbuild authored Apr 2, 2024
2 parents 3b17fcb + a64fc6e commit 5ae3c30
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions PhysicsTools/NanoAOD/plugins/GenJetFlavourTableProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ void GenJetFlavourTableProducer::produce(edm::Event& iEvent, const edm::EventSet
unsigned int ncand = 0;
std::vector<int16_t> partonFlavour;
std::vector<uint8_t> hadronFlavour;
std::vector<uint8_t> nBHadrons;
std::vector<uint8_t> nCHadrons;

for (const reco::GenJet& jet : jetsProd) {
if (!cut_(jet))
Expand All @@ -73,19 +75,25 @@ void GenJetFlavourTableProducer::produce(edm::Event& iEvent, const edm::EventSet
if (deltaR(jet.p4(), jetFlavourInfoMatching.first->p4()) < deltaR_) {
partonFlavour.push_back(jetFlavourInfoMatching.second.getPartonFlavour());
hadronFlavour.push_back(jetFlavourInfoMatching.second.getHadronFlavour());
nBHadrons.push_back(jetFlavourInfoMatching.second.getbHadrons().size());
nCHadrons.push_back(jetFlavourInfoMatching.second.getcHadrons().size());
matched = true;
break;
}
}
if (!matched) {
partonFlavour.push_back(0);
hadronFlavour.push_back(0);
nBHadrons.push_back(0);
nCHadrons.push_back(0);
}
}

auto tab = std::make_unique<nanoaod::FlatTable>(ncand, name_, false, true);
tab->addColumn<int16_t>("partonFlavour", partonFlavour, "flavour from parton matching");
tab->addColumn<uint8_t>("hadronFlavour", hadronFlavour, "flavour from hadron ghost clustering");
tab->addColumn<uint8_t>("nBHadrons", nBHadrons, "number of b-hadrons");
tab->addColumn<uint8_t>("nCHadrons", nCHadrons, "number of c-hadrons");

iEvent.put(std::move(tab));
}
Expand Down
2 changes: 0 additions & 2 deletions PhysicsTools/NanoAOD/python/jetMC_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@
name = _fatJetTable.name,
extension = cms.bool(True),
variables = cms.PSet(
nBHadrons = Var("jetFlavourInfo().getbHadrons().size()", "uint8", doc="number of b-hadrons"),
nCHadrons = Var("jetFlavourInfo().getcHadrons().size()", "uint8", doc="number of c-hadrons"),
hadronFlavour = Var("hadronFlavour()", "uint8", doc="flavour from hadron ghost clustering"),
# cut should follow genJetAK8Table.cut
genJetAK8Idx = Var("?genJetFwdRef().backRef().isNonnull() && genJetFwdRef().backRef().pt() > 100.?genJetFwdRef().backRef().key():-1", "int16", doc="index of matched gen AK8 jet"),
Expand Down
6 changes: 4 additions & 2 deletions PhysicsTools/NanoAOD/python/nanoDQM_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@
Plot1D('muEF', 'muEF', 20, 0, 1, 'muon Energy Fraction'),
Plot1D('neEmEF', 'neEmEF', 20, 0, 1, 'charged Electromagnetic EnergyFraction'),
Plot1D('neHEF', 'neHEF', 20, 0, 1, 'neutral Hadron Energy Fraction'),
Plot1D('nBHadrons', 'nBHadrons', 4, -0.5, 3.5, 'number of b-hadrons'),
Plot1D('nCHadrons', 'nCHadrons', 4, -0.5, 3.5, 'number of c-hadrons'),
Plot1D('particleNetMD_QCD', 'particleNetMD_QCD', 20, 0, 1, 'Mass-decorrelated ParticleNet tagger raw QCD score'),
Plot1D('particleNetMD_Xbb', 'particleNetMD_Xbb', 20, 0, 1, 'Mass-decorrelated ParticleNet tagger raw X->bb score. For X->bb vs QCD tagging, use Xbb/(Xbb+QCD)'),
Plot1D('particleNetMD_Xcc', 'particleNetMD_Xcc', 20, 0, 1, 'Mass-decorrelated ParticleNet tagger raw X->cc score. For X->cc vs QCD tagging, use Xcc/(Xcc+QCD)'),
Expand Down Expand Up @@ -315,6 +313,8 @@
Plot1D('eta', 'eta', 20, -7, 7, 'eta'),
Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'),
Plot1D('mass', 'mass', 20, 0, 200, 'mass'),
Plot1D('nBHadrons', 'nBHadrons', 4, -0.5, 3.5, 'number of b-hadrons'),
Plot1D('nCHadrons', 'nCHadrons', 4, -0.5, 3.5, 'number of c-hadrons'),
Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'),
Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'),
Plot1D('pt', 'pt', 20, 0, 200, 'pt'),
Expand All @@ -327,6 +327,8 @@
Plot1D('eta', 'eta', 20, -7, 7, 'eta'),
Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'),
Plot1D('mass', 'mass', 20, 0, 200, 'mass'),
Plot1D('nBHadrons', 'nBHadrons', 4, -0.5, 3.5, 'number of b-hadrons'),
Plot1D('nCHadrons', 'nCHadrons', 4, -0.5, 3.5, 'number of c-hadrons'),
Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'),
Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'),
Plot1D('pt', 'pt', 20, 0, 200, 'pt'),
Expand Down

0 comments on commit 5ae3c30

Please sign in to comment.