How to write some static data (that does not change) into a Ttree?

Dear All,

I did a quick search and did not find an example.
I would like to write some data - basically, metadata such as string of comments, array of calibration constants, and some constants that define run configuration and do not change, but they are needed when the tree is analyzed so I would look those up in that meta data section.
Please point me to an example :slight_smile: Could not find it! Thanks!

I.m not sure I understand what you’re asking for… Could you elaborate a bit?

For example,
I have a few dozen calibration constants that I multiply the data counts to get some sensible physical units in each channel. I don’t want to drag and write those copies of that array in each event. I would want to have an array of them written once at the beginning and just have it in the tree to address it when I process each event and do the multiplications necessary.
It is really a newbie thing - honestly, I have not worked with ROOT in several years now… forgot it all.

If you didn’t find any example in the ROOT primer, or in the tutorials, nothing in this collection of ROOT courses, or any post on this forum, then maybe @pcanal can give you some hints

If I say, write an object once, i.e. outside of the events loop, in its separate branch, that is probably what I want, right?
Say, how do you write a run number? The whole tree is for a single run. It is not smart to write it in every event, right? So I guess i can make another class, say, metadata() and write it once, tree->Write() outsire of the loop… right?

Thanks for trying to help.

Sure, you can write a meta data class once in the file next to the tree. You can write anything in a ROOT file

Thank you guys! It was shockingly easier than I had thought :slight_smile:
Really appreciate your responses.
I will create an example and post it here for the folks such as myself… soon!