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
45{
46 gROOT->cd();
47
49
50 // add MonitoringObject
52
53 // list of canvases to be added to MonitoringObject
54 m_c_avgEfficiency = new TCanvas("svd_avgEfficiency", "matched clusters and found tracks", 0, 0, 800, 600);
55 m_c_avgOffOccupancy = new TCanvas("svd_avgOffOccupancy", "strips", 0, 0, 800, 600);
56 m_c_MPVChargeClusterOnTrack = new TCanvas("svd_MPVChargeClusterOnTrack", "charge from Clusters on Track Charge", 0, 0, 400, 400);
57 m_c_MPVSNRClusterOnTrack = new TCanvas("svd_MPVSNRClusterOnTrack", "SNR from Clusters on Track Charge", 0, 0, 400, 400);
58 m_c_MPVTimeClusterOnTrack = new TCanvas("svd_MPVTimeClusterOnTrack", "time from Clusters on Track Charge", 0, 0, 400, 400);
59 m_c_avgMaxBinClusterOnTrack = new TCanvas("svd_avgMaxBin", "average MaxBin", 0, 0, 800, 600);
60 m_c_MeanSVDEventT0 = new TCanvas("svd_MeanSVDEventT0", "Mean Event T0 from SVD for all samples", 0, 0, 400, 400);
61
62 // add canvases used to create monitoring variables to MonitoringObject
63 m_monObj->addCanvas(m_c_avgEfficiency);
64 m_monObj->addCanvas(m_c_avgOffOccupancy);
69 m_monObj->addCanvas(m_c_MeanSVDEventT0);
70
72
73 //collect the list of all SVD Modules in the geometry here
74 std::vector<VxdID> sensors = geo.getListOfSensors();
75 for (const VxdID& aVxdID : sensors) {
76 VXD::SensorInfoBase info = geo.getSensorInfo(aVxdID);
77 // B2INFO("VXD " << aVxdID);
78 if (info.getType() != VXD::SensorInfoBase::SVD) continue;
79 m_SVDModules.push_back(aVxdID); // reorder, sort would be better
80 }
81 std::sort(m_SVDModules.begin(), m_SVDModules.end()); // back to natural order
82
83 if (!m_svdPlotsConfig.isValid())
84 B2FATAL("no valid configuration found for SVD reconstruction");
85 else {
86 B2DEBUG(20, "SVDRecoConfiguration: from now on we are using " << m_svdPlotsConfig->get_uniqueID());
87 //read back from payload
88 m_listOfSensorsToMonitor = m_svdPlotsConfig->getListOfSensors();
89 }
90
91 B2DEBUG(20, "DQMHistAnalysisSVDOnMiraBelle: initialized.");
92}
93
95{
96 B2DEBUG(20, "DQMHistAnalysisSVDOnMiraBelle: beginRun called.");
97}
98
100{
101 B2DEBUG(20, "DQMHistAnalysisSVDOnMiraBelle: event called.");
102}
103
105{
106 float nan = numeric_limits<float>::quiet_NaN();
107
108 // ladder label
109 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",
110 "L6.X.1", "L6.X.2", "L6.X.3", "L6.X.4", "L6.X.5"
111 };
112
113 // sensors to monitored from GT
114 // "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",
115 // "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"
116
117
118 // offline occupancy - integrated number of ZS5 fired strips
119 auto h_zs5countsU = findHist("SVDExpReco/SVDDQM_StripCountsU"); // made by SVDDQMExperssRecoModule
120 auto h_zs5countsV = findHist("SVDExpReco/SVDDQM_StripCountsV");
121 auto h_events = findHist("SVDExpReco/SVDDQM_nEvents");
122
123 // adding histograms to canvas
124 m_c_avgOffOccupancy->Clear();
125 m_c_avgOffOccupancy->Divide(2, 2);
126 m_c_avgOffOccupancy->cd(1);
127 if (h_zs5countsU) h_zs5countsU->Draw("colz");
128 m_c_avgOffOccupancy->cd(2);
129 if (h_zs5countsV) h_zs5countsV->Draw("colz");
130 m_c_avgOffOccupancy->cd(3);
131 if (h_events) h_events->Draw("colz");
132
133 int nE = 0;
134 if (h_events) nE = h_events->GetEntries(); // number of events for all "clusters on track" histograms
135
136 // setting monitoring variables
137 if (h_zs5countsU == NULL || h_zs5countsV == NULL || h_events == NULL) {
138 if (h_zs5countsU == NULL) {
139 B2INFO("Histograms needed for Average Offline Occupancy on U side are not found");
140 }
141 if (h_zs5countsV == NULL) {
142 B2INFO("Histograms needed for Average Offline Occupancy on V side are not found");
143 }
144 } else {
145 // average occupancy for each layer
146 std::pair<float, float> avgOffOccL3UV = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, 3);
147 SetVariable(avgOffOccL3UV);
148
149 std::pair<float, float> avgOffOccL4UV = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, 4);
150 SetVariable(avgOffOccL4UV);
151
152 std::pair<float, float> avgOffOccL5UV = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, 5);
153 SetVariable(avgOffOccL5UV);
154
155 std::pair<float, float> avgOffOccL6UV = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, 6);
156 SetVariable(avgOffOccL6UV);
157
158 // average occupancy for each layer for group Id0
159 std::pair<float, float> avgOffGrpId0OccL3UV = avgOccupancyGrpId0UV(3, nE);
160 SetVariable(avgOffGrpId0OccL3UV);
161
162 std::pair<float, float> avgOffGrpId0OccL4UV = avgOccupancyGrpId0UV(4, nE);
163 SetVariable(avgOffGrpId0OccL4UV);
164
165 std::pair<float, float> avgOffGrpId0OccL5UV = avgOccupancyGrpId0UV(5, nE);
166 SetVariable(avgOffGrpId0OccL5UV);
167
168 std::pair<float, float> avgOffGrpId0OccL6UV = avgOccupancyGrpId0UV(6, nE);
169 SetVariable(avgOffGrpId0OccL6UV);
170
171 // occupancy averaged over ladders
172 for (const auto& it : ladderLabel) {
173 int layer = 0;
174 int sensor = 0;
175 sscanf(it.c_str(), "L%d.X.%d", &layer, &sensor);
176 std::pair<float, float> avgOffOccL = avgOccupancyUV(h_zs5countsU, h_zs5countsV, nE, layer, -1, sensor);
177 addVariable(Form("avgOffOccL%dX%dUV", layer, sensor), avgOffOccL);
178 }
179
180 // average occupancy for high occupancy sensors
181 for (const auto& it : m_listOfSensorsToMonitor) {
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 auto h_found_tracksU = findHist("SVDEfficiency/TrackHitsU");
194 auto h_matched_clusU = findHist("SVDEfficiency/MatchedHitsU");
195 auto h_found_tracksV = findHist("SVDEfficiency/TrackHitsV");
196 auto h_matched_clusV = 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 int layer = 0;
238 int sensor = 0;
239 sscanf(it.c_str(), "L%d.X.%d", &layer, &sensor);
240 std::pair<float, float> avgEffL = avgEfficiencyUV(h_matched_clusU, h_matched_clusV, h_found_tracksU, h_found_tracksV, layer, -1,
241 sensor);
242 addVariable(Form("avgEffL%dX%dUV", layer, sensor), avgEffL);
243 }
244
245 // average efficiency for high occupancy sensors and
246 // average efficiency for low DCDC
247 for (const auto& it : m_listOfSensorsToMonitor) {
248 int layer = 0;
249 int ladder = 0;
250 int sensor = 0;
251 sscanf(it.c_str(), "%d.%d.%d", &layer, &ladder, &sensor);
252 std::pair<float, float> avgEffL = avgEfficiencyUV(h_matched_clusU, h_matched_clusV, h_found_tracksU, h_found_tracksV, layer, ladder,
253 sensor);
254 addVariable(Form("avgEffL%d%d%dUV", layer, ladder, sensor), avgEffL);
255 }
256 }
257
258 // MPV cluster charge for clusters on track
259 auto h_clusterCharge_L3U = findHist("SVDClsTrk/SVDTRK_ClusterChargeU3");
260 auto h_clusterCharge_L3V = findHist("SVDClsTrk/SVDTRK_ClusterChargeV3");
261 auto h_clusterCharge_L456U = findHist("SVDClsTrk/SVDTRK_ClusterChargeU456");
262 auto h_clusterCharge_L456V = findHist("SVDClsTrk/SVDTRK_ClusterChargeV456");
263
265 m_c_MPVChargeClusterOnTrack->Divide(2, 2);
267 if (h_clusterCharge_L3U) h_clusterCharge_L3U->Draw();
269 if (h_clusterCharge_L3V) h_clusterCharge_L3V->Draw();
271 if (h_clusterCharge_L456U) h_clusterCharge_L456U->Draw();
273 if (h_clusterCharge_L456U) h_clusterCharge_L456U->Draw();
274
275 // find abscissa of max Y in histograms
276 float MPVClusterChargeL3U = nan;
277 if (h_clusterCharge_L3U)
278 if (h_clusterCharge_L3U->GetEntries() != 0)
279 MPVClusterChargeL3U = xForMaxY(h_clusterCharge_L3U);
280 float MPVClusterChargeL3V = nan;
281 if (h_clusterCharge_L3V)
282 if (h_clusterCharge_L3V->GetEntries() != 0)
283 MPVClusterChargeL3V = xForMaxY(h_clusterCharge_L3V);
284 float MPVClusterChargeL456U = nan;
285 if (h_clusterCharge_L456U)
286 if (h_clusterCharge_L456U->GetEntries() != 0)
287 MPVClusterChargeL456U = xForMaxY(h_clusterCharge_L456U);
288 float MPVClusterChargeL456V = nan;
289 if (h_clusterCharge_L456V)
290 if (h_clusterCharge_L456V->GetEntries() != 0)
291 MPVClusterChargeL456V = xForMaxY(h_clusterCharge_L456V);
292
293 if (h_clusterCharge_L3U == NULL || h_clusterCharge_L456U == NULL) {
294 B2INFO("Histograms needed for MPV cluster charge on U side are not found");
295 } else {
296 m_monObj->setVariable("MPVClusterChargeL3U", MPVClusterChargeL3U);
297 m_monObj->setVariable("MPVClusterChargeL456U", MPVClusterChargeL456U);
298 }
299
300 if (h_clusterCharge_L3V == NULL || h_clusterCharge_L456V == NULL) {
301 B2INFO("Histograms needed for MPV cluster charge on V side are not found");
302 } else {
303 m_monObj->setVariable("MPVClusterChargeL3V", MPVClusterChargeL3V);
304 m_monObj->setVariable("MPVClusterChargeL456V", MPVClusterChargeL456V);
305 }
306
307
308 // MPV SNR for the clusters on track
309 auto h_clusterSNR_L3U = findHist("SVDClsTrk/SVDTRK_ClusterSNRU3");
310 auto h_clusterSNR_L3V = findHist("SVDClsTrk/SVDTRK_ClusterSNRV3");
311 auto h_clusterSNR_L456U = findHist("SVDClsTrk/SVDTRK_ClusterSNRU456");
312 auto h_clusterSNR_L456V = findHist("SVDClsTrk/SVDTRK_ClusterSNRV456");
313
315 m_c_MPVSNRClusterOnTrack->Divide(2, 2);
317 if (h_clusterSNR_L3U) h_clusterSNR_L3U->Draw();
319 if (h_clusterSNR_L3V) h_clusterSNR_L3V->Draw();
321 if (h_clusterSNR_L456U) h_clusterSNR_L456U->Draw();
323 if (h_clusterSNR_L456V) h_clusterSNR_L456V->Draw();
324
325 float MPVClusterSNRL3U = nan;
326 if (h_clusterSNR_L3U)
327 if (h_clusterSNR_L3U->GetEntries() != 0)
328 MPVClusterSNRL3U = xForMaxY(h_clusterSNR_L3U);
329 float MPVClusterSNRL3V = nan;
330 if (h_clusterSNR_L3V)
331 if (h_clusterSNR_L3V->GetEntries() != 0)
332 MPVClusterSNRL3V = xForMaxY(h_clusterSNR_L3V);
333 float MPVClusterSNRL456U = nan;
334 if (h_clusterSNR_L456U)
335 if (h_clusterSNR_L456U->GetEntries() != 0)
336 MPVClusterSNRL456U = xForMaxY(h_clusterSNR_L456U);
337 float MPVClusterSNRL456V = nan;
338 if (h_clusterSNR_L456V)
339 if (h_clusterSNR_L456V->GetEntries() != 0)
340 MPVClusterSNRL456V = xForMaxY(h_clusterSNR_L456V);
341
342 if (h_clusterSNR_L3U == NULL || h_clusterSNR_L456U == NULL) {
343 B2INFO("Histograms needed for MPV cluster SNR on U side are not found");
344 } else {
345 m_monObj->setVariable("MPVClusterSNRL3U", MPVClusterSNRL3U);
346 m_monObj->setVariable("MPVClusterSNRL456U", MPVClusterSNRL456U);
347 }
348
349 if (h_clusterSNR_L3V == NULL || h_clusterSNR_L456V == NULL) {
350 B2INFO("Histograms needed for MPV cluster SNR on V side are not found");
351 } else {
352 m_monObj->setVariable("MPVClusterSNRL3V", MPVClusterSNRL3V);
353 m_monObj->setVariable("MPVClusterSNRL456V", MPVClusterSNRL456V);
354 }
355
356
357 // MPV SVD cluster time for the clusters on track
358 auto h_clusterTime_L3U = findHist("SVDClsTrk/SVDTRK_ClusterTimeU3");
359 auto h_clusterTime_L3V = findHist("SVDClsTrk/SVDTRK_ClusterTimeV3");
360 auto h_clusterTime_L456U = findHist("SVDClsTrk/SVDTRK_ClusterTimeU456");
361 auto h_clusterTime_L456V = findHist("SVDClsTrk/SVDTRK_ClusterTimeV456");
362 auto h_MeanSVD3EventT0 = findHist("SVDHitTime/SVD3EventT0");
363 auto h_MeanSVD6EventT0 = findHist("SVDHitTime/SVD6EventT0");
364 TH1F* h_MeanSVDEventT0 = 0x0;
365
366 if (h_MeanSVD3EventT0)
367 h_MeanSVDEventT0 = dynamic_cast<TH1F*>(h_MeanSVD3EventT0->Clone());
368
370 m_c_MPVTimeClusterOnTrack->Divide(2, 2);
372 if (h_clusterTime_L3U) h_clusterTime_L3U->Draw();
374 if (h_clusterTime_L3V) h_clusterTime_L3V->Draw();
376 if (h_clusterTime_L456U) h_clusterTime_L456U->Draw();
378 if (h_clusterTime_L456V) h_clusterTime_L456V->Draw();
379
380 m_c_MeanSVDEventT0->Clear();
381 m_c_MeanSVDEventT0->Divide(2, 2);
382 m_c_MeanSVDEventT0->cd(1);
383 if (h_MeanSVD3EventT0) h_MeanSVD3EventT0->Draw();
384 m_c_MeanSVDEventT0->cd(2);
385 if (h_MeanSVD6EventT0) h_MeanSVD6EventT0->Draw();
386 m_c_MeanSVDEventT0->cd(3);
387 if (h_MeanSVDEventT0) {
388 if (h_MeanSVD6EventT0)
389 h_MeanSVDEventT0->Add(h_MeanSVD6EventT0);
390 h_MeanSVDEventT0->Draw();
391 }
392
393 float MPVClusterTimeL3U = nan;
394 if (h_clusterTime_L3U)
395 if (h_clusterTime_L3U->GetEntries() != 0)
396 MPVClusterTimeL3U = xForMaxY(h_clusterTime_L3U);
397 float MPVClusterTimeL3V = nan;
398 if (h_clusterTime_L3V)
399 if (h_clusterTime_L3V->GetEntries() != 0)
400 MPVClusterTimeL3V = xForMaxY(h_clusterTime_L3V);
401 float MPVClusterTimeL456U = nan;
402 if (h_clusterTime_L456U)
403 if (h_clusterTime_L456U->GetEntries() != 0)
404 MPVClusterTimeL456U = xForMaxY(h_clusterTime_L456U);
405 float MPVClusterTimeL456V = nan;
406 if (h_clusterTime_L456V)
407 if (h_clusterTime_L456V->GetEntries() != 0)
408 MPVClusterTimeL456V = xForMaxY(h_clusterTime_L456V);
409 float FWHMClusterTimeL3U = nan;
410 if (h_clusterTime_L3U)
411 if (h_clusterTime_L3U->GetEntries() != 0)
412 FWHMClusterTimeL3U = histFWHM(h_clusterTime_L3U);
413 float FWHMClusterTimeL3V = nan;
414 if (h_clusterTime_L3V)
415 if (h_clusterTime_L3V->GetEntries() != 0)
416 FWHMClusterTimeL3V = histFWHM(h_clusterTime_L3V);
417 float FWHMClusterTimeL456U = nan;
418 if (h_clusterTime_L456U)
419 if (h_clusterTime_L456U->GetEntries() != 0)
420 FWHMClusterTimeL456U = histFWHM(h_clusterTime_L456U);
421 float FWHMClusterTimeL456V = nan;
422 if (h_clusterTime_L456V)
423 if (h_clusterTime_L456V->GetEntries() != 0)
424 FWHMClusterTimeL456V = histFWHM(h_clusterTime_L456V);
425
426 float MeanSVD3EventT0 = nan;
427 if (h_MeanSVD3EventT0)
428 if (h_MeanSVD3EventT0->GetEntries() != 0)
429 MeanSVD3EventT0 = xForMaxY(h_MeanSVD3EventT0);
430
431 float MeanSVD6EventT0 = nan;
432 if (h_MeanSVD6EventT0)
433 if (h_MeanSVD6EventT0->GetEntries() != 0)
434 MeanSVD6EventT0 = xForMaxY(h_MeanSVD6EventT0);
435
436 float MeanSVDEventT0 = nan;
437 if (h_MeanSVDEventT0)
438 if (h_MeanSVDEventT0->GetEntries() != 0)
439 MeanSVDEventT0 = xForMaxY(h_MeanSVDEventT0);
440
441 if (h_clusterTime_L3U == NULL || h_clusterTime_L456U == NULL) {
442 B2INFO("Histograms needed for MPV cluster time on U side are not found");
443 } else {
444 m_monObj->setVariable("MPVClusterTimeL3U", MPVClusterTimeL3U);
445 m_monObj->setVariable("MPVClusterTimeL456U", MPVClusterTimeL456U);
446 m_monObj->setVariable("FWHMClusterTimeL3U", FWHMClusterTimeL3U);
447 m_monObj->setVariable("FWHMClusterTimeL456U", FWHMClusterTimeL456U);
448 }
449
450 if (h_clusterTime_L3V == NULL || h_clusterTime_L456V == NULL) {
451 B2INFO("Histograms needed for MPV cluster time on V side are not found");
452 } else {
453 m_monObj->setVariable("MPVClusterTimeL3V", MPVClusterTimeL3V);
454 m_monObj->setVariable("MPVClusterTimeL456V", MPVClusterTimeL456V);
455 m_monObj->setVariable("FWHMClusterTimeL3V", FWHMClusterTimeL3V);
456 m_monObj->setVariable("FWHMClusterTimeL456V", FWHMClusterTimeL456V);
457 }
458
459 if (h_MeanSVD3EventT0 == NULL) {
460 B2INFO("Histograms needed for SVD Event T0 (3 samples) not found");
461 } else {
462 m_monObj->setVariable("MeanSVD3EventT0", MeanSVD3EventT0);
463 }
464
465 if (h_MeanSVD6EventT0 == NULL) {
466 B2INFO("Histograms needed for SVD Event T0 (6 samples) not found");
467 } else {
468 m_monObj->setVariable("MeanSVD6EventT0", MeanSVD6EventT0);
469 }
470
471 if (h_MeanSVDEventT0 == NULL) {
472 B2INFO("Histograms needed for SVD Event T0 (all samples) not found");
473 } else {
474 m_monObj->setVariable("MeanSVDEventT0", MeanSVDEventT0);
475 }
476
477 // average maxBin for clusters on track
478 auto h_maxBinU = findHist("SVDClsTrk/SVDTRK_StripMaxBinUAll");
479 auto h_maxBinV = findHist("SVDClsTrk/SVDTRK_StripMaxBinVAll");
480
482 m_c_avgMaxBinClusterOnTrack->Divide(2, 1);
484 if (h_maxBinU) h_maxBinU->Draw();
486 if (h_maxBinV) h_maxBinV->Draw();
487
488 if (h_maxBinU == NULL) {
489 B2INFO("Histogram needed for Average MaxBin on U side is not found");
490 } else {
491 float avgMaxBinU = h_maxBinU->GetMean();
492 m_monObj->setVariable("avgMaxBinU", avgMaxBinU);
493 }
494
495 if (h_maxBinV == NULL) {
496 B2INFO("Histogram needed for Average MaxBin on V side is not found");
497 } else {
498 float avgMaxBinV = h_maxBinV->GetMean();
499 m_monObj->setVariable("avgMaxBinV", avgMaxBinV);
500 }
501
502 // Cluster on track ladder
503 for (const auto& it : ladderLabel) {
504 int layer = 0;
505 int sensor = 0;
506 sscanf(it.c_str(), "L%d.X.%d", &layer, &sensor);
507
508 TString name = Form("SVDClsTrk/SVDTRK_ClusterCharge_L%d.x.%d", layer, sensor);
509 TString title = Form("MPVClusterCharge_L%d.x.%d", layer, sensor);
510 auto h_clusterCharge = findHist(name.Data());
511 float MPVClusterCharge = nan;
512 if (h_clusterCharge)
513 if (h_clusterCharge->GetEntries() != 0)
514 MPVClusterCharge = xForMaxY(h_clusterCharge);
515
516 if (h_clusterCharge == NULL) {
517 B2INFO("Histograms needed for cluster charge not found");
518 } else {
519 m_monObj->setVariable(title.Data(), MPVClusterCharge);
520 }
521
522 name = Form("SVDClsTrk/SVDTRK_ClusterSNR_L%d.x.%d", layer, sensor);
523 title = Form("MPVClusterSNR_L%d.x.%d", layer, sensor);
524 auto h_clusterSNR = findHist(name.Data());
525 float MPVClusterSNR = nan;
526 if (h_clusterSNR)
527 if (h_clusterSNR->GetEntries() != 0)
528 MPVClusterSNR = xForMaxY(h_clusterSNR);
529
530 if (h_clusterSNR == NULL) {
531 B2INFO("Histograms needed for cluster SNR not found");
532 } else {
533 m_monObj->setVariable(title.Data(), MPVClusterSNR);
534 }
535 }
536
537 // Cluster on track peculiar sensors
538 for (const auto& it : m_listOfSensorsToMonitor) {
539 string sensorDescr = it;
540 string valueLabel = it;
541 replace(sensorDescr.begin(), sensorDescr.end(), '.', '_');
542 valueLabel.erase(remove(valueLabel.begin(), valueLabel.end(), '.'), valueLabel.end());
543
544 TString name = Form("SVDClsTrk/SVDTRK_%s_ClusterChargeU", sensorDescr.c_str());
545 TString title = Form("MPVClusterChargeL%sU", valueLabel.c_str());
546 TString title1 = "";
547 auto h_clusterChargeU = findHist(name.Data());
548 float MPVClusterCharge = nan;
549 if (h_clusterChargeU)
550 if (h_clusterChargeU->GetEntries() != 0)
551 MPVClusterCharge = xForMaxY(h_clusterChargeU);
552
553 if (h_clusterChargeU == NULL) {
554 B2INFO("Histograms needed for clusterU charge not found");
555 } else {
556 m_monObj->setVariable(title.Data(), MPVClusterCharge);
557 }
558
559 name = Form("SVDClsTrk/SVDTRK_%s_ClusterChargeV", sensorDescr.c_str());
560 title = Form("MPVClusterChargeL%sV", valueLabel.c_str());
561 auto h_clusterChargeV = findHist(name.Data());
562 MPVClusterCharge = nan;
563 if (h_clusterChargeV)
564 if (h_clusterChargeV->GetEntries() != 0)
565 MPVClusterCharge = xForMaxY(h_clusterChargeV);
566
567 if (h_clusterChargeV == NULL) {
568 B2INFO("Histograms needed for clusterV charge not found");
569 } else {
570 m_monObj->setVariable(title.Data(), MPVClusterCharge);
571 }
572
573 name = Form("SVDClsTrk/SVDTRK_%s_ClusterSNRU", sensorDescr.c_str());
574 title = Form("MPVClusterSNRL%sU", valueLabel.c_str());
575 auto h_clusterSNRU = findHist(name.Data());
576 float MPVClusterSNR = nan;
577 if (h_clusterSNRU)
578 if (h_clusterSNRU->GetEntries() != 0)
579 MPVClusterSNR = xForMaxY(h_clusterSNRU);
580
581 if (h_clusterSNRU == NULL) {
582 B2INFO("Histograms needed for clusterU SNR not found");
583 } else {
584 m_monObj->setVariable(title.Data(), MPVClusterSNR);
585 }
586
587 name = Form("SVDClsTrk/SVDTRK_%s_ClusterSNRV", sensorDescr.c_str());
588 title = Form("MPVClusterSNRL%sV", valueLabel.c_str());
589 auto h_clusterSNRV = findHist(name.Data());
590 MPVClusterSNR = nan;
591 if (h_clusterSNRV)
592 if (h_clusterSNRV->GetEntries() != 0)
593 MPVClusterSNR = xForMaxY(h_clusterSNRV);
594
595 if (h_clusterSNRV == NULL) {
596 B2INFO("Histograms needed for clusterV SNR not found");
597 } else {
598 m_monObj->setVariable(title.Data(), MPVClusterSNR);
599 }
600
601 name = Form("SVDClsTrk/SVDTRK_%s_ClusterTimeU", sensorDescr.c_str());
602 title = Form("MPVClusterTimeL%sU", valueLabel.c_str());
603 title1 = Form("FWHMClusterTimeL%sU", valueLabel.c_str());
604 auto h_clusterTimeU = findHist(name.Data());
605 float MPVClusterTime = nan;
606 float FWHMClusterTime = nan;
607 if (h_clusterTimeU)
608 if (h_clusterTimeU->GetEntries() != 0) {
609 MPVClusterTime = xForMaxY(h_clusterTimeU);
610 FWHMClusterTime = histFWHM(h_clusterTimeU);
611 }
612
613 if (h_clusterTimeU == NULL) {
614 B2INFO("Histograms needed for clusterU time not found");
615 } else {
616 m_monObj->setVariable(title.Data(), MPVClusterTime);
617 m_monObj->setVariable(title1.Data(), FWHMClusterTime);
618 }
619
620 name = Form("SVDClsTrk/SVDTRK_%s_ClusterTimeV", sensorDescr.c_str());
621 title = Form("MPVClusterTimeL%sV", valueLabel.c_str());
622 title1 = Form("FWHMClusterTimeL%sV", valueLabel.c_str());
623 auto h_clusterTimeV = findHist(name.Data());
624 MPVClusterTime = nan;
625 FWHMClusterTime = nan;
626 if (h_clusterTimeV)
627 if (h_clusterTimeV->GetEntries() != 0) {
628 MPVClusterTime = xForMaxY(h_clusterTimeV);
629 FWHMClusterTime = histFWHM(h_clusterTimeV);
630 }
631
632 if (h_clusterTimeV == NULL) {
633 B2INFO("Histograms needed for clusterV time not found");
634 } else {
635 m_monObj->setVariable(title.Data(), MPVClusterTime);
636 m_monObj->setVariable(title1.Data(), FWHMClusterTime);
637 }
638 }
639
640 B2INFO("DQMHistAnalysisSVDGeneral: endRun called");
641}
642
643
645{
646 B2INFO("DQMHistAnalysisSVDOnMiraBelle: terminate called");
647}
648
649std::pair<float, float> DQMHistAnalysisSVDOnMiraBelleModule::avgOccupancyUV(auto hU, auto hV, int nEvents,
650 int layer, int ladder, int sensor) const
651{
652 int nStripsV = -1;
653 if (layer == 3) {
654 nStripsV = 768;
655 } else if (layer >= 4 && layer <= 6) {
656 nStripsV = 512;
657 } else {
658 B2DEBUG(20, "Layer out of range [3,6].");
659 }
660 std::pair<float, float> avgOffOccUV(0.0, 0.0);
661
662 int minLayer = (layer != -1) ? layer : m_gTools->getFirstSVDLayer();
663 int maxLayer = (layer != -1) ? layer : m_gTools->getLastSVDLayer();
664 int sensorsN = 0;
665
666 if (ladder == 0) ladder = -1;
667
668 for (int layerId = minLayer; layerId < maxLayer + 1; ++layerId) {
669 int minLadder = (ladder != -1) ? ladder : 1;
670 int maxLadder = (ladder != -1) ? ladder : getNumberOfLadders(layerId);
671
672 int minSensor = (sensor != -1) ? sensor : 1;
673 int maxSensor = (sensor != -1) ? sensor : getNumberOfSensors(layerId);
674
675 for (int sensorId = minSensor; sensorId < maxSensor + 1; ++sensorId) {
676
677 for (int ladderId = minLadder; ladderId < maxLadder + 1; ++ladderId) {
678 int bin = m_gTools->getSVDSensorIndex(layerId, ladderId, sensorId) + 1;
679
680 avgOffOccUV.first += hU->GetBinContent(bin) / 768 * 100;
681 avgOffOccUV.second += hV->GetBinContent(bin) / nStripsV * 100;
682 sensorsN++;
683 }
684 }
685 }
686
687 avgOffOccUV.first /= (sensorsN * nEvents);
688 avgOffOccUV.second /= (sensorsN * nEvents);
689
690 return avgOffOccUV;
691}
692
693std::pair<float, float> DQMHistAnalysisSVDOnMiraBelleModule::avgOccupancyGrpId0UV(int iLayer, int nEvents) const
694{
695 int nStripsV = -1;
696 if (iLayer == 3) {
697 nStripsV = 768;
698 } else if (iLayer >= 4 && iLayer <= 6) {
699 nStripsV = 512;
700 } else {
701 B2DEBUG(20, "Layer out of range [3,6].");
702 }
703
704 Int_t nStripsU = 768;
705
706 std::vector<float> avgOffOccU;
707 std::vector<float> avgOffOccV;
708
709 for (unsigned int i = 0; i < m_SVDModules.size(); i++) {
710 int tmp_layer = m_SVDModules[i].getLayerNumber();
711 int tmp_ladder = m_SVDModules[i].getLadderNumber();
712 int tmp_sensor = m_SVDModules[i].getSensorNumber();
713
714 TString tmpnameGrpId0U = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsU", tmp_layer, tmp_ladder, tmp_sensor);
715 auto htmpU = findHist(tmpnameGrpId0U.Data());
716 if (htmpU == NULL) {
717 B2INFO("Occupancy U histogram for group Id0 not found");
718 } else {
719 if (tmp_layer == iLayer)
720 avgOffOccU.push_back(htmpU->GetEntries() / nStripsU / nEvents * 100);
721 }
722
723 TString tmpnameGrpId0V = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsV", tmp_layer, tmp_ladder, tmp_sensor);
724 auto htmpV = findHist(tmpnameGrpId0V.Data());
725 if (htmpV == NULL) {
726 B2INFO("Occupancy V histogram for group Id0 not found");
727 } else {
728 if (tmp_layer == iLayer)
729 avgOffOccV.push_back(htmpV->GetEntries() / nStripsV / nEvents * 100);
730 }
731 }
732
733 std::pair<float, float> avgOffOccUV(0., 0.);
734
735 avgOffOccUV.first = accumulate(avgOffOccU.begin(), avgOffOccU.end(), 0.0);
736 avgOffOccUV.first /= float(avgOffOccU.size());
737
738 avgOffOccUV.second = accumulate(avgOffOccV.begin(), avgOffOccV.end(), 0.0);
739 avgOffOccUV.second /= float(avgOffOccV.size());
740
741 return avgOffOccUV;
742}
743
744std::pair<float, float> DQMHistAnalysisSVDOnMiraBelleModule::avgEfficiencyUV(auto hMCU, auto hMCV, auto hFTU, auto hFTV,
745 int layer,
746 int ladder, int sensor) const
747{
748 float nan = numeric_limits<float>::quiet_NaN();
749 std::pair<float, float> avgEffUV(0.0, 0.0);
750 std::pair<float, float> sumMatchedClustersUV(0.0, 0.0);
751 std::pair<float, float> sumFoundTracksUV(0.0, 0.0);
752
753 int minLayer = (layer != -1) ? layer : m_gTools->getFirstSVDLayer();
754 int maxLayer = (layer != -1) ? layer : m_gTools->getLastSVDLayer();
755
756 if (ladder == 0) ladder = -1;
757
758 for (int layerId = minLayer; layerId < maxLayer + 1; ++layerId) {
759 int minLadder = (ladder != -1) ? ladder : 1;
760 int maxLadder = (ladder != -1) ? ladder : getNumberOfLadders(layerId);
761
762 int minSensor = (sensor != -1) ? sensor : 1;
763 int maxSensor = (sensor != -1) ? sensor : getNumberOfSensors(layerId);
764
765 for (int sensorId = minSensor; sensorId < maxSensor + 1; ++sensorId) {
766
767 for (int ladderId = minLadder; ladderId < maxLadder + 1; ++ladderId) {
768 int binY = findBinY(layerId, sensorId);
769 int binXY = hMCV->FindBin(ladderId, binY);
770
771 sumMatchedClustersUV.first += hMCU->GetBinContent(binXY);
772 sumMatchedClustersUV.second += hMCV->GetBinContent(binXY);
773 sumFoundTracksUV.first += hFTU->GetBinContent(binXY);
774 sumFoundTracksUV.second += hFTV->GetBinContent(binXY);
775 }
776 }
777 }
778
779 if (sumFoundTracksUV.first > 0) {
780 avgEffUV.first = sumMatchedClustersUV.first / sumFoundTracksUV.first * 100;
781 } else {
782 avgEffUV.first = nan;
783 }
784
785 if (sumFoundTracksUV.second > 0) {
786 avgEffUV.second = sumMatchedClustersUV.second / sumFoundTracksUV.second * 100;
787 } else {
788 avgEffUV.second = nan;
789 }
790
791 return avgEffUV;
792}
793
794
795void DQMHistAnalysisSVDOnMiraBelleModule::addVariable(string name, pair<float, float>& varUV)
796{
797 size_t pos = name.find("UV");
798
799 if (pos != string::npos)
800 name.replace(pos, 2, "");
801
802 m_monObj->setVariable(Form("%sU", name.c_str()), varUV.first);
803 m_monObj->setVariable(Form("%sV", name.c_str()), varUV.second);
804}
805
807{
808 int maxY = h->GetMaximumBin();
809 float xMaxY = h->GetXaxis()->GetBinCenter(maxY);
810 return xMaxY;
811}
812
814{
815 int bin1 = h->FindFirstBinAbove(h->GetMaximum() / 2);
816 int bin2 = h->FindLastBinAbove(h->GetMaximum() / 2);
817 float fwhm = h->GetBinCenter(bin2) - h->GetBinCenter(bin1);
818 return fwhm;
819}
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
DQMHistAnalysisModule()
Constructor / Destructor.
static TH1 * findHist(const std::string &dirname, const std::string &histname="", bool onlyIfUpdated=false)
Find histogram.
void initialize() override final
Module function initialize.
TCanvas * m_c_MPVTimeClusterOnTrack
time for clusters on track
static Int_t findBinY(Int_t layer, Int_t sensor)
find the Y bin given the layer and sensor number
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.
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.
static Int_t getNumberOfLadders(Int_t layer)
get number of ladders per layer
std::pair< float, float > avgOccupancyUV(auto hU, auto hV, int nEvents, int layer=-1, int ladder=-1, int sensor=-1) const
Calculate avg offline occupancy for one specific sensor, especially.
TCanvas * m_c_MPVSNRClusterOnTrack
SNR for clusters on track.
static Int_t getNumberOfSensors(Int_t layer)
get number of sensors per layer
void endRun() override final
Module function endRun.
TCanvas * m_c_avgOffOccupancy
number of ZS5 fired strips
void beginRun() override final
Module function beginRun.
std::pair< float, float > avgEfficiencyUV(auto hMCU, auto hMCV, auto hFTU, auto hFTV, int layer=-1, int ladder=-1, int sensor=-1) const
Calculate avg efficiency for specified sensors.
static float histFWHM(auto h)
Calculate full width at half maximum of histogram.
static float xForMaxY(auto h)
Calculate abscissa of max Y bin.
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)
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.