Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
302249f
2016 code
cvernier Jul 27, 2016
44d3caa
2016 data
cvernier Jul 27, 2016
372a2e9
trigger turn on
cvernier Jul 29, 2016
ed28c7b
test code
cvernier Jul 29, 2016
b96d77a
updating V23 and scripts for limits
cvernier Aug 1, 2016
cd343e9
Minor changes mainly in names to accomodate for 2016 file structure
Aug 1, 2016
4fbbcfc
solving conflicts from last commit
Aug 1, 2016
14969a7
Updated Double jet trigger + corrections in TE application
Aug 3, 2016
3bdf5f2
new trigger, updated variables for TrigEff
Aug 4, 2016
b1abfad
commit for test push + first implementation of trigger preselection +…
Aug 9, 2016
ce48f10
adding library
cvernier Aug 9, 2016
f1430b7
Merge branch '4b_2016' of https://github.com/souvik1982/HbbHbb_Run2 i…
cvernier Aug 9, 2016
9e634f6
Update of the preselectio XMR selection macros + some new
Aug 29, 2016
890196b
Merge remote-tracking branch 'origin/4b_2016' into 4b_2016
Aug 29, 2016
86bf3c6
Updated resolution macros + slight changes in display macros and sele…
Sep 7, 2016
4a675a9
New trigger eff. directories _data and _ttbar
Sep 8, 2016
cfa0a22
Update trigger efficiency, added README files
Sep 19, 2016
485a0f3
Minor changes to display macros
Sep 21, 2016
7fd9c75
Update of uncertainty computation of the turn-on fits
Sep 21, 2016
6c42d29
Up-to-date version of HbbHbb_Trigger.cc
Sep 23, 2016
3c06378
asd
cvernier Oct 21, 2016
13d59d4
Merge branch '4b_2016' of https://github.com/souvik1982/HbbHbb_Run2 i…
cvernier Oct 21, 2016
ad1c3cb
trigger update
cvernier Nov 14, 2016
f8d1ce1
fx
cvernier Nov 14, 2016
eaf3180
fx
cvernier Nov 16, 2016
0ccf889
fx
cvernier Nov 17, 2016
f5a3d3f
update to V24
cvernier Jan 12, 2017
e66c314
skim
cvernier Jan 12, 2017
5b85f49
update code
cvernier Jan 31, 2017
54beb59
update code
cvernier Jan 31, 2017
09bebb4
SF for deepCSV
cvernier Feb 8, 2017
e5bac5f
V25
cvernier Feb 9, 2017
5aa0918
fit
cvernier Feb 14, 2017
7f43966
add limits
cvernier Feb 14, 2017
493b8c4
add sklim
cvernier Feb 16, 2017
b596537
updatepreselection
cvernier Feb 16, 2017
4564b26
trigger weights
cvernier Mar 15, 2017
7ed7a9d
update syst
cvernier Apr 24, 2017
70b473a
update macro
cvernier Apr 26, 2017
2e3ae9b
update macro
cvernier Apr 26, 2017
b9f5eae
update
cvernier Apr 26, 2017
37bfdc8
update
cvernier Apr 26, 2017
4fb00ec
update
cvernier Apr 26, 2017
6bf47c6
updated scripts
cvernier May 9, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
111 changes: 81 additions & 30 deletions AnalysisCode/BackgroundPrediction_Kinematic_Bern.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

// Plot cosmetics
int iPeriod = 4; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV
int iPos = 22;
int iPos = 11;

#include "CMS_lumi.h"
#include <iostream>
Expand Down Expand Up @@ -193,10 +193,14 @@ std::string itoa(int i)

void BackgroundPrediction_Kinematic_Bern(double plot_lo, double plot_hi, double rebin,
double fit_lo, double fit_hi,
double gaussexp_mean_lo, double gaussexp_mean_hi,
double crystalball_mean_lo, double crystalball_mean_hi,
double crystalball_width_lo, double crystalball_width_hi,
double crystalball_exp_lo, double crystalball_exp_hi,
double crystalball_switch_lo, double crystalball_switch_hi,
/*double gaussexp_mean_lo, double gaussexp_mean_hi,
double gaussexp_width_lo, double gaussexp_width_hi,
double gaussexp_exp_lo, double gaussexp_exp_hi,
std::string hist="h_mX_SB_kinFit",
*/std::string hist="h_mX_SB_kinFit",
std::string log="lin")
{

Expand All @@ -206,9 +210,9 @@ void BackgroundPrediction_Kinematic_Bern(double plot_lo, double plot_hi, double
gStyle->SetOptStat(0000);
writeExtraText = true; // if extra text
extraText = "Preliminary"; // default extra text is "Preliminary"
lumi_13TeV = "2.3 fb^{-1}"; // default is "5.1 fb^{-1}"
lumi_13TeV = "35.9 fb^{-1}"; // default is "5.1 fb^{-1}"

TFile *f_data=new TFile("Histograms_BTagCSV_Skim.root");
TFile *f_data=new TFile("Histograms_BTagall.root");
TH1F *h_mX_SR=(TH1F*)f_data->Get(hist.c_str());
h_mX_SR->Rebin(rebin);
double nEventsSR=((TH1F*)f_data->Get("h_mX_SR_kinFit"))->GetSumOfWeights();
Expand All @@ -234,16 +238,16 @@ i*/ bg_p3=new RooRealVar("bg_p3", "bg_p3", 5.);
// bg_p10=new RooRealVar("bg_p10", "bg_p10", 0., 5.);
*/ // RooBernstein bg_pol("bg_pol", "bg_pol", *x, RooArgList(*bg_p4, *bg_p5, *bg_p6));

RooRealVar bg_p00("bg_p00", "bg_p00", gaussexp_mean_lo, gaussexp_mean_hi);
/*RooRealVar bg_p00("bg_p00", "bg_p00", gaussexp_mean_lo, gaussexp_mean_hi);
RooRealVar bg_p11("bg_p11", "bg_p11", gaussexp_width_lo, gaussexp_width_hi);
RooRealVar bg_p22("bg_p22", "bg_p22", gaussexp_exp_lo, gaussexp_exp_hi);

*/


RooRealVar bg_p0("bg_p0", "bg_p0", 0.); //gaussexp_mean_lo, gaussexp_mean_hi);
bg_p0.setConstant(1);
RooRealVar bg_p1("bg_p1", "bg_p1",1. , 100.);//gaussexp_width_lo, gaussexp_width_hi);
RooRealVar bg_p2("bg_p2", "bg_p2", 310., 600.); ///210., 300.
RooRealVar bg_p2("bg_p2", "bg_p2", 210., 300. );//310., 600.); ///210., 300.
// RooRealVar bg_p3("bg_p3", "bg_p3", -5., 5.);
// RooRealVar bg_p4("bg_p4", "bg_p4", -5., 5.);
/* bg_p3.setConstant(1);
Expand All @@ -267,16 +271,29 @@ i*/ bg_p3=new RooRealVar("bg_p3", "bg_p3", 5.);
//RooAddPdf bg("bg", "bg", RooArgList(bg_gauss, bg_pol), *bg_p7);
//bg.fitTo(pred, RooFit::Range(fit_lo, fit_hi), RooFit::Save(), RooFit::Minimizer("Minuit","simplex"));
RooFitResult *r_bg=bg.fitTo(pred, RooFit::Range(fit_lo, fit_hi), RooFit::Save());

bg_p1.setConstant(1);
/*bg_p1.setConstant(1);
bg_p2.setConstant(1);
bg_p4->setConstant(1);
bg_p5->setConstant(1);
bg_p6->setConstant(1);
bg_p7->setConstant(1);

*/

//GaussExp bg_exp("bg_exp", "Background Prediction PDF", *x, bg_p00, bg_p11, bg_p22);
RooRealVar bg_p00("bg_p00", "bg_p00", crystalball_switch_lo, crystalball_switch_hi);
RooRealVar bg_p11("bg_p11", "bg_p11", crystalball_exp_lo, crystalball_exp_hi);
RooRealVar bg_p22("bg_p22", "bg_p22", crystalball_mean_lo, crystalball_mean_hi);
RooRealVar bg_p33("bg_p33", "bg_p33", crystalball_width_lo, crystalball_width_hi);
RevCrystalBall bg_exp("bg_exp", "Background Prediction PDF", *x, bg_p00, bg_p11, bg_p22, bg_p33);

RooPlot *data_plot2=x->frame();
RooFitResult *r_bg_exp=bg_exp.fitTo(pred, RooFit::Range(fit_lo, fit_hi), RooFit::Save());
pred.plotOn(data_plot2);

//bg_exp.plotOn(data_plot2, RooFit::VisualizeError(*r_bg_exp, 1, kFALSE), RooFit::FillColor(kCyan+1), RooFit::FillStyle(3001));
bg_exp.plotOn(data_plot2, RooFit::LineColor(kBlue+1));
pred.plotOn(data_plot2, RooFit::LineColor(kBlack), RooFit::MarkerColor(kBlack));

GaussExp bg_exp("bg_exp", "Background Prediction PDF", *x, bg_p00, bg_p11, bg_p22);


RooPlot *data_plot=x->frame();
Expand All @@ -288,6 +305,10 @@ i*/ bg_p3=new RooRealVar("bg_p3", "bg_p3", 5.);
double fitChi2=data_plot->chiSquare();
std::cout<<"Fit chi2 = "<<fitChi2<<std::endl;

RooAbsReal* chi2_data = bg.createChi2(pred);
double pvalue=TMath::Prob(chi2_data->getVal(),int((fit_hi-fit_lo)/rebin)-3);
std::cout<<"p-value = "<<TMath::Prob(chi2_data->getVal(),int((fit_hi-fit_lo)/rebin)-3)<<std::endl;

/*TCanvas *c_Background=new TCanvas("c_Background", "c_Background", 700, 700);
TPad *p_1=new TPad("p_1", "p_1", 0, 0.35, 1, 1);
//p_1->SetBottomMargin(0.05);
Expand All @@ -309,30 +330,38 @@ i*/ bg_p3=new RooRealVar("bg_p3", "bg_p3", 5.);
c_Background->SetFillStyle(4000);
c_Background->SetFrameFillColor(0);

TPad *p_1=new TPad("p_1", "p_1", 0, xPad, 1, 1);
p_1->SetFillStyle(4000);
p_1->SetFrameFillColor(0);
TPad* p_2 = new TPad("p_2", "p_2",0,0,1,xPad);
p_2->SetBottomMargin((1.-xPad)/xPad*0.13);
p_2->SetTopMargin(0.06);
p_2->SetFillColor(0);
p_2->SetBorderMode(0);
p_2->SetBorderSize(2);
p_2->SetFrameBorderMode(0);
p_2->SetFrameBorderMode(0);
TPad *p_1=new TPad("p_1", "p_1", 0, xPad, 1, 1);
p_1->SetFillStyle(4000);
p_1->SetFrameFillColor(0);
p_1->SetBottomMargin(0.02);

TPad* p_2 = new TPad("p_2", "p_2",0,0,1,xPad);
p_2->SetBottomMargin((1.-xPad)/xPad*0.13);
p_2->SetTopMargin(0.03);
p_2->SetFillColor(0);
p_2->SetBorderMode(0);
p_2->SetBorderSize(2);
p_2->SetFrameBorderMode(0);
p_2->SetFrameBorderMode(0);

p_1->Draw();
p_2->Draw();
p_1->cd();



if (log=="log") data_plot->GetYaxis()->SetRangeUser(1e-4, h_mX_SR->GetMaximum()*5.);
else data_plot->GetYaxis()->SetRangeUser(0, h_mX_SR->GetMaximum()*1.5);
data_plot->Draw();
data_plot->GetXaxis()->SetLabelOffset(0.03);
data_plot->GetYaxis()->SetLabelFont(42);
data_plot->GetYaxis()->SetTitleFont(42);
data_plot2->Draw("same");
data_plot->GetYaxis()->SetTitleOffset(1.25);
data_plot->SetTitle(("; m_{X} (GeV); Events / "+itoa(h_mX_SR->GetBinWidth(1))+" GeV").c_str());
if (log=="log") p_1->SetLogy();

TPaveText *pave = new TPaveText(0.86,0.7,0.67,0.8,"NDC");
TPaveText *pave = new TPaveText(0.86,0.6,0.67,0.7,"NDC");
pave->SetBorderSize(0);
pave->SetTextSize(0.03);
pave->SetLineColor(1);
Expand All @@ -341,17 +370,22 @@ i*/ bg_p3=new RooRealVar("bg_p3", "bg_p3", 5.);
pave->SetFillColor(0);
pave->SetFillStyle(0);
char name[1000];
if (hist.substr(0,7)=="h_mX_SB") sprintf(name,"SB #chi^{2}/n = %.2f",fitChi2);
char name1[1000];
if (hist.substr(0,7)=="h_mX_SB") {
sprintf(name,"SB #chi^{2}/n = %.2f",fitChi2);
sprintf(name1,"p-value = %.2f",pvalue);
}
else sprintf(name,"SR #chi^{2}/n = %.2f",fitChi2);
pave->AddText(name);
pave->AddText(name1);
pave->Draw();

TLatex * tPrel = new TLatex();
tPrel->SetNDC();
tPrel->SetTextColor(kBlack);
tPrel->SetTextSize(0.04);

TLegend *leg = new TLegend(0.85625,0.7721654,0.6765625,0.8903839,NULL,"brNDC");
TLegend *leg = new TLegend(0.85625,0.721654,0.6165625,0.8903839,NULL,"brNDC");
leg->SetBorderSize(0);
leg->SetTextSize(0.035);
leg->SetLineColor(1);
Expand All @@ -360,8 +394,18 @@ i*/ bg_p3=new RooRealVar("bg_p3", "bg_p3", 5.);
leg->SetFillColor(0);
leg->SetFillStyle(0);
h_mX_SR->SetMarkerStyle(20);
if (hist.substr(0,7)=="h_mX_SB") leg->AddEntry(h_mX_SR, "Data in SB", "lep");
else leg->AddEntry(h_mX_SR, "Data in SR", "lep");
if (hist.substr(0,7)=="h_mX_SB"){
h_mX_SR->SetLineColor(kBlack);
h_mX_SR->SetMarkerColor(kBlack);
leg->AddEntry(h_mX_SR, "Data in SB", "ep");

}
else leg->AddEntry(h_mX_SR, "Data in SR", "ep");
TH1F * temp = new TH1F("temp", "temp", 100, 0,1); temp->SetLineWidth(2); temp->SetLineColor(kBlack);
leg->AddEntry(temp, "GaussBern fit", "l");
TH1F * temp1 = new TH1F("temp1", "temp1", 100, 0,1); temp1->SetLineWidth(2);
temp1->SetLineColor(kBlue+1);
leg->AddEntry(temp1, "CrystalBall fit", "l");
leg->Draw();

CMS_lumi( p_1, iPeriod, iPos );
Expand All @@ -370,6 +414,7 @@ i*/ bg_p3=new RooRealVar("bg_p3", "bg_p3", 5.);
RooHist *hpull;
hpull = data_plot->pullHist();
RooPlot* frameP = x->frame() ;

frameP->SetTitle("; m_{X} (GeV); Pull");
frameP->addPlotable(hpull,"P");
frameP->GetYaxis()->SetTitleSize(0.07);
Expand All @@ -380,6 +425,7 @@ i*/ bg_p3=new RooRealVar("bg_p3", "bg_p3", 5.);
frameP->GetYaxis()->SetLabelSize(0.06);
frameP->Draw();


TLine *line=new TLine(fit_lo, 0, fit_hi, 0);
line->SetLineWidth(2);
line->Draw();
Expand Down Expand Up @@ -430,10 +476,15 @@ i*/ bg_p3=new RooRealVar("bg_p3", "bg_p3", 5.);
// For the datacard
std::cout<<" === RooFit data fit result to be entered in datacard === "<<std::endl;
std::cout<<" Background number of events = "<<nEventsSR<<std::endl;
/* std::cout<< "bg_p0 param "<<bg_p0.getVal()<<" "<<bg_p0.getError()<<std::endl;
std::cout<< "bg_p0 param "<<bg_p0.getVal()<<" "<<bg_p0.getError()<<std::endl;
std::cout<< "bg_p1 param "<<bg_p1.getVal()<<" "<<bg_p1.getError()<<std::endl;
std::cout<< "bg_p2 param "<<bg_p2.getVal()<<" "<<bg_p2.getError()<<std::endl;
*/
std::cout<< "bg_p3 param "<<bg_p3->getVal()<<" "<<bg_p3->getError()<<std::endl;
std::cout<< "bg_p4 param "<<bg_p4->getVal()<<" "<<bg_p4->getError()<<std::endl;
std::cout<< "bg_p5 param "<<bg_p5->getVal()<<" "<<bg_p5->getError()<<std::endl;
std::cout<< "bg_p6 param "<<bg_p6->getVal()<<" "<<bg_p6->getError()<<std::endl;


}


Expand Down
Loading