when I run it, what it returns me is an empty Canvas.
I guess the error is silly, as if I type the same commands from the terminal, the histogram appears.
My difficulty, however, is to go and redefine the TH1D using the command:
TH1D* hist = new TH1D("hist","histogram",bin,min,max);
I’ll show you the simplest example of the construct.
ROOT::EnableImplicitMT(); // Tell ROOT you want to go parallel
ROOT::RDataFrame d("myTree", "file_*.root"); // Interface to TTree and TChain
auto myHisto = d.Histo1D("Branch_A"); // This happens in parallel!
myHisto->Draw();
The histogram is defined on the third line.
I tried to redefine it and then put it equal to “d.Histo1D (” Branch_A “);” but it does not work.
How would you do it?
About the blank canvas, the problem is that the histogram goes out of scope and “dies” before the canvas is displayed, you can use DrawClone() instead of Draw() to draw a copy of the histogram that ROOT will own, or keep myHisto around in some other way.
About specifying name, title and binning for the histogram, take a look at the RDF tutorials, you can do it so: Histo1D({"hist", "histogram", bin, min, max}, "Branch_A").