Re: [ROOTDEV] compiling program with TTree

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Mon, 29 Jan 2007 10:11:14 +0100


Hi Christian,

You need two changes in your program:

 -In treeTestMacro.C, replace
  TTestBranch* branch;

          by
  TTestBranch* branch=0;

-In TTestBranch.h, just before the line "};", add  ClassDef(TTestBranch,1)

-then modify your makefile to generate the dictionary with rootcint like shown below
rootcint -f TTestBranchDict.cpp -c TTestBranch.h g++ -o runMakeTestTree.run runMakeTestTree.cpp TMakeTestTree.cpp \ TTestBranch.cpp TTestBranchDict.cpp `root-config --cflags --libs`

Rene Brun

Christian Hansen wrote:
> Dear Rooters,
>
> I'm having problems getting a small test program
> working where I tried to follow the instructions
> for TTree.
>
> I'm trying to produce a tree with an "home made" branch
> that I call TTestBranch;
>
> TTestBranch* testBranch = new TTestBranch();
> fTree->Branch("testBranch","TTestBranch",&testBranch,64000,99);
>
> When I run the program I get the error:
>
> [chris_at_localhost test]$ ./runMakeTestTree.run
> Error in <TTree::Bronch>: Cannot find class:TTestBranch
>
> But still a tree is produced in the file "testTree.root".
> When I try to read in the produced tree with a macro
> (treeTestMacro.C) I also get error:
>
> root [0] .x treeTestMacro.C
> Error in <TTree::SetBranchAddress>: unknown branch -> testBranch
>
> All files are attached in the tar ball test.tgz.
>
> I did some research and found out that I have to
> produce a dictionary with rootcint. So I tried
>
> rootcint -v -l -f tTestBranchDict.cpp -c TTestBranch.h
>
> and added ClassDef(TTestBranch, 1); in TTestBranch.h
> and ClassImp(TTestBranch); in TTestBranch.cpp.
> I also tried to change in the Makefile but it does not
> want to compile; "gmake" gives me errors like:
>
> TTestBranch.o(.text+0x1a9): In function `__static_initialization_and_destruction_0(int, int)':
> TTestBranch.cpp: undefined reference to `ROOT::GenerateInitInstance(TTestBranch const*)'
>
> All files are attached in the tar ball dictTest.tgz.
>
> I use Fedora 4 and ROOT Version 5.04/00.
>
> If someone could point out to me what I have to change
> to get this small test program working I would be very
> thanksful!
>
> Thanks!
> / Christian Hansen
>
> ================================================
> Dep. of Phys. Office: +1 250 721 7710
> Univ of Victoria Mobile: +1 250 588 0860
> PO Box 3055
> V8W 3P6 Victoria BC
> Canada
> ------------------------------------------------
> Home Page : http://particle.phys.uvic.ca/~hansen
> http://cern.ch/christian.hansen
Received on Mon Jan 29 2007 - 10:11:29 CET

This archive was generated by hypermail 2.2.0 : Tue Jan 30 2007 - 11:50:01 CET