herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
exponential_generator.h
1// -*- C++ -*-
2//
3// exponential_generator.h is part of ExSample -- A Library for Sampling Sudakov-Type Distributions
4//
5// Copyright (C) 2008-2019 Simon Platzer -- simon.plaetzer@desy.de, The Herwig Collaboration
6//
7// ExSample is licenced under version 3 of the GPL, see COPYING for details.
8// Please respect the MCnet academic guidelines, see GUIDELINES for details.
9//
10//
11#ifndef EXSAMPLE_exponential_generator_h_included
12#define EXSAMPLE_exponential_generator_h_included
13
14#include "cell.h"
15#include "selectors.h"
16#include "statistics.h"
17#include "linear_interpolator.h"
18#include "binary_tree.h"
19
20namespace exsample {
21
25
27 template<class Function, class Random>
29
30 public:
31
35 rnd_gen_(), did_split_(false), initialized_(false),
46 splits_(0), docompensate_(false), detuning_(1.0) {}
47
48 public:
49
51 void initialize();
52
54 void finalize() {}
55
59 double generate(double enhance = 1.);
60
64 double generate(double cutoff,
65 double enhance) {
66 double oldcut = evolution_cutoff_;
67 evolution_cutoff_ = cutoff;
68 double w = 0.0;
69 try {
70 w = generate(enhance);
71 } catch(...) {
72 evolution_cutoff_ = oldcut;
73 throw;
74 }
75 evolution_cutoff_ = oldcut;
76 return w;
77 }
78
80 const std::vector<double>& last_point() const { return last_point_; }
81
83 double last_value() const { return last_value_; }
84
86 void reject() {
87 last_cell_->info().reject();
88 }
89
90 public:
91
93 bool initialized() const { return initialized_; }
94
96 bool did_split() const { return did_split_; }
97
99 Function& function() { return *function_; }
100
102 void function(Function * f) { function_ = f; }
103
106
108 void docompensate(bool yes = true) { docompensate_ = yes; }
109
111 void detuning(double val) { detuning_ = val; }
112
113 public:
114
116 template<class OStream>
117 void put(OStream& os) const;
118
120 template<class IStream>
121 void get(IStream& is);
122
123 private:
124
127 bool split();
128
136
139
142 std::set<std::vector<double> > parameter_points();
143
146 void recursive_parameter_points(std::set<std::vector<double> >&,
147 std::vector<double>&,
148 size_t);
149
151 Function * function_;
152
155 unsigned long check_events_;
156
159
162
165
168
171
174
177
180 std::vector<bool> sample_variables_;
181
184 std::vector<bool> sample_other_variables_;
185
188 std::map<std::size_t,std::vector<double> > parameter_splits_;
189
192
194 std::vector<double> last_point_;
195
198
201
203 std::map<bit_container<parameter_hash_bits>,linear_interpolator > exponents_;
204
206 std::vector<double> last_exponent_integrand_;
207
209 std::map<bit_container<parameter_hash_bits>,linear_interpolator >::iterator last_exponent_;
210
213
216
219
222
225
228
230 unsigned long attempts_;
231
233 unsigned long accepts_;
234
236 unsigned long splits_;
237
240
242 double detuning_;
243
244 };
245
246}
247
248#include "exponential_generator.icc"
249
250#endif // EXSAMPLE_exponential_generator_h_included
binary_tree represents a binary tree with the ability to ‘cascade’ visitor objects down the tree
Definition: binary_tree.h:21
The generator for sudakov-type distributions.
bool did_split() const
return true, if at least one split has been performed
adaption_info adaption_info_
the adaption info object
unsigned long accepts_
the number of accepted events so far
unsigned long attempts_
the number of trials in the veto loo so far
binary_tree< cell > root_cell_
the root cell
binary_tree< cell >::iterator last_cell_
the last selected cell
adaption_info & sampling_parameters()
access the adaption_info object
std::size_t evolution_variable_
the position of the evolution variable
integral_accessor integral_accessor_
the integral accessor to be used
void function(Function *f)
set the function
double evolution_cutoff_
the cutoff on the evolution variable
parametric_selector parametric_selector_
the parametric selector to be used
rnd_generator< Random > rnd_gen_
the random number generator to be used
double last_value() const
return the last evaluated function
std::vector< bool > sample_variables_
flags of variables to be sampled including the evolution variable
void finalize()
finalize this generator
parametric_selector exponent_selector_
the parametric selector to be used for parameter bins
void reject()
indicate that the last generated point has been rejected
double generate(double enhance=1.)
generate an event, returning the sign of the weight or zero for an event below the evolution cutoff
bool compensating_
wether or not we are compensating
Function * function_
function to be sampled
const std::vector< double > & last_point() const
return the last sampled phase space point
bool initialized() const
return true, if this generator has been initialized
parametric_missing_accessor missing_accessor_
the missing events accessor to be used
exponential_generator()
default constructor
void get_exponent()
get the projection of the density integrating over every variable to be sampled, except the evolution...
void recursive_parameter_points(std::set< std::vector< double > > &, std::vector< double > &, size_t)
get all parameter points to build all possible sub tree hashes
void initialize()
initialize this generator
std::map< bit_container< parameter_hash_bits >, linear_interpolator > exponents_
map parameter bin ids to exponent interpolations
bit_container< parameter_hash_bits > last_parameter_bin_
the last parameter bin id
std::map< std::size_t, std::vector< double > > parameter_splits_
the splits in any parameter done so far (including the evolution variable)
bool docompensate_
true, if compensation should be applied
std::set< std::vector< double > > parameter_points()
get all parameter points to build all possible sub tree hashes
void detuning(double val)
set the detuning parameter
bool did_split_
wether a split has already been performed
void docompensate(bool yes=true)
indicate, if compensation should be applied
unsigned long check_events_
the number of events after which a cell is checked for splits
double last_value_
the last function value
std::vector< bool > sample_other_variables_
flags of variables to be sampled excluding the evolution variable
bool split()
check for and possibly split the last selected cell
bool initialized_
wether this generator has been initialized
Function & function()
access the function
std::vector< double > last_exponent_integrand_
the last exponent integrand
void put(OStream &os) const
put to ostream
double generate(double cutoff, double enhance)
generate an event, returning the sign of the weight or zero for an event below the evolution cutoff
void get(IStream &is)
get from istream
std::vector< double > last_point_
the last sampled phasespace point
double detuning_
a detuning factor to be applied to the overestimate
std::map< bit_container< parameter_hash_bits >, linear_interpolator >::iterator last_exponent_
the last exponent
unsigned long splits_
number of splits done
parametric_sampling_selector< rnd_generator< Random > > parametric_sampler_
the parametric sampler to be used
A linear interpolation allowing for inversion of the linear interpolation.
sampling selector selecting only bins which contain the given parameter point
Definition: selectors.h:84
selector selecting only bins which contain the given parameter point
Definition: selectors.h:48
adaption_info is a container for parameters relevant to sampling and adaption.
Definition: adaption_info.h:18
Fixed-size, packed vector of bools.
Definition: utility.h:55
Exception thrown, if the exponential_generator has just changed its state.
accessor returning the integral of a cell
Definition: selectors.h:137
accessor returning the number of missing events for given parameter bin id
Definition: selectors.h:168
Random generator traits.
Definition: utility.h:319