14#include <dqm/analysis/modules/DQMHistOutputToEPICS.h>
15#include <framework/core/ModuleParam.templateDetails.h>
36 B2DEBUG(99,
"DQMHistOutputToEPICS: Constructor done.");
43 B2WARNING(
"Histolist with wrong nr of parameters " << it.size());
48 n->histoname = it.at(0);
49 SEVCHK(ca_create_channel(it.at(1).c_str(), NULL, NULL, 10, &n->mychid),
"ca_create_channel failure");
51 SEVCHK(ca_create_channel(it.at(2).c_str(), NULL, NULL, 10, &n->mychid_last),
"ca_create_channel failure");
59 B2DEBUG(99,
"DQMHistOutputToEPICS: initialized.");
65 for (
auto* it : pmynode) {
66 if (!it->mychid)
continue;
67 int length = int(ca_element_count(it->mychid));
69 it->data.resize(length, 0.0);
70 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid, (
void*)(it->data.data())),
"ca_put failure");
71 if (it->mychid_last) {
72 if (length ==
int(ca_element_count(it->mychid_last))) {
73 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid_last, (
void*)(it->data.data())),
"ca_put failure");
83 B2DEBUG(99,
"DQMHistOutputToEPICS: beginRun called.");
91 for (
auto& it : pmynode) {
92 if (!it->mychid)
continue;
93 int length = it->data.size();
95 if (hh1 && hh1->GetNcells() > 2 && length > 0 && length ==
int(ca_element_count(it->mychid))) {
98 if (hh1->GetDimension() == 1) {
100 int nx = hh1->GetNbinsX() + 1;
101 for (
int x = 1; x < nx && i < length ; x++) {
102 it->data[i++] = hh1->GetBinContent(x);
105 }
else if (hh1->GetDimension() == 2) {
107 int nx = hh1->GetNbinsX() + 1;
108 int ny = hh1->GetNbinsY() + 1;
109 for (
int y = 1; y < ny && i < length; y++) {
110 for (
int x = 1; x < nx && i < length ; x++) {
111 it->data[i++] = hh1->GetBinContent(x, y);
116 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid, (
void*)it->data.data()),
"ca_set failure");
126 for (
auto* it : pmynode) {
127 if (it->mychid && it->mychid_last) {
129 int length = it->data.size();
130 if (length > 0 && length ==
int(ca_element_count(it->mychid_last))) {
131 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid_last, (
void*)it->data.data()),
"ca_put failure");
135 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
143 B2DEBUG(99,
"DQMHistOutputToEPICS: endRun called");
149 B2DEBUG(99,
"DQMHistOutputToEPICS: terminate called");
153 for (
auto* it : pmynode) {
154 if (it->mychid) SEVCHK(ca_clear_channel(it->mychid),
"ca_clear_channel failure");
155 if (it->mychid_last) SEVCHK(ca_clear_channel(it->mychid_last),
"ca_clear_channel failure");
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
DQMHistAnalysisModule()
Constructor / Destructor.
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.
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.