Corrupted scalar branches in tree copy

Hi,

I’m trying to add branches to a copy of a tree using CloneTree(0), with an event loop and Fill.

It works well except for scalar branches (single integers, floats, etc.) that I read using SetBranchAddress from the original tree. The values of those branches get corrupted in the copied tree.

I wasn’t able to replicate this behavior in a simple small example though.

Any thoughts?

thanks,
Raz

EDIT: It took a while but with some help I realized if I change the branch address of the original tree I need to change it also for the copied tree.

[quote]EDIT: It took a while but with some help I realized if I change the branch address of the original tree I need to change it also for the copied tree.[/quote]Which way (SetBranchAddress or branch->SetAddress) did you use to set the addresses?

Cheers,
Philippe.

Hi Philippe,

I realized that I can either do

original->SetBranchAddress(…)
copy = original->CloneTree(0)

or

copy = original->CloneTree(0)
original->SetBranchAddress(…)
copy->SetBranchAddress( to the same buffer as the one used by original )

Does this sound sensible?
Thanks,
Raz

Hi Raz,

In both case, you should only have to set the branch addresses on the original. Could you send me a running example showing the case where:

copy = original->CloneTree(0)
original->SetBranchAddress(…)

fails to set properly the address of the copy.

Thanks,
Philippe.