]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/SPECTRA/PiKaPr/TestAOD/AliAnalysisTaskV2AllChAOD.cxx
a694b18865024e1ce3334e11cf791cf55d64c8d0
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TestAOD / AliAnalysisTaskV2AllChAOD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2009, 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 //-----------------------------------------------------------------
17 //         AliAnalysisTaskV2AllChAOD class
18 //-----------------------------------------------------------------
19
20 #include "TChain.h"
21 #include "TTree.h"
22 #include "TLegend.h"
23 #include "TH1F.h"
24 #include "TH1D.h"
25 #include "TH2F.h"
26 #include "THnSparse.h"
27 #include "TProfile.h"
28 #include "TCanvas.h"
29 #include "AliAnalysisTask.h"
30 #include "AliAODTrack.h"
31 #include "AliAODMCParticle.h"
32 #include "AliVParticle.h"
33 #include "AliAODEvent.h"
34 #include "AliAODInputHandler.h"
35 #include "AliAnalysisTaskV2AllChAOD.h"
36 #include "AliAnalysisTaskESDfilter.h"
37 #include "AliAnalysisDataContainer.h"
38 #include "AliSpectraAODTrackCuts.h"
39 #include "AliSpectraAODEventCuts.h"
40 #include "AliPIDCombined.h"
41 #include "AliCentrality.h"
42 #include "TProof.h"
43 #include "AliVEvent.h"
44 #include "AliStack.h"
45 #include <TMCProcess.h>
46 #include <TRandom.h>
47
48 #include <iostream>
49
50 using namespace std;
51
52 ClassImp(AliAnalysisTaskV2AllChAOD)
53
54 //________________________________________________________________________
55 AliAnalysisTaskV2AllChAOD::AliAnalysisTaskV2AllChAOD(const char *name) : AliAnalysisTaskSE(name),  
56   fAOD(0x0),
57   fTrackCuts(0x0),
58   fEventCuts(0x0),
59   fIsMC(0),
60   fCharge(0),
61   fVZEROside(0),
62   fOutput(0x0),
63   fOutput_lq(0x0),
64   fOutput_sq(0x0),
65   fnCentBins(20),
66   fnQvecBins(100),
67   fQvecUpperLim(100),
68   fCutLargeQperc(90.),
69   fCutSmallQperc(10.),
70   fEtaGapMin(-0.5),
71   fEtaGapMax(0.5),
72   fTrkBit(128),
73   fEtaCut(0.8),
74   fMinPt(0),
75   fMaxPt(20.0),
76   fMinTPCNcls(70),
77   fFillTHn(kFALSE),
78   fCentrality(0),
79   fQvector(0),
80   fQvector_lq(0),
81   fQvector_sq(0),
82   fResSP(0),
83   fResSP_vs_Cent(0),
84   f2partCumQA_vs_Cent(0),
85   f2partCumQB_vs_Cent(0),
86   fEta_vs_Phi_bef(0),
87   fEta_vs_PhiA(0),
88   fEta_vs_PhiB(0),
89   fResSP_lq(0),
90   fResSP_vs_Cent_lq(0),
91   f2partCumQA_vs_Cent_lq(0),
92   f2partCumQB_vs_Cent_lq(0),
93   fResSP_sq(0),
94   fResSP_vs_Cent_sq(0),
95   f2partCumQA_vs_Cent_sq(0),
96   f2partCumQB_vs_Cent_sq(0),
97   fResSP_inclusive(0),
98   fv2SPGap1A_inclusive_mb(0),
99   fv2SPGap1B_inclusive_mb(0),
100   fv2SPGap1A_inclusive_lq(0),
101   fv2SPGap1B_inclusive_lq(0),
102   fv2SPGap1A_inclusive_sq(0),
103   fv2SPGap1B_inclusive_sq(0),
104   fResSPmc_inclusive(0),
105   fv2SPGap1Amc_inclusive_mb(0),
106   fv2SPGap1Bmc_inclusive_mb(0),
107   fv2SPGap1Amc_inclusive_lq(0),
108   fv2SPGap1Bmc_inclusive_lq(0),
109   fv2SPGap1Amc_inclusive_sq(0),
110   fv2SPGap1Bmc_inclusive_sq(0),
111   fIsRecoEff(0),
112   fRecoEffList(0),
113   fQvecGen(0),
114   fQgenType(0),
115   fnNchBins(400),
116   fDoCentrSystCentrality(0)
117 {
118   
119   for (Int_t i = 0; i< 9; i++){
120     
121     fResSP_vs_Qvec[i] = 0;
122     
123     fv2SPGap1A[i] = 0;
124     fv2SPGap1B[i] = 0;
125
126     fSinGap1Aq[i] = 0;
127     fCosGap1Aq[i] = 0;
128     fSinGap1Bq[i] = 0;
129     fCosGap1Bq[i] = 0;
130
131     fSinGap1A[i] = 0;
132     fCosGap1A[i] = 0;
133     fSinGap1B[i] = 0;
134     fCosGap1B[i] = 0;
135     
136     //large q
137     fv2SPGap1A_lq[i] = 0;
138     fv2SPGap1B_lq[i] = 0;
139     
140     fSinGap1Aq_lq[i] = 0;
141     fCosGap1Aq_lq[i] = 0;
142     fSinGap1Bq_lq[i] = 0;
143     fCosGap1Bq_lq[i] = 0;
144     
145     fSinGap1A_lq[i] = 0;
146     fCosGap1A_lq[i] = 0;
147     fSinGap1B_lq[i] = 0;
148     fCosGap1B_lq[i] = 0;
149     
150     //small q
151     fv2SPGap1A_sq[i] = 0;
152     fv2SPGap1B_sq[i] = 0;
153     
154     fSinGap1Aq_sq[i] = 0;
155     fCosGap1Aq_sq[i] = 0;
156     fSinGap1Bq_sq[i] = 0;
157     fCosGap1Bq_sq[i] = 0;
158     
159     fSinGap1A_sq[i] = 0;
160     fCosGap1A_sq[i] = 0;
161     fSinGap1B_sq[i] = 0;
162     fCosGap1B_sq[i] = 0;
163     
164   }
165     
166   fRecoEffList=new TList();
167   fRecoEffList->SetOwner();
168   fRecoEffList->SetName("fRecoEffList");
169     
170   // Default constructor
171   DefineInput(0, TChain::Class());
172   DefineOutput(1, TList::Class());
173   DefineOutput(2, AliSpectraAODEventCuts::Class());
174   DefineOutput(3, AliSpectraAODTrackCuts::Class());
175   DefineOutput(4, TList::Class());
176   DefineOutput(5, TList::Class());
177 }
178
179 //________________________________________________________________________
180 void AliAnalysisTaskV2AllChAOD::UserCreateOutputObjects()
181 {
182   // create output objects
183   fOutput=new TList();
184   fOutput->SetOwner();
185   fOutput->SetName("fOutput");
186   
187   fOutput_lq=new TList();
188   fOutput_lq->SetOwner();
189   fOutput_lq->SetName("fOutput_lq");
190   
191   fOutput_sq=new TList();
192   fOutput_sq->SetOwner();
193   fOutput_sq->SetName("fOutput_sq");
194   
195   if (!fTrackCuts) AliFatal("Track Cuts should be set in the steering macro");
196   if (!fEventCuts) AliFatal("Event Cuts should be set in the steering macro");
197   
198   if( fFillTHn ){ 
199     //dimensions of THnSparse for Q vector checks
200     const Int_t nvarev=6;
201     //                                             cent         q-rec_perc        qvec-rec      q-gen_tracks   qvec-gen_vzero          Nch
202     Int_t    binsHistRealEv[nvarev] = {     fnCentBins,              100,        fnQvecBins,     fnQvecBins,       fnQvecBins,     fnNchBins};
203     Double_t xminHistRealEv[nvarev] = {             0.,               0.,                0.,             0.,               0.,            0.};
204     Double_t xmaxHistRealEv[nvarev] = {           100.,             100.,     fQvecUpperLim,  fQvecUpperLim,    fQvecUpperLim,         2000.};
205     
206     THnSparseF* NSparseHistEv = new THnSparseF("NSparseHistEv","NSparseHistEv",nvarev,binsHistRealEv,xminHistRealEv,xmaxHistRealEv);
207     NSparseHistEv->GetAxis(0)->SetTitle(Form("%s cent",fEventCuts->GetCentralityMethod().Data()));
208     NSparseHistEv->GetAxis(0)->SetName(Form("%s_cent",fEventCuts->GetCentralityMethod().Data()));
209    
210     NSparseHistEv->GetAxis(1)->SetTitle("q-vec rec percentile");
211     NSparseHistEv->GetAxis(1)->SetName("Qrec_perc");
212     
213     NSparseHistEv->GetAxis(2)->SetTitle("q-vec rec");
214     NSparseHistEv->GetAxis(2)->SetName("Qrec");
215     
216     NSparseHistEv->GetAxis(3)->SetTitle("q-vec gen tracks");
217     NSparseHistEv->GetAxis(3)->SetName("Qgen_tracks");
218     
219     NSparseHistEv->GetAxis(4)->SetTitle("q-vec gen vzero");
220     NSparseHistEv->GetAxis(4)->SetName("Qgen_vzero");
221     
222     NSparseHistEv->GetAxis(5)->SetTitle("Ncharged");
223     NSparseHistEv->GetAxis(5)->SetName("Nch");
224     fOutput->Add(NSparseHistEv);
225   }
226   
227   fCentrality = new TH1D("fCentrality", "centrality distribution; centrality", 200, 0., 100);
228   fOutput->Add(fCentrality);
229   
230   fQvector = new TH1D("fQvector", "q-vector distribution; q-vector", fnQvecBins, 0., fQvecUpperLim);
231   fOutput->Add(fQvector);
232   
233   fQvector_lq = new TH1D("fQvector_lq", "q-vector distribution; q-vector", fnQvecBins, 0., fQvecUpperLim);
234   fOutput_lq->Add(fQvector_lq);
235   
236   fQvector_sq = new TH1D("fQvector_sq", "q-vector distribution; q-vector", fnQvecBins, 0., fQvecUpperLim);
237   fOutput_sq->Add(fQvector_sq);
238   
239   // binning common to all the THn
240   //change it according to your needs + move it to global variables -> setter/getter
241 //   Double_t ptBins[] = {0., 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.4, 2.8, 3.2, 3.6, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 16.0, 20.0};
242 //   const Int_t nptBins = 31;
243   Double_t ptBins[] = {0., 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 3.0, 3.4, 3.8, 4.2, 4.6, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0, 10.0, 12.0, 14.0, 16.0, 20.0};
244   const Int_t nptBins = 33;
245   
246   fResSP = new TProfile("fResSP", "Resolution; centrality; Resolution", 9, -0.5, 8.5);
247   fOutput->Add(fResSP);
248   
249   fResSP_vs_Cent = new TProfile("fResSP_vs_Cent", "Resolution; centrality; Resolution", 20., 0., 100.);
250   fOutput->Add(fResSP_vs_Cent);
251   
252   f2partCumQA_vs_Cent = new TProfile("f2partCumQA_vs_Cent", "Resolution; centrality; Resolution", 100., 0., 100.);
253   fOutput->Add(f2partCumQA_vs_Cent);
254   
255   f2partCumQB_vs_Cent = new TProfile("f2partCumQB_vs_Cent", "Resolution; centrality; Resolution", 100., 0., 100.);
256   fOutput->Add(f2partCumQB_vs_Cent);
257
258   fEta_vs_Phi_bef = new TH2D("fEta_vs_Phi_bef","eta vs phi distribution before eta gap;#eta;#phi",200.,-1.,1.,175.,0.,7.);
259   fOutput->Add(fEta_vs_Phi_bef);
260   
261   fEta_vs_PhiA = new TH2D("fEta_vs_PhiA","eta vs phi distribution;#eta;#phi",200.,-1.,1.,175.,0.,7.);
262   fOutput->Add(fEta_vs_PhiA);
263   
264   fEta_vs_PhiB = new TH2D("fEta_vs_PhiB","eta vs phi distribution;#eta;#phi",200.,-1.,1.,175.,0.,7.);
265   fOutput->Add(fEta_vs_PhiB);
266   
267     // MC closure test
268     fResSP_inclusive = new TProfile("fResSP_inclusive", "Resolution; ese; Resolution", 3, 0., 3.);
269     fOutput->Add(fResSP_inclusive);
270   
271     fv2SPGap1A_inclusive_mb = new TProfile("fv2SPGap1A_inclusive_mb", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
272     fOutput->Add(fv2SPGap1A_inclusive_mb);
273
274     fv2SPGap1B_inclusive_mb = new TProfile("fv2SPGap1B_inclusive_mb", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
275     fOutput->Add(fv2SPGap1B_inclusive_mb);
276     
277     
278   //large q
279   fResSP_lq = new TProfile("fResSP_lq", "Resolution; centrality; Resolution", 9, -0.5, 8.5);
280   fOutput_lq->Add(fResSP_lq);
281   
282   fResSP_vs_Cent_lq = new TProfile("fResSP_vs_Cent_lq", "Resolution; centrality; Resolution", 20., 0., 100.);
283   fOutput_lq->Add(fResSP_vs_Cent_lq);
284   
285   f2partCumQA_vs_Cent_lq = new TProfile("f2partCumQA_vs_Cent_lq", "Resolution; centrality; Resolution", 100., 0., 100.);
286   fOutput_lq->Add(f2partCumQA_vs_Cent_lq);
287   
288   f2partCumQB_vs_Cent_lq = new TProfile("f2partCumQB_vs_Cent_lq", "Resolution; centrality; Resolution", 100., 0., 100.);
289   fOutput_lq->Add(f2partCumQB_vs_Cent_lq);
290         
291     // MC closure test
292     fv2SPGap1A_inclusive_lq = new TProfile("fv2SPGap1A_inclusive_lq", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
293     fOutput_lq->Add(fv2SPGap1A_inclusive_lq);
294
295     fv2SPGap1B_inclusive_lq = new TProfile("fv2SPGap1B_inclusive_lq", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
296     fOutput_lq->Add(fv2SPGap1B_inclusive_lq);
297   
298   //small q resolution
299   fResSP_sq = new TProfile("fResSP_sq", "Resolution; centrality; Resolution", 9, -0.5, 8.5);
300   fOutput_sq->Add(fResSP_sq);
301
302   fResSP_vs_Cent_sq = new TProfile("fResSP_vs_Cent_sq", "Resolution; centrality; Resolution", 20., 0., 100.);
303   fOutput_sq->Add(fResSP_vs_Cent_sq);
304   
305   f2partCumQA_vs_Cent_sq = new TProfile("f2partCumQA_vs_Cent_sq", "Resolution; centrality; Resolution", 100., 0., 100.);
306   fOutput_sq->Add(f2partCumQA_vs_Cent_sq);
307   
308   f2partCumQB_vs_Cent_sq = new TProfile("f2partCumQB_vs_Cent_sq", "Resolution; centrality; Resolution", 100., 0., 100.);
309   fOutput_sq->Add(f2partCumQB_vs_Cent_sq);
310         
311     // MC closure test
312     fv2SPGap1A_inclusive_sq = new TProfile("fv2SPGap1A_inclusive_sq", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
313     fOutput_sq->Add(fv2SPGap1A_inclusive_sq);
314
315     fv2SPGap1B_inclusive_sq = new TProfile("fv2SPGap1B_inclusive_sq", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
316     fOutput_sq->Add(fv2SPGap1B_inclusive_sq);
317   
318   for (Int_t iC = 0; iC < 9; iC++){
319     
320     fResSP_vs_Qvec[iC] = new TProfile(Form("fResSP_vs_Qvec_%d", iC), "Resolution; Qvec (V0A); Resolution", 10., 0., 100.);
321     fOutput->Add(fResSP_vs_Qvec[iC]);
322
323     fv2SPGap1A[iC] = new TProfile(Form("fv2SPGap1A_%d", iC), "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
324     fOutput->Add(fv2SPGap1A[iC]);
325
326     fv2SPGap1B[iC] = new TProfile(Form("fv2SPGap1B_%d", iC), "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
327     fOutput->Add(fv2SPGap1B[iC]);
328
329     fSinGap1Aq[iC] = new TProfile(Form("fSinGap1Aq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
330     fOutput->Add(fSinGap1Aq[iC]);
331       
332     fCosGap1Aq[iC] = new TProfile(Form("fCosGap1Aq_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
333     fOutput->Add(fCosGap1Aq[iC]);
334     
335     fSinGap1Bq[iC] = new TProfile(Form("fSinGap1Bq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
336     fOutput->Add(fSinGap1Bq[iC]);
337     
338     fCosGap1Bq[iC] = new TProfile(Form("fCosGap1Bq_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
339     fOutput->Add(fCosGap1Bq[iC]);
340
341     fSinGap1A[iC] = new TProfile(Form("fSinGap1A_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
342     fOutput->Add(fSinGap1A[iC]);
343       
344     fCosGap1A[iC] = new TProfile(Form("fCosGap1A_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
345     fOutput->Add(fCosGap1A[iC]);
346     
347     fSinGap1B[iC] = new TProfile(Form("fSinGap1B_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
348     fOutput->Add(fSinGap1B[iC]);
349     
350     fCosGap1B[iC] = new TProfile(Form("fCosGap1B_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
351     fOutput->Add(fCosGap1B[iC]);
352     
353     //large q
354     fv2SPGap1A_lq[iC] = new TProfile(Form("fv2SPGap1A_lq_%d", iC), "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
355     fOutput_lq->Add(fv2SPGap1A_lq[iC]);
356
357     fv2SPGap1B_lq[iC] = new TProfile(Form("fv2SPGap1B_lq_%d", iC), "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
358     fOutput_lq->Add(fv2SPGap1B_lq[iC]);
359
360     fSinGap1Aq_lq[iC] = new TProfile(Form("fSinGap1Aq_lq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
361     fOutput_lq->Add(fSinGap1Aq_lq[iC]);
362       
363     fCosGap1Aq_lq[iC] = new TProfile(Form("fCosGap1Aq_lq_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
364     fOutput_lq->Add(fCosGap1Aq_lq[iC]);
365     
366     fSinGap1Bq_lq[iC] = new TProfile(Form("fSinGap1Bq_lq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
367     fOutput_lq->Add(fSinGap1Bq_lq[iC]);
368     
369     fCosGap1Bq_lq[iC] = new TProfile(Form("fCosGap1Bq_lq_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
370     fOutput_lq->Add(fCosGap1Bq_lq[iC]);
371
372     fSinGap1A_lq[iC] = new TProfile(Form("fSinGap1A_lq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
373     fOutput_lq->Add(fSinGap1A_lq[iC]);
374       
375     fCosGap1A_lq[iC] = new TProfile(Form("fCosGap1A_lq_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
376     fOutput_lq->Add(fCosGap1A_lq[iC]);
377     
378     fSinGap1B_lq[iC] = new TProfile(Form("fSinGap1B_lq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
379     fOutput_lq->Add(fSinGap1B_lq[iC]);
380     
381     fCosGap1B_lq[iC] = new TProfile(Form("fCosGap1B_lq_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
382     fOutput_lq->Add(fCosGap1B_lq[iC]);
383     
384     //small q
385     fv2SPGap1A_sq[iC] = new TProfile(Form("fv2SPGap1A_sq_%d", iC), "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
386     fOutput_sq->Add(fv2SPGap1A_sq[iC]);
387
388     fv2SPGap1B_sq[iC] = new TProfile(Form("fv2SPGap1B_sq_%d", iC), "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
389     fOutput_sq->Add(fv2SPGap1B_sq[iC]);
390
391     fSinGap1Aq_sq[iC] = new TProfile(Form("fSinGap1Aq_sq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
392     fOutput_sq->Add(fSinGap1Aq_sq[iC]);
393       
394     fCosGap1Aq_sq[iC] = new TProfile(Form("fCosGap1Aq_sq_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
395     fOutput_sq->Add(fCosGap1Aq_sq[iC]);
396     
397     fSinGap1Bq_sq[iC] = new TProfile(Form("fSinGap1Bq_sq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
398     fOutput_sq->Add(fSinGap1Bq_sq[iC]);
399     
400     fCosGap1Bq_sq[iC] = new TProfile(Form("fCosGap1Bq_sq_%d", iC), "p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
401     fOutput_sq->Add(fCosGap1Bq_sq[iC]);
402
403     fSinGap1A_sq[iC] = new TProfile(Form("fSinGap1A_sq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
404     fOutput_sq->Add(fSinGap1A_sq[iC]);
405       
406     fCosGap1A_sq[iC] = new TProfile(Form("fCosGap1A_sq_%d", iC), ";p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
407     fOutput_sq->Add(fCosGap1A_sq[iC]);
408     
409     fSinGap1B_sq[iC] = new TProfile(Form("fSinGap1B_sq_%d", iC), ";p_{T} (GeV/c);#LT sin(2*#phi) #GT", nptBins, ptBins);
410     fOutput_sq->Add(fSinGap1B_sq[iC]);
411     
412     fCosGap1B_sq[iC] = new TProfile(Form("fCosGap1B_sq_%d", iC), "p_{T} (GeV/c);#LT cos(2*#phi) #GT", nptBins, ptBins);
413     fOutput_sq->Add(fCosGap1B_sq[iC]);
414   };
415   
416   if(fIsMC){
417     fResSPmc_inclusive = new TProfile("fResSPmc_inclusive", "Resolution; ese; Resolution", 3, 0., 3.);
418     fOutput->Add(fResSPmc_inclusive);
419
420     fv2SPGap1Amc_inclusive_mb = new TProfile("fv2SPGap1Amc_inclusive_mb", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
421     fOutput->Add(fv2SPGap1Amc_inclusive_mb);
422
423     fv2SPGap1Bmc_inclusive_mb = new TProfile("fv2SPGap1Bmc_inclusive_mb", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
424     fOutput->Add(fv2SPGap1Bmc_inclusive_mb);
425     
426     //large-q
427     fv2SPGap1Amc_inclusive_lq = new TProfile("fv2SPGap1Amc_inclusive_lq", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
428     fOutput_lq->Add(fv2SPGap1Amc_inclusive_lq);
429
430     fv2SPGap1Bmc_inclusive_lq = new TProfile("fv2SPGap1Bmc_inclusive_lq", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
431     fOutput_lq->Add(fv2SPGap1Bmc_inclusive_lq);
432     
433     //small-q
434     fv2SPGap1Amc_inclusive_sq = new TProfile("fv2SPGap1Amc_inclusive_sq", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
435     fOutput_sq->Add(fv2SPGap1Amc_inclusive_sq);
436
437     fv2SPGap1Bmc_inclusive_sq = new TProfile("fv2SPGap1Bmc_inclusive_sq", "v_{2}{2} vs p_{T}; p_{T} (GeV/c); v_{2}{2}", nptBins, ptBins);
438     fOutput_sq->Add(fv2SPGap1Bmc_inclusive_sq);
439   }
440
441   
442   PostData(1, fOutput  );
443   PostData(2, fEventCuts);
444   PostData(3, fTrackCuts);
445   PostData(4, fOutput_lq  );
446   PostData(5, fOutput_sq  );
447 }
448
449 //________________________________________________________________________
450
451 void AliAnalysisTaskV2AllChAOD::UserExec(Option_t *)
452 {
453   //Printf("An event");
454   // main event loop
455   fAOD = dynamic_cast<AliAODEvent*>(fInputEvent);
456   if (!fAOD) {
457     AliWarning("ERROR: AliAODEvent not available \n");
458     return;
459   }
460   
461   if (strcmp(fAOD->ClassName(), "AliAODEvent"))
462     {
463       AliFatal("Not processing AODs");
464     }
465   
466   if(!fEventCuts->IsSelected(fAOD,fTrackCuts))return;//event selection
467   
468   //Get q-vector percentile.
469   Double_t Qvec=0.;
470   if(fIsMC && fQvecGen) Qvec = fEventCuts->GetQvecPercentileMC(fVZEROside, fQgenType);
471   else Qvec = fEventCuts->GetQvecPercentile(fVZEROside);
472
473   fQvector->Fill(Qvec);
474   if (Qvec > fCutLargeQperc && Qvec < 100.) fQvector_lq->Fill(Qvec);
475   if (Qvec > 0. && Qvec < fCutSmallQperc) fQvector_sq->Fill(Qvec);
476
477   Double_t Cent=(fDoCentrSystCentrality)?1.01*fEventCuts->GetCent():fEventCuts->GetCent();
478   fCentrality->Fill(Cent);
479   
480   Int_t centV0 = -1;
481   if ((Cent > 0) && (Cent <= 5.0))
482       centV0 = 0; 
483     else if ((Cent > 5.0) && (Cent <= 10.0))
484       centV0 = 1;
485     else if ((Cent > 10.0) && (Cent <= 20.0))
486       centV0 = 2;
487     else if ((Cent > 20.0) && (Cent <= 30.0))
488       centV0 = 3;   
489     else if ((Cent > 30.0) && (Cent <= 40.0))
490       centV0 = 4; 
491     else if ((Cent > 40.0) && (Cent <= 50.0))
492       centV0 = 5;  
493     else if ((Cent > 50.0) && (Cent <= 60.0))
494       centV0 = 6;
495     else if ((Cent > 60.0) && (Cent <= 70.0))
496       centV0 = 7;                                      
497     else if ((Cent > 70.0) && (Cent <= 80.0))
498       centV0 = 8; 
499     
500   if(fIsMC) MCclosure(Qvec); // fill mc histograms for montecarlo closure
501
502   Double_t QxGap1A = 0., QyGap1A = 0.;
503   Double_t QxGap1B = 0., QyGap1B = 0.;
504   Int_t multGap1A = 0, multGap1B = 0;
505   
506   for (Int_t loop = 0; loop < 2; loop++){
507
508     //main loop on tracks
509     for (Int_t iTracks = 0; iTracks < fAOD->GetNumberOfTracks(); iTracks++) {
510       AliAODTrack* track = dynamic_cast<AliAODTrack*>(fAOD->GetTrack(iTracks));
511       if(!track) AliFatal("Not a standard AOD");
512       if(fCharge != 0 && track->Charge() != fCharge) continue;//if fCharge != 0 only select fCharge 
513       if (!fTrackCuts->IsSelected(track,kTRUE)) continue; //track selection (rapidity selection NOT in the standard cuts)
514     
515       fEta_vs_Phi_bef->Fill( track->Eta(), track->Phi() );
516       
517       if (fIsRecoEff){
518
519         // 2) reject randomly tracks at high pT until the reconstruction efficiency becomes flat (add the following before the loop == 0 part): (mail by Alexandru)
520
521         Double_t recoEff = GetRecoEff(track->Pt(), centV0);
522         if (recoEff < 0){
523           cout<<"No reconstruction efficiency!"<<endl;
524           continue;
525         }
526         
527         Double_t rndPt = gRandom->Rndm();
528 //         cout<<"rndPt: "<<rndPt<<endl;
529
530         Double_t minRecPt = GetRecoEff(0.200001, centV0);
531 //         cout<<"minRecPt: "<<minRecPt<<endl;            
532                     
533         if (rndPt > minRecPt/recoEff){
534 //        cout<<"Track rejected: "<<iTracks<<"  from "<<fAOD->GetNumberOfTracks()<<endl;
535           continue;
536         }
537
538       } // end fIsRecoEff
539   
540       if (loop == 0) {
541         
542         if (track->Eta() > fEtaGapMax){
543           QxGap1A += TMath::Cos(2.*track->Phi());
544           QyGap1A += TMath::Sin(2.*track->Phi());
545           multGap1A++;
546
547           fSinGap1Aq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
548           fCosGap1Aq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
549           
550           fEta_vs_PhiA->Fill( track->Eta(), track->Phi() );
551           
552           if (Qvec > fCutLargeQperc && Qvec < 100.){
553             fSinGap1Aq_lq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
554             fCosGap1Aq_lq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
555           }
556       
557           if (Qvec > 0. && Qvec < fCutSmallQperc){
558             fSinGap1Aq_sq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
559             fCosGap1Aq_sq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
560           }
561           
562         }
563     
564       if (track->Eta() < fEtaGapMin){
565         QxGap1B += TMath::Cos(2.*track->Phi());
566         QyGap1B += TMath::Sin(2.*track->Phi());
567         multGap1B++;
568                     
569         fCosGap1Bq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
570         fSinGap1Bq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
571         
572         fEta_vs_PhiB->Fill( track->Eta(), track->Phi() );
573                     
574         if (Qvec > fCutLargeQperc && Qvec < 100.){
575           fSinGap1Bq_lq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
576           fCosGap1Bq_lq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
577         }
578       
579         if (Qvec > 0. && Qvec < fCutSmallQperc){
580           fSinGap1Bq_sq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
581           fCosGap1Bq_sq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
582         }
583           
584       }
585   
586     } else {
587       
588         //eval v2 scalar product
589         if (track->Eta() < fEtaGapMin && multGap1A > 0){
590           Double_t v2SPGap1A = (TMath::Cos(2.*track->Phi())*QxGap1A + TMath::Sin(2.*track->Phi())*QyGap1A)/(Double_t)multGap1A;
591           fv2SPGap1A[centV0]->Fill(track->Pt(), v2SPGap1A);
592           
593           fv2SPGap1A_inclusive_mb->Fill(track->Pt(), v2SPGap1A); //mb v2 for mc closure
594
595           fSinGap1A[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
596           fCosGap1A[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
597       
598           if (Qvec > fCutLargeQperc && Qvec < 100.){
599             fv2SPGap1A_lq[centV0]->Fill(track->Pt(), v2SPGap1A);
600             fSinGap1A_lq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
601             fCosGap1A_lq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
602             
603             fv2SPGap1A_inclusive_lq->Fill(track->Pt(), v2SPGap1A); //lq v2 for mc closure
604           }
605       
606           if (Qvec > 0. && Qvec < fCutSmallQperc){
607             fv2SPGap1A_sq[centV0]->Fill(track->Pt(), v2SPGap1A);
608             fSinGap1A_sq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
609             fCosGap1A_sq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
610             
611             fv2SPGap1A_inclusive_sq->Fill(track->Pt(), v2SPGap1A); //sq v2 for mc closure
612           }
613
614         }
615       
616         if (track->Eta() > fEtaGapMax && multGap1B > 0){
617           Double_t v2SPGap1B = (TMath::Cos(2.*track->Phi())*QxGap1B + TMath::Sin(2.*track->Phi())*QyGap1B)/(Double_t)multGap1B;
618           fv2SPGap1B[centV0]->Fill(track->Pt(), v2SPGap1B);
619           
620           fv2SPGap1B_inclusive_mb->Fill(track->Pt(), v2SPGap1B); //mb v2 for mc closure
621           
622           fCosGap1B[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
623           fSinGap1B[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
624       
625           if (Qvec > fCutLargeQperc && Qvec < 100.){
626             fv2SPGap1B_lq[centV0]->Fill(track->Pt(), v2SPGap1B);
627             fSinGap1B_lq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
628             fCosGap1B_lq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
629             
630             fv2SPGap1B_inclusive_lq->Fill(track->Pt(), v2SPGap1B); //lq v2 for mc closure
631           }
632       
633           if (Qvec > 0. && Qvec < fCutSmallQperc){
634             fv2SPGap1B_sq[centV0]->Fill(track->Pt(), v2SPGap1B);
635             fSinGap1B_sq[centV0]->Fill(track->Pt(), TMath::Sin(2.*track->Phi()));
636             fCosGap1B_sq[centV0]->Fill(track->Pt(), TMath::Cos(2.*track->Phi()));
637             
638             fv2SPGap1B_inclusive_sq->Fill(track->Pt(), v2SPGap1B); //sq v2 for mc closure
639           }
640           
641         }
642       }// end else 
643     } // end loop on tracks
644   } // end loop
645   
646   
647   if (multGap1A > 0 && multGap1B > 0){
648     Double_t res = (QxGap1A*QxGap1B + QyGap1A*QyGap1B)/(Double_t)multGap1A/(Double_t)multGap1B;
649     fResSP->Fill((Double_t)centV0, res);
650     
651     fResSP_inclusive->Fill(0., res); //mb v2 for mc closure
652     fResSP_vs_Cent->Fill(Cent, res);
653     fResSP_vs_Qvec[centV0]->Fill(Qvec,res);
654     
655     Double_t f2partCumQA = -999.;
656     if(multGap1A>1)
657       f2partCumQA = ( ( (QxGap1A*QxGap1A + QyGap1A*QyGap1A) - (Double_t)multGap1A ) / ((Double_t)multGap1A*((Double_t)multGap1A-1)) );
658     if(f2partCumQA>0)f2partCumQA_vs_Cent->Fill((Double_t)Cent,f2partCumQA);
659     
660     Double_t f2partCumQB = -999.;
661     if(multGap1B>1) 
662       f2partCumQB = ( ( (QxGap1B*QxGap1B + QyGap1B*QyGap1B) - (Double_t)multGap1B ) / ((Double_t)multGap1B*((Double_t)multGap1B-1)) );
663     if(f2partCumQB>0)f2partCumQB_vs_Cent->Fill((Double_t)Cent,f2partCumQB);
664         
665     if (Qvec > fCutLargeQperc && Qvec < 100.){
666       fResSP_lq->Fill((Double_t)centV0, res);
667       fResSP_vs_Cent_lq->Fill(Cent, res);
668       if(f2partCumQA>0)f2partCumQA_vs_Cent_lq->Fill((Double_t)Cent,f2partCumQA);
669       if(f2partCumQB>0)f2partCumQB_vs_Cent_lq->Fill((Double_t)Cent,f2partCumQB);
670       
671       fResSP_inclusive->Fill(1., res); //lq v2 for mc closure
672     }
673     
674     if (Qvec > 0. && Qvec < fCutSmallQperc){
675       fResSP_sq->Fill((Double_t)centV0, res);
676       fResSP_vs_Cent_sq->Fill(Cent, res);
677       if(f2partCumQA>0)f2partCumQA_vs_Cent_sq->Fill((Double_t)Cent,f2partCumQA);
678       if(f2partCumQB>0)f2partCumQB_vs_Cent_sq->Fill((Double_t)Cent,f2partCumQB);
679       
680       fResSP_inclusive->Fill(2., res); //sq v2 for mc closure
681     }
682   }// end multiplicity if
683     
684   if( fFillTHn ){ 
685
686     
687     Double_t varEv[6];
688     varEv[0]=Cent;
689     varEv[1]=(Double_t)Qvec; // qvec_rec_perc
690     
691     Double_t qvzero = 0.;
692     if(fVZEROside==0)qvzero=(Double_t)fEventCuts->GetqV0A();
693     else if (fVZEROside==1)qvzero=(Double_t)fEventCuts->GetqV0C(); // qvec_rec
694     varEv[2]=(Double_t)qvzero; // qvec from VZERO
695     
696     Double_t qgen_tracks = (Double_t)fEventCuts->CalculateQVectorMC(fVZEROside, 0);
697     varEv[3]= (Double_t)qgen_tracks;
698     
699     Double_t qgen_vzero = (Double_t)fEventCuts->CalculateQVectorMC(fVZEROside, 1);
700     varEv[4]= (Double_t)qgen_vzero;
701     
702     varEv[5]=(Double_t)fEventCuts->GetNch(); // Nch
703     
704     ((THnSparseF*)fOutput->FindObject("NSparseHistEv"))->Fill(varEv);//event loop
705
706   }
707
708   
709   PostData(1, fOutput  );
710   PostData(2, fEventCuts);
711   PostData(3, fTrackCuts);
712   PostData(4, fOutput_lq  );
713   PostData(5, fOutput_sq  );
714 }
715
716 //_________________________________________________________________
717 Bool_t  AliAnalysisTaskV2AllChAOD::GetDCA(const AliAODTrack* trk, Double_t * p){
718   
719   //AliAODTrack::DCA(): for newest AOD fTrack->DCA() always gives -999. This should fix.
720   //FIXME should update EventCuts?
721   //FIXME add track->GetXYZ(p) method
722   
723   double xyz[3],cov[3];
724   
725   if (!trk->GetXYZ(xyz)) { // dca is not stored
726     AliExternalTrackParam etp;
727     etp.CopyFromVTrack(trk);
728     AliVEvent* ev = (AliVEvent*)trk->GetEvent();
729     if (!ev) {/*printf("Event is not connected to the track\n");*/ return kFALSE;}
730     if (!etp.PropagateToDCA(ev->GetPrimaryVertex(), ev->GetMagneticField(),999,xyz,cov)) return kFALSE; // failed, track is too far from vertex
731   }
732   p[0] = xyz[0];
733   p[1] = xyz[1];
734   return kTRUE;
735
736 }
737
738 //_________________________________________________________________
739 void  AliAnalysisTaskV2AllChAOD::MCclosure(Double_t qvec){
740   // First do MC to fill up the MC particle array
741   
742   TClonesArray *arrayMC = 0;
743   if (fIsMC)
744     {
745       arrayMC = (TClonesArray*) fAOD->GetList()->FindObject(AliAODMCParticle::StdBranchName());
746       if (!arrayMC) {
747         AliFatal("Error: MC particles branch not found!\n");
748       }
749       
750       Double_t QxGap1Amc = 0., QyGap1Amc = 0.;
751       Double_t QxGap1Bmc = 0., QyGap1Bmc = 0.;
752       Int_t multGap1Amc = 0, multGap1Bmc = 0;
753
754       for (Int_t loop = 0; loop < 2; loop++){
755         
756         Int_t nMC = arrayMC->GetEntries();
757       
758         for (Int_t iMC = 0; iMC < nMC; iMC++)
759           {
760             AliAODMCParticle *partMC = (AliAODMCParticle*) arrayMC->At(iMC);
761             if(!partMC->Charge()) continue;//Skip neutrals
762             if(fCharge != 0 && partMC->Charge()*fCharge < 0.) continue;//if fCharge != 0 only select fCharge
763           
764             if (!(partMC->IsPhysicalPrimary()))
765                 continue;
766             
767             if(partMC->Eta()<fTrackCuts->GetEtaMin() || partMC->Eta()>fTrackCuts->GetEtaMax()) continue;
768           
769             //Printf("a particle");
770             
771             
772            if (loop == 0) {
773              
774              if (partMC->Eta() > fEtaGapMax){
775                QxGap1Amc += TMath::Cos(2.*partMC->Phi());
776                QyGap1Amc += TMath::Sin(2.*partMC->Phi());
777                multGap1Amc++;
778             }
779             
780             if (partMC->Eta() < fEtaGapMin){
781               QxGap1Bmc += TMath::Cos(2.*partMC->Phi());
782               QyGap1Bmc += TMath::Sin(2.*partMC->Phi());
783               multGap1Bmc++;
784             }
785   
786           } else {
787             
788             //eval v2 scalar product
789             if (partMC->Eta() < fEtaGapMin && multGap1Amc > 0){
790               Double_t v2SPGap1Amc = (TMath::Cos(2.*partMC->Phi())*QxGap1Amc + TMath::Sin(2.*partMC->Phi())*QyGap1Amc)/(Double_t)multGap1Amc;
791               fv2SPGap1Amc_inclusive_mb->Fill(partMC->Pt(), v2SPGap1Amc);
792       
793               if (qvec > fCutLargeQperc && qvec < 100.){
794                 fv2SPGap1Amc_inclusive_lq->Fill(partMC->Pt(), v2SPGap1Amc);
795               }
796               
797               if (qvec > 0. && qvec < fCutSmallQperc){
798                 fv2SPGap1Amc_inclusive_sq->Fill(partMC->Pt(), v2SPGap1Amc);
799               }
800               
801             }
802             
803             if (partMC->Eta() > fEtaGapMax && multGap1Bmc > 0){
804               Double_t v2SPGap1Bmc = (TMath::Cos(2.*partMC->Phi())*QxGap1Bmc + TMath::Sin(2.*partMC->Phi())*QyGap1Bmc)/(Double_t)multGap1Bmc;
805               fv2SPGap1Bmc_inclusive_mb->Fill(partMC->Pt(), v2SPGap1Bmc);
806       
807               if (qvec > fCutLargeQperc && qvec < 100.){
808                 fv2SPGap1Bmc_inclusive_lq->Fill(partMC->Pt(), v2SPGap1Bmc);
809               }
810               
811               if (qvec > 0. && qvec < fCutSmallQperc){
812                 fv2SPGap1Bmc_inclusive_sq->Fill(partMC->Pt(), v2SPGap1Bmc);
813               }
814               
815             }
816       
817             
818           }// end else 
819         } // end loop on partMCs
820       } // end loop
821       
822       if (multGap1Amc > 0 && multGap1Bmc > 0){
823         Double_t resmc = (QxGap1Amc*QxGap1Bmc + QyGap1Amc*QyGap1Bmc)/(Double_t)multGap1Amc/(Double_t)multGap1Bmc;
824         fResSPmc_inclusive->Fill(0.,resmc);
825         
826         if (qvec > fCutLargeQperc && qvec < 100.){
827           fResSPmc_inclusive->Fill(1.,resmc);
828         }
829         
830         if (qvec > 0. && qvec < fCutSmallQperc){
831           fResSPmc_inclusive->Fill(2.,resmc);
832         }
833         
834       }
835         
836       }// end if MC
837 }
838   
839 //_________________________________________________________________
840 Double_t AliAnalysisTaskV2AllChAOD::GetRecoEff(Double_t pt, Int_t iC){
841
842   if(iC>8) return 1.;
843
844   if(pt<0.2 || pt>100.) return 1.;
845
846 // // //   //spectra ese binning
847 // // //   //const Double_t ptBins[] = {0.20,0.30,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.8,2.0,2.4,2.8,3.2,3.6,4.0,5.0,6.0,7.0,8.0,9.0,10.,12.,15.,20.,25.,30.,35.,40.,50.,75.,100.};
848 // // //   //const Int_t nptBins=34;
849   
850   const Double_t fEpsilon=0.000001;
851   
852   TH1F *h = (TH1F*)fRecoEffList->At(iC);
853   
854   Int_t bin = h->FindBin(pt);
855   
856   Double_t lowlim = h->GetBinLowEdge(bin);
857   Double_t uplim = h->GetBinLowEdge(bin) + h->GetBinWidth(bin);
858   
859   if( pt>lowlim && pt<uplim ) return h->GetBinContent(bin);
860   if( pt == lowlim ) return h->GetBinContent( h->FindBin(pt+fEpsilon) );
861   if( pt == uplim ) return h->GetBinContent( h->FindBin(pt-fEpsilon) );
862
863   else return 1.;
864   
865 }
866 //_________________________________________________________________
867 void   AliAnalysisTaskV2AllChAOD::Terminate(Option_t *)
868 {
869   // Terminate
870 }