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

add waveform canvas

parent a357aa7d
Branches
No related tags found
No related merge requests found
......@@ -3,8 +3,10 @@
host = clrlpc.jlab.org
port = 11111
etfile = /tmp/et_test
modules = ${THIS_DIR}/esb_module.conf
output = ${THIS_DIR}/../processed_data/online.root
update_interval = 2000 # ms
number_events = -1 # all events
update_interval = 2000 # ms
......@@ -308,6 +308,67 @@ 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",
};
inline void set_graph(TGraph *gr, int npt, double value = 0.)
{
for (int i = 0; i < npt; ++i) {
gr->SetPoint(i, i, value);
}
}
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);
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());
plt._plot_data._canvas->cd(i + 1);
gr->Draw("L");
}
return 0;
},
[&brdata, &mode] (hallc::DisplayPlot &plt) {
if (mode != 1) {
std::cout << "Skip raw waveform plot because data mode = " << mode << std::endl;
return 0;
}
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 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]);
}
} else {
std::cout << "Warning: cannot find raw data for " << gr->GetTitle() << std::endl;
}
gr->Draw("L");
gr->GetYaxis()->SetRangeUser(300, 1000);
gr->GetXaxis()->SetRangeUser(0, 64);
}
return 0;
});
}
void monitor(const std::string &cpath = "config/online_monitor.conf")
{
// read configuration
......@@ -346,9 +407,13 @@ void monitor(const std::string &cpath = "config/online_monitor.conf")
// root file and event tree
auto *hfile = new TFile(outfile.c_str(), "RECREATE", "MAPMT test results");
auto tree = new TTree("EvTree", "Cherenkov Test Events");
int data_mode = -1;
bool init_tree = false;
// display plots
auto dply = CreateMonitorDisplay("/online/latest/", 9100, tree);
// monitor display for raw waveform
AddWaveformDisplay(dply, brdata, data_mode);
dply->InitAll();
......@@ -357,8 +422,6 @@ void monitor(const std::string &cpath = "config/online_monitor.conf")
// start monitoring
int count = 0;
int data_mode = -1;
bool init_tree = false;
signal(SIGINT, handle_sig);
while (true) {
if (term > 0 || (nev > 0 && nev < count)) { break; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment