Usage of RResultPtr: Lifetime management.
This tutorial illustrates how to manage the lifetime of RDataFrame results. When RDataFrame results are declared in functions (or scopes in general), they are destroyed at the end of the scope. To prevent this, one needs to copy the RResultPtr or obtain a copy of its underlying shared_ptr.
#include <random>
#include <vector>
{
std::normal_distribution
gaus{5., 1.};
}, {});
for(int i=0; i<2; i++) {
}
c1 =
new TCanvas(
"c1",
"THStack without obtaining a shared_ptr (wrong)");
std::vector<std::shared_ptr<TH1D>>
results;
for(int i=0; i<2; i++) {
}
c2 =
new TCanvas(
"c2",
"Drawing with obtaining a shared_ptr (right)");
}
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 ,...
The Histogram stack class.
A struct which stores the parameters of a TH1D.
- Date
- 2025
- Author
- Stephan Hageboeck (CERN)
Definition in file df040_RResultPtr_lifetimeManagement.C.