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