Generate ROOTCINT dictionary to be used within GEANT4

Hi all,

I am currently trying to merge GEANT4 and ROOT to book, fill and write a

TTree *t1Tree = new TTree(“t1”,“3L_sim2_rt Output Data”);

that consists of three major branches that each has a bunch of leaves as defined in the class MyTree (see below).

MyTree *sct = new MyTree;
MyTree *pm1 = new MyTree;
MyTree *pm2 = new MyTree;

TBranch *Scint = t1Tree->Branch(“Sct.”,“MyTree”,&sct,64000,1);
TBranch *Pmt1 = t1Tree->Branch(“Pmt1.”,“MyTree”,&pm1,64000,1);
TBranch *Pmt2 = t1Tree->Branch(“Pmt2.”,“MyTree”,&pm2,64000,1);

The definition of the Class is very simple, it only contains a bunch of variable definitions.

%%%%%% Definition of the Class: MyTree %%%%%%%%%%%%%%

#ifndef XeMyTree_h
#define XeMyTree_h 1

#include “XeEventAction.hh”
#include “globals.hh”
//#include “Rtypes.h”

class MyTree{


int eventid;
int step;
int Nohits;
char type[25];
float xp;
float yp;
float zp;
float ke;
float Etot;
float time;
// ClassDef(MyTree, 1);



What I learned is that ROOT needs a dictionary file for each such user-defined class in order for it to know how to handle the class.

I tried to generate such a dictionary file, using the ROOTCINT utility as follows:
rootcint -f -c -I/sw/include/geant4/ -I/sw/include/ -p include/XeMyTree.hh MyTreeLinkDef.h

And the output after execution is:

In file included from include/XeEventAction.hh:20,
from include/XeMyTree.hh:4,
from /var/tmp/tmp.0.lO3mbp_rootcint.h:1,
from /var/tmp/tmp.5.EGLcQj_cint.cxx:1:
MyTree_Dict.h:5:2: #error MyTree_Dict.h/C is only for compilation. Abort cint.

Can somebody explain me why cint aborts? And tell me how to solve this problem? I am actually not very sure about the general procedure of generating such a dictionary.

The output after using rootcint is a *dict.h and * file, do I still have to do anything with them first? Or is it enough to simply include the files (once they are generated properly) into my GEANT project and compile it as a whole?

Thanks for your help !!


Hello Joerg,

I think there is a misunderstanding. Generated dictionary has to be compiled. It is not for interpretation. The error message you are seeing tells you that you try to interpret the dictionary code. Please read ROOT manual again.

Thank you
Masa Goto

Hi Masa,

well there surely is a misunderstanding, because I don’t really understand how that generally works. And my problem really is, that I cannot really find a decent description how to generate a dictionary file.

That’s why I have tried to get more info on that in this forum and tried to do what others did, but that seems to be not working for me. So where exactly in the ROOT user’s guide can I find these information? (So far I only have found something about it in “Example: MakeProject” p.198 ff.)

What I think to understand is that rootcint is supposed to GENERATE the two *_dict.C/.h files, right? That’s why I erase them before executing the rootcint command line. And still the ERROR-message complains about these files, that were just generated by rootcint itself. That is what puzzles me most.

So would you do me the favour and provide me with some kind of TODO list (or tell me where I can find one), in order to get a dictionary file, that I can smply include into my G4 project?

Thanks very much!



Read the chapter on Adding a class

[quote]I tried to generate such a dictionary file, using the ROOTCINT utility as follows:
rootcint -f -c -I/sw/include/geant4/ -I/sw/include/ -p include/XeMyTree.hh MyTreeLinkDef.h
This is perfectly sensible way to generate the C++ source for the dictionary. Note that the ‘-f’ means that you do not need to delete the previous dictionary files (they will be overload). However this also means that you makefile need to have a dependency from on XeMyTree.hh and MyTreeLinkDef.h (and any other files they includes).

Yes it is … More exactly you need to using the C++ compiler to generate a .o files. Then you need to include those .o files in a shared library. If you are not using a shared library then you need to add those .o files directly to link line of your executable.


PS. Note that just saying “And the output after execution is:” those not tell us what you really try and force to guess at what your problem really is. The more specific you are the better the answer will be.