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