8/27/2013

Using MyClass in a CINT macro

When I am evaluating something in my C++ program and calling a CINT macro by

gROOT->Macro(mymacro.C);

to draw figures, I need to pass parameters of the evaluation to this macro.
When the number of parameters increases and their structures get complicated,  passing them by

mymacro.C(hard coded parameter list)

is not useful. In this case, I prepare a class MyClass to define a set of parameters to use
in my evaluation and pass it to the macro. Results of the evaluation kept in MyClass
can certainly be passed to the macro for drawings. The way to do this is well described in
The CINT Dictionary Generator.

Here I note my sample case where MyClass is stand alone and not inheriting from TObject class.
MyClass is defined in MyClass.h and implemented in MyClass.cpp
MyClass has a constructor without arguments.
Parameters are defined as static members of MyClass.
MyClass is called in mymacro.C as

MyClass passParams;

In the Makefile which I showed on Aug. 13, the following lines are added to create
a dictionary MyClassDict.o to compile with the main part:
CINTCLASS = MyClass
UOBJS := $(UOBJS) $(CINTCLASS).o $(CINTCLASS)Dict.o
$(CINTCLASS)Dict.cpp: $(CINTCLASS).h
<<tab>> rootcint -f $(CINTCLASS)Dict.cpp -c $(CINTCLASS).h

Now I can draw figures of results from a C++ computation interactively in CINT.

No comments:

Post a Comment