14 #include <dqm/analysis/modules/DQMHistAnalysisPXDReduction.h>
16 #include <vxd/geometry/GeoCache.h>
36 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of Histogram dir", std::string(
"PXDDAQ"));
37 addParam(
"PVPrefix", m_pvPrefix,
"PV Prefix", std::string(
"DQM:PXD:Red:"));
38 addParam(
"useEpics", m_useEpics,
"Whether to update EPICS PVs.",
false);
39 B2DEBUG(1,
"DQMHistAnalysisPXDReduction: Constructor done.");
42 DQMHistAnalysisPXDReductionModule::~DQMHistAnalysisPXDReductionModule()
46 if (ca_current_context()) ca_context_destroy();
51 void DQMHistAnalysisPXDReductionModule::initialize()
53 B2DEBUG(1,
"DQMHistAnalysisPXDReduction: initialized.");
55 m_monObj = getMonitoringObject(
"pxd");
60 for (
VxdID& aVxdID : sensors) {
63 if (info.getType() != VXD::SensorInfoBase::PXD)
continue;
64 m_PXDModules.push_back(aVxdID);
67 std::sort(m_PXDModules.begin(), m_PXDModules.end());
71 m_cReduction =
new TCanvas((m_histogramDirectoryName +
"/c_Reduction").data());
72 m_hReduction =
new TH1F(
"hPXDReduction",
"PXD Reduction; Module; Reduction", m_PXDModules.size(), 0, m_PXDModules.size());
73 m_hReduction->SetDirectory(0);
74 m_hReduction->SetStats(
false);
75 for (
unsigned int i = 0; i < m_PXDModules.size(); i++) {
76 TString ModuleName = (std::string)m_PXDModules[i];
77 m_hReduction->GetXaxis()->SetBinLabel(i + 1, ModuleName);
80 m_hReduction->Draw(
"");
81 m_monObj->addCanvas(m_cReduction);
84 m_line1 =
new TLine(0, 10, m_PXDModules.size(), 10);
87 m_line1->SetHorizontal(
true);
88 m_line1->SetLineColor(3);
89 m_line1->SetLineWidth(3);
100 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
102 SEVCHK(ca_create_channel((m_pvPrefix +
"Status").data(), NULL, NULL, 10, &mychid[0]),
"ca_create_channel failure");
103 SEVCHK(ca_create_channel((m_pvPrefix +
"Value").data(), NULL, NULL, 10, &mychid[1]),
"ca_create_channel failure");
104 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
110 void DQMHistAnalysisPXDReductionModule::beginRun()
112 B2DEBUG(1,
"DQMHistAnalysisPXDReduction: beginRun called.");
114 m_cReduction->Clear();
117 void DQMHistAnalysisPXDReductionModule::event()
119 if (!m_cReduction)
return;
120 m_hReduction->Reset();
123 double ireduction = 0.0;
124 int ireductioncnt = 0;
126 for (
unsigned int i = 0; i < m_PXDModules.size(); i++) {
127 std::string name =
"PXDDAQDHEDataReduction_" + (std::string)m_PXDModules[i ];
130 TH1* hh1 = findHist(name);
132 hh1 = findHist(m_histogramDirectoryName, name);
135 auto mean = hh1->GetMean();
136 m_hReduction->Fill(i, mean);
137 if (hh1->GetEntries() > 100) enough =
true;
150 m_cReduction->Pad()->SetFillColor(kGray);
161 m_cReduction->Pad()->SetFillColor(kWhite);
165 double value = ireductioncnt > 0 ? ireduction / ireductioncnt : 0;
168 m_hReduction->Draw(
"");
170 m_line1->SetY1(value);
171 m_line1->SetY2(value);
178 m_monObj->setVariable(
"reduction", value);
180 m_cReduction->Modified();
181 m_cReduction->Update();
184 SEVCHK(ca_put(DBR_INT, mychid[0], (
void*)&status),
"ca_set failure");
185 SEVCHK(ca_put(DBR_DOUBLE, mychid[1], (
void*)&value),
"ca_set failure");
186 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
191 void DQMHistAnalysisPXDReductionModule::terminate()
193 B2DEBUG(1,
"DQMHistAnalysisPXDReduction: terminate called");
198 for (
auto m : mychid) SEVCHK(ca_clear_channel(m),
"ca_clear_channel failure");
199 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
The base class for the histogram analysis module.
DQM Histogram Analysis for PXD Reduction.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Base class to provide Sensor Information for PXD and SVD.
Class to uniquely identify a any structure of the PXD and SVD.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.