]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/EBYE/Fluctuations/macro/compareCentralitySets.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / EBYE / Fluctuations / macro / compareCentralitySets.C
1 //=======================================================================//
2 //Macro to draw the main results of the charge fluctuation analysis:
3 //=======================================================================//
4
5 //+++++++++++++++++++++GLOBAL VARIABLES+++++++++++++++++++++//
6 const Int_t nCentralityBins = 20;
7
8 Double_t gNParticipants20[nCentralityBins] = {382.646,329.213,280.911,238.617,201.81,169.339,141.067,116.208,94.2515,75.4558,59.4054,45.7565,34.4839,25.3127,18.0293,12.6535,8.84139,6.16348,4.37454,3.06182};
9 Double_t gNParticipants20Error[nCentralityBins] = {16.9428,18.0505,17.0971,16.2076,15.5418,14.9458,14.3174,13.9067,13.2661,12.6134,11.8133,11.0495,10.0939,8.99737,7.7884,6.48725,5.21602,3.91988,2.78741,1.75066};
10 Double_t gNParticipants10[nCentralityBins] = {356.132,260.175,185.76,128.428,84.5666,52.3432,29.7072,15.2207,7.47192,3.71973};//10 bins
11 Double_t gNParticipants10Error[nCentralityBins] = {31.8228,26.9093,22.3767,18.8802,15.9735,13.3103,10.5806,7.62745,4.78538,2.41942};//10 bins
12
13 //================================ALICE================================//
14 Double_t gNuDynALICEData20[nCentralityBins] = {10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.};
15 Double_t gNuDynALICEData20Error[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
16 Double_t gNetChargeALICEData20[nCentralityBins] = {10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.};
17 Double_t gNetChargeALICEData20Error[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
18 Double_t gNetChargeRmsALICEData20[nCentralityBins] = {10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.};
19 Double_t gNetChargeRmsALICEData20Error[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
20
21 Double_t gNuDynALICEData10[nCentralityBins] = {10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.};
22 Double_t gNuDynALICEData10Error[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
23 Double_t gNetChargeALICEData10[nCentralityBins] = {10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.};
24 Double_t gNetChargeALICEData10Error[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
25 Double_t gNetChargeRmsALICEData10[nCentralityBins] = {10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.,10.};
26 Double_t gNetChargeRmsALICEData10Error[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
27 //================================ALICE================================//
28 //+++++++++++++++++++++END OF VARIABLES+++++++++++++++++++++//
29
30 //_____________________________________________________//
31 void compareCentralitySets(const char*resultPath1 = "../LHC10h/Pass1_4Plus/20CentralityBins/", const char*resultPath2 = "../LHC10h/Pass1_4Plus/10CentralityBins/") {
32   //Draws the nu_dyn vs centrality percentile
33   SetDataPoints(resultPath1,resultPath2);
34   //================================================//
35   //ALICE PbPb @ 2.76 TeV
36   TGraphErrors *grALICEData20Nudyn = new TGraphErrors(nCentralityBins,
37                                                     gNParticipants20,
38                                                     gNuDynALICEData20,
39                                                     gNParticipants20Error,
40                                                     gNuDynALICEData20Error);
41   grALICEData20Nudyn->SetMarkerStyle(20);
42   grALICEData20Nudyn->SetMarkerColor(2);
43
44   TGraphErrors *grALICEData20NetCharge = new TGraphErrors(nCentralityBins,
45                                                         gNParticipants20,
46                                                         gNetChargeALICEData20,
47                                                         gNParticipants20Error,
48                                                         gNetChargeALICEData20Error);
49   grALICEData20NetCharge->SetMarkerStyle(20);
50   grALICEData20NetCharge->SetMarkerColor(2);
51
52   TGraphErrors *grALICEData20NetChargeRms = new TGraphErrors(nCentralityBins,
53                                                            gNParticipants20,
54                                                            gNetChargeRmsALICEData20,
55                                                            gNParticipants20Error,
56                                                            gNetChargeRmsALICEData20Error);
57   grALICEData20NetChargeRms->SetMarkerStyle(20);
58   grALICEData20NetChargeRms->SetMarkerColor(2);
59
60   //10 bins
61   TGraphErrors *grALICEData10NetCharge = new TGraphErrors(nCentralityBins,
62                                                         gNParticipants10,
63                                                         gNetChargeALICEData10,
64                                                         gNParticipants10Error,
65                                                         gNetChargeALICEData10Error);
66   grALICEData10NetCharge->SetMarkerStyle(24);
67   grALICEData10NetCharge->SetMarkerColor(2);
68
69   TGraphErrors *grALICEData10NetChargeRms = new TGraphErrors(nCentralityBins,
70                                                            gNParticipants10,
71                                                            gNetChargeRmsALICEData10,
72                                                            gNParticipants10Error,
73                                                            gNetChargeRmsALICEData10Error);
74   grALICEData10NetChargeRms->SetMarkerStyle(24);
75   grALICEData10NetChargeRms->SetMarkerColor(2);
76
77   TGraphErrors *grALICEData10Nudyn = new TGraphErrors(nCentralityBins,
78                                                     gNParticipants10,
79                                                     gNuDynALICEData10,
80                                                     gNParticipants10Error,
81                                                     gNuDynALICEData10Error);
82   grALICEData10Nudyn->SetMarkerStyle(24);
83   grALICEData10Nudyn->SetMarkerColor(2);
84   
85   //_____________________________________________________//
86   //Draw the results
87   //_____________________________________________________//
88   TLatex *latex = new TLatex();
89   latex->SetTextSize(0.035);
90
91   //====================================//
92   //Results vs centrality
93   TH2F *gEmpty1 = new TH2F("gEmpty1",
94                            ";N_{part.};",
95                            100,0,400,10000,-0.1,50.);
96   gEmpty1->SetStats(kFALSE);
97   gEmpty1->GetYaxis()->SetTitleOffset(1.5);
98   gEmpty1->GetXaxis()->SetTitleOffset(1.5);
99   gEmpty1->GetYaxis()->SetNdivisions(10);
100   gEmpty1->GetXaxis()->SetNdivisions(10);
101
102   TF1 *f1 = new TF1("f1","0",0,1000);
103   f1->SetLineColor(1); f1->SetLineStyle(3); f1->SetLineWidth(2);
104
105   //============================================================//
106   //nu_{dyn.}
107   TCanvas *c1 = new TCanvas("c1","Centrality dependence: nu_dyn",
108                             0,0,500,500);
109   c1->SetFillColor(10); c1->SetHighLightColor(10);
110   c1->SetLeftMargin(0.15); c1->SetBottomMargin(0.15);
111   c1->SetGridx(); c1->SetGridy();
112   gEmpty1->GetYaxis()->SetRangeUser(-0.08,0.01);
113   gEmpty1->GetYaxis()->SetTitle("#nu_{dyn.}");
114   gEmpty1->DrawCopy();
115   f1->Draw("same");
116   grALICEData20Nudyn->Draw("P");
117   grALICEData10Nudyn->Draw("P");
118
119   DrawMarker(140., -0.043, 20, 1.6, 2);
120   latex->DrawLatex(150.,-0.0445,"20 centrality bins");
121   DrawMarker(140., -0.05, 24, 1.6, 2);
122   latex->DrawLatex(150.,-0.0515,"10 centrality bins");
123
124   c1->SaveAs("comparissonCentralitySetsNparticipantsDependenceNuDyn.png");
125
126   //============================================================//
127   //net charge
128   TCanvas *c2 = new TCanvas("c2","Centrality dependence: net charge",
129                             100,100,500,500);
130   c2->SetFillColor(10); c2->SetHighLightColor(10);
131   c2->SetLeftMargin(0.15); c2->SetBottomMargin(0.15);
132   c2->SetGridx(); c2->SetGridy();
133   gEmpty1->GetYaxis()->SetRangeUser(0.0,10.0);
134   gEmpty1->GetYaxis()->SetTitle("#LT #Delta Q = N_{+} - N_{-}#GT");
135   gEmpty1->DrawCopy();
136   grALICEData20NetCharge->Draw("P");
137   grALICEData10NetCharge->Draw("P");
138
139   DrawMarker(40., 8.3, 20, 1.6, 2);
140   latex->DrawLatex(50.,8.1,"20 centrality bins");
141   DrawMarker(40., 7.3, 24, 1.6, 2);
142   latex->DrawLatex(50.,7.1,"10 centrality bins");
143
144   c2->SaveAs("comparissonCentralitySetsNparticipantsDependenceNetCharge.png");
145
146   //============================================================//
147   //rms net charge
148   TCanvas *c3 = new TCanvas("c3","Centrality dependence: net charge rms",
149                             200,200,500,500);
150   c3->SetFillColor(10); c3->SetHighLightColor(10);
151   c3->SetLeftMargin(0.15); c3->SetBottomMargin(0.15);
152   c3->SetGridx(); c3->SetGridy();
153   gEmpty1->GetYaxis()->SetRangeUser(0.0,40.0);
154   gEmpty1->GetYaxis()->SetTitle("#sigma_{#Delta Q}");
155   gEmpty1->DrawCopy();
156   grALICEData20NetChargeRms->Draw("P");
157   grALICEData10NetChargeRms->Draw("P");
158
159   DrawMarker(40., 38., 20, 1.6, 2);
160   latex->DrawLatex(50.,37.5,"20 centrality bins");
161   DrawMarker(40., 34., 24, 1.6, 2);
162   latex->DrawLatex(50.,33.5,"10 centrality bins");
163
164   c3->SaveAs("comparissonCentralitySetsNparticipantsDependenceNetChargeRms.png");
165 }
166
167 //_______________________________________________________________//
168 void SetDataPoints(const char* resultPath1,
169                    const char* resultPath2) {
170   //Calculate the mean and the statistical error of the data points
171   const Int_t nRuns = 7;
172   Double_t nuDyn[nRuns][nCentralityBins];
173   Double_t gNetCharge[nRuns][nCentralityBins];
174   Double_t gNetChargeRms[nRuns][nCentralityBins];
175   Double_t nuDyn[nRuns][nCentralityBins];
176   Int_t nEvents[nRuns][nCentralityBins];
177   Int_t nRunNumbers[nRuns] = {137161,137431,137549,
178                               137595,137638,137639,137693};
179   Int_t gCentrality;
180   Double_t netChargeValues[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
181                                            0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
182   Double_t netChargeValuesError[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,
183                                                     0.,0.,0.,0.,0.,0.,0.,0.,
184                                                     0.,0.,0.,0.};
185   Double_t netChargeRmsValues[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,
186                                                   0.,0.,0.,0.,0.,0.,0.,
187                                                   0.,0.,0.,0.,0.,0.};
188   Double_t netChargeRmsValuesError[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,
189                                                        0.,0.,0.,0.,0.,0.,0.,0.,
190                                                     0.,0.,0.,0.};
191   Double_t nuDynValues[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
192                                            0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
193   Double_t nuDynValuesError[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
194                                                 0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
195   Double_t nEventsValues[nCentralityBins] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,
196                                              0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
197
198   //20 centrality bins
199   TString inputFileName;
200   for(Int_t iRun = 0; iRun < nRuns; iRun++) {
201     ifstream inputAscii20;
202     Printf("Adding run %d",nRunNumbers[iRun]);
203     inputFileName = resultPath1;
204     inputFileName += "/output."; inputFileName += nRunNumbers[iRun];
205     inputFileName += ".txt";
206
207     Printf("Filename: %s",inputFileName.Data());
208     inputAscii20.open(inputFileName.Data());
209     for(Int_t iCentrality = 0; iCentrality < nCentralityBins; iCentrality++) {
210       inputAscii20>>gCentrality>>nuDyn[iRun][iCentrality]>>gNetCharge[iRun][iCentrality]>>gNetChargeRms[iRun][iCentrality]>>nEvents[iRun][iCentrality];
211       cout<<nuDyn[iRun][iCentrality]<<" "<<nEvents[iRun][iCentrality]<<endl;
212     }
213     inputAscii20.close();
214   }
215
216   Int_t nRunCounter = 0;
217   for(Int_t iCentrality = 0; iCentrality < nCentralityBins; iCentrality++) {
218     for(Int_t iRun = 0; iRun < nRuns; iRun++) {
219       nuDynValues[iCentrality] += nuDyn[iRun][iCentrality]*nEvents[iRun][iCentrality];
220       netChargeValues[iCentrality] += gNetCharge[iRun][iCentrality]*nEvents[iRun][iCentrality];
221       netChargeRmsValues[iCentrality] += gNetChargeRms[iRun][iCentrality]*nEvents[iRun][iCentrality];
222       nEventsValues[iCentrality] += nEvents[iRun][iCentrality];
223     }
224
225     if(nEventsValues[iCentrality] != 0) {
226       nRunCounter += 1;
227
228       netChargeValues[iCentrality] /= nEventsValues[iCentrality];
229       netChargeRmsValues[iCentrality] /= nEventsValues[iCentrality];
230       nuDynValues[iCentrality] /= nEventsValues[iCentrality];
231     }
232     else {
233       netChargeValues[iCentrality] = 999.;
234       netChargeRmsValues[iCentrality] = 999.;
235       nuDynValues[iCentrality] = 999.;
236     }
237
238     gNetChargeALICEData20[iCentrality] = netChargeValues[iCentrality];
239     gNetChargeRmsALICEData20[iCentrality] = netChargeRmsValues[iCentrality];
240     gNuDynALICEData20[iCentrality] = nuDynValues[iCentrality];
241   }
242
243   for(Int_t iCentrality = 0; iCentrality < nCentralityBins; iCentrality++) {
244     for(Int_t iRun = 0; iRun < nRuns; iRun++) {
245       netChargeValuesError[iCentrality] += TMath::Power((netChargeValues[iCentrality]-gNetCharge[iRun][iCentrality]),2);
246       netChargeRmsValuesError[iCentrality] += TMath::Power((netChargeRmsValues[iCentrality]-gNetChargeRms[iRun][iCentrality]),2);
247       nuDynValuesError[iCentrality] += TMath::Power((nuDynValues[iCentrality]-nuDyn[iRun][iCentrality]),2);
248     }
249     gNetChargeALICEData20Error[iCentrality] = TMath::Sqrt(netChargeValuesError[iCentrality]/(nRunCounter*(nRunCounter-1)));
250     gNetChargeRmsALICEData20Error[iCentrality] = TMath::Sqrt(netChargeRmsValuesError[iCentrality]/(nRunCounter*(nRunCounter-1)));
251     gNuDynALICEData20Error[iCentrality] = TMath::Sqrt(nuDynValuesError[iCentrality]/(nRunCounter*(nRunCounter-1)));
252     Printf("Centrality: %d - nu_dyn: %lf +- %lf - Net charge: %lf +- %lf - RMS: %lf - %lf",iCentrality+1,
253            gNuDynALICEData20[iCentrality],
254            gNuDynALICEData20Error[iCentrality],
255            gNetChargeALICEData20[iCentrality],
256            gNetChargeALICEData20Error[iCentrality],
257            gNetChargeRmsALICEData20[iCentrality],
258            gNetChargeRmsALICEData20Error[iCentrality]);
259   }
260
261   //10 centrality bins
262   nRunCounter = 0;
263   for(Int_t iRun = 0; iRun < nRuns; iRun++) {
264     for(Int_t iCentrality = 0; iCentrality < nCentralityBins; iCentrality++) {
265       nuDyn[iRun][iCentrality] = 0.;
266       gNetCharge[iRun][iCentrality] = 0.;
267       gNetChargeRms[iRun][iCentrality] = 0.;
268       nEvents[iRun][iCentrality] = 0.;
269       nuDynValues[iCentrality] = 0.;
270       netChargeValues[iCentrality] = 0.;
271       netChargeRmsValues[iCentrality] = 0.;
272       nEventsValues[iCentrality] = 0.;
273       netChargeValuesError[iCentrality] = 0.;
274       netChargeRmsValuesError[iCentrality] = 0.;
275       nuDynValuesError[iCentrality] = 0.;
276     }
277   }
278
279   for(Int_t iRun = 0; iRun < nRuns; iRun++) {
280     ifstream inputAscii10;
281     Printf("Adding run %d",nRunNumbers[iRun]);
282     inputFileName = resultPath2;
283     inputFileName += "/output."; inputFileName += nRunNumbers[iRun];
284     inputFileName += ".txt";
285
286     Printf("Filename: %s",inputFileName.Data());
287     inputAscii10.open(inputFileName.Data());
288     for(Int_t iCentrality = 0; iCentrality < nCentralityBins; iCentrality++) {
289       inputAscii10>>gCentrality>>nuDyn[iRun][iCentrality]>>gNetCharge[iRun][iCentrality]>>gNetChargeRms[iRun][iCentrality]>>nEvents[iRun][iCentrality];
290       //cout<<nuDyn[iRun][iCentrality]<<" "<<nEvents[iRun][iCentrality]<<endl;
291     }
292     inputAscii10.close();
293   }
294
295   Int_t nRunCounter = 0;
296   for(Int_t iCentrality = 0; iCentrality < nCentralityBins; iCentrality++) {
297     for(Int_t iRun = 0; iRun < nRuns; iRun++) {
298       nuDynValues[iCentrality] += nuDyn[iRun][iCentrality]*nEvents[iRun][iCentrality];
299       netChargeValues[iCentrality] += gNetCharge[iRun][iCentrality]*nEvents[iRun][iCentrality];
300       netChargeRmsValues[iCentrality] += gNetChargeRms[iRun][iCentrality]*nEvents[iRun][iCentrality];
301       nEventsValues[iCentrality] += nEvents[iRun][iCentrality];
302     }
303
304     if(nEventsValues[iCentrality] != 0) {
305       nRunCounter += 1;
306
307       netChargeValues[iCentrality] /= nEventsValues[iCentrality];
308       netChargeRmsValues[iCentrality] /= nEventsValues[iCentrality];
309       nuDynValues[iCentrality] /= nEventsValues[iCentrality];
310     }
311     else {
312       netChargeValues[iCentrality] = 999.;
313       netChargeRmsValues[iCentrality] = 999.;
314       nuDynValues[iCentrality] = 999.;
315     }
316
317     gNetChargeALICEData10[iCentrality] = netChargeValues[iCentrality];
318     gNetChargeRmsALICEData10[iCentrality] = netChargeRmsValues[iCentrality];
319     gNuDynALICEData10[iCentrality] = nuDynValues[iCentrality];
320   }
321
322   for(Int_t iCentrality = 0; iCentrality < nCentralityBins; iCentrality++) {
323     for(Int_t iRun = 0; iRun < nRuns; iRun++) {
324       netChargeValuesError[iCentrality] += TMath::Power((netChargeValues[iCentrality]-gNetCharge[iRun][iCentrality]),2);
325       netChargeRmsValuesError[iCentrality] += TMath::Power((netChargeRmsValues[iCentrality]-gNetChargeRms[iRun][iCentrality]),2);
326       nuDynValuesError[iCentrality] += TMath::Power((nuDynValues[iCentrality]-nuDyn[iRun][iCentrality]),2);
327     }
328     gNetChargeALICEData10Error[iCentrality] = TMath::Sqrt(netChargeValuesError[iCentrality]/(nRunCounter*(nRunCounter-1)));
329     gNetChargeRmsALICEData10Error[iCentrality] = TMath::Sqrt(netChargeRmsValuesError[iCentrality]/(nRunCounter*(nRunCounter-1)));
330     gNuDynALICEData10Error[iCentrality] = TMath::Sqrt(nuDynValuesError[iCentrality]/(nRunCounter*(nRunCounter-1)));
331     Printf("Centrality: %d - nu_dyn: %lf +- %lf - Net charge: %lf +- %lf - RMS: %lf - %lf",iCentrality+1,
332            gNuDynALICEData10[iCentrality],
333            gNuDynALICEData10Error[iCentrality],
334            gNetChargeALICEData10[iCentrality],
335            gNetChargeALICEData10Error[iCentrality],
336            gNetChargeRmsALICEData10[iCentrality],
337            gNetChargeRmsALICEData10Error[iCentrality]);
338   }
339
340 }
341
342
343 //_______________________________________________________________//
344 void DrawMarker(Double_t x, Double_t y, Int_t style, 
345                 Double_t size, Int_t color) {
346   TMarker *m = new TMarker(x,y,style);
347   m->SetMarkerSize(size);
348   m->SetMarkerColor(color);
349   m->Draw();
350 }