Hello, I am trying to read a root file in a root session while a stand alone program is writing a tree to the file. When I try to open it I get errors like Error in <TFile::ReadKeys>: reading illegal key, exiting after 0 keys Info in <TFile::Recover>: test.root, recovered key TTree:t2 at address 75342 I searched the archives and found http://root.cern.ch/root/roottalk/roottalk03/4491.html where and example was given on how to do this, however I can't get this example to run so I am not sure if its a problem with my version or if I'm still doing something wrong. the code I copied from that example is given here 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 } } 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(); } } } I ran treew() in one root session while I did the following in another. root [0] .L treew.C root [1] treer(); This is what returned after that. Error in <TFile::ReadKeys>: reading illegal key, exiting after 0 keys Info in <TFile::Recover>: junk.root, recovered key TNtuple:ntuple at address 1367252 Error in <TFile::ReadKeys>: reading illegal key, exiting after 0 keys *** Break *** segmentation violation Generating stack trace... 0x401a1dd1 in TUnixSystem::StackTrace() + 0x367 from /opt/root/lib/root/libCore.so 0x401a099e in TUnixSystem::DispatchSignals(ESignals) + 0x78 from /opt/root/lib/root/libCore.so 0x4019fbcf in <unknown> from /opt/root/lib/root/libCore.so 0x401a35a9 in <unknown> from /opt/root/lib/root/libCore.so 0x40cb7685 in <unknown> from /lib/libpthread.so.0 0x40e075f8 in <unknown> from /lib/libc.so.6 0x405806f6 in G__exec_asm + 0x7ff from /opt/root/lib/root/libCint.so 0x40574614 in G__exec_loop + 0x525 from /opt/root/lib/root/libCint.so 0x4057482e in G__exec_while + 0x77 from /opt/root/lib/root/libCint.so 0x40576bf0 in G__exec_statement + 0x1f3b from /opt/root/lib/root/libCint.so 0x4054e95c in G__interpret_func + 0x1d84 from /opt/root/lib/root/libCint.so 0x405363a0 in G__getfunction + 0x1817 from /opt/root/lib/root/libCint.so 0x4052f8df in G__getitem + 0x4b4 from /opt/root/lib/root/libCint.so 0x4052e60b in G__getexpr + 0x74f6 from /opt/root/lib/root/libCint.so 0x405709aa in G__exec_function + 0x129 from /opt/root/lib/root/libCint.so 0x40576fb5 in G__exec_statement + 0x2300 from /opt/root/lib/root/libCint.so 0x40518668 in G__exec_tempfile_core + 0x2d5 from /opt/root/lib/root/libCint.so 0x4051880a in G__exec_tempfile_fp + 0x22 from /opt/root/lib/root/libCint.so 0x4057eb38 in G__process_cmd + 0x43d3 from /opt/root/lib/root/libCint.so 0x40150c87 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0x9b from /opt/root/lib/root/libCore.so 0x400da433 in TApplication::ProcessLine(char const*, bool, int*) + 0x561 from /opt/root/lib/root/libCore.so 0x40c84c00 in TRint::HandleTermInput() + 0x11c from /opt/root/lib/root/libRint.so 0x40c83be6 in TTermInputHandler::Notify() + 0x24 from /opt/root/lib/root/libRint.so 0x40c853a0 in TTermInputHandler::ReadNotify() + 0x12 from /opt/root/lib/root/libRint.so 0x401a0d0b in TUnixSystem::CheckDescriptors() + 0xed from /opt/root/lib/root/libCore.so 0x401a04db in TUnixSystem::DispatchOneEvent(bool) + 0x101 from /opt/root/lib/root/libCore.so 0x4012518d in TSystem::InnerLoop() + 0x1b from /opt/root/lib/root/libCore.so 0x40125126 in TSystem::Run() + 0x78 from /opt/root/lib/root/libCore.so 0x400dae73 in TApplication::Run(bool) + 0x2d from /opt/root/lib/root/libCore.so 0x40c847d5 in TRint::Run(bool) + 0x2e1 from /opt/root/lib/root/libRint.so 0x08048782 in main + 0x6e from /opt/root/bin/root.exe 0x40df3e3e in __libc_start_main + 0xce from /lib/libc.so.6 0x08048685 in _Unwind_Resume + 0x31 from /opt/root/bin/root.exe Root > Function treer() busy flag cleared root [2] I'm using Root Version 3.05/04 Compiled for linuxdeb with thread support. Thank you for your assistance Mark
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET