Belle II Software development
DQMHistAnalysisSVDOnMiraBelle.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <numeric>
10#include <limits>
11#include <vxd/geometry/GeoCache.h>
12#include <vxd/dataobjects/VxdID.h>
13#include <svd/geometry/SensorInfo.h>
14#include <vxd/geometry/SensorInfoBase.h>
15#include <vxd/geometry/GeoTools.h>
16#include <framework/datastore/StoreObjPtr.h>
17#include <framework/datastore/StoreArray.h>
18
19
20#include <dqm/analysis/modules/DQMHistAnalysisSVDOnMiraBelle.h>
21
22using namespace std;
23using namespace Belle2;
24
25//-----------------------------------------------------------------
26// Register the Module
27//-----------------------------------------------------------------
28REG_MODULE(DQMHistAnalysisSVDOnMiraBelle);
29
30//-----------------------------------------------------------------
31// Implementation
32//-----------------------------------------------------------------
33
36{
37 setDescription("DQM Analysis Module that extracts monitoring variables from SVD DQM histograms and provides input to MiraBelle.");
39 B2DEBUG(20, "DQMHistAnalysisSVDOnMiraBelle: Constructor done.");
40}
41
43{
44 gROOT->cd();
45
47
48 // add MonitoringObject
50
51 // list of canvases to be added to MonitoringObject
52 m_c_avgEfficiency = new TCanvas("svd_avgEfficiency", "matched clusters and found tracks", 0, 0, 800, 600);
53 m_c_avgOffOccupancy = new TCanvas("svd_avgOffOccupancy", "strips", 0, 0, 800, 600);
54 m_c_MPVChargeClusterOnTrack = new TCanvas("svd_MPVChargeClusterOnTrack", "charge from Clusters on Track Charge", 0, 0, 400, 400);
55 m_c_MPVSNRClusterOnTrack = new TCanvas("svd_MPVSNRClusterOnTrack", "SNR from Clusters on Track Charge", 0, 0, 400, 400);
56 m_c_MPVTimeClusterOnTrack = new TCanvas("svd_MPVTimeClusterOnTrack", "time from Clusters on Track Charge", 0, 0, 400, 400);
57 m_c_avgMaxBinClusterOnTrack = new TCanvas("svd_avgMaxBin", "average MaxBin", 0, 0, 800, 600);
58 m_c_MeanSVDEventT0 = new TCanvas("svd_MeanSVDEventT0", "Mean Event T0 from SVD for all samples", 0, 0, 400, 400);
59
60 // add canvases used to create monitoring variables to MonitoringObject
61 m_monObj->addCanvas(m_c_avgEfficiency);
62 m_monObj->addCanvas(m_c_avgOffOccupancy);
67 m_monObj->addCanvas(m_c_MeanSVDEventT0);
68
70
71 //collect the list of all SVD Modules in the geometry here
72 std::vector<VxdID> sensors = geo.getListOfSensors();
73 for (VxdID& aVxdID : sensors) {
74 VXD::SensorInfoBase info = geo.getSensorInfo(aVxdID);
75 // B2INFO("VXD " << aVxdID);
76 if (info.getType() != VXD::SensorInfoBase::SVD) continue;
77 m_SVDModules.push_back(aVxdID); // reorder, sort would be better
78 }
79 std::sort(m_SVDModules.begin(), m_SVDModules.end()); // back to natural order
80
81 if (!m_svdPlotsConfig.isValid())
82 B2FATAL("no valid configuration found for SVD reconstruction");
83 else {
84 B2DEBUG(20, "SVDRecoConfiguration: from now on we are using " << m_svdPlotsConfig->get_uniqueID());
85 //read back from payload
86 m_listOfSensorsToMonitor = m_svdPlotsConfig->getListOfSensors();
87 }
88
89 B2DEBUG(20, "DQMHistAnalysisSVDOnMiraBelle: initialized.");
90}
91
93{
94 B2DEBUG(20, "DQMHistAnalysisSVDOnMiraBelle: beginRun called.");
95}
96
98{
99 B2DEBUG(20, "DQMHistAnalysisSVDOnMiraBelle: event called.");
100}
101
103{
104 float nan = numeric_limits<float>::quiet_NaN();
105
106 // ladder label
107 std::vector<string> ladderLabel = {"L3.X.1", "L3.X.2", "L4.X.1", "L4.X.2", "L4.X.3", "L5.X.1", "L5.X.2", "L5.X.3", "L5.X.4",
108 "L6.X.1", "L6.X.2", "L6.X.3", "L6.X.4", "L6.X.5"
109 };
110
111 // sensors to monitored from GT
112 // "3.1.1", "3.1.2", "3.2.1", "3.2.2", "4.1.1", "4.3.3", "4.6.1", "4.6.2", "4.9.2", "4.10.2", "5.1.3", "5.1.4", "5.8.1",
113 // "5.8.2", "5.9.2", "5.9.4", "6.4.3", "6.6.4", "6.10.1", "6.10.2", "6.10.3", "6.11.5", "6.12.4"
114
115
116 // offline occupancy - integrated number of ZS5 fired strips
117 TH1F* h_zs5countsU = (TH1F*)findHist("SVDExpReco/SVDDQM_StripCountsU"); // made by SVDDQMExperssRecoModule
118 TH1F* h_zs5countsV = (TH1F*)findHist("SVDExpReco/SVDDQM_StripCountsV");
119 TH1F* h_events = (TH1F*)findHist("SVDExpReco/SVDDQM_nEvents");
120
121 // adding histograms to canvas
122 m_c_avgOffOccupancy->Clear();
123 m_c_avgOffOccupancy->Divide(2, 2);
124 m_c_avgOffOccupancy->cd(1);
125 if (h_zs5countsU) h_zs5countsU->Draw("colz");
126 m_c_avgOffOccupancy->cd(2);
127 if (h_zs5countsV) h_zs5countsV->Draw("colz");
128 m_c_avgOffOccupancy->cd(3);
129 if (h_events) h_events->Draw("colz");
130
131 int nE = 0;
132 if (h_events) nE = h_events->GetEntries(); // number of events for all "clusters on track" histograms
133
134 // setting monitoring variables
135 if (h_zs5countsU == NULL || h_zs5countsV == NULL || h_events == NULL) {
136 if (h_zs5countsU == NULL) {
137 B2INFO("Histograms needed for Average Offline Occupancy on U side are not found");
138 }
139 if (h_zs5countsV == NULL) {
140 B2INFO("Histograms needed for Average Offline Occupancy on V side are not found");
141 }
142 } else {
143 // average occupancy for each layer
144 std::pair<float, float> avgOffOccL3UV = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, 3);
145 SetVariable(avgOffOccL3UV);
146
147 std::pair<float, float> avgOffOccL4UV = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, 4);
148 SetVariable(avgOffOccL4UV);
149
150 std::pair<float, float> avgOffOccL5UV = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, 5);
151 SetVariable(avgOffOccL5UV);
152
153 std::pair<float, float> avgOffOccL6UV = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, 6);
154 SetVariable(avgOffOccL6UV);
155
156 // average occupancy for each layer for group Id0
157 std::pair<float, float> avgOffGrpId0OccL3UV = avgOccupancyGrpId0UV(3, nE);
158 SetVariable(avgOffGrpId0OccL3UV);
159
160 std::pair<float, float> avgOffGrpId0OccL4UV = avgOccupancyGrpId0UV(4, nE);
161 SetVariable(avgOffGrpId0OccL4UV);
162
163 std::pair<float, float> avgOffGrpId0OccL5UV = avgOccupancyGrpId0UV(5, nE);
164 SetVariable(avgOffGrpId0OccL5UV);
165
166 std::pair<float, float> avgOffGrpId0OccL6UV = avgOccupancyGrpId0UV(6, nE);
167 SetVariable(avgOffGrpId0OccL6UV);
168
169 // occupancy averaged over ladders
170 for (const auto& it : ladderLabel) {
171 string sensorDescr = it;
172 int layer = 0;
173 int sensor = 0;
174 sscanf(it.c_str(), "L%d.X.%d", &layer, &sensor);
175 std::pair<float, float> avgOffOccL = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, layer, -1, sensor);
176 addVariable(Form("avgOffOccL%dX%dUV", layer, sensor), avgOffOccL);
177 }
178
179 // average occupancy for high occupancy sensors
180 for (const auto& it : m_listOfSensorsToMonitor) {
181 string sensorDescr = it;
182 int layer = 0;
183 int ladder = 0;
184 int sensor = 0;
185 sscanf(it.c_str(), "%d.%d.%d", &layer, &ladder, &sensor);
186 std::pair<float, float> avgOffOccL = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, layer, ladder, sensor);
187 addVariable(Form("avgOffOccL%d%d%dUV", layer, ladder, sensor), avgOffOccL);
188 }
189 }
190
191
192 // efficiency of cluster reconstruction for U and V side
193 TH2F* h_found_tracksU = (TH2F*)findHist("SVDEfficiency/TrackHitsU");
194 TH2F* h_matched_clusU = (TH2F*)findHist("SVDEfficiency/MatchedHitsU");
195 TH2F* h_found_tracksV = (TH2F*)findHist("SVDEfficiency/TrackHitsV");
196 TH2F* h_matched_clusV = (TH2F*)findHist("SVDEfficiency/MatchedHitsV");
197
198 m_c_avgEfficiency->Clear();
199 m_c_avgEfficiency->Divide(2, 2);
200 m_c_avgEfficiency->cd(1);
201 if (h_found_tracksU) h_found_tracksU->Draw("colz");
202 m_c_avgEfficiency->cd(2);
203 if (h_found_tracksV) h_found_tracksV->Draw("colz");
204 m_c_avgEfficiency->cd(3);
205 if (h_matched_clusU) h_matched_clusU->Draw("colz");
206 m_c_avgEfficiency->cd(4);
207 if (h_matched_clusV) h_matched_clusV->Draw("colz");
208
209 // setting monitoring variables
210 if (h_matched_clusU == NULL || h_matched_clusV == NULL || h_found_tracksU == NULL) {
211 if (h_matched_clusU == NULL) {
212 B2INFO("Histograms needed for Average Efficiency on U side are not found");
213 }
214 if (h_matched_clusV == NULL) {
215 B2INFO("Histograms needed for Average Efficiency on V side are not found");
216 }
217 } else {
218 // average efficiency in each layer for both side (U, V)
219 std::pair<float, float> avgEffL3 = avgEfficiencyUV(h_matched_clusU, h_matched_clusV, h_found_tracksU, h_found_tracksV, 3);
220 SetVariable(avgEffL3);
221
222 std::pair<float, float> avgEffL4 = avgEfficiencyUV(h_matched_clusU, h_matched_clusV, h_found_tracksU, h_found_tracksV, 4);
223 SetVariable(avgEffL4);
224
225 std::pair<float, float> avgEffL5 = avgEfficiencyUV(h_matched_clusU, h_matched_clusV, h_found_tracksU, h_found_tracksV, 5);
226 SetVariable(avgEffL5);
227
228 std::pair<float, float> avgEffL6 = avgEfficiencyUV(h_matched_clusU, h_matched_clusV, h_found_tracksU, h_found_tracksV, 6);
229 SetVariable(avgEffL6);
230
231 // average efficiency for all layers
232 std::pair<float, float> avgEffL3456 = avgEfficiencyUV(h_matched_clusU, h_matched_clusV, h_found_tracksU, h_found_tracksV);
233 SetVariable(avgEffL3456);
234
235 // efficiency averaged over ladders
236 for (const auto& it : ladderLabel) {
237 string sensorDescr = it;
238 int layer = 0;
239 int sensor = 0;
240 sscanf(it.c_str(), "L%d.X.%d", &layer, &sensor);
241 std::pair<float, float> avgEffL = avgEfficiencyUV(h_matched_clusU, h_matched_clusV, h_found_tracksU, h_found_tracksV, layer, -1,
242 sensor);
243 addVariable(Form("avgEffL%dX%dUV", layer, sensor), avgEffL);
244 }
245
246 // average efficiency for high occupancy sensors and
247 // average efficiency for low DCDC
248 for (const auto& it : m_listOfSensorsToMonitor) {
249 string sensorDescr = it;
250 int layer = 0;
251 int ladder = 0;
252 int sensor = 0;
253 sscanf(it.c_str(), "%d.%d.%d", &layer, &ladder, &sensor);
254 std::pair<float, float> avgEffL = avgEfficiencyUV(h_matched_clusU, h_matched_clusV, h_found_tracksU, h_found_tracksV, layer, ladder,
255 sensor);
256 addVariable(Form("avgEffL%d%d%dUV", layer, ladder, sensor), avgEffL);
257 }
258 }
259
260 // MPV cluster charge for clusters on track
261 TH1F* h_clusterCharge_L3U = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterChargeU3");
262 TH1F* h_clusterCharge_L3V = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterChargeV3");
263 TH1F* h_clusterCharge_L456U = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterChargeU456");
264 TH1F* h_clusterCharge_L456V = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterChargeV456");
265
267 m_c_MPVChargeClusterOnTrack->Divide(2, 2);
269 if (h_clusterCharge_L3U) h_clusterCharge_L3U->Draw();
271 if (h_clusterCharge_L3V) h_clusterCharge_L3V->Draw();
273 if (h_clusterCharge_L456U) h_clusterCharge_L456U->Draw();
275 if (h_clusterCharge_L456U) h_clusterCharge_L456U->Draw();
276
277 // find abscissa of max Y in histograms
278 float MPVClusterChargeL3U = nan;
279 if (h_clusterCharge_L3U)
280 if (h_clusterCharge_L3U->GetEntries() != 0)
281 MPVClusterChargeL3U = xForMaxY(h_clusterCharge_L3U);
282 float MPVClusterChargeL3V = nan;
283 if (h_clusterCharge_L3V)
284 if (h_clusterCharge_L3V->GetEntries() != 0)
285 MPVClusterChargeL3V = xForMaxY(h_clusterCharge_L3V);
286 float MPVClusterChargeL456U = nan;
287 if (h_clusterCharge_L456U)
288 if (h_clusterCharge_L456U->GetEntries() != 0)
289 MPVClusterChargeL456U = xForMaxY(h_clusterCharge_L456U);
290 float MPVClusterChargeL456V = nan;
291 if (h_clusterCharge_L456V)
292 if (h_clusterCharge_L456V->GetEntries() != 0)
293 MPVClusterChargeL456V = xForMaxY(h_clusterCharge_L456V);
294
295 if (h_clusterCharge_L3U == NULL || h_clusterCharge_L456U == NULL) {
296 B2INFO("Histograms needed for MPV cluster charge on U side are not found");
297 } else {
298 m_monObj->setVariable("MPVClusterChargeL3U", MPVClusterChargeL3U);
299 m_monObj->setVariable("MPVClusterChargeL456U", MPVClusterChargeL456U);
300 }
301
302 if (h_clusterCharge_L3V == NULL || h_clusterCharge_L456V == NULL) {
303 B2INFO("Histograms needed for MPV cluster charge on V side are not found");
304 } else {
305 m_monObj->setVariable("MPVClusterChargeL3V", MPVClusterChargeL3V);
306 m_monObj->setVariable("MPVClusterChargeL456V", MPVClusterChargeL456V);
307 }
308
309
310 // MPV SNR for the clusters on track
311 TH1F* h_clusterSNR_L3U = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterSNRU3");
312 TH1F* h_clusterSNR_L3V = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterSNRV3");
313 TH1F* h_clusterSNR_L456U = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterSNRU456");
314 TH1F* h_clusterSNR_L456V = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterSNRV456");
315
317 m_c_MPVSNRClusterOnTrack->Divide(2, 2);
319 if (h_clusterSNR_L3U) h_clusterSNR_L3U->Draw();
321 if (h_clusterSNR_L3V) h_clusterSNR_L3V->Draw();
323 if (h_clusterSNR_L456U) h_clusterSNR_L456U->Draw();
325 if (h_clusterSNR_L456V) h_clusterSNR_L456V->Draw();
326
327 float MPVClusterSNRL3U = nan;
328 if (h_clusterSNR_L3U)
329 if (h_clusterSNR_L3U->GetEntries() != 0)
330 MPVClusterSNRL3U = xForMaxY(h_clusterSNR_L3U);
331 float MPVClusterSNRL3V = nan;
332 if (h_clusterSNR_L3V)
333 if (h_clusterSNR_L3V->GetEntries() != 0)
334 MPVClusterSNRL3V = xForMaxY(h_clusterSNR_L3V);
335 float MPVClusterSNRL456U = nan;
336 if (h_clusterSNR_L456U)
337 if (h_clusterSNR_L456U->GetEntries() != 0)
338 MPVClusterSNRL456U = xForMaxY(h_clusterSNR_L456U);
339 float MPVClusterSNRL456V = nan;
340 if (h_clusterSNR_L456V)
341 if (h_clusterSNR_L456V->GetEntries() != 0)
342 MPVClusterSNRL456V = xForMaxY(h_clusterSNR_L456V);
343
344 if (h_clusterSNR_L3U == NULL || h_clusterSNR_L456U == NULL) {
345 B2INFO("Histograms needed for MPV cluster SNR on U side are not found");
346 } else {
347 m_monObj->setVariable("MPVClusterSNRL3U", MPVClusterSNRL3U);
348 m_monObj->setVariable("MPVClusterSNRL456U", MPVClusterSNRL456U);
349 }
350
351 if (h_clusterSNR_L3V == NULL || h_clusterSNR_L456V == NULL) {
352 B2INFO("Histograms needed for MPV cluster SNR on V side are not found");
353 } else {
354 m_monObj->setVariable("MPVClusterSNRL3V", MPVClusterSNRL3V);
355 m_monObj->setVariable("MPVClusterSNRL456V", MPVClusterSNRL456V);
356 }
357
358
359 // MPV SVD cluster time for the clusters on track
360 TH1F* h_clusterTime_L3U = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterTimeU3");
361 TH1F* h_clusterTime_L3V = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterTimeV3");
362 TH1F* h_clusterTime_L456U = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterTimeU456");
363 TH1F* h_clusterTime_L456V = (TH1F*)findHist("SVDClsTrk/SVDTRK_ClusterTimeV456");
364 TH1F* h_MeanSVD3EventT0 = (TH1F*)findHist("SVDHitTime/SVD3EventT0");
365 TH1F* h_MeanSVD6EventT0 = (TH1F*)findHist("SVDHitTime/SVD6EventT0");
366 TH1F* h_MeanSVDEventT0 = 0x0;
367
368 if (h_MeanSVD3EventT0)
369 h_MeanSVDEventT0 = (TH1F*)h_MeanSVD3EventT0->Clone();
370
372 m_c_MPVTimeClusterOnTrack->Divide(2, 2);
374 if (h_clusterTime_L3U) h_clusterTime_L3U->Draw();
376 if (h_clusterTime_L3V) h_clusterTime_L3V->Draw();
378 if (h_clusterTime_L456U) h_clusterTime_L456U->Draw();
380 if (h_clusterTime_L456V) h_clusterTime_L456V->Draw();
381
382 m_c_MeanSVDEventT0->Clear();
383 m_c_MeanSVDEventT0->Divide(2, 2);
384 m_c_MeanSVDEventT0->cd(1);
385 if (h_MeanSVD3EventT0) h_MeanSVD3EventT0->Draw();
386 m_c_MeanSVDEventT0->cd(2);
387 if (h_MeanSVD6EventT0) h_MeanSVD6EventT0->Draw();
388 m_c_MeanSVDEventT0->cd(3);
389 if (h_MeanSVDEventT0) {
390 if (h_MeanSVD6EventT0)
391 h_MeanSVDEventT0->Add(h_MeanSVD6EventT0);
392 h_MeanSVDEventT0->Draw();
393 }
394
395 float MPVClusterTimeL3U = nan;
396 if (h_clusterTime_L3U)
397 if (h_clusterTime_L3U->GetEntries() != 0)
398 MPVClusterTimeL3U = xForMaxY(h_clusterTime_L3U);
399 float MPVClusterTimeL3V = nan;
400 if (h_clusterTime_L3V)
401 if (h_clusterTime_L3V->GetEntries() != 0)
402 MPVClusterTimeL3V = xForMaxY(h_clusterTime_L3V);
403 float MPVClusterTimeL456U = nan;
404 if (h_clusterTime_L456U)
405 if (h_clusterTime_L456U->GetEntries() != 0)
406 MPVClusterTimeL456U = xForMaxY(h_clusterTime_L456U);
407 float MPVClusterTimeL456V = nan;
408 if (h_clusterTime_L456V)
409 if (h_clusterTime_L456V->GetEntries() != 0)
410 MPVClusterTimeL456V = xForMaxY(h_clusterTime_L456V);
411 float FWHMClusterTimeL3U = nan;
412 if (h_clusterTime_L3U)
413 if (h_clusterTime_L3U->GetEntries() != 0)
414 FWHMClusterTimeL3U = histFWHM(h_clusterTime_L3U);
415 float FWHMClusterTimeL3V = nan;
416 if (h_clusterTime_L3V)
417 if (h_clusterTime_L3V->GetEntries() != 0)
418 FWHMClusterTimeL3V = histFWHM(h_clusterTime_L3V);
419 float FWHMClusterTimeL456U = nan;
420 if (h_clusterTime_L456U)
421 if (h_clusterTime_L456U->GetEntries() != 0)
422 FWHMClusterTimeL456U = histFWHM(h_clusterTime_L456U);
423 float FWHMClusterTimeL456V = nan;
424 if (h_clusterTime_L456V)
425 if (h_clusterTime_L456V->GetEntries() != 0)
426 FWHMClusterTimeL456V = histFWHM(h_clusterTime_L456V);
427
428 float MeanSVD3EventT0 = nan;
429 if (h_MeanSVD3EventT0)
430 if (h_MeanSVD3EventT0->GetEntries() != 0)
431 MeanSVD3EventT0 = xForMaxY(h_MeanSVD3EventT0);
432
433 float MeanSVD6EventT0 = nan;
434 if (h_MeanSVD6EventT0)
435 if (h_MeanSVD6EventT0->GetEntries() != 0)
436 MeanSVD6EventT0 = xForMaxY(h_MeanSVD6EventT0);
437
438 float MeanSVDEventT0 = nan;
439 if (h_MeanSVDEventT0)
440 if (h_MeanSVDEventT0->GetEntries() != 0)
441 MeanSVDEventT0 = xForMaxY(h_MeanSVDEventT0);
442
443 if (h_clusterTime_L3U == NULL || h_clusterTime_L456U == NULL) {
444 B2INFO("Histograms needed for MPV cluster time on U side are not found");
445 } else {
446 m_monObj->setVariable("MPVClusterTimeL3U", MPVClusterTimeL3U);
447 m_monObj->setVariable("MPVClusterTimeL456U", MPVClusterTimeL456U);
448 m_monObj->setVariable("FWHMClusterTimeL3U", FWHMClusterTimeL3U);
449 m_monObj->setVariable("FWHMClusterTimeL456U", FWHMClusterTimeL456U);
450 }
451
452 if (h_clusterTime_L3V == NULL || h_clusterTime_L456V == NULL) {
453 B2INFO("Histograms needed for MPV cluster time on V side are not found");
454 } else {
455 m_monObj->setVariable("MPVClusterTimeL3V", MPVClusterTimeL3V);
456 m_monObj->setVariable("MPVClusterTimeL456V", MPVClusterTimeL456V);
457 m_monObj->setVariable("FWHMClusterTimeL3V", FWHMClusterTimeL3V);
458 m_monObj->setVariable("FWHMClusterTimeL456V", FWHMClusterTimeL456V);
459 }
460
461 if (h_MeanSVD3EventT0 == NULL) {
462 B2INFO("Histograms needed for SVD Event T0 (3 samples) not found");
463 } else {
464 m_monObj->setVariable("MeanSVD3EventT0", MeanSVD3EventT0);
465 }
466
467 if (h_MeanSVD6EventT0 == NULL) {
468 B2INFO("Histograms needed for SVD Event T0 (6 samples) not found");
469 } else {
470 m_monObj->setVariable("MeanSVD6EventT0", MeanSVD6EventT0);
471 }
472
473 if (h_MeanSVDEventT0 == NULL) {
474 B2INFO("Histograms needed for SVD Event T0 (all samples) not found");
475 } else {
476 m_monObj->setVariable("MeanSVDEventT0", MeanSVDEventT0);
477 }
478
479 // average maxBin for clusters on track
480 TH1F* h_maxBinU = (TH1F*)findHist("SVDClsTrk/SVDTRK_StripMaxBinUAll");
481 TH1F* h_maxBinV = (TH1F*)findHist("SVDClsTrk/SVDTRK_StripMaxBinVAll");
482
484 m_c_avgMaxBinClusterOnTrack->Divide(2, 1);
486 if (h_maxBinU) h_maxBinU->Draw();
488 if (h_maxBinV) h_maxBinV->Draw();
489
490 if (h_maxBinU == NULL) {
491 B2INFO("Histogram needed for Average MaxBin on U side is not found");
492 } else {
493 float avgMaxBinU = h_maxBinU->GetMean();
494 m_monObj->setVariable("avgMaxBinU", avgMaxBinU);
495 }
496
497 if (h_maxBinV == NULL) {
498 B2INFO("Histogram needed for Average MaxBin on V side is not found");
499 } else {
500 float avgMaxBinV = h_maxBinV->GetMean();
501 m_monObj->setVariable("avgMaxBinV", avgMaxBinV);
502 }
503
504 // Cluster on track ladder
505 for (const auto& it : ladderLabel) {
506 string sensorDescr = it;
507 int layer = 0;
508 int sensor = 0;
509 sscanf(it.c_str(), "L%d.X.%d", &layer, &sensor);
510
511 TString name = Form("SVDClsTrk/SVDTRK_ClusterCharge_L%d.x.%d", layer, sensor);
512 TString title = Form("MPVClusterCharge_L%d.x.%d", layer, sensor);
513 TH1F* h_clusterCharge = (TH1F*)findHist(name.Data());
514 float MPVClusterCharge = nan;
515 if (h_clusterCharge)
516 if (h_clusterCharge->GetEntries() != 0)
517 MPVClusterCharge = xForMaxY(h_clusterCharge);
518
519 if (h_clusterCharge == NULL) {
520 B2INFO("Histograms needed for cluster charge not found");
521 } else {
522 m_monObj->setVariable(title.Data(), MPVClusterCharge);
523 }
524
525 name = Form("SVDClsTrk/SVDTRK_ClusterSNR_L%d.x.%d", layer, sensor);
526 title = Form("MPVClusterSNR_L%d.x.%d", layer, sensor);
527 TH1F* h_clusterSNR = (TH1F*)findHist(name.Data());
528 float MPVClusterSNR = nan;
529 if (h_clusterSNR)
530 if (h_clusterSNR->GetEntries() != 0)
531 MPVClusterSNR = xForMaxY(h_clusterSNR);
532
533 if (h_clusterSNR == NULL) {
534 B2INFO("Histograms needed for cluster SNR not found");
535 } else {
536 m_monObj->setVariable(title.Data(), MPVClusterSNR);
537 }
538 }
539
540 // Cluster on track peculiar sensors
541 for (const auto& it : m_listOfSensorsToMonitor) {
542 string sensorDescr = it;
543 string valueLabel = it;
544 replace(sensorDescr.begin(), sensorDescr.end(), '.', '_');
545 valueLabel.erase(remove(valueLabel.begin(), valueLabel.end(), '.'), valueLabel.end());
546
547 TString name = Form("SVDClsTrk/SVDTRK_%s_ClusterChargeU", sensorDescr.c_str());
548 TString title = Form("MPVClusterChargeL%sU", valueLabel.c_str());
549 TString title1 = "";
550 TH1F* h_clusterCharge = (TH1F*)findHist(name.Data());
551 float MPVClusterCharge = nan;
552 if (h_clusterCharge)
553 if (h_clusterCharge->GetEntries() != 0)
554 MPVClusterCharge = xForMaxY(h_clusterCharge);
555
556 if (h_clusterCharge == NULL) {
557 B2INFO("Histograms needed for clusterU charge not found");
558 } else {
559 m_monObj->setVariable(title.Data(), MPVClusterCharge);
560 }
561
562 name = Form("SVDClsTrk/SVDTRK_%s_ClusterChargeV", sensorDescr.c_str());
563 title = Form("MPVClusterChargeL%sV", valueLabel.c_str());
564 h_clusterCharge = (TH1F*)findHist(name.Data());
565 MPVClusterCharge = nan;
566 if (h_clusterCharge)
567 if (h_clusterCharge->GetEntries() != 0)
568 MPVClusterCharge = xForMaxY(h_clusterCharge);
569
570 if (h_clusterCharge == NULL) {
571 B2INFO("Histograms needed for clusterV charge not found");
572 } else {
573 m_monObj->setVariable(title.Data(), MPVClusterCharge);
574 }
575
576 name = Form("SVDClsTrk/SVDTRK_%s_ClusterSNRU", sensorDescr.c_str());
577 title = Form("MPVClusterSNRL%sU", valueLabel.c_str());
578 TH1F* h_clusterSNR = (TH1F*)findHist(name.Data());
579 float MPVClusterSNR = nan;
580 if (h_clusterSNR)
581 if (h_clusterSNR->GetEntries() != 0)
582 MPVClusterSNR = xForMaxY(h_clusterSNR);
583
584 if (h_clusterSNR == NULL) {
585 B2INFO("Histograms needed for clusterU SNR not found");
586 } else {
587 m_monObj->setVariable(title.Data(), MPVClusterSNR);
588 }
589
590 name = Form("SVDClsTrk/SVDTRK_%s_ClusterSNRV", sensorDescr.c_str());
591 title = Form("MPVClusterSNRL%sV", valueLabel.c_str());
592 h_clusterSNR = (TH1F*)findHist(name.Data());
593 MPVClusterSNR = nan;
594 if (h_clusterSNR)
595 if (h_clusterSNR->GetEntries() != 0)
596 MPVClusterSNR = xForMaxY(h_clusterSNR);
597
598 if (h_clusterSNR == NULL) {
599 B2INFO("Histograms needed for clusterV SNR not found");
600 } else {
601 m_monObj->setVariable(title.Data(), MPVClusterSNR);
602 }
603
604 name = Form("SVDClsTrk/SVDTRK_%s_ClusterTimeU", sensorDescr.c_str());
605 title = Form("MPVClusterTimeL%sU", valueLabel.c_str());
606 title1 = Form("FWHMClusterTimeL%sU", valueLabel.c_str());
607 TH1F* h_clusterTime = (TH1F*)findHist(name.Data());
608 float MPVClusterTime = nan;
609 float FWHMClusterTime = nan;
610 if (h_clusterTime)
611 if (h_clusterTime->GetEntries() != 0) {
612 MPVClusterTime = xForMaxY(h_clusterTime);
613 FWHMClusterTime = histFWHM(h_clusterTime);
614 }
615
616 if (h_clusterTime == NULL) {
617 B2INFO("Histograms needed for clusterU time not found");
618 } else {
619 m_monObj->setVariable(title.Data(), MPVClusterTime);
620 m_monObj->setVariable(title1.Data(), FWHMClusterTime);
621 }
622
623 name = Form("SVDClsTrk/SVDTRK_%s_ClusterTimeV", sensorDescr.c_str());
624 title = Form("MPVClusterTimeL%sV", valueLabel.c_str());
625 title1 = Form("FWHMClusterTimeL%sV", valueLabel.c_str());
626 h_clusterTime = (TH1F*)findHist(name.Data());
627 MPVClusterTime = nan;
628 FWHMClusterTime = nan;
629 if (h_clusterTime)
630 if (h_clusterTime->GetEntries() != 0) {
631 MPVClusterTime = xForMaxY(h_clusterTime);
632 FWHMClusterTime = histFWHM(h_clusterTime);
633 }
634
635 if (h_clusterTime == NULL) {
636 B2INFO("Histograms needed for clusterU time not found");
637 } else {
638 m_monObj->setVariable(title.Data(), MPVClusterTime);
639 m_monObj->setVariable(title1.Data(), FWHMClusterTime);
640 }
641 }
642
643 B2INFO("DQMHistAnalysisSVDGeneral: endRun called");
644}
645
646
648{
649 B2INFO("DQMHistAnalysisSVDOnMiraBelle: terminate called");
650}
651
652std::pair<float, float> DQMHistAnalysisSVDOnMiraBelleModule::avgOccupancyUV(TH1F* hU, TH1F* hV, int nEvents,
653 int layer, int ladder, int sensor) const
654{
655 int nStripsV = -1;
656 if (layer == 3) {
657 nStripsV = 768;
658 } else if (layer >= 4 && layer <= 6) {
659 nStripsV = 512;
660 } else {
661 B2DEBUG(20, "Layer out of range [3,6].");
662 }
663 std::pair<float, float> avgOffOccUV(0.0, 0.0);
664
665 int minLayer = (layer != -1) ? layer : m_gTools->getFirstSVDLayer();
666 int maxLayer = (layer != -1) ? layer : m_gTools->getLastSVDLayer();
667 int sensorsN = 0;
668
669 if (ladder == 0) ladder = -1;
670
671 for (int layerId = minLayer; layerId < maxLayer + 1; ++layerId) {
672 int minLadder = (ladder != -1) ? ladder : 1;
673 int maxLadder = (ladder != -1) ? ladder : getNumberOfLadders(layerId);
674
675 int minSensor = (sensor != -1) ? sensor : 1;
676 int maxSensor = (sensor != -1) ? sensor : getNumberOfSensors(layerId);
677
678 for (int sensorId = minSensor; sensorId < maxSensor + 1; ++sensorId) {
679
680 for (int ladderId = minLadder; ladderId < maxLadder + 1; ++ladderId) {
681 int bin = m_gTools->getSVDSensorIndex(layerId, ladderId, sensorId) + 1;
682
683 avgOffOccUV.first += hU->GetBinContent(bin) / 768 * 100;
684 avgOffOccUV.second += hV->GetBinContent(bin) / nStripsV * 100;
685 sensorsN++;
686 }
687 }
688 }
689
690 avgOffOccUV.first /= (sensorsN * nEvents);
691 avgOffOccUV.second /= (sensorsN * nEvents);
692
693 return avgOffOccUV;
694}
695
696std::pair<float, float> DQMHistAnalysisSVDOnMiraBelleModule::avgOccupancyGrpId0UV(int iLayer, int nEvents) const
697{
698 int nStripsV = -1;
699 if (iLayer == 3) {
700 nStripsV = 768;
701 } else if (iLayer >= 4 && iLayer <= 6) {
702 nStripsV = 512;
703 } else {
704 B2DEBUG(20, "Layer out of range [3,6].");
705 }
706
707 Int_t nStripsU = 768;
708
709 std::vector<float> avgOffOccU;
710 std::vector<float> avgOffOccV;
711
712 for (unsigned int i = 0; i < m_SVDModules.size(); i++) {
713 int tmp_layer = m_SVDModules[i].getLayerNumber();
714 int tmp_ladder = m_SVDModules[i].getLadderNumber();
715 int tmp_sensor = m_SVDModules[i].getSensorNumber();
716
717 TString tmpnameGrpId0U = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsU", tmp_layer, tmp_ladder, tmp_sensor);
718 TH1F* htmpU = (TH1F*)findHist(tmpnameGrpId0U.Data());
719 if (htmpU == NULL) {
720 B2INFO("Occupancy U histogram for group Id0 not found");
721 } else {
722 if (tmp_layer == iLayer)
723 avgOffOccU.push_back(htmpU->GetEntries() / nStripsU / nEvents * 100);
724 }
725
726 TString tmpnameGrpId0V = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsV", tmp_layer, tmp_ladder, tmp_sensor);
727 TH1F* htmpV = (TH1F*)findHist(tmpnameGrpId0V.Data());
728 if (htmpV == NULL) {
729 B2INFO("Occupancy V histogram for group Id0 not found");
730 } else {
731 if (tmp_layer == iLayer)
732 avgOffOccV.push_back(htmpV->GetEntries() / nStripsV / nEvents * 100);
733 }
734 }
735
736 std::pair<float, float> avgOffOccUV(0., 0.);
737
738 avgOffOccUV.first = accumulate(avgOffOccU.begin(), avgOffOccU.end(), 0.0);
739 avgOffOccUV.first /= float(avgOffOccU.size());
740
741 avgOffOccUV.second = accumulate(avgOffOccV.begin(), avgOffOccV.end(), 0.0);
742 avgOffOccUV.second /= float(avgOffOccV.size());
743
744 return avgOffOccUV;
745}
746
747std::pair<float, float> DQMHistAnalysisSVDOnMiraBelleModule::avgEfficiencyUV(TH2F* hMCU, TH2F* hMCV, TH2F* hFTU, TH2F* hFTV,
748 int layer,
749 int ladder, int sensor) const
750{
751 float nan = numeric_limits<float>::quiet_NaN();
752 std::pair<float, float> avgEffUV(0.0, 0.0);
753 std::pair<float, float> sumMatchedClustersUV(0.0, 0.0);
754 std::pair<float, float> sumFoundTracksUV(0.0, 0.0);
755
756 int minLayer = (layer != -1) ? layer : m_gTools->getFirstSVDLayer();
757 int maxLayer = (layer != -1) ? layer : m_gTools->getLastSVDLayer();
758
759 if (ladder == 0) ladder = -1;
760
761 for (int layerId = minLayer; layerId < maxLayer + 1; ++layerId) {
762 int minLadder = (ladder != -1) ? ladder : 1;
763 int maxLadder = (ladder != -1) ? ladder : getNumberOfLadders(layerId);
764
765 int minSensor = (sensor != -1) ? sensor : 1;
766 int maxSensor = (sensor != -1) ? sensor : getNumberOfSensors(layerId);
767
768 for (int sensorId = minSensor; sensorId < maxSensor + 1; ++sensorId) {
769
770 for (int ladderId = minLadder; ladderId < maxLadder + 1; ++ladderId) {
771 int binY = findBinY(layerId, sensorId);
772 int binXY = hMCV->FindBin(ladderId, binY);
773
774 sumMatchedClustersUV.first += hMCU->GetBinContent(binXY);
775 sumMatchedClustersUV.second += hMCV->GetBinContent(binXY);
776 sumFoundTracksUV.first += hFTU->GetBinContent(binXY);
777 sumFoundTracksUV.second += hFTV->GetBinContent(binXY);
778 }
779 }
780 }
781
782 if (sumFoundTracksUV.first > 0) {
783 avgEffUV.first = sumMatchedClustersUV.first / sumFoundTracksUV.first * 100;
784 } else {
785 avgEffUV.first = nan;
786 }
787
788 if (sumFoundTracksUV.second > 0) {
789 avgEffUV.second = sumMatchedClustersUV.second / sumFoundTracksUV.second * 100;
790 } else {
791 avgEffUV.second = nan;
792 }
793
794 return avgEffUV;
795}
796
797
798void DQMHistAnalysisSVDOnMiraBelleModule::addVariable(string name, pair<float, float>& varUV)
799{
800 size_t pos = name.find("UV");
801
802 if (pos != string::npos)
803 name.replace(pos, 2, "");
804
805 m_monObj->setVariable(Form("%sU", name.c_str()), varUV.first);
806 m_monObj->setVariable(Form("%sV", name.c_str()), varUV.second);
807}
808
810{
811 int maxY = h->GetMaximumBin();
812 float xMaxY = h->GetXaxis()->GetBinCenter(maxY);
813 return xMaxY;
814}
815
817{
818 int bin1 = h->FindFirstBinAbove(h->GetMaximum() / 2);
819 int bin2 = h->FindLastBinAbove(h->GetMaximum() / 2);
820 float fwhm = h->GetBinCenter(bin2) - h->GetBinCenter(bin1);
821 return fwhm;
822}
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
DQMHistAnalysisModule()
Constructor / Destructor.
void initialize() override final
Module function initialize.
float histFWHM(TH1F *h) const
Calculate full width at half maximum of histogram.
TCanvas * m_c_MPVTimeClusterOnTrack
time for clusters on track
std::vector< VxdID > m_SVDModules
IDs of all SVD Modules to iterate over.
const VXD::GeoTools * m_gTools
geometrical tool pointer
void addVariable(std::string name, std::pair< float, float > &varUV)
Add variable to object monitoring.
TCanvas * m_c_MPVChargeClusterOnTrack
charge for clusters on track
DBObjPtr< SVDDQMPlotsConfiguration > m_svdPlotsConfig
SVD DQM plots configuration.
MonitoringObject * m_monObj
Monitoring Object to be produced by this module, which contain defined canvases and monitoring variab...
TCanvas * m_c_avgEfficiency
List of canvases to be added to MonitoringObject.
void terminate() override final
Module function terminate.
Int_t findBinY(Int_t layer, Int_t sensor) const
find the Y bin given the layer and sensor number
void event() override final
Module function event.
std::pair< float, float > avgOccupancyGrpId0UV(int iLayer, int nEvents) const
Calculate avg offline occupancy for specified layer for time group id = 0.
std::pair< float, float > avgOccupancyUV(TH1F *hU, TH1F *hV, int nEvents, int layer=-1, int ladder=-1, int sensor=-1) const
Calculate avg offline occupancy for one specific sensor, especially.
std::pair< float, float > avgEfficiencyUV(TH2F *hMCU, TH2F *hMCV, TH2F *hFTU, TH2F *hFTV, int layer=-1, int ladder=-1, int sensor=-1) const
Calculate avg efficiency for specified sensors.
TCanvas * m_c_MPVSNRClusterOnTrack
SNR for clusters on track.
Int_t getNumberOfLadders(Int_t layer) const
get number of ladders per layer
void endRun() override final
Module function endRun.
float xForMaxY(TH1F *h) const
Calculate abscissa of max Y bin.
TCanvas * m_c_avgOffOccupancy
number of ZS5 fired strips
void beginRun() override final
Module function beginRun.
TCanvas * m_c_avgMaxBinClusterOnTrack
average number of the APV sample which corresponds to the maximum amplitude for clusters on track
std::vector< std::string > m_listOfSensorsToMonitor
list of sensor to monitor (Charge, SNR, time; U/V) taken from DB (payload)
Int_t getNumberOfSensors(Int_t layer) const
get number of sensors per layer
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
Class to facilitate easy access to sensor information of the VXD like coordinate transformations or p...
Definition GeoCache.h:38
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
Definition GeoCache.cc:59
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference to the SensorInfo of a given SensorID.
Definition GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition GeoCache.cc:214
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Definition GeoCache.h:141
Base class to provide Sensor Information for PXD and SVD.
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:32
#define SetVariable(x)
set variable to mirabelle for a given member
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.