Order of calling C++ code

I am calling my ROOT C++ code from python, however, I have problems in order of code execution. In my code my class returns a pointer to TF2*. It seems that the calling of the class method is executed before the TF2::Draw(), although the call is made later. I print the results of the class method Clean() with cerr and function called by TF2 with cerr - the cerr from the Clean() is printed earlier.

I attach two files than generate this behaviour - the cpp file should be compiled in ROOT with .L test.cpp+
code.zip (1.08 KB)


several things that I do not understand … for one, Clean() is not a class method, so which class method are you referring to? As for ordering of calls to the TF2 for drawing, the canvas can draw/redraw at any time (e.g. b/c it got obscured by another window and now needs to refresh the screen). These are responses to OS events that come in asynchronously and that is the nature of graphical windows. What kind of order would you want to enforce, and why (you’d make the window freeze by forcing order)?


There is “void lePSF::Clean()” in my class definition, that is what I ment.

Anyway, thanks very much - you reminded me that I need to call gPad.Modified() and gPad.Update() to get drawing in the moment I want it to draw. Now it works :slight_smile:

To clarify - I am attempting to use in python a code, which is calculating a rather complicated function. Because of the function call time, I store it in a matrix for specific parameters. When I want to redraw a function for completely different parameters, I need to clear the matrix. That’s why I need to call the cleaning method between to calls to Draw() in my code.