Hello rooters,
beginner here.
My problem is: I have a root file with many histograms in it. Each histogram is called the same, but has diiferent row and column numbers: Energy_column_0_row_0, Energy_column_1_row_1, Energy_column_0_row_1 etc… there are 20 columns and 13 rows in total.
I am trying to make a loop to read all the histograms from file and save them with corresponding row and column numbers.
How can I loop over the names so it stores histogram Energy_column_0_row_1 to h_old_0_1 , etc??
So far I have this, but it doesn’t work for me, because later, when I want to call h_old[column][row] it gives me error: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
TFile* Energy = new TFile("Energy.root");
TH1D* h_old[19][12];
for (int row=0;row<13;row++)
{
for (int column=0; column<20; column++)
{
ss << "Energy_column_" << column << "_row_" << row;
name = ss.str();
h_old[column][row] = (TH1D*)Energy->Get(name.c_str());
}
}
I hope it is clear, what I am trying to do.
Thanks,
J.