1 |
buchmann |
1.1 |
#include <iostream>
|
2 |
|
|
#include <vector>
|
3 |
|
|
#include <sys/stat.h>
|
4 |
buchmann |
1.6 |
#include <fstream>
|
5 |
buchmann |
1.1 |
|
6 |
|
|
#include <TCut.h>
|
7 |
|
|
#include <TROOT.h>
|
8 |
|
|
#include <TCanvas.h>
|
9 |
|
|
#include <TMath.h>
|
10 |
|
|
#include <TColor.h>
|
11 |
|
|
#include <TPaveText.h>
|
12 |
|
|
#include <TRandom.h>
|
13 |
|
|
#include <TH1.h>
|
14 |
|
|
#include <TH2.h>
|
15 |
|
|
#include <TF1.h>
|
16 |
|
|
#include <TSQLResult.h>
|
17 |
|
|
#include <TProfile.h>
|
18 |
|
|
|
19 |
|
|
//#include "TTbar_stuff.C"
|
20 |
|
|
using namespace std;
|
21 |
|
|
|
22 |
|
|
using namespace PlottingSetup;
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
void rediscover_the_top(string mcjzb, string datajzb) {
|
26 |
buchmann |
1.3 |
dout << "Hi! today we are going to (try to) rediscover the top!" << endl;
|
27 |
buchmann |
1.1 |
TCanvas *c3 = new TCanvas("c3","c3");
|
28 |
|
|
c3->SetLogy(1);
|
29 |
|
|
vector<float> binning;
|
30 |
|
|
//binning=allsamples.get_optimal_binsize(mcjzb,cutmass&&cutOSSF&&cutnJets,20,50,800);
|
31 |
|
|
/*
|
32 |
|
|
binning.push_back(50);
|
33 |
|
|
binning.push_back(100);
|
34 |
|
|
binning.push_back(150);
|
35 |
|
|
binning.push_back(200);
|
36 |
|
|
binning.push_back(500);
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
TH1F *dataprediction = allsamples.Draw("dataprediction", "-"+datajzb, binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
|
40 |
|
|
TH1F *puresignal = allsamples.Draw("puresignal", datajzb, binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
|
41 |
|
|
// TH1F *puresignal = allsamples.Draw("puresignal", mcjzb, binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity,allsamples.FindSample("TTJets"));
|
42 |
|
|
TH1F *observed = allsamples.Draw("observed", datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity);
|
43 |
|
|
/*
|
44 |
|
|
ofstream myfile;
|
45 |
|
|
TH1F *ratio = (TH1F*)observed->Clone();
|
46 |
|
|
ratio->Divide(dataprediction);
|
47 |
|
|
ratio->GetYaxis()->SetTitle("Ratio obs/pred");
|
48 |
|
|
ratio->Draw();
|
49 |
|
|
c3->SaveAs("testratio.png");
|
50 |
|
|
myfile.open ("ShapeFit_log.txt");
|
51 |
|
|
establish_upper_limits(observed,dataprediction,puresignal,"LM4",myfile);
|
52 |
|
|
myfile.close();
|
53 |
|
|
*/
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
int nbins=100;
|
57 |
|
|
float low=0;
|
58 |
|
|
float hi=500;
|
59 |
|
|
TCanvas *c4 = new TCanvas("c4","c4",900,900);
|
60 |
|
|
c4->Divide(2,2);
|
61 |
|
|
c4->cd(1);
|
62 |
|
|
c4->cd(1)->SetLogy(1);
|
63 |
|
|
TH1F *datapredictiont = allsamples.Draw("datapredictiont", "-"+datajzb, nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
|
64 |
|
|
TH1F *datapredictiono = allsamples.Draw("datapredictiono", "-"+datajzb, nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
|
65 |
|
|
datapredictiont->Add(datapredictiono,-1);
|
66 |
buchmann |
1.3 |
dout << "Second way of doing this !!!! Analytical shape to the left :-D" << endl;
|
67 |
buchmann |
1.1 |
vector<TF1*> functions = do_cb_fit_to_plot(datapredictiont,10);
|
68 |
|
|
datapredictiont->SetMarkerColor(kRed);
|
69 |
|
|
datapredictiont->SetLineColor(kRed);
|
70 |
|
|
datapredictiont->Draw();
|
71 |
|
|
functions[1]->Draw("same");
|
72 |
|
|
TText *title1 = write_title("Top Background Prediction (JZB<0, with osof subtr)");
|
73 |
|
|
title1->Draw();
|
74 |
|
|
|
75 |
|
|
c4->cd(2);
|
76 |
|
|
c4->cd(2)->SetLogy(1);
|
77 |
|
|
TH1F *observedt = allsamples.Draw("observedt", datajzb, nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
|
78 |
|
|
observedt->Draw();
|
79 |
|
|
datapredictiont->Draw("histo,same");
|
80 |
|
|
functions[1]->Draw("same");
|
81 |
|
|
TText *title2 = write_title("Observed and predicted background");
|
82 |
|
|
title2->Draw();
|
83 |
|
|
|
84 |
|
|
c4->cd(3);
|
85 |
|
|
c4->cd(3)->SetLogy(1);
|
86 |
|
|
// TH1F *ratio = (TH1F*)observedt->Clone();
|
87 |
|
|
|
88 |
|
|
TH1F *analytical_background_prediction= new TH1F("analytical_background_prediction","",nbins,low,hi);
|
89 |
|
|
for(int i=0;i<=nbins;i++) {
|
90 |
|
|
analytical_background_prediction->SetBinContent(i+1,functions[1]->Eval(((hi-low)/((float)nbins))*(i+0.5)));
|
91 |
|
|
analytical_background_prediction->SetBinError(i+1,TMath::Sqrt(functions[1]->Eval(((hi-low)/((float)nbins))*(i+0.5))));
|
92 |
|
|
}
|
93 |
|
|
analytical_background_prediction->GetYaxis()->SetTitle("JZB [GeV]");
|
94 |
|
|
analytical_background_prediction->GetYaxis()->CenterTitle();
|
95 |
|
|
TH1F *analyticaldrawonly = (TH1F*)analytical_background_prediction->Clone();
|
96 |
|
|
analytical_background_prediction->SetFillColor(TColor::GetColor("#3399FF"));
|
97 |
|
|
analytical_background_prediction->SetMarkerSize(0);
|
98 |
|
|
analytical_background_prediction->Draw("e5");
|
99 |
|
|
analyticaldrawonly->Draw("histo,same");
|
100 |
|
|
functions[1]->Draw("same");
|
101 |
|
|
TText *title3 = write_title("Analytical bg pred histo");
|
102 |
|
|
title3->Draw();
|
103 |
|
|
|
104 |
|
|
c4->cd(4);
|
105 |
|
|
// c4->cd(4)->SetLogy(1);
|
106 |
|
|
vector<float> ratio_binning;
|
107 |
|
|
ratio_binning.push_back(0);
|
108 |
|
|
ratio_binning.push_back(5);
|
109 |
|
|
ratio_binning.push_back(10);
|
110 |
|
|
ratio_binning.push_back(20);
|
111 |
|
|
ratio_binning.push_back(50);
|
112 |
|
|
// ratio_binning.push_back(60);
|
113 |
|
|
/*
|
114 |
|
|
ratio_binning.push_back(51);
|
115 |
|
|
ratio_binning.push_back(52);
|
116 |
|
|
ratio_binning.push_back(53);
|
117 |
|
|
ratio_binning.push_back(54);
|
118 |
|
|
ratio_binning.push_back(55);
|
119 |
|
|
ratio_binning.push_back(56);
|
120 |
|
|
ratio_binning.push_back(57);
|
121 |
|
|
ratio_binning.push_back(58);
|
122 |
|
|
ratio_binning.push_back(59);
|
123 |
|
|
ratio_binning.push_back(60);
|
124 |
|
|
// ratio_binning.push_back(70);*/
|
125 |
|
|
// ratio_binning.push_back(80);
|
126 |
|
|
// ratio_binning.push_back(90);
|
127 |
|
|
ratio_binning.push_back(80);
|
128 |
|
|
// ratio_binning.push_back(110);
|
129 |
|
|
ratio_binning.push_back(500);
|
130 |
|
|
|
131 |
|
|
TH1F *observedtb = allsamples.Draw("observedtb", datajzb, ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
|
132 |
|
|
TH1F *datapredictiontb = allsamples.Draw("datapredictiontb", "-"+datajzb, ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
|
133 |
|
|
TH1F *datapredictiontbo = allsamples.Draw("datapredictiontbo", "-"+datajzb, ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
|
134 |
|
|
datapredictiontb->Add(datapredictiontbo,-1);
|
135 |
|
|
TH1F *analytical_background_predictionb = allsamples.Draw("analytical_background_predictionb",datajzb, ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"mll<2",data, luminosity);
|
136 |
|
|
for(int i=0;i<=ratio_binning.size();i++) {
|
137 |
|
|
analytical_background_predictionb->SetBinContent(i+1,functions[1]->Eval(analytical_background_predictionb->GetBinCenter(i)));
|
138 |
|
|
analytical_background_predictionb->SetBinError(i+1,TMath::Sqrt(functions[1]->Eval(analytical_background_predictionb->GetBinCenter(i))));
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
TH1F *ratio = (TH1F*) observedtb->Clone();
|
142 |
|
|
ratio->Divide(datapredictiontb);
|
143 |
|
|
|
144 |
|
|
for (int i=0;i<=ratio_binning.size();i++) {
|
145 |
buchmann |
1.3 |
dout << observedtb->GetBinLowEdge(i+1) << ";"<<observedtb->GetBinContent(i+1) << ";" << datapredictiontb->GetBinContent(i+1) << " --> " << ratio->GetBinContent(i+1) << "+/-" << ratio->GetBinError(i+1) << endl;
|
146 |
buchmann |
1.1 |
}
|
147 |
|
|
|
148 |
|
|
// ratio->Divide(datapredictiontb);
|
149 |
|
|
// ratio->Divide(analytical_background_predictionb);
|
150 |
|
|
// TGraphAsymmErrors *JZBratio= histRatio(observedtb,analytical_background_predictionb,data,ratio_binning);
|
151 |
|
|
// ratio->Divide(analytical_background_prediction);
|
152 |
|
|
// ratio->Divide(datapredictiont);
|
153 |
|
|
// ratio->GetYaxis()->SetTitle("obs/pred");
|
154 |
|
|
// JZBratio->Draw("AP");
|
155 |
|
|
ratio->GetYaxis()->SetRangeUser(0,10);
|
156 |
|
|
ratio->Draw();
|
157 |
|
|
//analytical_background_predictionb->Draw();
|
158 |
|
|
// JZBratio->SetTitle("");
|
159 |
|
|
TText *title4 = write_title("Ratio of observed to predicted");
|
160 |
|
|
title4->Draw();
|
161 |
|
|
|
162 |
|
|
// CompleteSave(c4,"test/ttbar_discovery_dataprediction___analytical_function");
|
163 |
|
|
CompleteSave(c4,"test/ttbar_discovery_dataprediction__analytical__new_binning_one_huge_bin_from_80");
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
}
|
170 |
|
|
|
171 |
buchmann |
1.15 |
vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, string plotfilename, bool doobserved) {
|
172 |
buchmann |
1.11 |
float sigma95=-9.9,sigma95A=-9.9;
|
173 |
buchmann |
1.15 |
int nuisancemodel=0;
|
174 |
|
|
/*
|
175 |
|
|
USAGE OF ROOSTATS_CL95
|
176 |
|
|
" Double_t limit = roostats_cl95(ilum, slum, eff, seff, bck, sbck, n, gauss = false, nuisanceModel, method, plotFileName, seed); \n"
|
177 |
|
|
" LimitResult expected_limit = roostats_clm(ilum, slum, eff, seff, bck, sbck, ntoys, nuisanceModel, method, seed); \n"
|
178 |
|
|
" Double_t average_limit = roostats_cla(ilum, slum, eff, seff, bck, sbck, nuisanceModel, method, seed); \n"
|
179 |
|
|
" \n"
|
180 |
|
|
"
|
181 |
|
|
" Double_t obs_limit = limit.GetObservedLimit(); \n"
|
182 |
|
|
" Double_t exp_limit = limit.GetExpectedLimit(); \n"
|
183 |
|
|
" Double_t exp_up = limit.GetOneSigmaHighRange(); \n"
|
184 |
|
|
" Double_t exp_down = limit.GetOneSigmaLowRange(); \n"
|
185 |
|
|
" Double_t exp_2up = limit.GetTwoSigmaHighRange(); \n"
|
186 |
|
|
" Double_t exp_2down = limit.GetTwoSigmaLowRange(); \n"
|
187 |
|
|
*/
|
188 |
buchmann |
1.12 |
if(mceff<=0) {
|
189 |
buchmann |
1.11 |
write_warning(__FUNCTION__,"Cannot compute upper limit in this configuration as the efficiency is negative:");
|
190 |
|
|
dout << "mc efficiency=" << mceff << " +/- " << mcefferr;
|
191 |
|
|
vector<float> sigmas;
|
192 |
|
|
sigmas.push_back(-1);
|
193 |
|
|
sigmas.push_back(-1);
|
194 |
|
|
return sigmas;
|
195 |
|
|
} else {
|
196 |
buchmann |
1.15 |
int nlimittoysused=1;
|
197 |
buchmann |
1.18 |
//if(doobserved) nlimittoysused=nlimittoys;
|
198 |
|
|
nlimittoysused=nlimittoys;
|
199 |
|
|
dout << "Now calling : CL95(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl;
|
200 |
buchmann |
1.4 |
sigma95 = CL95(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], Nobs[ibin], false, nuisancemodel);
|
201 |
buchmann |
1.15 |
|
202 |
buchmann |
1.18 |
/* dout << "Now calling : roostats_cl95(" << luminosity << "," << lumiuncert*luminosity << ","<<mceff <<","<<mcefferr<<","<<Npred[ibin]<<","<<Nprederr[ibin] << ",n=" << nlimittoysused << ",gauss=" << false << ",nuisanceModel="<<nuisancemodel<<",method="<<limitmethod<<",plotfilename="<<plotfilename<<",seed=0) " << endl;
|
203 |
|
|
/* dout << "Now calling : roostats_limit(" << luminosity << "," << lumiuncert*luminosity << ","<<mceff <<","<<mcefferr<<","<<Npred[ibin]<<","<<Nprederr[ibin] << ",n=" << nlimittoysused << ",gauss=" << false << ", nuisanceModel="<<nuisancemodel<<",method="<<limitmethod<<",plotfilename="<<plotfilename<<",seed=1) " << endl;
|
204 |
|
|
LimitResult limit = roostats_limit(luminosity,lumiuncert*luminosity,mceff,mcefferr,Npred[ibin],Nprederr[ibin],nlimittoysused,false,nuisancemodel,limitmethod,plotfilename,0);
|
205 |
|
|
dout << "Now interpreting and saving results ... " << endl;
|
206 |
buchmann |
1.2 |
vector<float> sigmas;
|
207 |
buchmann |
1.15 |
sigmas.push_back(limit.GetExpectedLimit());//expected
|
208 |
|
|
sigmas.push_back(limit.GetObservedLimit());//observed
|
209 |
|
|
//up to here for backward compatibility
|
210 |
|
|
sigmas.push_back(limit.GetOneSigmaHighRange());//expected, up
|
211 |
|
|
sigmas.push_back(limit.GetTwoSigmaHighRange());//expected, 2 up
|
212 |
|
|
sigmas.push_back(limit.GetOneSigmaLowRange());//expected, down
|
213 |
|
|
sigmas.push_back(limit.GetTwoSigmaLowRange());//expected, 2 down
|
214 |
buchmann |
1.18 |
*/
|
215 |
|
|
// float limit = roostats_cl95(luminosity,lumiuncert*luminosity,mceff,mcefferr,Npred[ibin],Nprederr[ibin],nlimittoysused,false,nuisancemodel,limitmethod,plotfilename,0);
|
216 |
|
|
if(doobserved) {
|
217 |
|
|
dout << "Now calling : CLA(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << nuisancemodel<< ") " << endl;
|
218 |
|
|
sigma95A = CLA(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], nuisancemodel);
|
219 |
|
|
}
|
220 |
|
|
// vector<float> sigmas;
|
221 |
|
|
// sigmas.push_back(limit);
|
222 |
|
|
vector<float> sigmas;
|
223 |
buchmann |
1.2 |
sigmas.push_back(sigma95);
|
224 |
buchmann |
1.18 |
sigmas.push_back(sigma95A);
|
225 |
buchmann |
1.2 |
return sigmas;
|
226 |
buchmann |
1.15 |
|
227 |
|
|
|
228 |
buchmann |
1.11 |
}
|
229 |
buchmann |
1.15 |
write_warning(__FUNCTION__,"STILL MISSING SIGMAS, LIMITS, EVERYTHING ...");
|
230 |
buchmann |
1.2 |
}
|
231 |
|
|
|
232 |
|
|
void compute_upper_limits_from_counting_experiment(vector<vector<float> > uncertainties,vector<float> jzbcuts, string mcjzb, bool doobserved) {
|
233 |
buchmann |
1.3 |
dout << "Doing counting experiment ... " << endl;
|
234 |
buchmann |
1.2 |
vector<vector<string> > limits;
|
235 |
|
|
vector<vector<float> > vlimits;
|
236 |
|
|
|
237 |
buchmann |
1.1 |
|
238 |
|
|
for(int isample=0;isample<signalsamples.collection.size();isample++) {
|
239 |
buchmann |
1.2 |
vector<string> rows;
|
240 |
|
|
vector<float> vrows;
|
241 |
buchmann |
1.3 |
dout << "Considering sample " << signalsamples.collection[isample].samplename << endl;
|
242 |
buchmann |
1.2 |
rows.push_back(signalsamples.collection[isample].samplename);
|
243 |
buchmann |
1.1 |
for(int ibin=0;ibin<jzbcuts.size();ibin++) {
|
244 |
buchmann |
1.3 |
dout << "_________________________________________________________________________________" << endl;
|
245 |
buchmann |
1.2 |
float JZBcutat=uncertainties[isample*jzbcuts.size()+ibin][0];
|
246 |
|
|
float mceff=uncertainties[isample*jzbcuts.size()+ibin][1];
|
247 |
|
|
float staterr=uncertainties[isample*jzbcuts.size()+ibin][2];
|
248 |
|
|
float systerr=uncertainties[isample*jzbcuts.size()+ibin][3];
|
249 |
|
|
float toterr =uncertainties[isample*jzbcuts.size()+ibin][4];
|
250 |
fronga |
1.9 |
float observed,observederr,null,result;
|
251 |
buchmann |
1.11 |
|
252 |
|
|
// fill_result_histos(observed,observederr, null,null,null,null,null,null,null,mcjzb,JZBcutat,14000,(int)5,result,(signalsamples.FindSample(signalsamples.collection[isample].filename)),signalsamples);
|
253 |
|
|
// observed-=result;//this is the actual excess we see!
|
254 |
|
|
// float expected=observed/luminosity;
|
255 |
buchmann |
1.17 |
string plotfilename=(string)(TString(signalsamples.collection[isample].samplename)+TString("___JZB_geq_")+TString(any2string(JZBcutat))+TString(".png"));
|
256 |
buchmann |
1.3 |
dout << "Sample: " << signalsamples.collection[isample].samplename << ", JZB>"<<JZBcutat<< " : " << mceff << " +/- " << staterr << " (stat) +/- " << systerr << " (syst) --> toterr = " << toterr << endl;
|
257 |
buchmann |
1.15 |
vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,plotfilename,doobserved);
|
258 |
buchmann |
1.2 |
|
259 |
|
|
if(doobserved) {
|
260 |
buchmann |
1.11 |
// rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(expected)+")");
|
261 |
|
|
rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(signalsamples.collection[isample].xs)+")");
|
262 |
buchmann |
1.2 |
vrows.push_back(sigmas[0]);
|
263 |
|
|
vrows.push_back(sigmas[1]);
|
264 |
buchmann |
1.11 |
// vrows.push_back(expected);
|
265 |
|
|
vrows.push_back(signalsamples.collection[isample].xs);
|
266 |
buchmann |
1.2 |
}
|
267 |
|
|
else {
|
268 |
buchmann |
1.11 |
// rows.push_back(any2string(sigmas[0])+"("+any2string(expected)+")");
|
269 |
|
|
rows.push_back(any2string(sigmas[0]));
|
270 |
buchmann |
1.2 |
vrows.push_back(sigmas[0]);
|
271 |
buchmann |
1.11 |
vrows.push_back(signalsamples.collection[isample].xs);
|
272 |
|
|
// vrows.push_back(expected);
|
273 |
buchmann |
1.2 |
}
|
274 |
buchmann |
1.1 |
}//end of bin loop
|
275 |
buchmann |
1.2 |
limits.push_back(rows);
|
276 |
|
|
vlimits.push_back(vrows);
|
277 |
buchmann |
1.1 |
}//end of sample loop
|
278 |
buchmann |
1.12 |
dout << endl << endl << endl << "_________________________________________________________________________________________________" << endl << endl;
|
279 |
buchmann |
1.11 |
dout << endl << endl << "PAS table 3: (notation: limit [95%CL])" << endl << endl;
|
280 |
buchmann |
1.3 |
dout << "\t";
|
281 |
buchmann |
1.2 |
for (int irow=0;irow<jzbcuts.size();irow++) {
|
282 |
buchmann |
1.3 |
dout << jzbcuts[irow] << "\t";
|
283 |
buchmann |
1.2 |
}
|
284 |
buchmann |
1.3 |
dout << endl;
|
285 |
buchmann |
1.2 |
for(int irow=0;irow<limits.size();irow++) {
|
286 |
|
|
for(int ientry=0;ientry<limits[irow].size();ientry++) {
|
287 |
buchmann |
1.12 |
if (limits[irow][ientry]>0) dout << limits[irow][ientry] << "\t";
|
288 |
|
|
else dout << " (N/A) \t";
|
289 |
buchmann |
1.2 |
}
|
290 |
buchmann |
1.3 |
dout << endl;
|
291 |
buchmann |
1.2 |
}
|
292 |
|
|
|
293 |
|
|
if(!doobserved) {
|
294 |
buchmann |
1.12 |
dout << endl << endl << "LIMITS: (Tex)" << endl;
|
295 |
buchmann |
1.13 |
tout << "\\begin{table}[hbtp]" << endl;
|
296 |
|
|
tout << "\\renewcommand{\arraystretch}{1.3}" << endl;
|
297 |
|
|
tout << "\\begin{center}" << endl;
|
298 |
buchmann |
1.14 |
tout << "\\caption{Observed upper limits on the cross section of different LM benchmark points " << (ConsiderSignalContaminationForLimits?" (accounting for signal contamination)":" (not accounting for signal contamination)") << "}\\label{tab:lmresults}" << endl;
|
299 |
buchmann |
1.13 |
tout << "" << endl;
|
300 |
buchmann |
1.12 |
tout << "\\begin{tabular}{ | l | ";
|
301 |
|
|
for (int irow=0;irow<jzbcuts.size();irow++) tout << " l |";
|
302 |
|
|
tout << "} " << endl << " \\hline " << endl << "& \t ";
|
303 |
buchmann |
1.2 |
for (int irow=0;irow<jzbcuts.size();irow++) {
|
304 |
buchmann |
1.12 |
tout << "JZB $>$ " << jzbcuts[irow] << " GeV & \t ";
|
305 |
buchmann |
1.2 |
}
|
306 |
buchmann |
1.12 |
tout << " \\\\ \\hline " << endl;
|
307 |
buchmann |
1.2 |
for(int irow=0;irow<limits.size();irow++) {
|
308 |
buchmann |
1.12 |
tout << limits[irow][0] << " \t";
|
309 |
buchmann |
1.2 |
for(int ientry=0;ientry<jzbcuts.size();ientry++) {
|
310 |
buchmann |
1.12 |
if(vlimits[irow][2*ientry]>0) tout << " & " << Round(vlimits[irow][2*ientry],2) << " \t (" << Round(vlimits[irow][2*ientry] / vlimits[irow][2*ientry+1],3)<< "x \\sigma ) \t";
|
311 |
|
|
else tout << " & ( N / A ) \t";
|
312 |
buchmann |
1.11 |
// dout << Round(vlimits[irow][2*ientry],3) << " / " << Round(vlimits[irow][2*ientry+1],3)<< "\t";
|
313 |
buchmann |
1.2 |
}
|
314 |
buchmann |
1.12 |
tout << " \\\\ \\hline " << endl;
|
315 |
buchmann |
1.2 |
}
|
316 |
buchmann |
1.12 |
tout << "\\end{tabular}" << endl;
|
317 |
buchmann |
1.13 |
tout << " \\end{tabular}"<< endl;
|
318 |
|
|
tout << "\\end{center}"<< endl;
|
319 |
|
|
tout << "\\end{table} "<< endl;
|
320 |
|
|
|
321 |
buchmann |
1.2 |
}//do observed
|
322 |
buchmann |
1.3 |
|
323 |
|
|
dout << endl << endl << "Final selection efficiencies with total statistical and systematic errors, and corresponding observed and expected upper limits (UL) on ($\\sigma\\times$ BR $\\times$ acceptance) for the LM4 and LM8 scenarios, in the different regions. The last column contains the predicted ($\\sigma \\times $BR$\\times$ acceptance) at NLO obtained from Monte Carlo simulation." << endl;
|
324 |
buchmann |
1.11 |
dout << "Scenario \t Efficiency [%] \t Upper limits [pb] \t \\sigma [pb]" << endl;
|
325 |
buchmann |
1.3 |
for(int icut=0;icut<jzbcuts.size();icut++) {
|
326 |
buchmann |
1.14 |
dout << "Region with JZB>" << jzbcuts[icut] << (ConsiderSignalContaminationForLimits?" (accounting for signal contamination)":" (not accounting for signal contamination)") << endl;
|
327 |
buchmann |
1.3 |
for(int isample=0;isample<signalsamples.collection.size();isample++) {
|
328 |
buchmann |
1.11 |
dout << limits[isample][0] << "\t" << Round(100*uncertainties[isample*jzbcuts.size()+icut][1],3) << "+/-" << Round(100*uncertainties[isample*jzbcuts.size()+icut][2],3) << " (stat) +/- " << Round(100*uncertainties[isample*jzbcuts.size()+icut][3],3) << " (syst) \t" << Round((vlimits[isample][2*icut]),3) << "\t" << Round(vlimits[isample][2*icut+1],3) << endl;
|
329 |
buchmann |
1.3 |
}
|
330 |
|
|
dout << endl;
|
331 |
|
|
}
|
332 |
buchmann |
1.4 |
|
333 |
buchmann |
1.11 |
write_warning(__FUNCTION__,"Still need to update the script");
|
334 |
buchmann |
1.1 |
}
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
|
338 |
buchmann |
1.7 |
/********************************************************************** new : Limits using SHAPES ***********************************
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
SSSSSSSSSSSSSSS hhhhhhh
|
342 |
|
|
SS:::::::::::::::Sh:::::h
|
343 |
|
|
S:::::SSSSSS::::::Sh:::::h
|
344 |
|
|
S:::::S SSSSSSSh:::::h
|
345 |
|
|
S:::::S h::::h hhhhh aaaaaaaaaaaaa ppppp ppppppppp eeeeeeeeeeee ssssssssss
|
346 |
|
|
S:::::S h::::hh:::::hhh a::::::::::::a p::::ppp:::::::::p ee::::::::::::ee ss::::::::::s
|
347 |
|
|
S::::SSSS h::::::::::::::hh aaaaaaaaa:::::ap:::::::::::::::::p e::::::eeeee:::::eess:::::::::::::s
|
348 |
|
|
SS::::::SSSSS h:::::::hhh::::::h a::::app::::::ppppp::::::pe::::::e e:::::es::::::ssss:::::s
|
349 |
|
|
SSS::::::::SS h::::::h h::::::h aaaaaaa:::::a p:::::p p:::::pe:::::::eeeee::::::e s:::::s ssssss
|
350 |
|
|
SSSSSS::::S h:::::h h:::::h aa::::::::::::a p:::::p p:::::pe:::::::::::::::::e s::::::s
|
351 |
|
|
S:::::S h:::::h h:::::h a::::aaaa::::::a p:::::p p:::::pe::::::eeeeeeeeeee s::::::s
|
352 |
|
|
S:::::S h:::::h h:::::ha::::a a:::::a p:::::p p::::::pe:::::::e ssssss s:::::s
|
353 |
|
|
SSSSSSS S:::::S h:::::h h:::::ha::::a a:::::a p:::::ppppp:::::::pe::::::::e s:::::ssss::::::s
|
354 |
|
|
S::::::SSSSSS:::::S h:::::h h:::::ha:::::aaaa::::::a p::::::::::::::::p e::::::::eeeeeeee s::::::::::::::s
|
355 |
|
|
S:::::::::::::::SS h:::::h h:::::h a::::::::::aa:::ap::::::::::::::pp ee:::::::::::::e s:::::::::::ss
|
356 |
|
|
SSSSSSSSSSSSSSS hhhhhhh hhhhhhh aaaaaaaaaa aaaap::::::pppppppp eeeeeeeeeeeeee sssssssssss
|
357 |
|
|
p:::::p
|
358 |
|
|
p:::::p
|
359 |
|
|
p:::::::p
|
360 |
|
|
p:::::::p
|
361 |
|
|
p:::::::p
|
362 |
|
|
ppppppppp
|
363 |
|
|
|
364 |
|
|
|
365 |
|
|
*********************************************************************** new : Limits using SHAPES ***********************************/
|
366 |
|
|
|
367 |
buchmann |
1.5 |
|
368 |
|
|
void limit_shapes_for_systematic_effect(TFile *limfile, string identifier, string mcjzb, string datajzb, int JES,vector<float> binning, TCanvas *limcan) {
|
369 |
|
|
dout << "Creatig shape templates ... ";
|
370 |
|
|
if(identifier!="") dout << "for systematic called "<<identifier;
|
371 |
|
|
dout << endl;
|
372 |
|
|
int dataormc=mcwithsignal;//this is only for tests - for real life you want dataormc=data !!!
|
373 |
buchmann |
1.6 |
if(dataormc!=data) write_warning(__FUNCTION__,"WATCH OUT! Not using data for limits!!!! this is ok for tests, but not ok for anything official!");
|
374 |
buchmann |
1.5 |
|
375 |
|
|
TCut limitnJetcut;
|
376 |
|
|
if(JES==noJES) limitnJetcut=cutnJets;
|
377 |
|
|
else {
|
378 |
|
|
if(JES==JESdown) limitnJetcut=cutnJetsJESdown;
|
379 |
|
|
if(JES==JESup) limitnJetcut=cutnJetsJESup;
|
380 |
|
|
}
|
381 |
|
|
TH1F *ZOSSFP = allsamples.Draw("ZOSSFP",datajzb,binning, "JZB4limits", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,dataormc,luminosity);
|
382 |
|
|
TH1F *ZOSOFP = allsamples.Draw("ZOSOFP",datajzb,binning, "JZB4limits", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,dataormc,luminosity);
|
383 |
|
|
TH1F *ZOSSFN = allsamples.Draw("ZOSSFN","-"+datajzb,binning, "JZB4limits", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,dataormc,luminosity);
|
384 |
|
|
TH1F *ZOSOFN = allsamples.Draw("ZOSOFN","-"+datajzb,binning, "JZB4limits", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,dataormc,luminosity);
|
385 |
|
|
|
386 |
|
|
TH1F *SBOSSFP = allsamples.Draw("SBOSSFP",datajzb,binning, "JZB4limits", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,dataormc,luminosity);
|
387 |
|
|
TH1F *SBOSOFP = allsamples.Draw("SBOSOFP",datajzb,binning, "JZB4limits", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,dataormc,luminosity);
|
388 |
|
|
TH1F *SBOSSFN = allsamples.Draw("SBOSSFN","-"+datajzb,binning, "JZB4limits", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,dataormc,luminosity);
|
389 |
|
|
TH1F *SBOSOFN = allsamples.Draw("SBOSOFN","-"+datajzb,binning, "JZB4limits", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,dataormc,luminosity);
|
390 |
|
|
|
391 |
|
|
TH1F *LZOSSFP = allsamples.Draw("LZOSSFP",mcjzb,binning, "JZB4limits", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,mc,luminosity,allsamples.FindSample("LM4"));
|
392 |
|
|
TH1F *LZOSOFP = allsamples.Draw("LZOSOFP",mcjzb,binning, "JZB4limits", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,mc,luminosity,allsamples.FindSample("LM4"));
|
393 |
|
|
TH1F *LZOSSFN = allsamples.Draw("LZOSSFN","-"+mcjzb,binning, "JZB4limits", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,mc,luminosity,allsamples.FindSample("LM4"));
|
394 |
|
|
TH1F *LZOSOFN = allsamples.Draw("LZOSOFN","-"+mcjzb,binning, "JZB4limits", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,mc,luminosity,allsamples.FindSample("LM4"));
|
395 |
|
|
|
396 |
|
|
TH1F *LSBOSSFP = allsamples.Draw("LSBOSSFP",mcjzb,binning, "JZB4limits", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,mc,luminosity,allsamples.FindSample("LM4"));
|
397 |
|
|
TH1F *LSBOSOFP = allsamples.Draw("LSBOSOFP",mcjzb,binning, "JZB4limits", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,mc,luminosity,allsamples.FindSample("LM4"));
|
398 |
|
|
TH1F *LSBOSSFN = allsamples.Draw("LSBOSSFN","-"+mcjzb,binning, "JZB4limits", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,mc,luminosity,allsamples.FindSample("LM4"));
|
399 |
|
|
TH1F *LSBOSOFN = allsamples.Draw("LSBOSOFN","-"+mcjzb,binning, "JZB4limits", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,mc,luminosity,allsamples.FindSample("LM4"));
|
400 |
|
|
|
401 |
|
|
string obsname="data_obs";
|
402 |
|
|
string predname="background";
|
403 |
|
|
string signalname="signal";
|
404 |
|
|
if(identifier!="") {
|
405 |
|
|
obsname=("data_"+identifier);
|
406 |
|
|
predname=("background_"+identifier);
|
407 |
|
|
signalname="signal_"+identifier;
|
408 |
|
|
}
|
409 |
|
|
|
410 |
|
|
TH1F *obs = (TH1F*)ZOSSFP->Clone();
|
411 |
|
|
obs->SetName(obsname.c_str());
|
412 |
|
|
obs->Write();
|
413 |
|
|
TH1F *pred = (TH1F*)ZOSSFN->Clone();
|
414 |
|
|
pred->Add(ZOSOFP,1.0/3);
|
415 |
|
|
pred->Add(ZOSOFN,-1.0/3);
|
416 |
|
|
pred->Add(SBOSSFP,1.0/3);
|
417 |
|
|
pred->Add(SBOSSFN,-1.0/3);
|
418 |
|
|
pred->Add(SBOSOFP,1.0/3);
|
419 |
|
|
pred->Add(SBOSOFN,-1.0/3);
|
420 |
|
|
pred->SetName(predname.c_str());
|
421 |
|
|
pred->Write();
|
422 |
|
|
|
423 |
|
|
// TH1F *Lobs = (TH1F*)LZOSSFP->Clone();
|
424 |
|
|
// TH1F *Lpred = (TH1F*)LZOSSFN->Clone();
|
425 |
|
|
|
426 |
|
|
TH1F *Lobs = new TH1F("Lobs","Lobs",binning.size()-1,&binning[0]);
|
427 |
|
|
TH1F *Lpred = new TH1F("Lpred","Lpred",binning.size()-1,&binning[0]);
|
428 |
|
|
Lobs->Add(LZOSSFP);
|
429 |
|
|
Lpred->Add(LZOSSFN);
|
430 |
|
|
Lpred->Add(LZOSOFP,1.0/3);
|
431 |
|
|
Lpred->Add(LZOSOFN,-1.0/3);
|
432 |
|
|
Lpred->Add(LSBOSSFP,1.0/3);
|
433 |
|
|
Lpred->Add(LSBOSSFN,-1.0/3);
|
434 |
|
|
Lpred->Add(LSBOSOFP,1.0/3);
|
435 |
|
|
Lpred->Add(LSBOSOFN,-1.0/3);
|
436 |
|
|
TH1F *signal = (TH1F*)Lobs->Clone();
|
437 |
|
|
signal->Add(Lpred,-1);
|
438 |
|
|
signal->SetName(signalname.c_str());
|
439 |
|
|
signal->Write();
|
440 |
|
|
|
441 |
|
|
delete Lobs;
|
442 |
|
|
delete Lpred;
|
443 |
|
|
|
444 |
|
|
delete ZOSSFP;
|
445 |
|
|
delete ZOSOFP;
|
446 |
|
|
delete ZOSSFN;
|
447 |
|
|
delete ZOSOFN;
|
448 |
|
|
|
449 |
|
|
delete SBOSSFP;
|
450 |
|
|
delete SBOSOFP;
|
451 |
|
|
delete SBOSSFN;
|
452 |
|
|
delete SBOSOFN;
|
453 |
|
|
|
454 |
|
|
delete LZOSSFP;
|
455 |
|
|
delete LZOSOFP;
|
456 |
|
|
delete LZOSSFN;
|
457 |
|
|
delete LZOSOFN;
|
458 |
|
|
|
459 |
|
|
delete LSBOSSFP;
|
460 |
|
|
delete LSBOSOFP;
|
461 |
|
|
delete LSBOSSFN;
|
462 |
|
|
delete LSBOSOFN;
|
463 |
|
|
|
464 |
|
|
}
|
465 |
|
|
|
466 |
|
|
void prepare_datacard(TFile *f) {
|
467 |
|
|
TH1F *dataob = (TH1F*)f->Get("data_obs");
|
468 |
|
|
TH1F *signal = (TH1F*)f->Get("signal");
|
469 |
|
|
TH1F *background = (TH1F*)f->Get("background");
|
470 |
|
|
|
471 |
|
|
ofstream datacard;
|
472 |
|
|
ensure_directory_exists(get_directory()+"/limits");
|
473 |
buchmann |
1.6 |
datacard.open ((get_directory()+"/limits/susydatacard.txt").c_str());
|
474 |
buchmann |
1.5 |
datacard << "Writing this to a file.\n";
|
475 |
|
|
datacard << "imax 1\n";
|
476 |
|
|
datacard << "jmax 1\n";
|
477 |
|
|
datacard << "kmax *\n";
|
478 |
|
|
datacard << "---------------\n";
|
479 |
|
|
datacard << "shapes * * limitfile.root $PROCESS $PROCESS_$SYSTEMATIC\n";
|
480 |
|
|
datacard << "---------------\n";
|
481 |
|
|
datacard << "bin 1\n";
|
482 |
|
|
datacard << "observation "<<dataob->Integral()<<"\n";
|
483 |
|
|
datacard << "------------------------------\n";
|
484 |
|
|
datacard << "bin 1 1\n";
|
485 |
|
|
datacard << "process signal background\n";
|
486 |
|
|
datacard << "process 0 1\n";
|
487 |
|
|
datacard << "rate "<<signal->Integral()<<" "<<background->Integral()<<"\n";
|
488 |
|
|
datacard << "--------------------------------\n";
|
489 |
|
|
datacard << "lumi lnN 1.10 1.0\n";
|
490 |
|
|
datacard << "bgnorm lnN 1.00 1.4 uncertainty on our prediction (40%)\n";
|
491 |
|
|
datacard << "JES shape 1 1 uncertainty on background shape and normalization\n";
|
492 |
|
|
datacard << "peak shape 1 1 uncertainty on signal resolution. Assume the histogram is a 2 sigma shift, \n";
|
493 |
|
|
datacard << "# so divide the unit gaussian by 2 before doing the interpolation\n";
|
494 |
|
|
datacard.close();
|
495 |
|
|
}
|
496 |
|
|
|
497 |
|
|
|
498 |
|
|
void prepare_limits(string mcjzb, string datajzb, float jzbpeakerrordata, float jzbpeakerrormc, vector<float> jzbbins) {
|
499 |
|
|
ensure_directory_exists(get_directory()+"/limits");
|
500 |
|
|
TFile *limfile = new TFile((get_directory()+"/limits/limitfile.root").c_str(),"RECREATE");
|
501 |
|
|
TCanvas *limcan = new TCanvas("limcan","Canvas for calculating limits");
|
502 |
|
|
limit_shapes_for_systematic_effect(limfile,"",mcjzb,datajzb,noJES,jzbbins,limcan);
|
503 |
|
|
limit_shapes_for_systematic_effect(limfile,"peakUp",newjzbexpression(mcjzb,jzbpeakerrormc),newjzbexpression(datajzb,jzbpeakerrordata),noJES,jzbbins,limcan);
|
504 |
|
|
limit_shapes_for_systematic_effect(limfile,"peakDown",newjzbexpression(mcjzb,-jzbpeakerrormc),newjzbexpression(datajzb,-jzbpeakerrordata),noJES,jzbbins,limcan);
|
505 |
|
|
limit_shapes_for_systematic_effect(limfile,"JESUp",mcjzb,datajzb,JESup,jzbbins,limcan);
|
506 |
|
|
limit_shapes_for_systematic_effect(limfile,"JESDown",mcjzb,datajzb,JESdown,jzbbins,limcan);
|
507 |
|
|
|
508 |
|
|
prepare_datacard(limfile);
|
509 |
buchmann |
1.6 |
limfile->Close();
|
510 |
buchmann |
1.5 |
write_info("prepare_limits","limitfile.root and datacard.txt have been generated. You can now use them to calculate limits!");
|
511 |
|
|
|
512 |
fronga |
1.9 |
}
|