herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Sampling
exsample
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
20
namespace
exsample {
21
24
struct
exponential_regenerate
{};
25
27
template
<
class
Function,
class
Random>
28
class
exponential_generator
{
29
30
public
:
31
33
exponential_generator
()
34
:
function_
(0),
check_events_
(0),
adaption_info_
(),
root_cell_
(),
35
rnd_gen_
(),
did_split_
(false),
initialized_
(false),
36
evolution_variable_
(0),
evolution_cutoff_
(0.),
37
sample_variables_
(),
sample_other_variables_
(),
38
parameter_splits_
(),
39
last_cell_
(),
last_point_
(),
last_value_
(0.),
40
last_parameter_bin_
(),
exponents_
(),
41
last_exponent_integrand_
(),
42
last_exponent_
(),
compensating_
(false),
43
integral_accessor_
(),
missing_accessor_
(),
44
parametric_selector_
(),
exponent_selector_
(),
45
parametric_sampler_
(),
attempts_
(0),
accepts_
(0),
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
105
adaption_info
&
sampling_parameters
() {
return
adaption_info_
; }
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
135
void
get_exponent
();
136
138
void
compensate
();
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
158
adaption_info
adaption_info_
;
159
161
binary_tree<cell>
root_cell_
;
162
164
rnd_generator<Random>
rnd_gen_
;
165
167
bool
did_split_
;
168
170
bool
initialized_
;
171
173
std::size_t
evolution_variable_
;
174
176
double
evolution_cutoff_
;
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
191
binary_tree<cell>::iterator
last_cell_
;
192
194
std::vector<double>
last_point_
;
195
197
double
last_value_
;
198
200
bit_container<parameter_hash_bits>
last_parameter_bin_
;
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
212
bool
compensating_
;
213
215
integral_accessor
integral_accessor_
;
216
218
parametric_missing_accessor
missing_accessor_
;
219
221
parametric_selector
parametric_selector_
;
222
224
parametric_selector
exponent_selector_
;
225
227
parametric_sampling_selector<rnd_generator<Random>
>
parametric_sampler_
;
228
230
unsigned
long
attempts_
;
231
233
unsigned
long
accepts_
;
234
236
unsigned
long
splits_
;
237
239
bool
docompensate_
;
240
242
double
detuning_
;
243
244
};
245
246
}
247
248
#include "exponential_generator.icc"
249
250
#endif
// EXSAMPLE_exponential_generator_h_included
exsample::binary_tree::iterator
iterator
Definition:
binary_tree.h:97
exsample::binary_tree
binary_tree represents a binary tree with the ability to ‘cascade’ visitor objects down the tree
Definition:
binary_tree.h:21
exsample::exponential_generator
The generator for sudakov-type distributions.
Definition:
exponential_generator.h:28
exsample::exponential_generator::did_split
bool did_split() const
return true, if at least one split has been performed
Definition:
exponential_generator.h:96
exsample::exponential_generator::adaption_info_
adaption_info adaption_info_
the adaption info object
Definition:
exponential_generator.h:158
exsample::exponential_generator::accepts_
unsigned long accepts_
the number of accepted events so far
Definition:
exponential_generator.h:233
exsample::exponential_generator::attempts_
unsigned long attempts_
the number of trials in the veto loo so far
Definition:
exponential_generator.h:230
exsample::exponential_generator::root_cell_
binary_tree< cell > root_cell_
the root cell
Definition:
exponential_generator.h:161
exsample::exponential_generator::last_cell_
binary_tree< cell >::iterator last_cell_
the last selected cell
Definition:
exponential_generator.h:191
exsample::exponential_generator::sampling_parameters
adaption_info & sampling_parameters()
access the adaption_info object
Definition:
exponential_generator.h:105
exsample::exponential_generator::evolution_variable_
std::size_t evolution_variable_
the position of the evolution variable
Definition:
exponential_generator.h:173
exsample::exponential_generator::integral_accessor_
integral_accessor integral_accessor_
the integral accessor to be used
Definition:
exponential_generator.h:215
exsample::exponential_generator::function
void function(Function *f)
set the function
Definition:
exponential_generator.h:102
exsample::exponential_generator::evolution_cutoff_
double evolution_cutoff_
the cutoff on the evolution variable
Definition:
exponential_generator.h:176
exsample::exponential_generator::parametric_selector_
parametric_selector parametric_selector_
the parametric selector to be used
Definition:
exponential_generator.h:221
exsample::exponential_generator::rnd_gen_
rnd_generator< Random > rnd_gen_
the random number generator to be used
Definition:
exponential_generator.h:164
exsample::exponential_generator::last_value
double last_value() const
return the last evaluated function
Definition:
exponential_generator.h:83
exsample::exponential_generator::sample_variables_
std::vector< bool > sample_variables_
flags of variables to be sampled including the evolution variable
Definition:
exponential_generator.h:180
exsample::exponential_generator::finalize
void finalize()
finalize this generator
Definition:
exponential_generator.h:54
exsample::exponential_generator::exponent_selector_
parametric_selector exponent_selector_
the parametric selector to be used for parameter bins
Definition:
exponential_generator.h:224
exsample::exponential_generator::reject
void reject()
indicate that the last generated point has been rejected
Definition:
exponential_generator.h:86
exsample::exponential_generator::generate
double generate(double enhance=1.)
generate an event, returning the sign of the weight or zero for an event below the evolution cutoff
exsample::exponential_generator::compensating_
bool compensating_
wether or not we are compensating
Definition:
exponential_generator.h:212
exsample::exponential_generator::function_
Function * function_
function to be sampled
Definition:
exponential_generator.h:151
exsample::exponential_generator::last_point
const std::vector< double > & last_point() const
return the last sampled phase space point
Definition:
exponential_generator.h:80
exsample::exponential_generator::compensate
void compensate()
compensate
exsample::exponential_generator::initialized
bool initialized() const
return true, if this generator has been initialized
Definition:
exponential_generator.h:93
exsample::exponential_generator::missing_accessor_
parametric_missing_accessor missing_accessor_
the missing events accessor to be used
Definition:
exponential_generator.h:218
exsample::exponential_generator::exponential_generator
exponential_generator()
default constructor
Definition:
exponential_generator.h:33
exsample::exponential_generator::get_exponent
void get_exponent()
get the projection of the density integrating over every variable to be sampled, except the evolution...
exsample::exponential_generator::recursive_parameter_points
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
exsample::exponential_generator::initialize
void initialize()
initialize this generator
exsample::exponential_generator::exponents_
std::map< bit_container< parameter_hash_bits >, linear_interpolator > exponents_
map parameter bin ids to exponent interpolations
Definition:
exponential_generator.h:203
exsample::exponential_generator::last_parameter_bin_
bit_container< parameter_hash_bits > last_parameter_bin_
the last parameter bin id
Definition:
exponential_generator.h:200
exsample::exponential_generator::parameter_splits_
std::map< std::size_t, std::vector< double > > parameter_splits_
the splits in any parameter done so far (including the evolution variable)
Definition:
exponential_generator.h:188
exsample::exponential_generator::docompensate_
bool docompensate_
true, if compensation should be applied
Definition:
exponential_generator.h:239
exsample::exponential_generator::parameter_points
std::set< std::vector< double > > parameter_points()
get all parameter points to build all possible sub tree hashes
exsample::exponential_generator::detuning
void detuning(double val)
set the detuning parameter
Definition:
exponential_generator.h:111
exsample::exponential_generator::did_split_
bool did_split_
wether a split has already been performed
Definition:
exponential_generator.h:167
exsample::exponential_generator::docompensate
void docompensate(bool yes=true)
indicate, if compensation should be applied
Definition:
exponential_generator.h:108
exsample::exponential_generator::check_events_
unsigned long check_events_
the number of events after which a cell is checked for splits
Definition:
exponential_generator.h:155
exsample::exponential_generator::last_value_
double last_value_
the last function value
Definition:
exponential_generator.h:197
exsample::exponential_generator::sample_other_variables_
std::vector< bool > sample_other_variables_
flags of variables to be sampled excluding the evolution variable
Definition:
exponential_generator.h:184
exsample::exponential_generator::split
bool split()
check for and possibly split the last selected cell
exsample::exponential_generator::initialized_
bool initialized_
wether this generator has been initialized
Definition:
exponential_generator.h:170
exsample::exponential_generator::function
Function & function()
access the function
Definition:
exponential_generator.h:99
exsample::exponential_generator::last_exponent_integrand_
std::vector< double > last_exponent_integrand_
the last exponent integrand
Definition:
exponential_generator.h:206
exsample::exponential_generator::put
void put(OStream &os) const
put to ostream
exsample::exponential_generator::generate
double generate(double cutoff, double enhance)
generate an event, returning the sign of the weight or zero for an event below the evolution cutoff
Definition:
exponential_generator.h:64
exsample::exponential_generator::get
void get(IStream &is)
get from istream
exsample::exponential_generator::last_point_
std::vector< double > last_point_
the last sampled phasespace point
Definition:
exponential_generator.h:194
exsample::exponential_generator::detuning_
double detuning_
a detuning factor to be applied to the overestimate
Definition:
exponential_generator.h:242
exsample::exponential_generator::last_exponent_
std::map< bit_container< parameter_hash_bits >, linear_interpolator >::iterator last_exponent_
the last exponent
Definition:
exponential_generator.h:209
exsample::exponential_generator::splits_
unsigned long splits_
number of splits done
Definition:
exponential_generator.h:236
exsample::exponential_generator::parametric_sampler_
parametric_sampling_selector< rnd_generator< Random > > parametric_sampler_
the parametric sampler to be used
Definition:
exponential_generator.h:227
exsample::linear_interpolator
A linear interpolation allowing for inversion of the linear interpolation.
Definition:
linear_interpolator.h:42
exsample::parametric_sampling_selector
sampling selector selecting only bins which contain the given parameter point
Definition:
selectors.h:84
exsample::parametric_selector
selector selecting only bins which contain the given parameter point
Definition:
selectors.h:48
exsample::adaption_info
adaption_info is a container for parameters relevant to sampling and adaption.
Definition:
adaption_info.h:18
exsample::bit_container
Fixed-size, packed vector of bools.
Definition:
utility.h:55
exsample::exponential_regenerate
Exception thrown, if the exponential_generator has just changed its state.
Definition:
exponential_generator.h:24
exsample::integral_accessor
accessor returning the integral of a cell
Definition:
selectors.h:137
exsample::parametric_missing_accessor
accessor returning the number of missing events for given parameter bin id
Definition:
selectors.h:168
exsample::rnd_generator
Random generator traits.
Definition:
utility.h:319
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6