Converting root tuple to another format


for cross-checking results between analyses, I need to take a root tuple and convert it identical to the style of another root tuple. What would be the most straight-forward way for doing this?

The original format does not have all the variables that the desired format has, and in these cases just zeroes have to be filled to the unavailable variables.

I have tried to do this by using the (desired format) class generated by TTree->MakeClass(“convert”), cloning the tree structure and subsituting the variable values with values from the original format, but I have not had luck with this approach.

Examples of the root tuple formats can be found here: … ormat.root … ormat.root

I’m sorry for the 500 Mb file sizes; I did not have luck in shrinking the files either.




What is the actual code you tried? Note that directly cloning a TTree while it is in MakeClass mode is not (correctly) supported.


Hi Philippe,

my code is attached, the main piece being TupleTransformer.C.

I managed to add a new item to the tree, but when trying to change values of an existing variable I face problems. I manage to affect the variable EvtHdr__mRun; it gets filled with a very big number 100 times instead of the loop variable that I try to fill it with.
Also, in my ResultTuple.root (attached) all the variables are just filled with zeroes instead of tha values from the DesiredFormat.root.

If you wish to run the code, the used (but afaik useless) libraries etc can be found from the package … former.tgz

The macro can be run with command $root runTupleTransformer.C’(“DesiredFormat.root”)’

ResultTuple.root (31 KB)
runTupleTransformer.C (469 Bytes)
TupleTransformer.h (27.4 KB)
TupleTransformer.C (2.41 KB)