11 #include <dqm/analysis/modules/DQMHistAnalysisRootFitExample.h>
12 #include <RooRealVar.h>
32 B2DEBUG(1,
"DQMHistAnalysisRooFitExample: Constructor done.");
35 DQMHistAnalysisRooFitExampleModule::~DQMHistAnalysisRooFitExampleModule()
38 if (ca_current_context()) ca_context_destroy();
42 void DQMHistAnalysisRooFitExampleModule::initialize()
44 B2INFO(
"DQMHistAnalysisRooFitExample: initialized.");
47 if (!ca_current_context()) SEVCHK(ca_context_create(ca_disable_preemptive_callback),
"ca_context_create");
48 SEVCHK(ca_create_channel(
"fit_value", NULL, NULL, 10, &mychid),
"ca_create_channel failure");
49 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
52 w =
new RooWorkspace(
"w");
53 w->factory(
"Gaussian::f(x[-20,20],mean[0,-5,5],sigma[3,1,10])");
56 m_c0 =
new TCanvas(
"example0");
60 void DQMHistAnalysisRooFitExampleModule::beginRun()
63 B2INFO(
"DQMHistAnalysisRooFitExample: beginRun called.");
66 TH1* hh1 = findHist(
"FirstDet/h_HitXPositionCh01");
71 data =
new RooDataHist(
"data",
"dataset with x", *x, (
const TH1*) hh1);
73 r = model->fitTo(*data);
83 B2FATAL(
"Histo now there ... -> zero pointer crash");
88 void DQMHistAnalysisRooFitExampleModule::event()
93 hh1 = findHist(
"FirstDet/h_HitXPositionCh01");
96 if (data)
delete data;
98 data =
new RooDataHist(
"data",
"dataset with x", *(w->var(
"x")), hh1);
100 r = model->fitTo(*data);
125 SEVCHK(ca_put(DBR_DOUBLE, mychid, (
void*)&fitdata),
"ca_set failure");
126 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
130 void DQMHistAnalysisRooFitExampleModule::endRun()
132 B2INFO(
"DQMHistAnalysisRooFitExample: endRun called");
136 void DQMHistAnalysisRooFitExampleModule::terminate()
139 SEVCHK(ca_clear_channel(mychid),
"ca_clear_channel failure");
140 SEVCHK(ca_pend_io(5.0),
"ca_pend_io failure");
142 B2INFO(
"DQMHistAnalysisRooFitExample: terminate called");