diff --git a/config/offline_monitor.conf b/config/offline_monitor.conf new file mode 100644 index 0000000000000000000000000000000000000000..09f3d14f92f584c957556826d248971658e84852 --- /dev/null +++ b/config/offline_monitor.conf @@ -0,0 +1,13 @@ +# configuration for online monitoring + +host = clrlpc.jlab.org +port = 11111 +etfile = /tmp/et_test + +modules = ${THIS_DIR}/esb_module.conf +output = ${THIS_DIR}/../processed_data/offline.root + +number_events = -1 # all events +update_interval = 2000 # ms +server_dir = /offline/latest/ +server_port = 9100 diff --git a/config/online_monitor.conf b/config/online_monitor.conf index 2c47433fcde56af80185217783e7e2e8ae7610cb..f6edecd1e7d561293b9a8369f8a890c5e389f7d9 100644 --- a/config/online_monitor.conf +++ b/config/online_monitor.conf @@ -9,4 +9,5 @@ output = ${THIS_DIR}/../processed_data/online.root number_events = -1 # all events update_interval = 2000 # ms - +server_dir = /online/latest/ +server_port = 9100 diff --git a/online/monitor.cxx b/online/monitor.cxx index da7e09116cade395d77481443da220f41fb64546..1da910dd6fd0307df7b2cb396454b78cf4ccf62a 100644 --- a/online/monitor.cxx +++ b/online/monitor.cxx @@ -309,13 +309,12 @@ void processEvent(const uint32_t *buf, int &count, TTree *tree, bool &init_tree, } -static std::vector<std::string> ec_channels = { -// "C4", "C6_1", "C7_1", -// "C5_1", "C9_1", "C8_1", -// "C1", "C2", "C3", - "C1", "C2", "C3", "C4", "C5_1", "C5_2", "C5_3", "C5_4", "C6_1", "C6_2", "C6_3", "C6_4", - "C7_1", "C7_2", "C7_3", "C7_4", "C8_1", "C8_2", "C8_3", "C8_4", "C9_1", "C9_2", "C9_3", "C9_4", +static std::vector<std::vector<std::string>> ec_channels = { + {"C4"}, {"C6_1", "C6_4", "C6_2", "C6_3"}, {"C7_1", "C7_4", "C7_2", "C7_3"}, + {"C5_1", "C5_4", "C5_2", "C5_3"}, {"C9_1", "C9_2", "C9_4", "C9_3"}, {"C8_2", "C8_3", "C8_1", "C8_4"}, + {"C1"}, {"C2"}, {"C3"}, }; +static std::vector<std::pair<int, int>> padnum; inline void set_graph(TGraph *gr, int npt, double value = 0.) { @@ -326,19 +325,28 @@ inline void set_graph(TGraph *gr, int npt, double value = 0.) void AddWaveformDisplay(hallc::MonitoringDisplay *dply, std::unordered_map<std::string, BranchData> &brdata, int &mode) { + dply->CreateDisplayPlot("raw/", "waveform", [] (hallc::DisplayPlot &plt) { - plt._plot_data._canvas = new TCanvas("ec_waveform", "EC Waveform", 1200, 700); - plt._plot_data._canvas->Divide(5, 5); + plt._plot_data._canvas = new TCanvas("ec_waveform_test2", "EC Waveform", 1200, 700); + plt._plot_data._canvas->DivideSquare(ec_channels.size()); + padnum.clear(); for (size_t i = 0; i < ec_channels.size(); ++i) { - auto gr = new TGraph(); - set_graph(gr, 64); - gr->SetLineColor(kRed); - gr->SetLineWidth(2); - plt._plot_data._graphs1.push_back(gr); - gr->SetTitle(ec_channels[i].c_str()); + auto gch = ec_channels[i]; plt._plot_data._canvas->cd(i + 1); - gr->Draw("L"); + int ndiv = int(std::sqrt(gch.size()) - 1e-4) + 1; + gPad->Divide(ndiv, ndiv, 0., 0.); + for (size_t j = 0; j < gch.size(); ++j) { + gPad->cd(j + 1); + auto gr = new TGraph(); + set_graph(gr, 64); + gr->SetLineColor(kRed); + gr->SetLineWidth(2); + gr->SetTitle(gch[j].c_str()); + gr->Draw("L"); + plt._plot_data._graphs1.push_back(gr); + padnum.push_back({i + 1, j + 1}); + } } return 0; }, @@ -349,14 +357,16 @@ void AddWaveformDisplay(hallc::MonitoringDisplay *dply, std::unordered_map<std:: } for (size_t i = 0; i < plt._plot_data._graphs1.size(); ++i) { - plt._plot_data._canvas->cd(i + 1); auto gr = plt._plot_data._graphs1[i]; - set_graph(gr, 64); + auto pn = padnum[i]; + plt._plot_data._canvas->cd(pn.first); + gPad->cd(pn.second); + auto it = brdata.find(gr->GetTitle()); if (it != brdata.end()) { auto data = it->second; - for (int k = 0; k < 64 && k < data.nraw; ++k) { - gr->SetPoint(k, k, data.raw[k]); + for (int k = 0; k < 64; ++k) { + gr->SetPoint(k, k, (k < data.nraw) ? data.raw[k] : 0.); } } else { std::cout << "Warning: cannot find raw data for " << gr->GetTitle() << std::endl; @@ -381,6 +391,8 @@ void monitor(const std::string &cpath = "config/online_monitor.conf") auto up_intvl = conf.Value<double>("update_interval", 5000); auto outfile = conf.Value<std::string>("output", "processed_data/online.root"); auto nev = conf.Value<int>("number_events", -1); + auto server_dir = conf.Value<std::string>("server_dir", "online/latest"); + auto server_port = conf.Value<int>("server_port", 9100); // connect et ETChannel et_chan(100, 100); @@ -411,7 +423,7 @@ void monitor(const std::string &cpath = "config/online_monitor.conf") bool init_tree = false; // display plots - auto dply = CreateMonitorDisplay("/online/latest/", 9100, tree); + auto dply = CreateMonitorDisplay(server_dir, server_port, tree); // monitor display for raw waveform AddWaveformDisplay(dply, brdata, data_mode); dply->InitAll(); @@ -448,7 +460,7 @@ void monitor(const std::string &cpath = "config/online_monitor.conf") processEvent(et_chan.GetEvBuffer(), count, tree, init_tree, data_mode, modules, brdata); break; } - } + } dply->Process(); dply->UpdateAll();