--- UserCode/IPHCalignment2/analysis/Layout.cpp 2011/11/27 09:57:20 1.1 +++ UserCode/IPHCalignment2/analysis/Layout.cpp 2011/11/28 13:18:09 1.3 @@ -1,10 +1,11 @@ #include "Layout.h" - - +#include +#include +#include void Layout::DrawInit() { - gStyle->SetCanvasColor(0); + /* gStyle->SetCanvasColor(0); gStyle->SetCanvasBorderMode(0); gStyle->SetCanvasBorderSize(3); @@ -69,21 +70,16 @@ void Layout::DrawInit() Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 }; TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont); gStyle->SetNumberContours(NCont); - + */ } -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, float K, float MU, float SIG) { + std::cout << "----------------- Draw : " << histos[0].histo->GetName() << std::endl; + // safety if (histos.empty()) return; @@ -95,6 +91,7 @@ void Layout::Draw(const std::vectorSetLineColor( histos[i].linecolor ); } @@ -113,7 +110,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.17,0.85-(0.04*histos.size()),0.33,0.85); mylegend->SetFillColor(0); for (unsigned int i=0;iDraw(); + std::cout << "size = " << mylegend->GetTextSize() << std::endl; + std::cout << "font = " << mylegend->GetTextFont() << std::endl; + + std::cout << mylegend->GetX1() << " " << mylegend->GetX2() << std::endl; + std::cout << mylegend->GetY1() << " " << mylegend->GetY2() << std::endl; + + TPaveText* toto = new TPaveText(0.17,0.72,0.43,0.83); + toto->SetFillColor(2); + toto->SetTextFont(2); + toto->SetTextSize(0); + toto->AddText("toto"); + toto->Draw(); // To Fit + std::vector sigmas; for (unsigned int i=0;iSetParameter(0,K); fitter->SetParameter(1,MU); fitter->SetParameter(2,SIG); - histos[i].histo->Fit(fitter,"R+"); + histos[i].histo->Fit(fitter,"0"); + sigmas.push_back(fitter->GetParameter(2)); + } + + // Display sigmas + for (unsigned int i=0;iGetWNDC() << std::endl; } // Save std::string filename = GetFileName(histos[0].histo->GetTitle()); mycanvas->SaveAs((filename+".gif").c_str()); + mycanvas->SaveAs((filename+".root").c_str()); + }