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