]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/vertexingHF/AliRDHFCutsDstoKKpi.cxx
Some fixes
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliRDHFCutsDstoKKpi.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 /////////////////////////////////////////////////////////////
19 //
20 // Class for cuts on AOD reconstructed Ds->KKpi
21 //
22 // Author: A.Dainese, andrea.dainese@pd.infn.it
23 /////////////////////////////////////////////////////////////
24
25 #include <TDatabasePDG.h>
26 #include <Riostream.h>
27
28 #include "AliRDHFCutsDstoKKpi.h"
29 #include "AliAODRecoDecayHF3Prong.h"
30 #include "AliAODTrack.h"
31 #include "AliESDtrack.h"
32
33 ClassImp(AliRDHFCutsDstoKKpi)
34
35 //--------------------------------------------------------------------------
36 AliRDHFCutsDstoKKpi::AliRDHFCutsDstoKKpi(const char* name) : 
37 AliRDHFCuts(name)
38 {
39   //
40   // Default Constructor
41   //
42   Int_t nvars=16;
43   SetNVars(nvars);
44   TString varNames[16]={"inv. mass [GeV]",   
45                         "pTK [GeV/c]",
46                         "pTPi [GeV/c]",
47                         "d0K [cm]",
48                         "d0Pi [cm]",
49                         "dist12 [cm]",
50                         "sigmavert [cm]",
51                         "decLen [cm]",
52                         "ptMax [GeV/c]",
53                         "cosThetaPoint",
54                         "Sum d0^2 (cm^2)",
55                         "dca [cm]",
56                         "inv. mass (Mphi-MKK) [GeV]",
57                         "inv. mass (MKo*-MKpi) [GeV]",
58                         "Abs(CosineKpiPhiRFrame)^3",
59                         "CosPiDsLabFrame"};
60                         
61   Bool_t isUpperCut[16]={kTRUE,
62                          kFALSE,
63                          kFALSE,
64                          kFALSE,
65                          kFALSE,
66                          kFALSE,
67                          kTRUE,
68                          kFALSE,
69                          kFALSE,
70                          kFALSE,
71                          kFALSE,
72                          kTRUE,
73                          kTRUE,
74                          kTRUE,
75                          kFALSE,
76                          kTRUE};
77   SetVarNames(16,varNames,isUpperCut);
78   Bool_t forOpt[16]={kFALSE,
79                     kFALSE,
80                     kFALSE,
81                     kFALSE,
82                     kFALSE,
83                     kFALSE,
84                     kTRUE,
85                     kTRUE,
86                     kTRUE,
87                     kTRUE,
88                     kTRUE,
89                     kFALSE,
90                     kTRUE,
91                     kTRUE,
92                     kFALSE,
93                     kFALSE};
94   SetVarsForOpt(7,forOpt);
95   Float_t limits[2]={0,999999999.};
96   SetPtBins(2,limits);
97   if(fPidHF)delete fPidHF;
98   fPidHF=new AliAODPidHF();
99   Double_t plim[2]={0.6,0.8};
100   Double_t nsigma[5]={2.,1.,2.,3.,0.};
101   
102   fPidHF->SetPLimit(plim);
103   fPidHF->SetAsym(kTRUE);
104   fPidHF->SetSigma(nsigma);
105   fPidHF->SetMatch(1);
106   fPidHF->SetTPC(1);
107   fPidHF->SetTOF(1);
108   fPidHF->SetITS(0);
109   fPidHF->SetTRD(0);
110   fPidHF->SetCompat(kTRUE);
111
112 }
113 //--------------------------------------------------------------------------
114 AliRDHFCutsDstoKKpi::AliRDHFCutsDstoKKpi(const AliRDHFCutsDstoKKpi &source) :
115   AliRDHFCuts(source)
116 {
117   //
118   // Copy constructor
119   //
120
121 }
122 //--------------------------------------------------------------------------
123 AliRDHFCutsDstoKKpi &AliRDHFCutsDstoKKpi::operator=(const AliRDHFCutsDstoKKpi &source)
124 {
125   //
126   // assignment operator
127   //
128   if(&source == this) return *this;
129
130   AliRDHFCuts::operator=(source);
131
132   return *this;
133 }
134
135
136 //---------------------------------------------------------------------------
137 void AliRDHFCutsDstoKKpi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters,AliAODEvent *aod) {
138   // 
139   // Fills in vars the values of the variables 
140   //
141
142   if(nvars!=fnVarsForOpt) {
143     printf("AliRDHFCutsDstoKKpi::GetCutsVarsForOpt: wrong number of variables\n");
144     return;
145   }
146
147   AliAODRecoDecayHF3Prong *dd = (AliAODRecoDecayHF3Prong*)d;
148   
149   //recalculate vertex w/o daughters
150   Bool_t cleanvtx=kFALSE;
151   AliAODVertex *origownvtx=0x0;
152   if(fRemoveDaughtersFromPrimary) {
153     if(dd->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*dd->GetOwnPrimaryVtx());
154     cleanvtx=kTRUE;
155     if(!RecalcOwnPrimaryVtx(dd,aod)) {
156       CleanOwnPrimaryVtx(dd,aod,origownvtx);
157       cleanvtx=kFALSE;
158     }
159   }
160
161   Int_t iter=-1;
162   if(fVarsForOpt[0]){
163     iter++;
164     if(TMath::Abs(pdgdaughters[0])==321){
165       vars[iter]=dd->InvMassDsKKpi();
166     }else{
167       vars[iter]=dd->InvMassDspiKK();
168     }
169   }
170   if(fVarsForOpt[1]){
171     iter++;
172     Float_t minPtDau=99999.;
173     for(Int_t iprong=0;iprong<3;iprong++){
174       if(TMath::Abs(pdgdaughters[iprong])==321 && 
175          dd->PtProng(iprong)<minPtDau) minPtDau=dd->PtProng(iprong);
176     }
177     vars[iter]=minPtDau;
178   }
179   if(fVarsForOpt[2]){
180     iter++;
181     for(Int_t iprong=0;iprong<3;iprong++){
182       if(TMath::Abs(pdgdaughters[iprong])==211) {
183         vars[iter]=dd->PtProng(iprong);
184       }
185     }
186   }
187   if(fVarsForOpt[3]){
188     iter++;
189     Float_t minImpParDau=99999.;
190     for(Int_t iprong=0;iprong<3;iprong++){
191       if(TMath::Abs(pdgdaughters[iprong])==321 &&
192          dd->Getd0Prong(iprong)<minImpParDau) minImpParDau=dd->Getd0Prong(iprong);
193     }
194     vars[iter]=minImpParDau;
195   }
196   if(fVarsForOpt[4]){
197     iter++;
198     for(Int_t iprong=0;iprong<3;iprong++){
199       if(TMath::Abs(pdgdaughters[iprong])==211) {
200         vars[iter]=dd->Getd0Prong(iprong);
201       }
202     }
203   }
204   if(fVarsForOpt[5]){
205     iter++;
206     Float_t minDistPair=TMath::Min(dd->GetDist12toPrim(),dd->GetDist23toPrim());
207     vars[iter]=minDistPair;
208   }
209   if(fVarsForOpt[6]){
210     iter++;
211     vars[iter]=dd->GetSigmaVert();
212   }
213   if(fVarsForOpt[7]){
214     iter++;
215     vars[iter] = dd->DecayLength();
216   }
217   if(fVarsForOpt[8]){
218     iter++;
219     Float_t ptmax=0;
220     for(Int_t i=0;i<3;i++){
221       if(dd->PtProng(i)>ptmax)ptmax=dd->PtProng(i);
222     }
223     vars[iter]=ptmax;
224   }
225   if(fVarsForOpt[9]){
226     iter++;
227     vars[iter]=dd->CosPointingAngle();
228   }
229   if(fVarsForOpt[10]){
230     iter++;
231     vars[iter]=dd->Getd0Prong(0)*dd->Getd0Prong(0)+dd->Getd0Prong(1)*dd->Getd0Prong(1)+dd->Getd0Prong(2)*dd->Getd0Prong(2);
232   }
233   if(fVarsForOpt[11]){
234     iter++;
235     Float_t maxDCA=0.;
236     for(Int_t i=0;i<3;i++){ 
237       if(d->GetDCA(i)>maxDCA) maxDCA=d->GetDCA(i);
238     }
239     vars[iter]=maxDCA;
240   }
241   if(fVarsForOpt[12]){
242     iter++;
243     Double_t mPDGPhi = TDatabasePDG::Instance()->GetParticle(333)->Mass();
244     if(TMath::Abs(pdgdaughters[0])==321){
245       
246       Double_t phimass01=d->InvMass2Prongs(0,1,321,321);
247        vars[iter]=TMath::Abs(phimass01-mPDGPhi);
248        // vars[iter]=dd->InvMass2Prongs(0,1,321,321);
249     }else{
250       Double_t phimass12=d->InvMass2Prongs(1,2,321,321);
251        vars[iter]=TMath::Abs(phimass12-mPDGPhi);
252        // vars[iter]=dd->InvMass2Prongs(1,2,321,321);      
253     }
254   }
255   if(fVarsForOpt[13]){
256     iter++;
257     Double_t mPDGK0star = TDatabasePDG::Instance()->GetParticle(313)->Mass();
258     if(TMath::Abs(pdgdaughters[0])==321){
259       
260       Double_t mass12kpi=d->InvMass2Prongs(1,2,321,211);
261       vars[iter]=TMath::Abs(mass12kpi-mPDGK0star);
262       //              vars[iter]=dd->InvMass2Prongs(1,2,321,211);
263     }else{
264       Double_t mass01pik=d->InvMass2Prongs(0,1,211,321);
265       vars[iter]=TMath::Abs(mass01pik-mPDGK0star);
266       //        vars[iter]=dd->InvMass2Prongs(0,1,211,321);      
267     }
268   }
269   if(fVarsForOpt[14]){
270     iter++;
271     if(TMath::Abs(pdgdaughters[0])==321){
272       vars[iter]=dd->CosPiKPhiRFrameKKpi();
273     }else{
274       vars[iter]=dd->CosPiKPhiRFramepiKK();
275     }
276   }
277   if(fVarsForOpt[15]){
278     iter++;
279     if(TMath::Abs(pdgdaughters[0])==321){
280       vars[iter]=dd->CosPiDsLabFrameKKpi();
281     }else{
282       vars[iter]=dd->CosPiDsLabFramepiKK();
283     }
284   }
285
286   if(cleanvtx)CleanOwnPrimaryVtx(dd,aod,origownvtx); 
287   return;
288 }
289 //---------------------------------------------------------------------------
290 Bool_t AliRDHFCutsDstoKKpi::IsInFiducialAcceptance(Double_t pt, Double_t y) const
291 {
292   //
293   // Checking if Ds is in fiducial acceptance region 
294   //
295
296   if(pt > 5.) {
297     // applying cut for pt > 5 GeV
298     AliDebug(2,Form("pt of Ds = %f (> 5), cutting at |y| < 0.8",pt)); 
299     if (TMath::Abs(y) > 0.8) return kFALSE;
300     
301   } else {
302     // appliying smooth cut for pt < 5 GeV
303     Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5; 
304     Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;         
305     AliDebug(2,Form("pt of Ds = %f (< 5), cutting  according to the fiducial zone [%f, %f]\n",pt,minFiducialY,maxFiducialY)); 
306     if (y < minFiducialY || y > maxFiducialY) return kFALSE;    
307   }
308
309   return kTRUE;
310 }
311
312 //---------------------------------------------------------------------------
313 Int_t AliRDHFCutsDstoKKpi::IsSelectedPID(AliAODRecoDecayHF *rd) {
314   // PID selection
315   // return values: 0->NOT OK, 1->OK as KKpi, 2->OK as piKK, 3->OK as both 
316   Int_t retCode=3;
317   Bool_t okKKpi=kTRUE;
318   Bool_t okpiKK=kTRUE;
319   if(!fUsePID || !rd) return retCode;
320   if(!fPidHF){
321     AliWarning("AliAODPidHF not created!");
322     return retCode;
323   }
324   Int_t nKaons=0;
325   Int_t nNotKaons=0;
326   Int_t sign= rd->GetCharge(); 
327   for(Int_t iDaught=0; iDaught<3; iDaught++){
328     AliAODTrack *track=(AliAODTrack*)rd->GetDaughter(iDaught);
329     Int_t isPion=fPidHF->MakeRawPid(track,AliPID::kPion);
330     Int_t isKaon=fPidHF->MakeRawPid(track,AliPID::kKaon);
331     Int_t isProton=fPidHF->MakeRawPid(track,AliPID::kProton);
332     
333     if(isProton>0 &&  isKaon<0  && isPion<0) return 0;
334     if(sign!=track->Charge()){// must be kaon
335       if(isKaon<0) return 0;
336     }
337     if(isKaon>0 && isPion<0) nKaons++;
338     if(isKaon<0) nNotKaons++;
339     if(iDaught==0){
340       if(isKaon<0) okKKpi=kFALSE;
341       if(isPion<0) okpiKK=kFALSE;
342     }
343     else if(iDaught==2){
344       if(isKaon<0) okpiKK=kFALSE;
345       if(isPion<0) okKKpi=kFALSE;
346     }
347   }
348   
349   if(nKaons>2)return 0;
350   if(nNotKaons>1) return 0;
351   
352   if(!okKKpi) retCode-=1;
353   if(!okpiKK) retCode-=2;
354
355   return retCode;
356 }
357
358 //---------------------------------------------------------------------------
359 Int_t AliRDHFCutsDstoKKpi::IsSelected(TObject* obj,Int_t selectionLevel, AliAODEvent* aod) {
360   //
361   // Apply selection
362   //
363
364   if(!fCutsRD){
365     cout<<"Cut matrix not inizialized. Exit..."<<endl;
366     return 0;
367   }
368   //PrintAll();
369   AliAODRecoDecayHF3Prong* d=(AliAODRecoDecayHF3Prong*)obj;
370
371   if(!d){
372     cout<<"AliAODRecoDecayHF3Prong null"<<endl;
373     return 0;
374   }
375  
376   Double_t ptD=d->Pt();
377   if(ptD<fMinPtCand) return 0;
378   if(ptD>fMaxPtCand) return 0;
379
380   // selection on daughter tracks 
381   if(selectionLevel==AliRDHFCuts::kAll || 
382      selectionLevel==AliRDHFCuts::kTracks) {
383     if(!AreDaughtersSelected(d)) return 0;
384   }
385
386
387
388  
389   // selection on candidate
390   if(selectionLevel==AliRDHFCuts::kAll || 
391      selectionLevel==AliRDHFCuts::kCandidate) {
392     //recalculate vertex w/o daughters
393     AliAODVertex *origownvtx=0x0;
394     if(fRemoveDaughtersFromPrimary) {
395       if(d->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*d->GetOwnPrimaryVtx());
396       if(!RecalcOwnPrimaryVtx(d,aod)) {
397         CleanOwnPrimaryVtx(d,aod,origownvtx);
398         return 0;
399       }
400     }
401
402     Int_t okDsKKpi=1;
403     Int_t okDspiKK=1;
404     Int_t okMassPhiKKpi=0;
405     Int_t okMassPhipiKK=0;
406     Int_t okMassK0starKKpi=0;
407     Int_t okMassK0starpiKK=0;
408     Int_t okDsPhiKKpi=0;
409     Int_t okDsPhipiKK=0;
410     Int_t okDsK0starKKpi=0;
411     Int_t okDsK0starpiKK=0;
412
413     Double_t pt=d->Pt();
414     Int_t ptbin=PtBin(pt);
415     if (ptbin==-1) {
416       CleanOwnPrimaryVtx(d,aod,origownvtx);
417       return 0;
418     }
419  
420     Double_t mDsPDG = TDatabasePDG::Instance()->GetParticle(431)->Mass();
421     Double_t mDsKKpi=d->InvMassDsKKpi();
422     Double_t mDspiKK=d->InvMassDspiKK();
423     if(TMath::Abs(mDsKKpi-mDsPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okDsKKpi = 0;
424     if(TMath::Abs(mDspiKK-mDsPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okDspiKK = 0;
425     if(!okDsKKpi && !okDspiKK){
426       CleanOwnPrimaryVtx(d,aod,origownvtx);
427       return 0;
428     }
429
430
431
432     // cuts on resonant decays (via Phi or K0*)
433     Double_t mPhiPDG = TDatabasePDG::Instance()->GetParticle(333)->Mass();
434     Double_t mK0starPDG = TDatabasePDG::Instance()->GetParticle(313)->Mass();
435     if(okDsKKpi){
436       Double_t mass01phi=d->InvMass2Prongs(0,1,321,321);
437       Double_t mass12K0s=d->InvMass2Prongs(1,2,321,211);
438       if(TMath::Abs(mass01phi-mPhiPDG)<fCutsRD[GetGlobalIndex(12,ptbin)]) okMassPhiKKpi=1;
439       if(TMath::Abs(mass12K0s-mK0starPDG)<fCutsRD[GetGlobalIndex(13,ptbin)]) okMassK0starKKpi = 1;
440       if(!okMassPhiKKpi && !okMassK0starKKpi) okDsKKpi=0;
441       if(okMassPhiKKpi) okDsPhiKKpi=1;
442       if(okMassK0starKKpi) okDsK0starKKpi=1;
443     }
444     if(okDspiKK){
445       Double_t mass01K0s=d->InvMass2Prongs(0,1,211,321);
446       Double_t mass12phi=d->InvMass2Prongs(1,2,321,321);
447       if(TMath::Abs(mass01K0s-mK0starPDG)<fCutsRD[GetGlobalIndex(13,ptbin)]) okMassK0starpiKK = 1;
448       if(TMath::Abs(mass12phi-mPhiPDG)<fCutsRD[GetGlobalIndex(12,ptbin)]) okMassPhipiKK=1;
449       if(!okMassPhipiKK && !okMassK0starpiKK) okDspiKK=0;
450       if(okMassPhipiKK) okDsPhipiKK=1;
451       if(okMassK0starpiKK) okDsK0starpiKK=1;
452     }
453     if(!okDsKKpi && !okDspiKK){
454       CleanOwnPrimaryVtx(d,aod,origownvtx);
455       return 0;
456     }
457
458     // Cuts on track pairs
459     for(Int_t i=0;i<3;i++){
460       if(d->GetDCA(i)>fCutsRD[GetGlobalIndex(11,ptbin)]){
461         CleanOwnPrimaryVtx(d,aod,origownvtx);
462         return 0;
463       }
464     }
465     if(d->GetDist12toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)] || 
466        d->GetDist23toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]){
467       CleanOwnPrimaryVtx(d,aod,origownvtx);
468       return 0;
469     }
470
471
472
473     //single track
474     if(TMath::Abs(d->Pt2Prong(1)) < fCutsRD[GetGlobalIndex(1,ptbin)]*fCutsRD[GetGlobalIndex(1,ptbin)] || 
475        TMath::Abs(d->Getd0Prong(1))<fCutsRD[GetGlobalIndex(3,ptbin)]){
476       CleanOwnPrimaryVtx(d,aod,origownvtx);
477       return 0;
478     }
479
480     if(okDsKKpi){
481       if(TMath::Abs(d->Pt2Prong(0)) < fCutsRD[GetGlobalIndex(1,ptbin)]*fCutsRD[GetGlobalIndex(1,ptbin)] || 
482          TMath::Abs(d->Getd0Prong(0))<fCutsRD[GetGlobalIndex(3,ptbin)]) okDsKKpi=0;
483       if(TMath::Abs(d->Pt2Prong(2)) < fCutsRD[GetGlobalIndex(2,ptbin)]*fCutsRD[GetGlobalIndex(2,ptbin)] || 
484          TMath::Abs(d->Getd0Prong(2))<fCutsRD[GetGlobalIndex(4,ptbin)]) okDsKKpi=0;
485     }
486     if(okDspiKK){
487       if(TMath::Abs(d->Pt2Prong(0)) < fCutsRD[GetGlobalIndex(2,ptbin)]*fCutsRD[GetGlobalIndex(2,ptbin)] || 
488          TMath::Abs(d->Getd0Prong(0))<fCutsRD[GetGlobalIndex(4,ptbin)]) okDspiKK=0;
489       if(TMath::Abs(d->Pt2Prong(2)) < fCutsRD[GetGlobalIndex(1,ptbin)]*fCutsRD[GetGlobalIndex(1,ptbin)] || 
490          TMath::Abs(d->Getd0Prong(2))<fCutsRD[GetGlobalIndex(3,ptbin)]) okDspiKK=0;
491     }
492     if(!okDsKKpi && !okDspiKK){
493       CleanOwnPrimaryVtx(d,aod,origownvtx);
494       return 0;
495     }
496
497     // Cuts on candidate triplet
498
499     if(d->GetSigmaVert()>fCutsRD[GetGlobalIndex(6,ptbin)]){
500       CleanOwnPrimaryVtx(d,aod,origownvtx);
501       return 0;
502     }
503
504     if(d->CosPointingAngle()< fCutsRD[GetGlobalIndex(9,ptbin)]){
505       CleanOwnPrimaryVtx(d,aod,origownvtx); 
506       return 0;
507     }
508      
509     if(d->Pt2Prong(0)<fCutsRD[GetGlobalIndex(8,ptbin)]*fCutsRD[GetGlobalIndex(8,ptbin)] && 
510        d->Pt2Prong(1)<fCutsRD[GetGlobalIndex(8,ptbin)]*fCutsRD[GetGlobalIndex(8,ptbin)] && 
511        d->Pt2Prong(2)<fCutsRD[GetGlobalIndex(8,ptbin)]*fCutsRD[GetGlobalIndex(8,ptbin)]) {
512       CleanOwnPrimaryVtx(d,aod,origownvtx); 
513       return 0;
514     }
515
516     if(d->DecayLength2()<fCutsRD[GetGlobalIndex(7,ptbin)]*fCutsRD[GetGlobalIndex(7,ptbin)]){
517       CleanOwnPrimaryVtx(d,aod,origownvtx);
518       return 0;
519     }
520
521
522     Double_t sum2=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
523     if(sum2<fCutsRD[GetGlobalIndex(10,ptbin)]){
524       CleanOwnPrimaryVtx(d,aod,origownvtx);
525       return 0;
526     }
527
528      // unset recalculated primary vertex when not needed any more
529     CleanOwnPrimaryVtx(d,aod,origownvtx);
530     
531     if(okDsKKpi){
532       Double_t cosPiKPhiRFKKpi=d->CosPiKPhiRFrameKKpi();
533       Double_t kincutPiKPhiKKpi=TMath::Abs(cosPiKPhiRFKKpi*cosPiKPhiRFKKpi*cosPiKPhiRFKKpi);
534       if(kincutPiKPhiKKpi<fCutsRD[GetGlobalIndex(14,ptbin)]) okDsKKpi=0;
535     }
536     if(okDspiKK){
537       Double_t cosPiKPhiRFpiKK=d->CosPiKPhiRFramepiKK();
538       Double_t kincutPiKPhipiKK=TMath::Abs(cosPiKPhiRFpiKK*cosPiKPhiRFpiKK*cosPiKPhiRFpiKK);
539       if(kincutPiKPhipiKK<fCutsRD[GetGlobalIndex(14,ptbin)]) okDspiKK=0;
540     }
541     if(!okDsKKpi && !okDspiKK){
542       CleanOwnPrimaryVtx(d,aod,origownvtx);
543       return 0;
544     }
545     
546     
547     
548     if(okDsKKpi){
549       Double_t cosPiDsLabFrameKKpi=d->CosPiDsLabFrameKKpi();
550       if(TMath::Abs(cosPiDsLabFrameKKpi)>fCutsRD[GetGlobalIndex(15,ptbin)]) okDsKKpi=0;
551     }
552     if(okDspiKK){
553       Double_t cosPiDsLabFramepiKK=d->CosPiDsLabFramepiKK();
554       if(TMath::Abs(cosPiDsLabFramepiKK)>fCutsRD[GetGlobalIndex(15,ptbin)]) okDspiKK=0;
555     }
556     if(!okDsKKpi && !okDspiKK){
557       CleanOwnPrimaryVtx(d,aod,origownvtx);
558       return 0;
559     }
560     
561     
562     
563
564     if(!okDsKKpi){
565       okDsPhiKKpi=0;
566       okDsK0starKKpi=0;
567     }
568     if(!okDspiKK){
569       okDsPhipiKK=0;
570       okDsK0starpiKK=0;
571     }
572
573     // PID selection
574     Int_t returnvaluePID=3;  
575     if(selectionLevel==AliRDHFCuts::kAll || 
576        selectionLevel==AliRDHFCuts::kCandidate ||     
577        selectionLevel==AliRDHFCuts::kPID) {
578       returnvaluePID = IsSelectedPID(d);
579       fIsSelectedPID=returnvaluePID;
580     }
581     if(returnvaluePID==0)return 0;
582
583     Bool_t okPidDsKKpi=returnvaluePID&1;
584     Bool_t okPidDspiKK=returnvaluePID&2;
585     if(!okPidDsKKpi){
586       okDsPhiKKpi=0;
587       okDsK0starKKpi=0;
588     }
589     if(!okPidDspiKK){
590       okDsPhipiKK=0;
591       okDsK0starpiKK=0;
592     }
593
594     if((okPidDsKKpi && okDsKKpi)||(okPidDspiKK && okDspiKK)){
595       Int_t returnvalue=0;
596       if(okDsKKpi) returnvalue+=1;
597       if(okDspiKK) returnvalue+=2;
598       if(okDsPhiKKpi) returnvalue+=4;
599       if(okDsPhipiKK) returnvalue+=8;
600       if(okDsK0starKKpi) returnvalue+=16;
601       if(okDsK0starpiKK) returnvalue+=32;
602       return returnvalue;
603     }else{
604       return 0;
605     }
606   }
607   return 15;
608
609 }
610 //---------------------------------------------------------------------------