Rivet 3.1.9
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
15
16
18 ParticleFinder(const Cut& c=Cuts::OPEN)
19 : _cuts(c), _theParticles()
20 { }
21
23 virtual ~ParticleFinder() {}
24
26 virtual unique_ptr<Projection> clone() const = 0;
27
29
31 using Projection::operator =;
32
33
35
36
38 size_t size() const { return particles().size(); }
40 size_t size(const Cut& c) const { return particles(c).size(); }
42 size_t size(const ParticleSelector& s) const { return particles(s).size(); }
43
45 bool empty() const { return size() == 0; }
47 bool empty(const Cut& c) const { return size(c) == 0; }
49 bool empty(const ParticleSelector& s) const { return size(s) == 0; }
50
52 virtual const Particles& particles() const { return _theParticles; }
53
59 Particles rtn;
60 for (const Particle& p : particles()) rtn += p.rawConstituents();
61 return rtn;
62 }
63
66 Particles particles(const Cut& c) const {
67 return filter_select(particles(), c);
68 }
69
72 Particles particles(const ParticleSelector& selector) const {
73 return filter_select(particles(), selector);
74 }
75
78 Particles particles(const ParticleSorter& sorter, const Cut& c=Cuts::open()) const {
79 return sortBy(particles(c), sorter);
80 }
81
84 Particles particles(const Cut& c, const ParticleSorter& sorter) const {
85 return sortBy(particles(c), sorter);
86 }
87
90 Particles particles(const ParticleSelector& selector, const ParticleSorter& sorter) const {
91 return sortBy(particles(selector), sorter);
92 }
93
96 Particles particles(const ParticleSorter& sorter, const ParticleSelector& selector) const {
97 return sortBy(particles(selector), sorter);
98 }
99
103 Particles particlesByPt(const Cut& c=Cuts::open()) const {
104 return particles(c, cmpMomByPt);
105 }
106
110 Particles particlesByPt(const ParticleSelector& selector) const {
111 return particles(selector, cmpMomByPt);
112 }
113
117 Particles particlesByPt(double ptmin) const {
118 return particles(Cuts::pT >= ptmin, cmpMomByPt);
119 }
120
122
123
126
127
129
130
131 typedef Particle entity_type;
132 typedef Particles collection_type;
133
135 const collection_type& entities() const { return particles(); }
136
138
140 virtual void project(const Event& e) = 0;
141
143 virtual CmpState compare(const Projection& p) const;
144
145
146 protected:
147
149 Cut _cuts;
150
152 Particles _theParticles;
153
154 };
155
156
157}
158
159#endif
Representation of a HepMC event, and enabler of Projection caching.
Definition Event.hh:22
Base class for projections which return subsets of an event's particles.
Definition ParticleFinder.hh:11
bool empty() const
Is this final state empty?
Definition ParticleFinder.hh:45
Particles particles(const Cut &c) const
Get the particles with selection cuts.
Definition ParticleFinder.hh:66
Particles particles(const ParticleSelector &selector, const ParticleSorter &sorter) const
Definition ParticleFinder.hh:90
bool empty(const Cut &c) const
Is this final state empty after a Cut is applied?
Definition ParticleFinder.hh:47
Particles particles(const Cut &c, const ParticleSorter &sorter) const
Definition ParticleFinder.hh:84
size_t size() const
Count the final-state particles.
Definition ParticleFinder.hh:38
Particles particlesByPt(const Cut &c=Cuts::open()) const
Definition ParticleFinder.hh:103
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:18
Particles particles(const ParticleSelector &selector) const
Get the particles with selection cuts via a functor.
Definition ParticleFinder.hh:72
Particles particlesByPt(const ParticleSelector &selector) const
Definition ParticleFinder.hh:110
Particles particlesByPt(double ptmin) const
Definition ParticleFinder.hh:117
virtual CmpState compare(const Projection &p) const
Compare projections.
const collection_type & entities() const
Template-usable interface common to JetAlg.
Definition ParticleFinder.hh:135
virtual ~ParticleFinder()
Virtual destructor for inheritance.
Definition ParticleFinder.hh:23
Particles particles(const ParticleSorter &sorter, const ParticleSelector &selector) const
Definition ParticleFinder.hh:96
size_t size(const ParticleSelector &s) const
Count the final-state particles after a selection functor is applied.
Definition ParticleFinder.hh:42
bool empty(const ParticleSelector &s) const
Is this final state empty after a selection functor is applied?
Definition ParticleFinder.hh:49
Particles rawParticles() const
Definition ParticleFinder.hh:58
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:52
size_t size(const Cut &c) const
Count the final-state particles after a Cut is applied.
Definition ParticleFinder.hh:40
Particles particles(const ParticleSorter &sorter, const Cut &c=Cuts::open()) const
Definition ParticleFinder.hh:78
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:53
Specialised vector of Particle objects.
Definition Particle.hh:25
Base class for all Rivet projections.
Definition Projection.hh:29
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:157
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:1451
bool cmpMomByPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing pT.
Definition Vector4.hh:1356
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:684
const Cut & open()
Fully open cut singleton, accepts everything.
Definition MC_Cent_pPb.hh:10