CMS 3D CMS Logo

PFTauDecayModeTools.cc
Go to the documentation of this file.
1 #include <map>
5 
6 namespace reco {
7  namespace tau {
8 
9  namespace {
10  struct entry {
11  char const *label;
13  };
14 
15  // Convert the string decay mode from PhysicsTools to the
16  // PFTau::hadronicDecayMode format
17  constexpr entry dmTranslatorMap[] = {{"unknown", reco::PFTau::kNull},
19  {"oneProng0Pi0", reco::PFTau::kOneProng0PiZero},
20  {"oneProng1Pi0", reco::PFTau::kOneProng1PiZero},
21  {"oneProng2Pi0", reco::PFTau::kOneProng2PiZero},
22  {"oneProngOther", reco::PFTau::kOneProngNPiZero},
23  {"threeProng0Pi0", reco::PFTau::kThreeProng0PiZero},
24  {"threeProng1Pi0", reco::PFTau::kThreeProng1PiZero},
25  {"threeProngOther", reco::PFTau::kThreeProngNPiZero},
26  {"electron", reco::PFTau::kNull},
27  {"muon", reco::PFTau::kNull},
28  {nullptr, reco::PFTau::kNull}};
29 
30  constexpr bool same(char const *x, char const *y) { return !*x && !*y ? true : (*x == *y && same(x + 1, y + 1)); }
31 
32  constexpr enum reco::PFTau::hadronicDecayMode decayModeStringToId(char const *label, entry const *entries) {
33  return !entries->label ? reco::PFTau::kRareDecayMode
34  : same(entries->label, label) ? entries->mode : decayModeStringToId(label, entries + 1);
35  }
36 
37  constexpr char const *decayModeIdToString(reco::PFTau::hadronicDecayMode mode, entry const *entries) {
38  return !entries->label ? "unknown"
39  : (entries->mode == mode ? entries->label : decayModeIdToString(mode, entries + 1));
40  }
41  } // namespace
42 
44  int modeAsInt = static_cast<int>(mode);
45  return (modeAsInt / PFTau::kOneProngNPiZero) + 1;
46  }
47 
49  int modeAsInt = static_cast<int>(mode);
50  return (modeAsInt % PFTau::kOneProngNPiZero);
51  }
52 
54  // If no tracks exist, this is definitely not a tau!
55  if (!nCharged)
56  return PFTau::kNull;
57  // Find the maximum number of PiZeros our parameterization can hold
58  const unsigned int maxPiZeros = PFTau::kOneProngNPiZero;
59  // Determine our track index
60  unsigned int trackIndex = (nCharged - 1) * (maxPiZeros + 1);
61  // Check if we handle the given number of tracks
62  if (trackIndex >= PFTau::kRareDecayMode)
63  return PFTau::kRareDecayMode;
64 
66  return static_cast<PFTau::hadronicDecayMode>(trackIndex + nPiZeros);
67  }
68 
70  return decayModeStringToId(name.c_str(), dmTranslatorMap);
71  }
72 
74  return decayModeIdToString(decayMode, dmTranslatorMap);
75  }
76 
78  if (!genJet)
79  return reco::PFTau::kNull;
81  }
82 
83  } // namespace tau
84 } // namespace reco
reco::PFTau::kNull
Definition: PFTau.h:39
reco::PFTau::kOneProng1PiZero
Definition: PFTau.h:41
reco::tau::getDecayMode
PFTau::hadronicDecayMode getDecayMode(const reco::GenJet *genJet)
Definition: PFTauDecayModeTools.cc:77
reco::GenJet
Jets made from MC generator particles.
Definition: GenJet.h:23
HLT_FULL_cff.nCharged
nCharged
Definition: HLT_FULL_cff.py:33252
metsig::tau
Definition: SignAlgoResolutions.h:49
mps_splice.entry
entry
Definition: mps_splice.py:68
reco::PFTau::kOneProng2PiZero
Definition: PFTau.h:42
HLT_FULL_cff.nPiZeros
nPiZeros
Definition: HLT_FULL_cff.py:33251
reco::PFTau::kOneProng0PiZero
Definition: PFTau.h:40
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::PFTau::kRareDecayMode
Definition: PFTau.h:55
mode
reco::PFTau::hadronicDecayMode mode
Definition: PFTauDecayModeTools.cc:12
reco::PFTau::kThreeProngNPiZero
Definition: PFTau.h:54
reco::tau::translateGenDecayModeToReco
PFTau::hadronicDecayMode translateGenDecayModeToReco(const std::string &genName)
Convert a genTau decay mode string ('oneProng0Pi0') to the RECO enum.
Definition: PFTauDecayModeTools.cc:69
PFTauDecayModeTools.h
taus_cff.decayMode
decayMode
Definition: taus_cff.py:58
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
reco::PFTau::kThreeProng1PiZero
Definition: PFTau.h:51
reco::tau::translateRecoDecayModeToGen
std::string translateRecoDecayModeToGen(PFTau::hadronicDecayMode decayMode)
Convert a RECO enum decay mode to a string ('oneProng0Pi0')
Definition: PFTauDecayModeTools.cc:73
reco::tau::translateDecayMode
PFTau::hadronicDecayMode translateDecayMode(unsigned int nCharged, unsigned int nPiZero)
Definition: PFTauDecayModeTools.cc:53
HLT_FULL_cff.maxPiZeros
maxPiZeros
Definition: HLT_FULL_cff.py:33249
reco::tau::piZerosInDecayMode
unsigned int piZerosInDecayMode(PFTau::hadronicDecayMode mode)
Definition: PFTauDecayModeTools.cc:48
reco::PFTau::kOneProngNPiZero
Definition: PFTau.h:44
reco::tau::chargedHadronsInDecayMode
unsigned int chargedHadronsInDecayMode(PFTau::hadronicDecayMode mode)
Reverse mapping of decay modes into multiplicities.
Definition: PFTauDecayModeTools.cc:43
reco::PFTau::kThreeProng0PiZero
Definition: PFTau.h:50
genVertex_cff.x
x
Definition: genVertex_cff.py:12
reco::PFTau::hadronicDecayMode
hadronicDecayMode
Definition: PFTau.h:38
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
GenJet.h
JetMCTag.h
label
const char * label
Definition: PFTauDecayModeTools.cc:11
JetMCTagUtils::genTauDecayMode
std::string genTauDecayMode(const reco::CompositePtrCandidate &c)
Definition: JetMCTag.cc:70