10 #include <dqm/analysis/modules/DQMHistAnalysisPXDCharge.h>
13 #include <vxd/geometry/GeoCache.h>
33 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of Histogram dir", std::string(
"PXDER"));
34 addParam(
"RangeLow", m_rangeLow,
"Lower boarder for fit", 30.);
35 addParam(
"RangeHigh", m_rangeHigh,
"High border for fit", 85.);
36 addParam(
"PVPrefix", m_pvPrefix,
"PV Prefix", std::string(
"DQM:PXD:Charge:"));
37 addParam(
"useEpics", m_useEpics,
"useEpics",
true);
38 B2DEBUG(99,
"DQMHistAnalysisPXDCharge: Constructor done.");
41 DQMHistAnalysisPXDChargeModule::~DQMHistAnalysisPXDChargeModule()
45 if (ca_current_context()) ca_context_destroy();
50 void DQMHistAnalysisPXDChargeModule::initialize()
52 B2DEBUG(99,
"DQMHistAnalysisPXDCharge: initialized.");
54 m_monObj = getMonitoringObject(
"pxd");
59 for (
VxdID& aVxdID : sensors) {
61 if (info.getType() != VXD::SensorInfoBase::PXD)
continue;
62 m_PXDModules.push_back(aVxdID);
64 std::sort(m_PXDModules.begin(), m_PXDModules.end());
68 m_cCharge =
new TCanvas((m_histogramDirectoryName +
"/c_Charge").data());
69 m_hCharge =
new TH1F(
"Cluster Charge",
"Cluster Charge; Module; Track Cluster Charge", m_PXDModules.size(), 0, m_PXDModules.size());
70 m_hCharge->SetDirectory(0);
71 m_hCharge->SetStats(
false);
72 for (
unsigned int i = 0; i < m_PXDModules.size(); i++) {
73 TString ModuleName = (std::string)m_PXDModules[i];
74 m_hCharge->GetXaxis()->SetBinLabel(i + 1, ModuleName);
79 m_monObj->addCanvas(m_cCharge);
97 m_fLandau =
new TF1(
"f_Landau",
"landau", m_rangeLow, m_rangeHigh);
98 m_fLandau->SetParameter(0, 1000);
99 m_fLandau->SetParameter(1, 50);
100 m_fLandau->SetParameter(2, 10);
101 m_fLandau->SetLineColor(4);
102 m_fLandau->SetNpx(60);
103 m_fLandau->SetNumberFitPoints(60);
105 m_fMean =
new TF1(
"f_Mean",
"pol0", 0.5, m_PXDModules.size() - 0.5);
106 m_fMean->SetParameter(0, 50);
107 m_fMean->SetLineColor(5);
108 m_fMean->SetNpx(m_PXDModules.size());
109 m_fMean->SetNumberFitPoints(m_PXDModules.size());
113 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
115 SEVCHK(ca_create_channel((m_pvPrefix +
"Mean").data(), NULL, NULL, 10, &mychid[0]),
"ca_create_channel failure");
116 SEVCHK(ca_create_channel((m_pvPrefix +
"Diff").data(), NULL, NULL, 10, &mychid[1]),
"ca_create_channel failure");
117 SEVCHK(ca_create_channel((m_pvPrefix +
"Status").data(), NULL, NULL, 10, &mychid[2]),
"ca_create_channel failure");
118 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
124 void DQMHistAnalysisPXDChargeModule::beginRun()
126 B2DEBUG(99,
"DQMHistAnalysisPXDCharge: beginRun called.");
131 void DQMHistAnalysisPXDChargeModule::event()
133 if (!m_cCharge)
return;
138 for (
unsigned int i = 0; i < m_PXDModules.size(); i++) {
139 std::string name =
"DQMER_PXD_" + (std::string)m_PXDModules[i] +
"_ClusterCharge";
140 std::replace(name.begin(), name.end(),
'.',
'_');
142 TH1* hh1 = findHist(name);
144 hh1 = findHist(m_histogramDirectoryName, name);
149 m_fLandau->SetParameter(0, 1000);
150 m_fLandau->SetParameter(1, 50);
151 m_fLandau->SetParLimits(1, 10, 80);
152 m_fLandau->SetParameter(2, 10);
153 m_fLandau->SetParLimits(2, 1, 50);
154 if (hh1->GetEntries() > 100) {
155 hh1->Fit(m_fLandau,
"R");
156 m_hCharge->SetBinContent(i + 1, m_fLandau->GetParameter(1));
157 m_hCharge->SetBinError(i + 1, m_fLandau->GetParError(1));
159 m_hCharge->SetBinContent(i + 1, 50);
160 m_hCharge->SetBinError(i + 1, 100);
168 if (hh1->GetEntries() > 100) m_fLandau->Draw(
"same");
171 if (hh1->GetEntries() > 1000) enough =
true;
178 if (m_hCharge && enough) {
179 double currentMin, currentMax;
184 m_hCharge->Fit(m_fMean,
"R");
185 data = m_fMean->GetParameter(0);
186 m_hCharge->GetMinimumAndMaximum(currentMin, currentMax);
187 diff = fabs(data - currentMin) > fabs(currentMax - data) ? fabs(data - currentMin) : fabs(currentMax - data);
188 if (0) B2INFO(
"Mean: " << data <<
" Max Diff: " << diff);
193 SEVCHK(ca_put(DBR_DOUBLE, mychid[0], (
void*)&data),
"ca_set failure");
194 SEVCHK(ca_put(DBR_DOUBLE, mychid[1], (
void*)&diff),
"ca_set failure");
202 m_cCharge->Pad()->SetFillColor(kGray);
206 if (fabs(data - 50.) > 20. || diff > 30) {
207 m_cCharge->Pad()->SetFillColor(kRed);
209 }
else if (fabs(data - 50) > 15. || diff > 10) {
210 m_cCharge->Pad()->SetFillColor(kYellow);
213 m_cCharge->Pad()->SetFillColor(kGreen);
218 m_cCharge->Pad()->SetFillColor(kGreen);
223 SEVCHK(ca_put(DBR_INT, mychid[2], (
void*)&status),
"ca_set failure");
224 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
228 auto tt =
new TLatex(5.5, 0,
"1.3.2 Module is excluded, please ignore");
229 tt->SetTextAngle(90);
230 tt->SetTextAlign(12);
233 m_cCharge->Modified();
237 void DQMHistAnalysisPXDChargeModule::endRun()
239 B2DEBUG(99,
"DQMHistAnalysisPXDCharge : endRun called");
243 void DQMHistAnalysisPXDChargeModule::terminate()
248 for (
auto m : mychid) SEVCHK(ca_clear_channel(m),
"ca_clear_channel failure");
249 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
252 B2DEBUG(99,
"DQMHistAnalysisPXDCharge: terminate called");