{ TNtuple *n = new TNtuple("n", "n", "a:b:c"); n->SetMarkerStyle(20); n->SetMarkerSize(1); for (Int_t i = 0; i < 20; i++) n->Fill(gRandom->Rndm(), gRandom->Rndm(), i); TCanvas *c = new TCanvas("c", "c"); c->Divide (2, 1); TH2F *h; c -> cd(1); cout << endl; TH2F *hold = new TH2F("hold", "hold", 100, 0, 1, 100, 0, 1); // hold->SetMarkerStyle(20); // hold->SetMarkerSize(1); cout << "TH2F hold histogram exists in advance -> " << hold << endl; n->Draw("a:b>>hold", "", ""); h = (TH2F *)(gPad->GetPrimitive("hold")); cout << "gPad -> " << h << " -> "; if (h) h->Print(); else cout << "hold" << endl; h = (TH2F *)(gROOT->FindObject("hold")); cout << "gROOT -> " << h << " -> "; if (h) h->Print(); else cout << "hold" << endl; c -> cd(2); cout << endl; cout << "TH2F hnew histogram DOES NOT exist in advance" << endl; n->Draw("a:b>>hnew", "", ""); h = (TH2F *)(gPad->GetPrimitive("hnew")); cout << "gPad -> " << h << " -> "; if (h) h->Print(); else cout << "hnew" << endl; h = (TH2F *)(gROOT->FindObject("hnew")); cout << "gROOT -> " << h << " -> "; if (h) h->Print(); else cout << "hnew" << endl; if (gROOT->GetVersionInt() > 59999) { // ROOT 6 h = (TH2F *)(gPad->GetPrimitive("hnew_copy")); cout << "gPad -> " << h << " -> "; if (h) h->Print(); else cout << "hnew_copy" << endl; h = (TH2F *)(gROOT->FindObject("hnew_copy")); cout << "gROOT -> " << h << " -> "; if (h) h->Print(); else cout << "hnew_copy" << endl; } c->cd(0); cout << endl; }