Rivet  3.1.2
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 
14  class PartonicTops : public ParticleFinder {
15  public:
16 
17 
21  enum class DecayMode {
22  ANY = 0,
23  ALL = 0,
24  ELECTRON,
25  MUON,
26  TAU,
27  E_MU,
28  E_MU_TAU,
29  HADRONIC
30  };
31 
33  enum class WhichTop { FIRST, LAST };
34 
35 
37 
38 
40  PartonicTops(const Cut& c=Cuts::OPEN, WhichTop whichtop=WhichTop::LAST)
41  : ParticleFinder(c), _topmode(whichtop), _decaymode(DecayMode::ALL),
42  _emu_from_prompt_tau(true), _include_hadronic_taus(false)
43  { }
44 
46  PartonicTops(DecayMode decaymode, bool emu_from_prompt_tau=true, bool include_hadronic_taus=false, const Cut& c=Cuts::OPEN, WhichTop whichtop=WhichTop::LAST)
47  : ParticleFinder(c), _topmode(whichtop), _decaymode(decaymode),
48  _emu_from_prompt_tau(emu_from_prompt_tau), _include_hadronic_taus(include_hadronic_taus)
49  { }
50 
52  PartonicTops(DecayMode decaymode, const Cut& c, bool emu_from_prompt_tau=true, bool include_hadronic_taus=false, WhichTop whichtop=WhichTop::LAST)
53  : ParticleFinder(c), _topmode(whichtop), _decaymode(decaymode),
54  _emu_from_prompt_tau(emu_from_prompt_tau), _include_hadronic_taus(include_hadronic_taus)
55  { }
56 
57 
60 
62 
63 
65  const Particles& tops() const { return _theParticles; }
66 
67 
69  void clear() {
70  _theParticles.clear();
71  }
72 
73 
74  protected:
75 
77  void project(const Event& event) {
78  // Find partonic tops
79  _theParticles = filter_select(event.allParticles(_cuts), (_topmode == WhichTop::LAST ? lastParticleWith(isTop) : firstParticleWith(isTop)));
80  // Filtering by decay mode
81  if (_decaymode != DecayMode::ALL) {
82  const auto fn = [&](const Particle& t) {
83  const Particles descendants = t.allDescendants();
84  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); });
85  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); });
86  if (prompt_e && (_decaymode == DecayMode::ELECTRON || _decaymode == DecayMode::E_MU || _decaymode == DecayMode::E_MU_TAU)) return true;
87  if (prompt_mu && (_decaymode == DecayMode::MUON || _decaymode == DecayMode::E_MU || _decaymode == DecayMode::E_MU_TAU)) return true;
88  const bool prompt_tau = any(descendants, [&](const Particle& p){ return p.abspid() == PID::TAU && p.isPrompt() && !p.hasAncestor(PID::PHOTON, false); });
89  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); });
90  if (prompt_tau && (_decaymode == DecayMode::TAU || _decaymode == DecayMode::E_MU_TAU)) return (_include_hadronic_taus || !prompt_hadronic_tau);
91  if (_decaymode == DecayMode::HADRONIC && (!prompt_e && !prompt_mu && (!prompt_tau || (_include_hadronic_taus && prompt_hadronic_tau)))) return true; //< logical hairiness...
92  return false;
93  };
94  ifilter_select(_theParticles, fn);
95  }
96  }
97 
98 
100  CmpState compare(const Projection& p) const {
101  const PartonicTops& other = dynamic_cast<const PartonicTops&>(p);
102  return cmp(_cuts, other._cuts) ||
103  cmp(_topmode, other._topmode) ||
104  cmp(_decaymode, other._decaymode) ||
105  cmp(_emu_from_prompt_tau, other._emu_from_prompt_tau) ||
106  cmp(_include_hadronic_taus, other._include_hadronic_taus);
107  }
108 
109 
110  private:
111 
112  WhichTop _topmode;
113 
114  DecayMode _decaymode;
115 
116  bool _emu_from_prompt_tau, _include_hadronic_taus;
117 
118  };
119 
120 
121 }
122 
123 
124 #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:311
CmpState compare(const Projection &p) const
Compare projections.
Definition: PartonicTops.hh:100
void project(const Event &event)
Apply the projection on the supplied event.
Definition: PartonicTops.hh:77
PartonicTops(const Cut &c=Cuts::OPEN, WhichTop whichtop=WhichTop::LAST)
Constructor optionally taking cuts object.
Definition: PartonicTops.hh:40
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:21
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:355
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 an optional cuts object)
Definition: PartonicTops.hh:52
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:46
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:69
Convenience finder of partonic top quarks.
Definition: PartonicTops.hh:14
const Particles & tops() const
Access to the found partonic tops.
Definition: PartonicTops.hh:65
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:33
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