herwig
is hosted by
Hepforge
,
IPPP Durham
Herwig
7.3.0
Sampling
exsample
selectors.h
1
// -*- C++ -*-
2
//
3
// selectors.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_selectors_h_included
12
#define EXSAMPLE_selectors_h_included
13
14
#include "cell.h"
15
16
namespace
exsample {
17
19
template
<
class
Random>
20
struct
sampling_selector
{
21
23
sampling_selector
()
24
:
rnd_gen
(),
compensate
(false) {}
25
27
explicit
sampling_selector
(
const
Random& r,
bool
comp =
true
)
28
:
rnd_gen
(r),
compensate
(comp) {}
29
31
std::pair<bool,bool>
use
(
cell
& parent,
32
const
cell
& first_child,
33
const
cell
& second_child)
const
;
34
36
bool
use
(
cell
& leaf)
const
;
37
39
Random
rnd_gen
;
40
42
bool
compensate
;
43
44
};
45
48
class
parametric_selector
{
49
50
public
:
51
53
parametric_selector
()
54
:
point_
(),
sampled_variables_
() {}
55
57
parametric_selector
(std::vector<double> * point,
58
const
std::vector<bool>& sample)
59
:
point_
(point),
sampled_variables_
(sample) {}
60
61
public
:
62
64
std::pair<bool,bool>
use
(
const
cell
& parent,
65
const
cell
&,
66
const
cell
&)
const
;
67
69
bool
use
(
const
cell
&)
const
{
return
true
; }
70
71
private
:
72
74
std::vector<double> *
point_
;
75
77
std::vector<bool>
sampled_variables_
;
78
79
};
80
83
template
<
class
Random>
84
class
parametric_sampling_selector
{
85
86
public
:
87
89
parametric_sampling_selector
()
90
:
point_
(),
bin_id_
(),
91
sampled_variables_
(),
rnd_gen_
(),
92
compensate_
(false) {}
93
96
parametric_sampling_selector
(std::vector<double> * p,
97
bit_container<parameter_hash_bits>
* bin_id,
98
const
std::vector<bool>& sample,
99
const
Random& rnd_gen)
100
:
point_
(p),
bin_id_
(bin_id),
101
sampled_variables_
(sample),
rnd_gen_
(rnd_gen),
102
compensate_
(false) {}
103
104
public
:
105
107
std::pair<bool,bool>
use
(
cell
& parent,
108
const
cell
& first_child,
109
const
cell
& second_child)
const
;
110
112
bool
use
(
cell
& leaf)
const
;
113
115
void
compensate
(
bool
doit =
true
) {
compensate_
= doit; }
116
117
private
:
118
120
std::vector<double> *
point_
;
121
123
bit_container<parameter_hash_bits>
*
bin_id_
;
124
126
std::vector<bool>
sampled_variables_
;
127
129
Random
rnd_gen_
;
130
132
bool
compensate_
;
133
134
};
135
137
struct
integral_accessor
{
138
140
double
&
set
(
cell
& node)
const
{
141
return
node.
integral
();
142
}
143
145
double
get
(
const
cell
& node,
bool
)
const
{
146
return
node.
integral
();
147
}
148
149
};
150
152
struct
missing_accessor
{
153
155
int
&
set
(
cell
& node)
const
{
156
return
node.
missing_events
();
157
}
158
160
int
get
(
const
cell
& node,
bool
)
const
{
161
return
node.
missing_events
();
162
}
163
164
};
165
168
struct
parametric_missing_accessor
{
169
171
parametric_missing_accessor
()
172
:
id_
() {}
173
175
explicit
parametric_missing_accessor
(
bit_container<parameter_hash_bits>
*
id
)
176
:
id_
(id) {}
177
179
int
&
set
(
cell
& node)
const
{
180
return
node.
missing_events
();
181
}
182
184
int
get
(
const
cell
& node,
bool
isleaf)
const
{
185
if
(isleaf)
186
return
node.
info
().
parametric_missing
(*
id_
);
187
return
node.
missing_events
();
188
}
189
190
private
:
191
193
bit_container<parameter_hash_bits>
*
id_
;
194
195
};
196
197
}
198
199
#include "selectors.icc"
200
201
#endif
// EXSAMPLE_selectors_h_included
exsample::cell_info::parametric_missing
int parametric_missing(const bit_container< parameter_hash_bits > &id) const
return the number of missing events for the given parameter bin id
exsample::cell
the general cell class
Definition:
cell.h:197
exsample::cell::missing_events
int & missing_events()
access the number of missing events
Definition:
cell.h:252
exsample::cell::info
cell_info & info()
access the cell_info object
Definition:
cell.h:261
exsample::cell::integral
double integral() const
return the integral
Definition:
cell.h:243
exsample::parametric_sampling_selector
sampling selector selecting only bins which contain the given parameter point
Definition:
selectors.h:84
exsample::parametric_sampling_selector::point_
std::vector< double > * point_
the point chosen
Definition:
selectors.h:120
exsample::parametric_sampling_selector::bin_id_
bit_container< parameter_hash_bits > * bin_id_
the corresponding bin id
Definition:
selectors.h:123
exsample::parametric_sampling_selector::compensate_
bool compensate_
wether or not compensation is needed
Definition:
selectors.h:132
exsample::parametric_sampling_selector::use
std::pair< bool, bool > use(cell &parent, const cell &first_child, const cell &second_child) const
return which of the children cells should be considered
exsample::parametric_sampling_selector::compensate
void compensate(bool doit=true)
indicate that compensation is to take place
Definition:
selectors.h:115
exsample::parametric_sampling_selector::parametric_sampling_selector
parametric_sampling_selector()
the default constructor
Definition:
selectors.h:89
exsample::parametric_sampling_selector::sampled_variables_
std::vector< bool > sampled_variables_
flags for variables to be sampled
Definition:
selectors.h:126
exsample::parametric_sampling_selector::parametric_sampling_selector
parametric_sampling_selector(std::vector< double > *p, bit_container< parameter_hash_bits > *bin_id, const std::vector< bool > &sample, const Random &rnd_gen)
construct from reference to point, subtree hash, flags of variables to be sampled,...
Definition:
selectors.h:96
exsample::parametric_sampling_selector::use
bool use(cell &leaf) const
return true, if the leaf cell should be considered
exsample::parametric_sampling_selector::rnd_gen_
Random rnd_gen_
the random number generator
Definition:
selectors.h:129
exsample::parametric_selector
selector selecting only bins which contain the given parameter point
Definition:
selectors.h:48
exsample::parametric_selector::parametric_selector
parametric_selector()
the default constructor
Definition:
selectors.h:53
exsample::parametric_selector::use
std::pair< bool, bool > use(const cell &parent, const cell &, const cell &) const
return which of the children cells should be considered
exsample::parametric_selector::point_
std::vector< double > * point_
the point chosen
Definition:
selectors.h:74
exsample::parametric_selector::parametric_selector
parametric_selector(std::vector< double > *point, const std::vector< bool > &sample)
construct from reference to point and flags to sample variables
Definition:
selectors.h:57
exsample::parametric_selector::sampled_variables_
std::vector< bool > sampled_variables_
flags for variables to be sampled
Definition:
selectors.h:77
exsample::parametric_selector::use
bool use(const cell &) const
return true, if the leaf cell should be considered
Definition:
selectors.h:69
exsample::bit_container
Fixed-size, packed vector of bools.
Definition:
utility.h:55
exsample::integral_accessor
accessor returning the integral of a cell
Definition:
selectors.h:137
exsample::integral_accessor::set
double & set(cell &node) const
update and return the value
Definition:
selectors.h:140
exsample::integral_accessor::get
double get(const cell &node, bool) const
get the value
Definition:
selectors.h:145
exsample::missing_accessor
accessor returning the number of missing events
Definition:
selectors.h:152
exsample::missing_accessor::set
int & set(cell &node) const
update and return the value
Definition:
selectors.h:155
exsample::missing_accessor::get
int get(const cell &node, bool) const
get the value
Definition:
selectors.h:160
exsample::parametric_missing_accessor
accessor returning the number of missing events for given parameter bin id
Definition:
selectors.h:168
exsample::parametric_missing_accessor::set
int & set(cell &node) const
update and return the value
Definition:
selectors.h:179
exsample::parametric_missing_accessor::id_
bit_container< parameter_hash_bits > * id_
the subtree hash to consider
Definition:
selectors.h:193
exsample::parametric_missing_accessor::parametric_missing_accessor
parametric_missing_accessor(bit_container< parameter_hash_bits > *id)
construct from subtree hash to consider
Definition:
selectors.h:175
exsample::parametric_missing_accessor::get
int get(const cell &node, bool isleaf) const
get the value
Definition:
selectors.h:184
exsample::parametric_missing_accessor::parametric_missing_accessor
parametric_missing_accessor()
the default constructor
Definition:
selectors.h:171
exsample::sampling_selector
flat sampling selector
Definition:
selectors.h:20
exsample::sampling_selector::rnd_gen
Random rnd_gen
The random number generator to be used.
Definition:
selectors.h:39
exsample::sampling_selector::compensate
bool compensate
Whether or not compensation is needed.
Definition:
selectors.h:42
exsample::sampling_selector::use
bool use(cell &leaf) const
return true, if the leaf cell should be considered
exsample::sampling_selector::sampling_selector
sampling_selector(const Random &r, bool comp=true)
the standard constructor
Definition:
selectors.h:27
exsample::sampling_selector::use
std::pair< bool, bool > use(cell &parent, const cell &first_child, const cell &second_child) const
return which of the children cells should be considered
exsample::sampling_selector::sampling_selector
sampling_selector()
the default constructor
Definition:
selectors.h:23
Generated on Thu Jun 20 2024 17:50:53 for Herwig by
1.9.6