1 |
andis |
1.1 |
#include "TCanvas.h"
|
2 |
|
|
#include "TROOT.h"
|
3 |
|
|
#include "TBrowser.h"
|
4 |
|
|
#include "TFile.h"
|
5 |
|
|
#include "TNtuple.h"
|
6 |
|
|
#include "TStyle.h"
|
7 |
|
|
#include "TFrame.h"
|
8 |
|
|
#include "TH1.h"
|
9 |
|
|
#include "TH2.h"
|
10 |
|
|
#include "TTree.h"
|
11 |
|
|
#include "TKey.h"
|
12 |
|
|
#include "TCut.h"
|
13 |
|
|
#include "TEntryList.h"
|
14 |
|
|
#include "TMath.h"
|
15 |
|
|
#include "TLine.h"
|
16 |
|
|
#include "TLegend.h"
|
17 |
|
|
#include <iostream>
|
18 |
|
|
#include <fstream>
|
19 |
|
|
#include <string>
|
20 |
|
|
#include <vector>
|
21 |
|
|
|
22 |
|
|
using namespace std;
|
23 |
|
|
|
24 |
|
|
void niceplots2()
|
25 |
|
|
{
|
26 |
|
|
// STYLES
|
27 |
|
|
|
28 |
|
|
gROOT->SetStyle("Plain");
|
29 |
|
|
gROOT->ForceStyle();
|
30 |
|
|
gStyle->SetOptStat(0);
|
31 |
|
|
gStyle->SetPalette(1);
|
32 |
|
|
gStyle->SetTitleBorderSize(0);
|
33 |
|
|
|
34 |
|
|
// GET FILES
|
35 |
|
|
|
36 |
|
|
TFile *savefile = new TFile("niceplots/niceplots2.root","RECREATE");
|
37 |
|
|
cout << "niceplots/niceplots2.root" << endl;
|
38 |
|
|
|
39 |
|
|
TFile *signal = new TFile("niceplots/signal.root","READ");
|
40 |
|
|
TFile *qcd_merged = new TFile("niceplots/qcd_merged.root","READ");
|
41 |
|
|
TFile *ttbar = new TFile("niceplots/ttbar.root","READ");
|
42 |
|
|
TFile *WW = new TFile("niceplots/WW.root","READ");
|
43 |
|
|
TFile *WZ = new TFile("niceplots/WZ.root","READ");
|
44 |
|
|
TFile *ZZ = new TFile("niceplots/ZZ.root","READ");
|
45 |
|
|
|
46 |
|
|
// GET NAME AND NUMBER OF FILES
|
47 |
|
|
|
48 |
|
|
signal->cd();
|
49 |
|
|
Int_t nfiles = gDirectory->GetListOfKeys()->GetEntries();
|
50 |
|
|
cout << "number of files: " << nfiles << endl;
|
51 |
|
|
|
52 |
|
|
vector<string> filenames;
|
53 |
|
|
vector<string>::const_iterator it_files;
|
54 |
|
|
|
55 |
|
|
TIter keys( gDirectory->GetListOfKeys() );
|
56 |
|
|
TKey *it_keys;
|
57 |
|
|
while ( it_keys = (TKey*)keys() )
|
58 |
|
|
filenames.push_back(it_keys->GetName());
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
// LOOP OVER DIRECTORIES
|
62 |
|
|
|
63 |
|
|
TH1D *sgnl,*qcd,*tt,*ww,*wz,*zz,*layer1,*layer2,*layer3,*layer4,*layer5,*layer6;
|
64 |
|
|
TLegend *leg_hist;
|
65 |
|
|
|
66 |
|
|
for( it_files = filenames.begin(); it_files != filenames.end(); ++it_files)
|
67 |
|
|
{
|
68 |
|
|
if(*it_files != "higgs_invmass")
|
69 |
|
|
{
|
70 |
|
|
TCanvas *ctemp = new TCanvas(it_files->c_str(),it_files->c_str());
|
71 |
|
|
ctemp->SetLineColor(0);
|
72 |
|
|
ctemp->cd(1);
|
73 |
|
|
sgnl = (TH1D*)signal->Get(it_files->c_str());
|
74 |
|
|
if(sgnl->GetEntries() > 0) {
|
75 |
|
|
sgnl->SetLineWidth(2);
|
76 |
|
|
sgnl->GetXaxis()->SetLabelSize(0.05);
|
77 |
|
|
sgnl->SetTitleSize(0.05);
|
78 |
|
|
sgnl->SetLineColor(2);
|
79 |
|
|
sgnl->SetFillStyle(0);
|
80 |
|
|
sgnl->DrawNormalized(); }
|
81 |
|
|
|
82 |
|
|
qcd = (TH1D*)qcd_merged->Get(it_files->c_str());
|
83 |
|
|
if(qcd->GetEntries() > 0) {
|
84 |
|
|
qcd->SetLineWidth(2);
|
85 |
|
|
qcd->SetLineColor(3);
|
86 |
|
|
qcd->SetFillStyle(0);
|
87 |
|
|
qcd->DrawNormalized("SAME"); }
|
88 |
|
|
|
89 |
|
|
tt = (TH1D*)ttbar->Get(it_files->c_str());
|
90 |
|
|
if(tt->GetEntries() > 0) {
|
91 |
|
|
tt->SetLineWidth(2);
|
92 |
|
|
tt->SetLineColor(4);
|
93 |
|
|
tt->SetLineStyle(5);
|
94 |
|
|
tt->SetFillStyle(0);
|
95 |
|
|
tt->DrawNormalized("SAME"); }
|
96 |
|
|
|
97 |
|
|
ww = (TH1D*)WW->Get(it_files->c_str());
|
98 |
|
|
if(ww->GetEntries() > 0) {
|
99 |
|
|
ww->SetLineWidth(2);
|
100 |
|
|
ww->SetLineColor(kBlack);
|
101 |
|
|
ww->SetLineStyle(5);
|
102 |
|
|
ww->SetFillStyle(0);
|
103 |
|
|
ww->DrawNormalized("SAME"); }
|
104 |
|
|
|
105 |
|
|
wz= (TH1D*)WZ->Get(it_files->c_str());
|
106 |
|
|
if(wz->GetEntries() > 0) {
|
107 |
|
|
wz->SetLineWidth(2);
|
108 |
|
|
wz->SetLineColor(kMagenta+1);
|
109 |
|
|
wz->SetLineStyle(5);
|
110 |
|
|
wz->SetFillStyle(0);
|
111 |
|
|
wz->DrawNormalized("SAME"); }
|
112 |
|
|
|
113 |
|
|
zz= (TH1D*)ZZ->Get(it_files->c_str());
|
114 |
|
|
if(zz->GetEntries() > 0) {
|
115 |
|
|
zz->SetLineWidth(2);
|
116 |
|
|
zz->SetLineColor(kGray);
|
117 |
|
|
zz->SetLineStyle(5);
|
118 |
|
|
zz->SetFillStyle(0);
|
119 |
|
|
zz->DrawNormalized("SAME"); }
|
120 |
|
|
|
121 |
|
|
leg_hist = new TLegend(0.5,0.6,0.79,0.79);
|
122 |
|
|
leg_hist->SetLineColor(1);
|
123 |
|
|
leg_hist->SetLineWidth(1);
|
124 |
|
|
leg_hist->AddEntry(sgnl,"Signal","l");
|
125 |
|
|
leg_hist->AddEntry(qcd,"QCD","l");
|
126 |
|
|
leg_hist->AddEntry(tt,"TTbar","l");
|
127 |
|
|
leg_hist->AddEntry(ww,"WW","l");
|
128 |
|
|
leg_hist->AddEntry(wz,"WZ","l");
|
129 |
|
|
leg_hist->AddEntry(zz,"ZZ","l");
|
130 |
|
|
|
131 |
|
|
leg_hist->DrawClone();
|
132 |
|
|
savefile->Add(ctemp->Clone());
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
else if(*it_files == "higgs_invmass")
|
136 |
|
|
{
|
137 |
|
|
TCanvas *lastplots = new TCanvas("lastplots","Higgs inv. mass (combined)");
|
138 |
|
|
lastplots->Divide(3,2);
|
139 |
|
|
TCanvas *higgs_signal = new TCanvas("higgs_signal","Higgs inv. mass (Signal sample)");
|
140 |
|
|
higgs_signal->Divide(4,3);
|
141 |
|
|
TCanvas *higgs_ttbar = new TCanvas("higgs_ttbar","Higgs inv. mass (TTbar sample)");
|
142 |
|
|
higgs_ttbar->Divide(4,3);
|
143 |
|
|
TCanvas *higgs_qcd = new TCanvas("higgs_qcd","Higgs inv. mass (QCD sample)");
|
144 |
|
|
higgs_qcd->Divide(4,3);
|
145 |
|
|
TCanvas *higgs_combined = new TCanvas("higgs_combined","Higgs inv. mass (combined)");
|
146 |
|
|
higgs_combined->Divide(4,3);
|
147 |
|
|
TCanvas *higgs_ww = new TCanvas("higgs_ww","Higgs inv. mass (WW sample)");
|
148 |
|
|
higgs_ww->Divide(4,3);
|
149 |
|
|
TCanvas *higgs_wz = new TCanvas("higgs_wz","Higgs inv. mass (WZ sample)");
|
150 |
|
|
higgs_wz->Divide(4,3);
|
151 |
|
|
TCanvas *higgs_zz = new TCanvas("higgs_zz","Higgs inv. mass (ZZ sample)");
|
152 |
|
|
higgs_zz->Divide(4,3);
|
153 |
|
|
|
154 |
|
|
TIter keys_sgnl( signal->GetDirectory("higgs_invmass")->GetListOfKeys() );
|
155 |
|
|
|
156 |
|
|
if( signal->GetDirectory("higgs_invmass")->GetListOfKeys()->GetEntries() == 0 )
|
157 |
|
|
{
|
158 |
|
|
cout << "no higgs invmass files" << endl;
|
159 |
|
|
return;
|
160 |
|
|
}
|
161 |
|
|
if( ttbar->GetDirectory("higgs_invmass")->GetListOfKeys()->GetEntries() == 0 )
|
162 |
|
|
{
|
163 |
|
|
cout << "no higgs invmass files" << endl;
|
164 |
|
|
return;
|
165 |
|
|
}
|
166 |
|
|
if( qcd_merged->GetDirectory("higgs_invmass")->GetListOfKeys()->GetEntries() == 0 )
|
167 |
|
|
{
|
168 |
|
|
cout << "no higgs invmass files" << endl;
|
169 |
|
|
return;
|
170 |
|
|
}
|
171 |
|
|
if( WW->GetDirectory("higgs_invmass")->GetListOfKeys()->GetEntries() == 0 )
|
172 |
|
|
{
|
173 |
|
|
cout << "no higgs invmass files" << endl;
|
174 |
|
|
return;
|
175 |
|
|
}
|
176 |
|
|
if( WZ->GetDirectory("higgs_invmass")->GetListOfKeys()->GetEntries() == 0 )
|
177 |
|
|
{
|
178 |
|
|
cout << "no higgs invmass files" << endl;
|
179 |
|
|
return;
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
if( ZZ->GetDirectory("higgs_invmass")->GetListOfKeys()->GetEntries() == 0 )
|
183 |
|
|
{
|
184 |
|
|
cout << "no higgs invmass files" << endl;
|
185 |
|
|
return;
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
Int_t count = 1;
|
189 |
|
|
|
190 |
|
|
for( ; it_keys = (TKey*)keys_sgnl(); ++count )
|
191 |
|
|
{
|
192 |
|
|
higgs_signal->cd(count);
|
193 |
|
|
sgnl = (TH1D*)(signal->Get(("higgs_invmass/" + string(it_keys->GetName())).c_str()));
|
194 |
|
|
if(sgnl->GetEntries() > 0) {
|
195 |
|
|
sgnl->SetLineWidth(2);
|
196 |
|
|
sgnl->GetXaxis()->SetLabelSize(0.05);
|
197 |
|
|
sgnl->SetTitleSize(0.05);
|
198 |
|
|
sgnl->SetLineColor(2);
|
199 |
|
|
if(count > 6) sgnl->Rebin();
|
200 |
|
|
sgnl->DrawClone(); }
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
higgs_ttbar->cd(count);
|
204 |
|
|
tt = (TH1D*)(ttbar->Get(("higgs_invmass/" + string(it_keys->GetName())).c_str()));
|
205 |
|
|
if(tt->GetEntries() > 0) {
|
206 |
|
|
tt->SetLineWidth(2);
|
207 |
|
|
tt->GetXaxis()->SetLabelSize(0.05);
|
208 |
|
|
tt->SetTitleSize(0.05);
|
209 |
|
|
tt->SetLineColor(4);
|
210 |
|
|
if(count > 6) tt->Rebin();
|
211 |
|
|
tt->DrawClone(); }
|
212 |
|
|
|
213 |
|
|
higgs_qcd->cd(count);
|
214 |
|
|
qcd = (TH1D*)(qcd_merged->Get(("higgs_invmass/" + string(it_keys->GetName())).c_str()));
|
215 |
|
|
if(qcd->GetEntries() > 0) {
|
216 |
|
|
qcd->SetLineWidth(2);
|
217 |
|
|
qcd->GetXaxis()->SetLabelSize(0.05);
|
218 |
|
|
qcd->SetTitleSize(0.05);
|
219 |
|
|
qcd->SetLineColor(3);
|
220 |
|
|
if(count > 6) qcd->Rebin();
|
221 |
|
|
qcd->DrawClone(); }
|
222 |
|
|
|
223 |
|
|
higgs_ww->cd(count);
|
224 |
|
|
ww = (TH1D*)(WW->Get(("higgs_invmass/" + string(it_keys->GetName())).c_str()));
|
225 |
|
|
if(ww->GetEntries() > 0) {
|
226 |
|
|
ww->SetLineWidth(2);
|
227 |
|
|
ww->GetXaxis()->SetLabelSize(0.05);
|
228 |
|
|
ww->SetTitleSize(0.05);
|
229 |
|
|
ww->SetLineColor(kBlack);
|
230 |
|
|
if(count > 6) ww->Rebin();
|
231 |
|
|
ww->DrawClone(); }
|
232 |
|
|
|
233 |
|
|
higgs_wz->cd(count);
|
234 |
|
|
wz = (TH1D*)(WZ->Get(("higgs_invmass/" + string(it_keys->GetName())).c_str()));
|
235 |
|
|
if(wz->GetEntries() > 0) {
|
236 |
|
|
wz->SetLineWidth(2);
|
237 |
|
|
wz->GetXaxis()->SetLabelSize(0.05);
|
238 |
|
|
wz->SetTitleSize(0.05);
|
239 |
|
|
wz->SetLineColor(kMagenta+1);
|
240 |
|
|
if(count > 6) wz->Rebin();
|
241 |
|
|
wz->DrawClone(); }
|
242 |
|
|
|
243 |
|
|
higgs_zz->cd(count);
|
244 |
|
|
zz = (TH1D*)(ZZ->Get(("higgs_invmass/" + string(it_keys->GetName())).c_str()));
|
245 |
|
|
if(zz->GetEntries() > 0) {
|
246 |
|
|
zz->SetLineWidth(2);
|
247 |
|
|
zz->GetXaxis()->SetLabelSize(0.05);
|
248 |
|
|
zz->SetTitleSize(0.05);
|
249 |
|
|
zz->SetLineColor(kGray);
|
250 |
|
|
if(count > 6) zz->Rebin();
|
251 |
|
|
zz->DrawClone(); }
|
252 |
|
|
|
253 |
|
|
higgs_combined->cd(count);
|
254 |
|
|
|
255 |
|
|
layer1 = (TH1D*)sgnl->Clone();
|
256 |
|
|
layer1->Scale(0.038);
|
257 |
|
|
layer2 = (TH1D*)layer1->Clone();
|
258 |
|
|
layer2->Add(zz,0.0037);
|
259 |
|
|
layer3 = (TH1D*)layer1->Clone();
|
260 |
|
|
layer3->Add(ww,0.15);
|
261 |
|
|
layer4 = (TH1D*)layer2->Clone();
|
262 |
|
|
layer4->Add(wz,0.012);
|
263 |
|
|
layer5 = (TH1D*)layer4->Clone();
|
264 |
|
|
layer5->Add(tt,0.46);
|
265 |
|
|
layer6 = (TH1D*)layer5->Clone();
|
266 |
|
|
layer6->Add(qcd);
|
267 |
|
|
|
268 |
|
|
layer6->SetFillStyle(1001);
|
269 |
|
|
layer6->SetLineColor(kGreen+1);
|
270 |
|
|
layer6->SetFillColor(kGreen+1);
|
271 |
|
|
layer3->SetFillStyle(1001);
|
272 |
|
|
layer3->SetFillColor(kBlack);
|
273 |
|
|
layer3->SetLineColor(kBlack);
|
274 |
|
|
layer2->SetFillStyle(1001);
|
275 |
|
|
layer2->SetFillColor(kGray);
|
276 |
|
|
layer2->SetLineColor(kGray);
|
277 |
|
|
layer5->SetFillStyle(1001);
|
278 |
|
|
layer5->SetFillColor(kBlue+1);
|
279 |
|
|
layer5->SetLineColor(kBlue+1);
|
280 |
|
|
layer4->SetFillStyle(1001);
|
281 |
|
|
layer4->SetFillColor(kMagenta+1);
|
282 |
|
|
layer4->SetLineColor(kMagenta+1);
|
283 |
|
|
layer1->SetFillStyle(1001);
|
284 |
|
|
layer1->SetFillColor(kRed);
|
285 |
|
|
layer1->SetLineColor(kRed);
|
286 |
|
|
|
287 |
|
|
if(layer6->GetEntries() > 0) layer6->Draw();
|
288 |
|
|
if(layer5->GetEntries() > 0) layer5->Draw("SAME");
|
289 |
|
|
if(layer4->GetEntries() > 0) layer4->Draw("SAME");
|
290 |
|
|
if(layer3->GetEntries() > 0) layer3->Draw("SAME");
|
291 |
|
|
if(layer2->GetEntries() > 0) layer2->Draw("SAME");
|
292 |
|
|
if(layer1->GetEntries() > 0) layer1->Draw("SAME");
|
293 |
|
|
|
294 |
|
|
leg_hist = new TLegend(0.7,0.55,0.89,0.89);
|
295 |
|
|
leg_hist->SetLineColor(1);
|
296 |
|
|
leg_hist->SetLineWidth(1);
|
297 |
|
|
leg_hist->AddEntry(layer1,"Signal","f");
|
298 |
|
|
leg_hist->AddEntry(layer2,"ZZ","f");
|
299 |
|
|
leg_hist->AddEntry(layer3,"WW","f");
|
300 |
|
|
leg_hist->AddEntry(layer4,"WZ","f");
|
301 |
|
|
leg_hist->AddEntry(layer5,"TTbar","f");
|
302 |
|
|
leg_hist->AddEntry(layer6,"QCD","f");
|
303 |
|
|
|
304 |
|
|
leg_hist->DrawClone();
|
305 |
|
|
|
306 |
|
|
if(count > 6)
|
307 |
|
|
{
|
308 |
|
|
lastplots->cd(count - 6);
|
309 |
|
|
if(layer6->GetEntries() > 0) layer6->Draw();
|
310 |
|
|
if(layer5->GetEntries() > 0) layer5->Draw("SAME");
|
311 |
|
|
if(layer4->GetEntries() > 0) layer4->Draw("SAME");
|
312 |
|
|
if(layer3->GetEntries() > 0) layer3->Draw("SAME");
|
313 |
|
|
if(layer2->GetEntries() > 0) layer2->Draw("SAME");
|
314 |
|
|
if(layer1->GetEntries() > 0) layer1->Draw("SAME");
|
315 |
|
|
leg_hist->DrawClone();
|
316 |
|
|
}
|
317 |
|
|
}
|
318 |
|
|
|
319 |
|
|
savefile->Add(higgs_combined->Clone());
|
320 |
|
|
savefile->Add(higgs_ttbar->Clone());
|
321 |
|
|
savefile->Add(higgs_signal->Clone());
|
322 |
|
|
savefile->Add(higgs_qcd->Clone());
|
323 |
|
|
savefile->Add(higgs_ww->Clone());
|
324 |
|
|
savefile->Add(higgs_wz->Clone());
|
325 |
|
|
savefile->Add(higgs_zz->Clone());
|
326 |
|
|
}
|
327 |
|
|
}
|
328 |
|
|
|
329 |
|
|
savefile->Write();
|
330 |
|
|
savefile->Close();
|
331 |
|
|
}
|
332 |
|
|
|
333 |
|
|
|