Re: [ROOT] matrix in TTree with a C structure

From: Matthieu Lechowski (lechowsk@lal.in2p3.fr)
Date: Wed Aug 27 2003 - 17:23:36 MEST


Hello again,

Sorry if you started to search a solution, I have understood my problem!
I declared my matrix with a fixed size ([nmax][5]), and I used it in
TTree::Branch(..) with a variable size. My matrix was cut, but since a
matrix is internally seen as a vector, I had not the elements I wanted
(first elements of the "vector" and not first columns and lines of the
matrix).

Matthieu Lechowski.

On Wed, 27 Aug 2003, Matthieu Lechowski wrote:

> Hello,
>
> I have a problem which is a little hard to explain.
>
> I have a TTree with a C structure:
>
> const Int_t nmax=250;
> typedef struct
> {
>   Int_t   TREEn;
>   Float_t TREEpt[nmax], ... ;
>   ...
>   Float_t TREEmmax[nmax][5],TREEptmax[nmax][5], ... ;
> } ENTITE;
>
> ENTITE P[n_entite];
>
> for(int i_P;i_P<n_entite;++i_P)
> {
>   TREE.Branch("n"+suffix[i_P],&P[i_P].TREEn,"n"+suffix[i_P]+"/I");
>   TREE.Branch("pt"+suffix[i_P],P[i_P].TREEpt,
>               "pt"+suffix[i_P]+"[n"+suffix[i_P]+"]/F");
>   ...
>   TREE.Branch("mmax"+suffix[i_P],P[i_P].TREEmmax,
>               "mmax"+suffix[i_P]+
>               "["+Nsel_str[i_P]+"]["+Nattendu_str[i_P]+"]/F");
>   ...
> }
>
> As you can see, each object ("ENTITE") has its suffix for the name of
> the variables, and its dimensions for the matrixes as mmax (Nsel_str and
> Nattendu_str are TString, I did Nsel_str[i_P]+=Nsel[i_P]; where Nsel[]
> are integers; I think it was not necessary)
>
> This synthax works with "pt", but not with mmax. Indeed, when I read the
> Tree, the variable has the good dimension (2x2 for example), but fields
> are empty beyond the first column (or line!), i.e mmax[0][j] are filled,
> but mmax[i>0][j] are 0.
>
> I checked, just before filling (function Fill()) the Tree, that my
> variables are really filled, and they are, so informations are lost
> filling the Tree.
> I think my synthax of "Branch(..)" is not correct for matrix.
>
> Have you an idea ?
> (I'm using root at cern om lxplus:
> ROOTSYS=/afs/cern.ch/sw/root/v3.05.05/rh73_gcc2952/root )
>
> Thank you.
>
>
> Matthieu Lechowski
> LAL Orsay
>



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