Hello,
Documentation for TExec is mentioning 3 use-cases. ROOT: TExec Class Reference
I want to use the second case to modify some histogram features (e.g. title, etc…) using a macro.C. I know gPad is known, but is it always pointing to the pad containing the histogram ?
The documentation doesn’t provide example how to get back the corresponding histogram.
From documentation, I believe when TH1 is drawn in a TBrowser, the macro is also called.
Is that correct ?
Case 2:
The TExec object may be added to the list of functions of a TH1 or TGraph object via hist->GetListOfFunctions()->Add("",""). When the histogram (or graph) is drawn, the TExec will be executed. If the histogram is made persistent on a file, the TExec object is also saved with the histogram. When redrawing the histogram in a new session, the TExec will be executed.
Example:
Assume an histogram TH1F *h already filled.
TExec *ex1 = new TExec("ex1","DoSomething()");
TExec *ex2 = new TExec("ex2",".x macro.C");
h->GetListOfFunctions()->Add(ex1);
h->GetListOfFunctions()->Add(ex2);
h->Draw();
When the Paint function for the histogram will be called, the "DoSomething" function will be called (interpreted or compiled) and also the macro.C.
Thank you very much.
M.