f2950856d77409a1427523229817ad87d23192c0
[u/mrichter/AliRoot.git] / PWGLF / STRANGENESS / LambdaK0PbPb / AliAnalysisTaskV0ForRAA.cxx
1 /***************************************************************          *
2  * Authors : Simone Schuchmann 
3  * Contributors are mentioned in the code where appropriate.              *
4  *                                                                        *
5  * Permission to use, copy, modify and distribute this software and its   *
6  * documentation strictly for non-commercial purposes is hereby granted   *
7  * without fee, provided that the above copyright notice appears in all   *
8  * copies and that both the copyright notice and this permission notice   *
9  * appear in the supporting documentation. The authors make no claims     *
10  * about the suitability of this software for any purpose. It is          *
11  * provided "as is" without express or implied warranty.                  *
12  **************************************************************************/
13
14 //-----------------------------------------------------------------
15 // AliAnalysisTaskV0ForRAA class
16 // This task is for analysing Lambda and K0s pt spectra in PbPb and
17 // pp as well as with MC. The flag for pp and MC  must be set
18 // accordingly, default is PbPb data.
19 // It works with ESD files only.
20 //-----------------------------------------------------------------
21
22
23 #define AliAnalysisTaskV0ForRAA_cxx
24 #include "Riostream.h"
25
26 #include "TROOT.h"
27 #include "TH1.h"
28 #include "TH2.h"
29 #include "TLorentzVector.h"
30
31 #include "AliESDVZERO.h"
32 #include "AliMultiplicity.h"
33 #include "AliCentrality.h"
34
35 #include "AliKFParticle.h"
36 #include "AliKFVertex.h"
37 #include "AliESDtrackCuts.h"
38 #include "AliESDpid.h"
39 #include "AliESDv0.h"
40 #include "AliESDEvent.h"
41 #include "AliMCEvent.h"
42 #include "AliStack.h"
43 #include "AliESDInputHandler.h"
44 #include "AliMCEventHandler.h"
45
46 #include "AliAnalysisManager.h"
47 #include "AliAnalysisTaskSE.h"
48
49 #include "AliAnalysisTaskV0ForRAA.h"
50
51
52
53 ClassImp(AliAnalysisTaskV0ForRAA)
54
55 //________________________________________________________________________
56    AliAnalysisTaskV0ForRAA::AliAnalysisTaskV0ForRAA(const char *name)
57       :AliAnalysisTaskSE(name),
58        fESD(0),
59        fMCev(0),
60        //other objects
61        fESDpid(0),
62        fESDTrackCuts(0),
63        fESDTrackCutsCharged(0),
64        fOutputContainer(0),
65        //event histos
66        fHistITSLayerHits(0),
67        fHistOneHitWithSDD(0),
68        fHistNEvents(0),
69        fHistPrimVtxZESDVSNContributors(0),
70        fHistPrimVtxZESDTPCVSNContributors(0),
71        fHistPrimVtxZESDSPDVSNContributors(0),
72        fHistPrimVtxZESDVSNContributorsMC(0),
73        fHistPrimVtxZESDTPCVSNContributorsMC(0),
74        fHistPrimVtxZESDSPDVSNContributorsMC(0),
75        fHistPrimVtxZESD(0),
76        fHistPrimVtxZESDTPC(0),
77        fHistPrimVtxZESDSPD(0),
78        fHistESDVertexZ(0),
79        fHistMCVertexZ(0),
80        fHistMuliplicity(0),
81        fHistMuliplicityRaw(0),
82        fHistMultiplicityPrimary(0),
83        fHistNPrim(0),
84        //MC pdg code histos
85        fHistPiPiPDGCode(0),
86        fHistPiPPDGCode(0),
87        fHistPiAPPDGCode(0),
88        //cosine of pointing angle of Xi vs pt histos
89        fHistPiPCosPointAngXiVsPt(0),
90        fHistPiAPCosPointAngXiVsPt(0),
91        // fHistUserPtShift(0),
92        //selection booleans and values
93        fMCMode(0),
94        fMCTruthMode(0),
95        fSelectInjected(0),
96        fUseCentrality(0),
97        fUseCentralityBin(0),
98        fUseCentralityRange(0),
99        fAnapp(0),
100        fSelSDD(0),
101        fOntheFly(0),
102        fVertexZCut(0),
103        fVtxStatus(0),
104        fUsePID(0),
105        fNSigma(0),
106        fPPIDcut(0),
107        fMoreNclsThanRows(0),
108        fMoreNclsThanFindable(0),
109        fChi2PerClusterITS(0),
110        fRapCutV0(0),
111        fRap(0),
112        fEtaCutMCDaughters(0),
113        fEtaCutMCDaughtersVal(0),
114        fMinPt(0),
115        fAlfaCut(0),
116        fQtCut(0),
117        fArmCutK0(0),      
118        fArmCutL(0),  
119        fDCAToVertexK0(0),
120        fDCAToVertexL(0),
121        fDCAXK(0),
122        fDCAYK(0),
123        fDCAXL(0),
124        fDCAYL(0),
125        fDCAZ(0),
126        fDCADaughtersL(0),
127        fDCADaughtersAL(0),
128        fDCADaughtersK0(0),
129        fDCADaughtersToVtxLarge(0),
130        fDCADaughtersToVtxSmall(0),
131        fDecayRadXYMin(0),
132        fDecayRadXYMax(0),
133        fCosPointAngL(0),
134        fCosPointAngK(0),
135        fCPAPtCutK0(0),
136        fCPAPtCutL(0),
137        fOpengAngleDaughters(0),
138        fDecayLengthMax(0),
139        fDecayLengthMin(0),
140        fCtauK0s(0),
141        fCtauL(0),
142        fCtauPtCutK0(0),
143        fCtauPtCutL(0),
144        fChiCutKf(0)                                    //  fShift(0),
145                                        // fDeltaInvP(0)
146 {  // Constructor.
147
148    DefineOutput(1,TList::Class());
149
150    // define defaults for globals
151    /*
152      fShift = kFALSE;                       // shift in charge/pt yes/no
153      fDeltaInvP = 0.00;                     // shift value
154    */
155    
156    fMCMode = kFALSE;
157    fMCTruthMode = kFALSE;
158
159    fUseCentrality = 0;
160    fUseCentralityBin = 0;
161    fUseCentralityRange =0;
162
163    fAnapp = kFALSE;
164    fSelSDD = kFALSE;
165
166    fSelectInjected = kFALSE;
167
168    fVertexZCut = 100000.0;
169    fVtxStatus = kFALSE;
170    
171    fOntheFly = kTRUE;
172
173    //----- define defaults for V0 and track cuts ----//
174    fUsePID = kFALSE;
175    fMoreNclsThanRows = kFALSE;
176    fMoreNclsThanFindable = kFALSE;
177    fChi2PerClusterITS = 100000.0;
178    fNSigma = 100000.0;
179    fPPIDcut = 100.0;
180
181    fRapCutV0=kFALSE;
182    fRap=1000.0;
183    fRap=1000.0;
184
185    fAlfaCut= -100.0;
186    fQtCut = 100.0;   
187    fArmCutK0=kFALSE;     
188    fArmCutL=kFALSE;  
189
190    fEtaCutMCDaughters = kFALSE;
191    fEtaCutMCDaughtersVal =50.0;
192
193    fMinPt= -1.0;
194
195    fDCAToVertexK0 = 10000.0;
196    fDCAToVertexL = 10000.0;
197    fDCAXK=10000.0;
198    fDCAYK=10000.0;
199    fDCAXL=10000.0;
200    fDCAYL=10000.0;
201    fDCAZ=10000.0;
202    
203    fDCADaughtersL=10000.0;
204    fDCADaughtersAL=10000.0;
205    fDCADaughtersK0=10000.0;
206
207    fDCADaughtersToVtxLarge=-1.0;
208    fDCADaughtersToVtxSmall=-1.0;
209
210    fDecayRadXYMin=-1.0;
211    fDecayRadXYMax=1000000.0;
212    fDecayLengthMax=100000.0;
213    fDecayLengthMin=-1.0;
214    
215    fCosPointAngL=-1.0;
216    fCosPointAngK=-1.0;
217    fCPAPtCutK0 = 1000.0;
218    fCPAPtCutL =1000.0;
219    fOpengAngleDaughters = -1.0;
220    
221    fCtauK0s=10000.0;
222    fCtauL=10000.0;
223    fCtauPtCutK0=1000.0;
224    fCtauPtCutL=10000.0;
225
226    fChiCutKf=1000000.0;
227
228    
229    //---- histograms ----//
230    for(Int_t j=0;j<2;j++){
231       fHistArmenteros[j]=NULL;
232       fHistV0RadiusZ[j] =NULL;
233       fHistV0RadiusZVSPt[j] =NULL;
234       fHistV0RadiusXY[j] =NULL;
235       fHistV0RadiusXYVSY[j] =NULL;
236       
237       //K0
238       fHistPiPiMass[j]=NULL;
239       fHistPiPiMassVSPt[j]=NULL;
240       fHistPiPiMassVSPtMCTruth[j]=NULL;
241       fHistPiPiMassVSAlpha[j]=NULL;
242       fHistPiPiRadiusXY[j]=NULL;
243       fHistPiPiCosPointAng[j]=NULL;
244       fHistPiPiDecayLengthVsPt[j]=NULL;
245       fHistPiPiDCADaughterPosToPrimVtxVSMass[j]=NULL;
246       fHistPiPiMassVSPtK0L[j]=NULL;
247       fHistPiPiDCADaughters[j]=NULL; 
248       fHistPiPiPtDaughters[j]=NULL;
249       fHistPiPiPtVSY[j]=NULL;
250       fHistPiPiDCAVSMass[j]=NULL;
251       fHistPiPiMonitorCuts[j] =NULL;
252
253
254       //Lambda
255       fHistPiPMass[j]=NULL;
256       fHistPiPMassVSPt[j]=NULL;
257       fHistPiPMassVSPtMCTruth[j]=NULL;
258       fHistPiPRadiusXY[j]=NULL;
259       fHistPiPCosPointAng[j]=NULL;
260       fHistPiPDecayLengthVsPt[j]=NULL;
261       fHistPiPDCADaughterPosToPrimVtxVSMass[j]=NULL;
262       fHistPiPMassVSPtSecSigma[j]=NULL;
263       fHistPiPMassVSPtSecXi[j]=NULL;
264       fHistPiPMassVSYSecXi[j]=NULL;
265       fHistPiPXi0PtVSLambdaPt[j]=NULL;
266       fHistPiPXiMinusPtVSLambdaPt[j]=NULL;
267       fHistPiPDCADaughters[j]=NULL;
268       fHistPiPPtDaughters[j]=NULL;
269       fHistPiPPtVSY[j]=NULL;
270       fHistPiPDCAVSMass[j]=NULL;
271       fHistPiPMonitorCuts[j] =NULL;
272
273       
274       //ALambda
275       fHistPiAPMass[j]=NULL;
276       fHistPiAPMassVSPt[j]=NULL;
277       fHistPiAPMassVSPtMCTruth[j]=NULL;
278       fHistPiAPRadiusXY[j]=NULL;
279       fHistPiAPCosPointAng[j]=NULL;
280       fHistPiAPDecayLengthVsPt[j]=NULL;
281       fHistPiAPDCADaughterPosToPrimVtxVSMass[j]=NULL;
282       fHistPiAPMassVSPtSecSigma[j]=NULL;
283       fHistPiAPMassVSPtSecXi[j]=NULL;
284       fHistPiAPMassVSYSecXi[j]=NULL;
285       fHistPiAPXi0PtVSLambdaPt[j]=NULL;
286       fHistPiAPXiMinusPtVSLambdaPt[j]=NULL;
287       fHistPiAPDCADaughters[j]=NULL;
288       fHistPiAPPtDaughters[j]=NULL;
289       fHistPiAPPtVSY[j]=NULL;
290       fHistPiAPDCAVSMass[j]=NULL;
291       fHistPiAPMonitorCuts[j] =NULL;
292       
293       //other 
294       fHistDedxSecProt[j]=NULL;
295       fHistDedxSecAProt[j]=NULL;
296       fHistDedxSecPiMinus[j]=NULL;
297       fHistDedxSecPiPlus[j]=NULL;
298       fHistNclsITSPos[j]=NULL;
299       fHistNclsITSNeg[j]=NULL;
300       fHistNclsTPCPos[j]=NULL;
301       fHistNclsTPCNeg[j]=NULL;
302       fHistChi2PerNclsITSPos[j]=NULL;
303       fHistChi2PerNclsITSNeg[j]=NULL;
304       fHistNCRowsTPCPos[j]=NULL;
305       fHistNCRowsTPCNeg[j]=NULL;
306       fHistNclsITSPosK0[j]=NULL;
307       fHistNclsITSNegK0[j]=NULL;
308       fHistNclsTPCPosK0[j]=NULL;
309       fHistNclsTPCNegK0[j]=NULL;
310       fHistChi2PerNclsITSPosK0[j]=NULL;
311       fHistChi2PerNclsITSNegK0[j]=NULL;
312       fHistNclsITSPosL[j]=NULL;
313       fHistNclsITSNegL[j]=NULL;
314       fHistNclsTPCPosL[j]=NULL;
315       fHistNclsTPCNegL[j]=NULL;
316       fHistChi2PerNclsITSPosL[j]=NULL;
317       fHistChi2PerNclsITSNegL[j]=NULL;
318
319       fHistPiPiEtaDMC[j] = NULL;
320       fHistPiPiEtaDMC[j] = NULL;
321       fHistPiPiEtaDReco[j] = NULL;
322       fHistPiPiEtaDReco[j] = NULL;
323       fHistPiPEtaDMC[j] = NULL;
324       fHistPiPEtaDMC[j] = NULL;
325       fHistPiPEtaDReco[j] = NULL;
326       fHistPiPEtaDReco[j] = NULL;
327    }
328    
329 }
330 //_____________________________________________________
331 AliAnalysisTaskV0ForRAA::~AliAnalysisTaskV0ForRAA()
332 {
333    //---- Remove all pointers ----//
334    if(fOutputContainer) delete fOutputContainer;fOutputContainer=0;
335    if(fESDTrackCuts) delete fESDTrackCuts;fESDTrackCuts=0;
336    if(fESDTrackCutsCharged) delete fESDTrackCutsCharged;fESDTrackCutsCharged=0;
337   
338    //histograms
339    if(fHistITSLayerHits) delete fHistITSLayerHits;fHistITSLayerHits=0;
340    if(fHistOneHitWithSDD) delete fHistOneHitWithSDD;fHistOneHitWithSDD=0;  
341    if(fHistNEvents) delete fHistNEvents; fHistNEvents=0;
342    if(fHistNPrim) delete fHistNPrim; fHistNPrim=0;
343    if(fHistMuliplicity) delete fHistMuliplicity;fHistMuliplicity =0;
344    if(fHistMuliplicityRaw) delete fHistMuliplicityRaw;fHistMuliplicityRaw =0;
345    if(fHistMultiplicityPrimary) delete fHistMultiplicityPrimary;fHistMultiplicityPrimary=0;
346   
347    if(fHistESDVertexZ) delete fHistESDVertexZ; fHistESDVertexZ=0;
348    if(fHistMCVertexZ) delete  fHistMCVertexZ;fHistMCVertexZ=0;
349   
350    // if(fHistUserPtShift) delete fHistUserPtShift; fHistUserPtShift=0;
351
352    if(fHistPrimVtxZESDVSNContributors) delete fHistPrimVtxZESDVSNContributors;fHistPrimVtxZESDVSNContributors=0;
353    if(fHistPrimVtxZESDTPCVSNContributors) delete fHistPrimVtxZESDTPCVSNContributors;fHistPrimVtxZESDTPCVSNContributors=0;
354    if(fHistPrimVtxZESDSPDVSNContributors) delete fHistPrimVtxZESDSPDVSNContributors;fHistPrimVtxZESDSPDVSNContributors=0;
355   
356    if(fHistPrimVtxZESDVSNContributorsMC) delete fHistPrimVtxZESDVSNContributorsMC;fHistPrimVtxZESDVSNContributorsMC=0;
357    if(fHistPrimVtxZESDTPCVSNContributorsMC) delete fHistPrimVtxZESDTPCVSNContributorsMC;fHistPrimVtxZESDTPCVSNContributorsMC=0;
358    if(fHistPrimVtxZESDSPDVSNContributorsMC) delete fHistPrimVtxZESDSPDVSNContributorsMC;fHistPrimVtxZESDSPDVSNContributorsMC=0;
359   
360    if(fHistPrimVtxZESD) delete fHistPrimVtxZESD; fHistPrimVtxZESD =0;
361    if(fHistPrimVtxZESDTPC) delete fHistPrimVtxZESDTPC; fHistPrimVtxZESDTPC =0;
362    if(fHistPrimVtxZESDSPD) delete fHistPrimVtxZESDSPD; fHistPrimVtxZESDSPD =0;
363   
364    if(fHistPiPCosPointAngXiVsPt) delete fHistPiPCosPointAngXiVsPt;fHistPiPCosPointAngXiVsPt=0;
365    if(fHistPiAPCosPointAngXiVsPt) delete fHistPiAPCosPointAngXiVsPt;fHistPiAPCosPointAngXiVsPt=0;
366   
367    if(fHistPiPPDGCode) delete  fHistPiPPDGCode;fHistPiPPDGCode=0;
368    if(fHistPiPiPDGCode) delete fHistPiPiPDGCode;fHistPiPiPDGCode=0;
369    if(fHistPiAPPDGCode) delete fHistPiAPPDGCode;fHistPiAPPDGCode=0;
370   
371    for(Int_t j=0;j<2;j++){// for primaries j=0 and secondaries j=1
372       //general V0
373       if(fHistArmenteros[j]) delete fHistArmenteros[j];fHistArmenteros[j]=0;
374       if(fHistV0RadiusZ[j]) delete fHistV0RadiusZ[j];fHistV0RadiusZ[j]=0;
375       if(fHistV0RadiusZVSPt[j]) delete fHistV0RadiusZVSPt[j];fHistV0RadiusZVSPt[j]=0;
376       if(fHistV0RadiusXY[j]) delete fHistV0RadiusXY[j];fHistV0RadiusXY[j]=0;
377       if(fHistV0RadiusXYVSY[j]) delete fHistV0RadiusXYVSY[j];fHistV0RadiusXYVSY[j]=0;
378     
379       //K0
380       if(fHistPiPiMass[j]) delete fHistPiPiMass[j];fHistPiPiMass[j]=0;
381       if(fHistPiPiMassVSPt[j]) delete fHistPiPiMassVSPt[j]; fHistPiPiMassVSPt[j]=0;
382       if(fHistPiPiMassVSPtMCTruth[j]) delete fHistPiPiMassVSPtMCTruth[j]; fHistPiPiMassVSPtMCTruth[j]=0;
383       if(fHistPiPiMassVSAlpha[j])delete fHistPiPiMassVSAlpha[j];fHistPiPiMassVSAlpha[j]=0;
384       if(fHistPiPiRadiusXY[j]) delete fHistPiPiRadiusXY[j];fHistPiPiRadiusXY[j]=0;
385       if(fHistPiPiCosPointAng[j])  delete fHistPiPiCosPointAng[j];fHistPiPiCosPointAng[j]=0;
386       if(fHistPiPiDecayLengthVsPt[j]) delete  fHistPiPiDecayLengthVsPt[j]; fHistPiPiDecayLengthVsPt[j]=0;
387       if(fHistPiPiDCADaughterPosToPrimVtxVSMass[j]) delete fHistPiPiDCADaughterPosToPrimVtxVSMass[j];fHistPiPiDCADaughterPosToPrimVtxVSMass[j]=0;
388       if(fHistPiPiMassVSPtK0L[j]) delete fHistPiPiMassVSPtK0L[j];fHistPiPiMassVSPtK0L[j]=0;
389       if(fHistPiPiDCADaughters[j]) delete fHistPiPiDCADaughters[j];fHistPiPiDCADaughters[j]=0; 
390       if(fHistPiPiPtDaughters[j]) delete fHistPiPiPtDaughters[j];fHistPiPiPtDaughters[j]=0;
391       if(fHistPiPiPtVSY[j]) delete fHistPiPiPtVSY[j];fHistPiPiPtVSY[j]=0;
392       if(fHistPiPiDCAVSMass[j]) delete fHistPiPiDCAVSMass[j]; fHistPiPiDCAVSMass[j]=0;
393       if(fHistPiPiMonitorCuts[j]) delete fHistPiPiMonitorCuts[j];fHistPiPiMonitorCuts[j]=0;
394     
395       //lambda 
396       if(fHistPiPMass[j]) delete fHistPiPMass[j];fHistPiPMass[j]=0;
397       if(fHistPiPMassVSPt[j]) delete fHistPiPMassVSPt[j];fHistPiPMassVSPt[j]=0;
398       if(fHistPiPMassVSPt[j]) delete fHistPiPMassVSPt[j]; fHistPiPMassVSPt[j]=0;
399       if(fHistPiPRadiusXY[j])  delete fHistPiPRadiusXY[j];fHistPiPRadiusXY[j]=0;
400       if(fHistPiPCosPointAng[j]) delete fHistPiPCosPointAng[j];fHistPiPCosPointAng[j]=0;
401       if(fHistPiPDecayLengthVsPt[j]) delete  fHistPiPDecayLengthVsPt[j]; fHistPiPDecayLengthVsPt[j]=0;
402       if(fHistPiPDCADaughterPosToPrimVtxVSMass[j]) delete fHistPiPDCADaughterPosToPrimVtxVSMass[j];fHistPiPDCADaughterPosToPrimVtxVSMass[j]=0;
403       if(fHistPiPDCADaughters[j]) delete fHistPiPDCADaughters[j];fHistPiPDCADaughters[j]=0; 
404       if(fHistPiPPtDaughters[j]) delete fHistPiPPtDaughters[j];fHistPiPPtDaughters[j]=0;
405       if(fHistPiPPtVSY[j]) delete fHistPiPPtVSY[j];fHistPiPPtVSY[j]=0;
406       if(fHistPiPDCAVSMass[j]) delete fHistPiPDCAVSMass[j]; fHistPiPDCAVSMass[j]=0;
407       if(fHistPiPMonitorCuts[j]) delete fHistPiPMonitorCuts[j];fHistPiPMonitorCuts[j]=0;
408     
409       //alambda 
410       if(fHistPiAPMass[j])delete fHistPiAPMass[j];fHistPiAPMass[j] =0;
411       if(fHistPiAPMassVSPt[j]) delete fHistPiAPMassVSPt[j]; fHistPiAPMassVSPt[j]=0;
412       if(fHistPiAPMassVSPt[j]) delete fHistPiAPMassVSPt[j]; fHistPiAPMassVSPt[j]=0;
413       if(fHistPiAPRadiusXY[j])  delete  fHistPiAPRadiusXY[j];fHistPiAPRadiusXY[j]=0;;
414       if(fHistPiAPCosPointAng[j]) delete fHistPiAPCosPointAng[j];fHistPiAPCosPointAng[j]=0;
415       if(fHistPiAPDecayLengthVsPt[j]) delete  fHistPiAPDecayLengthVsPt[j]; fHistPiAPDecayLengthVsPt[j]=0;
416       if(fHistPiAPDCADaughterPosToPrimVtxVSMass[j]) delete fHistPiAPDCADaughterPosToPrimVtxVSMass[j];fHistPiAPDCADaughterPosToPrimVtxVSMass[j]=0;
417       if(fHistPiAPDCADaughters[j]) delete fHistPiAPDCADaughters[j];fHistPiAPDCADaughters[j]=0; 
418       if(fHistPiAPPtDaughters[j]) delete fHistPiAPPtDaughters[j];fHistPiAPPtDaughters[j]=0;
419       if(fHistPiAPPtVSY[j]) delete fHistPiAPPtVSY[j];fHistPiAPPtVSY[j]=0;
420       if(fHistPiAPDCAVSMass[j]) delete fHistPiAPDCAVSMass[j]; fHistPiAPDCAVSMass[j]=0;
421       if(fHistPiAPMonitorCuts[j]) delete fHistPiAPMonitorCuts[j];fHistPiAPMonitorCuts[j]=0;
422     
423       //lambda and alambda
424       if(fHistPiPMassVSPtSecSigma[j])  delete fHistPiPMassVSPtSecSigma[j];fHistPiPMassVSPtSecSigma[j]=0;
425       if(fHistPiPMassVSPtSecXi[j])  delete fHistPiPMassVSPtSecXi[j];fHistPiPMassVSPtSecXi[j]=0;
426       if(fHistPiPMassVSYSecXi[j]) delete fHistPiPMassVSYSecXi[j];fHistPiPMassVSYSecXi[j]=0;
427       if(fHistPiPXi0PtVSLambdaPt[j]) delete fHistPiPXi0PtVSLambdaPt[j];fHistPiPXi0PtVSLambdaPt[j]=0;
428       if(fHistPiPXiMinusPtVSLambdaPt[j]) delete  fHistPiPXiMinusPtVSLambdaPt[j];  fHistPiPXiMinusPtVSLambdaPt[j]=0;
429       if(fHistPiAPMassVSPtSecSigma[j])  delete fHistPiAPMassVSPtSecSigma[j];fHistPiAPMassVSPtSecSigma[j]=0;
430       if(fHistPiAPMassVSPtSecXi[j])  delete fHistPiAPMassVSPtSecXi[j];fHistPiAPMassVSPtSecXi[j]=0;
431       if(fHistPiAPMassVSYSecXi[j])  delete fHistPiAPMassVSYSecXi[j];fHistPiAPMassVSYSecXi[j]=0;
432       if(fHistPiAPXi0PtVSLambdaPt[j]) delete fHistPiAPXi0PtVSLambdaPt[j];fHistPiAPXi0PtVSLambdaPt[j]=0;
433       if(fHistPiAPXiMinusPtVSLambdaPt[j]) delete  fHistPiAPXiMinusPtVSLambdaPt[j];  fHistPiAPXiMinusPtVSLambdaPt[j]=0;
434       
435       //others
436       if(fHistDedxSecProt[j]) delete fHistDedxSecProt[j];fHistDedxSecProt[j]=0;
437       if(fHistDedxSecAProt[j]) delete fHistDedxSecAProt[j]; fHistDedxSecAProt[j]=0;
438       if(fHistDedxSecPiMinus[j]) delete fHistDedxSecPiMinus[j];fHistDedxSecPiMinus[j]=0;
439       if(fHistDedxSecPiPlus[j]) delete fHistDedxSecPiPlus[j] ;fHistDedxSecPiPlus[j]=0;
440       if(fHistNclsITSPosK0[j]) delete fHistNclsITSPosK0[j];fHistNclsITSPosK0[j]=0;
441       if(fHistNclsITSNegK0[j]) delete fHistNclsITSNegK0[j];fHistNclsITSNegK0[j]=0;
442       if(fHistNclsTPCPosK0[j]) delete fHistNclsTPCPosK0[j];fHistNclsTPCPosK0[j]=0;
443       if(fHistNclsTPCNegK0[j]) delete fHistNclsTPCNegK0[j];fHistNclsTPCNegK0[j]=0;
444       if(fHistChi2PerNclsITSPosK0[j]) delete fHistChi2PerNclsITSPosK0[j];fHistChi2PerNclsITSPosK0[j]=0;
445       if(fHistChi2PerNclsITSNegK0[j]) delete fHistChi2PerNclsITSNegK0[j];fHistChi2PerNclsITSNegK0[j]=0;
446       if(fHistNclsITSPosL[j]) delete fHistNclsITSPosL[j];fHistNclsITSPosL[j]=0;
447       if(fHistNclsITSNegL[j]) delete fHistNclsITSNegL[j];fHistNclsITSNegL[j]=0;
448       if(fHistNclsTPCPosL[j]) delete fHistNclsTPCPosL[j];fHistNclsTPCPosL[j]=0;
449       if(fHistNclsTPCNegL[j]) delete fHistNclsTPCNegL[j];fHistNclsTPCNegL[j]=0;
450       if(fHistChi2PerNclsITSPosL[j]) delete fHistChi2PerNclsITSPosL[j];fHistChi2PerNclsITSPosL[j]=0;
451       if(fHistChi2PerNclsITSNegL[j]) delete fHistChi2PerNclsITSNegL[j];fHistChi2PerNclsITSNegL[j]=0;
452       if(fHistNclsITSPos[j]) delete fHistNclsITSPos[j];fHistNclsITSPos[j]=0;
453       if(fHistNclsITSNeg[j]) delete fHistNclsITSNeg[j];fHistNclsITSNeg[j]=0;
454       if(fHistNclsTPCPos[j]) delete fHistNclsTPCPos[j];fHistNclsTPCPos[j]=0;
455       if(fHistNclsTPCNeg[j]) delete fHistNclsTPCNeg[j];fHistNclsTPCNeg[j]=0;
456       if(fHistChi2PerNclsITSPos[j]) delete fHistChi2PerNclsITSPos[j];fHistChi2PerNclsITSPos[j]=0;
457       if(fHistChi2PerNclsITSNeg[j]) delete fHistChi2PerNclsITSNeg[j];fHistChi2PerNclsITSNeg[j]=0;
458       if(fHistNCRowsTPCNeg[j]) delete fHistNCRowsTPCNeg[j];fHistNCRowsTPCNeg[j]=0;
459       if(fHistNCRowsTPCPos[j]) delete fHistNCRowsTPCPos[j];fHistNCRowsTPCPos[j]=0;
460     
461       if(fHistPiPiEtaDMC[j]) delete fHistPiPiEtaDMC[j];fHistPiPiEtaDMC[j]=0;
462       if(fHistPiPiEtaDMC[j]) delete fHistPiPiEtaDMC[j];fHistPiPiEtaDMC[j]=0;
463       if(fHistPiPEtaDMC[j]) delete fHistPiPEtaDMC[j];fHistPiPEtaDMC[j]=0;
464       if(fHistPiPEtaDMC[j]) delete fHistPiPEtaDMC[j];fHistPiPEtaDMC[j]=0;
465       if(fHistPiPiEtaDReco[j]) delete fHistPiPiEtaDReco[j];fHistPiPiEtaDReco[j]=0;
466       if(fHistPiPiEtaDReco[j]) delete fHistPiPiEtaDReco[j];fHistPiPiEtaDReco[j]=0;
467       if(fHistPiPEtaDReco[j]) delete fHistPiPEtaDReco[j];fHistPiPEtaDReco[j]=0;
468       if(fHistPiPEtaDReco[j]) delete fHistPiPEtaDReco[j];fHistPiPEtaDReco[j]=0;     
469    }
470 }
471 //________________________________________________________________________
472 void AliAnalysisTaskV0ForRAA::UserCreateOutputObjects(){
473    //create output objects
474
475    Int_t nbPt=800;
476    Int_t nbMass=500;
477   
478    fHistITSLayerHits = new TH1F("fHistITSLayerHits","SDD layer -1=0,1=1,2=2 ... 5=5,0=nothing",7,-1.5,5.5);
479    fHistOneHitWithSDD = new TH1F("fHistOneHitWithSDD","min one hit in SDD",2,-0.5,1.5);
480    fHistNEvents = new TH1F("fHistNEvents","no of events before cuts =0, after cuts=1, after process =2",5,0.0,5.0);
481    fHistPrimVtxZESDVSNContributors = new TH2F("fHistPrimVtxZESDVSNContributors","prim vtx pos z ESD vs no. of contributers TPC",250,-50,50,500,0.0,500.0);
482    fHistPrimVtxZESDTPCVSNContributors = new TH2F("fHistPrimVtxZESDTPCVSNContributors","prim vtx pos z TPC vs no. of contributers TPC",250,-50,50,500,0.0,500.0);
483    fHistPrimVtxZESDSPDVSNContributors = new TH2F("fHistPrimVtxZESDSPDVSNContributors","prim vtx pos z SPD vs no. of contributers TPC",250,-50,50,500,0.0,500.0);
484   
485    fHistPrimVtxZESDVSNContributorsMC = new TH2F("fHistPrimVtxZESDVSNContributorsMC","prim vtx pos z ESD vs no. of contributers MC",250,-50,50,500,0.0,500.0);
486    fHistPrimVtxZESDTPCVSNContributorsMC = new TH2F("fHistPrimVtxZESDTPCVSNContributorsMC","prim vtx pos z TPC vs no. of contributers MC",250,-50,50,500,0.0,500.0);
487    fHistPrimVtxZESDSPDVSNContributorsMC = new TH2F("fHistPrimVtxZESDSPDVSNContributorsMC","prim vtx pos z SPD vs no. of contributers MC",250,-50,50,500,0.0,500.0);
488   
489    fHistPrimVtxZESD = new TH1F("fHistPrimVtxZESD","z vertex pos ESD",250,-50,50);
490    fHistPrimVtxZESDTPC = new TH1F("fHistPrimVtxZESDTPC","z vertex pos TPC",250,-50,50);
491    fHistPrimVtxZESDSPD = new TH1F("fHistPrimVtxZESDSPD","z vertex pos SPD",250,-50,50);
492   
493   
494    fHistMuliplicity =  new TH1F("fHistMuliplicity","V0 multiplicity",3000,0.0,30000);
495    fHistMuliplicityRaw =  new TH1F("fHistMuliplicityRaw","V0 multiplicity before process",3000,0.0,30000);
496    fHistNPrim = new TH1F("fHistNPrim","Number of contributers to vertex",3000,0.0,30000);
497    fHistMultiplicityPrimary = new TH1F("fHistMultiplicityPrimary","number of charged tracks",5000,0.0,20000);
498  
499    fHistV0RadiusZ[0]  = new TH2F("fHistV0RadiusZ","z of decay radius vs 2D radius",100,0.0,100.0,250,-125.0,125.0);
500    fHistV0RadiusZ[1]  = new TH2F("fHistV0RadiusZSec","z of decay radius vs 2D radius secondaries",100,0.0,100.0,250,-125.0,125.0);
501
502    fHistV0RadiusZVSPt[0]  = new TH2F("fHistV0RadiusZVSPt","z of decay radius vs pt radius",200,0.0,20.0,125,0.0,125.0);
503    fHistV0RadiusZVSPt[1]  = new TH2F("fHistV0RadiusZVSPtSec","z of decay radius vs pt secondaries",200,0.0,20.0,125,0.0,125.0);
504    
505    fHistV0RadiusXY[0]  = new TH2F("fHistV0RadiusXY","y vs x decay radius",250,-125.0,125.0,250,-125.0,125.0);
506    fHistV0RadiusXY[1]  = new TH2F("fHistV0RadiusXYSec","y vs x decay radius secondaries",250,-125.0,125.0,250,-125.0,125.0);
507
508    fHistV0RadiusXYVSY[0]  = new TH2F("fHistV0RadiusXYVSY","2D decay radius vs rap",100,-10,10,100,0.0,100.0);
509    fHistV0RadiusXYVSY[1]  = new TH2F("fHistV0RadiusXYVSYSec","2D decay radius vs rap sec",100,-10,10,100,0.0,100.0);
510    
511    fHistArmenteros[0] = new TH2F("fHistArmenteros"," pi+pi- armenteros",nbMass,-1.,1.,500,0.,0.5);
512    fHistArmenteros[1] = new TH2F("fHistArmenterosSec"," pi+pi- armenteros secondary",nbMass,-1.,1.,500,0.,0.5); 
513
514    
515    //********************************************** K0 *************************************************//
516         fHistPiPiMass[0] = new TH1F("fHistPiPiMass"," pi+pi- InvMass distribution",2*nbMass,0.,2.);
517    fHistPiPiMass[1] = new TH1F("fHistPiPiMassSec"," pi+pi- InvMass distribution secondary",2*nbMass,0.,2.);
518    
519    fHistPiPiMassVSPt[0] = new TH2F("fHistPiPiMassVSPt","pi+pi- InvMass distribution",nbMass,0.25,0.75,300,0.0,30.0);
520    fHistPiPiMassVSPt[1] = new TH2F("fHistPiPiMassVSPtSec","pi+pi- InvMass distribution",nbMass,0.25,0.75,300,0.0,30.0);
521
522    fHistPiPiMassVSPtMCTruth[0] = new TH2F("fHistPiPiMassVSPtMCTruth","pi+pi- InvMass distribution vs pt MCTruth",nbMass,0.25,0.75,300,0.0,30.0);
523    fHistPiPiMassVSPtMCTruth[1] = new TH2F("fHistPiPiMassVSPtMCTruthSec","pi+pi- InvMass distribution vs pt MCTruth",nbMass,0.25,0.75,300,0.0,30.0);
524
525    fHistPiPiPtVSY[0] = new TH2F("fHistPiPiPtVSY","p{t} vs y",100,-1,1,100,0.0,20);
526    fHistPiPiPtVSY[1] = new TH2F("fHistPiPiPtVSYSec","p{t} vs y secondaries",200,-1,1,100,0.0,20);
527    
528    fHistPiPiMassVSAlpha[0] = new TH2F("fHistPiPiMassVSAlpha"," alpha armenteros vs pi+pi- InvMass distribution",nbMass,0.25,0.75,500,-1.,1.);
529    fHistPiPiMassVSAlpha[1] = new TH2F("fHistPiPiMassVSAlphaSec"," alpha armenteros vs pi+pi- InvMass distribution secondary",nbMass,0.25,0.75,500,-1.,1.);
530    
531    fHistPiPiRadiusXY[0] = new TH2F("fHistPiPiRadiusXY","pi+pi- opening angle vs mass",nbMass,0.25,0.75,200,0.0,4.0);
532    fHistPiPiRadiusXY[1] = new TH2F("fHistPiPiRadiusXYSec","pi+pi- opening angle vs mass for secondary",nbMass,0.25,0.75,200,0.0,4.0);
533
534    fHistPiPiCosPointAng[0]  = new TH2F("fHistPiPiCosPointAng","K0 cosine of pointing angle vs dca to prim vtx",200,0.0,10.0,250,0.99,1.00);
535    fHistPiPiCosPointAng[1]  = new TH2F("fHistPiPiCosPointAngSec","K0 cosine of pointing angle vs dca to prim vtx for secondaries",200,0.0,10.0,250,0.99,1.00);
536
537    fHistPiPiDecayLengthVsPt[0] = new TH2F("fHistPiPiDecayLengthVsPt","K0 decay length vs pt",200,0.0,20.0,200,0.0,100.0);
538    fHistPiPiDecayLengthVsPt[1] = new TH2F("fHistPiPiDecayLengthVsPtSec","K0 decay length vs pt secondaries",200,0.0,20.0,200,0.0,100.0);
539
540    fHistPiPiDecayLengthVsMass[0] = new TH2F("fHistPiPiDecayLengthVsMass","K0 decay length vs mass",nbMass,0.25,0.75,200,0.0,100.0);
541    fHistPiPiDecayLengthVsMass[1] = new TH2F("fHistPiPiDecayLengthVsMassSec","K0 decay length vs mass secondaries",nbMass,0.25,0.75,200,0.0,100.0);
542    
543    fHistPiPiDCADaughterPosToPrimVtxVSMass[0] = new TH2F("fHistPiPiDCADaughterPosToPrimVtxVSMass","pi+ DCA daughter to prim vtx vsinvmass",nbMass,0.25,0.75,250,0.0,25.0);
544    fHistPiPiDCADaughterPosToPrimVtxVSMass[1] = new TH2F("fHistPiPiDCADaughterPosToPrimVtxVSMassSec","pi+ DCA  daughter to prim vtx vs invmass for secondaries",nbMass,0.25,0.75,250,0.0,25.0);
545
546    fHistPiPiPDGCode = new TH1F("fHistPiPiPDGCode","PDG code of K0s mothers",3500,0,3500);
547
548    fHistPiPiMassVSPtK0L[0] = new TH2F("fHistPiPiMassVSPtK0LMC","K0s from K0l pt vs mass MC truth",nbMass,0.25,0.75,100,0.,20.);
549    fHistPiPiMassVSPtK0L[1] = new TH2F("fHistPiPiMassVSPtK0L","K0s from K0l pt vs mass reco",nbMass,0.25,0.75,100,0.,20.);
550
551
552    fHistPiPMassVSPt[0] = new TH2F("fHistPiPMassVSPt","p+pi- InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
553    fHistPiPMassVSPt[1] = new TH2F("fHistPiPMassVSPtSec","p+pi- InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
554
555    fHistPiPiDCAVSMass[0] = new TH2F("fHistPiPiDCAVSMass","pi+pi- dca  vs pt",nbMass,0.25,0.75,250,0.0,5.0);
556    fHistPiPiDCAVSMass[1] = new TH2F("fHistPiPiDCAVSMassSec","pi+pi- dca  vs pt",nbMass,0.25,0.75,250,0.0,5.0);
557
558    fHistPiPiDCADaughters[0] = new TH2F("fHistPiPiDCADaughters","dca of K0 daughters",nbMass,0.25,0.75,250,0.0,2);
559    fHistPiPiDCADaughters[1] = new TH2F("fHistPiPiDCADaughtersSec","dca of K0 daughters secondary",nbMass,0.25,0.75,250,0.0,2);
560
561    fHistPiPiPtDaughters[0] = new TH2F("fHistPiPiPtDaughters","p_{t} pos vs p_{t} neg of daughters",400,0.0,20.0,400,0,20.0);
562    fHistPiPiPtDaughters[1] = new TH2F("fHistPiPiPtDaughtersSec","p_{t} pos vs p_{t} neg of daughters secondaries",400,0.0,20.0,400,0,20.0);
563
564    fHistPiPiMonitorCuts[0] = new TH1F("fHistPiPiMonitorCuts","K0 cut monitor",25,0.5,25.5);
565    fHistPiPiMonitorCuts[1] = new TH1F("fHistPiPiMonitorCutsSec","K0 cut monitor secondaries",25,0.5,25.5);
566
567    
568    //***************************************** Lambda **********************************//
569         fHistPiPMass[0] = new TH1F("fHistPiPMass"," p+pi- InvMass distribution",2*nbMass,0.,2.);
570    fHistPiPMass[1] = new TH1F("fHistPiPMassSec"," p+pi- InvMass distribution secondaries",2*nbMass,0.,2.);
571
572    fHistPiPMassVSPt[0] = new TH2F("fHistPiPMassVSPt","p+pi- InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
573    fHistPiPMassVSPt[1] = new TH2F("fHistPiPMassVSPtSec","p+pi- InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
574
575    fHistPiPMassVSPtMCTruth[0] = new TH2F("fHistPiPMassVSPtMCTruth","p+pi- InvMass distribution vs pt MCTruth",nbMass,1.05,1.25,300,0.0,30.0);
576    fHistPiPMassVSPtMCTruth[1] = new TH2F("fHistPiPMassVSPtMCTruthSec","p+pi- InvMass distribution vs pt MCTruth",nbMass,1.05,1.25,300,0.0,30.0);
577
578    fHistPiPPtVSY[0] = new TH2F("fHistPiPPtVSY","p{t} vs y",100,-1,1,100,0.0,20);
579    fHistPiPPtVSY[1] = new TH2F("fHistPiPPtVSYSec","p{t} vs y secondaries",100,-1,1,100,0.0,20);   
580
581    fHistPiPMassVSPtSecSigma[0] = new TH2F("fHistPiPMassVSPtSecSigmaMC"," pi-p+ InvMass distribution secondaries from sigma MC",nbMass,1.05,1.25,200,0.,20);
582    fHistPiPMassVSPtSecSigma[1] = new TH2F("fHistPiPMassVSPtSecSigma"," pi-p+ InvMass distribution secondaries from Sigma reco",nbMass,1.05,1.25,200,0.,20);
583    
584    fHistPiPMassVSPtSecXi[0] = new TH2F("fHistPiPMassVSPtSecXiMC"," pi-p+ InvMass distribution secondaries from  xi MC",nbMass,1.05,1.25,200,0.,20);
585    fHistPiPMassVSYSecXi[1] = new TH2F("fHistPiPMassVSYSecXi"," pi-p+ InvMass distribution secondaries from xi reco",nbMass,1.05,1.25,100,-2.,2);
586  
587    fHistPiPMassVSPtSecXi[1] = new TH2F("fHistPiPMassVSPtSecXi"," pi-p+ InvMass distribution secondaries from  xi  reco",nbMass,1.05,1.25,200,0.,20);
588    fHistPiPMassVSYSecXi[0] = new TH2F("fHistPiPMassVSYSecXiMC"," pi-p+ InvMass distribution secondaries from xi MC",nbMass,1.05,1.25,100,-2.,2);
589    
590    fHistPiPXi0PtVSLambdaPt[0]= new TH2F("fHistPiPXi0PtVSLambdaPtMC"," pt xi 0 vs pt lambda MC truth",200,0.0,20.0,200,0.0,20.0);
591    fHistPiPXi0PtVSLambdaPt[1]= new TH2F("fHistPiPXi0PtVSLambdaPt"," pt xi 0 truth vs pt lambda reco",200,0.0,20.0,200,0.0,20.0);
592
593    fHistPiPXiMinusPtVSLambdaPt[0]= new TH2F("fHistPiPXiMinusPtVSLambdaPtMC","pt xi- vs pt lambda MC truth",200,0.0,20.0,200,0.0,20.0);
594    fHistPiPXiMinusPtVSLambdaPt[1]= new TH2F("fHistPiPXiMinusPtVSLambdaPt","pt xi- truth vs pt lambda reco",200,0.0,20.0,200,0.0,20.0);
595
596    fHistPiPCosPointAngXiVsPt= new TH2F("fHistPiPCosPointAngXiVsPt","pi-p cos of pointing angle vs pt from xi",200,0.0,20.0,250,0.99,1.00);
597     
598    fHistPiPRadiusXY[0] = new TH2F("fHistPiPRadiusXY","pi-p+ opening angle vs mass",nbMass,1.05,1.25,200,0.0,4.0);
599    fHistPiPRadiusXY[1] = new TH2F("fHistPiPRadiusXYSec","pi-p+ opening angle vs mass for secondary",nbMass,1.05,1.25,200,0.0,4.0);
600
601    fHistPiPCosPointAng[0]  = new TH2F("fHistPiPCosPointAng","#Lambda cosine of pointing angle vs dca to prim vtx",200,0.0,10.0,250,0.99,1.00);
602    fHistPiPCosPointAng[1]  = new TH2F("fHistPiPCosPointAngSec","#Lambda cosine of pointing angle vs dca to prim vtx for secondaries",200,0.0,10.0,250,0.99,1.00);
603           
604    fHistPiPDecayLengthVsPt[0] = new TH2F("fHistPiPDecayLengthVsPt","#Lambda decay length vs pt",200,0.0,20.0,200,0.0,100.0);
605    fHistPiPDecayLengthVsPt[1] = new TH2F("fHistPiPDecayLengthVsPtSec","#Lambda decay length vs pt secondaries",200,0.0,20.0,200,0.0,100.0);
606    fHistPiPDecayLengthVsMass[0] = new TH2F("fHistPiPDecayLengthVsMass","#Lambda decay length vs mass",nbMass,1.05,1.25,200,0.0,100.0);
607    fHistPiPDecayLengthVsMass[1] = new TH2F("fHistPiPDecayLengthVsMassSec","#Lambda decay length vs mass secondaries",nbMass,1.05,1.25,200,0.0,100.0);
608
609    fHistPiPDCADaughterPosToPrimVtxVSMass[0] = new TH2F("fHistPiPDCADaughterPosToPrimVtxVSMass","p DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,25.0);
610    fHistPiPDCADaughterPosToPrimVtxVSMass[1] = new TH2F("fHistPiPDCADaughterPosToPrimVtxVSMassSec","p DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,25.0);
611         
612    fHistPiPPDGCode = new TH1F("fHistPiPPDGCode","PDG code of #Lambda  mothers",3500,0,3500);
613
614
615
616    fHistPiPDCAVSMass[0] = new TH2F("fHistPiPDCAVSMass","ppi- dca  vs pt",nbMass,1.05,1.25,250,0.0,5.0);
617    fHistPiPDCAVSMass[1] = new TH2F("fHistPiPDCAVSMassSec","ppi- dca  vs pt",nbMass,1.05,1.25,250,0.0,5.0);
618
619    fHistPiPDCADaughters[0] = new TH2F("fHistPiPDCADaughters","dca of #Lambda daughters",nbMass,1.05,1.25,250,0.0,2.0);
620    fHistPiPDCADaughters[1] = new TH2F("fHistPiPDCADaughtersSec","dca of #Lambda daughters secondary",nbMass,1.05,1.25,250,0.0,2.0);
621
622    fHistPiPPtDaughters[0] = new TH2F("fHistPiPPtDaughters","p_{t} pos vs p_{t} neg of daughters",400,0.0,20.0,400,0,20.0);
623    fHistPiPPtDaughters[1] = new TH2F("fHistPiPPtDaughtersSec","p_{t} pos vs p_{t} neg of daughters secondaries",400,0.0,20.0,400,0,20.0);
624    
625    fHistPiPMonitorCuts[0] = new TH1F("fHistPiPMonitorCuts","#Lambda cut monitor",25,0.5,25.5);
626    fHistPiPMonitorCuts[1] = new TH1F("fHistPiPMonitorCutsSec","#Lambda cut monitor secondaries",25,0.5,25.5);
627
628    
629    //***************antilambda **********************************************//
630         fHistPiAPMass[0] = new TH1F("fHistPiAPMass"," ap-pi+ InvMass distribution",2*nbMass,0.,2.);
631    fHistPiAPMass[1] = new TH1F("fHistPiAPMassSec"," p-pi+ InvMass distribution secondaries",2*nbMass,0.,2.);
632
633    fHistPiAPMassVSPt[0] = new TH2F("fHistPiAPMassVSPt","p-pi+ InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
634    fHistPiAPMassVSPt[1] = new TH2F("fHistPiAPMassVSPtSec","p-pi+ InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
635
636    fHistPiAPMassVSPtMCTruth[0] = new TH2F("fHistPiAPMassVSPtMCTruth","p-pi+ InvMass distribution vs pt MCTruth",nbMass,1.05,1.25,300,0.0,30.0);
637    fHistPiAPMassVSPtMCTruth[1] = new TH2F("fHistPiAPMassVSPtMCTruthSec","p-pi+ InvMass distribution vs pt MCTruth ",nbMass,1.05,1.25,300,0.0,30.0);
638
639    fHistPiAPPtVSY[0] = new TH2F("fHistPiAPPtVSY","p{t} vs y",100,-1,1,100,0.0,20);
640    fHistPiAPPtVSY[1] = new TH2F("fHistPiAPPtVSYSec","p{t} vs y secondaries",100,-1,1,100,0.0,20);
641    
642    fHistPiAPRadiusXY[0] = new TH2F("fHistPiAPRadiusXY","pi+p- opening angle vs mass",nbMass,1.05,1.25,200,0.0,4.0);
643    fHistPiAPRadiusXY[1] = new TH2F("fHistPiAPRadiusXYSec","pi+p- opening angle vs mass for secondary",nbMass,1.05,1.25,200,0.0,4.0);
644
645    fHistPiAPCosPointAngXiVsPt= new TH2F("fHistPiAPCosPointAngXiVsPt","pi+p- cos of pointing angle vs pt from xi",200,0.0,20.0,250,0.98,1.00);   
646
647    fHistPiAPMassVSPtSecSigma[0] = new TH2F("fHistPiAPMassVSPtSecSigmaMC"," pi+p- InvMass distribution secondaries from Sigma MC",nbMass,1.05,1.25,200,0.,20);
648    fHistPiAPMassVSPtSecSigma[1] = new TH2F("fHistPiAPMassVSPtSecSigma"," pi+p- InvMass distribution secondaries from  Sigma  reco",nbMass,1.05,1.25,200,0.,20);
649
650    fHistPiAPMassVSPtSecXi[1] = new TH2F("fHistPiAPMassVSPtSecXi"," pi+p- InvMass distribution secondaries from  Xi reco",nbMass,1.05,1.25,200,0.,20);
651    fHistPiAPMassVSPtSecXi[0] = new TH2F("fHistPiAPMassVSPtSecXiMC"," pi+p- InvMass distribution secondaries from xi MC",nbMass,1.05,1.25,200,0.,20);
652
653    fHistPiAPMassVSYSecXi[0] = new TH2F("fHistPiAPMassVSYSecXiMC"," pi+p- InvMass distribution secondaries from  xi MC",nbMass,1.05,1.25,100,-2,2);
654    fHistPiAPMassVSYSecXi[1] = new TH2F("fHistPiAPMassVSYSecXi"," pi+p- InvMass distribution secondaries from xi reco",nbMass,1.05,1.25,100,-2.,2);
655
656    fHistPiAPCosPointAng [0] = new TH2F("fHistPiAPCosPointAng","#bar{#Lambda} cosine of pointing angle vs dcs to prim vtx",200,0.0,10.0,250,0.99,1.00);
657    fHistPiAPCosPointAng[1]  = new TH2F("fHistPiAPCosPointAngSec","#bar{#Lambda} cosine of pointing angle vs dca to prim vtx for secondaries",200,0.0,10.0,250,0.99,1.00);
658
659    fHistPiAPDecayLengthVsPt[0] = new TH2F("fHistPiAPDecayLengthVsPt","#bar{#Lambda} decay length vs pt",200,0.0,20.0,200,0.0,100.0);
660    fHistPiAPDecayLengthVsPt[1] = new TH2F("fHistPiAPDecayLengthVsPtSec","#bar{#Lambda} decay length vs pt secondaries",200,0.0,20.0,200,0.0,100.0);
661
662    fHistPiAPDecayLengthVsMass[0] = new TH2F("fHistPiAPDecayLengthVsMass","#bar{#Lambda} decay length vs mass",nbMass,1.05,1.25,200,0.0,100.0);
663    fHistPiAPDecayLengthVsMass[1] = new TH2F("fHistPiAPDecayLengthVsMassSec","#bar{#Lambda} decay length vs mass secondaries",nbMass,1.05,1.25,200,0.0,100.0);
664
665    fHistPiAPXi0PtVSLambdaPt[0]= new TH2F("fHistPiAPXi0PtVSLambdaPtMC"," pt xi 0 vs pt Alambda MC truth",200,0.0,20.0,200,0.0,20.0);
666    fHistPiAPXi0PtVSLambdaPt[1]= new TH2F("fHistPiAPXi0PtVSLambdaPt"," pt xi 0 truth vs pt Alambda reco",200,0.0,20.0,200,0.0,20.0);
667
668    fHistPiAPXiMinusPtVSLambdaPt[0]= new TH2F("fHistPiAPXiMinusPtVSLambdaPtMC","pt xi- vs pt Alambda MC truth",200,0.0,20.0,200,0.0,20.0);
669    fHistPiAPXiMinusPtVSLambdaPt[1]= new TH2F("fHistPiAPXiMinusPtVSLambdaPt","pt xi- truth vs pt Alambda reco",200,0.0,20.0,200,0.0,20.0);
670           
671    fHistPiAPDCADaughterPosToPrimVtxVSMass[0] = new TH2F("fHistPiAPDCADaughterPosToPrimVtxVSMass","pi+ DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,25.0);
672    fHistPiAPDCADaughterPosToPrimVtxVSMass[1] = new TH2F("fHistPiAPDCADaughterPosToPrimVtxVSMassSec","pi+ DCA daughter to prim vtx vs invmass secondaries",nbMass,1.05,1.25,250,0.0,25.0);
673         
674    fHistPiAPPDGCode = new TH1F("fHistPiAPPDGCode","PDG code of #bar{#Lambda} mothers",3500,0,3500);
675
676    fHistPiAPDCAVSMass[0] = new TH2F("fHistPiAPDCAVSMass","pi+p- dca  vs pt",nbMass,1.05,1.25,250,0.0,5.0);
677    fHistPiAPDCAVSMass[1] = new TH2F("fHistPiAPDCAVSMassSec","pi+p- dca  vs pt",nbMass,1.05,1.25,250,0.0,5.0);
678
679    fHistPiAPDCADaughters[0] = new TH2F("fHistPiAPDCADaughters","dca of #bar{#Lambda} daughters",nbMass,1.05,1.25,250,0.0,2.0);
680    fHistPiAPDCADaughters[1] = new TH2F("fHistPiAPDCADaughtersSec","dca of #bar{#Lambda} daughters secondary",nbMass,1.05,1.25,250,0.0,2.0);
681      
682    fHistPiAPPtDaughters[0] = new TH2F("fHistPiAPPtDaughters","p_{t} pos vs p_{t} neg of daughters",400,0.0,20.0,400,0,20.0);
683    fHistPiAPPtDaughters[1] = new TH2F("fHistPiAPPtDaughtersSec","p_{t} pos vs p_{t} neg of daughters secondaries",400,0.0,20.0,400,0,20.0);
684
685    fHistPiAPMonitorCuts[0] = new TH1F("fHistPiAPMonitorCuts","#bar{#Lambda} cut monitor",25,0.5,25.5);
686    fHistPiAPMonitorCuts[1] = new TH1F("fHistPiAPMonitorCutsSec","#bar{#Lambda} cut monitor secondaries",25,0.5,25.5);
687
688    
689    //*********************************************************************TPC*****************************************************//
690         fHistESDVertexZ= new TH1F("fHistESDVertexZ"," z vertex distr in cm",500,-50,50);
691    fHistMCVertexZ= new TH1F("fHistMCVertexZ"," z vertex distr in cm MC",500,-50,50);
692    
693    fHistDedxSecProt[0] = new TH2F("fHistDedxSecProt","", nbPt, 0, 20, 100, 0, 400);
694    fHistDedxSecAProt[0] = new TH2F("fHistDedxSecAProt","", nbPt, 0, 20, 100, 0, 400);
695
696    fHistDedxSecPiPlus[0] = new TH2F("fHistDedxSecPiPlus","", nbPt, 0, 20, 100, 0, 400);
697    fHistDedxSecPiMinus[0] = new TH2F("fHistDedxSecPiMinus","", nbPt, 0, 20, 100, 0, 400);
698
699    fHistDedxSecProt[1] = new TH2F("fHistDedxSecProtSec","secondary", nbPt, 0, 20, 100, 0, 400);
700    fHistDedxSecAProt[1] = new TH2F("fHistDedxSecAProtSec","secondary", nbPt, 0, 20, 100, 0, 400);
701
702    fHistDedxSecPiPlus[1] = new TH2F("fHistDedxSecPiPlusSec","secondary", nbPt, 0, 20, 100, 0, 400);
703    fHistDedxSecPiMinus[1] = new TH2F("fHistDedxSecPiMinusSec","secondary", nbPt, 0, 20, 100, 0, 400);
704    
705    fHistNclsITSPosK0[0] = new TH1F("fHistNclsITSPosK0","fHistNclsITSPos K0",10,-0.5,9.5);
706    fHistNclsITSPosK0[1] = new TH1F("fHistNclsITSPosK0","fHistNclsITSPos K0 secondary",10,-0.5,9.5);
707
708    fHistNclsITSNegK0[0] = new TH1F("fHistNclsITSNegK0","fHistNclsITSNeg K0",10,-0.5,9.5);
709    fHistNclsITSNegK0[1] = new TH1F("fHistNclsITSNegK0Sec","fHistNclsITSNeg K0 secondary",10,-0.5,9.5);
710  
711    fHistNclsTPCPosK0[0] = new TH1F("fHistNclsTPCPosK0","fHistNclsTPCPos K0",200,-0.5,199.5);
712    fHistNclsTPCPosK0[1] = new TH1F("fHistNclsTPCPosK0Sec","fHistNclsTPCPos K0 secondary",200,-0.5,199.5);
713
714    fHistNclsTPCNegK0[0] = new TH1F("fHistNclsTPCNegK0","fHistNclsTPCNeg K0",200,-0.5,199.5);
715    fHistNclsTPCNegK0[1] = new TH1F("fHistNclsTPCNegK0Sec","fHistNclsTPCNeg K0 secondary",200,-0.5,199.5);
716
717    fHistChi2PerNclsITSPosK0[0] = new TH1F("fHistChi2PerNclsITSPosK0","chi2 per cluster ITS pi+pi-",250,0.0,50.0);
718    fHistChi2PerNclsITSPosK0[1] = new TH1F("fHistChi2PerNclsITSPosK0Sec","chi2 per cluster ITS pi+pi-",250,0.0,50.0);
719
720    fHistChi2PerNclsITSNegK0[0] = new TH1F("fHistChi2PerNclsITSNegK0","chi2 per cluster ITS pi+pi- neg",250,0.0,50.0);
721    fHistChi2PerNclsITSNegK0[1] = new TH1F("fHistChi2PerNclsITSNegK0Sec","chi2 per cluster ITS pi+pi- neg",250,0.0,50.0);
722
723    fHistNclsITSPosL[0] = new TH1F("fHistNclsITSPosL","fHistNclsITSPos #Lambda",10,-0.5,9.5);
724    fHistNclsITSPosL[1] = new TH1F("fHistNclsITSPosLSec","fHistNclsITSPos  #Lambda secondary",10,-0.5,9.5);
725    
726    fHistNclsITSNegL[0] = new TH1F("fHistNclsITSNegL","fHistNclsITSNeg #Lambda",10,-0.5,9.5);
727    fHistNclsITSNegL[1] = new TH1F("fHistNclsITSNegLSec","fHistNclsITSNeg  #Lambda secondary",10,-0.5,9.5);
728    
729    fHistNclsTPCPosL[0] = new TH1F("fHistNclsTPCPosL","fHistNclsTPCPos #Lambda",200,-0.5,199.5);
730    fHistNclsTPCPosL[1] = new TH1F("fHistNclsTPCPosLSec","fHistNclsTPCPos  #Lambda secondary",200,-0.5,199.5);
731
732    fHistNclsTPCNegL[0] = new TH1F("fHistNclsTPCNegL","fHistNclsTPCNeg #Lambda",200,-0.5,199.5);
733    fHistNclsTPCNegL[1] = new TH1F("fHistNclsTPCNegLSec","fHistNclsTPCNeg  #Lambda secondary",200,-0.5,199.5);
734
735    fHistChi2PerNclsITSPosL[0] = new TH1F("fHistChi2PerNclsITSPosL","chi2 per cluster ITS pi-p+ pos",250,0.0,50.0);
736    fHistChi2PerNclsITSPosL[1] = new TH1F("fHistChi2PerNclsITSPosLSec","chi2 per cluster ITS pi-p+ pos",250,0.0,50.0);
737
738    fHistChi2PerNclsITSNegL[0] = new TH1F("fHistChi2PerNclsITSNegL","chi2 per cluster ITS pi-p+ neg",250,0.0,50.0);
739    fHistChi2PerNclsITSNegL[1] = new TH1F("fHistChi2PerNclsITSNegLSec","chi2 per cluster ITS pi-p+ neg",250,0.0,50.0);
740
741    //for 2d pt dep studies
742    fHistNclsITSPos[0] = new TH2F("fHistNclsITSPos","fHistNclsITSPos  vs pt pos",200,0.0,20.0,10,-0.5,9.5);
743    fHistNclsITSPos[1] = new TH2F("fHistNclsITSPosSec","fHistNclsITSPos  vs pt pos secondary",200,0.0,20.0,10,-0.5,9.5);
744
745    fHistNclsITSNeg[0] = new TH2F("fHistNclsITSNeg","fHistNclsITSNeg vs pt neg",200,0.0,20.0,10,-0.5,9.5);
746    fHistNclsITSNeg[1] = new TH2F("fHistNclsITSNegSec","fHistNclsITSNeg  vs pt neg secondary",200,0.0,20.0,10,-0.5,9.5);
747    
748    fHistNclsTPCPos[0] = new TH2F("fHistNclsTPCPos","ncls vs findable ncls pos",200,0.0,200.0,200,0.0,200.0);
749    fHistNclsTPCPos[1] = new TH2F("fHistNclsTPCPosSec","ncls vs findable ncls pos secondary",200,0.0,200.0,200,0.0,200.0);
750
751    fHistNclsTPCNeg[0] = new TH2F("fHistNclsTPCNeg","ncls vs findable ncls neg",200,0.0,200.0,200,0.0,200.0);
752    fHistNclsTPCNeg[1] = new TH2F("fHistNclsTPCNegSec","ncls vs findable ncls neg secondary",200,0.0,200.0,200,0.0,200.0);
753
754    fHistChi2PerNclsITSPos[0] = new TH2F("fHistChi2PerNclsITSPos","chi2 per cluster ITS pi+p-vs pt pos",200,0.0,20.0,250,0.0,50.0);
755    fHistChi2PerNclsITSPos[1] = new TH2F("fHistChi2PerNclsITSPosSec","chi2 per cluster ITS pi+p- vs pt pos",200,0.0,20.0,250,0.0,50.0);
756
757    fHistChi2PerNclsITSNeg[0] = new TH2F("fHistChi2PerNclsITSNeg","chi2 per cluster ITS pi+p- neg vs pt neg",200,0.0,20.0,250,0.0,50.0);
758    fHistChi2PerNclsITSNeg[1] = new TH2F("fHistChi2PerNclsITSNegsSec","chi2 per cluster ITS pi+p- neg vs pt neg",200,0.0,20.0,250,0.0,50.0);
759
760    fHistNclsITS[0] = new TH2F("fHistNclsITS","fHistNclsITS pos vs neg",10,-0.5,9.5,10,-0.5,9.5);
761    fHistNclsITS[1] = new TH2F("fHistNclsITSSec","fHistNclsITS pos vs neg",10,-0.5,9.5,10,-0.5,9.5);
762
763    fHistNclsTPC[0] = new TH2F("fHistNclsTPC","ncls TPC neg vs crossed rows neg",200,-0.5,199.5,200,-0.5,199.5);
764    fHistNclsTPC[1] = new TH2F("fHistNclsTPCSec","ncls TPC neg vs crossed rows neg",200,-0.5,199.5,200,-0.5,199.5);
765
766
767    fHistNCRowsTPCPos[0] = new TH2F("fHistNCRowsTPCPos","n crossed rows vs pt pos",200,0.0,20.0,200,0.0,200.0);
768    fHistNCRowsTPCPos[1] = new TH2F("fHistNCRowsTPCPosSec","n crossed rows vs pt pos sec",200,0.0,20.0,200,0.0,200.0);
769
770    fHistNCRowsTPCNeg[0] = new TH2F("fHistNCRowsTPCNeg","n crossed rows vs pt neg",200,0.0,20.0,200,0.0,200.0);
771    fHistNCRowsTPCNeg[1] = new TH2F("fHistNCRowsTPCNegSec","n crossed rows vs pt neg sec",200,0.0,20.0,200,0.0,200.0);
772              
773    //***************************************** eta ******************************************************//
774         fHistPiPiEtaDMC[0] = new TH2F("fHistPiPiEtaDMCRaw","K0s daughters etaMC raw",300,-6,6,100,0,20);//
775    fHistPiPiEtaDMC[1] = new TH2F("fHistPiPiEtaDMC","K0s daughters etaMC after rap V0 cut",300,-6,6,100,0,20);
776
777    fHistPiPEtaDMC[0] = new TH2F("fHistPiPEtaDMCRaw","#Lambda daughters etaMC raw",300,-6,6,100,0,20);
778    fHistPiPEtaDMC[1] = new TH2F("fHistPiPEtaDMC","#Lambda daughters etaMC after rap V0 cut",300,-6,6,100,0,20);
779
780    fHistPiPiEtaDReco[0] = new TH2F("fHistPiPiEtaDRecoRaw","K0s daughters eta raw",300,-6,6,100,0,20);
781    fHistPiPiEtaDReco[1] = new TH2F("fHistPiPiEtaDReco","K0s daughters eta after rap V0 cut pos",300,-3,3,300,-3.00,3.0);
782
783    fHistPiPEtaDReco[0] = new TH2F("fHistPiPEtaDRecoRaw","#Lambda daughters eta raw",300,-6,6,100,0,20);
784    fHistPiPEtaDReco[1] = new TH2F("fHistPiPEtaDReco","#Lambda daughters eta after rap V0 cut neg",300,-3,3,300,-3.00,3.0);
785
786    /*    
787    //shift q/pt
788    fHistUserPtShift = new TH1F("fHistUserPtShift","user defined shift in 1/pt",100,-0.5,1.5);
789    */
790
791    
792       //-----------------  create output container -----------------//
793
794       fOutputContainer = new TList() ;
795       fOutputContainer->SetName(GetName()) ;
796
797       if(fAnapp){
798          fOutputContainer->Add(fHistITSLayerHits);
799          fOutputContainer->Add(fHistOneHitWithSDD);
800          fOutputContainer->Add(fHistPrimVtxZESDTPCVSNContributors);
801          fOutputContainer->Add(fHistPrimVtxZESDSPDVSNContributors);
802          fOutputContainer->Add(fHistPrimVtxZESDTPC);
803          fOutputContainer->Add(fHistPrimVtxZESDSPD);  
804       }
805       fOutputContainer->Add(fHistNEvents);
806       fOutputContainer->Add(fHistMuliplicity);
807       fOutputContainer->Add(fHistMuliplicityRaw);
808       fOutputContainer->Add(fHistMultiplicityPrimary);
809       fOutputContainer->Add(fHistESDVertexZ);
810       fOutputContainer->Add(fHistPrimVtxZESD);
811       fOutputContainer->Add(fHistPrimVtxZESDVSNContributors);
812       fOutputContainer->Add(fHistNPrim);
813
814       Int_t mchist = 1;// for Data
815       if((fMCMode && fMCTruthMode) || fMCTruthMode){//MC reco or MC truth only
816          fOutputContainer->Add(fHistPrimVtxZESDVSNContributorsMC);
817          fOutputContainer->Add(fHistPrimVtxZESDTPCVSNContributorsMC);
818          fOutputContainer->Add(fHistPrimVtxZESDSPDVSNContributorsMC);
819          fOutputContainer->Add(fHistMCVertexZ);
820          fOutputContainer->Add(fHistPiPPDGCode);
821          fOutputContainer->Add(fHistPiPiPDGCode);
822          fOutputContainer->Add(fHistPiAPPDGCode);
823          fOutputContainer->Add(fHistPiPCosPointAngXiVsPt);
824          fOutputContainer->Add(fHistPiAPCosPointAngXiVsPt);      
825
826          mchist = 2; //for MC to get secondaries
827       }
828
829       if((fMCMode) || (!fMCTruthMode && !fMCMode)){// for reco or data or mc data like MC reco only
830          fOutputContainer->Add(fHistPiPiEtaDReco[0]);
831          fOutputContainer->Add(fHistPiPiEtaDReco[1]);
832          fOutputContainer->Add(fHistPiPEtaDReco[0]);
833          fOutputContainer->Add(fHistPiPEtaDReco[1]);
834       
835       }
836               
837       for(Int_t j=0;j<mchist;j++){//add allways
838          fOutputContainer->Add(fHistArmenteros[j]);
839          fOutputContainer->Add(fHistPiPiPtVSY[j]);
840          fOutputContainer->Add(fHistPiPPtVSY[j]);
841          fOutputContainer->Add(fHistPiAPPtVSY[j]);
842          fOutputContainer->Add(fHistPiPiMassVSPt[j]);
843          fOutputContainer->Add(fHistPiPMassVSPt[j]);
844          fOutputContainer->Add(fHistPiAPMassVSPt[j]);
845          fOutputContainer->Add(fHistPiPiMass[j]);
846          fOutputContainer->Add(fHistPiPMass[j]);
847          fOutputContainer->Add(fHistPiAPMass[j]);
848          fOutputContainer->Add(fHistV0RadiusZ[j]);
849          fOutputContainer->Add(fHistV0RadiusZVSPt[j]);
850          fOutputContainer->Add(fHistV0RadiusXY[j]);
851          fOutputContainer->Add(fHistV0RadiusXYVSY[j]);
852          fOutputContainer->Add(fHistPiPiDecayLengthVsPt[j]);
853          fOutputContainer->Add(fHistPiPDecayLengthVsPt[j]);
854          fOutputContainer->Add(fHistPiAPDecayLengthVsPt[j]);
855                   
856          if((fMCMode) || (!fMCTruthMode && !fMCMode)){// for reco or data or mc data like MC reco only
857             //all
858             fOutputContainer->Add(fHistPiPiDCADaughters[j]); 
859             fOutputContainer->Add(fHistPiPDCADaughters[j]); 
860             fOutputContainer->Add(fHistPiAPDCADaughters[j]);
861             /*
862               fOutputContainer->Add( fHistPiPiPtDaughters[j]);
863               fOutputContainer->Add( fHistPiPPtDaughters[j]);
864               fOutputContainer->Add( fHistPiAPPtDaughters[j]);
865             */
866             fOutputContainer->Add(fHistPiPiDCAVSMass[j]);
867             fOutputContainer->Add(fHistPiPDCAVSMass[j]);
868             fOutputContainer->Add(fHistPiAPDCAVSMass[j]);
869             fOutputContainer->Add(fHistPiPiCosPointAng[j]);
870             fOutputContainer->Add(fHistPiPCosPointAng[j]);
871             fOutputContainer->Add(fHistPiAPCosPointAng[j]);
872             fOutputContainer->Add(fHistPiPiDecayLengthVsMass[j]);
873             fOutputContainer->Add(fHistPiPDecayLengthVsMass[j]);
874             fOutputContainer->Add(fHistPiAPDecayLengthVsMass[j]);
875             fOutputContainer->Add(fHistPiPiRadiusXY[j]);
876             fOutputContainer->Add(fHistPiPRadiusXY[j]);
877             fOutputContainer->Add(fHistPiAPRadiusXY[j]);
878             fOutputContainer->Add(fHistPiPiMonitorCuts[j]);
879             fOutputContainer->Add(fHistPiPMonitorCuts[j]);
880             fOutputContainer->Add(fHistPiAPMonitorCuts[j]);
881       
882             //others
883             fOutputContainer->Add(fHistDedxSecProt[j]);
884             fOutputContainer->Add(fHistDedxSecAProt[j]);
885             fOutputContainer->Add(fHistDedxSecPiPlus[j]);
886             fOutputContainer->Add(fHistDedxSecPiMinus[j]);
887             fOutputContainer->Add(fHistNclsITSPosK0[j]);
888             fOutputContainer->Add(fHistNclsITSNegK0[j]);
889             fOutputContainer->Add(fHistNclsTPCPosK0[j]);
890             fOutputContainer->Add(fHistNclsTPCNegK0[j]);
891             fOutputContainer->Add(fHistChi2PerNclsITSPosK0[j]);
892             fOutputContainer->Add(fHistChi2PerNclsITSNegK0[j]);
893             fOutputContainer->Add(fHistNclsITSPosL[j]);
894             fOutputContainer->Add(fHistNclsITSNegL[j]);
895             fOutputContainer->Add(fHistNclsTPCPosL[j]);
896             fOutputContainer->Add(fHistNclsTPCNegL[j]);
897             fOutputContainer->Add(fHistChi2PerNclsITSPosL[j]);
898             fOutputContainer->Add(fHistChi2PerNclsITSNegL[j]);
899             fOutputContainer->Add(fHistNclsITSPos[j]);
900             fOutputContainer->Add(fHistNclsITSNeg[j]);
901             fOutputContainer->Add(fHistNclsTPCPos[j]);
902             fOutputContainer->Add(fHistNclsTPCNeg[j]);
903             fOutputContainer->Add(fHistChi2PerNclsITSPos[j]);
904             fOutputContainer->Add(fHistChi2PerNclsITSNeg[j]);
905             fOutputContainer->Add(fHistNclsITS[j]);
906             fOutputContainer->Add(fHistNclsTPC[j]);
907             fOutputContainer->Add(fHistNCRowsTPCNeg[j]);
908             fOutputContainer->Add(fHistNCRowsTPCPos[j]);
909          }
910          if((fMCMode && fMCTruthMode) || fMCTruthMode){//MC reco or MC truth only
911             fOutputContainer->Add(fHistPiPMassVSPtSecXi[j]);
912             fOutputContainer->Add(fHistPiAPMassVSPtSecXi[j]);
913             fOutputContainer->Add(fHistPiPMassVSYSecXi[j]);
914             fOutputContainer->Add(fHistPiAPMassVSYSecXi[j]);
915             fOutputContainer->Add(fHistPiPXi0PtVSLambdaPt[j]);
916             fOutputContainer->Add(fHistPiAPXi0PtVSLambdaPt[j]);
917             fOutputContainer->Add(fHistPiPXiMinusPtVSLambdaPt[j]);
918             fOutputContainer->Add(fHistPiAPXiMinusPtVSLambdaPt[j]);
919             fOutputContainer->Add(fHistPiPMassVSPtSecSigma[j]);
920             fOutputContainer->Add(fHistPiAPMassVSPtSecSigma[j]);
921             fOutputContainer->Add(fHistPiPiEtaDMC[j]);
922             fOutputContainer->Add(fHistPiPEtaDMC[j]);
923             fOutputContainer->Add(fHistPiPiMassVSPtMCTruth[j]);
924             fOutputContainer->Add(fHistPiPMassVSPtMCTruth[j]);
925             fOutputContainer->Add(fHistPiAPMassVSPtMCTruth[j]);
926          }
927       }
928 }
929
930 //________________________________________________________________________
931 void AliAnalysisTaskV0ForRAA::UserExec(Option_t *) {
932    //user exec
933
934    //-- esd handler --//
935    AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> 
936       (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
937    if (!esdH) {
938       printf("ERROR: Could not get ESDInputHandler");
939       return;
940    } 
941    fESD = esdH->GetEvent();
942    if(!fESD) {
943       printf("ERROR: fESD not available \n");
944       return ;
945    }
946
947    //-- mc handler --//
948    if(fMCMode || fMCTruthMode){
949       AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*> 
950          (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
951       if(!mcH) {
952          printf("ERROR: Could not get MCInputHandler");
953          return;
954       }
955       fMCev = mcH->MCEvent();
956       if (!fMCev) {
957          printf("ERROR: fMCev not available \n");
958          return ;
959       }
960    }
961     
962
963    //--  AliPIDResponse --//
964    fESDpid = esdH->GetPIDResponse();
965    
966    //-- Count events before cuts --//
967    fHistNEvents->Fill(0);
968
969    //-- Check object existence --//
970    const AliESDVertex *    vtxESD    = fESD->GetPrimaryVertexTracks();
971    const AliESDVertex *    vtxESDTPC = fESD->GetPrimaryVertexTPC();  
972    const AliESDVertex *    vtxESDSPD = fESD->GetPrimaryVertexSPD();  
973    const AliMultiplicity * multESD   = fESD->GetMultiplicity();  
974
975    if ( !vtxESD ){
976       AliError("No Tracks Vertex");
977       return;
978    }
979
980    if ( !vtxESDTPC ){
981       AliError("No TPC Vertex");
982       return ;
983    }
984
985    if ( !vtxESDSPD ){
986       AliError("No SPD Vertex");
987       return ;
988    }
989
990    if ( !multESD ){
991       AliError("No Multiplicity");
992       return ;
993    }
994    
995
996    // ----------- MC vertex -----------------------------------//
997  
998    Int_t nContr =0;
999    if(fMCMode){
1000       Double_t vVertexPrim[3];
1001       fMCev->GetPrimaryVertex()->GetXYZ(vVertexPrim);
1002       fHistMCVertexZ->Fill(vVertexPrim[2]);
1003       
1004       if (vtxESD->GetStatus()){
1005          nContr=vtxESD->GetNContributors();
1006          fHistPrimVtxZESDVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1007          fHistPrimVtxZESDTPCVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1008       }
1009       else {
1010          if(vtxESDSPD->GetStatus()){
1011             nContr=vtxESDSPD->GetNContributors();
1012             fHistPrimVtxZESDTPCVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1013             fHistPrimVtxZESDSPDVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1014          }
1015          else{
1016             fHistPrimVtxZESDVSNContributorsMC->Fill(vVertexPrim[2],nContr);//add for correction ESD and ESDPSD!!!!
1017             fHistPrimVtxZESDTPCVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1018          }
1019       }
1020    }
1021   
1022    //-- Monitor event cuts --//
1023    fHistNEvents->Fill(1);
1024   
1025    // -- Check fo centrality
1026    Bool_t process = kTRUE;
1027   
1028    if(fUseCentrality) {
1029       Int_t centbin = CalculateCentralityBin();
1030       if(!fUseCentralityRange){
1031          if(centbin!= fUseCentralityBin) {process=kFALSE;}
1032       }
1033       else if(centbin< fUseCentralityBin || centbin>fUseCentralityBin+fUseCentralityRange)
1034          process = kFALSE;
1035    }
1036
1037    AliESDVZERO* esdV0 = fESD->GetVZEROData();
1038    Float_t multV0 = esdV0->GetMTotV0A() + esdV0->GetMTotV0C();
1039   
1040    if(fAnapp){// pp Analysis
1041       // SDD test for 2.76TeV pp
1042       Bool_t sdd = kFALSE;
1043       Int_t ntracks = fESD->GetNumberOfTracks();
1044       for(Int_t i=0;i<ntracks;i++){
1045          AliESDtrack *tr=   fESD->GetTrack(i);
1046       
1047          Bool_t sdd0 = tr->HasPointOnITSLayer(0);
1048          Bool_t sdd1 = tr->HasPointOnITSLayer(1);
1049          Bool_t sdd2 = tr->HasPointOnITSLayer(2);
1050          Bool_t sdd3 = tr->HasPointOnITSLayer(3);
1051          Bool_t sdd4 = tr->HasPointOnITSLayer(4);
1052          Bool_t sdd5 = tr->HasPointOnITSLayer(5);
1053        
1054          fHistITSLayerHits->Fill(Int_t(sdd0)*(-1));
1055          fHistITSLayerHits->Fill(Int_t(sdd1)*1);
1056          fHistITSLayerHits->Fill(Int_t(sdd2)*2);
1057          fHistITSLayerHits->Fill(Int_t(sdd3)*3);
1058          fHistITSLayerHits->Fill(Int_t(sdd4)*4);
1059          fHistITSLayerHits->Fill(Int_t(sdd5)*5);
1060         
1061          if(sdd2  || sdd3){
1062             sdd=kTRUE;
1063             break;
1064          }
1065       }
1066       if(sdd) fHistOneHitWithSDD->Fill(1);
1067       else fHistOneHitWithSDD->Fill(0);
1068     
1069       //select events with SDD
1070       if(fSelSDD && !sdd) return;
1071
1072       //vertex selection
1073       if (vtxESD->GetStatus()){
1074          fHistNEvents->Fill(2);
1075          fHistESDVertexZ->Fill(vtxESD->GetZv());
1076          if(fabs(vtxESD->GetZv()) < fVertexZCut){
1077             fHistMuliplicityRaw->Fill(multV0);
1078             fHistNEvents->Fill(3);
1079             fHistNPrim->Fill(nContr);
1080         
1081             Process();
1082         
1083             fHistMuliplicity->Fill(multV0);
1084         
1085             nContr = vtxESD->GetNContributors();
1086             //  if(nContr<501){
1087             fHistPrimVtxZESDVSNContributors->Fill(vtxESD->GetZv(),nContr);
1088             fHistPrimVtxZESDTPCVSNContributors->Fill(vtxESDTPC->GetZv(),nContr);
1089             //fHistPrimVtxZESDSPDVSNContributorsTPC->Fill(vtxESDSPD->GetZv(),nContr);
1090             //   }
1091             fHistPrimVtxZESD->Fill(vtxESD->GetZv());
1092             fHistPrimVtxZESDTPC->Fill(vtxESDTPC->GetZv());
1093             // fHistPrimVtxZESDSPD->Fill(vtxESDSPD->GetZv());
1094             // -- count events after processing
1095             fHistNEvents->Fill(4);
1096          }
1097       }
1098       else{
1099          if(vtxESDSPD->GetStatus()){
1100             fHistNEvents->Fill(2);
1101         
1102             fHistESDVertexZ->Fill(vtxESDSPD->GetZv());
1103             if(fabs(vtxESDSPD->GetZv()) < fVertexZCut){
1104           
1105                fHistMuliplicityRaw->Fill(multV0);
1106                fHistNEvents->Fill(3);
1107                fHistNPrim->Fill(nContr);
1108           
1109                Process();
1110           
1111                fHistMuliplicity->Fill(multV0);
1112           
1113                nContr = vtxESDSPD->GetNContributors();
1114                //  if(nContr<501){
1115                //fHistPrimVtxZESDVSNContributors->Fill(vtxESD->GetZv(),nContr);
1116                fHistPrimVtxZESDTPCVSNContributors->Fill(vtxESDTPC->GetZv(),nContr);
1117                fHistPrimVtxZESDSPDVSNContributors->Fill(vtxESDSPD->GetZv(),nContr);
1118                // }
1119                // fHistPrimVtxZESD->Fill(vtxESD->GetZv());
1120                fHistPrimVtxZESDTPC->Fill(vtxESDTPC->GetZv());
1121                fHistPrimVtxZESDSPD->Fill(vtxESDSPD->GetZv());
1122                // -- count events after processing
1123                fHistNEvents->Fill(4);
1124             }
1125          }
1126          //else return;
1127       }
1128    }
1129    else if(process){// PbPb analysis
1130       if(vtxESD->GetStatus()){
1131          Double_t vtxZ = vtxESD->GetZv();
1132          fHistNEvents->Fill(2);
1133          fHistESDVertexZ->Fill(vtxZ);
1134          if(fabs(vtxESD->GetZv()) < fVertexZCut){
1135             fHistMuliplicityRaw->Fill(multV0);
1136             fHistNEvents->Fill(3);
1137             fHistNPrim->Fill(nContr);
1138             Process();
1139             fHistMuliplicity->Fill(multV0);
1140             fHistPrimVtxZESD->Fill(vtxZ);
1141             fHistPrimVtxZESDVSNContributors->Fill(vtxZ,nContr);
1142             // -- count events after processing --//
1143             fHistNEvents->Fill(4);
1144          }
1145       }
1146    }
1147       
1148    PostData(1,fOutputContainer);
1149     
1150 }
1151
1152 //________________________________________________________________________
1153 void AliAnalysisTaskV0ForRAA::Terminate(Option_t *) {
1154    //terminate
1155 }
1156 //________________________________________________________________________
1157 void AliAnalysisTaskV0ForRAA::Process(){
1158    //run the analysis
1159
1160    Int_t ntracks = fESD->GetNumberOfTracks();
1161    Int_t count = 0;
1162
1163    //-- count number of tracks --//
1164    if(!(!fMCMode && fMCTruthMode)){
1165       for(Int_t i=0;i<ntracks;i++){
1166          AliESDtrack *track = (AliESDtrack*)fESD->GetTrack(i);
1167          if(!fESDTrackCuts->AcceptTrack(track)) continue;
1168          count++;
1169       }
1170       fHistMultiplicityPrimary->Fill(count);
1171    }
1172    
1173    //-- check number of V0s in case of data or mc data like analysis--//
1174    Int_t nV0 = fESD->GetNumberOfV0s();
1175    if(!fMCTruthMode) if(nV0 < 1) return;
1176    
1177    //-- run analysis --//
1178    if(fMCTruthMode)  V0MCTruthLoop();
1179    else  V0RecoLoop(0,0,0,0,0.0,0,0.0);
1180
1181 }
1182 //________________________________________________________________________
1183 void AliAnalysisTaskV0ForRAA::V0MCTruthLoop(){
1184    //loop over MC truth particles
1185
1186    //-- get MC stack --//
1187    AliStack *stack = fMCev->Stack();
1188
1189    /*
1190    //histo fo user defined shift in charge/pt 
1191    if(fShift){
1192    fHistUserPtShift->Fill(fDeltaInvP);
1193    }
1194    */
1195    /*
1196      AliKFVertex primVtxStart(*(fESD->GetPrimaryVertex()));
1197      Int_t nTracksPrim=primVtxStart.GetNContributors();
1198      fHistNPrim->Fill(nTracksPrim);
1199    */
1200    /*
1201    // MC
1202     
1203    Int_t mcPrimaries = stack->GetNprimary();
1204    Int_t mcParticles    = stack->GetNtrack();
1205     
1206    fHistMultiplicityPrimary->Fill(mcPrimaries);
1207    fHistMCMultiplicityTracks->Fill(mcParticles);
1208     
1209    // number of V0
1210    fHistNV0->Fill(nV0);
1211    if(nTracksPrim>0) {
1212    fHistNV0WithVertex->Fill(nV0);
1213    }
1214    */
1215
1216    //-- MC truht loop for V0s --//
1217    for (Int_t iMc = 0; iMc < (stack->GetNtrack()); iMc++){//MC truth loop    
1218       TParticle *p0 = stack->Particle(iMc);
1219       if(!p0) continue;
1220       
1221       Int_t pdgCode = p0->GetPdgCode();
1222       //-------------- only K0s and Lambda ----------//
1223       if( (pdgCode != 310 ) && ( fabs(pdgCode) != 3122 ) ) continue;
1224       if(p0->GetNDaughters() !=2) continue;
1225      
1226       //-------------- unique ID check-------------- //
1227       Int_t uniqueID =  p0->GetUniqueID();
1228       if(uniqueID==13) continue;
1229     
1230       //-------------- daughters --------------------//
1231       Int_t id0  = p0->GetDaughter(0);
1232       Int_t id1  = p0->GetDaughter(1);
1233       if(id0<0 || id1 <0) continue;
1234       Int_t pdgCodeD0 = stack->Particle(id0)->GetPdgCode();
1235       Int_t pdgCodeD1 = stack->Particle(id1)->GetPdgCode();
1236    
1237       if(pdgCodeD0 == pdgCodeD1) continue;
1238       if(pdgCodeD0*pdgCodeD1>0) continue;
1239       if((fabs(pdgCodeD0) != 211 ) && ( fabs(pdgCodeD0) != 2212 )) continue;
1240       if((fabs(pdgCodeD1) != 211 ) && ( fabs(pdgCodeD1) != 2212 )) continue;
1241   
1242       TParticle *p00 =stack->Particle(id0);
1243       TParticle *p01 =stack->Particle(id1);
1244       Double_t etaMC00   = p00->Eta();
1245       Double_t etaMC01   = p01->Eta();
1246     
1247       //----------- unique ID check daughters-------- //
1248       Int_t uniqueIDdaughter0 = p00->GetUniqueID();
1249       Int_t uniqueIDdaughter1 = p01->GetUniqueID();
1250       if (uniqueIDdaughter0 !=4 || uniqueIDdaughter1 !=4 ) continue;
1251      
1252       //----------------- mother variables-----------------//
1253       Int_t indexMother1  = p0->GetMother(0);
1254       Int_t isSecd=0;
1255       Int_t pdgMother =0;
1256       Int_t goodMother=0;
1257       Int_t uniqueIDmother=0;
1258       Double_t ptXiMother=0.0;
1259     
1260       //-----------get geometric properties --------------//
1261       // DCA of mother to prim vertex = production vertex
1262       //-- primary and secondary vetex --//
1263       Double_t vVertex[3];
1264       fMCev->GetPrimaryVertex()->GetXYZ(vVertex);
1265       //Double_t x0=p0->Vx(),y0=p0->Vy(),z0=p0->Vz();//mother production vertex
1266       Double_t x=p00->Vx(),y=p00->Vy(),z=p00->Vz();//daughter vertex =V0 decay vertex
1267
1268       //-- decay radii --//
1269       Double_t rMC2D  = sqrt(x*x+y*y);
1270       const  Double_t xyzMC[3] = {x,y,z};
1271       // Double_t rMC = p00->R();
1272       
1273       //-- phi --//
1274       Double_t pi = TMath::Pi();
1275       Double_t phi = p0->Phi();
1276       if(phi>pi) phi -=2*pi;
1277
1278       //-------------------- V0 variables ----------------//
1279       Double_t rapidity = p0->Y();
1280       Double_t massV0MC = p0->GetMass();
1281       Double_t ptV0MC =  p0->Pt();
1282       Double_t pV0MC =  p0->P();
1283
1284      
1285       
1286       //------check mother and fill mother histos---------//
1287       
1288       Bool_t isPrim= stack->IsPhysicalPrimary(iMc);
1289       
1290       if(indexMother1 >-1 && !isPrim){//secondary V0s
1291          isSecd=1;// is secondary V0s
1292          
1293          //-- check for mother --//
1294          TParticle *mother = stack->Particle(indexMother1);
1295          if(!mother) {
1296             Printf("no mother pointer!");continue;
1297          }
1298          pdgMother = mother->GetPdgCode();
1299
1300          uniqueIDmother =  mother->GetUniqueID();
1301
1302          if(uniqueIDmother==13) continue;
1303
1304
1305          //-- fill secondary V0s histos and pdg histos --// 
1306          ptXiMother=mother->Pt();
1307          
1308          //-- K0s --//
1309          if(pdgCode==310){
1310             if(fabs(pdgMother)==311 || fabs(pdgMother)==313 || fabs(pdgMother)==323 ) isSecd=0; // from K0L,  K0 and K* as primary
1311             else fHistPiPiPDGCode->Fill(fabs(pdgMother));
1312             goodMother=1;
1313          }
1314          //-- Lambda --//
1315          if(pdgCode==3122){
1316             fHistPiPPDGCode->Fill(fabs(pdgMother));
1317             if (//sigma family
1318                 ( TMath::Abs(pdgMother) == 3112) || //sigma minus
1319                 ( TMath::Abs(pdgMother) == 3222) || //sigma plus
1320                 ( TMath::Abs(pdgMother) == 3224) || //sigma *plus
1321                 ( TMath::Abs(pdgMother) == 3114) || //sigma *minus
1322                 ( TMath::Abs(pdgMother) == 3214) || //sigma *0 counts as primary????
1323                 ( TMath::Abs(pdgMother) == 3212)    //sigma 0 counts as primary
1324                 )
1325                {
1326                   isSecd=0;
1327                   goodMother=1;
1328                }
1329            
1330             if( TMath::Abs(pdgMother) == 3322) //xi0
1331                {
1332                   if(!fRapCutV0 || fabs(rapidity)<fRap){
1333                      if(!fEtaCutMCDaughters  ||  (fabs(etaMC00)<fEtaCutMCDaughtersVal|| fabs(etaMC01)<fEtaCutMCDaughtersVal)){
1334                         fHistPiPMassVSPtSecXi[0]->Fill(massV0MC,ptV0MC);
1335                         fHistPiPMassVSYSecXi[0]->Fill(massV0MC,ptV0MC);
1336                         fHistPiPXi0PtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1337                      }
1338                   }
1339                   goodMother=1;
1340                }
1341             if( TMath::Abs(pdgMother) == 3312) //xi minus
1342                {
1343                   if(!fRapCutV0 || fabs(rapidity)<fRap){
1344                      if(!fEtaCutMCDaughters  ||  (fabs(etaMC00)<fEtaCutMCDaughtersVal|| fabs(etaMC01)<fEtaCutMCDaughtersVal)){
1345                         fHistPiPMassVSPtSecXi[0]->Fill(massV0MC,ptV0MC);
1346                         fHistPiPMassVSYSecXi[0]->Fill(massV0MC,ptV0MC);
1347                         fHistPiPXiMinusPtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1348                      }
1349                   }
1350                   goodMother=1;
1351
1352                }            
1353             if(TMath::Abs(pdgMother) == 3334)//omega-
1354                {
1355                   //  fHistPiPDCAtoPrimVtxOmega[0]->Fill(p0->GetMass(),dcaV0ToPrimVertex);
1356                   goodMother=1;
1357                }
1358          }
1359          //-- AntiLambda --//
1360          if(pdgCode==-3122 ){
1361             fHistPiAPPDGCode->Fill(fabs(pdgMother));
1362             if (//sigma family
1363                 ( TMath::Abs(pdgMother) == 3112) ||//sigma minus
1364                 ( TMath::Abs(pdgMother) == 3222) ||//sigma plus
1365                 ( TMath::Abs(pdgMother) == 3224) ||//sigma *plus
1366                 ( TMath::Abs(pdgMother) == 3114) ||//sigma *minus
1367                 ( TMath::Abs(pdgMother) == 3214) || //sigma *0
1368                 ( TMath::Abs(pdgMother) == 3212)    //sigma 0 counts as primary
1369                 )
1370                {
1371                   isSecd=0;
1372                   goodMother=1;
1373                }
1374                    
1375             if( TMath::Abs(pdgMother) == 3322) //xi0
1376                {
1377                   if(!fRapCutV0 || fabs(rapidity)<fRap){
1378                      if(!fEtaCutMCDaughters  ||  (fabs(etaMC00)<fEtaCutMCDaughtersVal|| fabs(etaMC01)<fEtaCutMCDaughtersVal)){
1379                         fHistPiAPMassVSPtSecXi[0]->Fill(massV0MC,ptV0MC);
1380                         fHistPiAPMassVSYSecXi[0]->Fill(massV0MC,ptV0MC);
1381                         fHistPiAPXi0PtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1382                      }
1383                   }
1384                   goodMother=1;
1385                }
1386             if( TMath::Abs(pdgMother) == 3312) //xi minus
1387                {
1388                   if(!fRapCutV0 || fabs(rapidity)<fRap){
1389                      if(!fEtaCutMCDaughters  ||  (fabs(etaMC00)<fEtaCutMCDaughtersVal|| fabs(etaMC01)<fEtaCutMCDaughtersVal)){
1390                         fHistPiAPMassVSPtSecXi[0]->Fill(massV0MC,ptV0MC);
1391                         fHistPiAPMassVSYSecXi[0]->Fill(massV0MC,ptV0MC);
1392                         fHistPiAPXiMinusPtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1393                      }
1394                   }
1395                   goodMother=1;
1396                }
1397             if(
1398                (TMath::Abs(pdgMother) == 3334)//omega-
1399                )
1400                {
1401                   // fHistPiAPDCAtoPrimVtxOmega[0]->Fill(p0->GetMass(),dcaV0ToPrimVertex);
1402                   goodMother=1;
1403                }
1404          }
1405         
1406       }//end secondaries
1407       else goodMother=1;
1408       if(!goodMother) continue;// for (A)Lambda important
1409       
1410       //-------------- MC truth or reco mode -----------------//
1411       if(fMCTruthMode && !fMCMode){//MC true ana
1412          //-- DCA daughters --//
1413          // values of one daugher, should be the same      
1414          /*
1415          //to primary vertex
1416          trackPos->GetImpactParameters(tdcaPosToVertex[0],tdcaPosToVertex[1]);
1417          trackNeg->GetImpactParameters(tdcaNegToVertex[0],tdcaNegToVertex[1]);
1418          
1419          Double_t dcaPosToVertex = TMath::Sqrt(tdcaPosToVertex[0]*tdcaPosToVertex[0]+tdcaPosToVertex[1]*tdcaPosToVertex[1]);
1420          Double_t dcaNegToVertex = TMath::Sqrt(tdcaNegToVertex[0]*tdcaNegToVertex[0]+tdcaNegToVertex[1]*tdcaNegToVertex[1]);
1421          fHistDCADaughtersToPrimVtx[isSecd]->Fill(dcaPosToVertex,dcaNegToVertex);
1422          */
1423          
1424          
1425          //-- armenteros values --//
1426          TVector3 vecPip;
1427          TVector3 vecPin;
1428         
1429          Double_t ptPlus=0, ptMinus=0;
1430          Double_t pt00 = p00->Pt();
1431          Double_t pt01 = p01->Pt();
1432          
1433          if(p00->GetPdgCode()<0)
1434             {
1435                vecPip.SetXYZ(p01->Px(),p01->Py(),p01->Pz());
1436                vecPin.SetXYZ(p00->Px(),p00->Py(),p00->Pz());
1437                ptMinus = pt00;
1438                ptPlus = pt01;
1439             }
1440          else{
1441             vecPin.SetXYZ(p01->Px(),p01->Py(),p01->Pz());
1442             vecPip.SetXYZ(p00->Px(),p00->Py(),p00->Pz());
1443             ptMinus = pt01;
1444             ptPlus = pt00;
1445          }
1446          TVector3 momTot(p0->Px(),p0->Py(),p0->Pz());
1447          Double_t lQlNeg = fabs(vecPin.Dot(momTot)/momTot.Mag());
1448          Double_t lQlPos = fabs(vecPip.Dot(momTot)/momTot.Mag());
1449          Double_t alfa =0.0;
1450          Double_t den = lQlPos + lQlNeg;
1451          if(den>0) alfa = (lQlPos - lQlNeg)/den;
1452          TVector3 qtvec= vecPin.Cross(momTot);//vecPip.Mag()*sqrt(1-pow(thetapip,2));
1453          Float_t qt = qtvec.Mag()/momTot.Mag();
1454       
1455          //-- check for injejcted --//
1456          Bool_t injected = kTRUE;
1457          injected = fMCev->IsFromBGEvent(iMc);
1458          if(fSelectInjected && injected ) continue;
1459
1460          if(pdgCode == 310) {
1461             fHistPiPiEtaDMC[0]->Fill(etaMC00,ptV0MC);
1462             fHistPiPiEtaDMC[0]->Fill(etaMC01,ptV0MC);
1463          }
1464          if(fabs(pdgCode) == 3122) {
1465             fHistPiPEtaDMC[0]->Fill(etaMC00,ptV0MC);
1466             fHistPiPEtaDMC[0]->Fill(etaMC01,ptV0MC);
1467          }
1468
1469          //-- rapidity and eta cut --//      
1470          if(fRapCutV0 && fabs(rapidity)>fRap) continue;
1471          if(fEtaCutMCDaughters) { if(fabs(etaMC00)>fEtaCutMCDaughtersVal || fabs(etaMC01)>fEtaCutMCDaughtersVal ) continue; }
1472
1473          Double_t declength=p00->Rho();      
1474
1475          //-- Fill Particle histos --//
1476          if (pdgCode==310){//K0s
1477             fHistPiPiEtaDMC[1]->Fill(etaMC00,ptV0MC);
1478             fHistPiPiEtaDMC[1]->Fill(etaMC01,ptV0MC);
1479
1480             fHistPiPiMass[isSecd]->Fill(massV0MC);
1481             fHistPiPiMassVSPt[isSecd]->Fill(massV0MC,ptV0MC);
1482             fHistPiPiPtDaughters[isSecd]->Fill(ptMinus,ptPlus);
1483             fHistPiPiPtVSY[isSecd]->Fill(rapidity,ptV0MC);
1484            
1485             Double_t ctK0s=0.0;
1486             if(pV0MC>0.0) ctK0s=declength*0.497614/pV0MC;
1487             fHistPiPiDecayLengthVsPt[isSecd]->Fill(ptV0MC,ctK0s);
1488         
1489             //all V0s histo
1490             fHistArmenteros[isSecd]->Fill(alfa,qt);
1491             fHistV0RadiusZ[isSecd]->Fill(rMC2D,xyzMC[2]);
1492             fHistV0RadiusXY[isSecd]->Fill(xyzMC[0],xyzMC[1]);
1493             fHistV0RadiusZVSPt[isSecd]->Fill(ptV0MC,xyzMC[2]);
1494             
1495          }
1496          else if (pdgCode==3122){ //Lambda
1497             fHistPiPEtaDMC[1]->Fill(etaMC00,ptV0MC);
1498             fHistPiPEtaDMC[1]->Fill(etaMC01,ptV0MC);
1499
1500             fHistPiPMassVSPt[isSecd]->Fill(massV0MC,ptV0MC);
1501             fHistPiPMass[isSecd]->Fill(massV0MC);  
1502             fHistPiPPtDaughters[isSecd]->Fill(ptMinus,ptPlus);
1503             fHistPiPPtVSY[isSecd]->Fill(rapidity,ptV0MC);
1504            
1505             Double_t ctL=0.0;
1506             if(pV0MC>0.0) ctL=declength*1.115683/pV0MC;
1507             fHistPiPDecayLengthVsPt[isSecd]->Fill(ptV0MC,ctL);
1508
1509             //all V0s hito      
1510             fHistArmenteros[isSecd]->Fill(alfa,qt);
1511             fHistV0RadiusZ[isSecd]->Fill(rMC2D,xyzMC[2]);
1512             fHistV0RadiusXY[isSecd]->Fill(xyzMC[0],xyzMC[1]);
1513             fHistV0RadiusZVSPt[isSecd]->Fill(ptV0MC,xyzMC[2]);
1514          }
1515          else if (pdgCode==-3122){ //AntiLambda
1516             fHistPiPEtaDMC[1]->Fill(etaMC00,ptV0MC);
1517             fHistPiPEtaDMC[1]->Fill(etaMC01,ptV0MC);
1518
1519             fHistPiAPMassVSPt[isSecd]->Fill(massV0MC,ptV0MC);
1520             fHistPiAPMass[isSecd]->Fill(massV0MC);
1521             fHistPiAPPtDaughters[isSecd]->Fill(ptMinus,ptPlus);
1522             fHistPiAPPtVSY[isSecd]->Fill(rapidity,ptV0MC);
1523           
1524             Double_t ctAL=0.0;
1525             if(pV0MC>0.0) ctAL=declength*1.115683/pV0MC;
1526             fHistPiAPDecayLengthVsPt[isSecd]->Fill(ptV0MC,ctAL);
1527
1528             //all V0s histo        
1529             fHistArmenteros[isSecd]->Fill(alfa,qt);
1530             fHistV0RadiusZ[isSecd]->Fill(rMC2D,xyzMC[2]);
1531             fHistV0RadiusXY[isSecd]->Fill(xyzMC[0],xyzMC[1]);
1532             fHistV0RadiusZVSPt[isSecd]->Fill(ptV0MC,xyzMC[2]);
1533             fHistV0RadiusXYVSY[isSecd]->Fill(rapidity,rMC2D);
1534          }
1535       }//MC true ana
1536       else{// V0 reco ana
1537          V0RecoLoop(id0,id1,isSecd,pdgCode,ptV0MC,pdgMother,ptXiMother);
1538       }
1539       
1540    }//end MC stack loop
1541    
1542 }
1543 //________________________________________________________________________
1544 void AliAnalysisTaskV0ForRAA::V0RecoLoop(Int_t id0,Int_t id1,Int_t isSecd,Int_t what,Double_t ptV0MC, Int_t pdgMother,Double_t ptXiMother){
1545    //loop over reconstructed particles
1546
1547    
1548    //--------------------- define variables -----------------------//
1549    Double_t pp[3];
1550    Double_t pm[3];
1551    Double_t xr[3];
1552    
1553    Double_t massPi=0.13957018;
1554    Double_t massP=0.93827203;
1555   
1556    TLorentzVector positivesMIP;
1557    TLorentzVector negativesMIAP;
1558    TLorentzVector positivesMIPi;
1559    TLorentzVector negativesMIPi;
1560
1561    /*
1562      AliKFParticle::SetField(fESD->GetMagneticField());
1563      AliKFVertex primVtx(*(fESD->GetPrimaryVertex()));
1564      AliKFVertex primVtxImproved = primVtx;
1565
1566      AliKFParticle* negPiKF=NULL;
1567      AliKFParticle* posPiKF=NULL;
1568      AliKFParticle* posPKF=NULL;
1569      AliKFParticle* negAPKF=NULL;
1570    */
1571
1572    AliESDtrack* trackPos=NULL;
1573    AliESDtrack* trackNeg=NULL;
1574    AliESDtrack* trackPosTest = NULL;
1575    AliESDtrack* trackNegTest =NULL;
1576
1577    Float_t nSigmaTPCtrackPosToPion;
1578    Float_t nSigmaTPCtrackNegToPion;
1579    Float_t nSigmaTPCtrackPosToProton;
1580    Float_t nSigmaTPCtrackNegToProton;
1581
1582    Double_t primaryVtxPosition[3];
1583    primaryVtxPosition[0] = fESD->GetPrimaryVertex()->GetXv();
1584    primaryVtxPosition[1] = fESD->GetPrimaryVertex()->GetYv();
1585    primaryVtxPosition[2] = fESD->GetPrimaryVertex()->GetZv();
1586    
1587    Int_t nV0 = fESD->GetNumberOfV0s();
1588    AliESDv0 * v0MIs=NULL;
1589    
1590    //------------------------ V0 reco loop --------------------//
1591    for(Int_t iV0MI = 0; iV0MI < nV0; iV0MI++) {//V0 loop
1592       //-- get V0 info --//
1593       v0MIs = fESD->GetV0(iV0MI);
1594
1595       fHistPiPiMonitorCuts[isSecd]->Fill(1);
1596       fHistPiPMonitorCuts[isSecd]->Fill(1);
1597       fHistPiAPMonitorCuts[isSecd]->Fill(1);
1598
1599       //------------ get references of daughters --------------//
1600       //-- esd tracks --//
1601       trackPosTest = fESD->GetTrack(v0MIs->GetPindex());
1602       trackNegTest = fESD->GetTrack(v0MIs->GetNindex());
1603      
1604       if ( trackPosTest->GetSign() == trackNegTest->GetSign()) continue;
1605          
1606       fHistPiPiMonitorCuts[isSecd]->Fill(2);
1607       fHistPiPMonitorCuts[isSecd]->Fill(2);
1608       fHistPiAPMonitorCuts[isSecd]->Fill(2);
1609       
1610       //-- for MC mode --//
1611       if(fMCMode){
1612          //check MC labels (and find partners for MC truth V0 daughters for fMCTruthMode=kTRUE)
1613          if(!GetMCTruthPartner(trackPosTest,trackNegTest,id0,id1)) continue;
1614       }
1615
1616       fHistPiPiMonitorCuts[isSecd]->Fill(3);
1617       fHistPiPMonitorCuts[isSecd]->Fill(3);
1618       fHistPiAPMonitorCuts[isSecd]->Fill(3);
1619
1620       //-- onthefly selection --//
1621       Bool_t onthefly = v0MIs->GetOnFlyStatus();
1622       if(fOntheFly!=onthefly) continue;
1623
1624       fHistPiPiMonitorCuts[isSecd]->Fill(4);
1625       fHistPiPMonitorCuts[isSecd]->Fill(4);
1626       fHistPiAPMonitorCuts[isSecd]->Fill(4);
1627          
1628       //--  get eta from V0 daughters --//
1629       Double_t posDaughterEta=0.0;
1630       Double_t negDaughterEta=0.0;
1631       
1632       Double_t eta00 = trackPosTest->Eta();
1633       Double_t eta01 = trackNegTest->Eta();
1634             
1635       //---------- check sign assignment for daughters --------//
1636       Bool_t switchSign = kFALSE;
1637       
1638       if( trackPosTest->GetSign() >0){//pos
1639          trackPos =fESD->GetTrack(v0MIs->GetPindex());
1640          trackNeg =fESD->GetTrack(v0MIs->GetNindex());
1641
1642          v0MIs->GetPPxPyPz(pp[0],pp[1],pp[2]);
1643          v0MIs->GetNPxPyPz(pm[0],pm[1],pm[2]);
1644
1645          posDaughterEta =v0MIs->GetParamP()->Eta();
1646          negDaughterEta=v0MIs->GetParamN()->Eta();
1647       
1648          /*      
1649                  if (negPiKF) delete negPiKF; negPiKF=NULL;
1650                  if (posPiKF) delete posPiKF; posPiKF=NULL;
1651                  if (posPKF) delete posPKF; posPKF=NULL;
1652                  if (negAPKF) delete negAPKF; negAPKF=NULL;
1653
1654                  negPiKF = new AliKFParticle( *(v0MIs->GetParamN()) ,-211);
1655                  posPiKF = new AliKFParticle( *(v0MIs->GetParamP()) ,211);
1656                  posPKF = new AliKFParticle( *(v0MIs->GetParamP()) ,2212);
1657                  negAPKF = new AliKFParticle( *(v0MIs->GetParamN()) ,-2212);
1658          */
1659       }
1660       if( trackPosTest->GetSign() <0){//neg
1661          trackPos =fESD->GetTrack(v0MIs->GetNindex());
1662          trackNeg =fESD->GetTrack(v0MIs->GetPindex());
1663      
1664          v0MIs->GetNPxPyPz(pp[0],pp[1],pp[2]);
1665          v0MIs->GetPPxPyPz(pm[0],pm[1],pm[2]);
1666       
1667          posDaughterEta = v0MIs->GetParamN()->Eta();
1668          negDaughterEta = v0MIs->GetParamP()->Eta();
1669          
1670          /*
1671            if (negPiKF) delete negPiKF; negPiKF=NULL;
1672            if (posPiKF) delete posPiKF; posPiKF=NULL;
1673            if (posPKF) delete posPKF; posPKF=NULL;
1674            if (negAPKF) delete negAPKF; negAPKF=NULL;
1675
1676
1677            negPiKF = new AliKFParticle( *(v0MIs->GetParamP()) ,-211);
1678            posPiKF = new AliKFParticle( *(v0MIs->GetParamN()) ,211);
1679            posPKF = new AliKFParticle( *(v0MIs->GetParamN()) ,2212);
1680            negAPKF = new AliKFParticle( *(v0MIs->GetParamP()) ,-2212);
1681          */
1682          switchSign = kTRUE;
1683          eta01 = trackPosTest->Eta();
1684          eta00 = trackNegTest->Eta();
1685
1686       }
1687     
1688       // ------------- calc masses and 4 vectors -------------- //
1689       //K0
1690       positivesMIPi.SetXYZM(pp[0],pp[1],pp[2],massPi);
1691       negativesMIPi.SetXYZM(pm[0],pm[1],pm[2],massPi);
1692       TLorentzVector v0K0=positivesMIPi+negativesMIPi;
1693     
1694       //Lambda
1695       positivesMIP.SetXYZM(pp[0],pp[1],pp[2],massP);
1696       TLorentzVector v0Lambda=positivesMIP+negativesMIPi;
1697      
1698       //Anitlambda
1699       negativesMIAP.SetXYZM(pm[0],pm[1],pm[2],massP);
1700       TLorentzVector v0ALambda=positivesMIPi+negativesMIAP;
1701      
1702       //---------------------AliKFParticle ---------------------//
1703       /*  
1704           Double_t chi2K0C=0.0;
1705           Double_t chi2LambdaC=0.0;
1706           Double_t chi2ALambdaC=0.0;
1707
1708      
1709           AliKFParticle v0K0KF;
1710           v0K0KF +=(*negPiKF);
1711           v0K0KF +=(*posPiKF);
1712           //v0K0C.SetVtxGuess(xr[0],xr[1],xr[2]);
1713           v0K0KF.SetProductionVertex(primVtxImproved);
1714           
1715           AliKFParticle v0LambdaKF;
1716           v0LambdaKF +=(*negPiKF);
1717           v0LambdaKF +=(*posPKF);
1718           //v0LambdaC.SetVtxGuess(xr[0],xr[1],xr[2]);
1719           v0LambdaKF.SetProductionVertex(primVtxImproved);
1720           
1721           AliKFParticle v0ALambdaKF;
1722           v0ALambdaKF +=(*negAPKF);
1723           v0ALambdaKF +=(*posPiKF);
1724           //v0ALambdaC.SetVtxGuess(xr[0],xr[1],xr[2]);
1725           v0ALambdaKF.SetProductionVertex(primVtxImproved);
1726         
1727           if( v0K0KF.GetNDF() != 0) {
1728           chi2K0C = v0K0KF.GetChi2()/v0K0KF.GetNDF();
1729           }
1730
1731           Double_t chi2LambdaC=100000.;
1732           if( v0LambdaKF.GetNDF() != 0) {
1733           chi2LambdaC = v0LambdaKF.GetChi2()/v0LambdaKF.GetNDF();
1734           }
1735
1736           Double_t chi2ALambdaC=100000.;
1737           if( v0ALambdaKF.GetNDF() != 0) {
1738           chi2ALambdaC = v0ALambdaKF.GetChi2()/v0ALambdaKF.GetNDF();
1739           }
1740       */
1741     
1742       // ----------------- for MC mode ------------------------ //
1743       Bool_t fillK0sMC = kTRUE;
1744       Bool_t fillLambdaMC = kTRUE;
1745       Bool_t fillALambdaMC = kTRUE;
1746
1747       if(fMCMode && fMCTruthMode) {
1748          if(what == 310) {
1749             fillLambdaMC = kFALSE;
1750             fillALambdaMC = kFALSE;
1751          }
1752          else if(what == 3122){
1753             fillALambdaMC = kFALSE;
1754             fillK0sMC = kFALSE;
1755          }
1756          else if(what == -3122){
1757             fillLambdaMC = kFALSE;
1758             fillK0sMC = kFALSE;
1759          }
1760       }
1761    
1762       //----------------- prepare for V0 ana ------------------//
1763       TVector3 ppTrack(pp);
1764       TVector3 pmTrack(pm);
1765       
1766       Double_t posDaughterPt = ppTrack.Pt();
1767       Double_t negDaughterPt = pmTrack.Pt();
1768       /*
1769         Double_t v0sPt=v0MIs->Pt();
1770         if(what == 310 || what ==0){
1771         fHistPiPiEtaDReco[0]->Fill(posDaughterPt,v0sPt);
1772         fHistPiPiEtaDReco[0]->Fill(negDaughterPt,v0sPt);
1773         }
1774         if(fabs(what) == 3122 || what == 0){
1775         fHistPiPEtaDReco[0]->Fill(posDaughterPt,v0sPt);
1776         fHistPiPEtaDReco[0]->Fill(negDaughterPt,v0sPt);
1777         }
1778       */
1779       //------------------- DCA daughters ---------------------//
1780       //-- between the daughters --//
1781       Double_t dcaDaughters = v0MIs->GetDcaV0Daughters();  
1782     
1783       //-- to primary vertex --
1784       Double_t dcaPosToVertex=0.0,dcaNegToVertex=0.0;
1785       Double_t dzPos=(primaryVtxPosition[0]-xr[0])*ppTrack.Y() - (primaryVtxPosition[1]-xr[1])*ppTrack.X();
1786       dcaPosToVertex=TMath::Sqrt(dzPos*dzPos/(pow(ppTrack.X(),2)+pow(ppTrack.Y(),2)));
1787       Double_t dzNeg=(primaryVtxPosition[0]-xr[0])*pmTrack.Y() - (primaryVtxPosition[1]-xr[1])*pmTrack.X();
1788       dcaNegToVertex=TMath::Sqrt(dzNeg*dzNeg/(pow(pmTrack.X(),2)+pow(pmTrack.Y(),2)));
1789      
1790       // Double_t dcaPosToVertex[3];dcaNegToVertex[3];
1791       // trackPos->GetImpactParameters(dcaPosToVertex[0],dcaPosToVertex[1]);
1792       // trackNeg->GetImpactParameters(dcaNegToVertex[0],dcaNegToVertex[1]);
1793          
1794       // dcaPosToVertex = TMath::Sqrt(dcaPosToVertex[0]*dcaPosToVertex[0]+dcaPosToVertex[1]*dcaPosToVertex[1]);
1795       // dcaNegToVertex = TMath::Sqrt(dcaNegToVertex[0]*dcaNegToVertex[0]+dcaNegToVertex[1]*dcaNegToVertex[1]);
1796          
1797       //dcaPosToVertex  =   posPKF->GetDistanceFromVertexXY(primaryVtxPosition);
1798       //dcaNegToVertex  =   negPiKF->GetDistanceFromVertexXY(primaryVtxPosition);
1799         
1800       //------------------- dca and decay radius V0 -------------//
1801       v0MIs->GetXYZ(xr[0],xr[1],xr[2]);
1802        
1803       Double_t dim2V0Radius      = TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
1804
1805       Double_t decayLength =
1806          TMath::Sqrt(TMath::Power(xr[0] - primaryVtxPosition[0],2) +
1807                      TMath::Power(xr[1] - primaryVtxPosition[1],2) +
1808                      TMath::Power(xr[2] - primaryVtxPosition[2],2 ));
1809
1810       Double_t  dcaV0ToPrimVertex= v0MIs->GetD(primaryVtxPosition[0],primaryVtxPosition[1]);////v0K0KF.GetDistanceFromVertexXY(tPrimaryVtxPosition);
1811
1812       //-------------------- general cuts -------------------//
1813       //-- esd track cuts for daughters --//
1814       if(fESDTrackCuts){
1815          if(!fESDTrackCuts->AcceptTrack(trackPosTest)) continue;
1816          if(!fESDTrackCuts->AcceptTrack(trackNegTest)) continue;
1817       }
1818       
1819       fHistPiPiMonitorCuts[isSecd]->Fill(5);
1820       fHistPiPMonitorCuts[isSecd]->Fill(5);
1821       fHistPiAPMonitorCuts[isSecd]->Fill(5);
1822       
1823       //-- eta cut --//
1824       if( fabs(posDaughterEta) > fEtaCutMCDaughtersVal || fabs(negDaughterEta) > fEtaCutMCDaughtersVal) continue;
1825       fHistPiPiMonitorCuts[isSecd]->Fill(6);
1826       fHistPiPMonitorCuts[isSecd]->Fill(6);
1827       fHistPiAPMonitorCuts[isSecd]->Fill(6);
1828
1829       //-- pt cut --//
1830       if( fabs(posDaughterPt)<fMinPt || fabs(negDaughterPt) < fMinPt ) continue;
1831       fHistPiPiMonitorCuts[isSecd]->Fill(7);
1832       fHistPiPMonitorCuts[isSecd]->Fill(7);
1833       fHistPiAPMonitorCuts[isSecd]->Fill(7);
1834
1835       
1836       //-- radius xy min cut --//
1837       if(dim2V0Radius < fDecayRadXYMin) continue;
1838       //            if(fabs(xr[1])<fDecayRadY) continue;
1839       fHistPiPiMonitorCuts[isSecd]->Fill(8);
1840       fHistPiPMonitorCuts[isSecd]->Fill(8);
1841       fHistPiAPMonitorCuts[isSecd]->Fill(8);
1842
1843       //-- radius xy max cut --//
1844       if(dim2V0Radius > fDecayRadXYMax) continue;
1845       //            if(fabs(xr[1])<fDecayRadY) continue;
1846       fHistPiPiMonitorCuts[isSecd]->Fill(9);
1847       fHistPiPMonitorCuts[isSecd]->Fill(9);
1848       fHistPiAPMonitorCuts[isSecd]->Fill(9);
1849       
1850       //-- decay length min ->ctau --//
1851       //  if(decayLength<fDecayLengthMin) continue;
1852       //       fHistPiPiMonitorCuts[isSecd]->Fill(11);
1853       //       fHistPiPMonitorCuts[isSecd]->Fill(11);
1854       //       fHistPiAPMonitorCuts[isSecd]->Fill(11);
1855
1856       //-- decay length max cut --//
1857       if(decayLength>fDecayLengthMax) continue;
1858       fHistPiPiMonitorCuts[isSecd]->Fill(10);
1859       fHistPiPMonitorCuts[isSecd]->Fill(10);
1860       fHistPiAPMonitorCuts[isSecd]->Fill(10);
1861    
1862       //----------------------- V0 variables --------------------//
1863       //-- armenteros --//
1864       TVector3 momTot = ppTrack + pmTrack;
1865       Double_t lQlNeg = fabs(pmTrack.Dot(momTot)/momTot.Mag());
1866       Double_t lQlPos = fabs(ppTrack.Dot(momTot)/momTot.Mag());
1867       //return 1.-2./(1.+lQlNeg/lQlPos);
1868       Double_t alfa =0.0;
1869       Double_t den = lQlPos + lQlNeg;
1870       if(den>0) alfa = (lQlPos - lQlNeg)/den;
1871       TVector3 qtvec= pmTrack.Cross(momTot);//vecPip.Mag()*sqrt(1-pow(thetapip,2));
1872       Double_t qt = qtvec.Mag()/momTot.Mag();
1873
1874       //-- momenta --//
1875       Double_t ptK0s = v0K0.Pt();
1876       Double_t ptLambda = v0Lambda.Pt();
1877       Double_t ptALambda = v0ALambda.Pt();
1878       
1879       Double_t pK0s = v0K0.P();
1880       Double_t pLambda = v0Lambda.P();
1881       Double_t pALambda = v0ALambda.P();
1882       
1883       //-- masses --//
1884       Double_t massK0s = v0K0.M();
1885       Double_t massLambda = v0Lambda.M();
1886       Double_t massALambda = v0ALambda.M();
1887
1888       //-- rapidity --//
1889       Double_t rapK0s = v0MIs->Y(310);
1890       Double_t rapL   = v0MIs->Y(3122);
1891       Double_t rapAL  = v0MIs->Y(3122);
1892
1893       //-- other variables --//
1894       Double_t opAng =   fabs(ppTrack.Angle(pmTrack));
1895       //    if( ppTrack.Angle(pmTrack)<0.001) continue;  
1896       //    if( ppTrack.Angle(pmTrack)<0.004) continue;   
1897     
1898       Double_t cosOPAng = v0MIs->GetV0CosineOfPointingAngle();
1899     
1900       /*     
1901       //introduce more histo
1902       Double_t errOnMassK0s = v0MIs->ChangeMassHypothesis(310);
1903       Double_t errOnMassLambda = 0.0;
1904       Double_t errOnMassALambda = 0.0;
1905       if(!switchSign){
1906       errOnMassLambda  = v0MIs->ChangeMassHypothesis(3122);
1907       errOnMassALambda = v0MIs->ChangeMassHypothesis(-3122);
1908       }
1909       else{
1910       errOnMassLambda  = v0MIs->ChangeMassHypothesis(-3122);
1911       errOnMassALambda = v0MIs->ChangeMassHypothesis(3122);
1912       }
1913       */
1914
1915       
1916       //------------------------ detector values -------------------------------//
1917       //-- TPC ITS values pos --//
1918       Int_t nclsTPCPos =  trackPos->GetNcls(1);
1919       Int_t nclsTPCFindablePos =  trackPos->GetTPCNclsF();
1920       Int_t nclsITSPos =  trackPos->GetNcls(0);
1921       Double_t chi2PerClusterITSPos = -1.0;
1922       if(nclsITSPos>0) chi2PerClusterITSPos = trackPos->GetITSchi2()/Double_t(nclsITSPos);
1923       Double_t crossedRowsTPCPos = trackPos->GetTPCCrossedRows();
1924       
1925       //-- TPC ITS values neg --//
1926       Int_t nclsTPCNeg =  trackNeg->GetNcls(1);
1927       Int_t nclsTPCFindableNeg =  trackNeg->GetTPCNclsF();
1928       Int_t nclsITSNeg =  trackNeg->GetNcls(0);
1929       Double_t chi2PerClusterITSNeg = -1.0;
1930       if(nclsITSNeg>0) chi2PerClusterITSNeg =trackNeg->GetITSchi2()/Double_t(nclsITSNeg);
1931       Double_t crossedRowsTPCNeg = trackNeg->GetTPCCrossedRows();    
1932
1933       if(fMoreNclsThanRows && (crossedRowsTPCPos < nclsTPCPos || crossedRowsTPCNeg < nclsTPCNeg  )) continue;
1934       fHistPiPiMonitorCuts[isSecd]->Fill(11);
1935       fHistPiPMonitorCuts[isSecd]->Fill(11);
1936       fHistPiAPMonitorCuts[isSecd]->Fill(11);
1937       
1938       if(fMoreNclsThanFindable && (nclsTPCFindablePos < nclsTPCPos || nclsTPCFindableNeg < nclsTPCNeg  )) continue;
1939       fHistPiPiMonitorCuts[isSecd]->Fill(12);
1940       fHistPiPMonitorCuts[isSecd]->Fill(12);
1941       fHistPiAPMonitorCuts[isSecd]->Fill(12);      
1942
1943       if(chi2PerClusterITSNeg > fChi2PerClusterITS || chi2PerClusterITSPos > fChi2PerClusterITS ) continue;
1944       fHistPiPiMonitorCuts[isSecd]->Fill(13);
1945       fHistPiPMonitorCuts[isSecd]->Fill(13);
1946       fHistPiAPMonitorCuts[isSecd]->Fill(13);  
1947       
1948       //-- cut flags for V0 specific cuts --//
1949       Bool_t cutOKK0s = kTRUE;
1950       Bool_t cutOKLambda = kTRUE;
1951       Bool_t cutOKALambda = kTRUE;
1952       
1953       //-------------------------- K0 cuts -----------------------------//
1954
1955       if(dcaV0ToPrimVertex > fDCAToVertexK0) continue;
1956       if(fabs(xr[2])>fDCAZ) continue;//like decay radius z component
1957       fHistPiPiMonitorCuts[isSecd]->Fill(14);
1958       
1959       Double_t ctK0 = 0.0;
1960       if(fabs(pK0s)>0.0)  ctK0 = decayLength*0.497614/pK0s;
1961       if( ctK0 > fCtauK0s &&  fabs(ptK0s) <fCtauPtCutK0) cutOKK0s = kFALSE;
1962       else  fHistPiPiMonitorCuts[isSecd]->Fill(15);
1963       
1964       if((cosOPAng < fCosPointAngK && fabs(ptK0s) < fCPAPtCutK0) || cosOPAng<0.99) cutOKK0s = kFALSE;
1965       else  fHistPiPiMonitorCuts[isSecd]->Fill(16);
1966
1967       if(dcaDaughters > fDCADaughtersK0 )cutOKK0s = kFALSE;
1968       else  fHistPiPiMonitorCuts[isSecd]->Fill(17);
1969          
1970       if(dcaNegToVertex < fDCADaughtersToVtxSmall || dcaPosToVertex < fDCADaughtersToVtxSmall)  cutOKK0s = kFALSE;
1971       else  fHistPiPiMonitorCuts[isSecd]->Fill(18);
1972
1973       if(fRapCutV0 && fabs(rapK0s) > fRap) cutOKK0s = kFALSE;
1974       else  fHistPiPiMonitorCuts[isSecd]->Fill(19);  
1975         
1976       // if(chi2K0C > fChiCutKf) cutOKK0s = kFALSE;
1977       if(opAng < fOpengAngleDaughters)  cutOKK0s = kFALSE;
1978       else  fHistPiPiMonitorCuts[isSecd]->Fill(20);
1979
1980       Bool_t ptbinokK0s=kFALSE;
1981       if( ptK0s<6.5 && ptK0s>1.8) ptbinokK0s=kTRUE;
1982       if(fArmCutK0 && ptbinokK0s && qt<fQtCut) cutOKK0s = kFALSE;
1983       else  fHistPiPiMonitorCuts[isSecd]->Fill(21);
1984        
1985       //-------------------------- Lambda cuts -------------------------//
1986       if(dcaV0ToPrimVertex > fDCAToVertexL) continue;
1987       if(fabs(xr[2])>fDCAZ) continue;//like decay radius z component
1988       fHistPiPMonitorCuts[isSecd]->Fill(14);
1989          
1990       Double_t ctL = 0.0;
1991       if(fabs(pLambda)>0.0)  ctL = decayLength*1.115683/fabs(pLambda);
1992       if(ctL > fCtauL && fabs(ptLambda) <fCtauPtCutL)  cutOKLambda = kFALSE;
1993       else  fHistPiPMonitorCuts[isSecd]->Fill(15);
1994       
1995       if((cosOPAng<fCosPointAngL && fabs(ptLambda) < fCPAPtCutL)|| cosOPAng<0.99)  cutOKLambda = kFALSE;
1996       else fHistPiPMonitorCuts[isSecd]->Fill(16);
1997
1998       if(dcaDaughters > fDCADaughtersL )cutOKLambda = kFALSE;
1999       else  fHistPiPMonitorCuts[isSecd]->Fill(17);
2000  
2001       if( dcaNegToVertex < fDCADaughtersToVtxSmall || dcaPosToVertex < fDCADaughtersToVtxLarge)  cutOKLambda = kFALSE;
2002       else  fHistPiPMonitorCuts[isSecd]->Fill(18);
2003
2004       if(fRapCutV0 && fabs(rapL) > fRap) cutOKLambda = kFALSE;
2005       else  fHistPiPMonitorCuts[isSecd]->Fill(19);
2006       /*         
2007         if(chi2LambdaC > fChiCutKf) cutOKLambda = kFALSE;
2008         else  fHistPiPMonitorCuts[isSecd]->Fill(20);
2009       */
2010       fHistPiPMonitorCuts[isSecd]->Fill(20);
2011       
2012       if(alfa<fAlfaCut  || (fArmCutL && qt>fQtCut)) cutOKLambda = kFALSE;
2013       else  fHistPiPMonitorCuts[isSecd]->Fill(21);
2014       
2015       //--------------------------- ALambda cuts --------------------------//
2016
2017       if(dcaV0ToPrimVertex > fDCAToVertexL) continue;
2018       if(fabs(xr[2])>fDCAZ) continue;//like decay radius z component
2019       fHistPiAPMonitorCuts[isSecd]->Fill(14);
2020       
2021       Double_t ctAL = 0.0;
2022       if(fabs(pALambda)>0.0)  ctAL = decayLength*1.115683/fabs(pALambda);
2023       if(ctAL > fCtauL &&  fabs(ptALambda) <fCtauPtCutL)  cutOKALambda = kFALSE;
2024       else  fHistPiAPMonitorCuts[isSecd]->Fill(15);
2025
2026       if((cosOPAng<fCosPointAngL && fabs(ptALambda) < fCPAPtCutL)|| cosOPAng<0.99)  cutOKALambda = kFALSE;
2027       else fHistPiAPMonitorCuts[isSecd]->Fill(16);
2028       
2029       if(dcaDaughters > fDCADaughtersAL )cutOKALambda = kFALSE;
2030       else  fHistPiAPMonitorCuts[isSecd]->Fill(17);
2031          
2032       if( dcaPosToVertex < fDCADaughtersToVtxSmall || dcaNegToVertex < fDCADaughtersToVtxLarge)  cutOKALambda = kFALSE;
2033       else fHistPiAPMonitorCuts[isSecd]->Fill(18);
2034          
2035       if(fRapCutV0 && fabs(rapAL) > fRap) cutOKALambda = kFALSE;
2036       else fHistPiAPMonitorCuts[isSecd]->Fill(19);
2037       /*
2038         if(chi2ALambdaC > fChiCutKf) cutOKALambda = kFALSE;
2039         else  fHistPiAPMonitorCuts[isSecd]->Fill(20);
2040       */
2041       fHistPiAPMonitorCuts[isSecd]->Fill(20);
2042       
2043       if((fArmCutL && qt>fQtCut) || alfa > -1.0*fAlfaCut) cutOKALambda = kFALSE;
2044       else  fHistPiAPMonitorCuts[isSecd]->Fill(21);
2045       
2046       //--------------------- PID ----------------------------//
2047       //-- dEdx --//  
2048       nSigmaTPCtrackPosToPion = fabs(fESDpid->NumberOfSigmasTPC(trackPos,AliPID::kPion));
2049       nSigmaTPCtrackNegToPion = fabs(fESDpid->NumberOfSigmasTPC(trackNeg,AliPID::kPion));
2050       nSigmaTPCtrackPosToProton = fabs(fESDpid->NumberOfSigmasTPC(trackPos,AliPID::kProton));
2051       nSigmaTPCtrackNegToProton = fabs(fESDpid->NumberOfSigmasTPC(trackNeg,AliPID::kProton));
2052
2053       Bool_t pipidEdx=kTRUE;
2054       Bool_t pipdEdx =kTRUE;
2055       Bool_t piapdEdx=kTRUE;
2056
2057       Double_t posDaughterP = ppTrack.Mag();
2058       Double_t negDaughterP = pmTrack.Mag();
2059
2060       Double_t tpcsigPos= trackPos->GetTPCsignal();
2061       Double_t tpcsigNeg= trackNeg->GetTPCsignal();
2062
2063       //-- dedx cut --//
2064       if(fUsePID){
2065          //     if(fabs(posDaughterP)<fPPIDcut && nSigmaTPCtrackPosToPion > fNSigma ){
2066          //            pipidEdx =kFALSE;//k0s
2067          //     }
2068          if(fabs(posDaughterP)<fPPIDcut && tpcsigPos < 5.0){//no zero dedx values!
2069             pipidEdx =kFALSE;//k0s
2070             piapdEdx =kFALSE;//antilambda
2071          }
2072          if(fabs(posDaughterP)<fPPIDcut && (nSigmaTPCtrackPosToProton > fNSigma || tpcsigPos < 5.0)) pipdEdx =kFALSE;//lambda
2073             
2074          //     if(fabs(negDaughterP)<fPPIDcut && nSigmaTPCtrackNegToPion > fNSigma ){
2075          //         pipidEdx =kFALSE;//k0s
2076          //     }
2077          if(fabs(negDaughterP)<fPPIDcut &&  tpcsigNeg < 5.0){//no zero dedx values!
2078             pipidEdx =kFALSE;//k0s
2079             pipdEdx =kFALSE;//lambda
2080          }
2081          if(fabs(negDaughterP)<fPPIDcut && (nSigmaTPCtrackNegToProton > fNSigma || tpcsigNeg< 5.0)) piapdEdx =kFALSE;//antilambda
2082       }
2083       
2084      
2085
2086       //-------------------- V0 ana -------------------------//
2087       //-- cut flags for furhter histos--//
2088       Bool_t k0sOK=kFALSE;
2089       Bool_t lambdaOK=kFALSE;
2090       Bool_t alambdaOK=kFALSE;
2091
2092       //--  Check for K0 --//
2093       if( cutOKK0s  && fillK0sMC && pipidEdx){
2094          fHistPiPiMonitorCuts[isSecd]->Fill(22);
2095          k0sOK=kTRUE;               
2096          if(massK0s>0.25 && massK0s<0.75 ){
2097             fHistPiPiMonitorCuts[isSecd]->Fill(23);
2098             fHistPiPiMass[isSecd]->Fill(massK0s);
2099             fHistPiPiMassVSPt[isSecd]->Fill(massK0s,ptK0s);
2100             fHistPiPiMassVSPtMCTruth[isSecd]->Fill(massK0s,ptV0MC);
2101             fHistPiPiRadiusXY[isSecd]->Fill(massK0s,opAng);
2102             fHistPiPiCosPointAng[isSecd]->Fill(dcaV0ToPrimVertex,cosOPAng);
2103             fHistPiPiDecayLengthVsPt[isSecd]->Fill(ptK0s,ctK0);
2104             fHistPiPiDecayLengthVsMass[isSecd]->Fill(massK0s,ctK0);
2105             fHistPiPiDCADaughters[isSecd]->Fill(massK0s,dcaDaughters);
2106             fHistPiPiDCADaughterPosToPrimVtxVSMass[isSecd]->Fill(massK0s,dcaPosToVertex);
2107             fHistPiPiDCAVSMass[isSecd]->Fill(massK0s,dcaV0ToPrimVertex);
2108             // fHistPiPiPtDaughters[isSecd]->Fill(posDaughterPt,negDaughterPt);
2109             fHistPiPiPtVSY[isSecd]->Fill(rapK0s,ptK0s);
2110          }
2111          fHistArmenteros[isSecd]->Fill(alfa,qt);
2112          fHistDedxSecPiPlus[isSecd]->Fill(posDaughterP,tpcsigPos);
2113          fHistDedxSecPiMinus[isSecd]->Fill(negDaughterP,tpcsigNeg);
2114
2115          fHistV0RadiusZ[isSecd]->Fill(dim2V0Radius,xr[2]);
2116          fHistV0RadiusXY[isSecd]->Fill(xr[0],xr[1]);
2117          fHistV0RadiusZVSPt[isSecd]->Fill(ptK0s,dim2V0Radius);
2118          fHistV0RadiusXYVSY[isSecd]->Fill(rapK0s,dim2V0Radius);
2119
2120          //-- detector values --/
2121          fHistNclsITSPosK0[isSecd]->Fill(nclsITSPos);
2122          fHistNclsITSNegK0[isSecd]->Fill(nclsITSNeg);
2123          fHistNclsTPCPosK0[isSecd]->Fill(nclsTPCPos);
2124          fHistNclsTPCNegK0[isSecd]->Fill(nclsTPCNeg);
2125          fHistChi2PerNclsITSPosK0[isSecd]->Fill(chi2PerClusterITSPos);
2126          fHistChi2PerNclsITSNegK0[isSecd]->Fill(chi2PerClusterITSNeg);
2127       }
2128     
2129       //--  Check for Lambda --//
2130       if(cutOKLambda && fillLambdaMC && pipdEdx){
2131          fHistPiPMonitorCuts[isSecd]->Fill(22);
2132          lambdaOK=kTRUE;
2133          if( massLambda>1.05 && massLambda<1.25 ){
2134             fHistPiPMonitorCuts[isSecd]->Fill(23);
2135             fHistPiPMass[isSecd]->Fill(massLambda);
2136             fHistPiPMassVSPtMCTruth[isSecd]->Fill(massLambda,ptV0MC);
2137             fHistPiPMassVSPt[isSecd]->Fill(massLambda,ptLambda);
2138             fHistPiPRadiusXY[isSecd]->Fill(massLambda,opAng);
2139             fHistPiPCosPointAng[isSecd]->Fill(dcaV0ToPrimVertex,cosOPAng);
2140             fHistPiPPtVSY[isSecd]->Fill(rapL,ptLambda);
2141             //   fHistPiPPtDaughters[isSecd]->Fill(posDaughterPt,negDaughterPt);
2142             fHistPiPDCADaughters[isSecd]->Fill(massLambda,dcaDaughters);
2143             fHistPiPDCAVSMass[isSecd]->Fill(massLambda,dcaV0ToPrimVertex);
2144             fHistPiPDCADaughterPosToPrimVtxVSMass[isSecd]->Fill(massLambda,dcaPosToVertex);
2145             fHistPiPDecayLengthVsPt[isSecd]->Fill(ptLambda,ctL);
2146             fHistPiPDecayLengthVsMass[isSecd]->Fill(massLambda,ctL);
2147
2148             //-- secondaries --//
2149             if(isSecd==1){
2150                if(fabs(pdgMother)==3112 || fabs(pdgMother)==3114 || fabs(pdgMother)==3222 || fabs(pdgMother)==3224 || fabs(pdgMother)==3214 ){
2151                   fHistPiPMassVSPtSecSigma[1]->Fill(massLambda,ptLambda);
2152                 
2153                }
2154                //  if(pdgMother==3334){
2155                //                 fHistPiPDCAtoPrimVtxOmega[1]->Fill(massLambda,dcaV0ToPrimVertex);
2156                //              }
2157                if(pdgMother==3322){
2158                   fHistPiPCosPointAngXiVsPt->Fill(ptLambda,cosOPAng);
2159                   fHistPiPMassVSPtSecXi[1]->Fill(massLambda,ptLambda);
2160                   fHistPiPMassVSYSecXi[1]->Fill(massLambda,rapL);
2161                   fHistPiPXi0PtVSLambdaPt[1]->Fill(ptLambda,ptXiMother);
2162                }
2163                if(pdgMother==3312){
2164                   fHistPiPCosPointAngXiVsPt->Fill(ptLambda,cosOPAng);
2165                   fHistPiPMassVSPtSecXi[1]->Fill(massLambda,ptLambda);
2166                   fHistPiPMassVSYSecXi[1]->Fill(massLambda,rapL);
2167                   fHistPiPXiMinusPtVSLambdaPt[1]->Fill(ptLambda,ptXiMother);
2168                }
2169             }  
2170          }
2171          if(ptLambda>0.4) fHistArmenteros[isSecd]->Fill(alfa,qt);
2172          fHistV0RadiusZ[isSecd]->Fill(dim2V0Radius,xr[2]);
2173          fHistV0RadiusXY[isSecd]->Fill(xr[0],xr[1]);
2174          fHistV0RadiusZVSPt[isSecd]->Fill(ptLambda,dim2V0Radius);
2175          fHistV0RadiusXYVSY[isSecd]->Fill(rapL,dim2V0Radius);
2176          fHistDedxSecProt[isSecd]->Fill(posDaughterP,tpcsigPos);
2177          fHistDedxSecPiMinus[isSecd]->Fill(negDaughterP,tpcsigNeg);
2178          
2179          //-- detector values --//
2180          fHistNclsITSPosL[isSecd]->Fill(nclsITSPos);
2181          fHistNclsITSNegL[isSecd]->Fill(nclsITSNeg);
2182          fHistNclsTPCPosL[isSecd]->Fill(nclsTPCPos);
2183          fHistNclsTPCNegL[isSecd]->Fill(nclsTPCNeg);
2184          fHistChi2PerNclsITSPosL[isSecd]->Fill(chi2PerClusterITSPos);
2185          fHistChi2PerNclsITSNegL[isSecd]->Fill(chi2PerClusterITSNeg);
2186       }
2187
2188  
2189       //-- Check for AntiLambda --//
2190       if(cutOKALambda && fillALambdaMC && piapdEdx){
2191          fHistPiAPMonitorCuts[isSecd]->Fill(22);
2192          alambdaOK=kTRUE;
2193          if( massALambda>1.05 && massALambda<1.25  ){
2194             fHistPiAPMonitorCuts[isSecd]->Fill(23);
2195             fHistPiAPMass[isSecd]->Fill(massALambda);
2196             fHistPiAPMassVSPtMCTruth[isSecd]->Fill(massALambda,ptV0MC);
2197             fHistPiAPMassVSPt[isSecd]->Fill(massALambda,ptALambda);
2198             fHistPiAPRadiusXY[isSecd]->Fill(massALambda,opAng);
2199             fHistPiAPCosPointAng[isSecd]->Fill(dcaV0ToPrimVertex,cosOPAng);
2200             fHistPiAPPtVSY[isSecd]->Fill(rapAL,ptALambda);
2201             //  fHistPiAPPtDaughters[isSecd]->Fill(posDaughterPt,negDaughterPt);
2202             fHistPiAPDCADaughters[isSecd]->Fill(massALambda,dcaDaughters);
2203             fHistPiAPDCAVSMass[isSecd]->Fill(massALambda,dcaV0ToPrimVertex);
2204             fHistPiAPDCADaughterPosToPrimVtxVSMass[isSecd]->Fill(massALambda,dcaPosToVertex);
2205             fHistPiAPDecayLengthVsPt[isSecd]->Fill(ptALambda,ctAL);
2206             fHistPiAPDecayLengthVsMass[isSecd]->Fill(massALambda,ctAL);
2207
2208             //-- secondaries --//
2209             if(isSecd==1){
2210                if(fabs(pdgMother)==3112 || fabs(pdgMother)==3114 || fabs(pdgMother)==3222 || fabs(pdgMother)==3224 || fabs(pdgMother)==3214 ){
2211                   fHistPiAPMassVSPtSecSigma[1]->Fill(massALambda,ptALambda);
2212                }
2213                //  if(fabs(pdgMother)==3334){
2214                //                 fHistPiAPDCAtoPrimVtxOmega[1]->Fill(massALambda,dcaV0ToPrimVertex);
2215                //              }
2216                if(fabs(pdgMother) == 3322){
2217                   fHistPiAPCosPointAngXiVsPt->Fill(ptALambda,cosOPAng);
2218                   fHistPiAPMassVSPtSecXi[1]->Fill(massALambda,ptALambda);
2219                   fHistPiAPMassVSYSecXi[1]->Fill(massALambda,rapAL);
2220                   fHistPiAPXi0PtVSLambdaPt[1]->Fill(ptALambda,ptXiMother);
2221                }
2222                if(pdgMother == -3312){
2223                   fHistPiAPCosPointAngXiVsPt->Fill(ptALambda,cosOPAng);
2224                   fHistPiAPMassVSPtSecXi[1]->Fill(massALambda,ptALambda);
2225                   fHistPiAPMassVSYSecXi[1]->Fill(massALambda,rapAL);
2226                   fHistPiAPXiMinusPtVSLambdaPt[1]->Fill(ptALambda,ptXiMother);
2227                }
2228             }
2229          }
2230          if(ptALambda>0.4) fHistArmenteros[isSecd]->Fill(alfa,qt);
2231          fHistDedxSecAProt[isSecd]->Fill(negDaughterP,tpcsigNeg);
2232          fHistDedxSecPiPlus[isSecd]->Fill(posDaughterP,tpcsigPos);
2233          fHistV0RadiusZ[isSecd]->Fill(dim2V0Radius,xr[2]);
2234          fHistV0RadiusXY[isSecd]->Fill(xr[0],xr[1]);
2235          fHistV0RadiusZVSPt[isSecd]->Fill(ptALambda,dim2V0Radius);
2236          fHistV0RadiusXYVSY[isSecd]->Fill(rapAL,dim2V0Radius);
2237
2238       }
2239     
2240       //-- fill detector histos general --//
2241       if(lambdaOK || alambdaOK || k0sOK){
2242          //-- pos --//
2243          fHistNclsITSPos[isSecd]->Fill(fabs(posDaughterPt),nclsITSPos);
2244          fHistNclsTPCPos[isSecd]->Fill(nclsTPCFindablePos,nclsTPCPos);
2245          fHistNCRowsTPCPos[isSecd]->Fill(fabs(posDaughterPt),crossedRowsTPCPos);
2246          fHistChi2PerNclsITSPos[isSecd]->Fill(fabs(posDaughterPt),chi2PerClusterITSPos);
2247          //--neg --//
2248          fHistNclsITSNeg[isSecd]->Fill(fabs(negDaughterPt),nclsITSNeg);
2249          fHistNclsTPCNeg[isSecd]->Fill(nclsTPCFindableNeg,nclsTPCNeg);
2250          fHistNCRowsTPCNeg[isSecd]->Fill(fabs(negDaughterPt),crossedRowsTPCNeg);
2251          fHistChi2PerNclsITSNeg[isSecd]->Fill(fabs(negDaughterPt),chi2PerClusterITSNeg);
2252       
2253          fHistNclsITS[isSecd]->Fill(nclsITSPos,nclsITSNeg);
2254          //if(negDaughterPt >1.0)
2255          fHistNclsTPC[isSecd]->Fill(crossedRowsTPCNeg,nclsTPCNeg);
2256       
2257          fHistPiPiEtaDReco[1]->Fill(posDaughterEta,eta00);
2258          fHistPiPEtaDReco[1]->Fill(negDaughterEta,eta01);
2259       }
2260     
2261       /*
2262       //-- AliKFParticle --//
2263       if (negPiKF) delete negPiKF; negPiKF=NULL;
2264       if (posPiKF) delete posPiKF; posPiKF=NULL;
2265       if (posPKF) delete posPKF; posPKF=NULL;
2266       if (negAPKF) delete negAPKF; negAPKF=NULL;
2267       */
2268       if(fMCMode && fMCTruthMode) break;// otherwise we would not have ended up here
2269    }//end V0 reco loop
2270
2271 }
2272   
2273 //________________________________________________________________________
2274
2275 Int_t AliAnalysisTaskV0ForRAA::CalculateCentralityBin(){
2276    //find centrality bin for centrality selection
2277
2278    if (fUseCentrality == 0) return -1;
2279
2280    AliCentrality *esdCentrality = fESD->GetCentrality();
2281
2282    Float_t centralityVZERO  = esdCentrality->GetCentralityPercentile("V0M");  
2283    Float_t centralitySPD    = esdCentrality->GetCentralityPercentile("CL1");
2284
2285    Int_t centralityVZEROBin = -1;
2286    Int_t centralitySPDBin   = -1;
2287
2288    //-- SPD centrality --//
2289    if ( fUseCentrality == 2 ){
2290       if      ( centralitySPD >=  0. && centralitySPD <   5.) centralitySPDBin =  0;
2291       else if ( centralitySPD >=  5. && centralitySPD <  10.) centralitySPDBin =  5;
2292       else if ( centralitySPD >= 10. && centralitySPD <  20.) centralitySPDBin = 10;
2293       else if ( centralitySPD >= 20. && centralitySPD <  30.) centralitySPDBin = 20;
2294       else if ( centralitySPD >= 30. && centralitySPD <  40.) centralitySPDBin = 30;
2295       else if ( centralitySPD >= 40. && centralitySPD <  50.) centralitySPDBin = 40;
2296       else if ( centralitySPD >= 50. && centralitySPD <  60.) centralitySPDBin = 50;
2297       else if ( centralitySPD >= 60. && centralitySPD <  70.) centralitySPDBin = 60;
2298       else if ( centralitySPD >= 70. && centralitySPD <  80.) centralitySPDBin = 70;
2299       else if ( centralitySPD >= 80. && centralitySPD <  90.) centralitySPDBin = 80;
2300       else if ( centralitySPD >= 90. && centralitySPD <  99.) centralitySPDBin = 90;
2301       else if ( centralitySPD >= 99. ) centralitySPDBin = 100;
2302       else if ( fabs(centralitySPD)< 0.0001 ) centralitySPDBin = 100;
2303       return centralitySPDBin;
2304    }
2305    //-- V0 centrality --//
2306    if ( fUseCentrality == 1 ){
2307       if      ( centralityVZERO >  0. && centralityVZERO <   5.) centralityVZEROBin =  0;
2308       else if ( centralityVZERO >=  5. && centralityVZERO <  10.) centralityVZEROBin =  5;
2309       else if ( centralityVZERO >= 10. && centralityVZERO <  20.) centralityVZEROBin = 10;
2310       else if ( centralityVZERO >= 20. && centralityVZERO <  30.) centralityVZEROBin = 20;
2311       else if ( centralityVZERO >= 30. && centralityVZERO <  40.) centralityVZEROBin = 30;
2312       else if ( centralityVZERO >= 40. && centralityVZERO <  50.) centralityVZEROBin = 40;
2313       else if ( centralityVZERO >= 50. && centralityVZERO <  60.) centralityVZEROBin = 50;
2314       else if ( centralityVZERO >= 60. && centralityVZERO <  70.) centralityVZEROBin = 60;
2315       else if ( centralityVZERO >= 70. && centralityVZERO <  80.) centralityVZEROBin = 70;
2316       else if ( centralityVZERO >= 80. && centralityVZERO <  90.) centralityVZEROBin = 80;
2317       else if ( centralityVZERO >= 90. && centralityVZERO <  99.) centralityVZEROBin = 90;
2318       else if ( centralityVZERO >= 99. ) centralityVZEROBin = 100;
2319       else if ( fabs(centralityVZERO)< 0.0001 ) centralityVZEROBin = 100;
2320       return centralityVZEROBin;
2321    }
2322    return -1;
2323   
2324 }
2325 //________________________________________________________________________
2326 Bool_t  AliAnalysisTaskV0ForRAA::GetMCTruthPartner(AliESDtrack *pos,AliESDtrack *neg,Int_t id0,Int_t id1){
2327    //-- get daughter label and check it --//
2328    Int_t labelP = pos->GetLabel();
2329    Int_t labelN = neg->GetLabel();
2330    if(labelP<0 || labelN<0){
2331       return kFALSE;
2332    }
2333    if (labelN==labelP)  return kFALSE;
2334    
2335    if(fMCTruthMode){
2336       if ((labelP!=id0) && (labelP!=id1))  return kFALSE;
2337       if ((labelN!=id0) && (labelN!=id1))  return kFALSE;
2338    }
2339
2340    return kTRUE;
2341 }