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
35  : decayModeStringToId(label, entries + 1);
36  }
37 
38  constexpr char const *decayModeIdToString(reco::PFTau::hadronicDecayMode mode, entry const *entries) {
39  return !entries->label ? "unknown"
40  : (entries->mode == mode ? entries->label : decayModeIdToString(mode, entries + 1));
41  }
42  } // namespace
43 
45  int modeAsInt = static_cast<int>(mode);
46  return (modeAsInt / PFTau::kOneProngNPiZero) + 1;
47  }
48 
50  int modeAsInt = static_cast<int>(mode);
51  return (modeAsInt % PFTau::kOneProngNPiZero);
52  }
53 
55  // If no tracks exist, this is definitely not a tau!
56  if (!nCharged)
57  return PFTau::kNull;
58  // Find the maximum number of PiZeros our parameterization can hold
59  const unsigned int maxPiZeros = PFTau::kOneProngNPiZero;
60  // Determine our track index
61  unsigned int trackIndex = (nCharged - 1) * (maxPiZeros + 1);
62  // Check if we handle the given number of tracks
63  if (trackIndex >= PFTau::kRareDecayMode)
64  return PFTau::kRareDecayMode;
65 
67  return static_cast<PFTau::hadronicDecayMode>(trackIndex + nPiZeros);
68  }
69 
71  return decayModeStringToId(name.c_str(), dmTranslatorMap);
72  }
73 
75  return decayModeIdToString(decayMode, dmTranslatorMap);
76  }
77 
79  if (!genJet)
80  return reco::PFTau::kNull;
82  }
83 
84  } // namespace tau
85 } // 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:78
reco::GenJet
Jets made from MC generator particles.
Definition: GenJet.h:23
HLT_FULL_cff.nCharged
nCharged
Definition: HLT_FULL_cff.py:33268
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:33267
reco::PFTau::kOneProng0PiZero
Definition: PFTau.h:40
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
reco::PFTau::kRareDecayMode
Definition: PFTau.h:55
mode
reco::PFTau::hadronicDecayMode mode
Definition: PFTauDecayModeTools.cc:12
boostedTaus_cff.decayMode
decayMode
Definition: boostedTaus_cff.py:28
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:70
PFTauDecayModeTools.h
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:74
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::tau::translateDecayMode
PFTau::hadronicDecayMode translateDecayMode(unsigned int nCharged, unsigned int nPiZero)
Definition: PFTauDecayModeTools.cc:54
HLT_FULL_cff.maxPiZeros
maxPiZeros
Definition: HLT_FULL_cff.py:33265
reco::tau::piZerosInDecayMode
unsigned int piZerosInDecayMode(PFTau::hadronicDecayMode mode)
Definition: PFTauDecayModeTools.cc:49
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:44
reco::PFTau::kThreeProng0PiZero
Definition: PFTau.h:50
genVertex_cff.x
x
Definition: genVertex_cff.py:13
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