]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/AliRDHFCutsLctopKpi.cxx
merging trunk to TPCdev
[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     AliError("Cut matrice not inizialized. Exit...\n");
262     return 0;
263   }
264   //PrintAll();
265   AliAODRecoDecayHF3Prong* d=(AliAODRecoDecayHF3Prong*)obj;
266
267   if(!d){
268     AliError("AliAODRecoDecayHF3Prong null \n");
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
284   // selection on daughter tracks 
285   if(selectionLevel==AliRDHFCuts::kAll || 
286      selectionLevel==AliRDHFCuts::kTracks) {
287     if(!AreDaughtersSelected(d)) return 0;
288   }
289
290
291   // PID selection
292   if(selectionLevel==AliRDHFCuts::kAll ||
293      selectionLevel==AliRDHFCuts::kCandidate|| 
294      selectionLevel==AliRDHFCuts::kPID) {
295     switch (fPIDStrategy) {
296     case kNSigma:
297       returnvaluePID = IsSelectedPID(d);
298       break;
299     case kCombined:
300       returnvaluePID = IsSelectedCombinedPID(d);
301       break;
302     case kCombinedSoft:
303       returnvaluePID = IsSelectedCombinedPIDSoft(d);
304       break;
305     case kNSigmaStrong:
306       returnvaluePID = IsSelectedPIDStrong(d);
307       break;
308     }
309     fIsSelectedPID=returnvaluePID;
310   }
311   //  if(fUsePID || selectionLevel==AliRDHFCuts::kPID) returnvaluePID = IsSelectedCombinedPID(d);   // to test!!
312   if(returnvaluePID==0) return 0;
313
314
315
316
317   // selection on candidate
318   if(selectionLevel==AliRDHFCuts::kAll || 
319      selectionLevel==AliRDHFCuts::kCandidate) {
320
321     Double_t pt=d->Pt();
322     
323     Int_t ptbin=PtBin(pt);
324     
325     Double_t mLcpKpi=0.,mLcpiKp=0.;
326     Int_t okLcpKpi=1,okLcpiKp=1;
327
328     Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
329
330     mLcpKpi=d->InvMassLcpKpi();
331     mLcpiKp=d->InvMassLcpiKp();
332
333     if(TMath::Abs(mLcpKpi-mLcPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okLcpKpi = 0;
334     if(TMath::Abs(mLcpiKp-mLcPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okLcpiKp = 0;
335     if(!okLcpKpi && !okLcpiKp) return 0;
336
337   switch (fCutsStrategy) {
338
339     case kStandard:
340     if(TMath::Abs(d->PtProng(1)) < fCutsRD[GetGlobalIndex(1,ptbin)] || TMath::Abs(d->Getd0Prong(1))<fCutsRD[GetGlobalIndex(3,ptbin)]) return 0;//Kaon
341     if(d->Pt()>=3. && d->PProng(1)<0.55) return 0;
342     if(fUseSpecialCut) {
343       if(TMath::Abs(d->PtProng(0)) < TMath::Abs(d->PtProng(2)) )okLcpKpi=0;
344       if(TMath::Abs(d->PtProng(2)) < TMath::Abs(d->PtProng(0)) )okLcpiKp=0;
345     }
346     if((TMath::Abs(d->PtProng(0)) < fCutsRD[GetGlobalIndex(2,ptbin)]) || (TMath::Abs(d->PtProng(2)) < fCutsRD[GetGlobalIndex(12,ptbin)])) okLcpKpi=0;
347     if((TMath::Abs(d->PtProng(2)) < fCutsRD[GetGlobalIndex(2,ptbin)]) || (TMath::Abs(d->PtProng(0)) < fCutsRD[GetGlobalIndex(12,ptbin)]))okLcpiKp=0;
348     if(!okLcpKpi && !okLcpiKp) return 0;
349     //2track cuts
350     if(d->GetDist12toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]|| d->GetDist23toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]) return 0;
351     if(d->GetDist12toPrim()>0.5) return 0;
352     if(d->GetDist23toPrim()>0.5) return 0;
353     if(fUseImpParProdCorrCut){
354       if(d->Getd0Prong(0)*d->Getd0Prong(1)<0. && d->Getd0Prong(2)*d->Getd0Prong(1)<0.) return 0;
355     }
356     //sec vert
357     if(d->DecayLength()<fCutsRD[GetGlobalIndex(7,ptbin)]) return 0;
358     if(d->DecayLength()>0.5) return 0;
359
360   //  Double_t sumd0s=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
361   //  if(sumd0s<fCutsRD[GetGlobalIndex(10,ptbin)]) return 0;
362     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;
363     
364     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;
365     if(d->CosPointingAngle()< fCutsRD[GetGlobalIndex(9,ptbin)]) return 0;
366     if(d->GetSigmaVert(aod)>fCutsRD[GetGlobalIndex(6,ptbin)]) return 0;
367     
368     //DCA
369     for(Int_t i=0;i<3;i++) if(d->GetDCA(i)>fCutsRD[GetGlobalIndex(11,ptbin)]) return 0;
370
371     break;
372
373    case kKF:
374     Int_t pdgs[3]={0,321,0};
375     Bool_t constraint=kFALSE;
376     if(fCutsRD[GetGlobalIndex(1,ptbin)]>0.) constraint=kTRUE;
377     Double_t field=aod->GetMagneticField();
378     if (returnvaluePID==1 || returnvaluePID==3){
379
380       pdgs[0]=2122;pdgs[2]=211;
381       AliKFParticle *lc1=ReconstructKF(d,pdgs,field,constraint);
382       if(!lc1){
383         okLcpKpi=0;
384       }else{
385         if(lc1->GetChi2()/lc1->GetNDF()>fCutsRD[GetGlobalIndex(2,ptbin)]) okLcpKpi=0;
386       }
387     } else if(returnvaluePID>=2){
388
389       pdgs[0]=211;pdgs[2]=2212;
390       AliKFParticle *lc2=ReconstructKF(d,pdgs,field,constraint);
391       if(!lc2){ 
392         okLcpiKp=0;
393       }else{
394         if(lc2->GetChi2()/lc2->GetNDF()>fCutsRD[GetGlobalIndex(2,ptbin)])okLcpiKp=0; 
395       }
396     }
397     break;
398
399    }
400
401     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
402     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
403     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
404    
405   }
406
407
408   Int_t returnvalueTot=CombinePIDCuts(returnvalue,returnvaluePID);
409   return returnvalueTot;
410 }
411 //---------------------------------------------------------------------------
412 Int_t AliRDHFCutsLctopKpi::IsSelectedPID(AliAODRecoDecayHF* obj) {
413
414
415     if(!fUsePID || !obj) return 3;
416     Int_t okLcpKpi=0,okLcpiKp=0;
417     Int_t returnvalue=0;
418     Bool_t isPeriodd=fPidHF->GetOnePad();
419     Bool_t isMC=fPidHF->GetMC();
420     Bool_t ispion0=kTRUE,ispion2=kTRUE;
421     Bool_t isproton0=kFALSE,isproton2=kFALSE;
422     Bool_t iskaon1=kFALSE;
423     if(isPeriodd) {
424      fPidObjprot->SetOnePad(kTRUE);
425      fPidObjpion->SetOnePad(kTRUE);
426     }
427     if(isMC) {
428      fPidObjprot->SetMC(kTRUE);
429      fPidObjpion->SetMC(kTRUE);
430     }
431
432    if(fPidObjprot->GetPidResponse()==0x0){
433       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
434       AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
435       AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
436       fPidObjprot->SetPidResponse(pidResp);
437     }
438     if(fPidObjpion->GetPidResponse()==0x0){
439       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
440       AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
441       AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
442       fPidObjpion->SetPidResponse(pidResp);
443     }
444     if(fPidHF->GetPidResponse()==0x0){
445       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
446       AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
447       AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
448       fPidHF->SetPidResponse(pidResp);
449     }
450
451     for(Int_t i=0;i<3;i++){
452      AliAODTrack *track=(AliAODTrack*)obj->GetDaughter(i);
453      if(!track) return 0;
454      // identify kaon
455      if(track->P()<0.55){
456       fPidHF->SetTOF(kFALSE);
457       fPidHF->SetTOFdecide(kFALSE);
458      }
459      if(i==1) {
460       Int_t isKaon=fPidHF->MakeRawPid(track,3); 
461       if(isKaon>=1) iskaon1=kTRUE;
462       if(track->P()<0.55){
463        fPidHF->SetTOF(kTRUE);
464        fPidHF->SetTOFdecide(kTRUE);
465       }
466       
467       if(!iskaon1) return 0;
468      
469      }else{
470      //pion or proton
471     if(track->P()<1.){
472       fPidObjprot->SetTOF(kFALSE);
473       fPidObjprot->SetTOFdecide(kFALSE);
474      }
475       
476      Int_t isProton=fPidObjprot->MakeRawPid(track,4);
477      
478
479      Int_t isPion=fPidObjpion->MakeRawPid(track,2);
480      
481      if(track->P()<1.){
482       fPidObjprot->SetTOF(kTRUE);
483       fPidObjprot->SetTOFdecide(kTRUE);
484      }
485      
486
487      if(i==0) {
488       if(isPion<0) ispion0=kFALSE;
489       if(isProton>=1) isproton0=kTRUE;
490
491      }
492       if(!ispion0 && !isproton0) return 0;
493      if(i==2) {
494       if(isPion<0) ispion2=kFALSE;
495       if(isProton>=1) isproton2=kTRUE;
496      }
497
498     }
499    }
500
501     if(ispion2 && isproton0 && iskaon1) okLcpKpi=1;
502     if(ispion0 && isproton2 && iskaon1) okLcpiKp=1;
503     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
504     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
505     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
506
507  return returnvalue;
508 }
509 //---------------------------------------------------------------------------
510 Int_t AliRDHFCutsLctopKpi::IsSelectedCombinedPID(AliAODRecoDecayHF* obj) {
511
512   //  Printf(" -------- IsSelectedCombinedPID --------------");
513
514     
515     if(!fUsePID || !obj) {return 3;}
516     Int_t okLcpKpi=0,okLcpiKp=0;
517     Int_t returnvalue=0;
518     Bool_t isPeriodd=fPidHF->GetOnePad();
519     Bool_t isMC=fPidHF->GetMC();
520
521     if(isPeriodd) {
522             fPidObjprot->SetOnePad(kTRUE);
523             fPidObjpion->SetOnePad(kTRUE);
524     }
525     if(isMC) {
526             fPidObjprot->SetMC(kTRUE);
527             fPidObjpion->SetMC(kTRUE);
528     }
529
530     AliVTrack *track0=dynamic_cast<AliVTrack*>(obj->GetDaughter(0));
531     AliVTrack *track1=dynamic_cast<AliVTrack*>(obj->GetDaughter(1));
532     AliVTrack *track2=dynamic_cast<AliVTrack*>(obj->GetDaughter(2));
533     if (!track0 || !track1 || !track2) return 0;
534     Double_t prob0[AliPID::kSPECIES];
535     Double_t prob1[AliPID::kSPECIES];
536     Double_t prob2[AliPID::kSPECIES];
537     if(obj->Pt()<3. && track0->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
538     fPidHF->GetPidCombined()->ComputeProbabilities(track0,fPidHF->GetPidResponse(),prob0);
539     if(obj->Pt()<3. && track0->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
540
541    if(obj->Pt()<3. && track1->P()<0.55) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
542     fPidHF->GetPidCombined()->ComputeProbabilities(track1,fPidHF->GetPidResponse(),prob1);
543    if(obj->Pt()<3. && track1->P()<0.55) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
544
545     if(obj->Pt()<3. && track2->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
546     fPidHF->GetPidCombined()->ComputeProbabilities(track2,fPidHF->GetPidResponse(),prob2);
547    if(obj->Pt()<3. && track2->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
548
549     if(fPIDThreshold[AliPID::kPion]>0. && fPIDThreshold[AliPID::kKaon]>0. && fPIDThreshold[AliPID::kProton]>0.){
550     okLcpiKp=  (prob0[AliPID::kPion  ]>fPIDThreshold[AliPID::kPion  ])
551              &&(prob1[AliPID::kKaon  ]>fPIDThreshold[AliPID::kKaon  ])
552              &&(prob2[AliPID::kProton]>fPIDThreshold[AliPID::kProton]);
553     okLcpKpi=  (prob0[AliPID::kProton]>fPIDThreshold[AliPID::kProton])
554              &&(prob1[AliPID::kKaon  ]>fPIDThreshold[AliPID::kKaon  ])
555              &&(prob2[AliPID::kPion  ]>fPIDThreshold[AliPID::kPion  ]);
556    }else{ 
557                     //pion or proton
558                     
559                     
560     if(TMath::MaxElement(AliPID::kSPECIES,prob1) == prob1[AliPID::kKaon]){
561     if(TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kProton] && TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kPion]) okLcpKpi = 1;  
562     if(TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kProton] && TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kPion]) okLcpiKp = 1; 
563             }
564            }
565     
566     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
567     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
568     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
569     
570     return returnvalue;
571 }
572 //-----------------------
573 Int_t AliRDHFCutsLctopKpi::CombinePIDCuts(Int_t returnvalue, Int_t returnvaluePID) const {
574
575  Int_t returnvalueTot=0;
576  Int_t okLcpKpi=0,okLcpiKp=0;
577  if(returnvaluePID==1){
578    if(returnvalue==1 || returnvalue==3) okLcpKpi=1;
579  }
580  if(returnvaluePID==2){
581    if(returnvalue>=2) okLcpiKp=1;
582  }
583  if(returnvaluePID==3 && returnvalue>0){
584   if(returnvalue==1 || returnvalue==3) okLcpKpi=1;
585   if(returnvalue>=2) okLcpiKp=1;
586  } 
587
588  if(okLcpKpi) returnvalueTot=1; //cuts passed as Lc->pKpi
589  if(okLcpiKp) returnvalueTot=2; //cuts passed as Lc->piKp
590  if(okLcpKpi && okLcpiKp) returnvalueTot=3; //cuts passed as both pKpi and piKp
591  return returnvalueTot;
592 }
593 //----------------------------------
594 void AliRDHFCutsLctopKpi::SetStandardCutsPP2010() {
595
596  SetName("LctopKpiProdCuts");
597  SetTitle("Production cuts for Lc analysis");
598
599  AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
600  esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
601  esdTrackCuts->SetRequireTPCRefit(kTRUE);
602  esdTrackCuts->SetMinNClustersTPC(70);
603  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
604                                           AliESDtrackCuts::kAny);
605  esdTrackCuts->SetRequireITSRefit(kTRUE);
606  esdTrackCuts->SetMinNClustersITS(4);
607  esdTrackCuts->SetMinDCAToVertexXY(0.);
608  esdTrackCuts->SetEtaRange(-0.8,0.8);
609  esdTrackCuts->SetPtRange(0.3,1.e10);
610  AddTrackCuts(esdTrackCuts);
611
612  const Int_t nptbins=4;
613  const Int_t nvars=13;
614  Float_t* ptbins;
615  ptbins=new Float_t[nptbins+1];
616  
617  ptbins[0]=0.;
618  ptbins[1]=2.;
619  ptbins[2]=3.;
620  ptbins[3]=4.;
621  ptbins[4]=9999.;
622
623  SetGlobalIndex(nvars,nptbins);
624  SetPtBins(nptbins+1,ptbins);
625
626  Float_t** prodcutsval;
627  prodcutsval=new Float_t*[nvars];
628  for(Int_t iv=0;iv<nvars;iv++){
629   prodcutsval[iv]=new Float_t[nptbins];
630  }
631
632  for(Int_t ipt=0;ipt<nptbins;ipt++){
633   prodcutsval[0][ipt]=0.18;
634   prodcutsval[1][ipt]=0.4;
635   prodcutsval[2][ipt]=0.5;
636   prodcutsval[3][ipt]=0.;
637   prodcutsval[4][ipt]=0.;
638   prodcutsval[5][ipt]=0.01;
639   prodcutsval[6][ipt]=0.06;
640   prodcutsval[7][ipt]=0.005;
641   prodcutsval[8][ipt]=0.;
642   prodcutsval[9][ipt]=0.;
643   prodcutsval[10][ipt]=0.;
644   prodcutsval[11][ipt]=0.05;
645   prodcutsval[12][ipt]=0.4;
646  }
647  SetCuts(nvars,nptbins,prodcutsval);
648
649  AliAODPidHF* pidObjK=new AliAODPidHF();
650  Double_t sigmasK[5]={3.,1.,1.,3.,2.};
651  pidObjK->SetSigma(sigmasK);
652  pidObjK->SetAsym(kTRUE);
653  pidObjK->SetMatch(1);
654  pidObjK->SetTPC(kTRUE);
655  pidObjK->SetTOF(kTRUE);
656  pidObjK->SetITS(kTRUE);
657  Double_t plimK[2]={0.5,0.8};
658  pidObjK->SetPLimit(plimK,2);
659  pidObjK->SetTOFdecide(kTRUE);
660
661  SetPidHF(pidObjK);
662
663  AliAODPidHF* pidObjpi=new AliAODPidHF();
664  pidObjpi->SetTPC(kTRUE);
665  Double_t sigmaspi[5]={3.,0.,0.,0.,0.};
666  pidObjpi->SetSigma(sigmaspi);
667  pidObjpi->SetTOFdecide(kTRUE);
668  SetPidpion(pidObjpi);
669
670  AliAODPidHF* pidObjp=new AliAODPidHF();
671  Double_t sigmasp[5]={3.,1.,1.,3.,2.};
672  pidObjp->SetSigma(sigmasp);
673  pidObjp->SetAsym(kTRUE);
674  pidObjp->SetMatch(1);
675  pidObjp->SetTPC(kTRUE);
676  pidObjp->SetTOF(kTRUE);
677  pidObjp->SetITS(kTRUE);
678  Double_t plimp[2]={1.,2.};
679  pidObjp->SetPLimit(plimp,2);
680  pidObjp->SetTOFdecide(kTRUE);
681
682  SetPidprot(pidObjp);
683
684  SetUsePID(kTRUE);
685
686  PrintAll();
687
688  for(Int_t iiv=0;iiv<nvars;iiv++){
689   delete [] prodcutsval[iiv];
690  }
691  delete [] prodcutsval;
692  prodcutsval=NULL;
693  delete [] ptbins;
694  ptbins=NULL;
695
696  delete pidObjK;
697  pidObjK=NULL;
698  delete pidObjpi;
699  pidObjpi=NULL;
700  delete pidObjp;
701  pidObjp=NULL;
702
703  return;
704 }
705 //------------------
706 void AliRDHFCutsLctopKpi::SetStandardCutsPbPb2010() {
707
708  SetName("LctopKpiProdCuts");
709  SetTitle("Production cuts for Lc analysis");
710
711  AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
712
713  esdTrackCuts->SetRequireTPCRefit(kTRUE);
714  esdTrackCuts->SetMinNClustersTPC(70);
715  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
716                                           AliESDtrackCuts::kAny);
717  esdTrackCuts->SetRequireITSRefit(kTRUE);
718  esdTrackCuts->SetMinNClustersITS(4);
719  esdTrackCuts->SetMinDCAToVertexXYPtDep("0.0100*TMath::Max(0.,(1-TMath::Floor(TMath::Abs(pt)/2.)))");
720  esdTrackCuts->SetEtaRange(-0.8,0.8);
721  esdTrackCuts->SetMaxDCAToVertexXY(1.);
722  esdTrackCuts->SetMaxDCAToVertexZ(1.);
723  esdTrackCuts->SetPtRange(0.49,1.e10);
724  AddTrackCuts(esdTrackCuts);
725
726  const Int_t nptbins=4;
727  const Int_t nvars=13;
728  Float_t* ptbins;
729  ptbins=new Float_t[nptbins+1];
730  
731  ptbins[0]=0.;
732  ptbins[1]=2.;
733  ptbins[2]=3.;
734  ptbins[3]=4.;
735  ptbins[4]=9999.;
736
737  SetGlobalIndex(nvars,nptbins);
738  SetPtBins(nptbins+1,ptbins);
739
740  Float_t** prodcutsval;
741  prodcutsval=new Float_t*[nvars];
742  for(Int_t iv=0;iv<nvars;iv++){
743   prodcutsval[iv]=new Float_t[nptbins];
744  }
745
746  for(Int_t ipt=0;ipt<nptbins;ipt++){
747   prodcutsval[0][ipt]=0.13;
748   prodcutsval[1][ipt]=0.5;
749   prodcutsval[2][ipt]=0.6;
750   prodcutsval[3][ipt]=0.;
751   prodcutsval[4][ipt]=0.;
752   prodcutsval[5][ipt]=0.01;
753   prodcutsval[6][ipt]=0.04;
754   prodcutsval[7][ipt]=0.006;
755   prodcutsval[8][ipt]=0.8;
756   prodcutsval[9][ipt]=0.3;
757   prodcutsval[10][ipt]=0.;
758   prodcutsval[11][ipt]=0.05;
759   prodcutsval[12][ipt]=0.4;
760  }
761  SetCuts(nvars,nptbins,prodcutsval);
762
763  AliAODPidHF* pidObjK=new AliAODPidHF();
764  Double_t sigmasK[5]={3.,1.,1.,3.,2.};
765  pidObjK->SetSigma(sigmasK);
766  pidObjK->SetAsym(kTRUE);
767  pidObjK->SetMatch(1);
768  pidObjK->SetTPC(kTRUE);
769  pidObjK->SetTOF(kTRUE);
770  pidObjK->SetITS(kTRUE);
771  Double_t plimK[2]={0.5,0.8};
772  pidObjK->SetPLimit(plimK,2);
773
774  SetPidHF(pidObjK);
775
776  AliAODPidHF* pidObjpi=new AliAODPidHF();
777  pidObjpi->SetTPC(kTRUE);
778  Double_t sigmaspi[5]={3.,0.,0.,0.,0.};
779  pidObjpi->SetSigma(sigmaspi);
780  SetPidpion(pidObjpi);
781
782  AliAODPidHF* pidObjp=new AliAODPidHF();
783  Double_t sigmasp[5]={3.,1.,1.,3.,2.};
784  pidObjp->SetSigma(sigmasp);
785  pidObjp->SetAsym(kTRUE);
786  pidObjp->SetMatch(1);
787  pidObjp->SetTPC(kTRUE);
788  pidObjp->SetTOF(kTRUE);
789  pidObjp->SetITS(kTRUE);
790  Double_t plimp[2]={1.,2.};
791  pidObjp->SetPLimit(plimp,2);
792
793  SetPidprot(pidObjp);
794
795  SetUsePID(kTRUE);
796
797  PrintAll();
798
799  for(Int_t iiv=0;iiv<nvars;iiv++){
800   delete [] prodcutsval[iiv];
801  }
802  delete [] prodcutsval;
803  prodcutsval=NULL;
804  delete [] ptbins;
805  ptbins=NULL;
806
807  delete pidObjK;
808  pidObjK=NULL;
809  delete pidObjpi;
810  pidObjpi=NULL;
811  delete pidObjp;
812  pidObjp=NULL;
813
814  return;
815 }
816 //------------------
817 AliKFParticle* AliRDHFCutsLctopKpi::ReconstructKF(AliAODRecoDecayHF3Prong *d,Int_t *pdgs,Double_t field,Bool_t constraint) const{
818   // Method to construct the KF particle from the candidate
819
820  const Int_t nprongs=d->GetNProngs();
821  if(nprongs<=0) return 0x0;
822
823  Int_t iprongs[nprongs];
824  for(Int_t i=0;i<nprongs;i++) iprongs[i]=i;
825
826  Double_t mass[2]={0.,0.};
827
828  AliKFParticle *decay=d->ApplyVertexingKF(iprongs,nprongs,pdgs,constraint,field,mass);
829  if(!decay) return 0x0;
830  AliESDVertex *vertexESD = new AliESDVertex(decay->Parameters(),
831                                             decay->CovarianceMatrix(),
832                                             decay->GetChi2(),
833                                             nprongs);
834  Double_t pos[3],cov[6],chi2perNDF;
835  vertexESD->GetXYZ(pos);
836  vertexESD->GetCovMatrix(cov);
837  chi2perNDF = vertexESD->GetChi2toNDF();
838  delete vertexESD; vertexESD=NULL;
839  AliAODVertex *vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
840  d->SetSecondaryVtx(vertexAOD);
841  return decay;
842 }
843
844 //------------------
845 void AliRDHFCutsLctopKpi::SetStandardCutsPbPb2011() {
846
847   // Default 2010 PbPb cut object
848   SetStandardCutsPbPb2010();
849
850   //
851   // Enable all 2011 PbPb run triggers
852   //  
853   SetTriggerClass("");
854   ResetMaskAndEnableMBTrigger();
855   EnableCentralTrigger();
856   EnableSemiCentralTrigger();
857 }
858 //-----------------
859
860 Bool_t AliRDHFCutsLctopKpi::IsInFiducialAcceptance(Double_t pt, Double_t y) const
861 {
862   //
863   //  // Checking if Lc is in fiducial acceptance region 
864   //    //
865   //
866   if(fMaxRapidityCand>-998.){
867     if(TMath::Abs(y) > fMaxRapidityCand) return kFALSE;
868     else return kTRUE;
869   }
870
871   if(pt > 5.) {
872     // applying cut for pt > 5 GeV
873    AliDebug(2,Form("pt of Lc = %f (> 5), cutting at |y| < 0.8",pt));
874    if (TMath::Abs(y) > 0.8) return kFALSE;
875   
876   } else {
877    // appliying smooth cut for pt < 5 GeV
878    Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5;
879    Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;
880   AliDebug(2,Form("pt of Lc = %f (< 5), cutting  according to the fiducial zone [%f, %f]\n",pt,minFiducialY,maxFiducialY));
881   if (y < minFiducialY || y > maxFiducialY) return kFALSE;
882  }
883   //
884   return kTRUE;
885 }
886 //--------------------------------------------------------
887 Int_t AliRDHFCutsLctopKpi::IsSelectedCombinedPIDSoft(AliAODRecoDecayHF* obj) {
888  if(!fUsePID || !obj) {return 3;}
889  Int_t okLcpKpi=0,okLcpiKp=0;
890  Int_t returnvalue=0;
891  
892  AliVTrack *track0=dynamic_cast<AliVTrack*>(obj->GetDaughter(0));
893  AliVTrack *track1=dynamic_cast<AliVTrack*>(obj->GetDaughter(1));
894  AliVTrack *track2=dynamic_cast<AliVTrack*>(obj->GetDaughter(2));
895  if (!track0 || !track1 || !track2) return 0;
896  Double_t prob0[AliPID::kSPECIES];
897  Double_t prob1[AliPID::kSPECIES];
898  Double_t prob2[AliPID::kSPECIES];
899
900  Bool_t isTOF0=fPidHF->CheckTOFPIDStatus((AliAODTrack*)obj->GetDaughter(0));
901  Bool_t isTOF1=fPidHF->CheckTOFPIDStatus((AliAODTrack*)obj->GetDaughter(1));
902  Bool_t isTOF2=fPidHF->CheckTOFPIDStatus((AliAODTrack*)obj->GetDaughter(2));
903
904 Bool_t isK1=kFALSE;
905  if(isTOF1){ //kaon
906   if(track1->P()<1.8) {
907     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
908     if(obj->Pt()<3. && track1->P()<0.55) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
909     fPidHF->GetPidCombined()->ComputeProbabilities(track1,fPidHF->GetPidResponse(),prob1);
910    
911   }else{
912     AliAODTrack *trackaod1=(AliAODTrack*)(obj->GetDaughter(1));
913     if(trackaod1->P()<0.55){
914       fPidHF->SetTOF(kFALSE);
915       fPidHF->SetTOFdecide(kFALSE);
916      }
917     Int_t isKaon=fPidHF->MakeRawPid(trackaod1,3);
918     if(isKaon>=1) isK1=kTRUE;
919     if(trackaod1->P()<0.55){
920       fPidHF->SetTOF(kTRUE);
921       fPidHF->SetTOFdecide(kTRUE);
922      }
923   }
924  }else{
925   if(track1->P()<0.8){
926     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
927     fPidHF->GetPidCombined()->ComputeProbabilities(track1,fPidHF->GetPidResponse(),prob0);
928   }else{
929     AliAODTrack *trackaod1=(AliAODTrack*)(obj->GetDaughter(1));
930      if(trackaod1->P()<0.55){
931       fPidHF->SetTOF(kFALSE);
932       fPidHF->SetTOFdecide(kFALSE);
933      }
934     Int_t isKaon=fPidHF->MakeRawPid(trackaod1,3);
935     if(isKaon>=1) isK1=kTRUE;
936      if(trackaod1->P()<0.55){
937       fPidHF->SetTOF(kTRUE);
938       fPidHF->SetTOFdecide(kTRUE);
939      }
940   }
941  }
942
943  Bool_t ispi0=kFALSE;
944  Bool_t isp0=kFALSE;
945  Bool_t ispi2=kFALSE;
946  Bool_t isp2=kFALSE;
947
948  if(isTOF0){ //proton
949   if(track0->P()<2.2) {
950     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
951     if(obj->Pt()<3. && track0->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
952     fPidHF->GetPidCombined()->ComputeProbabilities(track0,fPidHF->GetPidResponse(),prob0);
953   }else{
954    AliAODTrack *trackaod0=(AliAODTrack*)(obj->GetDaughter(0));
955    if(trackaod0->P()<1.){
956       fPidObjprot->SetTOF(kFALSE);
957       fPidObjprot->SetTOFdecide(kFALSE);
958    }
959    Int_t isProton=fPidObjprot->MakeRawPid(trackaod0,4);
960    if(isProton>=1) isp0=kTRUE;
961    if(trackaod0->P()<1.){
962       fPidObjprot->SetTOF(kTRUE);
963       fPidObjprot->SetTOFdecide(kTRUE);
964    }
965   }
966  }else{
967    if(track0->P()<1.2){
968     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
969     fPidHF->GetPidCombined()->ComputeProbabilities(track0,fPidHF->GetPidResponse(),prob0);
970    }else{
971     AliAODTrack *trackaod0=(AliAODTrack*)(obj->GetDaughter(0));
972     if(trackaod0->P()<1.){
973       fPidObjprot->SetTOF(kFALSE);
974       fPidObjprot->SetTOFdecide(kFALSE);
975     }
976     Int_t isProton=fPidObjprot->MakeRawPid(trackaod0,4);
977     if(isProton>=1) isp0=kTRUE;
978     if(trackaod0->P()<1.){
979       fPidObjprot->SetTOF(kTRUE);
980       fPidObjprot->SetTOFdecide(kTRUE);
981     }
982    }
983  }
984
985  if(isTOF2){ //proton
986   if(track2->P()<2.2) {
987     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
988     if(obj->Pt()<3. && track2->P()<1.) fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
989     fPidHF->GetPidCombined()->ComputeProbabilities(track2,fPidHF->GetPidResponse(),prob2);
990   }else{
991     AliAODTrack *trackaod2=(AliAODTrack*)(obj->GetDaughter(2));
992     if(trackaod2->P()<1.){
993       fPidObjprot->SetTOF(kFALSE);
994       fPidObjprot->SetTOFdecide(kFALSE);
995     }
996    Int_t isProton=fPidObjprot->MakeRawPid(trackaod2,4);
997    if(isProton>=1) isp2=kTRUE;
998    if(trackaod2->P()<1.){
999       fPidObjprot->SetTOF(kTRUE);
1000       fPidObjprot->SetTOFdecide(kTRUE);
1001     }
1002   }
1003  }else{
1004    if(track2->P()<1.2){
1005     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
1006     fPidHF->GetPidCombined()->ComputeProbabilities(track2,fPidHF->GetPidResponse(),prob2);
1007    }else{
1008     AliAODTrack *trackaod2=(AliAODTrack*)(obj->GetDaughter(2));
1009      if(trackaod2->P()<1.){
1010       fPidObjprot->SetTOF(kFALSE);
1011       fPidObjprot->SetTOFdecide(kFALSE);
1012     }
1013     Int_t isProton=fPidObjprot->MakeRawPid(trackaod2,4);
1014     if(isProton>=1) isp2=kTRUE;
1015     if(trackaod2->P()<1.){
1016       fPidObjprot->SetTOF(kTRUE);
1017       fPidObjprot->SetTOFdecide(kTRUE);
1018     }
1019    }
1020  }
1021   AliAODTrack *trackaod2=(AliAODTrack*)(obj->GetDaughter(2));
1022   if(fPidObjpion->MakeRawPid(trackaod2,2)>=1)ispi2=kTRUE;
1023   AliAODTrack *trackaod0=(AliAODTrack*)(obj->GetDaughter(2));
1024   if(fPidObjpion->MakeRawPid(trackaod0,2)>=1)ispi0=kTRUE;
1025
1026   if(TMath::MaxElement(AliPID::kSPECIES,prob1) == prob1[AliPID::kKaon]){
1027
1028     if(TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kProton] && TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kPion]) okLcpKpi = 1;
1029     if(TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kProton] && TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kPion]) okLcpiKp = 1;
1030     }
1031
1032    if(!isK1 && TMath::MaxElement(AliPID::kSPECIES,prob1) == prob1[AliPID::kKaon]) isK1=kTRUE;
1033     if(!ispi0 && TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kPion]) ispi0=kTRUE;
1034     if(!ispi2 && TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kPion]) ispi2=kTRUE;
1035     if(!isp0 && TMath::MaxElement(AliPID::kSPECIES,prob0) == prob0[AliPID::kProton]) isp0=kTRUE;
1036     if(!isp2 && TMath::MaxElement(AliPID::kSPECIES,prob2) == prob2[AliPID::kProton]) isp2=kTRUE;
1037     if(isK1 && ispi0 && isp2) okLcpiKp = 1;
1038     if(isK1 && isp0 && ispi2) okLcpKpi = 1;
1039
1040    if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
1041     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
1042     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
1043
1044     return returnvalue;
1045  
1046
1047 }
1048 //----------------------------------------------------------
1049 Int_t AliRDHFCutsLctopKpi::IsSelectedPIDStrong(AliAODRecoDecayHF* obj) {
1050
1051
1052     if(!fUsePID || !obj) return 3;
1053     Int_t okLcpKpi=0,okLcpiKp=0;
1054     Int_t returnvalue=0;
1055     Bool_t isPeriodd=fPidHF->GetOnePad();
1056     Bool_t isMC=fPidHF->GetMC();
1057     Bool_t ispion0=kTRUE,ispion2=kTRUE;
1058     Bool_t isproton0=kFALSE,isproton2=kFALSE;
1059     Bool_t iskaon1=kFALSE;
1060     if(isPeriodd) {
1061      fPidObjprot->SetOnePad(kTRUE);
1062      fPidObjpion->SetOnePad(kTRUE);
1063     }
1064     if(isMC) {
1065      fPidObjprot->SetMC(kTRUE);
1066      fPidObjpion->SetMC(kTRUE);
1067     }
1068
1069     for(Int_t i=0;i<3;i++){
1070      AliAODTrack *track=(AliAODTrack*)obj->GetDaughter(i);
1071      if(!track) return 0;
1072      // identify kaon
1073      if(i==1) {
1074       Int_t isKaon=fPidHF->MakeRawPid(track,3);
1075       if(isKaon>=1) {
1076        iskaon1=kTRUE;
1077       if(fPidHF->MakeRawPid(track,2)>=1) iskaon1=kFALSE;
1078       }
1079       if(!iskaon1) return 0;
1080      
1081      }else{
1082      //pion or proton
1083      
1084      Int_t isProton=fPidObjprot->MakeRawPid(track,4);
1085      if(isProton>=1){
1086       if(fPidHF->MakeRawPid(track,2)>=1) isProton=-1;
1087       if(fPidHF->MakeRawPid(track,3)>=1) isProton=-1;
1088      }
1089
1090      Int_t isPion=fPidObjpion->MakeRawPid(track,2);
1091      if(fPidHF->MakeRawPid(track,3)>=1) isPion=-1;
1092      if(fPidObjprot->MakeRawPid(track,4)>=1) isPion=-1;
1093
1094
1095      if(i==0) {
1096       if(isPion<0) ispion0=kFALSE;
1097       if(isProton>=1) isproton0=kTRUE;
1098
1099      }
1100       if(!ispion0 && !isproton0) return 0;
1101      if(i==2) {
1102       if(isPion<0) ispion2=kFALSE;
1103       if(isProton>=1) isproton2=kTRUE;
1104      }
1105
1106     }
1107    }
1108
1109     if(ispion2 && isproton0 && iskaon1) okLcpKpi=1;
1110     if(ispion0 && isproton2 && iskaon1) okLcpiKp=1;
1111     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
1112     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
1113     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
1114
1115  return returnvalue;
1116 }