Skip to content

Commit deda9a2

Browse files
committed
rebin fixes
1 parent 50bb3f0 commit deda9a2

File tree

3 files changed

+399
-438
lines changed

3 files changed

+399
-438
lines changed

BackgroundPrediction.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bool useRatioFit=false;
4040
std::string tags="nominal"; // MMMM
4141

4242
double SR_lo=600.;
43-
double SR_hi=3500.;
43+
double SR_hi=3600.;
4444

4545
Double_t ErfExp(Double_t x, Double_t c, Double_t offset, Double_t width){
4646
if(width<1e-2)width=1e-2;
@@ -151,6 +151,7 @@ void BackgroundPrediction(std::string pname,int rebin_factor)
151151
{
152152
rebin = rebin_factor;
153153
std::string fname = std::string("../fitFilesBtagSF/") + pname + std::string("/histos_bkg.root");
154+
//std::string fname = std::string("../fitFilesAll/") + pname + std::string("/histos_bkg.root");
154155

155156
gStyle->SetOptStat(000000000);
156157
gStyle->SetPadGridX(0);
@@ -191,9 +192,11 @@ void BackgroundPrediction(std::string pname,int rebin_factor)
191192
}
192193
h_SR_Prediction->SetMarkerSize(0.7);
193194
h_SR_Prediction->GetYaxis()->SetTitleOffset(1.2);
195+
h_SR_Prediction->Sumw2();
194196

195197

196198
RooRealVar x("x", "m_{X} (GeV)", SR_lo, SR_hi);
199+
//RooRealVar x("x", "m_{X} (GeV)", SR_lo, 2000);
197200

198201
/* RooRealVar bg_p0("bg_p0", "bg_p0", 700., 1200.);
199202
RooRealVar bg_p1("bg_p1", "bg_p1", 50., 300.1);
@@ -202,9 +205,9 @@ void BackgroundPrediction(std::string pname,int rebin_factor)
202205
string name_output="CR_RooFit_GaussExp";
203206
*/
204207

205-
RooRealVar bg_p0((std::string("bg_p0_")+pname).c_str(), "bg_p0", 0., 200.);
206-
RooRealVar bg_p1((std::string("bg_p1_")+pname).c_str(), "bg_p1", 0., 30.1);
207-
RooRealVar bg_p2((std::string("bg_p2_")+pname).c_str(), "bg_p2", 0., 10.1);
208+
RooRealVar bg_p0((std::string("bg_p0_")+pname).c_str(), "bg_p0", 2.5, 0., 30);
209+
RooRealVar bg_p1((std::string("bg_p1_")+pname).c_str(), "bg_p1", 4.7, 0., 50);
210+
RooRealVar bg_p2((std::string("bg_p2_")+pname).c_str(), "bg_p2", 0.004,0., 10.1);
208211
RooGenericPdf bg = RooGenericPdf((std::string("bg_")+pname).c_str(),"(pow(1-@0/13000,@1)/pow(@0/13000,@2+@3*log(@0/13000)))",RooArgList(x,bg_p0,bg_p1,bg_p2));
209212
string name_output = "CR_RooFit_Exp";
210213

@@ -233,9 +236,11 @@ void BackgroundPrediction(std::string pname,int rebin_factor)
233236
RooBernstein bg("bg", "bg", x, RooArgList(*bg_p1,*bg_p2, *bg_p3, *bg_p4, *bg_p5));// *bg_p6, *bg_p7, *bg_p8));
234237
string name_output = "CR_RooFit_Bernestein";
235238
*/
239+
236240

237241
RooDataHist pred("pred", "Prediction from SB", RooArgList(x), h_SR_Prediction);
238-
RooFitResult *r_bg=bg.fitTo(pred, RooFit::Range(SR_lo, SR_hi), RooFit::Save());
242+
RooFitResult *r_bg=bg.fitTo(pred, RooFit::Range(SR_lo, SR_hi), RooFit::Save());//RooFit::SumW2Error(kTRUE)
243+
//RooFitResult *r_bg=bg.fitTo(pred, RooFit::Range(SR_lo, SR_hi), RooFit::Save(),RooFit::SumW2Error(kTRUE));
239244
//RooDataHist data_=*(bg.generateBinned(x, h_mMMMMa_3Tag_SR_Prediction->Integral(h_mMMMMa_3Tag_SR_Prediction->FindBin(SR_lo), h_mX_SR->FindBin(SR_hi)-1) , RooAbsData::Poisson));
240245
std::cout<<" --------------------- Building Envelope --------------------- "<<std::endl;
241246
std::cout<< "bg_p0_"<< pname << " param "<<bg_p0.getVal() << " "<<bg_p0.getError()<<std::endl;
@@ -273,14 +278,14 @@ void BackgroundPrediction(std::string pname,int rebin_factor)
273278
int nbins = (int) (SR_hi- SR_lo)/rebin;
274279
x.setBins(nbins);
275280

276-
std::cout << "chi2(data) " << aC_plot->chiSquare()<<std::endl;
281+
std::cout << "chi2(data) " << aC_plot->chiSquare((std::string("bg_")+pname).c_str(),"h_SR_Prediction",3)<<std::endl;
277282

278283
//std::cout << "p-value: data under hypothesis H0: " << TMath::Prob(chi2_data->getVal(), nbins - 1) << std::endl;
279284

280285

281286
aC_plot->GetXaxis()->SetRangeUser(SR_lo, SR_hi);
282287
aC_plot->GetXaxis()->SetLabelOffset(0.03);
283-
aC_plot->GetYaxis()->SetRangeUser(1, 500.);
288+
aC_plot->GetYaxis()->SetRangeUser(0.3, 500.);
284289
h_SR_Prediction->GetXaxis()->SetRangeUser(SR_lo, SR_hi);
285290
string rebin_ = itoa(rebin);
286291

@@ -310,7 +315,8 @@ void BackgroundPrediction(std::string pname,int rebin_factor)
310315

311316
TLegend *leg = new TLegend(0.85625,0.7721654,0.6765625,0.8903839,NULL,"brNDC");
312317
leg->SetBorderSize(0);
313-
leg->SetTextSize(0.035);
318+
leg->SetTextSize(0.04);
319+
leg->SetTextFont(42);
314320
leg->SetLineColor(1);
315321
leg->SetLineStyle(1);
316322
leg->SetLineWidth(2);
@@ -320,7 +326,7 @@ void BackgroundPrediction(std::string pname,int rebin_factor)
320326
h_SR_Prediction->SetLineColor(kBlack);
321327
h_SR_Prediction->SetMarkerStyle(20);
322328
//h_mMMMMa_3Tag_SR->GetXaxis()->SetTitleSize(0.09);
323-
leg->AddEntry(h_SR_Prediction, "Data", "lep");
329+
leg->AddEntry(h_SR_Prediction, "Data: sideband", "lep");
324330
TH1F *h=new TH1F();
325331
h->SetLineColor(kRed);
326332
h->SetLineWidth(3);
@@ -336,7 +342,8 @@ void BackgroundPrediction(std::string pname,int rebin_factor)
336342
frameP->GetXaxis()->SetRangeUser(SR_lo, SR_hi);
337343

338344
frameP->addPlotable(hpull,"P");
339-
frameP->GetYaxis()->SetRangeUser(-5,5);
345+
frameP->GetYaxis()->SetRangeUser(-7,7);
346+
frameP->GetYaxis()->SetNdivisions(505);
340347
frameP->GetYaxis()->SetTitle("Pull");
341348

342349
frameP->GetYaxis()->SetTitleSize((1.-xPad)/xPad*0.06);

0 commit comments

Comments
 (0)