I’m writing a piece of code in order to perform some simple Monte Carlo simulations.
I’m doing something like this:
#include ...
using namespace std;
int main(){
...
TApplication *myapp = new TApplication(...);
TCanvas *c1= new TCanvas(...);
TH1D *histo=new TH1D(...);
for(int i=0; i<NSIM;i++){
//Fill the histo with MC simulated data
Histofiller(histo, parameters);
c1->Modified();
c1->Update();
}
myapp->Run(true);
return 0;
}
What I’d like to do is to enable the GUI tools that you can use though TApplication::Run() (zoom, etc.) without freeze the program and have to click “Quit ROOT” for every simulation; in other words, I would like to put something like myapp->Run() inside the “for” loop and let the program run without stops.
Hi Bertrand,
thanks for your answer, that is a good solution, but the graphics setting, ie zooms etc, are refreshed in each iteration of the loop.
I found another way to do the job that is to add “c1->WaitPrimitive()” in the loop; the annoying part is that you’ve to press a key in order to proceed to the next iteration of the loop, anyway I need to visualize the MC events only few times so in my case it’s working fine.
[quote] but the graphics setting, ie zooms etc, are refreshed in each iteration of the loop. [/quote]This is usually because histo->Draw() is called within the loop. The ‘Draw’ is only needed to be done once.