29 constexpr static auto fMainFile{
"df037_TTreeEventMatching_C_main.root"};
30 constexpr static auto fAuxFile1{
"df037_TTreeEventMatching_C_aux_1.root"};
31 constexpr static auto fAuxFile2{
"df037_TTreeEventMatching_C_aux_2.root"};
32 constexpr static auto fMainTreeName{
"events"};
33 constexpr static auto fAuxTreeName1{
"auxdata_1"};
34 constexpr static auto fAuxTreeName2{
"auxdata_2"};
39 TFile f(fMainFile,
"RECREATE");
40 TTree mainTree(fMainTreeName, fMainTreeName);
43 mainTree.Branch(
"idx", &idx,
"idx/I");
44 mainTree.Branch(
"x", &
x,
"x/I");
60 TFile f(fAuxFile1,
"RECREATE");
61 TTree auxTree(fAuxTreeName1, fAuxTreeName1);
64 auxTree.Branch(
"idx", &idx,
"idx/I");
65 auxTree.Branch(
"y", &
y,
"y/I");
78 TFile f(fAuxFile2,
"RECREATE");
79 TTree auxTree(fAuxTreeName2, fAuxTreeName2);
82 auxTree.Branch(
"idx", &idx,
"idx/I");
83 auxTree.Branch(
"z", &z,
"z/I");
98 std::remove(fMainFile);
99 std::remove(fAuxFile1);
100 std::remove(fAuxFile2);
114 mainChain.Add(
dataset.fMainFile);
117 auxChain1.Add(
dataset.fAuxFile1);
118 auxChain1.BuildIndex(
"idx");
121 auxChain2.Add(
dataset.fAuxFile2);
122 auxChain2.BuildIndex(
"idx");
124 mainChain.AddFriend(&auxChain1);
125 mainChain.AddFriend(&auxChain2);
132 const std::string auxTree1ColIdx = std::string(
dataset.fAuxTreeName1) +
".idx";
133 const std::string auxTree1ColY = std::string(
dataset.fAuxTreeName1) +
".y";
134 const std::string auxTree2ColIdx = std::string(
dataset.fAuxTreeName2) +
".idx";
135 const std::string auxTree2ColZ = std::string(
dataset.fAuxTreeName2) +
".z";
137 constexpr static auto defaultValue = std::numeric_limits<int>::min();
141 auto display1 = df.DefaultValueFor(auxTree1ColIdx, defaultValue)
142 .DefaultValueFor(auxTree1ColY, defaultValue)
143 .DefaultValueFor(auxTree2ColIdx, defaultValue)
144 .DefaultValueFor(auxTree2ColZ, defaultValue)
146 {
"idx", auxTree1ColIdx, auxTree2ColIdx,
"x", auxTree1ColY, auxTree2ColZ});
151 auto display2 = df.DefaultValueFor(auxTree2ColIdx, defaultValue)
152 .DefaultValueFor(auxTree2ColZ, defaultValue)
153 .FilterAvailable(auxTree1ColY)
155 {
"idx", auxTree1ColIdx, auxTree2ColIdx,
"x", auxTree1ColY, auxTree2ColZ});
159 auto display3 = df.FilterMissing(auxTree1ColIdx).Display<
int,
int>({
"idx",
"x"});
161 std::cout <<
"Example 1: provide default values for all columns\n";
163 std::cout <<
"Example 2: skip the entry only when the first auxiliary tree does not match\n";
165 std::cout <<
"Example 3: keep entries from the main tree for which there is no match in the auxiliary tree\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.
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.