one possible way is a “function factory” (I haven’t tested the code but it should give you the idea):
auto make_cut(const std::string &sname) {
auto &c = m_cut.find(sname)->second;
return [&c](ints &vadcv, shorts& stripid) {
ints c_vadcv;
for (size_t i = 0; i < vadcv.size(); i++) {
if (vadcv[i]<4095 && vadcv[i] > c.find(stripid[i])->second)
c_vadcv.emplace_back(vadcv[i]);
}
return c_vadcv;
};
}
...
ROOT::RDF::RNode df = dataframe;
for (const auto &str : {"FD0", "FD1", "BD0", "BD1"})
df = df.Define(str + "_adcv", make_cut(str), {str + "_adcvr", str + "_stripidr"})
Another possible idea is to write a small class that takes sname as parameter in its constructor and then in its call operator, operator(), applies the appropriate cut. You can then do e.g. df.Define("FD1_adcv", MyCutEvaluator("FD1"), {"FD0_adcvr", "FD0_stripidr"}).