Problem with class import / TTrees

From: Ingo Froehlich (Ingo.Froehlich@exp2.physik.uni-giessen.de)
Date: Thu Aug 05 1999 - 16:20:43 MEST


Hi ROOTers,

I'm trying to gain experience with root-trees. For this reason I tried to
import a small test-class to root:

-----------------Momentum3.h
#ifndef MOMENTUM3_H
#define MOMENTUM3_H
#include "TObject.h"

class Momentum3: public TObject
{
public:
  Momentum3();
  Float_t p;

  ClassDef(Momentum3,1)
};
#endif
-----------------Momentum3.cpp
#include "Momentum3.h"
ClassImp(Momentum3)

Momentum3::Momentum3()
{
p=0;
};
-----------------
This class has been used to fill a root-tree:
-----------------Main.cpp
#include "TROOT.h"
#include "TFile.h"
#include "TTree.h"
#include "TBranch.h"
#include "Momentum3.h"

int main(void)
{
TROOT root("disto","Disto Analysis");
Momentum3 mom, *mymom = & mom;
TFile *hfile = new TFile("my.root", "RECREATE");
TTree *tree = new TTree("T", "MyTree");
tree->Branch("momentum", "Momentum3", &mymom, 64000, 1);

for (int i=0; i< 3; i++)
  {
    mymom->p=i;
    tree->Fill();
  }

hfile->Write();
hfile->Close();
return 0;
}
----------------
If I start my Main, it tells me:
Fatal in <operator delete>: unreasonable size (1084523672)
aborting

In addition, I compile a *.so from the Momentum3 class and the Dictionary,
but if I try to load this into CINT, a segmentation fault appears

Do I misunderstand something?

Thanks for your help and best regards,

Ingo Froehlich

--
Ingo Froehlich, II. Physikalisches Institut, Universitaet Giessen
Heinrich-Buff-Ring 16, D-35392 Giessen           |  Tel.: 0641 - 99 33250
EMail: Ingo.Froehlich@exp2.physik.uni-giessen.de |  Fax : 0641 - 99 33209
Sekretariat II. Physik: 0641 - 99 33261          |                    :-)


PS: My Makefile:
----------------
.SUFFIXES: .cpp .c
PACKAGE         = Tproject
VERSION         = 0
DICT		= Momentum3.h
OBJ		= EventDict.o Momentum3.o Main.o
TOBJS           = EventDict.o Momentum3.o

ROOTLIBS      = -L$(ROOTSYS)/lib -lNew -lBase -lCint -lClib -lCont -lFunc
\
                -lGraf -lGraf3d -lHist -lHtml -lMatrix -lMeta -lMinuit
-lNet \
                -lPostscript -lProof -lTree -lUnix -lZip
ROOTGLIBS     = -lGpad -lGui -lGX11 -lX3d

# Linux
C             = gcc
CFLAGS        = -O3 -Wall -D_DEBUG
CXX           = g++
CXXFLAGS      = -O3 -Wall -fPIC -I$(ROOTSYS)/include -D_DEBUG -DLINUX
LD            = g++
LDFLAGS       = -g
SOFLAGS       = -shared
LIBS          = $(ROOTLIBS) -lg++ -lm -ldl -rdynamic
GLIBS         = $(ROOTLIBS) $(ROOTGLIBS) -L/usr/X11R6/lib \
                -lXpm -lX11 -lg++ -lm -ldl -rdynamic


#------------------------------------------------------------------------------


all:            Momentum.so Main


Momentum.so:	$(TOBJS)
		$(LD) $(SOFLAGS) $(TOBJS) $(GLIBS) -o Momentum.so
		@echo "$(PROGRAMM) done"

Main:		$(OBJ)
		$(LD) $(LDFLAGS) $(OBJ) $(GLIBS) -o Main
		@echo "$(PROGRAMM) done"


clean:
		@rm -f $(OBJS) core

.cpp.o:
	@echo compiling $<
	$(CXX) $(CXXFLAGS) -c $<

.c.o:
	@echo compiling $<
	$(C) $(CFLAGS) -c $<

EventDict.cpp: $(DICT)
	@echo "Generating Dictionary"
	@$(ROOTSYS)/bin/rootcint -f EventDict.cpp -c $(DICT)



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:37 MET