TCanvas *tsmooth(){ TFile *fsm = new TFile("tsmooth.root", "RECREATE"); TCanvas *c2e = new TCanvas("c2e","c2e",600,600); Int_t nbinx = 40, nbiny=40; TH2F *h2e = new TH2F("h2e","TH2 drawn with option CONTZ",nbinx,-4,4,nbiny,-20,20); Float_t px, py; for (Int_t i = 0; i < 250000; i++) { gRandom->Rannor(px,py); h2e->Fill(px,5*py); } h2e->Smooth(); h2e->SetContour(60); h2e->Draw("contz"); c2e->SetFrameFillColor(1); c2e->SetFrameFillStyle(4001); // make a TGraph2D Int_t np=0; TAxis *xa = h2e->GetXaxis(); TAxis *ya = h2e->GetYaxis(); TGraph2D *g2 = new TGraph2D(nbinx*nbiny); for (Int_t ix=1; ix<=nbinx; ix++) { for (Int_t iy=1; iy<=nbiny; iy++) { g2->SetPoint(np, xa->GetBinCenter(ix),ya->GetBinCenter(iy), h2e->GetBinContent(ix, iy)); np++; } } // gStyle->SetPalette(kBird,NULL); // gStyle->SetPalette(kRainBow,NULL); gStyle->SetPalette(kDarkBodyRadiator,NULL); // gStyle->SetPalette(kWaterMelon,NULL); TCanvas *cgr2 = new TCanvas("cgr2","cgr2",10, 10, 600,600); cgr2->Draw(); cgr2->SetPhi(0); cgr2->SetTheta(90); g2->GetHistogram()->SetLabelOffset(-0.06,"X"); g2->Draw("tri2Z"); g2->Write(); h2e->Write(); return c2e; }