1 const Int_t numberOfCentralityBins = 11;
2 TString centralityArray[numberOfCentralityBins] = {"0-10","10-20","20-30","30-40","40-50","50-60","60-70","70-80","0-1","1-2","0-100"};
4 void drawBalanceFunctionPsi(const char* filename = "AnalysisResultsPsi.root",
6 Int_t gDeltaEtaDeltaPhi = 2,
8 const char* gCentralityEstimator = 0x0,
9 Double_t psiMin = -0.5, Double_t psiMax = 0.5,
10 Double_t ptTriggerMin = -1.,
11 Double_t ptTriggerMax = -1.,
12 Double_t ptAssociatedMin = -1.,
13 Double_t ptAssociatedMax = -1.,
14 Bool_t k2pMethod = kFALSE,
15 Bool_t k2pMethod2D = kFALSE,
16 TString eventClass = "EventPlane") //Can be "EventPlane", "Centrality", "Multiplicity"
18 //Macro that draws the BF distributions for each centrality bin
19 //for reaction plane dependent analysis
20 //Author: Panos.Christakoglou@nikhef.nl
21 //Load the PWG2ebye library
22 gSystem->Load("libANALYSIS.so");
23 gSystem->Load("libANALYSISalice.so");
24 gSystem->Load("libEventMixing.so");
25 gSystem->Load("libCORRFW.so");
26 gSystem->Load("libPWGTools.so");
27 gSystem->Load("libPWGCFebye.so");
29 //correction method check
30 if(k2pMethod2D&&!k2pMethod){
31 Printf("Chosen 2D 2particle correction method w/o 2particle correction --> not possible");
35 //Prepare the objects and return them
36 TList *listBF = GetListOfObjects(filename,gCentrality,gBit,gCentralityEstimator,0);
37 TList *listBFShuffled = GetListOfObjects(filename,gCentrality,gBit,gCentralityEstimator,1);
38 TList *listBFMixed = GetListOfObjects(filename,gCentrality,gBit,gCentralityEstimator,2);
40 Printf("The TList object was not created");
44 draw(listBF,listBFShuffled,listBFMixed,
45 gCentrality,gDeltaEtaDeltaPhi,
47 ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,
48 k2pMethod,k2pMethod2D,eventClass);
51 //______________________________________________________//
52 TList *GetListOfObjects(const char* filename,
55 const char *gCentralityEstimator,
57 //Get the TList objects (QA, bf, bf shuffled)
61 TFile *f = TFile::Open(filename,"UPDATE");
62 if((!f)||(!f->IsOpen())) {
63 Printf("The file %s is not found. Aborting...",filename);
68 TDirectoryFile *dir = dynamic_cast<TDirectoryFile *>(f->Get("PWGCFEbyE.outputBalanceFunctionPsiAnalysis"));
70 Printf("The TDirectoryFile is not found. Aborting...",filename);
77 //cout<<"no shuffling - no mixing"<<endl;
78 listBFName = "listBFPsi_";
81 //cout<<"shuffling - no mixing"<<endl;
82 listBFName = "listBFPsiShuffled_";
85 //cout<<"no shuffling - mixing"<<endl;
86 listBFName = "listBFPsiMixed_";
88 listBFName += centralityArray[gCentrality-1];
90 listBFName += "_Bit"; listBFName += gBit; }
91 if(gCentralityEstimator) {
92 listBFName += "_"; listBFName += gCentralityEstimator;}
94 // histograms were already retrieved (in first iteration)
95 if(dir->Get(Form("%s_histograms",listBFName.Data()))){
96 listBF = dynamic_cast<TList *>(dir->Get(Form("%s_histograms",listBFName.Data())));
99 // histograms were not yet retrieved (this is the first iteration)
102 listBF = dynamic_cast<TList *>(dir->Get(listBFName.Data()));
103 cout<<"======================================================="<<endl;
104 cout<<"List name (check): "<<listBFName.Data()<<endl;
105 cout<<"List name: "<<listBF->GetName()<<endl;
111 histoName = "fHistPV0M";
113 histoName = "fHistP_shuffleV0M";
115 histoName = "fHistPV0M";
116 AliTHn *fHistP = dynamic_cast<AliTHn *>(listBF->FindObject(histoName.Data()));
118 Printf("fHistP %s not found!!!",histoName.Data());
121 fHistP->FillParent(); fHistP->DeleteContainers();
124 histoName = "fHistNV0M";
126 histoName = "fHistN_shuffleV0M";
128 histoName = "fHistNV0M";
129 AliTHn *fHistN = dynamic_cast<AliTHn *>(listBF->FindObject(histoName.Data()));
131 Printf("fHistN %s not found!!!",histoName.Data());
134 fHistN->FillParent(); fHistN->DeleteContainers();
137 histoName = "fHistPNV0M";
139 histoName = "fHistPN_shuffleV0M";
141 histoName = "fHistPNV0M";
142 AliTHn *fHistPN = dynamic_cast<AliTHn *>(listBF->FindObject(histoName.Data()));
144 Printf("fHistPN %s not found!!!",histoName.Data());
147 fHistPN->FillParent(); fHistPN->DeleteContainers();
150 histoName = "fHistNPV0M";
152 histoName = "fHistNP_shuffleV0M";
154 histoName = "fHistNPV0M";
155 AliTHn *fHistNP = dynamic_cast<AliTHn *>(listBF->FindObject(histoName.Data()));
157 Printf("fHistNP %s not found!!!",histoName.Data());
160 fHistNP->FillParent(); fHistNP->DeleteContainers();
163 histoName = "fHistPPV0M";
165 histoName = "fHistPP_shuffleV0M";
167 histoName = "fHistPPV0M";
168 AliTHn *fHistPP = dynamic_cast<AliTHn *>(listBF->FindObject(histoName.Data()));
170 Printf("fHistPP %s not found!!!",histoName.Data());
173 fHistPP->FillParent(); fHistPP->DeleteContainers();
176 histoName = "fHistNNV0M";
178 histoName = "fHistNN_shuffleV0M";
180 histoName = "fHistNNV0M";
181 AliTHn *fHistNN = dynamic_cast<AliTHn *>(listBF->FindObject(histoName.Data()));
183 Printf("fHistNN %s not found!!!",histoName.Data());
186 fHistNN->FillParent(); fHistNN->DeleteContainers();
189 listBF->Write(Form("%s_histograms",listBFName.Data()), TObject::kSingleKey);
198 //______________________________________________________//
199 void draw(TList *listBF, TList *listBFShuffled, TList *listBFMixed,
200 Int_t gCentrality, Int_t gDeltaEtaDeltaPhi,
201 Double_t psiMin, Double_t psiMax,
202 Double_t ptTriggerMin, Double_t ptTriggerMax,
203 Double_t ptAssociatedMin, Double_t ptAssociatedMax,
204 Bool_t k2pMethod = kFALSE,Bool_t k2pMethod2D = kFALSE, TString eventClass="EventPlane") {
205 gROOT->LoadMacro("~/SetPlotStyle.C");
207 gStyle->SetPalette(1,0);
209 const Int_t gRebin = gDeltaEtaDeltaPhi; //rebin by 2 the Delta phi projection
219 //Printf("=================");
220 hP = (AliTHn*) listBF->FindObject("fHistPV0M");
221 hN = (AliTHn*) listBF->FindObject("fHistNV0M");
222 hPN = (AliTHn*) listBF->FindObject("fHistPNV0M");
223 hNP = (AliTHn*) listBF->FindObject("fHistNPV0M");
224 hPP = (AliTHn*) listBF->FindObject("fHistPPV0M");
225 hNN = (AliTHn*) listBF->FindObject("fHistNNV0M");
227 AliBalancePsi *b = new AliBalancePsi();
228 b->SetEventClass(eventClass);
236 //balance function shuffling
237 AliTHn *hPShuffled = NULL;
238 AliTHn *hNShuffled = NULL;
239 AliTHn *hPNShuffled = NULL;
240 AliTHn *hNPShuffled = NULL;
241 AliTHn *hPPShuffled = NULL;
242 AliTHn *hNNShuffled = NULL;
243 //listBFShuffled->ls();
244 hPShuffled = (AliTHn*) listBFShuffled->FindObject("fHistP_shuffleV0M");
245 hNShuffled = (AliTHn*) listBFShuffled->FindObject("fHistN_shuffleV0M");
246 hPNShuffled = (AliTHn*) listBFShuffled->FindObject("fHistPN_shuffleV0M");
247 hNPShuffled = (AliTHn*) listBFShuffled->FindObject("fHistNP_shuffleV0M");
248 hPPShuffled = (AliTHn*) listBFShuffled->FindObject("fHistPP_shuffleV0M");
249 hNNShuffled = (AliTHn*) listBFShuffled->FindObject("fHistNN_shuffleV0M");
251 AliBalancePsi *bShuffled = new AliBalancePsi();
252 bShuffled->SetEventClass(eventClass);
253 bShuffled->SetHistNp(hPShuffled);
254 bShuffled->SetHistNn(hNShuffled);
255 bShuffled->SetHistNpn(hPNShuffled);
256 bShuffled->SetHistNnp(hNPShuffled);
257 bShuffled->SetHistNpp(hPPShuffled);
258 bShuffled->SetHistNnn(hNNShuffled);
260 //balance function mixing
261 AliTHn *hPMixed = NULL;
262 AliTHn *hNMixed = NULL;
263 AliTHn *hPNMixed = NULL;
264 AliTHn *hNPMixed = NULL;
265 AliTHn *hPPMixed = NULL;
266 AliTHn *hNNMixed = NULL;
268 hPMixed = (AliTHn*) listBFMixed->FindObject("fHistPV0M");
269 hNMixed = (AliTHn*) listBFMixed->FindObject("fHistNV0M");
270 hPNMixed = (AliTHn*) listBFMixed->FindObject("fHistPNV0M");
271 hNPMixed = (AliTHn*) listBFMixed->FindObject("fHistNPV0M");
272 hPPMixed = (AliTHn*) listBFMixed->FindObject("fHistPPV0M");
273 hNNMixed = (AliTHn*) listBFMixed->FindObject("fHistNNV0M");
275 AliBalancePsi *bMixed = new AliBalancePsi();
276 bMixed->SetEventClass(eventClass);
277 bMixed->SetHistNp(hPMixed);
278 bMixed->SetHistNn(hNMixed);
279 bMixed->SetHistNpn(hPNMixed);
280 bMixed->SetHistNnp(hNPMixed);
281 bMixed->SetHistNpp(hPPMixed);
282 bMixed->SetHistNnn(hNNMixed);
284 TH1D *gHistBalanceFunction;
285 TH1D *gHistBalanceFunctionShuffled;
286 TH1D *gHistBalanceFunctionMixed;
287 TH1D *gHistBalanceFunctionSubtracted;
288 TString histoTitle, pngName;
291 if(eventClass == "Centrality"){
292 histoTitle = "Centrality: ";
293 histoTitle += psiMin;
295 histoTitle += psiMax;
297 histoTitle += " (0^{o} < #varphi - #Psi_{2} < 180^{o})";
299 else if(eventClass == "Multiplicity"){
300 histoTitle = "Multiplicity: ";
301 histoTitle += psiMin;
303 histoTitle += psiMax;
304 histoTitle += " tracks";
305 histoTitle += " (0^{o} < #varphi - #Psi_{2} < 180^{o})";
307 else{ // "EventPlane" (default)
308 histoTitle = "Centrality: ";
309 histoTitle += centralityArray[gCentrality-1];
311 if((psiMin == -0.5)&&(psiMax == 0.5))
312 histoTitle += " (-7.5^{o} < #varphi - #Psi_{2} < 7.5^{o})";
313 else if((psiMin == 0.5)&&(psiMax == 1.5))
314 histoTitle += " (37.5^{o} < #varphi - #Psi_{2} < 52.5^{o})";
315 else if((psiMin == 1.5)&&(psiMax == 2.5))
316 histoTitle += " (82.5^{o} < #varphi - #Psi_{2} < 97.5^{o})";
318 histoTitle += " (0^{o} < #varphi - #Psi_{2} < 180^{o})";
321 //Raw balance function
324 gHistBalanceFunction = b->GetBalanceFunctionHistogram2pMethod(0,gDeltaEtaDeltaPhi,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,bMixed);
327 cerr<<"RAW: NO MIXED BF BUT REQUESTED CORRECTING WITH IT! --> FAIL"<<endl;
331 else if(k2pMethod2D){
333 if(gDeltaEtaDeltaPhi==1) //Delta eta
334 gHistBalanceFunction = b->GetBalanceFunction1DFrom2D2pMethod(0,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,bMixed);
336 gHistBalanceFunction = b->GetBalanceFunction1DFrom2D2pMethod(1,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,bMixed);
339 cerr<<"RAW: NO MIXED BF BUT REQUESTED CORRECTING WITH IT! --> FAIL"<<endl;
344 gHistBalanceFunction = b->GetBalanceFunctionHistogram(0,gDeltaEtaDeltaPhi,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax);
345 gHistBalanceFunction->SetMarkerStyle(20);
346 gHistBalanceFunction->SetTitle(histoTitle.Data());
347 gHistBalanceFunction->GetYaxis()->SetTitleOffset(1.3);
348 gHistBalanceFunction->SetName("gHistBalanceFunction");
350 //Shuffled balance function
353 gHistBalanceFunctionShuffled = bShuffled->GetBalanceFunctionHistogram2pMethod(0,gDeltaEtaDeltaPhi,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,bMixed);
355 cerr<<"SHUFFLE: NO MIXED BF BUT REQUESTED CORRECTING WITH IT! --> FAIL"<<endl;
359 else if(k2pMethod2D){
361 if(gDeltaEtaDeltaPhi==1) //Delta eta
362 gHistBalanceFunctionShuffled = bShuffled->GetBalanceFunction1DFrom2D2pMethod(0,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,bMixed);
364 gHistBalanceFunctionShuffled = bShuffled->GetBalanceFunction1DFrom2D2pMethod(1,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,bMixed);
367 cerr<<"SHUFFLE: NO MIXED BF BUT REQUESTED CORRECTING WITH IT! --> FAIL"<<endl;
372 gHistBalanceFunctionShuffled = bShuffled->GetBalanceFunctionHistogram(0,gDeltaEtaDeltaPhi,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax);
373 gHistBalanceFunctionShuffled->SetMarkerStyle(24);
374 gHistBalanceFunctionShuffled->SetName("gHistBalanceFunctionShuffled");
376 //Mixed balance function
379 gHistBalanceFunctionMixed = bMixed->GetBalanceFunctionHistogram2pMethod(0,gDeltaEtaDeltaPhi,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,bMixed);
381 cerr<<"MIXED: NO MIXED BF BUT REQUESTED CORRECTING WITH IT! --> FAIL"<<endl;
385 else if(k2pMethod2D){
387 if(gDeltaEtaDeltaPhi==1) //Delta eta
388 gHistBalanceFunctionMixed = bMixed->GetBalanceFunction1DFrom2D2pMethod(0,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,bMixed);
390 gHistBalanceFunctionMixed = bMixed->GetBalanceFunction1DFrom2D2pMethod(1,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax,bMixed);
393 cerr<<"MIXED: NO MIXED BF BUT REQUESTED CORRECTING WITH IT! --> FAIL"<<endl;
398 gHistBalanceFunctionMixed = bMixed->GetBalanceFunctionHistogram(0,gDeltaEtaDeltaPhi,psiMin,psiMax,ptTriggerMin,ptTriggerMax,ptAssociatedMin,ptAssociatedMax);
399 gHistBalanceFunctionMixed->SetMarkerStyle(25);
400 gHistBalanceFunctionMixed->SetName("gHistBalanceFunctionMixed");
402 //Subtracted balance function
403 gHistBalanceFunctionSubtracted = dynamic_cast<TH1D *>(gHistBalanceFunction->Clone());
404 gHistBalanceFunctionSubtracted->Add(gHistBalanceFunctionMixed,-1);
405 gHistBalanceFunctionSubtracted->Rebin(gRebin);
406 gHistBalanceFunctionSubtracted->Scale(1./(Double_t)(gRebin));
407 gHistBalanceFunctionSubtracted->SetMarkerStyle(20);
408 gHistBalanceFunctionSubtracted->SetTitle(histoTitle.Data());
409 gHistBalanceFunctionSubtracted->GetYaxis()->SetTitleOffset(1.3);
410 gHistBalanceFunctionSubtracted->SetName("gHistBalanceFunctionSubtracted");
412 TCanvas *c1 = new TCanvas("c1","",0,0,600,500);
413 c1->SetFillColor(10);
414 c1->SetHighLightColor(10);
415 c1->SetLeftMargin(0.15);
416 gHistBalanceFunction->DrawCopy("E");
417 gHistBalanceFunctionShuffled->DrawCopy("ESAME");
418 gHistBalanceFunctionMixed->DrawCopy("ESAME");
420 legend = new TLegend(0.18,0.62,0.45,0.82,"","brNDC");
421 legend->SetTextSize(0.045);
422 legend->SetTextFont(42);
423 legend->SetBorderSize(0);
424 legend->SetFillStyle(0);
425 legend->SetFillColor(10);
426 legend->SetMargin(0.25);
427 legend->SetShadowColor(10);
428 legend->AddEntry(gHistBalanceFunction,"Data","lp");
429 legend->AddEntry(gHistBalanceFunctionShuffled,"Shuffled data","lp");
430 legend->AddEntry(gHistBalanceFunctionMixed,"Mixed data","lp");
433 pngName = "BalanceFunction.";
434 if(eventClass == "Centrality"){
435 pngName += Form("Centrality%.1fTo%.1f",psiMin,psiMax);
436 if(gDeltaEtaDeltaPhi == 1) pngName += ".InDeltaEta.PsiAll.PttFrom";
437 else if(gDeltaEtaDeltaPhi == 2) pngName += ".InDeltaPhi.PsiAll.PttFrom";
439 else if(eventClass == "Multiplicity"){
440 pngName += Form("Multiplicity%.0fTo%.0f",psiMin,psiMax);
441 if(gDeltaEtaDeltaPhi == 1) pngName += ".InDeltaEta.PsiAll.PttFrom";
442 else if(gDeltaEtaDeltaPhi == 2) pngName += ".InDeltaPhi.PsiAll.PttFrom";
444 else{ // "EventPlane" (default)
445 pngName += "Centrality";
446 pngName += gCentrality;
447 if(gDeltaEtaDeltaPhi == 1) pngName += ".InDeltaEta.Psi";
448 else if(gDeltaEtaDeltaPhi == 2) pngName += ".InDeltaPhi.Psi";
449 if((psiMin == -0.5)&&(psiMax == 0.5)) pngName += "InPlane.Ptt";
450 else if((psiMin == 0.5)&&(psiMax == 1.5)) pngName += "Intermediate.Ptt";
451 else if((psiMin == 1.5)&&(psiMax == 2.5)) pngName += "OutOfPlane.Ptt";
452 else if((psiMin == 2.5)&&(psiMax == 3.5)) pngName += "Rest.PttFrom";
453 else pngName += "All.PttFrom";
455 pngName += Form("%.1f",ptTriggerMin); pngName += "To";
456 pngName += Form("%.1f",ptTriggerMax); pngName += "PtaFrom";
457 pngName += Form("%.1f",ptAssociatedMin); pngName += "To";
458 pngName += Form("%.1f",ptAssociatedMax);
459 if(k2pMethod2D) pngName += "_2pMethod2D";
460 else if(k2pMethod) pngName += "_2pMethod";
463 c1->SaveAs(pngName.Data());
465 GetWeightedMean(gHistBalanceFunction);
466 GetWeightedMean(gHistBalanceFunctionShuffled);
468 TString meanLatex, rmsLatex, skewnessLatex, kurtosisLatex;
469 meanLatex = "#mu = ";
470 meanLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetMean());
471 meanLatex += " #pm ";
472 meanLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetMeanError());
474 rmsLatex = "#sigma = ";
475 rmsLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetRMS());
477 rmsLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetRMSError());
479 skewnessLatex = "S = ";
480 skewnessLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetSkewness(1));
481 skewnessLatex += " #pm ";
482 skewnessLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetSkewness(11));
484 kurtosisLatex = "K = ";
485 kurtosisLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetKurtosis(1));
486 kurtosisLatex += " #pm ";
487 kurtosisLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetKurtosis(11));
488 Printf("Mean: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetMean(),gHistBalanceFunctionSubtracted->GetMeanError());
489 Printf("RMS: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetRMS(),gHistBalanceFunctionSubtracted->GetRMSError());
490 Printf("Skeweness: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetSkewness(1),gHistBalanceFunctionSubtracted->GetSkewness(11));
491 Printf("Kurtosis: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetKurtosis(1),gHistBalanceFunctionSubtracted->GetKurtosis(11));
493 TCanvas *c2 = new TCanvas("c2","",600,0,600,500);
494 c2->SetFillColor(10);
495 c2->SetHighLightColor(10);
496 c2->SetLeftMargin(0.15);
497 gHistBalanceFunctionSubtracted->DrawCopy("E");
499 TLatex *latex = new TLatex();
501 latex->SetTextSize(0.035);
502 latex->SetTextColor(1);
503 latex->DrawLatex(0.64,0.85,meanLatex.Data());
504 latex->DrawLatex(0.64,0.81,rmsLatex.Data());
505 latex->DrawLatex(0.64,0.77,skewnessLatex.Data());
506 latex->DrawLatex(0.64,0.73,kurtosisLatex.Data());
508 TString newFileName = "balanceFunction.";
509 if(eventClass == "Centrality"){
510 newFileName += Form("Centrality%.1fTo%.1f",psiMin,psiMax);
511 if(gDeltaEtaDeltaPhi == 1) newFileName += ".InDeltaEta.PsiAll.PttFrom";
512 else if(gDeltaEtaDeltaPhi == 2) newFileName += ".InDeltaPhi.PsiAll.PttFrom";
514 else if(eventClass == "Multiplicity"){
515 newFileName += Form("Multiplicity%.0fTo%.0f",psiMin,psiMax);
516 if(gDeltaEtaDeltaPhi == 1) newFileName += ".InDeltaEta.PsiAll.PttFrom";
517 else if(gDeltaEtaDeltaPhi == 2) newFileName += ".InDeltaPhi.PsiAll.PttFrom";
519 else{ // "EventPlane" (default)
520 newFileName += "Centrality";
521 newFileName += gCentrality;
522 if(gDeltaEtaDeltaPhi == 1) newFileName += ".InDeltaEta.Psi";
523 else if(gDeltaEtaDeltaPhi == 2) newFileName += ".InDeltaPhi.Psi";
524 if((psiMin == -0.5)&&(psiMax == 0.5)) newFileName += "InPlane.Ptt";
525 else if((psiMin == 0.5)&&(psiMax == 1.5)) newFileName += "Intermediate.Ptt";
526 else if((psiMin == 1.5)&&(psiMax == 2.5)) newFileName += "OutOfPlane.Ptt";
527 else if((psiMin == 2.5)&&(psiMax == 3.5)) newFileName += "Rest.PttFrom";
528 else newFileName += "All.PttFrom";
530 newFileName += Form("%.1f",ptTriggerMin); newFileName += "To";
531 newFileName += Form("%.1f",ptTriggerMax); newFileName += "PtaFrom";
532 newFileName += Form("%.1f",ptAssociatedMin); newFileName += "To";
533 newFileName += Form("%.1f",ptAssociatedMax);
534 if(k2pMethod2D) newFileName += "_2pMethod2D";
535 else if(k2pMethod) newFileName += "_2pMethod";
536 newFileName += ".root";
538 TFile *fOutput = new TFile(newFileName.Data(),"recreate");
540 gHistBalanceFunction->Write();
541 gHistBalanceFunctionShuffled->Write();
542 gHistBalanceFunctionMixed->Write();
543 gHistBalanceFunctionSubtracted->Write();
547 //____________________________________________________________________//
548 void GetWeightedMean(TH1D *gHistBalance, Int_t fStartBin = 1) {
549 //Prints the calculated width of the BF and its error
550 Double_t gSumXi = 0.0, gSumBi = 0.0, gSumBiXi = 0.0;
551 Double_t gSumBiXi2 = 0.0, gSumBi2Xi2 = 0.0;
552 Double_t gSumDeltaBi2 = 0.0, gSumXi2DeltaBi2 = 0.0;
553 Double_t deltaBalP2 = 0.0, integral = 0.0;
554 Double_t deltaErrorNew = 0.0;
556 //Retrieve this variables from Histogram
557 Int_t fNumberOfBins = gHistBalance->GetNbinsX();
558 Double_t fP2Step = gHistBalance->GetBinWidth(1); // assume equal binning!
560 //cout<<"=================================================="<<endl;
561 //cout<<"RECALCULATION OF BF WIDTH (StartBin = "<<fStartBin<<")"<<endl;
562 //cout<<"HISTOGRAM has "<<fNumberOfBins<<" bins with bin size of "<<fP2Step<<endl;
563 //cout<<"=================================================="<<endl;
564 for(Int_t i = 1; i <= fNumberOfBins; i++) {
565 // this is to simulate |Delta eta| or |Delta phi|
566 if(fNumberOfBins/2 - fStartBin + 1 < i && i < fNumberOfBins/2 + fStartBin ) continue;
568 //cout<<"B: "<<gHistBalance->GetBinContent(i)<<"\t Error: "<<gHistBalance->GetBinError(i)<<"\t bin: "<<TMath::Abs(gHistBalance->GetBinCenter(i))<<endl;
570 gSumXi += TMath::Abs(gHistBalance->GetBinCenter(i)); // this is to simulate |Delta eta| or |Delta phi|
571 gSumBi += gHistBalance->GetBinContent(i);
572 gSumBiXi += gHistBalance->GetBinContent(i)*TMath::Abs(gHistBalance->GetBinCenter(i));
573 gSumBiXi2 += gHistBalance->GetBinContent(i)*TMath::Power(TMath::Abs(gHistBalance->GetBinCenter(i)),2);
574 gSumBi2Xi2 += TMath::Power(gHistBalance->GetBinContent(i),2)*TMath::Power(TMath::Abs(gHistBalance->GetBinCenter(i)),2);
575 gSumDeltaBi2 += TMath::Power(gHistBalance->GetBinError(i),2);
576 gSumXi2DeltaBi2 += TMath::Power(TMath::Abs(gHistBalance->GetBinCenter(i)),2) * TMath::Power(gHistBalance->GetBinError(i),2);
578 deltaBalP2 += fP2Step*TMath::Power(gHistBalance->GetBinError(i),2);
579 integral += fP2Step*gHistBalance->GetBinContent(i);
581 for(Int_t i = fStartBin; i < fNumberOfBins; i++)
582 deltaErrorNew += gHistBalance->GetBinError(i)*(TMath::Abs(gHistBalance->GetBinCenter(i))*gSumBi - gSumBiXi)/TMath::Power(gSumBi,2);
584 Double_t integralError = TMath::Sqrt(deltaBalP2);
586 Double_t delta = gSumBiXi / gSumBi;
587 Double_t deltaError = (gSumBiXi / gSumBi) * TMath::Sqrt(TMath::Power((TMath::Sqrt(gSumXi2DeltaBi2)/gSumBiXi),2) + TMath::Power((gSumDeltaBi2/gSumBi),2) );
588 cout<<"=================================================="<<endl;
589 cout<<"Width: "<<delta<<"\t Error: "<<deltaError<<endl;
590 cout<<"New error: "<<deltaErrorNew<<endl;
591 cout<<"Integral: "<<integral<<"\t Error: "<<integralError<<endl;
592 cout<<"=================================================="<<endl;
596 //______________________________________________________//
597 void drawBFPsi(const char* lhcPeriod = "LHC10h",
598 Int_t gCentrality = 1,
599 Int_t gDeltaEtaDeltaPhi = 2,
600 Double_t psiMin = -0.5, Double_t psiMax = 0.5,
601 Double_t ptTriggerMin = -1.,
602 Double_t ptTriggerMax = -1.,
603 Double_t ptAssociatedMin = -1.,
604 Double_t ptAssociatedMax = -1.) {
605 //Macro that draws the BF distributions for each centrality bin
606 //for reaction plane dependent analysis
607 //Author: Panos.Christakoglou@nikhef.nl
608 gROOT->LoadMacro("~/SetPlotStyle.C");
612 TString filename = lhcPeriod; filename +="/PttFrom";
613 filename += Form("%.1f",ptTriggerMin); filename += "To";
614 filename += Form("%.1f",ptTriggerMax); filename += "PtaFrom";
615 filename += Form("%.1f",ptAssociatedMin); filename += "To";
616 filename += Form("%.1f",ptAssociatedMax);
617 filename += "/balanceFunction.Centrality";
618 filename += gCentrality; filename += ".In";
619 if(gDeltaEtaDeltaPhi == 1) filename += "DeltaEta.Psi";
620 else if(gDeltaEtaDeltaPhi == 2) filename += "DeltaPhi.Psi";
621 if((psiMin == -0.5)&&(psiMax == 0.5)) filename += "InPlane.Ptt";
622 else if((psiMin == 0.5)&&(psiMax == 1.5)) filename += "Intermediate.Ptt";
623 else if((psiMin == 1.5)&&(psiMax == 2.5)) filename += "OutOfPlane.Ptt";
624 else if((psiMin == 2.5)&&(psiMax == 3.5)) filename += "Rest.Ptt";
625 else filename += "All.PttFrom";
626 filename += Form("%.1f",ptTriggerMin); filename += "To";
627 filename += Form("%.1f",ptTriggerMax); filename += "PtaFrom";
628 filename += Form("%.1f",ptAssociatedMin); filename += "To";
629 filename += Form("%.1f",ptAssociatedMax); filename += ".root";
632 TFile *f = TFile::Open(filename.Data());
633 if((!f)||(!f->IsOpen())) {
634 Printf("The file %s is not found. Aborting...",filename);
639 //Raw balance function
640 TH1D *gHistBalanceFunction = dynamic_cast<TH1D *>(f->Get("gHistBalanceFunction"));
641 gHistBalanceFunction->SetStats(kFALSE);
642 gHistBalanceFunction->SetMarkerStyle(20);
643 gHistBalanceFunction->GetYaxis()->SetTitleOffset(1.3);
644 if(gDeltaEtaDeltaPhi == 2) {
645 gHistBalanceFunction->GetYaxis()->SetTitle("B(#Delta #varphi)");
646 gHistBalanceFunction->GetXaxis()->SetTitle("#Delta #varphi (deg.)");
649 //Shuffled balance function
650 TH1D *gHistBalanceFunctionShuffled = dynamic_cast<TH1D *>(f->Get("gHistBalanceFunctionShuffled"));
651 gHistBalanceFunction->SetStats(kFALSE);
652 gHistBalanceFunctionShuffled->SetMarkerStyle(24);
654 //Mixed balance function
655 TH1D *gHistBalanceFunctionMixed = dynamic_cast<TH1D *>(f->Get("gHistBalanceFunctionMixed"));
656 gHistBalanceFunction->SetStats(kFALSE);
657 gHistBalanceFunctionMixed->SetMarkerStyle(25);
659 //Subtracted balance function
660 TH1D *gHistBalanceFunctionSubtracted = dynamic_cast<TH1D *>(f->Get("gHistBalanceFunctionSubtracted"));
661 gHistBalanceFunctionSubtracted->SetStats(kFALSE);
662 gHistBalanceFunctionSubtracted->SetMarkerStyle(20);
663 gHistBalanceFunctionSubtracted->GetYaxis()->SetTitleOffset(1.3);
664 if(gDeltaEtaDeltaPhi == 2) {
665 gHistBalanceFunctionSubtracted->GetYaxis()->SetTitle("B(#Delta #varphi)");
666 gHistBalanceFunctionSubtracted->GetXaxis()->SetTitle("#Delta #varphi (deg.)");
672 TString centralityLatex = "Centrality: ";
673 centralityLatex += centralityArray[gCentrality-1];
674 centralityLatex += "%";
677 if((psiMin == -0.5)&&(psiMax == 0.5))
678 psiLatex = " -7.5^{o} < #varphi - #Psi_{2} < 7.5^{o}";
679 else if((psiMin == 0.5)&&(psiMax == 1.5))
680 psiLatex = " 37.5^{o} < #varphi - #Psi_{2} < 52.5^{o}";
681 else if((psiMin == 1.5)&&(psiMax == 2.5))
682 psiLatex = " 82.5^{o} < #varphi - #Psi_{2} < 97.5^{o}";
684 psiLatex = " 0^{o} < #varphi - #Psi_{2} < 180^{o}";
686 TString pttLatex = Form("%.1f",ptTriggerMin);
687 pttLatex += " < p_{T}^{t} < "; pttLatex += Form("%.1f",ptTriggerMax);
688 pttLatex += " GeV/c";
690 TString ptaLatex = Form("%.1f",ptAssociatedMin);
691 ptaLatex += " < p_{T}^{a} < "; ptaLatex += Form("%.1f",ptAssociatedMax);
692 ptaLatex += " GeV/c";
695 TCanvas *c1 = new TCanvas("c1","",0,0,600,500);
696 c1->SetFillColor(10); c1->SetHighLightColor(10);
697 c1->SetLeftMargin(0.17); c1->SetTopMargin(0.05);
698 gHistBalanceFunction->SetTitle("");
699 gHistBalanceFunction->GetYaxis()->SetTitleOffset(1.4);
700 gHistBalanceFunction->GetYaxis()->SetNdivisions(10);
701 gHistBalanceFunction->GetXaxis()->SetNdivisions(10);
702 gHistBalanceFunction->DrawCopy("E");
703 gHistBalanceFunctionShuffled->DrawCopy("ESAME");
704 gHistBalanceFunctionMixed->DrawCopy("ESAME");
706 legend = new TLegend(0.2,0.72,0.45,0.92,"","brNDC");
707 legend->SetTextSize(0.05);
708 legend->SetTextFont(42);
709 legend->SetBorderSize(0);
710 legend->SetFillStyle(0);
711 legend->SetFillColor(10);
712 legend->SetMargin(0.25);
713 legend->SetShadowColor(10);
714 legend->AddEntry(gHistBalanceFunction,"Data","lp");
715 legend->AddEntry(gHistBalanceFunctionShuffled,"Shuffled data","lp");
716 legend->AddEntry(gHistBalanceFunctionMixed,"Mixed data","lp");
719 TLatex *latexInfo1 = new TLatex();
720 latexInfo1->SetNDC();
721 latexInfo1->SetTextSize(0.04);
722 latexInfo1->SetTextColor(1);
723 latexInfo1->DrawLatex(0.58,0.88,centralityLatex.Data());
724 latexInfo1->DrawLatex(0.58,0.82,psiLatex.Data());
725 latexInfo1->DrawLatex(0.58,0.76,pttLatex.Data());
726 latexInfo1->DrawLatex(0.58,0.70,ptaLatex.Data());
728 //pngName = "BalanceFunctionDeltaEta.Centrality";
729 //pngName += centralityArray[gCentrality-1];
730 //pngName += ".Psi"; //pngName += psiMin; pngName += "To"; pngName += psiMax;
732 //c1->SaveAs(pngName.Data());
734 TCanvas *c2 = new TCanvas("c2","",600,0,600,500);
735 c2->SetFillColor(10); c2->SetHighLightColor(10);
736 c2->SetLeftMargin(0.17); c2->SetTopMargin(0.05);
737 gHistBalanceFunctionSubtracted->SetTitle("");
738 gHistBalanceFunctionSubtracted->GetYaxis()->SetTitleOffset(1.4);
739 gHistBalanceFunctionSubtracted->GetYaxis()->SetNdivisions(10);
740 gHistBalanceFunctionSubtracted->GetXaxis()->SetNdivisions(10);
741 gHistBalanceFunctionSubtracted->DrawCopy("E");
743 //Opening the output ascii files
744 TString filenameMean = "meanIn";
745 TString filenameSigma = "sigmaIn";
746 TString filenameSkewness = "skewnessIn";
747 TString filenameKurtosis = "kurtosisIn";
748 if(gDeltaEtaDeltaPhi == 1) {
749 filenameMean += "DeltaEta.Psi"; filenameSigma += "DeltaEta.Psi";
750 filenameSkewness += "DeltaEta.Psi"; filenameKurtosis += "DeltaEta.Psi";
752 else if(gDeltaEtaDeltaPhi == 2) {
753 filenameMean += "DeltaPhi.Psi"; filenameSigma += "DeltaPhi.Psi";
754 filenameSkewness += "DeltaPhi.Psi"; filenameKurtosis += "DeltaPhi.Psi";
756 if((psiMin == -0.5)&&(psiMax == 0.5)) {
757 filenameMean += "InPlane.Ptt"; filenameSigma += "InPlane.Ptt";
758 filenameSkewness += "InPlane.Ptt"; filenameKurtosis += "InPlane.Ptt";
760 else if((psiMin == 0.5)&&(psiMax == 1.5)) {
761 filenameMean += "Intermediate.Ptt"; filenameSigma += "Intermediate.Ptt";
762 filenameSkewness += "Intermediate.Ptt";
763 filenameKurtosis += "Intermediate.Ptt";
765 else if((psiMin == 1.5)&&(psiMax == 2.5)) {
766 filenameMean += "OutOfPlane.Ptt"; filenameSigma += "OutOfPlane.Ptt";
767 filenameSkewness += "OutOfPlane.Ptt";
768 filenameKurtosis += "OutOfPlane.Ptt";
770 else if((psiMin == 2.5)&&(psiMax == 3.5)) {
771 filenameMean += "Rest.Ptt"; filenameSigma += "Rest.Ptt";
772 filenameSkewness += "Rest.Ptt"; filenameKurtosis += "Rest.Ptt";
775 filenameMean += "All.Ptt"; filenameSigma += "All.Ptt";
776 filenameSkewness += "All.Ptt"; filenameKurtosis += "All.Ptt";
778 filenameMean += Form("%.1f",ptTriggerMin); filenameMean += "To";
779 filenameMean += Form("%.1f",ptTriggerMax); filenameMean += "PtaFrom";
780 filenameMean += Form("%.1f",ptAssociatedMin); filenameMean += "To";
781 filenameMean += Form("%.1f",ptAssociatedMax); filenameMean += ".txt";
782 filenameSigma += Form("%.1f",ptTriggerMin); filenameSigma += "To";
783 filenameSigma += Form("%.1f",ptTriggerMax); filenameSigma += "PtaFrom";
784 filenameSigma += Form("%.1f",ptAssociatedMin); filenameSigma += "To";
785 filenameSigma += Form("%.1f",ptAssociatedMax); filenameSigma += ".txt";
786 filenameSkewness += Form("%.1f",ptTriggerMin); filenameSkewness += "To";
787 filenameSkewness += Form("%.1f",ptTriggerMax); filenameSkewness += "PtaFrom";
788 filenameSkewness += Form("%.1f",ptAssociatedMin); filenameSkewness += "To";
789 filenameSkewness += Form("%.1f",ptAssociatedMax);
790 filenameSkewness += ".txt";
791 filenameKurtosis += Form("%.1f",ptTriggerMin); filenameKurtosis += "To";
792 filenameKurtosis += Form("%.1f",ptTriggerMax); filenameKurtosis += "PtaFrom";
793 filenameKurtosis += Form("%.1f",ptAssociatedMin); filenameKurtosis += "To";
794 filenameKurtosis += Form("%.1f",ptAssociatedMax);
795 filenameKurtosis += ".txt";
797 TString meanLatex, rmsLatex, skewnessLatex, kurtosisLatex;
798 meanLatex = "#mu = ";
799 meanLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetMean());
800 meanLatex += " #pm ";
801 meanLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetMeanError());
802 ofstream fileMean(filenameMean.Data(),ios::app);
803 fileMean << gCentrality << " " << gHistBalanceFunctionSubtracted->GetMean() << " " <<gHistBalanceFunctionSubtracted->GetMeanError()<<endl;
806 rmsLatex = "#sigma = ";
807 rmsLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetRMS());
809 rmsLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetRMSError());
810 ofstream fileSigma(filenameSigma.Data(),ios::app);
811 fileSigma << gCentrality << " " << gHistBalanceFunctionSubtracted->GetRMS() << " " <<gHistBalanceFunctionSubtracted->GetRMSError()<<endl;
814 skewnessLatex = "S = ";
815 skewnessLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetSkewness(1));
816 skewnessLatex += " #pm ";
817 skewnessLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetSkewness(11));
818 ofstream fileSkewness(filenameSkewness.Data(),ios::app);
819 fileSkewness << gCentrality << " " << gHistBalanceFunctionSubtracted->GetSkewness(1) << " " <<gHistBalanceFunctionSubtracted->GetSkewness(11)<<endl;
820 fileSkewness.close();
822 kurtosisLatex = "K = ";
823 kurtosisLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetKurtosis(1));
824 kurtosisLatex += " #pm ";
825 kurtosisLatex += Form("%.3f",gHistBalanceFunctionSubtracted->GetKurtosis(11));
826 ofstream fileKurtosis(filenameKurtosis.Data(),ios::app);
827 fileKurtosis << gCentrality << " " << gHistBalanceFunctionSubtracted->GetKurtosis(1) << " " <<gHistBalanceFunctionSubtracted->GetKurtosis(11)<<endl;
828 fileKurtosis.close();
830 Printf("Mean: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetMean(),gHistBalanceFunctionSubtracted->GetMeanError());
831 Printf("RMS: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetRMS(),gHistBalanceFunctionSubtracted->GetRMSError());
832 Printf("Skeweness: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetSkewness(1),gHistBalanceFunctionSubtracted->GetSkewness(11));
833 Printf("Kurtosis: %lf - Error: %lf",gHistBalanceFunctionSubtracted->GetKurtosis(1),gHistBalanceFunctionSubtracted->GetKurtosis(11));
835 latexInfo1->DrawLatex(0.18,0.88,centralityLatex.Data());
836 latexInfo1->DrawLatex(0.18,0.82,psiLatex.Data());
837 latexInfo1->DrawLatex(0.18,0.76,pttLatex.Data());
838 latexInfo1->DrawLatex(0.18,0.70,ptaLatex.Data());
840 TLatex *latexResults = new TLatex();
841 latexResults->SetNDC();
842 latexResults->SetTextSize(0.04);
843 latexResults->SetTextColor(1);
844 latexResults->DrawLatex(0.6,0.88,meanLatex.Data());
845 latexResults->DrawLatex(0.6,0.82,rmsLatex.Data());
846 latexResults->DrawLatex(0.6,0.76,skewnessLatex.Data());
847 latexResults->DrawLatex(0.6,0.70,kurtosisLatex.Data());