--- UserCode/IPHCalignment2/analysis/Layout.cpp 2011/11/27 11:11:48 1.2 +++ UserCode/IPHCalignment2/analysis/Layout.cpp 2011/12/01 13:46:25 1.9 @@ -1,6 +1,7 @@ #include "Layout.h" - - +#include +#include +#include void Layout::DrawInit() { @@ -16,7 +17,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"); @@ -74,9 +75,11 @@ 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; + // safety if (histos.empty()) return; @@ -84,11 +87,9 @@ void Layout::Draw(const std::vectorGetName())+ "_canvas").c_str(), histos[0].histo->GetTitle()); - // SetLineColor for (unsigned int i=0;iSetLineColor( histos[i].linecolor ); } @@ -107,7 +108,7 @@ void Layout::Draw(const std::vectorGetXaxis()->GetXmin(); // Draw legend - TLegend* mylegend = new TLegend(0.17,0.72,0.43,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 - for (unsigned int i=0;iSetParameter(0,K); - fitter->SetParameter(1,MU); - fitter->SetParameter(2,SIG); - histos[i].histo->Fit(fitter,"0"); + // 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(); } // 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());