Hi Matt, I have no problems with your program (compiled & interpreted). I am pretty sure that your problem is the following; Looking at the results in compiled mode, one clearly sees that the VTBL for the class TTree is wrong. TTree::GetNbranches return TTree::GetAutoSave ==> You are compiling with a TTree.h file that does not match the one in $ROOTSYS/lib/libTree.so ==> Let me know. Rene Brun > > Why does the attached trivial `main.cxx' not work when it is compiled, > but works just fine when it is interpreted? Here is the output from > running the same file in both "compiled mode" and "interpreted mode": > > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > begin compiled output > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > $ ./main > ntuple has 1000000000 branches > ntuple has nan entries > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > end compiled output > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > begin interpreted output > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > $ root -l -b -n -q main.cxx > ******************************************* > * * > * W E L C O M E to R O O T * > * * > * Version 2.22/06 23 June 1999 * > * * > * You are welcome to visit our Web site * > * http://root.cern.ch * > * * > ******************************************* > > CINT/ROOT C/C++ Interpreter version 5.14.6, Jun 10 1999 > Type ? for help. Commands must be C++ statements. > Enclose multiple statements between { }. > root [0] > Processing main.cxx... > ntuple has 32 branches > ntuple has 998 entries > (int)0 > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > end interpreted output > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > It is as if the TTree in the compiled version of "main.cxx" isn't being > initialized by the TTree named "h10" in the test ".root" file > (i.e. notice the nice round number, 1E+09, for the number of branches, > and the NAN for the number of entries). However, clearly the TFile and > TTree pointers are valid, as evidenced by the two assert statements. > > I have included a Makefile (for RedHat Linux 6.0 Intel) which builds the > compiled version of "main.cxx". This Makefile may only require editing > "ROOTSYS" in order to work on other platforms. Simply type "make check" > to demonstrate my problem. The interpreted versions of "main.cxx" is > run with the command "root -l -b -n -q main.cxx". > > Note that the test file, > "/afs/slac.stanford.edu/public/users/langston/root/wabmc_test.root", > which is obviously served by an AFS server, is also available via > anonymous ftp at > "ftp://ftp.slac.stanford.edu/users/langston/root/wabmc_test.root". > > Machine configuration > --------------------- > RedHat Linux 6.0 Intel > kernel 2.2.5 (rpm version kernel-2.2.5-22) > glibc 2.1.1 (rpm version glibc-2.1.1-6) > egcs 1.1.2 (rpm version egcs-1.1.2-12) > binutils 2.9.1.0.23 (rpm version binutils-2.9.1.0.23-1 > ROOT 2.22.04 > > -- > Matthew D. Langston > SLD, Stanford Linear Accelerator Center > langston@SLAC.Stanford.EDU > > ------------------------------------------------------------------------ > #ifndef __CINT__ > #include <TROOT.h> > #include <TFile.h> > #include <TTree.h> > #endif > > #include <cassert> > #include <iostream> > > int > main( int argc, const char* argv[] ) > { > #ifndef __CINT__ > TROOT myApplication( "WAB", "WAB MC test" ); > #endif > > TFile* file = new TFile( "/afs/slac.stanford.edu/public/users/langston/root/wabmc_test.root" ); > assert( file != 0 ); > > TTree* ntuple = ( TTree* ) file->Get( "h10" ); > assert( ntuple != 0 ); > > cerr << "ntuple has " << ntuple->GetNbranches() << " branches" << endl; > cerr << "ntuple has " << ntuple->GetEntries() << " entries" << endl; > > if ( ntuple->GetEntries() != 998 ) > { > exit( 1 ); > } > > return 0; > } > > ------------------------------------------------------------------------ > # -*- Makefile -*- > # > # Matthew D. Langston <langston@SLAC.Stanford.EDU> > # 1999-06-27 > > ## System dependent macros. > CC = g++ > CXX = g++ > CPPFLAGS = -g -Wall $(ROOT_CFLAGS) > LDFLAGS = $(ROOT_LDFLAGS) $(ROOT_LIBS) > > ## ROOT macros. > ROOTSYS = /usr/local/root > ROOT_CFLAGS = -I$(ROOTSYS)/include > ROOT_LDFLAGS = -L$(ROOTSYS)/lib -Wl,-rpath,$(ROOTSYS)/lib > ROOT_LIBS = -lCint -lNew -lBase -lClib -lCont -lFunc -lGraf -lGraf3d \ > -lHist -lHtml -lMatrix -lMeta -lMinuit -lNet -lPhysics \ > -lPostscript -lProof -lTree -lUnix -lZip -lm -ldl > > # Everything below here is "generic", meaning it only requires that you > # have GNU make and gcc. You shouldn't have to edit anything below this > # line. > SOURCES = main.cxx > PROGRAMS = main > TESTS = $(PROGRAMS) > > .PHONY: all check clean realclean > all: $(PROGRAMS) > > # Include dependency files. > include $(SOURCES:.cxx=.d) > > realclean: clean; rm -f *.d $(PROGRAMS) > clean:; rm -f core a.out *.o *~ > check: $(TESTS) > @failed=0; all=0; \ > srcdir=$(srcdir); export srcdir; \ > for tst in $(TESTS); do \ > if test -f $$tst; then dir=.; \ > else dir="$(srcdir)"; fi; \ > if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \ > all=`expr $$all + 1`; \ > echo "PASS: $$tst"; \ > elif test $$? -ne 77; then \ > all=`expr $$all + 1`; \ > failed=`expr $$failed + 1`; \ > echo "FAIL: $$tst"; \ > fi; \ > done; \ > if test "$$failed" -eq 0; then \ > banner="All $$all tests passed"; \ > else \ > banner="$$failed of $$all tests failed"; \ > fi; \ > dashes=`echo "$$banner" | sed s/./=/g`; \ > echo "$$dashes"; \ > echo "$$banner"; \ > echo "$$dashes"; \ > test "$$failed" -eq 0 > > # pattern rules > %.d: %.cxx; $(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< | sed '\''s/\($*\)\.o[ :]*/\1.o $@: /g'\'' > $@; test -s $@ || rm -f $@' > %.o: %.cxx; $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:35 MET