Skip to content

Commit

Permalink
Add tau decay mode code to genTauJet as its status
Browse files Browse the repository at this point in the history
  • Loading branch information
mbluj committed Mar 20, 2023
1 parent 1c973d7 commit 0fb664e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
24 changes: 23 additions & 1 deletion PhysicsTools/JetMCAlgos/plugins/TauGenJetProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,27 @@
#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)
: tokenGenParticles_(consumes<GenParticleCollection>(iConfig.getParameter<InputTag>("GenParticles"))),
includeNeutrinos_(iConfig.getParameter<bool>("includeNeutrinos")),
Expand All @@ -39,7 +55,6 @@ 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";
Expand All @@ -51,6 +66,7 @@ void TauGenJetProducer::produce(edm::StreamID, Event& iEvent, const EventSetup&
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;
}
Expand Down Expand Up @@ -101,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
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

0 comments on commit 0fb664e

Please sign in to comment.