Re: [ROOT] TTree::MakeClass and 2D arrays

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Oct 20 2003 - 23:08:50 MEST


Julien,

Your branch "dir" has a branch count "nmcg".
You must read the branch b_nmcg before reading the b_dir.
Add the statement
   b_nmcg->GetEntry(ientry);
before the other calls to GetEntry.

Rene Brun

On Mon, 20 Oct 
2003, Julien 
Bolmont wrote:

> 
> Hi Rene,
> 
> Sorry, I forgot ! 
> I use root 3.04/02 on RH Linux 7.3.
> 
> I can add that GetEntry in the Loop function returns 0, so it's just 
> like my entry does not exist, but I can see it and plot histograms from 
> the Tree viewer and with the command line :
> 
> root [0] TFile f("1-02.root")  // the file containing the tree 'h1'
> root [1] h1->Draw("dir[0][2]")
> 
> 
> Thanks again,
> Julien
> 
> 
> On Fri, 17 Oct 2003, Rene Brun wrote:
> 
> > Hi Julien,
> > 
> > I cannot reproduce this problem. Unfortunately, you do not indicate
> > which version of ROOT and which machine.
> > 
> > Rene Brun
> > 
> > 
> > On Fri, 
> > 17 Oct 2003, Julien Bolmont wrote:
> > 
> > > 
> > > 
> > > Hello rooters,
> > > 
> > > I used TTree::MakeClass to generate a skeleton class for my tree.
> > > This tree contains simple variables, some 1D arrays and some 2D arrays.
> > > 
> > > All works well when I try to use simple variables or 1D arrays, ie I get 
> > > the right numbers.
> > > 
> > > But it doesn't work with 2D arrays. For example, I got a table:
> > >    Float_t         dir[100][3];
> > > which coresponds to the branch
> > >    TBranch        *b_dir;
> > > 
> > > In Init(..) we have :
> > >    fChain->SetBranchAddress("dir", dir);
> > > 
> > > In Notify() :
> > >    b_dir = fChain->GetBranch("dir");
> > > 
> > > 
> > > And now, if I have a Loop function with
> > > 
> > >    for (Int_t jentry = 0 ; jentry < nentries ; jentry++) {
> > > 
> > >       Int_t ientry = LoadTree(jentry);
> > >       if (ientry < 0) break;
> > > 
> > > 		nb1 += b_dir->GetEntry(ientry);
> > > 		
> > > 		
> > > 		cout << dir[0][2] << endl;
> > > 		
> > >    }
> > > 
> > > All I got is a lot's of 0.
> > > 
> > > 
> > > I think it's probably a problem of adress, but how to solve it ??
> > > 
> > > Thanks for your help !
> > > 
> > > JB.
> > > 
> > > 
> > > 
> > > 
> > 
> 
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET