Dear Rene, thank you very much for your help. Your samples work perfectly. I found an interesting bug/feature of the rootd server. If I change in your samples TFile to TNetFile and file to root://server/junk.root where server the name of the computer with the running rootd. Write part works perfectly, but the read part says: "Error in <TNetFile::TNetFile> file already opened in write mode". When I use mounted path via nfs everything is OK. Is it possible to use rootd in a DAQ/Viewer way how it's shown in your examples? Best regards, Yuriy. RB> You will find below two small scripts treew.C and treer.C RB> Run treew.C in a Root session. This will update the file at regular RB> intervals. RB> In a separate Root session, run treer.C. This will update an histogram RB> reading fresh data only. RB> You can combine this example with the new producer/consumer example RB> in $ROOTSYS/tutorials/spyserv.C and spy.C (version 3.03 only in CVS) RB> void treew() { RB> TFile f("junk.root","recreate"); RB> TNtuple *ntuple = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i"); RB> Float_t px, py, pz; RB> for ( Int_t i=0; i<1000000; i++) { RB> gRandom->Rannor(px,py); RB> pz = px*px + py*py; RB> Float_t random = gRandom->Rndm(1); RB> ntuple->Fill(px,py,pz,random,i); RB> if (i%1000 == 1) { RB> ntuple->AutoSave(); RB> f.SaveSelf(); RB> } RB> } RB> } RB> void treer() { RB> TFile f("junk.root"); RB> TCanvas c1; RB> Int_t first = 0; RB> while(1) { RB> f.ReadKeys(); RB> TTree *ntuple = (TTree*)f.Get("ntuple"); RB> if (first == 0) ntuple->Draw("px>>hpx","","",10000000,first); RB> else ntuple->Draw("px>>+hpx","","",10000000,first); RB> first = (Int_t)ntuple->GetEntries(); RB> delete ntuple; RB> c1.Update(); RB> gSystem->Sleep(1000); //sleep 1 second RB> } RB> } RB> Rene Brun RB> Yuriy Prokazov wrote: >> >> Dear ROOTers, >> I'd like to make work 2 independent processes where one of them >> writes information into the file and other reads it. If it is >> possible I would like to use TNetFile (if these processes are >> running on a different computers) or via TFile if (they are in >> the single box). I faced with following problem: from the WRITE >> process I create file using TFile and create TTree object with >> the single branch of a simple type. Every second WRITE process >> fills the branch and saves some amount of data. In the READ >> part I open the file using TFile::Open(). >> >> The problem is that in the READ call tree->GetEntries() always >> returns the same number. From the ROOT source code it is >> obviosly clear that it could return only the one value that have >> been saved during initialization. >> >> But the same time file->GetFileSize() show that the file is >> growing. >> >> Is there any way how to make independed reading/writing and say >> to READ process that the file was changed and it is required to >> read new data? >> >> Thank you. >> Best regards, >> Yuriy.
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:41 MET