Hi Yuriy,
You will find below two small scripts treew.C and treer.C
Run treew.C in a Root session. This will update the file at regular
intervals.
In a separate Root session, run treer.C. This will update an histogram
reading fresh data only.
You can combine this example with the new producer/consumer example
in $ROOTSYS/tutorials/spyserv.C and spy.C (version 3.03 only in CVS)
void treew() {
TFile f("junk.root","recreate");
TNtuple *ntuple = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i");
Float_t px, py, pz;
for ( Int_t i=0; i<1000000; i++) {
gRandom->Rannor(px,py);
pz = px*px + py*py;
Float_t random = gRandom->Rndm(1);
ntuple->Fill(px,py,pz,random,i);
if (i%1000 == 1) {
ntuple->AutoSave();
f.SaveSelf();
}
}
}
void treer() {
TFile f("junk.root");
TCanvas c1;
Int_t first = 0;
while(1) {
f.ReadKeys();
TTree *ntuple = (TTree*)f.Get("ntuple");
if (first == 0) ntuple->Draw("px>>hpx","","",10000000,first);
else ntuple->Draw("px>>+hpx","","",10000000,first);
first = (Int_t)ntuple->GetEntries();
delete ntuple;
c1.Update();
gSystem->Sleep(1000); //sleep 1 second
}
}
Rene Brun
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