TTree and Thread compatibility

Hello,

I would like to use TTree in a multithread acquisition. And I have problems in implementing it.

On one side (the data producer), I open a new TFile and create a TTree in it,
and fill it with data (using Fill()).

the data producer code is here

[code]RootFilename=Filename;
rootfile=new TFile(RootFilename.toLatin1(),“create”);

tree=new TTree(“Mimac”,“donnees d’acquisition”);

tree->Branch(“Timestamp”,&RawEvent.timestamp,“timestamp/i”);

while (!abort)
{
i++;
RawEvent.start_time=2;
RawEvent.duration=i;
RawEvent.PosVectSize=3;
RawEvent.NRJVectSize=3;
RawEvent.IndexVector[0]=2*i;
tree->Fill();
tree->Write();
}

rootfile->Close();[/code]

On the other side, I would like to be able to access the data that are filled by the other Thread (even thought the Tfile isn’t
closed). So for that, in the thread that uses the data, I tried to open the same root file in read only mode every time I need to check what kind of events I’m receiving.and maybe plot a
few histogram and graphs

See an example in the two files fw.C and fr.C in attachment. Although not using threads you should be able to pick the idea.

Rene
fr.C (845 Bytes)
fw.C (1.83 KB)