rivet is hosted by Hepforge, IPPP Durham
Rivet 4.0.2
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
24 // /// @brief Construction using a wrapped other ParticleFinder plus cuts
25 // ///
26 // /// Useful to apply extra cuts to a generic PF's returned particles.
27 // ParticleFinder(const ParticleFinder& pf, const Cut& c) //=Cuts::OPEN)
28 // : _cuts(c), _theParticles()
29 // {
30 // setName("ParticleFinder[" + pf.name() + "]");
31 // declare(pf, "PF");
32 // }
33
35 virtual ~ParticleFinder() {}
36
38 virtual unique_ptr<Projection> clone() const = 0;
39 // RIVET_DEFAULT_PROJ_CLONE(ParticleFinder);
40
42
44 using Projection::operator =;
45
46
49
51 size_t size() const { return particles().size(); }
53 size_t size(const Cut& c) const { return particles(c).size(); }
55 size_t size(const ParticleSelector& s) const { return particles(s).size(); }
56
58 bool empty() const { return size() == 0; }
60 bool empty(const Cut& c) const { return size(c) == 0; }
62 bool empty(const ParticleSelector& s) const { return size(s) == 0; }
63
65 virtual const Particles& particles() const { return _theParticles; }
66
72 Particles rtn;
73 for (const Particle& p : particles()) rtn += p.rawConstituents();
74 return rtn;
75 }
76
79 Particles particles(const Cut& c) const {
80 return select(particles(), c);
81 }
82
85 Particles particles(const ParticleSelector& selector) const {
86 return select(particles(), selector);
87 }
88
91 Particles particles(const ParticleSorter& sorter, const Cut& c=Cuts::open()) const {
92 return sortBy(particles(c), sorter);
93 }
94
97 Particles particles(const Cut& c, const ParticleSorter& sorter) const {
98 return sortBy(particles(c), sorter);
99 }
100
103 Particles particles(const ParticleSelector& selector, const ParticleSorter& sorter) const {
104 return sortBy(particles(selector), sorter);
105 }
106
109 Particles particles(const ParticleSorter& sorter, const ParticleSelector& selector) const {
110 return sortBy(particles(selector), sorter);
111 }
112
116 Particles particlesByPt(const Cut& c=Cuts::open()) const {
117 return particles(c, cmpMomByPt);
118 }
119
123 Particles particlesByPt(const ParticleSelector& selector) const {
124 return particles(selector, cmpMomByPt);
125 }
126
130 Particles particlesByPt(double ptmin) const {
131 return particles(Cuts::pT >= ptmin, cmpMomByPt);
132 }
133
135
136
139
140
143
144 typedef Particle entity_type;
145 typedef Particles collection_type;
146
148 const collection_type& entities() const { return particles(); }
149
151
153 virtual void project(const Event& e) = 0;
154
156 virtual CmpState compare(const Projection& p) const;
157
158
159 protected:
160
162 Cut _cuts;
163
165 Particles _theParticles;
166
167 };
168
169
170}
171
172#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:58
Particles particles(const Cut &c) const
Get the particles with selection cuts.
Definition ParticleFinder.hh:79
Particles particles(const ParticleSelector &selector, const ParticleSorter &sorter) const
Definition ParticleFinder.hh:103
bool empty(const Cut &c) const
Is this final state empty after a Cut is applied?
Definition ParticleFinder.hh:60
Particles particles(const Cut &c, const ParticleSorter &sorter) const
Definition ParticleFinder.hh:97
size_t size() const
Count the final-state particles.
Definition ParticleFinder.hh:51
Particles particlesByPt(const Cut &c=Cuts::open()) const
Definition ParticleFinder.hh:116
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:85
Particles particlesByPt(const ParticleSelector &selector) const
Definition ParticleFinder.hh:123
Particles particlesByPt(double ptmin) const
Definition ParticleFinder.hh:130
virtual CmpState compare(const Projection &p) const
Compare projections.
const collection_type & entities() const
Template-usable interface common to JetAlg.
Definition ParticleFinder.hh:148
virtual ~ParticleFinder()
Virtual destructor for inheritance.
Definition ParticleFinder.hh:35
Particles particles(const ParticleSorter &sorter, const ParticleSelector &selector) const
Definition ParticleFinder.hh:109
size_t size(const ParticleSelector &s) const
Count the final-state particles after a selection functor is applied.
Definition ParticleFinder.hh:55
bool empty(const ParticleSelector &s) const
Is this final state empty after a selection functor is applied?
Definition ParticleFinder.hh:62
Particles rawParticles() const
Definition ParticleFinder.hh:71
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:65
size_t size(const Cut &c) const
Count the final-state particles after a Cut is applied.
Definition ParticleFinder.hh:53
Particles particles(const ParticleSorter &sorter, const Cut &c=Cuts::open()) const
Definition ParticleFinder.hh:91
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:45
Specialised vector of Particle objects.
Definition Particle.hh:21
Base class for all Rivet projections.
Definition Projection.hh:29
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:152
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:1417
bool cmpMomByPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing pT.
Definition Vector4.hh:1322
const Cut & open()
Fully open cut singleton, accepts everything.
Definition MC_CENT_PPB_Projections.hh:10