Belle II Software  release-08-01-10
DQMHistInjection.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 : DQMHistInjection.cc
10 // Description : DQM module, which gives histograms showing occupancies after injection
11 //-
12 
13 
14 #include <dqm/analysis/modules/DQMHistInjection.h>
15 #include <klm/dataobjects/KLMElementNumbers.h>
16 #include <TROOT.h>
17 
18 using namespace std;
19 using namespace Belle2;
20 
21 //-----------------------------------------------------------------
22 // Register the Module
23 //-----------------------------------------------------------------
24 REG_MODULE(DQMHistInjection);
25 
26 //-----------------------------------------------------------------
27 // Implementation
28 //-----------------------------------------------------------------
29 
30 DQMHistInjectionModule::DQMHistInjectionModule() : DQMHistAnalysisModule()
31 {
32  // This module CAN NOT be run in parallel!
33 
34 // addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms were placed", std::string("PXDINJ"));
35  addParam("PVPrefix", m_pvPrefix, "PV Prefix", std::string("DQM:INJ:"));
36  B2DEBUG(1, "DQMHistInjection: Constructor done.");
37 }
38 
40 {
41 #ifdef _BELLE2_EPICS
42  if (getUseEpics()) {
43  if (ca_current_context()) ca_context_destroy();
44  }
45 #endif
46 }
47 
49 {
50 
51  gROOT->cd(); // this seems to be important, or strange things happen
52 
53  m_cInjectionLERPXD = new TCanvas("PXDINJ/c_InjectionLERPXD");
54  m_cInjectionLERPXDOcc = new TCanvas("PXDINJ/c_InjectionLERPXDOcc");
55  m_cInjectionLERSVD = new TCanvas("SVDInjection/c_InjectionLERSVD");
56  m_cInjectionLERSVDOcc = new TCanvas("SVDInjection/c_InjectionLERSVDOcc");
57  m_cInjectionLERECL = new TCanvas("ECLINJ/c_InjectionLERECL");
58  m_cBurstLERECL = new TCanvas("ECLINJ/c_BurstInjectionLERECL");
59  m_cInjectionLERTOP = new TCanvas("TOP/c_InjectionLERTOP");
60  m_cInjectionLERARICH = new TCanvas("ARICH/c_InjectionLERARICH");
61  m_cInjectionLERKLM = new TCanvas("KLM/c_InjectionLERKLM");
62 
63  m_cInjectionHERPXD = new TCanvas("PXDINJ/c_InjectionHERPXD");
64  m_cInjectionHERPXDOcc = new TCanvas("PXDINJ/c_InjectionHERPXDOcc");
65  m_cInjectionHERSVD = new TCanvas("SVDInjection/c_InjectionHERSVD");
66  m_cInjectionHERSVDOcc = new TCanvas("SVDInjection/c_InjectionHERSVDOcc");
67  m_cInjectionHERECL = new TCanvas("ECLINJ/c_InjectionHERECL");
68  m_cBurstHERECL = new TCanvas("ECLINJ/c_BurstInjectionHERECL");
69  m_cInjectionHERTOP = new TCanvas("TOP/c_InjectionHERTOP");
70  m_cInjectionHERARICH = new TCanvas("ARICH/c_InjectionHERARICH");
71  m_cInjectionHERKLM = new TCanvas("KLM/c_InjectionHERKLM");
72 
73  m_hInjectionLERPXD = new TH1F("HitInjectionLERPXD", "PXD Hits after LER Injection;Time in #mus;Mean Hits/event", 4000, 0, 20000);
74  m_hInjectionLERPXDOcc = new TH1F("HitInjectionPXDLEROcc", "PXD Occ after LER Injection;Time in #mus;Mean Occ in % per module", 4000,
75  0, 20000);
76  m_hInjectionLERSVD = new TH1F("HitInjectionLERSVD", "SVD Hits after LER Injection;Time in #mus;Mean Hits/event", 4000, 0, 20000);
77  m_hInjectionLERSVDOcc = new TH1F("HitInjectionSVDLEROcc", "SVD Occ after LER Injection;Time in #mus;Mean Occ in % per module", 4000,
78  0, 20000);
79  m_hInjectionLERECL = new TH1F("HitInjectionLERECL", "ECL Hits after LER Injection;Time in #mus;Mean Hits/event", 4000, 0, 20000);
80  m_hBurstLERECL = new TH1F("BurstInjectionLERECL", "ECL Bursts after LER Injection;Time in #mus;Suppressions/event (1 #mus bins)",
81  20000, 0, 20000);
82  m_hInjectionLERTOP = new TH1F("HitInjectionLERTOP", "TOP Occ after LER Injection;Time in #mus;Mean Occ in % /event", 4000, 0,
83  20000);
84  m_hInjectionLERARICH = new TH1F("HitInjectionLERARICH", "ARICH Occ after LER Injection;Time in #mus;Mean Hits/event", 4000, 0,
85  20000);
86  m_hInjectionLERKLM = new TH1F("HitInjectionLERKLM",
87  "KLM occupancy after LER Injection;Time [#mus];Digits occupancy in % / (5 #mus)", 4000, 0,
88  20000);
89 
90  m_hInjectionHERPXD = new TH1F("HitInjectionHERPXD", "PXD Hits after HER Injection;Time in #mus;Mean Hits/event", 4000, 0, 20000);
91  m_hInjectionHERPXDOcc = new TH1F("HitInjectionPXDHEROcc", "PXD Occ after HER Injection;Time in #mus;Mean Occ in % per modul", 4000,
92  0, 20000);
93  m_hInjectionHERSVD = new TH1F("HitInjectionHERSVD", "SVD Hits after HER Injection;Time in #mus;Mean Hits/event", 4000, 0, 20000);
94  m_hInjectionHERSVDOcc = new TH1F("HitInjectionSVDHEROcc", "SVD Occ after HER Injection;Time in #mus;Mean Occ in % per modul", 4000,
95  0, 20000);
96  m_hInjectionHERECL = new TH1F("HitInjectionHERECL", "ECL Hits after HER Injection;Time in #mus;Mean Hits/event", 4000, 0, 20000);
97  m_hBurstHERECL = new TH1F("BurstInjectionHERECL", "ECL Bursts after HER Injection;Time in #mus;Suppressions/event (1 #mus bins)",
98  20000, 0, 20000);
99  m_hInjectionHERTOP = new TH1F("HitInjectionHERTOP", "TOP Occ after HER Injection;Time in #mus;Mean Occ in % /event", 4000, 0,
100  20000);
101  m_hInjectionHERARICH = new TH1F("HitInjectionHERARICH", "ARICH Occ after HER Injection;Time in #mus;Mean Hits/event", 4000, 0,
102  20000);
103  m_hInjectionHERKLM = new TH1F("HitInjectionHERKLM",
104  "KLM occupancy after HER Injection;Time [#mus];Digits occupancy in % / (5 #mus)", 4000, 0,
105  20000);
106 
107 #ifdef _BELLE2_EPICS
108  if (getUseEpics()) {
109  if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback), "ca_context_create");
110  m_nodes.resize(14);
111  SEVCHK(ca_create_channel((m_pvPrefix + "LER:Triggers").data(), NULL, NULL, 10, &m_nodes[0].mychid), "ca_create_channel failure");
112  m_nodes[0].histo = nullptr;
113  SEVCHK(ca_create_channel((m_pvPrefix + "LER:PXD").data(), NULL, NULL, 10, &m_nodes[1].mychid), "ca_create_channel failure");
114  m_nodes[1].histo = m_hInjectionLERPXD;
115  SEVCHK(ca_create_channel((m_pvPrefix + "LER:ECL").data(), NULL, NULL, 10, &m_nodes[2].mychid), "ca_create_channel failure");
116  m_nodes[2].histo = m_hInjectionLERECL;
117  SEVCHK(ca_create_channel((m_pvPrefix + "HER:Triggers").data(), NULL, NULL, 10, &m_nodes[3].mychid), "ca_create_channel failure");
118  m_nodes[3].histo = nullptr;
119  SEVCHK(ca_create_channel((m_pvPrefix + "HER:PXD").data(), NULL, NULL, 10, &m_nodes[4].mychid), "ca_create_channel failure");
120  m_nodes[4].histo = m_hInjectionHERPXD;
121  SEVCHK(ca_create_channel((m_pvPrefix + "HER:ECL").data(), NULL, NULL, 10, &m_nodes[5].mychid), "ca_create_channel failure");
122  m_nodes[5].histo = m_hInjectionHERECL;
123  SEVCHK(ca_create_channel((m_pvPrefix + "LER:TOP").data(), NULL, NULL, 10, &m_nodes[6].mychid), "ca_create_channel failure");
124  m_nodes[6].histo = m_hInjectionLERTOP;
125  SEVCHK(ca_create_channel((m_pvPrefix + "HER:TOP").data(), NULL, NULL, 10, &m_nodes[7].mychid), "ca_create_channel failure");
126  m_nodes[7].histo = m_hInjectionHERTOP;
127  SEVCHK(ca_create_channel((m_pvPrefix + "LER:SVD").data(), NULL, NULL, 10, &m_nodes[8].mychid), "ca_create_channel failure");
128  m_nodes[8].histo = m_hInjectionLERSVD;
129  SEVCHK(ca_create_channel((m_pvPrefix + "HER:SVD").data(), NULL, NULL, 10, &m_nodes[9].mychid), "ca_create_channel failure");
130  m_nodes[9].histo = m_hInjectionHERSVD;
131  SEVCHK(ca_create_channel((m_pvPrefix + "LER:ARICH").data(), NULL, NULL, 10, &m_nodes[10].mychid), "ca_create_channel failure");
132  m_nodes[10].histo = m_hInjectionLERARICH;
133  SEVCHK(ca_create_channel((m_pvPrefix + "HER:ARICH").data(), NULL, NULL, 10, &m_nodes[11].mychid), "ca_create_channel failure");
134  m_nodes[11].histo = m_hInjectionHERARICH;
135  SEVCHK(ca_create_channel((m_pvPrefix + "LER:KLM").data(), NULL, NULL, 10, &m_nodes[10].mychid), "ca_create_channel failure");
136  m_nodes[12].histo = m_hInjectionLERKLM;
137  SEVCHK(ca_create_channel((m_pvPrefix + "HER:KLM").data(), NULL, NULL, 10, &m_nodes[11].mychid), "ca_create_channel failure");
138  m_nodes[13].histo = m_hInjectionHERKLM;
139 
140  SEVCHK(ca_pend_io(5.0), "ca_pend_io failure");
141  cleanPVs();
142  }
143 #endif
144  B2DEBUG(1, "DQMHistInjection: initialized.");
145 }
146 
147 
149 {
150  B2DEBUG(1, "DQMHistInjection: beginRun called.");
151 
152 // m_cInjectionLERPXD->Clear(); // FIXME, unclear if this lets to crashes on new run?
153 // m_cInjectionLERPXDOcc->Clear();
154 // m_cInjectionLERECL->Clear();
155 // m_cInjectionHERPXD->Clear();
156 // m_cInjectionHERPXDOcc->Clear();
157 // m_cInjectionHERECL->Clear();
158 
159 // cleanPVs();
160 }
161 
162 
164 {
165  TH1* Hits = nullptr, *Triggers = nullptr;
166  TString locationHits = "";
167  TString locationTriggers = "";
168  //PXD
169  m_histogramDirectoryName = "PXDINJ";
170 
171  locationHits = "PXDOccInjLER";
172  locationHits = m_histogramDirectoryName + "/" + locationHits;
173  Hits = (TH1*)findHist(locationHits.Data());
174  locationTriggers = "PXDEOccInjLER";
175  if (m_histogramDirectoryName != "") {
176  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
177  }
178  Triggers = (TH1*)findHist(locationTriggers.Data());
179 
180  //Finding only one of them should only happen in very strange situations...
181  //m_nodes[0].histo = Triggers;
182  if (Hits && Triggers) {
183  m_hInjectionLERPXD->Divide(Hits, Triggers);
184  m_hInjectionLERPXDOcc->Divide(Hits, Triggers, 100, 768 * 250); // to percent
185  }
186 
187  m_cInjectionLERPXD->Clear();
188  m_cInjectionLERPXD->cd(0);
189  m_hInjectionLERPXD->Draw("hist");
190 
191  m_cInjectionLERPXDOcc->Clear();
192  m_cInjectionLERPXDOcc->cd(0);
193  m_hInjectionLERPXDOcc->Draw("hist");
194 
195  locationHits = "PXDOccInjHER";
196  if (m_histogramDirectoryName != "") {
197  locationHits = m_histogramDirectoryName + "/" + locationHits;
198  }
199  Hits = (TH1*)findHist(locationHits.Data());
200  locationTriggers = "PXDEOccInjHER";
201  if (m_histogramDirectoryName != "") {
202  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
203  }
204  Triggers = (TH1*)findHist(locationTriggers.Data());
205 
206  //Finding only one of them should only happen in very strange situations...
207  //m_nodes[3].histo = Triggers;
208  if (Hits && Triggers) {
209  m_hInjectionHERPXD->Divide(Hits, Triggers);
210  m_hInjectionHERPXDOcc->Divide(Hits, Triggers, 100, 768 * 250); // to percent
211  }
212 
213  m_cInjectionHERPXD->Clear();
214  m_cInjectionHERPXD->cd(0);
215  m_hInjectionHERPXD->Draw("hist");
216 
217  m_cInjectionHERPXDOcc->Clear();
218  m_cInjectionHERPXDOcc->cd(0);
219  m_hInjectionHERPXDOcc->Draw("hist");
220 
221  //SVD
222  m_histogramDirectoryName = "SVDInjection";
223 
224  locationHits = "SVDOccInjLER";
225  locationHits = m_histogramDirectoryName + "/" + locationHits;
226  Hits = (TH1*)findHist(locationHits.Data());
227  locationTriggers = "SVDTrgOccInjLER";
228  if (m_histogramDirectoryName != "") {
229  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
230  }
231  Triggers = (TH1*)findHist(locationTriggers.Data());
232 
233  //Finding only one of them should only happen in very strange situations...
234  //m_nodes[0].histo = Triggers;
235  if (Hits && Triggers) {
236  m_hInjectionLERSVD->Divide(Hits, Triggers);
237  m_hInjectionLERSVDOcc->Divide(Hits, Triggers, 100, 768 * 7 * 2); // to percent (L3V has 768 strips * 2 * 7 sides)
238  }
239 
240  m_cInjectionLERSVD->Clear();
241  m_cInjectionLERSVD->cd(0);
242  m_hInjectionLERSVD->Draw("hist");
243 
244  m_cInjectionLERSVDOcc->Clear();
245  m_cInjectionLERSVDOcc->cd(0);
246  m_hInjectionLERSVDOcc->Draw("hist");
247 
248  locationHits = "SVDOccInjHER";
249  if (m_histogramDirectoryName != "") {
250  locationHits = m_histogramDirectoryName + "/" + locationHits;
251  }
252  Hits = (TH1*)findHist(locationHits.Data());
253  locationTriggers = "SVDTrgOccInjHER";
254  if (m_histogramDirectoryName != "") {
255  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
256  }
257  Triggers = (TH1*)findHist(locationTriggers.Data());
258 
259  //Finding only one of them should only happen in very strange situations...
260  //m_nodes[3].histo = Triggers;
261  if (Hits && Triggers) {
262  m_hInjectionHERSVD->Divide(Hits, Triggers);
263  m_hInjectionHERSVDOcc->Divide(Hits, Triggers, 100, 768 * 2 * 7); // to percent (L3V has 768 strips * 2 * 7 sides)
264  }
265 
266  m_cInjectionHERSVD->Clear();
267  m_cInjectionHERSVD->cd(0);
268  m_hInjectionHERSVD->Draw("hist");
269 
270  m_cInjectionHERSVDOcc->Clear();
271  m_cInjectionHERSVDOcc->cd(0);
272  m_hInjectionHERSVDOcc->Draw("hist");
273 
274 
275  //ECL
276  m_histogramDirectoryName = "ECLINJ";
277 
278  locationHits = "ECLHitsInjLER";
279  locationHits = m_histogramDirectoryName + "/" + locationHits;
280  Hits = (TH1*)findHist(locationHits.Data());
281  locationTriggers = "ECLEHitsInjLER";
282  if (m_histogramDirectoryName != "") {
283  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
284  }
285  Triggers = (TH1*)findHist(locationTriggers.Data());
286 
287  //Finding only one of them should only happen in very strange situations...
288 #ifdef _BELLE2_EPICS
289  if (getUseEpics()) {
290  m_nodes[0].histo = Triggers;
291  }
292 #endif
293  if (Hits && Triggers) {
294  m_hInjectionLERECL->Divide(Hits, Triggers);
295  }
296 
297  m_cInjectionLERECL->Clear();
298  m_cInjectionLERECL->cd(0);
299  m_hInjectionLERECL->Draw("hist");
300 
301  locationHits = "ECLHitsInjHER";
302  if (m_histogramDirectoryName != "") {
303  locationHits = m_histogramDirectoryName + "/" + locationHits;
304  }
305  Hits = (TH1*)findHist(locationHits.Data());
306  locationTriggers = "ECLEHitsInjHER";
307  if (m_histogramDirectoryName != "") {
308  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
309  }
310  Triggers = (TH1*)findHist(locationTriggers.Data());
311 
312  //Finding only one of them should only happen in very strange situations...
313 #ifdef _BELLE2_EPICS
314  if (getUseEpics()) {
315  m_nodes[3].histo = Triggers;
316  }
317 #endif
318  if (Hits && Triggers) {
319  m_hInjectionHERECL->Divide(Hits, Triggers);
320  }
321 
322  m_cInjectionHERECL->Clear();
323  m_cInjectionHERECL->cd(0);
324  m_hInjectionHERECL->Draw("hist");
325 // =====
326  locationHits = "ECLBurstsInjLER";
327  if (m_histogramDirectoryName != "") {
328  locationHits = m_histogramDirectoryName + "/" + locationHits;
329  }
330  Hits = (TH1*)findHist(locationHits.Data());
331  locationTriggers = "ECLEBurstsInjLER";
332  if (m_histogramDirectoryName != "") {
333  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
334  }
335  Triggers = (TH1*)findHist(locationTriggers.Data());
336 
337  if (Hits && Triggers) {
338  m_hBurstLERECL->Divide(Hits, Triggers);
339  }
340 
341  m_cBurstLERECL->Clear();
342  m_cBurstLERECL->cd(0);
343  m_hBurstLERECL->Draw("hist");
344 // =====
345 
346  locationHits = "ECLBurstsInjHER";
347  if (m_histogramDirectoryName != "") {
348  locationHits = m_histogramDirectoryName + "/" + locationHits;
349  }
350  Hits = (TH1*)findHist(locationHits.Data());
351  locationTriggers = "ECLEBurstsInjHER";
352  if (m_histogramDirectoryName != "") {
353  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
354  }
355  Triggers = (TH1*)findHist(locationTriggers.Data());
356 
357  if (Hits && Triggers) {
358  m_hBurstHERECL->Divide(Hits, Triggers);
359  }
360 
361  m_cBurstHERECL->Clear();
362  m_cBurstHERECL->cd(0);
363  m_hBurstHERECL->Draw("hist");
364 // =====
365 
366 
367  //TOP
368  m_histogramDirectoryName = "TOP";
369 
370  locationHits = "TOPOccInjLER";
371  locationHits = m_histogramDirectoryName + "/" + locationHits;
372  Hits = (TH1*)findHist(locationHits.Data());
373  locationTriggers = "TOPEOccInjLER";
374  if (m_histogramDirectoryName != "") {
375  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
376  }
377  Triggers = (TH1*)findHist(locationTriggers.Data());
378 
379  if (Hits && Triggers) {
380  m_hInjectionLERTOP->Divide(Hits, Triggers, 100, 8192);
381  }
382 
383  m_cInjectionLERTOP->Clear();
384  m_cInjectionLERTOP->cd(0);
385  m_hInjectionLERTOP->Draw("hist");
386 
387  locationHits = "TOPOccInjHER";
388  if (m_histogramDirectoryName != "") {
389  locationHits = m_histogramDirectoryName + "/" + locationHits;
390  }
391  Hits = (TH1*)findHist(locationHits.Data());
392  locationTriggers = "TOPEOccInjHER";
393  if (m_histogramDirectoryName != "") {
394  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
395  }
396  Triggers = (TH1*)findHist(locationTriggers.Data());
397 
398  if (Hits && Triggers) {
399  m_hInjectionHERTOP->Divide(Hits, Triggers, 100, 8192);
400  }
401 
402  m_cInjectionHERTOP->Clear();
403  m_cInjectionHERTOP->cd(0);
404  m_hInjectionHERTOP->Draw("hist");
405 
406 
407 
408  //ARICH
409  m_histogramDirectoryName = "ARICH";
410 
411  locationHits = "ARICHOccInjLER";
412  locationHits = m_histogramDirectoryName + "/" + locationHits;
413  Hits = (TH1*)findHist(locationHits.Data());
414  locationTriggers = "ARICHEOccInjLER";
415  if (m_histogramDirectoryName != "") {
416  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
417  }
418  Triggers = (TH1*)findHist(locationTriggers.Data());
419 
420  if (Hits && Triggers) {
421  m_hInjectionLERARICH->Divide(Hits, Triggers);
422  }
423 
424  m_cInjectionLERARICH->Clear();
425  m_cInjectionLERARICH->cd(0);
426  m_hInjectionLERARICH->Draw("hist");
427 
428  locationHits = "ARICHOccInjHER";
429  if (m_histogramDirectoryName != "") {
430  locationHits = m_histogramDirectoryName + "/" + locationHits;
431  }
432  Hits = (TH1*)findHist(locationHits.Data());
433  locationTriggers = "ARICHEOccInjHER";
434  if (m_histogramDirectoryName != "") {
435  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
436  }
437  Triggers = (TH1*)findHist(locationTriggers.Data());
438 
439  if (Hits && Triggers) {
440  m_hInjectionHERARICH->Divide(Hits, Triggers);
441  }
442 
443  m_cInjectionHERARICH->Clear();
444  m_cInjectionHERARICH->cd(0);
445  m_hInjectionHERARICH->Draw("hist");
446 
447  // KLM
448  m_histogramDirectoryName = "KLM";
449 
450  locationHits = "KLMOccInjLER";
451  locationHits = m_histogramDirectoryName + "/" + locationHits;
452  Hits = (TH1*)findHist(locationHits.Data());
453  locationTriggers = "KLMTrigInjLER";
454  if (m_histogramDirectoryName != "") {
455  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
456  }
457  Triggers = (TH1*)findHist(locationTriggers.Data());
458 
459  if (Hits && Triggers) {
460  m_hInjectionLERKLM->Divide(Hits, Triggers, 100, KLMElementNumbers::getTotalChannelNumber());
461  }
462 
463  m_cInjectionLERKLM->Clear();
464  m_cInjectionLERKLM->cd(0);
465  m_hInjectionLERKLM->Draw("hist");
466 
467  locationHits = "KLMOccInjHER";
468  if (m_histogramDirectoryName != "") {
469  locationHits = m_histogramDirectoryName + "/" + locationHits;
470  }
471  Hits = (TH1*)findHist(locationHits.Data());
472  locationTriggers = "KLMTrigInjHER";
473  if (m_histogramDirectoryName != "") {
474  locationTriggers = m_histogramDirectoryName + "/" + locationTriggers;
475  }
476  Triggers = (TH1*)findHist(locationTriggers.Data());
477 
478  if (Hits && Triggers) {
479  m_hInjectionHERKLM->Divide(Hits, Triggers, 100, KLMElementNumbers::getTotalChannelNumber());
480  }
481 
482  m_cInjectionHERKLM->Clear();
483  m_cInjectionHERKLM->cd(0);
484  m_hInjectionHERKLM->Draw("hist");
485 
486 #ifdef _BELLE2_EPICS
487  if (getUseEpics()) {
488  for (auto& m : m_nodes) {
489  if (!m.mychid) continue;
490  int length = m.data.size();
491  if (length != int(ca_element_count(m.mychid)) && int(ca_element_count(m.mychid)) > 0) {
492  // FIXME, unclear why this is needed to prevent crashes on new run?
493  m.data.resize(int(ca_element_count(m.mychid)), 0.0);
494  length = m.data.size();
495  }
496  if (m.histo && m.histo->GetNcells() > 2 && length > 0 && length == int(ca_element_count(m.mychid))) {
497  // If bin count doesnt match, we loose bins but otherwise ca_array_put will complain
498  // We fill up the array with ZEROs otherwise
499  if (m.histo->GetDimension() == 1) {
500  int i = 0;
501  int nx = m.histo->GetNbinsX() + 1;
502  for (int x = 1; x < nx && i < length ; x++) {
503  m.data[i++] = m.histo->GetBinContent(x);
504  }
505 
506  } else if (m.histo->GetDimension() == 2) {
507  int i = 0;
508  int nx = m.histo->GetNbinsX() + 1;
509  int ny = m.histo->GetNbinsY() + 1;
510  for (int y = 1; y < ny && i < length; y++) {
511  for (int x = 1; x < nx && i < length ; x++) {
512  m.data[i++] = m.histo->GetBinContent(x, y);
513  }
514  }
515  }
516  SEVCHK(ca_array_put(DBR_DOUBLE, length, m.mychid, (void*)m.data.data()), "ca_put failure");
517  } else {
518  B2DEBUG(99, "Inj " << ca_name(m.mychid) << " , " << m.histo << " , " << (m.histo ? m.histo->GetNcells() : 0) << " , " << length <<
519  " , "
520  <<
521  ca_element_count(m.mychid));
522  }
523  }
524  SEVCHK(ca_pend_io(5.0), "ca_pend_io failure");
525  }
526 #endif
527 }
528 
530 {
531 #ifdef _BELLE2_EPICS
532  if (getUseEpics()) {
533  for (auto m : m_nodes) {
534  if (m.mychid) {
535  int length = int(ca_element_count(m.mychid));
536  if (length > 0) {
537  m.data.resize(length, 0.0);
538  SEVCHK(ca_array_put(DBR_DOUBLE, length, m.mychid, (void*)m.data.data()), "ca_put failure");
539  } else {
540  B2DEBUG(99, "clean: lenght " << ca_name(m.mychid));
541  }
542  } else {
543  B2DEBUG(99, "clean: chid " << ca_name(m.mychid));
544  }
545  }
546  }
547 #endif
548 }
549 
551 {
552  B2DEBUG(1, "DQMHistInjection: terminate called");
553 #ifdef _BELLE2_EPICS
554  if (getUseEpics()) {
555  for (auto m : m_nodes) {
556  SEVCHK(ca_clear_channel(m.mychid), "ca_clear_channel failure");
557  }
558  SEVCHK(ca_pend_io(5.0), "ca_pend_io failure");
559  }
560 #endif
561 }
562 
The base class for the histogram analysis module.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
bool getUseEpics(void)
Getter for EPICS usage.
void terminate(void) override final
This method is called at the end of the event processing.
TH1F * m_hInjectionLERKLM
KLM occupancy after LER injection.
TCanvas * m_cInjectionLERSVD
Final Canvas.
TCanvas * m_cInjectionLERECL
Final Canvas.
TCanvas * m_cInjectionHERPXDOcc
Final Canvas.
TCanvas * m_cBurstLERECL
Final Canvas.
TCanvas * m_cInjectionHERSVDOcc
Final Canvas.
TCanvas * m_cInjectionLERKLM
Canvas for KLM occupancy after LER injection.
TCanvas * m_cInjectionLERPXDOcc
Final Canvas.
void initialize(void) override final
Initializer.
TCanvas * m_cInjectionLERPXD
Final Canvas.
std::string m_pvPrefix
prefix for EPICS PVs
TCanvas * m_cBurstHERECL
Final Canvas.
TCanvas * m_cInjectionHERECL
Final Canvas.
void cleanPVs(void)
Clean up PVs.
TCanvas * m_cInjectionLERTOP
Final Canvas.
TCanvas * m_cInjectionHERTOP
Final Canvas.
TCanvas * m_cInjectionHERKLM
Canvas for KLM occupancy after HER injection.
std::string m_histogramDirectoryName
name of histogram directory
TH1F * m_hInjectionHERKLM
KLM occupancy after HER injection.
TCanvas * m_cInjectionHERARICH
Final Canvas.
TH1F * m_hInjectionHERSVDOcc
SVD Occ norm.
TCanvas * m_cInjectionLERARICH
Final Canvas.
TH1F * m_hInjectionHERPXDOcc
PXD Occ norm.
TCanvas * m_cInjectionLERSVDOcc
Final Canvas.
TH1F * m_hInjectionLERSVDOcc
SVD Occ norm.
TCanvas * m_cInjectionHERSVD
Final Canvas.
TH1F * m_hInjectionLERPXDOcc
PXD Occ norm.
TCanvas * m_cInjectionHERPXD
Final Canvas.
void beginRun(void) override final
Called when entering a new run.
void event(void) override final
This method is called for each event.
static constexpr int getTotalChannelNumber()
Get total number of channels.
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.