Write an STL container into a ROOT file

I’d like to save an STL container into a ROOT file. A lot of documentation is available for doing so for TTree branches, but I need to save a single container so I’d avoid using a TTree. Is there a way to do something similar to calling the Write() method for a TObject?

1 Like

Hi Nicola,

sure. For example:

TFile outputFile("outputFile.root","RECREATE");
std::vector<int> v {1,2,3,4};



Thanks Danilo. Before asking I searched for some “WriteSomething” method in the TFile doxygen but I found nothing, just because I didn’t expand the lists of inherited member functions…

Yes if we show the whole list expanded then people complained that it makes the doc unreadable . It is hard to satisfy every body …

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