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