File indexing completed on 2026-08-06 09:24:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef EXSAMPLE_selectors_h_included
0012 #define EXSAMPLE_selectors_h_included
0013
0014 #include "cell.h"
0015
0016 namespace exsample {
0017
0018
0019 template<class Random>
0020 struct sampling_selector {
0021
0022
0023 sampling_selector()
0024 : rnd_gen(), compensate(false) {}
0025
0026
0027 explicit sampling_selector(const Random& r, bool comp = true)
0028 : rnd_gen(r), compensate(comp) {}
0029
0030
0031 std::pair<bool,bool> use(cell& parent,
0032 const cell& first_child,
0033 const cell& second_child) const;
0034
0035
0036 bool use(cell& leaf) const;
0037
0038
0039 Random rnd_gen;
0040
0041
0042 bool compensate;
0043
0044 };
0045
0046
0047
0048 class parametric_selector {
0049
0050 public:
0051
0052
0053 parametric_selector ()
0054 : point_(), sampled_variables_() {}
0055
0056
0057 parametric_selector(std::vector<double> * point,
0058 const std::vector<bool>& sample)
0059 : point_(point), sampled_variables_(sample) {}
0060
0061 public:
0062
0063
0064 std::pair<bool,bool> use(const cell& parent,
0065 const cell&,
0066 const cell&) const;
0067
0068
0069 bool use(const cell&) const { return true; }
0070
0071 private:
0072
0073
0074 std::vector<double> * point_;
0075
0076
0077 std::vector<bool> sampled_variables_;
0078
0079 };
0080
0081
0082
0083 template<class Random>
0084 class parametric_sampling_selector {
0085
0086 public:
0087
0088
0089 parametric_sampling_selector()
0090 : point_(), bin_id_(),
0091 sampled_variables_(), rnd_gen_(),
0092 compensate_(false) {}
0093
0094
0095
0096 parametric_sampling_selector(std::vector<double> * p,
0097 bit_container<parameter_hash_bits> * bin_id,
0098 const std::vector<bool>& sample,
0099 const Random& rnd_gen)
0100 : point_(p), bin_id_(bin_id),
0101 sampled_variables_(sample), rnd_gen_(rnd_gen),
0102 compensate_(false) {}
0103
0104 public:
0105
0106
0107 std::pair<bool,bool> use(cell& parent,
0108 const cell& first_child,
0109 const cell& second_child) const;
0110
0111
0112 bool use(cell& leaf) const;
0113
0114
0115 void compensate (bool doit = true) { compensate_ = doit; }
0116
0117 private:
0118
0119
0120 std::vector<double> * point_;
0121
0122
0123 bit_container<parameter_hash_bits> * bin_id_;
0124
0125
0126 std::vector<bool> sampled_variables_;
0127
0128
0129 Random rnd_gen_;
0130
0131
0132 bool compensate_;
0133
0134 };
0135
0136
0137 struct integral_accessor {
0138
0139
0140 double& set(cell& node) const {
0141 return node.integral();
0142 }
0143
0144
0145 double get(const cell& node, bool) const {
0146 return node.integral();
0147 }
0148
0149 };
0150
0151
0152 struct missing_accessor {
0153
0154
0155 int& set(cell& node) const {
0156 return node.missing_events();
0157 }
0158
0159
0160 int get(const cell& node, bool) const {
0161 return node.missing_events();
0162 }
0163
0164 };
0165
0166
0167
0168 struct parametric_missing_accessor {
0169
0170
0171 parametric_missing_accessor ()
0172 : id_() {}
0173
0174
0175 explicit parametric_missing_accessor (bit_container<parameter_hash_bits>* id)
0176 : id_ (id) {}
0177
0178
0179 int& set(cell& node) const {
0180 return node.missing_events();
0181 }
0182
0183
0184 int get(const cell& node, bool isleaf) const {
0185 if (isleaf)
0186 return node.info().parametric_missing(*id_);
0187 return node.missing_events();
0188 }
0189
0190 private:
0191
0192
0193 bit_container<parameter_hash_bits>* id_;
0194
0195 };
0196
0197 }
0198
0199 #include "selectors.icc"
0200
0201 #endif