rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.0
ParticleSmearingFunctions.hh
1 // -*- C++ -*-
2 #ifndef RIVET_ParticleSmearingFunctions_HH
3 #define RIVET_ParticleSmearingFunctions_HH
4 
5 #include "Rivet/Particle.hh"
6 #include "Rivet/Tools/MomentumSmearingFunctions.hh"
7 #include "Rivet/Tools/Random.hh"
8 
9 namespace Rivet {
10 
11 
13 
14 
16  typedef function<Particle(const Particle&)> ParticleSmearFn;
17 
19  typedef function<double(const Particle&)> ParticleEffFn;
20 
21 
23  inline double PARTICLE_EFF_ZERO(const Particle& ) { return 0; }
25  inline double PARTICLE_EFF_0(const Particle& ) { return 0; }
27  inline double PARTICLE_FN0(const Particle& ) { return 0; }
28 
30  inline double PARTICLE_EFF_ONE(const Particle& ) { return 1; }
32  inline double PARTICLE_EFF_1(const Particle& ) { return 1; }
34  inline double PARTICLE_EFF_PERFECT(const Particle& ) { return 1; }
36  inline double PARTICLE_FN1(const Particle& ) { return 1; }
37 
40  PARTICLE_EFF_CONST(double x) : _x(x) {}
41  double operator () (const Particle& ) const { return _x; }
42  double _x;
43  };
44 
45 
47  inline Particle PARTICLE_SMEAR_IDENTITY(const Particle& p) { return p; }
49  inline Particle PARTICLE_SMEAR_PERFECT(const Particle& p) { return p; }
50 
51 
56  ParticleEffSmearFn(const ParticleSmearFn& s, const ParticleEffFn& e)
57  : sfn(s), efn(e) { }
58 
59  ParticleEffSmearFn(const ParticleEffFn& e, const ParticleSmearFn& s)
60  : sfn(s), efn(e) { }
61 
62  ParticleEffSmearFn(const ParticleSmearFn& s)
63  : sfn(s), efn(PARTICLE_EFF_ONE) { }
64 
65  ParticleEffSmearFn(const ParticleEffFn& e)
66  : sfn(PARTICLE_SMEAR_IDENTITY), efn(e) { }
67 
68  ParticleEffSmearFn(double eff)
70 
72  pair<Particle,double> operator() (const Particle& p) const {
73  return make_pair(sfn(p), efn(p));
74  }
75 
77  int cmp(const ParticleEffSmearFn& other) const {
78  // cout << "Eff hashes = " << get_address(efn) << "," << get_address(other.efn) << "; "
79  // << "smear hashes = " << get_address(sfn) << "," << get_address(other.sfn) << endl;
80  if (get_address(sfn) == 0 || get_address(other.sfn) == 0) return UNDEFINED;
81  if (get_address(efn) == 0 || get_address(other.efn) == 0) return UNDEFINED;
82  return Rivet::cmp(get_address(sfn), get_address(other.sfn)) || Rivet::cmp(get_address(efn), get_address(other.efn));
83  }
84 
86  operator ParticleSmearFn () { return sfn; }
88  operator ParticleEffFn () { return efn; }
89 
90  // Stored functions/functors
91  const ParticleSmearFn sfn;
92  const ParticleEffFn efn;
93  };
94 
95 
97  inline bool efffilt(const Particle& p, const ParticleEffFn& feff) {
98  return rand01() < feff(p);
99  }
100 
104  template <typename FN>
105  ParticleEffFilter(const FN& feff) : _feff(feff) {}
106  ParticleEffFilter(double eff) : ParticleEffFilter( [&](const Particle& p){return eff;} ) {}
107  bool operator () (const Particle& p) const { return efffilt(p, _feff); }
108  private:
109  const ParticleEffFn _feff;
110  };
112 
114 
115 
116 }
117 
118 #endif
Definition: ALICE_2010_I880049.cc:13
double PARTICLE_FN0(const Particle &)
Alias for PARTICLE_EFF_ZERO.
Definition: ParticleSmearingFunctions.hh:27
double PARTICLE_FN1(const Particle &)
Alias for PARTICLE_EFF_ONE.
Definition: ParticleSmearingFunctions.hh:36
double PARTICLE_EFF_ONE(const Particle &)
Take a Particle and return 1.
Definition: ParticleSmearingFunctions.hh:30
Take a Particle and return a constant number.
Definition: ParticleSmearingFunctions.hh:39
Definition: ParticleSmearingFunctions.hh:103
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition: Particle.hh:18
Functor for simultaneous efficiency-filtering and smearing of Particles.
Definition: ParticleSmearingFunctions.hh:55
bool efffilt(const Jet &j, FN &feff)
Return true if Jet j is chosen to survive a random efficiency selection.
Definition: JetSmearingFunctions.hh:117
int cmp(const ParticleEffSmearFn &other) const
Compare to another, for use in the projection system.
Definition: ParticleSmearingFunctions.hh:77
double PARTICLE_EFF_1(const Particle &)
Alias for PARTICLE_EFF_ONE.
Definition: ParticleSmearingFunctions.hh:32
Particle PARTICLE_SMEAR_IDENTITY(const Particle &p)
Take a Particle and return it unmodified.
Definition: ParticleSmearingFunctions.hh:47
double PARTICLE_EFF_PERFECT(const Particle &)
Alias for PARTICLE_EFF_ONE.
Definition: ParticleSmearingFunctions.hh:34
Particle PARTICLE_SMEAR_PERFECT(const Particle &p)
Alias for PARTICLE_SMEAR_IDENTITY.
Definition: ParticleSmearingFunctions.hh:49
double PARTICLE_EFF_0(const Particle &)
Alias for PARTICLE_EFF_ZERO.
Definition: ParticleSmearingFunctions.hh:25
double PARTICLE_EFF_ZERO(const Particle &)
Take a Particle and return 0.
Definition: ParticleSmearingFunctions.hh:23
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