Hi Nicolas,
Add the line marked NEW below. Without this line, CINT
will allocate an automatic variable corresponding to h.
When this variable will be deleted in clearing the pad,
h will point to an already deleted object.
Rene Brun
On Thu, 26 Sep 2002, Nicolas de Sereville wrote:
> Hi rooters,
>
> I have the following problem, which to my mind comes from my bad knowledge of C++. If I run twice the small script below,
>
> void test()
> {
> TString path = "/user/deserevi/PH176/Analyse/";
> TString name = "fl18_cib*_new.root";
> path += name;
> TChain *ch = new TChain("coinc");
> ch->Add( path );
> cout << "OK 1" << endl;
>
> ch->Draw("energie_exc>>h(3000, 5000, 8000)");
TH1F *h = (TH1F*)gPad->GetPrimitive("h"); //<====NEW
> cout << "OK 2" << endl;
> TH1F *h5 = (TH1F*) h->Rebin(5,"h5");
> cout << "OK 3" << endl;
> h5->Draw();
> cout << "OK 4" << endl;
> }
>
>
> I obtain the following error just before executing the TH1F *h5 = (TH1F*) h->Rebin(5, "h5") ' line.
>
> *** Break *** segmentation violation
> Root > Function test() busy flag cleared
>
> any help is welcome
>
> Nicolas (RH7.2 with ROOT 3.03/09)
>
> -- :-------------------------------:
> : Nicolas de SEREVILLE :
> : C.S.N.S.M. :
> : Batiment 104 :
> : 91405 ORSAY Campus :
> : Tel : (+ 33) (0)1 69 15 52 29 :
> : Fax : (+ 33) (0)1 69 15 50 08 :
> :-------------------------------:
>
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:11 MET