Creating my own class


I have a C++ class that I made available for ROOT using ClassDef, classImp… as described in the chapter “Adding a Class” in the ROOT manual. I used ACLiC to generate the dictionnary and the shared library.

Some of my colleagues would rather use ROOT with python (hence PyROOT). PyROOT is working well with ROOT classes but how can I use my class?

For instance I have a class in teh file Power2D.C, ACLiC generates for me When, in Python, I try to load my class using “import Power2D_C” it complains:
“ImportError: dynamic module does not define init function (initPower2D_C)”

What is to correct way to generate the dictionnary? Obviously there is some functions missing. Should I use rootcint instead of ACLiC?



The easiest way is probably to use do:gROOT.ProcessLine(".L Power2D.C+");



when the .so is already available and no .rootmap file has been created to tickle the autoloader, the easiest thing is:import ROOT ROOT.gSystem.Load( "Power2D_C" )
With a proper .rootmap file for the autoloader to work with, and assuming that the class name is “Power2D”, the syntax would be:import ROOT myPower2DObject = ROOT.Power2D()