{ TNtuple* nt = new TNtuple("nt","","a:b:c"); TCanvas *Can = new TCanvas("Can","Can",200,10,800,400); Can->Divide(4,2); Double_t x[16] = {1.00, 2.00, 6.00, 7.00, 3.00, 10.00, 0.20, 5.55, 20.50, 9.75, 1.50, 8.00, 5.00, 0.95, 3.85, 8.70}; Double_t y[16] = {1.00, 2.00, 6.00, 7.00, 3.00, 10.00, 0.20, 5.55, 20.50, 9.75, 1.50, 8.00, 5.00, 0.95, 3.85, 8.70}; Double_t z[16] = {0.001, 2.50, 600.00, 0.00001, 30.00, 10.001, 300000.0, 500000.55, 20.50, 9.75, 280000.50, 8.00, 5.00, 0.95, 3.85, 8.70}; Double_t x3, y3, z3; for (Int_t h1 =0;h1<16;++h1) { x3 = x[h1]; y3 = y[h1]; z3 = z[h1]; nt->Fill(x3,y3,z3); } gStyle->SetOptStat(0); gStyle->SetPalette(1,0); nt->SetMarkerStyle(20); nt->SetMarkerSize(1); nt->SetEstimate(nt->GetEntries() + 1); Double_t xmin = nt->GetMinimum("a"); // "a" is X in the nt->Draw below Double_t xmax = nt->GetMaximum("a"); Double_t ymin = nt->GetMinimum("b"); // "b" is Y in the nt->Draw below Double_t ymax = nt->GetMaximum("b"); Double_t hxmin = xmin; Double_t hymin = ymin; #if 0 /* 0 or 1 */ xmin = 0.0; // enforce xmin = 0 ymin = 0.0; // enforce ymin = 0 #endif /* 0 or 1 */ Int_t xnbins = 100; Int_t ynbins = 100; #if 0 /* 0 or 1 */ xnbins = 40; // use the same number as for "automatically" creates histograms ynbins = 40; // use the same number as for "automatically" creates histograms #endif /* 0 or 1 */ TH2F *htemp; Can->cd(1); nt->Draw("b:a", "", ""); // note: TTree::Draw creates a "htemp" gPad->Modified(); gPad->Update(); gPad->SetLogx(1); gPad->SetLogy(1); Can->cd(2); nt->Draw("b:a", "", ""); // note: TTree::Draw creates a "htemp" gPad->Modified(); gPad->Update(); htemp = (TH2F *)gPad->GetPrimitive("htemp"); if (htemp) { htemp->GetXaxis()->SetLimits(xmin, xmax); // set proper "htemp" X axis limits htemp->GetYaxis()->SetLimits(ymin, ymax); // set proper "htemp" Y axis limits } gPad->SetLogx(1); gPad->SetLogy(1); Can->cd(3); nt->Draw("b:a>>auto_hba", "", ""); // note: TTree::Draw creates "auto_hba" gPad->Modified(); gPad->Update(); TH2F *auto_hba = (TH2F *)gPad->GetPrimitive("auto_hba"); if (auto_hba) { auto_hba->GetXaxis()->SetLimits(xmin, xmax); // set proper "htemp" X axis limits auto_hba->GetYaxis()->SetLimits(ymin, ymax); // set proper "htemp" Y axis limits } gPad->SetLogx(1); gPad->SetLogy(1); Can->cd(4); TH2F *hba = new TH2F("hba", "b:a>>hba", xnbins, hxmin, xmax, ynbins, hymin, ymax); nt->Draw("b:a>>hba", "", ""); gPad->Modified(); gPad->Update(); hba->GetXaxis()->SetLimits(xmin, xmax); // set proper "htemp" X axis limits hba->GetYaxis()->SetLimits(ymin, ymax); // set proper "htemp" Y axis limits gPad->SetLogx(1); gPad->SetLogy(1); Can->cd(5); nt->Draw("b:a:c", "", "colz"); // note: TTree::Draw creates a "htemp" gPad->Modified(); gPad->Update(); gPad->SetLogx(1); gPad->SetLogy(1); Can->cd(6); nt->Draw("b:a:c", "", "colz"); // note: TTree::Draw creates a "htemp" gPad->Modified(); gPad->Update(); htemp = (TH2F *)gPad->GetPrimitive("htemp"); if (htemp) { htemp->GetXaxis()->SetLimits(xmin, xmax); // set proper "htemp" X axis limits htemp->GetYaxis()->SetLimits(ymin, ymax); // set proper "htemp" Y axis limits } gPad->SetLogx(1); gPad->SetLogy(1); Can->cd(7); nt->Draw("b:a:c>>auto_hbac", "", "colz"); // note: TTree::Draw creates "auto_hbac" gPad->Modified(); gPad->Update(); TH2F *auto_hbac = (TH2F *)gPad->GetPrimitive("auto_hbac"); if (auto_hbac) { auto_hbac->GetXaxis()->SetLimits(xmin, xmax); // set proper "htemp" X axis limits auto_hbac->GetYaxis()->SetLimits(ymin, ymax); // set proper "htemp" Y axis limits } gPad->SetLogx(1); gPad->SetLogy(1); Can->cd(8); TH2F *hbac = new TH2F("hbac", "b:a:c>>hbac", xnbins, hxmin, xmax, ynbins, hymin, ymax); nt->Draw("b:a:c>>hbac", "", "colz"); gPad->Modified(); gPad->Update(); hbac->GetXaxis()->SetLimits(xmin, xmax); // set proper "htemp" X axis limits hbac->GetYaxis()->SetLimits(ymin, ymax); // set proper "htemp" Y axis limits gPad->SetLogx(1); gPad->SetLogy(1); Can->cd(0); }