1 |
|
#include <iostream> |
2 |
|
#include <vector> |
3 |
|
#include <sys/stat.h> |
4 |
+ |
#include <fstream> |
5 |
|
|
6 |
|
#include <TCut.h> |
7 |
|
#include <TROOT.h> |
23 |
|
|
24 |
|
|
25 |
|
void rediscover_the_top(string mcjzb, string datajzb) { |
26 |
< |
cout << "Hi! today we are going to (try to) rediscover the top!" << endl; |
26 |
> |
dout << "Hi! today we are going to (try to) rediscover the top!" << endl; |
27 |
|
TCanvas *c3 = new TCanvas("c3","c3"); |
28 |
|
c3->SetLogy(1); |
29 |
|
vector<float> binning; |
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 |
< |
cout << "Second way of doing this !!!! Analytical shape to the left :-D" << endl; |
66 |
> |
dout << "Second way of doing this !!!! Analytical shape to the left :-D" << endl; |
67 |
|
vector<TF1*> functions = do_cb_fit_to_plot(datapredictiont,10); |
68 |
|
datapredictiont->SetMarkerColor(kRed); |
69 |
|
datapredictiont->SetLineColor(kRed); |
142 |
|
ratio->Divide(datapredictiontb); |
143 |
|
|
144 |
|
for (int i=0;i<=ratio_binning.size();i++) { |
145 |
< |
cout << observedtb->GetBinLowEdge(i+1) << ";"<<observedtb->GetBinContent(i+1) << ";" << datapredictiontb->GetBinContent(i+1) << " --> " << ratio->GetBinContent(i+1) << "+/-" << ratio->GetBinError(i+1) << endl; |
145 |
> |
dout << observedtb->GetBinLowEdge(i+1) << ";"<<observedtb->GetBinContent(i+1) << ";" << datapredictiontb->GetBinContent(i+1) << " --> " << ratio->GetBinContent(i+1) << "+/-" << ratio->GetBinError(i+1) << endl; |
146 |
|
} |
147 |
|
|
148 |
|
// ratio->Divide(datapredictiontb); |
168 |
|
|
169 |
|
} |
170 |
|
|
171 |
< |
void calculate_upper_limits(string mcjzb, string datajzb) { |
172 |
< |
write_warning("calculate_upper_limits","Upper limit calculation temporarily deactivated"); |
173 |
< |
// write_warning("calculate_upper_limits","Calculation of SUSY upper limits has been temporarily suspended in favor of top discovery"); |
174 |
< |
// rediscover_the_top(mcjzb,datajzb); |
175 |
< |
/* |
176 |
< |
TCanvas *c3 = new TCanvas("c3","c3"); |
177 |
< |
c3->SetLogy(1); |
178 |
< |
vector<float> binning; |
179 |
< |
//binning=allsamples.get_optimal_binsize(mcjzb,cutmass&&cutOSSF&&cutnJets,20,50,800); |
180 |
< |
binning.push_back(50); |
181 |
< |
binning.push_back(100); |
182 |
< |
binning.push_back(150); |
183 |
< |
binning.push_back(200); |
184 |
< |
binning.push_back(500); |
185 |
< |
TH1F *datapredictiona = allsamples.Draw("datapredictiona", "-"+datajzb, binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity); |
186 |
< |
TH1F *datapredictionb = allsamples.Draw("datapredictionb", "-"+datajzb, binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity); |
187 |
< |
TH1F *datapredictionc = allsamples.Draw("datapredictionc", datajzb, binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity); |
188 |
< |
TH1F *dataprediction = (TH1F*)datapredictiona->Clone(); |
189 |
< |
dataprediction->Add(datapredictionb,-1); |
190 |
< |
dataprediction->Add(datapredictionc); |
191 |
< |
TH1F *puresignal = allsamples.Draw("puresignal", mcjzb, binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity,allsamples.FindSample("LM4")); |
192 |
< |
TH1F *signalpred = allsamples.Draw("signalpred", "-"+mcjzb, binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity,allsamples.FindSample("LM4")); |
192 |
< |
TH1F *signalpredlo = allsamples.Draw("signalpredlo", "-"+mcjzb, binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity,allsamples.FindSample("LM4")); |
193 |
< |
TH1F *signalpredro = allsamples.Draw("signalpredro", mcjzb, binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity,allsamples.FindSample("LM4")); |
194 |
< |
TH1F *puredata = allsamples.Draw("puredata", datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity); |
195 |
< |
signalpred->Add(signalpredlo,-1); |
196 |
< |
signalpred->Add(signalpredro); |
197 |
< |
puresignal->Add(signalpred,-1);//subtracting signal contamination |
198 |
< |
ofstream myfile; |
199 |
< |
myfile.open ("ShapeFit_log.txt"); |
200 |
< |
establish_upper_limits(puredata,dataprediction,puresignal,"LM4",myfile); |
201 |
< |
myfile.close(); |
202 |
< |
*/ |
171 |
> |
vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, bool doobserved=false) { |
172 |
> |
float sigma95=-9.9,sigma95A=-9.9; |
173 |
> |
int nuisancemodel=1; |
174 |
> |
if(mceff<=0) { |
175 |
> |
write_warning(__FUNCTION__,"Cannot compute upper limit in this configuration as the efficiency is negative:"); |
176 |
> |
dout << "mc efficiency=" << mceff << " +/- " << mcefferr; |
177 |
> |
vector<float> sigmas; |
178 |
> |
sigmas.push_back(-1); |
179 |
> |
sigmas.push_back(-1); |
180 |
> |
return sigmas; |
181 |
> |
} else { |
182 |
> |
dout << "Now calling : CL95(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl; |
183 |
> |
sigma95 = CL95(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], Nobs[ibin], false, nuisancemodel); |
184 |
> |
if(doobserved) { |
185 |
> |
dout << "Now calling : CLA(" << luminosity << "," << lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << nuisancemodel<< ") " << endl; |
186 |
> |
sigma95A = CLA(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], nuisancemodel); |
187 |
> |
} |
188 |
> |
vector<float> sigmas; |
189 |
> |
sigmas.push_back(sigma95); |
190 |
> |
sigmas.push_back(sigma95A); |
191 |
> |
return sigmas; |
192 |
> |
} |
193 |
|
} |
194 |
|
|
195 |
< |
void compute_upper_limits_from_counting_experiment(vector<vector<float> > uncertainties,vector<float> jzbcuts) { |
196 |
< |
cout << "Doing counting experiment ... " << endl; |
195 |
> |
void compute_upper_limits_from_counting_experiment(vector<vector<float> > uncertainties,vector<float> jzbcuts, string mcjzb, bool doobserved) { |
196 |
> |
dout << "Doing counting experiment ... " << endl; |
197 |
> |
vector<vector<string> > limits; |
198 |
> |
vector<vector<float> > vlimits; |
199 |
> |
|
200 |
|
|
201 |
|
for(int isample=0;isample<signalsamples.collection.size();isample++) { |
202 |
< |
cout << "Considering sample " << signalsamples.collection[isample].samplename << endl; |
202 |
> |
vector<string> rows; |
203 |
> |
vector<float> vrows; |
204 |
> |
dout << "Considering sample " << signalsamples.collection[isample].samplename << endl; |
205 |
> |
rows.push_back(signalsamples.collection[isample].samplename); |
206 |
|
for(int ibin=0;ibin<jzbcuts.size();ibin++) { |
207 |
< |
cout << " Considering bin " << jzbcuts[ibin] << endl; |
208 |
< |
for(int isyst=0;isyst<uncertainties[isample*jzbcuts.size()+ibin].size();isyst++) { |
209 |
< |
if(isyst==0) { |
210 |
< |
if(uncertainties[isample*jzbcuts.size()+ibin][isyst]!=jzbcuts[ibin]) cout << "WATCH OUT THERE SEEMS TO BE A PROBLEM - THE TEST BIN DOESN'T CORRESPOND TO YOUR BIN!" << endl; |
211 |
< |
continue; |
212 |
< |
} |
213 |
< |
cout << " Considering syst " << isyst << " : " << uncertainties[isample*jzbcuts.size()+ibin][isyst] << endl; |
214 |
< |
}//end of syst loop |
207 |
> |
dout << "_________________________________________________________________________________" << endl; |
208 |
> |
float JZBcutat=uncertainties[isample*jzbcuts.size()+ibin][0]; |
209 |
> |
float mceff=uncertainties[isample*jzbcuts.size()+ibin][1]; |
210 |
> |
float staterr=uncertainties[isample*jzbcuts.size()+ibin][2]; |
211 |
> |
float systerr=uncertainties[isample*jzbcuts.size()+ibin][3]; |
212 |
> |
float toterr =uncertainties[isample*jzbcuts.size()+ibin][4]; |
213 |
> |
float observed,observederr,null,result; |
214 |
> |
|
215 |
> |
// 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); |
216 |
> |
// observed-=result;//this is the actual excess we see! |
217 |
> |
// float expected=observed/luminosity; |
218 |
> |
|
219 |
> |
dout << "Sample: " << signalsamples.collection[isample].samplename << ", JZB>"<<JZBcutat<< " : " << mceff << " +/- " << staterr << " (stat) +/- " << systerr << " (syst) --> toterr = " << toterr << endl; |
220 |
> |
vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,doobserved); |
221 |
> |
|
222 |
> |
if(doobserved) { |
223 |
> |
// rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(expected)+")"); |
224 |
> |
rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(signalsamples.collection[isample].xs)+")"); |
225 |
> |
vrows.push_back(sigmas[0]); |
226 |
> |
vrows.push_back(sigmas[1]); |
227 |
> |
// vrows.push_back(expected); |
228 |
> |
vrows.push_back(signalsamples.collection[isample].xs); |
229 |
> |
} |
230 |
> |
else { |
231 |
> |
// rows.push_back(any2string(sigmas[0])+"("+any2string(expected)+")"); |
232 |
> |
rows.push_back(any2string(sigmas[0])); |
233 |
> |
vrows.push_back(sigmas[0]); |
234 |
> |
vrows.push_back(signalsamples.collection[isample].xs); |
235 |
> |
// vrows.push_back(expected); |
236 |
> |
} |
237 |
|
}//end of bin loop |
238 |
+ |
limits.push_back(rows); |
239 |
+ |
vlimits.push_back(vrows); |
240 |
|
}//end of sample loop |
241 |
< |
} |
242 |
< |
|
243 |
< |
void susy_scan_axis_labeling(TH2F *histo) { |
244 |
< |
histo->GetXaxis()->SetTitle("#Chi_{2}^{0}-LSP"); |
245 |
< |
histo->GetXaxis()->CenterTitle(); |
246 |
< |
histo->GetYaxis()->SetTitle("m_{#tilde{q}}"); |
247 |
< |
histo->GetYaxis()->CenterTitle(); |
248 |
< |
} |
249 |
< |
|
250 |
< |
void scan_susy_space(string mcjzb, string datajzb) { |
251 |
< |
TCanvas *c3 = new TCanvas("c3","c3"); |
252 |
< |
vector<float> binning; |
253 |
< |
binning=allsamples.get_optimal_binsize(mcjzb,cutmass&&cutOSSF&&cutnJets,20,50,800); |
254 |
< |
/* |
255 |
< |
binning.push_back(50); |
256 |
< |
binning.push_back(75); |
257 |
< |
binning.push_back(100); |
258 |
< |
binning.push_back(150); |
259 |
< |
binning.push_back(200); |
260 |
< |
binning.push_back(500); |
261 |
< |
*/ |
262 |
< |
float arrbinning[binning.size()]; |
263 |
< |
for(int i=0;i<binning.size();i++) arrbinning[i]=binning[i]; |
264 |
< |
TH1F *puredata = allsamples.Draw("puredata", datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity); |
265 |
< |
puredata->SetMarkerSize(DataMarkerSize); |
266 |
< |
TH1F *allbgs = allsamples.Draw("allbgs", "-"+datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity); |
267 |
< |
TH1F *allbgsb = allsamples.Draw("allbgsb", "-"+datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,luminosity); |
268 |
< |
TH1F *allbgsc = allsamples.Draw("allbgsc", datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,luminosity); |
269 |
< |
allbgs->Add(allbgsb,-1); |
270 |
< |
allbgs->Add(allbgsc); |
251 |
< |
int ndata=puredata->Integral(); |
252 |
< |
ofstream myfile; |
253 |
< |
myfile.open ("susyscan_log.txt"); |
254 |
< |
TFile *susyscanfile = new TFile("/scratch/fronga/SMS/T5z_SqSqToQZQZ_38xFall10.root"); |
255 |
< |
TTree *suevents = (TTree*)susyscanfile->Get("events"); |
256 |
< |
TH2F *exclusionmap = new TH2F("exclusionmap","",20,0,500,20,0,1000); |
257 |
< |
TH2F *exclusionmap1s = new TH2F("exclusionmap1s","",20,0,500,20,0,1000); |
258 |
< |
TH2F *exclusionmap2s = new TH2F("exclusionmap2s","",20,0,500,20,0,1000); |
259 |
< |
TH2F *exclusionmap3s = new TH2F("exclusionmap3s","",20,0,500,20,0,1000); |
260 |
< |
|
261 |
< |
susy_scan_axis_labeling(exclusionmap); |
262 |
< |
susy_scan_axis_labeling(exclusionmap1s); |
263 |
< |
susy_scan_axis_labeling(exclusionmap2s); |
264 |
< |
susy_scan_axis_labeling(exclusionmap3s); |
265 |
< |
|
266 |
< |
Int_t MyPalette[100]; |
267 |
< |
Double_t r[] = {0., 0.0, 1.0, 1.0, 1.0}; |
268 |
< |
Double_t g[] = {0., 0.0, 0.0, 1.0, 1.0}; |
269 |
< |
Double_t b[] = {0., 1.0, 0.0, 0.0, 1.0}; |
270 |
< |
Double_t stop[] = {0., .25, .50, .75, 1.0}; |
271 |
< |
Int_t FI = TColor::CreateGradientColorTable(5, stop, r, g, b, 100); |
272 |
< |
for (int i=0;i<100;i++) MyPalette[i] = FI+i; |
273 |
< |
|
274 |
< |
gStyle->SetPalette(100, MyPalette); |
275 |
< |
|
276 |
< |
for(int m23=50;m23<500;m23+=25) { |
277 |
< |
for (int m0=(2*(m23-50)+150);m0<=1000;m0+=50) |
278 |
< |
{ |
279 |
< |
c3->cd(); |
280 |
< |
stringstream drawcondition; |
281 |
< |
drawcondition << "pfJetGoodNum>=3&&(TMath::Abs(masses[0]-"<<m0<<")<10&&TMath::Abs(masses[2]-masses[3]-"<<m23<<")<10)&&mll>5&&id1==id2"; |
282 |
< |
TH1F *puresignal = new TH1F("puresignal","puresignal",binning.size()-1,arrbinning); |
283 |
< |
TH1F *puresignall= new TH1F("puresignall","puresignal",binning.size()-1,arrbinning); |
284 |
< |
stringstream drawvar,drawvar2; |
285 |
< |
drawvar<<mcjzb<<">>puresignal"; |
286 |
< |
drawvar2<<"-"<<mcjzb<<">>puresignall"; |
287 |
< |
suevents->Draw(drawvar.str().c_str(),drawcondition.str().c_str()); |
288 |
< |
suevents->Draw(drawvar2.str().c_str(),drawcondition.str().c_str()); |
289 |
< |
if(puresignal->Integral()<60) { |
290 |
< |
delete puresignal; |
291 |
< |
continue; |
292 |
< |
} |
293 |
< |
puresignal->Add(puresignall,-1);//we need to correct for the signal contamination - we effectively only see (JZB>0)-(JZB<0) !! |
294 |
< |
puresignal->Scale(ndata/(20*puresignal->Integral()));//normalizing it to 5% of the data |
295 |
< |
stringstream saveas; |
296 |
< |
saveas<<"Model_Scan/m0_"<<m0<<"__m23_"<<m23; |
297 |
< |
cout << "PLEASE KEEP IN MIND THAT SIGNAL CONTAMINATION IS NOT REALLY TAKEN CARE OF YET DUE TO LOW STATISTICS! SHOULD BE SOMETHING LIKE THIS : "<< endl; |
298 |
< |
// TH1F *signalpredlo = allsamples.Draw("signalpredlo", "-"+mcjzb, binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity,allsamples.FindSample("LM4")); |
299 |
< |
// TH1F *signalpredro = allsamples.Draw("signalpredro", mcjzb, binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity,allsamples.FindSample("LM4")); |
300 |
< |
// TH1F *puredata = allsamples.Draw("puredata", datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity); |
301 |
< |
// signalpred->Add(signalpredlo,-1); |
302 |
< |
// signalpred->Add(signalpredro); |
303 |
< |
// puresignal->Add(signalpred,-1);//subtracting signal contamination |
304 |
< |
//--------------------- |
305 |
< |
// cout << "(m0,m23)=("<<m0<<","<<m23<<") contains " << puresignal->Integral() << endl; |
306 |
< |
// TH1F *puresignal = allsamples.Draw("puresignal",mcjzb, binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity,allsamples.FindSample("LM4")); |
307 |
< |
vector<float> results=establish_upper_limits(puredata,allbgs,puresignal,saveas.str(),myfile); |
308 |
< |
if(results.size()==0) { |
309 |
< |
delete puresignal; |
310 |
< |
continue; |
241 |
> |
dout << endl << endl << endl << "_________________________________________________________________________________________________" << endl << endl; |
242 |
> |
dout << endl << endl << "PAS table 3: (notation: limit [95%CL])" << endl << endl; |
243 |
> |
dout << "\t"; |
244 |
> |
for (int irow=0;irow<jzbcuts.size();irow++) { |
245 |
> |
dout << jzbcuts[irow] << "\t"; |
246 |
> |
} |
247 |
> |
dout << endl; |
248 |
> |
for(int irow=0;irow<limits.size();irow++) { |
249 |
> |
for(int ientry=0;ientry<limits[irow].size();ientry++) { |
250 |
> |
if (limits[irow][ientry]>0) dout << limits[irow][ientry] << "\t"; |
251 |
> |
else dout << " (N/A) \t"; |
252 |
> |
} |
253 |
> |
dout << endl; |
254 |
> |
} |
255 |
> |
|
256 |
> |
if(!doobserved) { |
257 |
> |
dout << endl << endl << "LIMITS: (Tex)" << endl; |
258 |
> |
tout << "\\begin{tabular}{ | l | "; |
259 |
> |
for (int irow=0;irow<jzbcuts.size();irow++) tout << " l |"; |
260 |
> |
tout << "} " << endl << " \\hline " << endl << "& \t "; |
261 |
> |
for (int irow=0;irow<jzbcuts.size();irow++) { |
262 |
> |
tout << "JZB $>$ " << jzbcuts[irow] << " GeV & \t "; |
263 |
> |
} |
264 |
> |
tout << " \\\\ \\hline " << endl; |
265 |
> |
for(int irow=0;irow<limits.size();irow++) { |
266 |
> |
tout << limits[irow][0] << " \t"; |
267 |
> |
for(int ientry=0;ientry<jzbcuts.size();ientry++) { |
268 |
> |
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"; |
269 |
> |
else tout << " & ( N / A ) \t"; |
270 |
> |
// dout << Round(vlimits[irow][2*ientry],3) << " / " << Round(vlimits[irow][2*ientry+1],3)<< "\t"; |
271 |
|
} |
272 |
< |
exclusionmap->Fill(m23,m0,results[0]); |
313 |
< |
exclusionmap1s->Fill(m23,m0,results[1]); |
314 |
< |
exclusionmap2s->Fill(m23,m0,results[2]); |
315 |
< |
exclusionmap3s->Fill(m23,m0,results[3]); |
316 |
< |
delete puresignal; |
317 |
< |
cout << "(m0,m23)=("<<m0<<","<<m23<<") : 3 sigma at " << results[3] << endl; |
272 |
> |
tout << " \\\\ \\hline " << endl; |
273 |
|
} |
274 |
< |
}//end of model scan for loop |
274 |
> |
tout << "\\end{tabular}" << endl; |
275 |
> |
}//do observed |
276 |
|
|
277 |
< |
cout << "Exclusion Map contains" << exclusionmap->Integral() << " (integral) and entries: " << exclusionmap->GetEntries() << endl; |
278 |
< |
c3->cd(); |
279 |
< |
exclusionmap->Draw("CONTZ"); |
280 |
< |
CompleteSave(c3,"Model_Scan/CONT/Model_Scan_Mean_values"); |
281 |
< |
exclusionmap->Draw("COLZ"); |
282 |
< |
CompleteSave(c3,"Model_Scan/COL/Model_Scan_Mean_values"); |
283 |
< |
|
284 |
< |
exclusionmap1s->Draw("CONTZ"); |
285 |
< |
CompleteSave(c3,"Model_Scan/CONT/Model_Scan_1sigma_values"); |
330 |
< |
exclusionmap1s->Draw("COLZ"); |
331 |
< |
CompleteSave(c3,"Model_Scan/COL/Model_Scan_1sigma_values"); |
332 |
< |
|
333 |
< |
exclusionmap2s->Draw("CONTZ"); |
334 |
< |
CompleteSave(c3,"Model_Scan/CONT/Model_Scan_2sigma_values"); |
335 |
< |
exclusionmap2s->Draw("COLZ"); |
336 |
< |
CompleteSave(c3,"Model_Scan/COL/Model_Scan_2sigma_values"); |
337 |
< |
|
338 |
< |
exclusionmap3s->Draw("CONTZ"); |
339 |
< |
CompleteSave(c3,"Model_Scan/CONT/Model_Scan_3sigma_values"); |
340 |
< |
exclusionmap3s->Draw("COLZ"); |
341 |
< |
CompleteSave(c3,"Model_Scan/COL/Model_Scan_3sigma_values"); |
342 |
< |
|
343 |
< |
TFile *exclusion_limits = new TFile("exclusion_limits.root","RECREATE"); |
344 |
< |
exclusionmap->Write(); |
345 |
< |
exclusionmap1s->Write(); |
346 |
< |
exclusionmap2s->Write(); |
347 |
< |
exclusionmap3s->Write(); |
348 |
< |
exclusion_limits->Close(); |
349 |
< |
susyscanfile->Close(); |
277 |
> |
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; |
278 |
> |
dout << "Scenario \t Efficiency [%] \t Upper limits [pb] \t \\sigma [pb]" << endl; |
279 |
> |
for(int icut=0;icut<jzbcuts.size();icut++) { |
280 |
> |
dout << "Region with JZB>" << jzbcuts[icut] << endl; |
281 |
> |
for(int isample=0;isample<signalsamples.collection.size();isample++) { |
282 |
> |
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; |
283 |
> |
} |
284 |
> |
dout << endl; |
285 |
> |
} |
286 |
|
|
287 |
< |
myfile.close(); |
287 |
> |
write_warning(__FUNCTION__,"Still need to update the script"); |
288 |
|
} |
289 |
|
|
290 |
|
|
291 |
+ |
|
292 |
+ |
/********************************************************************** new : Limits using SHAPES *********************************** |
293 |
+ |
|
294 |
|
|
295 |
+ |
SSSSSSSSSSSSSSS hhhhhhh |
296 |
+ |
SS:::::::::::::::Sh:::::h |
297 |
+ |
S:::::SSSSSS::::::Sh:::::h |
298 |
+ |
S:::::S SSSSSSSh:::::h |
299 |
+ |
S:::::S h::::h hhhhh aaaaaaaaaaaaa ppppp ppppppppp eeeeeeeeeeee ssssssssss |
300 |
+ |
S:::::S h::::hh:::::hhh a::::::::::::a p::::ppp:::::::::p ee::::::::::::ee ss::::::::::s |
301 |
+ |
S::::SSSS h::::::::::::::hh aaaaaaaaa:::::ap:::::::::::::::::p e::::::eeeee:::::eess:::::::::::::s |
302 |
+ |
SS::::::SSSSS h:::::::hhh::::::h a::::app::::::ppppp::::::pe::::::e e:::::es::::::ssss:::::s |
303 |
+ |
SSS::::::::SS h::::::h h::::::h aaaaaaa:::::a p:::::p p:::::pe:::::::eeeee::::::e s:::::s ssssss |
304 |
+ |
SSSSSS::::S h:::::h h:::::h aa::::::::::::a p:::::p p:::::pe:::::::::::::::::e s::::::s |
305 |
+ |
S:::::S h:::::h h:::::h a::::aaaa::::::a p:::::p p:::::pe::::::eeeeeeeeeee s::::::s |
306 |
+ |
S:::::S h:::::h h:::::ha::::a a:::::a p:::::p p::::::pe:::::::e ssssss s:::::s |
307 |
+ |
SSSSSSS S:::::S h:::::h h:::::ha::::a a:::::a p:::::ppppp:::::::pe::::::::e s:::::ssss::::::s |
308 |
+ |
S::::::SSSSSS:::::S h:::::h h:::::ha:::::aaaa::::::a p::::::::::::::::p e::::::::eeeeeeee s::::::::::::::s |
309 |
+ |
S:::::::::::::::SS h:::::h h:::::h a::::::::::aa:::ap::::::::::::::pp ee:::::::::::::e s:::::::::::ss |
310 |
+ |
SSSSSSSSSSSSSSS hhhhhhh hhhhhhh aaaaaaaaaa aaaap::::::pppppppp eeeeeeeeeeeeee sssssssssss |
311 |
+ |
p:::::p |
312 |
+ |
p:::::p |
313 |
+ |
p:::::::p |
314 |
+ |
p:::::::p |
315 |
+ |
p:::::::p |
316 |
+ |
ppppppppp |
317 |
+ |
|
318 |
+ |
|
319 |
+ |
*********************************************************************** new : Limits using SHAPES ***********************************/ |
320 |
+ |
|
321 |
+ |
|
322 |
+ |
void limit_shapes_for_systematic_effect(TFile *limfile, string identifier, string mcjzb, string datajzb, int JES,vector<float> binning, TCanvas *limcan) { |
323 |
+ |
dout << "Creatig shape templates ... "; |
324 |
+ |
if(identifier!="") dout << "for systematic called "<<identifier; |
325 |
+ |
dout << endl; |
326 |
+ |
int dataormc=mcwithsignal;//this is only for tests - for real life you want dataormc=data !!! |
327 |
+ |
if(dataormc!=data) write_warning(__FUNCTION__,"WATCH OUT! Not using data for limits!!!! this is ok for tests, but not ok for anything official!"); |
328 |
+ |
|
329 |
+ |
TCut limitnJetcut; |
330 |
+ |
if(JES==noJES) limitnJetcut=cutnJets; |
331 |
+ |
else { |
332 |
+ |
if(JES==JESdown) limitnJetcut=cutnJetsJESdown; |
333 |
+ |
if(JES==JESup) limitnJetcut=cutnJetsJESup; |
334 |
+ |
} |
335 |
+ |
TH1F *ZOSSFP = allsamples.Draw("ZOSSFP",datajzb,binning, "JZB4limits", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,dataormc,luminosity); |
336 |
+ |
TH1F *ZOSOFP = allsamples.Draw("ZOSOFP",datajzb,binning, "JZB4limits", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,dataormc,luminosity); |
337 |
+ |
TH1F *ZOSSFN = allsamples.Draw("ZOSSFN","-"+datajzb,binning, "JZB4limits", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,dataormc,luminosity); |
338 |
+ |
TH1F *ZOSOFN = allsamples.Draw("ZOSOFN","-"+datajzb,binning, "JZB4limits", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,dataormc,luminosity); |
339 |
+ |
|
340 |
+ |
TH1F *SBOSSFP = allsamples.Draw("SBOSSFP",datajzb,binning, "JZB4limits", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,dataormc,luminosity); |
341 |
+ |
TH1F *SBOSOFP = allsamples.Draw("SBOSOFP",datajzb,binning, "JZB4limits", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,dataormc,luminosity); |
342 |
+ |
TH1F *SBOSSFN = allsamples.Draw("SBOSSFN","-"+datajzb,binning, "JZB4limits", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,dataormc,luminosity); |
343 |
+ |
TH1F *SBOSOFN = allsamples.Draw("SBOSOFN","-"+datajzb,binning, "JZB4limits", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,dataormc,luminosity); |
344 |
+ |
|
345 |
+ |
TH1F *LZOSSFP = allsamples.Draw("LZOSSFP",mcjzb,binning, "JZB4limits", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,mc,luminosity,allsamples.FindSample("LM4")); |
346 |
+ |
TH1F *LZOSOFP = allsamples.Draw("LZOSOFP",mcjzb,binning, "JZB4limits", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,mc,luminosity,allsamples.FindSample("LM4")); |
347 |
+ |
TH1F *LZOSSFN = allsamples.Draw("LZOSSFN","-"+mcjzb,binning, "JZB4limits", "events",cutmass&&cutOSSF&&limitnJetcut&&basiccut,mc,luminosity,allsamples.FindSample("LM4")); |
348 |
+ |
TH1F *LZOSOFN = allsamples.Draw("LZOSOFN","-"+mcjzb,binning, "JZB4limits", "events",cutmass&&cutOSOF&&limitnJetcut&&basiccut,mc,luminosity,allsamples.FindSample("LM4")); |
349 |
+ |
|
350 |
+ |
TH1F *LSBOSSFP = allsamples.Draw("LSBOSSFP",mcjzb,binning, "JZB4limits", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,mc,luminosity,allsamples.FindSample("LM4")); |
351 |
+ |
TH1F *LSBOSOFP = allsamples.Draw("LSBOSOFP",mcjzb,binning, "JZB4limits", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,mc,luminosity,allsamples.FindSample("LM4")); |
352 |
+ |
TH1F *LSBOSSFN = allsamples.Draw("LSBOSSFN","-"+mcjzb,binning, "JZB4limits", "events",cutOSSF&&limitnJetcut&&basiccut&&sidebandcut,mc,luminosity,allsamples.FindSample("LM4")); |
353 |
+ |
TH1F *LSBOSOFN = allsamples.Draw("LSBOSOFN","-"+mcjzb,binning, "JZB4limits", "events",cutOSOF&&limitnJetcut&&basiccut&&sidebandcut,mc,luminosity,allsamples.FindSample("LM4")); |
354 |
+ |
|
355 |
+ |
string obsname="data_obs"; |
356 |
+ |
string predname="background"; |
357 |
+ |
string signalname="signal"; |
358 |
+ |
if(identifier!="") { |
359 |
+ |
obsname=("data_"+identifier); |
360 |
+ |
predname=("background_"+identifier); |
361 |
+ |
signalname="signal_"+identifier; |
362 |
+ |
} |
363 |
+ |
|
364 |
+ |
TH1F *obs = (TH1F*)ZOSSFP->Clone(); |
365 |
+ |
obs->SetName(obsname.c_str()); |
366 |
+ |
obs->Write(); |
367 |
+ |
TH1F *pred = (TH1F*)ZOSSFN->Clone(); |
368 |
+ |
pred->Add(ZOSOFP,1.0/3); |
369 |
+ |
pred->Add(ZOSOFN,-1.0/3); |
370 |
+ |
pred->Add(SBOSSFP,1.0/3); |
371 |
+ |
pred->Add(SBOSSFN,-1.0/3); |
372 |
+ |
pred->Add(SBOSOFP,1.0/3); |
373 |
+ |
pred->Add(SBOSOFN,-1.0/3); |
374 |
+ |
pred->SetName(predname.c_str()); |
375 |
+ |
pred->Write(); |
376 |
+ |
|
377 |
+ |
// TH1F *Lobs = (TH1F*)LZOSSFP->Clone(); |
378 |
+ |
// TH1F *Lpred = (TH1F*)LZOSSFN->Clone(); |
379 |
+ |
|
380 |
+ |
TH1F *Lobs = new TH1F("Lobs","Lobs",binning.size()-1,&binning[0]); |
381 |
+ |
TH1F *Lpred = new TH1F("Lpred","Lpred",binning.size()-1,&binning[0]); |
382 |
+ |
Lobs->Add(LZOSSFP); |
383 |
+ |
Lpred->Add(LZOSSFN); |
384 |
+ |
Lpred->Add(LZOSOFP,1.0/3); |
385 |
+ |
Lpred->Add(LZOSOFN,-1.0/3); |
386 |
+ |
Lpred->Add(LSBOSSFP,1.0/3); |
387 |
+ |
Lpred->Add(LSBOSSFN,-1.0/3); |
388 |
+ |
Lpred->Add(LSBOSOFP,1.0/3); |
389 |
+ |
Lpred->Add(LSBOSOFN,-1.0/3); |
390 |
+ |
TH1F *signal = (TH1F*)Lobs->Clone(); |
391 |
+ |
signal->Add(Lpred,-1); |
392 |
+ |
signal->SetName(signalname.c_str()); |
393 |
+ |
signal->Write(); |
394 |
+ |
|
395 |
+ |
delete Lobs; |
396 |
+ |
delete Lpred; |
397 |
+ |
|
398 |
+ |
delete ZOSSFP; |
399 |
+ |
delete ZOSOFP; |
400 |
+ |
delete ZOSSFN; |
401 |
+ |
delete ZOSOFN; |
402 |
+ |
|
403 |
+ |
delete SBOSSFP; |
404 |
+ |
delete SBOSOFP; |
405 |
+ |
delete SBOSSFN; |
406 |
+ |
delete SBOSOFN; |
407 |
+ |
|
408 |
+ |
delete LZOSSFP; |
409 |
+ |
delete LZOSOFP; |
410 |
+ |
delete LZOSSFN; |
411 |
+ |
delete LZOSOFN; |
412 |
+ |
|
413 |
+ |
delete LSBOSSFP; |
414 |
+ |
delete LSBOSOFP; |
415 |
+ |
delete LSBOSSFN; |
416 |
+ |
delete LSBOSOFN; |
417 |
+ |
|
418 |
+ |
} |
419 |
+ |
|
420 |
+ |
void prepare_datacard(TFile *f) { |
421 |
+ |
TH1F *dataob = (TH1F*)f->Get("data_obs"); |
422 |
+ |
TH1F *signal = (TH1F*)f->Get("signal"); |
423 |
+ |
TH1F *background = (TH1F*)f->Get("background"); |
424 |
|
|
425 |
+ |
ofstream datacard; |
426 |
+ |
ensure_directory_exists(get_directory()+"/limits"); |
427 |
+ |
datacard.open ((get_directory()+"/limits/susydatacard.txt").c_str()); |
428 |
+ |
datacard << "Writing this to a file.\n"; |
429 |
+ |
datacard << "imax 1\n"; |
430 |
+ |
datacard << "jmax 1\n"; |
431 |
+ |
datacard << "kmax *\n"; |
432 |
+ |
datacard << "---------------\n"; |
433 |
+ |
datacard << "shapes * * limitfile.root $PROCESS $PROCESS_$SYSTEMATIC\n"; |
434 |
+ |
datacard << "---------------\n"; |
435 |
+ |
datacard << "bin 1\n"; |
436 |
+ |
datacard << "observation "<<dataob->Integral()<<"\n"; |
437 |
+ |
datacard << "------------------------------\n"; |
438 |
+ |
datacard << "bin 1 1\n"; |
439 |
+ |
datacard << "process signal background\n"; |
440 |
+ |
datacard << "process 0 1\n"; |
441 |
+ |
datacard << "rate "<<signal->Integral()<<" "<<background->Integral()<<"\n"; |
442 |
+ |
datacard << "--------------------------------\n"; |
443 |
+ |
datacard << "lumi lnN 1.10 1.0\n"; |
444 |
+ |
datacard << "bgnorm lnN 1.00 1.4 uncertainty on our prediction (40%)\n"; |
445 |
+ |
datacard << "JES shape 1 1 uncertainty on background shape and normalization\n"; |
446 |
+ |
datacard << "peak shape 1 1 uncertainty on signal resolution. Assume the histogram is a 2 sigma shift, \n"; |
447 |
+ |
datacard << "# so divide the unit gaussian by 2 before doing the interpolation\n"; |
448 |
+ |
datacard.close(); |
449 |
+ |
} |
450 |
+ |
|
451 |
+ |
|
452 |
+ |
void prepare_limits(string mcjzb, string datajzb, float jzbpeakerrordata, float jzbpeakerrormc, vector<float> jzbbins) { |
453 |
+ |
ensure_directory_exists(get_directory()+"/limits"); |
454 |
+ |
TFile *limfile = new TFile((get_directory()+"/limits/limitfile.root").c_str(),"RECREATE"); |
455 |
+ |
TCanvas *limcan = new TCanvas("limcan","Canvas for calculating limits"); |
456 |
+ |
limit_shapes_for_systematic_effect(limfile,"",mcjzb,datajzb,noJES,jzbbins,limcan); |
457 |
+ |
limit_shapes_for_systematic_effect(limfile,"peakUp",newjzbexpression(mcjzb,jzbpeakerrormc),newjzbexpression(datajzb,jzbpeakerrordata),noJES,jzbbins,limcan); |
458 |
+ |
limit_shapes_for_systematic_effect(limfile,"peakDown",newjzbexpression(mcjzb,-jzbpeakerrormc),newjzbexpression(datajzb,-jzbpeakerrordata),noJES,jzbbins,limcan); |
459 |
+ |
limit_shapes_for_systematic_effect(limfile,"JESUp",mcjzb,datajzb,JESup,jzbbins,limcan); |
460 |
+ |
limit_shapes_for_systematic_effect(limfile,"JESDown",mcjzb,datajzb,JESdown,jzbbins,limcan); |
461 |
+ |
|
462 |
+ |
prepare_datacard(limfile); |
463 |
+ |
limfile->Close(); |
464 |
+ |
write_info("prepare_limits","limitfile.root and datacard.txt have been generated. You can now use them to calculate limits!"); |
465 |
+ |
|
466 |
+ |
} |