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
Definition: MC_JetAnalysis.hh:9
Templated FS projection which can lose some of the supplied particles.
Definition: LossyFinalState.hh:17
Representation of particles from a HepMC::GenEvent.
Definition: Particle.hh:16
virtual const Projection * clone() const
Clone on the heap.
Definition: ConstLossyFinalState.hh:69
Functor used to implement constant random lossiness.
Definition: ConstLossyFinalState.hh:17
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
Randomly lose a constant fraction of particles.
Definition: ConstLossyFinalState.hh:45
Project out all final-state particles in an event. Probably the most important projection in Rivet! ...
Definition: FinalState.hh:14
bool operator()(const Particle &)
Definition: ConstLossyFinalState.hh:27
ConstLossyFinalState(const FinalState &fsp, double lossfraction)
Constructor from a FinalState.
Definition: ConstLossyFinalState.hh:52
static const double MAXRAPIDITY
A sensible default maximum value of rapidity for Rivet analyses to use.
Definition: Rivet.hh:24
Base class for all Rivet projections.
Definition: Projection.hh:28
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:285