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