14#include <dqm/analysis/modules/DQMHistOutputToEPICS.h>
15#include <framework/core/ModuleParam.templateDetails.h>
36 B2DEBUG(99,
"DQMHistOutputToEPICS: Constructor done.");
47 B2WARNING(
"Histolist with wrong nr of parameters " << it.size());
52 n->histoname = it.at(0);
53 SEVCHK(ca_create_channel(it.at(1).c_str(), NULL, NULL, 10, &n->mychid),
"ca_create_channel failure");
55 SEVCHK(ca_create_channel(it.at(2).c_str(), NULL, NULL, 10, &n->mychid_last),
"ca_create_channel failure");
63 B2DEBUG(99,
"DQMHistOutputToEPICS: initialized.");
69 for (
auto* it : pmynode) {
70 if (!it->mychid)
continue;
71 int length = int(ca_element_count(it->mychid));
73 it->data.resize(length, 0.0);
74 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid, (
void*)(it->data.data())),
"ca_put failure");
75 if (it->mychid_last) {
76 if (length ==
int(ca_element_count(it->mychid_last))) {
77 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid_last, (
void*)(it->data.data())),
"ca_put failure");
87 B2DEBUG(99,
"DQMHistOutputToEPICS: beginRun called.");
95 for (
auto& it : pmynode) {
96 if (!it->mychid)
continue;
97 int length = it->data.size();
99 if (hh1 && hh1->GetNcells() > 2 && length > 0 && length ==
int(ca_element_count(it->mychid))) {
102 if (hh1->GetDimension() == 1) {
104 int nx = hh1->GetNbinsX() + 1;
105 for (
int x = 1; x < nx && i < length ; x++) {
106 it->data[i++] = hh1->GetBinContent(x);
109 }
else if (hh1->GetDimension() == 2) {
111 int nx = hh1->GetNbinsX() + 1;
112 int ny = hh1->GetNbinsY() + 1;
113 for (
int y = 1; y < ny && i < length; y++) {
114 for (
int x = 1; x < nx && i < length ; x++) {
115 it->data[i++] = hh1->GetBinContent(x, y);
120 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid, (
void*)it->data.data()),
"ca_set failure");
130 for (
auto* it : pmynode) {
131 if (it->mychid && it->mychid_last) {
133 int length = it->data.size();
134 if (length > 0 && length ==
int(ca_element_count(it->mychid_last))) {
135 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid_last, (
void*)it->data.data()),
"ca_put failure");
139 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
147 B2DEBUG(99,
"DQMHistOutputToEPICS: endRun called");
153 B2DEBUG(99,
"DQMHistOutputToEPICS: terminate called");
157 for (
auto* it : pmynode) {
158 if (it->mychid) SEVCHK(ca_clear_channel(it->mychid),
"ca_clear_channel failure");
159 if (it->mychid_last) SEVCHK(ca_clear_channel(it->mychid_last),
"ca_clear_channel 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).
void terminate(void) override final
This method is called at the end of the event processing.
void initialize(void) override final
Initializer.
void endRun(void) override final
This method is called for each event.
DQMHistOutputToEPICSModule()
Constructor.
~DQMHistOutputToEPICSModule()
Destructor.
void cleanPVs(void)
set PVs to zero content (at run start)
std::vector< std::vector< std::string > > m_histlist
Parameter list for histograms.
void copyToLast(void)
copy over to "last" PV
bool m_dirty
Flag to mark that a new runs as started and data not copied to last PV.
void beginRun(void) override final
Called when entering a new run.
void event(void) override final
This method is called if the current run ends.
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.