10 #include <dqm/analysis/modules/DQMHistInjection.h>
30 addParam(
"PVPrefix", m_pvPrefix,
"PV Prefix", std::string(
"DQM:INJ:"));
31 addParam(
"useEpics", m_useEpics,
"useEpics",
true);
32 B2DEBUG(1,
"DQMHistInjection: Constructor done.");
35 DQMHistInjectionModule::~DQMHistInjectionModule()
39 if (ca_current_context()) ca_context_destroy();
44 void DQMHistInjectionModule::initialize()
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");
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");
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,
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,
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)",
78 m_hInjectionLERTOP =
new TH1F(
"HitInjectionLERTOP",
"TOP Occ after LER Injection;Time in #mus;Mean Occ in % /event", 4000, 0 ,
80 m_hInjectionLERARICH =
new TH1F(
"HitInjectionLERARICH",
"ARICH Occ after LER Injection;Time in #mus;Mean Hits/event", 4000, 0 ,
82 m_hInjectionLERKLM =
new TH1F(
"HitInjectionLERKLM",
"KLM Occ after LER Injection;Time in #mus;Mean Hits/event", 4000, 0 ,
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,
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,
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)",
94 m_hInjectionHERTOP =
new TH1F(
"HitInjectionHERTOP",
"TOP Occ after HER Injection;Time in #mus;Mean Occ in % /event", 4000, 0 ,
96 m_hInjectionHERARICH =
new TH1F(
"HitInjectionHERARICH",
"ARICH Occ after HER Injection;Time in #mus;Mean Hits/event", 4000, 0 ,
98 m_hInjectionHERKLM =
new TH1F(
"HitInjectionHERKLM",
"KLM Occ after HER Injection;Time in #mus;Mean Hits/event", 4000, 0 ,
103 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
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;
134 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
138 B2DEBUG(1,
"DQMHistInjection: initialized.");
142 void DQMHistInjectionModule::beginRun()
144 B2DEBUG(1,
"DQMHistInjection: beginRun called.");
157 void DQMHistInjectionModule::event()
159 TH1* Hits =
nullptr, *Triggers =
nullptr;
160 TString locationHits =
"";
161 TString locationTriggers =
"";
163 m_histogramDirectoryName =
"PXDINJ";
165 locationHits =
"PXDOccInjLER";
166 if (m_histogramDirectoryName !=
"") {
167 locationHits = m_histogramDirectoryName +
"/" + locationHits;
169 Hits = (TH1*)findHist(locationHits.Data());
170 locationTriggers =
"PXDEOccInjLER";
171 if (m_histogramDirectoryName !=
"") {
172 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
174 Triggers = (TH1*)findHist(locationTriggers.Data());
178 if (Hits && Triggers) {
179 m_hInjectionLERPXD->Divide(Hits, Triggers);
180 m_hInjectionLERPXDOcc->Divide(Hits, Triggers, 100, 768 * 250);
183 m_cInjectionLERPXD->Clear();
184 m_cInjectionLERPXD->cd(0);
185 m_hInjectionLERPXD->Draw(
"hist");
187 m_cInjectionLERPXDOcc->Clear();
188 m_cInjectionLERPXDOcc->cd(0);
189 m_hInjectionLERPXDOcc->Draw(
"hist");
191 locationHits =
"PXDOccInjHER";
192 if (m_histogramDirectoryName !=
"") {
193 locationHits = m_histogramDirectoryName +
"/" + locationHits;
195 Hits = (TH1*)findHist(locationHits.Data());
196 locationTriggers =
"PXDEOccInjHER";
197 if (m_histogramDirectoryName !=
"") {
198 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
200 Triggers = (TH1*)findHist(locationTriggers.Data());
204 if (Hits && Triggers) {
205 m_hInjectionHERPXD->Divide(Hits, Triggers);
206 m_hInjectionHERPXDOcc->Divide(Hits, Triggers, 100, 768 * 250);
209 m_cInjectionHERPXD->Clear();
210 m_cInjectionHERPXD->cd(0);
211 m_hInjectionHERPXD->Draw(
"hist");
213 m_cInjectionHERPXDOcc->Clear();
214 m_cInjectionHERPXDOcc->cd(0);
215 m_hInjectionHERPXDOcc->Draw(
"hist");
218 m_histogramDirectoryName =
"SVDInjection";
220 locationHits =
"SVDOccInjLER";
221 if (m_histogramDirectoryName !=
"") {
222 locationHits = m_histogramDirectoryName +
"/" + locationHits;
224 Hits = (TH1*)findHist(locationHits.Data());
225 locationTriggers =
"SVDTrgOccInjLER";
226 if (m_histogramDirectoryName !=
"") {
227 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
229 Triggers = (TH1*)findHist(locationTriggers.Data());
233 if (Hits && Triggers) {
234 m_hInjectionLERSVD->Divide(Hits, Triggers);
235 m_hInjectionLERSVDOcc->Divide(Hits, Triggers, 100, 768 * 7 * 2);
238 m_cInjectionLERSVD->Clear();
239 m_cInjectionLERSVD->cd(0);
240 m_hInjectionLERSVD->Draw(
"hist");
242 m_cInjectionLERSVDOcc->Clear();
243 m_cInjectionLERSVDOcc->cd(0);
244 m_hInjectionLERSVDOcc->Draw(
"hist");
246 locationHits =
"SVDOccInjHER";
247 if (m_histogramDirectoryName !=
"") {
248 locationHits = m_histogramDirectoryName +
"/" + locationHits;
250 Hits = (TH1*)findHist(locationHits.Data());
251 locationTriggers =
"SVDTrgOccInjHER";
252 if (m_histogramDirectoryName !=
"") {
253 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
255 Triggers = (TH1*)findHist(locationTriggers.Data());
259 if (Hits && Triggers) {
260 m_hInjectionHERSVD->Divide(Hits, Triggers);
261 m_hInjectionHERSVDOcc->Divide(Hits, Triggers, 100, 768 * 2 * 7);
264 m_cInjectionHERSVD->Clear();
265 m_cInjectionHERSVD->cd(0);
266 m_hInjectionHERSVD->Draw(
"hist");
268 m_cInjectionHERSVDOcc->Clear();
269 m_cInjectionHERSVDOcc->cd(0);
270 m_hInjectionHERSVDOcc->Draw(
"hist");
274 m_histogramDirectoryName =
"ECLINJ";
276 locationHits =
"ECLHitsInjLER";
277 if (m_histogramDirectoryName !=
"") {
278 locationHits = m_histogramDirectoryName +
"/" + locationHits;
280 Hits = (TH1*)findHist(locationHits.Data());
281 locationTriggers =
"ECLEHitsInjLER";
282 if (m_histogramDirectoryName !=
"") {
283 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
285 Triggers = (TH1*)findHist(locationTriggers.Data());
290 m_nodes[0].histo = Triggers;
293 if (Hits && Triggers) {
294 m_hInjectionLERECL->Divide(Hits, Triggers);
297 m_cInjectionLERECL->Clear();
298 m_cInjectionLERECL->cd(0);
299 m_hInjectionLERECL->Draw(
"hist");
301 locationHits =
"ECLHitsInjHER";
302 if (m_histogramDirectoryName !=
"") {
303 locationHits = m_histogramDirectoryName +
"/" + locationHits;
305 Hits = (TH1*)findHist(locationHits.Data());
306 locationTriggers =
"ECLEHitsInjHER";
307 if (m_histogramDirectoryName !=
"") {
308 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
310 Triggers = (TH1*)findHist(locationTriggers.Data());
315 m_nodes[3].histo = Triggers;
318 if (Hits && Triggers) {
319 m_hInjectionHERECL->Divide(Hits, Triggers);
322 m_cInjectionHERECL->Clear();
323 m_cInjectionHERECL->cd(0);
324 m_hInjectionHERECL->Draw(
"hist");
326 locationHits =
"ECLBurstsInjLER";
327 if (m_histogramDirectoryName !=
"") {
328 locationHits = m_histogramDirectoryName +
"/" + locationHits;
330 Hits = (TH1*)findHist(locationHits.Data());
331 locationTriggers =
"ECLEBurstsInjLER";
332 if (m_histogramDirectoryName !=
"") {
333 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
335 Triggers = (TH1*)findHist(locationTriggers.Data());
337 if (Hits && Triggers) {
338 m_hBurstLERECL->Divide(Hits, Triggers);
341 m_cBurstLERECL->Clear();
342 m_cBurstLERECL->cd(0);
343 m_hBurstLERECL->Draw(
"hist");
346 locationHits =
"ECLBurstsInjHER";
347 if (m_histogramDirectoryName !=
"") {
348 locationHits = m_histogramDirectoryName +
"/" + locationHits;
350 Hits = (TH1*)findHist(locationHits.Data());
351 locationTriggers =
"ECLEBurstsInjHER";
352 if (m_histogramDirectoryName !=
"") {
353 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
355 Triggers = (TH1*)findHist(locationTriggers.Data());
357 if (Hits && Triggers) {
358 m_hBurstHERECL->Divide(Hits, Triggers);
361 m_cBurstHERECL->Clear();
362 m_cBurstHERECL->cd(0);
363 m_hBurstHERECL->Draw(
"hist");
368 m_histogramDirectoryName =
"TOP";
370 locationHits =
"TOPOccInjLER";
371 if (m_histogramDirectoryName !=
"") {
372 locationHits = m_histogramDirectoryName +
"/" + locationHits;
374 Hits = (TH1*)findHist(locationHits.Data());
375 locationTriggers =
"TOPEOccInjLER";
376 if (m_histogramDirectoryName !=
"") {
377 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
379 Triggers = (TH1*)findHist(locationTriggers.Data());
381 if (Hits && Triggers) {
382 m_hInjectionLERTOP->Divide(Hits, Triggers, 100, 8192);
385 m_cInjectionLERTOP->Clear();
386 m_cInjectionLERTOP->cd(0);
387 m_hInjectionLERTOP->Draw(
"hist");
389 locationHits =
"TOPOccInjHER";
390 if (m_histogramDirectoryName !=
"") {
391 locationHits = m_histogramDirectoryName +
"/" + locationHits;
393 Hits = (TH1*)findHist(locationHits.Data());
394 locationTriggers =
"TOPEOccInjHER";
395 if (m_histogramDirectoryName !=
"") {
396 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
398 Triggers = (TH1*)findHist(locationTriggers.Data());
400 if (Hits && Triggers) {
401 m_hInjectionHERTOP->Divide(Hits, Triggers, 100, 8192);
404 m_cInjectionHERTOP->Clear();
405 m_cInjectionHERTOP->cd(0);
406 m_hInjectionHERTOP->Draw(
"hist");
411 m_histogramDirectoryName =
"ARICH";
413 locationHits =
"ARICHOccInjLER";
414 if (m_histogramDirectoryName !=
"") {
415 locationHits = m_histogramDirectoryName +
"/" + locationHits;
417 Hits = (TH1*)findHist(locationHits.Data());
418 locationTriggers =
"ARICHEOccInjLER";
419 if (m_histogramDirectoryName !=
"") {
420 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
422 Triggers = (TH1*)findHist(locationTriggers.Data());
424 if (Hits && Triggers) {
425 m_hInjectionLERARICH->Divide(Hits, Triggers);
428 m_cInjectionLERARICH->Clear();
429 m_cInjectionLERARICH->cd(0);
430 m_hInjectionLERARICH->Draw(
"hist");
432 locationHits =
"ARICHOccInjHER";
433 if (m_histogramDirectoryName !=
"") {
434 locationHits = m_histogramDirectoryName +
"/" + locationHits;
436 Hits = (TH1*)findHist(locationHits.Data());
437 locationTriggers =
"ARICHEOccInjHER";
438 if (m_histogramDirectoryName !=
"") {
439 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
441 Triggers = (TH1*)findHist(locationTriggers.Data());
443 if (Hits && Triggers) {
444 m_hInjectionHERARICH->Divide(Hits, Triggers);
447 m_cInjectionHERARICH->Clear();
448 m_cInjectionHERARICH->cd(0);
449 m_hInjectionHERARICH->Draw(
"hist");
452 m_histogramDirectoryName =
"KLM";
454 locationHits =
"KLMOccInjLER";
455 if (m_histogramDirectoryName !=
"") {
456 locationHits = m_histogramDirectoryName +
"/" + locationHits;
458 Hits = (TH1*)findHist(locationHits.Data());
459 locationTriggers =
"KLMEOccInjLER";
460 if (m_histogramDirectoryName !=
"") {
461 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
463 Triggers = (TH1*)findHist(locationTriggers.Data());
465 if (Hits && Triggers) {
466 m_hInjectionLERKLM->Divide(Hits, Triggers);
469 m_cInjectionLERKLM->Clear();
470 m_cInjectionLERKLM->cd(0);
471 m_hInjectionLERKLM->Draw(
"hist");
473 locationHits =
"KLMOccInjHER";
474 if (m_histogramDirectoryName !=
"") {
475 locationHits = m_histogramDirectoryName +
"/" + locationHits;
477 Hits = (TH1*)findHist(locationHits.Data());
478 locationTriggers =
"KLMEOccInjHER";
479 if (m_histogramDirectoryName !=
"") {
480 locationTriggers = m_histogramDirectoryName +
"/" + locationTriggers;
482 Triggers = (TH1*)findHist(locationTriggers.Data());
484 if (Hits && Triggers) {
485 m_hInjectionHERKLM->Divide(Hits, Triggers);
488 m_cInjectionHERKLM->Clear();
489 m_cInjectionHERKLM->cd(0);
490 m_hInjectionHERKLM->Draw(
"hist");
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) {
499 m.data.resize(
int(ca_element_count(m.mychid)), 0.0);
500 length = m.data.size();
502 if (m.histo && m.histo->GetNcells() > 2 && length > 0 && length == int(ca_element_count(m.mychid))) {
505 if (m.histo->GetDimension() == 1) {
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);
512 }
else if (m.histo->GetDimension() == 2) {
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);
522 SEVCHK(ca_array_put(DBR_DOUBLE, length, m.mychid, (
void*)m.data.data()),
"ca_put failure");
524 B2DEBUG(99,
"Inj " << ca_name(m.mychid) <<
" , " << m.histo <<
" , " << (m.histo ? m.histo->GetNcells() : 0) <<
" , " << length <<
527 ca_element_count(m.mychid));
530 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
535 void DQMHistInjectionModule::cleanPVs(
void)
539 for (
auto m : m_nodes) {
541 int length = int(ca_element_count(m.mychid));
543 m.data.resize(length, 0.0);
544 SEVCHK(ca_array_put(DBR_DOUBLE, length, m.mychid, (
void*)m.data.data()),
"ca_put failure");
546 B2DEBUG(99,
"clean: lenght " << ca_name(m.mychid));
549 B2DEBUG(99,
"clean: chid " << ca_name(m.mychid));
556 void DQMHistInjectionModule::terminate()
558 B2DEBUG(1,
"DQMHistInjection: terminate called");
561 for (
auto m : m_nodes) {
562 SEVCHK(ca_clear_channel(m.mychid),
"ca_clear_channel failure");
564 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");