Problems with modifying branch in cloned tree

Hi,

although I worked several times before with CloneTree I cannot find the answer to the following problem: there are 5 jets in my input tree of which I want to skip one in my cloned tree. To do so I have to set the value of the branch “njt” from 5 to 4 and write only 4 jet pt’s into the branch “jtpt”. What I did was disabling the branches “njt” and “jtpt” in the input tree, clone the tree into a tree tmp.root, enabling the branches in the input tree again to have access to the input data and finally creating new branches “njt” and “jtpt” in the output tree. The problem is, when I call the output branches to be filled instead of the new input (njt=4) I get two branches of the same name “njt” with the old inputs (njt=5).
I guess that has something to do with two branches “njt” existing both in the input and output tree, but I do not see when b_njt is defined on the output tree how the wrong branch gets filled.
I attach a shortcut of my program that should compile standalone.

Thanks in advance for your help

Petra
modifytree_x.cpp (6.41 KB)

Hi,

Most likely one of the branch you did not disable still depend on the njt branch (as a size of its array).
Use myclonedtree->Print() after cloning to see what was copying (or not).

Philippe

Hi,

thanks for your help! Some other branches depended on njt, indeed. I solved that problem but found another one. A variable that I modify before filling is correctly modified when I print it to screen but is filled wrong in the tree. Is there a way to check from which variable a branch gets it’s input before filling it?

Petra

For each branch you can call GetAddress and see where its point to.
For branches containing objects, you can also do branch->Print(“debugAddress”);

Cheers,
Philippe