--- UserCode/IPHCalignment2/analysis/Layout.cpp 2011/11/27 09:57:20 1.1 +++ UserCode/IPHCalignment2/analysis/Layout.cpp 2011/11/29 07:52:14 1.6 @@ -1,6 +1,7 @@ #include "Layout.h" - - +#include +#include +#include void Layout::DrawInit() { @@ -73,17 +74,12 @@ void Layout::DrawInit() } -struct HistoDescription -{ - unsigned int linecolor; - std::string algoName; -}; - - void Layout::Draw(const std::vector& histos, - std::string& xlabel, float K, float MU, float SIG) + 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; @@ -113,7 +109,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.40,0.85-(0.04*histos.size()),0.90,0.85); 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,"R+"); + // 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(histos[3].histo->GetTitle()); mycanvas->SaveAs((filename+".gif").c_str()); + mycanvas->SaveAs((filename+".root").c_str()); + }