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