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