Rivet  1.8.3
ConstLossyFinalState.hh
1 // -*- C++ -*-
2 #ifndef RIVET_ConstLossyFinalState_HH
3 #define RIVET_ConstLossyFinalState_HH
4 
5 #include "Rivet/Tools/Logging.hh"
6 #include "Rivet/Rivet.hh"
7 #include "Rivet/Particle.hh"
8 #include "Rivet/Event.hh"
9 #include "Rivet/Projection.hh"
10 #include "Rivet/Projections/FinalState.hh"
11 #include "Rivet/Projections/LossyFinalState.hh"
12 
13 namespace Rivet {
14 
15 
18  public:
19 
20  ConstRandomFilter(double lossFraction)
21  : _lossFraction(lossFraction)
22  {
23  assert(_lossFraction >= 0);
24  }
25 
26  // If operator() returns true, particle is deleted ("lost")
27  bool operator()(const Particle&) {
29  return (rand()/static_cast<double>(RAND_MAX) < _lossFraction);
30  }
31 
32  int compare(const ConstRandomFilter& other) const {
33  return cmp(_lossFraction, other._lossFraction);
34  }
35 
36  private:
37 
38  double _lossFraction;
39 
40  };
41 
42 
43 
45  class ConstLossyFinalState : public LossyFinalState<ConstRandomFilter> {
46  public:
47 
49 
50 
52  ConstLossyFinalState(const FinalState& fsp, double lossfraction)
54  {
55  setName("ConstLossyFinalState");
56  }
57 
59  ConstLossyFinalState(double lossfraction,
60  double mineta = -MAXRAPIDITY,
61  double maxeta = MAXRAPIDITY,
62  double minpt = 0.0)
63  : LossyFinalState<ConstRandomFilter>(ConstRandomFilter(lossfraction), mineta, maxeta, minpt)
64  {
65  setName("ConstLossyFinalState");
66  }
67 
69  virtual const Projection* clone() const {
70  return new ConstLossyFinalState(*this);
71  }
72 
74 
75  };
76 
77 
78 }
79 
80 #endif