Skip to content
Snippets Groups Projects
Commit 46a9799e authored by Danilo Piparo's avatar Danilo Piparo
Browse files

[TDF] Create dataset with TDF

parent d0f4f5c7
No related branches found
No related tags found
No related merge requests found
......@@ -12,22 +12,13 @@
// A simple helper function to fill a test tree: this makes the example
// stand-alone.
void fill_tree(const char *filename, const char *treeName)
void fill_tree(const char *treeName, const char *fileName)
{
TFile f(filename, "RECREATE");
TTree t(treeName, treeName);
float px, py, pz;
t.Branch("px", &px);
t.Branch("py", &py);
t.Branch("pz", &pz);
for (int i = 0; i < 25000; i++) {
gRandom->Rannor(px, py);
pz = px * px + py * py;
t.Fill();
}
t.Write();
f.Close();
return;
ROOT::Experimental::TDataFrame d(25000);
d.Define("px", [](){return gRandom->Gaus();})
.Define("py", [](){return gRandom->Gaus();})
.Define("pz", [](double px, double py){return sqrt(px * px + py * py);}, {"px", "py"})
.Snapshot(treeName, fileName);
}
void tdf003_profiles()
......@@ -35,7 +26,7 @@ void tdf003_profiles()
// We prepare an input tree to run on
auto fileName = "tdf003_profiles.root";
auto treeName = "myTree";
fill_tree(fileName, treeName);
fill_tree(treeName, fileName);
// We read the tree from the file and create a TDataFrame.
ROOT::Experimental::TDataFrame d(treeName, fileName, {"px", "py", "pz"});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment