Belle II Software  release-06-00-14
DQMHistAnalysisSVDGeneral.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 : DQMHistAnalysisSVDGeneral.cc
10 // Description : module for DQM histogram analysis of SVD sensors occupancies
11 //-
12 
13 
14 #include <dqm/analysis/modules/DQMHistAnalysisSVDGeneral.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 
25 using namespace std;
26 using namespace Belle2;
27 
28 //-----------------------------------------------------------------
29 // Register the Module
30 //-----------------------------------------------------------------
31 REG_MODULE(DQMHistAnalysisSVDGeneral)
32 
33 //-----------------------------------------------------------------
34 // Implementation
35 //-----------------------------------------------------------------
36 
39 {
40  //Parameter definition
41  B2INFO("DQMHistAnalysisSVDGeneral: Constructor done.");
42 
43  setDescription("DQM Analysis Module that produces colored canvas for a straightforward interpretation of the SVD Data Quality.");
44 
45  addParam("RefHistoFile", m_refFileName, "Reference histrogram file name", std::string("SVDrefHisto.root"));
46  addParam("unpackerErrorLevel", m_unpackError, "Maximum bin_content/ # events allowed before throwing ERROR", double(0.00001));
47  addParam("occLevel_Error", m_occError, "Maximum Occupancy (%) allowed for safe operations (red)", float(5));
48  addParam("occLevel_Warning", m_occWarning, "Occupancy (%) at WARNING level (orange)", float(3));
49  addParam("occLevel_Empty", m_occEmpty, "Maximum Occupancy (%) for which the sensor is considered empty", float(0));
50  addParam("onlineOccLevel_Error", m_onlineOccError, "Maximum OnlineOccupancy (%) allowed for safe operations (red)", float(10));
51  addParam("onlineOccLevel_Warning", m_onlineOccWarning, "OnlineOccupancy (%) at WARNING level (orange)", float(5));
52  addParam("onlineOccLevel_Empty", m_onlineOccEmpty, "Maximum OnlineOccupancy (%) for which the sensor is considered empty",
53  float(0));
54  addParam("printCanvas", m_printCanvas, "if True prints pdf of the analysis canvas", bool(false));
55  addParam("statThreshold", m_statThreshold, "Minimal number of events to compare histograms", int(10000));
56  addParam("timeThreshold", m_timeThreshold, "Acceptable difference between mean of central peak for present and reference run",
57  float(6)); // 6 ns
58  addParam("refMCTP", m_refMeanP, "Mean of the signal time peak from Physics reference run", float(0.0)); // Approximate, from exp 20
59  addParam("refMCTC", m_refMeanC, "Mean of the signal time peak from Cosmic reference run", float(0.0)); //
60 }
61 
62 DQMHistAnalysisSVDGeneralModule::~DQMHistAnalysisSVDGeneralModule() { }
63 
64 void DQMHistAnalysisSVDGeneralModule::initialize()
65 {
66  B2INFO("DQMHistAnalysisSVDGeneral: initialized.");
67  B2DEBUG(10, " black = " << kBlack);
68  B2DEBUG(10, " green = " << kGreen);
69  B2DEBUG(10, " orange = " << kOrange);
70  B2DEBUG(10, " Red = " << kRed);
71 
72  m_refFile = NULL;
73  if (m_refFileName != "") {
74  m_refFile = new TFile(m_refFileName.data(), "READ");
75  }
76 
77  //search for reference
78  if (m_refFile && m_refFile->IsOpen()) {
79  B2INFO("SVD DQMHistAnalysis: reference root file (" << m_refFileName << ") FOUND, reading ref histograms");
80 
81  TH1F* ref_occ = (TH1F*)m_refFile->Get("refOccupancy");
82  if (!ref_occ)
83  B2WARNING("SVD DQMHistAnalysis: Occupancy Level Reference not found! using module parameters");
84  else {
85  m_occEmpty = ref_occ->GetBinContent(1);
86  m_occWarning = ref_occ->GetBinContent(2);
87  m_occError = ref_occ->GetBinContent(3);
88  }
89 
90  TH1F* ref_onlineOcc = (TH1F*)m_refFile->Get("refOnlineOccupancy");
91  if (!ref_onlineOcc)
92  B2WARNING("SVD DQMHistAnalysis: OnlineOccupancy Level Reference not found! using module parameters");
93  else {
94  m_onlineOccEmpty = ref_onlineOcc->GetBinContent(1);
95  m_onlineOccWarning = ref_onlineOcc->GetBinContent(2);
96  m_onlineOccError = ref_onlineOcc->GetBinContent(3);
97  }
98  } else
99  B2WARNING("SVD DQMHistAnalysis: reference root file (" << m_refFileName << ") not found, or closed, using module parameters");
100 
101  B2INFO(" SVD occupancy thresholds:");
102  B2INFO("ONLINE OCCUPANCY: empty < " << m_onlineOccEmpty << " normal < " << m_onlineOccWarning << "warning < " << m_onlineOccError <<
103  " < error");
104  B2INFO("OFFLINE OCCUPANCY: empty < " << m_occEmpty << " normal < " << m_occWarning << "warning < " << m_occError << " < error");
105 
106  m_legError = new TPaveText(-1, 54, 3, 57.5);
107  m_legError->AddText("ERROR!!");
108  m_legError->SetFillColor(kRed);
109  m_legError->SetTextColor(kWhite);
110 
111  const VXD::GeoCache& geo = VXD::GeoCache::getInstance();
112 
113  //collect the list of all SVD Modules in the geometry here
114  std::vector<VxdID> sensors = geo.getListOfSensors();
115  for (VxdID& aVxdID : sensors) {
116  VXD::SensorInfoBase info = geo.getSensorInfo(aVxdID);
117  // B2INFO("VXD " << aVxdID);
118  if (info.getType() != VXD::SensorInfoBase::SVD) continue;
119  m_SVDModules.push_back(aVxdID); // reorder, sort would be better
120  }
121  std::sort(m_SVDModules.begin(), m_SVDModules.end()); // back to natural order
122 
123  //occupancy chart chip
124  m_cOccupancyChartChip = new TCanvas("SVDOccupancy/c_OccupancyChartChip");
125 
126  //strip occupancy per sensor
127  m_cStripOccupancyU = new TCanvas*[nSensors];
128  m_cStripOccupancyV = new TCanvas*[nSensors];
129  for (unsigned int i = 0; i < m_SVDModules.size(); i++) {
130  int tmp_layer = m_SVDModules[i].getLayerNumber();
131  int tmp_ladder = m_SVDModules[i].getLadderNumber();
132  int tmp_sensor = m_SVDModules[i].getSensorNumber();
133  m_cStripOccupancyU[i] = new TCanvas(Form("SVDOccupancy/c_StripOccupancyU_%d_%d_%d", tmp_layer, tmp_ladder, tmp_sensor));
134  m_cStripOccupancyV[i] = new TCanvas(Form("SVDOccupancy/c_StripOccupancyV_%d_%d_%d", tmp_layer, tmp_ladder, tmp_sensor));
135  }
136 
137 
138  //OFFLINE occupancy plots legend
139  m_legProblem = new TPaveText(11, findBinY(4, 3) - 3, 16, findBinY(4, 3));
140  m_legProblem->AddText("ERROR!");
141  m_legProblem->AddText("at least one sensor with:");
142  m_legProblem->AddText(Form("occupancy > %1.1f%%", m_occError));
143  m_legProblem->SetFillColor(kRed);
144  m_legWarning = new TPaveText(11, findBinY(4, 3) - 3, 16, findBinY(4, 3));
145  m_legWarning->AddText("WARNING!");
146  m_legWarning->AddText("at least one sensor with:");
147  m_legWarning->AddText(Form("%1.1f%% < occupancy < %1.1f%%", m_occWarning, m_occError));
148  m_legWarning->SetFillColor(kOrange);
149  m_legNormal = new TPaveText(11, findBinY(4, 3) - 3, 16, findBinY(4, 3));
150  m_legNormal->AddText("OCCUPANCY WITHIN LIMITS");
151  m_legNormal->AddText(Form("%1.1f%% < occupancy < %1.1f%%", m_occEmpty, m_occWarning));
152  m_legNormal->SetFillColor(kGreen);
153  m_legNormal->SetBorderSize(0.);
154  m_legNormal->SetLineColor(kBlack);
155  m_legEmpty = new TPaveText(11, findBinY(4, 3) - 2, 16, findBinY(4, 3));
156  m_legEmpty->AddText("NO DATA RECEIVED");
157  m_legEmpty->AddText("from at least one sensor");
158  m_legEmpty->SetFillColor(kBlack);
159  m_legEmpty->SetTextColor(kWhite);
160  m_legEmpty->SetBorderSize(0.);
161  m_legEmpty->SetLineColor(kBlack);
162 
163  //ONLINE occupancy plots legend
164  m_legOnProblem = new TPaveText(11, findBinY(4, 3) - 3, 16, findBinY(4, 3));
165  m_legOnProblem->AddText("ERROR!");
166  m_legOnProblem->AddText("at least one sensor with:");
167  m_legOnProblem->AddText(Form("online occupancy > %1.1f%%", m_onlineOccError));
168  m_legOnProblem->SetFillColor(kRed);
169  m_legOnWarning = new TPaveText(11, findBinY(4, 3) - 3, 16, findBinY(4, 3));
170  m_legOnWarning->AddText("WARNING!");
171  m_legOnWarning->AddText("at least one sensor with:");
172  m_legOnWarning->AddText(Form("%1.1f%% < online occupancy < %1.1f%%", m_onlineOccWarning, m_onlineOccError));
173  m_legOnWarning->SetFillColor(kOrange);
174  m_legOnNormal = new TPaveText(11, findBinY(4, 3) - 3, 16, findBinY(4, 3));
175  m_legOnNormal->AddText("OCCUPANCY WITHIN LIMITS");
176  m_legOnNormal->AddText(Form("%1.1f%% < online occupancy < %1.1f%%", m_onlineOccEmpty, m_onlineOccWarning));
177  m_legOnNormal->SetFillColor(kGreen);
178  m_legOnNormal->SetBorderSize(0.);
179  m_legOnNormal->SetLineColor(kBlack);
180  m_legOnEmpty = new TPaveText(11, findBinY(4, 3) - 2, 16, findBinY(4, 3));
181  m_legOnEmpty->AddText("NO DATA RECEIVED");
182  m_legOnEmpty->AddText("from at least one sensor");
183  m_legOnEmpty->SetFillColor(kBlack);
184  m_legOnEmpty->SetTextColor(kWhite);
185 
186 
187  //occupancy plot Y axis title
188  m_yTitle = new TText(-0.75, 13, "layer.ladder.sensor");
189  m_yTitle->SetTextAngle(90);
190  m_yTitle->SetTextSize(0.03);
191  m_yTitle->SetTextFont(42);
192 
193  gROOT->cd();
194  m_cUnpacker = new TCanvas("SVDAnalysis/c_SVDDataFormat");
195  m_cUnpacker->SetGrid(1);
196  m_cOccupancyU = new TCanvas("SVDAnalysis/c_SVDOccupancyU");
197  // m_cOccupancyU->SetGrid(1);
198  m_cOccupancyV = new TCanvas("SVDAnalysis/c_SVDOccupancyV");
199  // m_cOccupancyV->SetGrid(1);
200  m_cOnlineOccupancyU = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancyU");
201  // m_cOnlineOccupancyU->SetGrid(1);
202  m_cOnlineOccupancyV = new TCanvas("SVDAnalysis/c_SVDOnlineOccupancyV");
203  // m_cOnlineOccupancyV->SetGrid(1);
204  m_cClusterOnTrackTime_L456V = new TCanvas("SVDAnalysis/c_ClusterOnTrackTime_L456V");
205 
206  const int nY = 19;
207  TString Ylabels[nY] = {"", "L3.x.1", "L3.x.2",
208  "", "L4.x.1", "L4.x.2", "L4.x.3",
209  "", "L5.x.1", "L5.x.2", "L5.x.3", "L5.x.4",
210  "", "L6.x.1", "L6.x.2", "L6.x.3", "L6.x.4", "L6.x.5", ""
211  };
212 
213 
214  m_hOccupancyV = new TH2F("hOccupancyV", "Average OFFLINE Sensor Occupancy (%), V side ", 16, 0.5, 16.5, 19, 0, 19);
215  m_hOccupancyV->SetMarkerSize(1.1);
216  m_hOccupancyV->GetXaxis()->SetTitle("ladder number");
217  m_hOccupancyV->GetXaxis()->SetLabelSize(0.04);
218  for (unsigned short i = 0; i < nY; i++) m_hOccupancyV->GetYaxis()->SetBinLabel(i + 1, Ylabels[i].Data());
219 
220  m_hOccupancyU = new TH2F("hOccupancyU", "Average OFFLINE Sensor Occupancy (%), U side ", 16, 0.5, 16.5, 19, 0, 19);
221  m_hOccupancyU->SetMarkerSize(1.1);
222  m_hOccupancyU->GetXaxis()->SetTitle("ladder number");
223  m_hOccupancyU->GetXaxis()->SetLabelSize(0.04);
224  for (unsigned short i = 0; i < nY; i++) m_hOccupancyU->GetYaxis()->SetBinLabel(i + 1, Ylabels[i].Data());
225 
226  m_hOnlineOccupancyV = new TH2F("hOnlineOccupancyV", "Average ONLINE Sensor Occupancy (%), V side ", 16, 0.5, 16.5, 19, 0, 19);
227  m_hOnlineOccupancyV->SetMarkerSize(1.1);
228  m_hOnlineOccupancyV->GetXaxis()->SetTitle("ladder number");
229  m_hOnlineOccupancyV->GetXaxis()->SetLabelSize(0.04);
230  for (unsigned short i = 0; i < nY; i++) m_hOnlineOccupancyV->GetYaxis()->SetBinLabel(i + 1, Ylabels[i].Data());
231 
232  m_hOnlineOccupancyU = new TH2F("hOnlineOccupancyU", "Average ONLINE Sensor Occupancy (%), U side ", 16, 0.5, 16.5, 19, 0, 19);
233  m_hOnlineOccupancyU->SetMarkerSize(1.1);
234  m_hOnlineOccupancyU->GetXaxis()->SetTitle("ladder number");
235  m_hOnlineOccupancyU->GetXaxis()->SetLabelSize(0.04);
236  for (unsigned short i = 0; i < nY; i++) m_hOnlineOccupancyU->GetYaxis()->SetBinLabel(i + 1, Ylabels[i].Data());
237 
238  rtype = findHist("DQMInfo/rtype");
239  runtype = rtype ? rtype->GetTitle() : "";
240 }
241 
242 
243 void DQMHistAnalysisSVDGeneralModule::beginRun()
244 {
245  B2INFO("DQMHistAnalysisSVDGeneral: beginRun called.");
246  m_cUnpacker->Clear();
247  m_cOccupancyU->Clear();
248  m_cOccupancyV->Clear();
249  m_cOnlineOccupancyU->Clear();
250  m_cOnlineOccupancyV->Clear();
251  m_cOccupancyChartChip->Clear();
252  for (unsigned int i = 0; i < m_SVDModules.size(); i++) {
253  m_cStripOccupancyU[i]->Clear();
254  m_cStripOccupancyV[i]->Clear();
255  }
256  m_cClusterOnTrackTime_L456V->Clear();
257 }
258 
259 void DQMHistAnalysisSVDGeneralModule::event()
260 {
261 
262  //SETUP gSTYLE - all plots
263  // gStyle->SetOptStat(0);
264  // gStyle->SetTitleY(.97);
265 
266  //find nEvents
267  TH1* hnEvnts = findHist("SVDExpReco/SVDDQM_nEvents");
268  if (hnEvnts == NULL) {
269  B2INFO("no events, nothing to do here");
270  return;
271  }
272  TString runID = TString((hnEvnts->GetTitle())).Remove(0, 21);
273  B2INFO("runID = " << runID);
274  Float_t nEvents = hnEvnts->GetEntries();
275 
276  //check DATA FORMAT
277  TH1* h = findHist("SVDUnpacker/DQMUnpackerHisto");
278 
279  //test ERROR:
280  // h->SetBinContent(100,0.01);
281 
282  if (h != NULL) {
283  h->SetTitle("SVD Data Format Monitor " + runID);
284  //check if number of errors is above the allowed limit
285  bool hasError = false;
286  for (int un = 0; un < h->GetNcells(); un++)
287  if (h->GetBinContent(un) / nEvents > m_unpackError)
288  hasError = true;
289  if (! hasError) {
290  m_cUnpacker->SetFillColor(kGreen);
291  m_cUnpacker->SetFrameFillColor(10);
292  } else {
293  m_legError->Draw("same");
294  m_cUnpacker->SetFillColor(kRed);
295  m_cUnpacker->SetFrameFillColor(10);
296  }
297  } else {
298  B2INFO("Histogram SVDUnpacker/DQMUnpackerHisto from SVDUnpackerDQM not found!");
299  m_cUnpacker->SetFillColor(kRed);
300  }
301 
302  m_cUnpacker->cd();
303  h->Draw("colztext");
304  h->SetStats(0);
305 
306  m_cUnpacker->Modified();
307  m_cUnpacker->Update();
308 
309  if (m_printCanvas)
310  m_cUnpacker->Print("c_SVDDataFormat.pdf");
311 
312  //occupancy chart
313  TH1F* hChart = (TH1F*)findHist("SVDExpReco/SVDDQM_StripCountsChip");
314 
315  if (hChart != NULL) {
316  m_hOccupancyChartChip.Clear();
317  hChart->Copy(m_hOccupancyChartChip);
318  m_hOccupancyChartChip.SetName("SVDOccupancyChart");
319  m_hOccupancyChartChip.SetTitle("SVD OFFLINE Occupancy per chip " + runID);
320  m_hOccupancyChartChip.Scale(1 / nEvents / 128);
321  m_cOccupancyChartChip->cd();
322  // m_hOccupancyChartChip->SetStats(0);
323  m_hOccupancyChartChip.Draw();
324  }
325  m_cOccupancyChartChip->Modified();
326  m_cOccupancyChartChip->Update();
327 
328  if (m_printCanvas)
329  m_cOccupancyChartChip->Print("c_OccupancyChartChip.pdf");
330 
331  // cluster time for clusters of track
332  TH1* m_h = findHist("SVDClsTrk/SVDTRK_ClusterTimeV456");
333  if (m_h != NULL) {
334  m_hClusterOnTrackTime_L456V.Clear();
335  m_h->Copy(m_hClusterOnTrackTime_L456V);
336  m_hClusterOnTrackTime_L456V.GetXaxis()->SetRange(110, 190); // [-40 ns,40 ns]
337  Float_t mean_PeakInCenter = m_hClusterOnTrackTime_L456V.GetMean(); //
338  m_hClusterOnTrackTime_L456V.GetXaxis()->SetRange(); // back to [-150 ns,150 ns]
339  m_hClusterOnTrackTime_L456V.SetTitle("ClusterOnTrack Time L456V " + runID);
340  bool hasError = false;
341  if (nEvents > m_statThreshold) {
342  if (runtype == "physics") {
343  Float_t difference_physics = fabs(mean_PeakInCenter - m_refMeanP);
344  if (difference_physics > m_timeThreshold) {
345  hasError = true;
346  }
347  } else if (runtype == "cosmic") {
348  Float_t difference_cosmic = fabs(mean_PeakInCenter - m_refMeanC);
349  if (difference_cosmic > m_timeThreshold) {
350  hasError = true;
351  }
352  } else {
353  B2WARNING("Run type:" << runtype);
354  }
355  } else {
356  m_cClusterOnTrackTime_L456V->SetFillColor(kGray);
357  m_cClusterOnTrackTime_L456V->SetFrameFillColor(10);
358  }
359  if (! hasError) {
360  m_cClusterOnTrackTime_L456V->SetFillColor(kGreen);
361  m_cClusterOnTrackTime_L456V->SetFrameFillColor(10);
362  } else {
363  m_legError->Draw("same");
364  m_cClusterOnTrackTime_L456V->SetFillColor(kRed);
365  m_cClusterOnTrackTime_L456V->SetFrameFillColor(10);
366  }
367  } else {
368  B2INFO("Histogram SVDClsTrk/c_SVDTRK_ClusterTimeV456 from SVDDQMClustersOnTrack module not found!");
369  m_cClusterOnTrackTime_L456V->SetFillColor(kRed);
370  }
371 
372  m_cClusterOnTrackTime_L456V->cd();
373  m_hClusterOnTrackTime_L456V.Draw();
374 
375  m_cClusterOnTrackTime_L456V->Modified();
376  m_cClusterOnTrackTime_L456V->Update();
377 
378  if (m_printCanvas)
379  m_cClusterOnTrackTime_L456V->Print("c_SVDClusterOnTrackTime_L456V.pdf");
380 
381  //check MODULE OCCUPANCY online & offline
382 
383  //reset canvas color
384  m_occUstatus = 0;
385  m_occVstatus = 0;
386  m_onlineOccUstatus = 0;
387  m_onlineOccVstatus = 0;
388 
389  //update titles with exp and run number
390  m_hOccupancyU->SetTitle("Average OFFLINE Sensor Occupancy (%), U side " + runID);
391  m_hOccupancyU->SetStats(0);
392  m_hOccupancyV->SetTitle("Average OFFLINE Sensor Occupancy (%), V side " + runID);
393  m_hOccupancyV->SetStats(0);
394 
395  m_hOnlineOccupancyU->SetTitle("Average ONLINE Sensor Occupancy (%), U side " + runID);
396  m_hOnlineOccupancyU->SetStats(0);
397  m_hOnlineOccupancyV->SetTitle("Average ONLINE Sensor Occupancy (%), V side " + runID);
398  m_hOnlineOccupancyV->SetStats(0);
399 
400 
401  //set dedicate gStyle
402  const Int_t colNum = 4;
403  Int_t palette[colNum] {kBlack, kGreen, kOrange, kRed};
404  gStyle->SetPalette(colNum, palette);
405  gStyle->SetOptStat(0);
406  gStyle->SetPaintTextFormat("2.3f");
407 
408  TH1F* htmp = NULL;
409 
410  for (unsigned int i = 0; i < m_SVDModules.size(); i++) {
411  int tmp_layer = m_SVDModules[i].getLayerNumber();
412  int tmp_ladder = m_SVDModules[i].getLadderNumber();
413  int tmp_sensor = m_SVDModules[i].getSensorNumber();
414 
415 
416  Int_t bin = m_hOccupancyU->FindBin(tmp_ladder, findBinY(tmp_layer, tmp_sensor));
417 
418  //look for U histogram - OFFLINE ZS
419  TString tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountU", tmp_layer, tmp_ladder, tmp_sensor);
420 
421  htmp = (TH1F*)findHist(tmpname.Data());
422  if (htmp == NULL) {
423  B2INFO("Occupancy U histogram not found");
424  m_cOccupancyU->SetFillColor(kRed);
425  } else {
426 
427  Int_t nStrips = 768;
428 
429  Float_t occU = htmp->GetEntries() / nStrips / nEvents * 100;
430  m_hOccupancyU->SetBinContent(bin, occU);
431 
432  //test ERRORS
433  /*
434  if(bin == m_hOccupancyU->FindBin(2, findBinY(3, 1))){
435  occU = 0; //0,1,1.5,1.8,2,3
436  m_hOccupancyU->SetBinContent(bin, occU);
437  }
438  */
439 
440  if (occU <= m_occEmpty) {
441  if (m_occUstatus < 1) m_occUstatus = 1;
442  } else if (occU > m_occWarning) {
443  if (occU < m_occError) {
444  if (m_occUstatus < 2) m_occUstatus = 2;
445  } else {
446  if (m_occUstatus < 3) m_occUstatus = 3;
447  }
448  }
449 
450  // B2INFO(" x = " << tmp_ladder << ", y = " << tmp_layer * 10 + tmp_sensor << " U occ = " << occU << " status = " << m_occUstatus);
451 
452  //produce the occupancy plot
453  m_hStripOccupancyU[i].Clear();
454  htmp->Copy(m_hStripOccupancyU[i]);
455  m_hStripOccupancyU[i].Scale(1 / nEvents);
456  m_hStripOccupancyU[i].SetName(Form("%d_%d_%d_OccupancyU", tmp_layer, tmp_ladder, tmp_sensor));
457  m_hStripOccupancyU[i].SetTitle(Form("SVD Sensor %d_%d_%d U-Strip OFFLINE Occupancy vs Strip Number", tmp_layer, tmp_ladder,
458  tmp_sensor));
459  }
460  //look for V histogram - OFFLINE ZS
461  tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_StripCountV", tmp_layer, tmp_ladder, tmp_sensor);
462 
463  htmp = (TH1F*)findHist(tmpname.Data());
464  if (htmp == NULL) {
465  B2INFO("Occupancy V histogram not found");
466  m_cOccupancyV->SetFillColor(kRed);
467  } else {
468 
469  Int_t nStrips = 768;
470  if (tmp_layer != 3)
471  nStrips = 512;
472 
473  Float_t occV = htmp->GetEntries() / nStrips / nEvents * 100;
474  m_hOccupancyV->SetBinContent(bin, occV);
475 
476  //test ERRORS
477  /*
478  if(bin == m_hOccupancyV->FindBin(3, findBinY(3, 1))){
479  occV = 1.8; //0,1,1.5,1.8,2,3
480  m_hOccupancyV->SetBinContent(bin, occV);
481  }
482  */
483 
484  if (occV <= m_occEmpty) {
485  if (m_occVstatus < 1) m_occVstatus = 1;
486  } else if (occV > m_occWarning) {
487  if (occV < m_occError) {
488  if (m_occVstatus < 2) m_occVstatus = 2;
489  } else {
490  if (m_occVstatus < 3) m_occVstatus = 3;
491  }
492  }
493  //produce the occupancy plot
494  m_hStripOccupancyV[i].Clear();
495  htmp->Copy(m_hStripOccupancyV[i]);
496  m_hStripOccupancyV[i].Scale(1 / nEvents);
497  m_hStripOccupancyV[i].SetName(Form("%d_%d_%d_OccupancyV", tmp_layer, tmp_ladder, tmp_sensor));
498  m_hStripOccupancyV[i].SetTitle(Form("SVD Sensor %d_%d_%d V-Strip OFFLINE Occupancy vs Strip Number", tmp_layer, tmp_ladder,
499  tmp_sensor));
500 
501  }
502  //look for V histogram - ONLINE ZS
503  tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStripCountV", tmp_layer, tmp_ladder, tmp_sensor);
504 
505  htmp = (TH1F*)findHist(tmpname.Data());
506  if (htmp == NULL) {
507  B2INFO("OnlineOccupancy V histogram not found");
508  m_cOnlineOccupancyV->SetFillColor(kRed);
509  } else {
510 
511  Int_t nStrips = 768;
512  if (tmp_layer != 3)
513  nStrips = 512;
514 
515  Float_t onlineOccV = htmp->GetEntries() / nStrips / nEvents * 100;
516  m_hOnlineOccupancyV->SetBinContent(bin, onlineOccV);
517 
518  for (int b = 1; b < htmp->GetNbinsX() + 1; b++) {
519  htmp->SetBinContent(b, htmp->GetBinContent(b) / nEvents * 100);
520  }
521  htmp->GetYaxis()->SetTitle("ZS3 ccupancy (%)");
522  //test ERRORS
523  /*
524  if(bin == m_hOnlineOccupancyV->FindBin(3, findBinY(3, 1))){
525  onlineOccV = 1.8; //0,1,1.5,1.8,2,3
526  m_hOnlineOccupancyV->SetBinContent(bin, onlineOccV);
527  }
528  */
529 
530  if (onlineOccV <= m_onlineOccEmpty) {
531  if (m_onlineOccVstatus < 1) m_onlineOccVstatus = 1;
532  } else if (onlineOccV > m_onlineOccWarning) {
533  if (onlineOccV < m_onlineOccError) {
534  if (m_onlineOccVstatus < 2) m_onlineOccVstatus = 2;
535  } else {
536  if (m_onlineOccVstatus < 3) m_onlineOccVstatus = 3;
537  }
538  }
539 
540 
541  }
542  //look for U histogram - ONLINE ZS
543  tmpname = Form("SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStripCountU", tmp_layer, tmp_ladder, tmp_sensor);
544 
545  htmp = (TH1F*)findHist(tmpname.Data());
546  if (htmp == NULL) {
547  B2INFO("OnlineOccupancy U histogram not found");
548  m_cOnlineOccupancyU->SetFillColor(kRed);
549  } else {
550 
551  Int_t nStrips = 768;
552 
553  Float_t onlineOccU = htmp->GetEntries() / nStrips / nEvents * 100;
554  m_hOnlineOccupancyU->SetBinContent(bin, onlineOccU);
555 
556  for (int b = 1; b < htmp->GetNbinsX() + 1; b++) {
557  htmp->SetBinContent(b, htmp->GetBinContent(b) / nEvents * 100);
558  }
559  htmp->GetYaxis()->SetTitle("ZS3 ccupancy (%)");
560  //test ERRORS
561  /*
562  if(bin == m_hOnlineOccupancyU->FindBin(3, findBinY(3, 1))){
563  onlineOccU = 1.8; //0,1,1.5,1.8,2,3
564  m_hOnlineOccupancyU->SetBinContent(bin, onlineOccU);
565  }
566  */
567 
568  if (onlineOccU <= m_onlineOccEmpty) {
569  if (m_onlineOccUstatus < 1) m_onlineOccUstatus = 1;
570  } else if (onlineOccU > m_onlineOccWarning) {
571  if (onlineOccU < m_onlineOccError) {
572  if (m_onlineOccUstatus < 2) m_onlineOccUstatus = 2;
573  } else {
574  if (m_onlineOccUstatus < 3) m_onlineOccUstatus = 3;
575  }
576  }
577 
578  //B2INFO(" x = " << tmp_ladder << ", y = " << tmp_layer * 10 + tmp_sensor << " V occ = " << occV << " status = " << m_occVstatus);
579  }
580 
581  //update sensor occupancy canvas U and V
582  m_cStripOccupancyU[i]->cd();
583  m_hStripOccupancyU[i].Draw("histo");
584  m_cStripOccupancyV[i]->cd();
585  m_hStripOccupancyV[i].Draw("histo");
586  }
587 
588  //update summary offline occupancy U canvas
589  m_cOccupancyU->cd();
590  m_hOccupancyU->Draw("text");
591  m_yTitle->Draw("same");
592 
593  if (m_occUstatus == 0) {
594  m_cOccupancyU->SetFillColor(kGreen);
595  m_cOccupancyU->SetFrameFillColor(10);
596  m_legNormal->Draw("same");
597  } else {
598  if (m_occUstatus == 3) {
599  m_cOccupancyU->SetFillColor(kRed);
600  m_cOccupancyU->SetFrameFillColor(10);
601  m_legProblem->Draw("same");
602  }
603  if (m_occUstatus == 2) {
604  m_cOccupancyU->SetFillColor(kOrange);
605  m_cOccupancyU->SetFrameFillColor(10);
606  m_legWarning->Draw("same");
607  }
608  if (m_occUstatus == 1) {
609  m_cOccupancyU->SetFillColor(kGray);
610  m_cOccupancyU->SetFrameFillColor(10);
611  m_legEmpty->Draw("same");
612  }
613  }
614  m_cOccupancyU->Draw();
615  m_cOccupancyU->Update();
616  m_cOccupancyU->Modified();
617  m_cOccupancyU->Update();
618 
619 
620  //update summary offline occupancy V canvas
621  m_cOccupancyV->cd();
622  m_hOccupancyV->Draw("text");
623  m_yTitle->Draw("same");
624 
625  if (m_occVstatus == 0) {
626  m_cOccupancyV->SetFillColor(kGreen);
627  m_cOccupancyV->SetFrameFillColor(10);
628  m_legNormal->Draw("same");
629  } else {
630  if (m_occVstatus == 3) {
631  m_cOccupancyV->SetFillColor(kRed);
632  m_cOccupancyV->SetFrameFillColor(10);
633  m_legProblem->Draw("same");
634  }
635  if (m_occVstatus == 2) {
636  m_cOccupancyV->SetFillColor(kOrange);
637  m_cOccupancyV->SetFrameFillColor(10);
638  m_legWarning->Draw("same");
639  }
640  if (m_occVstatus == 1) {
641  m_cOccupancyV->SetFillColor(kGray);
642  m_cOccupancyV->SetFrameFillColor(10);
643  m_legEmpty->Draw("same");
644  }
645  }
646 
647  m_cOccupancyV->Draw();
648  m_cOccupancyV->Update();
649  m_cOccupancyV->Modified();
650  m_cOccupancyV->Update();
651 
652  //update summary online occupancy U canvas
653  m_cOnlineOccupancyU->cd();
654  m_hOnlineOccupancyU->Draw("text");
655  m_yTitle->Draw("same");
656 
657  if (m_onlineOccUstatus == 0) {
658  m_cOnlineOccupancyU->SetFillColor(kGreen);
659  m_cOnlineOccupancyU->SetFrameFillColor(10);
660  m_legOnNormal->Draw("same");
661  } else {
662  if (m_onlineOccUstatus == 3) {
663  m_cOnlineOccupancyU->SetFillColor(kRed);
664  m_cOnlineOccupancyU->SetFrameFillColor(10);
665  m_legOnProblem->Draw("same");
666  }
667  if (m_onlineOccUstatus == 2) {
668  m_cOnlineOccupancyU->SetFillColor(kOrange);
669  m_cOnlineOccupancyU->SetFrameFillColor(10);
670  m_legOnWarning->Draw("same");
671  }
672  if (m_onlineOccUstatus == 1) {
673  m_cOnlineOccupancyU->SetFillColor(kGray);
674  m_cOnlineOccupancyU->SetFrameFillColor(10);
675  m_legOnEmpty->Draw("same");
676  }
677  }
678 
679  m_cOnlineOccupancyU->Draw();
680  m_cOnlineOccupancyU->Update();
681  m_cOnlineOccupancyU->Modified();
682  m_cOnlineOccupancyU->Update();
683 
684  //update summary online occupancy V canvas
685  m_cOnlineOccupancyV->cd();
686  m_hOnlineOccupancyV->Draw("text");
687  m_yTitle->Draw("same");
688 
689  if (m_onlineOccVstatus == 0) {
690  m_cOnlineOccupancyV->SetFillColor(kGreen);
691  m_cOnlineOccupancyV->SetFrameFillColor(10);
692  m_legOnNormal->Draw("same");
693  } else {
694  if (m_onlineOccVstatus == 3) {
695  m_cOnlineOccupancyV->SetFillColor(kRed);
696  m_cOnlineOccupancyV->SetFrameFillColor(10);
697  m_legOnProblem->Draw("same");
698  }
699  if (m_onlineOccVstatus == 2) {
700  m_cOnlineOccupancyV->SetFillColor(kOrange);
701  m_cOnlineOccupancyV->SetFrameFillColor(10);
702  m_legOnWarning->Draw("same");
703  }
704  if (m_onlineOccVstatus == 1) {
705  m_cOnlineOccupancyV->SetFillColor(kGray);
706  m_cOnlineOccupancyV->SetFrameFillColor(10);
707  m_legOnEmpty->Draw("same");
708  }
709  }
710 
711  m_cOnlineOccupancyV->Draw();
712  m_cOnlineOccupancyV->Update();
713  m_cOnlineOccupancyV->Modified();
714  m_cOnlineOccupancyV->Update();
715 
716  if (m_printCanvas) {
717  m_cOccupancyU->Print("c_SVDOccupancyU.pdf");
718  m_cOccupancyV->Print("c_SVDOccupancyV.pdf");
719  m_cOnlineOccupancyU->Print("c_SVDOnlineOccupancyU.pdf");
720  m_cOnlineOccupancyV->Print("c_SVDOnlineOccupancyV.pdf");
721  }
722 
723 }
724 
725 void DQMHistAnalysisSVDGeneralModule::endRun()
726 {
727  B2INFO("DQMHistAnalysisSVDGeneral: endRun called");
728 }
729 
730 
731 void DQMHistAnalysisSVDGeneralModule::terminate()
732 {
733  B2INFO("DQMHistAnalysisSVDGeneral: terminate called");
734 
735  delete m_refFile;
736  delete m_legProblem;
737  delete m_legWarning;
738  delete m_legNormal;
739  delete m_legEmpty;
740  delete m_legError;
741  delete m_legOnProblem;
742  delete m_legOnWarning;
743  delete m_legOnNormal;
744  delete m_legOnEmpty;
745  delete m_legOnError;
746  delete m_yTitle;
747 
748  delete m_cUnpacker;
749 
750  delete m_hOccupancyU;
751  delete m_cOccupancyU;
752  delete m_hOccupancyV;
753  delete m_cOccupancyV;
754 
755  delete m_hOnlineOccupancyU;
756  delete m_cOnlineOccupancyU;
757  delete m_hOnlineOccupancyV;
758  delete m_cOnlineOccupancyV;
759 
760  delete m_cOccupancyChartChip;
761 
762  for (int module = 0; module < nSensors; module++) {
763  delete m_cStripOccupancyU[module];
764  delete m_cStripOccupancyV[module];
765  }
766 
767  delete m_cStripOccupancyU;
768  delete m_cStripOccupancyV;
769 
770  delete m_cClusterOnTrackTime_L456V;
771 }
772 
773 Int_t DQMHistAnalysisSVDGeneralModule::findBinY(Int_t layer, Int_t sensor)
774 {
775  if (layer == 3)
776  return sensor; //2
777  if (layer == 4)
778  return 2 + 1 + sensor; //6
779  if (layer == 5)
780  return 6 + 1 + sensor; // 11
781  if (layer == 6)
782  return 11 + 1 + sensor; // 17
783  else
784  return -1;
785 }
786 
The base class for the histogram analysis module.
Class definition for the output module of Sequential ROOT I/O.
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:58
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:66
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
#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.