rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.0
ParticleFinder.hh
1 // -*- C++ -*-
2 #ifndef RIVET_ParticleFinder_HH
3 #define RIVET_ParticleFinder_HH
4 
5 #include "Rivet/Projection.hh"
6 
7 namespace 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 
30 
32 
33 
35  size_t size() const { return particles().size(); }
37  size_t size(const Cut& c) const { return particles(c).size(); }
39  size_t size(const ParticleSelector& s) const { return particles(s).size(); }
40 
42  bool empty() const { return size() == 0; }
44  bool empty(const Cut& c) const { return size(c) == 0; }
46  bool empty(const ParticleSelector& s) const { return size(s) == 0; }
47 
49  virtual const Particles& particles() const { return _theParticles; }
50 
55  Particles rawParticles() const {
56  Particles rtn;
57  for (const Particle& p : particles()) rtn += p.rawConstituents();
58  return rtn;
59  }
60 
63  Particles particles(const Cut& c) const {
64  return filter_select(particles(), c);
65  }
66 
69  Particles particles(const ParticleSelector& selector) const {
70  return filter_select(particles(), selector);
71  }
72 
75  Particles particles(const ParticleSorter& sorter, const Cut& c=Cuts::open()) const {
76  return sortBy(particles(c), sorter);
77  }
78 
81  Particles particles(const Cut& c, const ParticleSorter& sorter) const {
82  return sortBy(particles(c), sorter);
83  }
84 
87  Particles particles(const ParticleSelector& selector, const ParticleSorter& sorter) const {
88  return sortBy(particles(selector), sorter);
89  }
90 
93  Particles particles(const ParticleSorter& sorter, const ParticleSelector& selector) const {
94  return sortBy(particles(selector), sorter);
95  }
96 
100  Particles particlesByPt(const Cut& c=Cuts::open()) const {
101  return particles(c, cmpMomByPt);
102  }
103 
107  Particles particlesByPt(const ParticleSelector& selector) const {
108  return particles(selector, cmpMomByPt);
109  }
110 
114  Particles particlesByPt(double ptmin) const {
115  return particles(Cuts::pT >= ptmin, cmpMomByPt);
116  }
117 
119 
120 
123 
124 
126 
127 
128  typedef Particle entity_type;
129  typedef Particles collection_type;
130 
132  const collection_type& entities() const { return particles(); }
133 
135 
137  virtual void project(const Event& e) = 0;
138 
140  virtual int compare(const Projection& p) const;
141 
142 
143  protected:
144 
146  Cut _cuts;
147 
149  Particles _theParticles;
150 
151  };
152 
153 
154 }
155 
156 #endif
Definition: ALICE_2010_I880049.cc:13
ParticleFinder(const Cut &c=Cuts::OPEN)
Construction using Cuts object.
Definition: ParticleFinder.hh:18
Particles particlesByPt(double ptmin) const
Definition: ParticleFinder.hh:114
bool empty(const Cut &c) const
Is this final state empty after a Cut is applied?
Definition: ParticleFinder.hh:44
const collection_type & entities() const
Template-usable interface common to JetAlg.
Definition: ParticleFinder.hh:132
Particles particles(const ParticleSorter &sorter, const ParticleSelector &selector) const
Definition: ParticleFinder.hh:93
virtual const Particles & particles() const
Get the particles in no particular order, with no cuts.
Definition: ParticleFinder.hh:49
virtual int compare(const Projection &p) const
Compare projections.
Definition: ParticleFinder.cc:7
Particles particlesByPt(const Cut &c=Cuts::open()) const
Definition: ParticleFinder.hh:100
size_t size(const ParticleSelector &s) const
Count the final-state particles after a selection functor is applied.
Definition: ParticleFinder.hh:39
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 empty() const
Is this final state empty?
Definition: ParticleFinder.hh:42
size_t size(const Cut &c) const
Count the final-state particles after a Cut is applied.
Definition: ParticleFinder.hh:37
Particles particles(const ParticleSelector &selector) const
Get the particles with selection cuts via a functor.
Definition: ParticleFinder.hh:69
bool empty(const ParticleSelector &s) const
Is this final state empty after a selection functor is applied?
Definition: ParticleFinder.hh:46
Definition: Event.hh:22
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:143
Particles rawParticles() const
Definition: ParticleFinder.hh:55
Particles particles(const ParticleSorter &sorter, const Cut &c=Cuts::open()) const
Definition: ParticleFinder.hh:75
const Cut & open()
Fully open cut singleton, accepts everything.
Definition: Cuts.cc:81
Particles particles(const Cut &c, const ParticleSorter &sorter) const
Definition: ParticleFinder.hh:81
virtual unique_ptr< Projection > clone() const =0
Clone on the heap.
bool cmpMomByPt(const FourMomentum &a, const FourMomentum &b)
Comparison to give a sorting by decreasing pT.
Definition: Vector4.hh:1342
virtual ~ParticleFinder()
Virtual destructor for inheritance.
Definition: ParticleFinder.hh:23
MOMS & sortBy(MOMS &pbs, const CMP &cmp)
Sort a container of momenta by cmp and return by reference for non-const inputs.
Definition: Vector4.hh:1431
size_t size() const
Count the final-state particles.
Definition: ParticleFinder.hh:35
Particles particlesByPt(const ParticleSelector &selector) const
Definition: ParticleFinder.hh:107
virtual void project(const Event &e)=0
Apply the projection to the event.
Particles particles(const Cut &c) const
Get the particles with selection cuts.
Definition: ParticleFinder.hh:63
Base class for all Rivet projections.
Definition: Projection.hh:29
Particles particles(const ParticleSelector &selector, const ParticleSorter &sorter) const
Definition: ParticleFinder.hh:87