Home | News | Documentation | Download

Copy TTree with one or two rescaled branches

Hi,

let’s assume I have a TTree of the following structure:
TLeaf1
TLeaf2

TBranch1
TBranch2

My goal is to add a ScaledTLeaf1 and ScaledTLeaf2 to the TTree which are just scaled versions of TLeaf1 and TLeaf2, e.g. every value in TLeaf2 is multiplied by a specific factor. What is the most efficient way to do this? And is there a way to do this completely in memory, i.e. without actually writing out anything? Is it possible to prevent a full copy?

Thanks!

Hi @mark1,
the title of the post mentions copying a TTree, but in the text you say it would be better to not write anything to disk. What do you mean with “adding to the TTree” then, exactly? What do you need to do with the data? Also are you using python or C++?

Cheers,
Enrico

Hi @eguiraud,
I don’t necessarily need the information of the rescaled branches after my code (C++) has terminated. I would like to prevent to writing the TTree to disk, as I have to do this many times and I need a fast and efficient solution.
Thanks

But what do you need to do with the rescaled branches? Because the most efficient thing to do, in principle, is to not store the branches at all: you can evaluate the values you need on the fly, for each entry, use them (e.g. to fill a histogram), and forget them.

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