14#include <dqm/analysis/modules/DQMHistAnalysisRootFitExample.h>
15#include <RooRealVar.h>
35 B2DEBUG(1,
"DQMHistAnalysisRooFitExample: Constructor done.");
41 if (ca_current_context()) ca_context_destroy();
47 B2INFO(
"DQMHistAnalysisRooFitExample: initialized.");
50 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
51 SEVCHK(ca_create_channel(
"fit_value", NULL, NULL, 10, &mychid),
"ca_create_channel failure");
52 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
55 w =
new RooWorkspace(
"w");
56 w->factory(
"Gaussian::f(x[-20,20],mean[0,-5,5],sigma[3,1,10])");
59 m_c0 =
new TCanvas(
"example0");
66 B2INFO(
"DQMHistAnalysisRooFitExample: beginRun called.");
69 TH1* hh1 =
findHist(
"FirstDet/h_HitXPositionCh01");
74 data =
new RooDataHist(
"data",
"dataset with x", *
x, (
const TH1*) hh1);
86 B2FATAL(
"Histo now there ... -> zero pointer crash");
96 hh1 =
findHist(
"FirstDet/h_HitXPositionCh01");
101 data =
new RooDataHist(
"data",
"dataset with x", *(
w->var(
"x")), hh1);
128 SEVCHK(ca_put(DBR_DOUBLE, mychid, (
void*)&fitdata),
"ca_set failure");
129 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
135 B2INFO(
"DQMHistAnalysisRooFitExample: endRun called");
142 SEVCHK(ca_clear_channel(mychid),
"ca_clear_channel failure");
143 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
145 B2INFO(
"DQMHistAnalysisRooFitExample: terminate called");
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).
RooAbsPdf * model
The PDF for fitting.
void terminate(void) override final
This method is called at the end of the event processing.
void initialize(void) override final
Initializer.
RooDataHist * data
The data of histogram for fitting.
void endRun(void) override final
This method is called if the current run ends.
~DQMHistAnalysisRooFitExampleModule()
Destructor.
DQMHistAnalysisRooFitExampleModule()
Constructor.
RooFitResult * r
The fitting result.
RooRealVar * x
The fitting variable.
TCanvas * m_c0
The drawing canvas for plotting the fitting result.
RooPlot * plot
The plot of the fitting result.
RooWorkspace * w
The RooFit work space.
void beginRun(void) override final
Called when entering a new run.
void event(void) override final
This method is called for each event.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.