Re: [ROOT] MakeCode bug?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Oct 22 2001 - 12:40:06 MEST


Hi Jiri,

Yes, MakeCode is an obsolete function. One should used MakeClass
or MakeSelector instead.
In the development version, I have added a Warning message when calling
the MakeCode function.

Rene Brun

Jiri Bystricky wrote:
> 
>   The following script Test.C shows a problem in
> TTree::MakeCode, which is correctly treated in
> TTree::MakeClass.
> {
>    gROOT->Reset();
>    TFile f("TestFile.root","recreate");
>    TTree * ntuple= new TTree("Test","test MakeCode");
>    Int_t NN[] = {1,2};
>    cout << ">>> Input values NN[0]="<<NN[0]<<" NN[1]="<<NN[1]<<endl;
>    ntuple->Branch("TwoInt",NN,"n1/I:n2/I");
>    ntuple->Fill();
>    ntuple->Write();
>    ntuple->MakeCode("TestCode.C");
>    ntuple->MakeClass("TestClass");
>    gROOT->ProcessLine(".x TestCode.C");
>    Test->Show(0);
>    Test->GetEntry(0);
>    cout << ">>> MakeCode test n1="<<TwoInt_n1<<" n2="<<TwoInt_n2<<endl;
>    gROOT->ProcessLine(".L TestClass.C");
>    TestClass t;
>    t.Show(0);
>    t.GetEntry(0);
>    cout << ">>> MakeClass test n1="<<t.TwoInt_n1<<" n2="<<t.TwoInt_n2<<endl;
> }
>   The ouput is
> 
> root [0] .x Test.C
> >>> Input values NN[0]=1 NN[1]=2
> Macro: TestCode.C generated from Tree: Test
> Files: TestClass.h and TestClass.C generated from Tree: Test
> ======> EVENT:0
>  n1              = 1
>  n2              = 2
> >>> MakeCode test n1=0 n2=1
> ======> EVENT:0
>  n1              = 1
>  n2              = 2
> >>> MakeClass test n1=1 n2=2
> 
>   The TestCode.C behaviour is explained by two lines
> in the generated code:
>    Test->SetBranchAddress("TwoInt",&TwoInt_n1);
>    Test->SetBranchAddress("TwoInt",&TwoInt_n2);
> 
>   Is MakeCode considered as obsolete and should not be used?
> 
>         Jiri
> P.S. May ROOT version is 3.01/06 on OSF1 system.



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:03 MET