26 constexpr static std::array<const char *, 3> fFileNames{
"df036_missingBranches_C_file_1.root",
27 "df036_missingBranches_C_file_2.root",
28 "df036_missingBranches_C_file_3.root"};
29 constexpr static std::array<const char *, 3> fTreeNames{
"tree_1",
"tree_2",
"tree_3"};
30 constexpr static auto fTreeEntries{5};
35 TFile f(fFileNames[0],
"RECREATE");
36 TTree t(fTreeNames[0], fTreeNames[0]);
39 t.Branch(
"x", &
x,
"x/I");
40 t.Branch(
"y", &
y,
"y/I");
41 for (
int i = 1; i <= fTreeEntries; i++) {
51 TFile f(fFileNames[1],
"RECREATE");
52 TTree t(fTreeNames[1], fTreeNames[1]);
54 t.Branch(
"y", &
y,
"y/I");
55 for (
int i = 1; i <= fTreeEntries; i++) {
64 TFile f(fFileNames[2],
"RECREATE");
65 TTree t(fTreeNames[2], fTreeNames[2]);
67 t.Branch(
"x", &
x,
"x/I");
68 for (
int i = 1; i <= fTreeEntries; i++) {
79 for (
auto &&fileName : fFileNames)
80 std::remove(fileName);
94 for (
auto i = 0; i < trees.fFileNames.size(); i++) {
95 const auto fullPath = std::string(trees.fFileNames[i]) +
"?#" + trees.fTreeNames[i];
96 c.
Add(fullPath.c_str());
101 constexpr static auto defaultValue = std::numeric_limits<int>::min();
104 auto display1 = df.DefaultValueFor(
"x", defaultValue)
105 .DefaultValueFor(
"y", defaultValue)
106 .Display<
int,
int>({
"x",
"y"}, 15);
111 df.DefaultValueFor(
"y", defaultValue).FilterAvailable(
"x").Display<
int,
int>({
"x",
"y"}, 15);
114 auto display3 = df.FilterMissing(
"y").Display<
int>({
"x"}, 15);
116 std::cout <<
"Example 1: provide a default value for all missing branches\n";
119 std::cout <<
"Example 2: provide a default value for branch y, but skip events where branch x is missing\n";
122 std::cout <<
"Example 3: only keep events where branch y is missing and display values for branch x\n";
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.
virtual Int_t Add(TChain *chain)
Add all files referenced by the passed chain to this chain.
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.