Use the Aggregate action to specify arbitrary data aggregations.
This tutorial shows how to use the Aggregate action to evaluate the product of all the elements of a column. This operation may be performed using a Reduce action, however aggregate is used for the sake of the tutorial
void df023_aggregate()
{
const std::string columnName = "x";
auto d = rdf.Define(columnName,
"rdfentry_ + 1.");
auto aggregator = [](
double acc,
double x) {
return acc *
x; };
auto merger = [](std::vector<double> &accumulators) {
auto size = accumulators.size();
for (
int i = 1; i <
size; ++i) {
accumulators[0] *= accumulators[i];
}
};
double initValue = 1.;
auto result =
d.Aggregate(aggregator, merger, columnName, initValue);
std::cout << *result << std::endl;
}
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT's RDataFrame offers a high level interface for analyses of data stored in TTree,...
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
- Date
- July 2018
- Authors
- Enrico Guiraud, Danilo Piparo (CERN), Massimo Tumolo (Politecnico di Torino)
Definition in file df023_aggregate.C.