14#include <dqm/analysis/modules/DQMHistOutputToEPICS.h>
15#include <framework/core/ModuleParam.templateDetails.h>
36 B2DEBUG(99,
"DQMHistOutputToEPICS: Constructor done.");
42 if (ca_current_context()) ca_context_destroy();
49 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
53 B2WARNING(
"Histolist with wrong nr of parameters " << it.size());
58 n->histoname = it.at(0);
59 SEVCHK(ca_create_channel(it.at(1).c_str(), NULL, NULL, 10, &n->mychid),
"ca_create_channel failure");
61 SEVCHK(ca_create_channel(it.at(2).c_str(), NULL, NULL, 10, &n->mychid_last),
"ca_create_channel failure");
70 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
72 B2DEBUG(99,
"DQMHistOutputToEPICS: initialized.");
78 for (
auto* it : pmynode) {
79 if (!it->mychid)
continue;
80 int length = int(ca_element_count(it->mychid));
82 it->data.resize(length, 0.0);
83 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid, (
void*)(it->data.data())),
"ca_put failure");
84 if (it->mychid_last) {
85 if (length ==
int(ca_element_count(it->mychid_last))) {
86 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid_last, (
void*)(it->data.data())),
"ca_put failure");
96 B2DEBUG(99,
"DQMHistOutputToEPICS: beginRun called.");
104 for (
auto& it : pmynode) {
105 if (!it->mychid)
continue;
106 int length = it->data.size();
108 if (hh1 && hh1->GetNcells() > 2 && length > 0 && length ==
int(ca_element_count(it->mychid))) {
111 if (hh1->GetDimension() == 1) {
113 int nx = hh1->GetNbinsX() + 1;
114 for (
int x = 1; x < nx && i < length ; x++) {
115 it->data[i++] = hh1->GetBinContent(x);
118 }
else if (hh1->GetDimension() == 2) {
120 int nx = hh1->GetNbinsX() + 1;
121 int ny = hh1->GetNbinsY() + 1;
122 for (
int y = 1; y < ny && i < length; y++) {
123 for (
int x = 1; x < nx && i < length ; x++) {
124 it->data[i++] = hh1->GetBinContent(x, y);
129 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid, (
void*)it->data.data()),
"ca_set failure");
132 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
140 for (
auto* it : pmynode) {
141 if (it->mychid && it->mychid_last) {
143 int length = it->data.size();
144 if (length > 0 && length ==
int(ca_element_count(it->mychid_last))) {
145 SEVCHK(ca_array_put(DBR_DOUBLE, length, it->mychid_last, (
void*)it->data.data()),
"ca_put failure");
149 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
157 B2DEBUG(99,
"DQMHistOutputToEPICS: endRun called");
163 B2DEBUG(99,
"DQMHistOutputToEPICS: terminate called");
167 for (
auto* it : pmynode) {
168 if (it->mychid) SEVCHK(ca_clear_channel(it->mychid),
"ca_clear_channel failure");
169 if (it->mychid_last) SEVCHK(ca_clear_channel(it->mychid_last),
"ca_clear_channel failure");
171 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).
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.