Creating a ROOT-file manually

Hello
I’m figuring out how to create a root file manually, instead of using a root framework.
I found some documentation in
root_cern/root/htmldoc/guides/users-guide/InputOutput.html
and in source: https_github_com/root-project/root/tree/master/io/doc/TFile,
from there I somehow understood how to write the ROOT file header.

Now I’m trying to figure out how TBasket and TTree are saved to the ROOT-file.

To understand this, I create the simplest uncompressed ROOT-file in the interpreter.

$ TFile *f = TFile::Open("myfyle.root", "RECREATE", "", 100, 0);
$ tree = TTree("mytree", "mytreetitle");
$ float var;
$ tree.Branch("mybranch0", &var);
$ var = 1;
$ tree.Fill();
$ tree.Write();
$ f->Write();

$ f->Map()
20211123/133509  At:100     N=122       TFile                     
20211123/133640  At:222     N=82        TBasket                   
20211123/133640  At:304     N=864       TTree                     
20211123/133650  At:1168    N=864       TTree                     
20211123/133650  At:2032    N=153       KeysList                  
20211123/133650  At:2185    N=14193     StreamerInfo              
20211123/133650  At:16378   N=57        FreeSegments              
20211123/133650  At:16435   N=1         END          

A question I didn’t understand from the documentation
what is the way to save TFile byte by byte (with 100 bytes 128 bytes)
what is the way to save TBasket byte by byte (with 228 bytes 82 bytes)
what is the way to save TTree byte by byte (with 304 bytes 864 bytes)

May be @pcanal can help.

if you want to create a ROOT file w/o the ROOT C++ libraries, you may want to have a look at other projects that already achieve such a thing.

I have actually given a talk about just this:

in there (page 10), you’ll find the (AFAIK) complete list of non-ROOT projects that can read (and sometimes write too) ROOT files:

hth,
-s

See also: ROOT: TFile Class Reference
ROOT: TKey Class Reference
ROOT: TBasket Class Reference
Physical Layout of Root Files.

But most importantly, what is your end goal?

There is a large data stream at the input.
Root files should be created at the output.
We want to write an alternative implementation of root file creation.

I can say, with excruciating details, that it’s a very long journey.
especially if you want to support TTree-like output.

(that said, I’d be interested to be pointed at your work/repository. if it’s a MIT/BSD-like license)

Why ? :). I.e. what are going to be the advantages of your alternative implementation?