diff --git a/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc b/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc index 450839b2650da..4a6e6656ac353 100644 --- a/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc +++ b/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc @@ -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 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("GenParticles")), - tokenGenParticles_(consumes(inputTagGenParticles_)), + : tokenGenParticles_(consumes(iConfig.getParameter("GenParticles"))), includeNeutrinos_(iConfig.getParameter("includeNeutrinos")), verbose_(iConfig.getUntrackedParameter("verbose", false)) { produces(); @@ -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; @@ -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)); diff --git a/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.h b/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.h index 71d2f67afb92f..306c7ed88b503 100644 --- a/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.h +++ b/PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.h @@ -31,7 +31,6 @@ class TauGenJetProducer : public edm::global::EDProducer<> { private: /// Input PFCandidates - const edm::InputTag inputTagGenParticles_; const edm::EDGetTokenT tokenGenParticles_; /// if yes, neutrinos will be included, for debug purposes diff --git a/PhysicsTools/JetMCUtils/src/JetMCTag.cc b/PhysicsTools/JetMCUtils/src/JetMCTag.cc index fefb2318992d9..20d23b8500481 100644 --- a/PhysicsTools/JetMCUtils/src/JetMCTag.cc +++ b/PhysicsTools/JetMCUtils/src/JetMCTag.cc @@ -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; @@ -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++; @@ -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: