|
@@ -401,11 +401,8 @@ class CounterMany : public _Counter<std::vector<V>,V>{
|
|
|
|
|
|
class PassCount : public Container<int,bool>{
|
|
|
private:
|
|
|
-
|
|
|
- void _fill(){
|
|
|
- if(this->value->get_value()){
|
|
|
- (*this->container)++;
|
|
|
- }
|
|
|
+ void _fill() {
|
|
|
+ if(this->value->get_value()) (*this->container)++;
|
|
|
}
|
|
|
public:
|
|
|
PassCount(const std::string& name, Value<bool>* value)
|
|
@@ -426,6 +423,61 @@ class PassCount : public Container<int,bool>{
|
|
|
};
|
|
|
|
|
|
|
|
|
+template <typename T>
|
|
|
+class EfficiencyContainer : public Container<TH1F, std::vector<T>>{
|
|
|
+ private:
|
|
|
+ std::function<bool(T)>* selector; // Selects whether object is up for consideration
|
|
|
+ std::function<bool(T)>* predicate; // Says whether the object passes the efficiency criteria
|
|
|
+ std::function<float(T)>* get_val; // Returns a floating point value from the object that is actually
|
|
|
+ // used in the histogram
|
|
|
+ TH1F num;
|
|
|
+ TH1F den;
|
|
|
+ TH1F eff;
|
|
|
+
|
|
|
+ TH1Params params;
|
|
|
+
|
|
|
+ void _fill(){
|
|
|
+ for (auto& obj : this->value->get_value()) {
|
|
|
+ if (selector == nullptr or (*selector)(obj)) {
|
|
|
+ float val = (*get_val)(obj);
|
|
|
+ den.Fill(val);
|
|
|
+ if ((*predicate)(obj)) {
|
|
|
+ num.Fill(val);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public:
|
|
|
+ EfficiencyContainer(const std::string& name, Value<std::vector<T>>* value, TH1Params params,
|
|
|
+ std::function<bool(T)>* selector, std::function<bool(T)>* predicate,
|
|
|
+ std::function<float(T)>* get_val)
|
|
|
+ :Container<TH1F, std::vector<T>>(name, value),
|
|
|
+ num{(name+"_num").c_str(), (name+"_num").c_str(), params.nbins, params.low, params.high},
|
|
|
+ den{(name+"_den").c_str(), (name+"_den").c_str(), params.nbins, params.low, params.high},
|
|
|
+ eff{name.c_str(), name.c_str(), params.nbins, params.low, params.high},
|
|
|
+ selector(selector), predicate(predicate), get_val(get_val), params(params) {
|
|
|
+ num.SetXTitle(params.label_x.c_str()); num.SetYTitle(params.label_y.c_str());
|
|
|
+ den.SetXTitle(params.label_x.c_str()); den.SetYTitle(params.label_y.c_str());
|
|
|
+ eff.SetXTitle(params.label_x.c_str()); eff.SetYTitle(params.label_y.c_str());
|
|
|
+ this->container = &eff;
|
|
|
+ }
|
|
|
+
|
|
|
+ TH1F* get_container() {
|
|
|
+ eff.Sumw2();
|
|
|
+ eff.Divide(&num, &den, 1, 1, "B");
|
|
|
+ return this->container;
|
|
|
+ }
|
|
|
+
|
|
|
+ GenContainer* clone_as(const std::string& new_name){
|
|
|
+ return new EfficiencyContainer<T>(new_name, this->value, this->params, selector, predicate, get_val);
|
|
|
+ }
|
|
|
+
|
|
|
+ void save_as(const std::string& fname, const SaveOption& option = SaveOption::PNG) {
|
|
|
+ util::save_as(this->get_container(), fname, option);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
template <typename... ArgTypes>
|
|
|
class MVA : public Container<TMVA::DataLoader,typename MVAData<ArgTypes...>::type>{
|
|
|
private:
|