14 #include <dqm/analysis/modules/DQMHistAnalysisRunNr.h>
16 #include <TPaveText.h>
36 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of Histogram dir", std::string(
"DAQ"));
37 addParam(
"PVPrefix", m_pvPrefix,
"PV Prefix", std::string(
"DQM:DAQ:RunNr:"));
38 addParam(
"useEpics", m_useEpics,
"Whether to update EPICS PVs.",
false);
40 B2DEBUG(99,
"DQMHistAnalysisRunNr: Constructor done.");
43 DQMHistAnalysisRunNrModule::~DQMHistAnalysisRunNrModule()
47 if (ca_current_context()) ca_context_destroy();
52 void DQMHistAnalysisRunNrModule::initialize()
54 m_monObj = getMonitoringObject(
"daq");
58 m_cRunNr =
new TCanvas((m_histogramDirectoryName +
"/c_RunNr").data());
64 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
66 SEVCHK(ca_create_channel((m_pvPrefix +
"Alarm").data(), NULL, NULL, 10, &mychid[0]),
"ca_create_channel failure");
67 SEVCHK(ca_create_channel((m_pvPrefix +
"RunNr").data(), NULL, NULL, 10, &mychid[1]),
"ca_create_channel failure");
69 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
72 B2DEBUG(99,
"DQMHistAnalysisRunNr: initialized.");
75 void DQMHistAnalysisRunNrModule::beginRun()
77 B2DEBUG(99,
"DQMHistAnalysisRunNr: beginRun called.");
87 SEVCHK(ca_put(DBR_INT, mychid[0], (
void*)&status),
"ca_set failure");
88 SEVCHK(ca_put(DBR_DOUBLE, mychid[1], (
void*)&mean),
"ca_set failure");
89 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
94 void DQMHistAnalysisRunNrModule::event()
96 if (!m_cRunNr)
return;
103 auto leg =
new TPaveText(0.6, 0.6, 0.95, 0.95,
"NDC");
104 leg->SetFillColor(kWhite);
106 auto name =
"hRunnr";
107 TH1* hh1 = findHist(name);
109 hh1 = findHist(m_histogramDirectoryName, name);
112 hh1->SetStats(kFALSE);
114 mean = hh1->GetMean();
115 if (hh1->GetEntries() > 0) {
116 leg->AddText(
"Contains Run: Entries");
119 for (
int i = 0; i <= hh1->GetXaxis()->GetNbins() + 1; i++) {
121 if (hh1->GetBinContent(i) > 0) {
124 tmp.Form(
"%ld: %ld", (
long int)hh1->GetXaxis()->GetBinCenter(i), (
long int)hh1->GetBinContent(i));
130 }
else if (nfilled == 1) {
138 m_cRunNr->Pad()->SetFillColor(kGray);
139 leg->AddText(
"No data yet");
140 }
else if (status == 2) {
142 m_cRunNr->Pad()->SetFillColor(kGreen);
145 m_cRunNr->Pad()->SetFillColor(kRed);
150 m_cRunNr->Modified();
157 SEVCHK(ca_put(DBR_INT, mychid[0], (
void*)&status),
"ca_set failure");
158 SEVCHK(ca_put(DBR_DOUBLE, mychid[1], (
void*)&mean),
"ca_set failure");
159 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
164 void DQMHistAnalysisRunNrModule::terminate()
166 B2DEBUG(99,
"DQMHistAnalysisRunNr: terminate called");
170 for (
auto m : mychid) SEVCHK(ca_clear_channel(m),
"ca_clear_channel failure");
171 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
The base class for the histogram analysis module.
DQM Histogram Analysis for PXD Common Modes.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.