10#include <dqm/analysis/modules/DQMHistAnalysisEcmsMonObj.h>
11#include <framework/particledb/EvtGenDatabasePDG.h>
13#include <unordered_map>
20#include <RooFitResult.h>
21#include <RooRealVar.h>
22#include <RooDataSet.h>
23#include <RooGaussian.h>
27#include <RooPolyVar.h>
28#include <RooArgusBG.h>
29#include <RooSimultaneous.h>
30#include <RooCategory.h>
32#include <RooConstVar.h>
37using namespace RooFit;
49 B2DEBUG(20,
"DQMHistAnalysisEcmsMonObj: Constructor done.");
59 B2DEBUG(20,
"DQMHistAnalysisEcmsMonObj: initialized.");
64 B2DEBUG(20,
"DQMHistAnalysisEcmsMonObj: beginRun called.");
69 B2DEBUG(20,
"DQMHistAnalysisEcmsMonObj: event called.");
79 bool isBatch = gROOT->IsBatch();
80 gROOT->SetBatch(kTRUE);
84 RooPlot* frame = eNow.frame(40) ;
85 dataE->plotOn(frame) ;
87 TString name = (nTag ==
"B0") ?
"B^{0}" :
"B^{#pm}";
88 sumB.paramOn(frame, Label(name), Format(
"TE"), Layout(0.5, 0.8, 0.85));
91 sumB.plotOn(frame, Components(argus), LineStyle(kDashed)) ;
92 sumB.plotOn(frame, Components(gauss), LineStyle(kDashed), LineColor(kRed)) ;
96 frame->GetXaxis()->SetTitleSize(0.0001);
97 frame->GetXaxis()->SetLabelSize(0.0001);
98 frame->SetTitleSize(0.0001);
99 frame->GetYaxis()->SetTitleSize(0.055);
100 frame->GetYaxis()->SetTitleOffset(1.1);
101 frame->GetYaxis()->SetLabelSize(0.05) ;
106 RooHist* hpull = frame->pullHist() ;
108 RooPlot* frameRat = eNow.frame(Title(
"."));
109 frameRat->GetYaxis()->SetTitle(
"Pull");
110 frameRat->GetYaxis()->CenterTitle();
111 frameRat->GetYaxis()->SetTitleSize(0.13);
113 frameRat->GetYaxis()->SetNdivisions(504);
114 frameRat->GetYaxis()->SetLabelSize(0.12);
115 frameRat->GetXaxis()->SetTitleSize(0.12);
116 frameRat->GetXaxis()->SetTitleOffset(1.1);
117 frameRat->GetXaxis()->SetLabelSize(0.12);
119 frameRat->GetYaxis()->SetTitleOffset(0.4);
120 frameRat->addPlotable(hpull,
"x0 P E1");
121 frameRat->SetMaximum(5.);
122 frameRat->SetMinimum(-5.);
124 TCanvas* c1 =
new TCanvas(nTag +
"_can");
125 TPad* pad =
new TPad(nTag +
"_pad",
"pad", 0, 0.3, 1, 1.0);
126 pad->SetBottomMargin(0.03);
127 pad->SetRightMargin(0.05);
128 pad->SetLeftMargin(0.15);
134 TLine* ll =
new TLine;
135 double mRev = 10579.4e-3 / 2;
136 ll->SetLineColor(kGreen);
137 ll->DrawLine(mRev, 0, mRev, frame->GetMaximum());
141 TPad* padRat =
new TPad(nTag +
"_padRat",
"padRat", 0, 0.00, 1, 0.3);
142 padRat->SetTopMargin(0.04);
143 padRat->SetBottomMargin(0.35);
144 padRat->SetRightMargin(0.05);
145 padRat->SetLeftMargin(0.15);
151 TLine* l =
new TLine(5279.34e-3, 0.0, 5.37, 0.0);
152 l->SetLineColor(kBlue);
156 gROOT->SetBatch(isBatch);
168 RooRealVar eNow(
"eNow",
"E^{*}_{B} [GeV]", cMBp, 5.37);
170 RooDataHist* dataE0 =
new RooDataHist(
"dataE0hist",
"Dataset from histogram", RooArgSet(eNow), hB0);
171 RooDataHist* dataEp =
new RooDataHist(
"dataEphist",
"Dataset from histogram", RooArgSet(eNow), hBp);
174 RooCategory Bcharge(
"sample",
"sample") ;
175 Bcharge.defineType(
"B0") ;
176 Bcharge.defineType(
"Bp") ;
178 RooDataHist combData(
"combData",
"combined data", eNow, Index(Bcharge), Import(
"B0", *dataE0), Import(
"Bp", *dataEp));
182 RooRealVar sigmean(
"mean",
"#mu", 5.29, 5.27, 5.30) ;
183 RooRealVar sigwidth(
"sigma",
"#sigma", 0.00237, 0.0001, 0.030) ;
185 RooGaussian gauss(
"gauss",
"gaussian PDF", eNow, sigmean, sigwidth) ;
188 RooRealVar argpar(
"Argus_param",
"c_{Argus}", -150.7, -300., +50.0) ;
189 RooRealVar endpointBp(
"EndPointBp",
"endPoint parameter", cMBp, 5.27, 5.291) ;
190 RooRealVar endpointB0(
"EndPointB0",
"endPoint parameter", cMB0, 5.27, 5.291) ;
191 endpointB0.setConstant(kTRUE);
192 endpointBp.setConstant(kTRUE);
196 RooPolyVar shape2B0(
"EndPoint2B0",
"shape parameter", endpointB0, RooArgSet(RooConst(0.), RooConst(2.)));
197 RooPolyVar eNowDifB0(
"eNowDifB0",
"eNowDifB0", eNow, RooArgSet(shape2B0, RooConst(-1.)));
198 RooArgusBG argusB0(
"argusB0",
"Argus PDF", eNowDifB0, endpointB0, argpar) ;
201 RooPolyVar shape2Bp(
"EndPoint2Bp",
"shape parameter", endpointBp, RooArgSet(RooConst(0.), RooConst(2.)));
202 RooPolyVar eNowDifBp(
"eNowDifBp",
"eNowDifBp", eNow, RooArgSet(shape2Bp, RooConst(-1.)));
203 RooArgusBG argusBp(
"argusBp",
"Argus PDF", eNowDifBp, endpointBp, argpar) ;
207 RooRealVar nsigB0(
"nsigB0",
"N_{sig}^{B^{0}}", 100, 0., 100000) ;
208 RooRealVar nbkgB0(
"nbkgB0",
"N_{bg}", 100, 0., 500000) ;
210 RooRealVar nsigBp(
"nsigBp",
"N_{sig}^{B^{#pm}}", 100, 0., 100000) ;
211 RooRealVar nbkgBp(
"nbkgBp",
"N_{bg}", 100, 0., 500000) ;
215 RooAddPdf sumB0(
"sumB0",
"g0+a0", RooArgList(gauss, argusB0), RooArgList(nsigB0, nbkgB0)) ;
216 RooAddPdf sumBp(
"sumBp",
"gP+aP", RooArgList(gauss, argusBp), RooArgList(nsigBp, nbkgBp)) ;
220 RooSimultaneous simPdf(
"simPdf",
"simultaneous pdf", Bcharge) ;
224 simPdf.addPdf(sumB0,
"B0") ;
225 simPdf.addPdf(sumBp,
"Bp") ;
228 simPdf.fitTo(combData);
231 m_canvas =
new TCanvas(
"ecms",
"ecms", 1500, 800);
232 TCanvas* c0 =
plotArgusFit(dataE0, sumB0, argusB0, gauss, eNow,
"B0");
233 TCanvas* cp =
plotArgusFit(dataEp, sumBp, argusBp, gauss, eNow,
"Bp");
239 for (
auto obj : *cp->GetListOfPrimitives()) obj->DrawClone();
241 for (
auto obj : *c0->GetListOfPrimitives()) obj->DrawClone();
253 return {{
"EcmsBBcnt", 2 * sigmean.getValV()}, {
"EcmsBBcntUnc", 2 * sigmean.getError()},
254 {
"EcmsBBspread", 2 * sigwidth.getValV()}, {
"EcmsBBspreadUnc", 2 * sigwidth.getError()}};
260 B2DEBUG(20,
"DQMHistAnalysisEcmsMonObj: endRun called.");
262 auto* hB0 = (TH1D*)
findHist(
"PhysicsObjectsMiraBelleEcmsBB/hB0");
263 auto* hBp = (TH1D*)
findHist(
"PhysicsObjectsMiraBelleEcmsBB/hBp");
274 B2DEBUG(20,
"terminate called");
void initialize() override final
Initialize the Module.
TCanvas * plotArgusFit(RooDataHist *dataE0, RooAddPdf &sumB0, RooArgusBG &argus, RooGaussian &gauss, RooRealVar &eNow, TString nTag="")
Plot the fit and return TCanvas with the plot.
std::unordered_map< std::string, double > fitEcmsBB(TH1D *hB0, TH1D *hBp)
Fit the histograms and return the fitted parameters.
TCanvas * m_canvas
Canvas to keep plots of the fit.
MonitoringObject * m_monObj
monitoring object
void terminate() override final
Termination action.
void event() override final
This method is called for each event.
~DQMHistAnalysisEcmsMonObjModule()
Destructor.
DQMHistAnalysisEcmsMonObjModule()
Constructor.
void endRun() override final
End-of-run action.
void beginRun() override final
Called when entering a new run.
The base class for the histogram analysis module.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
static EvtGenDatabasePDG * Instance()
Instance method that loads the EvtGen table.
void setDescription(const std::string &description)
Sets the description of the module.
void setVariable(const std::string &var, float val, float upErr=-1., float dwErr=-1)
set value to float variable (new variable is made if not yet existing)
void addCanvas(TCanvas *canv)
Add Canvas to monitoring object.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.