Belle II Software development
DQMHistAnalysisSVDOccupancy.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// File : DQMHistAnalysisSVDOccupancy.cc
10// Description : module for DQM histogram analysis of SVD sensors occupancies
11//-
12
13
14#include <dqm/analysis/modules/DQMHistAnalysisSVDOccupancy.h>
15#include <vxd/geometry/GeoCache.h>
16
17#include <TROOT.h>
18#include <TStyle.h>
19#include <TString.h>
20#include <TAxis.h>
21
22#include <TMath.h>
23#include <iostream>
24
25using namespace std;
26using namespace Belle2;
27
28//-----------------------------------------------------------------
29// Register the Module
30//-----------------------------------------------------------------
31REG_MODULE(DQMHistAnalysisSVDOccupancy);
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
38 : DQMHistAnalysisSVDModule(false, true, true)
39{
40 //Parameter definition
41 B2DEBUG(10, "DQMHistAnalysisSVDOccupancy: Constructor done.");
42
43 setDescription("DQM Analysis Module that produces colored canvas for a straightforward interpretation of the SVD Data Quality.");
44
45 addParam("occLevel_Error", m_occError, "Maximum Occupancy (%) allowed for safe operations (red)", double(3));
46 addParam("occLevel_Warning", m_occWarning, "Occupancy (%) at WARNING level (orange)", double(2.5));
47 addParam("occGroupIDsLevel_Error", m_groupIDsOccError, "Maximum group IDs Occupancy (%) allowed for safe operations (red)",
48 double(2));
49 addParam("occGroupIDsLevel_Warning", m_groupIDsOccWarning, "Group IDs Occupancy (%) at WARNING level (orange)", double(1.5));
50 addParam("occLevel_Empty", m_occEmpty, "Maximum Occupancy (%) for which the sensor is considered empty", double(0));
51 addParam("onlineOccLevel_Error", m_onlineOccError, "Maximum OnlineOccupancy (%) allowed for safe operations (red)", double(10));
52 addParam("onlineOccLevel_Warning", m_onlineOccWarning, "OnlineOccupancy (%) at WARNING level (orange)", double(5));
53 addParam("onlineOccLevel_Empty", m_onlineOccEmpty, "Maximum OnlineOccupancy (%) for which the sensor is considered empty",
54 double(0));
55 addParam("printCanvas", m_printCanvas, "if True prints pdf of the analysis canvas", bool(false));
56 addParam("additionalPlots", m_additionalPlots, "Flag to produce additional plots", bool(false));
57 addParam("RPhiView", m_RPhiView, "Flag to produce RPhi view plots", bool(true));
58 addParam("RPhiViewId0", m_RPhiViewId0, "Flag to produce RPhi view plots for Id0 group", bool(false));
59 addParam("samples3", m_3Samples, "if True 3 samples histograms analysis is performed", bool(false));
60 addParam("PVPrefix", m_pvPrefix, "PV Prefix", std::string("SVD:"));
61}
62
64{
65 B2DEBUG(10, "DQMHistAnalysisSVDOccupancy: initialized.");
66
68
69 //collect the list of all SVD Modules in the geometry here
70 std::vector<VxdID> sensors = geo.getListOfSensors();
71 for (const auto& aVxdID : sensors) {
72 VXD::SensorInfoBase info = geo.getSensorInfo(aVxdID);
73 // B2INFO("VXD " << aVxdID);
74 if (info.getType() != VXD::SensorInfoBase::SVD) continue;
75 m_SVDModules.push_back(aVxdID); // reorder, sort would be better
76 }
77 std::sort(m_SVDModules.begin(), m_SVDModules.end()); // back to natural order
78
79 //occupancy chart chip
80 m_cOccupancyChartChip = new TCanvas("SVDOccupancy/c_OccupancyChartChip");
81
82 //strip occupancy per sensor
84 m_sensors = m_SVDModules.size();
85 else
86 m_sensors = 2;
87
88 m_cStripOccupancyU = new TCanvas*[m_sensors];
89 m_cStripOccupancyV = new TCanvas*[m_sensors];
90 for (int i = 0; i < m_sensors; i++) {
91 int tmp_layer = m_SVDModules[i].getLayerNumber();
92 int tmp_ladder = m_SVDModules[i].getLadderNumber();
93 int tmp_sensor = m_SVDModules[i].getSensorNumber();
94 m_cStripOccupancyU[i] = new TCanvas(Form("SVDOccupancy/c_StripOccupancyU_%d_%d_%d", tmp_layer, tmp_ladder, tmp_sensor));
95 m_cStripOccupancyV[i] = new TCanvas(Form("SVDOccupancy/c_StripOccupancyV_%d_%d_%d", tmp_layer, tmp_ladder, tmp_sensor));
96 }
97
98 gROOT->cd();
99 m_cOccupancyU = new TCanvas("SVDAnalysis/c_SVDOccupancyU");
100 m_cOccupancyV = new TCanvas("SVDAnalysis/c_SVDOccupancyV");
101
102 m_cOnlineOccupancyU = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancyU");
103 m_cOnlineOccupancyV = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancyV");
104
105 m_cOccupancyUGroupId0 = new TCanvas("SVDAnalysis/c_SVDOccupancyUGroupId0");
106 m_cOccupancyVGroupId0 = new TCanvas("SVDAnalysis/c_SVDOccupancyVGroupId0");
107
108 if (m_RPhiView) {
109 m_cOccupancyRPhiViewU = new TCanvas("SVDAnalysis/c_SVDOccupancyRPhiViewU", "", 800, 800);
110 m_cOccupancyRPhiViewV = new TCanvas("SVDAnalysis/c_SVDOccupancyRPhiViewV", "", 800, 800);
111
112 m_cOnlineOccupancyRPhiViewU = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancyRPhiViewU", "", 800, 800);
113 m_cOnlineOccupancyRPhiViewV = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancyRPhiViewV", "", 800, 800);
114
115 if (m_RPhiViewId0) {
116 m_cOccupancyRPhiViewUGroupId0 = new TCanvas("SVDAnalysis/c_SVDOccupancyRPhiViewGroupId0U", "", 800, 800);
117 m_cOccupancyRPhiViewVGroupId0 = new TCanvas("SVDAnalysis/c_SVDOccupancyRPhiViewGroupId0V", "", 800, 800);
118 }
119 }
120
121 TString hName = getHistoNameFromCanvas(m_cOccupancyU->GetName(), "@view");
122 m_hOccupancy = new SVDSummaryPlots(hName.Data(), "Average OFFLINE Sensor Occupancy (%), @view/@side Side");
123 m_hOccupancy->setStats(0);
124
125 hName = getHistoNameFromCanvas(m_cOnlineOccupancyU->GetName(), "@view");
126 m_hOnlineOccupancy = new SVDSummaryPlots(hName.Data(), "Average ONLINE Sensor Occupancy (%), @view/@side Side");
127 m_hOnlineOccupancy->setStats(0);
128
129 // change name by hand cos side index not at the end
130 hName = getHistoNameFromCanvas("SVDAnalysis/c_SVDOccupancyGroupId0U", "@view");
131 m_hOccupancyGroupId0 = new SVDSummaryPlots(hName.Data(),
132 "Average OFFLINE Sensor Occupancy (%), @view/@side Side for cluster time group Id = 0, 1, 2 & 3");
133 m_hOccupancyGroupId0->setStats(0);
134
135 if (m_3Samples) {
136 m_cOccupancyU3Samples = new TCanvas("SVDAnalysis/c_SVDOccupancy3SamplesU");
137 m_cOccupancyV3Samples = new TCanvas("SVDAnalysis/c_SVDOccupancy3SamplesV");
138
139 m_cOnlineOccupancyU3Samples = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancy3SamplesU");
140 m_cOnlineOccupancyV3Samples = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancy3SamplesV");
141
142 if (m_RPhiView) {
143 m_cOccupancyRPhiViewU3Samples = new TCanvas("SVDAnalysis/c_SVDOccupancyRPhiView3SamplesU", "", 800, 800);
144 m_cOccupancyRPhiViewV3Samples = new TCanvas("SVDAnalysis/c_SVDOccupancyRPhiView3SamplesV", "", 800, 800);
145
146 m_cOnlineOccupancyRPhiViewU3Samples = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancyRPhiView3SamplesU", "", 800, 800);
147 m_cOnlineOccupancyRPhiViewV3Samples = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancyRPhiView3SamplesV", "", 800, 800);
148 }
149
150 hName = getHistoNameFromCanvas(m_cOccupancyU3Samples->GetName(), "@view");
151 m_hOccupancy3Samples = new SVDSummaryPlots(hName.Data(), "Average OFFLINE Sensor Occupancy (%), @view/@side Side for 3 samples");
152 m_hOnlineOccupancy->setStats(0);
153
154 hName = getHistoNameFromCanvas(m_cOnlineOccupancyU3Samples->GetName(), "@view");
156 "Average ONLINE Sensor Occupancy (%), @view/@side Side for 3 samples");
157 m_hOnlineOccupancy3Samples->setStats(0);
158 }
159
160
161 //register limits for EPICS
162 registerEpicsPV(m_pvPrefix + "occupancyLimits", "occLimits");
163 registerEpicsPV(m_pvPrefix + "occupancyOnlineLimits", "occOnlineLimits");
164 registerEpicsPV(m_pvPrefix + "occupancyGroupIDsLimits", "occGroupIDsLimits");
165}
166
168{
169 B2DEBUG(10, "DQMHistAnalysisSVDOccupancy: beginRun called.");
170
171 m_cOccupancyChartChip->Clear();
172 for (int i = 0; i < m_sensors; i++) {
173 m_cStripOccupancyU[i]->Clear();
174 m_cStripOccupancyV[i]->Clear();
175 }
176
177 // histo
178 if (m_cOccupancyU)
179 m_cOccupancyU->Clear();
180 if (m_cOccupancyV)
181 m_cOccupancyV->Clear();
182
184 m_cOnlineOccupancyU->Clear();
186 m_cOnlineOccupancyV->Clear();
187
189 m_cOccupancyUGroupId0->Clear();
191 m_cOccupancyVGroupId0->Clear();
192
193 // RPhiView
194 if (m_RPhiView) {
196 m_cOccupancyRPhiViewU->Clear();
198 m_cOccupancyRPhiViewV->Clear();
199
204 if (m_RPhiViewId0) {
209 }
210 }
211 // 3 samples
212 if (m_3Samples) {
213 m_cOccupancyU3Samples->Clear();
214 m_cOccupancyV3Samples->Clear();
217
218 if (m_RPhiView) {
223 }
224 }
225
226 //Retrieve limits from EPICS
227 double oocErrorLoOff = 0.;
228 double oocErrorLoOn = 0.;
229 double oocErrorLoIDs = 0.;
230
231 double occWarningOff = 0.;
232 double occWarningOn = 0.;
233 double occWarningIDs = 0.;
234
235 requestLimitsFromEpicsPVs("occLimits", oocErrorLoOff, occWarningOff, m_occWarning, m_occError);
236 requestLimitsFromEpicsPVs("occOnlineLimits", oocErrorLoOn, occWarningOn, m_onlineOccWarning, m_onlineOccError);
237 requestLimitsFromEpicsPVs("occGroupIDsLimits", oocErrorLoIDs, occWarningIDs, m_groupIDsOccWarning, m_groupIDsOccError);
238
239 B2DEBUG(10, " SVD occupancy thresholds taken from EPICS configuration file:");
240 B2DEBUG(10, " ONLINE OCCUPANCY: empty < " << m_onlineOccEmpty << " normal < " << m_onlineOccWarning << " warning < " <<
242 " < error");
243 B2DEBUG(10, " OFFLINE OCCUPANCY: empty < " << m_occEmpty << " normal < " << m_occWarning << " warning < " << m_occError <<
244 " < error with minimum statistics of " << m_occEmpty);
245
246 B2DEBUG(10, " Group IDs OCCUPANCY: empty < " << m_occEmpty << " normal < " << m_groupIDsOccWarning << " warning < " <<
248 " < error with minimum statistics of " << m_occEmpty);
249
250 // Create text panel
251 //OFFLINE occupancy plots legend
252 m_legProblem->Clear();
253 m_legProblem->AddText("ERROR!");
254 m_legProblem->AddText("at least one sensor with:");
255 m_legProblem->AddText(Form("occupancy > %1.1f%%", m_occError));
256
257 m_legWarning->Clear();
258 m_legWarning->AddText("WARNING!");
259 m_legWarning->AddText("at least one sensor with:");
260 m_legWarning->AddText(Form("%1.1f%% < occupancy < %1.1f%%", m_occWarning, m_occError));
261
262 m_legNormal->Clear();
263 m_legNormal->AddText("OCCUPANCY WITHIN LIMITS");
264 m_legNormal->AddText(Form("%1.1f%% < occupancy < %1.1f%%", m_occEmpty, m_occWarning));
265
266 m_legLowStat->Clear();
267 m_legLowStat->AddText("LOW STATISTICS");
268 m_legLowStat->AddText("from at least one sensor");
269
270 m_legEmpty->Clear();
271 m_legEmpty->AddText("at least one sensor is emtpy");
272
273 //ONLINE occupancy plots legend
274 m_legOnlineProblem->Clear();
275 m_legOnlineProblem->AddText("ERROR!");
276 m_legOnlineProblem->AddText("at least one sensor with:");
277 m_legOnlineProblem->AddText(Form("online occupancy > %1.1f%%", m_onlineOccError));
278
279 m_legOnlineWarning->Clear();
280 m_legOnlineWarning->AddText("WARNING!");
281 m_legOnlineWarning->AddText("at least one sensor with:");
282 m_legOnlineWarning->AddText(Form("%1.1f%% < online occupancy < %1.1f%%", m_onlineOccWarning, m_onlineOccError));
283
284 m_legOnlineNormal->Clear();
285 m_legOnlineNormal->AddText("OCCUPANCY WITHIN LIMITS");
286 m_legOnlineNormal->AddText(Form("%1.1f%% < online occupancy < %1.1f%%", m_onlineOccEmpty, m_onlineOccWarning));
287
288 //Group IDs occupancy plots legend
289 m_legGroupIDsProblem->Clear();
290 m_legGroupIDsProblem->AddText("ERROR!");
291 m_legGroupIDsProblem->AddText("at least one sensor with:");
292 m_legGroupIDsProblem->AddText(Form("group IDs occupancy > %1.1f%%", m_groupIDsOccError));
293
294 m_legGroupIDsWarning->Clear();
295 m_legGroupIDsWarning->AddText("WARNING!");
296 m_legGroupIDsWarning->AddText("at least one sensor with:");
297 m_legGroupIDsWarning->AddText(Form("%1.1f%% < group IDs occupancy < %1.1f%%", m_groupIDsOccWarning, m_groupIDsOccError));
298
299 m_legGroupIDsNormal->Clear();
300 m_legGroupIDsNormal->AddText("OCCUPANCY WITHIN LIMITS");
301 m_legGroupIDsNormal->AddText(Form("%1.1f%% < group IDs occupancy < %1.1f%%", m_groupIDsOccEmpty, m_groupIDsOccWarning));
302
303
306
309
312
315
318}
319
321{
322 B2DEBUG(10, "DQMHistAnalysisSVDOccupancy: event called.");
323
324 //find nEvents
325 TH1* hnEvnts = findHist("SVDExpReco/SVDDQM_nEvents", true);
326 if (hnEvnts == NULL) {
327 B2INFO("no events, nothing to do here");
328 return;
329 } else {
330 B2DEBUG(10, "SVDExpReco/SVDDQM_nEvents found");
331 }
332
333
334 TString tmp = hnEvnts->GetTitle();
335 Int_t pos = tmp.Last('~');
336 if (pos == -1) pos = 0;
337
338 TString runID = tmp(pos, tmp.Length() - pos);
339 B2INFO("DQMHistAnalysisSVDOccupancyModule::runID = " << runID);
340 Float_t nEvents = hnEvnts->GetEntries();
341
342 //occupancy chart
343 auto hChart = findHist("SVDExpReco/SVDDQM_StripCountsChip");
344
345 if (hChart != NULL) {
346 m_hOccupancyChartChip.Clear();
347 hChart->Copy(m_hOccupancyChartChip);
348 m_hOccupancyChartChip.SetName("SVDOccupancyChart");
349 m_hOccupancyChartChip.SetTitle(Form("SVD OFFLINE Occupancy per chip %s", runID.Data()));
350 m_hOccupancyChartChip.Scale(1 / nEvents / 128);
352 // m_hOccupancyChartChip->SetStats(0);
354 }
355 m_cOccupancyChartChip->Modified();
356 m_cOccupancyChartChip->Update();
357
358 if (m_printCanvas)
359 m_cOccupancyChartChip->Print("c_OccupancyChartChip.pdf");
360
361
362 //check MODULE OCCUPANCY online & offline
363 //reset canvas color
364 //update titles with exp and run number
367
370
373
376
379
380 m_hOccupancy->reset();
381 m_hOccupancy->setStats(0);
382 m_hOccupancy->setRunID(runID);
383
384 m_hOnlineOccupancy->reset();
385 m_hOnlineOccupancy->setStats(0);
386 m_hOnlineOccupancy->setRunID(runID);
387
388 m_hOccupancyGroupId0->reset();
389 m_hOccupancyGroupId0->setStats(0);
390 m_hOccupancyGroupId0->setRunID(runID);
391
392 if (m_3Samples) {
393 m_hOccupancy3Samples->reset();
394 m_hOccupancy3Samples->setStats(0);
395 m_hOccupancy3Samples->setRunID(runID);
396
398 m_hOnlineOccupancy3Samples->setStats(0);
399 m_hOnlineOccupancy3Samples->setRunID(runID);
400 }
401
402 //set dedicate gStyle
403 gStyle->SetOptStat(0);
404 gStyle->SetPaintTextFormat("2.3f");
405
406
407 for (unsigned int i = 0; i < m_SVDModules.size(); i++) {
408 int tmp_layer = m_SVDModules[i].getLayerNumber();
409 int tmp_ladder = m_SVDModules[i].getLadderNumber();
410 int tmp_sensor = m_SVDModules[i].getSensorNumber();
411
412 //look for U histogram - OFFLINE ZS
413 TString tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountU", tmp_layer, tmp_ladder, tmp_sensor);
414
415 auto hStripCountU = findHist(tmpname.Data());
416 if (hStripCountU == NULL) {
417 B2INFO("Occupancy U histogram not found");
419 } else {
420 Float_t occU = getOccupancy(hStripCountU->GetEntries(), tmp_layer, nEvents);
421 m_hOccupancy->fill(m_SVDModules[i], 1, occU);
423
424 //produce the occupancy plot
425 if (m_additionalPlots) {
426 m_hStripOccupancyU[i].Clear();
427 hStripCountU->Copy(m_hStripOccupancyU[i]);
428 m_hStripOccupancyU[i].Scale(1 / nEvents);
429 m_hStripOccupancyU[i].SetName(Form("%d_%d_%d_OccupancyU", tmp_layer, tmp_ladder, tmp_sensor));
430 m_hStripOccupancyU[i].SetTitle(Form("SVD Sensor %d_%d_%d U-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
431 tmp_sensor, runID.Data()));
432 } else {
433 if (i == 0 || i == 1) {
434 m_hStripOccupancyU[i].Clear();
435 hStripCountU->Copy(m_hStripOccupancyU[i]);
436 m_hStripOccupancyU[i].Scale(1 / nEvents);
437 m_hStripOccupancyU[i].SetName(Form("%d_%d_%d_OccupancyU", tmp_layer, tmp_ladder, tmp_sensor));
438 m_hStripOccupancyU[i].SetTitle(Form("SVD Sensor %d_%d_%d U-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
439 tmp_sensor, runID.Data()));
440 }
441 }
442 }
443
444 if (m_3Samples) {
445 //look for U histogram - OFFLINE ZS for 3 samples
446 tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_Strip3CountU", tmp_layer, tmp_ladder, tmp_sensor);
447
448 auto hStrip3CountU = findHist(tmpname.Data());
449 if (hStrip3CountU == NULL) {
450 B2INFO("Occupancy U histogram not found for 3 samples");
452
453 } else {
454 Float_t occU = getOccupancy(hStrip3CountU->GetEntries(), tmp_layer, nEvents);
455 m_hOccupancy3Samples->fill(m_SVDModules[i], 1, occU);
457 }
458 }
459
460 // groupId0 side U
461 TString tmpnameGrpId0 = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsU", tmp_layer, tmp_ladder, tmp_sensor);
462 auto hStripCountGroupIDsU = findHist(tmpnameGrpId0.Data());
463 if (hStripCountGroupIDsU == NULL) {
464 B2INFO("Occupancy U histogram for group Id0 not found");
465 setOccStatus(-1, m_occUGroupId0, kGroupIDs);
466
467 } else {
468 Float_t occU = getOccupancy(hStripCountGroupIDsU->GetEntries(), tmp_layer, nEvents);
469 m_hOccupancyGroupId0->fill(m_SVDModules[i], 1, occU);
470 setOccStatus(occU, m_occUGroupId0, kGroupIDs);
471 }
472
473 //look for V histogram - OFFLINE ZS
474 tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountV", tmp_layer, tmp_ladder, tmp_sensor);
475
476 auto hStripCountV = findHist(tmpname.Data());
477 if (hStripCountV == NULL) {
478 B2INFO("Occupancy V histogram not found");
480
481 } else {
482 Float_t occV = getOccupancy(hStripCountV->GetEntries(), tmp_layer, nEvents, true);
483 m_hOccupancy->fill(m_SVDModules[i], 0, occV);
485
486 //produce the occupancy plot
487 if (m_additionalPlots) {
488 m_hStripOccupancyV[i].Clear();
489 hStripCountV->Copy(m_hStripOccupancyV[i]);
490 m_hStripOccupancyV[i].Scale(1 / nEvents);
491 m_hStripOccupancyV[i].SetName(Form("%d_%d_%d_OccupancyV", tmp_layer, tmp_ladder, tmp_sensor));
492 m_hStripOccupancyV[i].SetTitle(Form("SVD Sensor %d_%d_%d V-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
493 tmp_sensor, runID.Data()));
494 } else {
495 if (i < (unsigned int)m_sensors) {
496 m_hStripOccupancyV[i].Clear();
497 hStripCountV->Copy(m_hStripOccupancyV[i]);
498 m_hStripOccupancyV[i].Scale(1 / nEvents);
499 m_hStripOccupancyV[i].SetName(Form("%d_%d_%d_OccupancyV", tmp_layer, tmp_ladder, tmp_sensor));
500 m_hStripOccupancyV[i].SetTitle(Form("SVD Sensor %d_%d_%d V-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
501 tmp_sensor, runID.Data()));
502 }
503 }
504 }
505
506 if (m_3Samples) {
507 //look for V histogram - OFFLINE ZS for 3 samples
508 tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_Strip3CountV", tmp_layer, tmp_ladder, tmp_sensor);
509
510 auto hStrip3CountV = findHist(tmpname.Data());
511 if (hStrip3CountV == NULL) {
512 B2INFO("Occupancy V histogram not found");
514
515 } else {
516 Float_t occV = getOccupancy(hStrip3CountV->GetEntries(), tmp_layer, nEvents, true);
517 m_hOccupancy3Samples->fill(m_SVDModules[i], 0, occV);
519 }
520 }
521
522 // groupId0 side V
523 tmpnameGrpId0 = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsV", tmp_layer, tmp_ladder, tmp_sensor);
524
525 auto hStripCountGroupIDsV = findHist(tmpnameGrpId0.Data());
526 if (hStripCountGroupIDsV == NULL) {
527 B2INFO("Occupancy U histogram for group Id0 not found");
528 setOccStatus(-1, m_occVGroupId0, kGroupIDs);
529
530 } else {
531 Float_t occV = getOccupancy(hStripCountGroupIDsV->GetEntries(), tmp_layer, nEvents, true);
532 m_hOccupancyGroupId0->fill(m_SVDModules[i], 0, occV);
533 setOccStatus(occV, m_occVGroupId0, kGroupIDs);
534 }
535
536 //look for V histogram - ONLINE ZS
537 tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStripCountV", tmp_layer, tmp_ladder, tmp_sensor);
538
539 auto hOnlineStripCountV = findHist(tmpname.Data());
540 if (hOnlineStripCountV == NULL) {
541 B2INFO("OnlineOccupancy V histogram not found");
542 setOccStatus(-1, m_onlineOccVstatus, kOnline);
543
544 } else {
545 Float_t onlineOccV = getOccupancy(hOnlineStripCountV->GetEntries(), tmp_layer, nEvents, true);
546 m_hOnlineOccupancy->fill(m_SVDModules[i], 0, onlineOccV);
547
548 for (int b = 1; b < hOnlineStripCountV->GetNbinsX() + 1; b++) {
549 hOnlineStripCountV->SetBinContent(b, hOnlineStripCountV->GetBinContent(b) / nEvents * 100);
550 }
551 hOnlineStripCountV->GetYaxis()->SetTitle("ZS3 occupancy (%)");
552 setOccStatus(onlineOccV, m_onlineOccVstatus, kOnline);
553 }
554
555 if (m_3Samples) {
556 //look for V histogram - ONLINE ZS for 3 samples
557 tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStrip3CountV", tmp_layer, tmp_ladder, tmp_sensor);
558
559 auto hOnlineStrip3CountV = findHist(tmpname.Data());
560 if (hOnlineStrip3CountV == NULL) {
561 B2INFO("OnlineOccupancy3 V histogram not found");
563
564 } else {
565 Float_t onlineOccV = getOccupancy(hOnlineStrip3CountV->GetEntries(), tmp_layer, nEvents, true);
566 m_hOnlineOccupancy3Samples->fill(m_SVDModules[i], 0, onlineOccV);
567
568 for (int b = 1; b < hOnlineStrip3CountV->GetNbinsX() + 1; b++) {
569 hOnlineStrip3CountV->SetBinContent(b, hOnlineStrip3CountV->GetBinContent(b) / nEvents * 100);
570 }
571 hOnlineStrip3CountV->GetYaxis()->SetTitle("ZS3 occupancy (%)");
572 setOccStatus(onlineOccV, m_onlineOccV3Samples, kOnline);
573 }
574 }
575
576 //look for U histogram - ONLINE ZS
577 tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStripCountU", tmp_layer, tmp_ladder, tmp_sensor);
578
579 auto hOnlineStripCountU = findHist(tmpname.Data());
580 if (hOnlineStripCountU == NULL) {
581 B2INFO("OnlineOccupancy U histogram not found");
583
584 } else {
585 Float_t onlineOccU = getOccupancy(hOnlineStripCountU->GetEntries(), tmp_layer, nEvents);
586 m_hOnlineOccupancy->fill(m_SVDModules[i], 1, onlineOccU);
587
588 for (int b = 1; b < hOnlineStripCountU->GetNbinsX() + 1; b++) {
589 hOnlineStripCountU->SetBinContent(b, hOnlineStripCountU->GetBinContent(b) / nEvents * 100);
590 }
591 hOnlineStripCountU->GetYaxis()->SetTitle("ZS3 occupancy (%)");
592 setOccStatus(onlineOccU, m_onlineOccUstatus, kOnline);
593 }
594
595 if (m_3Samples) {
596 //look for U histogram - ONLINE ZS for 3 samples
597 tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStrip3CountU", tmp_layer, tmp_ladder, tmp_sensor);
598
599 auto hOnlineStrip3CountU = findHist(tmpname.Data());
600 if (hOnlineStrip3CountU == NULL) {
601 B2INFO("OnlineOccupancy3 U histogram not found");
603
604 } else {
605 Float_t onlineOccU = getOccupancy(hOnlineStrip3CountU->GetEntries(), tmp_layer, nEvents);
606 m_hOnlineOccupancy3Samples->fill(m_SVDModules[i], 1, onlineOccU);
607
608 for (int b = 1; b < hOnlineStrip3CountU->GetNbinsX() + 1; b++) {
609 hOnlineStrip3CountU->SetBinContent(b, hOnlineStrip3CountU->GetBinContent(b) / nEvents * 100);
610 }
611 hOnlineStrip3CountU->GetYaxis()->SetTitle("ZS3 occupancy (%)");
612 setOccStatus(onlineOccU, m_onlineOccU3Samples, kOnline);
613 }
614 }
615
616 //update sensor occupancy canvas U and V
617 if (m_additionalPlots) {
618 m_cStripOccupancyU[i]->cd();
619 m_hStripOccupancyU[i].Draw("histo");
620 m_cStripOccupancyV[i]->cd();
621 m_hStripOccupancyV[i].Draw("histo");
622 } else {
623 if (i == 0 || i == 1) {
624 m_cStripOccupancyU[i]->cd();
625 m_hStripOccupancyU[i].Draw("histo");
626 m_cStripOccupancyV[i]->cd();
627 m_hStripOccupancyV[i].Draw("histo");
628 }
629 }
630 }
631
632 //update summary offline occupancy U canvas
634
635 //update summary offline occupancy V canvas
637
638 //update summary offline occupancy U canvas for groupId0
640
641 //update summary offline occupancy V canvas for groupId0
643
644 //update summary online occupancy U canvas
646
647 //update summary online occupancy V canvas
649
650 if (m_3Samples) {
651 //update summary offline occupancy U canvas for 3 samples
653
654 //update summary offline occupancy V canvas for 3 samples
656
657 //update summary online occupancy U canvas for 3 samples
659 true, kOnline);
660
661 //update summary online occupancy V canvas for 3 samples
663 false, kOnline);
664 }
665
666 if (m_printCanvas) {
667 m_cOccupancyU->Print("c_SVDOccupancyU.pdf");
668 m_cOccupancyV->Print("c_SVDOccupancyV.pdf");
669 m_cOnlineOccupancyU->Print("c_SVDOnlineOccupancyU.pdf");
670 m_cOnlineOccupancyV->Print("c_SVDOnlineOccupancyV.pdf");
671 }
672}
673
675{
676 B2DEBUG(10, "DQMHistAnalysisSVDOccupancy: endRun called");
677}
678
679
681{
682 B2DEBUG(10, "DQMHistAnalysisSVDOccupancy: terminate called");
683
684 delete m_hOccupancy;
685 delete m_hOnlineOccupancy;
689
691
692 delete m_cOccupancyU;
693 delete m_cOccupancyV;
694
695 delete m_cOnlineOccupancyU;
696 delete m_cOnlineOccupancyV;
697
700
703
706
707 if (m_RPhiView) {
710
713
716
719 if (m_RPhiViewId0) {
722 }
723 }
724
725 for (int module = 0; module < m_sensors; module++) {
726 delete m_cStripOccupancyU[module];
727 delete m_cStripOccupancyV[module];
728 }
729 delete m_cStripOccupancyU;
730 delete m_cStripOccupancyV;
731}
732
733Float_t DQMHistAnalysisSVDOccupancyModule::getOccupancy(float entries, int tmp_layer, int nEvents, bool sideV)
734{
735 Int_t nStrips = 768;
736 if (tmp_layer != 3 && sideV)
737 nStrips = 512;
738
739 return (entries / nStrips / nEvents * 100);
740}
741
742void DQMHistAnalysisSVDOccupancyModule::setOccStatus(float occupancy, svdStatus& occupancyStatus, int histoType)
743{
744 if (histoType == kOnline) {
745 if (occupancy < 0)
746 occupancyStatus = std::max(noStat, occupancyStatus);
747 else if (occupancy <= m_onlineOccEmpty) {
748 occupancyStatus = std::max(lowStat, occupancyStatus);
749 } else if (occupancy < m_onlineOccWarning && occupancy >= m_onlineOccEmpty) {
750 occupancyStatus = std::max(good, occupancyStatus);
751 } else if (occupancy > m_onlineOccWarning && occupancy < m_onlineOccError) {
752 occupancyStatus = std::max(warning, occupancyStatus);
753 } else if (occupancy >= m_onlineOccError) {
754 occupancyStatus = std::max(error, occupancyStatus);
755 }
756 } else if (histoType == kOffline) {
757 if (occupancy < 0)
758 occupancyStatus = std::max(noStat, occupancyStatus);
759 else if (occupancy <= m_occEmpty) {
760 occupancyStatus = std::max(lowStat, occupancyStatus);
761 } else if (occupancy < m_occWarning && occupancy >= m_occEmpty) {
762 occupancyStatus = std::max(good, occupancyStatus);
763 } else if (occupancy > m_occWarning && occupancy < m_occError) {
764 occupancyStatus = std::max(warning, occupancyStatus);
765 } else if (occupancy >= m_occError) {
766 occupancyStatus = std::max(error, occupancyStatus);
767 }
768 } else if (histoType == kGroupIDs) {
769 if (occupancy < 0)
770 occupancyStatus = std::max(noStat, occupancyStatus);
771 else if (occupancy <= m_groupIDsOccEmpty) {
772 occupancyStatus = std::max(lowStat, occupancyStatus);
773 } else if (occupancy < m_groupIDsOccWarning && occupancy >= m_groupIDsOccEmpty) {
774 occupancyStatus = std::max(good, occupancyStatus);
775 } else if (occupancy > m_groupIDsOccWarning && occupancy < m_groupIDsOccError) {
776 occupancyStatus = std::max(warning, occupancyStatus);
777 } else if (occupancy >= m_groupIDsOccError) {
778 occupancyStatus = std::max(error, occupancyStatus);
779 }
780 }
781}
int registerEpicsPV(const std::string &pvname, const std::string &keyname="")
EPICS related Functions.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.
TPaveText * m_legOnlineNormal
onlineOccupancy plot legend, normal
static TString getHistoNameFromCanvas(TString cName, TString view="", TString cPrefix="c_", TString hPrefix="")
get histogram name from Canvas name
TPaveText * m_legEmpty
plot legend, empty
TPaveText * m_legGroupIDsProblem
Group IDs Occupancy plot legend, problem.
void updateCanvases(SVDSummaryPlots *histo, TCanvas *canvas, TCanvas *canvasRPhi, svdStatus status, bool isU, int histoType=kOffline)
update canvases
TPaveText * m_legLowStat
plot legend, low stats
TPaveText * m_legWarning
plot legend, warning
TPaveText * m_legGroupIDsWarning
Group IDs Occupancy plot legend, warning.
TPaveText * m_legNormal
plot legend, normal
TPaveText * m_legProblem
plot legend, problem
TPaveText * m_legOnlineProblem
onlineOccupancy plot legend, problem
TPaveText * m_legOnlineWarning
onlineOccupancy plot legend, warning
DQMHistAnalysisSVDModule(bool panelTop=false, bool online=false, bool groupIDs=false)
Constructor.
TPaveText * m_legGroupIDsNormal
Group IDs Occupancy plot legend, normal.
TCanvas * m_cOnlineOccupancyU
online occupancy U histo canvas
svdStatus m_onlineOccV3Samples
0 = good, 4 = empty, 1 = warning, 2 = error for 3 sampes
svdStatus m_occVstatus
0 = good, 4 = empty, 1 = warning, 2 = error
TCanvas * m_cOccupancyRPhiViewVGroupId0
occupancy V histo canvas for cluster time group Id = 0
TCanvas * m_cOccupancyRPhiViewV3Samples
occupancy V plot canvas for 3 samples
TCanvas * m_cOnlineOccupancyRPhiViewU3Samples
occupancy U plot canvas for 3 samples
TCanvas ** m_cStripOccupancyV
u-side strip chart occupancy canvas
svdStatus m_occVGroupId0
0 = good, 4 = empty, 1 = warning, 2 = error for 3 sampels
std::vector< VxdID > m_SVDModules
IDs of all SVD Modules to iterate over.
double m_onlineOccError
error level of the onlineOccupancy
TCanvas * m_cOccupancyRPhiViewUGroupId0
occupancy U histo canvas for cluster time group Id = 0
TCanvas * m_cOccupancyVGroupId0
occupancy V histo canvas for cluster time group Id = 0
SVDSummaryPlots * m_hOccupancy3Samples
occupancy histos for 3 samples
svdStatus m_occU3Samples
0 = good, 4 = empty, 1 = warning, 2 = error for 3 samples
double m_onlineOccEmpty
empty level of the occupancy
svdStatus m_onlineOccUstatus
0 = good, 4 = empty, 1 = warning, 2 = error
SVDSummaryPlots * m_hOnlineOccupancy3Samples
online occupancy histos for 3 sampels
std::string m_pvPrefix
string prefix for EPICS PVs
TCanvas * m_cOnlineOccupancyRPhiViewV
online occupancy V plot canvas
double m_occWarning
warning level of the occupancy
svdStatus m_occUGroupId0
0 = good, 4 = empty, 1 = warning, 2 = error for 3 samples
void terminate() override final
This method is called at the end of the event processing.
TCanvas * m_cOccupancyU3Samples
occupancy U histo canvas for 3 sampes
SVDSummaryPlots * m_hOccupancyGroupId0
occupancy histos for cluster time group id=0
TCanvas * m_cOnlineOccupancyV3Samples
online Occupancy V histo canvas for 3 samples
TCanvas * m_cOccupancyChartChip
occupancy chart histo canvas
double m_groupIDsOccError
error level of the group IDs occupancy
void event() override final
This method is called for each event.
bool m_printCanvas
Parameters accesible from basf2 scripts.
TCanvas * m_cOnlineOccupancyRPhiViewV3Samples
occupancy V plot canvas for 3 samples
TCanvas ** m_cStripOccupancyU
u-side strip chart occupancy canvas
TH1F m_hStripOccupancyV[172]
u-side strip chart occupancy histos
static Float_t getOccupancy(float entries, int tmp_layer, int nEvents, bool sideV=false)
get occupancy value
svdStatus m_occV3Samples
0 = good, 4 = empty, 1 = warning, 2 = error for 3 sampels
double m_groupIDsOccWarning
warning level of the group IDs occupancy
bool m_3Samples
if true enable 3 samples histograms analysis
svdStatus m_onlineOccVstatus
0 = good, 4 = empty, 1 = warning, 2 = error
svdStatus m_onlineOccU3Samples
0 = good, 4 = empty, 1 = warning, 2 = error for 3 sample
void endRun() override final
This method is called if the current run ends.
TCanvas * m_cOccupancyRPhiViewU3Samples
occupancy U plot canvas for 3 samples
void beginRun() override final
Called when entering a new run.
SVDSummaryPlots * m_hOnlineOccupancy
online occupancy histos
TCanvas * m_cOccupancyRPhiViewU
occupancy U plot canvas
double m_groupIDsOccEmpty
empty level of the IDs occupancy
TCanvas * m_cOnlineOccupancyRPhiViewU
online occupancy U plot canvas
TCanvas * m_cOnlineOccupancyV
online Occupancy V histo canvas
TCanvas * m_cOccupancyUGroupId0
occupancy U histo canvas for cluster time group Id = 0
TCanvas * m_cOccupancyV3Samples
occupancy V histo canvas for 3 samples
double m_onlineOccWarning
warning level of the onlineOccupancy
TCanvas * m_cOnlineOccupancyU3Samples
online occupancy U histo canvas for 3 samples
svdStatus m_occUstatus
0 = good, 4 = empty, 1 = warning, 2 = error
TCanvas * m_cOccupancyRPhiViewV
occupancy V plot canvas
TH1F m_hStripOccupancyU[172]
u-side strip chart occupancy histos
void setOccStatus(float occ, svdStatus &occupancyStatus, int histoType=kOffline)
set occupancy status
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
class to summarize SVD quantities per sensor and side
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
Base class to provide Sensor Information for PXD and SVD.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#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.