TCanvases not dividing in running script

Greetings all,

I am trying to plot histograms from 20 root files in five TCanvases (with each TCanvas divided into four).

The all 20 files are opened correctly but the TCanvases fail to divide and I end up displaying only one histogram on each canvas.

for (i=0;i<PE_tally;i++){ PC[i] = new TCanvas(Form("PC%d",i+1),Form("Fitting canvas - %d",i+1),10,10,1000,705); PC[i]->Divide(1,4); //This divide is not happening for (j=0;j<GE_tally;j++){ PC[i]->cd(j); f[i][j] = TFile::Open( Pf[i][j].Data(), "READ" ); h[i][j]= (TH1*)f[i][j]->FindObjectAny(Ph[i][j].Data()); h[i][j]->Draw(); } }

A short code snippet is given above and I have attached a running script and a zip file containing 20 small root files that illustrate the problem.

Any guidance on where I am going wrong will be greatly appreciated.
TestScript.C (1.77 KB) (160 KB)


PC[i]->cd(j); to

PC[i]->cd(j+1); ->cd(0) moves to the canvas itself


Thank you Rene,

I get caught by zero subscripts so often, it should have been so obvious, sorry I missed it.

Thank you for your patience.