9#include <dqm/analysis/modules/DQMHistAnalysisEpicsExample.h>
36 B2DEBUG(20,
"DQMHistAnalysisEpicsExample: Constructor done.");
43 if (ca_current_context()) ca_context_destroy();
49 B2DEBUG(20,
"DQMHistAnalysisEpicsExample: initialized.");
53 a.ReplaceAll(
"/",
"_");
54 m_c1 =
new TCanvas(
"c_" + a);
56 m_f1->SetParameter(0, 1000);
57 m_f1->SetParameter(1, 0);
58 m_f1->SetParameter(2, 10);
59 m_f1->SetLineColor(4);
61 m_f1->SetNumberFitPoints(512);
63 m_line =
new TLine(0, 10, 0, 0);
88 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
92 aa =
m_f1->GetParName(i);
93 if (aa ==
"") aa = string(
"par") + string(TString::Itoa(i, 10).Data());
96 SEVCHK(ca_create_channel(aa.c_str(), NULL, NULL, 10, &mychid[i]),
"ca_create_channel failure");
102 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
113 B2DEBUG(20,
"DQMHistAnalysisEpicsExample: beginRun called.");
120 B2DEBUG(20,
"Histo " <<
m_histoname <<
" not in memfile");
121 TDirectory* d = gROOT;
125 while (myl.Tokenize(tok, from,
"/")) {
129 if (myl.Tokenize(dummy, f,
"/")) {
130 auto e = d->GetDirectory(tok);
132 B2DEBUG(20,
"Cd Dir " << tok);
140 TObject* obj = d->FindObject(tok);
142 if (obj->IsA()->InheritsFrom(
"TH1")) {
143 B2DEBUG(20,
"Histo " <<
m_histoname <<
" found in mem");
147 B2DEBUG(20,
"Histo " <<
m_histoname <<
" NOT found in mem");
158 B2DEBUG(20,
"Histo " <<
m_histoname <<
" not found");
169 B2DEBUG(20,
"Histo " <<
m_histoname <<
" not in memfile");
170 TDirectory* d = gROOT;
174 while (myl.Tokenize(tok, from,
"/")) {
178 if (myl.Tokenize(dummy, f,
"/")) {
179 auto e = d->GetDirectory(tok);
181 B2DEBUG(20,
"Cd Dir " << tok);
189 TObject* obj = d->FindObject(tok);
191 if (obj->IsA()->InheritsFrom(
"TH1")) {
192 B2DEBUG(20,
"Histo " <<
m_histoname <<
" found in mem");
197 B2DEBUG(20,
"Histo " <<
m_histoname <<
" NOT found in mem");
203 double y1 = hh1->GetMaximum();
204 double y2 = hh1->GetMinimum();
205 m_line->SetY1(y1 + (y1 - y2) * 0.05);
211 double x =
m_f1->GetParameter(1);
223 B2DEBUG(20,
"Histo " <<
m_histoname <<
" not found");
230 data =
m_f1->GetParameter(i);
231 if (mychid[i]) SEVCHK(ca_put(DBR_DOUBLE, mychid[i], (
void*)&data),
"ca_set failure");
233 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
240 B2DEBUG(20,
"DQMHistAnalysisEpicsExample : endRun called");
249 if (mychid[i]) SEVCHK(ca_clear_channel(mychid[i]),
"ca_clear_channel failure");
251 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
254 B2DEBUG(20,
"DQMHistAnalysisEpicsExample: terminate called");
void initialize() override final
Initializer.
TF1 * m_f1
The fit function.
DQMHistAnalysisEpicsExampleModule()
Constructor.
TLine * m_line_hi
The line for the higher bound.
std::string m_pvPrefix
The prefix of PV.
void terminate() override final
This method is called at the end of the event processing.
Int_t m_parameters
The fit function parameters for EPICS.
void event() override final
This method is called for each event.
TCanvas * m_c1
The drawing canvas.
TLine * m_line_lo
The line for the lower bound.
void endRun() override final
This method is called if the current run ends.
~DQMHistAnalysisEpicsExampleModule()
Destructor.
std::string m_histoname
The name of the histogram.
void beginRun() override final
Called when entering a new run.
TLine * m_line
The line for the fitting result.
std::string m_function
The definition of the fit function.
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 setDescription(const std::string &description)
Sets the description of the module.
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.