File indexing completed on 2024-09-10 02:59:05
0001 #ifndef SimDataFormats_SimTauCPLink_h
0002 #define SimDataFormats_SimTauCPLink_h
0003
0004 #include "DataFormats/HGCalReco/interface/TICLCandidate.h"
0005 #include "SimDataFormats/CaloAnalysis/interface/CaloParticleFwd.h"
0006 #include "SimDataFormats/CaloAnalysis/interface/CaloParticle.h"
0007 #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009
0010 class SimTauCPLink {
0011 public:
0012 SimTauCPLink() {}
0013 ~SimTauCPLink() {}
0014 struct DecayNav {
0015 int pdgId_;
0016 int resonance_idx_;
0017 int calo_particle_idx_;
0018 int gen_particle_idx_;
0019 int pdgId() const { return pdgId_; }
0020 int resonance_idx() const { return resonance_idx_; }
0021 int calo_particle_idx() const { return calo_particle_idx_; }
0022 int gen_particle_idx() const { return gen_particle_idx_; }
0023
0024 private:
0025 };
0026
0027 std::vector<std::pair<int, int>> resonances;
0028 std::vector<DecayNav> leaves;
0029 CaloParticleRefVector calo_particle_leaves;
0030 int decayMode;
0031
0032 enum decayModes {
0033 kNull = -1,
0034 kOneProng0PiZero,
0035 kOneProng1PiZero,
0036 kOneProng2PiZero,
0037 kOneProng3PiZero,
0038 kOneProngNPiZero,
0039 kTwoProng0PiZero,
0040 kTwoProng1PiZero,
0041 kTwoProng2PiZero,
0042 kTwoProng3PiZero,
0043 kTwoProngNPiZero,
0044 kThreeProng0PiZero,
0045 kThreeProng1PiZero,
0046 kThreeProng2PiZero,
0047 kThreeProng3PiZero,
0048 kThreeProngNPiZero,
0049 kRareDecayMode,
0050 kElectron,
0051 kMuon
0052 };
0053
0054 void dump(void) const {
0055 for (auto const &l : leaves) {
0056 LogDebug("SimTauProducer")
0057 .format(
0058 "L {} {} CP: {} GenP idx: {}", l.pdgId(), l.resonance_idx(), l.calo_particle_idx(), l.gen_particle_idx());
0059 }
0060 for (auto const &r : resonances) {
0061 LogDebug("SimTauProducer").format("R {} {}", r.first, r.second);
0062 }
0063 }
0064
0065 void dumpDecay(const std::pair<int, int> &entry) const {
0066 if (entry.second == -1) {
0067 LogDebug("SimTauProducer").format("{} {}", entry.first, entry.second);
0068 } else {
0069 LogDebug("SimTauProducer").format("{} {} coming from: ", entry.first, entry.second);
0070 auto const &mother = resonances[entry.second];
0071 dumpDecay(mother);
0072 }
0073 }
0074
0075 void dumpFullDecay(void) const {
0076 for (auto const &leaf : leaves) {
0077 dumpDecay({leaf.pdgId(), leaf.resonance_idx()});
0078 }
0079 }
0080
0081 int buildDecayModes() {
0082 int numElectrons = 0;
0083 int numMuons = 0;
0084 int numHadrons = 0;
0085 int numPhotons = 0;
0086 for (auto leaf : leaves) {
0087 int pdg_id = abs(leaf.pdgId());
0088 switch (pdg_id) {
0089 case 22:
0090 numPhotons++;
0091 break;
0092 case 11:
0093 numElectrons++;
0094 break;
0095 case 13:
0096 numMuons++;
0097 break;
0098 case 16:
0099 break;
0100 default:
0101 numHadrons++;
0102 }
0103 }
0104
0105 if (numElectrons == 1)
0106 return kElectron;
0107 else if (numMuons == 1)
0108 return kMuon;
0109 switch (numHadrons) {
0110 case 1:
0111 switch (numPhotons) {
0112 case 0:
0113 return kOneProng0PiZero;
0114 case 2:
0115 return kOneProng1PiZero;
0116 case 4:
0117 return kOneProng2PiZero;
0118 case 6:
0119 return kOneProng3PiZero;
0120 default:
0121 return kOneProngNPiZero;
0122 }
0123 case 2:
0124 switch (numPhotons) {
0125 case 0:
0126 return kTwoProng0PiZero;
0127 case 2:
0128 return kTwoProng1PiZero;
0129 case 4:
0130 return kTwoProng2PiZero;
0131 case 6:
0132 return kTwoProng3PiZero;
0133 default:
0134 return kTwoProngNPiZero;
0135 }
0136 case 3:
0137 switch (numPhotons) {
0138 case 0:
0139 return kThreeProng0PiZero;
0140 case 2:
0141 return kThreeProng1PiZero;
0142 case 4:
0143 return kThreeProng2PiZero;
0144 case 6:
0145 return kThreeProng3PiZero;
0146 default:
0147 return kThreeProngNPiZero;
0148 }
0149 default:
0150 return kRareDecayMode;
0151 }
0152 }
0153
0154 private:
0155 };
0156
0157 #endif