This example shows processing of a TTree-based dataset with horizontal concatenations (friends) and event matching (based on TTreeIndex). In case the current event being processed does not match one (or more) of the friend datasets, one can use the FilterAvailable and DefaultValueFor functionalities to act upon the situation.
#include <iostream>
#include <numeric>
constexpr static auto fMainFile{
"df037_TTreeEventMatching_C_main.root"};
constexpr static auto fAuxFile1{
"df037_TTreeEventMatching_C_aux_1.root"};
constexpr static auto fAuxFile2{
"df037_TTreeEventMatching_C_aux_2.root"};
{
{
int idx;
idx = 1;
idx = 2;
idx = 3;
}
{
int idx;
auxTree.Branch(
"idx", &idx,
"idx/I");
idx = 1;
idx = 2;
}
{
int z;
int idx;
auxTree.Branch(
"idx", &idx,
"idx/I");
idx = 1;
z = 6;
idx = 3;
z = 7;
}
}
{
}
};
{
constexpr static auto defaultValue = std::numeric_limits<int>::min();
std::cout << "Example 1: provide default values for all columns\n";
std::cout << "Example 2: skip the entry only when the first auxiliary tree does not match\n";
std::cout << "Example 3: keep entries from the main tree for which there is no match in the auxiliary tree\n";
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
A chain is a collection of files containing TTree objects.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
A TTree represents a columnar dataset.
Example 1: provide default values for all columns
+-----+-----+---------------+---------------+---+-------------+-------------+
| Row | idx | auxdata_1.idx | auxdata_2.idx | x | auxdata_1.y | auxdata_2.z |
+-----+-----+---------------+---------------+---+-------------+-------------+
| 0 | 1 | 1 | 1 | 1 | 4 | 6 |
+-----+-----+---------------+---------------+---+-------------+-------------+
| 1 | 2 | 2 | -2147483648 | 2 | 5 | -2147483648 |
+-----+-----+---------------+---------------+---+-------------+-------------+
| 2 | 3 | -2147483648 | 3 | 3 | -2147483648 | 7 |
+-----+-----+---------------+---------------+---+-------------+-------------+
Example 2: skip the entry only when the first auxiliary tree does not match
+-----+-----+---------------+---------------+---+-------------+-------------+
| Row | idx | auxdata_1.idx | auxdata_2.idx | x | auxdata_1.y | auxdata_2.z |
+-----+-----+---------------+---------------+---+-------------+-------------+
| 0 | 1 | 1 | 1 | 1 | 4 | 6 |
+-----+-----+---------------+---------------+---+-------------+-------------+
| 1 | 2 | 2 | -2147483648 | 2 | 5 | -2147483648 |
+-----+-----+---------------+---------------+---+-------------+-------------+
Example 3: keep entries from the main tree for which there is no match in the auxiliary tree
+-----+-----+---+
| Row | idx | x |
+-----+-----+---+
| 2 | 3 | 3 |
+-----+-----+---+