ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/IPHCalignment2/analysis/Layout.cpp
(Generate patch)

Comparing UserCode/IPHCalignment2/analysis/Layout.cpp (file contents):
Revision 1.3 by econte, Mon Nov 28 13:18:09 2011 UTC vs.
Revision 1.9 by cgoetzma, Thu Dec 1 13:46:25 2011 UTC

# Line 5 | Line 5
5  
6   void Layout::DrawInit()
7   {
8 <  /*  gStyle->SetCanvasColor(0);
8 >  gStyle->SetCanvasColor(0);
9    gStyle->SetCanvasBorderMode(0);
10    gStyle->SetCanvasBorderSize(3);
11  
# Line 17 | Line 17 | void Layout::DrawInit()
17    gStyle->SetFrameBorderMode(0);
18    gStyle->SetFrameBorderSize(0);
19    gStyle->SetFrameFillColor(0);
20 <  gStyle->SetOptStat(0);
20 >  //  gStyle->SetOptStat(0);
21  
22    gStyle->SetLabelOffset(0.005,"X");
23    gStyle->SetLabelSize(0.03,"X");
# Line 70 | Line 70 | void Layout::DrawInit()
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  
77  
78 < void Layout::Draw(const std::vector<HistoBlock>& histos,
79 <                  const std::string& xlabel, float K, float MU, float SIG)
78 > void Layout::Draw(const std::string title, const std::vector<HistoBlock>& histos,
79 >                  const std::string& xlabel, bool fit, float K, float MU, float SIG)
80   {
81    std::cout << "----------------- Draw : " << histos[0].histo->GetName() << std::endl;
82  
# Line 87 | Line 87 | void Layout::Draw(const std::vector<Hist
87    TCanvas* mycanvas = new TCanvas((std::string(histos[0].histo->GetName())+
88                                    "_canvas").c_str(),
89                                    histos[0].histo->GetTitle());
90
90    // SetLineColor
91    for (unsigned int i=0;i<histos.size();i++)
92    {
94    std::cout << "TEST : " << histos[i].linecolor << std::endl;
93      histos[i].histo->SetLineColor( histos[i].linecolor );
94    }
95  
# Line 110 | Line 108 | void Layout::Draw(const std::vector<Hist
108    float xmax = mystack->GetXaxis()->GetXmin();
109  
110    // Draw legend
111 <  TLegend* mylegend = new TLegend(0.17,0.85-(0.04*histos.size()),0.33,0.85);
111 >  TLegend* mylegend = new TLegend(0.55,0.90-(0.04*histos.size()),0.90,0.90);
112    mylegend->SetFillColor(0);
113    for (unsigned int i=0;i<histos.size();i++)
114    {
# Line 118 | Line 116 | void Layout::Draw(const std::vector<Hist
116                         histos[i].algoName.c_str(),"l");
117    }
118    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;
119  
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);
139    fitter->SetParameter(0,K);
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  }
120  
121 <  // Display sigmas
147 <  for (unsigned int i=0;i<sigmas.size();i++)
121 >  if (fit)
122    {
123 <    std::stringstream str;
124 <    str << "#sigma_{RECO} = ";
125 <    str << sigmas[i];
126 <    TLatex mytext(56,200,str.str().c_str());
127 <    std::cout << mycanvas->GetXlowNDC() << " " << mycanvas->GetWNDC() << std::endl;
123 >    // To Fit
124 >    std::vector<double> sigmas;
125 >    std::vector<double> errors;
126 >    for (unsigned int i=0;i<histos.size();i++)
127 >    {
128 >      TF1* fitter = new TF1(dummy().c_str(),"gaus",xmin,xmax);
129 >      fitter->SetParameter(0,K);
130 >      fitter->SetParameter(1,MU);
131 >      fitter->SetParameter(2,SIG);
132 >      histos[i].histo->Fit(fitter,"0");
133 >      sigmas.push_back(fitter->GetParameter(2));
134 >      errors.push_back(fitter->GetParError(2));
135 >    }
136 >
137 >    // Display sigmas
138 >    TPaveText* myblock = new TPaveText(0.65,0.65-(0.04*histos.size()),0.90,0.65,"NDC");
139 >    myblock->SetBorderSize(0);
140 >    myblock->SetFillColor(0);
141 >    for (unsigned int i=0;i<sigmas.size();i++)
142 >    {
143 >      std::stringstream str;
144 >      str << "#sigma_{" << histos[i].shortName <<"} = ";
145 >      str.precision(3); str << sigmas[i];
146 >      str << " #pm ";
147 >      str.precision(3); str << errors[i];
148 >      TText* mytext = myblock->AddText(str.str().c_str());
149 >      mytext->SetTextColor(histos[i].linecolor);
150 >      mytext->SetTextAlign(11);
151 >    }
152 >    myblock->Draw();
153    }
154  
155    // Save
156 <  std::string filename = GetFileName(histos[0].histo->GetTitle());
156 >  std::string filename = GetFileName(title);
157    mycanvas->SaveAs((filename+".gif").c_str());
158    mycanvas->SaveAs((filename+".root").c_str());
159  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines