1 #ifndef CROMBIE_CUTCONFIG_H 2 #define CROMBIE_CUTCONFIG_H 24 const std::string
cut;
37 : mchistname{mchistname} {}
52 std::string
nminus1(
const std::string& var,
const std::string&
cut);
58 std::ifstream
input {config};
67 std::string
nminus1(
const std::string& var,
const std::string&
cut) {
68 std::regex expr{std::string(
"\\b") + var +
"\\b\\s*[=<>]*\\s*-?[\\d\\.]+"};
69 return std::regex_replace(cut, expr,
"(1)");
76 auto parse_cut = [&sym] (
const std::string&
cut) {
78 return cut.substr(1,
cut.size() - 2);
82 catch(
const std::out_of_range& e) {
83 std::cerr <<
"Exception locating " <<
cut << std::endl;
88 auto current_symbol = symbols::key_type{};
89 auto joiner = symbols::mapped_type{};
91 std::regex expr{
"^([^\\s]*)\\s*([^\\s\\']*)\\s+(.+)$"};
97 if (tokens.size() == 3)
98 tokens.push_back(
"'1.0'");
100 if (tokens.size() != 4)
101 throw std::runtime_error{
"Problem with selection line " + line};
103 config.
selections.emplace(std::make_pair(tokens[1],
105 parse_cut(tokens[2]),
106 parse_cut(tokens[3]),
110 else if (std::regex_search(line, matches, expr)) {
111 if (matches[1].length()) {
112 current_symbol = matches[1];
115 joiner = decltype(joiner)(
" ") + joiner +
" ";
117 sym[current_symbol] += (matches[2].length() ?
"" : joiner) + parse_cut(matches[3]);