1 /**************************************************************************
2 * Author: Panos Christakoglou. *
3 * Contributors are mentioned in the code where appropriate. *
5 * Permission to use, copy, modify and distribute this software and its *
6 * documentation strictly for non-commercial purposes is hereby granted *
7 * without fee, provided that the above copyright notice appears in all *
8 * copies and that both the copyright notice and this permission notice *
9 * appear in the supporting documentation. The authors make no claims *
10 * about the suitability of this software for any purpose. It is *
11 * provided "as is" without express or implied warranty. *
12 **************************************************************************/
14 /* $Id: AliBalancePsi.cxx 54125 2012-01-24 21:07:41Z miweber $ */
16 //-----------------------------------------------------------------
17 // Balance Function class
18 // This is the class to deal with the Balance Function wrt Psi analysis
19 // Origin: Panos Christakoglou, Nikhef, Panos.Christakoglou@cern.ch
20 //-----------------------------------------------------------------
24 #include <Riostream.h>
30 #include <TLorentzVector.h>
31 #include <TObjArray.h>
32 #include <TGraphErrors.h>
35 #include "AliVParticle.h"
36 #include "AliMCParticle.h"
37 #include "AliESDtrack.h"
38 #include "AliAODTrack.h"
40 #include "AliAnalysisTaskTriggeredBF.h"
42 #include "AliBalancePsi.h"
44 ClassImp(AliBalancePsi)
46 //____________________________________________________________________//
47 AliBalancePsi::AliBalancePsi() :
50 fAnalysisLevel("ESD"),
63 fHistConversionbefore(0),
64 fHistConversionafter(0),
69 fConversionCut(kFALSE),
70 fEventClass("EventPlane"){
71 // Default constructor
74 //____________________________________________________________________//
75 AliBalancePsi::AliBalancePsi(const AliBalancePsi& balance):
76 TObject(balance), fShuffle(balance.fShuffle),
77 fAnalysisLevel(balance.fAnalysisLevel),
78 fAnalyzedEvents(balance.fAnalyzedEvents),
79 fCentralityId(balance.fCentralityId),
80 fCentStart(balance.fCentStart),
81 fCentStop(balance.fCentStop),
82 fHistP(balance.fHistP),
83 fHistN(balance.fHistN),
84 fHistPN(balance.fHistPN),
85 fHistNP(balance.fHistNP),
86 fHistPP(balance.fHistPP),
87 fHistNN(balance.fHistNN),
88 fHistHBTbefore(balance.fHistHBTbefore),
89 fHistHBTafter(balance.fHistHBTafter),
90 fHistConversionbefore(balance.fHistConversionbefore),
91 fHistConversionafter(balance.fHistConversionafter),
92 fHistPsiMinusPhi(balance.fHistPsiMinusPhi),
93 fPsiInterval(balance.fPsiInterval),
94 fDeltaEtaMax(balance.fDeltaEtaMax),
95 fHBTCut(balance.fHBTCut),
96 fConversionCut(balance.fConversionCut),
97 fEventClass("EventPlane"){
101 //____________________________________________________________________//
102 AliBalancePsi::~AliBalancePsi() {
111 delete fHistHBTbefore;
112 delete fHistHBTafter;
113 delete fHistConversionbefore;
114 delete fHistConversionafter;
115 delete fHistPsiMinusPhi;
119 //____________________________________________________________________//
120 void AliBalancePsi::InitHistograms() {
121 // single particle histograms
123 // global switch disabling the reference
124 // (to avoid "Replacing existing TH1" if several wagons are created in train)
125 Bool_t oldStatus = TH1::AddDirectoryStatus();
126 TH1::AddDirectory(kFALSE);
128 Int_t anaSteps = 1; // analysis steps
129 Int_t iBinSingle[kTrackVariablesSingle]; // binning for track variables
130 Double_t* dBinsSingle[kTrackVariablesSingle]; // bins for track variables
131 TString axisTitleSingle[kTrackVariablesSingle]; // axis titles for track variables
133 // two particle histograms
134 Int_t iBinPair[kTrackVariablesPair]; // binning for track variables
135 Double_t* dBinsPair[kTrackVariablesPair]; // bins for track variables
136 TString axisTitlePair[kTrackVariablesPair]; // axis titles for track variables
137 /**********************************************************
139 ======> Modification: Change Event Classification Scheme
141 ---> fEventClass == "EventPlane"
143 Default operation with Event Plane
145 ---> fEventClass == "Multiplicity"
147 Work with kTPCITStracklet multiplicity (from GetReferenceMultiplicity)
149 ---> fEventClass == "Centrality"
151 Work with Centrality Bins
153 ***********************************************************/
155 //--- Multiplicity Bins ------------------------------------
156 const Int_t kMultBins = 8;
157 //A first rough attempt at four bins
158 Double_t kMultBinLimits[kMultBins+1]={0,10,20,30,40,50,60,70,80};
159 //----------------------------------------------------------
161 //--- Centrality Bins --------------------------------------
162 const Int_t kNCentralityBins = 9;
163 Double_t centralityBins[kNCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.};
164 //----------------------------------------------------------
166 //--- Event Plane Bins -------------------------------------
167 //Psi_2: -0.5->0.5 (in plane), 0.5->1.5 (intermediate), 1.5->2.5 (out of plane), 2.5->3.5 (rest)
168 const Int_t kNPsi2Bins = 4;
169 Double_t psi2Bins[kNPsi2Bins+1] = {-0.5,0.5,1.5,2.5,3.5};
170 //----------------------------------------------------------
172 //Depending on fEventClass Variable, do one thing or the other...
173 if(fEventClass == "Multiplicity"){
174 iBinSingle[0] = kMultBins;
175 dBinsSingle[0] = kMultBinLimits;
176 axisTitleSingle[0] = "kTPCITStracklet multiplicity";
177 iBinPair[0] = kMultBins;
178 dBinsPair[0] = kMultBinLimits;
179 axisTitlePair[0] = "kTPCITStracklet multiplicity";
181 if(fEventClass == "Centrality"){
182 iBinSingle[0] = kNCentralityBins;
183 dBinsSingle[0] = centralityBins;
184 axisTitleSingle[0] = "Centrality percentile [%]";
185 iBinPair[0] = kNCentralityBins;
186 dBinsPair[0] = centralityBins;
187 axisTitlePair[0] = "Centrality percentile [%]";
189 if(fEventClass == "EventPlane"){
190 iBinSingle[0] = kNPsi2Bins;
191 dBinsSingle[0] = psi2Bins;
192 axisTitleSingle[0] = "#varphi - #Psi_{2} (a.u.)";
193 iBinPair[0] = kNPsi2Bins;
194 dBinsPair[0] = psi2Bins;
195 axisTitlePair[0] = "#varphi - #Psi_{2} (a.u.)";
199 const Int_t kNDeltaEtaBins = 80;
200 Double_t deltaEtaBins[kNDeltaEtaBins+1];
201 for(Int_t i = 0; i < kNDeltaEtaBins+1; i++)
202 deltaEtaBins[i] = - fDeltaEtaMax + i * 2 * fDeltaEtaMax / (Double_t)kNDeltaEtaBins;
203 iBinPair[1] = kNDeltaEtaBins;
204 dBinsPair[1] = deltaEtaBins;
205 axisTitlePair[1] = "#Delta#eta";
208 const Int_t kNDeltaPhiBins = 72;
209 Double_t deltaPhiBins[kNDeltaPhiBins+1];
210 for(Int_t i = 0; i < kNDeltaPhiBins+1; i++){
211 //deltaPhiBins[i] = -180.0 + i * 5.;
212 deltaPhiBins[i] = -TMath::Pi()/2. + i * 5.*TMath::Pi()/180.;
214 iBinPair[2] = kNDeltaPhiBins;
215 dBinsPair[2] = deltaPhiBins;
216 axisTitlePair[2] = "#Delta#varphi (rad)";
218 // pt(trigger-associated)
219 const Int_t kNPtBins = 16;
220 Double_t ptBins[kNPtBins+1] = {0.2,0.6,1.0,1.5,2.0,2.5,3.0,3.5,4.0,5.0,6.0,7.0,8.0,10.,12.,15.,20.};
221 //for(Int_t i = 0; i < kNPtBins+1; i++){
222 //ptBins[i] = 0.2 + i * 0.5;
224 iBinSingle[1] = kNPtBins;
225 dBinsSingle[1] = ptBins;
226 axisTitleSingle[1] = "p_{T,trig.} (GeV/c)";
228 iBinPair[3] = kNPtBins;
229 dBinsPair[3] = ptBins;
230 axisTitlePair[3] = "p_{T,trig.} (GeV/c)";
232 iBinPair[4] = kNPtBins;
233 dBinsPair[4] = ptBins;
234 axisTitlePair[4] = "p_{T,assoc.} (GeV/c)";
237 //+ triggered particles
239 if(fShuffle) histName.Append("_shuffle");
240 if(fCentralityId) histName += fCentralityId.Data();
241 fHistP = new AliTHn(histName.Data(),histName.Data(),anaSteps,kTrackVariablesSingle,iBinSingle);
242 for (Int_t j=0; j<kTrackVariablesSingle; j++) {
243 fHistP->SetBinLimits(j, dBinsSingle[j]);
244 fHistP->SetVarTitle(j, axisTitleSingle[j]);
247 //- triggered particles
249 if(fShuffle) histName.Append("_shuffle");
250 if(fCentralityId) histName += fCentralityId.Data();
251 fHistN = new AliTHn(histName.Data(),histName.Data(),anaSteps,kTrackVariablesSingle,iBinSingle);
252 for (Int_t j=0; j<kTrackVariablesSingle; j++) {
253 fHistN->SetBinLimits(j, dBinsSingle[j]);
254 fHistN->SetVarTitle(j, axisTitleSingle[j]);
258 histName = "fHistPN";
259 if(fShuffle) histName.Append("_shuffle");
260 if(fCentralityId) histName += fCentralityId.Data();
261 fHistPN = new AliTHn(histName.Data(),histName.Data(),anaSteps, kTrackVariablesPair, iBinPair);
262 for (Int_t j=0; j<kTrackVariablesPair; j++) {
263 fHistPN->SetBinLimits(j, dBinsPair[j]);
264 fHistPN->SetVarTitle(j, axisTitlePair[j]);
268 histName = "fHistNP";
269 if(fShuffle) histName.Append("_shuffle");
270 if(fCentralityId) histName += fCentralityId.Data();
271 fHistNP = new AliTHn(histName.Data(),histName.Data(),anaSteps, kTrackVariablesPair, iBinPair);
272 for (Int_t j=0; j<kTrackVariablesPair; j++) {
273 fHistNP->SetBinLimits(j, dBinsPair[j]);
274 fHistNP->SetVarTitle(j, axisTitlePair[j]);
278 histName = "fHistPP";
279 if(fShuffle) histName.Append("_shuffle");
280 if(fCentralityId) histName += fCentralityId.Data();
281 fHistPP = new AliTHn(histName.Data(),histName.Data(),anaSteps, kTrackVariablesPair, iBinPair);
282 for (Int_t j=0; j<kTrackVariablesPair; j++) {
283 fHistPP->SetBinLimits(j, dBinsPair[j]);
284 fHistPP->SetVarTitle(j, axisTitlePair[j]);
288 histName = "fHistNN";
289 if(fShuffle) histName.Append("_shuffle");
290 if(fCentralityId) histName += fCentralityId.Data();
291 fHistNN = new AliTHn(histName.Data(),histName.Data(),anaSteps, kTrackVariablesPair, iBinPair);
292 for (Int_t j=0; j<kTrackVariablesPair; j++) {
293 fHistNN->SetBinLimits(j, dBinsPair[j]);
294 fHistNN->SetVarTitle(j, axisTitlePair[j]);
296 AliInfo("Finished setting up the AliTHn");
299 fHistHBTbefore = new TH2D("fHistHBTbefore","before HBT cut",200,0,2,200,0,2.*TMath::Pi());
300 fHistHBTafter = new TH2D("fHistHBTafter","after HBT cut",200,0,2,200,0,2.*TMath::Pi());
301 fHistConversionbefore = new TH2D("fHistConversionbefore","before Conversion cut",200,0,2,200,0,2.*TMath::Pi());
302 fHistConversionafter = new TH2D("fHistConversionafter","after Conversion cut",200,0,2,200,0,2.*TMath::Pi());
303 fHistPsiMinusPhi = new TH2D("fHistPsiMinusPhi","",4,-0.5,3.5,100,0,2.*TMath::Pi());
305 TH1::AddDirectory(oldStatus);
309 //____________________________________________________________________//
310 void AliBalancePsi::CalculateBalance(Double_t gReactionPlane,
311 TObjArray *particles,
312 TObjArray *particlesMixed,
314 Double_t kMultorCent) {
315 // Calculates the balance function
318 // Initialize histograms if not done yet
320 AliWarning("Histograms not yet initialized! --> Will be done now");
321 AliWarning("This works only in local mode --> Add 'gBalance->InitHistograms()' in your configBalanceFunction");
325 Double_t trackVariablesSingle[kTrackVariablesSingle];
326 Double_t trackVariablesPair[kTrackVariablesPair];
329 AliWarning("particles TObjArray is NULL pointer --> return");
333 // define end of particle loops
334 Int_t iMax = particles->GetEntriesFast();
337 jMax = particlesMixed->GetEntriesFast();
339 // Eta() is extremely time consuming, therefore cache it for the inner loop here:
340 TObjArray* particlesSecond = (particlesMixed) ? particlesMixed : particles;
342 TArrayF secondEta(jMax);
343 TArrayF secondPhi(jMax);
344 TArrayF secondPt(jMax);
345 TArrayS secondCharge(jMax);
346 TArrayD secondCorrection(jMax);
348 for (Int_t i=0; i<jMax; i++){
349 secondEta[i] = ((AliVParticle*) particlesSecond->At(i))->Eta();
350 secondPhi[i] = ((AliVParticle*) particlesSecond->At(i))->Phi();
351 secondPt[i] = ((AliVParticle*) particlesSecond->At(i))->Pt();
352 secondCharge[i] = (Short_t)((AliVParticle*) particlesSecond->At(i))->Charge();
353 secondCorrection[i] = (Double_t)((AliBFBasicParticle*) particlesSecond->At(i))->Correction(); //==========================correction
357 for (Int_t i = 0; i < iMax; i++) {
358 //AliVParticle* firstParticle = (AliVParticle*) particles->At(i);
359 AliBFBasicParticle* firstParticle = (AliBFBasicParticle*) particles->At(i); //==========================correction
362 Float_t firstEta = firstParticle->Eta();
363 Float_t firstPhi = firstParticle->Phi();
364 Float_t firstPt = firstParticle->Pt();
365 Float_t firstCorrection = firstParticle->Correction();//==========================correction
367 // Event plane (determine psi bin)
368 Double_t gPsiMinusPhi = 0.;
369 Double_t gPsiMinusPhiBin = -10.;
370 gPsiMinusPhi = TMath::Abs(firstPhi - gReactionPlane);
372 if((gPsiMinusPhi <= 7.5*TMath::DegToRad())||
373 ((172.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 187.5*TMath::DegToRad())))
374 gPsiMinusPhiBin = 0.0;
376 else if(((37.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 52.5*TMath::DegToRad()))||
377 ((127.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 142.5*TMath::DegToRad()))||
378 ((217.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 232.5*TMath::DegToRad()))||
379 ((307.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 322.5*TMath::DegToRad())))
380 gPsiMinusPhiBin = 1.0;
382 else if(((82.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 97.5*TMath::DegToRad()))||
383 ((262.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 277.5*TMath::DegToRad())))
384 gPsiMinusPhiBin = 2.0;
387 gPsiMinusPhiBin = 3.0;
389 fHistPsiMinusPhi->Fill(gPsiMinusPhiBin,gPsiMinusPhi);
391 Short_t charge1 = (Short_t) firstParticle->Charge();
393 trackVariablesSingle[0] = gPsiMinusPhiBin;
394 trackVariablesSingle[1] = firstPt;
395 if(fEventClass=="Multiplicity" || fEventClass == "Centrality" ) trackVariablesSingle[0] = kMultorCent;
397 //fill single particle histograms
398 if(charge1 > 0) fHistP->Fill(trackVariablesSingle,0,firstCorrection); //==========================correction
399 else if(charge1 < 0) fHistN->Fill(trackVariablesSingle,0,firstCorrection); //==========================correction
402 for(Int_t j = 0; j < jMax; j++) {
404 if(!particlesMixed && j == i) continue; // no auto correlations (only for non mixing)
406 // pT,Assoc < pT,Trig
407 if(firstPt < secondPt[j]) continue;
409 Short_t charge2 = secondCharge[j];
411 trackVariablesPair[0] = trackVariablesSingle[0];
412 trackVariablesPair[1] = firstEta - secondEta[j]; // delta eta
413 trackVariablesPair[2] = firstPhi - secondPhi[j]; // delta phi
414 //if (trackVariablesPair[2] > 180.) // delta phi between -180 and 180
415 //trackVariablesPair[2] -= 360.;
416 //if (trackVariablesPair[2] < - 180.)
417 //trackVariablesPair[2] += 360.;
418 if (trackVariablesPair[2] > TMath::Pi()) // delta phi between -pi and pi
419 trackVariablesPair[2] -= 2.*TMath::Pi();
420 if (trackVariablesPair[2] < - TMath::Pi())
421 trackVariablesPair[2] += 2.*TMath::Pi();
422 if (trackVariablesPair[2] < - TMath::Pi()/2.)
423 trackVariablesPair[2] += 2.*TMath::Pi();
425 trackVariablesPair[3] = firstPt; // pt trigger
426 trackVariablesPair[4] = secondPt[j]; // pt
427 // trackVariablesPair[5] = fCentrality; // centrality
430 if(fHBTCut){ // VERSION 3 (all pairs)
431 //if(fHBTCut && charge1 * charge2 > 0){ // VERSION 2 (only for LS)
432 //if( dphi < 3 || deta < 0.01 ){ // VERSION 1
435 Double_t deta = firstEta - secondEta[j];
436 Double_t dphi = firstPhi - secondPhi[j];
437 // VERSION 2 (Taken from DPhiCorrelations)
438 // the variables & cuthave been developed by the HBT group
439 // see e.g. https://indico.cern.ch/materialDisplay.py?contribId=36&sessionId=6&materialId=slides&confId=142700
440 fHistHBTbefore->Fill(deta,dphi);
443 if (TMath::Abs(deta) < 0.02 * 2.5 * 3) //twoTrackEfficiencyCutValue = 0.02 [default for dphicorrelations]
446 //Float_t phi1rad = firstPhi*TMath::DegToRad();
447 //Float_t phi2rad = secondPhi[j]*TMath::DegToRad();
448 Float_t phi1rad = firstPhi;
449 Float_t phi2rad = secondPhi[j];
451 // check first boundaries to see if is worth to loop and find the minimum
452 Float_t dphistar1 = GetDPhiStar(phi1rad, firstPt, charge1, phi2rad, secondPt[j], charge2, 0.8, bSign);
453 Float_t dphistar2 = GetDPhiStar(phi1rad, firstPt, charge1, phi2rad, secondPt[j], charge2, 2.5, bSign);
455 const Float_t kLimit = 0.02 * 3;
457 Float_t dphistarminabs = 1e5;
458 Float_t dphistarmin = 1e5;
460 if (TMath::Abs(dphistar1) < kLimit || TMath::Abs(dphistar2) < kLimit || dphistar1 * dphistar2 < 0 ) {
461 for (Double_t rad=0.8; rad<2.51; rad+=0.01) {
462 Float_t dphistar = GetDPhiStar(phi1rad, firstPt, charge1, phi2rad, secondPt[j], charge2, rad, bSign);
463 Float_t dphistarabs = TMath::Abs(dphistar);
465 if (dphistarabs < dphistarminabs) {
466 dphistarmin = dphistar;
467 dphistarminabs = dphistarabs;
471 if (dphistarminabs < 0.02 && TMath::Abs(deta) < 0.02) {
472 //AliInfo(Form("HBT: Removed track pair %d %d with [[%f %f]] %f %f %f | %f %f %d %f %f %d %f", i, j, deta, dphi, dphistarminabs, dphistar1, dphistar2, phi1rad, pt1, charge1, phi2rad, pt2, charge2, bSign));
477 fHistHBTafter->Fill(deta,dphi);
482 if (charge1 * charge2 < 0) {
483 Double_t deta = firstEta - secondEta[j];
484 Double_t dphi = firstPhi - secondPhi[j];
485 fHistConversionbefore->Fill(deta,dphi);
487 Float_t m0 = 0.510e-3;
488 Float_t tantheta1 = 1e10;
491 //Float_t phi1rad = firstPhi*TMath::DegToRad();
492 //Float_t phi2rad = secondPhi[j]*TMath::DegToRad();
493 Float_t phi1rad = firstPhi;
494 Float_t phi2rad = secondPhi[j];
496 if (firstEta < -1e-10 || firstEta > 1e-10)
497 tantheta1 = 2 * TMath::Exp(-firstEta) / ( 1 - TMath::Exp(-2*firstEta));
499 Float_t tantheta2 = 1e10;
500 if (secondEta[j] < -1e-10 || secondEta[j] > 1e-10)
501 tantheta2 = 2 * TMath::Exp(-secondEta[j]) / ( 1 - TMath::Exp(-2*secondEta[j]));
503 Float_t e1squ = m0 * m0 + firstPt * firstPt * (1.0 + 1.0 / tantheta1 / tantheta1);
504 Float_t e2squ = m0 * m0 + secondPt[j] * secondPt[j] * (1.0 + 1.0 / tantheta2 / tantheta2);
506 Float_t masssqu = 2 * m0 * m0 + 2 * ( TMath::Sqrt(e1squ * e2squ) - ( firstPt * secondPt[j] * ( TMath::Cos(phi1rad - phi2rad) + 1.0 / tantheta1 / tantheta2 ) ) );
508 if (masssqu < 0.04*0.04){
509 //AliInfo(Form("Conversion: Removed track pair %d %d with [[%f %f] %f %f] %d %d <- %f %f %f %f %f %f ", i, j, deta, dphi, masssqu, charge1, charge2,eta1,eta2,phi1,phi2,pt1,pt2));
512 fHistConversionafter->Fill(deta,dphi);
516 if( charge1 > 0 && charge2 < 0) fHistPN->Fill(trackVariablesPair,0,firstCorrection*secondCorrection[j]); //==========================correction
517 else if( charge1 < 0 && charge2 > 0) fHistNP->Fill(trackVariablesPair,0,firstCorrection*secondCorrection[j]);//==========================correction
518 else if( charge1 > 0 && charge2 > 0) fHistPP->Fill(trackVariablesPair,0,firstCorrection*secondCorrection[j]);//==========================correction
519 else if( charge1 < 0 && charge2 < 0) fHistNN->Fill(trackVariablesPair,0,firstCorrection*secondCorrection[j]);//==========================correction
521 //AliWarning(Form("Wrong charge combination: charge1 = %d and charge2 = %d",charge,charge2));
524 }//end of 2nd particle loop
525 }//end of 1st particle loop
528 //____________________________________________________________________//
529 TH1D *AliBalancePsi::GetBalanceFunctionHistogram(Int_t iVariableSingle,
533 Double_t ptTriggerMin,
534 Double_t ptTriggerMax,
535 Double_t ptAssociatedMin,
536 Double_t ptAssociatedMax) {
537 //Returns the BF histogram, extracted from the 6 AliTHn objects
538 //(private members) of the AliBalancePsi class.
539 //iVariableSingle: 0(phi-Psi), 1(pt-trigger)
540 //iVariablePair: 0(phi-Psi) 1(Delta eta), 2(Delta phi), 3(pt-trigger), 4(pt-associated
542 fHistP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
543 fHistN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
544 fHistPN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
545 fHistNP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
546 fHistPP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
547 fHistNN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
550 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
551 fHistP->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
552 fHistN->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
553 fHistPN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
554 fHistNP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
555 fHistPP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
556 fHistNN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
560 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.)) {
561 fHistPN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
562 fHistNP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
563 fHistPP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
564 fHistNN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
567 //Printf("P:%lf - N:%lf - PN:%lf - NP:%lf - PP:%lf - NN:%lf",fHistP->GetEntries(0),fHistN->GetEntries(0),fHistPN->GetEntries(0),fHistNP->GetEntries(0),fHistPP->GetEntries(0),fHistNN->GetEntries(0));
569 // Project into the wanted space (1st: analysis step, 2nd: axis)
570 TH1D* hTemp1 = (TH1D*)fHistPN->Project(0,iVariablePair);
571 TH1D* hTemp2 = (TH1D*)fHistNP->Project(0,iVariablePair);
572 TH1D* hTemp3 = (TH1D*)fHistPP->Project(0,iVariablePair);
573 TH1D* hTemp4 = (TH1D*)fHistNN->Project(0,iVariablePair);
574 TH1D* hTemp5 = (TH1D*)fHistP->Project(0,iVariableSingle);
575 TH1D* hTemp6 = (TH1D*)fHistN->Project(0,iVariableSingle);
577 TH1D *gHistBalanceFunctionHistogram = 0x0;
578 if((hTemp1)&&(hTemp2)&&(hTemp3)&&(hTemp4)&&(hTemp5)&&(hTemp6)) {
579 gHistBalanceFunctionHistogram = (TH1D*)hTemp1->Clone();
580 gHistBalanceFunctionHistogram->Reset();
582 switch(iVariablePair) {
584 gHistBalanceFunctionHistogram->GetXaxis()->SetTitle("#Delta#eta");
585 gHistBalanceFunctionHistogram->GetYaxis()->SetTitle("B(#Delta#eta)");
588 gHistBalanceFunctionHistogram->GetXaxis()->SetTitle("#Delta#varphi (rad)");
589 gHistBalanceFunctionHistogram->GetYaxis()->SetTitle("B(#Delta#varphi)");
599 hTemp1->Add(hTemp3,-1.);
600 hTemp1->Scale(1./hTemp5->GetEntries());
601 hTemp2->Add(hTemp4,-1.);
602 hTemp2->Scale(1./hTemp6->GetEntries());
603 gHistBalanceFunctionHistogram->Add(hTemp1,hTemp2,1.,1.);
604 gHistBalanceFunctionHistogram->Scale(0.5);
606 //normalize to bin width
607 gHistBalanceFunctionHistogram->Scale(1./((Double_t)gHistBalanceFunctionHistogram->GetXaxis()->GetBinWidth(1)*(Double_t)gHistBalanceFunctionHistogram->GetYaxis()->GetBinWidth(1)));
610 return gHistBalanceFunctionHistogram;
613 //____________________________________________________________________//
614 TH1D *AliBalancePsi::GetBalanceFunctionHistogram2pMethod(Int_t iVariableSingle,
618 Double_t ptTriggerMin,
619 Double_t ptTriggerMax,
620 Double_t ptAssociatedMin,
621 Double_t ptAssociatedMax,
622 AliBalancePsi *bfMix) {
623 //Returns the BF histogram, extracted from the 6 AliTHn objects
624 //after dividing each correlation function by the Event Mixing one
625 //(private members) of the AliBalancePsi class.
626 //iVariableSingle: 0(phi-Psi), 1(pt-trigger)
627 //iVariablePair: 0(phi-Psi) 1(Delta eta), 2(Delta phi), 3(pt-trigger), 4(pt-associated
629 fHistP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
630 fHistN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
631 fHistPN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
632 fHistNP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
633 fHistPP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
634 fHistNN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
637 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
638 fHistP->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
639 fHistN->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
640 fHistPN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
641 fHistNP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
642 fHistPP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
643 fHistNN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
647 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.)) {
648 fHistPN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
649 fHistNP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
650 fHistPP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
651 fHistNN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
654 // ============================================================================================
655 // the same for event mixing
656 AliTHn *fHistPMix = bfMix->GetHistNp();
657 AliTHn *fHistNMix = bfMix->GetHistNn();
658 AliTHn *fHistPNMix = bfMix->GetHistNpn();
659 AliTHn *fHistNPMix = bfMix->GetHistNnp();
660 AliTHn *fHistPPMix = bfMix->GetHistNpp();
661 AliTHn *fHistNNMix = bfMix->GetHistNnn();
664 fHistPMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
665 fHistNMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
666 fHistPNMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
667 fHistNPMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
668 fHistPPMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
669 fHistNNMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
672 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
673 fHistPMix->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
674 fHistNMix->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
675 fHistPNMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
676 fHistNPMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
677 fHistPPMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
678 fHistNNMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
682 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.)) {
683 fHistPNMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
684 fHistNPMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
685 fHistPPMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
686 fHistNNMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
688 // ============================================================================================
690 //Printf("P:%lf - N:%lf - PN:%lf - NP:%lf - PP:%lf - NN:%lf",fHistP->GetEntries(0),fHistN->GetEntries(0),fHistPN->GetEntries(0),fHistNP->GetEntries(0),fHistPP->GetEntries(0),fHistNN->GetEntries(0));
692 // Project into the wanted space (1st: analysis step, 2nd: axis)
693 TH1D* hTemp1 = (TH1D*)fHistPN->Project(0,iVariablePair);
694 TH1D* hTemp2 = (TH1D*)fHistNP->Project(0,iVariablePair);
695 TH1D* hTemp3 = (TH1D*)fHistPP->Project(0,iVariablePair);
696 TH1D* hTemp4 = (TH1D*)fHistNN->Project(0,iVariablePair);
697 TH1D* hTemp5 = (TH1D*)fHistP->Project(0,iVariableSingle);
698 TH1D* hTemp6 = (TH1D*)fHistN->Project(0,iVariableSingle);
700 // ============================================================================================
701 // the same for event mixing
702 TH2D* hTemp1Mix = (TH2D*)fHistPNMix->Project(0,iVariablePair);
703 TH2D* hTemp2Mix = (TH2D*)fHistNPMix->Project(0,iVariablePair);
704 TH2D* hTemp3Mix = (TH2D*)fHistPPMix->Project(0,iVariablePair);
705 TH2D* hTemp4Mix = (TH2D*)fHistNNMix->Project(0,iVariablePair);
706 TH1D* hTemp5Mix = (TH1D*)fHistPMix->Project(0,iVariableSingle);
707 TH1D* hTemp6Mix = (TH1D*)fHistNMix->Project(0,iVariableSingle);
708 // ============================================================================================
710 TH1D *gHistBalanceFunctionHistogram = 0x0;
711 if((hTemp1)&&(hTemp2)&&(hTemp3)&&(hTemp4)&&(hTemp5)&&(hTemp6)) {
712 gHistBalanceFunctionHistogram = (TH1D*)hTemp1->Clone();
713 gHistBalanceFunctionHistogram->Reset();
715 switch(iVariablePair) {
717 gHistBalanceFunctionHistogram->GetXaxis()->SetTitle("#Delta#eta");
718 gHistBalanceFunctionHistogram->GetYaxis()->SetTitle("B(#Delta#eta)");
721 gHistBalanceFunctionHistogram->GetXaxis()->SetTitle("#Delta#varphi (rad)");
722 gHistBalanceFunctionHistogram->GetYaxis()->SetTitle("B(#Delta#varphi)");
737 hTemp1->Scale(1./hTemp5->GetEntries());
738 hTemp3->Scale(1./hTemp5->GetEntries());
739 hTemp2->Scale(1./hTemp6->GetEntries());
740 hTemp4->Scale(1./hTemp6->GetEntries());
741 hTemp1Mix->Scale(1./hTemp5Mix->GetEntries());
742 hTemp3Mix->Scale(1./hTemp5Mix->GetEntries());
743 hTemp2Mix->Scale(1./hTemp6Mix->GetEntries());
744 hTemp4Mix->Scale(1./hTemp6Mix->GetEntries());
746 hTemp1->Divide(hTemp1Mix);
747 hTemp2->Divide(hTemp2Mix);
748 hTemp3->Divide(hTemp3Mix);
749 hTemp4->Divide(hTemp4Mix);
751 hTemp1->Add(hTemp3,-1.);
752 hTemp2->Add(hTemp4,-1.);
754 gHistBalanceFunctionHistogram->Add(hTemp1,hTemp2,1.,1.);
755 gHistBalanceFunctionHistogram->Scale(0.5);
757 //normalize to bin width
758 gHistBalanceFunctionHistogram->Scale(1./((Double_t)gHistBalanceFunctionHistogram->GetXaxis()->GetBinWidth(1)*(Double_t)gHistBalanceFunctionHistogram->GetYaxis()->GetBinWidth(1)));
761 return gHistBalanceFunctionHistogram;
764 //____________________________________________________________________//
765 TH2D *AliBalancePsi::GetBalanceFunctionDeltaEtaDeltaPhi(Double_t psiMin,
767 Double_t ptTriggerMin,
768 Double_t ptTriggerMax,
769 Double_t ptAssociatedMin,
770 Double_t ptAssociatedMax) {
771 //Returns the BF histogram in Delta eta vs Delta phi,
772 //extracted from the 6 AliTHn objects
773 //(private members) of the AliBalancePsi class.
774 //iVariableSingle: 0(phi-Psi), 1(pt-trigger)
775 //iVariablePair: 0(phi-Psi) 1(Delta eta), 2(Delta phi), 3(pt-trigger), 4(pt-associated
776 TString histName = "gHistBalanceFunctionHistogram2D";
779 fHistP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
780 fHistN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
781 fHistPN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
782 fHistNP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
783 fHistPP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
784 fHistNN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
787 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
788 fHistP->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
789 fHistN->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
790 fHistPN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
791 fHistNP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
792 fHistPP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
793 fHistNN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
797 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.)) {
798 fHistPN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
799 fHistNP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
800 fHistPP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
801 fHistNN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
804 //AliInfo(Form("P:%lf - N:%lf - PN:%lf - NP:%lf - PP:%lf - NN:%lf",fHistP->GetEntries(0),fHistN->GetEntries(0),fHistPN->GetEntries(0),fHistNP->GetEntries(0),fHistPP->GetEntries(0),fHistNN->GetEntries(0)));
806 // Project into the wanted space (1st: analysis step, 2nd: axis)
807 TH2D* hTemp1 = (TH2D*)fHistPN->Project(0,1,2);
808 TH2D* hTemp2 = (TH2D*)fHistNP->Project(0,1,2);
809 TH2D* hTemp3 = (TH2D*)fHistPP->Project(0,1,2);
810 TH2D* hTemp4 = (TH2D*)fHistNN->Project(0,1,2);
811 TH1D* hTemp5 = (TH1D*)fHistP->Project(0,1);
812 TH1D* hTemp6 = (TH1D*)fHistN->Project(0,1);
814 TH2D *gHistBalanceFunctionHistogram = 0x0;
815 if((hTemp1)&&(hTemp2)&&(hTemp3)&&(hTemp4)&&(hTemp5)&&(hTemp6)) {
816 gHistBalanceFunctionHistogram = (TH2D*)hTemp1->Clone();
817 gHistBalanceFunctionHistogram->Reset();
818 gHistBalanceFunctionHistogram->GetXaxis()->SetTitle("#Delta#eta");
819 gHistBalanceFunctionHistogram->GetYaxis()->SetTitle("#Delta#varphi (rad)");
820 gHistBalanceFunctionHistogram->GetZaxis()->SetTitle("B(#Delta#eta,#Delta#varphi)");
826 hTemp1->Add(hTemp3,-1.);
827 hTemp1->Scale(1./hTemp5->GetEntries());
828 hTemp2->Add(hTemp4,-1.);
829 hTemp2->Scale(1./hTemp6->GetEntries());
830 gHistBalanceFunctionHistogram->Add(hTemp1,hTemp2,1.,1.);
831 gHistBalanceFunctionHistogram->Scale(0.5);
833 //normalize to bin width
834 gHistBalanceFunctionHistogram->Scale(1./((Double_t)gHistBalanceFunctionHistogram->GetXaxis()->GetBinWidth(1)*(Double_t)gHistBalanceFunctionHistogram->GetYaxis()->GetBinWidth(1)));
837 return gHistBalanceFunctionHistogram;
840 //____________________________________________________________________//
841 TH2D *AliBalancePsi::GetBalanceFunctionDeltaEtaDeltaPhi2pMethod(Double_t psiMin,
843 Double_t ptTriggerMin,
844 Double_t ptTriggerMax,
845 Double_t ptAssociatedMin,
846 Double_t ptAssociatedMax,
847 AliBalancePsi *bfMix) {
848 //Returns the BF histogram in Delta eta vs Delta phi,
849 //after dividing each correlation function by the Event Mixing one
850 //extracted from the 6 AliTHn objects
851 //(private members) of the AliBalancePsi class.
852 //iVariableSingle: 0(phi-Psi), 1(pt-trigger)
853 //iVariablePair: 0(phi-Psi) 1(Delta eta), 2(Delta phi), 3(pt-trigger), 4(pt-associated
854 TString histName = "gHistBalanceFunctionHistogram2D";
857 AliError("balance function object for event mixing not available");
862 fHistP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
863 fHistN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
864 fHistPN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
865 fHistNP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
866 fHistPP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
867 fHistNN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
870 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
871 fHistP->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
872 fHistN->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
873 fHistPN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
874 fHistNP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
875 fHistPP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
876 fHistNN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
880 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.)) {
881 fHistPN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
882 fHistNP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
883 fHistPP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
884 fHistNN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
888 // ============================================================================================
889 // the same for event mixing
890 AliTHn *fHistPMix = bfMix->GetHistNp();
891 AliTHn *fHistNMix = bfMix->GetHistNn();
892 AliTHn *fHistPNMix = bfMix->GetHistNpn();
893 AliTHn *fHistNPMix = bfMix->GetHistNnp();
894 AliTHn *fHistPPMix = bfMix->GetHistNpp();
895 AliTHn *fHistNNMix = bfMix->GetHistNnn();
898 fHistPMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
899 fHistNMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
900 fHistPNMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
901 fHistNPMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
902 fHistPPMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
903 fHistNNMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
906 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
907 fHistPMix->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
908 fHistNMix->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
909 fHistPNMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
910 fHistNPMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
911 fHistPPMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
912 fHistNNMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
916 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.)) {
917 fHistPNMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
918 fHistNPMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
919 fHistPPMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
920 fHistNNMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
922 // ============================================================================================
925 //AliInfo(Form("P:%lf - N:%lf - PN:%lf - NP:%lf - PP:%lf - NN:%lf",fHistP->GetEntries(0),fHistN->GetEntries(0),fHistPN->GetEntries(0),fHistNP->GetEntries(0),fHistPP->GetEntries(0),fHistNN->GetEntries(0)));
927 // Project into the wanted space (1st: analysis step, 2nd: axis)
928 TH2D* hTemp1 = (TH2D*)fHistPN->Project(0,1,2);
929 TH2D* hTemp2 = (TH2D*)fHistNP->Project(0,1,2);
930 TH2D* hTemp3 = (TH2D*)fHistPP->Project(0,1,2);
931 TH2D* hTemp4 = (TH2D*)fHistNN->Project(0,1,2);
932 TH1D* hTemp5 = (TH1D*)fHistP->Project(0,1);
933 TH1D* hTemp6 = (TH1D*)fHistN->Project(0,1);
935 // ============================================================================================
936 // the same for event mixing
937 TH2D* hTemp1Mix = (TH2D*)fHistPNMix->Project(0,1,2);
938 TH2D* hTemp2Mix = (TH2D*)fHistNPMix->Project(0,1,2);
939 TH2D* hTemp3Mix = (TH2D*)fHistPPMix->Project(0,1,2);
940 TH2D* hTemp4Mix = (TH2D*)fHistNNMix->Project(0,1,2);
941 TH1D* hTemp5Mix = (TH1D*)fHistPMix->Project(0,1);
942 TH1D* hTemp6Mix = (TH1D*)fHistNMix->Project(0,1);
943 // ============================================================================================
945 TH2D *gHistBalanceFunctionHistogram = 0x0;
946 if((hTemp1)&&(hTemp2)&&(hTemp3)&&(hTemp4)&&(hTemp5)&&(hTemp6)) {
947 gHistBalanceFunctionHistogram = (TH2D*)hTemp1->Clone();
948 gHistBalanceFunctionHistogram->Reset();
949 gHistBalanceFunctionHistogram->GetXaxis()->SetTitle("#Delta#eta");
950 gHistBalanceFunctionHistogram->GetYaxis()->SetTitle("#Delta#varphi (rad)");
951 gHistBalanceFunctionHistogram->GetZaxis()->SetTitle("B(#Delta#eta,#Delta#varphi)");
962 hTemp1->Scale(1./hTemp5->GetEntries());
963 hTemp3->Scale(1./hTemp5->GetEntries());
964 hTemp2->Scale(1./hTemp6->GetEntries());
965 hTemp4->Scale(1./hTemp6->GetEntries());
966 hTemp1Mix->Scale(1./hTemp5Mix->GetEntries());
967 hTemp3Mix->Scale(1./hTemp5Mix->GetEntries());
968 hTemp2Mix->Scale(1./hTemp6Mix->GetEntries());
969 hTemp4Mix->Scale(1./hTemp6Mix->GetEntries());
971 hTemp1->Divide(hTemp1Mix);
972 hTemp2->Divide(hTemp2Mix);
973 hTemp3->Divide(hTemp3Mix);
974 hTemp4->Divide(hTemp4Mix);
976 hTemp1->Add(hTemp3,-1.);
977 hTemp2->Add(hTemp4,-1.);
979 gHistBalanceFunctionHistogram->Add(hTemp1,hTemp2,1.,1.);
980 gHistBalanceFunctionHistogram->Scale(0.5);
982 //normalize to bin width
983 gHistBalanceFunctionHistogram->Scale(1./((Double_t)gHistBalanceFunctionHistogram->GetXaxis()->GetBinWidth(1)*(Double_t)gHistBalanceFunctionHistogram->GetYaxis()->GetBinWidth(1)));
986 return gHistBalanceFunctionHistogram;
989 //____________________________________________________________________//
990 TH1D *AliBalancePsi::GetBalanceFunction1DFrom2D2pMethod(Bool_t bPhi,
993 Double_t ptTriggerMin,
994 Double_t ptTriggerMax,
995 Double_t ptAssociatedMin,
996 Double_t ptAssociatedMax,
997 AliBalancePsi *bfMix) {
998 //Returns the BF histogram in Delta eta OR Delta phi,
999 //after dividing each correlation function by the Event Mixing one
1000 // (But the division is done here in 2D, this was basically done to check the Integral)
1001 //extracted from the 6 AliTHn objects
1002 //(private members) of the AliBalancePsi class.
1003 //iVariableSingle: 0(phi-Psi), 1(pt-trigger)
1004 //iVariablePair: 0(phi-Psi) 1(Delta eta), 2(Delta phi), 3(pt-trigger), 4(pt-associated
1005 TString histName = "gHistBalanceFunctionHistogram1D";
1008 AliError("balance function object for event mixing not available");
1013 fHistP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1014 fHistN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1015 fHistPN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1016 fHistNP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1017 fHistPP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1018 fHistNN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1021 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
1022 fHistP->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1023 fHistN->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1024 fHistPN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1025 fHistNP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1026 fHistPP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1027 fHistNN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1031 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.)) {
1032 fHistPN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1033 fHistNP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1034 fHistPP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1035 fHistNN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1039 // ============================================================================================
1040 // the same for event mixing
1041 AliTHn *fHistPMix = bfMix->GetHistNp();
1042 AliTHn *fHistNMix = bfMix->GetHistNn();
1043 AliTHn *fHistPNMix = bfMix->GetHistNpn();
1044 AliTHn *fHistNPMix = bfMix->GetHistNnp();
1045 AliTHn *fHistPPMix = bfMix->GetHistNpp();
1046 AliTHn *fHistNNMix = bfMix->GetHistNnn();
1049 fHistPMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1050 fHistNMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1051 fHistPNMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1052 fHistNPMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1053 fHistPPMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1054 fHistNNMix->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1057 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
1058 fHistPMix->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1059 fHistNMix->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1060 fHistPNMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1061 fHistNPMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1062 fHistPPMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1063 fHistNNMix->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1067 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.)) {
1068 fHistPNMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1069 fHistNPMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1070 fHistPPMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1071 fHistNNMix->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1073 // ============================================================================================
1076 //AliInfo(Form("P:%lf - N:%lf - PN:%lf - NP:%lf - PP:%lf - NN:%lf",fHistP->GetEntries(0),fHistN->GetEntries(0),fHistPN->GetEntries(0),fHistNP->GetEntries(0),fHistPP->GetEntries(0),fHistNN->GetEntries(0)));
1078 // Project into the wanted space (1st: analysis step, 2nd: axis)
1079 TH2D* hTemp1 = (TH2D*)fHistPN->Project(0,1,2);
1080 TH2D* hTemp2 = (TH2D*)fHistNP->Project(0,1,2);
1081 TH2D* hTemp3 = (TH2D*)fHistPP->Project(0,1,2);
1082 TH2D* hTemp4 = (TH2D*)fHistNN->Project(0,1,2);
1083 TH1D* hTemp5 = (TH1D*)fHistP->Project(0,1);
1084 TH1D* hTemp6 = (TH1D*)fHistN->Project(0,1);
1086 // ============================================================================================
1087 // the same for event mixing
1088 TH2D* hTemp1Mix = (TH2D*)fHistPNMix->Project(0,1,2);
1089 TH2D* hTemp2Mix = (TH2D*)fHistNPMix->Project(0,1,2);
1090 TH2D* hTemp3Mix = (TH2D*)fHistPPMix->Project(0,1,2);
1091 TH2D* hTemp4Mix = (TH2D*)fHistNNMix->Project(0,1,2);
1092 TH1D* hTemp5Mix = (TH1D*)fHistPMix->Project(0,1);
1093 TH1D* hTemp6Mix = (TH1D*)fHistNMix->Project(0,1);
1094 // ============================================================================================
1096 TH1D *gHistBalanceFunctionHistogram = 0x0;
1097 if((hTemp1)&&(hTemp2)&&(hTemp3)&&(hTemp4)&&(hTemp5)&&(hTemp6)) {
1108 hTemp1->Scale(1./hTemp5->GetEntries());
1109 hTemp3->Scale(1./hTemp5->GetEntries());
1110 hTemp2->Scale(1./hTemp6->GetEntries());
1111 hTemp4->Scale(1./hTemp6->GetEntries());
1113 hTemp1Mix->Scale(1./hTemp5Mix->GetEntries());
1114 hTemp3Mix->Scale(1./hTemp5Mix->GetEntries());
1115 hTemp2Mix->Scale(1./hTemp6Mix->GetEntries());
1116 hTemp4Mix->Scale(1./hTemp6Mix->GetEntries());
1118 hTemp1->Divide(hTemp1Mix);
1119 hTemp2->Divide(hTemp2Mix);
1120 hTemp3->Divide(hTemp3Mix);
1121 hTemp4->Divide(hTemp4Mix);
1123 // now only project on one axis
1124 TH1D *h1DTemp1 = NULL;
1125 TH1D *h1DTemp2 = NULL;
1126 TH1D *h1DTemp3 = NULL;
1127 TH1D *h1DTemp4 = NULL;
1129 h1DTemp1 = (TH1D*)hTemp1->ProjectionX(Form("%s_projX",hTemp1->GetName()));
1130 h1DTemp2 = (TH1D*)hTemp2->ProjectionX(Form("%s_projX",hTemp2->GetName()));
1131 h1DTemp3 = (TH1D*)hTemp3->ProjectionX(Form("%s_projX",hTemp3->GetName()));
1132 h1DTemp4 = (TH1D*)hTemp4->ProjectionX(Form("%s_projX",hTemp4->GetName()));
1135 h1DTemp1 = (TH1D*)hTemp1->ProjectionY(Form("%s_projX",hTemp1->GetName()));
1136 h1DTemp2 = (TH1D*)hTemp2->ProjectionY(Form("%s_projX",hTemp2->GetName()));
1137 h1DTemp3 = (TH1D*)hTemp3->ProjectionY(Form("%s_projX",hTemp3->GetName()));
1138 h1DTemp4 = (TH1D*)hTemp4->ProjectionY(Form("%s_projX",hTemp4->GetName()));
1141 gHistBalanceFunctionHistogram = (TH1D*)h1DTemp1->Clone(Form("%s_clone",h1DTemp1->GetName()));
1142 gHistBalanceFunctionHistogram->Reset();
1144 gHistBalanceFunctionHistogram->GetXaxis()->SetTitle("#Delta#eta");
1145 gHistBalanceFunctionHistogram->GetYaxis()->SetTitle("B(#Delta#eta)");
1148 gHistBalanceFunctionHistogram->GetXaxis()->SetTitle("#Delta#varphi (rad)");
1149 gHistBalanceFunctionHistogram->GetYaxis()->SetTitle("B(#Delta#varphi)");
1152 h1DTemp1->Add(h1DTemp3,-1.);
1153 h1DTemp2->Add(h1DTemp4,-1.);
1155 gHistBalanceFunctionHistogram->Add(h1DTemp1,h1DTemp2,1.,1.);
1156 gHistBalanceFunctionHistogram->Scale(0.5);
1159 return gHistBalanceFunctionHistogram;
1163 //____________________________________________________________________//
1164 TH2D *AliBalancePsi::GetCorrelationFunctionPN(Double_t psiMin,
1166 Double_t ptTriggerMin,
1167 Double_t ptTriggerMax,
1168 Double_t ptAssociatedMin,
1169 Double_t ptAssociatedMax) {
1170 //Returns the 2D correlation function for (+-) pairs
1172 fHistP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1173 fHistPN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1176 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
1177 fHistP->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1178 fHistPN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1182 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.))
1183 fHistPN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1185 //fHistP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(-0.5,2.5);
1186 //fHistPN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(-0.5,2.5);
1188 //TH2D *gHistTest = dynamic_cast<TH2D *>(fHistP->Project(0,0,1));
1189 //TCanvas *c1 = new TCanvas("c1","");
1192 //AliError("Projection of fHistP = NULL");
1196 //gHistTest->DrawCopy("colz");
1199 //0:step, 1: Delta eta, 2: Delta phi
1200 TH2D *gHist = dynamic_cast<TH2D *>(fHistPN->Project(0,1,2));
1202 AliError("Projection of fHistPN = NULL");
1206 //AliInfo(Form("Entries (test): %lf",(Double_t)(gHistTest->GetEntries())));
1207 //AliInfo(Form("Entries (1D): %lf",(Double_t)(fHistP->Project(0,1)->GetEntries())));
1208 //AliInfo(Form("Entries (2D): %lf",(Double_t)(fHistPN->Project(0,1,2)->GetEntries())));
1210 //TCanvas *c2 = new TCanvas("c2","");
1212 //fHistPN->Project(0,1,2)->DrawCopy("colz");
1214 if((Double_t)(fHistP->Project(0,1)->GetEntries())!=0)
1215 gHist->Scale(1./(Double_t)(fHistP->Project(0,1)->GetEntries()));
1217 //normalize to bin width
1218 gHist->Scale(1./((Double_t)gHist->GetXaxis()->GetBinWidth(1)*(Double_t)gHist->GetYaxis()->GetBinWidth(1)));
1223 //____________________________________________________________________//
1224 TH2D *AliBalancePsi::GetCorrelationFunctionNP(Double_t psiMin,
1226 Double_t ptTriggerMin,
1227 Double_t ptTriggerMax,
1228 Double_t ptAssociatedMin,
1229 Double_t ptAssociatedMax) {
1230 //Returns the 2D correlation function for (+-) pairs
1232 fHistN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1233 fHistNP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1236 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
1237 fHistN->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1238 fHistNP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1242 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.))
1243 fHistNP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1245 //0:step, 1: Delta eta, 2: Delta phi
1246 TH2D *gHist = dynamic_cast<TH2D *>(fHistNP->Project(0,1,2));
1248 AliError("Projection of fHistPN = NULL");
1252 //Printf("Entries (1D): %lf",(Double_t)(fHistN->Project(0,2)->GetEntries()));
1253 //Printf("Entries (2D): %lf",(Double_t)(fHistNP->Project(0,2,3)->GetEntries()));
1254 if((Double_t)(fHistN->Project(0,1)->GetEntries())!=0)
1255 gHist->Scale(1./(Double_t)(fHistN->Project(0,1)->GetEntries()));
1257 //normalize to bin width
1258 gHist->Scale(1./((Double_t)gHist->GetXaxis()->GetBinWidth(1)*(Double_t)gHist->GetYaxis()->GetBinWidth(1)));
1263 //____________________________________________________________________//
1264 TH2D *AliBalancePsi::GetCorrelationFunctionPP(Double_t psiMin,
1266 Double_t ptTriggerMin,
1267 Double_t ptTriggerMax,
1268 Double_t ptAssociatedMin,
1269 Double_t ptAssociatedMax) {
1270 //Returns the 2D correlation function for (+-) pairs
1272 fHistP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1273 fHistPP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1276 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
1277 fHistP->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1278 fHistPP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1282 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.))
1283 fHistPP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1285 //0:step, 1: Delta eta, 2: Delta phi
1286 TH2D *gHist = dynamic_cast<TH2D *>(fHistPP->Project(0,1,2));
1288 AliError("Projection of fHistPN = NULL");
1292 //Printf("Entries (1D): %lf",(Double_t)(fHistP->Project(0,2)->GetEntries()));
1293 //Printf("Entries (2D): %lf",(Double_t)(fHistPP->Project(0,2,3)->GetEntries()));
1294 if((Double_t)(fHistP->Project(0,1)->GetEntries())!=0)
1295 gHist->Scale(1./(Double_t)(fHistP->Project(0,1)->GetEntries()));
1297 //normalize to bin width
1298 gHist->Scale(1./((Double_t)gHist->GetXaxis()->GetBinWidth(1)*(Double_t)gHist->GetYaxis()->GetBinWidth(1)));
1303 //____________________________________________________________________//
1304 TH2D *AliBalancePsi::GetCorrelationFunctionNN(Double_t psiMin,
1306 Double_t ptTriggerMin,
1307 Double_t ptTriggerMax,
1308 Double_t ptAssociatedMin,
1309 Double_t ptAssociatedMax) {
1310 //Returns the 2D correlation function for (+-) pairs
1312 fHistN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1313 fHistNN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1316 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
1317 fHistN->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1318 fHistNN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1322 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.))
1323 fHistNN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1325 //0:step, 1: Delta eta, 2: Delta phi
1326 TH2D *gHist = dynamic_cast<TH2D *>(fHistNN->Project(0,1,2));
1328 AliError("Projection of fHistPN = NULL");
1332 //Printf("Entries (1D): %lf",(Double_t)(fHistN->Project(0,2)->GetEntries()));
1333 //Printf("Entries (2D): %lf",(Double_t)(fHistNN->Project(0,2,3)->GetEntries()));
1334 if((Double_t)(fHistN->Project(0,1)->GetEntries())!=0)
1335 gHist->Scale(1./(Double_t)(fHistN->Project(0,1)->GetEntries()));
1337 //normalize to bin width
1338 gHist->Scale(1./((Double_t)gHist->GetXaxis()->GetBinWidth(1)*(Double_t)gHist->GetYaxis()->GetBinWidth(1)));
1343 //____________________________________________________________________//
1344 TH2D *AliBalancePsi::GetCorrelationFunctionChargeIndependent(Double_t psiMin,
1346 Double_t ptTriggerMin,
1347 Double_t ptTriggerMax,
1348 Double_t ptAssociatedMin,
1349 Double_t ptAssociatedMax) {
1350 //Returns the 2D correlation function for the sum of all charge combination pairs
1352 fHistN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1353 fHistP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1354 fHistNN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1355 fHistPP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1356 fHistNP->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1357 fHistPN->GetGrid(0)->GetGrid()->GetAxis(0)->SetRangeUser(psiMin,psiMax);
1360 if((ptTriggerMin != -1.)&&(ptTriggerMax != -1.)) {
1361 fHistN->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1362 fHistP->GetGrid(0)->GetGrid()->GetAxis(1)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1363 fHistNN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1364 fHistPP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1365 fHistNP->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1366 fHistPN->GetGrid(0)->GetGrid()->GetAxis(3)->SetRangeUser(ptTriggerMin,ptTriggerMax);
1370 if((ptAssociatedMin != -1.)&&(ptAssociatedMax != -1.))
1371 fHistNN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1372 fHistPP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1373 fHistNP->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1374 fHistPN->GetGrid(0)->GetGrid()->GetAxis(4)->SetRangeUser(ptAssociatedMin,ptAssociatedMax);
1376 //0:step, 1: Delta eta, 2: Delta phi
1377 TH2D *gHistNN = dynamic_cast<TH2D *>(fHistNN->Project(0,1,2));
1379 AliError("Projection of fHistNN = NULL");
1382 TH2D *gHistPP = dynamic_cast<TH2D *>(fHistPP->Project(0,1,2));
1384 AliError("Projection of fHistPP = NULL");
1387 TH2D *gHistNP = dynamic_cast<TH2D *>(fHistNP->Project(0,1,2));
1389 AliError("Projection of fHistNP = NULL");
1392 TH2D *gHistPN = dynamic_cast<TH2D *>(fHistPN->Project(0,1,2));
1394 AliError("Projection of fHistPN = NULL");
1398 // sum all 2 particle histograms
1399 gHistNN->Add(gHistPP);
1400 gHistNN->Add(gHistNP);
1401 gHistNN->Add(gHistPN);
1403 // divide by sum of + and - triggers
1404 if((Double_t)(fHistN->Project(0,1)->GetEntries())!=0 && (Double_t)(fHistP->Project(0,1)->GetEntries())!=0)
1405 gHistNN->Scale(1./(Double_t)(fHistN->Project(0,1)->GetEntries() + fHistN->Project(0,1)->GetEntries()));
1407 //normalize to bin width
1408 gHistNN->Scale(1./((Double_t)gHistNN->GetXaxis()->GetBinWidth(1)*(Double_t)gHistNN->GetYaxis()->GetBinWidth(1)));
1413 //____________________________________________________________________//
1415 Bool_t AliBalancePsi::GetMomentsAnalytical(TH1D* gHist,
1416 Double_t &mean, Double_t &meanError,
1417 Double_t &sigma, Double_t &sigmaError,
1418 Double_t &skewness, Double_t &skewnessError,
1419 Double_t &kurtosis, Double_t &kurtosisError) {
1421 // helper method to calculate the moments and errors of a TH1D anlytically
1424 Bool_t success = kFALSE;
1430 skewnessError = -1.;
1432 kurtosisError = -1.;
1436 // ----------------------------------------------------------------------
1437 // basic parameters of histogram
1439 Int_t fNumberOfBins = gHist->GetNbinsX();
1440 // Int_t fBinWidth = gHist->GetBinWidth(1); // assume equal binning
1443 // ----------------------------------------------------------------------
1444 // first calculate the mean
1446 Double_t fWeightedAverage = 0.;
1447 Double_t fNormalization = 0.;
1449 for(Int_t i = 1; i <= fNumberOfBins; i++) {
1451 fWeightedAverage += gHist->GetBinContent(i) * gHist->GetBinCenter(i);
1452 fNormalization += gHist->GetBinContent(i);
1456 mean = fWeightedAverage / fNormalization;
1459 // ----------------------------------------------------------------------
1460 // then calculate the higher moments
1462 Double_t fDelta = 0.;
1463 Double_t fDelta2 = 0.;
1464 Double_t fDelta3 = 0.;
1465 Double_t fDelta4 = 0.;
1467 for(Int_t i = 1; i <= fNumberOfBins; i++) {
1468 fDelta += gHist->GetBinContent(i) * gHist->GetBinCenter(i) - mean;
1469 fDelta2 += TMath::Power((gHist->GetBinContent(i) * gHist->GetBinCenter(i) - mean),2);
1470 fDelta3 += TMath::Power((gHist->GetBinContent(i) * gHist->GetBinCenter(i) - mean),3);
1471 fDelta4 += TMath::Power((gHist->GetBinContent(i) * gHist->GetBinCenter(i) - mean),4);
1474 sigma = fDelta2 / fNormalization;
1475 skewness = fDelta3 / fNormalization / TMath::Power(sigma,3);
1476 kurtosis = fDelta4 / fNormalization / TMath::Power(sigma,4) - 3;
1486 //____________________________________________________________________//
1487 Float_t AliBalancePsi::GetDPhiStar(Float_t phi1, Float_t pt1, Float_t charge1, Float_t phi2, Float_t pt2, Float_t charge2, Float_t radius, Float_t bSign) {
1489 // calculates dphistar
1491 Float_t dphistar = phi1 - phi2 - charge1 * bSign * TMath::ASin(0.075 * radius / pt1) + charge2 * bSign * TMath::ASin(0.075 * radius / pt2);
1493 static const Double_t kPi = TMath::Pi();
1496 // if (dphistar > 2 * kPi)
1497 // dphistar -= 2 * kPi;
1498 // if (dphistar < -2 * kPi)
1499 // dphistar += 2 * kPi;
1502 dphistar = kPi * 2 - dphistar;
1503 if (dphistar < -kPi)
1504 dphistar = -kPi * 2 - dphistar;
1505 if (dphistar > kPi) // might look funny but is needed
1506 dphistar = kPi * 2 - dphistar;