Skip to content
Snippets Groups Projects
Commit 416c04fc authored by Cdaq User's avatar Cdaq User
Browse files

add subcanvases for subgroup of channels

parent 9528fde6
Branches
No related tags found
No related merge requests found
# 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
...@@ -9,4 +9,5 @@ output = ${THIS_DIR}/../processed_data/online.root ...@@ -9,4 +9,5 @@ output = ${THIS_DIR}/../processed_data/online.root
number_events = -1 # all events number_events = -1 # all events
update_interval = 2000 # ms update_interval = 2000 # ms
server_dir = /online/latest/
server_port = 9100
...@@ -309,13 +309,12 @@ void processEvent(const uint32_t *buf, int &count, TTree *tree, bool &init_tree, ...@@ -309,13 +309,12 @@ void processEvent(const uint32_t *buf, int &count, TTree *tree, bool &init_tree,
} }
static std::vector<std::string> ec_channels = { static std::vector<std::vector<std::string>> ec_channels = {
// "C4", "C6_1", "C7_1", {"C4"}, {"C6_1", "C6_4", "C6_2", "C6_3"}, {"C7_1", "C7_4", "C7_2", "C7_3"},
// "C5_1", "C9_1", "C8_1", {"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", {"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::pair<int, int>> padnum;
inline void set_graph(TGraph *gr, int npt, double value = 0.) 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.) ...@@ -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) void AddWaveformDisplay(hallc::MonitoringDisplay *dply, std::unordered_map<std::string, BranchData> &brdata, int &mode)
{ {
dply->CreateDisplayPlot("raw/", "waveform", dply->CreateDisplayPlot("raw/", "waveform",
[] (hallc::DisplayPlot &plt) { [] (hallc::DisplayPlot &plt) {
plt._plot_data._canvas = new TCanvas("ec_waveform", "EC Waveform", 1200, 700); plt._plot_data._canvas = new TCanvas("ec_waveform_test2", "EC Waveform", 1200, 700);
plt._plot_data._canvas->Divide(5, 5); plt._plot_data._canvas->DivideSquare(ec_channels.size());
padnum.clear();
for (size_t i = 0; i < ec_channels.size(); ++i) { for (size_t i = 0; i < ec_channels.size(); ++i) {
auto gr = new TGraph(); auto gch = ec_channels[i];
set_graph(gr, 64);
gr->SetLineColor(kRed);
gr->SetLineWidth(2);
plt._plot_data._graphs1.push_back(gr);
gr->SetTitle(ec_channels[i].c_str());
plt._plot_data._canvas->cd(i + 1); 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; return 0;
}, },
...@@ -349,14 +357,16 @@ void AddWaveformDisplay(hallc::MonitoringDisplay *dply, std::unordered_map<std:: ...@@ -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) { 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]; 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()); auto it = brdata.find(gr->GetTitle());
if (it != brdata.end()) { if (it != brdata.end()) {
auto data = it->second; auto data = it->second;
for (int k = 0; k < 64 && k < data.nraw; ++k) { for (int k = 0; k < 64; ++k) {
gr->SetPoint(k, k, data.raw[k]); gr->SetPoint(k, k, (k < data.nraw) ? data.raw[k] : 0.);
} }
} else { } else {
std::cout << "Warning: cannot find raw data for " << gr->GetTitle() << std::endl; 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") ...@@ -381,6 +391,8 @@ void monitor(const std::string &cpath = "config/online_monitor.conf")
auto up_intvl = conf.Value<double>("update_interval", 5000); auto up_intvl = conf.Value<double>("update_interval", 5000);
auto outfile = conf.Value<std::string>("output", "processed_data/online.root"); auto outfile = conf.Value<std::string>("output", "processed_data/online.root");
auto nev = conf.Value<int>("number_events", -1); 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 // connect et
ETChannel et_chan(100, 100); ETChannel et_chan(100, 100);
...@@ -411,7 +423,7 @@ void monitor(const std::string &cpath = "config/online_monitor.conf") ...@@ -411,7 +423,7 @@ void monitor(const std::string &cpath = "config/online_monitor.conf")
bool init_tree = false; bool init_tree = false;
// display plots // display plots
auto dply = CreateMonitorDisplay("/online/latest/", 9100, tree); auto dply = CreateMonitorDisplay(server_dir, server_port, tree);
// monitor display for raw waveform // monitor display for raw waveform
AddWaveformDisplay(dply, brdata, data_mode); AddWaveformDisplay(dply, brdata, data_mode);
dply->InitAll(); dply->InitAll();
...@@ -448,7 +460,7 @@ void monitor(const std::string &cpath = "config/online_monitor.conf") ...@@ -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); processEvent(et_chan.GetEvBuffer(), count, tree, init_tree, data_mode, modules, brdata);
break; break;
} }
} }
dply->Process(); dply->Process();
dply->UpdateAll(); dply->UpdateAll();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment