herwig is hosted by Hepforge, IPPP Durham
Herwig 7.3.0
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
16namespace exsample {
17
19 template<class Random>
21
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
43
44 };
45
49
50 public:
51
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>
85
86 public:
87
90 : point_(), bin_id_(),
92 compensate_(false) {}
93
96 parametric_sampling_selector(std::vector<double> * p,
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
124
126 std::vector<bool> sampled_variables_;
127
129 Random rnd_gen_;
130
133
134 };
135
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
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
169
172 : id_() {}
173
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
194
195 };
196
197}
198
199#include "selectors.icc"
200
201#endif // EXSAMPLE_selectors_h_included
int parametric_missing(const bit_container< parameter_hash_bits > &id) const
return the number of missing events for the given parameter bin id
the general cell class
Definition: cell.h:197
int & missing_events()
access the number of missing events
Definition: cell.h:252
cell_info & info()
access the cell_info object
Definition: cell.h:261
double integral() const
return the integral
Definition: cell.h:243
sampling selector selecting only bins which contain the given parameter point
Definition: selectors.h:84
std::vector< double > * point_
the point chosen
Definition: selectors.h:120
bit_container< parameter_hash_bits > * bin_id_
the corresponding bin id
Definition: selectors.h:123
bool compensate_
wether or not compensation is needed
Definition: selectors.h:132
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
void compensate(bool doit=true)
indicate that compensation is to take place
Definition: selectors.h:115
parametric_sampling_selector()
the default constructor
Definition: selectors.h:89
std::vector< bool > sampled_variables_
flags for variables to be sampled
Definition: selectors.h:126
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
bool use(cell &leaf) const
return true, if the leaf cell should be considered
Random rnd_gen_
the random number generator
Definition: selectors.h:129
selector selecting only bins which contain the given parameter point
Definition: selectors.h:48
parametric_selector()
the default constructor
Definition: selectors.h:53
std::pair< bool, bool > use(const cell &parent, const cell &, const cell &) const
return which of the children cells should be considered
std::vector< double > * point_
the point chosen
Definition: selectors.h:74
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
std::vector< bool > sampled_variables_
flags for variables to be sampled
Definition: selectors.h:77
bool use(const cell &) const
return true, if the leaf cell should be considered
Definition: selectors.h:69
Fixed-size, packed vector of bools.
Definition: utility.h:55
accessor returning the integral of a cell
Definition: selectors.h:137
double & set(cell &node) const
update and return the value
Definition: selectors.h:140
double get(const cell &node, bool) const
get the value
Definition: selectors.h:145
accessor returning the number of missing events
Definition: selectors.h:152
int & set(cell &node) const
update and return the value
Definition: selectors.h:155
int get(const cell &node, bool) const
get the value
Definition: selectors.h:160
accessor returning the number of missing events for given parameter bin id
Definition: selectors.h:168
int & set(cell &node) const
update and return the value
Definition: selectors.h:179
bit_container< parameter_hash_bits > * id_
the subtree hash to consider
Definition: selectors.h:193
parametric_missing_accessor(bit_container< parameter_hash_bits > *id)
construct from subtree hash to consider
Definition: selectors.h:175
int get(const cell &node, bool isleaf) const
get the value
Definition: selectors.h:184
parametric_missing_accessor()
the default constructor
Definition: selectors.h:171
flat sampling selector
Definition: selectors.h:20
Random rnd_gen
The random number generator to be used.
Definition: selectors.h:39
bool compensate
Whether or not compensation is needed.
Definition: selectors.h:42
bool use(cell &leaf) const
return true, if the leaf cell should be considered
sampling_selector(const Random &r, bool comp=true)
the standard constructor
Definition: selectors.h:27
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
sampling_selector()
the default constructor
Definition: selectors.h:23