--- UserCode/IPHCalignment2/analysis/Layout.cpp 2011/11/28 13:43:44 1.4 +++ UserCode/IPHCalignment2/analysis/Layout.cpp 2011/12/07 18:31:52 1.10 @@ -2,6 +2,8 @@ #include #include #include +#include +using namespace std; void Layout::DrawInit() { @@ -17,7 +19,7 @@ void Layout::DrawInit() gStyle->SetFrameBorderMode(0); gStyle->SetFrameBorderSize(0); gStyle->SetFrameFillColor(0); - gStyle->SetOptStat(0); + // gStyle->SetOptStat(0); gStyle->SetLabelOffset(0.005,"X"); gStyle->SetLabelSize(0.03,"X"); @@ -75,8 +77,8 @@ void Layout::DrawInit() } -void Layout::Draw(const std::vector& histos, - const std::string& xlabel, float K, float MU, float SIG) +void Layout::Draw(const std::string title, const std::vector& histos, + const std::string& xlabel, bool fit, float K, float MU, float SIG) { std::cout << "----------------- Draw : " << histos[0].histo->GetName() << std::endl; @@ -87,7 +89,6 @@ void Layout::Draw(const std::vectorGetName())+ "_canvas").c_str(), histos[0].histo->GetTitle()); - // SetLineColor for (unsigned int i=0;iGetXaxis()->GetXmin(); // Draw legend - TLegend* mylegend = new TLegend(0.17,0.85-(0.04*histos.size()),0.33,0.85); + TLegend* mylegend = new TLegend(0.55,0.90-(0.04*histos.size()),0.90,0.90); mylegend->SetFillColor(0); for (unsigned int i=0;iDraw(); - // To Fit - std::vector sigmas; - std::vector errors; - for (unsigned int i=0;iSetParameter(0,K); - fitter->SetParameter(1,MU); - fitter->SetParameter(2,SIG); - histos[i].histo->Fit(fitter,"0"); - sigmas.push_back(fitter->GetParameter(2)); - errors.push_back(fitter->GetParError(2)); - } - // Display sigmas - TPaveText* myblock = new TPaveText(0.6,0.65-(0.04*histos.size()),0.80,0.65,"NDC"); - myblock->SetBorderSize(0); - myblock->SetFillColor(0); - for (unsigned int i=0;iAddText(str.str().c_str()); - mytext->SetTextColor(histos[i].linecolor); - mytext->SetTextAlign(11); + // To Fit + std::vector sigmas; + std::vector errors; + for (unsigned int i=0;iSetParameter(0,K); + fitter->SetParameter(1,MU); + fitter->SetParameter(2,SIG); + histos[i].histo->Fit(fitter,"0"); + sigmas.push_back(fitter->GetParameter(2)); + errors.push_back(fitter->GetParError(2)); + } + + // Display sigmas + TPaveText* myblock = new TPaveText(0.65,0.65-(0.04*histos.size()),0.90,0.65,"NDC"); + myblock->SetBorderSize(0); + myblock->SetFillColor(0); + for (unsigned int i=0;iAddText(str.str().c_str()); + mytext->SetTextColor(histos[i].linecolor); + mytext->SetTextAlign(11); + } + myblock->Draw(); } - myblock->Draw(); // Save - std::string filename = GetFileName(histos[0].histo->GetTitle()); + std::string filename = GetFileName(title); mycanvas->SaveAs((filename+".gif").c_str()); mycanvas->SaveAs((filename+".root").c_str());