]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/AliRDHFCutsDstoKKpi.cxx
Transition PWG3 --> PWGHF
[u/mrichter/AliRoot.git] / PWGHF / 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 fPidOption(0)
39 {
40   //
41   // Default Constructor
42   //
43   Int_t nvars=16;
44   SetNVars(nvars);
45   TString varNames[16]={"inv. mass [GeV]",   
46                         "pTK [GeV/c]",
47                         "pTPi [GeV/c]",
48                         "d0K [cm]",
49                         "d0Pi [cm]",
50                         "dist12 [cm]",
51                         "sigmavert [cm]",
52                         "decLen [cm]",
53                         "ptMax [GeV/c]",
54                         "cosThetaPoint",
55                         "Sum d0^2 (cm^2)",
56                         "dca [cm]",
57                         "inv. mass (Mphi-MKK) [GeV]",
58                         "inv. mass (MKo*-MKpi) [GeV]",
59                         "Abs(CosineKpiPhiRFrame)^3",
60                         "CosPiDsLabFrame"};
61                         
62   Bool_t isUpperCut[16]={kTRUE,
63                          kFALSE,
64                          kFALSE,
65                          kFALSE,
66                          kFALSE,
67                          kFALSE,
68                          kTRUE,
69                          kFALSE,
70                          kFALSE,
71                          kFALSE,
72                          kFALSE,
73                          kTRUE,
74                          kTRUE,
75                          kTRUE,
76                          kFALSE,
77                          kTRUE};
78   SetVarNames(16,varNames,isUpperCut);
79   Bool_t forOpt[16]={kFALSE,
80                     kFALSE,
81                     kFALSE,
82                     kFALSE,
83                     kFALSE,
84                     kFALSE,
85                     kTRUE,
86                     kTRUE,
87                     kTRUE,
88                     kTRUE,
89                     kTRUE,
90                     kFALSE,
91                     kTRUE,
92                     kTRUE,
93                     kFALSE,
94                     kFALSE};
95   SetVarsForOpt(7,forOpt);
96   Float_t limits[2]={0,999999999.};
97   SetPtBins(2,limits);
98   if(fPidHF)delete fPidHF;
99   fPidHF=new AliAODPidHF();
100   Double_t plim[2]={0.6,0.8};
101   Double_t nsigma[5]={2.,1.,2.,3.,0.};
102   
103   fPidHF->SetPLimit(plim);
104   fPidHF->SetAsym(kTRUE);
105   fPidHF->SetSigma(nsigma);
106   fPidHF->SetMatch(1);
107   fPidHF->SetTPC(1);
108   fPidHF->SetTOF(1);
109   fPidHF->SetITS(0);
110   fPidHF->SetTRD(0);
111   fPidHF->SetCompat(kTRUE);
112
113 }
114 //--------------------------------------------------------------------------
115 AliRDHFCutsDstoKKpi::AliRDHFCutsDstoKKpi(const AliRDHFCutsDstoKKpi &source) :
116   AliRDHFCuts(source),
117   fPidOption(source.fPidOption)
118 {
119   //
120   // Copy constructor
121   //
122
123 }
124 //--------------------------------------------------------------------------
125 AliRDHFCutsDstoKKpi &AliRDHFCutsDstoKKpi::operator=(const AliRDHFCutsDstoKKpi &source)
126 {
127   //
128   // assignment operator
129   //
130   if(&source == this) return *this;
131
132   AliRDHFCuts::operator=(source);
133
134   fPidOption=source.fPidOption;
135
136   return *this;
137 }
138
139
140 //---------------------------------------------------------------------------
141 void AliRDHFCutsDstoKKpi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters,AliAODEvent *aod) {
142   // 
143   // Fills in vars the values of the variables 
144   //
145
146   if(nvars!=fnVarsForOpt) {
147     printf("AliRDHFCutsDstoKKpi::GetCutsVarsForOpt: wrong number of variables\n");
148     return;
149   }
150
151   AliAODRecoDecayHF3Prong *dd = (AliAODRecoDecayHF3Prong*)d;
152   
153   //recalculate vertex w/o daughters
154   Bool_t cleanvtx=kFALSE;
155   AliAODVertex *origownvtx=0x0;
156   if(fRemoveDaughtersFromPrimary) {
157     if(dd->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*dd->GetOwnPrimaryVtx());
158     cleanvtx=kTRUE;
159     if(!RecalcOwnPrimaryVtx(dd,aod)) {
160       CleanOwnPrimaryVtx(dd,aod,origownvtx);
161       cleanvtx=kFALSE;
162     }
163   }
164
165   Int_t iter=-1;
166   if(fVarsForOpt[0]){
167     iter++;
168     if(TMath::Abs(pdgdaughters[0])==321){
169       vars[iter]=dd->InvMassDsKKpi();
170     }else{
171       vars[iter]=dd->InvMassDspiKK();
172     }
173   }
174   if(fVarsForOpt[1]){
175     iter++;
176     Float_t minPtDau=99999.;
177     for(Int_t iprong=0;iprong<3;iprong++){
178       if(TMath::Abs(pdgdaughters[iprong])==321 && 
179          dd->PtProng(iprong)<minPtDau) minPtDau=dd->PtProng(iprong);
180     }
181     vars[iter]=minPtDau;
182   }
183   if(fVarsForOpt[2]){
184     iter++;
185     for(Int_t iprong=0;iprong<3;iprong++){
186       if(TMath::Abs(pdgdaughters[iprong])==211) {
187         vars[iter]=dd->PtProng(iprong);
188       }
189     }
190   }
191   if(fVarsForOpt[3]){
192     iter++;
193     Float_t minImpParDau=99999.;
194     for(Int_t iprong=0;iprong<3;iprong++){
195       if(TMath::Abs(pdgdaughters[iprong])==321 &&
196          dd->Getd0Prong(iprong)<minImpParDau) minImpParDau=dd->Getd0Prong(iprong);
197     }
198     vars[iter]=minImpParDau;
199   }
200   if(fVarsForOpt[4]){
201     iter++;
202     for(Int_t iprong=0;iprong<3;iprong++){
203       if(TMath::Abs(pdgdaughters[iprong])==211) {
204         vars[iter]=dd->Getd0Prong(iprong);
205       }
206     }
207   }
208   if(fVarsForOpt[5]){
209     iter++;
210     Float_t minDistPair=TMath::Min(dd->GetDist12toPrim(),dd->GetDist23toPrim());
211     vars[iter]=minDistPair;
212   }
213   if(fVarsForOpt[6]){
214     iter++;
215     vars[iter]=dd->GetSigmaVert(aod);
216   }
217   if(fVarsForOpt[7]){
218     iter++;
219     vars[iter] = dd->DecayLength();
220   }
221   if(fVarsForOpt[8]){
222     iter++;
223     Float_t ptmax=0;
224     for(Int_t i=0;i<3;i++){
225       if(dd->PtProng(i)>ptmax)ptmax=dd->PtProng(i);
226     }
227     vars[iter]=ptmax;
228   }
229   if(fVarsForOpt[9]){
230     iter++;
231     vars[iter]=dd->CosPointingAngle();
232   }
233   if(fVarsForOpt[10]){
234     iter++;
235     vars[iter]=dd->Getd0Prong(0)*dd->Getd0Prong(0)+dd->Getd0Prong(1)*dd->Getd0Prong(1)+dd->Getd0Prong(2)*dd->Getd0Prong(2);
236   }
237   if(fVarsForOpt[11]){
238     iter++;
239     Float_t maxDCA=0.;
240     for(Int_t i=0;i<3;i++){ 
241       if(d->GetDCA(i)>maxDCA) maxDCA=d->GetDCA(i);
242     }
243     vars[iter]=maxDCA;
244   }
245   if(fVarsForOpt[12]){
246     iter++;
247     Double_t mPDGPhi = TDatabasePDG::Instance()->GetParticle(333)->Mass();
248     if(TMath::Abs(pdgdaughters[0])==321){
249       
250       Double_t phimass01=d->InvMass2Prongs(0,1,321,321);
251        vars[iter]=TMath::Abs(phimass01-mPDGPhi);
252        // vars[iter]=dd->InvMass2Prongs(0,1,321,321);
253     }else{
254       Double_t phimass12=d->InvMass2Prongs(1,2,321,321);
255        vars[iter]=TMath::Abs(phimass12-mPDGPhi);
256        // vars[iter]=dd->InvMass2Prongs(1,2,321,321);      
257     }
258   }
259   if(fVarsForOpt[13]){
260     iter++;
261     Double_t mPDGK0star = TDatabasePDG::Instance()->GetParticle(313)->Mass();
262     if(TMath::Abs(pdgdaughters[0])==321){
263       
264       Double_t mass12kpi=d->InvMass2Prongs(1,2,321,211);
265       vars[iter]=TMath::Abs(mass12kpi-mPDGK0star);
266       //              vars[iter]=dd->InvMass2Prongs(1,2,321,211);
267     }else{
268       Double_t mass01pik=d->InvMass2Prongs(0,1,211,321);
269       vars[iter]=TMath::Abs(mass01pik-mPDGK0star);
270       //        vars[iter]=dd->InvMass2Prongs(0,1,211,321);      
271     }
272   }
273   if(fVarsForOpt[14]){
274     iter++;
275     if(TMath::Abs(pdgdaughters[0])==321){
276       vars[iter]=dd->CosPiKPhiRFrameKKpi();
277     }else{
278       vars[iter]=dd->CosPiKPhiRFramepiKK();
279     }
280   }
281   if(fVarsForOpt[15]){
282     iter++;
283     if(TMath::Abs(pdgdaughters[0])==321){
284       vars[iter]=dd->CosPiDsLabFrameKKpi();
285     }else{
286       vars[iter]=dd->CosPiDsLabFramepiKK();
287     }
288   }
289
290   if(cleanvtx)CleanOwnPrimaryVtx(dd,aod,origownvtx); 
291   return;
292 }
293 //---------------------------------------------------------------------------
294 Bool_t AliRDHFCutsDstoKKpi::IsInFiducialAcceptance(Double_t pt, Double_t y) const
295 {
296   //
297   // Checking if Ds is in fiducial acceptance region 
298   //
299
300   if(pt > 5.) {
301     // applying cut for pt > 5 GeV
302     AliDebug(2,Form("pt of Ds = %f (> 5), cutting at |y| < 0.8",pt)); 
303     if (TMath::Abs(y) > 0.8) return kFALSE;
304     
305   } else {
306     // appliying smooth cut for pt < 5 GeV
307     Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5; 
308     Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;         
309     AliDebug(2,Form("pt of Ds = %f (< 5), cutting  according to the fiducial zone [%f, %f]\n",pt,minFiducialY,maxFiducialY)); 
310     if (y < minFiducialY || y > maxFiducialY) return kFALSE;    
311   }
312
313   return kTRUE;
314 }
315
316 //---------------------------------------------------------------------------
317 Int_t AliRDHFCutsDstoKKpi::IsSelectedPID(AliAODRecoDecayHF *rd) {
318   // PID selection
319   // return values: 0->NOT OK, 1->OK as KKpi, 2->OK as piKK, 3->OK as both 
320   Int_t retCode=3;
321   Bool_t okKKpi=kTRUE;
322   Bool_t okpiKK=kTRUE;
323   if(!fUsePID || !rd) return retCode;
324   if(!fPidHF){
325     AliWarning("AliAODPidHF not created!");
326     return retCode;
327   }
328
329   Double_t origCompatTOF=fPidHF->GetPCompatTOF();
330   Double_t origThreshTPC=fPidHF->GetPtThresholdTPC();
331   if(fPidOption==kStrong){
332     fPidHF->SetPCompatTOF(999999.);
333     fPidHF->SetPtThresholdTPC(999999.);
334   }
335
336
337   Int_t nKaons=0;
338   Int_t nNotKaons=0;
339   Int_t sign= rd->GetCharge(); 
340   for(Int_t iDaught=0; iDaught<3; iDaught++){
341     AliAODTrack *track=(AliAODTrack*)rd->GetDaughter(iDaught);
342     
343     Int_t isPion=fPidHF->MakeRawPid(track,AliPID::kPion);
344     Int_t isKaon=fPidHF->MakeRawPid(track,AliPID::kKaon);
345     Int_t isProton=fPidHF->MakeRawPid(track,AliPID::kProton);
346     
347     if(isProton>0 &&  isKaon<0  && isPion<0){
348       fPidHF->SetPCompatTOF(origCompatTOF);
349       fPidHF->SetPtThresholdTPC(origThreshTPC);
350       return 0;
351     }
352     if(sign!=track->Charge()){// must be kaon
353       if(isKaon<0){
354         fPidHF->SetPCompatTOF(origCompatTOF);
355         fPidHF->SetPtThresholdTPC(origThreshTPC);
356         return 0;
357       }
358       if(fPidOption==kStrong && isKaon<=0){
359         fPidHF->SetPCompatTOF(origCompatTOF);
360         fPidHF->SetPtThresholdTPC(origThreshTPC);
361         return 0;
362       }
363     }
364     if(isKaon>0 && isPion<0) nKaons++;
365     if(isKaon<0) nNotKaons++;
366     if(iDaught==0){
367       if(isKaon<0) okKKpi=kFALSE;
368       if(isPion<0) okpiKK=kFALSE;      
369       if(fPidOption==kStrong){
370         if(isKaon<=0) okKKpi=kFALSE;
371         if(isPion<=0) okpiKK=kFALSE;
372       }
373     }
374     else if(iDaught==2){
375       if(isKaon<0) okpiKK=kFALSE;
376       if(isPion<0) okKKpi=kFALSE;
377        if(fPidOption==kStrong){
378         if(isKaon<=0) okpiKK=kFALSE;
379         if(isPion<=0) okKKpi=kFALSE;
380       }
381     }
382   }
383
384   fPidHF->SetPCompatTOF(origCompatTOF);
385   fPidHF->SetPtThresholdTPC(origThreshTPC);
386   
387   if(nKaons>2)return 0;
388   if(nNotKaons>1) return 0;
389   
390   if(!okKKpi) retCode-=1;
391   if(!okpiKK) retCode-=2;
392
393   return retCode;
394 }
395
396 //---------------------------------------------------------------------------
397 Int_t AliRDHFCutsDstoKKpi::IsSelected(TObject* obj,Int_t selectionLevel, AliAODEvent* aod) {
398   //
399   // Apply selection
400   //
401
402   if(!fCutsRD){
403     cout<<"Cut matrix not inizialized. Exit..."<<endl;
404     return 0;
405   }
406   //PrintAll();
407   AliAODRecoDecayHF3Prong* d=(AliAODRecoDecayHF3Prong*)obj;
408
409   if(!d){
410     cout<<"AliAODRecoDecayHF3Prong null"<<endl;
411     return 0;
412   }
413   
414   if(fKeepSignalMC) if(IsSignalMC(d,aod,431)) return 3;
415  
416   Double_t ptD=d->Pt();
417   if(ptD<fMinPtCand) return 0;
418   if(ptD>fMaxPtCand) return 0;
419
420   if(d->HasBadDaughters()) return 0;
421   
422
423   // selection on daughter tracks 
424   if(selectionLevel==AliRDHFCuts::kAll || 
425      selectionLevel==AliRDHFCuts::kTracks) {
426     if(!AreDaughtersSelected(d)) return 0;
427   }
428
429
430
431  
432   // selection on candidate
433   if(selectionLevel==AliRDHFCuts::kAll || 
434      selectionLevel==AliRDHFCuts::kCandidate) {
435     //recalculate vertex w/o daughters
436     AliAODVertex *origownvtx=0x0;
437     if(fRemoveDaughtersFromPrimary) {
438       if(d->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*d->GetOwnPrimaryVtx());
439       if(!RecalcOwnPrimaryVtx(d,aod)) {
440         CleanOwnPrimaryVtx(d,aod,origownvtx);
441         return 0;
442       }
443     }
444
445     Int_t okDsKKpi=1;
446     Int_t okDspiKK=1;
447     Int_t okMassPhiKKpi=0;
448     Int_t okMassPhipiKK=0;
449     Int_t okMassK0starKKpi=0;
450     Int_t okMassK0starpiKK=0;
451     Int_t okDsPhiKKpi=0;
452     Int_t okDsPhipiKK=0;
453     Int_t okDsK0starKKpi=0;
454     Int_t okDsK0starpiKK=0;
455
456     Double_t pt=d->Pt();
457     Int_t ptbin=PtBin(pt);
458     if (ptbin==-1) {
459       CleanOwnPrimaryVtx(d,aod,origownvtx);
460       return 0;
461     }
462  
463     Double_t mDsPDG = TDatabasePDG::Instance()->GetParticle(431)->Mass();
464     Double_t mDsKKpi=d->InvMassDsKKpi();
465     Double_t mDspiKK=d->InvMassDspiKK();
466     if(TMath::Abs(mDsKKpi-mDsPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okDsKKpi = 0;
467     if(TMath::Abs(mDspiKK-mDsPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okDspiKK = 0;
468     if(!okDsKKpi && !okDspiKK){
469       CleanOwnPrimaryVtx(d,aod,origownvtx);
470       return 0;
471     }
472
473
474
475     // cuts on resonant decays (via Phi or K0*)
476     Double_t mPhiPDG = TDatabasePDG::Instance()->GetParticle(333)->Mass();
477     Double_t mK0starPDG = TDatabasePDG::Instance()->GetParticle(313)->Mass();
478     if(okDsKKpi){
479       Double_t mass01phi=d->InvMass2Prongs(0,1,321,321);
480       Double_t mass12K0s=d->InvMass2Prongs(1,2,321,211);
481       if(TMath::Abs(mass01phi-mPhiPDG)<fCutsRD[GetGlobalIndex(12,ptbin)]) okMassPhiKKpi=1;
482       if(TMath::Abs(mass12K0s-mK0starPDG)<fCutsRD[GetGlobalIndex(13,ptbin)]) okMassK0starKKpi = 1;
483       if(!okMassPhiKKpi && !okMassK0starKKpi) okDsKKpi=0;
484       if(okMassPhiKKpi) okDsPhiKKpi=1;
485       if(okMassK0starKKpi) okDsK0starKKpi=1;
486     }
487     if(okDspiKK){
488       Double_t mass01K0s=d->InvMass2Prongs(0,1,211,321);
489       Double_t mass12phi=d->InvMass2Prongs(1,2,321,321);
490       if(TMath::Abs(mass01K0s-mK0starPDG)<fCutsRD[GetGlobalIndex(13,ptbin)]) okMassK0starpiKK = 1;
491       if(TMath::Abs(mass12phi-mPhiPDG)<fCutsRD[GetGlobalIndex(12,ptbin)]) okMassPhipiKK=1;
492       if(!okMassPhipiKK && !okMassK0starpiKK) okDspiKK=0;
493       if(okMassPhipiKK) okDsPhipiKK=1;
494       if(okMassK0starpiKK) okDsK0starpiKK=1;
495     }
496     if(!okDsKKpi && !okDspiKK){
497       CleanOwnPrimaryVtx(d,aod,origownvtx);
498       return 0;
499     }
500
501     // Cuts on track pairs
502     for(Int_t i=0;i<3;i++){
503       if(d->GetDCA(i)>fCutsRD[GetGlobalIndex(11,ptbin)]){
504         CleanOwnPrimaryVtx(d,aod,origownvtx);
505         return 0;
506       }
507     }
508     if(d->GetDist12toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)] || 
509        d->GetDist23toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]){
510       CleanOwnPrimaryVtx(d,aod,origownvtx);
511       return 0;
512     }
513
514
515
516     //single track
517     if(TMath::Abs(d->Pt2Prong(1)) < fCutsRD[GetGlobalIndex(1,ptbin)]*fCutsRD[GetGlobalIndex(1,ptbin)] || 
518        TMath::Abs(d->Getd0Prong(1))<fCutsRD[GetGlobalIndex(3,ptbin)]){
519       CleanOwnPrimaryVtx(d,aod,origownvtx);
520       return 0;
521     }
522
523     if(okDsKKpi){
524       if(TMath::Abs(d->Pt2Prong(0)) < fCutsRD[GetGlobalIndex(1,ptbin)]*fCutsRD[GetGlobalIndex(1,ptbin)] || 
525          TMath::Abs(d->Getd0Prong(0))<fCutsRD[GetGlobalIndex(3,ptbin)]) okDsKKpi=0;
526       if(TMath::Abs(d->Pt2Prong(2)) < fCutsRD[GetGlobalIndex(2,ptbin)]*fCutsRD[GetGlobalIndex(2,ptbin)] || 
527          TMath::Abs(d->Getd0Prong(2))<fCutsRD[GetGlobalIndex(4,ptbin)]) okDsKKpi=0;
528     }
529     if(okDspiKK){
530       if(TMath::Abs(d->Pt2Prong(0)) < fCutsRD[GetGlobalIndex(2,ptbin)]*fCutsRD[GetGlobalIndex(2,ptbin)] || 
531          TMath::Abs(d->Getd0Prong(0))<fCutsRD[GetGlobalIndex(4,ptbin)]) okDspiKK=0;
532       if(TMath::Abs(d->Pt2Prong(2)) < fCutsRD[GetGlobalIndex(1,ptbin)]*fCutsRD[GetGlobalIndex(1,ptbin)] || 
533          TMath::Abs(d->Getd0Prong(2))<fCutsRD[GetGlobalIndex(3,ptbin)]) okDspiKK=0;
534     }
535     if(!okDsKKpi && !okDspiKK){
536       CleanOwnPrimaryVtx(d,aod,origownvtx);
537       return 0;
538     }
539
540     // Cuts on candidate triplet
541
542
543     if(d->CosPointingAngle()< fCutsRD[GetGlobalIndex(9,ptbin)]){
544       CleanOwnPrimaryVtx(d,aod,origownvtx); 
545       return 0;
546     }
547      
548     if(d->Pt2Prong(0)<fCutsRD[GetGlobalIndex(8,ptbin)]*fCutsRD[GetGlobalIndex(8,ptbin)] && 
549        d->Pt2Prong(1)<fCutsRD[GetGlobalIndex(8,ptbin)]*fCutsRD[GetGlobalIndex(8,ptbin)] && 
550        d->Pt2Prong(2)<fCutsRD[GetGlobalIndex(8,ptbin)]*fCutsRD[GetGlobalIndex(8,ptbin)]) {
551       CleanOwnPrimaryVtx(d,aod,origownvtx); 
552       return 0;
553     }
554
555     if(d->DecayLength2()<fCutsRD[GetGlobalIndex(7,ptbin)]*fCutsRD[GetGlobalIndex(7,ptbin)]){
556       CleanOwnPrimaryVtx(d,aod,origownvtx);
557       return 0;
558     }
559
560
561     Double_t sum2=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
562     if(sum2<fCutsRD[GetGlobalIndex(10,ptbin)]){
563       CleanOwnPrimaryVtx(d,aod,origownvtx);
564       return 0;
565     }
566
567    
568     //sec vert
569     Double_t sigmavert=d->GetSigmaVert(aod);
570     if(sigmavert>fCutsRD[GetGlobalIndex(6,ptbin)]){
571       CleanOwnPrimaryVtx(d,aod,origownvtx);
572       return 0;
573     }
574
575     if(okDsKKpi){
576       Double_t cosPiKPhiRFKKpi=d->CosPiKPhiRFrameKKpi();
577       Double_t kincutPiKPhiKKpi=TMath::Abs(cosPiKPhiRFKKpi*cosPiKPhiRFKKpi*cosPiKPhiRFKKpi);
578       if(kincutPiKPhiKKpi<fCutsRD[GetGlobalIndex(14,ptbin)]) okDsKKpi=0;
579     }
580     if(okDspiKK){
581       Double_t cosPiKPhiRFpiKK=d->CosPiKPhiRFramepiKK();
582       Double_t kincutPiKPhipiKK=TMath::Abs(cosPiKPhiRFpiKK*cosPiKPhiRFpiKK*cosPiKPhiRFpiKK);
583       if(kincutPiKPhipiKK<fCutsRD[GetGlobalIndex(14,ptbin)]) okDspiKK=0;
584     }
585     if(!okDsKKpi && !okDspiKK){
586       CleanOwnPrimaryVtx(d,aod,origownvtx);
587       return 0;
588     }
589     
590     
591     
592     if(okDsKKpi){
593       Double_t cosPiDsLabFrameKKpi=d->CosPiDsLabFrameKKpi();
594       if(cosPiDsLabFrameKKpi>fCutsRD[GetGlobalIndex(15,ptbin)]) okDsKKpi=0;
595     }
596     if(okDspiKK){
597       Double_t cosPiDsLabFramepiKK=d->CosPiDsLabFramepiKK();
598       if(cosPiDsLabFramepiKK>fCutsRD[GetGlobalIndex(15,ptbin)]) okDspiKK=0;
599     }
600     if(!okDsKKpi && !okDspiKK){
601       CleanOwnPrimaryVtx(d,aod,origownvtx);
602       return 0;
603     }
604     
605      // unset recalculated primary vertex when not needed any more
606     CleanOwnPrimaryVtx(d,aod,origownvtx);
607       
608     
609
610     if(!okDsKKpi){
611       okDsPhiKKpi=0;
612       okDsK0starKKpi=0;
613     }
614     if(!okDspiKK){
615       okDsPhipiKK=0;
616       okDsK0starpiKK=0;
617     }
618
619     // PID selection
620     Int_t returnvaluePID=3;  
621     if(selectionLevel==AliRDHFCuts::kAll || 
622        selectionLevel==AliRDHFCuts::kCandidate ||     
623        selectionLevel==AliRDHFCuts::kPID) {
624       returnvaluePID = IsSelectedPID(d);
625       fIsSelectedPID=returnvaluePID;
626     }
627     if(returnvaluePID==0)return 0;
628
629     Bool_t okPidDsKKpi=returnvaluePID&1;
630     Bool_t okPidDspiKK=returnvaluePID&2;
631     if(!okPidDsKKpi){
632       okDsPhiKKpi=0;
633       okDsK0starKKpi=0;
634     }
635     if(!okPidDspiKK){
636       okDsPhipiKK=0;
637       okDsK0starpiKK=0;
638     }
639
640     if((okPidDsKKpi && okDsKKpi)||(okPidDspiKK && okDspiKK)){
641       Int_t returnvalue=0;
642       if(okDsKKpi) returnvalue+=1;
643       if(okDspiKK) returnvalue+=2;
644       if(okDsPhiKKpi) returnvalue+=4;
645       if(okDsPhipiKK) returnvalue+=8;
646       if(okDsK0starKKpi) returnvalue+=16;
647       if(okDsK0starpiKK) returnvalue+=32;
648       return returnvalue;
649     }else{
650       return 0;
651     }
652   }
653   return 15;
654
655 }
656
657 //--------------------------------------------------------------------------
658
659 UInt_t AliRDHFCutsDstoKKpi::GetPIDTrackTPCTOFBitMap(AliAODTrack *track) const{
660
661   UInt_t bitmap=0;
662
663   Double_t sigmaTPCPionHyp=-999.;
664   Double_t sigmaTPCKaonHyp=-999.;
665   Double_t sigmaTPCProtonHyp=-999.;
666   Double_t sigmaTOFPionHyp=-999.;
667   Double_t sigmaTOFKaonHyp=-999.;
668   Double_t sigmaTOFProtonHyp=-999.;
669   
670   Int_t oksigmaTPCPionHyp=fPidHF->GetnSigmaTPC(track,2,sigmaTPCPionHyp);
671   Int_t oksigmaTPCKaonHyp=fPidHF->GetnSigmaTPC(track,3,sigmaTPCKaonHyp);
672   Int_t oksigmaTPCProtonHyp=fPidHF->GetnSigmaTPC(track,4,sigmaTPCProtonHyp);
673   Int_t oksigmaTOFPionHyp=fPidHF->GetnSigmaTOF(track,2,sigmaTOFPionHyp);
674   Int_t oksigmaTOFKaonHyp=fPidHF->GetnSigmaTOF(track,3,sigmaTOFKaonHyp);
675   Int_t oksigmaTOFProtonHyp=fPidHF->GetnSigmaTOF(track,4,sigmaTOFProtonHyp);
676   
677   if (oksigmaTPCPionHyp && sigmaTPCPionHyp>0.){
678     if (sigmaTPCPionHyp<2.) bitmap+=1<<kTPCPionLess2;
679     else { if (sigmaTPCPionHyp<3.) bitmap+=1<<kTPCPionMore2Less3; else bitmap+=1<<kTPCPionMore3;}
680   }
681    if (oksigmaTPCKaonHyp && sigmaTPCKaonHyp>0.){
682     if (sigmaTPCKaonHyp<2.) bitmap+=1<<kTPCKaonLess2;
683     else { if (sigmaTPCKaonHyp<3.) bitmap+=1<<kTPCKaonMore2Less3; else bitmap+=1<<kTPCKaonMore3;}
684   }
685    if (oksigmaTPCProtonHyp && sigmaTPCProtonHyp>0.){
686     if (sigmaTPCProtonHyp<2.) bitmap+=1<<kTPCProtonLess2;
687     else { if (sigmaTPCProtonHyp<3.) bitmap+=1<<kTPCProtonMore2Less3; else bitmap+=1<<kTPCProtonMore3;}
688   }
689   
690   if (oksigmaTOFPionHyp && sigmaTOFPionHyp>0.){
691     if (sigmaTOFPionHyp<2.) bitmap+=1<<kTOFPionLess2;
692     else { if (sigmaTOFPionHyp<3.) bitmap+=1<<kTOFPionMore2Less3; else bitmap+=1<<kTOFPionMore3;}
693   }
694    if (oksigmaTOFKaonHyp && sigmaTOFKaonHyp>0.){
695     if (sigmaTOFKaonHyp<2.) bitmap+=1<<kTOFKaonLess2;
696     else { if (sigmaTOFKaonHyp<3.) bitmap+=1<<kTOFKaonMore2Less3; else bitmap+=1<<kTOFKaonMore3;}
697   }
698    if (oksigmaTOFProtonHyp && sigmaTOFProtonHyp>0.){
699     if (sigmaTOFProtonHyp<2.) bitmap+=1<<kTOFProtonLess2;
700     else { if (sigmaTOFProtonHyp<3.) bitmap+=1<<kTOFProtonMore2Less3; else bitmap+=1<<kTOFProtonMore3;}
701   }
702   
703   
704   return bitmap;
705
706 }
707