Dear all,
I am trying to write a kind of acquisition system and I would like to directly use ROOT files to save the acquired data. I would like the system to produce “big” files (say 500MB each) but with some intermediate “small” update (say every 100MB), in order to enable another data monitoring program (ROOT-based) to read the intermediate data and show some plots.
I have tried the following (let me know if you need a working example):
TFile f("datafile.root","RECREATE");
TTree *tree1=new TTree(...........)
TTree *tree2=new TTree(...........)
// allocate all the needed branches
tree1->Branch(........)
tree2->Branch(........)
// acquisition loop
for(int iev=0;iev<MAX_EVENTS;iev++)
{
// acquire data to tree variables
// ...
//tree fill
tree1->Fill();
tree2->Fill();
if(iev%NEVENTS_UPDATE==0)
{
// update file for data monitoring program
// no cycles
tree1->Write(0, TObject::kOverwrite);
tree2->Write(0, TObject::kOverwrite);
}
}
f.Write();
f.Close();
I have noticed that the update step (i.e. the loop on all the trees to perform a write with the kOverwrite option) is really time-consuming and has a major impact on the overall performances… The importance of this factor depends also on the used numbers of trees (linearly?).
Do you have any advice? Am I missing something?
Thank you!
Luigi