1 |
|
#include "Layout.h" |
2 |
< |
|
3 |
< |
|
2 |
> |
#include <sstream> |
3 |
> |
#include <TPaveText.h> |
4 |
> |
#include <TLatex.h> |
5 |
|
|
6 |
|
void Layout::DrawInit() |
7 |
|
{ |
8 |
< |
gStyle->SetCanvasColor(0); |
8 |
> |
/* gStyle->SetCanvasColor(0); |
9 |
|
gStyle->SetCanvasBorderMode(0); |
10 |
|
gStyle->SetCanvasBorderSize(3); |
11 |
|
|
70 |
|
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; |
71 |
|
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); |
72 |
|
gStyle->SetNumberContours(NCont); |
73 |
< |
|
73 |
> |
*/ |
74 |
|
|
75 |
|
} |
76 |
|
|
78 |
|
void Layout::Draw(const std::vector<HistoBlock>& histos, |
79 |
|
const std::string& xlabel, float K, float MU, float SIG) |
80 |
|
{ |
81 |
+ |
std::cout << "----------------- Draw : " << histos[0].histo->GetName() << std::endl; |
82 |
+ |
|
83 |
|
// safety |
84 |
|
if (histos.empty()) return; |
85 |
|
|
110 |
|
float xmax = mystack->GetXaxis()->GetXmin(); |
111 |
|
|
112 |
|
// Draw legend |
113 |
< |
TLegend* mylegend = new TLegend(0.17,0.72,0.43,0.85); |
113 |
> |
TLegend* mylegend = new TLegend(0.17,0.85-(0.04*histos.size()),0.33,0.85); |
114 |
|
mylegend->SetFillColor(0); |
115 |
|
for (unsigned int i=0;i<histos.size();i++) |
116 |
|
{ |
118 |
|
histos[i].algoName.c_str(),"l"); |
119 |
|
} |
120 |
|
mylegend->Draw(); |
121 |
+ |
std::cout << "size = " << mylegend->GetTextSize() << std::endl; |
122 |
+ |
std::cout << "font = " << mylegend->GetTextFont() << std::endl; |
123 |
+ |
|
124 |
+ |
std::cout << mylegend->GetX1() << " " << mylegend->GetX2() << std::endl; |
125 |
+ |
std::cout << mylegend->GetY1() << " " << mylegend->GetY2() << std::endl; |
126 |
+ |
|
127 |
+ |
TPaveText* toto = new TPaveText(0.17,0.72,0.43,0.83); |
128 |
+ |
toto->SetFillColor(2); |
129 |
+ |
toto->SetTextFont(2); |
130 |
+ |
toto->SetTextSize(0); |
131 |
+ |
toto->AddText("toto"); |
132 |
+ |
toto->Draw(); |
133 |
|
|
134 |
|
// To Fit |
135 |
+ |
std::vector<double> sigmas; |
136 |
|
for (unsigned int i=0;i<histos.size();i++) |
137 |
|
{ |
138 |
|
TF1* fitter = new TF1(dummy().c_str(),"gaus",xmin,xmax); |
140 |
|
fitter->SetParameter(1,MU); |
141 |
|
fitter->SetParameter(2,SIG); |
142 |
|
histos[i].histo->Fit(fitter,"0"); |
143 |
+ |
sigmas.push_back(fitter->GetParameter(2)); |
144 |
+ |
} |
145 |
+ |
|
146 |
+ |
// Display sigmas |
147 |
+ |
for (unsigned int i=0;i<sigmas.size();i++) |
148 |
+ |
{ |
149 |
+ |
std::stringstream str; |
150 |
+ |
str << "#sigma_{RECO} = "; |
151 |
+ |
str << sigmas[i]; |
152 |
+ |
TLatex mytext(56,200,str.str().c_str()); |
153 |
+ |
std::cout << mycanvas->GetXlowNDC() << " " << mycanvas->GetWNDC() << std::endl; |
154 |
|
} |
155 |
|
|
156 |
|
// Save |