Re: Trouble with trees

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 8 Jul 2009 10:31:40 +0200


Mario,

see this note in TTree::Branch

   // Note that the TTree will assume that all the item are contiguous in memory.

   // On some platform, this is not always true of the member of a struct or a class,

   // due to padding and alignment. Sorting your data member in order of decreasing

   // sizeof usually leads to their being contiguous in memory.

Using this old-style branch is less efficient than using a class in split mode. The compression level is less efficient and you are subject to these alignment problems.

Rene Brun

Mario Kadastik wrote:
>> It is likely an alignment problem within a struct when using data
>> types of different lengths. I cannot reproduce it on my machines.
>> Could you run the attached script on your machine and let me know if
>> it works?
>> It is better to pass the struct pointer instead that the description
>> of the individual members, ie replace
>> tree->Branch("cutvars",&cutvars.s,"s/I:mRel/D:sumpt:pt1:pt2:pt3:pt4:dRp:dRn:met:nTau/I");
>>
>> by
>> tree->Branch("cutvars",&cutvars);
>
> Ran your code and it worked just fine. Then I took the generated root
> file and ran my code on it (the same printTree.C that I copied to the
> e-mail previously) and it produced the same result (worked just fine).
> So it seems to be a saving issue with CMSSW somehow. By the way I can
> get the variables out manually:
>
> root [2] t->Show(1)
> ======> EVENT:1
> s = 1
> mRel = 1.00941
> sumpt = 447.262
> pt1 = 44.2483
> pt2 = 88.4943
> pt3 = 113.021
> pt4 = 201.498
> dRp = 0.967189
> dRn = 1.10596
> met = 22.8287
> nTau = 0
> root [3] t->GetLeaf("mRel")->GetValue()
> (const Double_t)1.00940619557053046e+00
>
> And you see that it's Double_t. The interesting part is that GetLeaf
> also shows s to be Double_t:
>
> root [4] t->GetLeaf("s")->GetValue()
> (const Double_t)1.00000000000000000e+00
>
> Odd...
>
> You can get my tree.root file (generated with CMSSW) from
> http://neptune.hep.kbfi.ee/~mario/tree.root just to see if you can
> understand what goes wrong in the saving process...
>
> Mario
>
Received on Wed Jul 08 2009 - 10:31:03 CEST

This archive was generated by hypermail 2.2.0 : Wed Jul 08 2009 - 11:50:03 CEST