H2root and variable length array

Dear rooters,
I have the following problem: I have a PAW ntuple which contains among the other variables these two:

ntrack integer

al(5,ntrack) float

I want to translate this ntuple into a rootple. h2root creates a rootple which contains

Ntrack integer

Al[Ntrack][5] float

For many reasons (after long discussions with other collaborators) we would prefer to have in the rootple something like

ntrack integer

al[5][ntrack] float

that is the same as above but with slightly different names AND with the correct order of columns and rows in the matrix. So I have written some code which open the ntuple read the content and try to write in the “correct” way a rootple. To fill the rootple I am using a structure like:

struct trklev {
Int_t ntrk;
Float_t al[5][50]; // ntrk always less than 50
}

and I book the rootple this way

struct trklev trklev2;
TFile *hfile=0;
TTree *tree=0;
hfile = new TFile(filename,“RECREATE”,“my data”);
tree = new TTree(“TrkLev2”,“my data”);
tree->Branch(“ntrk”,&trklev2.ntrk,“ntrk/I”);
tree->Branch(“al”,trklev2.al,“al[5][ntrk]/F”);

the program works (doesn’t crash) and I am sure I have in trklev2.al all the correct values (just to try I have fixed them) but when I look at the rootple content (with ntrk=1 for the moment) I find that only al[0][0] is correct while al[1][0]…al[4][0] contain random (?) numbers (like 3.503e-44, 8.579e-39, 7.553e+31,…).
I have tried to modify my program inverting rows with columns in the matrix and that worked perfectly, but it is not what I need.
My question is: is it possible to save a matrix which has variable length columns and not rows? why do h2root switch rows and columns? is it because fortran and C use the inverted convention for rows and columns or because it is not possible to do otherwise?

Many thanks,
Emiliano Mocchiutti (for the PAMELA collaboration)

Emiliano,

h2root converts your table from the Fortran convention to the C/C++
storage convention. We have no plans to change this.

Rene

Dear Rene,
I understand you will not change h2root, perhaps I did not explain well my problem.
A part h2root, is there any intrinsic reason for which I cannot create a branch in a tree which contains a matrix which has a variable length number columns instead of rows?
I mean, if I do this way

struct trklev trklev2;
TFile *hfile=0;
TTree *tree=0;
hfile = new TFile(filename,“RECREATE”,“my data”);
tree = new TTree(“TrkLev2”,“my data”);
tree->Branch(“ntrk”,&trklev2.ntrk,“ntrk/I”);
tree->Branch(“al”,trklev2.al,“al[ntrk][5]/F”);

it works, variable “al” contains the correct values.
If I do instead

struct trklev trklev2;
TFile *hfile=0;
TTree *tree=0;
hfile = new TFile(filename,“RECREATE”,“my data”);
tree = new TTree(“TrkLev2”,“my data”);
tree->Branch(“ntrk”,&trklev2.ntrk,“ntrk/I”);
tree->Branch(“al”,trklev2.al,“al[5][ntrk]/F”); <— different here!

it doesn’t work, variable “al” contains random numbers.
If you tell me it is the way ROOT fills matrixes and cannot be change I am happy with the answer, if you know it is possible to do it my question is how can I do it, since if I do this way it doesn’t work! I am using ROOT Version 4.03/02 9 February 2005.
Thanks anyway for your answer!
Emiliano