Canvas, pads and subpads

I am trying to divide pads to produce sub-pads in a single canvas.

void ksdjv() {

      //canvas creation
	Int_t w = 2000;
	Int_t h = 2000;	
	TCanvas *c1 = new TCanvas("c1","PICASSO Vertical Point Spread Function",w,h);
	c1->SetWindowSize( w+(w-c1->GetWw()), h+(h-c1->GetWh()) );
	c1->Divide(2,1);

        c1->cd(1);
   
        c1->cd(1);	gPad->cd(1);	//enter the first pad
	     gPad->Divide(2,2);
       //enter the 4 sub-pads and do stuff .  How do I enter this part?

       
        c1->cd(2);	gPad->cd(2);	//enter the second pad
	     gPad->Divide(2,2);
       //enter the 4 sub-pads and do stuff. How do I enter this part?
        .....   

       c1->cd(2);	gPad->cd(1);	
	   //do stuff
 return;
}

[code]#include <TCanvas.h>
#include <TVirtualPad.h>
#include <TText.h>

void ksdjv(void)
{
// canvas creation
Int_t w = 800;
Int_t h = 400;
TCanvas *c1 = new TCanvas(“c1”, “c1”, w, h);
c1->SetWindowSize( w+(w-c1->GetWw()), h+(h-c1->GetWh()) );
c1->Divide(2, 1); // … or … gPad->Divide(2, 1);

TVirtualPad *c1_1 = c1->cd(1); // enter the first pad
gPad->Divide(2, 2); // … or … c1_1->Divide(2, 2);
// enter the 4 sub-pads and do stuff
c1_1->cd(1); // … or … (c1->cd(1))->cd(1);
(new TText(0.1, 0.5, “c1 … 1 … 1”))->Draw(); gPad->Update();
c1_1->cd(2); // … or … (c1->cd(1))->cd(2);
(new TText(0.1, 0.5, “c1 … 1 … 2”))->Draw(); gPad->Update();
c1_1->cd(3); // … or … (c1->cd(1))->cd(3);
(new TText(0.1, 0.5, “c1 … 1 … 3”))->Draw(); gPad->Update();
c1_1->cd(4); // … or … (c1->cd(1))->cd(4);
(new TText(0.1, 0.5, “c1 … 1 … 4”))->Draw(); gPad->Update();

TVirtualPad *c1_2 = c1->cd(2); // enter the second pad
c1_2->Divide(2, 2); // … or … gPad->Divide(2, 2);
// enter the 4 sub-pads and do stuff
(c1->cd(2))->cd(1); // … or … c1_2->cd(1);
(new TText(0.1, 0.5, “c1 … 2 … 1”))->Draw(); gPad->Update();
(c1->cd(2))->cd(2); // … or … c1_2->cd(2);
(new TText(0.1, 0.5, “c1 … 2 … 2”))->Draw(); gPad->Update();
(c1->cd(2))->cd(3); // … or … c1_2->cd(3);
(new TText(0.1, 0.5, “c1 … 2 … 3”))->Draw(); gPad->Update();
(c1->cd(2))->cd(4); // … or … c1_2->cd(4);
(new TText(0.1, 0.5, “c1 … 2 … 4”))->Draw(); gPad->Update();

return;
}[/code]

Thanks Wile.The lines below (and similar) do not give complains however do not divide the first pad

 TVirtualPad *c1_1 = c1->cd(1); // enter the first pad
  gPad->Divide(2, 2); // ... or ... c1_1->Divide(2, 2);

therefore I have not reached my goal.

I get no problem with my macro (tried with ROOT 5.28 and 5.34). On the attached picture you can see all pads and sub-pads.


Thanks Wile, I committed a mistake in a line of my code. Everything is OK now.