File indexing completed on 2025-05-12 09:05:02
0001
0002 #ifndef RIVET_ConstLossyFinalState_HH
0003 #define RIVET_ConstLossyFinalState_HH
0004
0005 #include "Rivet/Tools/Logging.hh"
0006 #include "Rivet/Tools/Random.hh"
0007 #include "Rivet/Config/RivetCommon.hh"
0008 #include "Rivet/Particle.hh"
0009 #include "Rivet/Event.hh"
0010 #include "Rivet/Projection.hh"
0011 #include "Rivet/Projections/FinalState.hh"
0012 #include "Rivet/Projections/LossyFinalState.hh"
0013
0014 namespace Rivet {
0015
0016
0017
0018 class ConstRandomFilter {
0019 public:
0020
0021 ConstRandomFilter(double lossFraction)
0022 : _lossFraction(lossFraction)
0023 {
0024 assert(_lossFraction >= 0);
0025 }
0026
0027
0028 bool operator()(const Particle&) {
0029 return rand01() < _lossFraction;
0030 }
0031
0032 CmpState compare(const ConstRandomFilter& other) const {
0033 return cmp(_lossFraction, other._lossFraction);
0034 }
0035
0036
0037 protected:
0038
0039 double _lossFraction;
0040
0041 };
0042
0043
0044
0045
0046 class ConstLossyFinalState : public LossyFinalState<ConstRandomFilter> {
0047 public:
0048
0049
0050
0051
0052
0053 ConstLossyFinalState(const FinalState& fsp, double lossfraction)
0054 : LossyFinalState<ConstRandomFilter>(fsp, ConstRandomFilter(lossfraction))
0055 {
0056 setName("ConstLossyFinalState");
0057 }
0058
0059
0060 ConstLossyFinalState(double lossfraction, const Cut& c=Cuts::open())
0061 : LossyFinalState<ConstRandomFilter>(ConstRandomFilter(lossfraction), c)
0062 {
0063 setName("ConstLossyFinalState");
0064 }
0065
0066
0067 RIVET_DEFAULT_PROJ_CLONE(ConstLossyFinalState);
0068
0069
0070 using Projection::operator =;
0071
0072
0073
0074 };
0075
0076
0077 }
0078
0079 #endif