I’m trying to devide canvas into P x Q rows and columns,
Into that Canvas I Draw Z Histograms like this (where Z is input variable):
TH1 *h[“Z”];
Char_t *histname = new Char_t[“Z”];
for(Int_t a=1; a<Z+1; a++){
sprintf(histname,“hist%d”,a);
h[a] = new TH1F(histname,histname,100,-3,3);
Later I filled every histogram with other For Loop, but thats not important here…
Now I created two integers P and Q:
Int_t P;
Int_t Q;
Now for certain number of histograms that is determined by input variable Z, this program Divides canvas so it fits good onto screen like this:
if (Z<3)
{
P=1;
Q=2;
}
else if (Z<5)
{
P=2;
Q=2;
}
else if (Z<7)
{
P=2;
Q=3;
}
else if (Z<10)
{
P=3;
Q=3;
}
… //THIS COUNTINUES TILL P=5,Q=5
else
{
cout<<Z<<“too many histograms for canvas”<<endl;
break;
}
Divide->Divide(P,Q);