Re: TPaveStats and Divide

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Sat, 19 Apr 2008 22:47:58 +0200


Do:

fMCVerticesCanvas = new TCanvas("MCVerticesCanvas", "MC Vertices", 0, 0, 1100, 1100);

fMCVerticesCanvas->Divide(2, 2);

fMCVerticesCanvas->cd(1);

fMCVerticesCanvas->cd(1)->SetLogy();

fVerticesClass->Draw();

fMCVerticesCanvas->Update();
((TPaveStats
*)fVerticesClass->GetListOfFunctions()->FindObject("stats"))->SetOptStat(1111);

Rene

Manuel Mussini wrote:
>
> Hi,
>
> I have a script that:
>
> - sets a global style using gStyle->SetOptStat(11)
>
> - opens a root file
>
> - gets some TH1D
>
> - creates a canvas
>
> - divides the canvas in 4 (2x2)
>
> - draws a histo in each subcanvas
>
> - saves the canvas in a eps file
>
> Now the problem! How to change the OptStat options only for the first
> histo?
>
> I’ve searched for it on the web site but this solution doesn’t fix the
> problem in my script:
>
> fMCVerticesCanvas = new TCanvas("MCVerticesCanvas", "MC Vertices", 0,
> 0, 1100, 1100);
>
> fMCVerticesCanvas->Divide(2, 2);
>
> fMCVerticesCanvas->cd(1);
>
> fMCVerticesCanvas->cd(1)->SetLogy();
>
> fVerticesClass->Draw();
>
> ((TPaveStats
> *)fVerticesClass->GetListOfFunctions()->FindObject("stats"))->SetOptStat(1111);
>
> The tricky point is that if I try this interactively it works!!!
>
> Running from the script I get:
>
> Error: illegal pointer to class object
> (TPaveStats*)fVerticesClass->GetListOfFunctions()->FindObject("stats")
> 0x0 638 C:\root\ManuC\THeavyFlavoursAllPlots.C(198)
>
> I’m running 5.17.02 on WinXP!
>
> Bye…
>
Received on Sat Apr 19 2008 - 22:48:02 CEST

This archive was generated by hypermail 2.2.0 : Sun Apr 20 2008 - 05:50:03 CEST