ConstLossyFinalState.hh
// -*- C++ -*-
#ifndef RIVET_ConstLossyFinalState_HH
#define RIVET_ConstLossyFinalState_HH
#include "Rivet/Tools/Logging.hh"
#include "Rivet/Rivet.hh"
#include "Rivet/Particle.hh"
#include "Rivet/Event.hh"
#include "Rivet/Projection.hh"
#include "Rivet/Projections/FinalState.hh"
#include "Rivet/Projections/LossyFinalState.hh"
namespace Rivet {
class ConstRandomFilter {
public:
ConstRandomFilter(double lossFraction)
: _lossFraction(lossFraction)
{
assert(_lossFraction >= 0);
}
// If operator() returns true, particle is deleted ("lost")
bool operator()(const Particle&) {
return (rand()/static_cast<double>(RAND_MAX) < _lossFraction);
}
int compare(const ConstRandomFilter& other) const {
return cmp(_lossFraction, other._lossFraction);
}
private:
double _lossFraction;
};
class ConstLossyFinalState : public LossyFinalState<ConstRandomFilter> {
public:
ConstLossyFinalState(const FinalState& fsp, double lossfraction)
: LossyFinalState<ConstRandomFilter>(fsp, ConstRandomFilter(lossfraction))
{
setName("ConstLossyFinalState");
}
ConstLossyFinalState(double lossfraction,
double mineta = -MAXRAPIDITY,
double maxeta = MAXRAPIDITY,
double minpt = 0.0)
: LossyFinalState<ConstRandomFilter>(ConstRandomFilter(lossfraction), mineta, maxeta, minpt)
{
setName("ConstLossyFinalState");
}
virtual const Projection* clone() const {
return new ConstLossyFinalState(*this);
}
};
}
#endif
Rivet::Projection::setName
void setName(const std::string &name)
Used by derived classes to set their name.
Definition: Projection.hh:120
Rivet::LossyFinalState
Templated FS projection which can lose some of the supplied particles.
Definition: LossyFinalState.hh:17
Rivet::Particle
Representation of particles from a HepMC::GenEvent.
Definition: Particle.hh:16
Rivet::ConstLossyFinalState::clone
virtual const Projection * clone() const
Clone on the heap.
Definition: ConstLossyFinalState.hh:69
Rivet::ConstRandomFilter
Functor used to implement constant random lossiness.
Definition: ConstLossyFinalState.hh:17
Rivet::ConstLossyFinalState::ConstLossyFinalState
ConstLossyFinalState(double lossfraction, double mineta=-MAXRAPIDITY, double maxeta=MAXRAPIDITY, double minpt=0.0)
Stand-alone constructor. Initialises the base FinalState projection.
Definition: ConstLossyFinalState.hh:59
Rivet::ConstLossyFinalState
Randomly lose a constant fraction of particles.
Definition: ConstLossyFinalState.hh:45
Rivet::FinalState
Project out all final-state particles in an event. Probably the most important projection in Rivet! ...
Definition: FinalState.hh:14
Rivet::ConstRandomFilter::operator()
bool operator()(const Particle &)
Definition: ConstLossyFinalState.hh:27
Rivet::ConstLossyFinalState::ConstLossyFinalState
ConstLossyFinalState(const FinalState &fsp, double lossfraction)
Constructor from a FinalState.
Definition: ConstLossyFinalState.hh:52
Rivet::MAXRAPIDITY
static const double MAXRAPIDITY
A sensible default maximum value of rapidity for Rivet analyses to use.
Definition: Rivet.hh:24
Rivet::Projection
Base class for all Rivet projections.
Definition: Projection.hh:28
Rivet::cmp
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:285