there are a few ways in which you can “compute quantities between entries”, which one is simpler in your case depends on the actual use case.
For example in a case where you know you have no Filters and, for simplicity, you process all entries in the same thread, you can calculate, for each event, the difference between x[entry] and x[entry - 1] with a stateful Define helper:
#include <ROOT/RDataFrame.hxx>
struct DiffEvaluator {
int prevX = -1;
int operator()(int x) {
if (prevX == -1) {
prevX = x;
return 999; // do something special if there was no "previous x"
}
const int diff = x - prevX;
prevX = x;
return diff;
}
};
void foo() {
auto df = ROOT::RDataFrame(10).Define("x", "int(rdfentry_)");
auto h = df.Define("xdiff", DiffEvaluator(), {"x"})
.Filter("xdiff != 999")
.Histo1D("xdiff");
h->DrawClone();
}
I hope this gives you the idea: you can inject any arbitrary logic in RDF, so you can do pretty much what you want as part of the loop. With multi-threading activated you’ll have to have a different state for each “slot” (in this case a different “prevX” for each processing slot), see also DefineSlot.