CombineHarvester
CombineHarvester_Filters.cc
Go to the documentation of this file.
2 #include <vector>
3 #include <string>
4 #include <utility>
5 #include <set>
10 
11 namespace ch {
12 
14  std::vector<std::string> const& vec, bool cond) {
15  if (GetFlag("filters-use-regex")) {
16  FilterContainingRgx(procs_, vec, std::mem_fn(&Process::bin), cond);
17  FilterContainingRgx(obs_, vec, std::mem_fn(&Observation::bin), cond);
18  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::bin), cond);
19  } else {
20  FilterContaining(procs_, vec, std::mem_fn(&Process::bin), cond);
21  FilterContaining(obs_, vec, std::mem_fn(&Observation::bin), cond);
22  FilterContaining(systs_, vec, std::mem_fn(&Systematic::bin), cond);
23  }
24  return *this;
25 }
26 
28  std::vector<int> const& vec, bool cond) {
29  FilterContaining(procs_, vec, std::mem_fn(&Process::bin_id), cond);
30  FilterContaining(obs_, vec, std::mem_fn(&Observation::bin_id), cond);
31  FilterContaining(systs_, vec, std::mem_fn(&Systematic::bin_id), cond);
32  return *this;
33 }
34 
36  std::vector<std::string> const& vec, bool cond) {
37  if (GetFlag("filters-use-regex")) {
38  FilterContainingRgx(procs_, vec, std::mem_fn(&Process::process), cond);
39  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::process), cond);
40  } else {
41  FilterContaining(procs_, vec, std::mem_fn(&Process::process), cond);
42  FilterContaining(systs_, vec, std::mem_fn(&Systematic::process), cond);
43  }
44 
45  return *this;
46 }
47 
49  std::vector<std::string> const& vec, bool cond) {
50  FilterContainingRgx(procs_, vec, std::mem_fn(&Process::process), cond);
51  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::process), cond);
52  return *this;
53 }
54 
56  std::vector<std::string> const& vec, bool cond) {
57  if (GetFlag("filters-use-regex")) {
58  FilterContainingRgx(procs_, vec, std::mem_fn(&Process::analysis), cond);
59  FilterContainingRgx(obs_, vec, std::mem_fn(&Observation::analysis), cond);
60  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::analysis), cond);
61  } else {
62  FilterContaining(procs_, vec, std::mem_fn(&Process::analysis), cond);
63  FilterContaining(obs_, vec, std::mem_fn(&Observation::analysis), cond);
64  FilterContaining(systs_, vec, std::mem_fn(&Systematic::analysis), cond);
65  }
66  return *this;
67 }
68 
70  std::vector<std::string> const& vec, bool cond) {
71  if (GetFlag("filters-use-regex")) {
72  FilterContainingRgx(procs_, vec, std::mem_fn(&Process::era), cond);
73  FilterContainingRgx(obs_, vec, std::mem_fn(&Observation::era), cond);
74  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::era), cond);
75  } else {
76  FilterContaining(procs_, vec, std::mem_fn(&Process::era), cond);
77  FilterContaining(obs_, vec, std::mem_fn(&Observation::era), cond);
78  FilterContaining(systs_, vec, std::mem_fn(&Systematic::era), cond);
79  }
80  return *this;
81 }
82 
84  std::vector<std::string> const& vec, bool cond) {
85  if (GetFlag("filters-use-regex")) {
86  FilterContainingRgx(procs_, vec, std::mem_fn(&Process::channel), cond);
87  FilterContainingRgx(obs_, vec, std::mem_fn(&Observation::channel), cond);
88  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::channel), cond);
89  } else {
90  FilterContaining(procs_, vec, std::mem_fn(&Process::channel), cond);
91  FilterContaining(obs_, vec, std::mem_fn(&Observation::channel), cond);
92  FilterContaining(systs_, vec, std::mem_fn(&Systematic::channel), cond);
93  }
94  return *this;
95 }
96 
98  std::vector<std::string> const& vec, bool cond) {
99  if (GetFlag("filters-use-regex")) {
100  FilterContainingRgx(procs_, vec, std::mem_fn(&Process::mass), cond);
101  FilterContainingRgx(obs_, vec, std::mem_fn(&Observation::mass), cond);
102  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::mass), cond);
103  } else {
104  FilterContaining(procs_, vec, std::mem_fn(&Process::mass), cond);
105  FilterContaining(obs_, vec, std::mem_fn(&Observation::mass), cond);
106  FilterContaining(systs_, vec, std::mem_fn(&Systematic::mass), cond);
107  }
108  return *this;
109 }
110 
112  std::vector<std::string> const& vec, std::string attr_label, bool cond) {
113  if (GetFlag("filters-use-regex")) {
114  FilterContainingRgx(procs_, vec, std::mem_fn(&Process::attribute), attr_label, cond);
115  FilterContainingRgx(obs_, vec, std::mem_fn(&Observation::attribute), attr_label, cond);
116  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::attribute), attr_label, cond);
117  } else {
118  FilterContaining(procs_, vec, std::mem_fn(&Process::attribute), attr_label, cond);
119  FilterContaining(obs_, vec, std::mem_fn(&Observation::attribute), attr_label, cond);
120  FilterContaining(systs_, vec, std::mem_fn(&Systematic::attribute), attr_label, cond);
121  }
122  return *this;
123 }
124 
125 
127  std::vector<std::string> const& vec, bool cond) {
128  if (GetFlag("filters-use-regex")) {
129  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::name), cond);
130  } else {
131  FilterContaining(systs_, vec, std::mem_fn(&Systematic::name), cond);
132  }
133  return *this;
134 }
135 
137  std::vector<std::string> const& vec, bool cond) {
138  if (GetFlag("filters-use-regex")) {
139  FilterContainingRgx(systs_, vec, std::mem_fn(&Systematic::type), cond);
140  } else {
141  FilterContaining(systs_, vec, std::mem_fn(&Systematic::type), cond);
142  }
143  return *this;
144 }
145 
147  ch::erase_if(systs_, [&] (std::shared_ptr<Systematic> val) {
148  return !val->signal();
149  });
150  ch::erase_if(procs_, [&] (std::shared_ptr<Process> val) {
151  return !val->signal();
152  });
153  return *this;
154 }
155 
157  ch::erase_if(systs_, [&] (std::shared_ptr<Systematic> val) {
158  return val->signal();
159  });
160  ch::erase_if(procs_, [&] (std::shared_ptr<Process> val) {
161  return val->signal();
162  });
163  return *this;
164 }
165 
167  ch::erase_if(obs_, [&] (std::shared_ptr<Observation> val) {
168  return val->shape() == nullptr;
169  });
170  ch::erase_if(procs_, [&] (std::shared_ptr<Process> val) {
171  return val->shape() == nullptr;
172  });
173  return *this;
174 }
175 
177  ch::erase_if(procs_, [&] (std::shared_ptr<Process> val) {
178  return val->pdf() == nullptr;
179  });
180  return *this;
181 }
182 
184  ch::erase_if(obs_, [&] (std::shared_ptr<Observation> val) {
185  return val->data() == nullptr;
186  });
187  return *this;
188 }
189 
190 std::set<std::string> CombineHarvester::bin_set() {
191  std::set<std::string> result =
192  this->SetFromObs(std::mem_fn(&ch::Observation::bin));
193  std::set<std::string> result2 =
194  this->SetFromProcs(std::mem_fn(&ch::Process::bin));
195  std::set<std::string> result3 =
196  this->SetFromSysts(std::mem_fn(&ch::Systematic::bin));
197  result.insert(result2.begin(), result2.end());
198  result.insert(result3.begin(), result3.end());
199  return result;
200 }
201 
203  std::set<int> result =
204  this->SetFromObs(std::mem_fn(&ch::Observation::bin_id));
205  std::set<int> result2 =
206  this->SetFromProcs(std::mem_fn(&ch::Process::bin_id));
207  std::set<int> result3 =
208  this->SetFromSysts(std::mem_fn(&ch::Systematic::bin_id));
209  result.insert(result2.begin(), result2.end());
210  result.insert(result3.begin(), result3.end());
211  return result;
212 }
213 
214 std::set<std::string> CombineHarvester::process_set() {
215  std::set<std::string> result = this->SetFromProcs(
216  std::mem_fn(&ch::Process::process));
217  std::set<std::string> result2 = this->SetFromSysts(
218  std::mem_fn(&ch::Systematic::process));
219  result.insert(result2.begin(), result2.end());
220  return result;
221 }
222 
223 std::set<std::string> CombineHarvester::analysis_set() {
224  std::set<std::string> result = this->SetFromObs(
225  std::mem_fn(&ch::Observation::analysis));
226  std::set<std::string> result2 = this->SetFromProcs(
227  std::mem_fn(&ch::Process::analysis));
228  std::set<std::string> result3 = this->SetFromSysts(
229  std::mem_fn(&ch::Systematic::analysis));
230  result.insert(result2.begin(), result2.end());
231  result.insert(result3.begin(), result3.end());
232  return result;
233 }
234 
235 std::set<std::string> CombineHarvester::era_set() {
236  std::set<std::string> result =
237  this->SetFromObs(std::mem_fn(&ch::Observation::era));
238  std::set<std::string> result2 =
239  this->SetFromProcs(std::mem_fn(&ch::Process::era));
240  std::set<std::string> result3 =
241  this->SetFromSysts(std::mem_fn(&ch::Systematic::era));
242  result.insert(result2.begin(), result2.end());
243  result.insert(result3.begin(), result3.end());
244  return result;
245 }
246 
247 std::set<std::string> CombineHarvester::channel_set() {
248  std::set<std::string> result = this->SetFromObs(
249  std::mem_fn(&ch::Observation::channel));
250  std::set<std::string> result2 = this->SetFromProcs(
251  std::mem_fn(&ch::Process::channel));
252  std::set<std::string> result3 = this->SetFromSysts(
253  std::mem_fn(&ch::Systematic::channel));
254  result.insert(result2.begin(), result2.end());
255  result.insert(result3.begin(), result3.end());
256  return result;
257 }
258 
259 std::set<std::string> CombineHarvester::mass_set() {
260  std::set<std::string> result = this->SetFromObs(
261  std::mem_fn(&ch::Observation::mass));
262  std::set<std::string> result2 = this->SetFromProcs(
263  std::mem_fn(&ch::Process::mass));
264  std::set<std::string> result3 = this->SetFromSysts(
265  std::mem_fn(&ch::Systematic::mass));
266  result.insert(result2.begin(), result2.end());
267  result.insert(result3.begin(), result3.end());
268  return result;
269 }
270 
271 std::set<std::string> CombineHarvester::syst_name_set() {
272  std::set<std::string> result = this->SetFromSysts(
273  std::mem_fn(&ch::Systematic::name));
274  return result;
275 }
276 
277 std::set<std::string> CombineHarvester::syst_type_set() {
278  std::set<std::string> result = this->SetFromSysts(
279  std::mem_fn(&ch::Systematic::type));
280  return result;
281 }
282 }
CombineHarvester & process_rgx(std::vector< std::string > const &vec, bool cond=true)
CombineHarvester & bin_id(std::vector< int > const &vec, bool cond=true)
CombineHarvester & backgrounds()
CombineHarvester & signals()
CombineHarvester & mass(std::vector< std::string > const &vec, bool cond=true)
CombineHarvester & process(std::vector< std::string > const &vec, bool cond=true)
std::set< R > SetFromObs(T func)
Fill an std::set using only the Observation entries.
CombineHarvester & era(std::vector< std::string > const &vec, bool cond=true)
std::set< std::string > process_set()
CombineHarvester & attr(std::vector< std::string > const &vec, std::string attr_label, bool cond=true)
CombineHarvester & analysis(std::vector< std::string > const &vec, bool cond=true)
std::set< R > SetFromSysts(T func)
Fill an std::set using only the Systematic entries.
std::set< std::string > syst_type_set()
std::set< R > SetFromProcs(T func)
Fill an std::set using only the Process entries.
CombineHarvester & bin(std::vector< std::string > const &vec, bool cond=true)
std::set< std::string > mass_set()
std::set< std::string > bin_set()
CombineHarvester & syst_name(std::vector< std::string > const &vec, bool cond=true)
bool GetFlag(std::string const &flag) const
std::set< std::string > era_set()
std::set< std::string > channel_set()
CombineHarvester & histograms()
std::set< std::string > syst_name_set()
std::set< std::string > analysis_set()
CombineHarvester & channel(std::vector< std::string > const &vec, bool cond=true)
CombineHarvester & syst_type(std::vector< std::string > const &vec, bool cond=true)
virtual std::string const attribute(std::string const &attr_label) const
Definition: Object.h:44
virtual std::string const & process() const
Definition: Object.h:20
virtual std::string const & bin() const
Definition: Object.h:17
virtual int bin_id() const
Definition: Object.h:35
virtual std::string const & analysis() const
Definition: Object.h:26
virtual std::string const & era() const
Definition: Object.h:29
virtual std::string const & mass() const
Definition: Object.h:38
virtual std::string const & channel() const
Definition: Object.h:32
std::string const & type() const
Definition: Systematic.h:25
std::string const & name() const
Definition: Systematic.h:22
Definition: Algorithm.h:10
void FilterContainingRgx(Input &in, Filter const &filter, Converter fn, bool cond)
Definition: Algorithm.h:49
void FilterContaining(Input &in, Filter const &filter, Converter fn, bool cond)
Definition: Algorithm.h:41
void erase_if(Range &r, Predicate p)
Definition: Algorithm.h:12