Dear ROOTers,

I am trying to fit sliced TH2D graphs. I have something like this,

```
// 4 systems
TH2D** ratioTH2D;
// 16 TH2D each 10x16 bins
ratioTH2D = new TH2D*[15];
// my fitting function
TF1 *fit1 = new TF1("fit1", "pol1");
// object with all the slices
TObjArray aSlices;
// several canvas
TCanvas* canv_fit[4];
for(j=0;j<4;j++){
for(i=0;i<16;i++){
//for the title of the graphs
sprintf(tempj, "b1_test %d", j);
canv_fit[j] = new TCanvas(tempj,tempj);
canv_fit[j]->Divide(4,4);
canv_fit[j]->cd(i+1);
// for the sake of simplycity i try just one graph
ratioTH2D[i]->FitSlicesY(fit1, 0, -1, 0, "R", &aSlices); //NOT silent, to see the output in console
aSlices.Draw();
}
}
canv_fit[j]->Write();
```

This is obvioulsy a pseudo code.

I get 16 fittings in the console, not the 4x16x16=6464 that I would have expected (4 sets of 16 graphs each with x-axis binning of 16, therefore 16 y slices to be fitted linearly).

At the end in my root file (tree), there are 16 chi-square distributions plotted, most of them with no data displayed.

If I call a specific TH2D graph (perhaps `ratioTH2D[14]`

), `FitSlicesY`

is fitting just the first element in the array, i.e. `ratioTH2D[0]`

with 16 console outputs.

Could someone explain to me where is the error or suggesting a strategy to store and plot all these fitted slices?

LG,

Giammarco

*ROOT Version:* 5.36/34

*Platform:* Windows 10

*Compiler:* VS2015