Inconsistent values while reading a tree from a class object

Hi,

I’m constructing a new tree from 2 other ones which have the same structure. These 2 trees are read sequentially using a library extracted from TFile::MakeProject() function. So in this particular case I do like this:

    gSystem->Load("HptEventOld/HptEventOld.so");

    HptEventOld *p[2];
    for (int i=0; i<2; i++){
      p[i]=0;
      tree[i]->SetBranchAddress("Event",&p[i]);
      Long64_t nn = tree[i] -> GetEntries();
      for (Long64_t j=0; j<nn; j++){
        tree[i] -> GetEntry(j);
        ...
        }
      }

This means that the outer loop, goes for one tree and the the other. While the inner loop goes for the events within each tree.

The problem is that what is read from the trees is not what is stored inside them, so at the end you get different values for some of the variables. For instance, the variable “final_phi_s” in the new tree has 2000 “zeros”, while if you look into the other 2 trees you’ll see that there is a clear distribution different from “zero” for each one.

The ROOT version I use is 5.34/23.

In attachment I put a tarball containing a small program which reproduces the problem, the whole code is in “tree.cc” file, to create the program just type ‘make’ and to run do ./run_prog P1G P1H.

I don’t understand why the reading of those trees ends up in such a crazy values. Could someone please have a look and see if I’m making a stupid mistake?

Many thanks in advance.

Kind regards,
Luís.
new_tree.tgz (1.02 MB)

Hi Luis,

I can not reproduce your problem. After downloading and building your example I get:

[code]$ root.exe -b -l P1G-P1H_analysis.root
root [0]
Attaching file P1G-P1H_analysis.root as _file0…
root [1] USR1->Scan()


  • Row * final_phi * final_phi * phi * z * Xbj * y * Q2 * polarisat *

  •    0 * 2.4464240 * -0.279496 * 2.7259200 * 0.2937089 * 0.0208648 * 0.4101822 * 2.7569065 *    -0.497 *
    
  •    1 * -2.942322 * -3.021605 * 0.0792836 * 0.2532451 * 0.1479761 * 0.4189180 * 18.726482 *    -0.497 *
    
  •    2 * 1.1452977 * 0.9791643 * 0.1661334 * 0.5478341 * 0.0228655 * 0.7428098 * 5.2759635 *    0.5278 *
    
  •    3 * -0.132185 * 2.5472334 * 3.6037664 * 0.2224488 * 0.1239969 * 0.2716619 * 10.348139 *    0.5278 *
    
  •    4 * -2.371899 * 0.1813583 * 3.7299274 * 0.4102212 * 0.0189657 * 0.2533444 * 1.3677819 *    -0.497 *
    

[/code]

Maybe try with v6 or at least v5.34/34.

Cheers,
Philippe.

Hi Philippe,

Thanks for your answer, I’ll try that.

Cheers,
L.