]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/AliRDHFCutsLctopKpi.cxx
Update (R.Romita)
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliRDHFCutsLctopKpi.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 Lc->pKpi
21 //
22 // Author: A.Dainese, andrea.dainese@pd.infn.it
23 /////////////////////////////////////////////////////////////
24
25 #include <TDatabasePDG.h>
26 #include <Riostream.h>
27 #include <AliAnalysisManager.h>
28 #include <AliInputEventHandler.h>
29 #include <AliPIDResponse.h>
30
31 #include "AliRDHFCutsLctopKpi.h"
32 #include "AliAODRecoDecayHF3Prong.h"
33 #include "AliRDHFCuts.h"
34 #include "AliAODTrack.h"
35 #include "AliESDtrack.h"
36 #include "AliKFParticle.h"
37 #include "AliESDVertex.h"
38
39 using std::cout;
40 using std::endl;
41
42 ClassImp(AliRDHFCutsLctopKpi)
43
44 //--------------------------------------------------------------------------
45 AliRDHFCutsLctopKpi::AliRDHFCutsLctopKpi(const char* name) : 
46 AliRDHFCuts(name),
47 fPidObjprot(0),
48 fPidObjpion(0),
49 fUseImpParProdCorrCut(kFALSE),
50 fPIDStrategy(kNSigma),
51 fCutsStrategy(kStandard),
52 fUseSpecialCut(kFALSE)
53 {
54   //
55   // Default Constructor
56   //
57   Int_t nvars=13;
58   SetNVars(nvars);
59   TString varNames[13]={"inv. mass [GeV]",
60                         "pTK [GeV/c]",
61                         "pTP [GeV/c]",
62                         "d0K [cm]   lower limit!",
63                         "d0Pi [cm]  lower limit!",
64                         "dist12 (cm)",
65                         "sigmavert (cm)",
66                         "dist prim-sec (cm)",
67                         "pM=Max{pT1,pT2,pT3} (GeV/c)",
68                         "cosThetaPoint",
69                         "Sum d0^2 (cm^2)",
70                         "dca cut (cm)",
71                         "cut on pTpion [GeV/c]"};
72   Bool_t isUpperCut[13]={kTRUE,
73                          kFALSE,
74                          kFALSE,
75                          kFALSE,
76                          kFALSE,
77                          kFALSE,
78                          kTRUE,
79                          kFALSE,
80                          kFALSE,
81                          kFALSE,
82                          kFALSE,
83                          kTRUE,
84                          kFALSE
85                          };
86   SetVarNames(nvars,varNames,isUpperCut);
87   Bool_t forOpt[13]={kFALSE,
88                      kTRUE,
89                      kTRUE,
90                      kFALSE,
91                      kFALSE,
92                      kFALSE,
93                      kFALSE,
94                      kTRUE,
95                      kFALSE,
96                      kFALSE,
97                      kFALSE,
98                      kFALSE,
99                      kTRUE};
100   SetVarsForOpt(4,forOpt);
101   Float_t limits[2]={0,999999999.};
102   SetPtBins(2,limits);
103   for (Int_t ispecies=0;ispecies<AliPID::kSPECIES;++ispecies)
104       fPIDThreshold[ispecies]=0.;
105 }
106 //--------------------------------------------------------------------------
107 AliRDHFCutsLctopKpi::AliRDHFCutsLctopKpi(const AliRDHFCutsLctopKpi &source) :
108   AliRDHFCuts(source),
109   fPidObjprot(0x0),
110   fPidObjpion(0x0),
111   fUseImpParProdCorrCut(source.fUseImpParProdCorrCut),
112   fPIDStrategy(source.fPIDStrategy),
113   fCutsStrategy(source.fCutsStrategy),
114   fUseSpecialCut(source.fUseSpecialCut)
115 {
116   //
117   // Copy constructor
118   //
119   if (source.fPidObjprot) fPidObjprot = new AliAODPidHF(*(source.fPidObjprot));
120   else fPidObjprot = new AliAODPidHF();
121   if (source.fPidObjpion) fPidObjpion = new AliAODPidHF(*(source.fPidObjpion));
122   else fPidObjpion = new AliAODPidHF();
123   memcpy(fPIDThreshold,source.fPIDThreshold,AliPID::kSPECIES*sizeof(Double_t));
124 }
125 //--------------------------------------------------------------------------
126 AliRDHFCutsLctopKpi &AliRDHFCutsLctopKpi::operator=(const AliRDHFCutsLctopKpi &source)
127 {
128   //
129   // assignment operator
130   //
131   if(this != &source) {
132     
133     AliRDHFCuts::operator=(source);
134     delete fPidObjprot;
135     fPidObjprot = new AliAODPidHF(*(source.fPidObjprot));
136     delete fPidObjpion;
137     fPidObjpion = new AliAODPidHF(*(source.fPidObjpion));
138     fPIDStrategy=source.fPIDStrategy;
139     fCutsStrategy=source.fCutsStrategy;
140     memcpy(fPIDThreshold,source.fPIDThreshold,AliPID::kSPECIES*sizeof(Double_t));
141   }
142     
143   return *this;
144 }
145 //---------------------------------------------------------------------------
146 AliRDHFCutsLctopKpi::~AliRDHFCutsLctopKpi() {
147  //
148  //  // Default Destructor
149  //   
150  if(fPidObjpion){
151   delete fPidObjpion;
152   fPidObjpion=0;
153  }
154  if(fPidObjprot){
155   delete fPidObjprot;
156   fPidObjprot=0;
157  }
158
159 }
160
161 //---------------------------------------------------------------------------
162 void AliRDHFCutsLctopKpi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters, AliAODEvent *aod) {
163   // 
164   // Fills in vars the values of the variables 
165   //
166
167   if(nvars!=fnVarsForOpt) {
168     printf("AliRDHFCutsLctopKpi::GetCutsVarsForOpt: wrong number of variables\n");
169     return;
170   }
171
172   AliAODRecoDecayHF3Prong *dd = (AliAODRecoDecayHF3Prong*)d;
173
174     Int_t iter=-1;
175   if(fVarsForOpt[0]){
176     iter++;
177     vars[iter]=dd->InvMassLcpKpi();
178   }
179   if(fVarsForOpt[1]){
180     iter++;
181     for(Int_t iprong=0;iprong<3;iprong++){
182       if(TMath::Abs(pdgdaughters[iprong])==321) {
183         vars[iter]=dd->PtProng(iprong);
184       }
185     }
186   }
187   if(fVarsForOpt[2]){
188     iter++;
189     for(Int_t iprong=0;iprong<3;iprong++){
190       if(TMath::Abs(pdgdaughters[iprong])==2212) {
191         vars[iter]=dd->PtProng(iprong);
192       }
193     }
194   }
195   if(fVarsForOpt[3]){
196     iter++;
197     for(Int_t iprong=0;iprong<3;iprong++){
198       if(TMath::Abs(pdgdaughters[iprong])==2212) {
199         vars[iter]=dd->Getd0Prong(iprong);
200       }
201     }
202   }
203   if(fVarsForOpt[4]){
204     iter++;
205     for(Int_t iprong=0;iprong<3;iprong++){
206       if(TMath::Abs(pdgdaughters[iprong])==211) {
207         vars[iter]=dd->Getd0Prong(iprong);
208       }
209     }
210   }
211   if(fVarsForOpt[5]){
212     iter++;
213     vars[iter]=dd->GetDist12toPrim();
214   }
215   if(fVarsForOpt[6]){
216     iter++;
217     vars[iter]=dd->GetSigmaVert(aod);
218   }
219   if(fVarsForOpt[7]){
220     iter++;
221     vars[iter] = dd->DecayLength();
222   }
223   if(fVarsForOpt[8]){
224     iter++;
225     Float_t ptmax=0;
226     for(Int_t i=0;i<3;i++){
227       if(dd->PtProng(i)>ptmax)ptmax=dd->PtProng(i);
228     }
229     vars[iter]=ptmax;
230   }
231   if(fVarsForOpt[9]){
232     iter++;
233     vars[iter]=dd->CosPointingAngle();
234   }
235   if(fVarsForOpt[10]){
236     iter++;
237     vars[iter]=dd->Getd0Prong(0)*dd->Getd0Prong(0)+dd->Getd0Prong(1)*dd->Getd0Prong(1)+dd->Getd0Prong(2)*dd->Getd0Prong(2);
238   }
239   if(fVarsForOpt[11]){
240     iter++;
241     vars[iter]=dd->GetDCA();
242   }
243   if(fVarsForOpt[12]){
244     iter++;
245     for(Int_t iprong=0;iprong<3;iprong++){
246       if(TMath::Abs(pdgdaughters[iprong])==211) {
247         vars[iter]=dd->PtProng(iprong);
248       }
249     }
250   }
251
252   return;
253 }
254 //---------------------------------------------------------------------------
255 Int_t AliRDHFCutsLctopKpi::IsSelected(TObject* obj,Int_t selectionLevel,AliAODEvent *aod) {
256   //
257   // Apply selection
258   //
259
260   if(!fCutsRD){
261     cout<<"Cut matrice not inizialized. Exit..."<<endl;
262     return 0;
263   }
264   //PrintAll();
265   AliAODRecoDecayHF3Prong* d=(AliAODRecoDecayHF3Prong*)obj;
266
267   if(!d){
268     cout<<"AliAODRecoDecayHF3Prong null"<<endl;
269     return 0;
270   }
271
272
273   if(fKeepSignalMC) if(IsSignalMC(d,aod,4122)) return 3;
274
275   Int_t returnvalue=3;
276   Int_t returnvaluePID=3;
277
278   if(d->Pt()<fMinPtCand) return 0;
279   if(d->Pt()>fMaxPtCand) return 0;
280
281   if(fUseTrackSelectionWithFilterBits && d->HasBadDaughters()) return 0;
282
283   if(selectionLevel==AliRDHFCuts::kAll ||
284      selectionLevel==AliRDHFCuts::kCandidate|| 
285      selectionLevel==AliRDHFCuts::kPID) {
286      switch (fPIDStrategy) {
287       case kNSigma:
288        returnvaluePID = IsSelectedPID(d);
289     
290       break;
291       case kCombined:
292        returnvaluePID = IsSelectedCombinedPID(d);
293       break;
294       case kCombinedSoft:
295        returnvaluePID = IsSelectedCombinedPIDSoft(d);
296       break;
297       case kNSigmaStrong:
298        returnvaluePID = IsSelectedPIDStrong(d);
299      }
300      fIsSelectedPID=returnvaluePID;
301   }
302   //  if(fUsePID || selectionLevel==AliRDHFCuts::kPID) returnvaluePID = IsSelectedCombinedPID(d);   // to test!!
303   if(returnvaluePID==0) return 0;
304
305   // selection on candidate
306   if(selectionLevel==AliRDHFCuts::kAll || 
307      selectionLevel==AliRDHFCuts::kCandidate) {
308
309     Double_t pt=d->Pt();
310     
311     Int_t ptbin=PtBin(pt);
312     
313     Double_t mLcpKpi,mLcpiKp;
314     Int_t okLcpKpi=1,okLcpiKp=1;
315
316     Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
317
318     mLcpKpi=d->InvMassLcpKpi();
319     mLcpiKp=d->InvMassLcpiKp();
320
321     if(TMath::Abs(mLcpKpi-mLcPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okLcpKpi = 0;
322     if(TMath::Abs(mLcpiKp-mLcPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okLcpiKp = 0;
323     if(!okLcpKpi && !okLcpiKp) return 0;
324
325   switch (fCutsStrategy) {
326
327     case kStandard:
328     if(TMath::Abs(d->PtProng(1)) < fCutsRD[GetGlobalIndex(1,ptbin)] || TMath::Abs(d->Getd0Prong(1))<fCutsRD[GetGlobalIndex(3,ptbin)]) return 0;//Kaon
329     if(d->Pt()>=3. && d->PProng(1)<0.55) return 0;
330     if(fUseSpecialCut) {
331       if(TMath::Abs(d->PtProng(0)) < TMath::Abs(d->PtProng(2)) )okLcpKpi=0;
332       if(TMath::Abs(d->PtProng(2)) < TMath::Abs(d->PtProng(0)) )okLcpiKp=0;
333     }
334     if((TMath::Abs(d->PtProng(0)) < fCutsRD[GetGlobalIndex(2,ptbin)]) || (TMath::Abs(d->PtProng(2)) < fCutsRD[GetGlobalIndex(12,ptbin)])) okLcpKpi=0;
335     if((TMath::Abs(d->PtProng(2)) < fCutsRD[GetGlobalIndex(2,ptbin)]) || (TMath::Abs(d->PtProng(0)) < fCutsRD[GetGlobalIndex(12,ptbin)]))okLcpiKp=0;
336     if(!okLcpKpi && !okLcpiKp) return 0;
337     //2track cuts
338     if(d->GetDist12toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]|| d->GetDist23toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]) return 0;
339     if(d->GetDist12toPrim()>0.5) return 0;
340     if(d->GetDist23toPrim()>0.5) return 0;
341     if(fUseImpParProdCorrCut){
342       if(d->Getd0Prong(0)*d->Getd0Prong(1)<0. && d->Getd0Prong(2)*d->Getd0Prong(1)<0.) return 0;
343     }
344     //sec vert
345     if(d->DecayLength()<fCutsRD[GetGlobalIndex(7,ptbin)]) return 0;
346     if(d->DecayLength()>0.5) return 0;
347
348   //  Double_t sumd0s=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
349   //  if(sumd0s<fCutsRD[GetGlobalIndex(10,ptbin)]) return 0;
350     if((d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2))<fCutsRD[GetGlobalIndex(10,ptbin)]) return 0;
351     
352     if(TMath::Abs(d->PtProng(0))<fCutsRD[GetGlobalIndex(8,ptbin)] && TMath::Abs(d->PtProng(1))<fCutsRD[GetGlobalIndex(8,ptbin)] && TMath::Abs(d->PtProng(2))<fCutsRD[GetGlobalIndex(8,ptbin)]) return 0;
353     if(d->CosPointingAngle()< fCutsRD[GetGlobalIndex(9,ptbin)]) return 0;
354     if(d->GetSigmaVert(aod)>fCutsRD[GetGlobalIndex(6,ptbin)]) return 0;
355     
356     //DCA
357     for(Int_t i=0;i<3;i++) if(d->GetDCA(i)>fCutsRD[GetGlobalIndex(11,ptbin)]) return 0;
358
359     break;
360
361    case kKF:
362     Int_t pdgs[3]={0,321,0};
363     Bool_t constraint=kFALSE;
364     if(fCutsRD[GetGlobalIndex(1,ptbin)]>0.) constraint=kTRUE;
365     Double_t field=aod->GetMagneticField();
366     if (returnvaluePID==1 || returnvaluePID==3){
367
368       pdgs[0]=2122;pdgs[2]=211;
369       AliKFParticle *lc1=ReconstructKF(d,pdgs,field,constraint);
370       if(!lc1){
371         okLcpKpi=0;
372       }else{
373         if(lc1->GetChi2()/lc1->GetNDF()>fCutsRD[GetGlobalIndex(2,ptbin)]) okLcpKpi=0;
374       }
375     } else if(returnvaluePID>=2){
376
377       pdgs[0]=211;pdgs[2]=2212;
378       AliKFParticle *lc2=ReconstructKF(d,pdgs,field,constraint);
379       if(!lc2){ 
380         okLcpiKp=0;
381       }else{
382         if(lc2->GetChi2()/lc2->GetNDF()>fCutsRD[GetGlobalIndex(2,ptbin)])okLcpiKp=0; 
383       }
384     }
385     break;
386
387    }
388
389     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
390     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
391     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
392    
393   }
394
395   // selection on daughter tracks 
396   if(selectionLevel==AliRDHFCuts::kAll || 
397      selectionLevel==AliRDHFCuts::kTracks) {
398     if(!AreDaughtersSelected(d)) return 0;
399   }
400
401
402   Int_t returnvalueTot=CombinePIDCuts(returnvalue,returnvaluePID);
403   return returnvalueTot;
404 }
405 //---------------------------------------------------------------------------
406 Int_t AliRDHFCutsLctopKpi::IsSelectedPID(AliAODRecoDecayHF* obj) {
407
408
409     if(!fUsePID || !obj) return 3;
410     Int_t okLcpKpi=0,okLcpiKp=0;
411     Int_t returnvalue=0;
412     Bool_t isPeriodd=fPidHF->GetOnePad();
413     Bool_t isMC=fPidHF->GetMC();
414     Bool_t ispion0=kTRUE,ispion2=kTRUE;
415     Bool_t isproton0=kFALSE,isproton2=kFALSE;
416     Bool_t iskaon1=kFALSE;
417     if(isPeriodd) {
418      fPidObjprot->SetOnePad(kTRUE);
419      fPidObjpion->SetOnePad(kTRUE);
420     }
421     if(isMC) {
422      fPidObjprot->SetMC(kTRUE);
423      fPidObjpion->SetMC(kTRUE);
424     }
425
426    if(fPidObjprot->GetPidResponse()==0x0){
427       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
428       AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
429       AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
430       fPidObjprot->SetPidResponse(pidResp);
431     }
432     if(fPidObjpion->GetPidResponse()==0x0){
433       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
434       AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
435       AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
436       fPidObjpion->SetPidResponse(pidResp);
437     }
438     if(fPidHF->GetPidResponse()==0x0){
439       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
440       AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
441       AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
442       fPidHF->SetPidResponse(pidResp);
443     }
444
445     for(Int_t i=0;i<3;i++){
446      AliAODTrack *track=(AliAODTrack*)obj->GetDaughter(i);
447      if(!track) return 0;
448      // identify kaon
449      if(track->P()<0.55){
450       fPidHF->SetTOF(kFALSE);
451       fPidHF->SetTOFdecide(kFALSE);
452      }
453      if(i==1) {
454       Int_t isKaon=fPidHF->MakeRawPid(track,3); 
455       if(isKaon>=1) iskaon1=kTRUE;
456       if(track->P()<0.55){
457        fPidHF->SetTOF(kTRUE);
458        fPidHF->SetTOFdecide(kTRUE);
459       }
460       
461       if(!iskaon1) return 0;
462      
463      }else{
464      //pion or proton
465     if(track->P()<1.){
466       fPidObjprot->SetTOF(kFALSE);
467       fPidObjprot->SetTOFdecide(kFALSE);
468      }
469       
470      Int_t isProton=fPidObjprot->MakeRawPid(track,4);
471      
472
473      Int_t isPion=fPidObjpion->MakeRawPid(track,2);
474      
475      if(track->P()<1.){
476       fPidObjprot->SetTOF(kTRUE);
477       fPidObjprot->SetTOFdecide(kTRUE);
478      }
479      
480
481      if(i==0) {
482       if(isPion<0) ispion0=kFALSE;
483       if(isProton>=1) isproton0=kTRUE;
484
485      }
486       if(!ispion0 && !isproton0) return 0;
487      if(i==2) {
488       if(isPion<0) ispion2=kFALSE;
489       if(isProton>=1) isproton2=kTRUE;
490      }
491
492     }
493    }
494
495     if(ispion2 && isproton0 && iskaon1) okLcpKpi=1;
496     if(ispion0 && isproton2 && iskaon1) okLcpiKp=1;
497     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
498     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
499     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
500
501  return returnvalue;
502 }
503 //---------------------------------------------------------------------------
504 Int_t AliRDHFCutsLctopKpi::IsSelectedCombinedPID(AliAODRecoDecayHF* obj) {
505
506   //  Printf(" -------- IsSelectedCombinedPID --------------");
507
508     
509     if(!fUsePID || !obj) {return 3;}
510     Int_t okLcpKpi=0,okLcpiKp=0;
511     Int_t returnvalue=0;
512     Bool_t isPeriodd=fPidHF->GetOnePad();
513     Bool_t isMC=fPidHF->GetMC();
514
515     if(isPeriodd) {
516             fPidObjprot->SetOnePad(kTRUE);
517             fPidObjpion->SetOnePad(kTRUE);
518     }
519     if(isMC) {
520             fPidObjprot->SetMC(kTRUE);
521             fPidObjpion->SetMC(kTRUE);
522     }
523
524     AliVTrack *track0=dynamic_cast<AliVTrack*>(obj->GetDaughter(0));
525     AliVTrack *track1=dynamic_cast<AliVTrack*>(obj->GetDaughter(1));
526     AliVTrack *track2=dynamic_cast<AliVTrack*>(obj->GetDaughter(2));
527     if (!track0 || !track1 || !track2) return 0;
528     Double_t prob0[AliPID::kSPECIES];
529     Double_t prob1[AliPID::kSPECIES];
530     Double_t prob2[AliPID::kSPECIES];
531     if(obj->Pt()<3. && track0->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
532     fPidHF->GetPidCombined()->ComputeProbabilities(track0,fPidHF->GetPidResponse(),prob0);
533     if(obj->Pt()<3. && track0->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
534
535    if(obj->Pt()<3. && track1->P()<0.55) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
536     fPidHF->GetPidCombined()->ComputeProbabilities(track1,fPidHF->GetPidResponse(),prob1);
537    if(obj->Pt()<3. && track1->P()<0.55) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
538
539     if(obj->Pt()<3. && track2->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
540     fPidHF->GetPidCombined()->ComputeProbabilities(track2,fPidHF->GetPidResponse(),prob2);
541    if(obj->Pt()<3. && track2->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
542
543     if(fPIDThreshold[AliPID::kPion]>0. && fPIDThreshold[AliPID::kKaon]>0. && fPIDThreshold[AliPID::kProton]>0.){
544     okLcpiKp=  (prob0[AliPID::kPion  ]>fPIDThreshold[AliPID::kPion  ])
545              &&(prob1[AliPID::kKaon  ]>fPIDThreshold[AliPID::kKaon  ])
546              &&(prob2[AliPID::kProton]>fPIDThreshold[AliPID::kProton]);
547     okLcpKpi=  (prob0[AliPID::kProton]>fPIDThreshold[AliPID::kProton])
548              &&(prob1[AliPID::kKaon  ]>fPIDThreshold[AliPID::kKaon  ])
549              &&(prob2[AliPID::kPion  ]>fPIDThreshold[AliPID::kPion  ]);
550    }else{ 
551                     //pion or proton
552                     
553                     
554     if(TMath::MaxElement(AliPID::kSPECIES,prob1) == prob1[AliPID::kKaon]){
555     if(TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kProton] && TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kPion]) okLcpKpi = 1;  
556     if(TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kProton] && TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kPion]) okLcpiKp = 1; 
557             }
558            }
559     
560     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
561     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
562     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
563     
564     return returnvalue;
565 }
566 //-----------------------
567 Int_t AliRDHFCutsLctopKpi::CombinePIDCuts(Int_t returnvalue, Int_t returnvaluePID) const {
568
569  Int_t returnvalueTot=0;
570  Int_t okLcpKpi=0,okLcpiKp=0;
571  if(returnvaluePID==1){
572    if(returnvalue==1 || returnvalue==3) okLcpKpi=1;
573  }
574  if(returnvaluePID==2){
575    if(returnvalue>=2) okLcpiKp=1;
576  }
577  if(returnvaluePID==3 && returnvalue>0){
578   if(returnvalue==1 || returnvalue==3) okLcpKpi=1;
579   if(returnvalue>=2) okLcpiKp=1;
580  } 
581
582  if(okLcpKpi) returnvalueTot=1; //cuts passed as Lc->pKpi
583  if(okLcpiKp) returnvalueTot=2; //cuts passed as Lc->piKp
584  if(okLcpKpi && okLcpiKp) returnvalueTot=3; //cuts passed as both pKpi and piKp
585  return returnvalueTot;
586 }
587 //----------------------------------
588 void AliRDHFCutsLctopKpi::SetStandardCutsPP2010() {
589
590  SetName("LctopKpiProdCuts");
591  SetTitle("Production cuts for Lc analysis");
592
593  AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
594  esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
595  esdTrackCuts->SetRequireTPCRefit(kTRUE);
596  esdTrackCuts->SetMinNClustersTPC(70);
597  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
598                                           AliESDtrackCuts::kAny);
599  esdTrackCuts->SetRequireITSRefit(kTRUE);
600  esdTrackCuts->SetMinNClustersITS(4);
601  esdTrackCuts->SetMinDCAToVertexXY(0.);
602  esdTrackCuts->SetEtaRange(-0.8,0.8);
603  esdTrackCuts->SetPtRange(0.3,1.e10);
604  AddTrackCuts(esdTrackCuts);
605
606  const Int_t nptbins=4;
607  const Int_t nvars=13;
608  Float_t* ptbins;
609  ptbins=new Float_t[nptbins+1];
610  
611  ptbins[0]=0.;
612  ptbins[1]=2.;
613  ptbins[2]=3.;
614  ptbins[3]=4.;
615  ptbins[4]=9999.;
616
617  SetGlobalIndex(nvars,nptbins);
618  SetPtBins(nptbins+1,ptbins);
619
620  Float_t** prodcutsval;
621  prodcutsval=new Float_t*[nvars];
622  for(Int_t iv=0;iv<nvars;iv++){
623   prodcutsval[iv]=new Float_t[nptbins];
624  }
625
626  for(Int_t ipt=0;ipt<nptbins;ipt++){
627   prodcutsval[0][ipt]=0.18;
628   prodcutsval[1][ipt]=0.4;
629   prodcutsval[2][ipt]=0.5;
630   prodcutsval[3][ipt]=0.;
631   prodcutsval[4][ipt]=0.;
632   prodcutsval[5][ipt]=0.01;
633   prodcutsval[6][ipt]=0.06;
634   prodcutsval[7][ipt]=0.005;
635   prodcutsval[8][ipt]=0.;
636   prodcutsval[9][ipt]=0.;
637   prodcutsval[10][ipt]=0.;
638   prodcutsval[11][ipt]=0.05;
639   prodcutsval[12][ipt]=0.4;
640  }
641  SetCuts(nvars,nptbins,prodcutsval);
642
643  AliAODPidHF* pidObjK=new AliAODPidHF();
644  Double_t sigmasK[5]={3.,1.,1.,3.,2.};
645  pidObjK->SetSigma(sigmasK);
646  pidObjK->SetAsym(kTRUE);
647  pidObjK->SetMatch(1);
648  pidObjK->SetTPC(kTRUE);
649  pidObjK->SetTOF(kTRUE);
650  pidObjK->SetITS(kTRUE);
651  Double_t plimK[2]={0.5,0.8};
652  pidObjK->SetPLimit(plimK,2);
653  pidObjK->SetTOFdecide(kTRUE);
654
655  SetPidHF(pidObjK);
656
657  AliAODPidHF* pidObjpi=new AliAODPidHF();
658  pidObjpi->SetTPC(kTRUE);
659  Double_t sigmaspi[5]={3.,0.,0.,0.,0.};
660  pidObjpi->SetSigma(sigmaspi);
661  pidObjpi->SetTOFdecide(kTRUE);
662  SetPidpion(pidObjpi);
663
664  AliAODPidHF* pidObjp=new AliAODPidHF();
665  Double_t sigmasp[5]={3.,1.,1.,3.,2.};
666  pidObjp->SetSigma(sigmasp);
667  pidObjp->SetAsym(kTRUE);
668  pidObjp->SetMatch(1);
669  pidObjp->SetTPC(kTRUE);
670  pidObjp->SetTOF(kTRUE);
671  pidObjp->SetITS(kTRUE);
672  Double_t plimp[2]={1.,2.};
673  pidObjp->SetPLimit(plimp,2);
674  pidObjp->SetTOFdecide(kTRUE);
675
676  SetPidprot(pidObjp);
677
678  SetUsePID(kTRUE);
679
680  PrintAll();
681
682  for(Int_t iiv=0;iiv<nvars;iiv++){
683   delete [] prodcutsval[iiv];
684  }
685  delete [] prodcutsval;
686  prodcutsval=NULL;
687  delete [] ptbins;
688  ptbins=NULL;
689
690  delete pidObjp;
691  pidObjp=NULL;
692
693  return;
694 }
695 //------------------
696 void AliRDHFCutsLctopKpi::SetStandardCutsPbPb2010() {
697
698  SetName("LctopKpiProdCuts");
699  SetTitle("Production cuts for Lc analysis");
700
701  AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
702
703  esdTrackCuts->SetRequireTPCRefit(kTRUE);
704  esdTrackCuts->SetMinNClustersTPC(70);
705  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
706                                           AliESDtrackCuts::kAny);
707  esdTrackCuts->SetRequireITSRefit(kTRUE);
708  esdTrackCuts->SetMinNClustersITS(4);
709  esdTrackCuts->SetMinDCAToVertexXYPtDep("0.0100*TMath::Max(0.,(1-TMath::Floor(TMath::Abs(pt)/2.)))");
710  esdTrackCuts->SetEtaRange(-0.8,0.8);
711  esdTrackCuts->SetMaxDCAToVertexXY(1.);
712  esdTrackCuts->SetMaxDCAToVertexZ(1.);
713  esdTrackCuts->SetPtRange(0.8,1.e10);
714  AddTrackCuts(esdTrackCuts);
715
716  const Int_t nptbins=4;
717  const Int_t nvars=13;
718  Float_t* ptbins;
719  ptbins=new Float_t[nptbins+1];
720  
721  ptbins[0]=0.;
722  ptbins[1]=2.;
723  ptbins[2]=3.;
724  ptbins[3]=4.;
725  ptbins[4]=9999.;
726
727  SetGlobalIndex(nvars,nptbins);
728  SetPtBins(nptbins+1,ptbins);
729
730  Float_t** prodcutsval;
731  prodcutsval=new Float_t*[nvars];
732  for(Int_t iv=0;iv<nvars;iv++){
733   prodcutsval[iv]=new Float_t[nptbins];
734  }
735
736  for(Int_t ipt=0;ipt<nptbins;ipt++){
737   prodcutsval[0][ipt]=0.13;
738   prodcutsval[1][ipt]=0.5;
739   prodcutsval[2][ipt]=0.6;
740   prodcutsval[3][ipt]=0.;
741   prodcutsval[4][ipt]=0.;
742   prodcutsval[5][ipt]=0.01;
743   prodcutsval[6][ipt]=0.04;
744   prodcutsval[7][ipt]=0.006;
745   prodcutsval[8][ipt]=0.8;
746   prodcutsval[9][ipt]=0.3;
747   prodcutsval[10][ipt]=0.;
748   prodcutsval[11][ipt]=0.05;
749   prodcutsval[12][ipt]=0.4;
750  }
751  SetCuts(nvars,nptbins,prodcutsval);
752
753  AliAODPidHF* pidObjK=new AliAODPidHF();
754  Double_t sigmasK[5]={3.,1.,1.,3.,2.};
755  pidObjK->SetSigma(sigmasK);
756  pidObjK->SetAsym(kTRUE);
757  pidObjK->SetMatch(1);
758  pidObjK->SetTPC(kTRUE);
759  pidObjK->SetTOF(kTRUE);
760  pidObjK->SetITS(kTRUE);
761  Double_t plimK[2]={0.5,0.8};
762  pidObjK->SetPLimit(plimK,2);
763
764  SetPidHF(pidObjK);
765
766  AliAODPidHF* pidObjpi=new AliAODPidHF();
767  pidObjpi->SetTPC(kTRUE);
768  Double_t sigmaspi[5]={3.,0.,0.,0.,0.};
769  pidObjpi->SetSigma(sigmaspi);
770  SetPidpion(pidObjpi);
771
772  AliAODPidHF* pidObjp=new AliAODPidHF();
773  Double_t sigmasp[5]={3.,1.,1.,3.,2.};
774  pidObjp->SetSigma(sigmasp);
775  pidObjp->SetAsym(kTRUE);
776  pidObjp->SetMatch(1);
777  pidObjp->SetTPC(kTRUE);
778  pidObjp->SetTOF(kTRUE);
779  pidObjp->SetITS(kTRUE);
780  Double_t plimp[2]={1.,2.};
781  pidObjp->SetPLimit(plimp,2);
782
783  SetPidprot(pidObjp);
784
785  SetUsePID(kTRUE);
786
787  PrintAll();
788
789  for(Int_t iiv=0;iiv<nvars;iiv++){
790   delete [] prodcutsval[iiv];
791  }
792  delete [] prodcutsval;
793  prodcutsval=NULL;
794  delete [] ptbins;
795  ptbins=NULL;
796
797  delete pidObjp;
798  pidObjp=NULL;
799
800  return;
801 }
802 //------------------
803 AliKFParticle* AliRDHFCutsLctopKpi::ReconstructKF(AliAODRecoDecayHF3Prong *d,Int_t *pdgs,Double_t field,Bool_t constraint) const{
804   // Method to construct the KF particle from the candidate
805
806  const Int_t nprongs=d->GetNProngs();
807  if(nprongs<=0) return 0x0;
808
809  Int_t iprongs[nprongs];
810  for(Int_t i=0;i<nprongs;i++) iprongs[i]=i;
811
812  Double_t mass[2]={0.,0.};
813
814  AliKFParticle *decay=d->ApplyVertexingKF(iprongs,nprongs,pdgs,constraint,field,mass);
815  if(!decay) return 0x0;
816  AliESDVertex *vertexESD = new AliESDVertex(decay->Parameters(),
817                                             decay->CovarianceMatrix(),
818                                             decay->GetChi2(),
819                                             nprongs);
820  Double_t pos[3],cov[6],chi2perNDF;
821  vertexESD->GetXYZ(pos);
822  vertexESD->GetCovMatrix(cov);
823  chi2perNDF = vertexESD->GetChi2toNDF();
824  delete vertexESD; vertexESD=NULL;
825  AliAODVertex *vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
826  d->SetSecondaryVtx(vertexAOD);
827  return decay;
828 }
829
830 //------------------
831 void AliRDHFCutsLctopKpi::SetStandardCutsPbPb2011() {
832
833   // Default 2010 PbPb cut object
834   SetStandardCutsPbPb2010();
835
836   //
837   // Enable all 2011 PbPb run triggers
838   //  
839   SetTriggerClass("");
840   ResetMaskAndEnableMBTrigger();
841   EnableCentralTrigger();
842   EnableSemiCentralTrigger();
843 }
844 //-----------------
845
846 Bool_t AliRDHFCutsLctopKpi::IsInFiducialAcceptance(Double_t pt, Double_t y) const
847 {
848   //
849   //  // Checking if Dplus is in fiducial acceptance region 
850   //    //
851   //
852   if(pt > 5.) {
853     // applying cut for pt > 5 GeV
854    AliDebug(2,Form("pt of D+ = %f (> 5), cutting at |y| < 0.8",pt));
855    if (TMath::Abs(y) > 0.8) return kFALSE;
856   
857   } else {
858    // appliying smooth cut for pt < 5 GeV
859    Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5;
860    Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;
861   AliDebug(2,Form("pt of D+ = %f (< 5), cutting  according to the fiducial zone [%f, %f]\n",pt,minFiducialY,maxFiducialY));
862   if (y < minFiducialY || y > maxFiducialY) return kFALSE;
863  }
864   //
865   return kTRUE;
866 }
867 //--------------------------------------------------------
868 Int_t AliRDHFCutsLctopKpi::IsSelectedCombinedPIDSoft(AliAODRecoDecayHF* obj) {
869  if(!fUsePID || !obj) {return 3;}
870  Int_t okLcpKpi=0,okLcpiKp=0;
871  Int_t returnvalue=0;
872  
873  AliVTrack *track0=dynamic_cast<AliVTrack*>(obj->GetDaughter(0));
874  AliVTrack *track1=dynamic_cast<AliVTrack*>(obj->GetDaughter(1));
875  AliVTrack *track2=dynamic_cast<AliVTrack*>(obj->GetDaughter(2));
876  if (!track0 || !track1 || !track2) return 0;
877  Double_t prob0[AliPID::kSPECIES];
878  Double_t prob1[AliPID::kSPECIES];
879  Double_t prob2[AliPID::kSPECIES];
880
881  Bool_t isTOF0=fPidHF->CheckTOFPIDStatus((AliAODTrack*)obj->GetDaughter(0));
882  Bool_t isTOF1=fPidHF->CheckTOFPIDStatus((AliAODTrack*)obj->GetDaughter(1));
883  Bool_t isTOF2=fPidHF->CheckTOFPIDStatus((AliAODTrack*)obj->GetDaughter(2));
884
885 Bool_t isK1=kFALSE;
886  if(isTOF1){ //kaon
887   if(track1->P()<1.8) {
888     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
889     if(obj->Pt()<3. && track1->P()<0.55) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
890     fPidHF->GetPidCombined()->ComputeProbabilities(track1,fPidHF->GetPidResponse(),prob1);
891    
892   }else{
893     AliAODTrack *trackaod1=(AliAODTrack*)(obj->GetDaughter(1));
894     if(trackaod1->P()<0.55){
895       fPidHF->SetTOF(kFALSE);
896       fPidHF->SetTOFdecide(kFALSE);
897      }
898     Int_t isKaon=fPidHF->MakeRawPid(trackaod1,3);
899     if(isKaon>=1) isK1=kTRUE;
900     if(trackaod1->P()<0.55){
901       fPidHF->SetTOF(kTRUE);
902       fPidHF->SetTOFdecide(kTRUE);
903      }
904   }
905  }else{
906   if(track1->P()<0.8){
907     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
908     fPidHF->GetPidCombined()->ComputeProbabilities(track1,fPidHF->GetPidResponse(),prob0);
909   }else{
910     AliAODTrack *trackaod1=(AliAODTrack*)(obj->GetDaughter(1));
911      if(trackaod1->P()<0.55){
912       fPidHF->SetTOF(kFALSE);
913       fPidHF->SetTOFdecide(kFALSE);
914      }
915     Int_t isKaon=fPidHF->MakeRawPid(trackaod1,3);
916     if(isKaon>=1) isK1=kTRUE;
917      if(trackaod1->P()<0.55){
918       fPidHF->SetTOF(kTRUE);
919       fPidHF->SetTOFdecide(kTRUE);
920      }
921   }
922  }
923
924  Bool_t ispi0=kFALSE;
925  Bool_t isp0=kFALSE;
926  Bool_t ispi2=kFALSE;
927  Bool_t isp2=kFALSE;
928
929  if(isTOF0){ //proton
930   if(track0->P()<2.2) {
931     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
932     if(obj->Pt()<3. && track0->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
933     fPidHF->GetPidCombined()->ComputeProbabilities(track0,fPidHF->GetPidResponse(),prob0);
934   }else{
935    AliAODTrack *trackaod0=(AliAODTrack*)(obj->GetDaughter(0));
936    if(trackaod0->P()<1.){
937       fPidObjprot->SetTOF(kFALSE);
938       fPidObjprot->SetTOFdecide(kFALSE);
939    }
940    Int_t isProton=fPidObjprot->MakeRawPid(trackaod0,4);
941    if(isProton>=1) isp0=kTRUE;
942    if(trackaod0->P()<1.){
943       fPidObjprot->SetTOF(kTRUE);
944       fPidObjprot->SetTOFdecide(kTRUE);
945    }
946   }
947  }else{
948    if(track0->P()<1.2){
949     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
950     fPidHF->GetPidCombined()->ComputeProbabilities(track0,fPidHF->GetPidResponse(),prob0);
951    }else{
952     AliAODTrack *trackaod0=(AliAODTrack*)(obj->GetDaughter(0));
953     if(trackaod0->P()<1.){
954       fPidObjprot->SetTOF(kFALSE);
955       fPidObjprot->SetTOFdecide(kFALSE);
956     }
957     Int_t isProton=fPidObjprot->MakeRawPid(trackaod0,4);
958     if(isProton>=1) isp0=kTRUE;
959     if(trackaod0->P()<1.){
960       fPidObjprot->SetTOF(kTRUE);
961       fPidObjprot->SetTOFdecide(kTRUE);
962     }
963    }
964  }
965
966  if(isTOF2){ //proton
967   if(track2->P()<2.2) {
968     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
969     if(obj->Pt()<3. && track2->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
970     fPidHF->GetPidCombined()->ComputeProbabilities(track2,fPidHF->GetPidResponse(),prob2);
971   }else{
972     AliAODTrack *trackaod2=(AliAODTrack*)(obj->GetDaughter(2));
973     if(trackaod2->P()<1.){
974       fPidObjprot->SetTOF(kFALSE);
975       fPidObjprot->SetTOFdecide(kFALSE);
976     }
977    Int_t isProton=fPidObjprot->MakeRawPid(trackaod2,4);
978    if(isProton>=1) isp2=kTRUE;
979    if(trackaod2->P()<1.){
980       fPidObjprot->SetTOF(kTRUE);
981       fPidObjprot->SetTOFdecide(kTRUE);
982     }
983   }
984  }else{
985    if(track2->P()<1.2){
986     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
987     fPidHF->GetPidCombined()->ComputeProbabilities(track2,fPidHF->GetPidResponse(),prob2);
988    }else{
989     AliAODTrack *trackaod2=(AliAODTrack*)(obj->GetDaughter(2));
990      if(trackaod2->P()<1.){
991       fPidObjprot->SetTOF(kFALSE);
992       fPidObjprot->SetTOFdecide(kFALSE);
993     }
994     Int_t isProton=fPidObjprot->MakeRawPid(trackaod2,4);
995     if(isProton>=1) isp2=kTRUE;
996     if(trackaod2->P()<1.){
997       fPidObjprot->SetTOF(kTRUE);
998       fPidObjprot->SetTOFdecide(kTRUE);
999     }
1000    }
1001  }
1002   AliAODTrack *trackaod2=(AliAODTrack*)(obj->GetDaughter(2));
1003   if(fPidObjpion->MakeRawPid(trackaod2,2)>=1)ispi2=kTRUE;
1004   AliAODTrack *trackaod0=(AliAODTrack*)(obj->GetDaughter(2));
1005   if(fPidObjpion->MakeRawPid(trackaod0,2)>=1)ispi0=kTRUE;
1006
1007   if(TMath::MaxElement(AliPID::kSPECIES,prob1) == prob1[AliPID::kKaon]){
1008
1009     if(TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kProton] && TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kPion]) okLcpKpi = 1;
1010     if(TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kProton] && TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kPion]) okLcpiKp = 1;
1011     }
1012
1013    if(!isK1 && TMath::MaxElement(AliPID::kSPECIES,prob1) == prob1[AliPID::kKaon]) isK1=kTRUE;
1014     if(!ispi0 && TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kPion]) ispi0=kTRUE;
1015     if(!ispi2 && TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kPion]) ispi2=kTRUE;
1016     if(!isp0 && TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kProton]) isp0=kTRUE;
1017     if(!isp2 && TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kProton]) isp2=kTRUE;
1018     if(isK1 && ispi0 && isp2) okLcpiKp = 1;
1019     if(isK1 && isp0 && ispi2) okLcpKpi = 1;
1020
1021    if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
1022     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
1023     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
1024
1025     return returnvalue;
1026  
1027
1028 }
1029 //----------------------------------------------------------
1030 Int_t AliRDHFCutsLctopKpi::IsSelectedPIDStrong(AliAODRecoDecayHF* obj) {
1031
1032
1033     if(!fUsePID || !obj) return 3;
1034     Int_t okLcpKpi=0,okLcpiKp=0;
1035     Int_t returnvalue=0;
1036     Bool_t isPeriodd=fPidHF->GetOnePad();
1037     Bool_t isMC=fPidHF->GetMC();
1038     Bool_t ispion0=kTRUE,ispion2=kTRUE;
1039     Bool_t isproton0=kFALSE,isproton2=kFALSE;
1040     Bool_t iskaon1=kFALSE;
1041     if(isPeriodd) {
1042      fPidObjprot->SetOnePad(kTRUE);
1043      fPidObjpion->SetOnePad(kTRUE);
1044     }
1045     if(isMC) {
1046      fPidObjprot->SetMC(kTRUE);
1047      fPidObjpion->SetMC(kTRUE);
1048     }
1049
1050     for(Int_t i=0;i<3;i++){
1051      AliAODTrack *track=(AliAODTrack*)obj->GetDaughter(i);
1052      if(!track) return 0;
1053      // identify kaon
1054      if(i==1) {
1055       Int_t isKaon=fPidHF->MakeRawPid(track,3);
1056       if(isKaon>=1) {
1057        iskaon1=kTRUE;
1058       if(fPidHF->MakeRawPid(track,2)>=1) iskaon1=kFALSE;
1059       }
1060       if(!iskaon1) return 0;
1061      
1062      }else{
1063      //pion or proton
1064      
1065      Int_t isProton=fPidObjprot->MakeRawPid(track,4);
1066      if(isProton>=1){
1067       if(fPidHF->MakeRawPid(track,2)>=1) isProton=-1;
1068       if(fPidHF->MakeRawPid(track,3)>=1) isProton=-1;
1069      }
1070
1071      Int_t isPion=fPidObjpion->MakeRawPid(track,2);
1072      if(fPidHF->MakeRawPid(track,3)>=1) isPion=-1;
1073      if(fPidObjprot->MakeRawPid(track,4)>=1) isPion=-1;
1074
1075
1076      if(i==0) {
1077       if(isPion<0) ispion0=kFALSE;
1078       if(isProton>=1) isproton0=kTRUE;
1079
1080      }
1081       if(!ispion0 && !isproton0) return 0;
1082      if(i==2) {
1083       if(isPion<0) ispion2=kFALSE;
1084       if(isProton>=1) isproton2=kTRUE;
1085      }
1086
1087     }
1088    }
1089
1090     if(ispion2 && isproton0 && iskaon1) okLcpKpi=1;
1091     if(ispion0 && isproton2 && iskaon1) okLcpiKp=1;
1092     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
1093     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
1094     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
1095
1096  return returnvalue;
1097 }