Rivet API documentation

Rivet 4.1.3
ParticleFinder.hh
1// -*- C++ -*-
2#ifndef RIVET_ParticleFinder_HH
3#define RIVET_ParticleFinder_HH
4
5#include "Rivet/Projection.hh"
6
7namespace Rivet {
8
9
11 class ParticleFinder : public Projection {
12 public:
13
14 //using Projection::operator=;
15
18
20 ParticleFinder(const Cut& c = Cuts::OPEN)
21 : _cuts(c), _theParticles() { }
22
23 // /// @brief Construction using a wrapped other ParticleFinder plus cuts
24 // ///
25 // /// Useful to apply extra cuts to a generic PF's returned particles.
26 // ParticleFinder(const ParticleFinder& pf, const Cut& c) //=Cuts::OPEN)
27 // : _cuts(c), _theParticles()
28 // {
29 // setName("ParticleFinder[" + pf.name() + "]");
30 // declare(pf, "PF");
31 // }
32
34 virtual ~ParticleFinder() { }
35
37 virtual unique_ptr<Projection> clone() const = 0;
38 // RIVET_DEFAULT_PROJ_CLONE(ParticleFinder);
39
41
43 using Projection::operator=;
44
45
48
50 size_t size() const {
51 return particles().size();
52 }
53
54 size_t size(const Cut& c) const {
55 return particles(c).size();
56 }
57
58 size_t size(const ParticleSelector& s) const {
59 return particles(s).size();
60 }
61
63 bool empty() const {
64 return size() == 0;
65 }
66
67 bool empty(const Cut& c) const {
68 return size(c) == 0;
69 }
70
71 bool empty(const ParticleSelector& s) const {
72 return size(s) == 0;
73 }
74
76 virtual const Particles& particles() const {
77 return _theParticles;
78 }
79
85 Particles rtn;
86 for (const Particle& p : particles()) rtn += p.rawConstituents();
87 return rtn;
88 }
89
92 Particles particles(const Cut& c) const {
93 return select(particles(), c);
94 }
95
98 Particles particles(const ParticleSelector& selector) const {
99 return select(particles(), selector);
100 }
101
104 Particles particles(const ParticleSorter& sorter, const Cut& c = Cuts::open()) const {
105 return sortBy(particles(c), sorter);
106 }
107
110 Particles particles(const Cut& c, const ParticleSorter& sorter) const {
111 return sortBy(particles(c), sorter);
112 }
113
116 Particles particles(const ParticleSelector& selector, const ParticleSorter& sorter) const {
117 return sortBy(particles(selector), sorter);
118 }
119
122 Particles particles(const ParticleSorter& sorter, const ParticleSelector& selector) const {
123 return sortBy(particles(selector), sorter);
124 }
125
129 Particles particlesByPt(const Cut& c = Cuts::open()) const {
130 return particles(c, cmpMomByPt);
131 }
132
136 Particles particlesByPt(const ParticleSelector& selector) const {
137 return particles(selector, cmpMomByPt);
138 }
139
143 Particles particlesByPt(double ptmin) const {
144 return particles(Cuts::pT >= ptmin, cmpMomByPt);
145 }
146
148
149
152
153
156
157 typedef Particle entity_type;
158 typedef Particles collection_type;
159
161 const collection_type& entities() const {
162 return particles();
163 }
164
166
168 virtual void project(const Event& e) = 0;
169
171 virtual CmpState compare(const Projection& p) const;
172
173
174 protected:
175
177 Cut _cuts;
178
180 Particles _theParticles;
181 };
182
183
184}
185
186#endif
bool empty() const
Is this final state empty?
Definition ParticleFinder.hh:63
Particles particles(const Cut &c) const
Get the particles with selection cuts.
Definition ParticleFinder.hh:92
Particles particles(const ParticleSelector &selector, const ParticleSorter &sorter) const
Definition ParticleFinder.hh:116
bool empty(const Cut &c) const
Is this final state empty after a Cut is applied?
Definition ParticleFinder.hh:67
Particles particles(const Cut &c, const ParticleSorter &sorter) const
Definition ParticleFinder.hh:110
size_t size() const
Count the final-state particles.
Definition ParticleFinder.hh:50
Particles particlesByPt(const Cut &c=Cuts::open()) const
Definition ParticleFinder.hh:129
virtual void project(const Event &e)=0
Apply the projection to the event.
ParticleFinder(const Cut &c=Cuts::OPEN)
Construction using Cuts object.
Definition ParticleFinder.hh:20
Particles particles(const ParticleSelector &selector) const
Get the particles with selection cuts via a functor.
Definition ParticleFinder.hh:98
Particles particlesByPt(const ParticleSelector &selector) const
Definition ParticleFinder.hh:136
Particles particlesByPt(double ptmin) const
Definition ParticleFinder.hh:143
virtual CmpState compare(const Projection &p) const
Compare projections.
const collection_type & entities() const
Template-usable interface common to JetAlg.
Definition ParticleFinder.hh:161
virtual ~ParticleFinder()
Virtual destructor for inheritance.
Definition ParticleFinder.hh:34
Particles particles(const ParticleSorter &sorter, const ParticleSelector &selector) const
Definition ParticleFinder.hh:122
size_t size(const ParticleSelector &s) const
Count the final-state particles after a selection functor is applied.
Definition ParticleFinder.hh:58
bool empty(const ParticleSelector &s) const
Is this final state empty after a selection functor is applied?
Definition ParticleFinder.hh:71
Particles rawParticles() const
Definition ParticleFinder.hh:84
virtual unique_ptr< Projection > clone() const =0
Clone on the heap.
virtual const Particles & particles() const
Get the particles in no particular order, with no cuts.
Definition ParticleFinder.hh:76
size_t size(const Cut &c) const
Count the final-state particles after a Cut is applied.
Definition ParticleFinder.hh:54
Particles particles(const ParticleSorter &sorter, const Cut &c=Cuts::open()) const
Definition ParticleFinder.hh:104
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:50
Specialised vector of Particle objects.
Definition Particle.hh:21
Projection()
The default constructor.
friend class Event
Event is a friend.
Definition Projection.hh:33
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
MOMS sortBy(const MOMS &pbs, const CMP &cmp)
Sort a container of momenta by cmp and return by value for const inputs.
Definition Vector4.hh:1428
bool cmpMomByPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing pT.
Definition Vector4.hh:1333
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:819
const Cut & open()
Fully open cut singleton, accepts everything.
Definition LHCbCommon.hh:9