hist2image.C

Go to the documentation of this file.
00001 //Create an image from a 2-D histogram and manipulate it
00002 //Author: Valeriy Onuchin
00003 void hist2image()
00004 {
00005 
00006    TCanvas *canv = new TCanvas("image", "xygaus + xygaus(5) + xylandau(10)");
00007    canv->ToggleEventStatus();
00008    canv->SetRightMargin(0.2);
00009    canv->SetLeftMargin(0.01);
00010    canv->SetTopMargin(0.01);
00011    canv->SetBottomMargin(0.01);
00012 
00013    // histogram as image (hist taken from draw2dopt.C)
00014    TImage *img = TImage::Create();
00015 
00016    TF2 *f2 = new TF2("f2","(xygaus + xygaus(5) + xylandau(10))",-4,4,-4,4);
00017    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};
00018    f2->SetParameters(params);
00019    TH2D *h2 = new TH2D("h2","xygaus + xygaus(5) + xylandau(10)",100,-4,4,100,-4,4);
00020    h2->FillRandom("f2",40000);
00021    img->SetImage((const Double_t *)h2->GetArray(), h2->GetNbinsX() + 2, 
00022                   h2->GetNbinsY() + 2, gHistImagePalette);
00023    img->Draw();
00024    img->StartPaletteEditor();
00025 }

Generated on Tue Jul 5 15:44:48 2011 for ROOT_528-00b_version by  doxygen 1.5.1