Multiple leaf to extract data

Dear experts,

I try to extract data from a multiple-leaf root file.
the multiple-leaf is built, like below:
tree->Branch("event","&event", "nevent/I: multi: impactar");
However, I try to get the branch,
unfortunately, the error:

Error in <TTree::SetBranchStatus>: unknown branch -> nevent
Error in <TTree::SetBranchStatus>: unknown branch -> multi

I am appreciated to any suggestions.

Thanks
Liuyao

The syntax you use create a single branch with 3 leaves which are always read and written together and you can only call SetBranchStatus("event", status). To have finer grain control, you need to create 3 separate branch either manually or by creating a dictionary for the struct even and using tree->Branch("event.", &event);

Hi Pcanal, @pcanal.

Thanks for your answer. Actually, I have created the TTree owning a branch with 3 leaves using a struct class. Now, I just want to read the TTree. Just as I explained before
‘tree->Branch(“event”,"&event", “nevent/I: multi: impactar”);’
the branch event has three leaves: nevent, multi and impactar. To read a branch owning only one leaf, I know to call SetBranchStatus(" ", status), and contact the branch to the corresponding array[] using the SetBranchAddress("", array). However, for the branch owning three leaves, is there a convenient method or I have to use a struct class to have finer control.
If possible, I am appreciated that there is an example.

Cheers.
Liuyao

To read a branch owning only one leaf, I know to call SetBranchStatus(" ", status) … using the SetBranchAddress("", array)

Those calls can only be done on a per branch basis.

However, for the branch owning three leaves, is there a convenient method or I have to use a struct class to have finer control.

By design all 3 leaves will always be read from the file together … to avoid that you must using different branches.

dou can retrieve the address of “just” one leaf by using tree->GetLeaf(name)->GetValuePointer(); or tree->GetLeaf(name)->GetValue()

Perfect, it works.
Thanks a lot.

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