Rivet API documentation

Rivet 4.1.3
LossyFinalState.hh
1// -*- C++ -*-
2#ifndef RIVET_LossyFinalState_HH
3#define RIVET_LossyFinalState_HH
4
5#include "Rivet/Event.hh"
6#include "Rivet/Particle.hh"
7#include "Rivet/Projection.hh"
8#include "Rivet/Config/RivetCommon.hh"
9#include "Rivet/Projections/FinalState.hh"
10#include "Rivet/Tools/Logging.hh"
11
12namespace Rivet {
13
14
16 template <typename FILTER>
17 class LossyFinalState : public FinalState {
18 public:
19
22
24 LossyFinalState(const FinalState& fsp, FILTER filter)
25 : _filter(filter) {
26 setName("LossyFinalState");
27 declare(fsp, "FS");
28 }
29
31 LossyFinalState(FILTER filter, const Cut& c = Cuts::open())
32 : _filter(filter) {
33 setName("LossyFinalState");
34 declare(FinalState(c), "FS");
35 }
36
38 virtual ~LossyFinalState() { }
39
42
44
46 using Projection::operator=;
47
48
50 void project(const Event& e) {
51 const FinalState& fs = apply<FinalState>(e, "FS");
52 getLog() << Log::DEBUG << "Pre-loss number of FS particles = " << fs.particles().size() << '\n';
53 _theParticles.clear();
54 std::remove_copy_if(fs.particles().begin(), fs.particles().end(), std::back_inserter(_theParticles),
55 _filter);
56 getLog() << Log::DEBUG << "Filtered number of FS particles = " << _theParticles.size() << '\n';
57 }
58
59
61 CmpState compare(const Projection& p) const {
62 const LossyFinalState<FILTER>& other = pcast<LossyFinalState<FILTER>>(p);
63 const CmpState fscmp = mkNamedPCmp(other, "FS");
64 if (fscmp != CmpState::EQ) return fscmp;
65 return _filter.compare(other._filter);
66 }
67
68
69 protected:
70
72 FILTER _filter;
73 };
74
75
76}
77
78#endif
Representation of a HepMC event, and enabler of Projection caching.
Definition Event.hh:22
FinalState(const Cut &c=Cuts::OPEN)
Construction using Cuts object.
CmpState compare(const Projection &p) const
Compare projections.
Definition LossyFinalState.hh:61
RIVET_DEFAULT_PROJ_CLONE(LossyFinalState)
Clone on the heap.
virtual ~LossyFinalState()
Virtual destructor, to allow subclassing.
Definition LossyFinalState.hh:38
LossyFinalState(const FinalState &fsp, FILTER filter)
Constructor from FinalState.
Definition LossyFinalState.hh:24
void project(const Event &e)
Apply the projection on the supplied event.
Definition LossyFinalState.hh:50
LossyFinalState(FILTER filter, const Cut &c=Cuts::open())
Stand-alone constructor. Initialises the base FinalState projection.
Definition LossyFinalState.hh:31
virtual const Particles & particles() const
Get the particles in no particular order, with no cuts.
Definition ParticleFinder.hh:76
std::enable_if_t< std::is_base_of< Projection, PROJ >::value, const PROJ & > apply(const Event &evt, const Projection &proj) const
Apply the supplied projection on event evt.
Definition ProjectionApplier.hh:124
const PROJ & declare(const PROJ &proj, const std::string &name) const
Register a contained projection (user-facing version).
Definition ProjectionApplier.hh:205
Base class for all Rivet projections.
Definition Projection.hh:29
void setName(const std::string &name)
Used by derived classes to set their name.
Definition Projection.hh:146
Log & getLog() const
Get a Log object based on the getName() property of the calling projection object.
Definition Projection.hh:140
Cmp< Projection > mkNamedPCmp(const Projection &otherparent, const std::string &pname) const
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