4#ifndef ANALYSISTREE_SIMPLECUT_H
5#define ANALYSISTREE_SIMPLECUT_H
13#include "Constants.hpp"
15#include "Variable.hpp"
37 SimpleCut(std::vector<std::string> vars, std::function<
bool(std::vector<double>&)> lambda, std::string title =
"") : title_(std::move(title)),
39 std::transform(vars.begin(), vars.end(),
40 std::back_inserter(vars_),
41 [](
const std::string& arg_name) { return Variable::FromString(arg_name); });
52 friend SimpleCut RangeCut(
const std::string& variable_name,
double lo,
double hi,
const std::string& title);
59 friend SimpleCut EqualsCut(
const std::string& variable_name,
int value,
const std::string& title);
83 bool Apply(
const T&
object)
const {
84 std::vector<double> variables;
85 variables.reserve(vars_.size());
86 for (
const auto& var : vars_) {
87 variables.emplace_back(var.GetValue(
object));
92 bool Apply(std::vector<const BranchChannel*>& bch, std::vector<size_t>&
id)
const;
97 std::vector<Variable>& Variables() {
return vars_; }
98 ANALYSISTREE_ATTR_NODISCARD
const std::vector<Variable>& GetVariables()
const {
return vars_; }
99 ANALYSISTREE_ATTR_NODISCARD
const std::set<std::string>& GetBranches()
const {
return branch_names_; }
101 friend bool operator==(
const SimpleCut& that,
const SimpleCut& other);
104 SimpleCut(
const Variable& var,
double min,
double max, std::string title =
"");
105 SimpleCut(
const Variable& var,
int value, std::string title =
"");
107 void FillBranchNames();
110 std::vector<Variable> vars_{};
111 std::set<std::string> branch_names_{};
112 std::function<bool(std::vector<double>&)>
lambda_;
116SimpleCut RangeCut(
const std::string& variable_name,
double lo,
double hi,
const std::string& title =
"");
117SimpleCut EqualsCut(
const std::string& variable_name,
int value,
const std::string& title =
"");
Definition BranchChannel.hpp:19
SimpleCut keeps predicate (lambda function with vector of arguments) and list of Variables.
Definition SimpleCut.hpp:22
SimpleCut(std::vector< std::string > vars, std::function< bool(std::vector< double > &)> lambda, std::string title="")
Definition SimpleCut.hpp:37
std::function< bool(std::vector< double > &)> lambda_
function used to evaluate the cut.
Definition SimpleCut.hpp:112
friend SimpleCut RangeCut(const std::string &variable_name, double lo, double hi, const std::string &title)
Definition SimpleCut.cpp:28
bool Apply(const T &object) const
Evaluates cut.
Definition SimpleCut.hpp:83
friend SimpleCut EqualsCut(const std::string &variable_name, int value, const std::string &title)
Definition SimpleCut.cpp:32
Variable is a wrapper object for Field. In contrary to Field Variable is not bound to the data....
Definition Variable.hpp:23
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition BranchConfig.cpp:10
SimpleCut EqualsCut(const std::string &variable_name, int value, const std::string &title)
Definition SimpleCut.cpp:32
SimpleCut RangeCut(const std::string &variable_name, double lo, double hi, const std::string &title)
Definition SimpleCut.cpp:28