10 #include <dqm/analysis/modules/DQMHistInjection.h>
11 #include <klm/dataobjects/KLMElementNumbers.h>
31 addParam(
"PVPrefix", m_pvPrefix,
"PV Prefix", std::string(
"DQM:INJ:"));
32 addParam(
"useEpics", m_useEpics,
"useEpics",
true);
33 B2DEBUG(1,
"DQMHistInjection: Constructor done.");
36 DQMHistInjectionModule::~DQMHistInjectionModule()
40 if (ca_current_context()) ca_context_destroy();
45 void DQMHistInjectionModule::initialize()
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");
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");
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,
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,
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)",
79 m_hInjectionLERTOP =
new TH1F(
"HitInjectionLERTOP",
"TOP Occ after LER Injection;Time in #mus;Mean Occ in % /event", 4000, 0 ,
81 m_hInjectionLERARICH =
new TH1F(
"HitInjectionLERARICH",
"ARICH Occ after LER Injection;Time in #mus;Mean Hits/event", 4000, 0 ,
83 m_hInjectionLERKLM =
new TH1F(
"HitInjectionLERKLM",
84 "KLM occupancy after LER Injection;Time [#mus];Digits occupancy in % / (5 #mus)", 4000, 0 ,
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,
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,
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)",
96 m_hInjectionHERTOP =
new TH1F(
"HitInjectionHERTOP",
"TOP Occ after HER Injection;Time in #mus;Mean Occ in % /event", 4000, 0 ,
98 m_hInjectionHERARICH =
new TH1F(
"HitInjectionHERARICH",
"ARICH Occ after HER Injection;Time in #mus;Mean Hits/event", 4000, 0 ,
100 m_hInjectionHERKLM =
new TH1F(
"HitInjectionHERKLM",
101 "KLM occupancy after HER Injection;Time [#mus];Digits occupancy in % / (5 #mus)", 4000, 0 ,
106 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
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;
137 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
141 B2DEBUG(1,
"DQMHistInjection: initialized.");
145 void DQMHistInjectionModule::beginRun()
147 B2DEBUG(1,
"DQMHistInjection: beginRun called.");
160 void DQMHistInjectionModule::event()
162 TH1* Hits =
nullptr, *Triggers =
nullptr;
163 TString locationHits =
"";
164 TString locationTriggers =
"";
166 m_histogramDirectoryName =
"PXDINJ";
168 locationHits =
"PXDOccInjLER";
169 if (m_histogramDirectoryName !=
"") {
170 locationHits = m_histogramDirectoryName +
"/" + locationHits;
172 Hits = (TH1*)findHist(locationHits.Data());
173 locationTriggers =
"PXDEOccInjLER";
174 if (m_histogramDirectoryName !=
"") {
175 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
177 Triggers = (TH1*)findHist(locationTriggers.Data());
181 if (Hits && Triggers) {
182 m_hInjectionLERPXD->Divide(Hits, Triggers);
183 m_hInjectionLERPXDOcc->Divide(Hits, Triggers, 100, 768 * 250);
186 m_cInjectionLERPXD->Clear();
187 m_cInjectionLERPXD->cd(0);
188 m_hInjectionLERPXD->Draw(
"hist");
190 m_cInjectionLERPXDOcc->Clear();
191 m_cInjectionLERPXDOcc->cd(0);
192 m_hInjectionLERPXDOcc->Draw(
"hist");
194 locationHits =
"PXDOccInjHER";
195 if (m_histogramDirectoryName !=
"") {
196 locationHits = m_histogramDirectoryName +
"/" + locationHits;
198 Hits = (TH1*)findHist(locationHits.Data());
199 locationTriggers =
"PXDEOccInjHER";
200 if (m_histogramDirectoryName !=
"") {
201 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
203 Triggers = (TH1*)findHist(locationTriggers.Data());
207 if (Hits && Triggers) {
208 m_hInjectionHERPXD->Divide(Hits, Triggers);
209 m_hInjectionHERPXDOcc->Divide(Hits, Triggers, 100, 768 * 250);
212 m_cInjectionHERPXD->Clear();
213 m_cInjectionHERPXD->cd(0);
214 m_hInjectionHERPXD->Draw(
"hist");
216 m_cInjectionHERPXDOcc->Clear();
217 m_cInjectionHERPXDOcc->cd(0);
218 m_hInjectionHERPXDOcc->Draw(
"hist");
221 m_histogramDirectoryName =
"SVDInjection";
223 locationHits =
"SVDOccInjLER";
224 if (m_histogramDirectoryName !=
"") {
225 locationHits = m_histogramDirectoryName +
"/" + locationHits;
227 Hits = (TH1*)findHist(locationHits.Data());
228 locationTriggers =
"SVDTrgOccInjLER";
229 if (m_histogramDirectoryName !=
"") {
230 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
232 Triggers = (TH1*)findHist(locationTriggers.Data());
236 if (Hits && Triggers) {
237 m_hInjectionLERSVD->Divide(Hits, Triggers);
238 m_hInjectionLERSVDOcc->Divide(Hits, Triggers, 100, 768 * 7 * 2);
241 m_cInjectionLERSVD->Clear();
242 m_cInjectionLERSVD->cd(0);
243 m_hInjectionLERSVD->Draw(
"hist");
245 m_cInjectionLERSVDOcc->Clear();
246 m_cInjectionLERSVDOcc->cd(0);
247 m_hInjectionLERSVDOcc->Draw(
"hist");
249 locationHits =
"SVDOccInjHER";
250 if (m_histogramDirectoryName !=
"") {
251 locationHits = m_histogramDirectoryName +
"/" + locationHits;
253 Hits = (TH1*)findHist(locationHits.Data());
254 locationTriggers =
"SVDTrgOccInjHER";
255 if (m_histogramDirectoryName !=
"") {
256 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
258 Triggers = (TH1*)findHist(locationTriggers.Data());
262 if (Hits && Triggers) {
263 m_hInjectionHERSVD->Divide(Hits, Triggers);
264 m_hInjectionHERSVDOcc->Divide(Hits, Triggers, 100, 768 * 2 * 7);
267 m_cInjectionHERSVD->Clear();
268 m_cInjectionHERSVD->cd(0);
269 m_hInjectionHERSVD->Draw(
"hist");
271 m_cInjectionHERSVDOcc->Clear();
272 m_cInjectionHERSVDOcc->cd(0);
273 m_hInjectionHERSVDOcc->Draw(
"hist");
277 m_histogramDirectoryName =
"ECLINJ";
279 locationHits =
"ECLHitsInjLER";
280 if (m_histogramDirectoryName !=
"") {
281 locationHits = m_histogramDirectoryName +
"/" + locationHits;
283 Hits = (TH1*)findHist(locationHits.Data());
284 locationTriggers =
"ECLEHitsInjLER";
285 if (m_histogramDirectoryName !=
"") {
286 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
288 Triggers = (TH1*)findHist(locationTriggers.Data());
293 m_nodes[0].histo = Triggers;
296 if (Hits && Triggers) {
297 m_hInjectionLERECL->Divide(Hits, Triggers);
300 m_cInjectionLERECL->Clear();
301 m_cInjectionLERECL->cd(0);
302 m_hInjectionLERECL->Draw(
"hist");
304 locationHits =
"ECLHitsInjHER";
305 if (m_histogramDirectoryName !=
"") {
306 locationHits = m_histogramDirectoryName +
"/" + locationHits;
308 Hits = (TH1*)findHist(locationHits.Data());
309 locationTriggers =
"ECLEHitsInjHER";
310 if (m_histogramDirectoryName !=
"") {
311 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
313 Triggers = (TH1*)findHist(locationTriggers.Data());
318 m_nodes[3].histo = Triggers;
321 if (Hits && Triggers) {
322 m_hInjectionHERECL->Divide(Hits, Triggers);
325 m_cInjectionHERECL->Clear();
326 m_cInjectionHERECL->cd(0);
327 m_hInjectionHERECL->Draw(
"hist");
329 locationHits =
"ECLBurstsInjLER";
330 if (m_histogramDirectoryName !=
"") {
331 locationHits = m_histogramDirectoryName +
"/" + locationHits;
333 Hits = (TH1*)findHist(locationHits.Data());
334 locationTriggers =
"ECLEBurstsInjLER";
335 if (m_histogramDirectoryName !=
"") {
336 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
338 Triggers = (TH1*)findHist(locationTriggers.Data());
340 if (Hits && Triggers) {
341 m_hBurstLERECL->Divide(Hits, Triggers);
344 m_cBurstLERECL->Clear();
345 m_cBurstLERECL->cd(0);
346 m_hBurstLERECL->Draw(
"hist");
349 locationHits =
"ECLBurstsInjHER";
350 if (m_histogramDirectoryName !=
"") {
351 locationHits = m_histogramDirectoryName +
"/" + locationHits;
353 Hits = (TH1*)findHist(locationHits.Data());
354 locationTriggers =
"ECLEBurstsInjHER";
355 if (m_histogramDirectoryName !=
"") {
356 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
358 Triggers = (TH1*)findHist(locationTriggers.Data());
360 if (Hits && Triggers) {
361 m_hBurstHERECL->Divide(Hits, Triggers);
364 m_cBurstHERECL->Clear();
365 m_cBurstHERECL->cd(0);
366 m_hBurstHERECL->Draw(
"hist");
371 m_histogramDirectoryName =
"TOP";
373 locationHits =
"TOPOccInjLER";
374 if (m_histogramDirectoryName !=
"") {
375 locationHits = m_histogramDirectoryName +
"/" + locationHits;
377 Hits = (TH1*)findHist(locationHits.Data());
378 locationTriggers =
"TOPEOccInjLER";
379 if (m_histogramDirectoryName !=
"") {
380 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
382 Triggers = (TH1*)findHist(locationTriggers.Data());
384 if (Hits && Triggers) {
385 m_hInjectionLERTOP->Divide(Hits, Triggers, 100, 8192);
388 m_cInjectionLERTOP->Clear();
389 m_cInjectionLERTOP->cd(0);
390 m_hInjectionLERTOP->Draw(
"hist");
392 locationHits =
"TOPOccInjHER";
393 if (m_histogramDirectoryName !=
"") {
394 locationHits = m_histogramDirectoryName +
"/" + locationHits;
396 Hits = (TH1*)findHist(locationHits.Data());
397 locationTriggers =
"TOPEOccInjHER";
398 if (m_histogramDirectoryName !=
"") {
399 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
401 Triggers = (TH1*)findHist(locationTriggers.Data());
403 if (Hits && Triggers) {
404 m_hInjectionHERTOP->Divide(Hits, Triggers, 100, 8192);
407 m_cInjectionHERTOP->Clear();
408 m_cInjectionHERTOP->cd(0);
409 m_hInjectionHERTOP->Draw(
"hist");
414 m_histogramDirectoryName =
"ARICH";
416 locationHits =
"ARICHOccInjLER";
417 if (m_histogramDirectoryName !=
"") {
418 locationHits = m_histogramDirectoryName +
"/" + locationHits;
420 Hits = (TH1*)findHist(locationHits.Data());
421 locationTriggers =
"ARICHEOccInjLER";
422 if (m_histogramDirectoryName !=
"") {
423 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
425 Triggers = (TH1*)findHist(locationTriggers.Data());
427 if (Hits && Triggers) {
428 m_hInjectionLERARICH->Divide(Hits, Triggers);
431 m_cInjectionLERARICH->Clear();
432 m_cInjectionLERARICH->cd(0);
433 m_hInjectionLERARICH->Draw(
"hist");
435 locationHits =
"ARICHOccInjHER";
436 if (m_histogramDirectoryName !=
"") {
437 locationHits = m_histogramDirectoryName +
"/" + locationHits;
439 Hits = (TH1*)findHist(locationHits.Data());
440 locationTriggers =
"ARICHEOccInjHER";
441 if (m_histogramDirectoryName !=
"") {
442 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
444 Triggers = (TH1*)findHist(locationTriggers.Data());
446 if (Hits && Triggers) {
447 m_hInjectionHERARICH->Divide(Hits, Triggers);
450 m_cInjectionHERARICH->Clear();
451 m_cInjectionHERARICH->cd(0);
452 m_hInjectionHERARICH->Draw(
"hist");
455 m_histogramDirectoryName =
"KLM";
457 locationHits =
"KLMOccInjLER";
458 if (m_histogramDirectoryName !=
"") {
459 locationHits = m_histogramDirectoryName +
"/" + locationHits;
461 Hits = (TH1*)findHist(locationHits.Data());
462 locationTriggers =
"KLMTrigInjLER";
463 if (m_histogramDirectoryName !=
"") {
464 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
466 Triggers = (TH1*)findHist(locationTriggers.Data());
468 if (Hits && Triggers) {
469 m_hInjectionLERKLM->Divide(Hits, Triggers, 100, KLMElementNumbers::getTotalChannelNumber());
472 m_cInjectionLERKLM->Clear();
473 m_cInjectionLERKLM->cd(0);
474 m_hInjectionLERKLM->Draw(
"hist");
476 locationHits =
"KLMOccInjHER";
477 if (m_histogramDirectoryName !=
"") {
478 locationHits = m_histogramDirectoryName +
"/" + locationHits;
480 Hits = (TH1*)findHist(locationHits.Data());
481 locationTriggers =
"KLMTrigInjHER";
482 if (m_histogramDirectoryName !=
"") {
483 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
485 Triggers = (TH1*)findHist(locationTriggers.Data());
487 if (Hits && Triggers) {
488 m_hInjectionHERKLM->Divide(Hits, Triggers, 100, KLMElementNumbers::getTotalChannelNumber());
491 m_cInjectionHERKLM->Clear();
492 m_cInjectionHERKLM->cd(0);
493 m_hInjectionHERKLM->Draw(
"hist");
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) {
502 m.data.resize(
int(ca_element_count(m.mychid)), 0.0);
503 length = m.data.size();
505 if (m.histo && m.histo->GetNcells() > 2 && length > 0 && length == int(ca_element_count(m.mychid))) {
508 if (m.histo->GetDimension() == 1) {
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);
515 }
else if (m.histo->GetDimension() == 2) {
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);
525 SEVCHK(ca_array_put(DBR_DOUBLE, length, m.mychid, (
void*)m.data.data()),
"ca_put failure");
527 B2DEBUG(99,
"Inj " << ca_name(m.mychid) <<
" , " << m.histo <<
" , " << (m.histo ? m.histo->GetNcells() : 0) <<
" , " << length <<
530 ca_element_count(m.mychid));
533 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
538 void DQMHistInjectionModule::cleanPVs(
void)
542 for (
auto m : m_nodes) {
544 int length = int(ca_element_count(m.mychid));
546 m.data.resize(length, 0.0);
547 SEVCHK(ca_array_put(DBR_DOUBLE, length, m.mychid, (
void*)m.data.data()),
"ca_put failure");
549 B2DEBUG(99,
"clean: lenght " << ca_name(m.mychid));
552 B2DEBUG(99,
"clean: chid " << ca_name(m.mychid));
559 void DQMHistInjectionModule::terminate()
561 B2DEBUG(1,
"DQMHistInjection: terminate called");
564 for (
auto m : m_nodes) {
565 SEVCHK(ca_clear_channel(m.mychid),
"ca_clear_channel failure");
567 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");