Try something like this: TH2D *h = (TH2D *)gROOT->FindObject("Radiance_31"); // gROOT or gDirectory
delete h; // delete the old histogram (if found)
h = new TH2D("Radiance_31", "Radiance 31", ...); // create the new one
Remove “gROOT->Reset();” completely.
What are the definitions of “legend”, “buffer”, “Radiance_31”, “Radiance”, “Days”, “Latitudes”?
Try: / ...
TCanvas *c1 = (TCanvas *)gROOT->GetListOfCanvases()->FindObject("c1");
delete c1;
c1 = new TCanvas("c1");
// ...
TH2D *Histo_Rad31 = (TH2D *)gROOT->FindObject("Radiance_31");
delete Histo_Rad31;
Histo_Rad31 = new TH2D("Radiance_31", buffer, num_days, 1., 365., num_latitudes, -90., 90.);
// ... BTW. Apparently you create a histogram with the “Radiance_31” name but you also have a two-dimensional array “Radiance_31”.
It seems the problems was exactly that: I named both the histogram and the array with the same name
For your information. I’m defining a space optical system, and for that I need to define the radiance for a given latitude, local time and day of the year.
The legend and buffer variables are set when I choose a particular local time, and then I fill a 2D Histogram with the latitude, day of the year and radiance.
Thank you again! Next time I’ll be more careful when naming variables.