Re: [ROOT] Tree not readable

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Mar 22 2002 - 15:09:33 MET


Hi,

Could you add a statement:
   fTree->Print();
 just after fTree->Write(..
then in the program reading the file, do:

  TFile *file = new TFile( argv[1] );
  f->ShowTreamerInfo();  //<===add this line

and
    TBranch *logb = tree->GetBranch( "LogBranch" );
    logb->SetAddress( &logm );    // I assume you have LogMessage *logm = 0;
    gDebug=2;   //(need #include "Tsystem.h") <===add this line

Send me the output

Rene Brun

Hermann-Josef.Mathes@ik.fzk.de wrote:
> 
> Dear rooters,
> 
> I have a problem in reading objects written to a tree from my program. If
> I load the shared library into a ROOT session, everything works fine, I
> can see the leaves of the branch and plot their content.
> 
> Writing is done in the following way:
> 
> LogMessage   *fLogMessage = new LogMessage();
> 
> TFile*  fLogFile = new TFile( filename, "recreate" );
> 
> TTree* fTree = new TTree( "LogTree", "Tree containing LogMessage objects" );
> 
> // class LogMessage in namespace Logging
> fTree->Branch( "LogBranch", "Logging::LogMessage", &fLogMessage, 10000, 1 );
> 
> fTree->Fill();
> 
> after writing many LogMessage objects to the file I do:
> 
> fLogFile->Write( 0, TObject::kOverwrite );
> fLogFile->Close();
> 
> Reading is (should be) then done be the following code fragment:
> (I tried also the variants as offered by the MakeClass() method).
> 
>   TFile *file = new TFile( argv[1] );
>   TTree *tree = (TTree *)file->Get( "LogTree" );
> 
>   if ( tree ) {
> 
>     TBranch *logb = tree->GetBranch( "LogBranch" );
>     logb->SetAddress( &logm );
>     for ( Int_t n_entry=0; n_entry<tree->GetEntries(); n_entry++ ) {
> 
>       tree->GetEvent( n_entry );
>     }
>     delete tree;
>   }
> 
> The code crashes in the GetEvent() method:
> Program received signal SIGSEGV, Segmentation fault.
> 0x4022d930 in G__TString_ShowMembers_3_12__FP8G__valuePCcP8G__parami ()
>     at include/TStreamerInfo.h:127
> 127     include/TStreamerInfo.h: No such file or directory.
> (gdb) back
> #0  0x4022d930 in G__TString_ShowMembers_3_12__FP8G__valuePCcP8G__parami ()
>     at include/TStreamerInfo.h:127
> #1  0x40560b0e in G__CallFunc::Exec () from /cern/root/lib/libCint.so
> #2  0x4014f063 in TClass::BuildRealData (this=0x84235c8, pointer=0x8467520)
>     at meta/src/TClass.cxx:478
> #3  0x40152d92 in TClass::ReadBuffer (this=0x84235c8, b=@0x85401c8,
>     pointer=0x8467520) at meta/src/TClass.cxx:1583
> #4  0x40167e31 in TStreamerInfo::ReadBuffer (this=0x841b828, b=@0x85401c8,
>     pointer=0x8467510 "", first=2) at meta/src/TStreamerInfo.cxx:1864
> #5  0x40ade7bd in TBranchElement::ReadLeaves () from /cern/root/lib/libTree.so
> #6  0x40ad7e3a in TBranch::GetEntry () from /cern/root/lib/libTree.so
> #7  0x40add6ec in TBranchElement::GetEntry () from /cern/root/lib/libTree.so
> #8  0x40add69c in TBranchElement::GetEntry () from /cern/root/lib/libTree.so
> #9  0x40af3ea0 in TTree::GetEntry () from /cern/root/lib/libTree.so
> #10 0x40af6ae5 in TTree::GetEvent () from /cern/root/lib/libTree.so
> #11 0x804d683 in main (argc=2, argv=0xbfffee24) at FileBrowser.cc:70
> 
> I think it is a very trivial error which I do but I cannot find it. Do
> have any suggestions ? I am using 2.03/07
> 
> Thank you
>   Hermann-Josef
> 
> **************************************************************************
> *                                                                        *
> *   Dr. Hermann-Josef Mathes                                             *
> *   KASCADE & AUGER Collaboration                                        *
> *   Forschungszentrum Karlsruhe                Phone: +49 7247 822429    *
> *   Institut fuer Kernphysik                   FAX:   +49 7247 824075    *
> *   POB 3640                                                             *
> *   D-76021 Karlsruhe/Germany                  Mail:  mathes@ik.fzk.de   *
> *                                                     hjmathes@web.de    *
> *                                                                        *
> *   Feel free to visit my homepage:                                      *
> *          http://www-ik3.fzk.de/~mathes/Welcome.html                    *
> **************************************************************************



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:46 MET