Re: [ROOT] (TGraph*)gPad->GetPrimitive("Graph");

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Nov 18 2004 - 09:00:19 MET


Hi Vincent,

the TGraph object generated by TTree::Draw is marked as temporary
and to be automatically deleted when clearing the pad. You can reset
this attribute by adding the line below marked //<===

Rene Brun

        TCanvas *c1 = new TCanvas("c1","Rate and efficiencies",0,0,500,800);
        TNtuple *nt = a.GetTNtuple("nt");
        nt->Draw("c1:c2");
        TGraph *Gtemp = (TGraph*)gPad->GetPrimitive("Graph");
        Gtemp->ResetBit(kCanDelete); //<====
        TH1F *hEff=c1->DrawFrame(0,0,600,1.2);
        Gtemp->Draw("*L");

Vincent Roberfroid wrote:
> 
>  Dear root users,
> 
> I try this simple macro in root and it crashs (using root 4.01/03).
> Could you help me ?
> 
>         TCanvas *c1 = new TCanvas("c1","Rate and efficiencies",0,0,500,800);
>         TNtuple *nt = a.GetTNtuple("nt");
>         nt->Draw("c1:c2");
>         TGraph *Gtemp = (TGraph*)gPad->GetPrimitive("Graph");
>         TH1F *hEff=c1->DrawFrame(0,0,600,1.2);
>         Gtemp->Draw("*L");
> 
> Thanks,
> 
> Vincent



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET