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