14 #include <dqm/analysis/modules/DQMHistAnalysisPXDFits.h>
17 #include <boost/format.hpp>
37 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of the directory where histograms were placed",
38 std::string(
"PXDRAW"));
40 for (
auto i = 0, j = 0; i < 64; i++) {
41 auto layer = (((i >> 5) & 0x1) + 1);
42 auto ladder = ((i >> 1) & 0xF);
43 if (ladder == 0)
continue;
44 if (layer == 1 && ladder > 8)
continue;
45 if (layer == 2 && ladder > 12)
continue;
49 if (j == NUM_MODULES)
break;
51 for (
auto i = 0; i < NUM_MODULES; i++) {
52 m_hSignal[i] =
nullptr;
53 m_hCommon[i] =
nullptr;
54 m_hCounts[i] =
nullptr;
55 m_cSignal[i] =
nullptr;
56 m_cCommon[i] =
nullptr;
57 m_cCounts[i] =
nullptr;
59 B2DEBUG(1,
"DQMHistAnalysisPXDFits: Constructor done.");
62 void DQMHistAnalysisPXDFitsModule::initialize()
64 B2DEBUG(1,
"DQMHistAnalysisPXDFits: initialized.");
70 a =
"pxdraw/hSignalAll";
71 a.ReplaceAll(
"/",
"_");
72 m_cSignalAll =
new TCanvas((m_histogramDirectoryName +
"/c_").data() + a);
73 m_hSignalAll =
new TH1F(a, a, NUM_MODULES, 0, NUM_MODULES);
74 m_hSignalAll->SetDirectory(0);
75 m_hSignalAll->SetStats(
false);
77 a =
"pxdraw/hCommonAll";
78 a.ReplaceAll(
"/",
"_");
79 m_cCommonAll =
new TCanvas((m_histogramDirectoryName +
"/c_").data() + a);
80 m_hCommonAll =
new TH1F(a, a, NUM_MODULES, 0, NUM_MODULES);
81 m_hCommonAll->SetDirectory(0);
82 m_hCommonAll->SetStats(
false);
84 a =
"pxdraw/hCountsAll";
85 a.ReplaceAll(
"/",
"_");
86 m_cCountsAll =
new TCanvas((m_histogramDirectoryName +
"/c_").data() + a);
87 m_hCountsAll =
new TH1F(a, a, NUM_MODULES, 0, NUM_MODULES);
88 m_hCountsAll->SetDirectory(0);
89 m_hCountsAll->SetStats(
false);
91 a =
"pxdraw/hOccupancyAll";
92 a.ReplaceAll(
"/",
"_");
93 m_cOccupancyAll =
new TCanvas((m_histogramDirectoryName +
"/c_").data() + a);
94 m_hOccupancyAll =
new TH1F(a, a, NUM_MODULES, 0, NUM_MODULES);
95 m_hOccupancyAll->SetDirectory(0);
96 m_hOccupancyAll->SetStats(
false);
98 for (
auto i = 0; i < NUM_MODULES; i++) {
99 auto id = m_inx_to_id[i];
100 auto layer = (((
id >> 5) & 0x1) + 1);
101 auto ladder = ((
id >> 1) & 0xF);
102 auto sensor = ((
id & 0x1) + 1);
103 string s2 = str(format(
"_%d.%d.%d") % layer % ladder % sensor);
105 m_hSignalAll->GetXaxis()->SetBinLabel(i + 1, TString(s2));
106 m_hCommonAll->GetXaxis()->SetBinLabel(i + 1, TString(s2));
107 m_hCountsAll->GetXaxis()->SetBinLabel(i + 1, TString(s2));
108 m_hOccupancyAll->GetXaxis()->SetBinLabel(i + 1, TString(s2));
110 a =
"pxdraw/hSignal";
111 a.ReplaceAll(
"/",
"_");
114 m_cSignal[i] =
new TCanvas((m_histogramDirectoryName +
"/c_").data() + a);
115 m_hSignal[i] =
new TH2F(a, a, 6, 0, 6, 4, 0, 4);
116 m_hSignal[i]->SetDirectory(0);
117 m_hSignal[i]->SetStats(
false);
118 m_hSignal[i]->SetMinimum(0);
119 m_hSignal[i]->SetMaximum(64);
121 a =
"pxdraw/hCommon";
122 a.ReplaceAll(
"/",
"_");
124 m_cCommon[i] =
new TCanvas((m_histogramDirectoryName +
"/c_").data() + a);
125 m_hCommon[i] =
new TH2F(a, a, 6, 0, 6, 4, 0, 4);
126 m_hCommon[i]->SetDirectory(0);
127 m_hCommon[i]->SetStats(
false);
128 m_hCommon[i]->SetMinimum(0);
129 m_hCommon[i]->SetMaximum(256);
131 a =
"pxdraw/hCounts";
132 a.ReplaceAll(
"/",
"_");
134 m_cCounts[i] =
new TCanvas((m_histogramDirectoryName +
"/c_").data() + a);
135 m_hCounts[i] =
new TH2F(a, a, 6, 0, 6, 4, 0, 4);
136 m_hCounts[i]->SetDirectory(0);
137 m_hCounts[i]->SetStats(
false);
140 m_fLandau =
new TF1(
"f_Landau",
"landau", 0, 256);
141 m_fLandau->SetParameter(0, 1000);
142 m_fLandau->SetParameter(1, 0);
143 m_fLandau->SetParameter(2, 10);
144 m_fLandau->SetLineColor(4);
145 m_fLandau->SetNpx(256);
146 m_fLandau->SetNumberFitPoints(256);
148 m_fGaus =
new TF1(
"f_Gaus",
"gaus", 0, 8096);
149 m_fGaus->SetParameter(0, 1000);
150 m_fGaus->SetParameter(1, 0);
151 m_fGaus->SetParameter(2, 10);
152 m_fGaus->SetLineColor(4);
153 m_fGaus->SetNpx(256);
154 m_fGaus->SetNumberFitPoints(256);
158 void DQMHistAnalysisPXDFitsModule::beginRun()
160 B2DEBUG(1,
"DQMHistAnalysisPXDFits: beginRun called.");
163 for (
auto i = 0; i < NUM_MODULES; i++) {
164 m_cSignal[i]->Clear();
165 m_cCommon[i]->Clear();
166 m_cCounts[i]->Clear();
171 void DQMHistAnalysisPXDFitsModule::event()
175 m_hSignalAll->Reset();
176 m_hCommonAll->Reset();
177 m_hCountsAll->Reset();
178 m_hOccupancyAll->Reset();
180 for (
auto i = 0; i < NUM_MODULES; i++) {
181 auto id = m_inx_to_id[i];
182 auto layer = (((
id >> 5) & 0x1) + 1);
183 auto ladder = ((
id >> 1) & 0xF);
184 auto sensor = ((
id & 0x1) + 1);
186 m_hSignal[i]->Reset();
187 m_hCommon[i]->Reset();
188 m_hCounts[i]->Reset();
190 for (
auto j = 0; j < 6; j++) {
191 for (
auto k = 0; k < 4; k++) {
193 string s2 = str(format(
"_%d.%d.%d_%d_%d") % layer % ladder % sensor % j % k);
195 std::string name =
"hrawPxdHitsCharge" + s2;
196 TH1* hh1 = findHist(name);
198 hh1 = findHist(m_histogramDirectoryName, name);
209 m_hSignal[i]->Fill(j, k, hh1->GetMean());
210 m_hSignalAll->Fill(i, hh1->GetMean());
212 B2INFO(
"Histo " << name <<
" not found");
215 name =
"hrawPxdHitsCommonMode" + s2;
216 hh1 = findHist(name);
218 hh1 = findHist(m_histogramDirectoryName, name);
229 m_hCommon[i]->Fill(j, k, hh1->GetMean());
230 m_hCommonAll->Fill(i, hh1->GetMean());
232 B2INFO(
"Histo " << name <<
" not found");
235 name =
"hrawPxdCount" + s2;
236 hh1 = findHist(name);
238 hh1 = findHist(m_histogramDirectoryName, name);
249 m_hCounts[i]->Fill(j, k, hh1->GetMean());
250 m_hCountsAll->Fill(i, hh1->GetMean());
251 m_hOccupancyAll->Fill(i, hh1->GetMean() / (250 * 768 / 24));
253 B2INFO(
"Histo " << name <<
" not found");
259 if (m_hSignal[i]) m_hSignal[i]->Draw(
"colz");
260 m_cSignal[i]->Modified();
261 m_cSignal[i]->Update();
265 if (m_hCommon[i]) m_hCommon[i]->Draw(
"colz");
266 m_cCommon[i]->Modified();
267 m_cCommon[i]->Update();
271 if (m_hCounts[i]) m_hCounts[i]->Draw(
"colz");
272 m_cCounts[i]->Modified();
273 m_cCounts[i]->Update();
279 m_hSignalAll->Scale(1.0 / 24.0);
280 m_hSignalAll->Draw();
282 m_cSignalAll->Modified();
283 m_cSignalAll->Update();
288 m_hCommonAll->Scale(1.0 / 24.0);
289 m_hCommonAll->Draw();
291 m_cCommonAll->Modified();
292 m_cCommonAll->Update();
299 m_hCountsAll->Draw();
301 m_cCountsAll->Modified();
302 m_cCountsAll->Update();
304 if (m_cOccupancyAll) {
305 m_cOccupancyAll->cd();
306 if (m_hOccupancyAll) {
307 m_hOccupancyAll->Scale(1.0 / 24.0);
308 m_hOccupancyAll->Draw();
310 m_cOccupancyAll->Modified();
311 m_cOccupancyAll->Update();
315 void DQMHistAnalysisPXDFitsModule::endRun()
317 B2DEBUG(1,
"DQMHistAnalysisPXDFits : endRun called");
321 void DQMHistAnalysisPXDFitsModule::terminate()
323 B2DEBUG(1,
"DQMHistAnalysisPXDFits: terminate called");
The base class for the histogram analysis module.
Class definition for the output module of Sequential ROOT I/O.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.