1 |
/*
|
2 |
* Plotter.C
|
3 |
*
|
4 |
* Created on: 25.06.2012
|
5 |
* Author: csander
|
6 |
*/
|
7 |
|
8 |
#include "Plotter.h"
|
9 |
|
10 |
Plotter::Plotter() {
|
11 |
// TODO Auto-generated constructor stub
|
12 |
|
13 |
}
|
14 |
|
15 |
Plotter::~Plotter() {
|
16 |
// TODO Auto-generated destructor stub
|
17 |
}
|
18 |
|
19 |
void Plotter::Plot(std::string filename) {
|
20 |
|
21 |
gROOT->Reset();
|
22 |
//gROOT->SetStyle("Plain");
|
23 |
|
24 |
TStyle *MyStyle = new TStyle("MyStyle","My Root Styles");
|
25 |
MyStyle->SetStatColor(0);
|
26 |
MyStyle->SetCanvasColor(0);
|
27 |
MyStyle->SetPadColor(0);
|
28 |
MyStyle->SetPadBorderMode(0);
|
29 |
MyStyle->SetCanvasBorderMode(0);
|
30 |
MyStyle->SetFrameBorderMode(0);
|
31 |
MyStyle->SetOptStat(0);
|
32 |
MyStyle->SetStatBorderSize(2);
|
33 |
MyStyle->SetOptTitle(0);
|
34 |
MyStyle->SetPadTickX(1);
|
35 |
MyStyle->SetPadTickY(1);
|
36 |
MyStyle->SetPadBorderSize(2);
|
37 |
MyStyle->SetPalette(51, 0);
|
38 |
MyStyle->SetPadBottomMargin(0.15);
|
39 |
MyStyle->SetPadTopMargin(0.05);
|
40 |
MyStyle->SetPadLeftMargin(0.15);
|
41 |
MyStyle->SetPadRightMargin(0.25);
|
42 |
MyStyle->SetTitleColor(1);
|
43 |
MyStyle->SetTitleFillColor(0);
|
44 |
MyStyle->SetTitleFontSize(0.05);
|
45 |
MyStyle->SetTitleBorderSize(0);
|
46 |
MyStyle->SetLineWidth(1);
|
47 |
MyStyle->SetHistLineWidth(3);
|
48 |
MyStyle->SetLegendBorderSize(0);
|
49 |
MyStyle->SetNdivisions(502, "x");
|
50 |
MyStyle->SetMarkerSize(0.8);
|
51 |
MyStyle->SetTickLength(0.03);
|
52 |
MyStyle->SetTitleOffset(1.5, "x");
|
53 |
MyStyle->SetTitleOffset(1.5, "y");
|
54 |
MyStyle->SetTitleOffset(1.0, "z");
|
55 |
MyStyle->SetLabelSize(0.05, "x");
|
56 |
MyStyle->SetLabelSize(0.05, "y");
|
57 |
MyStyle->SetLabelSize(0.05, "z");
|
58 |
MyStyle->SetLabelOffset(0.03, "x");
|
59 |
MyStyle->SetLabelOffset(0.03, "y");
|
60 |
MyStyle->SetLabelOffset(0.03, "z");
|
61 |
MyStyle->SetTitleSize(0.05, "x");
|
62 |
MyStyle->SetTitleSize(0.05, "y");
|
63 |
MyStyle->SetTitleSize(0.05, "z");
|
64 |
gROOT->SetStyle("MyStyle");
|
65 |
|
66 |
//gROOT->ForceStyle();
|
67 |
|
68 |
bool DrawLog = true;
|
69 |
|
70 |
for (int i = 0; i < N_histos; ++i) {
|
71 |
|
72 |
THStack *hs;
|
73 |
TLegend *l;
|
74 |
if (bg.size() > 0) {
|
75 |
hs = new THStack("hs", bg.at(0).at(i)->GetName());
|
76 |
int Nset = data.size() + bg.size() + signal.size();
|
77 |
if (Nset > 20)
|
78 |
Nset = 20.;
|
79 |
l = new TLegend(0.76, 0.95 - 0.8 * Nset / 20., 1.0, 0.95);
|
80 |
l->SetFillStyle(1001);
|
81 |
l->SetFillColor(kWhite);
|
82 |
l->SetLineColor(kWhite);
|
83 |
l->SetLineWidth(2);
|
84 |
int j = 0;
|
85 |
for (std::vector<std::vector<TH1F*> >::const_iterator it = bg.begin(); it != bg.end(); ++it) {
|
86 |
switch (j) {
|
87 |
case 0:
|
88 |
it->at(i)->SetFillColor(kRed);
|
89 |
break;
|
90 |
case 1:
|
91 |
it->at(i)->SetFillColor(kOrange);
|
92 |
break;
|
93 |
case 2:
|
94 |
it->at(i)->SetFillColor(kYellow);
|
95 |
break;
|
96 |
case 3:
|
97 |
it->at(i)->SetFillColor(kGreen);
|
98 |
break;
|
99 |
case 4:
|
100 |
it->at(i)->SetFillColor(kCyan);
|
101 |
break;
|
102 |
case 5:
|
103 |
it->at(i)->SetFillColor(kBlue);
|
104 |
break;
|
105 |
case 6:
|
106 |
it->at(i)->SetFillColor(kMagenta);
|
107 |
break;
|
108 |
case 7:
|
109 |
it->at(i)->SetFillColor(kGray);
|
110 |
break;
|
111 |
case 8:
|
112 |
it->at(i)->SetFillColor(kGray + 2);
|
113 |
break;
|
114 |
default:
|
115 |
it->at(i)->SetFillColor(kBlack);
|
116 |
break;
|
117 |
}
|
118 |
hs->Add(it->at(i));
|
119 |
l->AddEntry(it->at(i), bg_names.at(j).c_str(), "f");
|
120 |
++j;
|
121 |
}
|
122 |
}
|
123 |
|
124 |
TCanvas *c = new TCanvas("c", "c", 800, 600);
|
125 |
c->SetLogy(DrawLog);
|
126 |
if (data.size() > 0) {
|
127 |
data.at(0).at(i)->SetMaximum(5 * data.at(0).at(i)->GetMaximum());
|
128 |
|
129 |
data.at(0).at(i)->GetXaxis()->SetTitleOffset(1.3);
|
130 |
data.at(0).at(i)->GetYaxis()->SetTitleOffset(1.3);
|
131 |
data.at(0).at(i)->GetYaxis()->SetTitle("Events");
|
132 |
data.at(0).at(i)->GetXaxis()->SetNdivisions(505);
|
133 |
|
134 |
data.at(0).at(i)->Draw("");
|
135 |
l->AddEntry(data.at(0).at(i), data_names.at(0).c_str(), "p");
|
136 |
hs->Draw("histsame");
|
137 |
int j = 0;
|
138 |
for (std::vector<std::vector<TH1F*> >::const_iterator it = signal.begin(); it != signal.end(); ++it) {
|
139 |
switch (j) {
|
140 |
case 0:
|
141 |
it->at(i)->SetLineColor(kRed+1);
|
142 |
break;
|
143 |
case 1:
|
144 |
it->at(i)->SetLineColor(kOrange+1);
|
145 |
break;
|
146 |
case 2:
|
147 |
it->at(i)->SetLineColor(kYellow+1);
|
148 |
break;
|
149 |
case 3:
|
150 |
it->at(i)->SetLineColor(kGreen+1);
|
151 |
break;
|
152 |
case 4:
|
153 |
it->at(i)->SetLineColor(kCyan+1);
|
154 |
break;
|
155 |
case 5:
|
156 |
it->at(i)->SetLineColor(kBlue+1);
|
157 |
break;
|
158 |
case 6:
|
159 |
it->at(i)->SetLineColor(kMagenta+1);
|
160 |
break;
|
161 |
case 7:
|
162 |
it->at(i)->SetLineColor(kGray);
|
163 |
break;
|
164 |
case 8:
|
165 |
it->at(i)->SetLineColor(kGray + 2);
|
166 |
break;
|
167 |
default:
|
168 |
it->at(i)->SetLineColor(kBlack);
|
169 |
break;
|
170 |
}
|
171 |
it->at(i)->SetLineWidth(2);
|
172 |
it->at(i)->Draw("histsame");
|
173 |
l->AddEntry(it->at(i), signal_names.at(j).c_str(), "l");
|
174 |
data.at(0).at(i)->SetMarkerStyle(20);
|
175 |
data.at(0).at(i)->Draw("psame");
|
176 |
l->Draw("same");
|
177 |
++j;
|
178 |
}
|
179 |
}
|
180 |
if (data.size() == 0) {
|
181 |
hs->Draw("hist");
|
182 |
}
|
183 |
if (i == 0 && N_histos > 1) {
|
184 |
c->Print("results.pdf(");
|
185 |
} else if (i > 0 && i == N_histos - 1)
|
186 |
c->Print("results.pdf)");
|
187 |
else
|
188 |
c->Print("results.pdf");
|
189 |
|
190 |
}
|
191 |
|
192 |
}
|