23 const std::map<std::string, int> decayModeStringToCodeMap = {{
"null", PFTau::kNull},
24 {
"oneProng0Pi0", PFTau::kOneProng0PiZero},
25 {
"oneProng1Pi0", PFTau::kOneProng1PiZero},
26 {
"oneProng2Pi0", PFTau::kOneProng2PiZero},
27 {
"threeProng0Pi0", PFTau::kThreeProng0PiZero},
28 {
"threeProng1Pi0", PFTau::kThreeProng1PiZero},
29 {
"electron", PFTau::kRareDecayMode + 1},
30 {
"muon", PFTau::kRareDecayMode + 2},
31 {
"rare", PFTau::kRareDecayMode},
32 {
"tau", PFTau::kNull - 1}};
37 includeNeutrinos_(iConfig.getParameter<
bool>(
"includeNeutrinos")),
38 verbose_(iConfig.getUntrackedParameter<
bool>(
"verbose",
false)) {
39 produces<GenJetCollection>();
47 auto pOutVisTaus = std::make_unique<GenJetCollection>();
54 for (
IGR iTau = allStatus2Taus.
begin(); iTau != allStatus2Taus.
end(); ++iTau) {
58 if (descendents.
empty()) {
59 edm::LogWarning(
"NoTauDaughters") <<
"Tau p4: " << (*iTau)->p4() <<
" vtx: " << (*iTau)->vertex()
60 <<
" has no daughters";
64 Jet::Constituents constituents;
66 constituents.push_back(
refToPtr(*iTau));
68 jet.setCharge((*iTau)->charge());
69 jet.setStatus(decayModeStringToCodeMap.at(
"tau"));
77 if (!status2TauDaughters.
empty())
83 Jet::Constituents constituents;
86 cout <<
"tau " << (*iTau) << endl;
88 for (
IGR igr = descendents.
begin(); igr != descendents.
end(); ++igr) {
89 int absPdgId =
abs((*igr)->pdgId());
93 if (absPdgId == 12 || absPdgId == 14 || absPdgId == 16)
98 cout <<
"\t" << (*igr) << endl;
100 charge += (*igr)->charge();
101 sumVisMom += (*igr)->p4();
105 constituents.push_back(
refToPtr(*igr));
113 if (
charge != (*iTau)->charge())
114 edm::LogError(
"TauGenJetProducer") <<
" charge of Tau: " << (*iTau)
115 <<
" not equal to charge of sum of charge of all descendents.\n" 116 <<
" Tau's charge: " << (*iTau)->charge() <<
" sum: " <<
charge 117 <<
" # descendents: " << constituents.size() <<
"\n";
122 search != decayModeStringToCodeMap.end())
125 jet.setStatus(decayModeStringToCodeMap.at(
"null"));
126 pOutVisTaus->push_back(
jet);
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
std::string genTauDecayMode(const reco::CompositePtrCandidate &c)
bool empty() const
Is the RefVector empty.
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
void findParticles(const reco::GenParticleCollection &sourceParticles, reco::GenParticleRefVector &particleRefs, int pdgId, int status)
find all particles of a given pdgId and status
const edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
Input PFCandidates.
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const bool verbose_
verbose ?
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
const bool includeNeutrinos_
if yes, neutrinos will be included, for debug purposes
Abs< T >::type abs(const T &t)
Jets made from MC generator particles.
#define DEFINE_FWK_MODULE(type)
builds a GenJet from the visible daughters of each status 2 tau in the event.
XYZPointD XYZPoint
point in space with cartesian internal representation
const_iterator end() const
Termination of iteration.
~TauGenJetProducer() override
TauGenJetProducer(const edm::ParameterSet &)
Log< level::Warning, false > LogWarning
const_iterator begin() const
Initialize an iterator over the RefVector.
void findDescendents(const reco::GenParticleRef &base, reco::GenParticleRefVector &descendents, int status, int pdgId=0)
find all descendents of a given status and pdgId (recursive)