Rivet API documentation

Rivet 4.1.3
PartonicTops.hh
1// -*- C++ -*-
2#ifndef RIVET_PartonicTops_HH
3#define RIVET_PartonicTops_HH
4
5#include "Rivet/Projections/ParticleFinder.hh"
6
7namespace Rivet {
8
9
13 enum class TopDecay { ANY = 0, ALL = 0, ELECTRON, MUON, TAU, E_MU, E_MU_TAU, HADRONIC };
14
16 enum class WhichTop { FIRST, LAST };
17
18 enum class PromptEMuFromTau { YES, NO };
19
20 enum class InclHadronicTau { YES, NO };
21
22
32 public:
33
36
39 PromptEMuFromTau emu_from_prompt_tau = PromptEMuFromTau::YES,
40 InclHadronicTau include_hadronic_taus = InclHadronicTau::NO,
41 const Cut& c = Cuts::OPEN,
42 WhichTop whichtop = WhichTop::LAST)
43 : ParticleFinder(c),
44 _topmode(whichtop),
45 _decaymode(decaymode),
46 _emu_from_prompt_tau(emu_from_prompt_tau == PromptEMuFromTau::YES),
47 _include_hadronic_taus(include_hadronic_taus == InclHadronicTau::YES) { }
48
51 const Cut& c,
52 PromptEMuFromTau emu_from_prompt_tau = PromptEMuFromTau::YES,
53 InclHadronicTau include_hadronic_taus = InclHadronicTau::NO,
54 WhichTop whichtop = WhichTop::LAST)
55 : PartonicTops(decaymode, emu_from_prompt_tau, include_hadronic_taus, c, whichtop) { }
56
58 PartonicTops(const Cut& c = Cuts::OPEN, WhichTop whichtop = WhichTop::LAST)
59 : PartonicTops(TopDecay::ALL, PromptEMuFromTau::YES, InclHadronicTau::NO, c, whichtop) { }
60
61
64
66
67
69 using Projection::operator=;
70
71
73 const Particles& tops() const {
74 return _theParticles;
75 }
76
77
79 void clear() {
80 _theParticles.clear();
81 }
82
83
84 protected:
85
87 void project(const Event& event) {
88
89 // Warn about how terrible this is, the first time it's called!
90 static bool donerubric = false;
91 if (!donerubric) {
92 MSG_WARNING("PartonicTops is not recommended: MC generators do not guarantee physical properties "
93 "for, or even the existence of, partonic event-record entries. Caveat emptor!");
94 donerubric = true;
95 }
96
97 // Find partonic tops
98 _theParticles = select(event.allParticles(_cuts),
99 (_topmode == WhichTop::LAST ? lastParticleWith(isTop)
100 : firstParticleWith(isTop)));
101
102 // Filtering by decay mode
103 if (_decaymode != TopDecay::ALL) {
104 const auto decaycheck = [&](const Particle& t) {
105 const Particles descendants = t.allDescendants();
106 const bool prompt_e = any(descendants, [&](const Particle& p) {
107 return p.abspid() == PID::ELECTRON && p.isPrompt(_emu_from_prompt_tau)
108 && !p.hasAncestorWith(Cuts::pid == PID::PHOTON, false);
109 });
110 const bool prompt_mu = any(descendants, [&](const Particle& p) {
111 return p.abspid() == PID::MUON && p.isPrompt(_emu_from_prompt_tau)
112 && !p.hasAncestorWith(Cuts::pid == PID::PHOTON, false);
113 });
114 if (prompt_e
115 && (_decaymode == TopDecay::ELECTRON || _decaymode == TopDecay::E_MU
116 || _decaymode == TopDecay::E_MU_TAU))
117 return true;
118 if (prompt_mu
119 && (_decaymode == TopDecay::MUON || _decaymode == TopDecay::E_MU
120 || _decaymode == TopDecay::E_MU_TAU))
121 return true;
122 const bool prompt_tau = any(descendants, [&](const Particle& p) {
123 return p.abspid() == PID::TAU && p.isPrompt()
124 && !p.hasAncestorWith(Cuts::pid == PID::PHOTON, false);
125 });
126 const bool prompt_hadronic_tau = any(descendants, [&](const Particle& p) {
127 return p.abspid() == PID::TAU && p.isPrompt()
128 && !p.hasAncestorWith(Cuts::pid == PID::PHOTON, false) && none(p.children(), isChargedLepton);
129 });
130 if (prompt_tau && (_decaymode == TopDecay::TAU || _decaymode == TopDecay::E_MU_TAU))
131 return (_include_hadronic_taus || !prompt_hadronic_tau);
132 if (_decaymode == TopDecay::HADRONIC
133 && (!prompt_e && !prompt_mu
134 && (!prompt_tau || (_include_hadronic_taus && prompt_hadronic_tau))))
135 return true; //< logical hairiness...
136 return false;
137 };
138 iselect(_theParticles, decaycheck);
139 }
140
141 // Filtering and warning about unphysical partonic tops
142 const auto physcheck = [&](const Particle& t) {
143 if (t.E() < 0 || t.mass() < 0) {
144 MSG_WARNING("Unphysical partonic top with negative E or m found: " << t.mom());
145 return false;
146 }
147 return true;
148 };
149 iselect(_theParticles, physcheck);
150 }
151
152
154 CmpState compare(const Projection& p) const {
155 const PartonicTops& other = dynamic_cast<const PartonicTops&>(p);
156 return cmp(_cuts, other._cuts) || cmp(_topmode, other._topmode) || cmp(_decaymode, other._decaymode)
157 || cmp(_emu_from_prompt_tau, other._emu_from_prompt_tau)
158 || cmp(_include_hadronic_taus, other._include_hadronic_taus);
159 }
160
161
162 protected:
163
164 WhichTop _topmode;
165
166 TopDecay _decaymode;
167
168 bool _emu_from_prompt_tau, _include_hadronic_taus;
169 };
170
171
172}
173
174#endif
Representation of a HepMC event, and enabler of Projection caching.
Definition Event.hh:22
const Particles & allParticles() const
All the raw GenEvent particles, wrapped in Rivet::Particle objects.
ParticleFinder(const Cut &c=Cuts::OPEN)
Construction using Cuts object.
Definition ParticleFinder.hh:20
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:50
Specialised vector of Particle objects.
Definition Particle.hh:21
const Particles & tops() const
Access to the found partonic tops.
Definition PartonicTops.hh:73
PartonicTops(TopDecay decaymode, PromptEMuFromTau emu_from_prompt_tau=PromptEMuFromTau::YES, InclHadronicTau include_hadronic_taus=InclHadronicTau::NO, const Cut &c=Cuts::OPEN, WhichTop whichtop=WhichTop::LAST)
Constructor taking decay mode details (and an optional cuts object).
Definition PartonicTops.hh:38
CmpState compare(const Projection &p) const
Compare projections.
Definition PartonicTops.hh:154
void clear()
Clear the projection.
Definition PartonicTops.hh:79
PartonicTops(TopDecay decaymode, const Cut &c, PromptEMuFromTau emu_from_prompt_tau=PromptEMuFromTau::YES, InclHadronicTau include_hadronic_taus=InclHadronicTau::NO, WhichTop whichtop=WhichTop::LAST)
Constructor taking decay mode details (and a non-optional cuts object).
Definition PartonicTops.hh:50
PartonicTops(const Cut &c=Cuts::OPEN, WhichTop whichtop=WhichTop::LAST)
Simple constructor optionally taking cuts object.
Definition PartonicTops.hh:58
RIVET_DEFAULT_PROJ_CLONE(PartonicTops)
Clone on the heap.
void project(const Event &event)
Apply the projection on the supplied event.
Definition PartonicTops.hh:87
Base class for all Rivet projections.
Definition Projection.hh:29
bool any(const CONTAINER &c)
Return true if x is true for any x in container c, otherwise false.
Definition Utils.hh:364
bool none(const CONTAINER &c)
Return true if x is false for all x in container c, otherwise false.
Definition Utils.hh:418
Jets select(const Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
Definition JetUtils.hh:183
Jets & iselect(Jets &jets, const Cut &c)
Filter a jet collection in-place to the subset that passes the supplied Cut.
#define MSG_WARNING(x)
Warning messages for non-fatal bad things, using MSG_LVL.
Definition Logging.hh:200
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:819
Definition LHCbCommon.hh:9
WhichTop
Enum for categorising which top quark to be selected: last (weakly decaying) or first?
Definition PartonicTops.hh:16
TopDecay
Enum for categorising top quark decay modes.
Definition PartonicTops.hh:13
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition Cmp.hh:253