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