9 #include "TPostScript.h"
16 void drawTower(TH1* h, TF1* f,
int id);
18 void mip_ring_draw(
const char* infile=
"mipskimfile.root",
const char* postscript=
"mipring.ps",
const char* outname=
"2008mipring.root")
20 const int nrings = 40;
23 TH1* ring_histo[nrings];
24 TH1F* ringMIP =
new TH1F(
"ringMIP",
"",nrings,-1.0,1.0);
25 ringMIP->SetXTitle(
"#eta");
26 ringMIP->SetYTitle(
"MIP peak (ADC)");
27 for(
int i = 0; i < nrings; i++)
29 sprintf(name,
"ring_histo_%i",i+1);
30 ring_histo[i] = (TH1F*)input.Get(name);
34 TPostScript* ps =
new TPostScript(postscript);
35 TCanvas* c =
new TCanvas(
"c",
"",100,100,600.,800.);
41 TF1 *gaussian_fit[nrings], *landau_fit[nrings];
42 for(
int i=0; i<nrings; i++){
52 cout<<
"fitting ring "<<i+1<<
" of "<<nrings<<endl;
54 sprintf(name,
"fit_%i",i+1);
56 gaussian_fit[i] =
new TF1(name,
"gaus",7.,45.);
57 landau_fit[i] =
new TF1(name,
"landau",7.,200.);
59 gaussian_fit[i]->SetParameter(1,20.);
60 gaussian_fit[i]->SetParameter(2,5.);
62 landau_fit[i]->SetParameter(1,17.);
63 landau_fit[i]->SetParameter(2,3.);
65 gaussian_fit[i]->SetLineColor(kGreen);
66 gaussian_fit[i]->SetLineWidth(0.6);
68 landau_fit[i]->SetLineColor(kYellow);
69 landau_fit[i]->SetLineWidth(0.6);
71 ring_histo[i]->Fit(gaussian_fit[i],
"rq");
72 ring_histo[i]->GetXaxis()->SetRangeUser(3.0,50.0);
74 drawTower(ring_histo[i],gaussian_fit[i],i);
76 double histogram_top = ring_histo[i]->GetBinContent(ring_histo[i]->GetMaximumBin());
78 double gaussian_mean = gaussian_fit[i]->GetParameter(1);
79 TLine *gaussian_peak =
new TLine(gaussian_mean,0.,gaussian_mean,histogram_top+15);
80 gaussian_peak->SetLineColor(kGreen);
81 gaussian_peak->SetLineWidth(2.0);
82 gaussian_peak->Draw(
"same");
85 float eta = (float)((i - 20) * 2 + 1)/40;
86 float theta = 2*TMath::ATan(TMath::Exp(-eta));
87 float mipenergy = 0.264 * (1+0.056*eta*eta)/TMath::Sin(theta);
88 cout<<mipenergy/gaussian_mean<<
", ";
89 ringMIP->Fill(eta,gaussian_mean);
90 ringMIP->SetBinError(i+1,gaussian_fit[i]->GetParError(1));
99 ringMIP->SetMarkerStyle(20);
100 ringMIP->GetYaxis()->SetRangeUser(0,35);
101 gStyle->SetOptStat(0);
106 TFile outfile(outname,
"RECREATE");
107 for(
int i = 0; i < nrings; i++)
109 ring_histo[i]->Write();
115 void drawTower(TH1* h, TF1* f,
int id){
130 sprintf(line_name,
"mip_peak_%i",
id);
137 char tower_title[100];
138 float eta = (float)((
id - 20) * 2 + 1)/40;
139 sprintf(tower_title,
"eta = %f",eta);
141 title_latex.SetTextSize(0.15);
144 title_latex.DrawTextNDC(0.13,0.78,tower_title);