Problem with variables declared as UShort_t

Dear ROOTers,

I’ve encountered a problem when workign with a root-file obtained by applying the h2root program to a ntuple-file produced by my mc program. After obtaining the root file and creating a skeleton class with MakeClass, I’ve met the problem related with variables declared as UShort_t. The contents of these variables is improper. Please try to convert the ntuple-file (see in attachment), then invoke the MakeClass comand on a tree “h1”. Inside the created MakeClass (inside Loop() method) please make an output of variable “Dnum”. You should be given by the output like this one (this variable is filled only for the 1st event!)

Dnum = 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 1 0 2 0 3 0 4 0 1 0 2 0 3 0 4 0 1 0 2 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 1 0 2 0 3 0 4 0 5 0 6 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11

instead of this one

Dnum = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 1 2 3 4 1 2 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 2 3 4 1

It looks like there is an alignment problem with UShort_t variables.

One important remark: this kind of problem exists if I use the ROOT version 4.00.02. The problem disappears if I use the ROOT version 3.10. In this case I obtain the proper result (the above mentioned 2nd output).

Have I missed something?
I’m working on Linux Red Hat 7.3 with gcc 2.96

Best regards,
Alexander
kopio_mc_7101.hbook.gz (67.2 KB)

I looked at your first event with both PAW and ROOT and the results are identical.
You array Dnum is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 2 3 4 1 2 3 4 1 2 1 2 3 4 5 6 7 8
and not what you claim:

Rene

Hi Rene,

Sorry I’m bothering you. Please try to download two files at
the following link: phy.bnl.gov/~artamonov/work/temp_dir.html

Then try to invoke the following (in any ROOT version 3.10 or 4.00.02):

TFile *f = new TFile(“kopio_mc_v400.root”)
h1->Scan(“Dnum”)

and

TFile *f = new TFile(“kopio_mc_v310.root”)
h1->Scan(“Dnum”)

I’m getting the different results. (Also at each created file you’ll find
a file with an output message when converting it by the h2root program.)

Best regards,
Alexander

Hi Rene,

The problem disappeared when using ROOT version 4.00/03.
My complains have been related to the previous version 4.00/02.
Has it been fixed somehow?

Best regards,
Alexander

Hi,

Indeed h2root was broken in regards to UShort_t in ROOT 4.00/02.
It is fixed in ROOT 4.00/03

Cheers,
Philippe.

OK, Thank you a lot indeed!

Cheers,
Alexander

Hi Alexander, it was me who introduced a bug into h2root and fixed it several days later.
You happened to be unlucky to have used the version which was bad. I would like to give you a word of caution: do not change vartiable packing range used during creation of ntuples.

h2root relies on packing info to infer size of variable. So, you may potentially have the same variable converted into Int_t or Short_t or even Char_t depending on what range you specify during ntuple creation for that particular variable. Once you chose packing for a variable - don’t change it, or you files will have different variable types.

Perhaps, ROOT founders will find it necessary to put this warning into h2root code.

Of course this is only valid for CWN ntuples.
Sorry about mishap. Khamit

Hi Khamit,

Thank you so much for your caution information. I will keep it in mind when working.

Cheers,
Alexander