update for 2012-02-27 meeting.
[u/mrichter/AliRoot.git] / PWGGA / PHOSTasks / PHOS_PbPb / macros / production / DrawPSBSFitParams.C
1 #include "TCanvas.h"
2
3
4
5 namespace RawProduction {
6   class Output;
7 }
8
9
10 void DrawAbs(const RawProduction::Output& output, const char* trigger, int cent, TStringToken& names) 
11 {
12   names.NextToken();
13
14   const char* pid = "All";
15   char canvName[256] = Form("PSBS_Abs_%s_c%03i_%s_%s", trigger, cent, pid, names.Data());
16   TCanvas* canv = new TCanvas(canvName, canvName);  
17   TLegend* leg = new TLegend(0.6,0.8,0.95,0.95);
18
19   TH1* hist = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, pid, names.Data()));
20   if(names.Contains("mr")) hist->SetTitle(Form("Peak Position, %s, %s, %s", trigger, RawProduction::GetCentString(cent), pid));
21   if(names.Contains("sr")) hist->SetTitle(Form("Peak Width, %s, %s, %s", trigger, RawProduction::GetCentString(cent), pid));
22   if(names.Contains("mr")) hist->GetYaxis()->SetRangeUser(0.12, 0.15);
23   if(names.Contains("mr")) hist->GetYaxis()->SetTitle("Peak #mu");
24   if(names.Contains("sr")) hist->GetYaxis()->SetRangeUser(0., 0.012);
25   if(names.Contains("sr")) hist->GetYaxis()->SetTitle("Peak #sigma");
26   hist->GetXaxis()->SetTitle("p_{T}");
27   //Printf(hist->GetTitle());
28   hist->SetMarkerStyle(21);
29   //hist->SetMarkerSize(1.5);
30   hist->SetMarkerColor(kBlack);
31   hist->SetLineColor(kBlack);
32   hist->Draw();
33   leg->AddEntry(hist, "Pol1, Ratio", "lep");
34   
35   int marker = 21;
36   Color_t color[3] = {kRed, kBlue, kMagenta};
37   while( names.NextToken() ) {
38     hist = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "All", names.Data()));
39     //Printf(hist->GetName());
40     hist->SetMarkerStyle(++marker);
41     hist->SetMarkerColor(color[marker-22]);
42     hist->SetLineColor(color[marker-22]);
43     hist->Draw("same");
44     char legName[256] = "";
45     if(names.Contains("1")) sprintf(legName, "Pol1");
46     if(names.Contains("2")) sprintf(legName, "Pol2");
47     if( marker <23 ) sprintf(legName, "%s, Ratio", legName);
48     leg->AddEntry(hist, legName, "lep");
49   }
50   
51   hist = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, pid, names.Data()));
52   hist->Draw("same");
53
54   leg->Draw();
55   
56   canv->SaveAs(Form("imgs/%s.png", canvName));
57   canv->SaveAs(Form("imgs/%s.pdf", canvName));
58 }
59
60 void DrawRatios(const RawProduction::Output& output, const char* trigger, int cent)
61 {
62   TStringToken graphs("mr1;sr1;mr1r;sr1r;mr2;sr2;mr2r;sr2r", ";");
63   while( graphs.NextToken() ) {
64     const char* graph = graphs.Data();
65
66     // ratio
67     TCanvas* canv = new TCanvas(Form("%s_c%03i_%s_ratio", trigger, cent, graph), Form("%s_c%03i_%s_ratio", trigger, cent, graph));
68     TLegend* leg = new TLegend(0.6,0.8,0.95,0.95);
69
70     hAll = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "All", graph));
71
72
73     TH1* hist = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "CPV", graph));
74     hist = (TH1*) hist->Clone(Form("dAll_%s", hist->GetName()));
75     if(graphs.Contains("mr1")) hist->SetTitle( "Peak Position, Pol1" );
76     if(graphs.Contains("mr2")) hist->SetTitle( "Peak Position, Pol2" );
77     if(graphs.Contains("mr1r")) hist->SetTitle( "Peak Position, Pol1, Ratio" );
78     if(graphs.Contains("mr2r")) hist->SetTitle( "Peak Position, Pol2, Ratio" );
79     if(graphs.Contains("sr1")) hist->SetTitle( "Peak Width, Pol1" );
80     if(graphs.Contains("sr2")) hist->SetTitle( "Peak Width, Pol2" );
81     if(graphs.Contains("sr1r")) hist->SetTitle( "Peak Width, Pol1, Ratio" );
82     if(graphs.Contains("sr2r")) hist->SetTitle( "Peak Width, Pol2, Ratio" );
83     hist->SetTitle(Form("%s, %s, centrality: %s", hist->GetTitle(), trigger, RawProduction::GetCentString(cent)));
84     if(graphs.Contains("mr")) hist->GetYaxis()->SetRangeUser(0.9, 1.05);
85     if(graphs.Contains("mr")) hist->GetYaxis()->SetTitle("Peak #mu");
86     if(graphs.Contains("sr")) hist->GetYaxis()->SetRangeUser(0.4, 1.4);
87     if(graphs.Contains("sr")) hist->GetYaxis()->SetTitle("Peak #sigma");
88     hist->GetXaxis()->SetTitle("p_{T}");
89     hist->Divide(hAll);
90     hist->SetMarkerStyle(22);
91     hist->SetMarkerColor(kRed);
92     hist->SetLineColor(kRed);
93     hist->Draw();
94     leg->AddEntry(hist, "CPV/All", "lep");
95
96     hist = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "Disp", graph));
97     hist = (TH1*) hist->Clone(Form("dAll_%s", hist->GetName()));
98     hist->Divide(hAll);
99     hist->SetMarkerStyle(23);
100     hist->SetMarkerColor(kBlue);
101     hist->SetLineColor(kBlue);
102     hist->Draw("same");
103     leg->AddEntry(hist, "Disp/All", "lep");
104
105     hist = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "Both", graph));
106     hist = (TH1*) hist->Clone(Form("dAll_%s", hist->GetName()));
107     hist->Divide(hAll);
108     hist->SetMarkerStyle(21);
109     hist->SetMarkerColor(kMagenta);
110     hist->SetLineColor(kMagenta);
111     hist->Draw("same");
112     leg->AddEntry(hist, "Both/All", "lep");
113
114     
115     leg->Draw();
116
117     canv->SaveAs(Form("imgs/PSBSFits_ratio_%s_c%03i_%s.png", trigger, cent, graph));
118     canv->SaveAs(Form("imgs/PSBSFits_ratio_%s_c%03i_%s.pdf", trigger, cent, graph));
119     
120
121
122
123     // core, ratio
124     canv = new TCanvas(Form("%s_c%03i_%s_ratio_core", trigger, cent, graph), Form("%s_c%03i_%s_ratio_core", trigger, cent, graph));
125     leg = new TLegend(0.6,0.8,0.95,0.95);
126
127     hAll = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "All", graph));
128
129     hAllcore = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "Allcore", graph));
130
131     hist = hAllcore;
132     hist = (TH1*) hist->Clone(Form("dAll_%s", hist->GetName()));
133     hist->Divide(hAll);
134     if(graphs.Contains("r1")) hist->SetTitle( Form("%s, Pol1", hist->GetTitle()) );
135     if(graphs.Contains("r2")) hist->SetTitle( Form("%s, Pol2", hist->GetTitle()) );
136     hist->SetTitle(Form("%s, %s, centrality: %s", hist->GetTitle(), trigger, RawProduction::GetCentString(cent)));
137     if(graphs.Contains("mr")) hist->GetYaxis()->SetRangeUser(0.9, 1.05);
138     if(graphs.Contains("mr")) hist->GetYaxis()->SetTitle("Peak #mu");
139     if(graphs.Contains("sr")) hist->GetYaxis()->SetRangeUser(0.4, 1.4);
140     if(graphs.Contains("sr")) hist->GetYaxis()->SetTitle("Peak #sigma");
141     hist->GetXaxis()->SetTitle("p_{T}");
142     hist->SetMarkerStyle(20);
143     hist->SetMarkerColor(kBlack);
144     hist->SetLineColor(kBlack);
145     hist->Draw();
146     leg->AddEntry(hist, "Allcore/All", "lep");
147
148     hist = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "CPVcore", graph));
149     hist = (TH1*) hist->Clone(Form("dAllcore_%s", hist->GetName()));
150     hist->Divide(hAllcore);
151     hist->SetMarkerStyle(22);
152     hist->SetMarkerColor(kRed);
153     hist->SetLineColor(kRed);
154     hist->Draw("same");
155     leg->AddEntry(hist, "CPVcore/Allcore", "lep");
156
157     hist = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "Dispcore", graph));
158     hist = (TH1*) hist->Clone(Form("dAllcore_%s", hist->GetName()));
159     hist->Divide(hAllcore);
160     hist->SetMarkerStyle(23);
161     hist->SetMarkerColor(kBlue);
162     hist->SetLineColor(kBlue);
163     hist->Draw("same");
164     leg->AddEntry(hist, "Dispcore/Allcore", "lep");
165
166     hist = output.GetHistogram(Form("%s/c%03i/%s/%s", trigger, cent, "Bothcore", graph));
167     hist = (TH1*) hist->Clone(Form("dAllcore_%s", hist->GetName()));
168     hist->Divide(hAllcore);
169     hist->SetMarkerStyle(21);
170     hist->SetMarkerColor(kMagenta);
171     hist->SetLineColor(kMagenta);
172     hist->Draw("same");
173     leg->AddEntry(hist, "Bothcore/Allcore", "lep");
174
175     
176     leg->Draw();
177
178     canv->SaveAs(Form("imgs/PSBSFits_ratio_core_%s_c%03i_%s.png", trigger, cent, graph));
179     canv->SaveAs(Form("imgs/PSBSFits_ratio_core_%s_c%03i_%s.pdf", trigger, cent, graph));
180     
181   }
182 }
183
184
185 void DrawPSBSFitMethodeParams(const RawProduction::Output& output, const char* trigger, int cent)
186 {
187   TStringToken mrst("mr1r;mr2r;mr1;mr2", ";");
188   DrawAbs(output, trigger, cent, mrst);
189
190   TStringToken srst("sr1r;sr2r;sr1;sr2", ";");
191   DrawAbs(output, trigger, cent, srst);
192   
193     
194   DrawRatios(output, trigger, cent);
195 }
196
197 void DrawPSBSFitParams()
198 {
199   gROOT->LoadMacro("MakeRawProduction.C+g");
200   RawProduction::Output output;
201   gStyle->SetOptStat(0);
202   
203   
204   DrawPSBSFitMethodeParams(output, "kMB", -10);
205   DrawPSBSFitMethodeParams(output, "kPHOSPb", -10);
206
207   DrawPSBSFitMethodeParams(output, "kCentral", -1);
208   DrawPSBSFitMethodeParams(output, "kMB", -1);
209   DrawPSBSFitMethodeParams(output, "kPHOSPb", -1);
210
211   DrawPSBSFitMethodeParams(output, "kSemiCentral", -11);
212   DrawPSBSFitMethodeParams(output, "kMB", -11);
213   DrawPSBSFitMethodeParams(output, "kPHOSPb", -11);
214
215   DrawPSBSFitMethodeParams(output, "kPHOSPb", -6);
216   DrawPSBSFitMethodeParams(output, "kMB", -6);
217 }