diff --git a/config/online_monitor.conf b/config/online_monitor.conf index f6edecd1e7d561293b9a8369f8a890c5e389f7d9..58d9b50814e2d8ea714f5a5a0aecaca716f3d7d4 100644 --- a/config/online_monitor.conf +++ b/config/online_monitor.conf @@ -1,8 +1,8 @@ # configuration for online monitoring host = clrlpc.jlab.org -port = 11111 -etfile = /tmp/et_test +port = 23911 +etfile = /tmp/et_sys_solidcer modules = ${THIS_DIR}/esb_module.conf output = ${THIS_DIR}/../processed_data/online.root diff --git a/include/MonitorDisplay.h b/include/MonitorDisplay.h index 7ea54c75cb23f04da21bfb280d1a5b8aa0b8286f..08cefad7c55e9ad05e9d3f4af077c3a643570366 100644 --- a/include/MonitorDisplay.h +++ b/include/MonitorDisplay.h @@ -49,8 +49,9 @@ hallc::MonitoringDisplay *CreateMonitorDisplay(const std::string &root_dir, int { gStyle->SetHistFillStyle(3002); gStyle->SetPalette(kBird, 0, 0.5); - gStyle->SetOptStat(10); - gStyle->SetTitleSize(0.04, ""); + // gStyle->SetOptStat(10); + gStyle->SetOptStat(0); + gStyle->SetTitleSize(0.08, ""); gStyle->SetTitleSize(0.04, "xyz"); gStyle->SetLabelSize(0.03, "xyz"); // gStyle->SetTitleW(1.0); diff --git a/include/WaveformDisplay.h b/include/WaveformDisplay.h index 20391414d3393bc2d4336e960c92b039ecda7e76..d45b2110e456853483d053e276ede1b485fa3516 100644 --- a/include/WaveformDisplay.h +++ b/include/WaveformDisplay.h @@ -46,31 +46,37 @@ inline void set_graph(TGraph *gr, int npt, double value = 0.) hallc::MonitoringDisplay *CreateWaveformDisplay(const std::string &root_dir, int port, std::unordered_map<std::string, BranchData> &brdata, int &mode) { + gROOT->SetBatch(); + auto dply = new hallc::MonitoringDisplay(port); dply->SetRootFolder(root_dir); for (auto &w : wfdata) { dply->CreateDisplayPlot(w.subdir, w.name, [&w] (hallc::DisplayPlot &plt) { - plt._plot_data._canvas = new TCanvas(w.name.c_str(), w.title.c_str(), 1200, 700); + plt._plot_data._canvas = new TCanvas(w.name.c_str(), w.title.c_str(), 1280, 720); plt._plot_data._canvas->DivideSquare(w.channels.size(), w.xmg, w.ymg); + //plt._plot_data._canvas->DivideSquare(w.channels.size()); w.pad.clear(); for (size_t i = 0; i < w.channels.size(); ++i) { auto gch = w.channels[i]; plt._plot_data._canvas->cd(i + 1); + size_t size = gch.size(); if (gch.size() > 1) { int ndiv = int(std::sqrt(gch.size()) - 1e-4) + 1; gPad->Divide(ndiv, ndiv, w.subxmg, w.subymg); + //gPad->Divide(ndiv, ndiv); + size = 4; } - for (size_t j = 0; j < gch.size(); ++j) { + for (size_t j = 0; j < size; ++j) { gPad->cd(j + 1); - auto gr = new TGraph(); - set_graph(gr, w.nsamples); - gr->SetLineColor(kRed); - gr->SetLineWidth(2); - gr->SetTitle(gch[j].c_str()); - gr->Draw("L"); - plt._plot_data._graphs1.push_back(gr); + auto h1f = new TH1F(("hwf_" + gch[j]).c_str(), gch[j].c_str(), w.nsamples, 0, w.nsamples - 1); + h1f->SetLineColor(kRed); + h1f->SetLineWidth(2); + h1f->Draw("C"); + h1f->GetYaxis()->SetRangeUser(w.ymin, w.ymax); + h1f->GetXaxis()->SetRangeUser(0, w.nsamples - 1); + plt._plot_data._hists1.push_back(h1f); w.pad.push_back({i + 1, j + 1}); } } @@ -82,23 +88,21 @@ hallc::MonitoringDisplay *CreateWaveformDisplay(const std::string &root_dir, int return 0; } - for (size_t i = 0; i < plt._plot_data._graphs1.size(); ++i) { - auto gr = plt._plot_data._graphs1[i]; + for (size_t i = 0; i < plt._plot_data._hists1.size(); ++i) { + auto h1f = plt._plot_data._hists1[i]; auto pn = w.pad[i]; plt._plot_data._canvas->cd(pn.first)->cd(pn.second); - auto it = brdata.find(gr->GetTitle()); + auto it = brdata.find(h1f->GetTitle()); if (it != brdata.end()) { auto data = it->second; - for (int k = 0; k < 64; ++k) { - gr->SetPoint(k, k, (k < data.nraw) ? data.raw[k] : 0.); + for (int k = 0; k < w.nsamples; ++k) { + h1f->SetBinContent(k, k, (k < data.nraw) ? data.raw[k] : 0.); } } else { - std::cout << "Warning: cannot find raw data for " << gr->GetTitle() << std::endl; + std::cout << "Warning: cannot find raw data for " << h1f->GetTitle() << std::endl; } - gr->Draw("L"); - gr->GetYaxis()->SetRangeUser(w.ymin, w.ymax); - gr->GetXaxis()->SetRangeUser(0, w.nsamples); + h1f->Draw("C"); } return 0; }); diff --git a/online/monitor.cxx b/online/monitor.cxx index f72a2e2c989a6247872e6fcad7eae9668a4d979c..a481037f0d1730b1bbd84e7ea21ae67e49c33f85 100644 --- a/online/monitor.cxx +++ b/online/monitor.cxx @@ -224,7 +224,9 @@ void processEvent(const uint32_t *buf, int &count, TTree *tree, bool &init_tree, return; case ETChannel::CODA_PRST: case ETChannel::CODA_END: + return; default: + std::cout << fmt::format("Skipping Unknown type of events {0:d} ({0:#x})") << std::endl; return; } @@ -322,6 +324,7 @@ void monitor(const std::string &cpath = "config/online_monitor.conf") auto dply2 = CreateWaveformDisplay(server_dir, server_port, brdata, data_mode); dply2->InitAll(); + gSystem->ProcessEvents(); // timer auto timer = std::chrono::steady_clock::now(); @@ -332,12 +335,13 @@ void monitor(const std::string &cpath = "config/online_monitor.conf") while (true) { if (term > 0 || (nev > 0 && nev < count)) { break; } auto now = std::chrono::steady_clock::now(); - if (std::chrono::duration_cast<std::chrono::milliseconds>(now - timer).count() > up_intvl) { + if ((count > 0) && (std::chrono::duration_cast<std::chrono::milliseconds>(now - timer).count() > up_intvl)) { timer = now; std::cout << "Monitor update, processed events - " << count << std::endl; dply->Process(); - dply->UpdateAll(); dply2->Process(); + gSystem->ProcessEvents(); + dply->UpdateAll(); dply2->UpdateAll(); } @@ -349,8 +353,8 @@ void monitor(const std::string &cpath = "config/online_monitor.conf") // term = 1; break; case ETChannel::READ_EMPTY: - std::cout << "ET station is empty, wait 2 secs..." << std::endl; - std::this_thread::sleep_for(std::chrono::seconds(2)); + // std::cout << "ET station is empty, wait 2 secs..." << std::endl; + // std::this_thread::sleep_for(std::chrono::seconds(2)); break; case ETChannel::READ_OK: processEvent(et_chan.GetEvBuffer(), count, tree, init_tree, data_mode, modules, brdata);