rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.0
ConstLossyFinalState.hh
1 // -*- C++ -*-
2 #ifndef RIVET_ConstLossyFinalState_HH
3 #define RIVET_ConstLossyFinalState_HH
4 
5 #include "Rivet/Tools/Logging.hh"
6 #include "Rivet/Config/RivetCommon.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&) {
28  return rand01() < _lossFraction;
29  }
30 
31  int compare(const ConstRandomFilter& other) const {
32  return cmp(_lossFraction, other._lossFraction);
33  }
34 
35  private:
36 
37  double _lossFraction;
38 
39  };
40 
41 
42 
44  class ConstLossyFinalState : public LossyFinalState<ConstRandomFilter> {
45  public:
46 
48 
49 
51  ConstLossyFinalState(const FinalState& fsp, double lossfraction)
53  {
54  setName("ConstLossyFinalState");
55  }
56 
58  ConstLossyFinalState(double lossfraction,
59  double mineta = -MAXDOUBLE,
60  double maxeta = MAXDOUBLE,
61  double minpt = 0.0)
62  : LossyFinalState<ConstRandomFilter>(ConstRandomFilter(lossfraction), mineta, maxeta, minpt)
63  {
64  setName("ConstLossyFinalState");
65  }
66 
68  DEFAULT_RIVET_PROJ_CLONE(ConstLossyFinalState);
69 
71 
72  };
73 
74 
75 }
76 
77 #endif
Definition: ALICE_2010_I880049.cc:13
Templated FS projection which can lose some of the supplied particles.
Definition: LossyFinalState.hh:17
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition: Particle.hh:18
Functor used to implement constant random lossiness.
Definition: ConstLossyFinalState.hh:17
static const double MAXDOUBLE
Definition: MathHeader.hh:12
Randomly lose a constant fraction of particles.
Definition: ConstLossyFinalState.hh:44
Project out all final-state particles in an event. Probably the most important projection in Rivet! ...
Definition: FinalState.hh:12
ConstLossyFinalState(const FinalState &fsp, double lossfraction)
Constructor from a FinalState.
Definition: ConstLossyFinalState.hh:51
ConstLossyFinalState(double lossfraction, double mineta=-MAXDOUBLE, double maxeta=MAXDOUBLE, double minpt=0.0)
Stand-alone constructor. Initialises the base FinalState projection.
Definition: ConstLossyFinalState.hh:58
double rand01()
Return a uniformly sampled random number between 0 and 1.
Definition: Random.cc:39
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition: Cmp.hh:285