Using TTree::MakeClass()

Hello
I am trying to create my own derived class from a class generated via

 TFile *inFile = TFile::Open(fn);
  inFile->ls();
 
  TTree *dataTree;   
inFile->GetObject("myG4dataTree", dataTree);
 dataTree->MakeClass("MyDataTree");

I have created my own class called G4TreeEngine which I have attached, I have created the G4TreeEngineLinkDef.hxx and makefile. Question: Do I need to also include the ClassImp line in my MyDataTree class? It would be odd since each time I generate this class viadataTree->MakeClass(“MyDataTree”); then i woul dhave to edit the file to include this line.
When I compile, I get the following error:

What am I missing?
Thanks,
C.

How about: #pragma link C++ class MyDataTree+;

Sorry, I forgot to attach my files…
I have in my G4TreeEngineLinkDef.hxx

C.


#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class MyDataTree+;
#pragma link C++ class G4TreeEngine+;


#endif

my makefile looks like this:

all:
	rm -f core G4TreeEngine
	rootcint -f G4TreeEngineDict.cxx -c MyDataTree.hxx G4TreeEngine.hxx G4TreeEngineLinkDef.hxx
	g++ `root-config --cflags --glibs` -o G4TreeEngine  G4TreeEngine.cxx G4TreeEngineDict.cxx

clean:
	rm -f *.*~ G4TreeEngineDict.cxx G4TreeEngineDict.hxx core G4TreeEngine

G4TreeEngineLinkDef.hxx (193 Bytes)
MyDataTree.hxx (8.1 KB)
MyDataTree.cxx (1.46 KB)
G4TreeEngine.cxx (1.86 KB)
G4TreeEngine.hxx (304 Bytes)

I was missing one declaration in my makefile. now everything seems to be working. I have still the question regarding the ClassImp() call inside the generated class… is it needed?

I will experiement further later on…
Just to complete this post, changes in my make file was:

g++ `root-config --cflags --glibs` -o G4TreeEngine  MyDataTree.cxx G4TreeEngine.cxx G4TreeEngineDict.cxx

Cheers,
C.

A small fix to your “G4TreeEngine.cxx”: printf("At %lld Entry %d hits %d %d %d \n",jentry+k,k,na_hits,ng_hits,nu_hits); and to your “Makefile”: `root-config --cxx --cflags` -o G4TreeEngine MyDataTree.cxx G4TreeEngine.cxx G4TreeEngineDict.cxx `root-config --glibs`

See [url]Simple way to create and merge shared libraries? for some additional neat Philippe’s notes concerning “ClassDef” / “ClassImp” / “TObject inheritance”.

Just a BIG thank you!
C.