14 #include <dqm/analysis/modules/DQMHistInjection.h>
15 #include <klm/dataobjects/KLMElementNumbers.h>
36 B2DEBUG(1,
"DQMHistInjection: Constructor done.");
43 if (ca_current_context()) ca_context_destroy();
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,
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,
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)",
82 m_hInjectionLERTOP =
new TH1F(
"HitInjectionLERTOP",
"TOP Occ after LER Injection;Time in #mus;Mean Occ in % /event", 4000, 0,
84 m_hInjectionLERARICH =
new TH1F(
"HitInjectionLERARICH",
"ARICH Occ after LER Injection;Time in #mus;Mean Hits/event", 4000, 0,
87 "KLM occupancy after LER Injection;Time [#mus];Digits occupancy in % / (5 #mus)", 4000, 0,
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,
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,
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)",
99 m_hInjectionHERTOP =
new TH1F(
"HitInjectionHERTOP",
"TOP Occ after HER Injection;Time in #mus;Mean Occ in % /event", 4000, 0,
101 m_hInjectionHERARICH =
new TH1F(
"HitInjectionHERARICH",
"ARICH Occ after HER Injection;Time in #mus;Mean Hits/event", 4000, 0,
104 "KLM occupancy after HER Injection;Time [#mus];Digits occupancy in % / (5 #mus)", 4000, 0,
109 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
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");
115 SEVCHK(ca_create_channel((
m_pvPrefix +
"LER:ECL").data(), NULL, NULL, 10, &m_nodes[2].mychid),
"ca_create_channel failure");
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");
121 SEVCHK(ca_create_channel((
m_pvPrefix +
"HER:ECL").data(), NULL, NULL, 10, &m_nodes[5].mychid),
"ca_create_channel failure");
123 SEVCHK(ca_create_channel((
m_pvPrefix +
"LER:TOP").data(), NULL, NULL, 10, &m_nodes[6].mychid),
"ca_create_channel failure");
125 SEVCHK(ca_create_channel((
m_pvPrefix +
"HER:TOP").data(), NULL, NULL, 10, &m_nodes[7].mychid),
"ca_create_channel failure");
127 SEVCHK(ca_create_channel((
m_pvPrefix +
"LER:SVD").data(), NULL, NULL, 10, &m_nodes[8].mychid),
"ca_create_channel failure");
129 SEVCHK(ca_create_channel((
m_pvPrefix +
"HER:SVD").data(), NULL, NULL, 10, &m_nodes[9].mychid),
"ca_create_channel failure");
131 SEVCHK(ca_create_channel((
m_pvPrefix +
"LER:ARICH").data(), NULL, NULL, 10, &m_nodes[10].mychid),
"ca_create_channel failure");
133 SEVCHK(ca_create_channel((
m_pvPrefix +
"HER:ARICH").data(), NULL, NULL, 10, &m_nodes[11].mychid),
"ca_create_channel failure");
135 SEVCHK(ca_create_channel((
m_pvPrefix +
"LER:KLM").data(), NULL, NULL, 10, &m_nodes[10].mychid),
"ca_create_channel failure");
137 SEVCHK(ca_create_channel((
m_pvPrefix +
"HER:KLM").data(), NULL, NULL, 10, &m_nodes[11].mychid),
"ca_create_channel failure");
140 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
144 B2DEBUG(1,
"DQMHistInjection: initialized.");
150 B2DEBUG(1,
"DQMHistInjection: beginRun called.");
165 TH1* Hits =
nullptr, *Triggers =
nullptr;
166 TString locationHits =
"";
167 TString locationTriggers =
"";
171 locationHits =
"PXDOccInjLER";
173 Hits = (TH1*)
findHist(locationHits.Data());
174 locationTriggers =
"PXDEOccInjLER";
178 Triggers = (TH1*)
findHist(locationTriggers.Data());
182 if (Hits && Triggers) {
195 locationHits =
"PXDOccInjHER";
199 Hits = (TH1*)
findHist(locationHits.Data());
200 locationTriggers =
"PXDEOccInjHER";
204 Triggers = (TH1*)
findHist(locationTriggers.Data());
208 if (Hits && Triggers) {
224 locationHits =
"SVDOccInjLER";
226 Hits = (TH1*)
findHist(locationHits.Data());
227 locationTriggers =
"SVDTrgOccInjLER";
231 Triggers = (TH1*)
findHist(locationTriggers.Data());
235 if (Hits && Triggers) {
248 locationHits =
"SVDOccInjHER";
252 Hits = (TH1*)
findHist(locationHits.Data());
253 locationTriggers =
"SVDTrgOccInjHER";
257 Triggers = (TH1*)
findHist(locationTriggers.Data());
261 if (Hits && Triggers) {
278 locationHits =
"ECLHitsInjLER";
280 Hits = (TH1*)
findHist(locationHits.Data());
281 locationTriggers =
"ECLEHitsInjLER";
285 Triggers = (TH1*)
findHist(locationTriggers.Data());
290 m_nodes[0].histo = Triggers;
293 if (Hits && Triggers) {
301 locationHits =
"ECLHitsInjHER";
305 Hits = (TH1*)
findHist(locationHits.Data());
306 locationTriggers =
"ECLEHitsInjHER";
310 Triggers = (TH1*)
findHist(locationTriggers.Data());
315 m_nodes[3].histo = Triggers;
318 if (Hits && Triggers) {
326 locationHits =
"ECLBurstsInjLER";
330 Hits = (TH1*)
findHist(locationHits.Data());
331 locationTriggers =
"ECLEBurstsInjLER";
335 Triggers = (TH1*)
findHist(locationTriggers.Data());
337 if (Hits && Triggers) {
346 locationHits =
"ECLBurstsInjHER";
350 Hits = (TH1*)
findHist(locationHits.Data());
351 locationTriggers =
"ECLEBurstsInjHER";
355 Triggers = (TH1*)
findHist(locationTriggers.Data());
357 if (Hits && Triggers) {
370 locationHits =
"TOPOccInjLER";
372 Hits = (TH1*)
findHist(locationHits.Data());
373 locationTriggers =
"TOPEOccInjLER";
377 Triggers = (TH1*)
findHist(locationTriggers.Data());
379 if (Hits && Triggers) {
387 locationHits =
"TOPOccInjHER";
391 Hits = (TH1*)
findHist(locationHits.Data());
392 locationTriggers =
"TOPEOccInjHER";
396 Triggers = (TH1*)
findHist(locationTriggers.Data());
398 if (Hits && Triggers) {
411 locationHits =
"ARICHOccInjLER";
413 Hits = (TH1*)
findHist(locationHits.Data());
414 locationTriggers =
"ARICHEOccInjLER";
418 Triggers = (TH1*)
findHist(locationTriggers.Data());
420 if (Hits && Triggers) {
428 locationHits =
"ARICHOccInjHER";
432 Hits = (TH1*)
findHist(locationHits.Data());
433 locationTriggers =
"ARICHEOccInjHER";
437 Triggers = (TH1*)
findHist(locationTriggers.Data());
439 if (Hits && Triggers) {
450 locationHits =
"KLMOccInjLER";
452 Hits = (TH1*)
findHist(locationHits.Data());
453 locationTriggers =
"KLMTrigInjLER";
457 Triggers = (TH1*)
findHist(locationTriggers.Data());
459 if (Hits && Triggers) {
467 locationHits =
"KLMOccInjHER";
471 Hits = (TH1*)
findHist(locationHits.Data());
472 locationTriggers =
"KLMTrigInjHER";
476 Triggers = (TH1*)
findHist(locationTriggers.Data());
478 if (Hits && Triggers) {
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) {
493 m.data.resize(
int(ca_element_count(m.mychid)), 0.0);
494 length = m.data.size();
496 if (m.histo && m.histo->GetNcells() > 2 && length > 0 && length == int(ca_element_count(m.mychid))) {
499 if (m.histo->GetDimension() == 1) {
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);
506 }
else if (m.histo->GetDimension() == 2) {
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);
516 SEVCHK(ca_array_put(DBR_DOUBLE, length, m.mychid, (
void*)m.data.data()),
"ca_put failure");
518 B2DEBUG(99,
"Inj " << ca_name(m.mychid) <<
" , " << m.histo <<
" , " << (m.histo ? m.histo->GetNcells() : 0) <<
" , " << length <<
521 ca_element_count(m.mychid));
524 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
533 for (
auto m : m_nodes) {
535 int length = int(ca_element_count(m.mychid));
537 m.data.resize(length, 0.0);
538 SEVCHK(ca_array_put(DBR_DOUBLE, length, m.mychid, (
void*)m.data.data()),
"ca_put failure");
540 B2DEBUG(99,
"clean: lenght " << ca_name(m.mychid));
543 B2DEBUG(99,
"clean: chid " << ca_name(m.mychid));
552 B2DEBUG(1,
"DQMHistInjection: terminate called");
555 for (
auto m : m_nodes) {
556 SEVCHK(ca_clear_channel(m.mychid),
"ca_clear_channel failure");
558 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
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.
TH1F * m_hInjectionLERTOP
TOP Occ.
TCanvas * m_cInjectionLERSVD
Final Canvas.
TCanvas * m_cInjectionLERECL
Final Canvas.
TCanvas * m_cInjectionHERPXDOcc
Final Canvas.
TH1F * m_hInjectionHERTOP
TOP Occ.
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.
TH1F * m_hInjectionHERARICH
ARICH Occ.
TH1F * m_hInjectionHERECL
ECL Hits.
std::string m_pvPrefix
prefix for EPICS PVs
TCanvas * m_cBurstHERECL
Final Canvas.
TCanvas * m_cInjectionHERECL
Final Canvas.
void cleanPVs(void)
Clean up PVs.
TH1F * m_hInjectionHERPXD
PXD Hits.
TH1F * m_hInjectionLERSVD
SVD Hits.
TCanvas * m_cInjectionLERTOP
Final Canvas.
TCanvas * m_cInjectionHERTOP
Final Canvas.
TH1F * m_hInjectionLERARICH
ARICH Occ.
~DQMHistInjectionModule()
Destructor.
TCanvas * m_cInjectionHERKLM
Canvas for KLM occupancy after HER injection.
std::string m_histogramDirectoryName
name of histogram directory
TH1F * m_hInjectionLERPXD
PXD Hits.
TH1F * m_hInjectionHERKLM
KLM occupancy after HER injection.
TH1F * m_hInjectionLERECL
ECL Hits.
TCanvas * m_cInjectionHERARICH
Final Canvas.
TH1F * m_hInjectionHERSVDOcc
SVD Occ norm.
TH1F * m_hBurstLERECL
ECL Bursts.
TH1F * m_hInjectionHERSVD
SVD Hits.
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.
TH1F * m_hBurstHERECL
ECL Bursts.
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 ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.