Belle II Software development
DQMHistAnalysisSVD.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 : DQMHistAnalysisSVDClustersOnTrack.cc
10// Description : module for DQM histogram analysis of SVD sensors occupancies
11//-
12
13
14#include <dqm/analysis/modules/DQMHistAnalysisSVD.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(DQMHistAnalysisSVD);
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
37DQMHistAnalysisSVDModule:: DQMHistAnalysisSVDModule(bool panelTop, bool online, bool groupIDs)
39{
40 //Parameter definition
41 B2DEBUG(10, "DQMHistAnalysisSVD: Constructor done.");
42
43 setDescription("DQM base SVD Analysis.");
44
45 addParam("setColzRange", m_setColzRange,
46 "If true you can set the range of the histogram in Z with 'ColzMax' and 'ColzMin' parameters.",
47 bool(false));
48 addParam("ColzMin", m_colzMinimum, "Minimum of Colz histogram", int(0));
49 addParam("ColzMax", m_colzMaximum, "Maximum of Colz histogram", int(-1111)); //-1111 set the maximum depending on the content
50
51 float x1 = 0;
52 float x2 = 0;
53 float y1 = 0;
54 float y2 = 0;
55
56 // cluster time on tracks legend
57 if (panelTop) {
58 x1 = 0.15;
59 y1 = 0.65;
60 x2 = 0.35;
61 y2 = 0.80;
62 } else {
63 x1 = 0.62;
64 y1 = 0.22;
65 x2 = 0.88;
66 y2 = 0.35;
67 }
68
69 m_legProblem = new TPaveText(x1, y1, x2, y2, "brNDC");
70 m_legProblem->SetFillColor(c_ColorDefault);
71 m_legProblem->SetTextColor(kBlack);
72
73 m_legWarning = new TPaveText(x1, y1, x2, y2, "brNDC");
74 m_legWarning->SetFillColor(c_ColorDefault);
75 m_legWarning->SetTextColor(kBlack);
76
77 m_legNormal = new TPaveText(x1, y1, x2, y2, "brNDC");
78 m_legNormal->SetFillColor(c_ColorDefault);
79 m_legNormal->SetTextColor(kBlack);
80
81 m_legEmpty = new TPaveText(x1, y1, x2, y2, "brNDC");
82 m_legEmpty->SetFillColor(c_ColorDefault);
83 m_legEmpty->SetTextColor(kBlack);
84
85 m_legLowStat = new TPaveText(x1, y1, x2, y2, "brNDC");
86 m_legLowStat->SetFillColor(c_ColorDefault);
87 m_legLowStat->SetTextColor(kBlack);
88
89 if (online) {
90 m_legOnlineProblem = new TPaveText(x1, y1, x2, y2, "brNDC");
92 m_legOnlineProblem->SetTextColor(kBlack);
93
94 m_legOnlineWarning = new TPaveText(x1, y1, x2, y2, "brNDC");
96 m_legOnlineWarning->SetTextColor(kBlack);
97
98 m_legOnlineNormal = new TPaveText(x1, y1, x2, y2, "brNDC");
99 m_legOnlineNormal->SetFillColor(c_ColorDefault);
100 m_legOnlineNormal->SetTextColor(kBlack);
101 }
102
103 if (groupIDs) {
104 m_legGroupIDsProblem = new TPaveText(x1, y1, x2, y2, "brNDC");
106 m_legGroupIDsProblem->SetTextColor(kBlack);
107
108 m_legGroupIDsWarning = new TPaveText(x1, y1, x2, y2, "brNDC");
110 m_legGroupIDsWarning->SetTextColor(kBlack);
111
112 m_legGroupIDsNormal = new TPaveText(x1, y1, x2, y2, "brNDC");
113 m_legGroupIDsNormal->SetFillColor(c_ColorDefault);
114 m_legGroupIDsNormal->SetTextColor(kBlack);
115 }
116
117 // text module numbers
118 pair<vector<TText*>, vector<TText*>> moduleNumbers = textModuleNumbers();
119 m_laddersText = moduleNumbers.first;
120 m_sensorsText = moduleNumbers.second;
121
122 // axes
123 m_ly = new TLine(0, 0, 0, 210);
124 m_ly->SetLineStyle(kDashed);
125 m_ly->SetLineWidth(2);
126
127 m_lx = new TLine(0, 0, 210, 0);
128 m_lx->SetLineStyle(kDashed);
129 m_lx->SetLineWidth(2);
130
131 m_arrowy = new TArrow(0, 0, 0, 10, 0.01, "|>");
132 m_arrowy->SetAngle(40);
133 m_arrowy->SetFillColor(1);
134 m_arrowy->SetLineWidth(2);
135
136 m_arrowx = new TArrow(0, 0, 10, 0, 0.01, "|>");
137 m_arrowx->SetAngle(40);
138 m_arrowx->SetFillColor(1);
139 m_arrowx->SetLineWidth(2);
140}
141
142DQMHistAnalysisSVDModule::~ DQMHistAnalysisSVDModule()
143{
144 delete m_legProblem;
145 delete m_legNormal;
146 delete m_legWarning;
147 delete m_legLowStat;
148 delete m_legEmpty;
149
153
157}
158
159void DQMHistAnalysisSVDModule::setStatusOfCanvas(int status, TCanvas* canvas, bool plotLeg, int histoType)
160{
161 switch (status) {
162 case good: {
164 if (plotLeg) {
165 if (histoType == kOnline)
166 m_legOnlineNormal->Draw();
167 else if (histoType == kOffline)
168 m_legNormal->Draw();
169 else if (histoType == kGroupIDs) {
170 m_legGroupIDsNormal->Draw();
171 }
172 }
173 break;
174 }
175 case warning: {
177 if (plotLeg) {
178 if (histoType == kOnline)
179 m_legOnlineWarning->Draw();
180 else if (histoType == kOffline)
181 m_legWarning->Draw();
182 else if (histoType == kGroupIDs)
183 m_legGroupIDsWarning->Draw();
184 }
185 break;
186 }
187 case error: {
189 if (plotLeg) {
190 if (histoType == kOnline)
191 m_legOnlineProblem->Draw();
192 else if (histoType == kOffline)
193 m_legProblem->Draw();
194 else if (histoType == kGroupIDs)
195 m_legGroupIDsProblem->Draw();
196 }
197 break;
198 }
199 case lowStat: {
201 if (plotLeg) m_legLowStat->Draw();
202 break;
203 }
204 case noStat: {
206 if (plotLeg) m_legEmpty->Draw();
207 break;
208 }
209 default: {
210 B2INFO("efficiency status not set properly: " << status);
211 break;
212 }
213 }
214
215 canvas->Modified();
216 canvas->Update();
217}
218
219// This function is used both for efficiency and occupancy (flag online used onlhy for occupancy)
220void DQMHistAnalysisSVDModule::updateCanvases(SVDSummaryPlots* histo, TCanvas* canvas, TCanvas* canvasRPhi, svdStatus status,
221 bool isU, int histoType)
222{
223 canvas->Draw();
224 canvas->cd();
225 if (histo) {
226 if (!m_setColzRange && m_valueMinimum > 0) histo->getHistogram(isU)->SetMinimum(m_valueMinimum * 99.9);
227 histo->getHistogram(isU)->Draw("text colz");
228 }
229 setStatusOfCanvas(status, canvas, true, histoType);
230
231 canvas->Modified();
232 canvas->Update();
233
234 if (canvasRPhi) {
235 canvasRPhi->Draw();
236 canvasRPhi->cd();
237 if (histo) {
238 if (m_setColzRange) histo->getPoly(isU, m_colzMinimum, m_colzMaximum)->Draw("colz l");
239 else histo->getPoly(isU)->Draw("colz l");
240 drawText();
241 }
242 setStatusOfCanvas(status, canvasRPhi, false);
243
244 canvasRPhi->Modified();
245 canvasRPhi->Update();
246 }
247}
248
249void DQMHistAnalysisSVDModule::updateErrCanvases(SVDSummaryPlots* histo, TCanvas* canvas, TCanvas* canvasRPhi, bool isU)
250{
251 canvas->Draw();
252 canvas->cd();
253 if (histo)
254 histo->getHistogram(isU)->Draw("text colz");
255
256 canvas->Modified();
257 canvas->Update();
258
259 if (canvasRPhi) {
260 canvasRPhi->Draw();
261 canvasRPhi->cd();
262 if (histo) {
263 histo->getPoly(isU, 0)->Draw("colz l");
264 drawText();
265 }
266
267 canvasRPhi->Modified();
268 canvasRPhi->Update();
269 }
270}
271
272pair<vector<TText*>, vector<TText*>> DQMHistAnalysisSVDModule::textModuleNumbers()
273{
274 vector<TText*> ladders;
275 vector<TText*> sensors;
276
277 const double rLayer[4] = {40, 70, 110, 160}; // layer position
278 const double nLadders[4] = {7, 10, 12, 16}; // per layer
279 const double nSensors[4] = {2, 3, 4, 5}; // per ladder
280 const double position[4] = {0.8, 1.2, 1., 0.8}; // text position
281 const double delta[4] = {9, 8, 8, 8}; // width of sensr bins
282 const double inclination[4] = {-17, -5, -13, -12}; // inclination
283
284 double pi = TMath::Pi();
285
286 for (int layer = 0; layer < 4; layer ++) {
287 for (int ladder = 1; ladder <= nLadders[layer]; ladder++) {
288 double deltaText = delta[layer] + position[layer];
289 double r = rLayer[layer] + (deltaText) * nSensors[layer];
290 double phi = 2 * pi / nLadders[layer];
291 double dphiThisPoint = (ladder - 1) * phi - phi / 2 + inclination[layer] * pi / 180.;
292 double dphiNextPoint = dphiThisPoint + phi;
293 double minX = r * TMath::Cos(dphiThisPoint);
294 double maxX = (r + deltaText) * TMath::Cos(dphiNextPoint);
295 double minY = r * TMath::Sin(dphiThisPoint);
296 double maxY = (r + deltaText) * TMath::Sin(dphiNextPoint);
297
298 double xcen = (minX + maxX) / 2.;
299 double ycen = (minY + maxY) / 2.;
300
301 double angle = TMath::ATan2(ycen, xcen) * 180. / TMath::Pi() - 90.;
302 if (ycen < 0) angle = TMath::ATan2(ycen, xcen) * 180. / TMath::Pi() + 90;
303
304 TText* t = new TText(xcen, ycen, Form("%d.%d", layer + 3, ladder));
305 t->SetTextAlign(22);
306 t->SetTextAngle(angle);
307 t->SetTextSize(0.025);
308
309 ladders.push_back(t);
310
311 for (int sensor = 1; sensor <= nSensors[layer]; sensor++) {
312 if ((layer == 0 && ladder == 4) || (layer == 1 && ladder == 5) || (layer == 2 && ladder == 6) || (layer == 3 && ladder == 7)) {
313 double rs = rLayer[layer] + (delta[layer]) * (sensor - 1);
314 double xcens = rs * TMath::Cos(dphiThisPoint);
315 double ycens = rs * TMath::Sin(dphiThisPoint);
316
317 double angles = TMath::ATan2(ycens, xcens) * 180. / pi - 90.;
318 if (ycen < 0) angles = TMath::ATan2(ycens, xcens) * 180. / pi + 90;
319
320 TText* ts = new TText(xcens, ycens, Form("%d ", sensor));
321 ts->SetTextAlign(31);
322 ts->SetTextAngle(angles);
323 ts->SetTextSize(0.018);
324
325 sensors.push_back(ts);
326 }
327 }
328 }
329 }
330
331 return std::make_pair(ladders, sensors);
332}
333
335{
336 m_ly->Draw("same");
337 m_lx->Draw("same");
338 m_arrowx->Draw();
339 m_arrowy->Draw();
340 for (int i = 0; i < (int)m_laddersText.size(); i++) m_laddersText[i]->Draw("same");
341 for (int i = 0; i < (int)m_sensorsText.size(); i++) m_sensorsText[i]->Draw("same");
342}
343
344TString DQMHistAnalysisSVDModule::getHistoNameFromCanvas(TString cName, TString view, TString cPrefix, TString hPrefix)
345{
346 TString hName;
347
348 int pos = cName.Last('/');
349
350 if (pos != -1)
351 hName = cName(pos + 1, cName.Length() - pos - 1);
352 else
353 hName = cName;
354
355 hName.ReplaceAll(cPrefix, hPrefix);
356
357 if (!view.IsNull()) {
358 // cut off side info
359 hName.Replace(hName.Length() - 1, 1, "");
360 // append view suffix
361 hName.Append(view);
362 }
363
364 return hName;
365}
static void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
@ c_ColorDefault
default for non-coloring
DQMHistAnalysisModule()
Constructor / Destructor.
@ 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 m_colzMaximum
Maximum of the histogram.
TPaveText * m_legOnlineNormal
onlineOccupancy plot legend, normal
static std::pair< std::vector< TText * >, std::vector< TText * > > textModuleNumbers()
create vectors of TText to write on the canvas
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.
int m_colzMinimum
Minimum of the histogram.
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
TArrow * m_arrowx
x-axis direction
TPaveText * m_legGroupIDsWarning
Group IDs Occupancy plot legend, warning.
std::vector< TText * > m_sensorsText
list of sensors to write on the cancas
void drawText()
draw text on the RPhi view
float m_valueMinimum
Minimum value of parameter.
TPaveText * m_legNormal
plot legend, normal
TArrow * m_arrowy
y-axis direction
std::vector< TText * > m_laddersText
list of ladders to write on the canvas
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.
void setStatusOfCanvas(int status, TCanvas *canvas, bool plotLeg=true, int histoType=kOffline)
set status of Canvas
void updateErrCanvases(SVDSummaryPlots *histo, TCanvas *canvas, TCanvas *canvasRPhi, bool isU)
update error canvases
bool m_setColzRange
set the range of the histogram in colz
TPaveText * m_legGroupIDsNormal
Group IDs Occupancy plot legend, normal.
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 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.