Access to contour levels

Hello!
I attempted to modify the tutorial draw2dopt.C to access the TGraph objects for a contour plot and am having no success. The gROOT->GetListOfSpecials() always returns an empty list. I have included the script below and am using 3.05/07. Can anyone tell me what I’m doing wrong?

Thanks,
Andrew

{
// display the various 2-d drawing options
gROOT->Reset();
gStyle->SetOptStat(0);
gStyle->SetPalette(1);
gStyle->SetCanvasColor(33);
gStyle->SetFrameFillColor(18);
TF2 *f2 = new TF2(“f2”,“xygaus + xygaus(5) + xylandau(10)”,-4,4,-4,4);
Double_t params[] = {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5,
3600,-2,0.7,-3,0.3};
f2.SetParameters(params);
TH2F h2(“h2”,“xygaus + xygaus(5) + xylandau(10)”,20,-4,4,20,-4,4);
h2.SetFillColor(46);
h2.FillRandom(“f2”,40000);
TPaveLabel pl;

//basic 2-d options
Float_t x1=0.67, y1=0.875, x2=0.85, y2=0.95;
Int_t cancolor = 17;

//contour options
TCanvas cont(“contourx”,“contourx”,0,0,800,600);
cont.Divide(2,2);
gPad->SetGrid();
cont.SetFillColor(cancolor);
cont.cd(1);
h2.Draw(“contz”); pl.DrawPaveLabel(x1,y1,x2,y2,“CONTZ”,“brNDC”);
cont.cd(2);
gPad->SetGrid();
h2.Draw(“cont1”); pl.DrawPaveLabel(x1,y1,x2,y2,“CONT1”,“brNDC”);
cont.cd(3);
gPad->SetGrid();
h2.Draw(“cont2”); pl.DrawPaveLabel(x1,y1,x2,y2,“CONT2”,“brNDC”);
cont.cd(4);
gPad->SetGrid();
h2.Draw(“cont3,list”); pl.DrawPaveLabel(x1,y1,x2,y2,“CONT3”,“brNDC”);
TObjArray *contours=(TObjArray *)
gROOT->GetListOfSpecials()->FindObject(“contours”);
printf("%d %p",gROOT->GetListOfSpecials()->GetSize(),contours);

}

The option “List” works only with “cont”. It does not work with “cont1”,cont2"

Rene

Hello!

 Thanks for your reply Rene. I am still having problems. As you suggested, I modified to code as given below. I still get an empty list. I tried this additionally with a older version 2.25/03 on a different operating system and 3.05/07.

Thanks,
Andrew

{
  // display the various 2-d drawing options
  gROOT->Reset();
  gStyle->SetOptStat(0);
  gStyle->SetPalette(1);
  gStyle->SetCanvasColor(33);
  gStyle->SetFrameFillColor(18);
  TF2 *f2 = new TF2("f2","xygaus + xygaus(5) + xylandau(10)",-4,4,-4,4);
  Double_t params[] = {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5, 
		       3600,-2,0.7,-3,0.3};
  f2.SetParameters(params);
  TH2F h2("h2","xygaus + xygaus(5) + xylandau(10)",20,-4,4,20,-4,4);
  h2.SetFillColor(46);
  h2.FillRandom("f2",40000);
  TPaveLabel pl;
   
  //basic 2-d options
  Float_t x1=0.67, y1=0.875, x2=0.85, y2=0.95;
  Int_t cancolor = 17;
   
   //contour options
  TCanvas cont("contourx","contourx",0,0,800,600);
  cont.Divide(2,2);
  gPad->SetGrid();
  cont.SetFillColor(cancolor);
  cont.cd(1);
  h2.Draw("contz"); pl.DrawPaveLabel(x1,y1,x2,y2,"CONTZ","brNDC");
  cont.cd(2);
  gPad->SetGrid();
  h2.Draw("cont1"); pl.DrawPaveLabel(x1,y1,x2,y2,"CONT1","brNDC");
  cont.cd(3);
  gPad->SetGrid();
  h2.Draw("cont2"); pl.DrawPaveLabel(x1,y1,x2,y2,"CONT2","brNDC");
  cont.cd(4);
  gPad->SetGrid();
  h2.Draw("cont,list"); pl.DrawPaveLabel(x1,y1,x2,y2,"CONT","brNDC");
  TObjArray *contours=(TObjArray *)
    gROOT->GetListOfSpecials()->FindObject("contours");
  printf("%d %p",gROOT->GetListOfSpecials()->GetSize(),contours);
   
}

Add the statement
gPad->Update();
after
h2.Draw("cont,list);…

This will force the contours to be paint.

Rene