]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/EMCALTasks/AliAnalysisTaskPi0V2.cxx
19c66bcc7333298ac48eec594f950e520b5ebdd8
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / AliAnalysisTaskPi0V2.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id: AliAnalysisTaskPi0V2.cxx 55404 2012-03-29 10:10:19Z fca $ */
17
18 /* AliAnalysisTaskPi0V2.cxx
19  *
20  * Template task producing a P_t spectrum and pseudorapidity distribution.
21  * Includes explanations of physics and primary track selections
22  *
23  * Instructions for adding histograms can be found below, starting with NEW HISTO
24  *
25  * Based on tutorial example from offline pages
26  * Edited by Arvinder Palaha
27  */
28 #include "AliAnalysisTaskPi0V2.h"
29
30 #include "Riostream.h"
31 #include "TChain.h"
32 #include "TTree.h"
33 #include "TH1F.h"
34 #include "TH2F.h"
35 #include "TH3F.h"
36 #include "TCanvas.h"
37 #include "TList.h"
38
39 #include "AliAnalysisTaskSE.h"
40 #include "AliAnalysisManager.h"
41 #include "AliStack.h"
42 #include "AliESDtrackCuts.h"
43 #include "AliESDEvent.h"
44 #include "AliESDInputHandler.h"
45 #include "AliAODEvent.h"
46 #include "AliMCEvent.h"
47
48 #include "AliEventplane.h"
49 #include "AliEMCALGeometry.h"
50 #include "THnSparse.h"
51 #include "TClonesArray.h"
52 #include "TString.h"
53
54 using std::cout;
55 using std::endl;
56
57 ClassImp(AliAnalysisTaskPi0V2)
58
59 //________________________________________________________________________
60 AliAnalysisTaskPi0V2::AliAnalysisTaskPi0V2(const char *name) // All data members should be initialised here
61    :AliAnalysisTaskSE(name),
62     fOutput(0),
63     fESD(0),
64     fTracksName("PicoTrack"),
65     fTrigClass("CVLN_|CSEMI_|CCENT|CVHN"),
66     fTracks(0),
67     fRunNumber(-999.),
68     fEvtSelect(1),
69     fVtxCut(15.),
70     fNcellCut(2), fECut(1), fEtaCut(0.65), fM02Cut(0.5), fPi0AsyCut(0), isV1Clus(1),
71     fCentrality(99.),
72     fEPTPC(-999.),
73     fEPTPCreso(0.), 
74     fEPV0(-999.), fEPV0A(-999.), fEPV0C(-999.), fEPV0Ar(-999.), fEPV0Cr(-999.), fEPV0r(-999.),
75     fEPV0AR4(-999.), fEPV0AR5(-999.), fEPV0AR6(-999.), fEPV0AR7(-999.), fEPV0CR0(-999.), fEPV0CR1(-999.), fEPV0CR2(-999.), fEPV0CR3(-999.),
76     hEvtCount(0), hAllcentV0(0), hAllcentV0r(0), hAllcentV0A(0), hAllcentV0C(0), hAllcentTPC(0),
77     h2DcosV0r(0), h2DsinV0r(0), h2DcosV0A(0), h2DsinV0A(0), h2DcosV0C(0), h2DsinV0C(0), h2DcosTPC(0), h2DsinTPC(0), 
78     hEPTPC(0), hresoTPC(0),
79     hEPV0(0), hEPV0A(0), hEPV0C(0), hEPV0Ar(0), hEPV0Cr(0), hEPV0r(0), hEPV0AR4(0), hEPV0AR7(0), hEPV0CR0(0), hEPV0CR3(0),
80     hdifV0Ar_V0Cr(0), hdifV0A_V0CR0(0), hdifV0A_V0CR3(0), hdifV0ACR0_V0CR3(0), hdifV0C_V0AR4(0), hdifV0C_V0AR7(0), hdifV0AR4_V0AR7(0),
81     hdifV0A_V0C(0), hdifV0A_TPC(0), hdifV0C_TPC(0), hdifV0C_V0A(0), 
82     hM02vsPtA(0), hM02vsPtB(0), hClusDxDZA(0), hClusDxDZB(0),
83     hdifEMC_EPV0(0), hdifEMC_EPV0A(0), hdifEMC_EPV0C(0), hdifful_EPV0(0), hdifful_EPV0A(0), hdifful_EPV0C(0), 
84     hdifout_EPV0(0), hdifout_EPV0A(0), hdifout_EPV0C(0), hdifEMC_EPTPC(0), hdifful_EPTPC(0), hdifout_EPTPC(0),
85     hdifClus_EPV0(0), hdifClus_EPV0A(0), hdifClus_EPV0C(0), hdifClus_EPTPC(0),
86     fHEPV0r(0), fHEPV0A(0), fHEPV0C(0), fHEPTPC(0)
87
88 {
89     // Dummy constructor ALWAYS needed for I/O.
90     DefineInput(0, TChain::Class());
91     DefineOutput(1, TList::Class());                                            // for output list
92 }
93
94 //________________________________________________________________________
95 AliAnalysisTaskPi0V2::AliAnalysisTaskPi0V2() // All data members should be initialised here
96    :AliAnalysisTaskSE("default_name"),
97     fOutput(0),
98     fESD(0),
99     fTracksName("PicoTracks"),
100     fTrigClass("CVLN_|CSEMI_|CCENT|CVHN"),
101     fTracks(0),
102     fRunNumber(-999.),
103     fEvtSelect(1),
104     fVtxCut(15.),
105     fNcellCut(2), fECut(1), fEtaCut(0.65), fM02Cut(0.5), fPi0AsyCut(0), isV1Clus(1),
106     fCentrality(99.),
107     fEPTPC(-999.),
108     fEPTPCreso(0.),
109     fEPV0(-999.), fEPV0A(-999.), fEPV0C(-999.), fEPV0Ar(-999.), fEPV0Cr(-999.), fEPV0r(-999.),
110     fEPV0AR4(-999.), fEPV0AR5(-999.), fEPV0AR6(-999.), fEPV0AR7(-999.), fEPV0CR0(-999.), fEPV0CR1(-999.), fEPV0CR2(-999.), fEPV0CR3(-999.),
111     hEvtCount(0), hAllcentV0(0), hAllcentV0r(0), hAllcentV0A(0), hAllcentV0C(0), hAllcentTPC(0),
112     h2DcosV0r(0), h2DsinV0r(0), h2DcosV0A(0), h2DsinV0A(0), h2DcosV0C(0), h2DsinV0C(0), h2DcosTPC(0), h2DsinTPC(0), 
113     hEPTPC(0), hresoTPC(0),
114     hEPV0(0), hEPV0A(0), hEPV0C(0), hEPV0Ar(0), hEPV0Cr(0), hEPV0r(0), hEPV0AR4(0), hEPV0AR7(0), hEPV0CR0(0), hEPV0CR3(0),
115     hdifV0Ar_V0Cr(0), hdifV0A_V0CR0(0), hdifV0A_V0CR3(0), hdifV0ACR0_V0CR3(0), hdifV0C_V0AR4(0), hdifV0C_V0AR7(0), hdifV0AR4_V0AR7(0),
116     hdifV0A_V0C(0), hdifV0A_TPC(0), hdifV0C_TPC(0), hdifV0C_V0A(0),  
117     hM02vsPtA(0), hM02vsPtB(0), hClusDxDZA(0), hClusDxDZB(0),
118     hdifEMC_EPV0(0), hdifEMC_EPV0A(0), hdifEMC_EPV0C(0), hdifful_EPV0(0), hdifful_EPV0A(0), hdifful_EPV0C(0), 
119     hdifout_EPV0(0), hdifout_EPV0A(0), hdifout_EPV0C(0), hdifEMC_EPTPC(0), hdifful_EPTPC(0), hdifout_EPTPC(0),
120     hdifClus_EPV0(0), hdifClus_EPV0A(0), hdifClus_EPV0C(0), hdifClus_EPTPC(0),
121     fHEPV0r(0), fHEPV0A(0), fHEPV0C(0), fHEPTPC(0)
122 {
123     // Constructor
124     // Define input and output slots here (never in the dummy constructor)
125     // Input slot #0 works with a TChain - it is connected to the default input container
126     // Output slot #1 writes into a TH1 container
127     DefineInput(0, TChain::Class());
128     DefineOutput(1, TList::Class());                                            // for output list
129 }
130
131 //________________________________________________________________________
132 AliAnalysisTaskPi0V2::~AliAnalysisTaskPi0V2()
133 {
134     // Destructor. Clean-up the output list, but not the histograms that are put inside
135     // (the list is owner and will clean-up these histograms). Protect in PROOF case.
136      delete fOutput;
137 }
138 //_____________________________________________________________________
139 Double_t AliAnalysisTaskPi0V2::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
140 {
141   // Get maximum energy of attached cell.
142
143   id = -1;
144
145   AliVCaloCells *cells = 0;
146   if (fESD)
147     cells = fESD->GetEMCALCells();
148   if (!cells)
149     return 0;
150
151   Double_t maxe = 0;
152   const Int_t ncells = cluster->GetNCells();
153   for (Int_t i=0; i<ncells; i++) {
154     Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
155     if (e>maxe) {
156       maxe = e;
157       id   = cluster->GetCellAbsId(i);
158     }
159   }
160   return maxe;
161 }
162 //_____________________________________________________________________
163 Double_t AliAnalysisTaskPi0V2::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax) const
164 {
165   // Calculate the energy of cross cells around the leading cell.
166
167   AliVCaloCells *cells = 0;
168   if (fESD)
169     cells = fESD->GetEMCALCells();
170   if (!cells)
171     return 0;
172
173   AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
174   if (!geom)
175     return 0;
176
177   Int_t iSupMod = -1;
178   Int_t iTower  = -1;
179   Int_t iIphi   = -1;
180   Int_t iIeta   = -1;
181   Int_t iphi    = -1;
182   Int_t ieta    = -1;
183   Int_t iphis   = -1;
184   Int_t ietas   = -1;
185
186   Double_t crossEnergy = 0.;
187
188   geom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
189   geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
190
191   Int_t ncells = cluster->GetNCells();
192   for (Int_t i=0; i<ncells; i++) {
193     Int_t cellAbsId = cluster->GetCellAbsId(i);
194     geom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
195     geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
196     Int_t aphidiff = TMath::Abs(iphi-iphis);
197     if (aphidiff>1)
198       continue;
199     Int_t aetadiff = TMath::Abs(ieta-ietas);
200     if (aetadiff>1)
201       continue;
202     if ( (aphidiff==1 && aetadiff==0) ||
203         (aphidiff==0 && aetadiff==1) ) {
204       crossEnergy += cells->GetCellAmplitude(cellAbsId);
205     }
206   }
207
208   return crossEnergy;
209 }
210 //_____________________________________________________________________
211 Bool_t AliAnalysisTaskPi0V2::IsWithinFiducialVolume(Short_t id) const
212 {
213   // Check if cell is within given fiducial volume.
214
215   Double_t fNFiducial = 1;
216
217   Int_t iSupMod = -1;
218   Int_t iTower  = -1;
219   Int_t iIphi   = -1;
220   Int_t iIeta   = -1;
221   Int_t iphi    = -1;
222   Int_t ieta    = -1;
223
224   Bool_t okrow = kFALSE;
225   Bool_t okcol = kFALSE;
226
227   AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
228   if (!geom)
229     return kFALSE;
230
231   Int_t cellAbsId = id;
232   geom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
233   geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
234
235   // Check rows/phi
236   if (iSupMod < 10) {
237     if (iphi >= fNFiducial && iphi < 24-fNFiducial)
238       okrow = kTRUE;
239   } else {
240     if (iphi >= fNFiducial && iphi < 12-fNFiducial)
241       okrow = kTRUE;
242   }
243   // Check columns/eta
244   Bool_t noEMCALBorderAtEta0 = kTRUE;
245   if (!noEMCALBorderAtEta0) {
246     if (ieta > fNFiducial && ieta < 48-fNFiducial)
247       okcol = kTRUE;
248   } else {
249     if (iSupMod%2==0) {
250       if (ieta >= fNFiducial)
251         okcol = kTRUE;
252     } else {
253       if (ieta < 48-fNFiducial)
254         okcol = kTRUE;
255     }
256   }
257   if (okrow && okcol)
258      return kTRUE;
259
260   return kFALSE;
261 }
262 //______________________________________________________________________
263 Bool_t AliAnalysisTaskPi0V2::IsGoodCluster(const AliESDCaloCluster *c) const
264 {
265
266   if(!c)
267     return kFALSE;
268
269   if(c->GetNCells() < fNcellCut)
270    return kFALSE;
271
272   if(c->E() < fECut)
273    return kFALSE;
274
275   Short_t id = -1;
276   Double_t maxE = GetMaxCellEnergy(c, id); 
277      if((1. - double(GetCrossEnergy(c,id))/maxE) > 0.97)
278     return kFALSE;
279
280
281   Float_t pos1[3];
282   c->GetPosition(pos1);
283   TVector3 clsPos(pos1);
284   Double_t eta = clsPos.Eta();
285
286   if(TMath::Abs(eta) > fEtaCut)
287     return kFALSE;  
288
289   if (!IsWithinFiducialVolume(id))
290     return kFALSE;
291
292   if(c->GetM02() >fM02Cut)
293     return kFALSE;
294
295
296   return kTRUE;
297
298 }
299 //________________________________________________________________________________________________
300 Bool_t AliAnalysisTaskPi0V2::IsGoodClusterV1(const AliESDCaloCluster *c) const
301 {
302
303   if(!c)
304     return kFALSE;
305
306   if(c->GetNCells() < fNcellCut)
307    return kFALSE;
308
309   if(c->E() < fECut)
310    return kFALSE;
311
312   Short_t id = -1;
313   Double_t maxE = GetMaxCellEnergy(c, id);
314      if((1. - double(GetCrossEnergy(c,id))/maxE) > 0.97)
315     return kFALSE;
316
317
318   Float_t pos1[3];
319   c->GetPosition(pos1);
320   TVector3 clsPos(pos1);
321   Double_t eta = clsPos.Eta();
322
323   if(TMath::Abs(eta) > fEtaCut)
324     return kFALSE;
325
326   if (!IsWithinFiducialVolume(id))
327     return kFALSE;
328
329   if(c->GetM02() <0.5)
330     return kFALSE;
331
332   Double_t dr = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx() + c->GetTrackDz()*c->GetTrackDz());
333   if(dr>0.025)
334     return kFALSE;
335
336   return kTRUE;
337
338 }
339 //_____________________________________________________________________
340 Bool_t AliAnalysisTaskPi0V2::IsGoodPion(const TLorentzVector &p1, const TLorentzVector &p2) const
341 {
342   // Is good pion?
343
344   if(fPi0AsyCut){
345     Double_t asym = TMath::Abs(p1.E()-p2.E())/(p1.E()+p2.E());
346     if (asym>0.7)
347       return kFALSE;
348   }
349   TLorentzVector pion;
350   pion = p1 + p2;
351   Double_t eta = pion.Eta();
352   if(TMath::Abs(eta) > fEtaCut)
353     return kFALSE;
354
355   return kTRUE;
356 }
357 //_______________________________________________________________________
358 void AliAnalysisTaskPi0V2::FillPion(const TLorentzVector& p1, const TLorentzVector& p2, Double_t EPV0r, Double_t EPV0A, Double_t EPV0C, Double_t EPTPC)
359 {
360   // Fill histogram.
361
362   if (!IsGoodPion(p1,p2))
363     return;
364   TLorentzVector pion;
365   pion = p1 + p2;
366
367   Double_t mass = pion.M();
368   Double_t pt   = pion.Pt();
369   Double_t phi  = pion.Phi();
370
371   Double_t dphiV0   = phi-EPV0r;
372   Double_t dphiV0A  = phi-EPV0A;
373   Double_t dphiV0C  = phi-EPV0C;
374   Double_t dphiTPC  = phi-EPTPC;
375
376   Double_t cos2phiV0  = TMath::Cos(2.*(dphiV0));
377   Double_t cos2phiV0A = TMath::Cos(2.*(dphiV0A));
378   Double_t cos2phiV0C = TMath::Cos(2.*(dphiV0C));
379   Double_t cos2phiTPC = TMath::Cos(2.*(dphiTPC));
380
381   dphiV0  = TVector2::Phi_0_2pi(dphiV0);  if(dphiV0  >TMath::Pi())  dphiV0 -= TMath::Pi();
382   dphiV0A = TVector2::Phi_0_2pi(dphiV0A); if(dphiV0A >TMath::Pi())  dphiV0A -= TMath::Pi();
383   dphiV0C = TVector2::Phi_0_2pi(dphiV0C); if(dphiV0C >TMath::Pi())  dphiV0C -= TMath::Pi();
384   dphiTPC = TVector2::Phi_0_2pi(dphiTPC); if(dphiTPC >TMath::Pi())  dphiTPC -= TMath::Pi();
385
386   Double_t xV0[5]; // Match ndims in fH  V0 EP
387   xV0[0]       = mass;
388   xV0[1]       = pt;
389   xV0[2]       = fCentrality;
390   xV0[3]       = dphiV0;
391   xV0[4]       = cos2phiV0;
392   fHEPV0r->Fill(xV0);
393
394   Double_t xV0A[5]; // Match ndims in fH V0A EP
395   xV0A[0]       = mass;
396   xV0A[1]       = pt;
397   xV0A[2]       = fCentrality;
398   xV0A[3]       = dphiV0A;
399   xV0A[4]       = cos2phiV0A;
400   fHEPV0A->Fill(xV0A);
401
402   Double_t xV0C[5]; // Match ndims in fH V0C EP
403   xV0C[0]       = mass;
404   xV0C[1]       = pt;
405   xV0C[2]       = fCentrality;
406   xV0C[3]       = dphiV0C;
407   xV0C[4]       = cos2phiV0C;
408   fHEPV0C->Fill(xV0C);
409
410   Double_t xTPC[5]; // Match ndims in fH TPC EP
411   xTPC[0]       = mass;
412   xTPC[1]       = pt;
413   xTPC[2]       = fCentrality;
414   xTPC[3]       = dphiTPC;
415   xTPC[4]       = cos2phiTPC;
416   fHEPTPC->Fill(xTPC);
417
418
419 }
420 //________________________________________________________________________________________________________________________________
421 void AliAnalysisTaskPi0V2::FillCluster(const TLorentzVector& p1, Double_t EPV0r, Double_t EPV0A, Double_t EPV0C, Double_t EPTPC)
422 {
423   //cluster(photon) v2 method
424   Double_t Pt   = p1.Pt();
425   Double_t Phi  = p1.Phi();
426
427   Double_t difClusV0 = TVector2::Phi_0_2pi(Phi-EPV0r);   if(difClusV0 >TMath::Pi()) difClusV0  -= TMath::Pi();
428   Double_t difClusV0A = TVector2::Phi_0_2pi(Phi-EPV0A);  if(difClusV0A >TMath::Pi()) difClusV0A -= TMath::Pi();
429   Double_t difClusV0C = TVector2::Phi_0_2pi(Phi-EPV0C);  if(difClusV0C >TMath::Pi()) difClusV0C -= TMath::Pi();
430   Double_t difClusTPC = TVector2::Phi_0_2pi(Phi-EPTPC);  if(difClusTPC >TMath::Pi()) difClusTPC -= TMath::Pi();
431
432   hdifClus_EPV0->Fill(fCentrality,  difClusV0, Pt);
433   hdifClus_EPV0A->Fill(fCentrality, difClusV0A, Pt);
434   hdifClus_EPV0C->Fill(fCentrality, difClusV0C, Pt);
435   hdifClus_EPTPC->Fill(fCentrality, difClusTPC, Pt);
436
437
438 }
439 //_________________________________________________________________________________________________
440 void AliAnalysisTaskPi0V2::GetMom(TLorentzVector& p, const AliESDCaloCluster *c, Double_t *vertex)
441 {
442   // Calculate momentum.
443   Float_t posMom[3];
444   c->GetPosition(posMom);
445   TVector3 clsPos2(posMom);
446
447   Double_t e   = c->E();
448   Double_t r   = clsPos2.Perp();
449   Double_t eta = clsPos2.Eta();
450   Double_t phi = clsPos2.Phi();
451
452   TVector3 pos;
453   pos.SetPtEtaPhi(r,eta,phi);
454
455   if (vertex) { //calculate direction relative to vertex
456     pos -= vertex;
457   }
458
459   Double_t rad = pos.Mag();
460   p.SetPxPyPzE(e*pos.x()/rad, e*pos.y()/rad, e*pos.z()/rad, e);
461
462 }
463 //________________________________________________________________________
464 void AliAnalysisTaskPi0V2::UserCreateOutputObjects()
465 {
466     // Create histograms
467     // Called once (on the worker node)
468         
469     fOutput = new TList();
470     fOutput->SetOwner();  // IMPORTANT!
471
472     hEvtCount = new TH1F("hEvtCount", " Event Plane", 10, 0.5, 10.5);
473     hEvtCount->GetXaxis()->SetBinLabel(1,"All");
474     hEvtCount->GetXaxis()->SetBinLabel(2,"Evt Cut");
475     hEvtCount->GetXaxis()->SetBinLabel(3,"Trg Class");
476     hEvtCount->GetXaxis()->SetBinLabel(4,"Vtx");
477     hEvtCount->GetXaxis()->SetBinLabel(5,"Cent");
478     hEvtCount->GetXaxis()->SetBinLabel(5,"EPtask");
479     hEvtCount->GetXaxis()->SetBinLabel(7,"EPvalue");
480     hEvtCount->GetXaxis()->SetBinLabel(8,"Pass");
481     fOutput->Add(hEvtCount);
482     
483     hEPTPC   = new TH2F("hEPTPC",   "EPTPC     vs cent", 100, 0., 100., 100, 0., TMath::Pi());
484     hresoTPC = new TH2F("hresoTPC", "TPc reso  vs cent", 100, 0., 100., 100, 0., 1.);
485     hEPV0    = new TH2F("hEPV0",    "EPV0      vs cent", 100, 0., 100., 100, 0., TMath::Pi());
486     hEPV0A   = new TH2F("hEPV0A",   "EPV0A     vs cent", 100, 0., 100., 100, 0., TMath::Pi());
487     hEPV0C   = new TH2F("hEPV0C",   "EPV0C     vs cent", 100, 0., 100., 100, 0., TMath::Pi());
488     hEPV0Ar  = new TH2F("hEPV0Ar",  "EPV0Ar    vs cent", 100, 0., 100., 100, 0., TMath::Pi());
489     hEPV0Cr  = new TH2F("hEPV0Cr",  "EPV0Cr    vs cent", 100, 0., 100., 100, 0., TMath::Pi());
490     hEPV0r   = new TH2F("hEPV0r",   "EPV0r     vs cent", 100, 0., 100., 100, 0., TMath::Pi());
491     hEPV0AR4 = new TH2F("hEPV0AR4", "EPV0AR4   vs cent", 100, 0., 100., 100, 0., TMath::Pi());
492     hEPV0AR7 = new TH2F("hEPV0AR7", "EPV0AR7   vs cent", 100, 0., 100., 100, 0., TMath::Pi());
493     hEPV0CR0 = new TH2F("hEPV0CR0", "EPV0CR0   vs cent", 100, 0., 100., 100, 0., TMath::Pi());
494     hEPV0CR3 = new TH2F("hEPV0CR3", "EPV0CR3   vs cent", 100, 0., 100., 100, 0., TMath::Pi());
495     fOutput->Add(hEPTPC);
496     fOutput->Add(hresoTPC);
497     fOutput->Add(hEPV0);
498     fOutput->Add(hEPV0A);
499     fOutput->Add(hEPV0C);
500     fOutput->Add(hEPV0Ar);
501     fOutput->Add(hEPV0Cr);
502     fOutput->Add(hEPV0r);
503     fOutput->Add(hEPV0AR4);
504     fOutput->Add(hEPV0AR7);
505     fOutput->Add(hEPV0CR0);
506     fOutput->Add(hEPV0CR3);
507
508     hdifV0Ar_V0Cr    = new TH2F("hdifV0Ar_V0Cr",    "EP Ar-Cr ", 100, 0., 100., 100, -1., 1.);    
509     hdifV0A_V0CR0    = new TH2F("hdifV0A_V0CR0",    "EP A-R0 ",  100, 0., 100., 100, -1., 1.);    
510     hdifV0A_V0CR3    = new TH2F("hdifV0A_V0CR3",    "EP A-R3 ",  100, 0., 100., 100, -1., 1.);    
511     hdifV0ACR0_V0CR3 = new TH2F("hdifV0ACR0_V0CR3", "EP R0-R3 ", 100, 0., 100., 100, -1., 1.);    
512     hdifV0C_V0AR4    = new TH2F("hdifV0C_V0AR4",    "EP C-R4 ",  100, 0., 100., 100, -1., 1.);    
513     hdifV0C_V0AR7    = new TH2F("hdifV0C_V0AR7",    "EP C-R7 ",  100, 0., 100., 100, -1., 1.);    
514     hdifV0AR4_V0AR7  = new TH2F("hdifV0AR4_V0AR7",  "EP R4-R7 ", 100, 0., 100., 100, -1., 1.);    
515     fOutput->Add(hdifV0Ar_V0Cr);
516     fOutput->Add(hdifV0A_V0CR0);
517     fOutput->Add(hdifV0A_V0CR3);
518     fOutput->Add(hdifV0ACR0_V0CR3);
519     fOutput->Add(hdifV0C_V0AR4);
520     fOutput->Add(hdifV0C_V0AR7);
521     fOutput->Add(hdifV0AR4_V0AR7);
522
523     hdifV0A_V0C = new TH2F("hdifV0A_V0C", "EP A-C  ", 100, 0., 100., 100, -1., 1.);
524     hdifV0A_TPC = new TH2F("hdifV0A_TPC", "EP A-TPC", 100, 0., 100., 100, -1., 1.);
525     hdifV0C_TPC = new TH2F("hdifV0C_TPC", "EP C-TPC", 100, 0., 100., 100, -1., 1.);
526     hdifV0C_V0A = new TH2F("hdifV0C_V0A", "EP C-A  ", 100, 0., 100., 100, -1., 1.);
527     fOutput->Add(hdifV0A_V0C);
528     fOutput->Add(hdifV0A_TPC);
529     fOutput->Add(hdifV0C_TPC);
530     fOutput->Add(hdifV0C_V0A);
531
532
533
534     hdifEMC_EPV0  = new TH3F("hdifEMC_EPV0",  "dif phi in EMC with EP",  100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
535     hdifEMC_EPV0A = new TH3F("hdifEMC_EPV0A", "dif phi in EMC with EP",  100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
536     hdifEMC_EPV0C = new TH3F("hdifEMC_EPV0C", "dif phi in EMC with EP",  100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
537     fOutput->Add(hdifEMC_EPV0);
538     fOutput->Add(hdifEMC_EPV0A);
539     fOutput->Add(hdifEMC_EPV0C);
540
541     hdifful_EPV0 = new TH3F("hdifful_EPV0",    "dif phi in full with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
542     hdifful_EPV0A = new TH3F("hdifful_EPV0A",  "dif phi in full with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
543     hdifful_EPV0C = new TH3F("hdifful_EPV0C",  "dif phi in full with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
544     fOutput->Add(hdifful_EPV0);
545     fOutput->Add(hdifful_EPV0A);
546     fOutput->Add(hdifful_EPV0C);
547
548     hdifout_EPV0  = new TH3F("hdifout_EPV0",  "dif phi NOT in EMC with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
549     hdifout_EPV0A = new TH3F("hdifout_EPV0A", "dif phi NOT in EMC with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
550     hdifout_EPV0C = new TH3F("hdifout_EPV0C", "dif phi NOT in EMC with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
551     fOutput->Add(hdifout_EPV0);
552     fOutput->Add(hdifout_EPV0A);
553     fOutput->Add(hdifout_EPV0C);
554
555     hdifEMC_EPTPC = new TH3F("hdifEMC_EPTPC", "dif phi in EMC with EP",  100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
556     hdifful_EPTPC = new TH3F("hdifful_EPTPC",  "dif phi in full with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
557     hdifout_EPTPC = new TH3F("hdifout_EPTPC", "dif phi NOT in EMC with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
558     fOutput->Add(hdifEMC_EPTPC);
559     fOutput->Add(hdifful_EPTPC);
560     fOutput->Add(hdifout_EPTPC);
561
562     hdifClus_EPV0 = new TH3F("hdifClus_EPV0", "dif phi in EMC Clus with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
563     hdifClus_EPV0A = new TH3F("hdifClus_EPV0A", "dif phi in EMC Clus with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
564     hdifClus_EPV0C = new TH3F("hdifClus_EPV0C", "dif phi in EMC Clus with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
565     hdifClus_EPTPC = new TH3F("hdifClus_EPTPC", "dif phi in EMC Clus with EP", 100, 0., 100., 100, 0., TMath::Pi(), 15, 0., 15.);
566     fOutput->Add(hdifClus_EPV0);
567     fOutput->Add(hdifClus_EPV0A);
568     fOutput->Add(hdifClus_EPV0C);
569     fOutput->Add(hdifClus_EPTPC);
570
571     hAllcentV0  = new TH1F("hAllcentV0",  "All cent EP V0",  100, 0., TMath::Pi());
572     hAllcentV0r = new TH1F("hAllcentV0r", "All cent EP V0r", 100, 0., TMath::Pi());
573     hAllcentV0A = new TH1F("hAllcentV0A", "All cent EP V0A", 100, 0., TMath::Pi());
574     hAllcentV0C = new TH1F("hAllcentV0C", "All cent EP V0C", 100, 0., TMath::Pi());
575     hAllcentTPC = new TH1F("hAllcentTPC", "All cent EP TPC", 100, 0., TMath::Pi());
576     fOutput->Add(hAllcentV0);
577     fOutput->Add(hAllcentV0r);
578     fOutput->Add(hAllcentV0A);
579     fOutput->Add(hAllcentV0C);
580     fOutput->Add(hAllcentTPC);
581
582     h2DcosV0r = new TH2F("h2DcosV0r", "cos(Phi) V0r vs Run NUmber", 200, 0, 200, 100, -1, 1);
583     h2DsinV0r = new TH2F("h2DsinV0r", "sin(Phi) V0r vs Run NUmber", 200, 0, 200, 100, -1, 1);
584     h2DcosV0A = new TH2F("h2DcosV0A", "cos(Phi) V0r vs Run NUmber", 200, 0, 200, 100, -1, 1);
585     h2DsinV0A = new TH2F("h2DsinV0A", "sin(Phi) V0r vs Run NUmber", 200, 0, 200, 100, -1, 1);
586     h2DcosV0C = new TH2F("h2DcosV0C", "cos(Phi) V0r vs Run NUmber", 200, 0, 200, 100, -1, 1);
587     h2DsinV0C = new TH2F("h2DsinV0C", "sin(Phi) V0r vs Run NUmber", 200, 0, 200, 100, -1, 1);
588     h2DcosTPC = new TH2F("h2DcosTPC", "cos(Phi) V0r vs Run NUmber", 200, 0, 200, 100, -1, 1);
589     h2DsinTPC = new TH2F("h2DsinTPC", "sin(Phi) V0r vs Run NUmber", 200, 0, 200, 100, -1, 1);
590     fOutput->Add(h2DcosV0r);
591     fOutput->Add(h2DsinV0r);
592     fOutput->Add(h2DcosV0A);
593     fOutput->Add(h2DsinV0A);
594     fOutput->Add(h2DcosV0C);
595     fOutput->Add(h2DsinV0C);
596     fOutput->Add(h2DcosTPC);
597     fOutput->Add(h2DsinTPC);
598
599     hM02vsPtA = new TH2F("hM02vsPtA", "M02 vs Et before cut", 5000, 0, 50, 400, 0, 4.);
600     hM02vsPtB = new TH2F("hM02vsPtB", "M02 vs Et before cut", 5000, 0, 50, 400, 0, 4.);
601     fOutput->Add(hM02vsPtA);
602     fOutput->Add(hM02vsPtB);
603
604     hClusDxDZA = new TH2F("hClusDxDZA", "clus Dx vs Dz", 1000, -1., 1., 1000, -1., 1);
605     hClusDxDZB = new TH2F("hClusDxDZB", "clus Dx vs Dz", 1000, -1., 1., 1000, -1., 1);
606     fOutput->Add(hClusDxDZA);
607     fOutput->Add(hClusDxDZB);
608
609     const Int_t ndims = 5;
610     Int_t nMgg=500, nPt=40, nCent=20, nDeltaPhi=315,  ncos2phi=500;
611     Int_t bins[ndims] = {nMgg, nPt, nCent, nDeltaPhi, ncos2phi};
612     Double_t xmin[ndims] = { 0,   0.,  0,   0.,     -1.};
613     Double_t xmax[ndims] = { 0.5, 20., 100, 3.15,   1.};
614     fHEPV0r  = new THnSparseF("fHEPV0r",  "Flow histogram EPV0",  ndims, bins, xmin, xmax);
615     fHEPV0A = new THnSparseF("fHEPV0A",   "Flow histogram EPV0A", ndims, bins, xmin, xmax);
616     fHEPV0C = new THnSparseF("fHEPV0C",   "Flow histogram EPV0C", ndims, bins, xmin, xmax);
617     fHEPTPC = new THnSparseF("fHEPTPC",   "Flow histogram EPTPC", ndims, bins, xmin, xmax);
618     fOutput->Add(fHEPV0r);
619     fOutput->Add(fHEPV0A);
620     fOutput->Add(fHEPV0C);
621     fOutput->Add(fHEPTPC);
622
623     
624
625     PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram
626 }
627
628 //________________________________________________________________________
629 void AliAnalysisTaskPi0V2::UserExec(Option_t *) 
630 {
631     // Main loop
632     // Called for each event
633         
634     // Create pointer to reconstructed event
635    AliVEvent *event = InputEvent();
636    if (!event) { Printf("ERROR: Could not retrieve event"); return; }
637    // create pointer to event
638    fESD = dynamic_cast<AliESDEvent*>(event);
639    if (!fESD) {
640      AliError("Cannot get the ESD event");
641      return;
642    }
643    hEvtCount->Fill(1);
644     
645   Int_t AbsRunNumber = fESD->GetRunNumber();
646   fRunNumber = ConvertToInternalRunNumber(AbsRunNumber);
647
648   Bool_t isSelected =0;      
649   if(fEvtSelect == 1){  //MB+SemiCentral
650     isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & (AliVEvent::kAnyINT | AliVEvent::kSemiCentral));
651   } else if (fEvtSelect == 2){  //MB+Central+SemiCentral
652     isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & (AliVEvent::kAnyINT | AliVEvent::kSemiCentral | AliVEvent::kCentral));
653   } else if(fEvtSelect == 3){  //MB
654  isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & (AliVEvent::kAnyINT ));
655   }
656
657   if(!isSelected )
658         return; 
659
660   hEvtCount->Fill(2);
661   if(!fTrigClass.IsNull()){
662     TString fired;
663     fired = fESD->GetFiredTriggerClasses();
664     if (!fired.Contains("-B-"))
665       return;
666     TObjArray *arr = fTrigClass.Tokenize("|");
667     if (!arr)
668       return;
669     Bool_t match = 0;
670     for (Int_t i=0;i<arr->GetEntriesFast();++i) {
671       TObject *obj = arr->At(i);
672       if (!obj)
673         continue;
674       if (fired.Contains(obj->GetName())) {
675         match = 1;
676         break;
677       }
678     }
679     delete arr;
680     if (
681         !match && //select by Trigger classes in KCentral and KSemiCentral
682         !(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & (AliVEvent::kAnyINT ))              // always accept MB
683         ) 
684       return; //Not match skip this event
685   }
686
687     hEvtCount->Fill(3);
688     const AliESDVertex* fvertex = fESD->GetPrimaryVertex();
689     if(TMath::Abs(fvertex->GetZ())>fVtxCut)
690       return;
691     Double_t vertex[3] = {fvertex->GetX(), fvertex->GetY(), fvertex->GetZ()};
692
693     hEvtCount->Fill(4);
694
695     if(fESD->GetCentrality()) {
696       fCentrality = 
697         fESD->GetCentrality()->GetCentralityPercentile("CL1"); //spd vertex
698     } else{
699            return;
700     }
701
702     hEvtCount->Fill(5);
703     AliEventplane *ep = fESD->GetEventplane();
704     if (ep) {
705       if (ep->GetQVector())
706         fEPTPC    = ep->GetQVector()->Phi()/2. ;
707       else
708         fEPTPC = -999.;
709       if (ep->GetQsub1()&&ep->GetQsub2())
710         fEPTPCreso  = TMath::Cos(2.*(ep->GetQsub1()->Phi()/2.-ep->GetQsub2()->Phi()/2.));
711       else
712         fEPTPCreso = -1;
713
714       fEPV0    = ep->GetEventplane("V0",  fESD);
715       fEPV0A   = ep->GetEventplane("V0A", fESD);
716       fEPV0C   = ep->GetEventplane("V0C", fESD);
717       Double_t qx=0, qy=0;
718       Double_t qxr=0, qyr=0;
719       fEPV0Ar  = ep->CalculateVZEROEventPlane(fESD, 4, 5, 2, qxr, qyr);
720       fEPV0Cr  = ep->CalculateVZEROEventPlane(fESD, 2, 3, 2, qx,  qy);
721       qxr += qx;
722       qyr += qy;
723       fEPV0r   = TMath::ATan2(qyr,qxr)/2.;
724       fEPV0AR4 = ep->CalculateVZEROEventPlane(fESD, 4, 2, qx, qy);
725       fEPV0AR5 = ep->CalculateVZEROEventPlane(fESD, 5, 2, qx, qy);
726       fEPV0AR6 = ep->CalculateVZEROEventPlane(fESD, 6, 2, qx, qy);
727       fEPV0AR7 = ep->CalculateVZEROEventPlane(fESD, 7, 2, qx, qy);
728       fEPV0CR0 = ep->CalculateVZEROEventPlane(fESD, 0, 2, qx, qy);
729       fEPV0CR1 = ep->CalculateVZEROEventPlane(fESD, 1, 2, qx, qy);
730       fEPV0CR2 = ep->CalculateVZEROEventPlane(fESD, 2, 2, qx, qy);
731       fEPV0CR3 = ep->CalculateVZEROEventPlane(fESD, 3, 2, qx, qy);
732     }
733     FillEPQA(); //Fill the EP QA
734
735     hEvtCount->Fill(6);
736
737     if( fEPV0A<-2. || fEPV0C<-2. || fEPTPC<-2. || fEPV0r<-2.) 
738       return;
739
740     hEvtCount->Fill(7);
741
742     fEPV0   = TVector2::Phi_0_2pi(fEPV0);    if(fEPV0>TMath::Pi())   fEPV0  = fEPV0  - TMath::Pi();
743     fEPV0r  = TVector2::Phi_0_2pi(fEPV0r);   if(fEPV0r>TMath::Pi())  fEPV0r = fEPV0r - TMath::Pi();
744     fEPV0A  = TVector2::Phi_0_2pi(fEPV0A);   if(fEPV0A>TMath::Pi())  fEPV0A = fEPV0A - TMath::Pi();
745     fEPV0C  = TVector2::Phi_0_2pi(fEPV0C);   if(fEPV0C>TMath::Pi())  fEPV0C = fEPV0C - TMath::Pi();
746     fEPV0Ar = TVector2::Phi_0_2pi(fEPV0Ar);  if(fEPV0Ar>TMath::Pi()) fEPV0Ar = fEPV0Ar - TMath::Pi();
747     fEPV0Cr = TVector2::Phi_0_2pi(fEPV0Cr);  if(fEPV0Cr>TMath::Pi()) fEPV0Cr = fEPV0Cr - TMath::Pi();
748     fEPV0AR4   = TVector2::Phi_0_2pi(fEPV0AR4);    if(fEPV0AR4>TMath::Pi())   fEPV0AR4  = fEPV0AR4 - TMath::Pi();
749     fEPV0AR7   = TVector2::Phi_0_2pi(fEPV0AR7);    if(fEPV0AR7>TMath::Pi())   fEPV0AR7  = fEPV0AR7 - TMath::Pi();
750     fEPV0CR0   = TVector2::Phi_0_2pi(fEPV0CR0);    if(fEPV0CR0>TMath::Pi())   fEPV0CR0  = fEPV0CR0 - TMath::Pi();
751     fEPV0CR3   = TVector2::Phi_0_2pi(fEPV0CR3);    if(fEPV0CR3>TMath::Pi())   fEPV0CR3  = fEPV0CR3 - TMath::Pi();
752
753    if(fEPTPC != -999.)
754    hEPTPC->Fill(fCentrality,  fEPTPC); 
755    if(fEPTPCreso!=-1) hresoTPC->Fill(fCentrality, fEPTPCreso);
756    hEPV0->Fill(fCentrality,   fEPV0);
757    hEPV0A->Fill(fCentrality,  fEPV0A);
758    hEPV0C->Fill(fCentrality,  fEPV0C);
759    hEPV0Ar->Fill(fCentrality, fEPV0Ar);
760    hEPV0Cr->Fill(fCentrality, fEPV0Cr);
761    hEPV0r->Fill(fCentrality,  fEPV0r);
762    hEPV0AR4->Fill(fCentrality, fEPV0AR4);
763    hEPV0AR7->Fill(fCentrality, fEPV0AR7);
764    hEPV0CR0->Fill(fCentrality, fEPV0CR0);
765    hEPV0CR3->Fill(fCentrality, fEPV0CR3);
766
767    hAllcentV0->Fill(fEPV0);
768    hAllcentV0r->Fill(fEPV0r);
769    hAllcentV0A->Fill(fEPV0A);
770    hAllcentV0C->Fill(fEPV0C);  
771    hAllcentTPC->Fill(fEPTPC);
772
773    hdifV0Ar_V0Cr->Fill(fCentrality, TMath::Cos(2.*(fEPV0Ar - fEPV0Cr)));
774    hdifV0A_V0CR0->Fill(fCentrality, TMath::Cos(2.*(fEPV0A - fEPV0CR0)));
775    hdifV0A_V0CR3->Fill(fCentrality, TMath::Cos(2.*(fEPV0A - fEPV0CR3)));
776    hdifV0ACR0_V0CR3->Fill(fCentrality, TMath::Cos(2*(fEPV0CR0 - fEPV0CR3)));
777    hdifV0C_V0AR4->Fill(fCentrality, TMath::Cos(2*(fEPV0C - fEPV0AR4)));
778    hdifV0C_V0AR7->Fill(fCentrality, TMath::Cos(2*(fEPV0C - fEPV0AR7)));
779    hdifV0AR4_V0AR7->Fill(fCentrality, TMath::Cos(2*(fEPV0AR4 - fEPV0AR7)));
780         
781    hdifV0A_V0C->Fill(fCentrality, TMath::Cos(2*(fEPV0A - fEPV0C)));
782    hdifV0A_TPC->Fill(fCentrality, TMath::Cos(2*(fEPV0A - fEPTPC)));
783    hdifV0C_TPC->Fill(fCentrality, TMath::Cos(2*(fEPV0C - fEPTPC)));
784    hdifV0C_V0A->Fill(fCentrality, TMath::Cos(2*(fEPV0C - fEPV0A)));
785     // Cluster loop for reconstructed event
786
787    Int_t nCluster =  fESD->GetNumberOfCaloClusters(); 
788    for(Int_t i=0; i<nCluster; ++i){
789      AliESDCaloCluster *c1 = fESD->GetCaloCluster(i);
790      hClusDxDZA->Fill(c1->GetTrackDz(), c1->GetTrackDx());
791      Float_t clsPosEt[3] = {0,0,0};
792      c1->GetPosition(clsPosEt);
793      TVector3 clsVec(clsPosEt);
794      Double_t Et = c1->E()*TMath::Sin(clsVec.Theta());
795      hM02vsPtA->Fill(Et, c1->GetM02());
796      if(!c1->IsEMCAL()) continue;
797      if(!IsGoodCluster(c1)) continue;
798      hM02vsPtB->Fill(Et, c1->GetM02()); 
799      hClusDxDZB->Fill(c1->GetTrackDz(), c1->GetTrackDx());
800      TLorentzVector p1;
801      GetMom(p1, c1, vertex);
802      for(Int_t j=i+1; j<nCluster; ++j){
803        AliESDCaloCluster *c2 = fESD->GetCaloCluster(j);
804        if(!c2->IsEMCAL()) continue;
805        if(!IsGoodCluster(c2)) continue;
806        TLorentzVector p2;
807        GetMom(p2, c2, vertex);
808        FillPion(p1, p2, fEPV0r, fEPV0A, fEPV0C, fEPTPC);
809      }
810    }
811
812   if(isV1Clus){
813     for(Int_t i=0; i<nCluster; ++i){
814       AliESDCaloCluster *c3 = fESD->GetCaloCluster(i);      
815       if(!c3->IsEMCAL()) continue;
816       if(!IsGoodClusterV1(c3)) continue;
817       TLorentzVector p3;
818       GetMom(p3, c3, vertex);
819       FillCluster(p3, fEPV0r, fEPV0A, fEPV0C, fEPTPC);
820     }
821   }
822
823
824    if (!fTracksName.IsNull() && !fTracks) {
825      fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName));
826      if (!fTracks) {
827        AliError(Form("%s: Could not retrieve tracks %s!", GetName(), fTracksName.Data())); 
828        return;
829      }
830   }
831
832    Int_t ntracks = fTracks->GetEntries();
833    for(Int_t i=0; i<ntracks; ++i){
834      AliVTrack *track = static_cast<AliVTrack*>(fTracks->At(i));
835      Double_t tPhi = track->Phi();
836      Double_t tPt  = track->Pt();
837
838      Double_t difTrackV0  = TVector2::Phi_0_2pi(tPhi-fEPV0);   if(difTrackV0  >TMath::Pi()) difTrackV0  -= TMath::Pi();
839      Double_t difTrackV0A = TVector2::Phi_0_2pi(tPhi-fEPV0A);  if(difTrackV0A >TMath::Pi()) difTrackV0A -= TMath::Pi();
840      Double_t difTrackV0C = TVector2::Phi_0_2pi(tPhi-fEPV0C);  if(difTrackV0C >TMath::Pi()) difTrackV0C -= TMath::Pi();
841      Double_t difTrackTPC = TVector2::Phi_0_2pi(tPhi-fEPTPC);  if(difTrackTPC >TMath::Pi()) difTrackTPC -= TMath::Pi();
842      if(track->IsEMCAL()){      
843        hdifEMC_EPV0->Fill(fCentrality, difTrackV0, tPt);
844        hdifEMC_EPV0A->Fill(fCentrality, difTrackV0A, tPt);
845        hdifEMC_EPV0C->Fill(fCentrality, difTrackV0C, tPt);
846        hdifEMC_EPTPC->Fill(fCentrality, difTrackTPC, tPt);
847      }else{
848        hdifout_EPV0->Fill(fCentrality, difTrackV0, tPt);
849        hdifout_EPV0A->Fill(fCentrality, difTrackV0A, tPt);
850        hdifout_EPV0C->Fill(fCentrality, difTrackV0C, tPt);
851        hdifout_EPTPC->Fill(fCentrality, difTrackTPC, tPt);
852      }
853      hdifful_EPV0->Fill(fCentrality,    difTrackV0, tPt);
854      hdifful_EPV0A->Fill(fCentrality,   difTrackV0A, tPt);
855      hdifful_EPV0C->Fill(fCentrality,   difTrackV0C, tPt);
856      hdifful_EPTPC->Fill(fCentrality,   difTrackTPC, tPt);
857     }
858     hEvtCount->Fill(8);
859
860     // NEW HISTO should be filled before this point, as PostData puts the
861     // information for this iteration of the UserExec in the container
862     PostData(1, fOutput);
863 }
864 //____________________________________________________________________
865 Int_t AliAnalysisTaskPi0V2::ConvertToInternalRunNumber(Int_t n)
866 {
867     switch(n){
868     case  170593 : return 179 ;
869     case  170572 : return 178 ;
870     case  170556 : return 177 ;
871     case  170552 : return 176 ;
872     case  170546 : return 175 ;
873     case  170390 : return 174 ;
874     case  170389 : return 173 ;
875     case  170388 : return 172 ;
876     case  170387 : return 171 ;
877     case  170315 : return 170 ;
878     case  170313 : return 169 ;
879     case  170312 : return 168 ;
880     case  170311 : return 167 ;
881     case  170309 : return 166 ;
882     case  170308 : return 165 ;
883     case  170306 : return 164 ;
884     case  170270 : return 163 ;
885     case  170269 : return 162 ;
886     case  170268 : return 161 ;
887     case  170267 : return 160 ;
888     case  170264 : return 159 ;
889     case  170230 : return 158 ;
890     case  170228 : return 157 ;
891     case  170208 : return 156 ;
892     case  170207 : return 155 ;
893     case  170205 : return 154 ;
894     case  170204 : return 153 ;
895     case  170203 : return 152 ;
896     case  170195 : return 151 ;
897     case  170193 : return 150 ;
898     case  170163 : return 149 ;
899     case  170162 : return 148 ;
900     case  170159 : return 147 ;
901     case  170155 : return 146 ;
902     case  170152 : return 145 ;
903     case  170091 : return 144 ;
904     case  170089 : return 143 ;
905     case  170088 : return 142 ;
906     case  170085 : return 141 ;
907     case  170084 : return 140 ;
908     case  170083 : return 139 ;
909     case  170081 : return 138 ;
910     case  170040 : return 137 ;
911     case  170038 : return 136 ;
912     case  170036 : return 135 ;
913     case  170027 : return 134 ;
914     case  169981 : return 133 ;
915     case  169975 : return 132 ;
916     case  169969 : return 131 ;
917     case  169965 : return 130 ;
918     case  169961 : return 129 ;
919     case  169956 : return 128 ;
920     case  169926 : return 127 ;
921     case  169924 : return 126 ;
922     case  169923 : return 125 ;
923     case  169922 : return 124 ;
924     case  169919 : return 123 ;
925     case  169918 : return 122 ;
926     case  169914 : return 121 ;
927     case  169859 : return 120 ;
928     case  169858 : return 119 ;
929     case  169855 : return 118 ;
930     case  169846 : return 117 ;
931     case  169838 : return 116 ;
932     case  169837 : return 115 ;
933     case  169835 : return 114 ;
934     case  169683 : return 113 ;
935     case  169628 : return 112 ;
936     case  169591 : return 111 ;
937     case  169590 : return 110 ;
938     case  169588 : return 109 ;
939     case  169587 : return 108 ;
940     case  169586 : return 107 ;
941     case  169584 : return 106 ;
942     case  169557 : return 105 ;
943     case  169555 : return 104 ;
944     case  169554 : return 103 ;
945     case  169553 : return 102 ;
946     case  169550 : return 101 ;
947     case  169515 : return 100 ;
948     case  169512 : return 99 ;
949     case  169506 : return 98 ;
950     case  169504 : return 97 ;
951     case  169498 : return 96 ;
952     case  169475 : return 95 ;
953     case  169420 : return 94 ;
954     case  169419 : return 93 ;
955     case  169418 : return 92 ;
956     case  169417 : return 91 ;
957     case  169415 : return 90 ;
958     case  169411 : return 89 ;
959     case  169238 : return 88 ;
960     case  169236 : return 87 ;
961     case  169167 : return 86 ;
962     case  169160 : return 85 ;
963     case  169156 : return 84 ;
964     case  169148 : return 83 ;
965     case  169145 : return 82 ;
966     case  169144 : return 81 ;
967     case  169143 : return 80 ;
968     case  169138 : return 79 ;
969     case  169099 : return 78 ;
970     case  169094 : return 77 ;
971     case  169091 : return 76 ;
972     case  169045 : return 75 ;
973     case  169044 : return 74 ;
974     case  169040 : return 73 ;
975     case  169035 : return 72 ;
976     case  168992 : return 71 ;
977     case  168988 : return 70 ;
978     case  168984 : return 69 ;
979     case  168826 : return 68 ;
980     case  168777 : return 67 ;
981     case  168514 : return 66 ;
982     case  168512 : return 65 ;
983     case  168511 : return 64 ;
984     case  168467 : return 63 ;
985     case  168464 : return 62 ;
986     case  168461 : return 61 ;
987     case  168460 : return 60 ;
988     case  168458 : return 59 ;
989     case  168362 : return 58 ;
990     case  168361 : return 57 ;
991     case  168356 : return 56 ;
992     case  168342 : return 55 ;
993     case  168341 : return 54 ;
994     case  168325 : return 53 ;
995     case  168322 : return 52 ;
996     case  168318 : return 51 ;
997     case  168311 : return 50 ;
998     case  168310 : return 49 ;
999     case  168213 : return 48 ;
1000     case  168212 : return 47 ;
1001     case  168208 : return 46 ;
1002     case  168207 : return 45 ;
1003     case  168206 : return 44 ;
1004     case  168205 : return 43 ;
1005     case  168204 : return 42 ;
1006     case  168203 : return 41 ;
1007     case  168181 : return 40 ;
1008     case  168177 : return 39 ;
1009     case  168175 : return 38 ;
1010     case  168173 : return 37 ;
1011     case  168172 : return 36 ;
1012     case  168171 : return 35 ;
1013     case  168115 : return 34 ;
1014     case  168108 : return 33 ;
1015     case  168107 : return 32 ;
1016     case  168105 : return 31 ;
1017     case  168104 : return 30 ;
1018     case  168103 : return 29 ;
1019     case  168076 : return 28 ;
1020     case  168069 : return 27 ;
1021     case  168068 : return 26 ;
1022     case  168066 : return 25 ;
1023     case  167988 : return 24 ;
1024     case  167987 : return 23 ;
1025     case  167986 : return 22 ;
1026     case  167985 : return 21 ;
1027     case  167921 : return 20 ;
1028     case  167920 : return 19 ;
1029     case  167915 : return 18 ;
1030     case  167909 : return 17 ;
1031     case  167903 : return 16 ;
1032     case  167902 : return 15 ;
1033     case  167818 : return 14 ;
1034     case  167814 : return 13 ;
1035     case  167813 : return 12 ;
1036     case  167808 : return 11 ;
1037     case  167807 : return 10 ;
1038     case  167806 : return 9 ;
1039     case  167713 : return 8 ;
1040     case  167712 : return 7 ;
1041     case  167711 : return 6 ;
1042     case  167706 : return 5 ;
1043     case  167693 : return 4 ;
1044     case  166532 : return 3 ;
1045     case  166530 : return 2 ;
1046     case  166529 : return 1 ;
1047
1048     default : return 199;
1049     }
1050 }
1051 //_______________________________________________________________________
1052 void AliAnalysisTaskPi0V2::FillEPQA()
1053 {
1054   
1055   h2DcosV0r->Fill(fRunNumber, TMath::Cos(fEPV0r));
1056   h2DsinV0r->Fill(fRunNumber, TMath::Sin(fEPV0r));
1057   h2DcosV0A->Fill(fRunNumber, TMath::Cos(fEPV0A));
1058   h2DsinV0A->Fill(fRunNumber, TMath::Sin(fEPV0A));
1059   h2DcosV0C->Fill(fRunNumber, TMath::Cos(fEPV0C));
1060   h2DsinV0C->Fill(fRunNumber, TMath::Sin(fEPV0C));
1061   h2DcosTPC->Fill(fRunNumber, TMath::Cos(fEPTPC));
1062   h2DsinTPC->Fill(fRunNumber, TMath::Sin(fEPTPC));
1063
1064
1065 }
1066 //________________________________________________________________________
1067 void AliAnalysisTaskPi0V2::Terminate(Option_t *) 
1068 {
1069     // Draw result to screen, or perform fitting, normalizations
1070     // Called once at the end of the query
1071 //    fOutput = dynamic_cast<TList*> (GetOutputData(1));
1072  //   if(!fOutput) { Printf("ERROR: could not retrieve TList fOutput"); return; }
1073         
1074     // Get the physics selection histograms with the selection statistics
1075     //AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1076     //AliESDInputHandler *inputH = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
1077     //TH2F *histStat = (TH2F*)inputH->GetStatistics();
1078    
1079    
1080     // NEW HISTO should be retrieved from the TList container in the above way,
1081     // so it is available to draw on a canvas such as below
1082
1083 }