Generate TH2D histograms using dat files

I would like to know how to write the coordinates of the points I want to plot to a dat file in advance and use that file to generate a graph in TH2D.
In the case of tgraph2d, I can plot the points written to the dat file with the following macro, but I could not do it with TH2D.

auto g = new TGraph2D("exm.dat");

Hi @mai1, welcome back to the forum!

Such .dat files are like .csv files, and you can import them to ROOTs RDataFrame with the FromCSV() method as described in this tutorial.

Once you have the RDataFrame, you can use RDataFrame::Histo2D() to generate the TH2D histograms.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.