Belle II Software release-09-00-00
DQMHistAnalysisSVDEfficiency.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 : DQMHistAnalysisSVDEfficiency.cc
10// Description : module for DQM histogram analysis of SVD sensors efficiencies
11//-
12
13
14#include <dqm/analysis/modules/DQMHistAnalysisSVDEfficiency.h>
15#include <vxd/geometry/GeoCache.h>
16
17#include <TROOT.h>
18#include <TStyle.h>
19#include <TString.h>
20#include <TMath.h>
21
22using namespace std;
23using namespace Belle2;
24
25//-----------------------------------------------------------------
26// Register the Module
27//-----------------------------------------------------------------
28REG_MODULE(DQMHistAnalysisSVDEfficiency);
29
30//-----------------------------------------------------------------
31// Implementation
32//-----------------------------------------------------------------
33
36 m_effUstatus(good),
37 m_effVstatus(good)
38{
39 //Parameter definition
40 B2DEBUG(10, "DQMHistAnalysisSVDEfficiency: Constructor done.");
41
42 setDescription("DQM Analysis Module that computes the average SVD sensor efficiency.");
43
44 addParam("RefHistoFile", m_refFileName, "Reference histogram file name", std::string("SVDrefHisto.root"));
45 addParam("effLevel_Error", m_effError, "Efficiency error (%) level (red)", double(0.9));
46 addParam("effLevel_Warning", m_effWarning, "Efficiency WARNING (%) level (orange)", double(0.94));
47 addParam("statThreshold", m_statThreshold, "minimal number of tracks per sensor to set green/red alert", double(100));
48 addParam("samples3", m_3Samples, "if True 3 samples histograms analysis is performed", bool(false));
49 addParam("PVPrefix", m_pvPrefix, "PV Prefix", std::string("SVD:"));
50 addParam("setEfficiencyRange", m_setEfficiencyRange,
51 "If true you can set the range of the efficiency histogram with 'efficiencyMax' and 'efficiencyMin' parameters.",
52 bool(false));
53 addParam("efficiencyMin", m_efficiencyMin, "Minimum of efficiency histogram", int(0));
54 addParam("efficiencyMax", m_efficiencyMax, "Maximum of efficiency histogram",
55 int(-1111)); //-1111 set the maximum depending on the content
56}
57
59
61{
62 B2DEBUG(10, "DQMHistAnalysisSVDEfficiency: initialize");
63
64 //build the legend
65 m_legProblem = new TPaveText(0.62, 0.22, 0.88, 0.35, "brNDC");
66 m_legProblem->AddText("ERROR!");
67 m_legProblem->AddText("at least one sensor with:");
68 m_legProblem->AddText(Form("efficiency < %1.0f%%", m_effError * 100));
69 m_legProblem->SetFillColor(c_ColorDefault);
70 m_legProblem->SetLineColor(kBlack);
71
72 m_legWarning = new TPaveText(0.62, 0.22, 0.88, 0.35, "brNDC");
73 m_legWarning->AddText("WARNING!");
74 m_legWarning->AddText("at least one sensor with:");
75 m_legWarning->AddText(Form("%1.0f%% < efficiency < %1.0f%%", m_effError * 100, m_effWarning * 100));
76 m_legWarning->SetFillColor(c_ColorDefault);
77 m_legWarning->SetLineColor(kBlack);
78
79 m_legNormal = new TPaveText(0.62, 0.22, 0.88, 0.35, "brNDC");
80 m_legNormal->AddText("EFFICIENCY WITHIN LIMITS");
81 m_legNormal->AddText(Form("efficiency > %1.0f%%", m_effWarning * 100));
82 m_legNormal->SetFillColor(c_ColorDefault);
83 m_legNormal->SetLineColor(kBlack);
84
85 m_legEmpty = new TPaveText(0.62, 0.22, 0.88, 0.35, "brNDC");
86 m_legEmpty->AddText("Not enough statistics,");
87 m_legEmpty->AddText("check again in a few minutes");
88 m_legEmpty->SetFillColor(c_ColorDefault);
89 m_legEmpty->SetTextColor(kWhite);
90 m_legEmpty->SetLineColor(kBlack);
91
92
94
95 //collect the list of all SVD Modules in the geometry here
96 std::vector<VxdID> sensors = geo.getListOfSensors();
97 for (VxdID& aVxdID : sensors) {
98 VXD::SensorInfoBase info = geo.getSensorInfo(aVxdID);
99 // B2INFO("VXD " << aVxdID);
100 if (info.getType() != VXD::SensorInfoBase::SVD) continue;
101 m_SVDModules.push_back(aVxdID); // reorder, sort would be better
102 }
103 std::sort(m_SVDModules.begin(), m_SVDModules.end()); // back to natural order
104
105
106 gROOT->cd();
107 m_cEfficiencyU = new TCanvas("SVDAnalysis/c_SVDEfficiencyU");
108 m_cEfficiencyV = new TCanvas("SVDAnalysis/c_SVDEfficiencyV");
109 m_cEfficiencyErrU = new TCanvas("SVDAnalysis/c_SVDEfficiencyErrU");
110 m_cEfficiencyErrV = new TCanvas("SVDAnalysis/c_SVDEfficiencyErrV");
111
112 m_cEfficiencyRPhiViewU = new TCanvas("SVDAnalysis/c_SVDEfficiencyRPhiViewU", "", 800, 800);
113 m_cEfficiencyRPhiViewV = new TCanvas("SVDAnalysis/c_SVDEfficiencyRPhiViewV", "", 800, 800);
114 m_cEfficiencyErrRPhiViewU = new TCanvas("SVDAnalysis/c_SVDEfficiencyErrRPhiViewU", "", 800, 800);
115 m_cEfficiencyErrRPhiViewV = new TCanvas("SVDAnalysis/c_SVDEfficiencyErrRPhiViewV", "", 800, 800);
116
117 m_hEfficiency = new SVDSummaryPlots("SVDEfficiency@view", "Summary of SVD efficiencies (%), @view/@side Side");
122 }
123 m_hEfficiencyErr = new SVDSummaryPlots("SVDEfficiencyErr@view", "Summary of SVD efficiencies errors (%), @view/@side Side");
125
126 if (m_3Samples) {
127 m_cEfficiencyU3Samples = new TCanvas("SVDAnalysis/c_SVDEfficiencyU3Samples");
128 m_cEfficiencyV3Samples = new TCanvas("SVDAnalysis/c_SVDEfficiencyV3Samples");
129 m_cEfficiencyErrU3Samples = new TCanvas("SVDAnalysis/c_SVDEfficiencyErrU3Samples");
130 m_cEfficiencyErrV3Samples = new TCanvas("SVDAnalysis/c_SVDEfficiencyErrV3Samples");
131
132 m_cEfficiencyRPhiViewU3Samples = new TCanvas("SVDAnalysis/c_SVDEfficiencyRPhiViewU3Samples", "", 800, 800);
133 m_cEfficiencyRPhiViewV3Samples = new TCanvas("SVDAnalysis/c_SVDEfficiencyRPhiViewV3Samples", "", 800, 800);
134 m_cEfficiencyErrRPhiViewU3Samples = new TCanvas("SVDAnalysis/c_SVDEfficiencyErrRPhiViewU3Samples", "", 800, 800);
135 m_cEfficiencyErrRPhiViewV3Samples = new TCanvas("SVDAnalysis/c_SVDEfficiencyErrRPhiViewV3Samples", "", 800, 800);
136
137 m_hEfficiency3Samples = new SVDSummaryPlots("SVD3Efficiency@view",
138 "Summary of SVD efficiencies (%), @view/@side Side for 3 samples");
143 }
144 m_hEfficiencyErr3Samples = new SVDSummaryPlots("SVD3EfficiencyErr@view",
145 "Summary of SVD efficiencies errors (%), @view/@side Side for 3 samples");
147 }
148
149 //register limits for EPICS
150 registerEpicsPV(m_pvPrefix + "efficiencyLimits", "effLimits");
151
152 //find nEvents testing if histograms are present
153 TH1* hnEvnts = findHist("SVDExpReco/SVDDQM_nEvents");
154 if (hnEvnts == NULL) {
155 B2INFO("no events, nothing to do here");
156 return;
157 }
158
159 // text module numbers
160 std::tuple<std::vector<TText*>, std::vector<TText*>> moduleNumbers = textModuleNumbers();
161 m_laddersText = std::get<0>(moduleNumbers);
162 m_sensorsText = std::get<1>(moduleNumbers);
163
164 // axes
165 m_ly = new TLine(0, 0, 0, 210);
166 m_ly->SetLineStyle(kDashed);
167 m_ly->SetLineWidth(2);
168
169 m_lx = new TLine(0, 0, 210, 0);
170 m_lx->SetLineStyle(kDashed);
171 m_lx->SetLineWidth(2);
172
173 m_arrowy = new TArrow(0, 0, 0, 10, 0.01, "|>");
174 m_arrowy->SetAngle(40);
175 m_arrowy->SetFillColor(1);
176 m_arrowy->SetLineWidth(2);
177
178 m_arrowx = new TArrow(0, 0, 10, 0, 0.01, "|>");
179 m_arrowx->SetAngle(40);
180 m_arrowx->SetFillColor(1);
181 m_arrowx->SetLineWidth(2);
182
183}
184
186{
187 B2DEBUG(10, "DQMHistAnalysisSVDEfficiency: beginRun called.");
188
189 if (m_cEfficiencyU)
190 m_cEfficiencyU->Clear();
191 if (m_cEfficiencyV)
192 m_cEfficiencyV->Clear();
194 m_cEfficiencyErrU->Clear();
196 m_cEfficiencyErrV->Clear();
197
199 m_cEfficiencyRPhiViewU->Clear();
201 m_cEfficiencyRPhiViewV->Clear();
206
207 if (m_3Samples) {
209 m_cEfficiencyU3Samples->Clear();
211 m_cEfficiencyV3Samples->Clear();
216
225 }
226
227 //Retrieve limits from EPICS
228 double effErrorLo = 0.;
229 double effWarnLo = 0.;
230
231 requestLimitsFromEpicsPVs("effLimits", effErrorLo, effWarnLo, m_effWarning, m_effError);
232
233 B2DEBUG(10, " SVD efficiency thresholds taken from EPICS configuration file:");
234 B2DEBUG(10, " EFFICIENCY: normal > " << m_effWarning << " > warning > " << m_effError << " > error with minimum statistics of " <<
236}
237
239{
240 B2DEBUG(10, "DQMHistAnalysisSVDEfficiency: event called.");
241
242 //find nEvents
243 TH1* hnEvnts = findHist("SVDExpReco/SVDDQM_nEvents", true);
244 if (hnEvnts == NULL) {
245 B2INFO("no events, nothing to do here");
246 return;
247 } else {
248 B2DEBUG(10, "SVDExpReco/SVDDQM_nEvents found");
249 }
250
251 TString tmp = hnEvnts->GetTitle();
252 Int_t pos = tmp.Last('~');
253 if (pos == -1) pos = 0;
254
255 TString runID = tmp(pos, tmp.Length() - pos);
256 B2INFO("DQMHistAnalysisSVDEfficiencyModule::runID = " << runID);
257
258 gStyle->SetOptStat(0);
259 gStyle->SetPaintTextFormat("2.1f");
260
261 // do it by nhand, the interface of the SVDSummaryPlots does not allow to change the title after cstr
262 if (m_hEfficiency) {
264 m_hEfficiency->setRunID(runID);
265 }
266
267 if (m_hEfficiencyErr) {
270 }
271
272 if (m_3Samples) {
276 }
277
281 }
282 }
283
284
285 Float_t effU = -1;
286 Float_t effV = -1;
287 Float_t erreffU = -1;
288 Float_t erreffV = -1;
289
290 // Efficiency for the U and V sides
291 TH2F* found_tracksU = (TH2F*)findHist("SVDEfficiency/TrackHitsU");
292 TH2F* matched_clusU = (TH2F*)findHist("SVDEfficiency/MatchedHitsU");
293
294 TH2F* found_tracksV = (TH2F*)findHist("SVDEfficiency/TrackHitsV");
295 TH2F* matched_clusV = (TH2F*)findHist("SVDEfficiency/MatchedHitsV");
296
297 if (matched_clusU != NULL && found_tracksU != NULL && matched_clusV != NULL && found_tracksV != NULL) {
298 B2DEBUG(10, "Before loop on sensors, size :" << m_SVDModules.size());
301 for (unsigned int i = 0; i < m_SVDModules.size(); i++) {
302 B2DEBUG(10, "module " << i << "," << m_SVDModules[i]);
303 int bin = found_tracksU->FindBin(m_SVDModules[i].getLadderNumber(), findBinY(m_SVDModules[i].getLayerNumber(),
304 m_SVDModules[i].getSensorNumber()));
305 // U-side
306 float numU = matched_clusU->GetBinContent(bin);
307 float denU = found_tracksU->GetBinContent(bin);
308 if (denU > 0)
309 effU = numU / denU;
310 B2DEBUG(10, "effU = " << numU << "/" << denU << " = " << effU);
311 m_hEfficiency->fill(m_SVDModules[i], 1, effU * 100);
312 if (denU > 0)
313 erreffU = std::sqrt(effU * (1 - effU) / denU);
314 m_hEfficiencyErr->fill(m_SVDModules[i], 1, erreffU * 100);
315 // V-side
316 float numV = matched_clusV->GetBinContent(bin);
317 float denV = found_tracksV->GetBinContent(bin);
318 if (denV > 0)
319 effV = numV / denV;
320 B2DEBUG(10, "effV = " << numV << "/" << denV << " = " << effV);
321 m_hEfficiency->fill(m_SVDModules[i], 0, effV * 100);
322 if (denV > 0)
323 erreffV = std::sqrt(effV * (1 - effV) / denV);
324 m_hEfficiencyErr->fill(m_SVDModules[i], 0, erreffV * 100);
325
326 if (denU < m_statThreshold) {
327 m_effUstatus = std::max(lowStat, m_effUstatus);
328 } else if (effU > m_effWarning) {
329 m_effUstatus = std::max(good, m_effUstatus);
330 } else if ((effU <= m_effWarning) && (effU > m_effError)) {
331 m_effUstatus = std::max(warning, m_effUstatus);
332 } else if ((effU <= m_effError)) {
333 m_effUstatus = std::max(error, m_effUstatus);
334 }
335
336 if (denV < m_statThreshold) {
337 m_effVstatus = std::max(lowStat, m_effVstatus);
338 } else if (effV > m_effWarning) {
339 m_effVstatus = std::max(good, m_effVstatus);
340 } else if ((effV <= m_effWarning) && (effV > m_effError)) {
341 m_effVstatus = std::max(warning, m_effVstatus);
342 } else if ((effV <= m_effError)) {
343 m_effVstatus = std::max(error, m_effVstatus);
344 }
345 B2DEBUG(10, "Status U-side is " << m_effUstatus);
346 B2DEBUG(10, "Status V-side is " << m_effVstatus);
347 }
348 } else {
349 if (matched_clusU == NULL || found_tracksU == NULL) {
350 B2INFO("Histograms needed for U-side Efficiency computation are not found");
351 m_cEfficiencyU->Draw();
352 m_cEfficiencyU->cd();
353 if (m_hEfficiency)
354 m_hEfficiency->getHistogram(1)->Draw("text");
356
359 if (m_hEfficiency) {
361 else m_hEfficiency->getPoly(1)->Draw("colz l");
362 drawText();
363 }
365 }
366 if (matched_clusV == NULL || found_tracksV == NULL) {
367 B2INFO("Histograms needed for V-side Efficiency computation are not found");
368 m_cEfficiencyV->cd();
369 m_cEfficiencyV->Draw();
370 if (m_hEfficiency)
371 m_hEfficiency->getHistogram(0)->Draw("text");
373
376 if (m_hEfficiency) {
378 else m_hEfficiency->getPoly(0)->Draw("colz l");
379 drawText();
380 }
382 }
383 }
384
385 // update summary for U side
386 m_cEfficiencyU->Draw();
387 m_cEfficiencyU->cd();
388 if (m_hEfficiency)
389 m_hEfficiency->getHistogram(1)->Draw("text");
391
392// setEpicsPV("EfficiencyUAlarm", alarm);
393
394 m_cEfficiencyU->Update();
395 m_cEfficiencyU->Modified();
396 m_cEfficiencyU->Update();
397
400 if (m_hEfficiency) {
402 else m_hEfficiency->getPoly(1)->Draw("colz l");
403 drawText();
404 }
406
407 m_cEfficiencyRPhiViewU->Update();
408 m_cEfficiencyRPhiViewU->Modified();
409 m_cEfficiencyRPhiViewU->Update();
410
411 // update summary for V side
412 m_cEfficiencyV->cd();
413 m_cEfficiencyV->Draw();
414 if (m_hEfficiency)
415 m_hEfficiency->getHistogram(0)->Draw("text");
417
418 m_cEfficiencyV->Update();
419 m_cEfficiencyV->Modified();
420 m_cEfficiencyV->Update();
421
424 if (m_hEfficiency) {
426 else m_hEfficiency->getPoly(0)->Draw("colz l");
427 drawText();
428 }
430
431 m_cEfficiencyRPhiViewV->Update();
432 m_cEfficiencyRPhiViewV->Modified();
433 m_cEfficiencyRPhiViewV->Update();
434
435 m_cEfficiencyErrU->cd();
437 m_hEfficiencyErr->getHistogram(1)->Draw("colztext");
438 m_cEfficiencyErrU->Draw();
439 m_cEfficiencyErrU->Update();
440 m_cEfficiencyErrU->Modified();
441 m_cEfficiencyErrU->Update();
442
444 if (m_hEfficiencyErr) {
445 m_hEfficiencyErr->getPoly(1, 0)->Draw("colz l");
446 drawText();
447 }
450 m_cEfficiencyErrRPhiViewU->Modified();
452
453 m_cEfficiencyErrV->cd();
455 m_hEfficiencyErr->getHistogram(0)->Draw("colztext");
456 m_cEfficiencyErrV->Draw();
457 m_cEfficiencyErrV->Update();
458 m_cEfficiencyErrV->Modified();
459 m_cEfficiencyErrV->Update();
460
462 if (m_hEfficiencyErr) {
463 m_hEfficiencyErr->getPoly(0, 0)->Draw("colz l");
464 drawText();
465 }
468 m_cEfficiencyErrRPhiViewV->Modified();
470
471 if (m_3Samples) {
477
478 // Efficiency for the U and V-side - 3 samples
479 TH2F* found3_tracksU = (TH2F*)findHist("SVDEfficiency/TrackHits3U");
480 TH2F* matched3_clusU = (TH2F*)findHist("SVDEfficiency/MatchedHits3U");
481
482 TH2F* found3_tracksV = (TH2F*)findHist("SVDEfficiency/TrackHits3V");
483 TH2F* matched3_clusV = (TH2F*)findHist("SVDEfficiency/MatchedHits3V");
484
485 if (matched3_clusU != NULL && found3_tracksU != NULL && matched3_clusV != NULL && found3_tracksV != NULL) {
486 B2DEBUG(10, "Before loop on sensors, size :" << m_SVDModules.size());
489 for (unsigned int i = 0; i < m_SVDModules.size(); i++) {
490 B2DEBUG(10, "module " << i << "," << m_SVDModules[i]);
491 int bin = found3_tracksU->FindBin(m_SVDModules[i].getLadderNumber(), findBinY(m_SVDModules[i].getLayerNumber(),
492 m_SVDModules[i].getSensorNumber()));
493 // U-side
494 float numU = matched3_clusU->GetBinContent(bin);
495 float denU = found3_tracksU->GetBinContent(bin);
496 if (denU > 0)
497 effU = numU / denU;
498 B2DEBUG(10, "effU = " << numU << "/" << denU << " = " << effU);
499 m_hEfficiency3Samples->fill(m_SVDModules[i], 1, effU * 100);
500 if (denU > 0)
501 erreffU = std::sqrt(effU * (1 - effU) / denU);
502 m_hEfficiencyErr3Samples->fill(m_SVDModules[i], 1, erreffU * 100);
503 // V-side
504 float numV = matched3_clusV->GetBinContent(bin);
505 float denV = found3_tracksV->GetBinContent(bin);
506 if (denV > 0)
507 effV = numV / denV;
508 B2DEBUG(10, "effV = " << numV << "/" << denV << " = " << effV);
509 m_hEfficiency3Samples->fill(m_SVDModules[i], 0, effV * 100);
510 if (denV > 0)
511 erreffV = std::sqrt(effV * (1 - effV) / denV);
512 m_hEfficiencyErr3Samples->fill(m_SVDModules[i], 0, erreffV * 100);
513
514 if (denU < m_statThreshold) {
515 m_effUstatus = std::max(lowStat, m_effUstatus);
516 } else if (effU > m_effWarning) {
517 m_effUstatus = std::max(good, m_effUstatus);
518 } else if ((effU <= m_effWarning) && (effU > m_effError)) {
519 m_effUstatus = std::max(warning, m_effUstatus);
520 } else if ((effU <= m_effError)) {
521 m_effUstatus = std::max(error, m_effUstatus);
522 }
523
524 if (denV < m_statThreshold) {
525 m_effVstatus = std::max(lowStat, m_effVstatus);
526 } else if (effV > m_effWarning) {
527 m_effVstatus = std::max(good, m_effVstatus);
528 } else if ((effV <= m_effWarning) && (effV > m_effError)) {
529 m_effVstatus = std::max(warning, m_effVstatus);
530 } else if ((effV <= m_effError)) {
531 m_effVstatus = std::max(error, m_effVstatus);
532 }
533
534 B2DEBUG(10, "Status U-side is " << m_effUstatus);
535 B2DEBUG(10, "Status V-side is " << m_effVstatus);
536 }
537 } else {
538 if (matched3_clusU == NULL || found3_tracksU == NULL) {
539 B2INFO("Histograms needed for Efficiency computation are not found");
543 m_hEfficiency3Samples->getHistogram(1)->Draw("text");
545
550 else m_hEfficiency3Samples->getPoly(1)->Draw("colz l");
551 drawText();
552 }
554 }
555 if (matched3_clusV == NULL || found3_tracksV == NULL) {
556 B2INFO("Histograms needed for Efficiency computation are not found");
560 m_hEfficiency3Samples->getHistogram(0)->Draw("text");
562
567 else m_hEfficiency3Samples->getPoly(0)->Draw("colz l");
568 drawText();
569 }
571 }
572 }
573
574 // update summary for U side
578 m_hEfficiency3Samples->getHistogram(1)->Draw("text");
580
581 m_cEfficiencyU3Samples->Update();
582 m_cEfficiencyU3Samples->Modified();
583 m_cEfficiencyU3Samples->Update();
584
589 else m_hEfficiency3Samples->getPoly(1)->Draw("colz l");
590 drawText();
591 }
593
597
598 // update summary for V side
602 m_hEfficiency3Samples->getHistogram(0)->Draw("text");
604
605 m_cEfficiencyV3Samples->Update();
606 m_cEfficiencyV3Samples->Modified();
607 m_cEfficiencyV3Samples->Update();
608
613 else m_hEfficiency3Samples->getPoly(0)->Draw("colz l");
614 drawText();
615 }
617
621
624 m_hEfficiencyErr3Samples->getHistogram(1)->Draw("colztext");
627 m_cEfficiencyErrU3Samples->Modified();
629
632 m_hEfficiencyErr3Samples->getPoly(1, 0)->Draw("colz l");
633 drawText();
634 }
639
642 m_hEfficiencyErr3Samples->getHistogram(0)->Draw("colztext");
645 m_cEfficiencyErrV3Samples->Modified();
647
650 m_hEfficiencyErr3Samples->getPoly(0, 0)->Draw("colz l");
651 drawText();
652 }
657 }
658}
659
661{
662 B2DEBUG(10, "DQMHistAnalysisSVDEfficiency: endRun called");
663}
664
666{
667 B2DEBUG(10, "DQMHistAnalysisSVDEfficiency: terminate called");
668
669 delete m_refFile;
670 delete m_legProblem;
671 delete m_legWarning;
672 delete m_legNormal;
673 delete m_legEmpty;
674
675 delete m_hEfficiency;
676 delete m_cEfficiencyU;
677 delete m_cEfficiencyV;
678 delete m_hEfficiencyErr;
679 delete m_cEfficiencyErrU;
680 delete m_cEfficiencyErrV;
681
686
687 for (int i = 0; i < (int)m_laddersText.size(); i++) delete m_laddersText[i];
688 for (int i = 0; i < (int)m_sensorsText.size(); i++) delete m_sensorsText[i];
689
690 delete m_ly;
691 delete m_lx;
692 delete m_arrowx;
693 delete m_arrowy;
694
695 if (m_3Samples) {
702
707 }
708}
709
710// return y coordinate in TH2F histogram for specified sensor
711Int_t DQMHistAnalysisSVDEfficiencyModule::findBinY(Int_t layer, Int_t sensor)
712{
713 if (layer == 3)
714 return sensor; //2 -> 1,2
715 if (layer == 4)
716 return 2 + 1 + sensor; //6 -> 4,5,6
717 if (layer == 5)
718 return 6 + 1 + sensor; // 11 -> 8, 9, 10, 11
719 if (layer == 6)
720 return 11 + 1 + sensor; // 17 -> 13, 14, 15, 16, 17
721 else
722 return -1;
723}
724
725std::tuple<std::vector<TText*>, std::vector<TText*>> DQMHistAnalysisSVDEfficiencyModule::textModuleNumbers()
726{
727 std::vector<TText*> ladders;
728 std::vector<TText*> sensors;
729
730 const double rLayer[4] = {40, 70, 110, 160}; // layer position
731 const double nLadders[4] = {7, 10, 12, 16}; // per layer
732 const double nSensors[4] = {2, 3, 4, 5}; // per ladder
733 const double position[4] = {0.8, 1.2, 1., 0.8}; // text position
734 const double delta[4] = {9, 8, 8, 8}; // width of sensr bins
735 const double inclination[4] = {-17, -5, -13, -12}; // inclination
736
737 double pi = TMath::Pi();
738
739 for (int layer = 0; layer < 4; layer ++) {
740 for (int ladder = 1; ladder <= nLadders[layer]; ladder++) {
741 double deltaText = delta[layer] + position[layer];
742 double r = rLayer[layer] + (deltaText) * nSensors[layer];
743 double phi = 2 * pi / nLadders[layer];
744 double dphiThisPoint = (ladder - 1) * phi - phi / 2 + inclination[layer] * pi / 180.;
745 double dphiNextPoint = dphiThisPoint + phi;
746 double minX = r * TMath::Cos(dphiThisPoint);
747 double maxX = (r + deltaText) * TMath::Cos(dphiNextPoint);
748 double minY = r * TMath::Sin(dphiThisPoint);
749 double maxY = (r + deltaText) * TMath::Sin(dphiNextPoint);
750
751 double xcen = (minX + maxX) / 2.;
752 double ycen = (minY + maxY) / 2.;
753
754 double angle = TMath::ATan2(ycen, xcen) * 180. / TMath::Pi() - 90.;
755 if (ycen < 0) angle = TMath::ATan2(ycen, xcen) * 180. / TMath::Pi() + 90;
756
757 TText* t = new TText(xcen, ycen, Form("%d.%d", layer + 3, ladder));
758 t->SetTextAlign(22);
759 t->SetTextAngle(angle);
760 t->SetTextSize(0.025);
761
762 ladders.push_back(t);
763
764 for (int sensor = 1; sensor <= nSensors[layer]; sensor++) {
765 if ((layer == 0 && ladder == 4) || (layer == 1 && ladder == 5) || (layer == 2 && ladder == 6) || (layer == 3 && ladder == 7)) {
766 double rs = rLayer[layer] + (delta[layer]) * (sensor - 1);
767 double xcens = rs * TMath::Cos(dphiThisPoint);
768 double ycens = rs * TMath::Sin(dphiThisPoint);
769
770 double angles = TMath::ATan2(ycens, xcens) * 180. / pi - 90.;
771 if (ycen < 0) angles = TMath::ATan2(ycens, xcens) * 180. / pi + 90;
772
773 TText* ts = new TText(xcens, ycens, Form("%d ", sensor));
774 ts->SetTextAlign(31);
775 ts->SetTextAngle(angles);
776 ts->SetTextSize(0.018);
777
778 sensors.push_back(ts);
779 }
780 }
781 }
782 }
783
784 return std::make_tuple(ladders, sensors);
785}
786
788{
789 m_ly->Draw("same");
790 m_lx->Draw("same");
791 m_arrowx->Draw();
792 m_arrowy->Draw();
793 for (int i = 0; i < (int)m_laddersText.size(); i++) m_laddersText[i]->Draw("same");
794 for (int i = 0; i < (int)m_sensorsText.size(); i++) m_sensorsText[i]->Draw("same");
795}
796
797void DQMHistAnalysisSVDEfficiencyModule::setStatusOfCanvas(int status, TCanvas* canvas, bool plotLeg)
798{
799 switch (status) {
800 case good: {
802 if (plotLeg) m_legNormal->Draw();
803 break;
804 }
805 case error: {
807 if (plotLeg) m_legProblem->Draw();
808 break;
809 }
810 case warning: {
812 if (plotLeg) m_legWarning->Draw();
813 break;
814 }
815 case lowStat: {
817 if (plotLeg) m_legEmpty->Draw();
818 break;
819 }
820 default: {
821 B2INFO("efficiency status not set properly: " << status);
822 break;
823 }
824 }
825}
The base class for the histogram analysis module.
void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
@ c_ColorDefault
default for non-coloring
@ c_StatusDefault
default for non-coloring
@ c_StatusTooFew
Not enough entries/event to judge.
@ c_StatusError
Analysis result: Severe issue found.
@ c_StatusWarning
Analysis result: Warning, there may be minor issues.
@ c_StatusGood
Analysis result: Good.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.
TCanvas * m_cEfficiencyErrRPhiViewU
efficiency U error plot canvas
TCanvas * m_cEfficiencyErrRPhiViewV3Samples
efficiency V error plot canvas for 3 samples
SVDSummaryPlots * m_hEfficiency3Samples
efficiency histo for 3 samples
int m_efficiencyMin
Minimum of the efficiency histogram.
TCanvas * m_cEfficiencyErrV3Samples
efficiency V error plot canvas for 3 samples
TCanvas * m_cEfficiencyErrRPhiViewV
efficiency V error plot canvas
TPaveText * m_legEmpty
efficiency plot legend, empty
double m_statThreshold
minimal number of tracks per sensor to set green or red frame
TCanvas * m_cEfficiencyErrU
efficiency U error plot canvas
Int_t findBinY(Int_t layer, Int_t sensor)
find Y bin corresponding to sensor, efficiency plot
TCanvas * m_cEfficiencyRPhiViewV3Samples
efficiency V plot canvas for 3 samples
std::vector< VxdID > m_SVDModules
IDs of all SVD Modules to iterate over.
effStatus m_effUstatus
number representing the status of the efficiency U side
SVDSummaryPlots * m_hEfficiencyErr3Samples
efficiency error histo for 3 samples
std::string m_pvPrefix
string prefix for EPICS PVs
double m_effWarning
warning level of the efficiency
double m_effError
error level of the efficiency
void terminate() override final
This method is called at the end of the event processing.
TPaveText * m_legWarning
efficiency plot legend, warning
void event() override final
This method is called for each event.
bool m_3Samples
if true enable 3 samples histograms analysis
TCanvas * m_cEfficiencyU3Samples
efficiency U plot canvas for 3 samples
void endRun() override final
This method is called if the current run ends.
TCanvas * m_cEfficiencyErrU3Samples
efficiency U error plot canvas for 3 samples
void setStatusOfCanvas(int status, TCanvas *canvas, bool plotLeg)
set status of Canvas
bool m_setEfficiencyRange
set the range of the efficiency histogram
std::vector< TText * > m_sensorsText
list of sensors to write on the cancas
effStatus m_effVstatus
number representing the status of the efficiency V side
void beginRun() override final
Called when entering a new run.
TCanvas * m_cEfficiencyRPhiViewU
efficiency U plot canvas
TPaveText * m_legNormal
efficiency plot legend, normal
std::vector< TText * > m_laddersText
list of ladders to write on the canvas
TCanvas * m_cEfficiencyV3Samples
efficiency V plot canvas for 3 samples
TCanvas * m_cEfficiencyErrV
efficiency V error plot canvas
TCanvas * m_cEfficiencyRPhiViewV
efficiency V plot canvas
int m_efficiencyMax
Maximum of the efficiency histogram.
TPaveText * m_legProblem
efficiency plot legend, problem
std::tuple< std::vector< TText * >, std::vector< TText * > > textModuleNumbers()
create vectors of TText to write on the canvas
TCanvas * m_cEfficiencyErrRPhiViewU3Samples
efficiency U error plot canvas for 3 samples
SVDSummaryPlots * m_hEfficiencyErr
efficiency error histo
TCanvas * m_cEfficiencyRPhiViewU3Samples
efficiency U plot canvas for 3 samples
TFile * m_refFile
The pointer to the reference file.
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
void setStats(bool stats=true)
set histograms stat
TH2Poly * getPoly(int view, int min=-1111, int max=-1111)
Create the TH2Poly version of the plot.
void fill(int layer, int ladder, int sensor, int view, float value)
fill the histogram for
TH2F * getHistogram(int view)
get a reference to the histogram for
void setMinimum(Int_t value=0)
set histogram minimum
void setRunID(const TString &runID)
set run ids in title
void reset()
Reset histograms.
void setMaximum(Int_t value=0)
set histogram maximum
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
Definition: GeoCache.cc:59
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne 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.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
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:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.