How to access the information contained in branches of the root file

Hi,
I have this root file whose branches contains a number of leaves.I don’t know how to access the individual leaves of each branch of this tree. I am attaching the root file. Please let me know how to access the leaves variables of the individual branches.

Bedp.root (2.8 MB)

Hi mustak21,
there are several ways to read data from a TTree in a ROOT file. Depending on the method you use to read the data the syntax to access the leaves might be different.

I am missing dictionaries for the classes stored in your file, but can you maybe provide a small macro/source file with your attempt that I can try to correct?

Cheers,
Enrico

Thanks for replying. I am attaching the macro that I tried to write.

th_macro.C (1.2 KB)

Also I would like to know that if I can change the structure of the root file from Tree->Branch->Leaves Structure to another root file to Tree->Leaves structure without losing any data.

Yes, afaik the only way is to read in your data and write in out in the form you prefer.
You can use TDataFrame (if you have access to ROOT v6.10) or TTree directly with SetBranchAddress and Fill to write out data.

Hi,
I have not forgot about this thread but my tests to read a leaf using TTree::SetBranchAddress failed, so I do not have a quick solution for you.

TDataFrame or the analysis skeleton might be a way forward.
Otherwise I’d ask @pcanal or @Axel to comment when they are back from vacation.

Feel free to comment on this thread again in a few days if you don’t get a reply, to bring it to our attention.
Cheers,
Enrico

I cannot call TTree::GetEntry() on the file; it fails reading a vector<double> branch…

But in general, to read a TLeaf you cannot call SetBranchAddress() but t0->GetLeaf("W1")->GetValue().

Axel.

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

How did this macro fail?