herwig is hosted by Hepforge, IPPP Durham
Herwig  7.2.1
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>
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 
42  bool compensate;
43 
44  };
45 
49 
50  public:
51 
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>
85 
86  public:
87 
90  : point_(), bin_id_(),
91  sampled_variables_(), rnd_gen_(),
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
accessor returning the integral of a cell
Definition: selectors.h:137
selector selecting only bins which contain the given parameter point
Definition: selectors.h:48
sampling_selector()
the default constructor
Definition: selectors.h:23
sampling selector selecting only bins which contain the given parameter point
Definition: selectors.h:84
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
parametric_selector()
the default constructor
Definition: selectors.h:53
Random rnd_gen_
the random number generator
Definition: selectors.h:129
bool compensate_
wether or not compensation is needed
Definition: selectors.h:132
std::vector< double > * point_
the point chosen
Definition: selectors.h:74
void compensate(bool doit=true)
indicate that compensation is to take place
Definition: selectors.h:115
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
the general cell class
Definition: cell.h:197
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, and random number generator
Definition: selectors.h:96
parametric_missing_accessor()
the default constructor
Definition: selectors.h:171
sampling_selector(const Random &r, bool comp=true)
the standard constructor
Definition: selectors.h:27
std::vector< bool > sampled_variables_
flags for variables to be sampled
Definition: selectors.h:77
bit_container< parameter_hash_bits > * bin_id_
the corresponding bin id
Definition: selectors.h:123
flat sampling selector
Definition: selectors.h:20
Random rnd_gen
The random number generator to be used.
Definition: selectors.h:39
parametric_missing_accessor(bit_container< parameter_hash_bits > *id)
construct from subtree hash to consider
Definition: selectors.h:175
std::vector< double > * point_
the point chosen
Definition: selectors.h:120
accessor returning the number of missing events
Definition: selectors.h:152
bit_container< parameter_hash_bits > * id_
the subtree hash to consider
Definition: selectors.h:193
std::vector< bool > sampled_variables_
flags for variables to be sampled
Definition: selectors.h:126
bool compensate
Whether or not compensation is needed.
Definition: selectors.h:42
parametric_sampling_selector()
the default constructor
Definition: selectors.h:89
bool use(const cell &) const
return true, if the leaf cell should be considered
Definition: selectors.h:69
accessor returning the number of missing events for given parameter bin id
Definition: selectors.h:168