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
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 // text module numbers
104 pair<vector<TText*>, vector<TText*>> moduleNumbers = textModuleNumbers();
105 m_laddersText = moduleNumbers.first;
106 m_sensorsText = moduleNumbers.second;
107
108 // axes
109 m_ly = new TLine(0, 0, 0, 210);
110 m_ly->SetLineStyle(kDashed);
111 m_ly->SetLineWidth(2);
112
113 m_lx = new TLine(0, 0, 210, 0);
114 m_lx->SetLineStyle(kDashed);
115 m_lx->SetLineWidth(2);
116
117 m_arrowy = new TArrow(0, 0, 0, 10, 0.01, "|>");
118 m_arrowy->SetAngle(40);
119 m_arrowy->SetFillColor(1);
120 m_arrowy->SetLineWidth(2);
121
122 m_arrowx = new TArrow(0, 0, 10, 0, 0.01, "|>");
123 m_arrowx->SetAngle(40);
124 m_arrowx->SetFillColor(1);
125 m_arrowx->SetLineWidth(2);
126}
127
128DQMHistAnalysisSVDModule::~ DQMHistAnalysisSVDModule()
129{
130 delete m_legProblem;
131 delete m_legNormal;
132 delete m_legWarning;
133 delete m_legLowStat;
134 delete m_legEmpty;
135
139}
140
141void DQMHistAnalysisSVDModule::setStatusOfCanvas(int status, TCanvas* canvas, bool plotLeg, bool online)
142{
143 switch (status) {
144 case good: {
146 if (plotLeg) {
147 if (online)
148 m_legOnlineNormal->Draw();
149 else
150 m_legNormal->Draw();
151 }
152 break;
153 }
154 case warning: {
156 if (plotLeg) {
157 if (online)
158 m_legOnlineWarning->Draw();
159 else
160 m_legWarning->Draw();
161 }
162 break;
163 }
164 case error: {
166 if (plotLeg) {
167 if (online)
168 m_legOnlineProblem->Draw();
169 else
170 m_legProblem->Draw();
171 }
172 break;
173 }
174 case lowStat: {
176 if (plotLeg) m_legLowStat->Draw();
177 break;
178 }
179 case noStat: {
181 if (plotLeg) m_legEmpty->Draw();
182 break;
183 }
184 default: {
185 B2INFO("efficiency status not set properly: " << status);
186 break;
187 }
188 }
189
190 canvas->Modified();
191 canvas->Update();
192}
193
194// This function is used both for efficiency and occupancy (flag online used onlhy for occupancy)
195void DQMHistAnalysisSVDModule::updateCanvases(SVDSummaryPlots* histo, TCanvas* canvas, TCanvas* canvasRPhi, svdStatus status,
196 bool isU, bool online)
197{
198 canvas->Draw();
199 canvas->cd();
200 if (histo) {
201 if (!m_setColzRange && m_valueMinimum > 0) histo->setMinimum(m_valueMinimum * 99.9);
202 histo->getHistogram(isU)->Draw("text colz");
203 }
204 setStatusOfCanvas(status, canvas, true, online);
205
206 canvas->Modified();
207 canvas->Update();
208
209 if (canvasRPhi) {
210 canvasRPhi->Draw();
211 canvasRPhi->cd();
212 if (histo) {
213 if (m_setColzRange) histo->getPoly(isU, m_colzMinimum, m_colzMaximum)->Draw("colz l");
214 else histo->getPoly(isU)->Draw("colz l");
215 drawText();
216 }
217 setStatusOfCanvas(status, canvasRPhi, false);
218
219 canvasRPhi->Modified();
220 canvasRPhi->Update();
221 }
222}
223
224void DQMHistAnalysisSVDModule::updateErrCanvases(SVDSummaryPlots* histo, TCanvas* canvas, TCanvas* canvasRPhi, bool isU)
225{
226 canvas->Draw();
227 canvas->cd();
228 if (histo)
229 histo->getHistogram(isU)->Draw("text colz");
230
231 canvas->Modified();
232 canvas->Update();
233
234 if (canvasRPhi) {
235 canvasRPhi->Draw();
236 canvasRPhi->cd();
237 if (histo) {
238 histo->getPoly(isU, 0)->Draw("colz l");
239 drawText();
240 }
241
242 canvasRPhi->Modified();
243 canvasRPhi->Update();
244 }
245}
246
247pair<vector<TText*>, vector<TText*>> DQMHistAnalysisSVDModule::textModuleNumbers()
248{
249 vector<TText*> ladders;
250 vector<TText*> sensors;
251
252 const double rLayer[4] = {40, 70, 110, 160}; // layer position
253 const double nLadders[4] = {7, 10, 12, 16}; // per layer
254 const double nSensors[4] = {2, 3, 4, 5}; // per ladder
255 const double position[4] = {0.8, 1.2, 1., 0.8}; // text position
256 const double delta[4] = {9, 8, 8, 8}; // width of sensr bins
257 const double inclination[4] = {-17, -5, -13, -12}; // inclination
258
259 double pi = TMath::Pi();
260
261 for (int layer = 0; layer < 4; layer ++) {
262 for (int ladder = 1; ladder <= nLadders[layer]; ladder++) {
263 double deltaText = delta[layer] + position[layer];
264 double r = rLayer[layer] + (deltaText) * nSensors[layer];
265 double phi = 2 * pi / nLadders[layer];
266 double dphiThisPoint = (ladder - 1) * phi - phi / 2 + inclination[layer] * pi / 180.;
267 double dphiNextPoint = dphiThisPoint + phi;
268 double minX = r * TMath::Cos(dphiThisPoint);
269 double maxX = (r + deltaText) * TMath::Cos(dphiNextPoint);
270 double minY = r * TMath::Sin(dphiThisPoint);
271 double maxY = (r + deltaText) * TMath::Sin(dphiNextPoint);
272
273 double xcen = (minX + maxX) / 2.;
274 double ycen = (minY + maxY) / 2.;
275
276 double angle = TMath::ATan2(ycen, xcen) * 180. / TMath::Pi() - 90.;
277 if (ycen < 0) angle = TMath::ATan2(ycen, xcen) * 180. / TMath::Pi() + 90;
278
279 TText* t = new TText(xcen, ycen, Form("%d.%d", layer + 3, ladder));
280 t->SetTextAlign(22);
281 t->SetTextAngle(angle);
282 t->SetTextSize(0.025);
283
284 ladders.push_back(t);
285
286 for (int sensor = 1; sensor <= nSensors[layer]; sensor++) {
287 if ((layer == 0 && ladder == 4) || (layer == 1 && ladder == 5) || (layer == 2 && ladder == 6) || (layer == 3 && ladder == 7)) {
288 double rs = rLayer[layer] + (delta[layer]) * (sensor - 1);
289 double xcens = rs * TMath::Cos(dphiThisPoint);
290 double ycens = rs * TMath::Sin(dphiThisPoint);
291
292 double angles = TMath::ATan2(ycens, xcens) * 180. / pi - 90.;
293 if (ycen < 0) angles = TMath::ATan2(ycens, xcens) * 180. / pi + 90;
294
295 TText* ts = new TText(xcens, ycens, Form("%d ", sensor));
296 ts->SetTextAlign(31);
297 ts->SetTextAngle(angles);
298 ts->SetTextSize(0.018);
299
300 sensors.push_back(ts);
301 }
302 }
303 }
304 }
305
306 return std::make_pair(ladders, sensors);
307}
308
310{
311 m_ly->Draw("same");
312 m_lx->Draw("same");
313 m_arrowx->Draw();
314 m_arrowy->Draw();
315 for (int i = 0; i < (int)m_laddersText.size(); i++) m_laddersText[i]->Draw("same");
316 for (int i = 0; i < (int)m_sensorsText.size(); i++) m_sensorsText[i]->Draw("same");
317}
The base class for the histogram analysis module.
void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
@ 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 m_colzMaximum
Maximum of the histogram.
TPaveText * m_legOnlineNormal
onlineOccupancy plot legend, normal
std::pair< std::vector< TText * >, std::vector< TText * > > textModuleNumbers()
create vectors of TText to write on the canvas
TPaveText * m_legEmpty
plot legend, empty
int m_colzMinimum
Minimum of the histogram.
TPaveText * m_legLowStat
plot legend, low stats
DQMHistAnalysisSVDModule(bool panelTop=false, bool online=false)
Constructor.
TPaveText * m_legWarning
plot legend, warning
void setStatusOfCanvas(int status, TCanvas *canvas, bool plotLeg=true, bool online=false)
set status of Canvas
TArrow * m_arrowx
x-axis direction
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
void updateErrCanvases(SVDSummaryPlots *histo, TCanvas *canvas, TCanvas *canvasRPhi, bool isU)
update error canvases
void updateCanvases(SVDSummaryPlots *histo, TCanvas *canvas, TCanvas *canvasRPhi, svdStatus status, bool isU, bool online=false)
update canvases
bool m_setColzRange
set the range of the histogram in colz
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: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.