1 |
#include <iostream>
|
2 |
#include <vector>
|
3 |
#include <sys/stat.h>
|
4 |
|
5 |
#include <TCut.h>
|
6 |
#include <TROOT.h>
|
7 |
#include <TCanvas.h>
|
8 |
#include <TMath.h>
|
9 |
#include <TColor.h>
|
10 |
#include <TPaveText.h>
|
11 |
#include <TRandom.h>
|
12 |
#include <TH1.h>
|
13 |
#include <TH2.h>
|
14 |
#include <TF1.h>
|
15 |
#include <TSQLResult.h>
|
16 |
#include <TProfile.h>
|
17 |
#include <TLegendEntry.h>
|
18 |
|
19 |
using namespace std;
|
20 |
|
21 |
using namespace PlottingSetup;
|
22 |
|
23 |
void todo() {
|
24 |
dout << "My to do list: " << endl;
|
25 |
dout << " - ExperimentalModule::Poisson_ratio_plot : Get the second part to work!" << endl;
|
26 |
dout << "Info : The trigger requirement is currently set to " << (const char*) passtrig << endl;
|
27 |
dout << "Info : The pt requirement is currently set to " << (const char*) passtrig << endl;
|
28 |
dout << "Info : The mll requirement is currently set to " << (const char*) cutmass << endl;
|
29 |
dout << "Info : The lepton requirement is currently set to " << (const char*) leptoncut << endl;
|
30 |
}
|
31 |
|
32 |
void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true )
|
33 |
{
|
34 |
// Temporarily switch off PU reweighting, if asked
|
35 |
TCut weightbackup=cutWeight;
|
36 |
if ( !doPUreweighting ) cutWeight="1.0";
|
37 |
|
38 |
TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
|
39 |
TH1F *rawJZBeemmMC = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
|
40 |
TH1F *rawJZBeemmData = allsamples.Draw("rawJZBeemmData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
|
41 |
TH1F *rawJZBemMC = allsamples.Draw("rawJZBemMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
|
42 |
TH1F *rawJZBemData = allsamples.Draw("rawJZBemData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
|
43 |
TH1F *rawttbarjzbeemmMC;
|
44 |
|
45 |
if(method==doKM) {
|
46 |
//we only need this histo for the KM fitting...
|
47 |
rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,100, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
|
48 |
MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
|
49 |
DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
|
50 |
}
|
51 |
else {
|
52 |
TH1F *reducedMC = (TH1F*)rawJZBeemmMC->Clone();
|
53 |
TH1F *reducedData = (TH1F*)rawJZBeemmData->Clone();
|
54 |
reducedMC->Add(rawJZBemMC,-1);
|
55 |
reducedData->Add(rawJZBemData,-1);
|
56 |
//this is Kostas' way of doing it - we subtract em to get rid of some of the ttbar contribution (in reality, of flavor-symmetric contribution)
|
57 |
MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
|
58 |
DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
|
59 |
|
60 |
}
|
61 |
|
62 |
// Revert to original PU reweighting
|
63 |
if ( !doPUreweighting ) cutWeight = weightbackup;
|
64 |
|
65 |
// MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
|
66 |
// DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
|
67 |
dout << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
|
68 |
result << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
|
69 |
dout << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
|
70 |
result << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
|
71 |
delete tempcan;
|
72 |
}
|
73 |
|
74 |
void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
|
75 |
|
76 |
TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
|
77 |
|
78 |
TH1F *datahistoOSSF = allsamples.Draw("datahistoOSSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&cutnJets&&basiccut,data,luminosity);
|
79 |
THStack mcstackOSSF = allsamples.DrawStack("mcstackOSSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&cutnJets&&basiccut,mc,luminosity);
|
80 |
TH1F *datahistoOSOF = allsamples.Draw("datahistoOSOF","mll",nbins,min,max, xlabel, "events",cutOSOF&&cutnJets&&basiccut,data,luminosity);
|
81 |
|
82 |
if(logscale) ckin->SetLogy(1);
|
83 |
datahistoOSSF->SetMarkerSize(DataMarkerSize);
|
84 |
datahistoOSSF->GetXaxis()->SetTitle(xlabel.c_str());
|
85 |
datahistoOSSF->GetXaxis()->CenterTitle();
|
86 |
datahistoOSSF->GetYaxis()->SetTitle("events");
|
87 |
datahistoOSSF->GetYaxis()->CenterTitle();
|
88 |
datahistoOSOF->SetMarkerSize(DataMarkerSize);
|
89 |
datahistoOSSF->SetMarkerSize(DataMarkerSize);
|
90 |
datahistoOSSF->Draw();
|
91 |
|
92 |
mcstackOSSF.Draw("same");
|
93 |
datahistoOSSF->Draw("same");
|
94 |
|
95 |
datahistoOSOF->SetMarkerColor(TColor::GetColor("#FE642E"));
|
96 |
datahistoOSOF->SetLineColor(kRed);
|
97 |
datahistoOSOF->SetMarkerStyle(21);
|
98 |
datahistoOSOF->Draw("same");
|
99 |
|
100 |
// Try to re-arrange legend...
|
101 |
TLegend *bgleg = allsamples.allbglegend("",datahistoOSSF);
|
102 |
TLegend *kinleg = make_legend();
|
103 |
kinleg->AddEntry(datahistoOSSF,"SF (data)","p");
|
104 |
kinleg->AddEntry(datahistoOSOF,"OF (data)","p");
|
105 |
TIter next(bgleg->GetListOfPrimitives());
|
106 |
TObject* obj;
|
107 |
// Copy the nice bkgd legend skipping the "data"
|
108 |
while ( obj = next() )
|
109 |
if ( strcmp(((TLegendEntry*)obj)->GetObject()->GetName(),"datahistoOSSF") )
|
110 |
kinleg->GetListOfPrimitives()->Add(obj);
|
111 |
|
112 |
kinleg->Draw();
|
113 |
CompleteSave(ckin,"kin/mll_ossf_osof_distribution");
|
114 |
|
115 |
delete datahistoOSOF;
|
116 |
delete datahistoOSSF;
|
117 |
delete ckin;
|
118 |
}
|
119 |
|
120 |
|
121 |
void draw_ratio_plot(TH1* hdata, THStack& hmc, float ymin=0.5, float ymax=1.5) {
|
122 |
|
123 |
// Make a histogram from stack
|
124 |
TIter next(hmc.GetHists());
|
125 |
TObject* obj;
|
126 |
TH1* hratio = NULL;
|
127 |
while ( obj = next() ) {
|
128 |
if ( !hratio ) {
|
129 |
hratio = (TH1*)obj->Clone();
|
130 |
hratio->SetName("hratio");
|
131 |
} else hratio->Add( (TH1*)obj );
|
132 |
}
|
133 |
hratio->Divide(hdata);
|
134 |
hratio->SetMaximum(ymax);
|
135 |
hratio->SetMinimum(ymin);
|
136 |
hratio->SetMarkerStyle(2);
|
137 |
hratio->SetLineWidth(1);
|
138 |
hratio->GetYaxis()->SetLabelSize(0.08);
|
139 |
hratio->GetXaxis()->SetLabelSize(0.0);
|
140 |
|
141 |
TPad* rpad = new TPad("rpad","",0.15,0.73,0.4,0.88);
|
142 |
rpad->SetTopMargin(0.0);
|
143 |
rpad->SetBottomMargin(0.0);
|
144 |
rpad->SetRightMargin(0.0);
|
145 |
rpad->Draw();
|
146 |
rpad->cd();
|
147 |
// hratio->GetXaxis()->SetNdivisions(0);
|
148 |
hratio->GetYaxis()->SetNdivisions(502,false);
|
149 |
hratio->Draw("e1x0");
|
150 |
|
151 |
TF1* oneline = new TF1("","1.0",0,1000);
|
152 |
oneline->SetLineColor(kBlue);
|
153 |
oneline->SetLineStyle(1);
|
154 |
oneline->SetLineWidth(1);
|
155 |
oneline->Draw("same");
|
156 |
}
|
157 |
|
158 |
float lastrange_min=0;
|
159 |
float lastrange_max=0;
|
160 |
|
161 |
void make_kin_plot(string variable, string addcut, int nbins, float min, float max, bool logscale,
|
162 |
string xlabel, string filename, bool isPF=true, bool plotratio=true, bool loadlastminmax=false ) {
|
163 |
// TCut basiccut("(pfJetGoodNum>=2&&pfJetGoodID[0])&&(pfJetGoodNum>=2&&pfJetGoodID[1])&&(passed_triggers||!is_data)");
|
164 |
TCut ibasiccut=basiccut;
|
165 |
bool draw_separation_lines=false;
|
166 |
|
167 |
if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
|
168 |
|
169 |
if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
|
170 |
|
171 |
//Step 1: Adapt the variable (if we're dealing with PF we need to adapt the variable!)
|
172 |
if(isPF) {
|
173 |
if(variable=="mll") variable="pfmll[0]";
|
174 |
if(variable=="jetpt[0]") variable="pfJetGoodPt[0]";
|
175 |
if(variable=="jeteta[0]") variable="pfJetGoodEta[0]";
|
176 |
if(variable=="pt") variable="pfpt[0]";
|
177 |
if(variable=="pt1") variable="pfpt1[0]";
|
178 |
if(variable=="pt2") variable="pfpt2[0]";
|
179 |
if(variable=="eta1") variable="pfeta1[0]";
|
180 |
if(variable=="jzb[1]") variable="pfjzb[0]";
|
181 |
//if(variable=="pfJetGoodNum") variable="pfJetGoodNum"; // pointless.
|
182 |
}
|
183 |
|
184 |
//Step 2: Refine the cut
|
185 |
TCut cut;
|
186 |
cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
|
187 |
if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
|
188 |
if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
|
189 |
if(filename=="mll") {
|
190 |
cut=cutOSSF&&cutnJets&&ibasiccut;
|
191 |
draw_separation_lines=true;
|
192 |
}
|
193 |
if(filename=="mll_ee") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
|
194 |
if(filename=="mll_osof") {
|
195 |
cut=cutOSOF&&cutnJets&&ibasiccut;
|
196 |
draw_separation_lines=true;
|
197 |
}
|
198 |
if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
|
199 |
if(filename=="mll_aboveJZB100") cut=cutOSSF&&cutnJets&&ibasiccut;
|
200 |
if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
|
201 |
if(filename=="mll_inclusive_osof") cut=cutOSOF;
|
202 |
if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
|
203 |
if(filename=="mll_inclusive_mm") cut=cutOSSF&&"id1==1";
|
204 |
if(filename=="pfJetGoodEta_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
|
205 |
if(filename=="pfJetGoodPt_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
|
206 |
|
207 |
TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
|
208 |
ckin->SetLogy(logscale);
|
209 |
TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
|
210 |
datahisto->SetMarkerSize(DataMarkerSize);
|
211 |
THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
|
212 |
if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
|
213 |
if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
|
214 |
if(filename=="mll_inclusive") datahisto->SetMinimum(1);
|
215 |
if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
|
216 |
if(filename=="mll_osof") datahisto->SetMinimum(9);
|
217 |
|
218 |
datahisto->SetMaximum(5.3*datahisto->GetMaximum());
|
219 |
datahisto->Draw("e1");
|
220 |
ckin->Update();
|
221 |
if(loadlastminmax) {
|
222 |
datahisto->SetMinimum(lastrange_min);
|
223 |
datahisto->SetMaximum(lastrange_max);
|
224 |
if(logscale) {
|
225 |
datahisto->SetMinimum(pow(10,lastrange_min));
|
226 |
datahisto->SetMaximum(pow(10,lastrange_max));
|
227 |
}
|
228 |
}
|
229 |
|
230 |
mcstack.Draw("same");
|
231 |
datahisto->Draw("same,e1");
|
232 |
TLegend *kinleg = allsamples.allbglegend();
|
233 |
kinleg->Draw();
|
234 |
if(filename=="mll_osof") {
|
235 |
kinleg->SetHeader("Opposite flavor");
|
236 |
kinleg->SetX1(0.58);
|
237 |
}
|
238 |
if(filename=="mll") {
|
239 |
kinleg->SetHeader("Same flavor");
|
240 |
kinleg->SetX1(0.58);
|
241 |
}
|
242 |
TText* write_cut = write_cut_on_canvas(decipher_cut(cut,basicqualitycut));
|
243 |
write_cut->Draw();
|
244 |
TText* write_variable = write_text(0.99,0.01,variable);
|
245 |
write_variable->SetTextAlign(31);
|
246 |
write_variable->SetTextSize(0.02);
|
247 |
|
248 |
TLine *lowerboundary;
|
249 |
TLine *upperboundary;
|
250 |
|
251 |
if(RestrictToMassPeak&&draw_separation_lines) {
|
252 |
Color_t linecolor=kBlue;
|
253 |
float linemin=pow(10,ckin->GetUymin());
|
254 |
if(filename=="mll_osof") linemin=pow(10,lastrange_min);
|
255 |
lowerboundary = new TLine(71,linemin,71,datahisto->GetMaximum());
|
256 |
upperboundary = new TLine(111,linemin,111,datahisto->GetMaximum());
|
257 |
lowerboundary->SetLineColor(linecolor);
|
258 |
lowerboundary->SetLineStyle(2);
|
259 |
upperboundary->SetLineColor(linecolor);
|
260 |
upperboundary->SetLineStyle(2);
|
261 |
}
|
262 |
|
263 |
lastrange_min=ckin->GetUymin();
|
264 |
lastrange_max=ckin->GetUymax();
|
265 |
|
266 |
|
267 |
if ( plotratio ) {
|
268 |
TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
|
269 |
kinpad->cd();
|
270 |
kinpad->SetLogy(logscale);
|
271 |
datahisto->Draw("e1");
|
272 |
mcstack.Draw("same");
|
273 |
datahisto->Draw("same,e1");
|
274 |
datahisto->Draw("same,axis");
|
275 |
if(RestrictToMassPeak&&draw_separation_lines) {
|
276 |
lowerboundary->Draw("same");
|
277 |
upperboundary->Draw("same");
|
278 |
}
|
279 |
|
280 |
kinleg->Draw();
|
281 |
write_cut->Draw();
|
282 |
DrawPrelim();
|
283 |
string saveas="kin/"+filename;
|
284 |
if(isPF) saveas="kin/"+filename+"__PF";
|
285 |
save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
|
286 |
// if(isPF) CompleteSave(with_ratio,"kin/"+filename+"__PF_withratio");
|
287 |
// else CompleteSave(with_ratio,"kin/"+filename+"_withratio");
|
288 |
// delete with_ratio;
|
289 |
} else {
|
290 |
if(isPF) CompleteSave(ckin,"kin/"+filename+"__PF");
|
291 |
else CompleteSave(ckin,"kin/"+filename);
|
292 |
}
|
293 |
datahisto->Delete();
|
294 |
delete ckin;
|
295 |
}
|
296 |
|
297 |
|
298 |
void make_JES_plot() {
|
299 |
|
300 |
int nbins=10;
|
301 |
float min=-0.5;
|
302 |
float max = 9.5;
|
303 |
bool logscale=true;
|
304 |
string xlabel="nJets";
|
305 |
TCut cut=cutmass&&cutOSSF&&basiccut;
|
306 |
|
307 |
TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
|
308 |
ckin->SetLogy(logscale);
|
309 |
TH1F *datahisto = allsamples.Draw("datahisto","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,data,luminosity);
|
310 |
datahisto->SetMarkerSize(DataMarkerSize);
|
311 |
THStack mcstack = allsamples.DrawStack("mcstack","pfJetGoodNum",nbins,min,max, xlabel, "events",cut,mc,luminosity);
|
312 |
TH1F *JESup = allsamples.Draw("JESup","pfJetGoodNum315",nbins,min,max, xlabel, "events",cut,mc,luminosity);
|
313 |
TH1F *JESdn = allsamples.Draw("JESdn","pfJetGoodNum285",nbins,min,max, xlabel, "events",cut,mc,luminosity);
|
314 |
|
315 |
datahisto->SetMinimum(1);
|
316 |
datahisto->SetMaximum(5.3*datahisto->GetMaximum()); // in line with kinematic plots style
|
317 |
|
318 |
float xs[nbins],ys[nbins],exs[nbins],eys[nbins];
|
319 |
for(int i=1;i<JESup->GetNbinsX();i++) {
|
320 |
float up=JESup->GetBinContent(i);
|
321 |
float dn=JESdn->GetBinContent(i);
|
322 |
xs[i]=JESup->GetBinCenter(i);
|
323 |
ys[i]=0.5*(up+dn);
|
324 |
exs[i]=0.5*JESup->GetBinWidth(i);
|
325 |
eys[i]=0.5*TMath::Abs(up-dn);
|
326 |
}
|
327 |
|
328 |
TGraphAsymmErrors *JESunc = new TGraphAsymmErrors(nbins, xs,ys,exs,exs,eys,eys);
|
329 |
JESunc->SetFillColor(TColor::GetColor("#00ADE1"));
|
330 |
JESunc->SetFillStyle(3002);
|
331 |
datahisto->Draw("e1");
|
332 |
mcstack.Draw("same");
|
333 |
JESunc->Draw("2");
|
334 |
datahisto->Draw("same,e1");
|
335 |
TLegend *kinleg = allsamples.allbglegend();
|
336 |
kinleg->AddEntry(JESunc,"JES uncertainty","f");
|
337 |
kinleg->Draw();
|
338 |
CompleteSave(ckin,"Systematics/JES");
|
339 |
datahisto->Delete();
|
340 |
delete ckin;
|
341 |
|
342 |
}
|
343 |
|
344 |
void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
|
345 |
{
|
346 |
bool dolog=true;
|
347 |
bool nolog=false;
|
348 |
if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
|
349 |
float mll_low=40;
|
350 |
float mll_hi=160;
|
351 |
if(!PlottingSetup::RestrictToMassPeak) {
|
352 |
mll_low=30;
|
353 |
mll_hi=180;
|
354 |
}
|
355 |
make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
|
356 |
make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
|
357 |
make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
|
358 |
make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
|
359 |
make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
|
360 |
make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
|
361 |
make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
|
362 |
make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
|
363 |
make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
|
364 |
make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
|
365 |
make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
|
366 |
make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
|
367 |
make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
|
368 |
make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
|
369 |
make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
|
370 |
make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
|
371 |
make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
|
372 |
make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
|
373 |
if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
|
374 |
stringstream jzbcut;
|
375 |
jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
|
376 |
make_kin_plot("mll",jzbcut.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB100",doPF,true);
|
377 |
}
|
378 |
|
379 |
void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
|
380 |
int nbins, float xmin, float xmax, bool log,
|
381 |
float ymin=0, float ymax=0, bool leftJustified=false ) {
|
382 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- WATCH OUT: the argument in the function changed!
|
383 |
|
384 |
TCut weightbackup=cutWeight;//backing up the correct weight (restoring below!)
|
385 |
if(weightbackup==TCut("1.0")||weightbackup==TCut("1")) write_warning(__FUNCTION__,"WATCH OUT THE WEIGHT HAS POSSIBLY NOT BEEN RESET!!!! PLEASE CHANGE LINE "+any2string(__LINE__));
|
386 |
if(var=="numVtx") cutWeight=TCut("1.0");
|
387 |
TCut jzbData[]= { TCut(TString(datajzb+">"+any2string(jzbcut))),TCut(TString(datajzb+"<-"+any2string(jzbcut))) };
|
388 |
TCut jzbMC[] = { TCut(TString(mcjzb+">"+any2string(jzbcut))),TCut(TString(mcjzb+"<-"+any2string(jzbcut))) };
|
389 |
|
390 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- below: the next ~20 lines changed!
|
391 |
int nRegions=4;
|
392 |
if(!PlottingSetup::RestrictToMassPeak) {
|
393 |
nRegions=2;
|
394 |
}
|
395 |
|
396 |
string sRegions[] = { "SFZP","OFZP","SFSB","OFSB" };
|
397 |
TCut kRegions[] = { cutOSSF&&cutnJets&&cutmass, cutOSOF&&cutnJets&&cutmass,
|
398 |
cutOSSF&&cutnJets&&sidebandcut, cutOSOF&&cutnJets&&sidebandcut };
|
399 |
|
400 |
//find ymax
|
401 |
TH1F *Refdatahisto = allsamples.Draw("datahisto", var,nbins,xmin,xmax,xlabel,"events",kRegions[0]&&jzbData[0],data,luminosity);
|
402 |
ymax=int((Refdatahisto->GetMaximum()+2*TMath::Sqrt(Refdatahisto->GetMaximum()))*1.2+0.5);
|
403 |
delete Refdatahisto;
|
404 |
|
405 |
for ( int iregion=0; iregion<nRegions; ++iregion )
|
406 |
for ( int ijzb=0; ijzb<2; ++ijzb ) {
|
407 |
TCanvas *ccomp = new TCanvas("ccomp","Comparison plot",600,400);
|
408 |
ccomp->SetLogy(log);
|
409 |
TH1F *datahisto = allsamples.Draw("datahisto", var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity);
|
410 |
TH1F *lm4histo = signalsamples.Draw("lm4histo", var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbData[ijzb],data,luminosity,signalsamples.FindSample("LM4"));
|
411 |
THStack mcstack = allsamples.DrawStack("mcstack",var,nbins,xmin,xmax,xlabel,"events",kRegions[iregion]&&jzbMC[ijzb], mc, luminosity);
|
412 |
datahisto->SetMarkerSize(DataMarkerSize);
|
413 |
if (ymax>ymin) datahisto->SetMaximum(ymax);
|
414 |
lm4histo->SetLineStyle(2);
|
415 |
datahisto->Draw("e1");
|
416 |
mcstack.Draw("same");
|
417 |
datahisto->Draw("same,e1");
|
418 |
// lm4histo->Draw("hist,same");
|
419 |
TLegend *kinleg = allsamples.allbglegend((sRegions[iregion]+(ijzb?"neg":"pos")).c_str());
|
420 |
if ( leftJustified ) {
|
421 |
Float_t w = kinleg->GetX2()-kinleg->GetX1();
|
422 |
kinleg->SetX1(0.2);
|
423 |
kinleg->SetX2(0.2+w);
|
424 |
}
|
425 |
// kinleg->AddEntry(lm4histo,"LM4","l");
|
426 |
kinleg->Draw();
|
427 |
TText* write_variable = write_text(0.99,0.01,var);
|
428 |
write_variable->SetTextAlign(31);
|
429 |
write_variable->SetTextSize(0.02);
|
430 |
ccomp->RedrawAxis();
|
431 |
CompleteSave(ccomp,"compare/JZBcut_at_"+any2string(jzbcut)+"/"+filename+"/"+filename+sRegions[iregion]+(ijzb?"neg":"pos"));
|
432 |
delete datahisto;
|
433 |
delete ccomp;
|
434 |
delete lm4histo;
|
435 |
}
|
436 |
cutWeight=weightbackup;
|
437 |
}
|
438 |
|
439 |
|
440 |
void region_comparison_plots(string mcjzb, string datajzb, vector<float> jzb_cuts) {
|
441 |
dout << "Creating comparison plots for signal and control regions" << endl;
|
442 |
// Compare a few quantities in the signal region and all 7 control regions
|
443 |
|
444 |
switch_overunderflow(true); // switching overflow/underflow bins on
|
445 |
|
446 |
|
447 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
|
448 |
for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
|
449 |
float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
|
450 |
float mll_low=50;float mll_high=170;
|
451 |
if(!PlottingSetup::RestrictToMassPeak) {
|
452 |
mll_high=200;
|
453 |
mll_low=50;
|
454 |
}
|
455 |
make_comp_plot("mll","m_{ll} [GeV]","mll",jzbcut,mcjzb,datajzb,30,mll_low,mll_high,false,0,16.);
|
456 |
make_comp_plot("met[4]","pfMET [GeV]","pfmet",jzbcut,mcjzb,datajzb,18,0,360,false,0,16.);
|
457 |
make_comp_plot("pfJetGoodNum","#(jets)","njets",jzbcut,mcjzb,datajzb,10,0,10, false,0,35.);
|
458 |
make_comp_plot("pt","Z p_{T} [GeV]","Zpt",jzbcut,mcjzb,datajzb,26,0,525,false,0.,21.);
|
459 |
make_comp_plot("numVtx","#(prim. vertices)","nvtx",jzbcut,mcjzb,datajzb,20,0.,20.,false,0,16.);
|
460 |
make_comp_plot("TMath::Abs(dphi)","#Delta#phi(leptons)","dphilep",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
|
461 |
make_comp_plot("TMath::Abs(dphi_sumJetVSZ[1])","#Delta#phi(Z,jets)","dphiZjets",jzbcut,mcjzb,datajzb,10,0.,3.1415,false,0,16.,true);
|
462 |
}
|
463 |
|
464 |
switch_overunderflow(false); // switching overflow/underflow bins off
|
465 |
}
|
466 |
|
467 |
|
468 |
|
469 |
void do_kinematic_PF_plots(string mcjzb, string datajzb)
|
470 |
{
|
471 |
do_kinematic_plots(mcjzb,datajzb,true);
|
472 |
}
|
473 |
|
474 |
void signal_bg_comparison()
|
475 |
{
|
476 |
TCanvas *can = new TCanvas("can","Signal Background Comparison Canvas");
|
477 |
can->SetLogy(1);
|
478 |
|
479 |
int sbg_nbins=130;
|
480 |
float sbg_min=-500; //-110;
|
481 |
float sbg_max=800; //jzbHigh;
|
482 |
|
483 |
float simulatedlumi=luminosity;//in pb please - adjust to your likings
|
484 |
|
485 |
TH1F *JZBplotZJETs = allsamples.Draw("JZBplotZJETs",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/DY"));
|
486 |
TH1F *JZBplotLM4 = allsamples.Draw("JZBplotLM4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("LM4"));
|
487 |
TH1F *JZBplotTtbar = allsamples.Draw("JZBplotTtbar",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("TTJets"));
|
488 |
|
489 |
JZBplotTtbar->SetLineColor(allsamples.GetColor("TTJet"));
|
490 |
JZBplotZJETs->SetFillColor(allsamples.GetColor("DY"));
|
491 |
JZBplotZJETs->SetLineColor(kBlack);
|
492 |
JZBplotLM4->SetLineStyle(2);
|
493 |
JZBplotZJETs->SetMaximum(JZBplotZJETs->GetMaximum()*5);
|
494 |
JZBplotZJETs->SetMinimum(1);
|
495 |
|
496 |
JZBplotTtbar->SetMaximum(JZBplotZJETs->GetMaximum());
|
497 |
JZBplotTtbar->SetMinimum(0.01);
|
498 |
JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
|
499 |
JZBplotTtbar->DrawClone("histo");
|
500 |
JZBplotZJETs->Draw("histo,same");
|
501 |
JZBplotTtbar->SetFillColor(0);
|
502 |
JZBplotTtbar->DrawClone("histo,same");
|
503 |
JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
|
504 |
JZBplotLM4->Draw("histo,same");
|
505 |
|
506 |
|
507 |
TLegend *signal_bg_comparison_leg2 = make_legend("",0.55,0.75,false);
|
508 |
signal_bg_comparison_leg2->AddEntry(JZBplotZJETs,"Z+Jets","f");
|
509 |
signal_bg_comparison_leg2->AddEntry(JZBplotTtbar,"t#bar{t}","f");
|
510 |
signal_bg_comparison_leg2->AddEntry(JZBplotLM4,"LM4","f");
|
511 |
signal_bg_comparison_leg2->Draw();
|
512 |
DrawMCPrelim(simulatedlumi);
|
513 |
CompleteSave(can,"jzb_bg_vs_signal_distribution");
|
514 |
|
515 |
// Define illustrative set of SMS points
|
516 |
TCut kSMS1("MassGlu==250&&MassLSP==75");
|
517 |
TCut kSMS2("MassGlu==800&&MassLSP==200");
|
518 |
TCut kSMS3("MassGlu==1050&&MassLSP==850");
|
519 |
TCut kSMS4("MassGlu==1200&&MassLSP==100");
|
520 |
|
521 |
//If the scan samples haven't been loaded yet, this is a good point to load them (all of them!)
|
522 |
if((scansample.collection).size()<2) define_SMS_sample(false, allsamples, signalsamples, scansample, true); // loading ALL zones for the scans, not only the basic one.
|
523 |
|
524 |
|
525 |
TH1F *JZBplotSMS1 = scansample.Draw("JZBplotSMS1",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&kSMS1,mc,simulatedlumi,scansample.FindSample("t"));
|
526 |
JZBplotSMS1->Scale(JZBplotLM4->Integral()/JZBplotSMS1->Integral());
|
527 |
|
528 |
TH1F *JZBplotSMS2 = scansample.Draw("JZBplotSMS2",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&kSMS2,mc,simulatedlumi,scansample.FindSample("t"));
|
529 |
JZBplotSMS2->Scale(JZBplotLM4->Integral()/JZBplotSMS2->Integral());
|
530 |
|
531 |
TH1F *JZBplotSMS3 = scansample.Draw("JZBplotSMS3",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&kSMS3,mc,simulatedlumi,scansample.FindSample("t"));
|
532 |
JZBplotSMS3->Scale(JZBplotLM4->Integral()/JZBplotSMS3->Integral());
|
533 |
|
534 |
TH1F *JZBplotSMS4 = scansample.Draw("JZBplotSMS4",jzbvariablemc,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&kSMS4,mc,simulatedlumi,scansample.FindSample("t"));
|
535 |
JZBplotSMS4->Scale(JZBplotLM4->Integral()/JZBplotSMS4->Integral());
|
536 |
|
537 |
// Draw all plots overlaid
|
538 |
JZBplotTtbar->SetMaximum(JZBplotZJETs->GetMaximum());
|
539 |
JZBplotTtbar->SetMinimum(0.01);
|
540 |
JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
|
541 |
JZBplotTtbar->DrawClone("histo");
|
542 |
JZBplotZJETs->Draw("histo,same");
|
543 |
JZBplotTtbar->SetFillColor(0);
|
544 |
JZBplotTtbar->DrawClone("histo,same");
|
545 |
JZBplotTtbar->SetFillColor(allsamples.GetColor("TTJets"));
|
546 |
|
547 |
JZBplotSMS1->SetLineColor(kRed+1);
|
548 |
JZBplotSMS2->SetLineColor(kBlue+1);
|
549 |
JZBplotSMS3->SetLineColor(kRed+1);
|
550 |
JZBplotSMS4->SetLineColor(kBlue+1);
|
551 |
JZBplotSMS3->SetLineStyle(2);
|
552 |
JZBplotSMS4->SetLineStyle(2);
|
553 |
|
554 |
JZBplotSMS1->Draw("histo,same");
|
555 |
JZBplotSMS2->Draw("histo,same");
|
556 |
JZBplotSMS3->Draw("histo,same");
|
557 |
JZBplotSMS4->Draw("histo,same");
|
558 |
JZBplotLM4->SetLineColor(kGreen);JZBplotLM4->Draw("histo,same");
|
559 |
TLegend *signal_bg_comparison_leg6 = make_legend("",0.55,0.55,false);
|
560 |
signal_bg_comparison_leg6->AddEntry(JZBplotZJETs,"Z+Jets","f");
|
561 |
signal_bg_comparison_leg6->AddEntry(JZBplotTtbar,"t#bar{t}","f");
|
562 |
signal_bg_comparison_leg6->AddEntry(JZBplotSMS1,"","");
|
563 |
signal_bg_comparison_leg6->AddEntry(JZBplotSMS1,"SMS parameters","");
|
564 |
signal_bg_comparison_leg6->AddEntry(JZBplotSMS1,"(250,75) [GeV]","f");
|
565 |
signal_bg_comparison_leg6->AddEntry(JZBplotSMS2,"(800,200) [GeV]","f");
|
566 |
signal_bg_comparison_leg6->AddEntry(JZBplotSMS3,"(1050,850) [GeV]","f");
|
567 |
signal_bg_comparison_leg6->AddEntry(JZBplotSMS4,"(1200,100) [GeV]","f");
|
568 |
signal_bg_comparison_leg6->AddEntry(JZBplotLM4,"LM4","f");
|
569 |
signal_bg_comparison_leg6->Draw();
|
570 |
DrawMCPrelim(simulatedlumi);
|
571 |
CompleteSave(can,"jzb_bg_vs_signal_distribution_SMS__summary");
|
572 |
|
573 |
while((scansample.collection).size() > 1) scansample.RemoveLastSample();
|
574 |
|
575 |
}
|
576 |
|
577 |
vector<TF1*> do_cb_fit_to_plot(TH1F *histo, float Sigma, float doingfitacrosstheboard=false) {
|
578 |
TF1 *BpredFunc = new TF1("BpredFunc",InvCrystalBall,0,1000,5);
|
579 |
BpredFunc->SetParameter(0,histo->GetBinContent(1));
|
580 |
if(doingfitacrosstheboard) BpredFunc->SetParameter(0,histo->GetMaximum());
|
581 |
BpredFunc->SetParameter(1,0.);
|
582 |
if(method==1) BpredFunc->SetParameter(2,10*Sigma);//KM
|
583 |
else BpredFunc->SetParameter(2,Sigma);//Gaussian based methods
|
584 |
if(method==-99) BpredFunc->SetParameter(2,2.0*Sigma);//Kostas
|
585 |
BpredFunc->SetParameter(3,1.8);
|
586 |
BpredFunc->SetParameter(4,2.5);
|
587 |
histo->Fit(BpredFunc,"QN0");
|
588 |
BpredFunc->SetLineColor(kBlue);
|
589 |
|
590 |
TF1 *BpredFuncP = new TF1("BpredFuncP",InvCrystalBallP,-1000,histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX()),5);
|
591 |
TF1 *BpredFuncN = new TF1("BpredFuncN",InvCrystalBallN,-1000,histo->GetBinLowEdge(histo->GetNbinsX())+histo->GetBinWidth(histo->GetNbinsX()),5);
|
592 |
|
593 |
BpredFuncP->SetParameters(BpredFunc->GetParameters());
|
594 |
BpredFuncP->SetLineColor(kBlue);
|
595 |
BpredFuncP->SetLineStyle(2);
|
596 |
|
597 |
BpredFuncN->SetParameters(BpredFunc->GetParameters());
|
598 |
BpredFuncN->SetLineColor(kBlue);
|
599 |
BpredFuncN->SetLineStyle(2);
|
600 |
|
601 |
vector<TF1*> functions;
|
602 |
functions.push_back(BpredFuncN);
|
603 |
functions.push_back(BpredFunc);
|
604 |
functions.push_back(BpredFuncP);
|
605 |
return functions;
|
606 |
}
|
607 |
|
608 |
|
609 |
TF1* do_logpar_fit_to_plot(TH1F *osof) {
|
610 |
TCanvas *logpar_fit_can = new TCanvas("logpar_fit_can","Fit canvas for LogPar");
|
611 |
TF1 *logparfunc = new TF1("logparfunc",LogParabola,0,300,3);
|
612 |
TF1 *logparfunc2 = new TF1("logparfunc2",LogParabola,0,(osof->GetXaxis()->GetBinLowEdge(osof->GetNbinsX())+osof->GetXaxis()->GetBinWidth(osof->GetNbinsX())),3);
|
613 |
TF1 *logparfuncN = new TF1("logparfuncN",LogParabolaN,0,(osof->GetXaxis()->GetBinLowEdge(osof->GetNbinsX())+osof->GetXaxis()->GetBinWidth(osof->GetNbinsX())),3);
|
614 |
TF1 *logparfuncP = new TF1("logparfuncP",LogParabolaP,0,(osof->GetXaxis()->GetBinLowEdge(osof->GetNbinsX())+osof->GetXaxis()->GetBinWidth(osof->GetNbinsX())),3);
|
615 |
osof->SetMinimum(0);
|
616 |
osof->Fit(logparfunc,"QR");
|
617 |
osof->Draw();
|
618 |
logparfunc->SetLineWidth(2);
|
619 |
logparfunc2->SetParameters(logparfunc->GetParameters());
|
620 |
logparfuncN->SetParameters(logparfunc->GetParameters());
|
621 |
logparfuncP->SetParameters(logparfunc->GetParameters());
|
622 |
stringstream fitinfo;
|
623 |
fitinfo << "#Chi^{2} / NDF : " << logparfunc->GetChisquare() << " / " << logparfunc->GetNDF();
|
624 |
TText *writefitinfo = write_text(0.8,0.8,fitinfo.str());
|
625 |
writefitinfo->SetTextSize(0.03);
|
626 |
DrawPrelim();
|
627 |
writefitinfo->Draw();
|
628 |
logparfunc->Draw("same");
|
629 |
logparfunc2->Draw("same");
|
630 |
logparfuncN->SetLineStyle(2);
|
631 |
logparfuncP->SetLineStyle(2);
|
632 |
logparfuncN->Draw("same");
|
633 |
logparfuncP->Draw("same");
|
634 |
CompleteSave(logpar_fit_can,"MakingOfBpredFunction/Bpred_Data_LogPar_Fit_To_TTbarPred");
|
635 |
delete logpar_fit_can;
|
636 |
return logparfunc2;
|
637 |
}
|
638 |
|
639 |
vector<TF1*> do_extended_fit_to_plot(TH1F *prediction, TH1F *Tprediction, TH1F *ossf, TH1F *osof,int isdata) {
|
640 |
/* there are mainly two background contributions: Z+Jets (a) and ttbar (b). So:
|
641 |
a) The case is clear - we take the OSSF prediction - OSOF prediction, and fit a crystal ball function to it. We then extract the CB parameters.
|
642 |
b) For ttbar, we use the OSOF distribution and look at the [10,100] GeV JZB range, and fit our log parabola. We then extract the LP parameters.
|
643 |
Once we have these two components, we use the combined parameters to get the final function and we're done.
|
644 |
*/
|
645 |
//Step 1: take the OSSF prediction - OSOF prediction, and fit a crystal ball function to it
|
646 |
TH1F *step1cb = (TH1F*)ossf->Clone("step1cb");
|
647 |
step1cb->Add(osof,-1);
|
648 |
vector<TF1*> functions = do_cb_fit_to_plot(step1cb,PlottingSetup::JZBPeakWidthData);
|
649 |
TF1 *zjetscrystalball = functions[1];
|
650 |
|
651 |
//Step 2: use the OSOF distribution and look at the [10,100] GeV JZB range, and fit our log parabola
|
652 |
// TH1F *ttbarprediction=(TH1F*)prediction->Clone("ttbarprediction");
|
653 |
// ttbarprediction->Add(ossf,-1);//without the Z+Jets estimate, this is really just the ttbar estimate!
|
654 |
// the line above is not necessary anymore as we're now looking at a prediction without Z+Jets, and not multiplied with (1.0/3)
|
655 |
TF1 *ttbarlogpar = do_logpar_fit_to_plot(Tprediction);
|
656 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
|
657 |
if(PlottingSetup::RestrictToMassPeak) ttbarlogpar->SetParameter(0,1.0/3*ttbarlogpar->GetParameter(0));//correcting for the fact that we didn't multiply with (1.0/3);
|
658 |
|
659 |
|
660 |
TF1 *ttbarlogparP = new TF1("ttbarlogparP",LogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
|
661 |
TF1 *ttbarlogparN = new TF1("ttbarlogparN",LogParabolaN,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
|
662 |
|
663 |
//and now fuse the two!
|
664 |
TF1 *kmlp = new TF1("kmlp", CrystalBallPlusLogParabola, 0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
|
665 |
TF1 *kmlpP= new TF1("kmlpP",CrystalBallPlusLogParabolaP,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
|
666 |
TF1 *kmlpN= new TF1("kmlpN",CrystalBallPlusLogParabolaN,0,(prediction->GetXaxis()->GetBinLowEdge(prediction->GetNbinsX())+prediction->GetXaxis()->GetBinWidth(prediction->GetNbinsX())),8);
|
667 |
double kmlp_pars[10];
|
668 |
for(int i=0;i<5;i++) kmlp_pars[i]=zjetscrystalball->GetParameter(i);
|
669 |
for(int i=0;i<3;i++) kmlp_pars[5+i]=ttbarlogpar->GetParameter(i);
|
670 |
ttbarlogparP->SetParameters(ttbarlogpar->GetParameters());
|
671 |
ttbarlogparN->SetParameters(ttbarlogpar->GetParameters());
|
672 |
kmlp->SetParameters(kmlp_pars);
|
673 |
prediction->Fit(kmlp,"Q");//fitting the final result (done this in the past but kicked it)
|
674 |
/*
|
675 |
if you want to start from scratch (without the partial fitting and only fitting the whole thing, some good start values could be :
|
676 |
*/
|
677 |
kmlp_pars[0]=kmlp->GetParameter(0);
|
678 |
kmlp_pars[1]=3.6198;
|
679 |
kmlp_pars[2]=16.4664;
|
680 |
kmlp_pars[3]=1.92253;
|
681 |
kmlp_pars[4]=3.56099;
|
682 |
kmlp_pars[5]=5.83;
|
683 |
kmlp_pars[6]=0.000757479;
|
684 |
kmlp_pars[7]=95.6157;
|
685 |
kmlp_pars[8]=0;
|
686 |
kmlp_pars[9]=0;
|
687 |
kmlp->SetParameters(kmlp_pars);
|
688 |
/**/
|
689 |
prediction->Fit(kmlp,"Q");//fitting the final result (done this in the past but kicked it)
|
690 |
|
691 |
kmlpP->SetParameters(kmlp->GetParameters());
|
692 |
kmlpN->SetParameters(kmlp->GetParameters());
|
693 |
|
694 |
// now that we're done, let's save all of this so we can have a look at it afterwards.
|
695 |
TCanvas *can = new TCanvas("can","Prediction Fit Canvas");
|
696 |
can->SetLogy(1);
|
697 |
prediction->SetMarkerColor(kRed);
|
698 |
prediction->Draw();
|
699 |
|
700 |
kmlp->SetLineColor(TColor::GetColor("#04B404"));
|
701 |
kmlpP->SetLineColor(TColor::GetColor("#04B404"));
|
702 |
kmlpN->SetLineColor(TColor::GetColor("#04B404"));
|
703 |
kmlp->Draw("same");
|
704 |
kmlpN->SetLineStyle(2);
|
705 |
kmlpP->SetLineStyle(2);
|
706 |
kmlpN->Draw("same");
|
707 |
kmlpP->Draw("same");
|
708 |
|
709 |
ttbarlogpar->SetLineColor(TColor::GetColor("#CC2EFA"));//purple
|
710 |
ttbarlogpar->Draw("same");
|
711 |
ttbarlogparP->SetLineColor(TColor::GetColor("#CC2EFA"));//purple
|
712 |
ttbarlogparN->SetLineColor(TColor::GetColor("#CC2EFA"));//purple
|
713 |
ttbarlogparP->SetLineStyle(2);
|
714 |
ttbarlogparN->SetLineStyle(2);
|
715 |
ttbarlogparP->Draw("same");
|
716 |
ttbarlogparN->Draw("same");
|
717 |
|
718 |
functions[0]->Draw("same");functions[1]->Draw("same");functions[2]->Draw("same");
|
719 |
|
720 |
TLegend *analyticalBpredLEG = make_legend("",0.5,0.55);
|
721 |
analyticalBpredLEG->AddEntry(prediction,"predicted","p");
|
722 |
analyticalBpredLEG->AddEntry(functions[1],"Crystal Ball fit","l");
|
723 |
analyticalBpredLEG->AddEntry(functions[0],"1#sigma Crystal Ball fit","l");
|
724 |
analyticalBpredLEG->AddEntry(ttbarlogparN,"TTbar fit","l");
|
725 |
analyticalBpredLEG->AddEntry(ttbarlogpar,"1#sigma TTbar fit","l");
|
726 |
analyticalBpredLEG->AddEntry(kmlp,"Combined function","l");
|
727 |
analyticalBpredLEG->AddEntry(kmlpN,"1#sigma combined function","l");
|
728 |
analyticalBpredLEG->Draw("same");
|
729 |
|
730 |
if(isdata==0) CompleteSave(can,"MakingOfBpredFunction/Bpred_MC_Analytical_Function_Composition");
|
731 |
if(isdata==1) CompleteSave(can,"MakingOfBpredFunction/Bpred_data_Analytical_Function_Composition");
|
732 |
if(isdata==2) CompleteSave(can,"MakingOfBpredFunction/Bpred_MCBnS_Analytical_Function_Composition");
|
733 |
delete can;
|
734 |
|
735 |
//and finally: prep return functions
|
736 |
vector<TF1*> return_functions;
|
737 |
return_functions.push_back(kmlpN);
|
738 |
return_functions.push_back(kmlp);
|
739 |
return_functions.push_back(kmlpP);
|
740 |
|
741 |
return_functions.push_back(ttbarlogparN);
|
742 |
return_functions.push_back(ttbarlogpar);
|
743 |
return_functions.push_back(ttbarlogparP);
|
744 |
|
745 |
return_functions.push_back(functions[0]);
|
746 |
return_functions.push_back(functions[1]);
|
747 |
return_functions.push_back(functions[2]);
|
748 |
|
749 |
return return_functions;
|
750 |
}
|
751 |
|
752 |
void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false )
|
753 |
{
|
754 |
bool is_data=false;
|
755 |
bool use_signal=false;
|
756 |
if(use_data==1) is_data=true;
|
757 |
if(use_data==2) use_signal=true;
|
758 |
int nbins=50;//100;
|
759 |
if(is_data) nbins=50;
|
760 |
float low=0;
|
761 |
float hi=500;
|
762 |
TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
|
763 |
TH1F *RcorrJZBeemm = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
764 |
TH1F *LcorrJZBeemm = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
765 |
TH1F *RcorrJZBem = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
766 |
TH1F *LcorrJZBem = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
767 |
blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
|
768 |
blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
|
769 |
blankback->GetXaxis()->CenterTitle();
|
770 |
blankback->GetYaxis()->CenterTitle();
|
771 |
|
772 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
|
773 |
TH1F *RcorrJZBSBem;
|
774 |
TH1F *LcorrJZBSBem;
|
775 |
TH1F *RcorrJZBSBeemm;
|
776 |
TH1F *LcorrJZBSBeemm;
|
777 |
|
778 |
TH1F *RcorrJZBeemmNoS;
|
779 |
|
780 |
//these are for the ratio
|
781 |
TH1F *JRcorrJZBeemm = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
782 |
TH1F *JLcorrJZBeemm = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
783 |
TH1F *JRcorrJZBem = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
784 |
TH1F *JLcorrJZBem = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
785 |
|
786 |
TH1F *JRcorrJZBSBem;
|
787 |
TH1F *JLcorrJZBSBem;
|
788 |
TH1F *JRcorrJZBSBeemm;
|
789 |
TH1F *JLcorrJZBSBeemm;
|
790 |
|
791 |
if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
|
792 |
|
793 |
|
794 |
if(PlottingSetup::RestrictToMassPeak) {
|
795 |
RcorrJZBSBem = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
796 |
LcorrJZBSBem = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
797 |
RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
798 |
LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
799 |
|
800 |
//these are for the ratio
|
801 |
JRcorrJZBSBem = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
802 |
JLcorrJZBSBem = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
803 |
JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
804 |
JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
805 |
|
806 |
}
|
807 |
|
808 |
TH1F *lm4RcorrJZBeemm;
|
809 |
if(overlay_signal || use_data == 2 ) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM4"));
|
810 |
|
811 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
|
812 |
|
813 |
TH1F *Zjetspred = (TH1F*)LcorrJZBeemm->Clone("Zjetspred");
|
814 |
TH1F *TTbarpred = (TH1F*)RcorrJZBem->Clone("TTbarpred");
|
815 |
|
816 |
TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
|
817 |
TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
|
818 |
if(PlottingSetup::RestrictToMassPeak) {
|
819 |
Bpred->Add(RcorrJZBem,1.0/3.);
|
820 |
Bpred->Add(LcorrJZBem,-1.0/3.);
|
821 |
Bpred->Add(RcorrJZBSBem,1.0/3.);
|
822 |
Bpred->Add(LcorrJZBSBem,-1.0/3.);
|
823 |
Bpred->Add(RcorrJZBSBeemm,1.0/3.);
|
824 |
Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
|
825 |
|
826 |
TTbarpred->Scale(1.0/3);
|
827 |
Zjetspred->Add(LcorrJZBem,-1.0/3.);
|
828 |
Zjetspred->Add(LcorrJZBSBem,-1.0/3.);
|
829 |
TTbarpred->Add(RcorrJZBSBem,1.0/3.);
|
830 |
Zjetspred->Add(LcorrJZBSBeemm,-1.0/3.);
|
831 |
TTbarpred->Add(RcorrJZBSBeemm,1.0/3.);
|
832 |
|
833 |
//these are for the ratio
|
834 |
JBpred->Add(JRcorrJZBem,1.0/3.);
|
835 |
JBpred->Add(JLcorrJZBem,-1.0/3.);
|
836 |
JBpred->Add(JRcorrJZBSBem,1.0/3.);
|
837 |
JBpred->Add(JLcorrJZBSBem,-1.0/3.);
|
838 |
JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
|
839 |
JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
|
840 |
} else {
|
841 |
Bpred->Add(RcorrJZBem,1.0);
|
842 |
Bpred->Add(LcorrJZBem,-1.0);
|
843 |
|
844 |
Zjetspred->Add(LcorrJZBem,-1.0);
|
845 |
|
846 |
//these are for the ratio
|
847 |
JBpred->Add(JRcorrJZBem,1.0);
|
848 |
JBpred->Add(JLcorrJZBem,-1.0);
|
849 |
}
|
850 |
|
851 |
|
852 |
|
853 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
|
854 |
TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
|
855 |
Tpred->Add(LcorrJZBem,-1.0);
|
856 |
if(PlottingSetup::RestrictToMassPeak) {
|
857 |
Tpred->Add(RcorrJZBSBem,1.0);
|
858 |
Tpred->Add(LcorrJZBSBem,-1.0);
|
859 |
Tpred->Add(RcorrJZBSBeemm,1.0);
|
860 |
Tpred->Add(LcorrJZBSBeemm,-1.0);
|
861 |
}
|
862 |
|
863 |
globalcanvas->cd();
|
864 |
globalcanvas->SetLogy(1);
|
865 |
|
866 |
RcorrJZBeemm->SetMarkerStyle(20);
|
867 |
RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
|
868 |
RcorrJZBeemm->SetMinimum(0.1);
|
869 |
|
870 |
Bpred->SetLineColor(kRed);
|
871 |
Bpred->SetStats(0);
|
872 |
|
873 |
int versok=false;
|
874 |
if(gROOT->GetVersionInt()>=53000) versok=true;
|
875 |
|
876 |
|
877 |
if ( overlay_signal || use_data==2 ) lm4RcorrJZBeemm->SetLineColor(TColor::GetColor("#088A08"));
|
878 |
RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
|
879 |
|
880 |
TLegend *legBpred = make_legend("",0.6,0.55);
|
881 |
TLegend *legBpred2 = make_legend("",0.6,0.55);
|
882 |
|
883 |
|
884 |
vector<TF1*> analytical_function;
|
885 |
TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
|
886 |
kinpad->cd();
|
887 |
kinpad->SetLogy(1);
|
888 |
|
889 |
string Bpredsaveas="Bpred_Data";
|
890 |
blankback->SetMaximum(5*RcorrJZBeemm->GetMaximum());
|
891 |
blankback->SetMinimum(0.1);
|
892 |
if(use_data!=1) blankback->SetMinimum(0.1);
|
893 |
blankback->Draw();
|
894 |
if(use_data==1)
|
895 |
{
|
896 |
analytical_function = do_extended_fit_to_plot(Bpred,Tpred,LcorrJZBeemm,LcorrJZBem,is_data);
|
897 |
kinpad->cd();//necessary because the extended fit function creates its own canvas
|
898 |
RcorrJZBeemm->Draw("e1x0,same");
|
899 |
|
900 |
Bpred->Draw("hist,same");
|
901 |
analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
|
902 |
RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
|
903 |
legBpred->AddEntry(RcorrJZBeemm,"observed","p");
|
904 |
legBpred->AddEntry(Bpred,"predicted","l");
|
905 |
legBpred->AddEntry(analytical_function[1],"predicted fit","l");
|
906 |
legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
|
907 |
if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
|
908 |
legBpred->Draw();
|
909 |
DrawPrelim();
|
910 |
|
911 |
//this plot shows what the prediction is composed of
|
912 |
TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
|
913 |
specialcanv->SetLogy(1);
|
914 |
Zjetspred->SetFillColor(kYellow);
|
915 |
Zjetspred->SetLineColor(kYellow);
|
916 |
TTbarpred->SetFillColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
|
917 |
TTbarpred->SetLineColor(allsamples.GetColor((allsamples.FindSample("TTJets"))[0]));
|
918 |
THStack predcomposition("predcomposition","prediction composition");
|
919 |
predcomposition.Add(TTbarpred);
|
920 |
predcomposition.Add(Zjetspred);
|
921 |
blankback->Draw();
|
922 |
RcorrJZBeemm->Draw("e1x0,same");
|
923 |
predcomposition.Draw("histo,same");//
|
924 |
Bpred->Draw("hist,same");
|
925 |
analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
|
926 |
RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
|
927 |
legBpred->Draw();
|
928 |
DrawPrelim();
|
929 |
TLegend *specialleg = new TLegend(0.6,0.4,0.89,0.55);
|
930 |
specialleg->SetFillColor(kWhite);specialleg->SetLineColor(kWhite);
|
931 |
specialleg->AddEntry(Zjetspred,"Z+Jets prediction","f");
|
932 |
specialleg->AddEntry(TTbarpred,"t#bar{t} prediction","f");
|
933 |
specialleg->Draw("same");
|
934 |
CompleteSave(specialcanv,"Bpred_Data_____PredictionComposition");
|
935 |
|
936 |
THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
|
937 |
blankback->Draw();
|
938 |
kostack.Draw("same");
|
939 |
Bpred->Draw("hist,same");
|
940 |
analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
|
941 |
RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
|
942 |
legBpred->Draw();
|
943 |
DrawPrelim();
|
944 |
CompleteSave(specialcanv,"Bpred_Data_____PredictionCompositioninMC");
|
945 |
|
946 |
delete specialcanv;
|
947 |
delete specialleg;
|
948 |
delete Zjetspred;
|
949 |
delete TTbarpred;
|
950 |
|
951 |
kinpad->cd();
|
952 |
}
|
953 |
if(use_data==0) {
|
954 |
RcorrJZBeemm->Draw("e1x0,same");
|
955 |
Bpred->Draw("hist,same");
|
956 |
RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
|
957 |
legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
|
958 |
legBpred->AddEntry(Bpred,"MC predicted","l");
|
959 |
if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
|
960 |
if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
|
961 |
if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
|
962 |
legBpred->Draw();
|
963 |
DrawMCPrelim();
|
964 |
Bpredsaveas="Bpred_MC";
|
965 |
// CompleteSave(globalcanvas,"Bpred_MC"); // done below in save_with_ratio
|
966 |
}
|
967 |
if(use_data==2) {
|
968 |
RcorrJZBeemm->Draw("e1x0,same");
|
969 |
Bpred->Draw("hist,same");
|
970 |
RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
|
971 |
legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
|
972 |
legBpred->AddEntry(Bpred,"MC predicted","l");
|
973 |
legBpred2->AddEntry(RcorrJZBeemm,"MC observed","p");
|
974 |
legBpred2->AddEntry(Bpred,"MC predicted","l");
|
975 |
{
|
976 |
if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18 --> now only allowed for root >=v5.30
|
977 |
if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18 --> now only allowed for root >=v5.30
|
978 |
legBpred->Draw();
|
979 |
DrawMCPrelim();
|
980 |
Bpredsaveas="Bpred_MCwithS";
|
981 |
// CompleteSave(globalcanvas,"Bpred_MCwithS"); // done below in save_with_ratio
|
982 |
}
|
983 |
{
|
984 |
RcorrJZBeemmNoS->SetLineStyle(2);
|
985 |
legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
|
986 |
legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
|
987 |
legBpred2->Draw();
|
988 |
RcorrJZBeemmNoS->SetLineColor(TColor::GetColor("#61210B"));
|
989 |
RcorrJZBeemmNoS->Draw("histo,same");
|
990 |
RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
|
991 |
lm4RcorrJZBeemm->Draw("histo,same");
|
992 |
DrawMCPrelim();
|
993 |
Bpredsaveas="Bpred_MCwithS__plus";
|
994 |
// CompleteSave(globalcanvas,"Bpred_MCwithS__plus"); // done below in save_with_ratio
|
995 |
}
|
996 |
}
|
997 |
|
998 |
|
999 |
//3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
|
1000 |
string ytitle("ratio");
|
1001 |
if ( use_data==1 ) ytitle = "data/pred";
|
1002 |
save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
|
1003 |
|
1004 |
|
1005 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
|
1006 |
/// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
|
1007 |
if(!PlottingSetup::RestrictToMassPeak) return;
|
1008 |
TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
|
1009 |
Bpredem->Add(RcorrJZBem);
|
1010 |
Bpredem->Add(LcorrJZBem,-1);
|
1011 |
TH1F *BpredSBem = (TH1F*)LcorrJZBeemm->Clone("BpredSBem");
|
1012 |
BpredSBem->Add(RcorrJZBSBem);
|
1013 |
Bpred->Add(LcorrJZBSBem,-1);
|
1014 |
TH1F *BpredSBeemm = (TH1F*)LcorrJZBeemm->Clone("BpredSBeemm");
|
1015 |
BpredSBeemm->Add(RcorrJZBSBeemm);
|
1016 |
BpredSBeemm->Add(LcorrJZBSBeemm,-1.0);
|
1017 |
globalcanvas->cd();
|
1018 |
globalcanvas->SetLogy(1);
|
1019 |
|
1020 |
RcorrJZBeemm->SetMarkerStyle(20);
|
1021 |
RcorrJZBeemm->GetXaxis()->SetRangeUser(0,high);
|
1022 |
blankback->Draw();
|
1023 |
RcorrJZBeemm->Draw("e1x0,same");
|
1024 |
RcorrJZBeemm->SetMarkerSize(DataMarkerSize);
|
1025 |
|
1026 |
Bpredem->SetLineColor(kRed+1);
|
1027 |
Bpredem->SetStats(0);
|
1028 |
Bpredem->Draw("hist,same");
|
1029 |
|
1030 |
BpredSBem->SetLineColor(kGreen+2);//TColor::GetColor("#0B6138"));
|
1031 |
BpredSBem->SetLineStyle(2);
|
1032 |
BpredSBem->Draw("hist,same");
|
1033 |
|
1034 |
BpredSBeemm->SetLineColor(kBlue+1);
|
1035 |
BpredSBeemm->SetLineStyle(3);
|
1036 |
BpredSBeemm->Draw("hist,same");
|
1037 |
RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
|
1038 |
|
1039 |
TLegend *legBpredc = make_legend("",0.6,0.55);
|
1040 |
if(use_data==1)
|
1041 |
{
|
1042 |
legBpredc->AddEntry(RcorrJZBeemm,"observed","p");
|
1043 |
legBpredc->AddEntry(Bpredem,"OFZP","l");
|
1044 |
legBpredc->AddEntry(BpredSBem,"OFSB","l");
|
1045 |
legBpredc->AddEntry(BpredSBeemm,"SFSB","l");
|
1046 |
legBpredc->Draw();
|
1047 |
CompleteSave(globalcanvas,"Bpred_Data_comparison");
|
1048 |
}
|
1049 |
if(use_data==0) {
|
1050 |
legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
|
1051 |
legBpredc->AddEntry(Bpredem,"MC OFZP","l");
|
1052 |
legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
|
1053 |
legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
|
1054 |
legBpredc->Draw();
|
1055 |
CompleteSave(globalcanvas,"Bpred_MC_comparison");
|
1056 |
}
|
1057 |
if(use_data==2) {
|
1058 |
legBpredc->AddEntry(RcorrJZBeemm,"MC observed","p");
|
1059 |
legBpredc->AddEntry(Bpredem,"MC OFZP","l");
|
1060 |
legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
|
1061 |
legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
|
1062 |
if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
|
1063 |
legBpredc->Draw();
|
1064 |
CompleteSave(globalcanvas,"Bpred_MCwithS_comparison");
|
1065 |
}
|
1066 |
delete RcorrJZBeemm;
|
1067 |
delete LcorrJZBeemm;
|
1068 |
delete RcorrJZBem;
|
1069 |
delete LcorrJZBem;
|
1070 |
|
1071 |
delete JRcorrJZBeemm;
|
1072 |
delete JLcorrJZBeemm;
|
1073 |
delete JRcorrJZBem;
|
1074 |
delete JLcorrJZBem;
|
1075 |
|
1076 |
delete blankback;
|
1077 |
|
1078 |
if(PlottingSetup::RestrictToMassPeak) {
|
1079 |
delete RcorrJZBSBem;
|
1080 |
delete LcorrJZBSBem;
|
1081 |
delete RcorrJZBSBeemm;
|
1082 |
delete LcorrJZBSBeemm;
|
1083 |
|
1084 |
delete JRcorrJZBSBem;
|
1085 |
delete JLcorrJZBSBem;
|
1086 |
delete JRcorrJZBSBeemm;
|
1087 |
delete JLcorrJZBSBeemm;
|
1088 |
}
|
1089 |
if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
|
1090 |
}
|
1091 |
|
1092 |
void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
|
1093 |
TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
|
1094 |
do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
|
1095 |
do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
|
1096 |
do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
|
1097 |
}
|
1098 |
|
1099 |
void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
|
1100 |
bool do_data=0;
|
1101 |
bool dosignal=0;
|
1102 |
if(is_data==1) do_data=1;
|
1103 |
if(is_data==2) dosignal=1;
|
1104 |
TH1F *RcorrJZBeemm = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
|
1105 |
TH1F *LcorrJZBeemm = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
|
1106 |
TH1F *RcorrJZBem = allsamples.Draw("RcorrJZBem",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
|
1107 |
TH1F *LcorrJZBem = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
|
1108 |
|
1109 |
TH1F *RcorrJZBSBem;
|
1110 |
TH1F *LcorrJZBSBem;
|
1111 |
TH1F *RcorrJZBSBeemm;
|
1112 |
TH1F *LcorrJZBSbeemm;
|
1113 |
|
1114 |
if(PlottingSetup::RestrictToMassPeak) {
|
1115 |
RcorrJZBSBem = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
|
1116 |
LcorrJZBSBem = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
|
1117 |
RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
|
1118 |
LcorrJZBSbeemm = allsamples.Draw("LcorrJZBSbeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
|
1119 |
}
|
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
|
1125 |
TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
|
1126 |
if(PlottingSetup::RestrictToMassPeak) {
|
1127 |
Bpred->Add(RcorrJZBem,1.0/3);
|
1128 |
Bpred->Add(LcorrJZBem,-1.0/3);
|
1129 |
Bpred->Add(RcorrJZBSBem,1.0/3);
|
1130 |
Bpred->Add(LcorrJZBSBem,-1.0/3);
|
1131 |
Bpred->Add(RcorrJZBSBeemm,1.0/3);
|
1132 |
Bpred->Add(LcorrJZBSbeemm,-1.0/3);
|
1133 |
} else {
|
1134 |
Bpred->Add(RcorrJZBem,1.0);
|
1135 |
Bpred->Add(LcorrJZBem,-1.0);
|
1136 |
}
|
1137 |
|
1138 |
can->cd();
|
1139 |
can->SetLogy(0);
|
1140 |
Bpred->SetLineColor(kRed);
|
1141 |
Bpred->SetStats(0);
|
1142 |
if(high>0) Bpred->GetXaxis()->SetRangeUser(0,high);
|
1143 |
TH1F *JZBratioforfitting=(TH1F*)RcorrJZBeemm->Clone("JZBratioforfitting");
|
1144 |
JZBratioforfitting->Divide(Bpred);
|
1145 |
TGraphAsymmErrors *JZBratio = histRatio(RcorrJZBeemm,Bpred,is_data,binning,false);
|
1146 |
|
1147 |
|
1148 |
JZBratio->SetTitle("");
|
1149 |
JZBratio->GetYaxis()->SetRangeUser(0.0,9.0);
|
1150 |
// if(is_data==1) JZBratio->GetXaxis()->SetRangeUser(0,jzbHigh );
|
1151 |
|
1152 |
TF1 *pol0 = new TF1("pol0","[0]",0,1000);
|
1153 |
TF1 *pol0d = new TF1("pol0","[0]",0,1000);
|
1154 |
// straightline_fit->SetParameter(0,1);
|
1155 |
JZBratioforfitting->Fit(pol0,"Q0R","",0,30);
|
1156 |
pol0d->SetParameter(0,pol0->GetParameter(0));
|
1157 |
|
1158 |
JZBratio->GetYaxis()->SetTitle("Observed/Predicted");
|
1159 |
JZBratio->GetXaxis()->SetTitle("JZB [GeV]");
|
1160 |
if ( high>0 ) JZBratio->GetXaxis()->SetRangeUser(0.0,high);
|
1161 |
JZBratio->GetYaxis()->SetNdivisions(519);
|
1162 |
JZBratio->GetYaxis()->SetRangeUser(0.0,4.0);
|
1163 |
JZBratio->GetYaxis()->CenterTitle();
|
1164 |
JZBratio->GetXaxis()->CenterTitle();
|
1165 |
JZBratio->SetMarkerSize(DataMarkerSize);
|
1166 |
JZBratio->Draw("AP");
|
1167 |
/////----------------------------
|
1168 |
TPaveText *writeresult = new TPaveText(0.15,0.78,0.49,0.91,"blNDC");
|
1169 |
writeresult->SetFillStyle(4000);
|
1170 |
writeresult->SetFillColor(kWhite);
|
1171 |
writeresult->SetTextFont(42);
|
1172 |
writeresult->SetTextSize(0.03);
|
1173 |
writeresult->SetTextAlign(12);
|
1174 |
ostringstream jzb_agreement_data_text;
|
1175 |
jzb_agreement_data_text<< setprecision(2) << "mean =" << pol0->GetParameter(0) << " #pm " << setprecision(1) << pol0->GetParError(0);
|
1176 |
if(is_data==1) fitresultconstdata=pol0->GetParameter(0);// data
|
1177 |
if(is_data==0) fitresultconstmc=pol0->GetParameter(0); // monte carlo, no signal
|
1178 |
/* if(is_data) writeresult->AddText("Data closure test");
|
1179 |
else writeresult->AddText("MC closure test");
|
1180 |
*/
|
1181 |
writeresult->AddText(jzb_agreement_data_text.str().c_str());
|
1182 |
// writeresult->Draw("same");
|
1183 |
// pol0d->Draw("same");
|
1184 |
TF1 *topline = new TF1("","1.5",0,1000);
|
1185 |
TF1 *bottomline = new TF1("","0.5",0,1000);
|
1186 |
topline->SetLineColor(kBlue);
|
1187 |
topline->SetLineStyle(2);
|
1188 |
bottomline->SetLineColor(kBlue);
|
1189 |
bottomline->SetLineStyle(2);
|
1190 |
// topline->Draw("same");
|
1191 |
// bottomline->Draw("same");
|
1192 |
TF1 *oneline = new TF1("","1.0",0,1000);
|
1193 |
oneline->SetLineColor(kBlue);
|
1194 |
oneline->SetLineStyle(1);
|
1195 |
oneline->Draw("same");
|
1196 |
TLegend *phony_leg = make_legend("ratio",0.6,0.55,false);//this line is just to have the default CMS Preliminary (...) on the canvas as well.
|
1197 |
if(is_data==1) DrawPrelim();
|
1198 |
else DrawMCPrelim();
|
1199 |
TLegend *leg = new TLegend(0.55,0.75,0.89,0.89);
|
1200 |
leg->SetTextFont(42);
|
1201 |
leg->SetTextSize(0.04);
|
1202 |
// if(is_data==1) leg->SetHeader("Ratio (data)");
|
1203 |
// else leg->SetHeader("Ratio (MC)");
|
1204 |
|
1205 |
TString MCtitle("MC ");
|
1206 |
if (is_data==1) MCtitle = "";
|
1207 |
|
1208 |
leg->SetFillStyle(4000);
|
1209 |
leg->SetFillColor(kWhite);
|
1210 |
leg->SetTextFont(42);
|
1211 |
// leg->AddEntry(topline,"+20\% sys envelope","l");
|
1212 |
leg->AddEntry(JZBratio,MCtitle+"obs / "+MCtitle+"pred","p");
|
1213 |
leg->AddEntry(oneline,"ratio = 1","l");
|
1214 |
// leg->AddEntry(pol0d,"fit in [0,30] GeV","l");
|
1215 |
// leg->AddEntry(bottomline,"#pm50% envelope","l");
|
1216 |
|
1217 |
|
1218 |
//leg->Draw("same"); // no longer drawing legend
|
1219 |
|
1220 |
if(is_data==1) CompleteSave(can, "jzb_ratio_data");
|
1221 |
if(is_data==0) CompleteSave(can, "jzb_ratio_mc");
|
1222 |
if(is_data==2) CompleteSave(can, "jzb_ratio_mc_BandS");//special case, MC with signal!
|
1223 |
|
1224 |
delete RcorrJZBeemm;
|
1225 |
delete LcorrJZBeemm;
|
1226 |
delete RcorrJZBem;
|
1227 |
delete LcorrJZBem;
|
1228 |
|
1229 |
delete RcorrJZBSBem;
|
1230 |
delete LcorrJZBSBem;
|
1231 |
delete RcorrJZBSBeemm;
|
1232 |
delete LcorrJZBSbeemm;
|
1233 |
}
|
1234 |
|
1235 |
void do_ratio_plots(string mcjzb,string datajzb,vector<float> ratio_binning) {
|
1236 |
TCanvas *globalc = new TCanvas("globalc","Ratio Plot Canvas");
|
1237 |
globalc->SetLogy(0);
|
1238 |
|
1239 |
do_ratio_plot(mc,ratio_binning,mcjzb,globalc, jzbHigh );
|
1240 |
do_ratio_plot(data,ratio_binning,datajzb,globalc, jzbHigh );
|
1241 |
do_ratio_plot(mcwithsignal,ratio_binning,mcjzb,globalc, jzbHigh );
|
1242 |
}
|
1243 |
|
1244 |
string give_jzb_expression(float peak, int type) {
|
1245 |
stringstream val;
|
1246 |
if(type==data) {
|
1247 |
if(peak<0) val << jzbvariabledata << "+" << TMath::Abs(peak);
|
1248 |
if(peak>0) val << jzbvariabledata << "-" << TMath::Abs(peak);
|
1249 |
if(peak==0) val << jzbvariabledata;
|
1250 |
}
|
1251 |
if(type==mc) {
|
1252 |
if(peak<0) val << jzbvariablemc << "+" << TMath::Abs(peak);
|
1253 |
if(peak>0) val << jzbvariablemc << "-" << TMath::Abs(peak);
|
1254 |
if(peak==0) val << jzbvariablemc;
|
1255 |
}
|
1256 |
return val.str();
|
1257 |
}
|
1258 |
|
1259 |
|
1260 |
void lepton_comparison_plots() {
|
1261 |
Float_t ymin = 1.e-5, ymax = 0.25;
|
1262 |
TCanvas *can = new TCanvas("can","Lepton Comparison Canvas");
|
1263 |
can->SetLogy(1);
|
1264 |
TH1F *eemc = allsamples.Draw("eemc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("/DY"));
|
1265 |
TH1F *mmmc = allsamples.Draw("mmmc","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("/DY"));
|
1266 |
eemc->SetLineColor(kBlue);
|
1267 |
mmmc->SetLineColor(kRed);
|
1268 |
eemc->SetMinimum(0.1);
|
1269 |
eemc->SetMaximum(10*eemc->GetMaximum());
|
1270 |
eemc->Draw("histo");
|
1271 |
mmmc->Draw("histo,same");
|
1272 |
TLegend *leg = make_legend();
|
1273 |
leg->AddEntry(eemc,"ZJets->ee (MC)","l");
|
1274 |
leg->AddEntry(mmmc,"ZJets->#mu#mu (MC)","l");
|
1275 |
leg->Draw("same");
|
1276 |
CompleteSave(can, "lepton_comparison/mll_effratio_mc");
|
1277 |
|
1278 |
TH1F *eed = allsamples.Draw("eed","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",data, luminosity);
|
1279 |
TH1F *mmd = allsamples.Draw("mmd","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",data, luminosity);
|
1280 |
eed->SetLineColor(kBlue);
|
1281 |
mmd->SetLineColor(kRed);
|
1282 |
eed->SetMinimum(0.1);
|
1283 |
eed->SetMaximum(10*eed->GetMaximum());
|
1284 |
eed->Draw("histo");
|
1285 |
mmd->Draw("histo,same");
|
1286 |
TLegend *leg2 = make_legend();
|
1287 |
leg2->AddEntry(eed,"ZJets->ee (data)","l");
|
1288 |
leg2->AddEntry(mmd,"ZJets->#mu#mu (data)","l");
|
1289 |
leg2->Draw();
|
1290 |
CompleteSave(can, "lepton_comparison/mll_effratio_data");
|
1291 |
|
1292 |
TH1F *jeed = allsamples.Draw("jeed",jzbvariabledata, int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutOSSF&&cutnJets&&"(id1==0)",data, luminosity);
|
1293 |
TH1F *jmmd = allsamples.Draw("jmmd",jzbvariabledata, int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutOSSF&&cutnJets&&"(id1==1)",data, luminosity);
|
1294 |
TH1F *jeemmd = allsamples.Draw("jeemmd",jzbvariabledata,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutOSSF&&cutnJets,data, luminosity);
|
1295 |
dout << "ee : " << jeed->GetMean() << "+/-" << jeed->GetMeanError() << endl;
|
1296 |
dout << "ee : " << jmmd->GetMean() << "+/-" << jmmd->GetMeanError() << endl;
|
1297 |
dout << "eemd : " << jeemmd->GetMean() << "+/-" << jeemmd->GetMeanError() << endl;
|
1298 |
jeemmd->SetLineColor(kBlack);
|
1299 |
jeemmd->SetMarkerStyle(25);
|
1300 |
jeed->SetLineColor(kBlue);
|
1301 |
jmmd->SetLineColor(kRed);
|
1302 |
jeed->SetMinimum(0.1);
|
1303 |
jeed->SetMaximum(10*eed->GetMaximum());
|
1304 |
TH1* njeemmd = jeemmd->DrawNormalized();
|
1305 |
njeemmd->SetMinimum(ymin);
|
1306 |
njeemmd->SetMaximum(ymax);
|
1307 |
|
1308 |
jeed->DrawNormalized("histo,same");
|
1309 |
jmmd->DrawNormalized("histo,same");
|
1310 |
jeemmd->DrawNormalized("same");
|
1311 |
TLegend *jleg2 = make_legend(" ");
|
1312 |
jleg2->AddEntry(jeemmd,"ee and #mu#mu","p");
|
1313 |
jleg2->AddEntry(jeed,"ee","l");
|
1314 |
jleg2->AddEntry(jmmd,"#mu#mu","l");
|
1315 |
jleg2->Draw();
|
1316 |
CompleteSave(can,"lepton_comparison/jzb_effratio_data");
|
1317 |
|
1318 |
TPad *eemmpad = new TPad("eemmpad","eemmpad",0,0,1,1);
|
1319 |
eemmpad->cd();
|
1320 |
eemmpad->SetLogy(1);
|
1321 |
jeed->Draw("histo");
|
1322 |
jmmd->Draw("histo,same");
|
1323 |
TLegend *eemmlegend = make_legend(" ");
|
1324 |
eemmlegend->AddEntry(jeed,"ee","l");
|
1325 |
eemmlegend->AddEntry(jmmd,"#mu#mu","l");
|
1326 |
eemmlegend->Draw();
|
1327 |
DrawPrelim();
|
1328 |
save_with_ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
|
1329 |
|
1330 |
TH1F *zjeed = allsamples.Draw("zjeed",jzbvariablemc, int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==0)",mc, luminosity,allsamples.FindSample("/DY"));
|
1331 |
TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc, int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc, luminosity,allsamples.FindSample("/DY"));
|
1332 |
TH1F *zjeemmd = allsamples.Draw("zjeemmd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets, mc, luminosity,allsamples.FindSample("/DY"));
|
1333 |
dout << "Z+Jets ee : " << zjeed->GetMean() << "+/-" << zjeed->GetMeanError() << endl;
|
1334 |
dout << "Z+Jets ee : " << zjmmd->GetMean() << "+/-" << zjmmd->GetMeanError() << endl;
|
1335 |
dout << "Z+Jets eemd : " << zjeemmd->GetMean() << "+/-" << zjeemmd->GetMeanError() << endl;
|
1336 |
zjeemmd->SetLineColor(kBlack);
|
1337 |
zjeemmd->SetMarkerStyle(25);
|
1338 |
zjeed->SetLineColor(kBlue);
|
1339 |
zjmmd->SetLineColor(kRed);
|
1340 |
zjeed->SetMinimum(0.1);
|
1341 |
zjeed->SetMaximum(10*eed->GetMaximum());
|
1342 |
|
1343 |
TH1* nzjeemmd = zjeemmd->DrawNormalized();
|
1344 |
nzjeemmd->SetMinimum(ymin);
|
1345 |
nzjeemmd->SetMaximum(ymax);
|
1346 |
zjeed->DrawNormalized("histo,same");
|
1347 |
zjmmd->DrawNormalized("histo,same");
|
1348 |
zjeemmd->DrawNormalized("same");
|
1349 |
TLegend *zjleg2 = make_legend("Z+jets MC");
|
1350 |
zjleg2->AddEntry(jeemmd,"ee and #mu#mu","p");
|
1351 |
zjleg2->AddEntry(jeed,"ee","l");
|
1352 |
zjleg2->AddEntry(jmmd,"#mu#mu","l");
|
1353 |
zjleg2->Draw();
|
1354 |
CompleteSave(can,"lepton_comparison/jzb_effratio_ZJets");
|
1355 |
|
1356 |
TH1F *ld = allsamples.Draw("ld","mll",50,50,150, "mll [GeV]", "events", cutOSSF&&cutnJets,data, luminosity);
|
1357 |
ld->DrawNormalized("e1");
|
1358 |
eed->DrawNormalized("histo,same");
|
1359 |
mmd->DrawNormalized("histo,same");
|
1360 |
TLegend *leg3 = make_legend();
|
1361 |
leg3->AddEntry(ld,"ZJets->ll (data)","p");
|
1362 |
leg3->AddEntry(eed,"ZJets->ee (data)","l");
|
1363 |
leg3->AddEntry(mmd,"ZJets->#mu#mu (data)","l");
|
1364 |
leg3->Draw();
|
1365 |
CompleteSave(can,"lepton_comparison/mll_effratio_data__all_compared");
|
1366 |
/*
|
1367 |
TH1F *jzbld = allsamples.Draw("jzbld",jzbvariable,75,-150,150, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
|
1368 |
TH1F *jzbemd = allsamples.Draw("jzbemd",jzbvariable,75,-150,150, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
|
1369 |
*/
|
1370 |
TH1F *jzbld = allsamples.Draw("jzbld",jzbvariabledata,int((jzbHigh+110)/5),-110,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
|
1371 |
TH1F *jzbemd = allsamples.Draw("jzbemd",jzbvariabledata,int((jzbHigh+110)/5),-110,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
|
1372 |
jzbld->SetMarkerColor(kBlack);
|
1373 |
jzbld->SetMarkerStyle(26);
|
1374 |
jzbemd->SetMarkerStyle(25);
|
1375 |
jzbemd->SetMarkerColor(kRed);
|
1376 |
jzbemd->SetLineColor(kRed);
|
1377 |
jzbld->SetMinimum(0.35);
|
1378 |
jzbld->Draw("e1");
|
1379 |
jzbemd->Draw("e1,same");
|
1380 |
TLegend *leg4 = make_legend();
|
1381 |
leg4->AddEntry(jzbld,"SFZP","p");
|
1382 |
leg4->AddEntry(jzbemd,"OFZP","p");
|
1383 |
leg4->AddEntry((TObject*)0,"",""); //causes segmentation violation
|
1384 |
leg4->AddEntry((TObject*)0,"",""); //causes segmentation violation
|
1385 |
leg4->Draw();
|
1386 |
CompleteSave(can,"lepton_comparison/jzb_eemumu_emu_data");
|
1387 |
|
1388 |
TH1F *ttbarjzbld = allsamples.Draw("ttbarjzbld",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity,allsamples.FindSample("TTJet"));
|
1389 |
TH1F *ttbarjzbemd = allsamples.Draw("ttbarjzbemd",jzbvariablemc,int((jzbHigh+150)/5),-150,jzbHigh, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity,allsamples.FindSample("TTJet"));
|
1390 |
ttbarjzbld->SetLineColor(allsamples.GetColor("TTJet"));
|
1391 |
ttbarjzbemd->SetLineColor(allsamples.GetColor("TTJet"));
|
1392 |
ttbarjzbld->Draw("histo");
|
1393 |
ttbarjzbemd->SetLineStyle(2);
|
1394 |
ttbarjzbemd->Draw("histo,same");
|
1395 |
TLegend *leg5 = make_legend();
|
1396 |
leg5->AddEntry(ttbarjzbld,"t#bar{t}->(ee or #mu#mu)","l");
|
1397 |
leg5->AddEntry(ttbarjzbemd,"t#bar{t}->e#mu","l");
|
1398 |
leg5->Draw();
|
1399 |
CompleteSave(can,"lepton_comparison/ttbar_emu_mc");
|
1400 |
|
1401 |
}
|
1402 |
|
1403 |
bool is_OF(TCut cut) {
|
1404 |
string scut = (const char*) cut;
|
1405 |
if((int)scut.find("id1!=id2")>-1) return true;
|
1406 |
if((int)scut.find("id1==id2")>-1) return false;
|
1407 |
return false;
|
1408 |
}
|
1409 |
|
1410 |
bool is_ZP(TCut cut) {
|
1411 |
string scut = (const char*) cut;
|
1412 |
if((int)scut.find("91")>-1) return true;
|
1413 |
return false;
|
1414 |
}
|
1415 |
|
1416 |
|
1417 |
void draw_pure_jzb_histo(TCut cut,string datavariable, string mcvariable, string savename, TCanvas *can,vector<float> binning) {
|
1418 |
TPad *jzbpad = new TPad("jzbpad","jzbpad",0,0,1,1);
|
1419 |
jzbpad->cd();
|
1420 |
jzbpad->SetLogy(1);
|
1421 |
string xlabel="JZB [GeV]";
|
1422 |
|
1423 |
TH1F *datahisto = allsamples.Draw("datahisto",datavariable,binning, xlabel, "events",cut,data,luminosity);
|
1424 |
THStack mcstack = allsamples.DrawStack("mcstack",mcvariable,binning, xlabel, "events",cut,mc,luminosity);
|
1425 |
|
1426 |
datahisto->SetMinimum(0.1);
|
1427 |
datahisto->SetMarkerSize(DataMarkerSize);
|
1428 |
datahisto->Draw("e1");
|
1429 |
mcstack.Draw("same");
|
1430 |
datahisto->Draw("same,e1");
|
1431 |
|
1432 |
TLegend *leg;
|
1433 |
if(is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("OFZP",datahisto);
|
1434 |
else if(!is_OF(cut) && is_ZP(cut)) leg = allsamples.allbglegend("SFZP",datahisto);
|
1435 |
else if( is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("OFSB",datahisto);
|
1436 |
else if(!is_OF(cut) && !is_ZP(cut)) leg = allsamples.allbglegend("SFSB",datahisto);
|
1437 |
else {
|
1438 |
std::cerr << "Unable to decode cut: " << cut.GetTitle() << std::endl;
|
1439 |
exit(-1);
|
1440 |
}
|
1441 |
leg->Draw();
|
1442 |
string write_cut = decipher_cut(cut,"");
|
1443 |
TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
|
1444 |
writeline1->SetTextSize(0.035);
|
1445 |
writeline1->Draw();
|
1446 |
save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
|
1447 |
TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
|
1448 |
jzbpad2->cd();
|
1449 |
jzbpad2->SetLogy(1);
|
1450 |
datahisto->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
|
1451 |
datahisto->SetMinimum(0.1);
|
1452 |
datahisto->SetMarkerSize(DataMarkerSize);
|
1453 |
datahisto->Draw("e1");
|
1454 |
mcstack.Draw("same");
|
1455 |
datahisto->Draw("same,e1");
|
1456 |
leg->SetHeader("");
|
1457 |
leg->Draw();
|
1458 |
writeline1->SetTextSize(0.035);
|
1459 |
writeline1->Draw();
|
1460 |
DrawPrelim();
|
1461 |
save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
|
1462 |
datahisto->Delete();
|
1463 |
mcstack.Delete();
|
1464 |
}
|
1465 |
|
1466 |
Double_t GausR(Double_t *x, Double_t *par) {
|
1467 |
return gRandom->Gaus(x[0],par[0]);
|
1468 |
}
|
1469 |
|
1470 |
void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
|
1471 |
TCanvas *can = new TCanvas("can","JZB Plots Canvas");
|
1472 |
float max=jzbHigh ;
|
1473 |
float min=-120;
|
1474 |
int nbins=(int)((max-min)/5.0); // we want 5 GeV/bin
|
1475 |
int coarserbins=int(nbins/2.0);
|
1476 |
int rebinnedbins=int(nbins/4.0);
|
1477 |
|
1478 |
vector<float>binning;vector<float>coarse_binning;vector<float>coarsest_binning;
|
1479 |
for(int i=0;i<=nbins;i++)binning.push_back(min+i*(max-min)/((float)nbins));
|
1480 |
for(int i=0;i<=coarserbins;i++)coarse_binning.push_back(min+i*(max-min)/((float)coarserbins));
|
1481 |
for(int i=0;i<=rebinnedbins;i++)coarsest_binning.push_back(min+i*(max-min)/((float)rebinnedbins));
|
1482 |
|
1483 |
draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP",can,binning);
|
1484 |
draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP",can,binning);
|
1485 |
draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_SFZP",can,binning);
|
1486 |
draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_SFZP",can,binning);
|
1487 |
draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==0",datajzb,mcjzb,"ee/jzb_OS_OFZP",can,binning);
|
1488 |
draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass&&"id1==1",datajzb,mcjzb,"mm/jzb_OS_OFZP",can,binning);
|
1489 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
|
1490 |
if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB",can,binning);
|
1491 |
if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB",can,binning);
|
1492 |
|
1493 |
draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarse",can,coarse_binning);
|
1494 |
draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarse",can,coarse_binning);
|
1495 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
|
1496 |
if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarse",can,coarse_binning);
|
1497 |
if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
|
1498 |
|
1499 |
// draw_pure_jzb_histo(cutOSSF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_SFZP_coarsest",can,coarsest_binning);
|
1500 |
// draw_pure_jzb_histo(cutOSOF&&cutnJets&&cutmass,datajzb,mcjzb,"jzb_OS_OFZP_coarsest",can,coarsest_binning);
|
1501 |
// flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
|
1502 |
// if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSSF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_SFSB_coarsest",can,coarsest_binning);
|
1503 |
// if(PlottingSetup::RestrictToMassPeak) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarsest",can,coarsest_binning);
|
1504 |
}
|
1505 |
|
1506 |
|
1507 |
void calculate_all_yields(string mcdrawcommand,vector<float> jzb_cuts) {
|
1508 |
dout << "Calculating background yields in MC:" << endl;
|
1509 |
jzb_cuts.push_back(14000);
|
1510 |
TH1F *allbgs = allsamples.Draw("allbgs",jzbvariablemc,jzb_cuts, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc,luminosity);
|
1511 |
float cumulative=0;
|
1512 |
for(int i=allbgs->GetNbinsX();i>=1;i--) {
|
1513 |
cumulative+=allbgs->GetBinContent(i);
|
1514 |
dout << "Above " << allbgs->GetBinLowEdge(i) << " GeV/c : " << cumulative << endl;
|
1515 |
}
|
1516 |
}
|
1517 |
|
1518 |
|
1519 |
TCut give_jzb_expression(string mcjzb, float jzbcut, string posneg="pos") {
|
1520 |
stringstream res;
|
1521 |
res << "(" << mcjzb;
|
1522 |
if(posneg=="pos") res << ">";
|
1523 |
else res << "<-";
|
1524 |
res << jzbcut << ")";
|
1525 |
return TCut(res.str().c_str());
|
1526 |
}
|
1527 |
|
1528 |
string sigdig(float number, int nsigdig=3, float min=0) {
|
1529 |
//this function tries to extract n significant digits, and if the number is below (min), it returns "<min"
|
1530 |
if(number<min) return "< "+any2string(min);
|
1531 |
stringstream sol;
|
1532 |
sol << setprecision(nsigdig) << number;
|
1533 |
|
1534 |
return sol.str();
|
1535 |
}
|
1536 |
|
1537 |
string jzb_tex_command(string region, string posneg) {
|
1538 |
if(posneg=="pos") posneg="POS";
|
1539 |
else posneg="NEG";
|
1540 |
stringstream texcommand;
|
1541 |
texcommand<<"\\"<<region <<"JZB"<<posneg;
|
1542 |
return texcommand.str();
|
1543 |
}
|
1544 |
// \SFZPJZBPOS
|
1545 |
// Sample & \OFZPJZBPOS & \OFZPJZBNEG & \SFZPJZBPOS & \SFZPJZBNEG & \OFSBJZBPOS & \OFSBJZBNEG & \SFSBJZBPOS & \SFSBJZBNEG \\\hline
|
1546 |
|
1547 |
void compute_MC_yields(string mcjzb,vector<float> jzb_cuts) {
|
1548 |
dout << "Calculating background yields in MC:" << endl;
|
1549 |
|
1550 |
TCanvas *yica = new TCanvas("yica","yield canvas");
|
1551 |
|
1552 |
int nRegions=4;
|
1553 |
if(!PlottingSetup::RestrictToMassPeak) nRegions=2;
|
1554 |
string tsRegions[] = {"SFZP","OFZP","SFSB","OFSB"};
|
1555 |
string posneg[] = {"pos","neg"};
|
1556 |
TCut tkRegions[] = {cutOSSF&&cutnJets&&cutmass,cutOSOF&&cutnJets&&cutmass,cutOSSF&&cutnJets&&sidebandcut,cutOSOF&&cutnJets&&sidebandcut};
|
1557 |
|
1558 |
for(int ijzb=0;ijzb<jzb_cuts.size();ijzb++) {
|
1559 |
TCut jzbMC[] = { give_jzb_expression(mcjzb,jzb_cuts[ijzb],"pos"), give_jzb_expression(mcjzb,jzb_cuts[ijzb],"neg") };
|
1560 |
dout << "_________________________________________________________" << endl;
|
1561 |
dout << "Table for JZB> " << jzb_cuts[ijzb] << endl;
|
1562 |
for(int isample=0;isample<(allsamples.collection).size();isample++) {
|
1563 |
if(!(allsamples.collection)[isample].is_data) dout << (allsamples.collection)[isample].samplename << " & ";
|
1564 |
else dout << "Sample & ";
|
1565 |
for(int iregion=0;iregion<nRegions;iregion++) {
|
1566 |
for(int ipos=0;ipos<2;ipos++) {
|
1567 |
if((allsamples.collection)[isample].is_data) dout << jzb_tex_command(tsRegions[iregion],posneg[ipos]) << " & ";
|
1568 |
else {
|
1569 |
vector<int> specific;specific.push_back(isample);
|
1570 |
TH1F *shisto = allsamples.Draw("shisto","mll",1,0,500,"tester","events",tkRegions[iregion]&&jzbMC[ipos],mc,luminosity,specific);
|
1571 |
dout << sigdig(shisto->Integral(),3,0.05) <<" & ";
|
1572 |
delete shisto;
|
1573 |
}
|
1574 |
}//end of ipos
|
1575 |
}//end of iregion
|
1576 |
dout << " \\\\" << endl;
|
1577 |
}//end of isample
|
1578 |
}//end of ijzb
|
1579 |
dout << " \\hline" << endl;
|
1580 |
|
1581 |
delete yica;
|
1582 |
}
|
1583 |
|
1584 |
void draw_ttbar_and_zjets_shape_for_one_configuration(string mcjzb, string datajzb, int leptontype=-1, int scenario=0,bool floating=false) {
|
1585 |
//Step 1: Establishing cuts
|
1586 |
stringstream jetcutstring;
|
1587 |
string writescenario="";
|
1588 |
|
1589 |
if(scenario==0) jetcutstring << "(pfJetGoodNum>=3)&&"<<(const char*) basicqualitycut;
|
1590 |
if(scenario==1) jetcutstring << "(pfJetPt[0]>50&&pfJetPt[1]>50)&&"<<(const char*)basicqualitycut;
|
1591 |
TCut jetcut(jetcutstring.str().c_str());
|
1592 |
string leptoncut="mll>0";
|
1593 |
if(leptontype==0||leptontype==1) {
|
1594 |
if(leptontype==0) {
|
1595 |
leptoncut="id1==0";
|
1596 |
writescenario="__ee";
|
1597 |
}
|
1598 |
else {
|
1599 |
leptoncut="id1==1";
|
1600 |
writescenario="__ee";
|
1601 |
}
|
1602 |
}
|
1603 |
TCut lepcut(leptoncut.c_str());
|
1604 |
|
1605 |
TCanvas *c5 = new TCanvas("c5","c5",1500,500);
|
1606 |
TCanvas *c6 = new TCanvas("c6","c6");
|
1607 |
c5->Divide(3,1);
|
1608 |
|
1609 |
//STEP 2: Extract Zjets shape in data
|
1610 |
c5->cd(1);
|
1611 |
c5->cd(1)->SetLogy(1);
|
1612 |
TCut massat40("mll>40");
|
1613 |
TH1F *ossfleft = allsamples.Draw("ossfleft", "-"+datajzb,40,0,200, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,data,luminosity);
|
1614 |
TH1F *osofleft = allsamples.Draw("osofleft", "-"+datajzb,40,0,200, "JZB [GeV]", "events", massat40&&cutOSOF&&jetcut&&lepcut,data,luminosity);
|
1615 |
ossfleft->SetLineColor(kRed);
|
1616 |
ossfleft->SetMarkerColor(kRed);
|
1617 |
ossfleft->Add(osofleft,-1);
|
1618 |
vector<TF1*> functions = do_cb_fit_to_plot(ossfleft,10);
|
1619 |
ossfleft->SetMarkerSize(DataMarkerSize);
|
1620 |
ossfleft->Draw();
|
1621 |
functions[0]->Draw("same");functions[1]->Draw("same");functions[2]->Draw("same");
|
1622 |
TF1 *zjetsfunc = (TF1*) functions[1]->Clone();
|
1623 |
TF1 *zjetsfuncN = (TF1*) functions[0]->Clone();
|
1624 |
TF1 *zjetsfuncP = (TF1*) functions[2]->Clone();
|
1625 |
zjetsfunc->Draw("same");zjetsfuncN->Draw("same");zjetsfuncP->Draw("same");
|
1626 |
TLegend *leg1 = new TLegend(0.6,0.6,0.89,0.80);
|
1627 |
leg1->SetFillColor(kWhite);
|
1628 |
leg1->SetLineColor(kWhite);
|
1629 |
leg1->AddEntry(ossfleft,"OSSF (sub),JZB<peak","p");
|
1630 |
leg1->AddEntry(zjetsfunc,"OSSF fit ('zjets')","l");
|
1631 |
leg1->Draw("same");
|
1632 |
TText *titleleft = write_title("Extracting Z+Jets shape");
|
1633 |
titleleft->Draw();
|
1634 |
|
1635 |
//Step 3: Extract ttbar shape (in data or MC?)
|
1636 |
c5->cd(2);
|
1637 |
c5->cd(2)->SetLogy(1);
|
1638 |
TH1F *osof;
|
1639 |
TText *titlecenter;
|
1640 |
bool frommc=false;
|
1641 |
if(frommc) {
|
1642 |
osof = allsamples.Draw("osof",datajzb,40,-200,200, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,mc,luminosity,allsamples.FindSample("TTJets"));
|
1643 |
titlecenter = write_title("Extracting ttbar shape (from ossf MC)");
|
1644 |
}
|
1645 |
else {
|
1646 |
osof = allsamples.Draw("osof",datajzb,40,-200,200, "JZB [GeV]", "events", massat40&&cutOSOF&&jetcut&&lepcut,data,luminosity);
|
1647 |
titlecenter = write_title("Extracting ttbar shape (from osof data)");
|
1648 |
}
|
1649 |
osof->SetMarkerSize(DataMarkerSize);
|
1650 |
osof->Draw();
|
1651 |
vector<TF1*> ttbarfunctions = do_cb_fit_to_plot(osof,35,true);
|
1652 |
ttbarfunctions[0]->SetLineColor(kRed); ttbarfunctions[0]->SetLineStyle(2); ttbarfunctions[0]->Draw("same");
|
1653 |
ttbarfunctions[1]->SetLineColor(kRed); ttbarfunctions[1]->Draw("same");
|
1654 |
ttbarfunctions[2]->SetLineColor(kRed); ttbarfunctions[2]->SetLineStyle(2); ttbarfunctions[2]->Draw("same");
|
1655 |
|
1656 |
TLegend *leg2 = new TLegend(0.15,0.8,0.4,0.89);
|
1657 |
leg2->SetFillColor(kWhite);
|
1658 |
leg2->SetLineColor(kWhite);
|
1659 |
if(frommc) {
|
1660 |
leg2->AddEntry(osof,"t#bar{t} OSSF, MC","p");
|
1661 |
leg2->AddEntry(ttbarfunctions[1],"Fit to t#bar{t} OSSF,MC","l");
|
1662 |
} else {
|
1663 |
leg2->AddEntry(osof,"OSOF","p");
|
1664 |
leg2->AddEntry(ttbarfunctions[1],"Fit to OSOF","l");
|
1665 |
}
|
1666 |
leg2->Draw("same");
|
1667 |
titlecenter->Draw();
|
1668 |
|
1669 |
//--------------------------------------------------------------------------------------------------------------------------------
|
1670 |
//STEP 4: Present it!
|
1671 |
// actually: if we wanna let it float we need to do that first :-)
|
1672 |
c5->cd(3);
|
1673 |
c5->cd(3)->SetLogy(1);
|
1674 |
TH1F *observed = allsamples.Draw("observed",datajzb,100,0,500, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,data,luminosity);
|
1675 |
observed->SetMarkerSize(DataMarkerSize);
|
1676 |
|
1677 |
TF1 *logparc = new TF1("logparc",InvCrystalBall,0,1000,5); logparc->SetLineColor(kRed);
|
1678 |
TF1 *logparcn = new TF1("logparcn",InvCrystalBallN,0,1000,5); logparcn->SetLineColor(kRed); logparcn->SetLineStyle(2);
|
1679 |
TF1 *logparcp = new TF1("logparcp",InvCrystalBallP,0,1000,5); logparcp->SetLineColor(kRed); logparcp->SetLineStyle(2);
|
1680 |
|
1681 |
TF1 *zjetsc = new TF1("zjetsc",InvCrystalBall,0,1000,5); zjetsc->SetLineColor(kBlue);
|
1682 |
TF1 *zjetscn = new TF1("zjetscn",InvCrystalBallN,0,1000,5); zjetscn->SetLineColor(kBlue); zjetscn->SetLineStyle(2);
|
1683 |
TF1 *zjetscp = new TF1("zjetscp",InvCrystalBallP,0,1000,5); zjetscp->SetLineColor(kBlue); zjetscp->SetLineStyle(2);
|
1684 |
|
1685 |
TF1 *ZplusJetsplusTTbar = new TF1("ZplusJetsplusTTbar", DoubleInvCrystalBall,0,1000,10); ZplusJetsplusTTbar->SetLineColor(kBlue);
|
1686 |
TF1 *ZplusJetsplusTTbarP= new TF1("ZplusJetsplusTTbarP",DoubleInvCrystalBallP,0,1000,10); ZplusJetsplusTTbarP->SetLineColor(kBlue); ZplusJetsplusTTbarP->SetLineStyle(2);
|
1687 |
TF1 *ZplusJetsplusTTbarN= new TF1("ZplusJetsplusTTbarN",DoubleInvCrystalBallN,0,1000,10); ZplusJetsplusTTbarN->SetLineColor(kBlue); ZplusJetsplusTTbarN->SetLineStyle(2);
|
1688 |
|
1689 |
zjetsc->SetParameters(zjetsfunc->GetParameters());
|
1690 |
zjetscp->SetParameters(zjetsfunc->GetParameters());
|
1691 |
zjetscn->SetParameters(zjetsfunc->GetParameters());
|
1692 |
|
1693 |
TH1F *observeda = allsamples.Draw("observeda",datajzb,53,80,jzbHigh, "JZB [GeV]", "events", massat40&&cutOSSF&&jetcut&&lepcut,data,luminosity);
|
1694 |
//blublu
|
1695 |
logparc->SetParameters(ttbarfunctions[1]->GetParameters());
|
1696 |
logparcn->SetParameters(ttbarfunctions[1]->GetParameters());
|
1697 |
logparcp->SetParameters(ttbarfunctions[1]->GetParameters());
|
1698 |
if(floating) {
|
1699 |
dout << "TTbar contribution assumed (before fitting) : " << logparc->GetParameter(0) << endl;
|
1700 |
logparc->SetParameters(ttbarfunctions[1]->GetParameters());
|
1701 |
for(int i=0;i<10;i++) {
|
1702 |
if(i<5) ZplusJetsplusTTbar->FixParameter(i,zjetsfunc->GetParameter(i));
|
1703 |
if(i>=5) {
|
1704 |
if (i>5) ZplusJetsplusTTbar->FixParameter(i,logparc->GetParameter(i-5));
|
1705 |
if (i==5) ZplusJetsplusTTbar->SetParameter(i,logparc->GetParameter(i-5));
|
1706 |
}
|
1707 |
}//end of setting parameters
|
1708 |
observeda->Draw("same");
|
1709 |
ZplusJetsplusTTbar->Draw("same");
|
1710 |
observeda->Fit(ZplusJetsplusTTbar);
|
1711 |
dout << "--> Quality of Z+Jets / TTbar fit : chi2/ndf = " << ZplusJetsplusTTbar->GetChisquare() << "/" << ZplusJetsplusTTbar->GetNDF() << endl;
|
1712 |
ZplusJetsplusTTbar->Draw("same");
|
1713 |
ZplusJetsplusTTbarP->SetParameters(ZplusJetsplusTTbar->GetParameters());
|
1714 |
ZplusJetsplusTTbarN->SetParameters(ZplusJetsplusTTbar->GetParameters());
|
1715 |
dout << "TTbar contribution found (after fitting) : " << ZplusJetsplusTTbar->GetParameter(5) << endl;
|
1716 |
float factor = ZplusJetsplusTTbar->GetParameter(5) / logparc->GetParameter(0);
|
1717 |
dout << "FACTOR: " << factor << endl;
|
1718 |
logparc->SetParameter(0,factor*ttbarfunctions[1]->GetParameter(0));
|
1719 |
logparcn->SetParameter(0,factor*ttbarfunctions[1]->GetParameter(0));
|
1720 |
logparcp->SetParameter(0,factor*ttbarfunctions[1]->GetParameter(0));
|
1721 |
}
|
1722 |
|
1723 |
c5->cd(3);
|
1724 |
c5->cd(3)->SetLogy(1);
|
1725 |
observed->Draw();
|
1726 |
zjetsc->Draw("same");zjetscn->Draw("same");zjetscp->Draw("same");
|
1727 |
logparc->Draw("same");
|
1728 |
logparcn->Draw("same");
|
1729 |
logparcp->Draw("same");
|
1730 |
|
1731 |
TLegend *leg3 = new TLegend(0.6,0.6,0.89,0.80);
|
1732 |
leg3->SetFillColor(kWhite);
|
1733 |
leg3->SetLineColor(kWhite);
|
1734 |
leg3->AddEntry(observed,"OSSF,JZB>peak","p");
|
1735 |
leg3->AddEntry(ttbarfunctions[1],"OSOF fit ('ttbar')","l");
|
1736 |
leg3->AddEntry(zjetsfunc,"OSSF,JZB<0 fit ('zjets')","l");
|
1737 |
leg3->Draw("same");
|
1738 |
TText *titleright = write_title("Summary of shapes and observed shape");
|
1739 |
titleright->Draw();
|
1740 |
|
1741 |
c6->cd()->SetLogy(1);
|
1742 |
observed->Draw();
|
1743 |
zjetsc->Draw("same");zjetscn->Draw("same");zjetscp->Draw("same");
|
1744 |
logparc->Draw("same");
|
1745 |
logparcn->Draw("same");
|
1746 |
logparcp->Draw("same");
|
1747 |
leg3->Draw("same");
|
1748 |
titleright->Draw();
|
1749 |
|
1750 |
if(scenario==0) {
|
1751 |
CompleteSave(c5,"Shapes2/Making_of___3jetsabove30"+writescenario);
|
1752 |
CompleteSave(c5->cd(1),"Shapes2/Making_of___3jetsabove30"+writescenario+"__cd1");
|
1753 |
CompleteSave(c5->cd(2),"Shapes2/Making_of___3jetsabove30"+writescenario+"__cd2");
|
1754 |
CompleteSave(c5->cd(3),"Shapes2/Making_of___3jetsabove30"+writescenario+"__cd3");
|
1755 |
CompleteSave(c6,"Shapes2/Background_Shapes___3jetsabove30"+writescenario);
|
1756 |
} else {
|
1757 |
CompleteSave(c5,"Shapes2/Making_of___2jetsabove50"+writescenario);
|
1758 |
CompleteSave(c5->cd(1),"Shapes2/Making_of___2jetsabove50"+writescenario+"__cd1");
|
1759 |
CompleteSave(c5->cd(2),"Shapes2/Making_of___2jetsabove50"+writescenario+"__cd2");
|
1760 |
CompleteSave(c5->cd(3),"Shapes2/Making_of___2jetsabove50"+writescenario+"__cd3");
|
1761 |
CompleteSave(c6,"Shapes2/Background_Shapes___2jetsabove50"+writescenario);
|
1762 |
}
|
1763 |
dout << "Statistics about our fits: " << endl;
|
1764 |
dout << "Z+Jets shape: Chi2/ndf = " << zjetsfunc->GetChisquare() << "/" << ossfleft->GetNbinsX() << endl;
|
1765 |
dout << "ttbar shape: Chi2/ndf = " << ttbarfunctions[1]->GetChisquare() << "/" << osof->GetNbinsX() << endl;
|
1766 |
|
1767 |
c6->cd();
|
1768 |
TLegend *additionallegend = new TLegend(0.6,0.6,0.89,0.89);
|
1769 |
additionallegend->SetFillColor(kWhite);
|
1770 |
additionallegend->SetLineColor(kWhite);
|
1771 |
additionallegend->AddEntry(observed,"Data","p");
|
1772 |
additionallegend->AddEntry(ZplusJetsplusTTbar,"Fitted Z+jets & TTbar","l");
|
1773 |
additionallegend->AddEntry(zjetsc,"Z+jets","l");
|
1774 |
additionallegend->AddEntry(logparc,"TTbar","l");
|
1775 |
observed->Draw();
|
1776 |
ZplusJetsplusTTbar->SetLineColor(kGreen);
|
1777 |
ZplusJetsplusTTbarP->SetLineColor(kGreen);
|
1778 |
ZplusJetsplusTTbarN->SetLineColor(kGreen);
|
1779 |
ZplusJetsplusTTbarP->SetLineStyle(2);
|
1780 |
ZplusJetsplusTTbarN->SetLineStyle(2);
|
1781 |
TF1 *ZplusJetsplusTTbar2 = new TF1("ZplusJetsplusTTbar2",DoubleInvCrystalBall,0,1000,10);
|
1782 |
ZplusJetsplusTTbar2->SetParameters(ZplusJetsplusTTbar->GetParameters());
|
1783 |
ZplusJetsplusTTbar2->SetLineColor(kGreen);
|
1784 |
ZplusJetsplusTTbarP->SetFillColor(TColor::GetColor("#81F781"));
|
1785 |
ZplusJetsplusTTbarN->SetFillColor(kWhite);
|
1786 |
ZplusJetsplusTTbarP->Draw("fcsame");
|
1787 |
ZplusJetsplusTTbarN->Draw("fcsame");
|
1788 |
TH1F *hZplusJetsplusTTbar = (TH1F*)ZplusJetsplusTTbar2->GetHistogram();
|
1789 |
TH1F *hZplusJetsplusTTbarN = (TH1F*)ZplusJetsplusTTbarN->GetHistogram();
|
1790 |
TH1F *hZplusJetsplusTTbarP = (TH1F*)ZplusJetsplusTTbarP->GetHistogram();
|
1791 |
hZplusJetsplusTTbar->SetMarkerSize(0);
|
1792 |
hZplusJetsplusTTbarP->SetMarkerSize(0);
|
1793 |
hZplusJetsplusTTbarN->SetMarkerSize(0);
|
1794 |
for (int i=1;i<=hZplusJetsplusTTbar->GetNbinsX();i++) {
|
1795 |
float newerror=hZplusJetsplusTTbarP->GetBinContent(i)-hZplusJetsplusTTbar->GetBinContent(i);
|
1796 |
hZplusJetsplusTTbar->SetBinError(i,newerror);
|
1797 |
if(hZplusJetsplusTTbar->GetBinContent(i)<0.05) hZplusJetsplusTTbar->SetBinContent(i,0); //avoiding a displaying probolem
|
1798 |
}
|
1799 |
hZplusJetsplusTTbarP->SetFillColor(kGreen);
|
1800 |
hZplusJetsplusTTbarN->SetFillColor(kWhite);
|
1801 |
hZplusJetsplusTTbarN->Draw("same");
|
1802 |
|
1803 |
ZplusJetsplusTTbar2->SetMarkerSize(0);
|
1804 |
ZplusJetsplusTTbar2->Draw("same");
|
1805 |
|
1806 |
zjetsc->Draw("same");zjetscn->Draw("same");zjetscp->Draw("same");
|
1807 |
logparc->Draw("same");
|
1808 |
logparcn->Draw("same");
|
1809 |
logparcp->Draw("same");
|
1810 |
additionallegend->Draw("same");
|
1811 |
if(scenario==0) {
|
1812 |
CompleteSave(c6,"Shapes2/Background_Shapes___3jetsabove30__allfits__"+writescenario);
|
1813 |
} else {
|
1814 |
CompleteSave(c6,"Shapes2/Background_Shapes___2jetsabove50__allfits__"+writescenario);
|
1815 |
}
|
1816 |
//--------------------------------------------------------------------------------------------------------------------------------
|
1817 |
}
|
1818 |
|
1819 |
void draw_ttbar_and_zjets_shape(string mcjzb, string datajzb) {
|
1820 |
int all_leptons=-1;
|
1821 |
int electrons_only=0;
|
1822 |
int mu_only=1;
|
1823 |
int twojetswith50gev=1;
|
1824 |
int threejetswith30gev=0;
|
1825 |
/*
|
1826 |
draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,twojetswith50gev);
|
1827 |
draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev);
|
1828 |
|
1829 |
draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,electrons_only,twojetswith50gev);
|
1830 |
draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,electrons_only,threejetswith30gev);
|
1831 |
|
1832 |
draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,mu_only,twojetswith50gev);
|
1833 |
draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,mu_only,threejetswith30gev);
|
1834 |
*/
|
1835 |
|
1836 |
draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
|
1837 |
}
|
1838 |
|
1839 |
void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
|
1840 |
//first: colorful plots
|
1841 |
TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
|
1842 |
cancorr->SetLogz();
|
1843 |
cancorr->SetRightMargin(0.13);
|
1844 |
flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak
|
1845 |
TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
|
1846 |
TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
|
1847 |
(allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
|
1848 |
niceresponseplotd->SetStats(0);
|
1849 |
niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
|
1850 |
niceresponseplotd->GetYaxis()->SetTitle("Response");
|
1851 |
niceresponseplotd->GetXaxis()->CenterTitle();
|
1852 |
niceresponseplotd->GetYaxis()->CenterTitle();
|
1853 |
niceresponseplotd->Draw("COLZ");
|
1854 |
TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
|
1855 |
profd->SetMarkerSize(DataMarkerSize);
|
1856 |
profd->Fit("pol0","","same,e1",30,400);
|
1857 |
DrawPrelim();
|
1858 |
TText* title = write_text(0.5,0.7,"Data");
|
1859 |
title->SetTextAlign(12);
|
1860 |
title->Draw();
|
1861 |
TF1 *datapol=(TF1*)profd->GetFunction("pol0");
|
1862 |
float datacorrection=datapol->GetParameter(0);
|
1863 |
stringstream dataresstring;
|
1864 |
dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
|
1865 |
TText* restitle = write_text(0.5,0.65,dataresstring.str());
|
1866 |
restitle->SetTextAlign(12);
|
1867 |
restitle->SetTextSize(0.03);
|
1868 |
restitle->Draw();
|
1869 |
CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
|
1870 |
|
1871 |
TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
|
1872 |
(allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
|
1873 |
niceresponseplotm->SetStats(0);
|
1874 |
niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
|
1875 |
niceresponseplotm->GetYaxis()->SetTitle("Response");
|
1876 |
niceresponseplotm->GetXaxis()->CenterTitle();
|
1877 |
niceresponseplotm->GetYaxis()->CenterTitle();
|
1878 |
niceresponseplotm->Draw("COLZ");
|
1879 |
(allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
|
1880 |
TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
|
1881 |
profm->SetMarkerSize(DataMarkerSize);
|
1882 |
profm->Fit("pol0","","same,e1",30,400);
|
1883 |
DrawMCPrelim();
|
1884 |
title = write_text(0.5,0.7,"MC simulation");
|
1885 |
title->SetTextAlign(12);
|
1886 |
title->Draw();
|
1887 |
TF1 *mcpol=(TF1*)profm->GetFunction("pol0");
|
1888 |
float mccorrection=mcpol->GetParameter(0);
|
1889 |
stringstream mcresstring;
|
1890 |
mcresstring<<"Response: "<<std::setprecision(2)<<100*mccorrection<<" %";
|
1891 |
TText* mcrestitle = write_text(0.5,0.65,mcresstring.str());
|
1892 |
mcrestitle->SetTextAlign(12);
|
1893 |
mcrestitle->SetTextSize(0.03);
|
1894 |
mcrestitle->Draw();
|
1895 |
CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_MC");
|
1896 |
|
1897 |
|
1898 |
//Step 2: Getting the result
|
1899 |
// TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
|
1900 |
stringstream jzbvardatas;
|
1901 |
if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
|
1902 |
if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
|
1903 |
jzbvardata=jzbvardatas.str();
|
1904 |
stringstream jzbvarmcs;
|
1905 |
if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
|
1906 |
if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
|
1907 |
jzbvarmc=jzbvarmcs.str();
|
1908 |
dout << "JZB Z pt correction summary : " << endl;
|
1909 |
dout << " Data: The response is " << datacorrection << " --> jzb variable is now : " << jzbvardata << endl;
|
1910 |
dout << " MC : The response is " << mccorrection << " --> jzb variable is now : " << jzbvarmc << endl;
|
1911 |
}
|
1912 |
|
1913 |
void pick_up_events(string cut) {
|
1914 |
dout << "Picking up events with cut " << cut << endl;
|
1915 |
allsamples.PickUpEvents(cut);
|
1916 |
}
|
1917 |
|
1918 |
void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError) {
|
1919 |
dout << "Saving configuration template!" << endl;
|
1920 |
ofstream configfile;
|
1921 |
configfile.open("../DistributedModelCalculations/last_configuration.C");
|
1922 |
configfile<<"#include <iostream>\n";
|
1923 |
configfile<<"#include <vector>\n";
|
1924 |
configfile<<"#ifndef SampleClassLoaded\n";
|
1925 |
configfile<<"#include \"SampleClass.C\"\n";
|
1926 |
configfile<<"#endif\n";
|
1927 |
configfile<<"#define SetupLoaded\n";
|
1928 |
configfile<<"#ifndef ResultLibraryClassLoaded\n";
|
1929 |
configfile<<"#include \"ResultLibraryClass.C\"\n";
|
1930 |
configfile<<"#endif\n";
|
1931 |
|
1932 |
configfile<<"\nusing namespace std;\n\n";
|
1933 |
|
1934 |
configfile<<"namespace PlottingSetup { \n";
|
1935 |
configfile<<"string datajzb=\"datajzb_ERROR\";\n";
|
1936 |
configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
|
1937 |
configfile<<"vector<float>jzb_cuts;\n";
|
1938 |
configfile<<"float MCPeakError=-999;\n";
|
1939 |
configfile<<"}\n\n";
|
1940 |
|
1941 |
configfile<<"void read_config() {\n";
|
1942 |
configfile<<"datajzb=\""<<datajzb<<"\";\n";
|
1943 |
configfile<<"mcjzb=\""<<mcjzb<<"\";\n\n";
|
1944 |
configfile<<"\n\nMCPeakError="<<MCPeakError<<";\n\n";
|
1945 |
for(int i=0;i<jzb_cuts.size();i++) configfile<<"jzb_cuts.push_back("<<jzb_cuts[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
|
1946 |
configfile<<"\n\n";
|
1947 |
for(int i=0;i<Nobs.size();i++) configfile<<"Nobs.push_back("<<Nobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
|
1948 |
for(int i=0;i<Npred.size();i++) configfile<<"Npred.push_back("<<Npred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
|
1949 |
for(int i=0;i<Nprederr.size();i++) configfile<<"Nprederr.push_back("<<Nprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
|
1950 |
configfile<<"\n\n";
|
1951 |
for(int i=0;i<flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
|
1952 |
for(int i=0;i<flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
|
1953 |
for(int i=0;i<flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
|
1954 |
configfile<<"\n\n";
|
1955 |
configfile<<"luminosity="<<luminosity<<";\n";
|
1956 |
|
1957 |
configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
|
1958 |
|
1959 |
configfile.close();
|
1960 |
|
1961 |
}
|
1962 |
|
1963 |
float get_nonzero_minimum(TH1F *histo) {
|
1964 |
float min=histo->GetMaximum();
|
1965 |
for(int ibin=1;ibin<=histo->GetNbinsX();ibin++) {
|
1966 |
float curcont=histo->GetBinContent(ibin);
|
1967 |
if(curcont<min&&curcont>0) min=curcont;
|
1968 |
}
|
1969 |
return min;
|
1970 |
}
|
1971 |
|
1972 |
void draw_all_ttbar_histos(TCanvas *can, vector<TH1F*> histos, string drawoption="", float manualmin=-9) {
|
1973 |
can->cd();
|
1974 |
float min=1;
|
1975 |
float max=histos[0]->GetMaximum();
|
1976 |
if(manualmin>=0) min=manualmin;
|
1977 |
else {
|
1978 |
for(int i=1;i<histos.size();i++) {
|
1979 |
float curmin=get_nonzero_minimum(histos[i]);
|
1980 |
float curmax=histos[i]->GetMaximum();
|
1981 |
if(curmin<min) min=curmin;
|
1982 |
if(curmax>max) max=curmax;
|
1983 |
}
|
1984 |
}
|
1985 |
histos[0]->GetYaxis()->SetRangeUser(min,4*max);
|
1986 |
histos[0]->Draw(drawoption.c_str());
|
1987 |
stringstream drawopt;
|
1988 |
drawopt << drawoption << ",same";
|
1989 |
for(int i=1;i<histos.size();i++) {
|
1990 |
histos[i]->Draw(drawopt.str().c_str());
|
1991 |
}
|
1992 |
}
|
1993 |
|
1994 |
void ttbar_sidebands_comparison(string mcjzb, vector<float> binning, string prestring) {
|
1995 |
//in the case of the on peak analysis, we compare the 3 control regions to the real value
|
1996 |
//in the case of the OFF peak analysis, we compare our control region to the real value
|
1997 |
TCut weightbackup=cutWeight;
|
1998 |
cutWeight="1.0";
|
1999 |
float simulatedlumi = luminosity; //in pb please - adjust to your likings
|
2000 |
|
2001 |
|
2002 |
TH1F *TZem = systsamples.Draw("TZem",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
|
2003 |
TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
|
2004 |
TH1F *TSem;
|
2005 |
TH1F *nTSem;
|
2006 |
TH1F *TZeemm = systsamples.Draw("TZeemm",mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
|
2007 |
TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
|
2008 |
TH1F *TSeemm;
|
2009 |
TH1F *nTSeemm;
|
2010 |
|
2011 |
if(PlottingSetup::RestrictToMassPeak) {
|
2012 |
TSem = systsamples.Draw("TSem",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
|
2013 |
nTSem = systsamples.Draw("nTSem","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
|
2014 |
TSeemm = systsamples.Draw("TSeemm",mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
|
2015 |
nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTJets"));
|
2016 |
}
|
2017 |
|
2018 |
TCanvas *tcan = new TCanvas("tcan","tcan");
|
2019 |
|
2020 |
tcan->SetLogy(1);
|
2021 |
|
2022 |
TZeemm->SetLineColor(kBlack);
|
2023 |
TZem->SetLineColor(kRed);
|
2024 |
TZeemm->SetMarkerColor(kBlack);
|
2025 |
TZem->SetMarkerColor(kRed);
|
2026 |
|
2027 |
|
2028 |
if(PlottingSetup::RestrictToMassPeak) {
|
2029 |
TSem->SetLineColor(TColor::GetColor("#00A616"));
|
2030 |
TSeemm->SetLineColor(kMagenta+2);
|
2031 |
TSem->SetMarkerColor(TColor::GetColor("#00A616"));
|
2032 |
TSeemm->SetMarkerColor(kMagenta+2);
|
2033 |
TSem->SetLineStyle(2);
|
2034 |
TSeemm->SetLineStyle(3);
|
2035 |
}
|
2036 |
|
2037 |
vector<TH1F*> histos;
|
2038 |
histos.push_back(TZem);
|
2039 |
histos.push_back(TZeemm);
|
2040 |
if(PlottingSetup::RestrictToMassPeak) {
|
2041 |
histos.push_back(TSem);
|
2042 |
histos.push_back(TSeemm);
|
2043 |
}
|
2044 |
draw_all_ttbar_histos(tcan,histos,"histo",0.04);
|
2045 |
|
2046 |
TLegend *leg = make_legend("MC t#bar{t}",0.6,0.65,false);
|
2047 |
leg->AddEntry(TZeemm,"SFZP","l");
|
2048 |
leg->AddEntry(TZem,"OFZP","l");
|
2049 |
if(PlottingSetup::RestrictToMassPeak) {
|
2050 |
leg->AddEntry(TSeemm,"SFSB","l");
|
2051 |
leg->AddEntry(TSem,"OFSB","l");
|
2052 |
}
|
2053 |
leg->Draw("same");
|
2054 |
DrawMCPrelim(simulatedlumi);
|
2055 |
CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
|
2056 |
|
2057 |
TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
|
2058 |
TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
|
2059 |
TH1F *TSeemmcopy = (TH1F*)TSeemm->Clone("TSeemmcopy");
|
2060 |
TH1F *TSemcopy = (TH1F*)TSem->Clone("TSemcopy");
|
2061 |
|
2062 |
TZem->Divide(TZeemm);
|
2063 |
TZem->SetMarkerStyle(21);
|
2064 |
if(PlottingSetup::RestrictToMassPeak) {
|
2065 |
TSem->Divide(TZeemm);
|
2066 |
TSeemm->Divide(TZeemm);
|
2067 |
TSem->SetMarkerStyle(24);
|
2068 |
TSeemm->SetMarkerStyle(32);
|
2069 |
}
|
2070 |
|
2071 |
tcan->SetLogy(0);
|
2072 |
TZem->GetYaxis()->SetRangeUser(0,2.5);
|
2073 |
TZem->GetYaxis()->SetTitle("ratio");
|
2074 |
TZem->Draw();
|
2075 |
if(PlottingSetup::RestrictToMassPeak) {
|
2076 |
TSem->Draw("same");
|
2077 |
TSeemm->Draw("same");
|
2078 |
}
|
2079 |
|
2080 |
float linepos=0.25;
|
2081 |
if(PlottingSetup::RestrictToMassPeak) linepos=0.25;
|
2082 |
TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
|
2083 |
TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
|
2084 |
TLine *bottom = new TLine(binning[0],1.0-linepos,binning[binning.size()-1],1.0-linepos);
|
2085 |
|
2086 |
top->SetLineColor(kBlue);top->SetLineStyle(2);
|
2087 |
bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
|
2088 |
center->SetLineColor(kBlue);
|
2089 |
|
2090 |
top->Draw("same");
|
2091 |
center->Draw("same");
|
2092 |
bottom->Draw("same");
|
2093 |
|
2094 |
TLegend *leg2 = make_legend("MC t#bar{t}",0.55,0.75,false);
|
2095 |
leg2->AddEntry(TZem,"OFZP / SFZP","ple");
|
2096 |
if(PlottingSetup::RestrictToMassPeak) {
|
2097 |
leg2->AddEntry(TSeemm,"SFSB / SFZP","ple");
|
2098 |
leg2->AddEntry(TSem,"OFSB / SFZP","ple");
|
2099 |
}
|
2100 |
leg2->AddEntry(bottom,"syst. envelope","l");
|
2101 |
leg2->SetX1(0.25);leg2->SetX2(0.6);
|
2102 |
leg2->SetY1(0.65);
|
2103 |
|
2104 |
leg2->Draw("same");
|
2105 |
|
2106 |
DrawMCPrelim(simulatedlumi);
|
2107 |
CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
|
2108 |
|
2109 |
|
2110 |
|
2111 |
///-------------- second part: only look at the quantity we actually care about!
|
2112 |
TH1F *leftsfzp = (TH1F*)nTZeemm->Clone("leftsfzp");
|
2113 |
TH1F *rightsfzp = (TH1F*)TZeemmcopy->Clone("rightsfzp");
|
2114 |
rightsfzp->Add(leftsfzp,-1);
|
2115 |
TH1F *leftofzp = (TH1F*)nTZem->Clone("leftofzp");
|
2116 |
TH1F *rightofzp = (TH1F*)TZemcopy->Clone("rightofzp");
|
2117 |
rightofzp->Add(leftofzp,-1);
|
2118 |
TH1F *leftofsb;
|
2119 |
TH1F *rightofsb;
|
2120 |
TH1F *leftsfsb;
|
2121 |
TH1F *rightsfsb;
|
2122 |
if(PlottingSetup::RestrictToMassPeak) {
|
2123 |
leftofsb = (TH1F*)nTSem->Clone("leftofsb");
|
2124 |
rightofsb = (TH1F*)TSemcopy->Clone("rightofsb");
|
2125 |
rightofsb->Add(leftofsb,-1);
|
2126 |
leftsfsb = (TH1F*)nTSeemm->Clone("leftsfsb");
|
2127 |
rightsfsb = (TH1F*)TSeemmcopy->Clone("rightsfsb");
|
2128 |
rightsfsb->Add(leftsfsb,-1);
|
2129 |
}
|
2130 |
|
2131 |
tcan->SetLogy(1);
|
2132 |
rightsfzp->GetXaxis()->SetRangeUser(0,binning[binning.size()-1]);
|
2133 |
rightsfzp->GetYaxis()->SetTitle("#deltaJZB / 25 GeV");
|
2134 |
rightsfzp->Draw("histo");
|
2135 |
rightofzp->Draw("histo,same");
|
2136 |
if(PlottingSetup::RestrictToMassPeak) {
|
2137 |
rightofsb->Draw("histo,same");
|
2138 |
rightsfsb->Draw("histo,same");
|
2139 |
}
|
2140 |
DrawMCPrelim(simulatedlumi);
|
2141 |
|
2142 |
TLegend *legA = make_legend("MC t#bar{t}",0.6,0.65,false);
|
2143 |
legA->AddEntry(rightsfzp,"SFZP","l");
|
2144 |
legA->AddEntry(rightofzp,"OFZP","l");
|
2145 |
if(PlottingSetup::RestrictToMassPeak) {
|
2146 |
legA->AddEntry(rightofsb,"SFSB","l");
|
2147 |
legA->AddEntry(rightsfsb,"OFSB","l");
|
2148 |
}
|
2149 |
legA->Draw();
|
2150 |
|
2151 |
CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison");
|
2152 |
|
2153 |
tcan->SetLogy(0);
|
2154 |
rightofzp->Divide(rightsfzp);
|
2155 |
rightofzp->GetXaxis()->SetRangeUser(0.0,binning[binning.size()-1]);
|
2156 |
rightofzp->GetYaxis()->SetRangeUser(0.0,2.0);
|
2157 |
rightofzp->GetYaxis()->SetTitle("#deltaJZB ratio");
|
2158 |
rightofzp->Draw();
|
2159 |
if(PlottingSetup::RestrictToMassPeak) {
|
2160 |
rightofsb->Divide(rightsfzp);
|
2161 |
rightsfsb->Divide(rightsfzp);
|
2162 |
rightofsb->Draw("same");
|
2163 |
rightsfsb->Draw("same");
|
2164 |
}
|
2165 |
|
2166 |
TLine *top2 = new TLine(0.0,1.0+linepos,binning[binning.size()-1],1.0+linepos);
|
2167 |
TLine *center2 = new TLine(0.0,1.0,binning[binning.size()-1],1.0);
|
2168 |
TLine *bottom2 = new TLine(0.0,1.0-linepos,binning[binning.size()-1],1.0-linepos);
|
2169 |
|
2170 |
top2->SetLineColor(kBlue);top2->SetLineStyle(2);
|
2171 |
bottom2->SetLineColor(kBlue);bottom2->SetLineStyle(2);
|
2172 |
center2->SetLineColor(kBlue);
|
2173 |
|
2174 |
top2->Draw("same");
|
2175 |
center2->Draw("same");
|
2176 |
bottom2->Draw("same");
|
2177 |
|
2178 |
rightofzp->SetMarkerStyle(21);
|
2179 |
if(PlottingSetup::RestrictToMassPeak) {
|
2180 |
rightofsb->SetMarkerStyle(24);
|
2181 |
rightsfsb->SetMarkerStyle(32);
|
2182 |
}
|
2183 |
|
2184 |
TLegend *leg3 = make_legend("MC t#bar{t}",0.55,0.75,false);
|
2185 |
leg3->AddEntry(rightofzp,"OFZP / SFZP","ple");
|
2186 |
if(PlottingSetup::RestrictToMassPeak) {
|
2187 |
leg3->AddEntry(rightsfsb,"SFSB / SFZP","ple");
|
2188 |
leg3->AddEntry(rightofsb,"OFSB / SFZP","ple");
|
2189 |
}
|
2190 |
leg3->AddEntry(bottom,"syst. envelope","l");
|
2191 |
leg3->SetX1(0.25);leg3->SetX2(0.6);
|
2192 |
leg3->SetY1(0.65);
|
2193 |
|
2194 |
leg3->Draw("same");
|
2195 |
|
2196 |
DrawMCPrelim(simulatedlumi);
|
2197 |
CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_deltajzb_comparison_ratio");
|
2198 |
|
2199 |
delete TZem;
|
2200 |
delete nTZem;
|
2201 |
delete TZeemm;
|
2202 |
delete nTZeemm;
|
2203 |
if(PlottingSetup::RestrictToMassPeak) {
|
2204 |
delete TSem;
|
2205 |
delete nTSem;
|
2206 |
delete TSeemm;
|
2207 |
delete nTSeemm;
|
2208 |
}
|
2209 |
|
2210 |
delete tcan;
|
2211 |
cutWeight=weightbackup;
|
2212 |
}
|
2213 |
|
2214 |
void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
|
2215 |
vector<float> nicer_binning;
|
2216 |
nicer_binning.push_back(-125);
|
2217 |
nicer_binning.push_back(-100);
|
2218 |
nicer_binning.push_back(-75);
|
2219 |
nicer_binning.push_back(-50);
|
2220 |
nicer_binning.push_back(-25);
|
2221 |
nicer_binning.push_back(0);
|
2222 |
nicer_binning.push_back(25);
|
2223 |
nicer_binning.push_back(50);
|
2224 |
nicer_binning.push_back(75);
|
2225 |
nicer_binning.push_back(100);
|
2226 |
nicer_binning.push_back(125);
|
2227 |
nicer_binning.push_back(150);
|
2228 |
nicer_binning.push_back(175);
|
2229 |
nicer_binning.push_back(200);
|
2230 |
nicer_binning.push_back(230);
|
2231 |
nicer_binning.push_back(280);
|
2232 |
nicer_binning.push_back(400);
|
2233 |
ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
|
2234 |
}
|
2235 |
|
2236 |
|
2237 |
void zjets_prediction_comparison() {
|
2238 |
// Do it without PU re-weighting
|
2239 |
float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
|
2240 |
stringstream resultsNoPU;
|
2241 |
|
2242 |
stringstream mcjzbnoPU;
|
2243 |
find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,false);
|
2244 |
if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
|
2245 |
else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
|
2246 |
|
2247 |
string mcjzb = mcjzbnoPU.str();
|
2248 |
dout << "The peak corrected JZB expression for MC without pileup is : " << mcjzb << endl;
|
2249 |
|
2250 |
TCut weightbackup=cutWeight;
|
2251 |
cutWeight="1.0";
|
2252 |
float sbg_min=0.;
|
2253 |
float sbg_max=100.;
|
2254 |
int sbg_nbins=5;
|
2255 |
float simulatedlumi = luminosity;//in pb please - adjust to your likings
|
2256 |
|
2257 |
TCut kPos((mcjzb+">0").c_str());
|
2258 |
TCut kNeg((mcjzb+"<0").c_str());
|
2259 |
string var( "abs("+mcjzb+")" );
|
2260 |
|
2261 |
TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
|
2262 |
TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
|
2263 |
kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
|
2264 |
TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
|
2265 |
kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
|
2266 |
hJZBpos->SetLineColor(kBlack);
|
2267 |
hJZBneg->SetLineColor(kRed);
|
2268 |
|
2269 |
Int_t nbins = 5;
|
2270 |
Float_t xmax = 100.;
|
2271 |
|
2272 |
|
2273 |
TCanvas *zcan = new TCanvas("zcan","zcan");
|
2274 |
zcan->SetLogy(1);
|
2275 |
|
2276 |
hJZBpos->Draw("e1");
|
2277 |
hJZBneg->Draw("same,hist");
|
2278 |
hJZBpos->Draw("same,e1"); // So it's on top...
|
2279 |
|
2280 |
TLegend *leg = make_legend("MC Z+jets",0.55,0.75,false);
|
2281 |
leg->AddEntry(hJZBpos,"Observed","pe");
|
2282 |
leg->AddEntry(hJZBneg,"Predicted","l");
|
2283 |
leg->Draw("same");
|
2284 |
DrawMCPrelim(simulatedlumi);
|
2285 |
CompleteSave(zcan,"Systematics/zjets_prediction");
|
2286 |
|
2287 |
TH1F* hratio = (TH1F*)hJZBpos->Clone("hratio");
|
2288 |
hratio->Divide(hJZBneg);
|
2289 |
|
2290 |
zcan->SetLogy(0);
|
2291 |
hratio->GetYaxis()->SetRangeUser(0,2.5);
|
2292 |
hratio->GetYaxis()->SetTitle("Observed/Predicted");
|
2293 |
hratio->Draw("e1");
|
2294 |
|
2295 |
TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
|
2296 |
TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
|
2297 |
TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
|
2298 |
|
2299 |
|
2300 |
top->SetLineColor(kBlue);top->SetLineStyle(2);
|
2301 |
bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
|
2302 |
center->SetLineColor(kBlue);
|
2303 |
|
2304 |
top->Draw("same");
|
2305 |
center->Draw("same");
|
2306 |
bottom->Draw("same");
|
2307 |
|
2308 |
TLegend *leg2 = make_legend("MC Z+jets",0.25,0.75,false);
|
2309 |
leg2->AddEntry(hratio,"obs / pred","pe");
|
2310 |
leg2->AddEntry(bottom,"syst. envelope","l");
|
2311 |
leg2->Draw("same");
|
2312 |
DrawMCPrelim(simulatedlumi);
|
2313 |
CompleteSave(zcan,"Systematics/zjets_prediction_ratio");
|
2314 |
|
2315 |
delete zcan;
|
2316 |
cutWeight=weightbackup;
|
2317 |
|
2318 |
}
|
2319 |
|
2320 |
|
2321 |
|
2322 |
void sideband_assessment(string datajzb, float min=30.0, float max=50.0) {
|
2323 |
tout << endl << endl;
|
2324 |
stringstream bordercut;
|
2325 |
bordercut << "(TMath::Abs(" << datajzb << ")<" << max << ")&&(TMath::Abs(" << datajzb << ")>" << min << ")";
|
2326 |
tout << bordercut.str().c_str() << endl;
|
2327 |
TH1F *ofsb = allsamples.Draw("ofsb",datajzb,100, 0,100, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets&&bordercut.str().c_str(),data, luminosity);
|
2328 |
TH1F *ofzp = allsamples.Draw("ofzp",datajzb,100, 0,100, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&bordercut.str().c_str(),data, luminosity);
|
2329 |
float OFSB = ofsb->Integral();
|
2330 |
float OFZP = ofzp->Integral();
|
2331 |
|
2332 |
tout << "\\begin{table}[hbtp]" << endl;
|
2333 |
tout << "\\renewcommand{\\arraystretch}{1.3}" << endl;
|
2334 |
tout << "\\begin{center}" << endl;
|
2335 |
tout << "\\caption{Total number of events observed in the auxiliary region $|JZB|>"<<min<<"\\GeV \\cup |JZB|<"<<max<<"\\GeV$ for the {\\OFZP} and {\\OFSB}.}\\label{tab:auxcounts}" << endl;
|
2336 |
tout << "\\begin{tabular}{l|cc}" << endl;
|
2337 |
tout << "\\hline" << endl;
|
2338 |
tout << "& {\\OFZP} & {\\OFSB} \\\\\\hline" << endl;
|
2339 |
tout << "\\#(events) & "<<OFSB<<" & "<<OFZP<<"\\\\ \\hline" << endl;
|
2340 |
tout << "\\end{tabular}" << endl;
|
2341 |
tout << "\\end{center}" << endl;
|
2342 |
tout << "\\end{table}" << endl;
|
2343 |
|
2344 |
|
2345 |
}
|
2346 |
|
2347 |
void make_table(samplecollection &coll, string jzbexpr, bool is_data, vector<float> jzb_cuts, string subselection="none") {
|
2348 |
|
2349 |
vector<float> jzbcutprediction;
|
2350 |
vector<float> metcutprediction;
|
2351 |
|
2352 |
vector<float> jzbcutobservation;
|
2353 |
vector<float> metcutobservation;
|
2354 |
|
2355 |
TCanvas *cannie = new TCanvas("cannie","cannie");
|
2356 |
|
2357 |
for(int icut=0;icut<jzb_cuts.size();icut++) {
|
2358 |
float currcut=jzb_cuts[icut];
|
2359 |
int nbins=1;float low=currcut;
|
2360 |
vector<int> mysample;
|
2361 |
if(subselection!="none") mysample=coll.FindSample(subselection);
|
2362 |
TH1F *RcorrJZBeemm = coll.Draw("RcorrJZBeemm",jzbexpr,1,currcut,14000, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
|
2363 |
TH1F *LcorrJZBeemm = coll.Draw("LcorrJZBeemm",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
|
2364 |
TH1F *RcorrJZBem = coll.Draw("RcorrJZBem",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
|
2365 |
TH1F *LcorrJZBem = coll.Draw("LcorrJZBem",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
|
2366 |
|
2367 |
TH1F *RcorrJZBSBem;
|
2368 |
TH1F *LcorrJZBSBem;
|
2369 |
TH1F *RcorrJZBSBeemm;
|
2370 |
TH1F *LcorrJZBSBeemm;
|
2371 |
|
2372 |
if(PlottingSetup::RestrictToMassPeak) {
|
2373 |
RcorrJZBSBem = coll.Draw("RcorrJZBSBem",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
|
2374 |
LcorrJZBSBem = coll.Draw("LcorrJZBSBem",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
|
2375 |
RcorrJZBSBeemm = coll.Draw("RcorrJZBSBeemm",jzbexpr.c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
|
2376 |
LcorrJZBSBeemm = coll.Draw("LcorrJZBSBeemm",("-("+jzbexpr+")").c_str(),nbins,low,14000, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
|
2377 |
}
|
2378 |
|
2379 |
TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
|
2380 |
if(PlottingSetup::RestrictToMassPeak) {
|
2381 |
Bpred->Add(RcorrJZBem,1.0/3.);
|
2382 |
Bpred->Add(LcorrJZBem,-1.0/3.);
|
2383 |
Bpred->Add(RcorrJZBSBem,1.0/3.);
|
2384 |
Bpred->Add(LcorrJZBSBem,-1.0/3.);
|
2385 |
Bpred->Add(RcorrJZBSBeemm,1.0/3.);
|
2386 |
Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
|
2387 |
} else {
|
2388 |
Bpred->Add(RcorrJZBem,1.0);
|
2389 |
Bpred->Add(LcorrJZBem,-1.0);
|
2390 |
}
|
2391 |
|
2392 |
jzbcutobservation.push_back(RcorrJZBeemm->Integral());
|
2393 |
jzbcutprediction.push_back(Bpred->Integral());
|
2394 |
|
2395 |
delete RcorrJZBeemm;
|
2396 |
delete LcorrJZBeemm;
|
2397 |
delete RcorrJZBem;
|
2398 |
delete LcorrJZBem;
|
2399 |
delete RcorrJZBSBem;
|
2400 |
delete LcorrJZBSBem;
|
2401 |
delete RcorrJZBSBeemm;
|
2402 |
delete LcorrJZBSBeemm;
|
2403 |
|
2404 |
TH1F *MetObs = coll.Draw("MetObs",("met[4]"),nbins,low,14000, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity, mysample);
|
2405 |
TH1F *MetPred = coll.Draw("MetPred",("met[4]"),nbins,low,14000, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity, mysample);
|
2406 |
|
2407 |
metcutobservation.push_back(MetObs->Integral());
|
2408 |
metcutprediction.push_back(MetPred->Integral());
|
2409 |
delete MetObs;
|
2410 |
delete MetPred;
|
2411 |
}//end of cut loop
|
2412 |
|
2413 |
//prediction part
|
2414 |
if(is_data) cout << "Data prediction & ";
|
2415 |
if(subselection!="none") cout << subselection << " prediction &";
|
2416 |
for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutprediction[ij] << " vs " << metcutprediction[ij] << " & ";
|
2417 |
|
2418 |
cout << endl;
|
2419 |
//observation part
|
2420 |
if(is_data) cout << "Data observation & ";
|
2421 |
if(subselection!="none") cout << subselection << " observation &";
|
2422 |
for(int ij=0;ij<jzb_cuts.size();ij++) cout << jzbcutobservation[ij] << " vs " << metcutobservation[ij] << " & ";
|
2423 |
cout << endl;
|
2424 |
cout << "_________________________________________________________________" << endl;
|
2425 |
delete cannie;
|
2426 |
}
|
2427 |
|
2428 |
void met_jzb_cut(string datajzb, string mcjzb, vector<float> jzb_cut) {
|
2429 |
/*we want a table like this:
|
2430 |
__________________ 50 | 100 | ...
|
2431 |
| Data prediction | a vs b | a vs b | ...
|
2432 |
| Data observed | a vs b | a vs b | ...
|
2433 |
--------------------------------------
|
2434 |
--------------------------------------
|
2435 |
| LM4 prediction | a vs b | a vs b | ...
|
2436 |
| LM4 observed | a vs b | a vs b | ...
|
2437 |
| LM8 prediction | a vs b | a vs b | ...
|
2438 |
| LM8 observed | a vs b | a vs b | ...
|
2439 |
|
2440 |
where a is the result for a jzb cut at X, and b is the result for a met cut at X
|
2441 |
*/
|
2442 |
make_table(allsamples,datajzb, true,jzb_cut,"none");
|
2443 |
make_table(signalsamples,mcjzb, false,jzb_cut,"LM4");
|
2444 |
make_table(signalsamples,mcjzb, false,jzb_cut,"LM8");
|
2445 |
}
|
2446 |
|
2447 |
|
2448 |
//________________________________________________________________________________________
|
2449 |
// JZB Efficiency plot (efficiency of passing reco. JZB cut as function of generator JZB cut)
|
2450 |
void JZBSelEff(string mcjzb, TTree* events, string informalname, vector<float> jzb_bins) {
|
2451 |
|
2452 |
float min = 0, max = 400;
|
2453 |
float xbins[] = {min,10,20,30,40,50,60,70,80,90,100,110,120,140,150,160,170,180,190,200,210,220,250,300,max,max+100};
|
2454 |
int nbins = sizeof(xbins)/sizeof(float)-1;
|
2455 |
int markers[] = { 20, 26, 21, 24, 22, 25, 28 };
|
2456 |
|
2457 |
TH1F* heff = new TH1F("heff", "JZB eff ; generator-level JZB [GeV]; efficiency",nbins,xbins);
|
2458 |
TH1F* hgen = new TH1F("hgen", "JZB gen ; generator-level JZB [GeV]; efficiency",nbins,xbins);
|
2459 |
TH1F* hreco = new TH1F("hreco","JZB reco ; generator-level JZB [GeV]; efficiency",nbins,xbins);
|
2460 |
|
2461 |
TCut kgen(genMassCut&&"genZPt>0&&genNjets>2&&abs(genMID)==23"&&cutOSSF);
|
2462 |
TCut kreco(cutmass);
|
2463 |
|
2464 |
TF1* func = new TF1("func","0.5*[2]*(TMath::Erf((x-[1])/[0])+1)",min,max);
|
2465 |
func->SetParNames("epsilon","x_{1/2}","sigma");
|
2466 |
func->SetParameter(0,50.);
|
2467 |
func->SetParameter(1,0.);
|
2468 |
func->SetParameter(2,1.);
|
2469 |
gStyle->SetOptStat(0);
|
2470 |
gStyle->SetOptFit(0);
|
2471 |
|
2472 |
TCanvas *can = new TCanvas("can","Canvas for JZB Efficiency",600,600);
|
2473 |
can->SetGridx(1);
|
2474 |
can->SetGridy(1);
|
2475 |
TLegend *leg = make_legend("",0.6,0.2,false,0.89,0.5);
|
2476 |
|
2477 |
|
2478 |
|
2479 |
for ( int icut=0; icut<jzb_bins.size(); ++icut ) {
|
2480 |
|
2481 |
ostringstream selection;
|
2482 |
selection << mcjzb << ">" << jzb_bins[icut];
|
2483 |
TCut ksel(selection.str().c_str());
|
2484 |
events->Draw("genJZB>>hgen", kgen&&kreco, "goff");
|
2485 |
events->Draw("genJZB>>hreco",kgen&&kreco&&ksel,"goff");
|
2486 |
|
2487 |
// Loop over steps to get efficiency curve
|
2488 |
for ( Int_t iBin = 0; iBin<nbins-1; ++iBin ) {
|
2489 |
Float_t eff = hreco->GetBinContent(iBin+1)/hgen->GetBinContent(iBin+1);
|
2490 |
heff->SetBinContent(iBin+1,eff);
|
2491 |
heff->SetBinError(iBin+1,TMath::Sqrt(eff*(1-eff)/hgen->GetBinContent(iBin+1)));
|
2492 |
}
|
2493 |
|
2494 |
heff->GetXaxis()->SetRangeUser(min, max);
|
2495 |
heff->SetMarkerStyle(markers[icut]);
|
2496 |
heff->Fit("func","Q+","same");
|
2497 |
|
2498 |
// Print values
|
2499 |
dout << "+++ For " << selection.str() << std::endl;
|
2500 |
for ( int i=0; i<func->GetNpar(); ++i )
|
2501 |
dout << " " << func->GetParName(i) << " " << func->GetParameter(i) << " \\pm " << func->GetParError(i) << std::endl;
|
2502 |
char hname[256]; sprintf(hname,"heff%d",icut);
|
2503 |
|
2504 |
// Store plot
|
2505 |
TH1F* h = (TH1F*)heff->Clone(hname);
|
2506 |
if ( icut) h->Draw("same");
|
2507 |
else h->Draw();
|
2508 |
char htitle[256]; sprintf(htitle,"JZB > %3.0f GeV", jzb_bins[icut]);
|
2509 |
leg->AddEntry(h,htitle,"p");
|
2510 |
|
2511 |
}
|
2512 |
|
2513 |
leg->Draw();
|
2514 |
DrawMCPrelim(0.0);
|
2515 |
CompleteSave(can, "Systematics/jzb_efficiency_curve"+informalname );
|
2516 |
|
2517 |
delete hgen;
|
2518 |
delete hreco;
|
2519 |
delete heff;
|
2520 |
}
|
2521 |
|
2522 |
//________________________________________________________________________________________
|
2523 |
// Calls the above function for each signal sample
|
2524 |
void plot_jzb_sel_eff(string mcjzb, samplecollection &signalsamples, vector<float> bins )
|
2525 |
{
|
2526 |
for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
|
2527 |
dout << "JZB selection efficiency curve: " << std::endl;
|
2528 |
JZBSelEff(mcjzb,(signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,bins); // Only for some selected samples
|
2529 |
}
|
2530 |
}
|
2531 |
|
2532 |
void qcd_plots(string datajzb, string mcjzb, vector<float> bins) {
|
2533 |
// What this function aims to do:
|
2534 |
// Illustrate cut flow for QCD (requiring only one lepton, requiring etc.)
|
2535 |
// Illustrate how little QCD is left over! i.e. make some pointless JZB plot with only QCD to visualize the fact that there's not much really.
|
2536 |
TCanvas *can = new TCanvas("can","can");
|
2537 |
TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
|
2538 |
kinpad->cd();
|
2539 |
|
2540 |
string jzb=mcjzb;
|
2541 |
|
2542 |
float hi=400;
|
2543 |
bool use_signal=false;
|
2544 |
bool use_data=false;
|
2545 |
|
2546 |
bool is_data=false;
|
2547 |
int nbins=50;//100;
|
2548 |
float low=0;
|
2549 |
float high=500;
|
2550 |
int versok=false;
|
2551 |
if(gROOT->GetVersionInt()>=53000) versok=true;
|
2552 |
|
2553 |
TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
|
2554 |
TH1F *RcorrJZBeemm = qcdsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
2555 |
TH1F *LcorrJZBeemm = qcdsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
2556 |
TH1F *RcorrJZBem = qcdsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
2557 |
TH1F *LcorrJZBem = qcdsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
2558 |
blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
|
2559 |
blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
|
2560 |
blankback->GetXaxis()->CenterTitle();
|
2561 |
blankback->GetYaxis()->CenterTitle();
|
2562 |
|
2563 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
|
2564 |
TH1F *RcorrJZBSBem;
|
2565 |
TH1F *LcorrJZBSBem;
|
2566 |
TH1F *RcorrJZBSBeemm;
|
2567 |
TH1F *LcorrJZBSBeemm;
|
2568 |
|
2569 |
TH1F *RcorrJZBeemmNoS;
|
2570 |
|
2571 |
//these are for the ratio
|
2572 |
TH1F *JRcorrJZBeemm = qcdsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
2573 |
TH1F *JLcorrJZBeemm = qcdsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
2574 |
TH1F *JRcorrJZBem = qcdsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
2575 |
TH1F *JLcorrJZBem = qcdsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
2576 |
|
2577 |
TH1F *JRcorrJZBSBem;
|
2578 |
TH1F *JLcorrJZBSBem;
|
2579 |
TH1F *JRcorrJZBSBeemm;
|
2580 |
TH1F *JLcorrJZBSBeemm;
|
2581 |
|
2582 |
if(PlottingSetup::RestrictToMassPeak) {
|
2583 |
RcorrJZBSBem = qcdsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
2584 |
LcorrJZBSBem = qcdsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
2585 |
RcorrJZBSBeemm = qcdsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
2586 |
LcorrJZBSBeemm = qcdsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
2587 |
|
2588 |
//these are for the ratio
|
2589 |
JRcorrJZBSBem = qcdsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
2590 |
JLcorrJZBSBem = qcdsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
|
2591 |
JRcorrJZBSBeemm = qcdsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
2592 |
JLcorrJZBSBeemm = qcdsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
|
2593 |
|
2594 |
}
|
2595 |
|
2596 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
|
2597 |
|
2598 |
TH1F *Zjetspred = (TH1F*)LcorrJZBeemm->Clone("Zjetspred");
|
2599 |
TH1F *TTbarpred = (TH1F*)RcorrJZBem->Clone("TTbarpred");
|
2600 |
|
2601 |
TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
|
2602 |
TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
|
2603 |
if(PlottingSetup::RestrictToMassPeak) {
|
2604 |
Bpred->Add(RcorrJZBem,1.0/3.);
|
2605 |
Bpred->Add(LcorrJZBem,-1.0/3.);
|
2606 |
Bpred->Add(RcorrJZBSBem,1.0/3.);
|
2607 |
Bpred->Add(LcorrJZBSBem,-1.0/3.);
|
2608 |
Bpred->Add(RcorrJZBSBeemm,1.0/3.);
|
2609 |
Bpred->Add(LcorrJZBSBeemm,-1.0/3.);
|
2610 |
|
2611 |
TTbarpred->Scale(1.0/3);
|
2612 |
Zjetspred->Add(LcorrJZBem,-1.0/3.);
|
2613 |
Zjetspred->Add(LcorrJZBSBem,-1.0/3.);
|
2614 |
TTbarpred->Add(RcorrJZBSBem,1.0/3.);
|
2615 |
Zjetspred->Add(LcorrJZBSBeemm,-1.0/3.);
|
2616 |
TTbarpred->Add(RcorrJZBSBeemm,1.0/3.);
|
2617 |
|
2618 |
//these are for the ratio
|
2619 |
JBpred->Add(JRcorrJZBem,1.0/3.);
|
2620 |
JBpred->Add(JLcorrJZBem,-1.0/3.);
|
2621 |
JBpred->Add(JRcorrJZBSBem,1.0/3.);
|
2622 |
JBpred->Add(JLcorrJZBSBem,-1.0/3.);
|
2623 |
JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
|
2624 |
JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
|
2625 |
} else {
|
2626 |
Bpred->Add(RcorrJZBem,1.0);
|
2627 |
Bpred->Add(LcorrJZBem,-1.0);
|
2628 |
|
2629 |
Zjetspred->Add(LcorrJZBem,-1.0);
|
2630 |
|
2631 |
//these are for the ratio
|
2632 |
JBpred->Add(JRcorrJZBem,1.0);
|
2633 |
JBpred->Add(JLcorrJZBem,-1.0);
|
2634 |
}
|
2635 |
|
2636 |
|
2637 |
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
|
2638 |
|
2639 |
TLegend *legBpred = make_legend("",0.6,0.55,false);
|
2640 |
RcorrJZBeemm->Draw("e1x0,same");
|
2641 |
Bpred->Draw("hist,same");
|
2642 |
RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
|
2643 |
legBpred->AddEntry(RcorrJZBeemm,"MC observed","p");
|
2644 |
legBpred->AddEntry(Bpred,"MC predicted","l");
|
2645 |
if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
|
2646 |
if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
|
2647 |
legBpred->Draw();
|
2648 |
DrawMCPrelim();
|
2649 |
|
2650 |
//3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
|
2651 |
string ytitle("ratio");
|
2652 |
if ( use_data==1 ) ytitle = "data/pred";
|
2653 |
save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
|
2654 |
|
2655 |
TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
|
2656 |
TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
|
2657 |
TH1F *osof = qcdsamples.Draw("osof","pfJetGoodNum",1,0,100, "internal code", "events", cutOSOF ,mc, luminosity);
|
2658 |
TH1F *njossf = qcdsamples.Draw("njossf","pfJetGoodNum",1,0,100, "internal code", "events", cutnJets&&cutOSSF ,mc, luminosity);
|
2659 |
TH1F *njosof = qcdsamples.Draw("njosof","pfJetGoodNum",1,0,100, "internal code", "events", cutnJets&&cutOSOF ,mc, luminosity);
|
2660 |
|
2661 |
dout << "______________________________________________" << endl;
|
2662 |
dout << "QCD contribution: " << endl;
|
2663 |
dout << "Total number of events: " << allevents->Integral() << endl;
|
2664 |
dout << "OSSF events: " << ossf->Integral() << endl;
|
2665 |
dout << "OSOF events: " << osof->Integral() << endl;
|
2666 |
dout << "OSSF events with >=3 jets:" << njossf->Integral() << endl;
|
2667 |
dout << "OSOF events with >=3 jets:" << njosof->Integral() << endl;
|
2668 |
dout << "(note that no mass requirement has been imposed)" << endl;
|
2669 |
|
2670 |
dout << "______________________________________________" << endl;
|
2671 |
dout << "How QCD shows up in the different regions: " << endl;
|
2672 |
dout << "OSSF: " << endl;
|
2673 |
if(PlottingSetup::RestrictToMassPeak) {
|
2674 |
dout << " Z window: \t" << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
|
2675 |
dout << " sideband: \t" << RcorrJZBSBeemm->Integral() << " (JZB>0) , " << LcorrJZBSBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBSBeemm->Integral() + LcorrJZBSBeemm->Integral() << endl;
|
2676 |
} else {
|
2677 |
dout << " " << RcorrJZBeemm->Integral() << " (JZB>0) , " << LcorrJZBeemm->Integral() << " (JZB<0) --> total: " << RcorrJZBeemm->Integral() + LcorrJZBeemm->Integral() << endl;
|
2678 |
}
|
2679 |
dout << "OSOF: " << endl;
|
2680 |
if(PlottingSetup::RestrictToMassPeak) {
|
2681 |
dout << " Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
|
2682 |
dout << " sideband: \t" << RcorrJZBSBem->Integral() << " (JZB>0) , " << LcorrJZBSBem->Integral() << " (JZB<0) --> total: " << RcorrJZBSBem->Integral() + LcorrJZBSBem->Integral() << endl;
|
2683 |
} else {
|
2684 |
dout << " Z window: \t" << RcorrJZBem->Integral() << " (JZB>0) , " << LcorrJZBem->Integral() << " (JZB<0) --> total: " << RcorrJZBem->Integral() + LcorrJZBem->Integral() << endl;
|
2685 |
}
|
2686 |
dout << "Therefore: " << endl;
|
2687 |
if(PlottingSetup::RestrictToMassPeak) {
|
2688 |
dout << " Prediction increases by : " << LcorrJZBeemm->Integral() << " + (1.0/3)*(" << RcorrJZBSBeemm->Integral() <<"-"<< LcorrJZBSBeemm->Integral() << ") (SFSB) ";
|
2689 |
dout << " + (1.0/3)*(" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
|
2690 |
dout << " + (1.0/3)*(" << RcorrJZBSBem->Integral() <<"-"<< LcorrJZBSBem->Integral() << ") (OFSB) ";
|
2691 |
dout << " = " << LcorrJZBeemm->Integral() + (1.0/3)*(RcorrJZBSBeemm->Integral() - LcorrJZBSBeemm->Integral() + RcorrJZBem->Integral() - LcorrJZBem->Integral() + RcorrJZBSBem->Integral() - LcorrJZBSBem->Integral()) << endl;
|
2692 |
} else {
|
2693 |
dout << " Prediction increases by : " << LcorrJZBeemm->Integral();
|
2694 |
dout << " + (" << RcorrJZBem->Integral() <<"-"<< LcorrJZBem->Integral() << ") (OFZP) ";
|
2695 |
dout << " = " << LcorrJZBeemm->Integral() + RcorrJZBem->Integral() - LcorrJZBem->Integral() << endl;
|
2696 |
}
|
2697 |
dout << " Observation increases by : " << RcorrJZBeemm->Integral() << endl;
|
2698 |
|
2699 |
dout << endl;
|
2700 |
for(int i=0;i<bins.size();i++) {
|
2701 |
dout << " JZB > " << bins[i] << " : " << endl;
|
2702 |
dout << " Observation increases by : " << RcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
|
2703 |
if(PlottingSetup::RestrictToMassPeak) {
|
2704 |
dout << " Prediction increases by : " << LcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + (1.0/3)*(RcorrJZBSBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBSBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBSBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBSBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX())) << endl;
|
2705 |
} else {
|
2706 |
dout << " Prediction increases by : " << LcorrJZBeemm->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) + RcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) - LcorrJZBem->Integral(RcorrJZBeemm->FindBin(bins[i]),RcorrJZBeemm->GetNbinsX()) << endl;
|
2707 |
}
|
2708 |
}
|
2709 |
|
2710 |
delete can;
|
2711 |
delete allevents;
|
2712 |
if(ossf) delete ossf;
|
2713 |
if(RcorrJZBem) delete RcorrJZBem;
|
2714 |
if(LcorrJZBem) delete LcorrJZBem;
|
2715 |
if(RcorrJZBeemm) delete RcorrJZBeemm;
|
2716 |
if(LcorrJZBeemm) delete LcorrJZBeemm;
|
2717 |
if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBem) delete RcorrJZBSBem;
|
2718 |
if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBem) delete LcorrJZBSBem;
|
2719 |
if(PlottingSetup::RestrictToMassPeak&&RcorrJZBSBeemm) delete RcorrJZBSBeemm;
|
2720 |
if(PlottingSetup::RestrictToMassPeak&&LcorrJZBSBeemm) delete LcorrJZBSBeemm;
|
2721 |
}
|
2722 |
|
2723 |
void check_ptsanity() {
|
2724 |
TCanvas *ptsancan = new TCanvas("ptsancan","ptsancan",600,1800);
|
2725 |
TH1F *individualpt1histos[allsamples.collection.size()];
|
2726 |
TH1F *individualpt2histos[allsamples.collection.size()];
|
2727 |
TH1F *fpt1 = new TH1F("fpt1","fpt1",50,0,50);
|
2728 |
fpt1->GetYaxis()->SetRangeUser(0,1);
|
2729 |
fpt1->GetXaxis()->SetTitle("p_{T,1}");
|
2730 |
fpt1->GetXaxis()->CenterTitle();
|
2731 |
|
2732 |
TH1F *fpt2 = new TH1F("fpt2","fpt2",50,0,50);
|
2733 |
fpt2->GetXaxis()->SetTitle("p_{T,2}");
|
2734 |
fpt2->GetXaxis()->CenterTitle();
|
2735 |
|
2736 |
ptsancan->Divide(1,3);
|
2737 |
ptsancan->cd(1);
|
2738 |
float maxpt1entry=0;
|
2739 |
float maxpt2entry=0;
|
2740 |
|
2741 |
TLegend *leg = make_legend();
|
2742 |
leg->SetX1(0.0);
|
2743 |
leg->SetY1(0.0);
|
2744 |
leg->SetX2(1.0);
|
2745 |
leg->SetY2(1.0);
|
2746 |
|
2747 |
|
2748 |
for(int isample=0;isample<allsamples.collection.size();isample++) {
|
2749 |
string nowname=(allsamples.collection)[isample].filename;
|
2750 |
cout << "Drawing: " << nowname << " (sample " << isample+1 << " / " << allsamples.collection.size() << ")" << endl;
|
2751 |
individualpt1histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt1",50,0,50, "p_{T,1}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
|
2752 |
individualpt2histos[isample] = allsamples.Draw(GetNumericHistoName(),"pt2",50,0,50, "p_{T,2}", "events",cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample(nowname));
|
2753 |
individualpt1histos[isample]->SetLineColor(isample+1);
|
2754 |
individualpt2histos[isample]->SetLineColor(isample+1);
|
2755 |
float currmaxpt1entry=individualpt1histos[isample]->GetMaximum()/individualpt1histos[isample]->Integral();
|
2756 |
float currmaxpt2entry=individualpt2histos[isample]->GetMaximum()/individualpt2histos[isample]->Integral();
|
2757 |
cout << " pt 1 histo contains; " << individualpt1histos[isample]->Integral() << endl;
|
2758 |
cout << " pt 2 histo contains; " << individualpt2histos[isample]->Integral() << endl;
|
2759 |
if(currmaxpt1entry>maxpt1entry)maxpt1entry=currmaxpt1entry;
|
2760 |
if(currmaxpt2entry>maxpt2entry)maxpt2entry=currmaxpt2entry;
|
2761 |
leg->AddEntry(individualpt2histos[isample],((allsamples.collection)[isample].filename).c_str(),"f");
|
2762 |
}
|
2763 |
|
2764 |
fpt1->GetYaxis()->SetRangeUser(0,maxpt1entry);
|
2765 |
fpt2->GetYaxis()->SetRangeUser(0,maxpt2entry);
|
2766 |
|
2767 |
ptsancan->cd(1);
|
2768 |
fpt1->Draw();
|
2769 |
ptsancan->cd(2);
|
2770 |
fpt2->Draw();
|
2771 |
|
2772 |
for(int isample=0;isample<allsamples.collection.size();isample++) {
|
2773 |
ptsancan->cd(1);
|
2774 |
individualpt1histos[isample]->DrawNormalized("same,histo");
|
2775 |
ptsancan->cd(2);
|
2776 |
individualpt2histos[isample]->DrawNormalized("same,histo");
|
2777 |
}
|
2778 |
ptsancan->cd(3);
|
2779 |
leg->Draw();
|
2780 |
CompleteSave(ptsancan,"PtSanityCheck");
|
2781 |
|
2782 |
delete ptsancan;
|
2783 |
}
|
2784 |
|
2785 |
void test() {
|
2786 |
|
2787 |
TCanvas *testcanv = new TCanvas("testcanv","testcanv");
|
2788 |
testcanv->cd();
|
2789 |
switch_overunderflow(true);
|
2790 |
TH1F *ptdistr = allsamples.Draw("ptdistr","pt1",100,30,200, "p_{T} [GeV]", "events", cutOSSF,data,luminosity);
|
2791 |
switch_overunderflow(false);
|
2792 |
ptdistr->Draw();
|
2793 |
testcanv->SaveAs("test.png");
|
2794 |
dout << "HELLO there!" << endl;
|
2795 |
|
2796 |
}
|