Reading data from sub-branch

Hello,

I am having trouble reading a sub branch of a tree. I have seen other posts in on the root forum like:

https://root.cern.ch/root/html/tutorials/tree/tree4.C.html

But I am still very confused and I was really hoping someone can help me out. The ROOT file I am looking at contains a tree called “dataTree” in which there is a branch called “summary” which contains all the variables I need to access.

When I do “dataTree->Print()” this is the output I get:

oot [1] dataTree->Print();


*Tree :dataTree : dataTree *
*Entries : 10 : Total = 354293 bytes File Size = 153961 *

  •    :          : Tree compression factor =   2.16                       *
    

*Branch :summary *
*Entries : 10 : BranchElement (see below) *

*Br 0 :fUniqueID : UInt_t *
*Entries : 10 : Total Size= 625 bytes File Size = 101 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.19 *

*Br 1 :fBits : UInt_t *
*Entries : 10 : Total Size= 653 bytes File Size = 130 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.26 *

*Br 2 :weight : Double_t *
*Entries : 10 : Total Size= 650 bytes File Size = 101 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.55 *

*Br 3 :trueZen : Float_t *
*Entries : 10 : Total Size= 615 bytes File Size = 99 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.19 *

*Br 4 :trueAzi : Float_t *
*Entries : 10 : Total Size= 615 bytes File Size = 99 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.19 *

*Br 5 :recoZen : Float_t *
*Entries : 10 : Total Size= 615 bytes File Size = 116 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.02 *

Here I have shortened the output as there are over 50 variables in this file. Can someone please tell me explicitly how to do this.

I have tried to play around with:

Summary* summary=new Summary();
and
TBranch *summary=dataTree->GetBranch(“summary”);
and
dataTree->SetBranchAddress(“summary”,&summary);
and
dataTree->SetBranchAddress(“summary.trueZen”,&trueZen);

But I am not sure in what order to use (or not to use) them. I am really confused. I would really appreciate any help.

If open the ROOT browser I can plot the values of the “weights” on the Canvas and it shows to me the address on the axis as being “summary.weights”. How does ROOT access these data values if I cant seem to do it?

Thanks


_ROOT Version: 5.43
_Platform: Cent OS 7
_Compiler: GCC 4.8.5


Never mind. I found the lib*.so files for the “summary” variable. After loading the required libraries it works.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.