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