Rivet: /Users/chrisg/software/rivet/include/Rivet/Tools/ParticleSmearingFunctions.hh Source File

| Rivet 3.1.9

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
9namespace Rivet {
10
11
14
17
19 typedef function<Particle(const Particle&)> ParticleSmearFn;
20
22 typedef function<double(const Particle&)> ParticleEffFn;
23
24
26 inline double PARTICLE_EFF_ZERO(const Particle& ) { return 0; }
28 inline double PARTICLE_EFF_0(const Particle& ) { return 0; }
30 inline double PARTICLE_FN0(const Particle& ) { return 0; }
31
33 inline double PARTICLE_EFF_ONE(const Particle& ) { return 1; }
35 inline double PARTICLE_EFF_1(const Particle& ) { return 1; }
37 inline double PARTICLE_EFF_PERFECT(const Particle& ) { return 1; }
39 inline double PARTICLE_FN1(const Particle& ) { return 1; }
40
42 struct PARTICLE_EFF_CONST {
43 PARTICLE_EFF_CONST(double x) : _x(x) {}
44 double operator () (const Particle& ) const { return _x; }
45 double _x;
46 };
47
48
50 inline Particle PARTICLE_SMEAR_IDENTITY(const Particle& p) { return p; }
52 inline Particle PARTICLE_SMEAR_PERFECT(const Particle& p) { return p; }
53
54
58 struct ParticleEffSmearFn {
59 ParticleEffSmearFn(const ParticleSmearFn& s, const ParticleEffFn& e)
60 : sfn(s), efn(e) { }
61
62 ParticleEffSmearFn(const ParticleEffFn& e, const ParticleSmearFn& s)
63 : sfn(s), efn(e) { }
64
65 ParticleEffSmearFn(const ParticleSmearFn& s)
66 : sfn(s), efn(PARTICLE_EFF_ONE) { }
67
68 ParticleEffSmearFn(const ParticleEffFn& e)
69 : sfn(PARTICLE_SMEAR_IDENTITY), efn(e) { }
70
71 ParticleEffSmearFn(double eff)
72 : ParticleEffSmearFn(PARTICLE_EFF_CONST(eff)) { }
73
75 pair<Particle,double> operator() (const Particle& p) const {
76 return make_pair(sfn(p), efn(p));
77 }
78
80 CmpState cmp(const ParticleEffSmearFn& other) const {
81 // cout << "Eff hashes = " << get_address(efn) << "," << get_address(other.efn) << "; "
82 // << "smear hashes = " << get_address(sfn) << "," << get_address(other.sfn) << '\n';
83 if (get_address(sfn) == 0 || get_address(other.sfn) == 0) return CmpState::NEQ;
84 if (get_address(efn) == 0 || get_address(other.efn) == 0) return CmpState::NEQ;
85 return Rivet::cmp(get_address(sfn), get_address(other.sfn)) || Rivet::cmp(get_address(efn), get_address(other.efn));
86 }
87
89 operator ParticleSmearFn () { return sfn; }
91 operator ParticleEffFn () { return efn; }
92
93 // Stored functions/functors
94 const ParticleSmearFn sfn;
95 const ParticleEffFn efn;
96 };
97
98
100 inline bool efffilt(const Particle& p, const ParticleEffFn& feff) {
101 return rand01() < feff(p);
102 }
103
107 struct ParticleEffFilter {
108 template <typename FN>
109 ParticleEffFilter(const FN& feff) : _feff(feff) {}
110 ParticleEffFilter(double eff) : ParticleEffFilter( [&](const Particle& p){return eff;} ) {}
111 bool operator () (const Particle& p) const { return efffilt(p, _feff); }
112 private:
113 const ParticleEffFn _feff;
114 };
115 using particleEffFilter = ParticleEffFilter;
116
118
120
121}
122
123#endif
Rivet::Particle
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition Particle.hh:53
Rivet::Kin::p
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:684
Rivet::PARTICLE_EFF_ONE
double PARTICLE_EFF_ONE(const Particle &)
Take a Particle and return 1.
Definition ParticleSmearingFunctions.hh:33
Rivet::PARTICLE_SMEAR_PERFECT
Particle PARTICLE_SMEAR_PERFECT(const Particle &p)
Alias for PARTICLE_SMEAR_IDENTITY.
Definition ParticleSmearingFunctions.hh:52
Rivet::PARTICLE_EFF_PERFECT
double PARTICLE_EFF_PERFECT(const Particle &)
Alias for PARTICLE_EFF_ONE.
Definition ParticleSmearingFunctions.hh:37
Rivet::ParticleSmearFn
function< Particle(const Particle &)> ParticleSmearFn
Typedef for Particle smearing functions/functors.
Definition ParticleSmearingFunctions.hh:19
Rivet::PARTICLE_FN1
double PARTICLE_FN1(const Particle &)
Alias for PARTICLE_EFF_ONE.
Definition ParticleSmearingFunctions.hh:39
Rivet::PARTICLE_SMEAR_IDENTITY
Particle PARTICLE_SMEAR_IDENTITY(const Particle &p)
Take a Particle and return it unmodified.
Definition ParticleSmearingFunctions.hh:50
Rivet::PARTICLE_EFF_0
double PARTICLE_EFF_0(const Particle &)
Alias for PARTICLE_EFF_ZERO.
Definition ParticleSmearingFunctions.hh:28
Rivet::PARTICLE_FN0
double PARTICLE_FN0(const Particle &)
Alias for PARTICLE_EFF_ZERO.
Definition ParticleSmearingFunctions.hh:30
Rivet::PARTICLE_EFF_ZERO
double PARTICLE_EFF_ZERO(const Particle &)
Take a Particle and return 0.
Definition ParticleSmearingFunctions.hh:26
Rivet::ParticleEffFn
function< double(const Particle &)> ParticleEffFn
Typedef for Particle efficiency functions/functors.
Definition ParticleSmearingFunctions.hh:22
Rivet::PARTICLE_EFF_1
double PARTICLE_EFF_1(const Particle &)
Alias for PARTICLE_EFF_ONE.
Definition ParticleSmearingFunctions.hh:35
Rivet::efffilt
bool efffilt(const Jet &j, FN &feff)
Return true if Jet j is chosen to survive a random efficiency selection.
Definition JetSmearingFunctions.hh:138
Rivet
Definition MC_Cent_pPb.hh:10
Rivet::rand01
double rand01()
Return a uniformly sampled random number between 0 and 1.
Rivet::cmp
Cmp< T > cmp(const T &t1, const T &t2)
Global helper function for easy creation of Cmp objects.
Definition Cmp.hh:255
std::get_address
uintptr_t get_address(std::function< T(U...)> f)
Get a function pointer / hash integer from an std::function.
Definition RivetSTL.hh:193
Rivet::PARTICLE_EFF_CONST
Take a Particle and return a constant number.
Definition ParticleSmearingFunctions.hh:42
Rivet::ParticleEffFilter
A functor to return true if Particle p survives a random efficiency selection.
Definition ParticleSmearingFunctions.hh:107
Rivet::ParticleEffSmearFn
Functor for simultaneous efficiency-filtering and smearing of Particles.
Definition ParticleSmearingFunctions.hh:58
Rivet::ParticleEffSmearFn::cmp
CmpState cmp(const ParticleEffSmearFn &other) const
Compare to another, for use in the projection system.
Definition ParticleSmearingFunctions.hh:80
Rivet::ParticleEffSmearFn::operator()
pair< Particle, double > operator()(const Particle &p) const
Smear and calculate an efficiency for the given particle.
Definition ParticleSmearingFunctions.hh:75