]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/Correlations/macros/twoplusone/output_TwoPlusOne.C
Set jet area to jets from lightweight jet finder
[u/mrichter/AliRoot.git] / PWGCF / Correlations / macros / twoplusone / output_TwoPlusOne.C
CommitLineData
c9ae910e 1Float_t gpTMin_T1 = 6.0;
2Float_t gpTMax_T1 = 14.0;
3Float_t gpTMin_T2 = 4.0;
4Float_t gpTMax_T2 = 10.0;
227badde 5Float_t gpTMin_assoc = 1.0;
6Float_t gpTMax_assoc = 4.0;
7Float_t gVertex = 6.9;
c9ae910e 8Float_t gZVtxRange = -1;
48c9fd73 9Float_t gAxis = 0;
10Float_t gBasisSize = 350;
5a9d8759 11Float_t g_phi_bin = 0.51;//0.32;//bins of 0.174532 //maximum is pi/4, because max(delta phi) + 2 alpha < pi/2 (because at Delta phi = pi/2 the number of background triggers are measured)
12Float_t g_eta_bin = 0.39;//bins of 0.2
13//char* path = "PWGCF_TwoPlusOne/addedEvents_";
14char* path = "PWGCF_TwoPlusOne/histosTwoPlusOne";
c9ae910e 15
16void loadlibs()
17{
18 gSystem->Load("libANALYSIS");
19 gSystem->Load("libANALYSISalice");
20 gSystem->Load("libCORRFW");
21 gSystem->Load("libPWGTools");
22 gSystem->Load("libPWGCFCorrelationsBase");
23}
24
227badde 25
48c9fd73 26void* getList(const char* fileName, const char* folder)
c9ae910e 27{
28 file = TFile::Open(fileName);
29 if (!file)
30 return 0;
31
48c9fd73 32 list = (TList*) gFile->Get(folder);
33 //list = (TList*) gFile->Get("PWGCF_TwoPlusOne/histosTwoPlusOne");
c9ae910e 34
35 if (!list)
36 return 0;
48c9fd73 37
38 return list;
c9ae910e 39}
40
227badde 41const char* lastFileName = 0;
42const char* lastFileName2 = 0;
43void* cacheEvent = 0;
44void* cacheEvent2 = 0;
45
46
48c9fd73 47void* GetTwoPlusOne(const char* fileName)
c9ae910e 48{
227badde 49
50 if (lastFileName && strcmp(lastFileName, fileName) == 0){
51 Printf("GetTwoPlusOne --> Using cache for %s", fileName);
52 return cacheEvent;
53 }
54 if (lastFileName2 && strcmp(lastFileName2, fileName) == 0){
55 Printf("GetTwoPlusOne --> Using cache for %s", fileName);
56 return cacheEvent2;
57 }
58 if(lastFileName)
59 lastFileName2 = fileName;
60 else
61 lastFileName = fileName;
62
5a9d8759 63 //list = (TList*) getList(fileName, "PWGCF_TwoPlusOne/histosTwoPlusOne");
64 list = (TList*) getList(fileName, path);
48c9fd73 65
66 AliTwoPlusOneContainer* container = (AliTwoPlusOneContainer*) list->FindObject("AliTwoPlusOneContainer");
c9ae910e 67
48c9fd73 68 if (container->GetData()->GetTrackHist(0)->GetGrid(6)->GetGrid()->GetNbins() == 0)
69 {
70 Printf("We have %d axes", ((AliTHn*) container->GetData()->GetTrackHist(0)->GetNVar()));
71
72 ((AliTHn*) container->GetData()->GetTrackHist(0))->FillParent();
73 ((AliTHn*) container->GetData()->GetTrackHist(0))->DeleteContainers();
74 }
75
227badde 76 if(lastFileName2 && strcmp(lastFileName2, fileName) == 0){
77 cacheEvent2 = container;
78 return cacheEvent2;
79 }
80
81 cacheEvent = container;
82
83 return cacheEvent;
48c9fd73 84}
85
86void* GetPhiCorrelations(const char* fileName)
87{
88 list = (TList*) getList(fileName, "PWG4_PhiCorrelations/histosPhiCorrelations");
89
c9ae910e 90
48c9fd73 91 AliUEHistograms* container = list->FindObject("AliUEHistogramsSame");
c9ae910e 92
48c9fd73 93 if (container->GetUEHist(2)->GetTrackHist(0)->GetGrid(6)->GetGrid()->GetNbins() == 0)
c9ae910e 94 {
48c9fd73 95 Printf("We have %d axes", ((AliTHn*) container->GetUEHist(2)->GetTrackHist(0)->GetNVar()));
c9ae910e 96
48c9fd73 97 ((AliTHn*) container->GetUEHist(2)->GetTrackHist(0))->FillParent();
98 ((AliTHn*) container->GetUEHist(2)->GetTrackHist(0))->DeleteContainers();
c9ae910e 99 }
100
48c9fd73 101 return container;
102}
103
104void* showEvents(const char* fileName, int twoPlusOne = 1)
105{
106 if(twoPlusOne)
5a9d8759 107 //list = (TList*) getList(fileName, "PWGCF_TwoPlusOne/histosTwoPlusOne");
108 list = (TList*) getList(fileName, path);
48c9fd73 109 else
110 list = (TList*) getList(fileName, "PWG4_PhiCorrelations/histosPhiCorrelations");
111
112 TH1F* event_stat = (TH1F*) list->FindObject("eventStat");
113 TCanvas* can = new TCanvas();
114 event_stat->DrawCopy();
115}
116
48c9fd73 117//returns maximum of the flow
227badde 118//flow from 1.0 > |eta| > 1.6 is subtracted from the rest of the histogram
119//the flow in the TH2 is subtracted
48c9fd73 120void subtractFlow(TH2* etaPhi){
121 int firstbin = etaPhi->GetYaxis()->FindBin(1.01);
227badde 122 int lastbin = etaPhi->GetYaxis()->FindBin(1.39);
48c9fd73 123
124 TH1D* etaPhi_proj = etaPhi->ProjectionX("_px", firstbin, lastbin);
125 int usedBins = lastbin - firstbin + 1;
126
227badde 127 firstbin = etaPhi->GetYaxis()->FindBin(-1.39);
48c9fd73 128 lastbin = etaPhi->GetYaxis()->FindBin(-1.01);
129 TH1D* signal2 = etaPhi->ProjectionX("_px2", firstbin, lastbin);
130 usedBins += lastbin - firstbin + 1;
131 etaPhi_proj->Add(signal2, 1.0);
132
133 etaPhi_proj->Scale(1.0/usedBins);
134
135 etaPhi->GetYaxis()->SetRangeUser(-1.0, 1.0);
136
137 for(int i=0;i<=etaPhi->GetNbinsX();i++){
138 double subtract = etaPhi_proj->GetBinContent(i);
139
140 for(int j=0;j<etaPhi->GetNbinsY();j++){
141 double content = etaPhi->GetBinContent(i,j)-subtract;
142 etaPhi->SetBinContent(i,j,content);
143 }
144 }
48c9fd73 145}
146
227badde 147 //use fit method to subtract the baseline if the subtractFlow method doesn't work because of poor statistics
148Double_t subtractBaseline(TH1D* h1_phi){
48c9fd73 149
227badde 150 TF1* fit = new TF1("fit", "[0]", -TMath::Pi()/2+0.01, TMath::Pi()/2-0.01);
48c9fd73 151
227badde 152 h1_phi->Fit("fit", "N", "", -TMath::Pi()/2+0.01, -1.0);
153 Double_t par0 = fit->GetParameter(0);
154
155 h1_phi->Fit("fit", "N", "", 1.0, TMath::Pi()/2-0.01);
156 Double_t par1 = fit->GetParameter(0);
48c9fd73 157
227badde 158 //this is done so that the fit is not drawn
159 //h1_phi->Fit("fit", "0", "", 1.0, TMath::Pi()/2-0.01);
160
161 Double_t subtract = (par0+par1)/2;//h1_phi->GetMinimum();
48c9fd73 162
48c9fd73 163
227badde 164 for(int i=0; i<h1_phi->GetNbinsX(); i++)
165 h1_phi->SetBinContent(i, h1_phi->GetBinContent(i) - subtract);
48c9fd73 166
227badde 167 return subtract;
48c9fd73 168}
169
170
227badde 171void showAllTriggerPt(const char* fileName, Int_t multBinBegin = 5, Int_t multBinEnd = 7, Int_t side = 0){
48c9fd73 172
173 const Int_t pt1_bins_length = 3;
174 //Int_t pt1_bins[pt1_bins_length+1] = {6.0, 8.0, 10.0, 12.0, 14.0};
175 Int_t pt1_bins[pt1_bins_length+1] = {6.0, 8.0, 10.0, 12.0};
176 const Int_t pt2_bins_length = 2;
177 Int_t pt2_bins[pt2_bins_length] = {4.0, 6.0};
178
179 for(Int_t i=0; i<pt1_bins_length; i++){
180 Double_t pt1Minimum = pt1_bins[i];
181 Double_t pt1Maximum = pt1_bins[i+1];
182 for(Int_t j=0; j<pt2_bins_length; j++){
183 Double_t pt2Minimum = pt2_bins[j];
227badde 184 getAnalysis(fileName, pt1Minimum, pt1Maximum, pt2Minimum, gpTMin_assoc, gpTMax_assoc, gVertex, multBinBegin, multBinEnd, side, i, j, 1, 0);
185 }
186 }
187}
188
189void showAllTrigger1Pt(const char* fileName, Int_t multBinBegin = 5, Int_t multBinEnd = 7, Int_t pt2Minimum = 4.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0){
190
191 const Int_t pt1_bins_length = 3;
192 Int_t pt1_bins[pt1_bins_length+1] = {6.0, 8.0, 10.0, 12.0};
193
194 for(Int_t i=0; i<pt1_bins_length; i++){
195 TH1D* near = getAnalysis(fileName, pt1_bins[i], pt1_bins[i+1], pt2Minimum, ptAssocMin, ptAssocMax, gVertex, multBinBegin, multBinEnd, 0, i, 0, 1, 0);
196
197 TH1D* away = getAnalysis(fileName, pt1_bins[i], pt1_bins[i+1], pt2Minimum, ptAssocMin, ptAssocMax, gVertex, multBinBegin, multBinEnd, 1, i, 1, 1, 0);
198 /*
199 near->Divide(near, away);
200 TCanvas* c1 = new TCanvas(Form("can %i %i", i, 0), Form("can %i %i", i, 0), i*gBasisSize+50, 0, gBasisSize, gBasisSize);
201 near->DrawCopy();
202 */
203 }
204
205}
206
207void showAllAssocPt(const char* fileName, Int_t multBinBegin = 0, Int_t multBinEnd = 16, Int_t pt1Minimum = 4.0, Int_t pt1Maximum = 14.0, Int_t pt2Minimum = 2.0){
208
209 //const Int_t ptAssoc_bins_length = 5;
210 //Int_t ptAssoc_bins[ptAssoc_bins_length+1] = {1.0, 2.0, 3.0, 4.0, 6.0, 8.0};
211 const Int_t ptAssoc_bins_length = 3;
212 Int_t ptAssoc_bins[ptAssoc_bins_length+1] = {1.0, 3.0, 6.0, 8.0};
213
214 for(Int_t i=0; i<ptAssoc_bins_length; i++){
215 Int_t draw = 0;
216
217 TH1D* near = getAnalysis(fileName, pt1Minimum, pt1Maximum, pt2Minimum, ptAssoc_bins[i], ptAssoc_bins[i+1], gVertex, multBinBegin, multBinEnd, 0, i, 0, draw, 0)->Clone();
218
219 TH1D* away = getAnalysis(fileName, pt1Minimum, pt1Maximum, pt2Minimum, ptAssoc_bins[i], ptAssoc_bins[i+1], gVertex, multBinBegin, multBinEnd, 1, i, 1, draw, 0)->Clone();
220
221 if(!draw){
222 near->Divide(near, away);
223
224 TCanvas* c1 = new TCanvas(Form("can %i %i", i, 0), Form("can %i %i", i, 0), i*gBasisSize+50, 0, gBasisSize, gBasisSize);
225 near->DrawCopy();
226 //TCanvas* c2 = new TCanvas(Form("can2 %i %i", i, 0), Form("can2 %i %i", i, 0), i*gBasisSize+50, gBasisSize+50, gBasisSize, gBasisSize);
227 //away->DrawCopy();
48c9fd73 228 }
229 }
227badde 230}
231
232void showAllMult(const char* fileName, Int_t pt1Minimum = 4.0, Int_t pt1Maximum = 14.0, Int_t pt2Minimum = 2.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0){
233
234 //in multiplicity this are the bins
235 //standard binning: 0, 1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100.1
236 const Int_t mult_bins_length = 5;
237 //Int_t mult_bins[mult_bins_length+1] = {1, 5, 6, 8, 11, 15};
238 Int_t mult_bins[mult_bins_length+1] = {1, 1, 5, 7, 9, 10};
239
240 for(Int_t i=0; i<mult_bins_length; i++){
241 TH1D* near = getAnalysis(fileName, pt1Minimum, pt1Maximum, pt2Minimum, ptAssocMin, ptAssocMax, gVertex, mult_bins[i], mult_bins[i+1], 0, i, 0, 1, 0);
242
243 TH1D* away = getAnalysis(fileName, pt1Minimum, pt1Maximum, pt2Minimum, ptAssocMin, ptAssocMax, gVertex, mult_bins[i], mult_bins[i+1], 1, i, 1, 1, 0);
244 /*
245 near->Divide(near, away);
246
247 TCanvas* c1 = new TCanvas(Form("can %i %i", i, 0), Form("can %i %i", i, 0), i*gBasisSize+50, 0, gBasisSize, gBasisSize);
248 near->DrawCopy();
249 */
250 }
48c9fd73 251
252}
c9ae910e 253
227badde 254void showMultCompare(const char* filename, Int_t pt1Minimum = 4.0, Int_t pt1Maximum = 14.0, Int_t pt2Minimum = 2.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0, Int_t side = 0, Int_t subtractMixedComb = 1, Int_t subtractFlow = 1){
255
256 TLegend *leg = new TLegend(0.65,0.7,0.85,0.9);
257 leg->SetFillColor(10);
258 leg->SetFillStyle(0);
259 leg->SetBorderSize(0);
260 leg->SetTextFont(gStyle->GetTextFont());
261 leg->SetTextSize(gStyle->GetTextSize()*1.0);
262
263 TH1D* central = getAnalysis(filename, pt1Minimum, pt1Maximum, pt2Minimum, ptAssocMin, ptAssocMax, 6.9, 1, 5, side, 1, 1, 0, subtractMixedComb, subtractFlow);
264
265 TCanvas* multCompare = new TCanvas("multCompare", "multCompare", gBasisSize+100, gBasisSize+50, 2*gBasisSize, 2*gBasisSize);
266 central->SetLineColor(kBlue);
267 leg->AddEntry(central->Clone(),"central","l");
268 subtractBaseline(central);
269 central->DrawCopy();
270
271 TH1D* semiCentral = getAnalysis(filename, pt1Minimum, pt1Maximum, pt2Minimum, ptAssocMin, ptAssocMax, 6.9, 9, 10, side, 1, 1, 0, subtractMixedComb, subtractFlow);
272
273 semiCentral->SetLineColor(kRed);
274 subtractBaseline(semiCentral);
275 semiCentral->DrawCopy("same");
276 leg->AddEntry(semiCentral->Clone(),"semiCentral","l");
277 /*
278 TH1D* peripheral = getAnalysis(filename, pt1Minimum, pt1Maximum, pt2Minimum, ptAssocMin, ptAssocMax, 6.9, 11, 14, side, 1, 1, 0, subtractMixedComb);
279
280 peripheral->SetLineColor(kGreen);
281 leg->AddEntry(peripheral,"peripheral","l");
282 peripheral->DrawCopy("same");
283 */
284
285 leg->Draw("same");
286
287 //show same and mixed event of one vertex and multiplicity bin
288 //getRawAnalysis(filename, pt1Minimum, pt1Maximum, pt2Minimum, ptAssocMin, ptAssocMax, 3, 3);
289}
290
291void showAnalysis(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 2.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t subtractMixedComb = 0, Int_t subtractFlow = 0){
292
293 TLegend* leg = getLegend();
294 Int_t showPlots = 1;
295
296 TH1* near = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, 6.9, multBinBegin, multBinEnd, 0, 1, 1, showPlots, subtractMixedComb, subtractFlow)->Clone();
297 /*
298 subtractFlow(h2_etaPhi);
299 h2_etaPhi->GetYaxis()->SetRangeUser(-1.6, 1.6);//corresponds to the really used eta range
300
301 int firstbin = h2_etaPhi->GetYaxis()->FindBin(-0.59);
302 int lastbin = h2_etaPhi->GetYaxis()->FindBin(0.59);
303
304 TH1D* h1_phi = projectToTH1D(h2_etaPhi, "fully corrected", firstbin, lastbin, 1.0);//last number is triggers
305 */
306 leg->AddEntry(near->Clone(), "near side", "l");
307 if(true) return;
308 TH1* away = getAnalysis(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, 6.9, multBinBegin, multBinEnd, 1, 2, 1, showPlots, subtractMixedComb, subtractFlow);
309 leg->AddEntry(away, "away side", "l");
310
311
312
313 TCanvas* c1 = new TCanvas("can", "can", gBasisSize+50, gBasisSize+50, gBasisSize, gBasisSize);
314 near->DrawCopy();
315
316 away->SetLineColor(kRed);
317 away->DrawCopy("same");
318 leg->Draw("same");
319}
320
321void peakDifference_mult(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 2.0, Int_t subtractMixedComb = 1, Int_t subtractFlow = 1){
322
323 Int_t side = 0;//no effect because here both sides for one multiplicity are shown
324 Int_t mode = 0;
325 peakDifference(fileName, pt1Min, pt1Max, pt2Min, 1, 5, side, 0, mode, subtractMixedComb, subtractFlow);
326 peakDifference(fileName, pt1Min, pt1Max, pt2Min, 9, 10, side, 1, mode, subtractMixedComb, subtractFlow);
327
328}
329
330void peakDifference_side(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 2.0, Int_t subtractMixedComb = 1, Int_t subtractFlow = 1){
331
332 Int_t mult = 0;//no effect because here both multiplicities for one side are shown
333 Int_t mode = 1;
334 peakDifference(fileName, pt1Min, pt1Max, pt2Min, mult, mult, 0, 0, mode, subtractMixedComb, subtractFlow);
335 peakDifference(fileName, pt1Min, pt1Max, pt2Min, mult, mult, 1, 1, mode, subtractMixedComb, subtractFlow);
336
337}
338
339//mode 0 near and away side (two different multiplicities in the two rows)
340//mode 1 central and semi central (near side in top and away side in bottom row)
7db96852 341void peakDifference(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 2.0, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t side = 0, Int_t yPos = 0, Int_t mode = 0, Int_t subtractMixedComb = 1, Int_t subtractFlow = 1, Int_t draw = 0){
227badde 342
2cfcbf43 343 static const int pt_assoc_bins_number = 8;
344 Double_t pt_assoc_bins[pt_assoc_bins_number] = {0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0};
227badde 345 Double_t near_content[pt_assoc_bins_number-1];
346 Double_t away_content[pt_assoc_bins_number-1];
2cfcbf43 347 Double_t onePlusOne_content[pt_assoc_bins_number-1];
227badde 348 Double_t near_error[pt_assoc_bins_number-1];
349 Double_t away_error[pt_assoc_bins_number-1];
2cfcbf43 350 Double_t onePlusOne_error[pt_assoc_bins_number-1];
227badde 351
2cfcbf43 352 Double_t pt_assoc_bin_center[pt_assoc_bins_number-1] = {0.75, 1.5, 2.5, 3.5, 5.0, 7.0, 9.0};
353 Double_t pt_assoc_bin_error[pt_assoc_bins_number-1] = {0.25, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0};
227badde 354
355 for(int i=0; i<pt_assoc_bins_number-1; i++){
356 TH1* near;
357 TH1* away;
2cfcbf43 358 TH1* onePlusOne;
227badde 359 TCanvas* can;
360
361 if(mode==0){
362 near = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 6.9, multBinBegin, multBinEnd, 0, 1, 1, 0, subtractMixedComb, subtractFlow)->Clone();
2cfcbf43 363 away = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 6.9, multBinBegin, multBinEnd, 1, 2, 1, 0, subtractMixedComb, subtractFlow)->Clone();
364 onePlusOne = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 6.9, multBinBegin, multBinEnd, 6, 2, 1, 0, subtractMixedComb, subtractFlow);
7db96852 365 //onePlusOne = (TH1*)getAnalysis(fileName, pt2Min, pt1Min, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 6.9, multBinBegin, multBinEnd, 6, 2, 1, 0, subtractMixedComb, subtractFlow);
227badde 366
367 can = new TCanvas(Form(" %i, mult %i-%i ", i, multBinBegin, multBinEnd), Form(" %i, mult %i-%i ", i, multBinBegin, multBinEnd), i*gBasisSize+100, yPos*(gBasisSize+50), gBasisSize, gBasisSize);
7db96852 368
227badde 369 }else if(mode==1){
370 near = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 6.9, 1, 5, side, 1, 1, 0, subtractMixedComb, subtractFlow)->Clone();
371 away = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 6.9, 9, 10, side, 2, 1, 0, subtractMixedComb, subtractFlow);
372
373 can = new TCanvas(Form(" %i, side %i ", i, side), Form(" %i, side %i ", i, side), i*gBasisSize+50, yPos*(gBasisSize+50), gBasisSize, gBasisSize);
374 }else{
375 Printf("mode does not exist!");
376 return;
377 }
378 away->SetLineColor(kRed);
7db96852 379 if(mode==0)
380 onePlusOne->SetLineColor(kGreen);
227badde 381
382 Int_t bin_start = near->FindBin(-1*g_phi_bin);
383 Int_t bin_end = near->FindBin(g_phi_bin);
384
385 near_content[i] = near->IntegralAndError(bin_start, bin_end, near_error[i]);
386 away_content[i] = away->IntegralAndError(bin_start, bin_end, away_error[i]);
2cfcbf43 387 if(mode==0)
388 onePlusOne_content[i] = onePlusOne->IntegralAndError(bin_start, bin_end, onePlusOne_error[i]);
227badde 389
390 ((TH1*)(near->Clone()))->DrawCopy();
391 ((TH1*)(away->Clone()))->DrawCopy("same");
7db96852 392 if(mode==0)
393 ((TH1*)(onePlusOne->Clone()))->DrawCopy("same");
227badde 394
395 if(i==4){
396 TLegend* leg = getLegend();
397 if(mode==0){
398 leg->AddEntry(near,"near side","l");
399 leg->AddEntry(away,"away side","l");
2cfcbf43 400 leg->AddEntry(onePlusOne, "1plus1", "l");
227badde 401 }else if(mode==1){
402 leg->AddEntry(near,"central","l");
403 leg->AddEntry(away,"semi central","l");
404 }
405 leg->Draw("same");
406 }
407 }
408
2cfcbf43 409 double sum_near = 0;
410 double sum_away = 0;
411 double sum_1plus1 = 0;
412 double err_near = 0;
413 double err_away = 0;
414 double err_1plus1 = 0;
415
227badde 416 for(int i=0; i<pt_assoc_bins_number-1; i++){
417 Double_t diff = near_content[i] - away_content[i];
418 Double_t err = TMath::Sqrt(TMath::Power(near_error[i], 2) + TMath::Power(away_error[i], 2));
419
2cfcbf43 420 if(mode==0){
227badde 421 Printf("near side (%.1f - %.1f): %f +/- %f, away side %f +/- %f, difference: %f +/- %f ", pt_assoc_bins[i], pt_assoc_bins[i+1], near_content[i], near_error[i], away_content[i], away_error[i], diff, err);
2cfcbf43 422 sum_near += near_content[i]*(pt_assoc_bins[i] + pt_assoc_bins[i+1])/2;
423 sum_away += away_content[i]*(pt_assoc_bins[i] + pt_assoc_bins[i+1])/2;
424 sum_1plus1 += onePlusOne_content[i]*(pt_assoc_bins[i] + pt_assoc_bins[i+1])/2;
425 err_near += near_error[i]*(pt_assoc_bins[i] + pt_assoc_bins[i+1])/2;
426 err_away += away_error[i]*(pt_assoc_bins[i] + pt_assoc_bins[i+1])/2;
427 err_1plus1 += onePlusOne_error[i]*(pt_assoc_bins[i] + pt_assoc_bins[i+1])/2;
428 }else
227badde 429 Printf("central (%.1f - %.1f): %f +/- %f, semi central %f +/- %f, difference: %f +/- %f ", pt_assoc_bins[i], pt_assoc_bins[i+1], near_content[i], near_error[i], away_content[i], away_error[i], diff, err);
430 }
431
2cfcbf43 432 if(mode==0){
433 Printf("Near side pT: %f +/- %f", sum_near, err_near);
434 Printf("Away side pT: %f +/- %f", sum_away, err_away);
435 Printf("1plus1 pT: %f +/- %f", sum_1plus1, err_1plus1);
436 }
437
438 //scale content with the bin width
439 for(int i=0; i<pt_assoc_bins_number-1; i++){
440 near_content[i] /= 2*pt_assoc_bin_error[i];
441 near_error[i] /= 2*pt_assoc_bin_error[i];
442 away_content[i] /= 2*pt_assoc_bin_error[i];
443 away_error[i] /= 2*pt_assoc_bin_error[i];
7db96852 444 if(mode==0){
445 onePlusOne_content[i] /= 2*pt_assoc_bin_error[i];
446 onePlusOne_error[i] /= 2*pt_assoc_bin_error[i];
447 }
2cfcbf43 448 }
7db96852 449 /*
450 //divide content by 1+1 content
451 for(int i=0; i<pt_assoc_bins_number-1; i++){
452 near_content[i] /= onePlusOne_content[i];
453 near_error[i] /= onePlusOne_content[i];
454 away_content[i] /= onePlusOne_content[i];
455 away_error[i] /= onePlusOne_content[i];
456 }
457 */
227badde 458 TGraphErrors* graph_near = new TGraphErrors(pt_assoc_bins_number, pt_assoc_bin_center, near_content, pt_assoc_bin_error, near_error);
459 TGraphErrors* graph_away = new TGraphErrors(pt_assoc_bins_number, pt_assoc_bin_center, away_content, pt_assoc_bin_error, away_error);
2cfcbf43 460 TGraphErrors* graph_onePlusone = new TGraphErrors(pt_assoc_bins_number, pt_assoc_bin_center, onePlusOne_content, pt_assoc_bin_error, onePlusOne_error);
227badde 461
462 TCanvas* can_graph = new TCanvas(Form("result %i", yPos), Form("result %i", yPos), pt_assoc_bins_number*gBasisSize+50, yPos*(gBasisSize+50), gBasisSize, gBasisSize);
463
464 graph_near->GetXaxis()->SetTitle("p_{T,assoc} (GeV/c)");
465 graph_near->GetYaxis()->SetTitle("1/N dN/dpT");
466 graph_near->SetMarkerSize(2);
467 graph_near->SetLineWidth(2);
468 graph_near->SetMarkerColor(kBlue);
469 graph_near->SetLineColor(kBlue);
470 graph_near->SetMarkerStyle(20);
471 graph_away->GetXaxis()->SetTitle("p_{T,assoc} (GeV/c)");
472 graph_away->GetYaxis()->SetTitle("1/N dN/dpT");
473 graph_away->SetMarkerSize(2);
474 graph_away->SetLineWidth(2);
475 graph_away->SetMarkerColor(kRed);
476 graph_away->SetLineColor(kRed);
477 graph_away->SetMarkerStyle(22);
478 graph_near->Draw("AP");
479 graph_away->Draw("P");
7db96852 480
481 if(false && mode==0){
482 graph_onePlusone->GetXaxis()->SetTitle("p_{T,assoc} (GeV/c)");
483 graph_onePlusone->GetYaxis()->SetTitle("1/N dN/dpT");
484 graph_onePlusone->SetMarkerSize(2);
485 graph_onePlusone->SetLineWidth(2);
486 graph_onePlusone->SetMarkerColor(kGreen);
487 graph_onePlusone->SetLineColor(kGreen);
488 graph_onePlusone->SetMarkerStyle(22);
489 graph_onePlusone->Draw("P");
490 }
491 gPad->SetLogy();
227badde 492
493 TLegend* leg2 = getLegend();
494 if(mode==0){
495 leg2->AddEntry(graph_near,"near side","l");
496 leg2->AddEntry(graph_away,"away side","l");
2cfcbf43 497 leg2->AddEntry(graph_onePlusone,"1plus1","l");
227badde 498 }else if(mode==1){
499 leg2->AddEntry(graph_near,"central","l");
500 leg2->AddEntry(graph_away,"semi central","l");
501 }
502 leg2->Draw("same");
503
504}
505
506
7db96852 507
508
509
510
511
9c98f458 512void create_peakDifference_pictures(const char* fileName){
513
514 gROOT->SetBatch(kTRUE);
515
516 peakDifference_draw(fileName, 6, 8, 4, 1, 1, 1);
517 peakDifference_draw(fileName, 6, 8, 6, 1, 1, 1);
518 peakDifference_draw(fileName, 8, 10, 4, 1, 1, 1);
519 peakDifference_draw(fileName, 8, 10, 6, 1, 1, 1);
520 peakDifference_draw(fileName, 10, 12, 4, 1, 1, 1);
521 peakDifference_draw(fileName, 10, 12, 6, 1, 1, 1);
522
5a9d8759 523 TCanvas* can = new TCanvas("can_filename", "can_filename");
9c98f458 524 TH1F* mixedDist = getMixedDist(fileName);
525 mixedDist->SetTitle(fileName);
526 mixedDist->Draw("colz");
527 can->SaveAs("pt_spectra/filename.eps");
528
529}
530
531
7db96852 532
533
7db96852 534void peakDifference_draw(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 2.0, Int_t yPos = 0, Int_t subtractMixedComb = 1, Int_t subtractFlow = 1){
535
536 TGraphErrors* graph_central_near = (TGraphErrors*)(peakDifference_graph(fileName, pt1Min, pt1Max, pt2Min, 1, 5, 0, yPos, subtractMixedComb, subtractFlow)->Clone());
537 TGraphErrors* graph_central_away = (TGraphErrors*)(peakDifference_graph(fileName, pt1Min, pt1Max, pt2Min, 1, 5, 1, yPos, subtractMixedComb, subtractFlow)->Clone());
538
539 TGraphErrors* graph_semi_near = (TGraphErrors*)(peakDifference_graph(fileName, pt1Min, pt1Max, pt2Min, 9, 10, 0, yPos, subtractMixedComb, subtractFlow)->Clone());
540 TGraphErrors* graph_semi_away = (TGraphErrors*)(peakDifference_graph(fileName, pt1Min, pt1Max, pt2Min, 9, 10, 1, yPos, subtractMixedComb, subtractFlow)->Clone());
541
542 TCanvas* can_graph = new TCanvas(Form("result %i", yPos), Form("result %i", yPos), gBasisSize+50, yPos*(gBasisSize+50), gBasisSize, gBasisSize);
7db96852 543
9c98f458 544 Int_t elements = 7;
5a9d8759 545
9c98f458 546 Double_t maximum = TMath::MaxElement(elements, graph_central_near->GetY());
547 Printf("maximum of central near is %f ", maximum);
548 Double_t max = TMath::MaxElement(elements, graph_central_away->GetY());
549 Printf("maximum of central away is %f ", max);
550 if(max>maximum) maximum = max;
551 max = TMath::MaxElement(elements, graph_semi_near->GetY());
552 Printf("maximum of semi near is %f ", max);
553 if(max>maximum) maximum = max;
554 max = TMath::MaxElement(elements, graph_semi_away->GetY());
555 Printf("maximum of semi away is %f ", max);
556 if(max>maximum) maximum = max;
557 graph_central_near->SetMaximum(maximum*1.25);
558
559 Double_t minimum = TMath::MinElement(elements, graph_central_near->GetY());
560 Printf("minimum of central near is %f ", minimum);
561 Double_t min = TMath::MinElement(elements, graph_central_away->GetY());
562 Printf("minimum of central away is %f ", min);
563 if(min>0 && min<minimum) minimum = min;
564 min = TMath::MinElement(elements, graph_semi_near->GetY());
565 Printf("minimum of semi near is %f ", min);
566 if(min>0 && min<minimum) minimum = min;
567 min = TMath::MinElement(elements, graph_semi_away->GetY());
568 Printf("minimum of semi away is %f ", min);
569 if(min>0 && min<minimum) minimum = min;
570 graph_central_near->SetMinimum(minimum/1.30);
571
5a9d8759 572
9c98f458 573 graph_central_near->SetTitle(Form("p_{T,assoc} spectrum for %.1f < p_{T,1} < %.1f and %.1f < p_{T,2} < p_{T,1}", pt1Min, pt1Max, pt2Min));
7db96852 574 graph_central_near->Draw("AP");
9c98f458 575
7db96852 576 graph_central_away->SetMarkerColor(kRed);
577 graph_central_away->SetLineColor(kRed);
578 graph_central_away->Draw("P");
5a9d8759 579
7db96852 580 graph_semi_near->SetMarkerColor(kCyan);
581 graph_semi_near->SetLineColor(kCyan);
582 graph_semi_near->Draw("P");
583
584 graph_semi_away->SetMarkerColor(kOrange);
585 graph_semi_away->SetLineColor(kOrange);
586 graph_semi_away->Draw("P");
587
588 gPad->SetLogy();
589
9c98f458 590 TLegend* leg = getLegend(0.40,0.75,0.85,0.9);
7db96852 591 leg->AddEntry(graph_central_near,"central near","l");
592 leg->AddEntry(graph_central_away,"central away side","l");
593 leg->AddEntry(graph_semi_near,"semi central near","l");
594 leg->AddEntry(graph_semi_away,"semi central away","l");
595 leg->Draw("same");
596
9c98f458 597 can_graph->SaveAs(Form("pt_spectra/pt_spectrum_%.0f_%.0f_%.0f.eps", pt1Min, pt1Max, pt2Min));
598
5a9d8759 599 save_graph_ratio(graph_central_near, graph_central_away, graph_semi_near, graph_semi_away, elements, Form("central and semi near over away p_{T,assoc} spectrum for %.1f < p_{T,1} < %.1f and %.1f < p_{T,2} < p_{T,1}", pt1Min, pt1Max, pt2Min), Form("pt_spectra/centralANDsemi_near_away_ratio_%.0f_%.0f_%.0f.eps", pt1Min, pt1Max, pt2Min), "central", "semi central");
9c98f458 600
5a9d8759 601 save_graph_ratio(graph_central_near, graph_semi_near, graph_central_away, graph_semi_away, elements, Form("near and semi central over semi p_{T,assoc} spectrum for %.1f < p_{T,1} < %.1f and %.1f < p_{T,2} < p_{T,1}", pt1Min, pt1Max, pt2Min), Form("pt_spectra/nearANDaway_central_semi_ratio_%.0f_%.0f_%.0f.eps", pt1Min, pt1Max, pt2Min), "near", "away");
9c98f458 602
5a9d8759 603 save_graph_difference(graph_central_near, graph_central_away, graph_semi_near, graph_semi_away, elements, Form("central and semi near minus away p_{T,assoc} spectrum for %.1f < p_{T,1} < %.1f and %.1f < p_{T,2} < p_{T,1}", pt1Min, pt1Max, pt2Min), Form("pt_spectra/centralANDsemi_near_away_diff_%.0f_%.0f_%.0f.eps", pt1Min, pt1Max, pt2Min));
9c98f458 604
9c98f458 605}
606
607
5a9d8759 608void save_graph_ratio(TGraphErrors* first, TGraphErrors* second, TGraphErrors* third, TGraphErrors* forth, const Int_t bins, char* title, char* name, char* legend1, char* legend2){
609
610 Double_t start_x = 0.45;
611 if(legend1=="near")
612 start_x = 0.70;
613
614 TLegend *leg = getLegend(start_x,0.75,0.85,0.9);
615
616 TGraphErrors* graph = (TGraphErrors*)(save_graph_compute(first, second, bins, title, 0, NULL, NULL)->Clone());
617 if(third!=NULL && forth!=NULL){
618 TGraphErrors* graph2 = (TGraphErrors*)(save_graph_compute(third, forth, bins, title, 0, NULL, NULL)->Clone());
9c98f458 619
5a9d8759 620 leg->AddEntry(graph, legend1, "p");
621 leg->AddEntry(graph2, legend2, "p");
622
623 save_graph(graph, graph2, name, 0, leg);
624 }else{
625 save_graph(graph, NULL, name, 0, leg);
626 }
9c98f458 627
7db96852 628}
629
9c98f458 630
5a9d8759 631void save_graph_difference(TGraphErrors* first, TGraphErrors* second, TGraphErrors* third, TGraphErrors* forth, const Int_t bins, char* title, char* name){
632
633 Double_t diff1 = 0;
634 Double_t diff1_err = 0;
635 Double_t diff2 = 0;
636 Double_t diff2_err = 0;
637
638 TGraphErrors* graph = (TGraphErrors*)(save_graph_compute(first, second, bins, title, 1, &diff1, &diff1_err)->Clone());
639 TGraphErrors* graph2 = (TGraphErrors*)(save_graph_compute(third, forth, bins, title, 1, &diff2, &diff2_err)->Clone());
640
641 TLegend *leg = getLegend(0.45,0.15,0.85,0.3);
642 leg->AddEntry(graph, "central", "p");
643 leg->AddEntry(graph2, "semi central", "p");
644 leg->AddEntry(graph, Form("\\Delta E = %.1f \\pm %.1f", diff1, diff1_err),"");
645 leg->AddEntry(graph2, Form("\\Delta E = %.1f \\pm %.1f", diff2, diff2_err),"");
9c98f458 646
5a9d8759 647 save_graph(graph, graph2, name, 1, leg);
9c98f458 648
649}
650
651
652//mode: 0 ratio of the graphs
653//mode: 1 difference of the graphs
5a9d8759 654//returns difference of the graphs
655void save_graph(TGraphErrors* first, TGraphErrors* second, char* name, int mode, TLegend *leg){
656 TCanvas* can_graph_ratio = new TCanvas("can_saveGraph", "can_saveGraph", gBasisSize+50, gBasisSize+50, gBasisSize, gBasisSize);
657 if(mode==0){
658 first->SetMinimum(0.4);
659 first->SetMaximum(1.6);
660 }
661 first->SetMarkerSize(1);
662 first->SetLineWidth(3);
663 first->SetMarkerColor(kBlue);
664 first->SetLineColor(kBlue);
665 first->SetMarkerStyle(20);
666 first->Draw("AP");
667
668 if(second!=NULL){
669 second->SetMarkerSize(1);
670 second->SetLineWidth(3);
671 second->SetMarkerColor(kRed);
672 second->SetLineColor(kRed);
673 second->SetMarkerStyle(20);
674 second->Draw("P");
675 }
676
677 leg->Draw("same");
678
679 can_graph_ratio->SaveAs(name);
680}
681
682TGraphErrors* save_graph_compute(TGraphErrors* first, TGraphErrors* second, const Int_t bins, char* title, int mode, Double_t* diff, Double_t* diff_err){
9c98f458 683 Double_t content_x[bins];
684 Double_t content_y[bins];
685 Double_t x_error[bins];
686 Double_t y_error[bins];
687
688 for(int i=0; i<bins; i++){
689 Double_t error_first;
690 Double_t error_second;
691 first->GetPoint(i, content_x[i], content_y[i]);
692 x_error[i] = first->GetErrorX(i);
693 error_first = first->GetErrorY(i);
694 Double_t content_second;
695 second->GetPoint(i, content_x[i], content_second);
696 error_second = second->GetErrorY(i);
697 if(content_second>0 && error_second>0){
698 if(mode==0){
699 content_y[i] /= content_second;
700 y_error[i] = TMath::Sqrt(TMath::Power(error_first/content_second, 2) + TMath::Power(error_second/content_second*content_y[i], 2));
701 }else if(mode==1){
702 content_y[i] -= content_second;
703 y_error[i] = TMath::Sqrt(TMath::Power(error_first, 2) + TMath::Power(error_second, 2));
704 }else{
705 Printf("calls save graph with no correct mode");
706 return;
707 }
708 }
709 }
5a9d8759 710
711 //if this is mode 1 (difference of the graphs) this calculates the difference of the plots
712 //Double_t diff = 0;
713 //Double_t diff_err = 0;
714 if(mode==1){
715 for(int i=0; i<bins; i++){
716 *diff += content_y[i] * content_x[i];
717 *diff_err += TMath::Power(y_error[i]*content_x[i], 2);
718 }
719 *diff_err = TMath::Sqrt(*diff_err);
9c98f458 720
5a9d8759 721 }
722
9c98f458 723 TGraphErrors* graph = new TGraphErrors(bins, content_x, content_y, x_error, y_error);
724 graph->SetTitle(title);
5a9d8759 725 graph->GetXaxis()->SetTitle("p_{T,assoc} (GeV/c)");
9c98f458 726
5a9d8759 727 return graph;
9c98f458 728}
729
730
7db96852 731TGraphErrors* peakDifference_graph(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 2.0, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t side = 0, Int_t yPos = 0, Int_t subtractMixedComb = 1, Int_t subtractFlow = 1, Int_t draw = 0){
732
733 static const int pt_assoc_bins_number = 8;
734 Double_t pt_assoc_bins[pt_assoc_bins_number] = {0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0};
735 Double_t content[pt_assoc_bins_number-1];
736 Double_t error[pt_assoc_bins_number-1];
737
738 Double_t pt_assoc_bin_center[pt_assoc_bins_number-1] = {0.75, 1.5, 2.5, 3.5, 5.0, 7.0, 9.0};
739 Double_t pt_assoc_bin_error[pt_assoc_bins_number-1] = {0.25, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0};
740
741 for(int i=0; i<pt_assoc_bins_number-1; i++){
742 TH1* near = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 6.9, multBinBegin, multBinEnd, side, 1, 1, 0, subtractMixedComb, subtractFlow)->Clone();
743
744 Int_t bin_start = near->FindBin(-1*g_phi_bin);
745 Int_t bin_end = near->FindBin(g_phi_bin);
746
747 content[i] = near->IntegralAndError(bin_start, bin_end, error[i]);
748 }
749
750 //scale content with the bin width
751 for(int i=0; i<pt_assoc_bins_number-1; i++){
752 content[i] /= 2*pt_assoc_bin_error[i];
753 error[i] /= 2*pt_assoc_bin_error[i];
754 }
755
756 TGraphErrors* graph = new TGraphErrors(pt_assoc_bins_number-1, pt_assoc_bin_center, content, pt_assoc_bin_error, error);
757
758 graph->GetXaxis()->SetTitle("p_{T,assoc} (GeV/c)");
759 graph->GetYaxis()->SetTitle("1/N dN/dpT");
9c98f458 760 graph->SetMarkerSize(1);
7db96852 761 graph->SetLineWidth(3);
762 graph->SetMarkerColor(kBlue);
763 graph->SetLineColor(kBlue);
764 graph->SetMarkerStyle(20);
765
766 return graph;
767
768}
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785void showAll1plus1(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 2.0, Int_t subtractMixedComb = 1, Int_t subtractFlow = 1){
786
787 show1plus1("AnalysisResults_1045.root", pt1Min, pt1Max, 1, 5, 0, subtractFlow);
788
789 show1plus1("AnalysisResults_1045.root", pt1Min, pt1Max, 9, 10, 1, subtractFlow);
790}
791
792void show1plus1(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t yPos = 0, Int_t subtractFlow = 1){
793
794 //for 1+1 there is no mixed comb
795 Int_t subtractMixedComb = 0;
796
797 const int pt1_bins = 2;//(pt1Max-pt1Min)/2;
798 static const int pt1_bins_max = 20;
799
800 if(pt1_bins>pt1_bins_max){
801 printf("error not enough pt1_bins");
802 return;
803 }
804
805 static const int pt_assoc_bins_number = 8;
806 Double_t pt_assoc_bins[pt_assoc_bins_number] = {0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0};
807 Double_t content[pt1_bins_max][pt_assoc_bins_number-1];
808 Double_t error[pt1_bins_max][pt_assoc_bins_number-1];
809
810 Double_t pt_assoc_bin_center[pt_assoc_bins_number-1] = {0.75, 1.5, 2.5, 3.5, 5.0, 7.0, 9.0};
811 Double_t pt_assoc_bin_error[pt_assoc_bins_number-1] = {0.25, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0};
812
813 for(int i=0; i<pt_assoc_bins_number-1; i++){
814 TCanvas* can = new TCanvas(Form("1plus1 %i, pT %i", yPos, i), Form("1plus1 %i, pT %i", yPos, i), i*gBasisSize+50, yPos*(gBasisSize+50), gBasisSize, gBasisSize);
815
816 TLegend *leg = getLegend();
817
818 for(int j=0; j<pt1_bins; j++){
819 double pt1Minimum = pt1Min+j*2.0;
820 TH1D* onePlusOne = (TH1*)getAnalysis(fileName, pt1Minimum, pt1Minimum + 2.0, 0, pt_assoc_bins[i], pt_assoc_bins[i+1], 6.9, multBinBegin, multBinEnd, 6, 2, 1, 0, subtractMixedComb, subtractFlow);
821
822 Int_t bin_start = onePlusOne->FindBin(-1*g_phi_bin);
823 Int_t bin_end = onePlusOne->FindBin(g_phi_bin);
824
825 content[j][i] = onePlusOne->IntegralAndError(bin_start, bin_end, error[j][i]);
826
827 if(j==1)
828 onePlusOne->SetLineColor(kRed);
829 else if(j==2)
830 onePlusOne->SetLineColor(kGreen);
831 else if(j==3)
832 onePlusOne->SetLineColor(kMagenta);
833
834 if(j==0){
835 ((TH1*)(onePlusOne->Clone()))->DrawCopy();
836 }else{
837 ((TH1*)(onePlusOne->Clone()))->DrawCopy("same");
838 }
839
840 leg->AddEntry((TH1*)(onePlusOne->Clone()), Form("pT %.0f", pt1Minimum) ,"l");
841 if(j==pt1_bins-1)
842 leg->Draw("same");
843 }
844 }
845
846
847 TCanvas* can_graph = new TCanvas(Form("result %i", yPos), Form("result %i", yPos), pt_assoc_bins_number*gBasisSize+50, yPos*(gBasisSize+50), gBasisSize, gBasisSize);
848
849 TLegend *leg = getLegend();
850
851 for(int j=0; j<pt1_bins; j++){
852 TGraphErrors* graph = new TGraphErrors(pt_assoc_bins_number, pt_assoc_bin_center, content[j], pt_assoc_bin_error, error[j]);
853
854 graph->GetXaxis()->SetTitle("p_{T,assoc} (GeV/c)");
855 graph->GetYaxis()->SetTitle("1/N dN/dpT");
856 graph->SetMarkerSize(2);
857 graph->SetLineWidth(2);
858 graph->SetMarkerStyle(20);
859
860 if(j==0){
861 //graph->SetMarkerColor(kCyan);
862 //graph->SetLineColor(kCyan);
863 graph->SetMarkerColor(kBlue);
864 graph->SetLineColor(kBlue);
865 (TGraphErrors*)(graph->Clone())->Draw("AP");
866 //(TGraphErrors*)(graph->Clone())->Draw("P");
867 }else if(j==1){
868 //graph->SetMarkerColor(kOrange);
869 //graph->SetLineColor(kOrange);
870 graph->SetMarkerColor(kRed);
871 graph->SetLineColor(kRed);
872 (TGraphErrors*)(graph->Clone())->Draw("P");
873 }else if(j==2){
874 //graph->SetMarkerColor(kMagenta);
875 //graph->SetLineColor(kMagenta);
876 graph->SetMarkerColor(kGreen);
877 graph->SetLineColor(kGreen);
878 (TGraphErrors*)(graph->Clone())->Draw("P");
879 }
880
881 double pt1Minimum = pt1Min+j*2.0;
882 leg->AddEntry((TGraphErrors*)(graph->Clone()),Form("pT %.0f", pt1Minimum),"l");
883 if(j==pt1_bins-1)
884 leg->Draw("same");
885 }
886
887
888}
889
890
227badde 891//does the reading out of the results
892//divides the same event by the mixed events
893//subtracts the mixed combinatorics
7db96852 894TH1D* getAnalysis(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, Double_t pt2Min = 2.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0, Double_t setVertex = 7, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t step = 0, Int_t posX = 1, Int_t posY = 1, Int_t showPlots = 0, Int_t subtractMixedComb = 0, Int_t subtractFlow =0, Int_t* trigger = NULL)
48c9fd73 895{
896 loadlibs();
227badde 897 //to guarantee to pick only the bins from the choosen pt on
898 pt1Min += 0.01;
899 pt1Max -= 0.01;
900 pt2Min += 0.01;
901 ptAssocMin += 0.01;
902 ptAssocMax -= 0.01;
48c9fd73 903
904 AliTwoPlusOneContainer* h = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
905
906 AliUEHist::CFStep step_same = step;//(AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS;
7db96852 907 AliUEHist::CFStep step_mixed = (step%2)+2;//(AliUEHist::CFStep) AliTwoPlusOneContainer::kMixedNS;
908 if(step>=7) step_mixed = ((step+1)%2)+2;
909 AliUEHist::CFStep step_mixedComb = (step%2)+4;//(AliUEHist::CStep) AliTwoPlusOneContainer::kMixedCombNS;
910 AliUEHist::CFStep step_backgroundSame = (step%2)+7;//(AliUEHist::CStep) AliTwoPlusOneContainer::kBackgroundSameNS;
227badde 911
912 AliUEHist::CFStep step_1plus1 = (AliUEHist::CFStep) AliTwoPlusOneContainer::k1plus1;
913 AliUEHist::CFStep step_1plus1_mixed = (AliUEHist::CFStep) AliTwoPlusOneContainer::kMixed1plus1;
48c9fd73 914
48c9fd73 915 h->GetData()->SetPtRange(ptAssocMin, ptAssocMax);
916 h->GetData()->SetPt2Min(pt2Min);
227badde 917 h->GetData()->SetZVtxRange(-1*setVertex, setVertex);
918
919 //GetSumOfRatios2(mixed, step, region, ptLeadMin, ptLeadMax, multBinBegin, multBinEnd, normalizePerTrigger, stepForMixed)
920 TH2D* h2_etaPhi;
921 TH2D* h2_etaPhi_mixedComb;
922 TH2D* h2_etaPhi_backgroundSame;
923
924 //TH2D* h2_etaPhi2;
925 //TH2D* h2_etaPhi_mixedComb2;
926
927 TH1D* h1_phi_cloneProject;
928
929 if(step>=2||!subtractMixedComb){
7db96852 930 Int_t trigger_etaPhi;
2cfcbf43 931 if(step!=6)
7db96852 932 h2_etaPhi = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_same, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kTRUE, step_mixed, &trigger_etaPhi);
2cfcbf43 933 else if(step==6)
7db96852 934 h2_etaPhi = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_1plus1, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kTRUE, step_1plus1_mixed, &trigger_etaPhi);
935
936 if(trigger!=NULL)
937 *trigger = (Int_t)trigger_etaPhi;
227badde 938 }else if(step<2 && subtractMixedComb){
939 Int_t trigger_same;
940 Int_t trigger_mixed_comb;
941 Int_t trigger_background_same;
942
943 h2_etaPhi = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_same, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed, &trigger_same);
944 TH2D* h2_etaPhi_clone = h2_etaPhi->Clone();
945 if(subtractFlow)
946 subtractFlow(h2_etaPhi_clone);
947 h2_etaPhi_clone->Scale(1.0/trigger_same);
948
949 //don't need to use getMixedComb_scaled_backgroundSame, see compareScaledMixedComb which shows that both methods are identical but here getSumOfRatios is used which makes it easier (and safer against errors)
7db96852 950 //the 1+1 analysis can only be used if the full analysis was done within the same pt bins
5a9d8759 951
7db96852 952 if(step==0)
953 h2_etaPhi_mixedComb = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_1plus1, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_1plus1_mixed, &trigger_mixed_comb);
954 else if(step==1)
955 h2_etaPhi_mixedComb = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_1plus1, 0, pt2Min, pt1Min, multBinBegin, multBinEnd, kFALSE, step_1plus1_mixed, &trigger_mixed_comb);
9c98f458 956 else //this is never used, it's the old method of getting the background
9c98f458 957 h2_etaPhi_mixedComb = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_mixedComb, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed, &trigger_mixed_comb);
2cfcbf43 958
227badde 959 h2_etaPhi_backgroundSame = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_backgroundSame, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed, &trigger_background_same);
960
961 //trigger_background_same *= 2;//error in the plots for runs 968 and 973
962 double trigger_ratio = (double)trigger_background_same;
963 if(trigger_mixed_comb>0)
964 trigger_ratio /= trigger_mixed_comb;
965 Printf("trigger mixed comb: %i, trigger background same %i, ratio %f", trigger_mixed_comb, trigger_background_same, trigger_ratio);
966 h2_etaPhi_mixedComb->Scale(trigger_ratio);
967 trigger_mixed_comb = trigger_background_same;
968 Printf("trigger same: %i, trigger mixed comb %i ", trigger_same, trigger_mixed_comb);
969
970 int firstbin = h2_etaPhi->GetYaxis()->FindBin(-1*g_eta_bin);
971 int lastbin = h2_etaPhi->GetYaxis()->FindBin(g_eta_bin);
972
973 if(showPlots==1){
974 TCanvas* can_1 = new TCanvas("sameEvent near side", "sameEvent near side", 100, 50, gBasisSize, gBasisSize);
975 h2_etaPhi->DrawCopy("surf1");
976
977 //TH1D* h1_phi_1 = projectToTH1D(h2_etaPhi, "same near", firstbin, lastbin, trigger_same);
978 TH1D* h1_phi_1 = projectToTH1D(h2_etaPhi, "same near", firstbin, lastbin, 1.0);
979 h1_phi_1->SetLineColor(kRed);
980 //h1_phi_1->DrawCopy();
981
982 TLegend *leg = getLegend();
983 leg->AddEntry(h1_phi_1,"same event","l");
984
985 TCanvas* can_2 = new TCanvas("sameEvent mixed comb", "sameEvent mixed comb", gBasisSize+100, 50, gBasisSize, gBasisSize);
986 h2_etaPhi_mixedComb->DrawCopy("surf1");
987 //TH1D* h1_phi_2 = projectToTH1D(h2_etaPhi_mixedComb, "mixedComb near", firstbin, lastbin, trigger_mixed_comb);
988 TH1D* h1_phi_2 = projectToTH1D(h2_etaPhi_mixedComb, "mixedComb near", firstbin, lastbin, 1.0);
989 Printf(Form("trigger mixed_comb", trigger_mixed_comb));
990 //h1_phi_2->DrawCopy();
991 leg->AddEntry(h1_phi_2->Clone(),"mixed comb","l");
992 //leg->Draw("same");
993 //if(true) return;
994 TCanvas* can_2 = new TCanvas("sameEvent flow subtracted", "sameEvent flow subtracted", 100, 2*(gBasisSize+50), gBasisSize, gBasisSize);
995 //TH2D* h2_etaPhi_clone = h2_etaPhi->Clone(); // is already cloned earlier
996 //subtractFlow(h2_etaPhi_clone);
997
998 h1_phi_cloneProject = projectToTH1D(h2_etaPhi_clone, "same flow subtracted", firstbin, lastbin, trigger_same);
999 h1_phi_cloneProject->DrawCopy();
1000
1001 TCanvas* can_3 = new TCanvas("mixed comb subtracted", "mixed comb subtracted", 2*gBasisSize+100, 2*(gBasisSize+50), gBasisSize, gBasisSize);
1002 h2_etaPhi->Add(h2_etaPhi_mixedComb, -1);
1003 //h2_etaPhi2->Add(h2_etaPhi_mixedComb2, -1);
1004
1005 if(trigger_same-trigger_mixed_comb>0)
1006 h2_etaPhi->Scale(1.0/(trigger_same-trigger_mixed_comb));
1007 //h2_etaPhi2->Scale(1.0/(trigger_same2-trigger_mixed_comb2));
1008
1009 //h2_etaPhi->DrawCopy("surf1");
1010 h1_phi_3 = projectToTH1D(h2_etaPhi, "same minus mixedComb", firstbin, lastbin, 1.0);
1011 //h1_phi_3_b = projectToTH1D(h2_etaPhi2, "same minus mixedComb away", firstbin, lastbin, 1.0);
1012 h1_phi_3->SetLineColor(kRed);
1013 h1_phi_3->DrawCopy();
1014 //h1_phi_3_b->DrawCopy("same");
1015
1016 TLegend* leg2 = getLegend();
1017 leg2->AddEntry(h1_phi_3, "near side", "l");
1018 //leg2->AddEntry(h1_phi_3_b, "away side", "l");
1019 leg2->Draw("same");
1020 }else{
1021
1022 h2_etaPhi->Add(h2_etaPhi_mixedComb, -1);
1023
1024 if(trigger_same-trigger_mixed_comb>0)
1025 h2_etaPhi->Scale(1.0/(trigger_same-trigger_mixed_comb));
1026 //using backgroundSame as correction, can only be used if the used phi and eta bins of the associated particles are very close to the trigger particles
1027 /*
1028 h2_etaPhi->Add(h2_etaPhi_backgroundSame, -1);
1029 h2_etaPhi->Scale(1.0/(trigger_same-trigger_background_same));
1030 */
1031
1032 if(subtractFlow)
1033 subtractFlow(h2_etaPhi_mixedComb);
1034 if(trigger_mixed_comb>0)
1035 h2_etaPhi_mixedComb->Scale(1.0/trigger_mixed_comb);
1036 }
1037
7db96852 1038 if(trigger!=NULL)
1039 *trigger = (Int_t)trigger_same-trigger_mixed_comb;
1040
227badde 1041 }else{
1042 Printf("cannot subtract mixed combinatorics from step %i ", step);
1043 return 0;
1044 }
48c9fd73 1045
227badde 1046 if(subtractFlow)
1047 subtractFlow(h2_etaPhi);
1048 h2_etaPhi->GetYaxis()->SetRangeUser(-1.6, 1.6);//corresponds to the really used eta range
1049
1050 int firstbin = h2_etaPhi->GetYaxis()->FindBin(-1*g_eta_bin);
1051 int lastbin = h2_etaPhi->GetYaxis()->FindBin(g_eta_bin);
1052
1053 TH1D* h1_phi = projectToTH1D(h2_etaPhi, "fully corrected", firstbin, lastbin, 1.0);
1054 //TH1D* h1_phi = projectToTH1D(h2_etaPhi_mixedComb, "fully corrected", firstbin, lastbin, 1.0);//shows background distributions
1055
1056 if(showPlots>0){
1057 TLegend *leg = getLegend();
1058
1059 TCanvas* can_4 = new TCanvas(Form("fully corrected, %i, %i ", posX, posY), Form("fully corrected, %i, %i ", posX, posY), posX*gBasisSize+100, 50, gBasisSize, gBasisSize);
2cfcbf43 1060 h2_etaPhi->GetYaxis()->SetRangeUser(-1.4, 1.4);
227badde 1061 h2_etaPhi->DrawCopy("surf1");
1062 //h2_etaPhi_mixedComb->DrawCopy("surf1");
1063 //h1_phi->DrawCopy();
1064 //h1_phi_cloneProject->SetLineColor(kRed);
1065 //h1_phi_cloneProject->DrawCopy("same");
1066
1067 leg->AddEntry(h1_phi,"with mixed comb","l");
1068 leg->AddEntry(h1_phi_cloneProject,"without mixed comb","l");
48c9fd73 1069
227badde 1070 //leg->Draw("same");
1071 }
1072
1073 if(showPlots==2){
1074 TCanvas* can_5 = new TCanvas(Form("compare projection, %i, %i ", posX, posY), Form("compare projection, %i, %i ", posX, posY), posX*gBasisSize+100, posY*gBasisSize+50, gBasisSize, gBasisSize);
1075 TLegend *leg2 = getLegend();
1076
1077 h1_phi->DrawCopy();
1078 leg2->AddEntry(h1_phi,"chosen correction","l");
1079 TH1D* h1_phi_raw = projectToTH1D(h2_etaPhi_clone, "raw same event", firstbin, lastbin, 1.0);
1080 h1_phi_raw->SetLineColor(kRed);
1081 h1_phi_raw->DrawCopy("same");
1082 leg2->AddEntry(h1_phi_raw,"raw same event","l");
1083 TH1D* h1_phi_mixedComb = projectToTH1D(h2_etaPhi_mixedComb, "mixed comb", firstbin, lastbin, 1.0);
1084 h1_phi_mixedComb->SetLineColor(kGreen);
1085 h1_phi_mixedComb->DrawCopy("same");
1086 leg2->AddEntry(h1_phi_mixedComb,"mixed comb","l");
1087 leg2->Draw("same");
1088 }
1089
1090 return h1_phi;
1091}
48c9fd73 1092
48c9fd73 1093
227badde 1094TH1D* projectToTH1D(TH2D* etaPhi, char* name, int firstbin, int lastbin, int trigger){
1095 // Printf(Form("name %s", name));
48c9fd73 1096
227badde 1097 TH1D* h1_phi_1 = etaPhi->ProjectionX(Form("px_%s", name), firstbin, lastbin);
1098 h1_phi_1->SetLineWidth(3);
1099 h1_phi_1->SetStats(kFALSE);
1100 h1_phi_1->Scale(1.0/trigger);
1101 h1_phi_1->Scale(1.0/(double)(lastbin-firstbin+1));
7db96852 1102 h1_phi_1->Scale(etaPhi->GetYaxis()->GetBinWidth(firstbin));//scale with eta bin width
227badde 1103 h1_phi_1->GetXaxis()->SetRangeUser(-TMath::Pi()/2+0.01, TMath::Pi()/2-0.01);
1104 //h1_phi_1->GetXaxis()->SetRangeUser(-TMath::Pi()/2+0.01, 3*TMath::Pi()/2-0.01);
1105 h1_phi_1->SetYTitle("1/N \\ dN/(d \\Delta \\varphi)");
1106
7db96852 1107 symmetrize(h1_phi_1);
1108 subtractBaseline(h1_phi_1);
227badde 1109
1110 return h1_phi_1;
1111}
1112
9c98f458 1113TLegend* getLegend(double x_start = 0.65, double y_start = 0.7, double x_end = 0.85, double y_end = 0.9){
1114 TLegend *leg = new TLegend(x_start, y_start, x_end, y_end);
227badde 1115 leg->SetFillColor(10);
1116 leg->SetFillStyle(0);
1117 leg->SetBorderSize(0);
1118 leg->SetTextFont(gStyle->GetTextFont());
1119 leg->SetTextSize(gStyle->GetTextSize()*1.0);
1120 return leg;
1121}
1122
7db96852 1123void compareAllBackground(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, Double_t pt2Min = 2.0, Int_t subtractMixedComb = 0, Int_t subtractFlow = 0){
1124
1125 static const int pt_assoc_bins_number = 8;
1126 Double_t pt_assoc_bins[pt_assoc_bins_number] = {0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0};
1127
1128 for(int i=0; i<pt_assoc_bins_number-1; i++){
1129 compareBackground(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 1, 5, i, 0, subtractMixedComb, subtractFlow);
1130 compareBackground(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 9, 10, i, 1, subtractMixedComb, subtractFlow);
1131 }
1132
1133}
1134
1135
1136//compares the background of the mixed comb analysis with the 1+1 background
5a9d8759 1137//statistics for background same is the worst because in each event at 2 places is searched for T2
1138//for mixed comb a lot of events are searched for the second trigger particle
1139//for 1+1 no second trigger particle needs to be found at all so the statistics is the highest
7db96852 1140void compareBackground(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, Double_t pt2Min = 2.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t posX = 1, Int_t posY = 1, Int_t subtractMixedComb = 0, Int_t subtractFlow = 0){
1141
1142 Int_t trigger_mixed_comb=0;
1143 Int_t trigger_1plus1=0;
5a9d8759 1144 Int_t trigger_background_same=0;
1145
1146 TH1D* mixedComb = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, 6.9, multBinBegin, multBinEnd, 4, 1, 1, 0, subtractMixedComb, subtractFlow, &trigger_mixed_comb)->Clone();
7db96852 1147
5a9d8759 1148 TH1D* backgroundSame = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, 6.9, multBinBegin, multBinEnd, 7, 1, 1, 0, subtractMixedComb, subtractFlow, &trigger_background_same)->Clone();
7db96852 1149
1150 //near side
5a9d8759 1151 TH1D* onePlusOne = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, 6.9, multBinBegin, multBinEnd, 6, 1, 1, 0, subtractMixedComb, subtractFlow, &trigger_1plus1)->Clone();
7db96852 1152 //away side
5a9d8759 1153 //TH1D* onePlusOne = (TH1*)getAnalysis(fileName, pt2Min, pt1Min, pt2Min, ptAssocMin, ptAssocMax, 6.9, multBinBegin, multBinEnd, 6, 1, 1, 0, subtractMixedComb, subtractFlow, &trigger_1plus1)->Clone();
7db96852 1154
1155 onePlusOne->SetLineColor(kRed);
5a9d8759 1156 backgroundSame->SetLineColor(kGreen);
7db96852 1157
5a9d8759 1158 Printf("found trigger: mixed comb %i, 1plus1 %i, background_same %i", trigger_mixed_comb, trigger_1plus1, trigger_background_same);
7db96852 1159 //do not need to scale these distributions because both are already divided by the number of triggers
1160
1161 TCanvas* can = new TCanvas(Form("compare background, %i, %i ", posX, posY), Form("compare background, %i, %i ", posX, posY), posX*gBasisSize+100, posY*gBasisSize+50, gBasisSize, gBasisSize);
1162
5a9d8759 1163 ((TH1*)(backgroundSame->Clone()))->DrawCopy();
1164 ((TH1*)(mixedComb->Clone()))->DrawCopy("same");
7db96852 1165 ((TH1*)(onePlusOne->Clone()))->DrawCopy("same");
1166
1167 TLegend *leg = getLegend();
1168 leg->AddEntry(mixedComb, "mixed combinatorics","l");
1169 leg->AddEntry(onePlusOne, "1plus1 background","l");
5a9d8759 1170 leg->AddEntry(backgroundSame, "background same","l");
7db96852 1171 leg->Draw("same");
1172}
1173
1174void compareAllMixedComb(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, Double_t pt2Min = 2.0, Int_t subtractMixedComb = 0, Int_t subtractFlow = 0){
1175
1176 static const int pt_assoc_bins_number = 8;
1177 Double_t pt_assoc_bins[pt_assoc_bins_number] = {0.5, 1.0, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0};
1178
1179 for(int i=0; i<pt_assoc_bins_number-1; i++){
1180 compareMixedComb_sides(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 1, 5, i, 0, subtractMixedComb, subtractFlow);
1181 compareMixedComb_sides(fileName, pt1Min, pt1Max, pt2Min, pt_assoc_bins[i], pt_assoc_bins[i+1], 9, 10, i, 1, subtractMixedComb, subtractFlow);
1182 }
1183
1184}
1185
1186
1187void compareMixedComb_sides(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, Double_t pt2Min = 2.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t posX = 1, Int_t posY = 1, Int_t subtractMixedComb = 0, Int_t subtractFlow = 0){
1188
1189 Int_t trigger_mixed_comb=0;
1190
1191 TH1D* mixedComb_near = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, 6.9, multBinBegin, multBinEnd, 4, 1, 1, 0, subtractMixedComb, subtractFlow, &trigger_mixed_comb)->Clone();
1192
1193 TH1D* mixedComb_away = (TH1*)getAnalysis(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, 6.9, multBinBegin, multBinEnd, 5, 1, 1, 0, subtractMixedComb, subtractFlow, &trigger_mixed_comb)->Clone();
1194
1195 TCanvas* can = new TCanvas(Form("compare mixedComb, %i, %i ", posX, posY), Form("compare mixedComb, %i, %i ", posX, posY), posX*gBasisSize+100, posY*gBasisSize+50, gBasisSize, gBasisSize);
1196
1197 mixedComb_away->SetLineColor(kRed);
1198
1199 ((TH1*)(mixedComb_near->Clone()))->DrawCopy();
1200 ((TH1*)(mixedComb_away->Clone()))->DrawCopy("same");
1201
1202 TLegend *leg = getLegend();
1203 leg->AddEntry(mixedComb_near, "near side","l");
1204 leg->AddEntry(mixedComb_away, "away side","l");
1205 //leg->Draw("same");
1206}
1207
1208
1209
227badde 1210
1211//calculates the mixed comb by scaling it up to the amount of trigger in same background
1212//this method can probably not be used because the statistics is too smal
1213//within one vertex and multiplicity bin there are 12 to 30 trigger combinations -> the error on the correction factor is too high.
1214TH2D* getMixedComb_scaled_backgroundSame(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 4.0, double ptAssocMin = 2.0, double ptAssocMax = 4.0, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Double_t setVertex = 7, Int_t step = 4, Int_t* trigger = NULL){
1215
1216 loadlibs();
1217
1218 printf("#############################");
1219 printf(Form("step %i", step));
1220 printf("#############################");
1221 AliTwoPlusOneContainer* h = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
1222 h->GetData()->SetPtRange(ptAssocMin, ptAssocMax);
1223 h->GetData()->SetPt2Min(pt2Min);
1224
1225 TH2D* return_mixed_comb = 0;
1226
1227 if(step!=4 && step!=5){
1228 Printf("#############################");
1229 Printf("ERROR wrong step in getMixedComb_scaled_backgroundSame");
1230 Printf("#############################");
1231 return return_mixed_comb;
1232 }
1233
1234 THnBase* trackMixedCombAll = 0;
1235 TH2* eventMixedCombAll = 0;
1236 h->GetData()->GetHistsZVtxMult((AliUEHist::CFStep)step, AliUEHist::kToward, pt1Min, pt1Max, &trackMixedCombAll, &eventMixedCombAll);
1237
1238 THnBase* trackBackgroundSameAll = 0;
1239 TH2* eventBackgroundSameAll = 0;
1240 h->GetData()->GetHistsZVtxMult((AliUEHist::CFStep)(step+3), AliUEHist::kToward, pt1Min, pt1Max, &trackBackgroundSameAll, &eventBackgroundSameAll);
1241
1242 TAxis* vertexAxis = trackMixedCombAll->GetAxis(2);
1243 Int_t vertexBinBegin = vertexAxis->FindBin(-1*setVertex);
1244 Int_t vertexBinEnd = vertexAxis->FindBin(setVertex);
1245
1246 Printf(Form("vertex bin begin %i, end %i ", vertexBinBegin, vertexBinEnd));
1247
1248 for(Int_t multBin=multBinBegin; multBin<=multBinEnd; multBin++){
1249 for(Int_t vertexBin=vertexBinBegin; vertexBin<=vertexBinEnd; vertexBin++){
1250 Printf(" multBin %i, vertexBin %i ", multBin, vertexBin);
1251
1252 trackMixedCombAll->GetAxis(3)->SetRange(multBin, multBin);
1253 trackMixedCombAll->GetAxis(2)->SetRange(vertexBin, vertexBin);
1254
1255 trackBackgroundSameAll->GetAxis(3)->SetRange(multBin, multBin);
1256 trackBackgroundSameAll->GetAxis(2)->SetRange(vertexBin, vertexBin);
1257
1258 TH2D* tracks_mixedComb = trackMixedCombAll->Projection(1, 0, "E");
1259 Int_t trigger_mixed_comb = eventMixedCombAll->Integral(vertexBin, vertexBin, multBin, multBin);
1260
1261 TH2D* tracks_background_same = trackBackgroundSameAll->Projection(1, 0, "E");
1262 Int_t trigger_background_same = eventBackgroundSameAll->Integral(vertexBin, vertexBin, multBin, multBin);
1263
1264 //this has to be done because of a bug in the AliRoot code
1265 //because of an absolute cast in the dphi computation only half of this background is considered
1266 //wrong runs are 968 and 973
1267 //trigger_background_same *= 2;
1268
1269 Double_t trigger_ratio = 0;
1270 if(trigger_background_same>0)
1271 trigger_ratio = (Double_t)trigger_background_same/trigger_mixed_comb;
1272 Printf("(getMixedComb_scaled_backgroundSame) Triggers: mixed comb %i, background same %i, trigger ratio %f ", trigger_mixed_comb, trigger_background_same, trigger_ratio);
1273
1274 double b1 = tracks_mixedComb->GetBinContent(tracks_mixedComb->FindBin(0.001,0.001));
1275 double b2 = tracks_mixedComb->GetBinContent(tracks_mixedComb->FindBin(0.001,-0.001));
1276 double b3 = tracks_mixedComb->GetBinContent(tracks_mixedComb->FindBin(-0.001,0.001));
1277 double b4 = tracks_mixedComb->GetBinContent(tracks_mixedComb->FindBin(-0.001,-0.001));
1278
1279 double b1_bsame = tracks_background_same->GetBinContent(tracks_background_same->FindBin(0.001,0.001));
1280 double b2_bsame = tracks_background_same->GetBinContent(tracks_background_same->FindBin(0.001,-0.001));
1281 double b3_bsame = tracks_background_same->GetBinContent(tracks_background_same->FindBin(-0.001,0.001));
1282 double b4_bsame = tracks_background_same->GetBinContent(tracks_background_same->FindBin(-0.001,-0.001));
1283
1284 Double_t content_ratio = 0;
1285 if(b1 + b2 + b3 + b4 > 0)
1286 content_ratio = (b1_bsame + b2_bsame + b3_bsame + b4_bsame)/(b1 + b2 + b3 + b4);
1287 Printf(" trigger_ratio %f, content_ratio %f", trigger_ratio, content_ratio);
1288
1289 //Printf("Maximum: mixed comb %f, background same %f, normalization ratio %f ", content_mixed_comb, content_background_same, content_ratio);
1290
1291 tracks_mixedComb->Scale(trigger_ratio);
1292 //tracks_mixedComb->Scale(content_ratio);
1293
1294 //correct event with mixed event
1295 TH2D* mixedEvent = getMixedEvent(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, multBin, multBin, vertexBin, vertexBin, (AliUEHist::CFStep)(step-2), 0);
1296 //TH2D* mixedEvent = getMixedEvent(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, multBin, multBin, vertexBinBegin, vertexBinEnd, (AliUEHist::CFStep)(step-2), 1);
1297 tracks_mixedComb->Divide(mixedEvent);
1298
1299 //TCanvas* can_1 = new TCanvas("mixed comb", "mixed comb", 100, 50, gBasisSize, gBasisSize);
1300 //tracks_mixedComb->DrawCopy("surf1");
1301 //TCanvas* can_2 = new TCanvas("mixed", "mixed", gBasisSize+100, 50, gBasisSize, gBasisSize);
1302 //mixedEvent->DrawCopy("surf1");
1303
1304 if(!return_mixed_comb)
1305 return_mixed_comb = (TH2D*) tracks_mixedComb->Clone("total tracks");
1306 else
1307 return_mixed_comb->Add(tracks_mixedComb);
1308
1309 if(trigger!=NULL)
1310 *trigger += trigger_background_same ;
1311 }
1312 }
1313
1314 // normalizate to dphi widht
1315 Float_t normalization = return_mixed_comb->GetXaxis()->GetBinWidth(1);
1316 return_mixed_comb->Scale(1.0 / normalization);
1317
1318 return return_mixed_comb;
1319}
1320
1321
1322//shows alpha dependent significance of the signal, signal/background for different centralities
1323void get1plus1(const char* fileName, Double_t pt1Min, Double_t pt1Max, Double_t ptAssocMin, Double_t ptAssocMax){
1324 loadlibs();
1325 TFile::Open(fileName);
1326
1327 //to guarantee to pick only the bins from the choosen pt on
1328 pt1Min += 0.01;
1329 pt1Max -= 0.01;
1330 ptAssocMin += 0.01;
1331 ptAssocMax -= 0.01;
1332
1333 Int_t alpha_bins = 5;//number of alpha bins maximal used around the two bins close to pi, maximum usable would be 5 because than already the full away side is searched for a trigger 2
1334 Int_t showAlpha = 1;
1335 Double_t alpha_bin_width = 0.174532;
1336 Int_t draw = 1;
1337
1338 Int_t multBinBegin = 9;
1339 Int_t multBinEnd = 10;
1340
1341 AliTwoPlusOneContainer* h = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
1342
1343 AliUEHist::CFStep step_1plus1 = (AliUEHist::CFStep) AliTwoPlusOneContainer::k1plus1;
1344 AliUEHist::CFStep step_mixed = (AliUEHist::CFStep) AliTwoPlusOneContainer::kMixedNS;
1345
1346 TH1D* alpha_plot_significance = new TH1D("alpha_plot", "", alpha_bins, 0, alpha_bins*alpha_bin_width);
1347 alpha_plot_significance->SetXTitle("\\alpha");
1348 alpha_plot_significance->SetYTitle("significance");
1349
1350 TH1D* alpha_plot_sigBack = new TH1D("alpha_plot", "", alpha_bins, 0, alpha_bins*alpha_bin_width);
1351 alpha_plot_sigBack->SetXTitle("\\alpha");
1352 alpha_plot_sigBack->SetYTitle("signal/background");
1353
1354 for(Int_t cent = 0; cent<4; cent++){
1355 char* cent_string = "";
1356 if(cent==0){
1357 multBinBegin = 1;
1358 multBinEnd = 5;
1359 cent_string = "0-5%";
1360 }else if(cent==1){
1361 multBinBegin = 6;
1362 multBinEnd = 6;
1363 cent_string = "5-10%";
1364 }else if(cent==2){
1365 multBinBegin = 7;
1366 multBinEnd = 8;
1367 cent_string = "10-30%";
1368 }else if(cent==3){
1369 multBinBegin = 9;
1370 multBinEnd = 10;
1371 cent_string = "30-50%";
1372 }
1373
1374 for(Int_t alpha = 0; alpha <alpha_bins; alpha++){
1375 if(alpha==showAlpha) draw = 1; else draw = 0;
1376
1377 h->GetData()->SetPtRange(ptAssocMin, ptAssocMax);
1378 TH2* h2_etaPhi = h->GetData()->GetSumOfRatios2(h->GetData(), step_1plus1, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed);
1379 Double_t arr1[4];
1380 showResult(h2_etaPhi, cent, 0, alpha, arr1, draw);
1381 alpha_plot_significance->SetBinContent(alpha+1, arr1[0]);
1382 alpha_plot_significance->SetBinError(alpha+1, arr1[2]);
1383 alpha_plot_sigBack->SetBinContent(alpha+1, arr1[1]);
1384 alpha_plot_sigBack->SetBinError(alpha+1, arr1[3]);
1385 }
1386
1387 TCanvas* c1 = new TCanvas(Form("alpha_plot_significance %s ", cent_string), Form("alpha_plot_significance %s ", cent_string), cent*gBasisSize+50, 1*gBasisSize+50, gBasisSize, gBasisSize);
1388 alpha_plot_significance->DrawCopy("E");
1389
1390 TCanvas* c2 = new TCanvas(Form("alpha_plot_signalBackground %s ", cent_string), Form("alpha_plot_signalBackground %s ", cent_string), cent*gBasisSize+50, 2*gBasisSize+50, gBasisSize, gBasisSize);
1391 alpha_plot_sigBack->DrawCopy("E");
1392 }
1393
1394}
1395
1396
1397
1398//method used just in get1plus1 to calculate the significance and the signal/background
1399void showResult(TH2* h2_etaPhi, Int_t posX, Int_t posY, Int_t alpha_bins, Double_t* arr, Int_t draw){
1400
1401 int firstbin = h2_etaPhi->GetYaxis()->FindBin(-1*g_eta_bin);
1402 int lastbin = h2_etaPhi->GetYaxis()->FindBin(g_eta_bin);
1403
1404 Printf("firstbin %i, lastbin %i, \n", firstbin, lastbin);
48c9fd73 1405
1406 TH1D* h1_phi = h2_etaPhi->ProjectionX(Form("px_%i_%i", posX, posY), firstbin, lastbin);
227badde 1407
1408 double alpha = 0.15;// use 0.15 to get only the next two bins which are a bit smaller than 0.2//0.2;
1409 //Pi is exactely the bin edge
1410 int bin_1 = 27 - alpha_bins;//h1_phi->FindBin(TMath::Pi()-alpha+0.01);
1411 int bin_2 = 28 + alpha_bins;//h1_phi->FindBin(TMath::Pi()+alpha-0.01);
1412
1413 Int_t bin_start = h1_phi->FindBin(TMath::Pi()/3+0.01);
1414 Int_t bin_end = h1_phi->FindBin(2*TMath::Pi()/3-0.01);
1415 Double_t par0 = 0;
1416 Double_t err0 = 0;
1417
1418 for(int i=bin_start; i<=bin_end; i++){
1419 par0 += h1_phi->GetBinContent(i);
1420 err0 += h1_phi->GetBinError(i);
1421 }
1422 par0 /= bin_end - bin_start + 1;
1423 err0 /= bin_end - bin_start + 1;
1424
1425
1426 double sum = 0;
1427 double sum_err = 0;
1428 for(int bin = bin_1; bin<=bin_2; bin++){
1429 sum += h1_phi->GetBinContent(bin);
1430 sum_err += h1_phi->GetBinError(bin);
1431 }
1432 sum_err /= (bin_2-bin_1+1);
1433 double background = (bin_2 - bin_1 + 1)*par0;
1434 double background_err = (bin_2 - bin_1 + 1)*err0;
1435 double signal2 = sum - background;
1436 double signal2_err = TMath::Sqrt(sum_err*sum_err+background_err*background_err);
1437
7db96852 1438 Double_t significance = signal2/h1_phi->GetBinError((bin_1+bin_2)/2);
1439 Double_t significance_err = signal2_err/(TMath::Sqrt(sum));
1440 //Double_t significance = signal2/(TMath::Sqrt(sum));
1441 //Double_t significance_err = TMath::Sqrt(TMath::Power(signal2_err/(TMath::Sqrt(sum)), 2) + TMath::Power(signal2/(TMath::Sqrt(sum*sum*sum)*sum_err), 2));
227badde 1442
1443 Double_t significance_rel = signal2/background;//signal over background
1444 Double_t significance_rel_err = TMath::Sqrt(TMath::Power(signal2_err/background,2)+TMath::Power(signal2/(background*background)*background_err,2));//signal over background
1445
1446 Printf("X %i, Y %i, significance: %f, signal over background %f ", posX, posY, significance, significance_rel);
1447
48c9fd73 1448 h1_phi->SetYTitle("1/N_{trig} \\ dN_{assoc}/d \\varphi");
1449 h1_phi->SetTitle("");
1450 h1_phi->SetStats(kFALSE);
227badde 1451 //h1_phi->Scale(1/(lastbin - firstbin + 1));
1452 if(draw>0){
1453 TCanvas* c1 = new TCanvas(Form("can %i %i", posX, posY), Form("can %i %i", posX, posY), posX*gBasisSize+50, posY*gBasisSize+50, gBasisSize, gBasisSize);
1454 //h1_phi->DrawCopy();
1455 h2_etaPhi->DrawCopy("surf1");
1456 }
1457
1458 arr[0] = significance;
1459 arr[1] = significance_rel;
1460 arr[2] = significance_err;
1461 arr[3] = significance_rel_err;
48c9fd73 1462}
1463
227badde 1464
1465//this method is not further maintained after the copy into this file
1466//it was used to compare the different kind of background distributions
1467//this method compares the expected amount of background trigger combinations for 3 methods:
1468//1. get background from the arithmetical average between delta phi = pi/3 and 2pi/3
1469//2. mixed combinatorics (they are lacking some combinations because the buffers have to be filled first)
1470//3. background same, search at delta phi = pi/2 for trigger particles the same way as it is done in mixed comb
1471void printBackground2plus1(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, Double_t pt2Min = 2.0, Double_t ptAssocMin = 2.0, Double_t ptAssocMax = 4.0, Double_t setVertex = 7, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t step = 0){
1472
48c9fd73 1473 loadlibs();
227badde 1474 TFile::Open(fileName);
48c9fd73 1475
227badde 1476 //to guarantee to pick only the bins from the choosen pt on
1477 pt1Min += 0.01;
1478 pt1Max -= 0.01;
1479 pt2Min += 0.01;
1480 ptAssocMin += 0.01;
1481 ptAssocMax -= 0.01;
48c9fd73 1482
227badde 1483 Double_t alpha_radius = 0.393;// =pi/8 //0.2;//use radius which was used by the mixed comb and background same method in the loaded file
1484
1485 AliTwoPlusOneContainer* h = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
1486 AliUEHist::CFStep step_1plus1 = (AliUEHist::CFStep) AliTwoPlusOneContainer::k1plus1;
1487 AliUEHist::CFStep step_mixed = (AliUEHist::CFStep) AliTwoPlusOneContainer::kMixedAS;
1488 AliUEHist::CFStep step_mixedComb = (AliUEHist::CFStep) AliTwoPlusOneContainer::kMixedCombAS;
1489 AliUEHist::CFStep step_backgroundSame = (AliUEHist::CFStep) AliTwoPlusOneContainer::kBackgroundSameAS;
48c9fd73 1490
227badde 1491 //get error from the 1+1 correlation
1492
1493 THnBase* trackSameAll = 0;
48c9fd73 1494 TH2* eventSameAll = 0;
227badde 1495 //h->GetData()->SetPtRange(pt2Min, pt1Max);
1496 h->GetData()->SetPtRange(ptAssocMin, ptAssocMax);
1497 //h->GetData()->SetPtRange(6, 10);
1498 h->GetData()->SetPt2Min(pt2Min);
1499 h->GetData()->SetZVtxRange(-1*setVertex, setVertex);
1500 /*
1501 h->GetData()->GetHistsZVtxMult(step_1plus1, AliUEHist::kToward, pt1Min, pt1Max, &trackSameAll, &eventSameAll);
1502 trackSameAll->GetAxis(3)->SetRange(multBinBegin, multBinEnd);
48c9fd73 1503
227badde 1504 TAxis* vertexAxis = trackSameAll->GetAxis(2);
1505 Int_t vertexBinBegin = vertexAxis->FindBin(-1*setVertex);
1506 Int_t vertexBinEnd = vertexAxis->FindBin(setVertex);
48c9fd73 1507
227badde 1508 trackSameAll->GetAxis(2)->SetRange(vertexBinBegin, vertexBinEnd);
48c9fd73 1509
227badde 1510 TH2* tracksSame = trackSameAll->Projection(1, 0, "E");
1511 TH1D* h1_phi = tracksSame->ProjectionX();
1512 h1_phi->Scale(1/h1_phi->GetXaxis()->GetBinWidth(1));
1513
1514 */
48c9fd73 1515
227badde 1516 TH2* h2_etaPhi = h->GetData()->GetSumOfRatios2(h->GetData(), step_1plus1, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed);
48c9fd73 1517
227badde 1518 int firstbin = -1;//h2_etaPhi->GetYaxis()->FindBin(-0.99);
1519 int lastbin = -1;//h2_etaPhi->GetYaxis()->FindBin(0.99);
1520 TH1D* h1_phi = h2_etaPhi->ProjectionX("px", firstbin, lastbin);
1521
48c9fd73 1522
227badde 1523 //undo phi normalization
1524 //h1_phi->Scale(h1_phi->GetXaxis()->GetBinWidth(1));
1525 /*
1526 TF1* fit = new TF1("fit", "[0]", 1.01, 1.99);
1527 h1_phi->Fit("fit", "N", "", 1.01, 1.99);
1528 Double_t par0 = fit->GetParameter(0);
1529 Double_t err0 = fit->GetParError(0);
1530 */
1531 Int_t bin_start = h1_phi->FindBin(TMath::Pi()/3+0.01);
1532 Int_t bin_end = h1_phi->FindBin(2*TMath::Pi()/3-0.01);
1533 //Int_t bin_start = h1_phi->FindBin(1.37);
1534 //Int_t bin_end = h1_phi->FindBin(1.57);
1535 Double_t sum = 0;
1536 Double_t err = 0;
1537
1538 for(int i=bin_start; i<=bin_end; i++){
1539 sum += h1_phi->GetBinContent(i);
1540 err += h1_phi->GetBinError(i);
1541 }
1542 Printf("bin start %i, bin end %i, sum %f ", bin_start, bin_end, sum);
1543 sum /= (bin_end - bin_start + 1);
1544 err /= (bin_end - bin_start + 1);
1545 Printf(" sum %f ", sum);
48c9fd73 1546
227badde 1547 Printf("sum %f, bin width %f ", sum, h1_phi->GetBinWidth(bin_start));
48c9fd73 1548
227badde 1549 double background = 2*alpha_radius*sum;//the plot is already normalized for the bin_width by getting it from getSumOfRatios2
1550 double background_err = 2*alpha_radius*err;
48c9fd73 1551
227badde 1552 //TCanvas* can = new TCanvas();
1553 //h1_phi->DrawCopy();
48c9fd73 1554
227badde 1555 //get error from mixed combinatorics
1556 Int_t trigger_mixed_comb;
48c9fd73 1557
48c9fd73 1558
48c9fd73 1559
48c9fd73 1560
227badde 1561 //TH2* h2_etaPhi_mixedComb = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_mixedComb, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed, &trigger_mixed_comb);
1562 h2_etaPhi_mixedComb = getMixedComb_scaled_backgroundSame(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, multBinBegin, multBinEnd, setVertex, step_mixedComb, &trigger_mixed_comb);
48c9fd73 1563
227badde 1564 int firstbin_eta = h2_etaPhi_mixedComb->GetYaxis()->FindBin(-0.39);
1565 int lastbin_eta = h2_etaPhi_mixedComb->GetYaxis()->FindBin(0.39);
1566 TH1* h1_phi_mixedComb = h2_etaPhi_mixedComb->ProjectionX("mixedComb_px", firstbin_eta, lastbin_eta);
48c9fd73 1567
227badde 1568 //get error from mixed combinatorics
1569 Int_t trigger_backgroundSame;
1570
1571 TH2* h2_etaPhi_backgroundSame = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_backgroundSame, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed, &trigger_backgroundSame);
1572 TH1* h1_phi_backgroundSame = h2_etaPhi_backgroundSame->ProjectionX("backgroundSame_px", firstbin_eta, lastbin_eta);
1573
1574
1575 TCanvas* can = new TCanvas("can", "can", gBasisSize+50, gBasisSize+50, 2*gBasisSize, 2*gBasisSize);
1576 h1_phi_mixedComb->SetLineWidth(3);
1577 h1_phi_mixedComb->SetStats(kFALSE);
1578 h1_phi_mixedComb->DrawCopy();
1579 h1_phi_backgroundSame->SetLineWidth(3);
1580 h1_phi_backgroundSame->SetLineColor(kRed);
1581 h1_phi_backgroundSame->DrawCopy("same");
1582
1583 TLegend *leg = getLegend();
1584 leg->AddEntry(h1_phi_mixedComb, "mixed combinatorics","l");
1585 leg->AddEntry(h1_phi_backgroundSame, "background same","l");
1586 leg->Draw("same");
1587
1588 Printf("expect from 1+1 %f +/- %f", background, background_err);
1589 Printf("expect from trigger_mixed_comb %i ", trigger_mixed_comb);
1590 Printf("expect from trigger_backgroundSame %i ", trigger_backgroundSame);
1591}
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603void symmetrize(TH1D* tracks)
1604{
1605 int bins = tracks->FindBin(TMath::Pi()/2-0.01);
1606 for(int i=0; i<=bins/2; i++){
1607 double tmp = (tracks->GetBinContent(i)+tracks->GetBinContent(bins-i+1))/2;
1608 tracks->SetBinContent(i, tmp);
1609 tracks->SetBinContent(bins-i+1, tmp);
1610 }
1611}
1612
1613
1614
1615
1616
1617
1618
1619
1620TH2D* getMixedEvent(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 2.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t vertexBinBegin = 1, Int_t vertexBinEnd = 5, Int_t step = 1, Int_t symmetrize = 0)
1621{
1622
1623 TH2D* tracksMixed = getCorrelationStep(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, multBinBegin, multBinEnd, vertexBinBegin, vertexBinEnd, step);
1624
1625 double b1 = tracksMixed->GetBinContent(tracksMixed->FindBin(0.001,0.001));
1626 double b2 = tracksMixed->GetBinContent(tracksMixed->FindBin(0.001,-0.001));
1627 double b3 = tracksMixed->GetBinContent(tracksMixed->FindBin(-0.001,0.001));
1628 double b4 = tracksMixed->GetBinContent(tracksMixed->FindBin(-0.001,-0.001));
1629 double divide = (b1 + b2 + b3 + b4)/4;//=value at zero
1630 double error = TMath::Power(b1/divide-1, 2)+TMath::Power(b2/divide-1, 2)+TMath::Power(b3/divide-1, 2)+TMath::Power(b4/divide-1, 2);//not further used
1631 Printf(Form(" filename: %s, four bins: %f, %f, %f, %f, divide: %f", fileName, b1/divide, b2/divide, b3/divide, b4/divide, divide));
1632
1633 //symmetrize
1634 if(symmetrize>0)
1635 for(i=0; i<=tracksMixed->GetNbinsX(); i++){
1636 int y_bins = tracksMixed->GetNbinsY();
1637 for(j=0; j<=y_bins/2; j++){
1638 double tmp = (tracksMixed->GetBinContent(i, j)+tracksMixed->GetBinContent(i, y_bins-j+1))/2;
1639 tracksMixed->SetBinContent(i, j, tmp);
1640 tracksMixed->SetBinContent(i, y_bins-j+1, tmp);
1641 }
1642 }
1643
1644 //finite bin correction
1645 //ftrackEtaCut = 0.9;
1646 Double_t finiteBinCorrection = -1.0 / (2*0.9) * tracksMixed->GetYaxis()->GetBinWidth(1) / 2 + 1;
1647 Printf("Finite bin correction: %f", finiteBinCorrection);
1648 divide /= finiteBinCorrection;
1649 error /= finiteBinCorrection;//not further used
1650
1651 tracksMixed->Scale(1.0/divide);
1652
1653 TH1D* proj = tracksMixed->ProjectionY("_norm");
1654 Int_t bins_X = tracksMixed->GetNbinsX();
1655
1656 double norm1 = proj->GetBinContent(proj->FindBin(-0.001));
1657 double norm2 = proj->GetBinContent(proj->FindBin(0.001));
1658 double norm = (norm1+norm2)/2.0;
1659
1660 //tracksMixed->Scale(1.0/(bins_X*norm));
1661 Printf("norm1 %f, norm2 %f, norm %f", norm1/norm, norm2/norm, norm);
1662
1663 //TCanvas* c2 = new TCanvas("mixedEvent", "mixedEvent", gBasisSize+50, 2*gBasisSize+50, gBasisSize, gBasisSize);
1664 //tracksMixed->DrawCopy("surf1");
1665
1666 return tracksMixed;
1667}
1668
1669
1670
1671
1672//old method with an double cache
1673//used to compare results but very difficult to read
1674const char* lastFileName_corStep = 0;
1675double lastPt1Min = 0;
1676double lastPt1Max = 0;
1677double lastPt2Min = 0;
1678double lastPtAssocMin = 0;
1679double lastPtAssocMax = 0;
1680int laststep = 0;
1681void* cacheHistsZVTxMult = 0;
1682void* cacheEvtZVTxMult = 0;
1683
1684const char* lastFileName2_corStep = 0;
1685double lastPt1Min2 = 0;
1686double lastPt1Max2 = 0;
1687double lastPt2Min2 = 0;
1688double lastPtAssocMin2 = 0;
1689double lastPtAssocMax2 = 0;
1690int laststep2 = 0;
1691void* cacheHistsZVTxMult2 = 0;
1692void* cacheEvtZVTxMult2 = 0;
1693
1694int next = 1;
1695
1696TH2D* getCorrelationStep(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, double pt2Min = 2.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t vertexBinBegin = 1, Int_t vertexBinEnd = 5, Int_t step = 1, Int_t* trigger = NULL){
1697
1698 //to guarantee to pick only the bins from the choosen pt on
1699 pt1Min += 0.01;
1700 pt1Max -= 0.01;
1701 pt2Min += 0.01;
1702 ptAssocMin += 0.01;
1703 ptAssocMax -= 0.01;
1704
1705
1706 THnBase* trackMixedAll = 0;
1707 TH2* eventMixedAll = 0;
1708
1709 //look if the THnBase is already in the cache
1710 if(lastFileName_corStep && strcmp(lastFileName_corStep, fileName) == 0 && lastPt1Min==pt1Min && lastPt1Max==pt1Max && lastPt2Min==pt2Min && lastPtAssocMin==ptAssocMin && lastPtAssocMax==ptAssocMax && laststep==step){
1711 Printf("use cache 1");
1712
1713 trackMixedAll = cacheHistsZVTxMult;
1714 eventMixedAll = cacheEvtZVTxMult;
1715
1716 }else if(lastFileName2_corStep && strcmp(lastFileName2_corStep, fileName) == 0 && lastPt1Min2==pt1Min && lastPt1Max2==pt1Max && lastPt2Min2==pt2Min && lastPtAssocMin2==ptAssocMin && lastPtAssocMax2==ptAssocMax && laststep2==step){
1717 Printf("use cache 2");
1718
1719 trackMixedAll = cacheHistsZVTxMult2;
1720 eventMixedAll = cacheEvtZVTxMult2;
48c9fd73 1721
227badde 1722 //if it is in no cache continue getting it (by always recomputing it a memory leak is introduced)
1723 }else{
1724 loadlibs();
1725
1726 AliTwoPlusOneContainer* twoPlusOne = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
1727
1728 twoPlusOne->GetData()->SetPtRange(ptAssocMin, ptAssocMax);
1729 twoPlusOne->GetData()->SetPt2Min(pt2Min);
1730
1731 twoPlusOne->GetData()->GetHistsZVtxMult((AliUEHist::CFStep)step, AliUEHist::kToward, pt1Min, pt1Max, &trackMixedAll, &eventMixedAll);
1732
1733 if(next == 1){
1734 cacheHistsZVTxMult = trackMixedAll;
1735 cacheEvtZVTxMult = eventMixedAll;
1736
1737 lastFileName_corStep = fileName;
1738 lastPt1Min = pt1Min;
1739 lastPt1Max = pt1Max;
1740 lastPt2Min = pt2Min;
1741 lastPtAssocMin = ptAssocMin;
1742 lastPtAssocMax = ptAssocMax;
1743 laststep = step;
1744
1745 next = 2;
1746
1747 }else if(next ==2){
1748 cacheHistsZVTxMult2 = trackMixedAll;
1749 cacheEvtZVTxMult2 = eventMixedAll;
1750
1751 lastFileName2_corStep = fileName;
1752 lastPt1Min2 = pt1Min;
1753 lastPt1Max2 = pt1Max;
1754 lastPt2Min2 = pt2Min;
1755 lastPtAssocMin2 = ptAssocMin;
1756 lastPtAssocMax2 = ptAssocMax;
1757 laststep2 = step;
1758
1759 next = 1;
48c9fd73 1760 }
1761 }
1762
227badde 1763 trackMixedAll->GetAxis(3)->SetRange(multBinBegin, multBinEnd);
1764 trackMixedAll->GetAxis(2)->SetRange(vertexBinBegin, vertexBinEnd);
48c9fd73 1765
227badde 1766 TH2D* tracksMixed = trackMixedAll->Projection(1, 0, "E");
48c9fd73 1767
227badde 1768 if(trigger!=NULL)
1769 *trigger = eventMixedAll->Integral(vertexBinBegin, vertexBinEnd, multBinBegin, multBinEnd);
48c9fd73 1770
227badde 1771 return tracksMixed;
1772}
48c9fd73 1773
48c9fd73 1774
227badde 1775void showMixedDist(const char* fileName){
1776 loadlibs();
1777
5a9d8759 1778 TH1F* mixedDist = getMixedDist(fileName);
227badde 1779 TCanvas* can = new TCanvas();
1780 mixedDist->DrawCopy("colz");
9c98f458 1781}
1782
1783TH1F* getMixedDist(const char* fileName){
1784 loadlibs();
48c9fd73 1785
5a9d8759 1786 //list = (TList*) getList(fileName, "PWGCF_TwoPlusOne/histosTwoPlusOne");
1787 //list = (TList*) getList(fileName, "PWGCF_TwoPlusOne/addedEvents_");
1788 list = (TList*) getList(fileName, path);
9c98f458 1789
1790 TH1F* mixedDist = (TH1F*) list->FindObject("mixedDist");
1791 return mixedDist;
48c9fd73 1792}
1793
1794
1795
227badde 1796void compareScaledMixedComb(const char* fileName, double pt1Min = 4.0, double pt1Max = 14.0, Double_t pt2Min = 2.0, Double_t ptAssocMin = 0.5, Double_t ptAssocMax = 8.0, Double_t setVertex = 7, Int_t multBinBegin = 1, Int_t multBinEnd = 5, Int_t step = 0){
1797
1798 loadlibs();
1799
1800 //to guarantee to pick only the bins from the choosen pt on
1801 pt1Min += 0.01;
1802 pt1Max -= 0.01;
1803 pt2Min += 0.01;
1804 ptAssocMin += 0.01;
1805 ptAssocMax -= 0.01;
1806
1807 AliTwoPlusOneContainer* h = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
1808
1809 AliUEHist::CFStep step_same = step;//(AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS;
1810 AliUEHist::CFStep step_mixed = step+2;//(AliUEHist::CFStep) AliTwoPlusOneContainer::kMixedNS;
1811 AliUEHist::CFStep step_mixedComb = step+4;//(AliUEHist::CStep) AliTwoPlusOneContainer::kMixedCombNS;
1812 AliUEHist::CFStep step_backgroundSame = step+7;//(AliUEHist::CStep) AliTwoPlusOneContainer::kBackgroundSameNS;
1813
1814 h->GetData()->SetPtRange(ptAssocMin, ptAssocMax);
1815 h->GetData()->SetPt2Min(pt2Min);
1816 h->GetData()->SetZVtxRange(-1*setVertex, setVertex);
1817
1818 //GetSumOfRatios2(mixed, step, region, ptLeadMin, ptLeadMax, multBinBegin, multBinEnd, normalizePerTrigger, stepForMixed)
1819 TH2D* h2_etaPhi;
1820 TH2D* h2_etaPhi_mixedComb;
1821 TH2D* h2_etaPhi_backgroundSame;
1822
1823
1824 Int_t trigger_same;
1825 Int_t trigger_mixed_comb;
1826 Int_t trigger_mixed_comb_method;
1827 Int_t trigger_background_same;
1828
1829
1830 h2_etaPhi_mixedComb_sumOfRatios = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_mixedComb, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed, &trigger_mixed_comb);
1831 h2_etaPhi_backgroundSame_sumOfRatios = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_backgroundSame, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed, &trigger_background_same);
1832 //trigger_background_same *= 2;//error in the plots for run 968 and 973
1833 double trigger_ratio = (double)trigger_background_same/trigger_mixed_comb;
1834 Printf("trigger mixed comb: %i, trigger background same %i, ratio %f", trigger_mixed_comb, trigger_background_same, trigger_ratio);
1835 h2_etaPhi_mixedComb_sumOfRatios->Scale(trigger_ratio);
1836 trigger_mixed_comb = trigger_background_same;
1837
1838 h2_etaPhi_mixedComb_method = getMixedComb_scaled_backgroundSame(fileName, pt1Min, pt1Max, pt2Min, ptAssocMin, ptAssocMax, multBinBegin, multBinEnd, setVertex, step_mixedComb, &trigger_mixed_comb_method);
1839
1840
1841 TCanvas* can = new TCanvas("can", "can", gBasisSize+50, gBasisSize+50, gBasisSize, gBasisSize);
1842 h2_etaPhi_mixedComb_sumOfRatios->DrawCopy("surf1");
1843
1844 TCanvas* can2 = new TCanvas("can2", "can2", gBasisSize+50, 2*(gBasisSize+50), gBasisSize, gBasisSize);
1845 h2_etaPhi_mixedComb_method->DrawCopy("surf1");
1846
1847 TCanvas* can3 = new TCanvas("can3", "can3", gBasisSize+50, 3*(gBasisSize+50), gBasisSize, gBasisSize);
1848 h2_etaPhi_mixedComb_sumOfRatios->Add(h2_etaPhi_mixedComb_method, -1);
1849 h2_etaPhi_mixedComb_sumOfRatios->Divide(h2_etaPhi_mixedComb_method);
1850 h2_etaPhi_mixedComb_sumOfRatios->GetYaxis()->SetRangeUser(-1.5, 1.5);
1851 h2_etaPhi_mixedComb_sumOfRatios->DrawCopy("surf1");
1852
1853 Printf("mixed comb sumofratios %i, method %i", trigger_mixed_comb, h2_etaPhi_mixedComb_sumOfRatios);
1854
1855
1856}
1857
1858
1859void Plot_oneAxis(const char* fileName, int project)
48c9fd73 1860{
1861 loadlibs();
1862
1863 TFile::Open(fileName);
1864
1865 AliTwoPlusOneContainer* h = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
227badde 1866
48c9fd73 1867 TCanvas* c1 = new TCanvas("can1", "can1", 1200, 800);
227badde 1868 c1->Divide(2, 1);
1869
1870 AliCFGridSparse* near_plot = h->GetData()->GetTrackHist(0)->GetGrid((AliUEHist::CFStep) AliTwoPlusOneContainer::k1plus1);
c9ae910e 1871 //near_plot->SetRangeUser(2, gpTMin_T1, gpTMax_T1);
1872 //near_plot->SetRangeUser(6, gpTMin_T2, gpTMax_T2);
1873 //near_plot->SetRangeUser(1, gpTMin_assoc, gpTMax_assoc);
227badde 1874 TH1D* tracks_near = near_plot->Project(project);
c9ae910e 1875
227badde 1876 c1->cd(1);
c9ae910e 1877 tracks_near->DrawCopy();
c9ae910e 1878
227badde 1879 AliCFGridSparse* away_plot = h->GetData()->GetTrackHist(0)->GetGrid((AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS);
1880 TH1D* tracks_away = away_plot->Project(project);
1881
1882 c1->cd(2);
c9ae910e 1883 tracks_away->DrawCopy();
227badde 1884}
c9ae910e 1885
227badde 1886void test(const char* fileName, double pt1Min, double pt1Max, double pt2Min, double ptAssocMin, double ptAssocMax)
1887{
1888 loadlibs();
1889 Int_t multBinBegin = 1;
1890 Int_t multBinEnd = 5;
1891 Int_t trigger_mixed_comb;
48c9fd73 1892
227badde 1893 TFile::Open(fileName);
c9ae910e 1894
227badde 1895 AliTwoPlusOneContainer* h = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
c9ae910e 1896
227badde 1897 h->GetData()->SetPtRange(ptAssocMin, ptAssocMax);
1898 h->GetData()->SetPt2Min(pt2Min);
1899 h->GetData()->SetZVtxRange(-1*6.9, 6.9);
c9ae910e 1900
227badde 1901 AliUEHist::CFStep step_same = (AliUEHist::CFStep) AliTwoPlusOneContainer::kSameNS;
1902 AliUEHist::CFStep step_mixed = (AliUEHist::CFStep) AliTwoPlusOneContainer::kMixedNS;
1903
1904 AliUEHist::CFStep step_1plus1 = (AliUEHist::CFStep) AliTwoPlusOneContainer::k1plus1;
1905
1906 //GetSumOfRatios2(mixed, step, region, ptLeadMin, ptLeadMax, multBinBegin, multBinEnd, normalizePerTrigger, stepForMixed)
1907 TH2D* h2_etaPhi;
1908 TH2D* h2_etaPhi_mixedComb;
1909
1910 h2_etaPhi_mixedComb = (TH2D*) h->GetData()->GetSumOfRatios2(h->GetData(), step_1plus1, 0, pt1Min, pt1Max, multBinBegin, multBinEnd, kFALSE, step_mixed, &trigger_mixed_comb);
1911
1912 TCanvas* c1 = new TCanvas("can1", "can1", 1200, 800);
1913 h2_etaPhi_mixedComb->DrawCopy("surf1");
1914}
7db96852 1915
5a9d8759 1916void showAsymmetry(const char* fileName, Int_t mixed){
7db96852 1917 loadlibs();
1918
1919 TFile::Open(fileName);
1920 AliTwoPlusOneContainer* h = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
1921
5a9d8759 1922 TH1F* asymm_same = h->GetAsymmetry();
1923 TH1F* asymm_mixed = h->GetAsymmetryMixed();
1924
7db96852 1925 TCanvas* c1 = new TCanvas("can1", "can1", 1200, 800);
5a9d8759 1926 if(mixed==0)
1927 asymm_same->DrawCopy();
1928 else if(mixed==1)
1929 asymm_mixed->DrawCopy();
1930 else if(mixed==2){
1931 asymm_same->DrawCopy();
1932 asymm_mixed->SetLineColor(kRed);
1933 asymm_mixed->Scale(1.0/80);
1934 asymm_mixed->DrawCopy("same");
1935 }
7db96852 1936}
1937
1938void showTriggerPt(const char* fileName){
1939 loadlibs();
1940
1941 TFile::Open(fileName);
1942 AliTwoPlusOneContainer* h = (AliTwoPlusOneContainer*) GetTwoPlusOne(fileName);
1943
1944 TCanvas* c1 = new TCanvas("can1", "can1", 1200, 800);
1945 h->GetTriggerPt()->DrawCopy("colz");
1946}
1947