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