[ROOT] Divide canvas

From: Vu Anh Tuan (vuanh@lal.in2p3.fr)
Date: Tue Jan 07 2003 - 20:11:53 MET


Hi,

It's formidable to begin a new year with this bug, but it's still a bug
for me and I need your help to root it out.

In short, I want to make small macro with a list of histograms (say 4),
create a canvas with the same number (4 then) of subpads and draw each
histogram into a subpad (1st histo in 1st subpad, 2nd histo in 2nd
pad, so on..). Actually it's supposed to do more than that, but I
describe here only the necessary things.

Here is the main relevant lines:

void fillCanvas(const TString &canvasName,
		const TString *inputHistos, const int &numberOfHistos)
{
  const int maxNumber = 10;

  TH1F *histo[maxNumber]; // numberOfHistos is about 4 in reality

  TCanvas c1;

  if (numberOfHistos == 2)
    c1.Divide(2,1);
  if (numberOfHistos == 3)
    c1.Divide(2,2);
  if (numberOfHistos == 4)
    c1.Divide(2.2);

  for (int hidx = 0; hidx < numberOfHistos; hidx++)
	{
	  // Read some root file and take the histogram out one by one

	  c1.cd(hidx);
	  // Then set color to each histo
	  // and draw
	  histo[hidx]->Draw();
	}//end of loop over histos

  c1.Print(canvasName);
  c1.Close();
}//end of function fillCanvas

It doesn't work well since the final gif file contains only on undivided
image, and only the last histogram is printed, no trace of the previous
one.

So where's the bug?

Thanks and Happy New Year anyhow,

Tuan



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:08 MET