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