Rivet  3.1.3
PartonicTops.hh
1 // -*- C++ -*-
2 #ifndef RIVET_PartonicTops_HH
3 #define RIVET_PartonicTops_HH
4 
5 #include "Rivet/Projections/ParticleFinder.hh"
6 
7 namespace Rivet {
8 
9 
18  class PartonicTops : public ParticleFinder {
19  public:
20 
21 
25  enum class DecayMode {
26  ANY = 0,
27  ALL = 0,
28  ELECTRON,
29  MUON,
30  TAU,
31  E_MU,
32  E_MU_TAU,
33  HADRONIC
34  };
35 
37  enum class WhichTop { FIRST, LAST };
38 
39 
41 
42 
44  PartonicTops(DecayMode decaymode, bool emu_from_prompt_tau=true, bool include_hadronic_taus=false, const Cut& c=Cuts::OPEN, WhichTop whichtop=WhichTop::LAST)
45  : ParticleFinder(c), _topmode(whichtop), _decaymode(decaymode),
46  _emu_from_prompt_tau(emu_from_prompt_tau), _include_hadronic_taus(include_hadronic_taus)
47  { }
48 
50  PartonicTops(DecayMode decaymode, const Cut& c, bool emu_from_prompt_tau=true, bool include_hadronic_taus=false, WhichTop whichtop=WhichTop::LAST)
51  : PartonicTops(decaymode, emu_from_prompt_tau, include_hadronic_taus, c, whichtop)
52  { }
53 
55  PartonicTops(const Cut& c=Cuts::OPEN, WhichTop whichtop=WhichTop::LAST)
56  : PartonicTops(DecayMode::ALL, true, false, c, whichtop)
57  { }
58 
59 
62 
64 
65 
67  const Particles& tops() const { return _theParticles; }
68 
69 
71  void clear() {
72  _theParticles.clear();
73  }
74 
75 
76  protected:
77 
79  void project(const Event& event) {
80 
81  // Warn about how terrible this is, the first time it's called!
82  static bool donerubric = false;
83  if (!donerubric) {
84  MSG_WARNING("PartonicTops is not recommended: MC generators do not guarantee physical properties for, or even the existence of, partonic event-record entries. Caveat emptor!");
85  donerubric = true;
86  }
87 
88  // Find partonic tops
89  _theParticles = filter_select(event.allParticles(_cuts), (_topmode == WhichTop::LAST ? lastParticleWith(isTop) : firstParticleWith(isTop)));
90 
91  // Filtering by decay mode
92  if (_decaymode != DecayMode::ALL) {
93  const auto decaycheck = [&](const Particle& t) {
94  const Particles descendants = t.allDescendants();
95  const bool prompt_e = any(descendants, [&](const Particle& p){ return p.abspid() == PID::ELECTRON && p.isPrompt(_emu_from_prompt_tau) && !p.hasAncestor(PID::PHOTON, false); });
96  const bool prompt_mu = any(descendants, [&](const Particle& p){ return p.abspid() == PID::MUON && p.isPrompt(_emu_from_prompt_tau) && !p.hasAncestor(PID::PHOTON, false); });
97  if (prompt_e && (_decaymode == DecayMode::ELECTRON || _decaymode == DecayMode::E_MU || _decaymode == DecayMode::E_MU_TAU)) return true;
98  if (prompt_mu && (_decaymode == DecayMode::MUON || _decaymode == DecayMode::E_MU || _decaymode == DecayMode::E_MU_TAU)) return true;
99  const bool prompt_tau = any(descendants, [&](const Particle& p){ return p.abspid() == PID::TAU && p.isPrompt() && !p.hasAncestor(PID::PHOTON, false); });
100  const bool prompt_hadronic_tau = any(descendants, [&](const Particle& p){ return p.abspid() == PID::TAU && p.isPrompt() && !p.hasAncestor(PID::PHOTON, false) && none(p.children(), isChargedLepton); });
101  if (prompt_tau && (_decaymode == DecayMode::TAU || _decaymode == DecayMode::E_MU_TAU)) return (_include_hadronic_taus || !prompt_hadronic_tau);
102  if (_decaymode == DecayMode::HADRONIC && (!prompt_e && !prompt_mu && (!prompt_tau || (_include_hadronic_taus && prompt_hadronic_tau)))) return true; //< logical hairiness...
103  return false;
104  };
105  ifilter_select(_theParticles, decaycheck);
106  }
107 
108  // Filtering and warning about unphysical partonic tops
109  const auto physcheck = [&](const Particle& t) {
110  if (t.E() < 0 || t.mass() < 0) {
111  MSG_WARNING("Unphysical partonic top with negative E or m found: " << t.mom());
112  return false;
113  }
114  return true;
115  };
116  ifilter_select(_theParticles, physcheck);
117  }
118 
119 
121  CmpState compare(const Projection& p) const {
122  const PartonicTops& other = dynamic_cast<const PartonicTops&>(p);
123  return cmp(_cuts, other._cuts) ||
124  cmp(_topmode, other._topmode) ||
125  cmp(_decaymode, other._decaymode) ||
126  cmp(_emu_from_prompt_tau, other._emu_from_prompt_tau) ||
127  cmp(_include_hadronic_taus, other._include_hadronic_taus);
128  }
129 
130 
131  private:
132 
133  WhichTop _topmode;
134 
135  DecayMode _decaymode;
136 
137  bool _emu_from_prompt_tau, _include_hadronic_taus;
138 
139  };
140 
141 
142 }
143 
144 
145 #endif
Definition: MC_Cent_pPb.hh:10
bool any(const CONTAINER &c)
Return true if x is true for any x in container c, otherwise false.
Definition: Utils.hh:323
CmpState compare(const Projection &p) const
Compare projections.
Definition: PartonicTops.hh:121
void project(const Event &event)
Apply the projection on the supplied event.
Definition: PartonicTops.hh:79
PartonicTops(const Cut &c=Cuts::OPEN, WhichTop whichtop=WhichTop::LAST)
Simple constructor optionally taking cuts object.
Definition: PartonicTops.hh:55
const Particles & allParticles() const
All the raw GenEvent particles, wrapped in Rivet::Particle objects.
Jets filter_select(const Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
Definition: JetUtils.hh:160
DecayMode
Enum for categorising top quark decay modes.
Definition: PartonicTops.hh:25
Particles children(const Cut &c=Cuts::OPEN) const
Get a list of the direct descendants from the current particle (with optional selection Cut) ...
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition: Particle.hh:18
Base class for projections which return subsets of an event&#39;s particles.
Definition: ParticleFinder.hh:11
bool none(const CONTAINER &c)
Return true if x is false for all x in container c, otherwise false.
Definition: Utils.hh:367
PartonicTops(DecayMode decaymode, const Cut &c, bool emu_from_prompt_tau=true, bool include_hadronic_taus=false, WhichTop whichtop=WhichTop::LAST)
Constructor taking decay mode details (and a non-optional cuts object)
Definition: PartonicTops.hh:50
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
Determine whether a particle is the first in a decay chain to meet the cut/function.
Definition: ParticleUtils.hh:556
bool isTop(int pid)
Determine if the PID is that of a t/tbar.
Definition: ParticleIdUtils.hh:223
DEFAULT_RIVET_PROJ_CLONE(PartonicTops)
Clone on the heap.
PartonicTops(DecayMode decaymode, bool emu_from_prompt_tau=true, bool include_hadronic_taus=false, const Cut &c=Cuts::OPEN, WhichTop whichtop=WhichTop::LAST)
Constructor taking decay mode details (and an optional cuts object)
Definition: PartonicTops.hh:44
Jets & ifilter_select(Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
void clear()
Clear the projection.
Definition: PartonicTops.hh:71
Convenience finder of partonic top quarks.
Definition: PartonicTops.hh:18
const Particles & tops() const
Access to the found partonic tops.
Definition: PartonicTops.hh:67
Determine whether a particle is the last in a decay chain to meet the cut/function.
Definition: ParticleUtils.hh:575
Base class for all Rivet projections.
Definition: Projection.hh:29
PdgId abspid() const
Absolute value of the PDG ID code.
Definition: Particle.hh:164
WhichTop
Enum for categorising which top quark to be selected: last (weakly decaying) or first?
Definition: PartonicTops.hh:37
#define MSG_WARNING(x)
Warning messages for non-fatal bad things, using MSG_LVL.
Definition: Logging.hh:200
bool isPrompt(bool allow_from_prompt_tau=false, bool allow_from_prompt_mu=false) const
Alias for isDirect.
Definition: Particle.hh:518
bool hasAncestor(PdgId pid, bool only_physical=true) const
bool isChargedLepton(int pid)
Determine if the PID is that of a charged lepton.
Definition: ParticleIdUtils.hh:158
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:255