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)