10 #include <dqm/analysis/modules/DQMHistAnalysisPXDReduction.h>
12 #include <vxd/geometry/GeoCache.h>
32 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of Histogram dir", std::string(
"PXDDAQ"));
33 addParam(
"PVPrefix", m_pvPrefix,
"PV Prefix", std::string(
"DQM:PXD:Red:"));
34 addParam(
"useEpics", m_useEpics,
"useEpics",
true);
35 B2DEBUG(1,
"DQMHistAnalysisPXDReduction: Constructor done.");
38 DQMHistAnalysisPXDReductionModule::~DQMHistAnalysisPXDReductionModule()
42 if (ca_current_context()) ca_context_destroy();
47 void DQMHistAnalysisPXDReductionModule::initialize()
49 B2DEBUG(1,
"DQMHistAnalysisPXDReduction: initialized.");
51 m_monObj = getMonitoringObject(
"pxd");
56 for (
VxdID& aVxdID : sensors) {
59 if (info.getType() != VXD::SensorInfoBase::PXD)
continue;
60 m_PXDModules.push_back(aVxdID);
63 std::sort(m_PXDModules.begin(), m_PXDModules.end());
67 m_cReduction =
new TCanvas((m_histogramDirectoryName +
"/c_Reduction").data());
68 m_hReduction =
new TH1F(
"Reduction",
"Reduction; Module; Reduction", m_PXDModules.size(), 0, m_PXDModules.size());
69 m_hReduction->SetDirectory(0);
70 m_hReduction->SetStats(
false);
71 for (
unsigned int i = 0; i < m_PXDModules.size(); i++) {
72 TString ModuleName = (std::string)m_PXDModules[i];
73 m_hReduction->GetXaxis()->SetBinLabel(i + 1, ModuleName);
76 m_hReduction->Draw(
"");
77 m_monObj->addCanvas(m_cReduction);
80 m_line1 =
new TLine(0, 10, m_PXDModules.size(), 10);
83 m_line1->SetHorizontal(
true);
84 m_line1->SetLineColor(3);
85 m_line1->SetLineWidth(3);
96 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
98 SEVCHK(ca_create_channel((m_pvPrefix +
"Status").data(), NULL, NULL, 10, &mychid[0]),
"ca_create_channel failure");
99 SEVCHK(ca_create_channel((m_pvPrefix +
"Value").data(), NULL, NULL, 10, &mychid[1]),
"ca_create_channel failure");
100 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
106 void DQMHistAnalysisPXDReductionModule::beginRun()
108 B2DEBUG(1,
"DQMHistAnalysisPXDReduction: beginRun called.");
110 m_cReduction->Clear();
113 void DQMHistAnalysisPXDReductionModule::event()
115 if (!m_cReduction)
return;
116 m_hReduction->Reset();
119 double ireduction = 0.0;
120 int ireductioncnt = 0;
122 for (
unsigned int i = 0; i < m_PXDModules.size(); i++) {
123 std::string name =
"PXDDAQDHEDataReduction_" + (std::string)m_PXDModules[i ];
126 TH1* hh1 = findHist(name);
128 hh1 = findHist(m_histogramDirectoryName, name);
131 auto mean = hh1->GetMean();
132 m_hReduction->Fill(i, mean);
133 if (hh1->GetEntries() > 100) enough =
true;
146 m_cReduction->Pad()->SetFillColor(kGray);
157 m_cReduction->Pad()->SetFillColor(kWhite);
161 double value = ireductioncnt > 0 ? ireduction / ireductioncnt : 0;
164 m_hReduction->Draw(
"");
166 m_line1->SetY1(value);
173 m_monObj->setVariable(
"reduction", value);
175 m_cReduction->Modified();
176 m_cReduction->Update();
179 SEVCHK(ca_put(DBR_INT, mychid[0], (
void*)&status),
"ca_set failure");
180 SEVCHK(ca_put(DBR_DOUBLE, mychid[1], (
void*)&value),
"ca_set failure");
181 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
186 void DQMHistAnalysisPXDReductionModule::terminate()
188 B2DEBUG(1,
"DQMHistAnalysisPXDReduction: terminate called");
193 for (
auto m : mychid) SEVCHK(ca_clear_channel(m),
"ca_clear_channel failure");
194 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");