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

Build genTauJets for undecayed taus and add tau decay-mode to genTauJets [13_0_X] #41104

Merged
merged 2 commits into from
Mar 21, 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
41 changes: 38 additions & 3 deletions PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,29 @@
#include "DataFormats/Common/interface/RefToPtr.h"

#include "PhysicsTools/HepMCCandAlgos/interface/GenParticlesHelper.h"
#include "PhysicsTools/JetMCUtils/interface/JetMCTag.h"
#include "DataFormats/TauReco/interface/PFTau.h"

using namespace std;
using namespace edm;
using namespace reco;

namespace {
//Map to convert names of decay modes to integer codes
const std::map<std::string, int> decayModeStringToCodeMap = {{"null", PFTau::kNull},
{"oneProng0Pi0", PFTau::kOneProng0PiZero},
{"oneProng1Pi0", PFTau::kOneProng1PiZero},
{"oneProng2Pi0", PFTau::kOneProng2PiZero},
{"threeProng0Pi0", PFTau::kThreeProng0PiZero},
{"threeProng1Pi0", PFTau::kThreeProng1PiZero},
{"electron", PFTau::kRareDecayMode + 1},
{"muon", PFTau::kRareDecayMode + 2},
{"rare", PFTau::kRareDecayMode},
{"tau", PFTau::kNull - 1}};
} // namespace

TauGenJetProducer::TauGenJetProducer(const edm::ParameterSet& iConfig)
: inputTagGenParticles_(iConfig.getParameter<InputTag>("GenParticles")),
tokenGenParticles_(consumes<GenParticleCollection>(inputTagGenParticles_)),
: tokenGenParticles_(consumes<GenParticleCollection>(iConfig.getParameter<InputTag>("GenParticles"))),
includeNeutrinos_(iConfig.getParameter<bool>("includeNeutrinos")),
verbose_(iConfig.getUntrackedParameter<bool>("verbose", false)) {
produces<GenJetCollection>();
Expand All @@ -40,7 +55,21 @@ void TauGenJetProducer::produce(edm::StreamID, Event& iEvent, const EventSetup&
// look for all status 1 (stable) descendents
GenParticleRefVector descendents;
findDescendents(*iTau, descendents, 1);

if (descendents.empty()) {
edm::LogWarning("NoTauDaughters") << "Tau p4: " << (*iTau)->p4() << " vtx: " << (*iTau)->vertex()
<< " has no daughters";

math::XYZPoint vertex;
GenJet::Specific specific;
Jet::Constituents constituents;

constituents.push_back(refToPtr(*iTau));
GenJet jet((*iTau)->p4(), vertex, specific, constituents);
jet.setCharge((*iTau)->charge());
jet.setStatus(decayModeStringToCodeMap.at("tau"));
pOutVisTaus->emplace_back(std::move(jet));
continue;
}
// CV: skip status 2 taus that radiate-off a photon
// --> have a status 2 tau lepton in the list of descendents
GenParticleRefVector status2TauDaughters;
Expand Down Expand Up @@ -88,6 +117,12 @@ void TauGenJetProducer::produce(edm::StreamID, Event& iEvent, const EventSetup&
<< " # descendents: " << constituents.size() << "\n";

jet.setCharge(charge);
// determine tau decay mode and set it as jet status
if (auto search = decayModeStringToCodeMap.find(JetMCTagUtils::genTauDecayMode(jet));
search != decayModeStringToCodeMap.end())
jet.setStatus(search->second);
else
jet.setStatus(decayModeStringToCodeMap.at("null"));
pOutVisTaus->push_back(jet);
}
iEvent.put(std::move(pOutVisTaus));
Expand Down
1 change: 0 additions & 1 deletion PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class TauGenJetProducer : public edm::global::EDProducer<> {

private:
/// Input PFCandidates
const edm::InputTag inputTagGenParticles_;
const edm::EDGetTokenT<reco::GenParticleCollection> tokenGenParticles_;

/// if yes, neutrinos will be included, for debug purposes
Expand Down
6 changes: 6 additions & 0 deletions PhysicsTools/JetMCUtils/src/JetMCTag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ bool JetMCTagUtils::decayFromCHadron(const Candidate &c) {
std::string JetMCTagUtils::genTauDecayMode(const CompositePtrCandidate &c) {
int numElectrons = 0;
int numMuons = 0;
int numTaus = 0;
int numChargedHadrons = 0;
int numNeutralHadrons = 0;
int numPhotons = 0;
Expand All @@ -89,6 +90,9 @@ std::string JetMCTagUtils::genTauDecayMode(const CompositePtrCandidate &c) {
case 13:
numMuons++;
break;
case 15:
numTaus++;
break;
default: {
if ((*daughter)->charge() != 0)
numChargedHadrons++;
Expand All @@ -102,6 +106,8 @@ std::string JetMCTagUtils::genTauDecayMode(const CompositePtrCandidate &c) {
return std::string("electron");
else if (numMuons == 1)
return std::string("muon");
else if (numTaus == 1) //MB: a tau undecayed by generator or an intermediate state used to generate radiations
return std::string("tau");

switch (numChargedHadrons) {
case 1:
Expand Down