Re: [ROOT] TTree of myclass

From: Rene Brun (brun@pcbrun.cern.ch)
Date: Wed Sep 15 2004 - 23:36:15 MEST


Hi Kevin,

You must set your branch pointer temprun to 0

TRun *temprun=0;

Rene Brun

On Wed, 15 Sep 2004, kevin 
reil wrote:

> Hi all,
> 
> I have a file which is a one branch tree of a small class (TRun)
> 
>   TRun *trun=new TRun();
>   TTree *tree = new TTree("mytree","My ROOT Tree");
>   tree->Branch("TRunBranch","TRun",&trun,32000,99);
> 
>   for (loop...) {
>     trun->FillFrom(nt,i);
>     tree->Fill();
>   }
> write and close.
> 
> If I start root, load the TRun library and then the file created I can 
> 
> {
>   TFile *f2 = new TFile("/home/reil/flash/data/trun_test.root","OPEN");
>   TRun *temprun;
>   TRun *trun;
>   TTree *tree =(TTree*)gROOT->FindObject("mytree");
>   Int_t nruns=(Int_t)tree->GetEntries();
>  
>   tree->SetBranchAddress("TRunBranch",&temprun);
>   tree->Dump();
>   for (Int_t i=0; i<nruns; ++i) {
>     tree->GetEntry(i);
> 
> and now use my class (loaded into temprun)
> 
> In a compiled program (e165), at the line
>     tree->GetEntry(i);
> 
> line I crash with 
>  *** Break *** segmentation violation
>  Generating stack trace...
> /usr/bin/addr2line: e165: No such file or directory
> /usr/bin/addr2line: e165: No such file or directory
> /usr/bin/addr2line: e165: No such file or directory
>  0x00298121 in TClass::BuildRealData(void*) + 0x511 from
> /data/root/lib/libCore.so
>  0x002af21f in TStreamerInfo::BuildOld() + 0x71 from /data/root/lib/libCore.so
>  0x0029bc00 in TClass::GetStreamerInfo(int) + 0x1a8 from
> /data/root/lib/libCore.so
>  0x00ee01d8 in TBranchElement::GetInfo() + 0xda from /data/root/lib/libTree.so
>  0x00ee1794 in TBranchElement::SetAddress(void*) + 0x8e from
> /data/root/lib/libTree.so
>  0x00f02376 in TTree::SetBranchAddress(char const*, void*) + 0xc0 from
> /data/root/lib/libTree.so
>  0x08049efd in Analyze() + 0x289 from e165
>  0x0804a990 in main + 0xc8 from e165
>  0x06dff770 in __libc_start_main + 0xf0 from /lib/tls/libc.so.6
>  0x08049be5 in TFile::TFile[in-charge](char const*, char const*, char
> const*, int) + 0x31 from e165
> Aborted
> 
> Is there something obvious here that I am missing? Or would I need a
> detailed debug?
> 
>  *******************************************
>   *                                         *
>   *        W E L C O M E  to  R O O T       *
>   *                                         *
>   *   Version   4.00/08    10 August 2004   *
>   *                                         *
>   *  You are welcome to visit our Web site  *
>   *          http://root.cern.ch            *
>   *                                         *
>   *******************************************
> 
> FreeType Engine v2.1.3 used to render TrueType fonts.
> Compiled for linux with thread support.
> 
> CINT/ROOT C/C++ Interpreter version 5.15.138, May 23 2004
> Type ? for help. Commands must be C++ statements.
> Enclose multiple statements between { }.
> Linux  2.4.22-1.2197.nptl #1 Thu Jul 1 15:14:28 EDT 2004 i686 i686
> i386 GNU/Linux
> 
> Thanks,
> Kevin
> 
> 
> 
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET