f2c5bbb465d46cb8a04feddcbbfa6336ffd7f33e
[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 "TH3.h"//xxx
33 #include "TLorentzVector.h"
34
35 #include "AliAnalysisTaskSE.h"
36 #include "AliAnalysisManager.h"
37 #include "AliESDInputHandler.h"
38 #include "AliMCEventHandler.h"
39
40 #include "AliESDVZERO.h"
41 #include "AliMultiplicity.h"
42 #include "AliCentrality.h"
43
44 #include "AliKFParticle.h"
45 #include "AliKFVertex.h"
46 #include "AliESDtrackCuts.h"
47 #include "AliESDpid.h"
48 #include "AliESDv0.h"
49 #include "AliESDEvent.h"
50 #include "AliMCEvent.h"
51 #include "AliStack.h"
52 #include "AliGenEventHeader.h"
53
54
55 ClassImp(AliAnalysisTaskV0ForRAA)
56
57 //________________________________________________________________________
58 AliAnalysisTaskV0ForRAA::AliAnalysisTaskV0ForRAA(const char *name)
59 :AliAnalysisTaskSE(name),
60   fESD(0),
61   fMCev(0),
62 //other objects
63   fESDpid(0),
64   fESDTrackCuts(0),
65   fESDTrackCutsCharged(0),
66   fESDTrackCutsLowPt(0),
67   fOutputContainer(0),
68 //event histos
69   fHistITSLayerHits(0),
70   fHistOneHitWithSDD(0),
71   fHistNEvents(0),
72   fHistPrimVtxZESDVSNContributors(0),
73   fHistPrimVtxZESDTPCVSNContributors(0),
74   fHistPrimVtxZESDSPDVSNContributors(0),
75   fHistPrimVtxZESD(0),
76   fHistPrimVtxZESDTPC(0),
77   fHistPrimVtxZESDSPD(0),
78   fHistESDVertexZ(0),
79   fHistMuliplicity(0),
80   fHistMuliplicityRaw(0),
81   fHistCentBinRaw(0),
82   fHistCentBin(0),
83   fHistMultiplicityPrimary(0),
84   fHistNPrim(0),
85   fHistPiPiK0sVsLambdaMass(0),
86   fHistPiPiK0sVsALambdaMass(0),
87   fHistPiPK0sVsLambdaMass(0),
88   fHistPiAPK0sVsALambdaMass(0),
89   fHistPiPALambdaVsLambdaMass(0),
90   fHistPiAPLambdaVsALambdaMass(0),
91 //-----------K0 histos -------------------//
92   fHistPiPiMass(0),
93   fHistPiPiMassVSPt(0),
94   fHistPiPiMassVSPtMCTruth(0),
95   fHistPiPiMassVSY(0),
96   fHistPiPiPtVSY(0),
97 // fHistPiPiMassVSAlpha(0),
98   fHistPiPiRadiusXY(0),
99   fHistPiPiCosPointAng(0),
100   fHistPiPiDCADaughterPosToPrimVtxVSMass(0),  
101   fHistPiPiDecayLengthVsPt(0),
102   fHistPiPiDecayLengthVsMass(0),
103   fHistPiPiDecayLengthVsCtau(0),
104 // fHistPiPiMassVSPtK0L(0),
105   fHistPiPiDCADaughters(0), 
106 //    fHistPiPiPtDaughters(0),
107   fHistPiPiDCAVSMass(0),
108   fHistPiPiDCAZPos(0),
109   fHistPiPiDCAZNeg(0),
110   fHistPiPiTrackLengthPosVsMass(0),
111   fHistPiPiTrackLengthNegVsMass(0),  
112   fHistPiPiMonitorCuts(0),
113   fHistPiPiMonitorMCCuts(0),
114   fHistPiPiDecayLengthResolution(0),
115   fHistNclsITSPosK0(0),
116   fHistNclsITSNegK0(0),
117   fHistNclsTPCPosK0(0),
118   fHistNclsTPCNegK0(0),
119   fHistChi2PerNclsITSPosK0(0),
120   fHistChi2PerNclsITSNegK0(0),
121   fHistNCRowsTPCPosK0(0),
122   fHistNCRowsTPCNegK0(0),
123   fHistRatioFoundOverFinableTPCK0Pos(0),
124   fHistRatioFoundOverFinableTPCK0Neg(0),
125 //------------MC only histos-----------
126   fHistPrimVtxZESDVSNContributorsMC(0),
127   fHistPrimVtxZESDTPCVSNContributorsMC(0),
128   fHistPrimVtxZESDSPDVSNContributorsMC(0),
129   fHistMCVertexZ(0),
130   fHistPiPiPDGCode(0),
131   fHistPiPPDGCode(0),
132   fHistPiAPPDGCode(0),
133 //cosine of pointing angle of Xi vs pt histos
134   fHistPiPCosPointAngXiVsPt(0),
135   fHistPiAPCosPointAngXiVsPt(0),
136   fHistPiPMassVSPtSecXiMCTruth(0),
137   fHistPiPMassVSPtSecOmegaMCTruth(0),
138   fHistPiAPMassVSPtSecXiMCTruth(0),
139   fHistPiAPMassVSPtSecOmegaMCTruth(0),
140  // fHistUserPtShift(0),
141 //  fHistPiPiPhiPosVsPtPosVsMass(0),//xxx
142 //  fHistPiPPhiPosVsPtPosVsMass(0),//xxx
143 //selection booleans and values
144   fMCMode(0),
145   fMCTruthMode(0),
146   fSelectInjected(0),
147   fSelectMBMotherMC(0),
148   fCheckNegLabelReco(0),
149   fOnlyFoundRecoV0(0),
150   fUseCentrality(0),
151   fUseCentralityBin(0),
152   fUseCentralityRange(0),
153   fAnapp(0),
154   fRejectPileUpSPD(0),
155   fSelSDD(0),
156   fSelNoSDD(0),
157   fOntheFly(0),
158   fVertexZCut(0),
159   fVtxStatus(0),
160   fUsePID(0),
161   fUsePIDPion(0),
162   fNSigma(0),
163   fNSigma2(0),
164   fPPIDcut(0),
165   fPtTPCCut(0),
166   fMoreNclsThanRows(0),
167   fMoreNclsThanFindable(0),
168   fMoreNclsThanFindableMax(0),
169   fRatioFoundOverFindable(0),
170   fRatioMaxCRowsOverFindable(0),
171   fChi2PerClusterITS(0),
172   fMinNCLSITSPos(0),
173   fMinNCLSITSNeg(0),
174   fMaxNCLSITSPos(0),
175   fMaxNCLSITSNeg(0),
176   fSwitchCaseITSCls(0),
177   fCutMITrackLength(0),
178   fCutMICrossedR(0),
179   fCutMITPCncls(0),
180   fCutMITrackLengthLengthF(0),
181   fCutMICrossedRLengthF(0),
182   fRapCutV0(0),
183   fRap(0),
184   fEtaCutMCDaughters(0),
185   fEtaCutMCDaughtersVal(0),
186   fMinPt(0),
187   fAlfaCut(0),
188   fQtCut(0),
189   fQtCutPt(0),
190   fQtCutPtLow(0),
191   fArmCutK0(0),      
192   fArmCutL(0),
193   fArmQtSlope(0),
194   fExcludeLambdaFromK0s(0),
195   fExcludeK0sFromLambda(0),
196   fDCAToVertexK0(0),
197   fDCAToVertexL(0),
198   fDCAXK(0),
199   fDCAYK(0),
200   fDCAXL(0),
201   fDCAYL(0),
202   fDCAZ(0),
203   fDCADaughtersL(0),
204   fDCADaughtersAL(0),
205   fDCADaughtersK0(0),
206   fDCADaughtersToVtxLarge(0),
207   fDCADaughtersToVtxSmall(0),
208   fDecayRadXYMin(0),
209   fDecayRadXYMax(0),
210   fCosPointAngL(0),
211   fCosPointAngK(0),
212   fCPAPtCutK0(0),
213   fCPAPtCutL(0),
214   fOpengAngleDaughters(0),
215   fOpAngPtCut(0),
216   fDecayLengthMax(0),
217   fDecayLengthMin(0),
218   fDecRadCutITSMin(0),
219   fDecRadCutITSMax(0),
220   fCtauK0s(0),
221   fCtauL(0),
222   fCtauPtCutK0(0),
223   fCtauPtCutL(0),
224   fChiCutKf(0),                 
225   fK0sLowMassCut(0),
226   fK0sHighMassCut(0),
227   fLLowMassCut(0),
228   fLHighMassCut(0),
229   fSetFillDetAL(0),
230   fSetPtDepHist(0)
231   //  fShift(0),
232   // fDeltaInvP(0)
233 {  // Constructor.
234
235   DefineOutput(1,TList::Class());
236
237   // define defaults for globals
238   /*
239     fShift = kFALSE;                       // shift in charge/pt yes/no
240     fDeltaInvP = 0.00;                     // shift value
241   */
242    
243   fMCMode = kFALSE;
244   fMCTruthMode = kFALSE;
245
246   fUseCentrality = 0;
247   fUseCentralityBin = 0;
248   fUseCentralityRange =0;
249
250   fAnapp = kFALSE;
251   fRejectPileUpSPD = kFALSE;
252   fSelSDD = kFALSE;
253   fSelNoSDD= kFALSE;
254    
255   fSelectInjected = kFALSE;
256   fSelectMBMotherMC = kFALSE;
257   fCheckNegLabelReco = kFALSE;
258   fOnlyFoundRecoV0= kFALSE;
259
260   fVertexZCut = 100000.0;
261   fVtxStatus = kFALSE;
262    
263   fOntheFly = kTRUE;
264
265   //----- define defaults for V0 and track cuts ----//
266   fUsePID = kFALSE;
267   fUsePIDPion = kFALSE;
268   fMoreNclsThanRows = kFALSE;
269   fMoreNclsThanFindable = kFALSE;
270   fMoreNclsThanFindableMax = kFALSE;
271   fRatioFoundOverFindable = -1.0;
272   fRatioMaxCRowsOverFindable = 1000.0;
273
274
275   fChi2PerClusterITS = 100000.0;
276   fMinNCLSITSPos = -1;
277   fMaxNCLSITSPos = 1000;
278   fMinNCLSITSNeg = -1;
279   fMaxNCLSITSNeg = 1000;
280   fSwitchCaseITSCls = kFALSE;
281
282   fCutMITrackLength = kFALSE;
283   fCutMICrossedR    = kFALSE;
284   fCutMITPCncls     = kFALSE;
285   fCutMITrackLengthLengthF = 1.0;
286   fCutMICrossedRLengthF = 0.85;
287
288   fNSigma   = 100000.0;
289   fNSigma2  = 100000.0;
290   fPPIDcut  = 100.0;
291   fPtTPCCut = -1.0;
292
293
294   fRapCutV0=kFALSE;
295   fRap=1000.0;
296   fRap=1000.0;
297
298   fAlfaCut= -100.0;
299   fQtCut = -1.0;
300   fQtCutPt = 100.0;
301   fQtCutPtLow = -1.0;
302   fArmCutK0=kFALSE;     
303   fArmCutL=kFALSE;  
304   fArmQtSlope =0.2;
305   fExcludeLambdaFromK0s = -1.0;
306   fExcludeK0sFromLambda = -1.0;
307
308   fEtaCutMCDaughters = kFALSE;
309   fEtaCutMCDaughtersVal = 50.0;
310
311   fMinPt= -1.0;
312
313   fDCAToVertexK0 = 10000.0;
314   fDCAToVertexL = 10000.0;
315   fDCAXK=10000.0;
316   fDCAYK=10000.0;
317   fDCAXL=10000.0;
318   fDCAYL=10000.0;
319   fDCAZ=10000.0;
320    
321   fDCADaughtersL=10000.0;
322   fDCADaughtersAL=10000.0;
323   fDCADaughtersK0=10000.0;
324
325   fDCADaughtersToVtxLarge=-1.0;
326   fDCADaughtersToVtxSmall=-1.0;
327
328   fDecayRadXYMin=-100000.0;
329   fDecayRadXYMax=1000000.0;
330   fDecayLengthMax=100000.0;
331   fDecayLengthMin=-1000000.0;
332    
333   fDecRadCutITSMin = 0.0000;
334   fDecRadCutITSMax = 10000.0;
335
336   fCosPointAngL=-1.0;
337   fCosPointAngK=-1.0;
338   fCPAPtCutK0 = 1000.0;
339   fCPAPtCutL =1000.0;
340   fOpengAngleDaughters = -1.0;
341   fOpAngPtCut = -1.0;
342       
343   fCtauK0s=10e6;
344   fCtauL=10e6;
345   fCtauPtCutK0=10e6;
346   fCtauPtCutL=10e6;
347
348   fChiCutKf=1000000.0;
349
350   fK0sLowMassCut  = 0.25;
351   fK0sHighMassCut = 0.75;
352
353   fLLowMassCut  = 1.05;
354   fLHighMassCut = 1.25;
355
356
357   fSetFillDetAL = kFALSE;
358
359   fSetPtDepHist=kFALSE;
360
361   //---- histograms ----//
362   for(Int_t j=0;j<2;j++){
363     fHistArmenteros[j]=NULL;
364     fHistV0RadiusZ[j] =NULL;
365     fHistV0RadiusZVSPt[j] =NULL;
366     fHistV0RadiusXY[j] =NULL;
367     fHistV0RadiusXYVSY[j] =NULL;
368          
369     //Lambda
370     fHistPiPMass[j]=NULL;
371     fHistPiPMassVSPt[j]=NULL;
372     fHistPiPMassVSY[j] = NULL;
373     fHistPiPMassVSPtMCTruth[j]=NULL;
374     fHistPiPRadiusXY[j]=NULL;
375     fHistPiPCosPointAng[j]=NULL;
376     fHistPiPDecayLengthVsPt[j]=NULL;
377     fHistPiPDecayLengthVsMass[j]=NULL;
378     fHistPiPDecayLengthVsCtau[j]=NULL;
379     fHistPiPDCADaughterPosToPrimVtxVSMass[j]=NULL;
380     fHistPiPDCADaughterNegToPrimVtxVSMass[j]=NULL;
381     fHistPiPMassVSPtSecSigma[j]=NULL;
382     fHistPiPMassVSPtSecXi[j]=NULL;
383     fHistPiPMassVSPtSecOmega[j]=NULL;
384     fHistPiPMassVSYSecXi[j]=NULL;
385     fHistPiPXi0PtVSLambdaPt[j]=NULL;
386     fHistPiPXiMinusPtVSLambdaPt[j]=NULL;
387     fHistPiPOmegaPtVSLambdaPt[j]=NULL;
388     fHistPiPDCADaughters[j]=NULL;
389     //  fHistPiPPtDaughters[j]=NULL;
390     fHistPiPPtVSY[j]=NULL;
391     fHistPiPDCAVSMass[j]=NULL;
392     fHistPiPMonitorCuts[j] =NULL;
393     fHistPiPMonitorMCCuts[j] =NULL;
394     fHistPiPDecayLengthResolution[j] =NULL;
395     //    fHistPiPDCAZPos[j] =NULL;
396     //fHistPiPDCAZNeg[j] =NULL;
397     fHistPiPTrackLengthPosVsMass[j] = NULL;
398     fHistPiPTrackLengthNegVsMass[j] = NULL;
399
400     //ALambda
401     fHistPiAPMass[j]=NULL;
402     fHistPiAPMassVSPt[j]=NULL;
403     fHistPiAPMassVSY[j] = NULL;
404     fHistPiAPMassVSPtMCTruth[j]=NULL;
405     fHistPiAPRadiusXY[j]=NULL;
406     fHistPiAPCosPointAng[j]=NULL;
407     fHistPiAPDecayLengthVsPt[j]=NULL;
408     fHistPiAPDecayLengthVsMass[j]=NULL;
409     fHistPiAPDecayLengthVsCtau[j]=NULL;
410     fHistPiAPDCADaughterPosToPrimVtxVSMass[j]=NULL;
411     fHistPiAPDCADaughterNegToPrimVtxVSMass[j]=NULL;
412     fHistPiAPMassVSPtSecSigma[j]=NULL;
413     fHistPiAPMassVSPtSecXi[j]=NULL;
414     fHistPiAPMassVSPtSecOmega[j]=NULL;
415     fHistPiAPMassVSYSecXi[j]=NULL;
416     fHistPiAPXi0PtVSLambdaPt[j]=NULL;
417     fHistPiAPXiMinusPtVSLambdaPt[j]=NULL;
418     fHistPiAPOmegaPtVSLambdaPt[j] =NULL;
419     fHistPiAPDCADaughters[j]=NULL;
420     // fHistPiAPPtDaughters[j]=NULL;
421     fHistPiAPPtVSY[j]=NULL;
422     fHistPiAPDCAVSMass[j]=NULL;
423     fHistPiAPMonitorCuts[j] =NULL;
424     fHistPiAPMonitorMCCuts[j] =NULL;
425     fHistPiAPDecayLengthResolution[j] =NULL;
426     //    fHistPiAPDCAZPos[j] =NULL;
427     //fHistPiAPDCAZNeg[j] =NULL;
428     fHistPiAPTrackLengthPosVsMass[j] = NULL;
429     fHistPiAPTrackLengthNegVsMass[j] = NULL;
430
431     //other 
432     fHistDedxSecProt[j]=NULL;
433     fHistDedxSecAProt[j]=NULL;
434     fHistDedxSecPiMinus[j]=NULL;
435     fHistDedxSecPiPlus[j]=NULL;
436     fHistDedxProt[j]=NULL;
437     fHistDedxAProt[j]=NULL;
438     fHistDedxPiMinus[j]=NULL;
439     fHistDedxPiPlus[j]=NULL;
440     fHistNclsITS[j]=NULL;
441     fHistNclsTPC[j]=NULL;
442     fHistNclsITSPosL[j]=NULL;
443     fHistNclsITSNegL[j]=NULL;
444     fHistNclsTPCPosL[j]=NULL;
445     fHistNclsTPCNegL[j]=NULL;
446     fHistChi2PerNclsITSPosL[j]=NULL;
447     fHistChi2PerNclsITSNegL[j]=NULL;
448     fHistNCRowsTPCPosL[j]=NULL;
449     fHistNCRowsTPCNegL[j]=NULL;
450     fHistRatioFoundOverFinableTPCLPos[j]=NULL;
451     fHistRatioFoundOverFinableTPCLNeg[j]=NULL;
452     fHistPiPiEtaDMC[j] = NULL;
453     fHistPiPiEtaDReco[j] = NULL;
454     fHistPiPEtaDMC[j] = NULL;
455     fHistPiPEtaDReco[j] = NULL;
456   }
457    
458 }
459 //_____________________________________________________
460 AliAnalysisTaskV0ForRAA::~AliAnalysisTaskV0ForRAA()
461 {
462   //---- Remove all pointers ----//
463   if(fOutputContainer) delete fOutputContainer;fOutputContainer=0;
464   if(fESDTrackCuts) delete fESDTrackCuts;fESDTrackCuts=0;
465   if(fESDTrackCutsCharged) delete fESDTrackCutsCharged;fESDTrackCutsCharged=0;
466   if(fESDTrackCutsLowPt) delete fESDTrackCutsLowPt; fESDTrackCutsLowPt=0;
467 }
468 //________________________________________________________________________
469 void AliAnalysisTaskV0ForRAA::UserCreateOutputObjects(){
470   //create output objects
471
472   Int_t nbPt=800;
473   Int_t nbMass=500;
474
475    
476   //-----------------  create output container -----------------//
477
478   fOutputContainer = new TList() ;
479   fOutputContainer->SetName(GetName()) ;
480   fOutputContainer->SetOwner();
481   
482   Int_t mchist = 1;// for Data
483   if((fMCMode && fMCTruthMode) || fMCTruthMode) mchist = 2;
484         
485
486   //------------ create allways -----------------------//
487   fHistNEvents = new TH1F("fHistNEvents","no of events before cuts =0, after cuts=1, after process =2",5,0.0,5.0);
488   fOutputContainer->Add(fHistNEvents);
489       
490   fHistMuliplicity =  new TH1F("fHistMuliplicity","V0 multiplicity",3000,0.0,30000);
491   fOutputContainer->Add(fHistMuliplicity);
492       
493   fHistMuliplicityRaw =  new TH1F("fHistMuliplicityRaw","V0 multiplicity before process",3000,0.0,30000);      
494   fOutputContainer->Add(fHistMuliplicityRaw);
495       
496   fHistMultiplicityPrimary = new TH1F("fHistMultiplicityPrimary","number of charged tracks",5000,0.0,20000);
497   fOutputContainer->Add(fHistMultiplicityPrimary);
498       
499   fHistESDVertexZ= new TH1F("fHistESDVertexZ"," z vertex distr in cm",500,-50,50);
500   fOutputContainer->Add(fHistESDVertexZ);
501    
502   fHistPrimVtxZESD = new TH1F("fHistPrimVtxZESD","z vertex pos ESD",250,-50,50);
503   fOutputContainer->Add(fHistPrimVtxZESD);
504       
505   fHistPrimVtxZESDVSNContributors = new TH2F("fHistPrimVtxZESDVSNContributors","prim vtx pos z ESD vs no. of contributers TPC",250,-50,50,500,0.0,500.0);
506   fOutputContainer->Add(fHistPrimVtxZESDVSNContributors);
507       
508   fHistNPrim = new TH1F("fHistNPrim","Number of contributers to vertex",2500,0.0,5000);
509   fOutputContainer->Add(fHistNPrim);
510  
511   //------------------------ pp analysis only -------------------------//
512   if(fAnapp){
513     fHistITSLayerHits = new TH1F("fHistITSLayerHits","SDD layer -1=0,1=1,2=2 ... 5=5,0=nothing",7,-1.5,5.5);
514     fOutputContainer->Add(fHistITSLayerHits);
515     fHistOneHitWithSDD = new TH1F("fHistOneHitWithSDD","min one hit in SDD",2,-0.5,1.5);
516     fOutputContainer->Add(fHistOneHitWithSDD);
517     fHistPrimVtxZESDTPC = new TH1F("fHistPrimVtxZESDTPC","z vertex pos TPC",250,-50,50);
518     fOutputContainer->Add(fHistPrimVtxZESDTPC);
519     fHistPrimVtxZESDSPD = new TH1F("fHistPrimVtxZESDSPD","z vertex pos SPD",250,-50,50);
520     fOutputContainer->Add(fHistPrimVtxZESDSPD);  
521     fHistPrimVtxZESDTPCVSNContributors = new TH2F("fHistPrimVtxZESDTPCVSNContributors","prim vtx pos z TPC vs no. of contributers TPC",250,-50,50,500,0.0,500.0);
522     fOutputContainer->Add(fHistPrimVtxZESDTPCVSNContributors);
523     fHistPrimVtxZESDSPDVSNContributors = new TH2F("fHistPrimVtxZESDSPDVSNContributors","prim vtx pos z SPD vs no. of contributers TPC",250,-50,50,500,0.0,500.0);
524     fOutputContainer->Add(fHistPrimVtxZESDSPDVSNContributors);
525
526   }
527   else {
528     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};
529     fHistCentBinRaw = new TH1F("fHistCentBinRaw","centrality bin before cent selection",11,binsCent);
530     fOutputContainer->Add(fHistCentBinRaw);
531     fHistCentBin = new TH1F("fHistCentBin","centrality bin",11,binsCent);
532     fOutputContainer->Add(fHistCentBin);
533       
534   }
535    
536   // ------------------- add always ---------------------------//
537   fHistV0RadiusZ[0]  = new TH2F("fHistV0RadiusZ","z of decay radius vs 2D radius",100,0.0,100.0,250,-125.0,125.0);
538   fHistV0RadiusZVSPt[0]  = new TH2F("fHistV0RadiusZVSPt","z of decay radius vs pt radius",200,0.0,20.0,125,0.0,125.0);
539   fHistV0RadiusXY[0]  = new TH2F("fHistV0RadiusXY","y vs x decay radius",250,-125.0,125.0,250,-125.0,125.0);
540   fHistV0RadiusXYVSY[0]  = new TH2F("fHistV0RadiusXYVSY","2D decay radius vs rap",100,-1,1,100,0.0,100.0);
541   fHistArmenteros[0] = new TH2F("fHistArmenteros"," pi+pi- armenteros",nbMass,-1.,1.,500,0.,0.5);
542
543   // fHistPiPiPhiPosVsPtPosVsMass = new TH3F("fHistPiPiPhiPosVsPtPosVsMass","ctau K0s vs pt vs mass",250,0.25,0.75,440,0.0,110.0,200,0.0,20.0);//4.0);//xxx
544   //  fHistPiPPhiPosVsPtPosVsMass  = new TH3F("fHistPiPPhiPosVsPtPosVsMass","ctau L vs pt vs mass",250,0.25,0.75,440,0.0,110.0,200,0.0,20.0);//4.0);//xxx
545   fHistPiPiK0sVsLambdaMass  = new TH2F("fHistPiPiK0sVsLambdaMass","K0s mass vs Lambda mass for all pt for K0s",250,1.05,1.25,250,0.25,0.75);
546   fHistPiPiK0sVsALambdaMass = new TH2F("fHistPiPiK0sVsALambdaMass","K0s mass vs ALambda mass for all pt for K0s",250,1.05,1.25,250,0.25,0.75);
547
548   fHistPiPK0sVsLambdaMass   = new TH2F("fHistPiPK0sVsLambdaMass","K0s mass vs Lambda mass for all pt for Lambda",250,1.05,1.25,250,0.25,0.75);
549
550   fHistPiAPK0sVsALambdaMass = new TH2F("fHistPiAPK0sVsALambdaMass","K0s mass vs ALambda mass for all pt for ALambda",250,1.05,1.25,250,0.25,0.75);
551
552   fHistPiPALambdaVsLambdaMass  = new TH2F("fHistPiPALambdaVsLambdaMass","ALambda mass vs Lambda mass for Lambda",250,1.05,1.25,250,1.05,1.25);
553   fHistPiAPLambdaVsALambdaMass = new TH2F("fHistPiAPLambdaVsALambdaMass","Lambda mass vs ALambda mass for ALambda",250,1.05,1.25,250,1.05,1.25);
554
555   //-----K0s
556   fHistPiPiMass = new TH1F("fHistPiPiMass"," pi+pi- InvMass distribution",2*nbMass,0.,2.);
557   fHistPiPiMassVSPt = new TH2F("fHistPiPiMassVSPt","pi+pi- InvMass distribution",nbMass,0.25,0.75,300,0.0,30.0);
558   fHistPiPiMassVSPtMCTruth = new TH2F("fHistPiPiMassVSPtMCTruth","pi+pi- InvMass distribution vs pt MCTruth",nbMass,0.25,0.75,300,0.0,30.0);
559   fHistPiPiMassVSY = new TH2F("fHistPiPiMassVSY","pi+pi- InvMass distribution vs rapidity",nbMass,0.25,0.75,200,-1.0,1.0);
560   fHistPiPiPtVSY = new TH2F("fHistPiPiPtVSY","phi vs mass",100,-1,1,100,0.0,20);
561   fHistPiPiDecayLengthVsPt = new TH2F("fHistPiPiDecayLengthVsPt","K0 decay length vs pt",200,0.0,20.0,220,0.0,110.0);
562   fHistPiPiDecayLengthVsMass = new TH2F("fHistPiPiDecayLengthVsMass","K0s decay length vs mass",nbMass,0.25,0.75,220,0.0,110.0);  
563   if(!fSetPtDepHist){
564     fHistPiPiDecayLengthVsCtau = new TH2F("fHistPiPiDecayLengthVsCtau","K0s ctau vs mass",nbMass,0.25,0.75,250,0.0,50.0);
565   }
566     else{
567       fHistPiPiDecayLengthVsCtau = new TH2F("fHistPiPiDecayLengthVsCtau","K0s ctau vs pt",200,0,20.0,250,0.0,50.0);
568     } 
569   
570     fHistPiPiMonitorCuts = new TH1F("fHistPiPiMonitorCuts","K0 cut monitor",35,0.5,35.5);
571     fHistPiPiMonitorMCCuts = new TH1F("fHistPiPiMonitorMCCuts","K0 cut monitor mc",35,0.5,35.5);
572   
573     //---------------Lambda
574     fHistPiPMass[0] = new TH1F("fHistPiPMass"," p+pi- InvMass distribution",2*nbMass,0.,2.);
575     fHistPiPMassVSPt[0] = new TH2F("fHistPiPMassVSPt","p+pi- InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
576     fHistPiPMassVSPtMCTruth[0] = new TH2F("fHistPiPMassVSPtMCTruth","p+pi- InvMass distribution vs pt MCTruth",nbMass,1.05,1.25,300,0.0,30.0);
577     fHistPiPMassVSY[0] = new TH2F("fHistPiPMassVSY","p+pi- InvMass distribution vs rapidity",nbMass,1.05,1.25,200,-1.0,1.0);
578     fHistPiPPtVSY[0] = new TH2F("fHistPiPPtVSY","p{t} vs y",100,-1,1,100,0.0,20);
579     fHistPiPDecayLengthVsPt[0] = new TH2F("fHistPiPDecayLengthVsPt","#Lambda decay length vs pt",200,0.0,20.0,220,0.0,110.0);
580     fHistPiPDecayLengthVsMass[0] = new TH2F("fHistPiPDecayLengthVsMass","#Lambda decay length vs mass",nbMass,1.05,1.25,220,0.0,110.0);
581     if(!fSetPtDepHist){
582       fHistPiPDecayLengthVsCtau[0] = new TH2F("fHistPiPDecayLengthVsCtau","L ctau vs mass",nbMass,1.05,1.25,250,0.0,50.0);
583     }
584     else{
585       fHistPiPDecayLengthVsCtau[0] = new TH2F("fHistPiPDecayLengthVsCtau","L ctau vs pt",200,0.0,20.0,250,0.0,50.0);
586     }
587     fHistPiPMonitorCuts[0] = new TH1F("fHistPiPMonitorCuts","#Lambda cut monitor",35,0.5,35.5);
588     fHistPiPMonitorMCCuts[0] = new TH1F("fHistPiPMonitorMCCuts","#Lambda cut monitor mc ",35,0.5,35.5);
589   
590     //-------------ALamda
591     fHistPiAPMass[0] = new TH1F("fHistPiAPMass"," ap-pi+ InvMass distribution",2*nbMass,0.,2.);
592     fHistPiAPMassVSPt[0] = new TH2F("fHistPiAPMassVSPt","p-pi+ InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
593     fHistPiAPMassVSPtMCTruth[0] = new TH2F("fHistPiAPMassVSPtMCTruth","p-pi+ InvMass distribution vs pt MCTruth",nbMass,1.05,1.25,300,0.0,30.0);
594     fHistPiAPMassVSY[0] = new TH2F("fHistPiAPMassVSY","p-pi+ InvMass distribution vs rapidity",nbMass,1.05,1.25,200,-1.0,1.0);
595     fHistPiAPPtVSY[0] = new TH2F("fHistPiAPPtVSY","p{t} vs y",100,-1,1,100,0.0,20);
596     fHistPiAPDecayLengthVsPt[0] = new TH2F("fHistPiAPDecayLengthVsPt","#bar{#Lambda} decay length vs pt",200,0.0,20.0,220,0.0,110.0);
597     fHistPiAPDecayLengthVsMass[0] = new TH2F("fHistPiAPDecayLengthVsMass","#bar{#Lambda} decay length vs mass",nbMass,1.05,1.25,220,0.0,110.0);
598     if(!fSetPtDepHist){
599       fHistPiAPDecayLengthVsCtau[0] = new TH2F("fHistPiAPDecayLengthVsCtau","AL ctau vs mass",nbMass,1.05,1.25,250,0.0,50.0);
600     }
601     else{
602       fHistPiAPDecayLengthVsCtau[0] = new TH2F("fHistPiAPDecayLengthVsCtau","AL ctau vs pt",200,0.0,20.0,250,0.0,50.0);
603     }
604     fHistPiAPMonitorCuts[0] = new TH1F("fHistPiAPMonitorCuts","#bar{#Lambda} cut monitor",35,0.5,35.5);
605     fHistPiAPMonitorMCCuts[0] = new TH1F("fHistPiAPMonitorMCCuts","#bar{#Lambda} cut monitor mc",35,0.5,35.5);   
606
607     // ---------------------------------------------for MC reco secondaries -----------------------------------------//
608     if(mchist==2){
609       fHistV0RadiusZ[1]  = new TH2F("fHistV0RadiusZSec","z of decay radius vs 2D radius",100,0.0,100.0,250,-125.0,125.0);
610       fHistV0RadiusZVSPt[1]  = new TH2F("fHistV0RadiusZVSPtSec","z of decay radius vs pt radius",200,0.0,20.0,125,0.0,125.0);
611       fHistV0RadiusXY[1]  = new TH2F("fHistV0RadiusXYSec","y vs x decay radius",250,-125.0,125.0,250,-125.0,125.0);
612       fHistV0RadiusXYVSY[1]  = new TH2F("fHistV0RadiusXYVSYSec","2D decay radius vs rap",100,-1,1,100,0.0,100.0);
613       fHistArmenteros[1] = new TH2F("fHistArmenterosSec"," pi+pi- armenteros",nbMass,-1.,1.,500,0.,0.5);
614
615       //K0s
616       //--------------- Lambda
617       fHistPiPMass[1] = new TH1F("fHistPiPMassSec"," p+pi- InvMass distribution",2*nbMass,0.,2.);
618       fHistPiPMassVSPt[1] = new TH2F("fHistPiPMassVSPtSec","p+pi- InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
619       fHistPiPMassVSPtMCTruth[1] = new TH2F("fHistPiPMassVSPtMCTruthSec","p+pi- InvMass distribution vs pt MCTruth",nbMass,1.05,1.25,300,0.0,30.0);
620       fHistPiPMassVSY[1] = new TH2F("fHistPiPMassVSYSec","p+pi- InvMass distribution vs rapidity",nbMass,1.05,1.25,200,-1.0,1.0);   
621       fHistPiPPtVSY[1] = new TH2F("fHistPiPPtVSYSec","p{t} vs y",100,-1,1,100,0.0,20);
622       fHistPiPDecayLengthVsPt[1] = new TH2F("fHistPiPDecayLengthVsPtSec","#Lambda decay length vs pt",200,0.0,20.0,220,0.0,110.0);
623       fHistPiPDecayLengthVsMass[1] = new TH2F("fHistPiPDecayLengthVsMassSec","#Lambda decay length vs mass",nbMass,1.05,1.25,220,0.0,110.0);
624       if(!fSetPtDepHist){
625         fHistPiPDecayLengthVsCtau[1] = new TH2F("fHistPiPDecayLengthVsCtauSec","L ctau vs mass",nbMass,1.05,1.25,250,0.0,50.0);
626       }
627       else{
628         fHistPiPDecayLengthVsCtau[1] = new TH2F("fHistPiPDecayLengthVsCtauSec","L ctau vs pt",200,0.0,20.0,250,0.0,50.0);
629       }
630       fHistPiPMonitorCuts[1] = new TH1F("fHistPiPMonitorCutsSec","#Lambda cut monitor",35,0.5,35.5);
631       fHistPiPMonitorMCCuts[1] = new TH1F("fHistPiPMonitorMCCutsSec","#Lambda cut monitor mc",35,0.5,35.5);
632
633       //----------------ALambda
634       fHistPiAPMass[1] = new TH1F("fHistPiAPMassSec"," ap-pi+ InvMass distribution",2*nbMass,0.,2.);
635       fHistPiAPMassVSPt[1] = new TH2F("fHistPiAPMassVSPtSec","p-pi+ InvMass distribution",nbMass,1.05,1.25,300,0.0,30.0);
636       fHistPiAPMassVSPtMCTruth[1] = new TH2F("fHistPiAPMassVSPtMCTruthSec","p-pi+ InvMass distribution vs pt MCTruth",nbMass,1.05,1.25,300,0.0,30.0);
637       fHistPiAPMassVSY[1] = new TH2F("fHistPiAPMassVSYSec","p-pi+ InvMass distribution vs rapidity",nbMass,1.05,1.25,200,-1.0,1.0);
638       fHistPiAPPtVSY[1] = new TH2F("fHistPiAPPtVSYSec","p{t} vs y",100,-1,1,100,0.0,20);
639       fHistPiAPDecayLengthVsPt[1] = new TH2F("fHistPiAPDecayLengthVsPtSec","#bar{#Lambda} decay length vs pt",200,0.0,20.0,220,0.0,110.0);
640       fHistPiAPDecayLengthVsMass[1] = new TH2F("fHistPiAPDecayLengthVsMassSec","#bar{#Lambda} decay length vs mass",nbMass,1.05,1.25,220,0.0,110.0);
641       if(!fSetPtDepHist){
642         fHistPiAPDecayLengthVsCtau[1] = new TH2F("fHistPiAPDecayLengthVsCtauSec","AL ctau vs mass",nbMass,1.05,1.25,250,0.0,50.0);
643       }
644       else{
645         fHistPiAPDecayLengthVsCtau[1] = new TH2F("fHistPiAPDecayLengthVsCtauSec","AL ctau vs pt",200,0.0,20.0,250,0.0,50.0);
646       }
647
648       fHistPiAPMonitorCuts[1] = new TH1F("fHistPiAPMonitorCutsSec","#bar{#Lambda} cut monitor",35,0.5,35.5);
649       fHistPiAPMonitorMCCuts[1] = new TH1F("fHistPiAPMonitorMCCutsSec","#bar{#Lambda} cut monitor mc",35,0.5,35.5);
650     }
651
652     //add
653     //------------ K0s ------------------
654     fOutputContainer->Add(fHistPiPiMass);        
655     fOutputContainer->Add(fHistPiPiMassVSPt);
656     fOutputContainer->Add(fHistPiPiMassVSPtMCTruth);
657     fOutputContainer->Add(fHistPiPiMassVSY);
658     fOutputContainer->Add(fHistPiPiPtVSY);
659     fOutputContainer->Add(fHistPiPiDecayLengthVsPt);
660     fOutputContainer->Add(fHistPiPiDecayLengthVsCtau);
661     fOutputContainer->Add(fHistPiPiDecayLengthVsMass);  
662     fOutputContainer->Add(fHistPiPiMonitorCuts);
663     fOutputContainer->Add(fHistPiPiMonitorMCCuts);
664     fOutputContainer->Add(fHistPiPiK0sVsLambdaMass);
665     fOutputContainer->Add(fHistPiPiK0sVsALambdaMass);
666     // fOutputContainer->Add(fHistPiPiPhiPosVsPtPosVsMass);//xxx
667
668     // --------------- Lambda ---------------
669     fOutputContainer->Add(fHistPiPK0sVsLambdaMass);
670     fOutputContainer->Add(fHistPiPALambdaVsLambdaMass);
671     // fOutputContainer->Add(fHistPiPPhiPosVsPtPosVsMass);//xxx
672
673     // --------------- ALambda ---------------
674     fOutputContainer->Add(fHistPiAPK0sVsALambdaMass);
675     fOutputContainer->Add(fHistPiAPLambdaVsALambdaMass);
676
677   
678     for(Int_t j=0;j<mchist;j++){
679       fOutputContainer->Add(fHistArmenteros[j]);
680       fOutputContainer->Add(fHistV0RadiusZ[j]);
681       fOutputContainer->Add(fHistV0RadiusZVSPt[j]);
682       fOutputContainer->Add(fHistV0RadiusXY[j]);
683       fOutputContainer->Add(fHistV0RadiusXYVSY[j]);
684       fOutputContainer->Add(fHistPiPMass[j]);
685       fOutputContainer->Add(fHistPiAPMass[j]);
686       fOutputContainer->Add(fHistPiPMassVSPt[j]);
687       fOutputContainer->Add(fHistPiAPMassVSPt[j]);
688       fOutputContainer->Add(fHistPiPMassVSPtMCTruth[j]);
689       fOutputContainer->Add(fHistPiAPMassVSPtMCTruth[j]);
690       fOutputContainer->Add(fHistPiPMassVSY[j]);
691       fOutputContainer->Add(fHistPiAPMassVSY[j]);      
692       fOutputContainer->Add(fHistPiPPtVSY[j]);
693       fOutputContainer->Add(fHistPiAPPtVSY[j]);
694       fOutputContainer->Add(fHistPiPDecayLengthVsPt[j]);
695       fOutputContainer->Add(fHistPiAPDecayLengthVsPt[j]);
696       fOutputContainer->Add(fHistPiPDecayLengthVsCtau[j]);
697       fOutputContainer->Add(fHistPiAPDecayLengthVsCtau[j]);
698       fOutputContainer->Add(fHistPiPDecayLengthVsMass[j]);
699       fOutputContainer->Add(fHistPiAPDecayLengthVsMass[j]);
700       fOutputContainer->Add(fHistPiPMonitorCuts[j]);
701       fOutputContainer->Add(fHistPiAPMonitorCuts[j]);
702       fOutputContainer->Add(fHistPiPMonitorMCCuts[j]);
703       fOutputContainer->Add(fHistPiAPMonitorMCCuts[j]);
704     }
705
706     
707     //----------------- for reco or data or mc data like MC reco only -----------------//
708     if((fMCMode) || (!fMCTruthMode && !fMCMode)){
709     
710       fHistPiPiEtaDReco[0] = new TH2F("fHistPiPiEtaDRecoRaw","K0s daughters eta raw",300,-6,6,100,0,20);
711       fOutputContainer->Add(fHistPiPiEtaDReco[0]);
712       fHistPiPiEtaDReco[1] = new TH2F("fHistPiPiEtaDReco","K0s daughters eta after rap V0 cut pos",300,-3,3,300,-3.00,3.0);
713       fOutputContainer->Add(fHistPiPiEtaDReco[1]);       
714       fHistPiPEtaDReco[0] = new TH2F("fHistPiPEtaDRecoRaw","#Lambda daughters eta raw",300,-6,6,100,0,20);
715       fOutputContainer->Add(fHistPiPEtaDReco[0]);
716       fHistPiPEtaDReco[1] = new TH2F("fHistPiPEtaDReco","#Lambda daughters eta after rap V0 cut neg",300,-3,3,300,-3.00,3.0);
717       fOutputContainer->Add(fHistPiPEtaDReco[1]);
718         
719       //K0
720   
721       // fHistPiPiMassVSAlpha = new TH2F("fHistPiPiMassVSAlpha"," alpha armenteros vs pi+pi- InvMass distribution",nbMass,0.25,0.75,500,-1.,1.);
722       if(!fSetPtDepHist){
723         fHistPiPiDCADaughters = new TH2F("fHistPiPiDCADaughters","dca of K0 daughters",nbMass,0.25,0.75,250,0.0,2);
724         fHistPiPiDCADaughterPosToPrimVtxVSMass = new TH2F("fHistPiPiDCADaughterPosToPrimVtxVSMass","pi+ DCA daughter to prim vtx vsinvmass",nbMass,0.25,0.75,250,0.0,10.0);
725         fHistPiPiDCAVSMass = new TH2F("fHistPiPiDCAVSMass","pi+pi- dca  vs pt",nbMass,0.25,0.75,250,0.0,5.0);
726         fHistPiPiCosPointAng  = new TH2F("fHistPiPiCosPointAng","K0 cosine of pointing angle vs mass ",nbMass,0.25,0.75,200,0.99,1.00);
727         fHistPiPiRadiusXY = new TH2F("fHistPiPiRadiusXY","pi+pi- phi dist vs mass",nbMass,0.25,0.75,200,0.0,4.0);
728         // fHistPiPiPtDaughters = new TH2F("fHistPiPiPtDaughters","p_{t} pos vs p_{t} neg of daughters",400,0.0,20.0,400,0,20.0);
729         fHistPiPiDCAZPos = new TH2F("fHistPiPiDCAZPos","dca z  of K0 pos daughters",nbMass,0.25,0.75,200,-20.0,20.0);
730         fHistPiPiDCAZNeg = new TH2F("fHistPiPiDCAZNeg","dca z  of K0 neg daughters",nbMass,0.25,0.75,200,-20.0,20.0);
731         fHistPiPiTrackLengthPosVsMass = new TH2F("fHistPiPiTrackLengthPosVsMass","track lenght of pos K0s daughter in TPC",nbMass,0.25,0.75,250,0.0,250.0);
732         fHistPiPiTrackLengthNegVsMass = new TH2F("fHistPiPiTrackLengthNegVsMass","track lenght of neg K0s daughter in TPC",nbMass,0.25,0.75,250,0.0,250.0);
733       }
734       else{//pt dependence
735         fHistPiPiDCADaughters = new TH2F("fHistPiPiDCADaughters","dca of K0 daughters",200,0.0,20.0,250,0.0,2);
736         fHistPiPiDCADaughterPosToPrimVtxVSMass = new TH2F("fHistPiPiDCADaughterPosToPrimVtxVSMass","pi+ DCA daughter to prim vtx vsinvmass",200,0.0,20.0,250,0.0,10.0);
737         fHistPiPiDCAVSMass = new TH2F("fHistPiPiDCAVSMass","pi+pi- dca  vs pt",200,0.0,20.0,250,0.0,5.0);
738         fHistPiPiCosPointAng  = new TH2F("fHistPiPiCosPointAng","K0 cosine of pointing angle vs mass ",200,0.0,20.0,200,0.99,1.00);
739         fHistPiPiRadiusXY = new TH2F("fHistPiPiRadiusXY","pi+pi- phi dist vs mass",200,0.0,20.0,200,0.0,4.0);
740         fHistPiPiDCAZPos = new TH2F("fHistPiPiDCAZPos","dca z  of K0 pos daughters",200,0.0,20.0,200,-20.0,20.0);
741         fHistPiPiDCAZNeg = new TH2F("fHistPiPiDCAZNeg","dca z  of K0 neg daughters",200,0.0,20.0,200,-20.0,20.0);
742         fHistPiPiTrackLengthPosVsMass = new TH2F("fHistPiPiTrackLengthPosVsMass","track lenght of pos K0s daughter in TPC",200,0.0,20.0,250,0.0,250.0);
743         fHistPiPiTrackLengthNegVsMass = new TH2F("fHistPiPiTrackLengthNegVsMass","track lenght of neg K0s daughter in TPC",200,0.0,20.0,250,0.0,250.0);
744       }
745
746       //Lambda
747       if(!fSetPtDepHist){
748         fHistPiPDCADaughters[0] = new TH2F("fHistPiPDCADaughters","dca of #Lambda daughters",nbMass,1.05,1.25,250,0.0,2.0);
749         fHistPiPDCADaughterPosToPrimVtxVSMass[0] = new TH2F("fHistPiPDCADaughterPosToPrimVtxVSMass","pos DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,10.0);
750         fHistPiPDCADaughterNegToPrimVtxVSMass[0] = new TH2F("fHistPiPDCADaughterNegToPrimVtxVSMass","neg DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,10.0);
751         fHistPiPDCAVSMass[0] = new TH2F("fHistPiPDCAVSMass","ppi- dca  vs pt",nbMass,1.05,1.25,250,0.0,5.0);
752         fHistPiPCosPointAng[0]  = new TH2F("fHistPiPCosPointAng","#Lambda cosine of pointing angle vs mass ",nbMass,1.05,1.25,200,0.99,1.00);
753         fHistPiPRadiusXY[0] = new TH2F("fHistPiPRadiusXY","pi-p+ phi dist vs mass",nbMass,1.05,1.25,200,0.0,4.0);
754         // fHistPiPPtDaughters[0] = new TH2F("fHistPiPPtDaughters","p_{t} pos vs p_{t} neg of daughters",400,0.0,20.0,400,0,20.0);
755         //      fHistPiPDCAZPos[0] = new TH2F("fHistPiPDCAZPos","dca z  of Lambda pos daughters",nbMass,1.05,1.25,200,-20.0,20.0);
756         //fHistPiPDCAZNeg[0] = new TH2F("fHistPiPDCAZNeg","dca z  of Lambda neg daughters",nbMass,1.05,1.25,200,-20.0,20.0);
757         fHistPiPTrackLengthPosVsMass[0] = new TH2F("fHistPiPTrackLengthPosVsMass","track length of pos Lambda daughter in TPC",nbMass,1.05,1.25,250,0.0,250.0);
758         fHistPiPTrackLengthNegVsMass[0] = new TH2F("fHistPiPTrackLengthNegVsMass","track length of neg Lambda daughter in TPC",nbMass,1.05,1.25,250,0.0,250.0);
759       }
760       else{//pt dependence
761         fHistPiPDCADaughters[0] = new TH2F("fHistPiPDCADaughters","dca of #Lambda daughters",200,0.0,20.0,250,0.0,2.0);
762         fHistPiPDCADaughterPosToPrimVtxVSMass[0] = new TH2F("fHistPiPDCADaughterPosToPrimVtxVSMass","pos DCA daughter to prim vtx vs invmass",200,0.0,20.0,250,0.0,10.0);
763         fHistPiPDCADaughterNegToPrimVtxVSMass[0] = new TH2F("fHistPiPDCADaughterNegToPrimVtxVSMass","neg DCA daughter to prim vtx vs invmass",200,0.0,20.0,250,0.0,10.0);
764         fHistPiPDCAVSMass[0] = new TH2F("fHistPiPDCAVSMass","ppi- dca  vs pt",200,0.0,20.0,250,0.0,5.0);
765         fHistPiPCosPointAng[0]  = new TH2F("fHistPiPCosPointAng","#Lambda cosine of pointing angle vs mass ",200,0.0,20.0,200,0.99,1.00);
766         fHistPiPRadiusXY[0] = new TH2F("fHistPiPRadiusXY","pi-p+ phi dist vs mass",200,0.0,20.0,200,0.0,4.0);
767         //fHistPiPDCAZPos[0] = new TH2F("fHistPiPDCAZPos","dca z  of Lambda pos daughters",200,0.0,20.0,200,-20.0,20.0);
768         //fHistPiPDCAZNeg[0] = new TH2F("fHistPiPDCAZNeg","dca z  of Lambda neg daughters",200,0.0,20.0,200,-20.0,20.0);
769         fHistPiPTrackLengthPosVsMass[0] = new TH2F("fHistPiPTrackLengthPosVsMass","track length of pos Lambda daughter in TPC",200,0.0,20.0,250,0.0,250.0);
770         fHistPiPTrackLengthNegVsMass[0] = new TH2F("fHistPiPTrackLengthNegVsMass","track length of neg Lambda daughter in TPC",200,0.0,20.0,250,0.0,250.0);
771       }
772
773       //AntiLambda
774       if(!fSetPtDepHist){
775         fHistPiAPDCADaughters[0] = new TH2F("fHistPiAPDCADaughters","dca of #bar{#Lambda} daughters",nbMass,1.05,1.25,250,0.0,2.0);
776         fHistPiAPDCADaughterPosToPrimVtxVSMass[0] = new TH2F("fHistPiAPDCADaughterPosToPrimVtxVSMass","pos DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,10.0);
777         fHistPiAPDCADaughterNegToPrimVtxVSMass[0] = new TH2F("fHistPiAPDCADaughterNegToPrimVtxVSMass","neg DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,10.0);
778         fHistPiAPDCAVSMass[0] = new TH2F("fHistPiAPDCAVSMass","pi+p- dca  vs pt",nbMass,1.05,1.25,250,0.0,5.0);
779         fHistPiAPCosPointAng[0] = new TH2F("fHistPiAPCosPointAng","#bar{#Lambda} cosine of pointing angle vs mass",nbMass,1.05,1.25,200,0.99,1.00);
780         fHistPiAPRadiusXY[0] = new TH2F("fHistPiAPRadiusXY","pi+p- phi dist vs mass",nbMass,1.05,1.25,200,0.0,4.0);
781         // fHistPiAPPtDaughters[0] = new TH2F("fHistPiAPPtDaughters","p_{t} pos vs p_{t} neg of daughters",400,0.0,20.0,400,0,20.0);
782         //      fHistPiAPDCAZPos[0] = new TH2F("fHistPiAPDCAZPos","dca z  of ALambda pos daughters",nbMass,1.05,1.25,200,-20.0,20.0);
783         //fHistPiAPDCAZNeg[0] = new TH2F("fHistPiAPDCAZNeg","dca z  of ALambda neg daughters",nbMass,1.05,1.25,200,-20.0,20.0);
784         fHistPiAPTrackLengthPosVsMass[0] = new TH2F("fHistPiAPTrackLengthPosVsMass","track length of pos ALambda daughter in TPC",nbMass,1.05,1.25,250,0.0,250.0);
785         fHistPiAPTrackLengthNegVsMass[0] = new TH2F("fHistPiAPTrackLengthNegVsMass","track length of neg ALambda daughter in TPC",nbMass,1.05,1.25,250,0.0,250.0);
786       }
787       else{//pt dependence
788         fHistPiAPDCADaughters[0] = new TH2F("fHistPiAPDCADaughters","dca of #bar{#Lambda} daughters",200,0.0,20.0,250,0.0,2.0);
789         fHistPiAPDCADaughterPosToPrimVtxVSMass[0] = new TH2F("fHistPiAPDCADaughterPosToPrimVtxVSMass","pos DCA daughter to prim vtx vs invmass",200,0.0,20.0,250,0.0,10.0);
790         fHistPiAPDCADaughterNegToPrimVtxVSMass[0] = new TH2F("fHistPiAPDCADaughterNegToPrimVtxVSMass","neg DCA daughter to prim vtx vs invmass",200,0.0,20.0,250,0.0,10.0);
791         fHistPiAPDCAVSMass[0] = new TH2F("fHistPiAPDCAVSMass","pi+p- dca  vs pt",200,0.0,20.0,250,0.0,5.0);
792         fHistPiAPCosPointAng[0] = new TH2F("fHistPiAPCosPointAng","#bar{#Lambda} cosine of pointing angle vs mass",200,0.0,20.0,200,0.99,1.00);
793         fHistPiAPRadiusXY[0] = new TH2F("fHistPiAPRadiusXY","pi+p- phi dist vs mass",200,0.0,20.0,200,0.0,4.0);
794         //      fHistPiAPDCAZPos[0] = new TH2F("fHistPiAPDCAZPos","dca z  of ALambda pos daughters",200,0.0,20.0,200,-20.0,20.0);
795         //fHistPiAPDCAZNeg[0] = new TH2F("fHistPiAPDCAZNeg","dca z  of ALambda neg daughters",200,0.0,20.0,200,-20.0,20.0);
796         fHistPiAPTrackLengthPosVsMass[0] = new TH2F("fHistPiAPTrackLengthPosVsMass","track length of pos ALambda daughter in TPC",200,0.0,20.0,250,0.0,250.0);
797         fHistPiAPTrackLengthNegVsMass[0] = new TH2F("fHistPiAPTrackLengthNegVsMass","track length of neg ALambda daughter in TPC",200,0.0,20.0,250,0.0,250.0);
798       }
799    
800       //dedx
801       fHistDedxSecProt[0] = new TH2F("fHistDedxSecProt","proton", nbPt, 0, 20, 100, 0, 400);
802       fHistDedxSecPiPlus[0] = new TH2F("fHistDedxSecPiPlus","pi plus", nbPt, 0, 20, 100, 0, 400);
803       fHistDedxSecAProt[0] = new TH2F("fHistDedxSecAProt","antiproton", nbPt, 0, 20, 100, 0, 400);
804       fHistDedxSecPiMinus[0] = new TH2F("fHistDedxSecPiMinus","pi minus", nbPt, 0, 20, 100, 0, 400);
805       fHistDedxProt[0] = new TH2F("fHistDedxProt","proton", nbPt, 0, 20, 100, 0, 400);
806       fHistDedxPiPlus[0] = new TH2F("fHistDedxPiPlus","pi plus", nbPt, 0, 20, 100, 0, 400);
807       fHistDedxAProt[0] = new TH2F("fHistDedxAProt","antiproton", nbPt, 0, 20, 100, 0, 400);
808       fHistDedxPiMinus[0] = new TH2F("fHistDedxPiMinus","pi minus", nbPt, 0, 20, 100, 0, 400);
809
810
811       // ------------------------------------------ clusters --------------------------------------------------//
812       fHistNclsITS[0] = new TH2F("fHistNclsITS","fHistNclsITS pos vs neg L",10,-0.5,9.5,10,-0.5,9.5);
813       fHistNclsTPC[0] = new TH2F("fHistNclsTPC","ncls TPC neg vs crossed rows neg L",200,-0.5,199.5,200,-0.5,199.5);
814
815       fHistNclsITS[1] = new TH2F("fHistNclsITSSec","fHistNclsITS pos vs neg K0",10,-0.5,9.5,10,-0.5,9.5);
816       fHistNclsTPC[1] = new TH2F("fHistNclsTPCSec","ncls TPC neg vs crossed rows neg K0",200,-0.5,199.5,200,-0.5,199.5);
817
818       if(!fSetPtDepHist){
819         //K0s
820         fHistNclsITSPosK0 = new TH2F("fHistNclsITSPosK0","fHistNclsITSPos  vs pt K0 pos",nbMass,0.25,0.75,7,-0.5,6.5);
821         fHistNclsITSNegK0 = new TH2F("fHistNclsITSNegK0","fHistNclsITSNeg vs pt K0 neg",nbMass,0.25,0.75,7,-0.5,6.5);
822           
823         fHistNclsTPCPosK0 = new TH2F("fHistNclsTPCPosK0","K0 mass vs phi pos",nbMass,0.25,0.75,200,0.0,200.0);
824         fHistNclsTPCNegK0 = new TH2F("fHistNclsTPCNegK0","K0 mass vs phi neg",nbMass,0.25,0.75,200,0.0,200.0);
825           
826         fHistChi2PerNclsITSPosK0 = new TH2F("fHistChi2PerNclsITSPosK0","chi2 per cluster ITS K0 pos",nbMass,0.25,0.75,250,0.0,25.0);
827         fHistChi2PerNclsITSNegK0 = new TH2F("fHistChi2PerNclsITSNegK0","chi2 per cluster ITS K0 neg",nbMass,0.25,0.75,250,0.0,25.0);
828           
829         fHistNCRowsTPCPosK0 = new TH2F("fHistNCRowsTPCPosK0","n crossed rows vs K0 pos",nbMass,0.25,0.75,200,0.0,200.0);
830         fHistNCRowsTPCNegK0 = new TH2F("fHistNCRowsTPCNegK0","n crossed rows vs K0 neg",nbMass,0.25,0.75,200,0.0,200.0);
831    
832         fHistRatioFoundOverFinableTPCK0Pos = new TH2F("fHistRatioFoundOverFinableTPCK0Pos","ncls found over findable K0 pos sec",nbMass,0.25,0.75,200,0.0,2.0);
833         fHistRatioFoundOverFinableTPCK0Neg = new TH2F("fHistRatioFoundOverFinableTPCK0Neg","ncls found over findable K0 neg sec",nbMass,0.25,0.75,200,0.0,2.0);
834         //Lambda
835         fHistNclsITSPosL[0] = new TH2F("fHistNclsITSPosL","fHistNclsITSPos  vs pt L pos",nbMass,1.05,1.25,7,-0.5,6.5);
836         fHistNclsITSNegL[0] = new TH2F("fHistNclsITSNegL","fHistNclsITSNeg vs pt L neg",nbMass,1.05,1.25,7,-0.5,6.5);
837           
838         fHistNclsTPCPosL[0] = new TH2F("fHistNclsTPCPosL","L mass vs phi pos",nbMass,1.05,1.25,200,0.0,200.0);
839         fHistNclsTPCNegL[0] = new TH2F("fHistNclsTPCNegL","L mass vs phi neg",nbMass,1.05,1.25,200,0.0,200.0);
840           
841         fHistChi2PerNclsITSPosL[0] = new TH2F("fHistChi2PerNclsITSPosL","chi2 per cluster ITS L pos",nbMass,1.05,1.25,250,0.0,25.0);
842         fHistChi2PerNclsITSNegL[0] = new TH2F("fHistChi2PerNclsITSNegL","chi2 per cluster ITS L neg",nbMass,1.05,1.25,250,0.0,25.0);
843           
844         fHistNCRowsTPCPosL[0] = new TH2F("fHistNCRowsTPCPosL","n crossed rows vs L pos",nbMass,1.05,1.25,200,0.0,200.0);
845         fHistNCRowsTPCNegL[0] = new TH2F("fHistNCRowsTPCNegL","n crossed rows vs L neg",nbMass,1.05,1.25,200,0.0,200.0);
846    
847         fHistRatioFoundOverFinableTPCLPos[0] = new TH2F("fHistRatioFoundOverFinableTPCLPos","ncls found over findable L pos sec",nbMass,1.05,1.25,200,0.0,2.0);
848         fHistRatioFoundOverFinableTPCLNeg[0] = new TH2F("fHistRatioFoundOverFinableTPCLNeg","ncls found over findable L neg sec",nbMass,1.05,1.25,200,0.0,2.0);
849       }
850       else{//pt dependence
851         //K0s
852         fHistNclsITSPosK0 = new TH2F("fHistNclsITSPosK0","fHistNclsITSPos  vs pt L pos",200,0.0,20.0,7,-0.5,6.5);
853         fHistNclsITSNegK0 = new TH2F("fHistNclsITSNegK0","fHistNclsITSNeg vs pt L neg",200,0.0,20.0,7,-0.5,6.5);
854           
855         fHistNclsTPCPosK0 = new TH2F("fHistNclsTPCPosK0","L mass vs phi pos",200,0.0,20.0,200,0.0,200.0);
856         fHistNclsTPCNegK0 = new TH2F("fHistNclsTPCNegK0","L mass vs phi neg",200,0.0,20.0,200,0.0,200.0);
857           
858         fHistChi2PerNclsITSPosK0 = new TH2F("fHistChi2PerNclsITSPosK0","chi2 per cluster ITS L pos",200,0.0,20.0,250,0.0,25.0);
859         fHistChi2PerNclsITSNegK0 = new TH2F("fHistChi2PerNclsITSNegK0","chi2 per cluster ITS L neg",200,0.0,20.0,250,0.0,25.0);
860           
861         fHistNCRowsTPCPosK0 = new TH2F("fHistNCRowsTPCPosK0","n crossed rows vs L pos",200,0.0,20.0,200,0.0,200.0);
862         fHistNCRowsTPCNegK0 = new TH2F("fHistNCRowsTPCNegK0","n crossed rows vs L neg",200,0.0,20.0,200,0.0,200.0);
863    
864         fHistRatioFoundOverFinableTPCK0Pos = new TH2F("fHistRatioFoundOverFinableTPCK0Pos","ncls found over findable L pos sec",200,0.0,20.0,200,0.0,2.0);
865         fHistRatioFoundOverFinableTPCK0Neg = new TH2F("fHistRatioFoundOverFinableTPCK0Neg","ncls found over findable L neg sec",200,0.0,20.0,200,0.0,2.0);
866         //Lambda
867         fHistNclsITSPosL[0] = new TH2F("fHistNclsITSPosL","fHistNclsITSPos  vs pt L pos",200,0.0,20.0,7,-0.5,6.5);
868         fHistNclsITSNegL[0] = new TH2F("fHistNclsITSNegL","fHistNclsITSNeg vs pt L neg",200,0.0,20.0,7,-0.5,6.5);
869           
870         fHistNclsTPCPosL[0] = new TH2F("fHistNclsTPCPosL","L mass vs phi pos",200,0.0,20.0,200,0.0,200.0);
871         fHistNclsTPCNegL[0] = new TH2F("fHistNclsTPCNegL","L mass vs phi neg",200,0.0,20.0,200,0.0,200.0);
872           
873         fHistChi2PerNclsITSPosL[0] = new TH2F("fHistChi2PerNclsITSPosL","chi2 per cluster ITS L pos",200,0.0,20.0,250,0.0,25.0);
874         fHistChi2PerNclsITSNegL[0] = new TH2F("fHistChi2PerNclsITSNegL","chi2 per cluster ITS L neg",200,0.0,20.0,250,0.0,25.0);
875           
876         fHistNCRowsTPCPosL[0] = new TH2F("fHistNCRowsTPCPosL","n crossed rows vs L pos",200,0.0,20.0,200,0.0,200.0);
877         fHistNCRowsTPCNegL[0] = new TH2F("fHistNCRowsTPCNegL","n crossed rows vs L neg",200,0.0,20.0,200,0.0,200.0);
878    
879         fHistRatioFoundOverFinableTPCLPos[0] = new TH2F("fHistRatioFoundOverFinableTPCLPos","ncls found over findable L pos sec",200,0.0,20.0,200,0.0,2.0);
880         fHistRatioFoundOverFinableTPCLNeg[0] = new TH2F("fHistRatioFoundOverFinableTPCLNeg","ncls found over findable L neg sec",200,0.0,20.0,200,0.0,2.0);
881
882       }
883
884       // --------------------------------------------- for MC reco secondaries -----------------------------------------//
885       if(mchist==2){// for MC reco
886
887         //K0
888         //Lambda
889         if(!fSetPtDepHist){
890           fHistPiPDCADaughters[1] = new TH2F("fHistPiPDCADaughtersSec","dca of #Lambda daughters",nbMass,1.05,1.25,250,0.0,2.0);
891           fHistPiPDCADaughterPosToPrimVtxVSMass[1] = new TH2F("fHistPiPDCADaughterPosToPrimVtxVSMassSec","pos sec DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,10.0);
892           fHistPiPDCADaughterNegToPrimVtxVSMass[1] = new TH2F("fHistPiPDCADaughterNegToPrimVtxVSMassSec","neg sec DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,10.0);
893           fHistPiPDCAVSMass[1] = new TH2F("fHistPiPDCAVSMassSec","ppi- dca  vs pt",nbMass,1.05,1.25,250,0.0,5.0);
894           fHistPiPCosPointAng[1]  = new TH2F("fHistPiPCosPointAngSec","#Lambda cosine of pointing angle vs mass",nbMass,1.05,1.25,200,0.99,1.00);
895           //     fHistPiPDecayLengthVsMass[1] = new TH2F("fHistPiPDecayLengthVsMassSec","#Lambda decay length vs mass",nbMass,1.05,1.25,200,0.0,100.0);
896           fHistPiPRadiusXY[1] = new TH2F("fHistPiPRadiusXYSec","pi-p+ phi dist vs mass",nbMass,1.05,1.25,200,0.0,4.0);
897           // fHistPiPPtDaughters[0] = new TH2F("fHistPiPPtDaughters","p_{t} pos vs p_{t} neg of daughters",400,0.0,20.0,400,0,20.0);
898           //      fHistPiPDCAZPos[1] = new TH2F("fHistPiPDCAZPosSec","dca z  of Lambda sec pos daughters",nbMass,1.05,1.25,200,-20.0,20.0);
899           //      fHistPiPDCAZNeg[1] = new TH2F("fHistPiPDCAZNegSec","dca z  of Lambda sec neg daughters",nbMass,1.05,1.25,200,-20.0,20.0);
900           fHistPiPTrackLengthPosVsMass[1] = new TH2F("fHistPiPTrackLengthPosVsMassSec","track length of pos sec Lambda daughter in TPC",nbMass,1.05,1.25,250,0.0,250.0);
901           fHistPiPTrackLengthNegVsMass[1] = new TH2F("fHistPiPTrackLengthNegVsMassSec","track length of neg sec Lambda daughter in TPC",nbMass,1.05,1.25,250,0.0,250.0);
902         }
903         else{
904           fHistPiPDCADaughters[1] = new TH2F("fHistPiPDCADaughtersSec","dca of #Lambda daughters",200,0.0,20.0,250,0.0,2.0);
905           fHistPiPDCADaughterPosToPrimVtxVSMass[1] = new TH2F("fHistPiPDCADaughterPosToPrimVtxVSMassSec","pos sec DCA daughter to prim vtx vs invmass",200,0.0,20.0,250,0.0,10.0);
906           fHistPiPDCADaughterNegToPrimVtxVSMass[1] = new TH2F("fHistPiPDCADaughterNegToPrimVtxVSMassSec","neg sec DCA daughter to prim vtx vs invmass",200,0.0,20.0,250,0.0,10.0);
907           fHistPiPDCAVSMass[1] = new TH2F("fHistPiPDCAVSMassSec","ppi- dca  vs pt",200,0.0,20.0,250,0.0,5.0);
908           fHistPiPCosPointAng[1]  = new TH2F("fHistPiPCosPointAngSec","#Lambda cosine of pointing angle vs mass",200,0.0,20.0,200,0.99,1.00);
909           fHistPiPRadiusXY[1] = new TH2F("fHistPiPRadiusXYSec","pi-p+ phi dist vs mass",200,0.0,20.0,200,0.0,4.0);
910           //      fHistPiPDCAZPos[1] = new TH2F("fHistPiPDCAZPosSec","dca z  of Lambda sec pos daughters",200,0.0,20.0,200,-20.0,20.0);
911           //fHistPiPDCAZNeg[1] = new TH2F("fHistPiPDCAZNegSec","dca z  of Lambda sec neg daughters",200,0.0,20.0,200,-20.0,20.0);
912           fHistPiPTrackLengthPosVsMass[1] = new TH2F("fHistPiPTrackLengthPosVsMassSec","track length of pos sec Lambda daughter in TPC",200,0.0,20.0,250,0.0,250.0);
913           fHistPiPTrackLengthNegVsMass[1] = new TH2F("fHistPiPTrackLengthNegVsMassSec","track length of neg sec Lambda daughter in TPC",200,0.0,20.0,250,0.0,250.0);
914         }
915           
916         //ALambda
917         if(!fSetPtDepHist){
918           fHistPiAPDCADaughters[1] = new TH2F("fHistPiAPDCADaughtersSec","dca of #bar{#Lambda} daughters",nbMass,1.05,1.25,250,0.0,2.0);
919           fHistPiAPDCADaughterPosToPrimVtxVSMass[1] = new TH2F("fHistPiAPDCADaughterPosToPrimVtxVSMassSec","pos sec DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,10.0);
920           fHistPiAPDCADaughterNegToPrimVtxVSMass[1] = new TH2F("fHistPiAPDCADaughterNegToPrimVtxVSMassSec","neg sec DCA daughter to prim vtx vs invmass",nbMass,1.05,1.25,250,0.0,10.0);
921           fHistPiAPDCAVSMass[1]   = new TH2F("fHistPiAPDCAVSMassSec","pi+p- dca  vs pt",nbMass,1.05,1.25,250,0.0,5.0);
922           fHistPiAPCosPointAng[1] = new TH2F("fHistPiAPCosPointAngSec","#bar{#Lambda} cosine of pointing angle vs mass",nbMass,1.05,1.25,200,0.99,1.00);
923           //     fHistPiAPDecayLengthVsMass[1] = new TH2F("fHistPiAPDecayLengthVsMassSec","#bar{#Lambda} decay length vs mass",nbMass,1.05,1.25,200,0.0,100.0);
924           fHistPiAPRadiusXY[1] = new TH2F("fHistPiAPRadiusXYSec","pi+p- phi dist vs mass",nbMass,1.05,1.25,200,0.0,4.0);
925           // fHistPiAPPtDaughters[0] = new TH2F("fHistPiAPPtDaughters","p_{t} pos vs p_{t} neg of daughters",400,0.0,20.0,400,0,20.0);
926           //      fHistPiAPDCAZPos[1] = new TH2F("fHistPiAPDCAZPosSec","dca z  of ALambda sec pos daughters",nbMass,1.05,1.25,200,-20.0,20.0);
927           //fHistPiAPDCAZNeg[1] = new TH2F("fHistPiAPDCAZNegSec","dca z  of ALambda sec neg daughters",nbMass,1.05,1.25,200,-20.0,20.0);
928           fHistPiAPTrackLengthPosVsMass[1] = new TH2F("fHistPiAPTrackLengthPosVsMassSec","track length of pos sec ALambda daughter in TPC",nbMass,1.05,1.25,250,0.0,250.0);
929           fHistPiAPTrackLengthNegVsMass[1] = new TH2F("fHistPiAPTrackLengthNegVsMassSec","track length of neg sec ALambda daughter in TPC",nbMass,1.05,1.25,250,0.0,250.0);
930         }
931         else{
932           fHistPiAPDCADaughters[1] = new TH2F("fHistPiAPDCADaughtersSec","dca of #bar{#Lambda} daughters",200,0.0,20.0,250,0.0,2.0);
933           fHistPiAPDCADaughterPosToPrimVtxVSMass[1] = new TH2F("fHistPiAPDCADaughterPosToPrimVtxVSMassSec","pos sec DCA daughter to prim vtx vs invmass",200,0.0,20.0,250,0.0,10.0);
934           fHistPiAPDCADaughterNegToPrimVtxVSMass[1] = new TH2F("fHistPiAPDCADaughterNegToPrimVtxVSMassSec","neg sec DCA daughter to prim vtx vs invmass",200,0.0,20.0,250,0.0,10.0);
935           fHistPiAPDCAVSMass[1]   = new TH2F("fHistPiAPDCAVSMassSec","pi+p- dca  vs pt",200,0.0,20.0,250,0.0,5.0);
936           fHistPiAPCosPointAng[1] = new TH2F("fHistPiAPCosPointAngSec","#bar{#Lambda} cosine of pointing angle vs mass",200,0.0,20.0,200,0.99,1.00);
937           fHistPiAPRadiusXY[1] = new TH2F("fHistPiAPRadiusXYSec","pi+p- phi dist vs mass",200,0.0,20.0,200,0.0,4.0);
938           //      fHistPiAPDCAZPos[1] = new TH2F("fHistPiAPDCAZPosSec","dca z  of ALambda sec pos daughters",200,0.0,20.0,200,-20.0,20.0);
939           //fHistPiAPDCAZNeg[1] = new TH2F("fHistPiAPDCAZNegSec","dca z  of ALambda sec neg daughters",200,0.0,20.0,200,-20.0,20.0);
940           fHistPiAPTrackLengthPosVsMass[1] = new TH2F("fHistPiAPTrackLengthPosVsMassSec","track length of pos sec ALambda daughter in TPC",200,0.0,20.0,250,0.0,250.0);
941           fHistPiAPTrackLengthNegVsMass[1] = new TH2F("fHistPiAPTrackLengthNegVsMassSec","track length of neg sec ALambda daughter in TPC",200,0.0,20.0,250,0.0,250.0);
942         }
943
944         //dedx
945         fHistDedxSecProt[1] = new TH2F("fHistDedxSecProtSec","proton", nbPt, 0, 20, 100, 0, 400);
946         fHistDedxSecPiPlus[1] = new TH2F("fHistDedxSecPiPlusSec","pi plus", nbPt, 0, 20, 100, 0, 400);
947         fHistDedxSecAProt[1] = new TH2F("fHistDedxSecAProtSec","antiproton", nbPt, 0, 20, 100, 0, 400);
948         fHistDedxSecPiMinus[1] = new TH2F("fHistDedxSecPiMinusSec","pi minus", nbPt, 0, 20, 100, 0, 400);
949         fHistDedxProt[1] = new TH2F("fHistDedxProtSec","proton", nbPt, 0, 20, 100, 0, 400);
950         fHistDedxPiPlus[1] = new TH2F("fHistDedxPiPlusSec","pi plus", nbPt, 0, 20, 100, 0, 400);
951         fHistDedxAProt[1] = new TH2F("fHistDedxAProtSec","antiproton", nbPt, 0, 20, 100, 0, 400);
952         fHistDedxPiMinus[1] = new TH2F("fHistDedxPiMinusSec","pi minus", nbPt, 0, 20, 100, 0, 400);
953
954         // ------------------------------------------ clusters --------------------------------------------------//
955         if(!fSetPtDepHist){
956           fHistNclsITSPosL[1] = new TH2F("fHistNclsITSPosLSec","fHistNclsITSPos  vs pt L pos",nbMass,1.05,1.25,7,-0.5,6.5);
957           fHistNclsITSNegL[1] = new TH2F("fHistNclsITSNegLSec","fHistNclsITSNeg vs pt L neg",nbMass,1.05,1.25,7,-0.5,6.5);
958           
959           fHistNclsTPCPosL[1] = new TH2F("fHistNclsTPCPosLSec","L mass vs phi pos",nbMass,1.05,1.25,200,0.0,200.0);
960           fHistNclsTPCNegL[1] = new TH2F("fHistNclsTPCNegLSec","L mass vs phi neg",nbMass,1.05,1.25,200,0.0,200.0);
961           
962           fHistChi2PerNclsITSPosL[1] = new TH2F("fHistChi2PerNclsITSPosLSec","chi2 per cluster ITS L pos",nbMass,1.05,1.25,250,0.0,25.0);
963           fHistChi2PerNclsITSNegL[1] = new TH2F("fHistChi2PerNclsITSNegLSec","chi2 per cluster ITS L neg",nbMass,1.05,1.25,250,0.0,25.0);
964           
965           fHistNCRowsTPCPosL[1] = new TH2F("fHistNCRowsTPCPosLSec","n crossed rows vs L pos",nbMass,1.05,1.25,200,0.0,200.0);
966           fHistNCRowsTPCNegL[1] = new TH2F("fHistNCRowsTPCNegLSec","n crossed rows vs L neg",nbMass,1.05,1.25,200,0.0,200.0);
967    
968           fHistRatioFoundOverFinableTPCLPos[1] = new TH2F("fHistRatioFoundOverFinableTPCLPosSec","ncls found over findable L pos sec",nbMass,1.05,1.25,200,0.0,2.0);
969           fHistRatioFoundOverFinableTPCLNeg[1] = new TH2F("fHistRatioFoundOverFinableTPCLNegSec","ncls found over findable L neg sec",nbMass,1.05,1.25,200,0.0,2.0);
970         }
971         else{
972           fHistNclsITSPosL[1] = new TH2F("fHistNclsITSPosLSec","fHistNclsITSPos  vs pt L pos",200,0.0,20.0,7,-0.5,6.5);
973           fHistNclsITSNegL[1] = new TH2F("fHistNclsITSNegLSec","fHistNclsITSNeg vs pt L neg",200,0.0,20.0,7,-0.5,6.5);
974           
975           fHistNclsTPCPosL[1] = new TH2F("fHistNclsTPCPosLSec","L mass vs phi pos",200,0.0,20.0,200,0.0,200.0);
976           fHistNclsTPCNegL[1] = new TH2F("fHistNclsTPCNegLSec","L mass vs phi neg",200,0.0,20.0,200,0.0,200.0);
977           
978           fHistChi2PerNclsITSPosL[1] = new TH2F("fHistChi2PerNclsITSPosLSec","chi2 per cluster ITS L pos",200,0.0,20.0,250,0.0,25.0);
979           fHistChi2PerNclsITSNegL[1] = new TH2F("fHistChi2PerNclsITSNegLSec","chi2 per cluster ITS L neg",200,0.0,20.0,250,0.0,25.0);
980           
981           fHistNCRowsTPCPosL[1] = new TH2F("fHistNCRowsTPCPosLSec","n crossed rows vs L pos",200,0.0,20.0,200,0.0,200.0);
982           fHistNCRowsTPCNegL[1] = new TH2F("fHistNCRowsTPCNegLSec","n crossed rows vs L neg",200,0.0,20.0,200,0.0,200.0);
983    
984           fHistRatioFoundOverFinableTPCLPos[1] = new TH2F("fHistRatioFoundOverFinableTPCLPosSec","ncls found over findable L pos sec",200,0.0,20.0,200,0.0,2.0);
985           fHistRatioFoundOverFinableTPCLNeg[1] = new TH2F("fHistRatioFoundOverFinableTPCLNegSec","ncls found over findable L neg sec",200,0.0,20.0,200,0.0,2.0);
986         }
987         
988       }
989
990       //------ ITS TPC clusters --------------
991       fOutputContainer->Add(fHistNclsITS[0]) ;
992       fOutputContainer->Add(fHistNclsTPC[0]);
993       fOutputContainer->Add(fHistNclsITS[1]);
994       fOutputContainer->Add(fHistNclsTPC[1]);
995
996       //-----------K0s ------------------
997       fOutputContainer->Add(fHistPiPiDCAZNeg);
998       fOutputContainer->Add(fHistPiPiDCAZPos);
999       fOutputContainer->Add(fHistPiPiDCADaughters); 
1000       fOutputContainer->Add(fHistPiPiDCADaughterPosToPrimVtxVSMass);
1001       fOutputContainer->Add(fHistPiPiDCAVSMass);
1002       fOutputContainer->Add(fHistPiPiCosPointAng);
1003       fOutputContainer->Add(fHistPiPiTrackLengthPosVsMass);
1004       fOutputContainer->Add(fHistPiPiTrackLengthNegVsMass);
1005       fOutputContainer->Add(fHistPiPiRadiusXY);
1006       //        fOutputContainer->Add( fHistPiPiPtDaughters);
1007       fOutputContainer->Add(fHistNclsITSPosK0);
1008       fOutputContainer->Add(fHistNclsITSNegK0);
1009       fOutputContainer->Add(fHistNclsTPCPosK0);
1010       fOutputContainer->Add(fHistNclsTPCNegK0);
1011       fOutputContainer->Add(fHistChi2PerNclsITSPosK0);
1012       fOutputContainer->Add(fHistChi2PerNclsITSNegK0);
1013       fOutputContainer->Add(fHistNCRowsTPCPosK0);
1014       fOutputContainer->Add(fHistNCRowsTPCNegK0);
1015       fOutputContainer->Add(fHistRatioFoundOverFinableTPCK0Pos);
1016       fOutputContainer->Add(fHistRatioFoundOverFinableTPCK0Neg);
1017
1018       //----------- Lambda Antilambda -------------
1019       for(Int_t j=0;j<mchist;j++){
1020         fOutputContainer->Add(fHistPiPDCADaughters[j]); 
1021         fOutputContainer->Add(fHistPiAPDCADaughters[j]);
1022         fOutputContainer->Add( fHistPiPDCADaughterPosToPrimVtxVSMass[j]);
1023         fOutputContainer->Add( fHistPiPDCADaughterNegToPrimVtxVSMass[j]);
1024         fOutputContainer->Add( fHistPiAPDCADaughterPosToPrimVtxVSMass[j]);
1025         fOutputContainer->Add( fHistPiAPDCADaughterNegToPrimVtxVSMass[j]);
1026           //fOutputContainer->Add( fHistPiPPtDaughters[j]);
1027           //fOutputContainer->Add( fHistPiAPPtDaughters[j]);
1028         fOutputContainer->Add(fHistPiPDCAVSMass[j]);
1029         fOutputContainer->Add(fHistPiAPDCAVSMass[j]);
1030         fOutputContainer->Add(fHistPiPCosPointAng[j]);
1031         fOutputContainer->Add(fHistPiAPCosPointAng[j]);
1032         //fOutputContainer->Add(fHistPiPDCAZNeg[j]);
1033         //fOutputContainer->Add(fHistPiPDCAZPos[j]);
1034         //fOutputContainer->Add(fHistPiAPDCAZNeg[j]);
1035         //fOutputContainer->Add(fHistPiAPDCAZPos[j]);
1036         fOutputContainer->Add(fHistPiPTrackLengthPosVsMass[j]);
1037         fOutputContainer->Add(fHistPiPTrackLengthNegVsMass[j]);
1038         fOutputContainer->Add(fHistPiAPTrackLengthPosVsMass[j]);
1039         fOutputContainer->Add(fHistPiAPTrackLengthNegVsMass[j]);     
1040         fOutputContainer->Add(fHistPiPRadiusXY[j]);
1041         fOutputContainer->Add(fHistPiAPRadiusXY[j]);
1042       
1043         //--------- dEdx --------------------------//
1044         fOutputContainer->Add(fHistDedxSecProt[j]);
1045         fOutputContainer->Add(fHistDedxSecAProt[j]);
1046         fOutputContainer->Add(fHistDedxSecPiPlus[j]);
1047         fOutputContainer->Add(fHistDedxSecPiMinus[j]);
1048         fOutputContainer->Add(fHistDedxProt[j]);
1049         fOutputContainer->Add(fHistDedxAProt[j]);
1050         fOutputContainer->Add(fHistDedxPiPlus[j]);
1051         fOutputContainer->Add(fHistDedxPiMinus[j]);
1052
1053         //--------- TPC Lambda-----------------
1054         fOutputContainer->Add(fHistNclsITSPosL[j]);
1055         fOutputContainer->Add(fHistNclsITSNegL[j]);
1056         fOutputContainer->Add(fHistNclsTPCPosL[j]);
1057         fOutputContainer->Add(fHistNclsTPCNegL[j]);
1058         fOutputContainer->Add(fHistChi2PerNclsITSPosL[j]);
1059         fOutputContainer->Add(fHistChi2PerNclsITSNegL[j]);
1060         fOutputContainer->Add(fHistNCRowsTPCPosL[j]);
1061         fOutputContainer->Add(fHistNCRowsTPCNegL[j]);
1062         fOutputContainer->Add(fHistRatioFoundOverFinableTPCLPos[j]);
1063         fOutputContainer->Add(fHistRatioFoundOverFinableTPCLNeg[j]);
1064       }  
1065     }
1066
1067     //----------------------------- MC reco or MC truth only --------------------------//
1068     if((fMCMode && fMCTruthMode) || fMCTruthMode){//mc reco truth only
1069       if(fAnapp){
1070         fHistPrimVtxZESDVSNContributorsMC = new TH2F("fHistPrimVtxZESDVSNContributorsMC","prim vtx pos z ESD vs no. of contributers MC",250,-50,50,500,0.0,500.0);
1071         fOutputContainer->Add(fHistPrimVtxZESDVSNContributorsMC);
1072         fHistPrimVtxZESDTPCVSNContributorsMC = new TH2F("fHistPrimVtxZESDTPCVSNContributorsMC","prim vtx pos z TPC vs no. of contributers MC",250,-50,50,500,0.0,500.0);
1073         fOutputContainer->Add(fHistPrimVtxZESDTPCVSNContributorsMC);
1074         fHistPrimVtxZESDSPDVSNContributorsMC = new TH2F("fHistPrimVtxZESDSPDVSNContributorsMC","prim vtx pos z SPD vs no. of contributers MC",250,-50,50,500,0.0,500.0);
1075         fOutputContainer->Add(fHistPrimVtxZESDSPDVSNContributorsMC);
1076       }
1077       fHistMCVertexZ= new TH1F("fHistMCVertexZ"," z vertex distr in cm MC",500,-50,50);
1078       fOutputContainer->Add(fHistMCVertexZ);
1079       fHistPiPiPDGCode = new TH1F("fHistPiPiPDGCode","PDG code of K0s mothers",3500,0,3500);
1080       fOutputContainer->Add(fHistPiPiPDGCode);
1081       fHistPiPPDGCode = new TH1F("fHistPiPPDGCode","PDG code of #Lambda  mothers",3500,0,3500);
1082       fOutputContainer->Add(fHistPiPPDGCode);
1083       fHistPiAPPDGCode = new TH1F("fHistPiAPPDGCode","PDG code of #bar{#Lambda} mothers",3500,0,3500);
1084       fOutputContainer->Add(fHistPiAPPDGCode);
1085       fHistPiPCosPointAngXiVsPt= new TH2F("fHistPiPCosPointAngXiVsPt","pi-p cos of pointing angle vs pt from xi",200,0.0,20.0,250,0.99,1.00);
1086       fOutputContainer->Add(fHistPiPCosPointAngXiVsPt);
1087       fHistPiAPCosPointAngXiVsPt= new TH2F("fHistPiAPCosPointAngXiVsPt","pi+p- cos of pointing angle vs pt from xi",200,0.0,20.0,250,0.99,1.00);        
1088       fOutputContainer->Add(fHistPiAPCosPointAngXiVsPt);    
1089       fHistPiPiEtaDMC[0] = new TH2F("fHistPiPiEtaDMCRaw","K0s daughters etaMC raw",300,-6,6,100,0,20);//
1090       fOutputContainer->Add(fHistPiPiEtaDMC[0]);
1091       fHistPiPiEtaDMC[1] = new TH2F("fHistPiPiEtaDMC","K0s daughters etaMC after rap V0 cut",300,-6,6,100,0,20);
1092       fOutputContainer->Add(fHistPiPiEtaDMC[1]); 
1093       fHistPiPEtaDMC[0] = new TH2F("fHistPiPEtaDMCRaw","#Lambda daughters etaMC raw",300,-6,6,100,0,20);
1094       fOutputContainer->Add(fHistPiPEtaDMC[0]); 
1095       fHistPiPEtaDMC[1] = new TH2F("fHistPiPEtaDMC","#Lambda daughters etaMC after rap V0 cut",300,-6,6,100,0,20);
1096       fOutputContainer->Add(fHistPiPEtaDMC[1]);
1097
1098       //-------------K0s
1099    
1100       fHistPiPiDecayLengthResolution = new TH2F("fHistPiPiDecayLengthResolution","K0s decay length resolution MC",220,0.0,110.0,220,0.0,110);
1101          
1102       //-------------Lambda
1103       fHistPiPDecayLengthResolution[0] = new TH2F("fHistPiPDecayLengthResolution","Lambda decay length resolution MC",220,0.0,110.0,220,0.0,110);
1104       fHistPiPDecayLengthResolution[1] = new TH2F("fHistPiPDecayLengthResolutionSec","Lambda sec decay length resolution MC",220,0.0,110.0,220,0.0,110);
1105
1106       fHistPiPMassVSPtSecSigma[0] = new TH2F("fHistPiPMassVSPtSecSigmaMC"," pi-p+ InvMass distribution secondaries from sigma MC",nbMass,1.05,1.25,200,0.,20);
1107       fHistPiPMassVSPtSecSigma[1] = new TH2F("fHistPiPMassVSPtSecSigma"," pi-p+ InvMass distribution secondaries from Sigma reco",nbMass,1.05,1.25,200,0.,20);
1108    
1109       fHistPiPMassVSPtSecXi[0] = new TH2F("fHistPiPMassVSPtSecXiMC"," pi-p+ InvMass distribution secondaries from  xi MC",nbMass,1.05,1.25,200,0.,20);
1110       fHistPiPMassVSPtSecXi[1] = new TH2F("fHistPiPMassVSPtSecXi"," pi-p+ InvMass distribution secondaries from  xi  reco",nbMass,1.05,1.25,200,0.,20);
1111
1112       fHistPiPMassVSPtSecXiMCTruth = new TH2F("fHistPiPMassVSPtSecXiMCTruth","Lambda mass reco vs pt sec Lambda from xi MC truth pt",nbMass,1.05,1.25,200,0.0,20.0);
1113  
1114       fHistPiPMassVSYSecXi[0] = new TH2F("fHistPiPMassVSYSecXiMC"," pi-p+ InvMass distribution secondaries from xi MC",nbMass,1.05,1.25,100,-2.,2);
1115       fHistPiPMassVSYSecXi[1] = new TH2F("fHistPiPMassVSYSecXi"," pi-p+ InvMass distribution secondaries from xi reco",nbMass,1.05,1.25,100,-2.,2);
1116
1117       fHistPiPXi0PtVSLambdaPt[0]= new TH2F("fHistPiPXi0PtVSLambdaPtMC"," pt xi 0 vs pt lambda MC truth",200,0.0,20.0,200,0.0,20.0);
1118       fHistPiPXi0PtVSLambdaPt[1]= new TH2F("fHistPiPXi0PtVSLambdaPt"," pt xi 0 truth vs pt lambda reco",200,0.0,20.0,200,0.0,20.0);
1119
1120       fHistPiPXiMinusPtVSLambdaPt[0]= new TH2F("fHistPiPXiMinusPtVSLambdaPtMC","pt xi- vs pt lambda MC truth",200,0.0,20.0,200,0.0,20.0);
1121       fHistPiPXiMinusPtVSLambdaPt[1]= new TH2F("fHistPiPXiMinusPtVSLambdaPt","pt xi- truth vs pt lambda reco",200,0.0,20.0,200,0.0,20.0);
1122
1123       fHistPiPOmegaPtVSLambdaPt[0] = new TH2F("fHistPiPOmegaPtVSLambdaPtMC","pt omega vs pt lambda MC truth",200,0.0,20.0,200,0.0,20.0);
1124       fHistPiPOmegaPtVSLambdaPt[1] = new TH2F("fHistPiPOmegaPtVSLambdaPt","pt omega vs pt lambda MC reco",200,0.0,20.0,200,0.0,20.0);
1125
1126       fHistPiPMassVSPtSecOmega[0] = new TH2F("fHistPiPMassVSPtSecOmegaMC","Lambda mass vs pt omega MCtruth",nbMass,1.05,1.25,200,0.0,20.0);
1127       fHistPiPMassVSPtSecOmega[1] = new TH2F("fHistPiPMassVSPtSecOmega","Lambda mass vs pt omega MCreco",nbMass,1.05,1.25,200,0.0,20.0);
1128       fHistPiPMassVSPtSecOmegaMCTruth= new TH2F("fHistPiPMassVSPtSecOmegaMCTruth","Lambda mass vs pt sec Lambda from Omega MC truth pt",nbMass,1.05,1.25,200,0.0,20.0);
1129
1130       //--------------ALambda
1131       fHistPiAPDecayLengthResolution[0] = new TH2F("fHistPiAPDecayLengthResolution","ALambda decay length resolution MC",220,0.0,110.0,220,0.0,110);
1132       fHistPiAPDecayLengthResolution[1] = new TH2F("fHistPiAPDecayLengthResolutionSec","ALambda sec decay length resolution MC",220,0.0,110.0,220,0.0,110);
1133
1134       fHistPiAPMassVSPtSecSigma[0] = new TH2F("fHistPiAPMassVSPtSecSigmaMC"," pi+p- InvMass distribution secondaries from Sigma MC",nbMass,1.05,1.25,200,0.,20);
1135       fHistPiAPMassVSPtSecSigma[1] = new TH2F("fHistPiAPMassVSPtSecSigma"," pi+p- InvMass distribution secondaries from  Sigma  reco",nbMass,1.05,1.25,200,0.,20);
1136
1137       fHistPiAPMassVSPtSecXi[0] = new TH2F("fHistPiAPMassVSPtSecXiMC"," pi+p- InvMass distribution secondaries from xi MC",nbMass,1.05,1.25,200,0.,20);
1138       fHistPiAPMassVSPtSecXi[1] = new TH2F("fHistPiAPMassVSPtSecXi"," pi+p- InvMass distribution secondaries from  Xi reco",nbMass,1.05,1.25,200,0.,20);
1139
1140       fHistPiAPMassVSPtSecXiMCTruth = new TH2F("fHistPiAPMassVSPtSecXiMCTruth","ALambda mass reco vs pt sec Lambda from xi MC truth pt",nbMass,1.05,1.25,200,0.0,20.0);
1141       
1142       fHistPiAPMassVSYSecXi[0] = new TH2F("fHistPiAPMassVSYSecXiMC"," pi+p- InvMass distribution secondaries from  xi MC",nbMass,1.05,1.25,100,-2,2);
1143       fHistPiAPMassVSYSecXi[1] = new TH2F("fHistPiAPMassVSYSecXi"," pi+p- InvMass distribution secondaries from xi reco",nbMass,1.05,1.25,100,-2.,2);
1144
1145      
1146       fHistPiAPXi0PtVSLambdaPt[0]= new TH2F("fHistPiAPXi0PtVSLambdaPtMC"," pt xi 0 vs pt Alambda MC truth",200,0.0,20.0,200,0.0,20.0);
1147       fHistPiAPXi0PtVSLambdaPt[1]= new TH2F("fHistPiAPXi0PtVSLambdaPt"," pt xi 0 truth vs pt Alambda reco",200,0.0,20.0,200,0.0,20.0);
1148
1149       fHistPiAPXiMinusPtVSLambdaPt[0]= new TH2F("fHistPiAPXiMinusPtVSLambdaPtMC","pt xi- vs pt Alambda MC truth",200,0.0,20.0,200,0.0,20.0);
1150       fHistPiAPXiMinusPtVSLambdaPt[1]= new TH2F("fHistPiAPXiMinusPtVSLambdaPt","pt xi- truth vs pt Alambda reco",200,0.0,20.0,200,0.0,20.0);
1151
1152       fHistPiAPOmegaPtVSLambdaPt[0] = new TH2F("fHistPiAPOmegaPtVSLambdaPtMC","pt omega vs pt alambda MC truth",200,0.0,20.0,200,0.0,20.0);
1153       fHistPiAPOmegaPtVSLambdaPt[1] = new TH2F("fHistPiAPOmegaPtVSLambdaPt","pt omega vs pt alambda MC reco",200,0.0,20.0,200,0.0,20.0);
1154
1155       fHistPiAPMassVSPtSecOmega[0] = new TH2F("fHistPiAPMassVSPtSecOmegaMC","ALambda mass vs pt omega MCtruth",nbMass,1.05,1.25,200,0.0,20.0);
1156       fHistPiAPMassVSPtSecOmega[1] = new TH2F("fHistPiAPMassVSPtSecOmega","ALambda mass vs pt omega MCreco",nbMass,1.05,1.25,200,0.0,20.0);
1157       fHistPiAPMassVSPtSecOmegaMCTruth= new TH2F("fHistPiAPMassVSPtSecOmegaMCTruth","ALambda mass vs pt sec Lambda from Omega MC truth pt",nbMass,1.05,1.25,200,0.0,20.0);
1158    
1159       fOutputContainer->Add(fHistPiPMassVSPtSecXiMCTruth);
1160       fOutputContainer->Add(fHistPiPMassVSPtSecOmegaMCTruth);
1161
1162       fOutputContainer->Add(fHistPiAPMassVSPtSecXiMCTruth);
1163       fOutputContainer->Add(fHistPiAPMassVSPtSecOmegaMCTruth);
1164
1165       fOutputContainer->Add(fHistPiPiDecayLengthResolution);   
1166   
1167   
1168       for(Int_t j=0;j<2;j++){
1169
1170         fOutputContainer->Add(fHistPiPDecayLengthResolution[j]);  
1171         fOutputContainer->Add(fHistPiAPDecayLengthResolution[j]);
1172         fOutputContainer->Add(fHistPiPMassVSPtSecXi[j]);
1173         fOutputContainer->Add(fHistPiAPMassVSPtSecXi[j]);
1174         fOutputContainer->Add(fHistPiPMassVSYSecXi[j]);
1175         fOutputContainer->Add(fHistPiAPMassVSYSecXi[j]);
1176         fOutputContainer->Add(fHistPiPXi0PtVSLambdaPt[j]);
1177         fOutputContainer->Add(fHistPiAPXi0PtVSLambdaPt[j]);
1178         fOutputContainer->Add(fHistPiPXiMinusPtVSLambdaPt[j]);
1179         fOutputContainer->Add(fHistPiAPXiMinusPtVSLambdaPt[j]);
1180         fOutputContainer->Add(fHistPiPMassVSPtSecSigma[j]);
1181         fOutputContainer->Add(fHistPiAPMassVSPtSecSigma[j]);
1182         fOutputContainer->Add(fHistPiPOmegaPtVSLambdaPt[j]);
1183         fOutputContainer->Add(fHistPiAPOmegaPtVSLambdaPt[j]);
1184         fOutputContainer->Add(fHistPiPMassVSPtSecOmega[j]);
1185         fOutputContainer->Add(fHistPiAPMassVSPtSecOmega[j]);
1186       }
1187     }
1188
1189     /*    
1190     //shift q/pt
1191     fHistUserPtShift = new TH1F("fHistUserPtShift","user defined shift in 1/pt",100,-0.5,1.5);
1192     */
1193    
1194   }
1195
1196   //________________________________________________________________________
1197   void AliAnalysisTaskV0ForRAA::UserExec(Option_t *) {
1198     //user exec
1199
1200     //-- esd handler --//
1201     AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> 
1202       (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
1203     if (!esdH) {
1204       printf("ERROR: Could not get ESDInputHandler");
1205       return;
1206     } 
1207     fESD = esdH->GetEvent();
1208     if(!fESD) {
1209       printf("ERROR: fESD not available \n");
1210       return ;
1211     }
1212
1213     //-- mc handler --//
1214     if(fMCMode || fMCTruthMode){
1215       AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*> 
1216         (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
1217       if(!mcH) {
1218         printf("ERROR: Could not get MCInputHandler");
1219         return;
1220       }
1221       fMCev = mcH->MCEvent();
1222       if (!fMCev) {
1223         printf("ERROR: fMCev not available \n");
1224         return ;
1225       }
1226     }
1227     
1228     //--  AliPIDResponse --//
1229     fESDpid = esdH->GetPIDResponse();
1230  
1231     //-- Count events before cuts --//
1232     fHistNEvents->Fill(0);
1233
1234     //-- Check object existence --//
1235     const AliESDVertex *    vtxESD    = fESD->GetPrimaryVertexTracks();
1236     const AliESDVertex *    vtxESDTPC = fESD->GetPrimaryVertexTPC();  
1237     const AliESDVertex *    vtxESDSPD = fESD->GetPrimaryVertexSPD();  
1238     const AliMultiplicity * multESD   = fESD->GetMultiplicity();  
1239
1240     if ( !vtxESD ){
1241       AliError("No Tracks Vertex");
1242       return;
1243     }
1244
1245     if ( !vtxESDTPC ){
1246       AliError("No TPC Vertex");
1247       return ;
1248     }
1249
1250     if ( !vtxESDSPD ){
1251       AliError("No SPD Vertex");
1252       return ;
1253     }
1254
1255     if ( !multESD ){
1256       AliError("No Multiplicity");
1257       return ;
1258     }
1259    
1260
1261     // ----------- MC vertex -----------------------------------//
1262  
1263     Int_t nContr =0;
1264   
1265     if(fMCTruthMode){
1266       Double_t vVertexPrim[3];
1267       fMCev->GetPrimaryVertex()->GetXYZ(vVertexPrim);
1268       fHistMCVertexZ->Fill(vVertexPrim[2]);
1269     
1270       if(fMCMode && fAnapp){
1271         if (vtxESD->GetStatus()){
1272           nContr=vtxESD->GetNContributors();
1273           fHistPrimVtxZESDVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1274           fHistPrimVtxZESDTPCVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1275         }
1276         else {
1277           if(vtxESDSPD->GetStatus()){
1278             nContr=vtxESDSPD->GetNContributors();
1279             fHistPrimVtxZESDTPCVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1280             fHistPrimVtxZESDSPDVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1281           }
1282           else{
1283             fHistPrimVtxZESDVSNContributorsMC->Fill(vVertexPrim[2],nContr);//add for correction ESD and ESDPSD!!!!
1284             fHistPrimVtxZESDTPCVSNContributorsMC->Fill(vVertexPrim[2],nContr);
1285           }
1286         }
1287       }
1288     }
1289   
1290      
1291   
1292     // -- Check fo centrality
1293     Bool_t process = kTRUE;
1294     Int_t centBin = -1;
1295     if(fUseCentrality) {
1296       centBin = CalculateCentralityBin();
1297       if(!fUseCentralityRange){
1298         if(centBin!= fUseCentralityBin) process=kFALSE;
1299       }
1300       else if(centBin < fUseCentralityBin || centBin > fUseCentralityBin+fUseCentralityRange)
1301         process = kFALSE;
1302     }
1303
1304     AliESDVZERO* esdV0 = fESD->GetVZEROData();
1305     Float_t multV0 = esdV0->GetMTotV0A() + esdV0->GetMTotV0C();
1306   
1307     if(fAnapp){// pp Analysis
1308   
1309       // SDD test for 2.76TeV pp
1310       // select events with SDD
1311       //   TString trCl = fESD->GetFiredTriggerClasses();
1312       //if(!(trCl.Contains("ALLNOTRD")) && fSelSDD) return;
1313       UInt_t maskSel = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
1314       if(maskSel& AliVEvent::kFastOnly && fSelSDD) return;
1315       if(!(maskSel& AliVEvent::kFastOnly) && fSelNoSDD) return;
1316          
1317
1318       //-- Monitor event cuts --//
1319       fHistNEvents->Fill(1);
1320
1321       //ask for pileup from SPD
1322       Bool_t pileUpSPD = fESD->IsPileupFromSPD();
1323       if(fRejectPileUpSPD && pileUpSPD) return;
1324     
1325       Int_t ntracks = fESD->GetNumberOfTracks();
1326       for(Int_t i=0;i<ntracks;i++){//check sdd event selection
1327         AliESDtrack *tr=   fESD->GetTrack(i);
1328       
1329         Bool_t sdd0 = tr->HasPointOnITSLayer(0);
1330         Bool_t sdd1 = tr->HasPointOnITSLayer(1);
1331         Bool_t sdd2 = tr->HasPointOnITSLayer(2);
1332         Bool_t sdd3 = tr->HasPointOnITSLayer(3);
1333         Bool_t sdd4 = tr->HasPointOnITSLayer(4);
1334         Bool_t sdd5 = tr->HasPointOnITSLayer(5);
1335        
1336         fHistITSLayerHits->Fill(Int_t(sdd0)*(-1),ntracks);
1337         fHistITSLayerHits->Fill(Int_t(sdd1)*1,ntracks);
1338         fHistITSLayerHits->Fill(Int_t(sdd2)*2,ntracks);
1339         fHistITSLayerHits->Fill(Int_t(sdd3)*3,ntracks);
1340         fHistITSLayerHits->Fill(Int_t(sdd4)*4,ntracks);
1341         fHistITSLayerHits->Fill(Int_t(sdd5)*5,ntracks);
1342       }
1343       
1344       //vertex selection
1345       if (vtxESD->GetStatus()){
1346         fHistNEvents->Fill(2);
1347         fHistESDVertexZ->Fill(vtxESD->GetZv());
1348         if(fabs(vtxESD->GetZv()) < fVertexZCut){
1349           fHistMuliplicityRaw->Fill(multV0);
1350           fHistNEvents->Fill(3);
1351           fHistNPrim->Fill(nContr);
1352         
1353           Process();
1354         
1355           fHistMuliplicity->Fill(multV0);
1356         
1357           nContr = vtxESD->GetNContributors();
1358           //  if(nContr<501){
1359           fHistPrimVtxZESDVSNContributors->Fill(vtxESD->GetZv(),nContr);
1360           fHistPrimVtxZESDTPCVSNContributors->Fill(vtxESDTPC->GetZv(),nContr);
1361           //fHistPrimVtxZESDSPDVSNContributorsTPC->Fill(vtxESDSPD->GetZv(),nContr);
1362           //   }
1363           fHistPrimVtxZESD->Fill(vtxESD->GetZv());
1364           fHistPrimVtxZESDTPC->Fill(vtxESDTPC->GetZv());
1365           // fHistPrimVtxZESDSPD->Fill(vtxESDSPD->GetZv());
1366           // -- count events after processing
1367           fHistNEvents->Fill(4);
1368         }
1369       }
1370       else{
1371         if(vtxESDSPD->GetStatus()){
1372           fHistNEvents->Fill(2);
1373         
1374           fHistESDVertexZ->Fill(vtxESDSPD->GetZv());
1375           if(fabs(vtxESDSPD->GetZv()) < fVertexZCut){
1376           
1377             fHistMuliplicityRaw->Fill(multV0);
1378             fHistNEvents->Fill(3);
1379             fHistNPrim->Fill(nContr);
1380           
1381             Process();
1382           
1383             fHistMuliplicity->Fill(multV0);
1384           
1385             nContr = vtxESDSPD->GetNContributors();
1386             //  if(nContr<501){
1387             //fHistPrimVtxZESDVSNContributors->Fill(vtxESD->GetZv(),nContr);
1388             fHistPrimVtxZESDTPCVSNContributors->Fill(vtxESDTPC->GetZv(),nContr);
1389             fHistPrimVtxZESDSPDVSNContributors->Fill(vtxESDSPD->GetZv(),nContr);
1390             // }
1391             // fHistPrimVtxZESD->Fill(vtxESD->GetZv());
1392             fHistPrimVtxZESDTPC->Fill(vtxESDTPC->GetZv());
1393             fHistPrimVtxZESDSPD->Fill(vtxESDSPD->GetZv());
1394             // -- count events after processing
1395             fHistNEvents->Fill(4);
1396           }
1397         }
1398         //else return;
1399       }
1400     }
1401     else{// PbPb analysis
1402       //-- Monitor event cuts --//
1403       fHistNEvents->Fill(1);
1404
1405       if(vtxESD->GetStatus()){
1406         Double_t vtxZ = vtxESD->GetZv();
1407         fHistESDVertexZ->Fill(vtxZ);
1408         if(process){
1409           fHistNEvents->Fill(2);
1410           if(fabs(vtxZ) < fVertexZCut){
1411             nContr = vtxESD->GetNContributors();
1412             fHistMuliplicityRaw->Fill(multV0);
1413             fHistNEvents->Fill(3);
1414             fHistNPrim->Fill(nContr);
1415             Process();
1416             fHistMuliplicity->Fill(multV0);
1417             fHistPrimVtxZESD->Fill(vtxZ);
1418             fHistPrimVtxZESDVSNContributors->Fill(vtxZ,nContr);
1419             // -- count events after processing --//
1420             fHistCentBin->Fill(centBin);
1421             fHistNEvents->Fill(4);
1422           }
1423         }
1424         if(fabs(vtxZ) < fVertexZCut) fHistCentBinRaw->Fill(centBin);
1425       }
1426     }
1427     PostData(1,fOutputContainer);
1428
1429   }
1430
1431   //________________________________________________________________________
1432   void AliAnalysisTaskV0ForRAA::Terminate(Option_t *) {
1433     //terminate
1434   }
1435   //________________________________________________________________________
1436   void AliAnalysisTaskV0ForRAA::Process(){
1437     //run the analysis
1438
1439     Int_t ntracks = fESD->GetNumberOfTracks();
1440     Int_t count = 0;
1441
1442     //-- count number of tracks --//
1443    
1444     if(!(!fMCMode && fMCTruthMode)){
1445       for(Int_t i=0;i<ntracks;i++){
1446         AliESDtrack *track = (AliESDtrack*)fESD->GetTrack(i);
1447         if(!fESDTrackCuts->AcceptTrack(track)) continue;
1448         if( track->Eta() > fEtaCutMCDaughtersVal) continue;
1449         count++;
1450       }
1451       fHistMultiplicityPrimary->Fill(count);
1452     }
1453    
1454     //-- check number of V0s in case of data or mc data like analysis--//
1455     Int_t nV0 = fESD->GetNumberOfV0s();
1456     if(!fMCTruthMode) if(nV0 < 1) return;
1457    
1458     //-- run analysis --//
1459     if(fMCTruthMode)  V0MCTruthLoop();
1460     else  V0RecoLoop(0,0,0,0,0.0,0,0.0,0.0);
1461
1462   }
1463   //________________________________________________________________________
1464   void AliAnalysisTaskV0ForRAA::V0MCTruthLoop(){
1465     //loop over MC truth particles
1466
1467     //-- get MC stack --//
1468     AliStack *stack = fMCev->Stack();
1469
1470     /*
1471     //histo fo user defined shift in charge/pt 
1472     if(fShift){
1473     fHistUserPtShift->Fill(fDeltaInvP);
1474     }
1475     */
1476     /*
1477       AliKFVertex primVtxStart(*(fESD->GetPrimaryVertex()));
1478       Int_t nTracksPrim=primVtxStart.GetNContributors();
1479       fHistNPrim->Fill(nTracksPrim);
1480     */
1481     /*
1482     // MC
1483     
1484     Int_t mcPrimaries = stack->GetNprimary();
1485     Int_t mcParticles    = stack->GetNtrack();
1486     
1487     fHistMultiplicityPrimary->Fill(mcPrimaries);
1488     fHistMCMultiplicityTracks->Fill(mcParticles);
1489     
1490     // number of V0
1491     fHistNV0->Fill(nV0);
1492     if(nTracksPrim>0) {
1493     fHistNV0WithVertex->Fill(nV0);
1494     }
1495     */
1496
1497     //-- MC truht loop for V0s --//
1498     for (Int_t iMc = 0; iMc < (stack->GetNtrack()); iMc++){//MC truth loop
1499       Int_t fillMCtruth= int(fMCTruthMode);
1500       if(fMCTruthMode){
1501         fHistPiPiMonitorMCCuts->Fill(1*fillMCtruth);
1502         fHistPiPMonitorMCCuts[0]->Fill(1*fillMCtruth);
1503         fHistPiAPMonitorMCCuts[0]->Fill(1*fillMCtruth);
1504       }
1505       TParticle *p0 = stack->Particle(iMc);
1506       if(!p0) continue;
1507
1508       if(fMCTruthMode){
1509         fHistPiPiMonitorMCCuts->Fill(2*fillMCtruth);
1510         fHistPiPMonitorMCCuts[0]->Fill(2*fillMCtruth);
1511         fHistPiAPMonitorMCCuts[0]->Fill(2*fillMCtruth);
1512       }
1513
1514
1515
1516       Int_t pdgCode = p0->GetPdgCode();
1517
1518       //-------------- only K0s and Lambda ----------//
1519       if( (pdgCode != 310 ) && ( fabs(pdgCode) != 3122 ) ) continue;
1520       Int_t fillFlagK0 = (3122- fabs(pdgCode))/(3122-310)*fillMCtruth;
1521       Int_t fillFlagL = (fabs(pdgCode) - 310)/(3122-310)*(pdgCode+3122)/(2*3122)*fillMCtruth;
1522       Int_t fillFlagAL = (fabs(pdgCode) - 310)/(3122-310)*(pdgCode-3122)/(-2*3122)*fillMCtruth;
1523     
1524       fHistPiPiMonitorMCCuts->Fill(3*fillFlagK0);
1525       fHistPiPMonitorMCCuts[0]->Fill(3*fillFlagL);
1526       fHistPiAPMonitorMCCuts[0]->Fill(3*fillFlagAL);
1527       
1528       if(p0->GetNDaughters() !=2) continue;
1529       fHistPiPiMonitorMCCuts->Fill(4*fillFlagK0);
1530       fHistPiPMonitorMCCuts[0]->Fill(4*fillFlagL);
1531       fHistPiAPMonitorMCCuts[0]->Fill(4*fillFlagAL);
1532       
1533       //-------------- unique ID check-------------- //
1534       Int_t uniqueID =  p0->GetUniqueID();
1535       if(uniqueID==13) continue;
1536       
1537       fHistPiPiMonitorMCCuts->Fill(5*fillFlagK0);
1538       fHistPiPMonitorMCCuts[0]->Fill(5*fillFlagL);
1539       fHistPiAPMonitorMCCuts[0]->Fill(5*fillFlagAL);
1540       
1541       //-------------- daughters --------------------//
1542       Int_t id0  = p0->GetDaughter(0);
1543       Int_t id1  = p0->GetDaughter(1);
1544       if(id0<0 || id1 <0) continue;
1545       
1546       fHistPiPiMonitorMCCuts->Fill(6*fillFlagK0);
1547       fHistPiPMonitorMCCuts[0]->Fill(6*fillFlagL);
1548       fHistPiAPMonitorMCCuts[0]->Fill(6*fillFlagAL);
1549             
1550       Int_t pdgCodeD0 = stack->Particle(id0)->GetPdgCode();
1551       Int_t pdgCodeD1 = stack->Particle(id1)->GetPdgCode();
1552       
1553       if(pdgCodeD0 == pdgCodeD1) continue;
1554       if(pdgCodeD0*pdgCodeD1>0) continue;
1555       
1556       fHistPiPiMonitorMCCuts->Fill(7*fillFlagK0);
1557       fHistPiPMonitorMCCuts[0]->Fill(7*fillFlagL);
1558       fHistPiAPMonitorMCCuts[0]->Fill(7*fillFlagAL);
1559             
1560       if((fabs(pdgCodeD0) != 211 ) && ( fabs(pdgCodeD0) != 2212 )) continue;
1561       if((fabs(pdgCodeD1) != 211 ) && ( fabs(pdgCodeD1) != 2212 )) continue;
1562       
1563       fHistPiPiMonitorMCCuts->Fill(8*fillFlagK0);
1564       fHistPiPMonitorMCCuts[0]->Fill(8*fillFlagL);
1565       fHistPiAPMonitorMCCuts[0]->Fill(8*fillFlagAL);
1566       
1567       TParticle *p00 =stack->Particle(id0);
1568       TParticle *p01 =stack->Particle(id1);
1569       Double_t etaMC00   = p00->Eta();
1570       Double_t etaMC01   = p01->Eta();
1571
1572       //----------- unique ID check daughters-------- //
1573       Int_t uniqueIDdaughter0 = p00->GetUniqueID();
1574       Int_t uniqueIDdaughter1 = p01->GetUniqueID();
1575       if (uniqueIDdaughter0 !=4 || uniqueIDdaughter1 !=4 ) continue;
1576       
1577       fHistPiPiMonitorMCCuts->Fill(9*fillFlagK0);
1578       fHistPiPMonitorMCCuts[0]->Fill(9*fillFlagL);
1579       fHistPiAPMonitorMCCuts[0]->Fill(9*fillFlagAL);
1580
1581       fHistPiPMonitorMCCuts[1]->Fill(9*fillFlagL);
1582       fHistPiAPMonitorMCCuts[1]->Fill(9*fillFlagAL);
1583       
1584       //------------ check label reco -------------------//
1585       if(fCheckNegLabelReco || fOnlyFoundRecoV0){   // check label reco
1586         Bool_t found =kFALSE;
1587         Int_t label0=0,label1=0;      
1588         AliESDv0 * v0MIsMC=NULL;
1589         AliESDtrack *tr0 = NULL;
1590         AliESDtrack *tr1 = NULL;
1591         for(Int_t recL=0;recL < fESD->GetNumberOfV0s();recL++){
1592           v0MIsMC = fESD->GetV0(recL);
1593           if(!v0MIsMC) continue;
1594           tr0 = fESD->GetTrack(v0MIsMC->GetPindex());
1595           tr1 = fESD->GetTrack(v0MIsMC->GetNindex());
1596           if(tr0 && tr1){
1597             label0 = tr0->GetLabel();
1598             label1 = tr1->GetLabel();
1599             if((fabs(label0) == id0 && fabs(label1) == id1) || 
1600                (fabs(label0) == id1 && fabs(label1) == id0)){
1601               found =kTRUE;
1602               break; 
1603             }     
1604           }
1605         }
1606         if(fCheckNegLabelReco && !fOnlyFoundRecoV0) {
1607           if(found && (label0 <0 || label1 < 0)) continue;
1608         }
1609         else{
1610           if(!found) continue;
1611           if(fCheckNegLabelReco && found && (label0 <0 || label1 < 0)) continue;
1612         }
1613       
1614       }
1615       //-----------get geometric properties --------------//
1616       // DCA of mother to prim vertex = production vertex
1617       //-- primary and secondary vetex --//
1618       Double_t vVertexPrimMC[3];
1619       fMCev->GetPrimaryVertex()->GetXYZ(vVertexPrimMC);
1620       // Double_t x0=p0->Vx(),y0=p0->Vy(),z0=p0->Vz();//mother production vertex
1621     
1622       Double_t x=p00->Vx(),y=p00->Vy(),z=p00->Vz();//daughter vertex =V0 decay vertex
1623       Double_t rx = x - vVertexPrimMC[0];
1624       Double_t ry = y - vVertexPrimMC[1];
1625       Double_t rz = z - vVertexPrimMC[2];
1626       Double_t sdeclength = rx*rx+ry*ry;//+rz*rz;//=p00->Rho();  
1627       Double_t declength =0.0;
1628       if(sdeclength>0) declength = sqrt(sdeclength);
1629       Double_t declength3d = sqrt( rx*rx+ry*ry+rz*rz);
1630       //-- decay radii --//
1631       Double_t rMC2D  = sqrt(x*x+y*y);
1632       const  Double_t xyzMC[3] = {x,y,z};
1633       // Double_t rMC = p00->R();
1634       
1635       //-- phi --//
1636       Double_t pi = TMath::Pi();
1637       Double_t phi = p0->Phi();
1638       if(phi>pi) phi -=2*pi;
1639
1640       //-------------------- V0 variables ----------------//
1641       Double_t rapidity = p0->Y();
1642       Double_t massV0MC = p0->GetMass();
1643       Double_t ptV0MC =  p0->Pt();
1644       Double_t pV0MC =  p0->P();
1645
1646      
1647       //----------------- mother variables-----------------//
1648       Int_t indexMother1  = p0->GetMother(0);
1649       Int_t isSecd=0;
1650       Int_t pdgMother =0;
1651       // Int_t goodMother=1;
1652       Int_t uniqueIDmother=0;
1653       Double_t ptXiMother=0.0;
1654       Double_t rapXiMother = 0.0;
1655
1656
1657       //------check mother and fill mother histos---------//
1658       Bool_t isPrim= stack->IsPhysicalPrimary(iMc);
1659    
1660       if(!isPrim){//prim or sec
1661         isSecd=1;// is secondary V0s
1662         //    cout<<notinjected<<endl;
1663         if(indexMother1 >-1){// && !isPrim){//secondary V0s
1664           //     isSecd=1;// is secondary V0s
1665           //   cout<<fMCev->IsFromBGEvent(indexMother1)<<endl;
1666           // if(fSelectMBMotherMC && !fMCev->IsFromBGEvent(indexMother1)) continue;//xxx only standard hijing particles for sec. lambdas:not needed
1667           //-- check for mother --//
1668           TParticle *mother = stack->Particle(indexMother1);
1669           if(!mother) {
1670             Printf("no mother pointer!");continue;
1671           }
1672           pdgMother = mother->GetPdgCode();
1673           fHistPiPMonitorMCCuts[1]->Fill(11*fillFlagL);
1674           fHistPiAPMonitorMCCuts[1]->Fill(11*fillFlagAL);
1675
1676           //-- check for injejcted --//
1677           Bool_t notinjectedMother = kTRUE;
1678           notinjectedMother = fMCev->IsFromBGEvent(indexMother1);
1679         
1680           if(fSelectInjected && !notinjectedMother ) continue;
1681           fHistPiPMonitorMCCuts[1]->Fill(10*fillMCtruth);
1682           fHistPiAPMonitorMCCuts[1]->Fill(10*fillMCtruth);
1683
1684           Bool_t isPrimMother= stack->IsPhysicalPrimary(indexMother1);
1685           if(!isPrimMother) continue;
1686           fHistPiPMonitorMCCuts[1]->Fill(12*fillFlagL);
1687           fHistPiAPMonitorMCCuts[1]->Fill(12*fillFlagAL);
1688       
1689           uniqueIDmother =  mother->GetUniqueID();
1690
1691           if(uniqueIDmother==13){
1692             //  goodMother =0;
1693             continue;
1694           }
1695           fHistPiPMonitorMCCuts[1]->Fill(13*fillFlagL);
1696           fHistPiAPMonitorMCCuts[1]->Fill(13*fillFlagAL);
1697
1698
1699           //-- fill secondary V0s histos and pdg histos --// 
1700           ptXiMother=mother->Pt();
1701           rapXiMother=mother->Y();
1702         
1703
1704           //-- K0s --//
1705           if(pdgCode==310){
1706             if(fabs(pdgMother)==311 || fabs(pdgMother)==313 || fabs(pdgMother)==323 ) isSecd=0; // from K0L,  K0 and K* as primary
1707             else fHistPiPiPDGCode->Fill(fabs(pdgMother));
1708             //goodMother=1;
1709           }
1710           //-- Lambda --//
1711           if(pdgCode==3122){
1712             fHistPiPPDGCode->Fill(fabs(pdgMother));
1713             if (//sigma family
1714                 ( TMath::Abs(pdgMother) == 3112) || //sigma minus
1715                 ( TMath::Abs(pdgMother) == 3222) || //sigma plus
1716                 ( TMath::Abs(pdgMother) == 3224) || //sigma *plus
1717                 ( TMath::Abs(pdgMother) == 3114) || //sigma *minus
1718                 ( TMath::Abs(pdgMother) == 3214) || //sigma *0 counts as primary????
1719                 ( TMath::Abs(pdgMother) == 3212)    //sigma 0 counts as primary
1720                 )
1721               {
1722                 isSecd=0;
1723                 //goodMother=1;
1724               }
1725            
1726             if( pdgMother == 3322) //xi0
1727               {
1728                 if(!fRapCutV0 || fabs(rapidity)<fRap){
1729                   if(!fEtaCutMCDaughters  ||  (fabs(etaMC00)<fEtaCutMCDaughtersVal|| fabs(etaMC01)<fEtaCutMCDaughtersVal)){
1730                     fHistPiPMassVSPtSecXi[0]->Fill(massV0MC,ptV0MC);
1731                     fHistPiPMassVSYSecXi[0]->Fill(massV0MC,rapidity);
1732                     if(!fRapCutV0 || fabs(rapXiMother)<fRap) fHistPiPXi0PtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1733                   }
1734                 }
1735                 //goodMother=1;
1736               }
1737             if(pdgMother == 3312) //xi minus
1738               {
1739                 if(!fRapCutV0 || fabs(rapidity)<fRap){
1740                   if(!fEtaCutMCDaughters  ||  (fabs(etaMC00)<fEtaCutMCDaughtersVal|| fabs(etaMC01)<fEtaCutMCDaughtersVal)){
1741                     fHistPiPMassVSPtSecXi[0]->Fill(massV0MC,ptV0MC);
1742                     fHistPiPMassVSYSecXi[0]->Fill(massV0MC,rapidity);
1743                     if(!fRapCutV0 || fabs(rapXiMother)<fRap)  fHistPiPXiMinusPtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1744                   }
1745                 }
1746                 //goodMother=1;
1747
1748               }     
1749             if(pdgMother == 3334)//omega-
1750               {
1751                 //  fHistPiPDCAtoPrimVtxOmega[0]->Fill(p0->GetMass(),dcaV0ToPrimVertex);
1752                 if(!fRapCutV0 || fabs(rapXiMother)<fRap) fHistPiPOmegaPtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1753                 fHistPiPMassVSPtSecOmega[0]->Fill(massV0MC,ptV0MC);
1754                 //goodMother=1;
1755               }
1756           }
1757           //-- AntiLambda --//
1758           if(pdgCode==-3122 ){
1759             fHistPiAPPDGCode->Fill(fabs(pdgMother));
1760             if (//sigma family
1761                 ( TMath::Abs(pdgMother) == 3112) ||//sigma minus
1762                 ( TMath::Abs(pdgMother) == 3222) ||//sigma plus
1763                 ( TMath::Abs(pdgMother) == 3224) ||//sigma *plus
1764                 ( TMath::Abs(pdgMother) == 3114) ||//sigma *minus
1765                 ( TMath::Abs(pdgMother) == 3214) || //sigma *0
1766                 ( TMath::Abs(pdgMother) == 3212)    //sigma 0 counts as primary
1767                 )
1768               {
1769                 isSecd=0;
1770                 //          goodMother=1;
1771               }
1772                    
1773             if( pdgMother == -3322) //xi0
1774               {
1775                 if(!fRapCutV0 || fabs(rapidity)<fRap){
1776                   if(!fEtaCutMCDaughters  ||  (fabs(etaMC00)<fEtaCutMCDaughtersVal|| fabs(etaMC01)<fEtaCutMCDaughtersVal)){
1777                     fHistPiAPMassVSPtSecXi[0]->Fill(massV0MC,ptV0MC);
1778                     fHistPiAPMassVSYSecXi[0]->Fill(massV0MC,rapidity);
1779                     if(!fRapCutV0 || fabs(rapXiMother)<fRap) fHistPiAPXi0PtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1780                   }
1781                 }
1782                 // goodMother=1;
1783               }
1784             if(pdgMother == -3312) //xi plus
1785               {
1786                 if(!fRapCutV0 || fabs(rapidity)<fRap){
1787                   if(!fEtaCutMCDaughters  ||  (fabs(etaMC00)<fEtaCutMCDaughtersVal|| fabs(etaMC01)<fEtaCutMCDaughtersVal)){
1788                     fHistPiAPMassVSPtSecXi[0]->Fill(massV0MC,ptV0MC);
1789                     fHistPiAPMassVSYSecXi[0]->Fill(massV0MC,rapidity);
1790                     if(!fRapCutV0 || fabs(rapXiMother)<fRap) fHistPiAPXiMinusPtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1791                   }
1792                 }
1793                 //goodMother=1;
1794               }
1795             if(pdgMother == -3334)//omega+
1796               {
1797                 fHistPiAPOmegaPtVSLambdaPt[0]->Fill(ptV0MC,ptXiMother);
1798                 if(!fRapCutV0 || fabs(rapXiMother)<fRap) fHistPiAPMassVSPtSecOmega[0]->Fill(massV0MC,ptV0MC);
1799                 // fHistPiAPDCAtoPrimVtxOmega[0]->Fill(p0->GetMass(),dcaV0ToPrimVertex);
1800                 // goodMother=1;
1801               }
1802           }
1803         }       
1804       }//end secondaries
1805       else{
1806         //-- check for injejcted --//
1807         Bool_t notinjected = kTRUE;
1808         notinjected = fMCev->IsFromBGEvent(iMc);
1809       
1810         if(fSelectInjected && !notinjected ) continue;
1811         fHistPiPiMonitorMCCuts->Fill(10*fillMCtruth);
1812         fHistPiPMonitorMCCuts[0]->Fill(10*fillMCtruth);
1813         fHistPiAPMonitorMCCuts[0]->Fill(10*fillMCtruth);
1814       }
1815       //else goodMother=1;
1816       // if(!goodMother) continue;// for (A)Lambda important
1817
1818       //-------------- MC truth or reco mode -----------------//
1819       if(fMCTruthMode && !fMCMode){//MC true ana
1820         fHistPiPiMonitorMCCuts->Fill(14*fillFlagK0);
1821         fHistPiPMonitorMCCuts[isSecd]->Fill(14*fillFlagL);
1822         fHistPiAPMonitorMCCuts[isSecd]->Fill(14*fillFlagAL);
1823       
1824         //-- DCA daughters --//
1825         // values of one daugher, should be the same      
1826         /*
1827         //to primary vertex
1828         trackPos->GetImpactParameters(tdcaPosToVertex[0],tdcaPosToVertex[1]);
1829         trackNeg->GetImpactParameters(tdcaNegToVertex[0],tdcaNegToVertex[1]);
1830          
1831         Double_t dcaPosToVertex = TMath::Sqrt(tdcaPosToVertex[0]*tdcaPosToVertex[0]+tdcaPosToVertex[1]*tdcaPosToVertex[1]);
1832         Double_t dcaNegToVertex = TMath::Sqrt(tdcaNegToVertex[0]*tdcaNegToVertex[0]+tdcaNegToVertex[1]*tdcaNegToVertex[1]);
1833         fHistDCADaughtersToPrimVtx[isSecd]->Fill(dcaPosToVertex,dcaNegToVertex);
1834         */
1835          
1836          
1837         //-- armenteros values --//
1838         TVector3 vecPip;
1839         TVector3 vecPin;
1840         
1841         Double_t ptPlus=0, ptMinus=0;
1842         Double_t pt00 = p00->Pt();
1843         Double_t pt01 = p01->Pt();
1844         Double_t  phiPosMC=0.0;
1845             
1846         if(p00->GetPdgCode()<0)
1847           {
1848             vecPip.SetXYZ(p01->Px(),p01->Py(),p01->Pz());
1849             vecPin.SetXYZ(p00->Px(),p00->Py(),p00->Pz());
1850             ptMinus = pt00;
1851             ptPlus = pt01;
1852             phiPosMC = p01->Phi();
1853           }
1854         else{
1855           vecPin.SetXYZ(p01->Px(),p01->Py(),p01->Pz());
1856           vecPip.SetXYZ(p00->Px(),p00->Py(),p00->Pz());
1857           ptMinus = pt01;
1858           ptPlus = pt00;
1859           phiPosMC = p00->Phi();
1860         }
1861             
1862         TVector3 momTot(p0->Px(),p0->Py(),p0->Pz());
1863         Double_t lQlNeg = fabs(vecPin.Dot(momTot)/momTot.Mag());
1864         Double_t lQlPos = fabs(vecPip.Dot(momTot)/momTot.Mag());
1865         Double_t alfa =0.0;
1866         Double_t den = lQlPos + lQlNeg;
1867         if(den>0) alfa = (lQlPos - lQlNeg)/den;
1868         TVector3 qtvec= vecPin.Cross(momTot);//vecPip.Mag()*sqrt(1-pow(thetapip,2));
1869         Float_t qt = qtvec.Mag()/momTot.Mag();
1870       
1871         //clalc masses for test
1872         Double_t massPi=0.13957018;
1873         Double_t massP=0.93827203;
1874
1875         TLorentzVector pionPTest(vecPip, massPi);
1876         TLorentzVector pionNTest(vecPin, massPi);
1877         TLorentzVector k0sTest = pionPTest+pionNTest;
1878
1879         TLorentzVector protPTest(vecPip, massP);
1880         TLorentzVector lambdaTest = protPTest+pionNTest;
1881
1882         TLorentzVector protNTest(vecPin, massP);
1883         TLorentzVector alambdaTest = protNTest+pionPTest;
1884
1885         Double_t calcK0smass = fabs(k0sTest.M());
1886         Double_t calcLambdamass = fabs(lambdaTest.M());
1887         Double_t calcALambdamass = fabs(alambdaTest.M());
1888
1889         if(pdgCode == 310) {
1890           fHistPiPiEtaDMC[isSecd]->Fill(etaMC00,ptV0MC);
1891           fHistPiPiEtaDMC[isSecd]->Fill(etaMC01,ptV0MC);
1892         }
1893         if(fabs(pdgCode) == 3122) {
1894           fHistPiPEtaDMC[isSecd]->Fill(etaMC00,ptV0MC);
1895           fHistPiPEtaDMC[isSecd]->Fill(etaMC01,ptV0MC);
1896         }
1897
1898         //-- rapidity and eta cut --//      
1899         if(fRapCutV0 && fabs(rapidity)>fRap) continue;
1900         fHistPiPiMonitorMCCuts->Fill(15*fillFlagK0);
1901         fHistPiPMonitorMCCuts[isSecd]->Fill(15*fillFlagL);
1902         fHistPiAPMonitorMCCuts[isSecd]->Fill(15*fillFlagAL);
1903          
1904         if(fEtaCutMCDaughters) { if(fabs(etaMC00)>fEtaCutMCDaughtersVal || fabs(etaMC01)>fEtaCutMCDaughtersVal ) continue; }
1905         fHistPiPiMonitorMCCuts->Fill(16*fillFlagK0);
1906         fHistPiPMonitorMCCuts[isSecd]->Fill(16*fillFlagL);
1907         fHistPiAPMonitorMCCuts[isSecd]->Fill(16*fillFlagAL);
1908
1909     
1910         //      Double_t phiMC =   p0->Phi(); 
1911      
1912
1913         //-- Fill Particle histos --//
1914         if (pdgCode==310){//K0s
1915           fHistPiPiMonitorMCCuts->Fill(17);
1916
1917           fHistPiPiEtaDMC[1]->Fill(etaMC00,ptV0MC);
1918           fHistPiPiEtaDMC[1]->Fill(etaMC01,ptV0MC);
1919           
1920           fHistPiPiMass->Fill(massV0MC);
1921           fHistPiPiMassVSPt->Fill(massV0MC,ptV0MC);
1922           fHistPiPiMassVSY->Fill(massV0MC,rapidity);
1923           // fHistPiPiPtDaughters->Fill(ptMinus,ptPlus);
1924           fHistPiPiPtVSY->Fill(rapidity,ptV0MC);
1925            
1926           Double_t ctTK0s=0.0,ctK0s=0.0;
1927           if(pV0MC>0.0) ctK0s=declength3d*0.497614/pV0MC;
1928           if(ptV0MC>0.0) ctTK0s=declength*0.497614/ptV0MC;
1929           fHistPiPiDecayLengthResolution->Fill(declength3d,declength);
1930           fHistPiPiDecayLengthVsPt->Fill(ptV0MC,declength);//ptV0MC,ctK0s);
1931           fHistPiPiDecayLengthVsCtau->Fill(massV0MC,ctTK0s);
1932           fHistPiPiDecayLengthVsMass->Fill(massV0MC,declength);
1933           //all V0s histo
1934           fHistArmenteros[isSecd]->Fill(alfa,qt);
1935           fHistV0RadiusZ[isSecd]->Fill(rMC2D,xyzMC[2]);
1936           fHistV0RadiusXY[isSecd]->Fill(xyzMC[0],xyzMC[1]);
1937           fHistV0RadiusZVSPt[isSecd]->Fill(ptV0MC,xyzMC[2]);
1938           //    fHistPiPiPhiPosVsPtPosVsMass->Fill(massV0MC,declength,ptV0MC);//,ctK0s);//phiPosMC);//xxx
1939           fHistPiPiK0sVsLambdaMass->Fill(calcLambdamass,calcK0smass);
1940           fHistPiPiK0sVsALambdaMass->Fill(calcALambdamass,calcK0smass);     
1941         }
1942         if (pdgCode==3122){ //Lambda
1943           fHistPiPMonitorMCCuts[isSecd]->Fill(17);
1944         
1945           fHistPiPEtaDMC[1]->Fill(etaMC00,ptV0MC);
1946           fHistPiPEtaDMC[1]->Fill(etaMC01,ptV0MC);
1947
1948           fHistPiPMassVSPt[isSecd]->Fill(massV0MC,ptV0MC);
1949           fHistPiPMass[isSecd]->Fill(massV0MC);  
1950           fHistPiPMassVSY[isSecd]->Fill(massV0MC,rapidity);
1951           //  fHistPiPPtDaughters[isSecd]->Fill(ptMinus,ptPlus);
1952           fHistPiPPtVSY[isSecd]->Fill(rapidity,ptV0MC);
1953            
1954           Double_t ctTL=0.0, ctL=0.0;
1955           if(pV0MC>0.0) ctL=declength3d*1.115683/pV0MC;
1956           if(ptV0MC>0.0) ctTL=declength*1.115683/ptV0MC;
1957           fHistPiPDecayLengthResolution[0]->Fill(declength3d,declength);
1958           fHistPiPDecayLengthVsPt[isSecd]->Fill(ptV0MC,declength);//(ptV0MC,ctL);
1959           fHistPiPDecayLengthVsCtau[isSecd]->Fill(massV0MC,ctTL);
1960           fHistPiPDecayLengthVsMass[isSecd]->Fill(massV0MC,declength);
1961           //all V0s hito        
1962           fHistArmenteros[isSecd]->Fill(alfa,qt);
1963           fHistV0RadiusZ[isSecd]->Fill(rMC2D,xyzMC[2]);
1964           fHistV0RadiusXY[isSecd]->Fill(xyzMC[0],xyzMC[1]);
1965           fHistV0RadiusZVSPt[isSecd]->Fill(ptV0MC,xyzMC[2]);
1966           //    fHistPiPPhiPosVsPtPosVsMass->Fill(massV0MC,declength,ptV0MC);//,ctK0s);//phiPosMC);//xxx
1967           fHistPiPK0sVsLambdaMass->Fill(calcLambdamass,calcK0smass);
1968         }
1969         if (pdgCode==-3122){ //AntiLambda
1970           fHistPiAPMonitorMCCuts[isSecd]->Fill(17);
1971             
1972           fHistPiPEtaDMC[1]->Fill(etaMC00,ptV0MC);
1973           fHistPiPEtaDMC[1]->Fill(etaMC01,ptV0MC);
1974
1975           fHistPiAPMassVSPt[isSecd]->Fill(massV0MC,ptV0MC);
1976           fHistPiAPMass[isSecd]->Fill(massV0MC);
1977           fHistPiPMassVSY[isSecd]->Fill(massV0MC,rapidity);
1978           //  fHistPiAPPtDaughters[isSecd]->Fill(ptMinus,ptPlus);
1979           fHistPiAPPtVSY[isSecd]->Fill(rapidity,ptV0MC);
1980           
1981           Double_t ctTL=0.0, ctL=0.0;
1982           if(pV0MC>0.0) ctL=declength3d*1.115683/pV0MC;
1983           if(ptV0MC>0.0) ctTL=declength*1.115683/ptV0MC;
1984           fHistPiAPDecayLengthResolution[0]->Fill(declength3d,declength);
1985           fHistPiAPDecayLengthVsPt[isSecd]->Fill(ptV0MC,declength);//(ptV0MC,ctAL);
1986           fHistPiAPDecayLengthVsCtau[isSecd]->Fill(massV0MC,ctL);
1987           fHistPiAPDecayLengthVsMass[isSecd]->Fill(massV0MC,ctTL);//declength);
1988           //all V0s histo          
1989           fHistArmenteros[isSecd]->Fill(alfa,qt);
1990           fHistV0RadiusZ[isSecd]->Fill(rMC2D,xyzMC[2]);
1991           fHistV0RadiusXY[isSecd]->Fill(xyzMC[0],xyzMC[1]);
1992           fHistV0RadiusZVSPt[isSecd]->Fill(ptV0MC,xyzMC[2]);
1993           fHistV0RadiusXYVSY[isSecd]->Fill(rapidity,rMC2D);
1994           fHistPiAPK0sVsALambdaMass->Fill(calcALambdamass,calcK0smass);
1995         }
1996       }//MC true ana
1997       else{// V0 reco ana
1998         V0RecoLoop(id0,id1,isSecd,pdgCode,ptV0MC,pdgMother,ptXiMother,declength);
1999       }
2000       
2001     }//end MC stack loop
2002   }
2003   //________________________________________________________________________
2004   void AliAnalysisTaskV0ForRAA::V0RecoLoop(Int_t id0,Int_t id1,Int_t isSecd,Int_t what,Double_t ptV0MC, Int_t pdgMother,Double_t ptXiMother,Double_t declengthV0MC){
2005     //loop over reconstructed particles
2006
2007    
2008     //--------------------- define variables -----------------------//
2009     Double_t pp[3];
2010     Double_t pm[3];
2011     Double_t xr[3];
2012    
2013     Double_t massPi=0.13957018;
2014     Double_t massP=0.93827203;
2015   
2016     TLorentzVector positivesMIP;
2017     TLorentzVector negativesMIAP;
2018     TLorentzVector positivesMIPi;
2019     TLorentzVector negativesMIPi;
2020
2021     /*
2022       AliKFParticle::SetField(fESD->GetMagneticField());
2023       AliKFVertex primVtx(*(fESD->GetPrimaryVertex()));
2024       AliKFVertex primVtxImproved = primVtx;
2025
2026       AliKFParticle* negPiKF=NULL;
2027       AliKFParticle* posPiKF=NULL;
2028       AliKFParticle* posPKF=NULL;
2029       AliKFParticle* negAPKF=NULL;
2030     */
2031
2032     AliESDtrack* trackPos=NULL;
2033     AliESDtrack* trackNeg=NULL;
2034     AliESDtrack* trackPosTest = NULL;
2035     AliESDtrack* trackNegTest =NULL;
2036
2037     Double_t primaryVtxPosition[3];
2038     primaryVtxPosition[0] = fESD->GetPrimaryVertex()->GetXv();
2039     primaryVtxPosition[1] = fESD->GetPrimaryVertex()->GetYv();
2040     primaryVtxPosition[2] = fESD->GetPrimaryVertex()->GetZv();
2041    
2042     Int_t nV0 = fESD->GetNumberOfV0s();
2043     AliESDv0 * v0MIs=NULL;
2044
2045
2046     //    Int_t on =0,off=0;
2047     Bool_t stopLoop = kFALSE;
2048     //------------------------ V0 reco loop --------------------//
2049     for(Int_t iV0MI = 0; iV0MI < nV0; iV0MI++) {//V0 loop
2050       //-- get V0 info --//
2051       // cout<<iV0MI<<endl;
2052       if(stopLoop) break;
2053          
2054       v0MIs = fESD->GetV0(iV0MI);
2055       if(!v0MIs ) continue;
2056
2057       // cout<<"after: "<<iV0MI<<endl;
2058       fHistPiPiMonitorCuts->Fill(1);
2059       fHistPiPMonitorCuts[isSecd]->Fill(1);
2060       fHistPiAPMonitorCuts[isSecd]->Fill(1);
2061
2062       //------------ get references of daughters --------------//
2063       //-- esd tracks --//
2064       trackPosTest = fESD->GetTrack(v0MIs->GetPindex());
2065       trackNegTest = fESD->GetTrack(v0MIs->GetNindex());
2066      
2067       if ( trackPosTest->GetSign() == trackNegTest->GetSign()) continue;
2068          
2069       fHistPiPiMonitorCuts->Fill(2);
2070       fHistPiPMonitorCuts[isSecd]->Fill(2);
2071       fHistPiAPMonitorCuts[isSecd]->Fill(2);
2072
2073       Bool_t onthefly = v0MIs->GetOnFlyStatus();
2074       if(fOntheFly!=onthefly) continue;
2075       //  cout<<"onthefly "<<onthefly<<endl;
2076       // if(onthefly) on++;
2077       // else off++;
2078           
2079       fHistPiPiMonitorCuts->Fill(3);
2080       fHistPiPMonitorCuts[isSecd]->Fill(3);
2081       fHistPiAPMonitorCuts[isSecd]->Fill(3);
2082          
2083       //-- for MC mode --//
2084       if(fMCMode){
2085         //check MC labels (and find partners for MC truth V0 daughters for fMCTruthMode=kTRUE)
2086         if(!GetMCTruthPartner(trackPosTest,trackNegTest,id0,id1)) continue;
2087         else stopLoop = kTRUE;
2088       }
2089
2090       fHistPiPiMonitorCuts->Fill(4);
2091       fHistPiPMonitorCuts[isSecd]->Fill(4);
2092       fHistPiAPMonitorCuts[isSecd]->Fill(4);
2093      
2094       //-- onthefly selection --//
2095       //  Bool_t onthefly = v0MIs->GetOnFlyStatus();
2096       //         if(fOntheFly!=onthefly) continue;
2097          
2098    
2099       //         fHistPiPiMonitorCuts[isSecd]->Fill(4);
2100       //         fHistPiPMonitorCuts[isSecd]->Fill(4);
2101       //         fHistPiAPMonitorCuts[isSecd]->Fill(4);
2102          
2103       //--  get eta from V0 daughters --//
2104       Double_t posDaughterEta=0.0;
2105       Double_t negDaughterEta=0.0;
2106       Double_t posDaughterPhi=0.0;
2107       Double_t negDaughterPhi=0.0;
2108          
2109       Double_t eta00 = trackPosTest->Eta();
2110       Double_t eta01 = trackNegTest->Eta();
2111             
2112
2113       Int_t indexPos = 0,indexNeg=0;
2114       //---------- check sign assignment for daughters --------//
2115       Bool_t switchSign = kFALSE;
2116      
2117       if( trackPosTest->GetSign() >0){//pos
2118         indexPos = v0MIs->GetPindex();
2119         indexNeg = v0MIs->GetNindex();
2120
2121         //  trackPos =fESD->GetTrack(indexPos);
2122         //  trackNeg =fESD->GetTrack(indexNeg);
2123
2124         v0MIs->GetPPxPyPz(pp[0],pp[1],pp[2]);
2125         v0MIs->GetNPxPyPz(pm[0],pm[1],pm[2]);
2126
2127         posDaughterEta = v0MIs->GetParamP()->Eta();
2128         negDaughterEta = v0MIs->GetParamN()->Eta();
2129         posDaughterPhi = v0MIs->GetParamP()->Phi();
2130         negDaughterPhi = v0MIs->GetParamN()->Phi();
2131         /*      
2132                 if (negPiKF) delete negPiKF; negPiKF=NULL;
2133                 if (posPiKF) delete posPiKF; posPiKF=NULL;
2134                 if (posPKF) delete posPKF; posPKF=NULL;
2135                 if (negAPKF) delete negAPKF; negAPKF=NULL;
2136
2137                 negPiKF = new AliKFParticle( *(v0MIs->GetParamN()) ,-211);
2138                 posPiKF = new AliKFParticle( *(v0MIs->GetParamP()) ,211);
2139                 posPKF = new AliKFParticle( *(v0MIs->GetParamP()) ,2212);
2140                 negAPKF = new AliKFParticle( *(v0MIs->GetParamN()) ,-2212);
2141         */
2142             
2143       }
2144       if( trackPosTest->GetSign() <0){//neg
2145
2146         indexPos = v0MIs->GetNindex();
2147         indexNeg = v0MIs->GetPindex();
2148
2149         // trackPos =fESD->GetTrack(indexPos);
2150         // trackNeg =fESD->GetTrack(indexNeg);
2151      
2152         v0MIs->GetNPxPyPz(pp[0],pp[1],pp[2]);
2153         v0MIs->GetPPxPyPz(pm[0],pm[1],pm[2]);
2154       
2155         posDaughterEta = v0MIs->GetParamN()->Eta();
2156         negDaughterEta = v0MIs->GetParamP()->Eta();
2157         posDaughterPhi = v0MIs->GetParamN()->Phi();
2158         negDaughterPhi = v0MIs->GetParamP()->Phi();
2159         /*
2160           if (negPiKF) delete negPiKF; negPiKF=NULL;
2161           if (posPiKF) delete posPiKF; posPiKF=NULL;
2162           if (posPKF) delete posPKF; posPKF=NULL;
2163           if (negAPKF) delete negAPKF; negAPKF=NULL;
2164
2165
2166           negPiKF = new AliKFParticle( *(v0MIs->GetParamP()) ,-211);
2167           posPiKF = new AliKFParticle( *(v0MIs->GetParamN()) ,211);
2168           posPKF = new AliKFParticle( *(v0MIs->GetParamN()) ,2212);
2169           negAPKF = new AliKFParticle( *(v0MIs->GetParamP()) ,-2212);
2170         */
2171       
2172         switchSign = kTRUE;
2173         eta01 = trackPosTest->Eta();
2174         eta00 = trackNegTest->Eta();
2175
2176       }
2177     
2178       trackPos =fESD->GetTrack(indexPos);
2179       trackNeg =fESD->GetTrack(indexNeg);
2180     
2181       // ------------- calc masses and 4 vectors -------------- //
2182       //K0
2183       positivesMIPi.SetXYZM(pp[0],pp[1],pp[2],massPi);
2184       negativesMIPi.SetXYZM(pm[0],pm[1],pm[2],massPi);
2185       TLorentzVector v0K0=positivesMIPi+negativesMIPi;
2186     
2187       //Lambda
2188       positivesMIP.SetXYZM(pp[0],pp[1],pp[2],massP);
2189       TLorentzVector v0Lambda=positivesMIP+negativesMIPi;
2190      
2191       //Anitlambda
2192       negativesMIAP.SetXYZM(pm[0],pm[1],pm[2],massP);
2193       TLorentzVector v0ALambda=positivesMIPi+negativesMIAP;
2194
2195       //---------------------AliKFParticle ---------------------//
2196       /*  
2197           Double_t chi2K0C=0.0;
2198           Double_t chi2LambdaC=0.0;
2199           Double_t chi2ALambdaC=0.0;
2200
2201      
2202           AliKFParticle v0K0KF;
2203           v0K0KF +=(*negPiKF);
2204           v0K0KF +=(*posPiKF);
2205           //v0K0C.SetVtxGuess(xr[0],xr[1],xr[2]);
2206           v0K0KF.SetProductionVertex(primVtxImproved);
2207           
2208           AliKFParticle v0LambdaKF;
2209           v0LambdaKF +=(*negPiKF);
2210           v0LambdaKF +=(*posPKF);
2211           //v0LambdaC.SetVtxGuess(xr[0],xr[1],xr[2]);
2212           v0LambdaKF.SetProductionVertex(primVtxImproved);
2213           
2214           AliKFParticle v0ALambdaKF;
2215           v0ALambdaKF +=(*negAPKF);
2216           v0ALambdaKF +=(*posPiKF);
2217           //v0ALambdaC.SetVtxGuess(xr[0],xr[1],xr[2]);
2218           v0ALambdaKF.SetProductionVertex(primVtxImproved);
2219         
2220           if( v0K0KF.GetNDF() != 0) {
2221           chi2K0C = v0K0KF.GetChi2()/v0K0KF.GetNDF();
2222           }
2223
2224           Double_t chi2LambdaC=100000.;
2225           if( v0LambdaKF.GetNDF() != 0) {
2226           chi2LambdaC = v0LambdaKF.GetChi2()/v0LambdaKF.GetNDF();
2227           }
2228
2229           Double_t chi2ALambdaC=100000.;
2230           if( v0ALambdaKF.GetNDF() != 0) {
2231           chi2ALambdaC = v0ALambdaKF.GetChi2()/v0ALambdaKF.GetNDF();
2232           }
2233       */
2234       
2235       // ----------------- for MC mode ------------------------ //
2236       Bool_t fillK0sMC = kTRUE;
2237       Bool_t fillLambdaMC = kTRUE;
2238       Bool_t fillALambdaMC = kTRUE;
2239
2240       if(fMCMode && fMCTruthMode) {
2241         if(what == 310) {
2242           fillLambdaMC = kFALSE;
2243           fillALambdaMC = kFALSE;
2244         }
2245         else if(what == 3122){
2246           fillALambdaMC = kFALSE;
2247           fillK0sMC = kFALSE;
2248         }
2249         else if(what == -3122){
2250           fillLambdaMC = kFALSE;
2251           fillK0sMC = kFALSE;
2252         }
2253       }
2254    
2255       //----------------- prepare for V0 ana ------------------//
2256       TVector3 ppTrack(pp);
2257       TVector3 pmTrack(pm);
2258       
2259       //      Double_t posDaughterPt = ppTrack.Pt();
2260       //      Double_t negDaughterPt = pmTrack.Pt();
2261
2262
2263       //         Double_t phiPos = trackPos->Phi();
2264       //Double_t phiNeg = trackNeg->Phi();
2265       
2266       /*
2267         Double_t v0sPt=v0MIs->Pt();
2268         if(what == 310 || what ==0){
2269         fHistPiPiEtaDReco[0]->Fill(posDaughterPt,v0sPt);
2270         fHistPiPiEtaDReco[0]->Fill(negDaughterPt,v0sPt);
2271         }
2272         if(fabs(what) == 3122 || what == 0){
2273         fHistPiPEtaDReco[0]->Fill(posDaughterPt,v0sPt);
2274         fHistPiPEtaDReco[0]->Fill(negDaughterPt,v0sPt);
2275         }
2276       */
2277      
2278       //------------------- DCA daughters ---------------------//
2279       v0MIs->GetXYZ(xr[0],xr[1],xr[2]);   
2280     
2281       //-- between the daughters --//
2282       Double_t dcaDaughters = v0MIs->GetDcaV0Daughters();  
2283     
2284       //-- to primary vertex --
2285       /* 
2286          Float_t bP[2],bN[2];
2287          Float_t bCovP[3],bCovN[3];
2288     
2289          trackPos->GetImpactParameters(bP,bCovP);
2290          trackNeg->GetImpactParameters(bN,bCovN);
2291     
2292          if (bCovP[0]<=0 || bCovP[2]<=0) {
2293          AliDebug(1, "Estimated b resolution lower or equal zero!");
2294          bCovP[0]=0; bCovP[2]=0;
2295          }
2296          if (bCovN[0]<=0 || bCovN[2]<=0) {
2297          AliDebug(1, "Estimated b resolution lower or equal zero!");
2298          bCovN[0]=0; bCovN[2]=0;
2299          }
2300     
2301          Float_t dcaToVertexZPos = bP[1];//Float_t dcaToVertexXY = b[0];
2302          Float_t dcaToVertexZNeg = bN[1];//Float_t dcaToVertexXY = b[0];    
2303       */
2304       /*  
2305           Float_t dcaToVertexZPos = 0.0, dcaToVertexZNeg = 0.0;
2306           Float_t bP=0.0,bN=0.0;
2307           trackPos->GetImpactParameters(bP,dcaToVertexZPos);
2308           trackNeg->GetImpactParameters(bN,dcaToVertexZNeg);
2309       */
2310
2311       Double_t dcaToVertexZPos = 0.0, dcaToVertexZNeg = 0.0;
2312       AliExternalTrackParam *parPos = NULL;
2313       AliExternalTrackParam *parNeg = NULL;
2314       Double_t dcaYZP[2],dcaYZN[2],covar[3];
2315       if(!switchSign){
2316         parPos = new AliExternalTrackParam( *v0MIs->GetParamP());
2317         parNeg = new AliExternalTrackParam( *v0MIs->GetParamN());
2318       }
2319       else{
2320         parPos = new AliExternalTrackParam( *v0MIs->GetParamN());
2321         parNeg = new AliExternalTrackParam( *v0MIs->GetParamP());
2322       }
2323       Bool_t checkProp = parPos->PropagateToDCA(fESD->GetPrimaryVertex(),fESD->GetMagneticField(),40.0,dcaYZP,covar);
2324       dcaToVertexZPos =  dcaYZP[1];
2325       delete parPos;
2326       checkProp = parNeg->PropagateToDCA(fESD->GetPrimaryVertex(),fESD->GetMagneticField(),40.0,dcaYZN,covar);
2327       dcaToVertexZNeg =  dcaYZN[1];
2328       delete parNeg;
2329
2330
2331       Double_t dcaPosToVertex=0.0,dcaNegToVertex=0.0;
2332       Double_t dzPos=(primaryVtxPosition[0]-xr[0])*ppTrack.Y() - (primaryVtxPosition[1]-xr[1])*ppTrack.X();
2333       dcaPosToVertex=TMath::Sqrt(dzPos*dzPos/(pow(ppTrack.X(),2)+pow(ppTrack.Y(),2)));
2334       Double_t dzNeg=(primaryVtxPosition[0]-xr[0])*pmTrack.Y() - (primaryVtxPosition[1]-xr[1])*pmTrack.X();
2335       dcaNegToVertex=TMath::Sqrt(dzNeg*dzNeg/(pow(pmTrack.X(),2)+pow(pmTrack.Y(),2)));
2336      
2337       // Double_t dcaPosToVertex[3];dcaNegToVertex[3];
2338       // trackPos->GetImpactParameters(dcaPosToVertex[0],dcaPosToVertex[1]);
2339       // trackNeg->GetImpactParameters(dcaNegToVertex[0],dcaNegToVertex[1]);
2340          
2341       // dcaPosToVertex = TMath::Sqrt(dcaPosToVertex[0]*dcaPosToVertex[0]+dcaPosToVertex[1]*dcaPosToVertex[1]);
2342       // dcaNegToVertex = TMath::Sqrt(dcaNegToVertex[0]*dcaNegToVertex[0]+dcaNegToVertex[1]*dcaNegToVertex[1]);
2343          
2344       //dcaPosToVertex  =   posPKF->GetDistanceFromVertexXY(primaryVtxPosition);
2345       //dcaNegToVertex  =   negPiKF->GetDistanceFromVertexXY(primaryVtxPosition);
2346         
2347       //------------------- dca and decay radius V0 -------------//
2348    
2349        
2350       Double_t dim2V0Radius= sqrt(   pow(xr[0] - primaryVtxPosition[0],2.0)
2351                                      +pow(xr[1] - primaryVtxPosition[1],2.0));//TMath::Sqrt(xr[0]*xr[0]+xr[1]*xr[1]);
2352
2353       Double_t decayLength = sqrt( pow(xr[0] - primaryVtxPosition[0],2.0) 
2354                                    +pow(xr[1] - primaryVtxPosition[1],2.0)
2355                                    +pow(xr[2] - primaryVtxPosition[2],2.0)
2356                                    );
2357   
2358          
2359       Double_t  dcaV0ToPrimVertex= v0MIs->GetD(primaryVtxPosition[0],primaryVtxPosition[1]);////v0K0KF.GetDistanceFromVertexXY(tPrimaryVtxPosition);
2360
2361       //-------------------- general cuts -------------------//
2362       //-- esd track cuts for daughters --//
2363       // if(fESDTrackCuts){
2364       //   if(!fESDTrackCuts->AcceptTrack(trackPosTest)) continue;
2365       //   if(!fESDTrackCuts->AcceptTrack(trackNegTest)) continue;
2366       // }
2367       
2368       // fHistPiPiMonitorCuts->Fill(5);
2369       // fHistPiPMonitorCuts[isSecd]->Fill(5);
2370       // fHistPiAPMonitorCuts[isSecd]->Fill(5);
2371       
2372       //-- eta cut --//
2373       if( fabs(posDaughterEta) > fEtaCutMCDaughtersVal || fabs(negDaughterEta) > fEtaCutMCDaughtersVal) continue;
2374       fHistPiPiMonitorCuts->Fill(5);
2375       fHistPiPMonitorCuts[isSecd]->Fill(5);
2376       fHistPiAPMonitorCuts[isSecd]->Fill(5);
2377
2378
2379       
2380       //-- radius xy min cut --//
2381       if(dim2V0Radius < fDecayRadXYMin) continue;
2382       //            if(fabs(xr[1])<fDecayRadY) continue;
2383       fHistPiPiMonitorCuts->Fill(6);
2384       fHistPiPMonitorCuts[isSecd]->Fill(6);
2385       fHistPiAPMonitorCuts[isSecd]->Fill(6);
2386
2387       //-- radius xy max cut --//
2388       if(dim2V0Radius > fDecayRadXYMax) continue;
2389       //            if(fabs(xr[1])<fDecayRadY) continue;
2390       fHistPiPiMonitorCuts->Fill(7);
2391       fHistPiPMonitorCuts[isSecd]->Fill(7);
2392       fHistPiAPMonitorCuts[isSecd]->Fill(7);
2393       
2394       //-- decay length min ->ctau --//
2395       if(decayLength > fDecayLengthMax) continue;
2396       fHistPiPiMonitorCuts->Fill(8);
2397       fHistPiPMonitorCuts[isSecd]->Fill(8);
2398       fHistPiAPMonitorCuts[isSecd]->Fill(8);
2399          
2400       //-- decay length min cut --//
2401       if(decayLength < fDecayLengthMin) continue;
2402       fHistPiPiMonitorCuts->Fill(9);
2403       fHistPiPMonitorCuts[isSecd]->Fill(9);
2404       fHistPiAPMonitorCuts[isSecd]->Fill(9);
2405    
2406       //------------------------ detector values -------------------------------//
2407       //-- TPC ITS values pos --//
2408       Int_t nclsTPCPos =  trackPos->GetNcls(1);
2409       Int_t nclsTPCFindablePos =  trackPos->GetTPCNclsF();
2410       Int_t nclsITSPos =  trackPos->GetNcls(0);
2411       Double_t chi2PerClusterITSPos = -1.0;
2412       if(nclsITSPos>0) chi2PerClusterITSPos = trackPos->GetITSchi2()/Double_t(nclsITSPos);
2413       Double_t crossedRowsTPCPos = trackPos->GetTPCCrossedRows();
2414       
2415       //-- TPC ITS values neg --//
2416       Int_t nclsTPCNeg =  trackNeg->GetNcls(1);
2417       Int_t nclsTPCFindableNeg =  trackNeg->GetTPCNclsF();
2418       Int_t nclsITSNeg =  trackNeg->GetNcls(0);
2419       Double_t chi2PerClusterITSNeg = -1.0;
2420       if(nclsITSNeg>0) chi2PerClusterITSNeg =trackNeg->GetITSchi2()/Double_t(nclsITSNeg);
2421       Double_t crossedRowsTPCNeg = trackNeg->GetTPCCrossedRows();    
2422
2423       Double_t ratio = 10.0;
2424       if(nclsTPCFindableNeg >0.0) ratio =double(crossedRowsTPCNeg)/ double(nclsTPCFindableNeg);
2425     
2426       Double_t ratioPos = 10.0;
2427       if(nclsTPCFindablePos >0.0) ratioPos =double(crossedRowsTPCPos)/ double(nclsTPCFindablePos);
2428     
2429       Double_t ratioFoFi = 10.0;
2430       if(nclsTPCFindableNeg >0.0) ratioFoFi =double(nclsTPCNeg)/ double(nclsTPCFindableNeg);
2431     
2432       Double_t ratioFoFiPos = 10.0;
2433       if(nclsTPCFindablePos >0.0) ratioFoFiPos =double(nclsTPCPos)/ double(nclsTPCFindablePos);
2434       
2435       
2436
2437       if(fMoreNclsThanRows && (crossedRowsTPCPos < nclsTPCPos || crossedRowsTPCNeg < nclsTPCNeg  )) continue;
2438       fHistPiPiMonitorCuts->Fill(10);
2439       fHistPiPMonitorCuts[isSecd]->Fill(10);
2440       fHistPiAPMonitorCuts[isSecd]->Fill(10);
2441       
2442       if(fMoreNclsThanFindable && (nclsTPCFindablePos < nclsTPCPos || nclsTPCFindableNeg < nclsTPCNeg  )) continue;
2443       fHistPiPiMonitorCuts->Fill(11);
2444       fHistPiPMonitorCuts[isSecd]->Fill(11);
2445       fHistPiAPMonitorCuts[isSecd]->Fill(11);      
2446
2447       if(fMoreNclsThanFindableMax && ( nclsTPCPos < (nclsTPCFindablePos -60.0) || nclsTPCNeg < (nclsTPCFindableNeg - 60.0) )) continue;
2448       // if(chi2PerClusterITSNeg > fChi2PerClusterITS || chi2PerClusterITSPos > fChi2PerClusterITS ) continue;
2449       fHistPiPiMonitorCuts->Fill(12);
2450       fHistPiPMonitorCuts[isSecd]->Fill(12);
2451       fHistPiAPMonitorCuts[isSecd]->Fill(12);  
2452       
2453       if(ratio > fRatioMaxCRowsOverFindable || ratioPos > fRatioMaxCRowsOverFindable) continue; 
2454
2455       if(ratioFoFi < fRatioFoundOverFindable || ratioFoFiPos < fRatioFoundOverFindable) continue; 
2456       fHistPiPiMonitorCuts->Fill(13);
2457       fHistPiPMonitorCuts[isSecd]->Fill(13);
2458       fHistPiAPMonitorCuts[isSecd]->Fill(13); 
2459
2460       Bool_t cutOKITSNegNeg =kTRUE;
2461       Bool_t cutOKITSPosPos =kTRUE;
2462
2463       Bool_t cutOKITSNegPos =kTRUE;
2464       Bool_t cutOKITSPosNeg =kTRUE;
2465
2466       if(nclsITSNeg < fMinNCLSITSNeg ||  nclsITSNeg > fMaxNCLSITSNeg){
2467         if(!fSwitchCaseITSCls) continue;
2468         else cutOKITSNegNeg = kFALSE;
2469       }
2470   
2471       fHistPiPiMonitorCuts->Fill(14);
2472       fHistPiPMonitorCuts[isSecd]->Fill(14);
2473       fHistPiAPMonitorCuts[isSecd]->Fill(14); 
2474
2475       if(nclsITSPos < fMinNCLSITSPos || nclsITSPos > fMaxNCLSITSPos){
2476         if(dim2V0Radius >= fDecRadCutITSMin  && dim2V0Radius < fDecRadCutITSMax){//only for a certain decay radius 2D in xy
2477           if(!fSwitchCaseITSCls) continue;
2478           else cutOKITSPosPos = kFALSE;
2479         }
2480       }
2481     
2482       if(fSwitchCaseITSCls){
2483         if(nclsITSPos < fMinNCLSITSNeg || nclsITSPos > fMaxNCLSITSNeg){
2484           if(dim2V0Radius >= fDecRadCutITSMin  && dim2V0Radius < fDecRadCutITSMax){//only for a certain decay radius 2D in xy
2485             cutOKITSPosNeg = kFALSE;
2486           }
2487         }
2488         if(nclsITSNeg < fMinNCLSITSPos || nclsITSNeg > fMaxNCLSITSPos){
2489           if(dim2V0Radius >= fDecRadCutITSMin  && dim2V0Radius < fDecRadCutITSMax){//only for a certain decay radius 2D in xy    
2490             cutOKITSNegPos = kFALSE;
2491           }      
2492         }
2493       
2494         if(!(cutOKITSNegPos && cutOKITSPosNeg) && !(cutOKITSNegNeg && cutOKITSPosPos) ) continue;
2495       }
2496
2497       fHistPiPiMonitorCuts->Fill(15);
2498       fHistPiPMonitorCuts[isSecd]->Fill(15);
2499       fHistPiAPMonitorCuts[isSecd]->Fill(15); 
2500
2501     
2502       Double_t lengthTPCPos = trackPos->GetLengthInActiveZone(0,3,236, fESD->GetMagneticField(),0,0);//-5 ,0,0);
2503       Double_t lengthTPCNeg = trackNeg->GetLengthInActiveZone(0,3,236, fESD->GetMagneticField(),0,0);//-5 ,0,0);
2504    
2505
2506       if(fCutMITrackLength && lengthTPCPos <=  fCutMITrackLengthLengthF * (130.0 - 5.0*fabs(trackPos->GetSigned1Pt()))) continue;
2507       fHistPiPiMonitorCuts->Fill(16);
2508       fHistPiPMonitorCuts[isSecd]->Fill(16);
2509       fHistPiAPMonitorCuts[isSecd]->Fill(16); 
2510       if(fCutMITrackLength && lengthTPCNeg <=  fCutMITrackLengthLengthF * (130.0 - 5.0*fabs(trackNeg->GetSigned1Pt()))) continue;
2511       fHistPiPiMonitorCuts->Fill(17);
2512       fHistPiPMonitorCuts[isSecd]->Fill(17);
2513       fHistPiAPMonitorCuts[isSecd]->Fill(17); 
2514
2515
2516       if(fCutMICrossedR && trackPos->GetTPCClusterInfo(3,1) <= fCutMICrossedRLengthF *(130.0 - 5.0*fabs(trackPos->GetSigned1Pt()))) continue;
2517       fHistPiPiMonitorCuts->Fill(18);
2518       fHistPiPMonitorCuts[isSecd]->Fill(18);
2519       fHistPiAPMonitorCuts[isSecd]->Fill(18); 
2520       if(fCutMICrossedR && trackNeg->GetTPCClusterInfo(3,1) <= fCutMICrossedRLengthF *(130.0 - 5.0*fabs(trackNeg->GetSigned1Pt()))) continue;
2521       fHistPiPiMonitorCuts->Fill(19);
2522       fHistPiPMonitorCuts[isSecd]->Fill(19);
2523       fHistPiAPMonitorCuts[isSecd]->Fill(19);
2524
2525       if(fCutMITPCncls &&  nclsTPCPos <= 0.6*(130.0 - 5.0*fabs(trackPos->GetSigned1Pt()))) continue;
2526       fHistPiPiMonitorCuts->Fill(20);
2527       fHistPiPMonitorCuts[isSecd]->Fill(20);
2528       fHistPiAPMonitorCuts[isSecd]->Fill(20); 
2529       if(fCutMITPCncls &&   nclsTPCNeg <= 0.6*(130.0 - 5.0*fabs(trackNeg->GetSigned1Pt()))) continue;
2530       fHistPiPiMonitorCuts->Fill(21);
2531       fHistPiPMonitorCuts[isSecd]->Fill(21);
2532       fHistPiAPMonitorCuts[isSecd]->Fill(21); 
2533     
2534    
2535       //--------------------- PID ----------------------------//
2536       //-- dEdx --//
2537       Float_t nSigmaTPCtrackPosToPion = 0.0;
2538       Float_t nSigmaTPCtrackNegToPion = 0.0;
2539       Float_t nSigmaTPCtrackPosToProton = 0.0;
2540       Float_t nSigmaTPCtrackNegToProton = 0.0;
2541
2542          
2543       if(fESDpid){
2544         nSigmaTPCtrackPosToPion = fabs(fESDpid->NumberOfSigmasTPC(trackPos,AliPID::kPion));
2545         nSigmaTPCtrackNegToPion = fabs(fESDpid->NumberOfSigmasTPC(trackNeg,AliPID::kPion));
2546         nSigmaTPCtrackPosToProton = fabs(fESDpid->NumberOfSigmasTPC(trackPos,AliPID::kProton));
2547         nSigmaTPCtrackNegToProton = fabs(fESDpid->NumberOfSigmasTPC(trackNeg,AliPID::kProton));
2548       }
2549          
2550       Bool_t pipidEdx=kTRUE;
2551       Bool_t pipdEdx =kTRUE;
2552       Bool_t piapdEdx=kTRUE;
2553
2554       Double_t posDaughterP = ppTrack.Mag();
2555       Double_t negDaughterP = pmTrack.Mag();
2556
2557       Double_t tpcsigPos= trackPos->GetTPCsignal();
2558       Double_t tpcsigNeg= trackNeg->GetTPCsignal();
2559      
2560       /*
2561         Double_t tpcsigNPos= trackPos->GetTPCsignalN();
2562         Double_t tpcsigNNeg= trackNeg->GetTPCsignalN();
2563       */
2564      
2565       //AliExternalTrackParam *extTParPos = (AliExternalTrackParam*)trackPos->GetTPCInnerParam();
2566       //Double_t tpcMomPos = extTParPos->GetP();
2567       Double_t tpcMomPos =trackPos->GetInnerParam()->GetP();
2568       // AliExternalTrackParam *extTParNeg = (AliExternalTrackParam*)trackNeg->GetTPCInnerParam();
2569       // Double_t tpcMomNeg = extTParNeg->GetP();
2570       Double_t tpcMomNeg = trackNeg->GetInnerParam()->GetP();
2571          
2572       //-- dedx cut --//
2573       if(fUsePID){
2574         if(fabs(posDaughterP)<fPPIDcut && tpcsigPos < 5.0){//no zero dedx values!
2575           pipidEdx =kFALSE;//k0s
2576           piapdEdx =kFALSE;//antilambda
2577         }
2578
2579         if(fabs(negDaughterP)<fPPIDcut &&  tpcsigNeg < 5.0){//no zero dedx values!
2580           pipidEdx =kFALSE;//k0s
2581           pipdEdx =kFALSE;//lambda
2582         }
2583
2584         if(fabs(posDaughterP)<fPPIDcut && (nSigmaTPCtrackPosToProton > fNSigma || tpcsigPos < 5.0)) pipdEdx =kFALSE;//lambda
2585         if(fabs(negDaughterP)<fPPIDcut && (nSigmaTPCtrackNegToProton > fNSigma || tpcsigNeg < 5.0)) piapdEdx =kFALSE;//antilambda
2586      
2587         if(fabs(fNSigma-fNSigma2) > 0.001){
2588           if(fabs(posDaughterP) >= fPPIDcut && (nSigmaTPCtrackPosToProton > fNSigma2 || tpcsigPos < 5.0)) pipdEdx =kFALSE;//lambda
2589           if(fabs(negDaughterP) >= fPPIDcut && (nSigmaTPCtrackNegToProton > fNSigma2 || tpcsigNeg < 5.0)) piapdEdx =kFALSE;//antilambda
2590
2591           if(fabs(posDaughterP) >= fPPIDcut && tpcsigPos < 5.0){//no zero dedx values!
2592             pipidEdx =kFALSE;//k0s
2593             piapdEdx =kFALSE;//antilambda
2594           }
2595         
2596           if(fabs(negDaughterP) >= fPPIDcut &&  tpcsigNeg < 5.0){//no zero dedx values!
2597             pipidEdx =kFALSE;//k0s
2598             pipdEdx =kFALSE;//lambda
2599           }
2600         
2601         }
2602       
2603       }
2604
2605
2606       if(fUsePIDPion){
2607         if(fabs(posDaughterP)<fPPIDcut && nSigmaTPCtrackPosToPion > fNSigma ){
2608           pipidEdx =kFALSE;//k0s
2609         }
2610       
2611         if(fabs(negDaughterP)<fPPIDcut && nSigmaTPCtrackNegToPion > fNSigma ){
2612           pipidEdx =kFALSE;//k0s
2613         }
2614       }
2615
2616       //----------------------- V0 variables --------------------//
2617       //-- armenteros --//
2618       TVector3 momTot = ppTrack + pmTrack;
2619       Double_t lQlNeg = fabs(pmTrack.Dot(momTot)/momTot.Mag());
2620       Double_t lQlPos = fabs(ppTrack.Dot(momTot)/momTot.Mag());
2621       //return 1.-2./(1.+lQlNeg/lQlPos);
2622       Double_t alfa =0.0;
2623       Double_t den = lQlPos + lQlNeg;
2624       if(den>0) alfa = (lQlPos - lQlNeg)/den;
2625       TVector3 qtvec= pmTrack.Cross(momTot);//vecPip.Mag()*sqrt(1-pow(thetapip,2));
2626       Double_t qt = qtvec.Mag()/momTot.Mag();
2627
2628       //-- momenta --//
2629       Double_t ptK0s = v0K0.Pt();
2630       Double_t ptLambda = v0Lambda.Pt();
2631       Double_t ptALambda = v0ALambda.Pt();
2632       
2633       Double_t pK0s = v0K0.P();
2634       Double_t pLambda = v0Lambda.P();
2635       Double_t pALambda = v0ALambda.P();
2636       
2637       //-- masses --//
2638       Double_t massK0s = v0K0.M();
2639       Double_t massLambda = v0Lambda.M();
2640       Double_t massALambda = v0ALambda.M();
2641
2642       TLorentzVector e1(ppTrack,0.51099);
2643       TLorentzVector e2(pmTrack,0.51099);
2644       TLorentzVector photon = e1+e2;
2645       Double_t massPhoton = photon.M();
2646
2647       //-- rapidity --//
2648       Double_t rapK0s = v0MIs->Y(310);
2649       Double_t rapL   = v0MIs->Y(3122);
2650       Double_t rapAL  = v0MIs->Y(3122);
2651
2652       //-- other variables --//
2653       Double_t opAng =   fabs(ppTrack.Angle(pmTrack));
2654       Double_t cosOPAng = v0MIs->GetV0CosineOfPointingAngle();
2655       
2656       //    if( ppTrack.Angle(pmTrack)<0.001) continue;  
2657       //    if( ppTrack.Angle(pmTrack)<0.004) continue;   
2658       
2659       /*    
2660       Double_t phiK0 =  v0K0.Phi();
2661       Double_t phiL =  v0Lambda.Phi();
2662       Double_t phiAL =  v0ALambda.Phi();
2663       */
2664             
2665       /*     
2666       //introduce more histo
2667       Double_t errOnMassK0s = v0MIs->ChangeMassHypothesis(310);
2668       Double_t errOnMassLambda = 0.0;
2669       Double_t errOnMassALambda = 0.0;
2670       if(!switchSign){
2671       errOnMassLambda  = v0MIs->ChangeMassHypothesis(3122);
2672       errOnMassALambda = v0MIs->ChangeMassHypothesis(-3122);
2673       }
2674       else{
2675       errOnMassLambda  = v0MIs->ChangeMassHypothesis(-3122);
2676       errOnMassALambda = v0MIs->ChangeMassHypothesis(3122);
2677       }
2678       */
2679
2680       //------------------ cut flags for V0 specific cuts --------------//
2681       Bool_t cutOKK0s = kTRUE;
2682       Bool_t cutOKLambda = kTRUE;
2683       Bool_t cutOKALambda = kTRUE;
2684
2685       //-------------------------- K0 cuts -----------------------------//
2686
2687       if(dcaV0ToPrimVertex > fDCAToVertexK0)  cutOKK0s = kFALSE;//continue;
2688       else fHistPiPiMonitorCuts->Fill(22);
2689       
2690       if(fabs(xr[2])> fDCAZ) cutOKK0s = kFALSE; //like decay radius z component
2691       else fHistPiPiMonitorCuts->Fill(23);
2692       
2693       Double_t ctK0 = 0.0,ctTK0 = 0.0;
2694       if(fabs(pK0s)>0.0)  ctK0 = decayLength*0.497614/pK0s;
2695       if(fabs(ptK0s)>0.0)  ctTK0 = dim2V0Radius*0.497614/ptK0s;
2696       if(ctK0 > fCtauK0s &&  fabs(ptK0s) <fCtauPtCutK0) cutOKK0s = kFALSE;
2697       else  fHistPiPiMonitorCuts->Fill(24);
2698       
2699       if((cosOPAng < fCosPointAngK && fabs(ptK0s) < fCPAPtCutK0)|| cosOPAng<0.99)
2700         cutOKK0s = kFALSE;
2701       else  fHistPiPiMonitorCuts->Fill(25);
2702
2703       if(dcaDaughters > fDCADaughtersK0 )cutOKK0s = kFALSE;
2704       else  fHistPiPiMonitorCuts->Fill(26);
2705          
2706       if(dcaNegToVertex < fDCADaughtersToVtxSmall || dcaPosToVertex < fDCADaughtersToVtxSmall)  cutOKK0s = kFALSE;
2707       else  fHistPiPiMonitorCuts->Fill(27);
2708
2709       if(fRapCutV0 && fabs(rapK0s) > fRap) cutOKK0s = kFALSE;
2710       else  fHistPiPiMonitorCuts->Fill(28);  
2711     
2712       // if(chi2K0C > fChiCutKf) cutOKK0s = kFALSE;
2713       if(opAng < fOpengAngleDaughters && fabs(ptK0s) < fOpAngPtCut )  cutOKK0s = kFALSE;
2714       else fHistPiPiMonitorCuts->Fill(29);
2715     
2716       Bool_t ptbinokK0s=kFALSE;
2717       if( ptK0s < fQtCutPt &&  ptK0s > fQtCutPtLow ) ptbinokK0s=kTRUE;
2718     
2719       Double_t qtval = fArmQtSlope*fabs(alfa);
2720    
2721       if(fArmCutK0 && ptbinokK0s && qt < qtval) cutOKK0s = kFALSE;
2722       if(fArmCutK0 && ptbinokK0s && qt < fQtCut) cutOKK0s = kFALSE;
2723       else  fHistPiPiMonitorCuts->Fill(30);
2724     
2725       if( ptK0s > fPtTPCCut){
2726         if(fESDTrackCuts){
2727           if(!fESDTrackCuts->AcceptTrack(trackPosTest) || !fESDTrackCuts->AcceptTrack(trackNegTest)) cutOKK0s = kFALSE;
2728           else  fHistPiPiMonitorCuts->Fill(31); 
2729         }
2730       }
2731       else{
2732         if(fESDTrackCutsLowPt){
2733           if(!fESDTrackCutsLowPt->AcceptTrack(trackPosTest) || !fESDTrackCutsLowPt->AcceptTrack(trackNegTest))  cutOKK0s = kFALSE; 
2734         }
2735       }
2736
2737       //-------------------------- Lambda cuts -------------------------//
2738       if(dcaV0ToPrimVertex > fDCAToVertexL) cutOKLambda = kFALSE;//continue;
2739       else  fHistPiPMonitorCuts[isSecd]->Fill(22);
2740
2741       if(fabs(xr[2])>fDCAZ) cutOKLambda = kFALSE; //like decay radius z component
2742       else  fHistPiPMonitorCuts[isSecd]->Fill(23);
2743          
2744       Double_t ctL = 0.0,ctTL=0.0;
2745       if(fabs(pLambda)>0.0)  ctL  = decayLength*1.115683/fabs(pLambda);
2746       if(fabs(ptLambda)>0.0) ctTL = dim2V0Radius*1.115683/fabs(ptLambda);
2747          
2748       if(ctL > fCtauL && fabs(ptLambda) <fCtauPtCutL)  cutOKLambda = kFALSE;
2749       else  fHistPiPMonitorCuts[isSecd]->Fill(24);
2750       
2751       if((cosOPAng<fCosPointAngL && fabs(ptLambda) < fCPAPtCutL)|| cosOPAng<0.99)
2752         cutOKLambda = kFALSE;
2753       else fHistPiPMonitorCuts[isSecd]->Fill(25);
2754
2755       if(dcaDaughters > fDCADaughtersL )cutOKLambda = kFALSE;
2756       else  fHistPiPMonitorCuts[isSecd]->Fill(26);
2757  
2758       if( dcaNegToVertex < fDCADaughtersToVtxSmall || dcaPosToVertex < fDCADaughtersToVtxLarge)  cutOKLambda = kFALSE;
2759       else  fHistPiPMonitorCuts[isSecd]->Fill(27);
2760
2761       if(fRapCutV0 && fabs(rapL) > fRap) cutOKLambda = kFALSE;
2762       else  fHistPiPMonitorCuts[isSecd]->Fill(28);
2763        
2764    
2765       /*         
2766                  if(chi2LambdaC > fChiCutKf) cutOKLambda = kFALSE;
2767                  else  fHistPiPMonitorCuts[isSecd]->Fill(20);
2768       */
2769
2770       if(opAng < fOpengAngleDaughters && fabs(ptLambda) < fOpAngPtCut )  cutOKLambda = kFALSE;
2771       else  fHistPiPMonitorCuts[isSecd]->Fill(29);
2772     
2773
2774       if(alfa<fAlfaCut  || (fArmCutL && qt > fQtCut)) cutOKLambda = kFALSE;
2775       else  fHistPiPMonitorCuts[isSecd]->Fill(30);
2776
2777       if(ptLambda > fPtTPCCut){
2778         if(fESDTrackCuts && fESDTrackCutsCharged){
2779           if(!fESDTrackCutsCharged->AcceptTrack(trackPosTest) || !fESDTrackCuts->AcceptTrack(trackNegTest)) cutOKLambda = kFALSE;
2780           else  fHistPiPMonitorCuts[isSecd]->Fill(31); 
2781         }
2782       }
2783       else{
2784         if(fESDTrackCutsLowPt){
2785           if(!fESDTrackCutsLowPt->AcceptTrack(trackPosTest) || !fESDTrackCutsLowPt->AcceptTrack(trackNegTest))  cutOKLambda = kFALSE; 
2786         }
2787       }
2788
2789       //--------------------------- ALambda cuts --------------------------//
2790
2791       if(dcaV0ToPrimVertex > fDCAToVertexL) cutOKALambda = kFALSE;//continue;
2792       else fHistPiAPMonitorCuts[isSecd]->Fill(22);
2793  
2794       if(fabs(xr[2])> fDCAZ) cutOKALambda = kFALSE;//continue;//like decay radius z component
2795       else fHistPiAPMonitorCuts[isSecd]->Fill(23);
2796
2797       Double_t ctAL = 0.0,ctTAL=0.0;
2798       if(fabs(pALambda)>0.0)  ctAL  = decayLength*1.115683/fabs(pALambda);
2799       if(fabs(ptALambda)>0.0) ctTAL = dim2V0Radius*1.115683/fabs(ptALambda);
2800       if(ctAL > fCtauL &&  fabs(ptALambda) <fCtauPtCutL)  cutOKALambda = kFALSE;
2801       else  fHistPiAPMonitorCuts[isSecd]->Fill(24);
2802
2803       if((cosOPAng<fCosPointAngL && fabs(ptALambda) < fCPAPtCutL)|| cosOPAng<0.99)  cutOKALambda = kFALSE;
2804       else fHistPiAPMonitorCuts[isSecd]->Fill(25);
2805       
2806       if(dcaDaughters > fDCADaughtersAL )cutOKALambda = kFALSE;
2807       else  fHistPiAPMonitorCuts[isSecd]->Fill(26);
2808          
2809       if( dcaPosToVertex < fDCADaughtersToVtxSmall || dcaNegToVertex < fDCADaughtersToVtxLarge)  cutOKALambda = kFALSE;
2810       else fHistPiAPMonitorCuts[isSecd]->Fill(27);
2811          
2812       if(fRapCutV0 && fabs(rapAL) > fRap) cutOKALambda = kFALSE;
2813       else fHistPiAPMonitorCuts[isSecd]->Fill(28);
2814
2815       /*
2816         if(chi2ALambdaC > fChiCutKf) cutOKALambda = kFALSE;
2817         else  fHistPiAPMonitorCuts[isSecd]->Fill(20);
2818       */
2819      
2820       if(opAng < fOpengAngleDaughters && fabs(ptALambda) < fOpAngPtCut )  cutOKALambda = kFALSE;
2821       else  fHistPiAPMonitorCuts[isSecd]->Fill(29);
2822     
2823       
2824       if((fArmCutL && qt>qtval) || alfa > -1.0*fAlfaCut) cutOKALambda = kFALSE;
2825       else  fHistPiAPMonitorCuts[isSecd]->Fill(30);
2826
2827       if(ptALambda > fPtTPCCut){
2828         if(fESDTrackCuts && fESDTrackCutsCharged){
2829           if(!fESDTrackCuts->AcceptTrack(trackPosTest) || !fESDTrackCutsCharged->AcceptTrack(trackNegTest)) cutOKALambda = kFALSE;
2830           else  fHistPiAPMonitorCuts[isSecd]->Fill(31); 
2831         }
2832       }
2833       else{
2834         if(fESDTrackCutsLowPt){
2835           if(!fESDTrackCutsLowPt->AcceptTrack(trackPosTest))  cutOKALambda = kFALSE; 
2836           if(!fESDTrackCutsLowPt->AcceptTrack(trackNegTest))  cutOKALambda = kFALSE; 
2837         }
2838       }
2839   
2840       //-------------------- V0 ana -------------------------//
2841
2842       //-- cut flags for furhter histos--//
2843       Bool_t k0sOK=kFALSE;
2844       Bool_t lambdaOK=kFALSE;
2845       Bool_t alambdaOK=kFALSE;
2846
2847       //--  Check for K0 --//
2848       Bool_t exMass = kFALSE;
2849       if(fabs(1.115 - massLambda)  < fExcludeLambdaFromK0s){
2850         cutOKK0s = kFALSE;
2851         exMass = kTRUE;
2852       }
2853       if(fabs(1.115 - massALambda) < fExcludeLambdaFromK0s){
2854         cutOKK0s = kFALSE;
2855         exMass = kTRUE;
2856       }
2857    
2858       if(fabs(massPhoton) < fExcludeLambdaFromK0s) {
2859         cutOKK0s = kFALSE;
2860         exMass = kTRUE;
2861       }
2862    
2863       if(ptK0s >fMinPt){
2864         if( cutOKK0s  && fillK0sMC ){
2865           fHistDedxPiPlus[isSecd]->Fill(tpcMomPos,tpcsigPos);
2866           fHistDedxPiMinus[isSecd]->Fill(tpcMomNeg,tpcsigNeg);
2867           fHistPiPiMonitorCuts->Fill(32);
2868           if(pipidEdx){
2869             fHistPiPiMonitorCuts->Fill(33);
2870             k0sOK = kTRUE;                  
2871             if(!exMass && massK0s > fK0sLowMassCut && massK0s < fK0sHighMassCut ){
2872               if(!fMCMode){
2873                 ptV0MC = ptK0s;
2874                 declengthV0MC = dim2V0Radius;
2875               }
2876               fHistPiPiMonitorCuts->Fill(34);
2877               fHistPiPiMass->Fill(massK0s);
2878               fHistPiPiMassVSPt->Fill(massK0s,ptK0s);
2879               fHistPiPiMassVSPtMCTruth->Fill(massK0s,ptV0MC);
2880               fHistPiPiMassVSY->Fill(massK0s,rapK0s);
2881               fHistPiPiPtVSY->Fill(rapK0s,ptK0s);
2882               fHistPiPiDecayLengthVsMass->Fill(massK0s,dim2V0Radius);//decayLength);
2883               if(massK0s > 0.46 && massK0s < 0.53)  fHistPiPiDecayLengthVsPt->Fill(ptV0MC,dim2V0Radius);//decayLength
2884               // fHistPiPiPtDaughters->Fill(posDaughterPt,negDaughterPt);
2885               if(!fSetPtDepHist){
2886                 fHistPiPiRadiusXY->Fill(massK0s,opAng);//posDaughterPhi);//opAng);
2887                 //          fHistPiPiPhiPosVsPtPosVsMass->Fill(massK0s,dim2V0Radius,ptV0MC);//,ctK0);//posDaughterPhi);//xxx
2888                 fHistPiPiCosPointAng->Fill(massK0s,cosOPAng);
2889                 fHistPiPiDecayLengthVsCtau->Fill(massK0s,ctTK0);
2890                 fHistPiPiTrackLengthPosVsMass->Fill(massK0s,lengthTPCPos);
2891                 fHistPiPiTrackLengthNegVsMass->Fill(massK0s,lengthTPCNeg);
2892                 fHistPiPiDCAZPos->Fill(massK0s,dcaToVertexZPos);
2893                 fHistPiPiDCAZNeg->Fill(massK0s,dcaToVertexZNeg);
2894                 fHistPiPiDCADaughters->Fill(massK0s,dcaDaughters);
2895                 fHistPiPiDCADaughterPosToPrimVtxVSMass->Fill(massK0s,dcaPosToVertex);
2896                 fHistPiPiDCAVSMass->Fill(massK0s,dcaV0ToPrimVertex);
2897               }
2898               else{
2899                 fHistPiPiRadiusXY->Fill(ptV0MC,opAng);
2900                 fHistPiPiCosPointAng->Fill(ptV0MC,cosOPAng);
2901                 fHistPiPiDecayLengthVsCtau->Fill(ptV0MC,ctTK0);
2902                 fHistPiPiTrackLengthPosVsMass->Fill(ptV0MC,lengthTPCPos);
2903                 fHistPiPiTrackLengthNegVsMass->Fill(ptV0MC,lengthTPCNeg);
2904                 fHistPiPiDCAZPos->Fill(ptV0MC,dcaToVertexZPos);
2905                 fHistPiPiDCAZNeg->Fill(ptV0MC,dcaToVertexZNeg);
2906                 fHistPiPiDCADaughters->Fill(ptV0MC,dcaDaughters);
2907                 fHistPiPiDCADaughterPosToPrimVtxVSMass->Fill(ptV0MC,dcaPosToVertex);
2908                 fHistPiPiDCAVSMass->Fill(ptV0MC,dcaV0ToPrimVertex);
2909               }
2910
2911
2912               if(fMCMode)  fHistPiPiDecayLengthResolution->Fill(declengthV0MC,dim2V0Radius);
2913
2914               fHistPiPiK0sVsLambdaMass->Fill(massLambda,massK0s);
2915               fHistPiPiK0sVsALambdaMass->Fill(massALambda,massK0s);
2916           
2917               fHistArmenteros[isSecd]->Fill(alfa,qt);
2918               fHistDedxSecPiPlus[isSecd]->Fill(tpcMomPos,tpcsigPos);
2919               fHistDedxSecPiMinus[isSecd]->Fill(tpcMomNeg,tpcsigNeg);
2920
2921               fHistV0RadiusZ[isSecd]->Fill(dim2V0Radius,xr[2]);
2922               fHistV0RadiusXY[isSecd]->Fill(xr[0],xr[1]);
2923               fHistV0RadiusZVSPt[isSecd]->Fill(ptK0s,dim2V0Radius);
2924               fHistV0RadiusXYVSY[isSecd]->Fill(rapK0s,dim2V0Radius);
2925
2926               //-- detector values --/
2927               fHistNclsITS[1]->Fill(nclsITSPos,nclsITSNeg);
2928               fHistNclsTPC[1]->Fill(crossedRowsTPCNeg,nclsTPCNeg);
2929
2930               if(!fSetPtDepHist){
2931                 fHistNclsITSPosK0->Fill(massK0s,nclsITSPos);
2932                 fHistNclsITSNegK0->Fill(massK0s,nclsITSNeg);
2933                 fHistNclsTPCPosK0->Fill(massK0s,nclsTPCPos);
2934                 fHistNclsTPCNegK0->Fill(massK0s,nclsTPCNeg);
2935                 fHistChi2PerNclsITSPosK0->Fill(massK0s,chi2PerClusterITSPos);
2936                 fHistChi2PerNclsITSNegK0->Fill(massK0s,chi2PerClusterITSNeg);
2937                 fHistNCRowsTPCPosK0->Fill(massK0s,crossedRowsTPCPos);
2938                 fHistNCRowsTPCNegK0->Fill(massK0s,crossedRowsTPCNeg);
2939                 fHistRatioFoundOverFinableTPCK0Neg->Fill(massK0s,ratioFoFi);
2940                 fHistRatioFoundOverFinableTPCK0Pos->Fill(massK0s,ratioFoFiPos);
2941               }
2942               else{
2943                 fHistNclsITSPosK0->Fill(ptV0MC,nclsITSPos);
2944                 fHistNclsITSNegK0->Fill(ptV0MC,nclsITSNeg);
2945                 fHistNclsTPCPosK0->Fill(ptV0MC,nclsTPCPos);
2946                 fHistNclsTPCNegK0->Fill(ptV0MC,nclsTPCNeg);
2947                 fHistChi2PerNclsITSPosK0->Fill(ptV0MC,chi2PerClusterITSPos);
2948                 fHistChi2PerNclsITSNegK0->Fill(ptV0MC,chi2PerClusterITSNeg);
2949                 fHistNCRowsTPCPosK0->Fill(ptV0MC,crossedRowsTPCPos);
2950                 fHistNCRowsTPCNegK0->Fill(ptV0MC,crossedRowsTPCNeg);
2951                 fHistRatioFoundOverFinableTPCK0Neg->Fill(ptV0MC,ratioFoFi);
2952                 fHistRatioFoundOverFinableTPCK0Pos->Fill(ptV0MC,ratioFoFiPos);
2953               }
2954             }
2955           }
2956         }
2957       }
2958       //--  Check for Lambda --//
2959       Bool_t  exMassL =kFALSE;
2960       if(fabs(0.497 - massK0s) < fExcludeK0sFromLambda){
2961         cutOKLambda = kFALSE;
2962         exMassL = kTRUE;
2963       }
2964       if(fabs(massPhoton) < fExcludeK0sFromLambda) {
2965         cutOKLambda = kFALSE;
2966         exMassL = kTRUE;
2967       }
2968     
2969       if(ptLambda > fMinPt){
2970         if(cutOKLambda && fillLambdaMC){
2971           fHistDedxProt[isSecd]->Fill(tpcMomPos,tpcsigPos);
2972           fHistDedxPiMinus[isSecd]->Fill(tpcMomNeg,tpcsigNeg);
2973           fHistPiPMonitorCuts[isSecd]->Fill(32);
2974           if(pipdEdx){
2975             fHistPiPMonitorCuts[isSecd]->Fill(33);
2976             lambdaOK = kTRUE;
2977             if(!exMassL && massLambda > fLLowMassCut && massLambda < fLHighMassCut){// 1.05 && massLambda < 1.25 ){
2978               if(!fMCMode) {
2979                 ptV0MC = ptLambda;
2980                 declengthV0MC = dim2V0Radius;
2981               }
2982               fHistPiPMonitorCuts[isSecd]->Fill(34);
2983               fHistPiPMass[isSecd]->Fill(massLambda);
2984               fHistPiPMassVSPt[isSecd]->Fill(massLambda,ptLambda);
2985               fHistPiPMassVSPtMCTruth[isSecd]->Fill(massLambda,ptV0MC);
2986               fHistPiPMassVSY[isSecd]->Fill(massLambda,rapL);
2987               fHistPiPPtVSY[isSecd]->Fill(rapL,ptLambda);
2988               //fHistPiPDecayLengthVsPt[isSecd]->Fill(ptLambda,ctL);
2989               if( massLambda > 1.108 && massLambda < 1.123 ) fHistPiPDecayLengthVsPt[isSecd]->Fill(ptV0MC,dim2V0Radius);//decayLength);
2990               fHistPiPDecayLengthVsMass[isSecd]->Fill(massLambda,dim2V0Radius);//decayLength);
2991               //  fHistPiPPhiPosVsPtPosVsMass->Fill(massLambda,dim2V0Radius,ptV0MC);//
2992
2993               if(!fSetPtDepHist){
2994                 fHistPiPRadiusXY[isSecd]->Fill(massLambda,opAng);//,posDaughterPhi);//opAng);
2995                 fHistPiPCosPointAng[isSecd]->Fill(massLambda,cosOPAng);
2996                 fHistPiPTrackLengthPosVsMass[isSecd]->Fill(massLambda,lengthTPCPos);
2997                 fHistPiPTrackLengthNegVsMass[isSecd]->Fill(massLambda,lengthTPCNeg);
2998                 //fHistPiPDCAZPos[isSecd]->Fill(massLambda,dcaToVertexZPos);
2999                 //fHistPiPDCAZNeg[isSecd]->Fill(massLambda,dcaToVertexZNeg);
3000                 fHistPiPDCADaughters[isSecd]->Fill(massLambda,dcaDaughters);
3001                 fHistPiPDCAVSMass[isSecd]->Fill(massLambda,dcaV0ToPrimVertex);
3002                 fHistPiPDCADaughterPosToPrimVtxVSMass[isSecd]->Fill(massLambda,dcaPosToVertex);
3003                 fHistPiPDCADaughterNegToPrimVtxVSMass[isSecd]->Fill(massLambda,dcaNegToVertex);
3004                 fHistPiPDecayLengthVsCtau[isSecd]->Fill(massLambda,ctTL);
3005               }
3006               else{
3007                 fHistPiPRadiusXY[isSecd]->Fill(ptV0MC,opAng);
3008                 fHistPiPCosPointAng[isSecd]->Fill(ptV0MC,cosOPAng);
3009                 fHistPiPTrackLengthPosVsMass[isSecd]->Fill(ptV0MC,lengthTPCPos);
3010                 fHistPiPTrackLengthNegVsMass[isSecd]->Fill(ptV0MC,lengthTPCNeg);
3011                 //fHistPiPDCAZPos[isSecd]->Fill(ptV0MC,dcaToVertexZPos);
3012                 //fHistPiPDCAZNeg[isSecd]->Fill(ptV0MC,dcaToVertexZNeg);
3013                 fHistPiPDCADaughters[isSecd]->Fill(ptV0MC,dcaDaughters);
3014                 fHistPiPDCAVSMass[isSecd]->Fill(ptV0MC,dcaV0ToPrimVertex);
3015                 fHistPiPDCADaughterPosToPrimVtxVSMass[isSecd]->Fill(ptV0MC,dcaPosToVertex);
3016                 fHistPiPDCADaughterNegToPrimVtxVSMass[isSecd]->Fill(ptV0MC,dcaNegToVertex);
3017                 fHistPiPDecayLengthVsCtau[isSecd]->Fill(ptV0MC,ctTL);
3018               }
3019
3020               if(fMCMode)  fHistPiPDecayLengthResolution[isSecd]->Fill(declengthV0MC,dim2V0Radius);
3021               //   fHistPiPPtDaughters[isSecd]->Fill(posDaughterPt,negDaughterPt);
3022               fHistPiPK0sVsLambdaMass->Fill(massLambda,massK0s);
3023               fHistPiPALambdaVsLambdaMass->Fill(massLambda,massALambda);
3024             
3025             
3026               //-- secondaries --//
3027               if(isSecd==1){
3028                 if(fabs(pdgMother) == 3112 || fabs(pdgMother) == 3114 || fabs(pdgMother) == 3222 || fabs(pdgMother) == 3224 || fabs(pdgMother) == 3214 ){
3029                   fHistPiPMassVSPtSecSigma[1]->Fill(massLambda,ptLambda);
3030                 
3031                 }
3032               
3033                 if(pdgMother == 3322 || pdgMother == 3312){//Xi0 and xi minus
3034                   fHistPiPCosPointAngXiVsPt->Fill(ptLambda,cosOPAng);
3035                   fHistPiPMassVSPtSecXi[1]->Fill(massLambda,ptLambda);
3036                   fHistPiPMassVSPtSecXiMCTruth->Fill(massLambda,ptV0MC);
3037                   fHistPiPMassVSYSecXi[1]->Fill(massLambda,rapL);
3038                   fHistPiPXi0PtVSLambdaPt[1]->Fill(ptLambda,ptXiMother);
3039                 }
3040                 if(pdgMother == 3334){//Omega
3041                   fHistPiPMassVSPtSecOmega[1]->Fill(massLambda,ptLambda);
3042                   fHistPiPMassVSPtSecOmegaMCTruth->Fill(massLambda,ptV0MC);
3043                   fHistPiPOmegaPtVSLambdaPt[1]->Fill(ptLambda,ptXiMother);
3044                 }  
3045               }
3046
3047               if(ptLambda > 0.4) fHistArmenteros[isSecd]->Fill(alfa,qt);
3048               fHistV0RadiusZ[isSecd]->Fill(dim2V0Radius,xr[2]);
3049               fHistV0RadiusXY[isSecd]->Fill(xr[0],xr[1]);
3050               fHistV0RadiusZVSPt[isSecd]->Fill(ptLambda,dim2V0Radius);
3051               fHistV0RadiusXYVSY[isSecd]->Fill(rapL,dim2V0Radius);
3052               fHistDedxSecProt[isSecd]->Fill(tpcMomPos,tpcsigPos);
3053               fHistDedxSecPiMinus[isSecd]->Fill(tpcMomNeg,tpcsigNeg);
3054
3055               if(!fSetFillDetAL){
3056                 //-- detector values --//
3057                 fHistNclsITS[0]->Fill(nclsITSPos,nclsITSNeg);
3058                 fHistNclsTPC[0]->Fill(crossedRowsTPCNeg,nclsTPCNeg);
3059                 if(!fSetPtDepHist){
3060                   fHistNclsITSPosL[isSecd]->Fill(massLambda,nclsITSPos);
3061                   fHistNclsITSNegL[isSecd]->Fill(massLambda,nclsITSNeg);
3062                   fHistNclsTPCPosL[isSecd]->Fill(massLambda,nclsTPCPos);
3063                   fHistNclsTPCNegL[isSecd]->Fill(massLambda,nclsTPCNeg);
3064                   fHistChi2PerNclsITSPosL[isSecd]->Fill(massLambda,chi2PerClusterITSPos);
3065                   fHistChi2PerNclsITSNegL[isSecd]->Fill(massLambda,chi2PerClusterITSNeg);
3066                   fHistNCRowsTPCPosL[isSecd]->Fill(massLambda,crossedRowsTPCPos);
3067                   fHistNCRowsTPCNegL[isSecd]->Fill(massLambda,crossedRowsTPCNeg);
3068                   fHistRatioFoundOverFinableTPCLNeg[isSecd]->Fill(massLambda,ratioFoFi);
3069                   fHistRatioFoundOverFinableTPCLPos[isSecd]->Fill(massLambda,ratioFoFiPos);
3070                 }
3071                 else{
3072                   fHistNclsITSPosL[isSecd]->Fill(ptV0MC,nclsITSPos);
3073                   fHistNclsITSNegL[isSecd]->Fill(ptV0MC,nclsITSNeg);
3074                   fHistNclsTPCPosL[isSecd]->Fill(ptV0MC,nclsTPCPos);
3075                   fHistNclsTPCNegL[isSecd]->Fill(ptV0MC,nclsTPCNeg);
3076                   fHistChi2PerNclsITSPosL[isSecd]->Fill(ptV0MC,chi2PerClusterITSPos);
3077                   fHistChi2PerNclsITSNegL[isSecd]->Fill(ptV0MC,chi2PerClusterITSNeg);
3078                   fHistNCRowsTPCPosL[isSecd]->Fill(ptV0MC,crossedRowsTPCPos);
3079                   fHistNCRowsTPCNegL[isSecd]->Fill(ptV0MC,crossedRowsTPCNeg);
3080                   fHistRatioFoundOverFinableTPCLNeg[isSecd]->Fill(ptV0MC,ratioFoFi);
3081                   fHistRatioFoundOverFinableTPCLPos[isSecd]->Fill(ptV0MC,ratioFoFiPos);
3082                 }
3083               }
3084             }
3085           
3086           }
3087         }
3088       }
3089
3090
3091       //-- Check for AntiLambda --//    
3092       Bool_t  exMassAL =kFALSE;
3093       if(fabs(0.497 - massK0s) < fExcludeK0sFromLambda){
3094         exMassAL = kTRUE;
3095       }
3096       if(fabs(massPhoton) < fExcludeK0sFromLambda) {
3097         exMassAL = kTRUE;
3098       }
3099
3100       if(ptALambda > fMinPt){
3101         if(cutOKALambda && fillALambdaMC){
3102           fHistDedxAProt[isSecd]->Fill(tpcMomNeg,tpcsigNeg);
3103           fHistDedxPiPlus[isSecd]->Fill(tpcMomPos,tpcsigPos);
3104           fHistPiAPMonitorCuts[isSecd]->Fill(32);
3105           if(piapdEdx){
3106             fHistPiAPMonitorCuts[isSecd]->Fill(33);
3107             alambdaOK = kTRUE;
3108             if( !exMassAL && massALambda > fLLowMassCut && massALambda < fLHighMassCut){//1.05 && massALambda < 1.25  ){
3109               if(!fMCMode) {
3110                 ptV0MC = ptALambda;
3111                 declengthV0MC = dim2V0Radius;
3112               }
3113               fHistPiAPMonitorCuts[isSecd]->Fill(34);
3114               fHistPiAPMass[isSecd]->Fill(massALambda);
3115               fHistPiAPMassVSPt[isSecd]->Fill(massALambda,ptALambda);
3116               fHistPiAPMassVSPtMCTruth[isSecd]->Fill(massALambda,ptV0MC);
3117               fHistPiAPMassVSY[isSecd]->Fill(massALambda,rapAL);
3118               fHistPiAPPtVSY[isSecd]->Fill(rapAL,ptALambda);
3119               //  fHistPiAPPtDaughters[isSecd]->Fill(posDaughterPt,negDaughterPt);
3120               if( massALambda>1.108 && massALambda<1.123 )  fHistPiAPDecayLengthVsPt[isSecd]->Fill(ptV0MC,dim2V0Radius);//decayLength);
3121               fHistPiAPDecayLengthVsMass[isSecd]->Fill(massALambda,dim2V0Radius);//decayLength);
3122             
3123               if(!fSetPtDepHist){
3124                 fHistPiAPRadiusXY[isSecd]->Fill(massALambda,posDaughterPhi);//,opAng);
3125                 fHistPiAPCosPointAng[isSecd]->Fill(massALambda,cosOPAng);           
3126                 fHistPiAPTrackLengthPosVsMass[isSecd]->Fill(massALambda,lengthTPCPos);
3127                 fHistPiAPTrackLengthNegVsMass[isSecd]->Fill(massALambda,lengthTPCNeg);
3128                 //fHistPiAPDCAZPos[isSecd]->Fill(massALambda,dcaToVertexZPos);
3129                 //fHistPiAPDCAZNeg[isSecd]->Fill(massALambda,dcaToVertexZNeg);
3130                 fHistPiAPDCADaughters[isSecd]->Fill(massALambda,dcaDaughters);
3131                 fHistPiAPDCAVSMass[isSecd]->Fill(massALambda,dcaV0ToPrimVertex);
3132                 fHistPiAPDCADaughterPosToPrimVtxVSMass[isSecd]->Fill(massALambda,dcaPosToVertex);
3133                 fHistPiAPDCADaughterNegToPrimVtxVSMass[isSecd]->Fill(massALambda,dcaNegToVertex);
3134                 fHistPiAPDecayLengthVsCtau[isSecd]->Fill(massALambda,ctTAL);
3135            
3136               }
3137               else{
3138                 fHistPiAPRadiusXY[isSecd]->Fill(ptV0MC,posDaughterPhi);
3139                 fHistPiAPCosPointAng[isSecd]->Fill(ptV0MC,cosOPAng);
3140                 fHistPiAPTrackLengthPosVsMass[isSecd]->Fill(ptV0MC,lengthTPCPos);
3141                 fHistPiAPTrackLengthNegVsMass[isSecd]->Fill(ptV0MC,lengthTPCNeg);
3142                 //fHistPiAPDCAZPos[isSecd]->Fill(ptV0MC,dcaToVertexZPos);
3143                 //fHistPiAPDCAZNeg[isSecd]->Fill(ptV0MC,dcaToVertexZNeg);
3144                 fHistPiAPDCADaughters[isSecd]->Fill(ptV0MC,dcaDaughters);
3145                 fHistPiAPDCAVSMass[isSecd]->Fill(ptV0MC,dcaV0ToPrimVertex);
3146                 fHistPiAPDCADaughterPosToPrimVtxVSMass[isSecd]->Fill(ptV0MC,dcaPosToVertex);
3147                 fHistPiAPDCADaughterNegToPrimVtxVSMass[isSecd]->Fill(ptV0MC,dcaNegToVertex);
3148                 fHistPiAPDecayLengthVsCtau[isSecd]->Fill(ptV0MC,ctTAL);
3149               }
3150
3151               if(fMCMode)  fHistPiAPDecayLengthResolution[isSecd]->Fill(declengthV0MC,dim2V0Radius);
3152               fHistPiAPK0sVsALambdaMass->Fill(massALambda,massK0s);
3153               fHistPiAPLambdaVsALambdaMass->Fill(massALambda,massLambda);
3154
3155               //-- secondaries --//
3156               if(isSecd == 1){
3157                 if(fabs(pdgMother) == 3112 || fabs(pdgMother) == 3114 || fabs(pdgMother) == 3222 || fabs(pdgMother) == 3224 || fabs(pdgMother) ==  3214 ){
3158                   fHistPiAPMassVSPtSecSigma[1]->Fill(massLambda,ptLambda);
3159                 
3160                 }
3161                 if(pdgMother == -3322 || pdgMother == -3312){//Xi0 and xiplus
3162                   fHistPiAPCosPointAngXiVsPt->Fill(ptALambda,cosOPAng);
3163                   fHistPiAPMassVSPtSecXi[1]->Fill(massALambda,ptALambda);
3164                   fHistPiAPMassVSPtSecXiMCTruth->Fill(massALambda,ptV0MC);
3165                   fHistPiAPMassVSYSecXi[1]->Fill(massALambda,rapAL);
3166                   fHistPiAPXi0PtVSLambdaPt[1]->Fill(ptALambda,ptXiMother);
3167                 }
3168                 if(pdgMother == -3334){//Omega
3169                   fHistPiAPMassVSPtSecOmega[1]->Fill(massALambda,ptALambda);
3170                   fHistPiAPMassVSPtSecOmegaMCTruth->Fill(massALambda,ptV0MC);
3171                   fHistPiAPOmegaPtVSLambdaPt[1]->Fill(ptALambda,ptXiMother);
3172                 }  
3173               }
3174   
3175               if(ptALambda > 0.4) fHistArmenteros[isSecd]->Fill(alfa,qt);
3176               fHistDedxSecAProt[isSecd]->Fill(tpcMomNeg,tpcsigNeg);
3177               fHistDedxSecPiPlus[isSecd]->Fill(tpcMomPos,tpcsigPos);
3178               fHistV0RadiusZ[isSecd]->Fill(dim2V0Radius,xr[2]);
3179               fHistV0RadiusXY[isSecd]->Fill(xr[0],xr[1]);
3180               fHistV0RadiusZVSPt[isSecd]->Fill(ptALambda,dim2V0Radius);
3181               fHistV0RadiusXYVSY[isSecd]->Fill(rapAL,dim2V0Radius);
3182
3183               if(fSetFillDetAL){
3184                 //-- detector values --//
3185                 //-- detector values --//
3186                 fHistNclsITS[0]->Fill(nclsITSPos,nclsITSNeg);
3187                 fHistNclsTPC[0]->Fill(crossedRowsTPCNeg,nclsTPCNeg);
3188                 if(!fSetPtDepHist){
3189                   fHistNclsITSPosL[isSecd]->Fill(massALambda,nclsITSPos);
3190                   fHistNclsITSNegL[isSecd]->Fill(massALambda,nclsITSNeg);
3191                   fHistNclsTPCPosL[isSecd]->Fill(massALambda,nclsTPCPos);
3192                   fHistNclsTPCNegL[isSecd]->Fill(massALambda,nclsTPCNeg);
3193                   fHistChi2PerNclsITSPosL[isSecd]->Fill(massALambda,chi2PerClusterITSPos);
3194                   fHistChi2PerNclsITSNegL[isSecd]->Fill(massALambda,chi2PerClusterITSNeg);
3195                   fHistNCRowsTPCPosL[isSecd]->Fill(massALambda,crossedRowsTPCPos);
3196                   fHistNCRowsTPCNegL[isSecd]->Fill(massALambda,crossedRowsTPCNeg);
3197                   fHistRatioFoundOverFinableTPCLNeg[isSecd]->Fill(massALambda,ratioFoFi);
3198                   fHistRatioFoundOverFinableTPCLPos[isSecd]->Fill(massALambda,ratioFoFiPos);
3199                 }
3200                 else{
3201                   fHistNclsITSPosL[isSecd]->Fill(ptV0MC,nclsITSPos);
3202                   fHistNclsITSNegL[isSecd]->Fill(ptV0MC,nclsITSNeg);
3203                   fHistNclsTPCPosL[isSecd]->Fill(ptV0MC,nclsTPCPos);
3204                   fHistNclsTPCNegL[isSecd]->Fill(ptV0MC,nclsTPCNeg);
3205                   fHistChi2PerNclsITSPosL[isSecd]->Fill(ptV0MC,chi2PerClusterITSPos);
3206                   fHistChi2PerNclsITSNegL[isSecd]->Fill(ptV0MC,chi2PerClusterITSNeg);
3207                   fHistNCRowsTPCPosL[isSecd]->Fill(ptV0MC,crossedRowsTPCPos);
3208                   fHistNCRowsTPCNegL[isSecd]->Fill(ptV0MC,crossedRowsTPCNeg);
3209                   fHistRatioFoundOverFinableTPCLNeg[isSecd]->Fill(ptV0MC,ratioFoFi);
3210                   fHistRatioFoundOverFinableTPCLPos[isSecd]->Fill(ptV0MC,ratioFoFiPos);
3211                 }
3212               }
3213
3214
3215
3216             }
3217           }
3218         }
3219       }
3220         
3221       //-- fill detector histos general --//
3222       if((lambdaOK && !exMassL) || (alambdaOK && !exMassAL) || (k0sOK && !exMass)){
3223         fHistPiPiEtaDReco[1]->Fill(posDaughterEta,eta00);
3224         fHistPiPEtaDReco[1]->Fill(negDaughterEta,eta01);
3225       }
3226    
3227     
3228
3229       /*
3230       //-- AliKFParticle --//
3231       if (negPiKF) delete negPiKF; negPiKF=NULL;
3232       if (posPiKF) delete posPiKF; posPiKF=NULL;
3233       if (posPKF) delete posPKF; posPKF=NULL;
3234       if (negAPKF) delete negAPKF; negAPKF=NULL;
3235       */
3236         
3237         
3238     }//---- end V0 reco loop----//
3239   }
3240   
3241   //________________________________________________________________________
3242
3243   Int_t AliAnalysisTaskV0ForRAA::CalculateCentralityBin(){
3244     //find centrality bin for centrality selection
3245
3246     if (fUseCentrality == 0) return -1;
3247
3248     AliCentrality *esdCentrality = fESD->GetCentrality();
3249
3250     Float_t centralityVZERO  = esdCentrality->GetCentralityPercentile("V0M");  
3251     Float_t centralitySPD    = esdCentrality->GetCentralityPercentile("CL1");
3252
3253     Int_t centralityVZEROBin = -1;
3254     Int_t centralitySPDBin   = -1;
3255
3256     //-- SPD centrality --//
3257     if ( fUseCentrality == 2 ){
3258       if      ( centralitySPD >=  0. && centralitySPD <   5.) centralitySPDBin =  0;
3259       else if ( centralitySPD >=  5. && centralitySPD <  10.) centralitySPDBin =  5;
3260       else if ( centralitySPD >= 10. && centralitySPD <  20.) centralitySPDBin = 10;
3261       else if ( centralitySPD >= 20. && centralitySPD <  30.) centralitySPDBin = 20;
3262       else if ( centralitySPD >= 30. && centralitySPD <  40.) centralitySPDBin = 30;
3263       else if ( centralitySPD >= 40. && centralitySPD <  50.) centralitySPDBin = 40;
3264       else if ( centralitySPD >= 50. && centralitySPD <  60.) centralitySPDBin = 50;
3265       else if ( centralitySPD >= 60. && centralitySPD <  70.) centralitySPDBin = 60;
3266       else if ( centralitySPD >= 70. && centralitySPD <  80.) centralitySPDBin = 70;
3267       else if ( centralitySPD >= 80. && centralitySPD <  90.) centralitySPDBin = 80;
3268       else if ( centralitySPD >= 90. && centralitySPD <  99.) centralitySPDBin = 90;
3269       else if ( centralitySPD >= 99. ) centralitySPDBin = 100;
3270       else if ( fabs(centralitySPD)< 0.0001 ) centralitySPDBin = 100;
3271       return centralitySPDBin;
3272     }
3273     //-- V0 centrality --//
3274     if ( fUseCentrality == 1 ){
3275       if      ( centralityVZERO >  0. && centralityVZERO <   5.) centralityVZEROBin =  0;
3276       else if ( centralityVZERO >=  5. && centralityVZERO <  10.) centralityVZEROBin =  5;
3277       else if ( centralityVZERO >= 10. && centralityVZERO <  20.) centralityVZEROBin = 10;
3278       else if ( centralityVZERO >= 20. && centralityVZERO <  30.) centralityVZEROBin = 20;
3279       else if ( centralityVZERO >= 30. && centralityVZERO <  40.) centralityVZEROBin = 30;
3280       else if ( centralityVZERO >= 40. && centralityVZERO <  50.) centralityVZEROBin = 40;
3281       else if ( centralityVZERO >= 50. && centralityVZERO <  60.) centralityVZEROBin = 50;
3282       else if ( centralityVZERO >= 60. && centralityVZERO <  70.) centralityVZEROBin = 60;
3283       else if ( centralityVZERO >= 70. && centralityVZERO <  80.) centralityVZEROBin = 70;
3284       else if ( centralityVZERO >= 80. && centralityVZERO <  90.) centralityVZEROBin = 80;
3285       else if ( centralityVZERO >= 90. && centralityVZERO <  99.) centralityVZEROBin = 90;
3286       else if ( centralityVZERO >= 99. ) centralityVZEROBin = 100;
3287       else if ( fabs(centralityVZERO)< 0.0001 ) centralityVZEROBin = 100;
3288       return centralityVZEROBin;
3289     }
3290     return -1;
3291   
3292   }
3293   //__________________________________________________________________________________________________________
3294   Bool_t  AliAnalysisTaskV0ForRAA::GetMCTruthPartner(AliESDtrack *pos,AliESDtrack *neg,Int_t id0,Int_t id1){
3295     //-- get daughter label and check it --//
3296     Int_t labelP = fabs(pos->GetLabel());
3297     Int_t labelN = fabs(neg->GetLabel());
3298
3299     // cout<<pos->GetLabel()<<"  "<<neg->GetLabel()<<"  id "<<id0<<"  "<<id1<<endl;
3300       
3301     if (labelN==labelP)  return kFALSE;
3302       
3303     if(fMCTruthMode){
3304       if ((labelP!=id0) && (labelP!=id1))  return kFALSE;
3305       if ((labelN!=id0) && (labelN!=id1))  return kFALSE;
3306     }
3307     // cout<<"yes"<<endl;
3308     return kTRUE;
3309   }
3310