Currently, I am trying to making monitoring system.
We are taking data with a few hour length, and we want to check some histograms during data taking.
So, what I tried is fill the histogram ~O(1000) events and show it via the canvas like below.
TApplication* theApp = new TApplication("app", &argc, argv);
TCanvas* c = new TCanvas("", "");
while(1) {
for (int i = 0; i < 1000; i++)
aHist->Fill(value);
c->cd();
aHist->Draw("Hist");
theApp->Run();
}
We want to use the compiled script, so we tried it with TApplication.
The plot for the first for-loop is well pop. But after that, it is stuck at theApp->Run();.
And also I tried this one with searching live updates for plot
TApplication* theApp = new TApplication("app", &argc, argv);
TCanvas* c = new TCanvas("", "");
TH1D* aHist = new TH1D(...);
aHist->Draw();
while(1) {
for (int i = 0; i < 1000; i++)
aHist->Fill(value);
c->Update();
c->Pad()->Draw();
}
TApplication* theApp = new TApplication("app", &argc, argv);
theApp->SetReturnFromRun(true);
TCanvas* c = new TCanvas("", "");
TH1D* aHist = new TH1D(...);
aHist->Draw();
while(1) {
for (int i = 0; i < 1000; i++)
aHist->Fill(value);
c->Update();
c->Pad()->Draw();
gSystem->ProcessEvents();
}
But after plot is pop, I cannot make any changes on the plot while the system is under loop. Like adjusting the axis range, rebin the plot and etc.
Is there any possible solution for it? I’d very appreciate any suggestion!
Thank you for suggestion!
Unfortunately, I already make a system sleep ~5 seconds with gSystem->Sleep(5000); right after updating the canvas.
Also std::this_thread::sleep_for(std::chrono::milliseconds(300)) does not works.
Anyway, thank you very much!
Why it is not possible? gSystem->ProcessEvents() returns fast and you can modify canvas or histograms as much as you want. Just not forget to invoke c->Modified(); c-Update(); after your modifications.
Like:
TH1D* aHist = new TH1D(...);
aHist->Draw();
for (int i = 0; i < 1000; i++)
aHist->Fill(value);
c->Modified();
c->Update();
gSystem->ProcessEvents();
aHist->Rebin(2);
c->Modified();
c->Update();
while(true) {
gSystem->Sleep(10);
gSystem->ProcessEvents();
}