652d1c6e1bd71c82c188bd0b8d3179cb6491e86a
[u/mrichter/AliRoot.git] / PWGCF / Correlations / DPhi / MuonHadron / AliAnalysisTaskMuonHadronCorrelations.cxx
1 #include "AliLog.h"
2 #include "TH1D.h"
3 #include "TH2D.h"
4 #include "TTree.h"
5 #include "TAxis.h"
6 #include "AliAODEvent.h"
7 #include "AliAODTrack.h"
8 #include "TMath.h"
9 #include "TString.h"
10
11 #include "AliAnalysisTaskMuonHadronCorrelations.h"
12 #include "AliAnalysisManager.h"
13 #include "AliInputEventHandler.h"
14 #include "AliEventPoolManager.h"
15
16 ClassImp(AliAnalysisTaskMuonHadronCorrelations)
17
18 //====================================================================================================================================================
19
20 AliAnalysisTaskMuonHadronCorrelations::AliAnalysisTaskMuonHadronCorrelations() : 
21   AliAnalysisTaskSE(), 
22   fAOD(0x0),
23   fPoolMgr(0x0),
24   fTrackCB(0x0),
25   fTrackMA(0x0),
26   fFilterBitCentralBarrel(0),
27   fMaxEtaCentralBarrel(1.0),
28   fMinEtaCentralBarrel(-1.0),
29   fMaxChi2Muon(9999999999.), 
30   fMinRAbsMuon(0), 
31   fMaxRAbsMuon(9999999999.),
32   fTriggerMatchLevelMuon(0),
33   fNbinsCent(1), 
34   fNbinsPt(1),
35   fCentAxis(0x0), 
36   fPtAxis(0x0),
37   fEtaAxis(0x0),
38   fHistV0Multiplicity(0x0), 
39   fHistITSMultiplicity(0x0),
40   fHistCentrality(0x0),
41   fHistEvStat(0x0),
42   fCentMethod(0),
43   fOutputList(0x0)
44 {
45
46   // Default constructor
47
48   for (Int_t iCent=0; iCent<fNMaxBinsCentrality; iCent++) {
49     for (Int_t iPtBinCB=0; iPtBinCB<fNMaxBinsPt; iPtBinCB++) {
50       for (Int_t iPtBinMA=0; iPtBinMA<fNMaxBinsPt; iPtBinMA++) {
51         fHistDeltaPhi[iCent][iPtBinCB][iPtBinMA]    = NULL;
52         fHistDeltaPhiMix[iCent][iPtBinCB][iPtBinMA] = NULL;
53         fHistEtaDeltaPhi[iCent][iPtBinCB][iPtBinMA]    = NULL;
54         fHistEtaDeltaPhiMix[iCent][iPtBinCB][iPtBinMA] = NULL;
55       }
56     }
57     fHistNTracksCB_vs_NTracksMA[iCent]  = NULL;
58     fHistNTracksCB_vs_NTracksMAmixed[iCent]  = NULL;
59     fHistTracksEtaMAvsEtaCB[iCent] = NULL;
60     fHistTracksEtaMAvsEtaCBmixed[iCent] = NULL;
61     fHistSingleMuonsPt[iCent]   = NULL;
62     fHistSingleMuonsPtmixed[iCent]   = NULL;
63     fHistSingleMuonsEtaPt[iCent]   = NULL;
64     fHistSingleMuonsEtaPtmixed[iCent]   = NULL;
65     fHistSingleMuonsTrigMatch[iCent] = NULL;
66     fHistSingleMuonsChi2[iCent] = NULL;
67     fHistSingleMuonsEtaVsPt[iCent]   = NULL;
68     fHistSingleMuonsEtaVsRAbs[iCent] = NULL;
69   }  
70   
71 }
72
73
74 //====================================================================================================================================================
75
76 AliAnalysisTaskMuonHadronCorrelations::AliAnalysisTaskMuonHadronCorrelations(const char *name) : 
77   AliAnalysisTaskSE(name), 
78   fAOD(0x0),
79   fPoolMgr(0x0),
80   fTrackCB(0x0),
81   fTrackMA(0x0),
82   fFilterBitCentralBarrel(0),
83   fMaxEtaCentralBarrel(1.0),
84   fMinEtaCentralBarrel(-1.0),
85   fMaxChi2Muon(9999999999.), 
86   fMinRAbsMuon(0), 
87   fMaxRAbsMuon(9999999999.),
88   fTriggerMatchLevelMuon(0),
89   fNbinsCent(1), 
90   fNbinsPt(1),
91   fCentAxis(0x0), 
92   fPtAxis(0x0),
93   fEtaAxis(0x0),
94   fHistV0Multiplicity(0x0), 
95   fHistITSMultiplicity(0x0),
96   fHistCentrality(0x0),
97   fHistEvStat(0x0),
98   fCentMethod(0),
99   fOutputList(0x0)
100 {
101
102   // Constructor
103
104   for (Int_t iCent=0; iCent<fNMaxBinsCentrality; iCent++) {
105     for (Int_t iPtBinCB=0; iPtBinCB<fNMaxBinsPt; iPtBinCB++) {
106       for (Int_t iPtBinMA=0; iPtBinMA<fNMaxBinsPt; iPtBinMA++) {
107         fHistDeltaPhi[iCent][iPtBinCB][iPtBinMA]    = NULL;
108         fHistDeltaPhiMix[iCent][iPtBinCB][iPtBinMA] = NULL;
109         fHistEtaDeltaPhi[iCent][iPtBinCB][iPtBinMA]    = NULL;
110         fHistEtaDeltaPhiMix[iCent][iPtBinCB][iPtBinMA] = NULL;
111       }
112     }
113     fHistNTracksCB_vs_NTracksMA[iCent]  = NULL;
114     fHistNTracksCB_vs_NTracksMAmixed[iCent]  = NULL;
115     fHistTracksEtaMAvsEtaCB[iCent] = NULL;
116     fHistTracksEtaMAvsEtaCBmixed[iCent] = NULL;
117     fHistSingleMuonsPt[iCent]   = NULL;
118     fHistSingleMuonsPtmixed[iCent]   = NULL;
119     fHistSingleMuonsEtaPt[iCent]   = NULL;
120     fHistSingleMuonsEtaPtmixed[iCent]   = NULL;
121     fHistSingleMuonsTrigMatch[iCent] = NULL;
122     fHistSingleMuonsChi2[iCent] = NULL;
123     fHistSingleMuonsEtaVsPt[iCent]   = NULL;
124     fHistSingleMuonsEtaVsRAbs[iCent] = NULL;
125   }  
126   
127   // Define input and output slots here
128   DefineOutput(1, TList::Class());
129   
130 }
131
132 //====================================================================================================================================================
133
134 AliAnalysisTaskMuonHadronCorrelations::~AliAnalysisTaskMuonHadronCorrelations() {
135   
136   delete fCentAxis;
137   delete fPtAxis;
138   delete fEtaAxis;
139
140   if (fOutputList  && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) 
141     delete fOutputList;
142 }
143
144 //====================================================================================================================================================
145
146 void AliAnalysisTaskMuonHadronCorrelations::UserCreateOutputObjects() {
147   
148   fOutputList = new TList();
149   fOutputList->SetOwner(kTRUE);
150
151   for (Int_t iCent=0; iCent<fNbinsCent; iCent++) {
152     for (Int_t iPtBinCB=0; iPtBinCB<fNbinsPt; iPtBinCB++) {
153       for (Int_t iPtBinMA=0; iPtBinMA<fNbinsPt; iPtBinMA++) {
154         
155         fHistDeltaPhi[iCent][iPtBinCB][iPtBinMA]    = new TH1D(Form("fHistDeltaPhi_Cent%02d_PtBin%02d_%02d",iCent,iPtBinCB,iPtBinMA), 
156                                                                Form("%d-%d %%, %3.1f<p_{T}^{TPC}<%3.1f, %3.1f<p_{T}^{Muon}<%3.1f",
157                                                                     Int_t(fCentAxis->GetBinLowEdge(iCent+1)),
158                                                                     Int_t(fCentAxis->GetBinUpEdge(iCent+1)),
159                                                                     fPtAxis->GetBinLowEdge(iPtBinCB+1),
160                                                                     fPtAxis->GetBinUpEdge(iPtBinCB+1),
161                                                                     fPtAxis->GetBinLowEdge(iPtBinMA+1),
162                                                                     fPtAxis->GetBinUpEdge(iPtBinMA+1)),
163                                                                100, -0.5*TMath::RadToDeg()*TMath::Pi(), 1.5*TMath::RadToDeg()*TMath::Pi());
164         
165         fHistDeltaPhiMix[iCent][iPtBinCB][iPtBinMA]    = new TH1D(Form("fHistDeltaPhiMix_Cent%02d_PtBin%02d_%02d",iCent,iPtBinCB,iPtBinMA), 
166                                                                   Form("%d-%d %%, %3.1f<p_{T}^{TPC}<%3.1f, %3.1f<p_{T}^{Muon}<%3.1f MIXED",
167                                                                        Int_t(fCentAxis->GetBinLowEdge(iCent+1)),
168                                                                        Int_t(fCentAxis->GetBinUpEdge(iCent+1)),
169                                                                        fPtAxis->GetBinLowEdge(iPtBinCB+1),
170                                                                        fPtAxis->GetBinUpEdge(iPtBinCB+1),
171                                                                        fPtAxis->GetBinLowEdge(iPtBinMA+1),
172                                                                        fPtAxis->GetBinUpEdge(iPtBinMA+1)),
173                                                                   100, -0.5*TMath::RadToDeg()*TMath::Pi(), 1.5*TMath::RadToDeg()*TMath::Pi());
174         
175         fHistDeltaPhi[iCent][iPtBinCB][iPtBinMA]    -> SetXTitle("#Delta#varphi  [degrees]");
176         fHistDeltaPhiMix[iCent][iPtBinCB][iPtBinMA] -> SetXTitle("#Delta#varphi  [degrees]");
177
178         fHistDeltaPhi[iCent][iPtBinCB][iPtBinMA]    -> Sumw2();
179         fHistDeltaPhiMix[iCent][iPtBinCB][iPtBinMA] -> Sumw2();
180         
181         fOutputList -> Add(fHistDeltaPhi[iCent][iPtBinCB][iPtBinMA]);
182         fOutputList -> Add(fHistDeltaPhiMix[iCent][iPtBinCB][iPtBinMA]);
183
184         fHistEtaDeltaPhi[iCent][iPtBinCB][iPtBinMA]    = new TH2D(Form("fHistEtaDeltaPhi_Cent%02d_PtBin%02d_%02d",iCent,iPtBinCB,iPtBinMA), 
185                                                                   Form("%d-%d %%, %3.1f<p_{T}^{TPC}<%3.1f, %3.1f<p_{T}^{Muon}<%3.1f",
186                                                                        Int_t(fCentAxis->GetBinLowEdge(iCent+1)),
187                                                                        Int_t(fCentAxis->GetBinUpEdge(iCent+1)),
188                                                                        fPtAxis->GetBinLowEdge(iPtBinCB+1),
189                                                                        fPtAxis->GetBinUpEdge(iPtBinCB+1),
190                                                                        fPtAxis->GetBinLowEdge(iPtBinMA+1),
191                                                                        fPtAxis->GetBinUpEdge(iPtBinMA+1)),
192                                                                   100, -0.5*TMath::RadToDeg()*TMath::Pi(), 1.5*TMath::RadToDeg()*TMath::Pi(),
193                                                                   fEtaAxis->GetNbins(),(Double_t*)fEtaAxis->GetXbins()->GetArray());
194         
195         fHistEtaDeltaPhiMix[iCent][iPtBinCB][iPtBinMA]    = new TH2D(Form("fHistEtaDeltaPhiMix_Cent%02d_PtBin%02d_%02d",iCent,iPtBinCB,iPtBinMA), 
196                                                                      Form("%d-%d %%, %3.1f<p_{T}^{TPC}<%3.1f, %3.1f<p_{T}^{Muon}<%3.1f MIXED",
197                                                                           Int_t(fCentAxis->GetBinLowEdge(iCent+1)),
198                                                                           Int_t(fCentAxis->GetBinUpEdge(iCent+1)),
199                                                                           fPtAxis->GetBinLowEdge(iPtBinCB+1),
200                                                                           fPtAxis->GetBinUpEdge(iPtBinCB+1),
201                                                                           fPtAxis->GetBinLowEdge(iPtBinMA+1),
202                                                                           fPtAxis->GetBinUpEdge(iPtBinMA+1)),
203                                                                      100, -0.5*TMath::RadToDeg()*TMath::Pi(), 1.5*TMath::RadToDeg()*TMath::Pi(),
204                                                                      fEtaAxis->GetNbins(),(Double_t*)fEtaAxis->GetXbins()->GetArray());
205         
206         fHistEtaDeltaPhi[iCent][iPtBinCB][iPtBinMA]    -> SetXTitle("#Delta#varphi  [degrees]");
207         fHistEtaDeltaPhiMix[iCent][iPtBinCB][iPtBinMA] -> SetXTitle("#Delta#varphi  [degrees]");
208         fHistEtaDeltaPhi[iCent][iPtBinCB][iPtBinMA]    -> SetYTitle("#eta");
209         fHistEtaDeltaPhiMix[iCent][iPtBinCB][iPtBinMA] -> SetYTitle("#eta");
210
211         fHistEtaDeltaPhi[iCent][iPtBinCB][iPtBinMA]    -> Sumw2();
212         fHistEtaDeltaPhiMix[iCent][iPtBinCB][iPtBinMA] -> Sumw2();
213         
214         fOutputList -> Add(fHistEtaDeltaPhi[iCent][iPtBinCB][iPtBinMA]);
215         fOutputList -> Add(fHistEtaDeltaPhiMix[iCent][iPtBinCB][iPtBinMA]);
216
217       }
218     }
219
220     fHistNTracksCB_vs_NTracksMA[iCent] = new TH2D(Form("fHistNTracksCB_vs_NTracksMA_Cent%02d",iCent),
221                                                   Form("%d-%d %%",Int_t(fCentAxis->GetBinLowEdge(iCent+1)),Int_t(fCentAxis->GetBinUpEdge(iCent+1))),
222                                                   100, 0, 500, 20, 0, 20);
223     fHistNTracksCB_vs_NTracksMA[iCent] -> SetXTitle("N_{tracks} Central Barrel");
224     fHistNTracksCB_vs_NTracksMA[iCent] -> SetYTitle("N_{tracks} Muon Arm");
225     fHistNTracksCB_vs_NTracksMA[iCent] -> Sumw2();
226
227     fHistNTracksCB_vs_NTracksMAmixed[iCent] = new TH2D(Form("fHistNTracksCB_vs_NTracksMAmixed_Cent%02d",iCent),
228                                                   Form("%d-%d %% MIXED",Int_t(fCentAxis->GetBinLowEdge(iCent+1)),Int_t(fCentAxis->GetBinUpEdge(iCent+1))),
229                                                   100, 0, 500, 20, 0, 20);
230     fHistNTracksCB_vs_NTracksMAmixed[iCent] -> SetXTitle("N_{tracks} Central Barrel");
231     fHistNTracksCB_vs_NTracksMAmixed[iCent] -> SetYTitle("N_{tracks} Muon Arm");
232     fHistNTracksCB_vs_NTracksMAmixed[iCent] -> Sumw2();
233
234     fHistTracksEtaMAvsEtaCB[iCent] = new TH2D(Form("fHistTracksEtaMAvsEtaCB_%02d",iCent),
235                                               "#eta muon vs #eta barrel",
236                                               100,-4.5,-2.,100,-1.5,1.5);
237     fHistTracksEtaMAvsEtaCBmixed[iCent] = new TH2D(Form("fHistTracksEtaMAvsEtaCBmixed_%02d",iCent),
238                                                    "#eta muon vs #eta barrel",
239                                                    100,-4.5,-2.,100,-1.5,1.5);
240
241     fOutputList -> Add(fHistNTracksCB_vs_NTracksMA[iCent]);
242     fOutputList -> Add(fHistNTracksCB_vs_NTracksMAmixed[iCent]);
243     fOutputList -> Add(fHistTracksEtaMAvsEtaCB[iCent]);
244     fOutputList -> Add(fHistTracksEtaMAvsEtaCBmixed[iCent]);
245
246     fHistSingleMuonsPt[iCent] = new TH1D(Form("fHistSingleMuonPt_Cent%02d",iCent),
247                                          "p_{T} for single muons",
248                                          fNbinsPt, (Double_t*)fPtAxis->GetXbins()->GetArray());
249     fHistSingleMuonsPtmixed[iCent] = new TH1D(Form("fHistSingleMuonPtmixed_Cent%02d",iCent),
250                                               "p_{T} for single muons",
251                                               fNbinsPt, (Double_t*)fPtAxis->GetXbins()->GetArray());
252     fOutputList -> Add(fHistSingleMuonsPt[iCent]);
253     fOutputList -> Add(fHistSingleMuonsPtmixed[iCent]);
254
255     fHistSingleMuonsEtaPt[iCent] = new TH2D(Form("fHistSingleMuonEtaPt_Cent%02d",iCent),
256                                             "#eta vs p_{T} for single muons",
257                                             fNbinsPt, (Double_t*)fPtAxis->GetXbins()->GetArray(),
258                                             fEtaAxis->GetNbins(),(Double_t*)fEtaAxis->GetXbins()->GetArray());
259     fHistSingleMuonsEtaPtmixed[iCent] = new TH2D(Form("fHistSingleMuonEtaPtmixed_Cent%02d",iCent),
260                                                  "#eta vs p_{T} for single muons",
261                                                  fNbinsPt, (Double_t*)fPtAxis->GetXbins()->GetArray(),
262                                                  fEtaAxis->GetNbins(),(Double_t*)fEtaAxis->GetXbins()->GetArray());
263     fOutputList -> Add(fHistSingleMuonsEtaPt[iCent]);
264     fOutputList -> Add(fHistSingleMuonsEtaPtmixed[iCent]);
265
266     fHistSingleMuonsTrigMatch[iCent] = new TH1D(Form("fHistSingleMuonsTrigMatch_Cent%02d",iCent),
267                                                 "Single muons trigger match flag",10,-0.5,9.5);
268     fOutputList -> Add(fHistSingleMuonsTrigMatch[iCent]);
269     fHistSingleMuonsChi2[iCent] = new TH1D(Form("fHistSingleMuonsChi2_Cent%02d",iCent),
270                                            "Single muons Chi2",100,0.,10.);
271     fOutputList -> Add(fHistSingleMuonsChi2[iCent]);
272
273     fHistSingleMuonsEtaVsPt[iCent]   = new TH2D(Form("fHistSingleMuonsEtaVsPt_Cent%02d",iCent),
274                                                "#eta vs p_{T} for single muons",
275                                                 100, -4.5, -2., 100, 0., 10.);
276     fOutputList->Add(fHistSingleMuonsEtaVsPt[iCent]);
277     fHistSingleMuonsEtaVsRAbs[iCent] = new TH2D(Form("fHistSingleMuonsEtaVsRAbs_Cent%02d",iCent),
278                                                 "#eta vs R_{Abs} for single muons",
279                                                 100, -4.5, -2., 100, 0, 100);
280     fOutputList->Add(fHistSingleMuonsEtaVsRAbs[iCent]);
281     
282   }
283   
284   fHistV0Multiplicity = new TH1D("fHistV0Multiplicity", "V0 Multiplicity", 500, 0, 1000);
285   fHistV0Multiplicity -> SetXTitle("Multiplicity");
286   fHistV0Multiplicity -> Sumw2();
287
288   fHistITSMultiplicity = new TH1D("fHistITSMultiplicity", "ITS Multiplicity", 500, 0, 500);
289   fHistITSMultiplicity -> SetXTitle("N_{Clusters}");
290   fHistITSMultiplicity -> Sumw2();
291
292   fHistCentrality = new TH1D("fHistCentrality", Form("%s Centrality",fCentMethod.Data()), 300, -100, 200);
293   fHistCentrality -> SetXTitle("Centrality  [%]");
294   fHistCentrality -> Sumw2();
295
296   fOutputList -> Add(fHistV0Multiplicity);
297   fOutputList -> Add(fHistITSMultiplicity);
298   fOutputList -> Add(fHistCentrality);
299
300   fHistEvStat = new TH1D("fHistEvStat","Event cuts statistics",20,-0.5,19.5);
301   fHistEvStat->SetXTitle("Cut index");
302   fOutputList->Add(fHistEvStat);
303
304   const Int_t kNZvtxBins  = 10;
305   // bins for further buffers are shifted by 100 cm
306   Double_t vertexBins[kNZvtxBins+1] = { -10,   -8,  -6,  -4,  -2,   0,   2,   4,   6,   8,  10 };
307   Int_t nZvtxBins  = kNZvtxBins;
308   Double_t* zvtxbin = vertexBins;
309
310   fPoolMgr = new AliEventPoolManager(1000, 20000, fNbinsCent, (Double_t*)fCentAxis->GetXbins()->GetArray(), nZvtxBins, zvtxbin);
311
312   PostData(1, fOutputList); 
313
314 }
315
316 //====================================================================================================================================================
317
318 void AliAnalysisTaskMuonHadronCorrelations::UserExec(Option_t *) {
319
320   fAOD = dynamic_cast<AliAODEvent *>(InputEvent());  
321   if (!fAOD) return;  
322
323   Int_t cutIndex = 0;
324   fHistEvStat->Fill(cutIndex++);
325   // Trigger selection
326   if (!(IsTriggerFired())) return;
327   fHistEvStat->Fill(cutIndex++);
328   
329   fHistV0Multiplicity  -> Fill(GetV0Multiplicity());
330   fHistITSMultiplicity -> Fill(GetITSMultiplicity());
331
332   Int_t centBin = GetCentBin();
333   if (centBin<0) return;
334   fHistEvStat->Fill(cutIndex++);
335   Double_t percentile = fAOD->GetCentrality()->GetCentralityPercentile(fCentMethod.Data());
336   fHistCentrality->Fill(percentile);
337
338   // Vertex selection
339   const AliAODVertex* trkVtx = fAOD->GetPrimaryVertex();
340   if (!trkVtx || trkVtx->GetNContributors()<=0) return;
341   TString vtxTtl = trkVtx->GetTitle();
342   if (!vtxTtl.Contains("VertexerTracks")) return;
343   fHistEvStat->Fill(cutIndex++);
344   Double_t zvtx = trkVtx->GetZ();
345   const AliAODVertex* spdVtx = fAOD->GetPrimaryVertexSPD();
346   if (spdVtx->GetNContributors()<=0) return;
347   TString vtxTyp = spdVtx->GetTitle();
348   Double_t cov[6]={0};
349   spdVtx->GetCovarianceMatrix(cov);
350   Double_t zRes = TMath::Sqrt(cov[5]);
351   if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
352   if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
353   fHistEvStat->Fill(cutIndex++);
354
355   if (TMath::Abs(zvtx) > 10.) return;
356   fHistEvStat->Fill(cutIndex++);
357
358   TObjArray *tracksMuonArm = GetAcceptedTracksMuonArm(fAOD,centBin);
359   if (tracksMuonArm->GetEntriesFast() == 0) {
360     delete tracksMuonArm;
361     return;
362   }
363   fHistEvStat->Fill(cutIndex++);
364   TObjArray *tracksCentralBarrel = GetAcceptedTracksCentralBarrel(fAOD);
365   
366   fHistNTracksCB_vs_NTracksMA[centBin] -> Fill(tracksCentralBarrel->GetEntries(), tracksMuonArm->GetEntries());
367
368   AliDebug(1, Form("Single Event analysis : nTracksCB = %4d, nTracksMA = %4d", tracksCentralBarrel->GetEntries(), tracksMuonArm->GetEntries()));
369
370   // Same event  
371   for (Int_t iTrMA=0; iTrMA<tracksMuonArm->GetEntriesFast(); iTrMA++) {
372     fTrackMA = (AliAODTrack*) tracksMuonArm->At(iTrMA);
373     fHistSingleMuonsPt[centBin]->Fill(fTrackMA->Pt());
374     fHistSingleMuonsEtaPt[centBin]->Fill(fTrackMA->Pt(),fTrackMA->Eta());
375     for (Int_t iTrCB=0; iTrCB<tracksCentralBarrel->GetEntriesFast(); iTrCB++) {
376       fTrackCB = (AliAODTrack*) tracksCentralBarrel -> At(iTrCB);
377       FillHistograms(centBin, kSingleEvent);
378     }
379   }
380
381   // Mixed event
382   {
383     AliEventPool* pool = fPoolMgr->GetEventPool(percentile, zvtx);
384     //pool->PrintInfo();
385     if (pool->IsReady() || pool->NTracksInPool() > 2000 || pool->GetCurrentNEvents() >= 5) 
386       for (Int_t jMix=0; jMix<pool->GetCurrentNEvents(); jMix++) {
387         TObjArray *mixedTracks = pool->GetEvent(jMix);
388         fHistNTracksCB_vs_NTracksMAmixed[centBin]->Fill(mixedTracks->GetEntriesFast(), tracksMuonArm->GetEntriesFast());
389         for (Int_t iTrMA=0; iTrMA<tracksMuonArm->GetEntriesFast(); iTrMA++) {
390           fTrackMA = (AliAODTrack*) tracksMuonArm->At(iTrMA);
391           fHistSingleMuonsPtmixed[centBin]->Fill(fTrackMA->Pt());
392           fHistSingleMuonsEtaPtmixed[centBin]->Fill(fTrackMA->Pt(),fTrackMA->Eta());
393           for (Int_t iTrCB=0; iTrCB<mixedTracks->GetEntriesFast(); iTrCB++) {
394             fTrackCB = (AliAODTrack*) mixedTracks -> At(iTrCB);
395             FillHistograms(centBin, kMixedEvent);
396           }
397         }
398       }
399     pool->UpdatePool(tracksCentralBarrel);
400   }
401
402   delete tracksMuonArm;
403
404   PostData(1, fOutputList); 
405
406 }
407
408 //====================================================================================================================================================
409
410 void AliAnalysisTaskMuonHadronCorrelations::FillHistograms(Int_t centrality, Int_t option) {
411
412   Int_t ptBinTrackCB = fPtAxis -> FindBin(fTrackCB->Pt());
413   Int_t ptBinTrackMA = fPtAxis -> FindBin(fTrackMA->Pt());
414
415   if (ptBinTrackCB<1 || ptBinTrackCB>fNbinsPt || ptBinTrackMA<1 || ptBinTrackMA>fNbinsPt) return;
416
417   Double_t deltaPhi = fTrackCB->Phi() - fTrackMA->Phi();
418   if (deltaPhi >  1.5*TMath::Pi()) deltaPhi -= TMath::TwoPi();
419   if (deltaPhi < -0.5*TMath::Pi()) deltaPhi += TMath::TwoPi();
420
421   if (option==kSingleEvent)     fHistDeltaPhi[centrality][ptBinTrackCB-1][ptBinTrackMA-1]    -> Fill(TMath::RadToDeg()*deltaPhi);
422   else if (option==kMixedEvent) fHistDeltaPhiMix[centrality][ptBinTrackCB-1][ptBinTrackMA-1] -> Fill(TMath::RadToDeg()*deltaPhi);
423
424   if (option==kSingleEvent)     fHistEtaDeltaPhi[centrality][ptBinTrackCB-1][ptBinTrackMA-1]    -> Fill(TMath::RadToDeg()*deltaPhi,fTrackMA->Eta());
425   else if (option==kMixedEvent) fHistEtaDeltaPhiMix[centrality][ptBinTrackCB-1][ptBinTrackMA-1] -> Fill(TMath::RadToDeg()*deltaPhi,fTrackMA->Eta());
426
427   if (option==kSingleEvent)     fHistTracksEtaMAvsEtaCB[centrality]->Fill(fTrackMA->Eta(),fTrackCB->Eta());
428   else if (option==kMixedEvent) fHistTracksEtaMAvsEtaCBmixed[centrality]->Fill(fTrackMA->Eta(),fTrackCB->Eta());
429 }
430
431 //====================================================================================================================================================
432
433 Bool_t AliAnalysisTaskMuonHadronCorrelations::IsTriggerFired() {
434   
435   Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7); 
436
437   return isSelected;
438 }
439
440 //====================================================================================================================================================
441
442 Float_t AliAnalysisTaskMuonHadronCorrelations::GetV0Multiplicity() {
443   
444   Float_t multiplicity=0;
445   for (Int_t iChannel=0; iChannel<64; iChannel++) multiplicity += fAOD->GetVZEROData()->GetMultiplicity(iChannel);
446   return multiplicity;
447
448 }
449
450 //====================================================================================================================================================
451
452 TObjArray* AliAnalysisTaskMuonHadronCorrelations::GetAcceptedTracksCentralBarrel(AliAODEvent *aodEvent) {
453
454   // fills the array of central barrel tracks that pass the cuts
455
456   TObjArray *tracks = new TObjArray;
457   tracks->SetOwner(kTRUE);
458
459   Int_t nTracks = aodEvent->GetNumberOfTracks();
460
461   AliAODTrack *track = 0;
462
463   for (Int_t iTrack=0; iTrack<nTracks; iTrack++) {
464     track = aodEvent->GetTrack(iTrack);
465     if (track->TestFilterBit(fFilterBitCentralBarrel) && track->Eta()>fMinEtaCentralBarrel && track->Eta()<fMaxEtaCentralBarrel) {
466       tracks->Add(new AliAODTrack(*track));
467     }
468   }
469
470   return tracks;
471
472 }
473
474 //====================================================================================================================================================
475
476 TObjArray* AliAnalysisTaskMuonHadronCorrelations::GetAcceptedTracksMuonArm(AliAODEvent *aodEvent, Int_t centBin) {
477
478   // fills the array of muon tracks that pass the cuts
479
480   TObjArray *tracks = new TObjArray;
481   tracks->SetOwner(kFALSE);
482
483   Int_t nTracks = aodEvent->GetNumberOfTracks();
484
485   AliAODTrack *track = 0;
486   
487   for (Int_t iTrack=0; iTrack<nTracks; iTrack++) {
488     track = aodEvent->GetTrack(iTrack);
489     if (track->IsMuonTrack()) fHistSingleMuonsTrigMatch[centBin]->Fill(track->GetMatchTrigger());
490     if (track->IsMuonTrack() && track->GetMatchTrigger()>=fTriggerMatchLevelMuon) {
491       fHistSingleMuonsChi2[centBin]->Fill(track->Chi2perNDF());
492       //     if (track->Chi2perNDF() < 5.) {
493         // histos
494         fHistSingleMuonsEtaVsPt[centBin]->Fill(track->Eta(),track->Pt());
495         fHistSingleMuonsEtaVsRAbs[centBin]->Fill(track->Eta(),track->GetRAtAbsorberEnd());
496         if (track->Eta() > -4. && track->Eta() < -2.5) {
497           Double_t rabs = track->GetRAtAbsorberEnd();
498           if (rabs > 17.6 && rabs < 89.5) {
499             tracks->Add(new AliAODTrack(*track));
500           }
501         }
502         //      }
503     }
504   }
505
506   return tracks;
507
508 }
509
510 //====================================================================================================================================================
511
512 void AliAnalysisTaskMuonHadronCorrelations::SetCentBinning(Int_t nBins, Double_t *limits) {
513
514   if (nBins>fNMaxBinsCentrality) {
515     AliInfo(Form("WARNING : only %d centrality bins (out of the %d proposed) will be considered",fNMaxBinsCentrality,nBins));
516     nBins = fNMaxBinsCentrality;
517   }
518   if (nBins<=0) {
519     AliInfo("WARNING : at least one centrality bin must be considered");
520     nBins = 1;
521   }
522   
523   fNbinsCent = nBins;
524   fCentAxis  = new TAxis(fNbinsCent, limits);
525
526 }
527
528 //====================================================================================================================================================
529
530 void AliAnalysisTaskMuonHadronCorrelations::SetPtBinning(Int_t nBins, Double_t *limits) {
531
532   if (nBins>fNMaxBinsPt) {
533     AliInfo(Form("WARNING : only %d pt bins (out of the %d proposed) will be considered",fNMaxBinsPt,nBins));
534     nBins = fNMaxBinsPt;
535   }
536   if (nBins<=0) {
537     AliInfo("WARNING : at least one pt bin must be considered");
538     nBins = 1;
539   }
540   
541   fNbinsPt = nBins;
542   fPtAxis  = new TAxis(fNbinsPt, limits);
543
544 }
545
546 //====================================================================================================================================================
547
548 void AliAnalysisTaskMuonHadronCorrelations::SetEtaBinning(Int_t nBins, Double_t *limits) {
549
550   if (nBins>fNMaxBinsEta) {
551     AliInfo(Form("WARNING : only %d pt bins (out of the %d proposed) will be considered",fNMaxBinsEta,nBins));
552     nBins = fNMaxBinsEta;
553   }
554   if (nBins<=0) {
555     AliInfo("WARNING : at least one pt bin must be considered");
556     nBins = 1;
557   }
558   
559   fEtaAxis  = new TAxis(nBins, limits);
560
561 }
562
563 //====================================================================================================================================================
564
565 Int_t AliAnalysisTaskMuonHadronCorrelations::GetCentBin() {
566
567   Double_t percentile = fAOD->GetCentrality()->GetCentralityPercentile(fCentMethod.Data());
568
569   Int_t bin = fCentAxis->FindBin(percentile) - 1;
570   if (bin >= fNbinsCent) bin = -1;
571   return bin;
572   
573 }
574
575 //====================================================================================================================================================
576
577 Double_t AliAnalysisTaskMuonHadronCorrelations::GetITSMultiplicity() {
578
579   Double_t multiplicity = fAOD->GetHeader()->GetNumberOfITSClusters(1);
580
581   return multiplicity;
582
583 }
584
585 //====================================================================================================================================================
586
587 void AliAnalysisTaskMuonHadronCorrelations::Terminate(Option_t *) {
588
589   fOutputList = dynamic_cast<TList*> (GetOutputData(1));
590   if (!fOutputList) {
591     printf("ERROR: Output list not available\n");
592     return;
593   }  
594
595 }
596
597 //====================================================================================================================================================
598