First implementation of combined Bayesian PID (Pietro, ChiaraZ)
[u/mrichter/AliRoot.git] / PWG3 / 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
28 #include "AliRDHFCutsLctopKpi.h"
29 #include "AliAODRecoDecayHF3Prong.h"
30 #include "AliRDHFCuts.h"
31 #include "AliAODTrack.h"
32 #include "AliESDtrack.h"
33 #include "AliKFParticle.h"
34 #include "AliESDVertex.h"
35
36 ClassImp(AliRDHFCutsLctopKpi)
37
38 //--------------------------------------------------------------------------
39 AliRDHFCutsLctopKpi::AliRDHFCutsLctopKpi(const char* name) : 
40 AliRDHFCuts(name),
41 fPidObjprot(0),
42 fPidObjpion(0),
43 fRecoKF(kFALSE)
44 {
45   //
46   // Default Constructor
47   //
48   Int_t nvars=13;
49   SetNVars(nvars);
50   TString varNames[13]={"inv. mass [GeV]",
51                         "pTK [GeV/c]",
52                         "pTP [GeV/c]",
53                         "d0K [cm]   lower limit!",
54                         "d0Pi [cm]  lower limit!",
55                         "dist12 (cm)",
56                         "sigmavert (cm)",
57                         "dist prim-sec (cm)",
58                         "pM=Max{pT1,pT2,pT3} (GeV/c)",
59                         "cosThetaPoint",
60                         "Sum d0^2 (cm^2)",
61                         "dca cut (cm)",
62                         "cut on pTpion [GeV/c]"};
63   Bool_t isUpperCut[13]={kTRUE,
64                          kFALSE,
65                          kFALSE,
66                          kFALSE,
67                          kFALSE,
68                          kFALSE,
69                          kTRUE,
70                          kFALSE,
71                          kFALSE,
72                          kFALSE,
73                          kFALSE,
74                          kTRUE,
75                          kFALSE
76                          };
77   SetVarNames(nvars,varNames,isUpperCut);
78   Bool_t forOpt[13]={kFALSE,
79                      kTRUE,
80                      kTRUE,
81                      kFALSE,
82                      kFALSE,
83                      kFALSE,
84                      kFALSE,
85                      kTRUE,
86                      kFALSE,
87                      kFALSE,
88                      kFALSE,
89                      kFALSE,
90                      kTRUE};
91   SetVarsForOpt(4,forOpt);
92   Float_t limits[2]={0,999999999.};
93   SetPtBins(2,limits);
94 }
95 //--------------------------------------------------------------------------
96 AliRDHFCutsLctopKpi::AliRDHFCutsLctopKpi(const AliRDHFCutsLctopKpi &source) :
97   AliRDHFCuts(source),
98   fPidObjprot(0),
99   fPidObjpion(0),
100   fRecoKF(kFALSE)
101 {
102   //
103   // Copy constructor
104   //
105   if(source.fPidObjprot) SetPidprot(source.fPidObjprot);
106   if(source.fPidObjpion) SetPidpion(source.fPidObjpion);
107 }
108 //--------------------------------------------------------------------------
109 AliRDHFCutsLctopKpi &AliRDHFCutsLctopKpi::operator=(const AliRDHFCutsLctopKpi &source)
110 {
111   //
112   // assignment operator
113   //
114   if(&source == this) return *this;
115
116   AliRDHFCuts::operator=(source);
117   SetPidprot(source.GetPidprot());
118   SetPidpion(source.GetPidpion());
119
120   return *this;
121 }
122 //---------------------------------------------------------------------------
123 AliRDHFCutsLctopKpi::~AliRDHFCutsLctopKpi() {
124  //
125  //  // Default Destructor
126  //   
127  if(fPidObjpion){
128   delete fPidObjpion;
129   fPidObjpion=0;
130  }
131  if(fPidObjprot){
132   delete fPidObjprot;
133   fPidObjprot=0;
134  }
135
136 }
137
138 //---------------------------------------------------------------------------
139 void AliRDHFCutsLctopKpi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters) {
140   // 
141   // Fills in vars the values of the variables 
142   //
143
144   if(nvars!=fnVarsForOpt) {
145     printf("AliRDHFCutsLctopKpi::GetCutsVarsForOpt: wrong number of variables\n");
146     return;
147   }
148
149   AliAODRecoDecayHF3Prong *dd = (AliAODRecoDecayHF3Prong*)d;
150
151     Int_t iter=-1;
152   if(fVarsForOpt[0]){
153     iter++;
154     vars[iter]=dd->InvMassLcpKpi();
155   }
156   if(fVarsForOpt[1]){
157     iter++;
158     for(Int_t iprong=0;iprong<3;iprong++){
159       if(TMath::Abs(pdgdaughters[iprong])==321) {
160         vars[iter]=dd->PtProng(iprong);
161       }
162     }
163   }
164   if(fVarsForOpt[2]){
165     iter++;
166     for(Int_t iprong=0;iprong<3;iprong++){
167       if(TMath::Abs(pdgdaughters[iprong])==2212) {
168         vars[iter]=dd->PtProng(iprong);
169       }
170     }
171   }
172   if(fVarsForOpt[3]){
173     iter++;
174     for(Int_t iprong=0;iprong<3;iprong++){
175       if(TMath::Abs(pdgdaughters[iprong])==2212) {
176         vars[iter]=dd->Getd0Prong(iprong);
177       }
178     }
179   }
180   if(fVarsForOpt[4]){
181     iter++;
182     for(Int_t iprong=0;iprong<3;iprong++){
183       if(TMath::Abs(pdgdaughters[iprong])==211) {
184         vars[iter]=dd->Getd0Prong(iprong);
185       }
186     }
187   }
188   if(fVarsForOpt[5]){
189     iter++;
190     vars[iter]=dd->GetDist12toPrim();
191   }
192   if(fVarsForOpt[6]){
193     iter++;
194     vars[iter]=dd->GetSigmaVert();
195   }
196   if(fVarsForOpt[7]){
197     iter++;
198     vars[iter] = dd->DecayLength();
199   }
200   if(fVarsForOpt[8]){
201     iter++;
202     Float_t ptmax=0;
203     for(Int_t i=0;i<3;i++){
204       if(dd->PtProng(i)>ptmax)ptmax=dd->PtProng(i);
205     }
206     vars[iter]=ptmax;
207   }
208   if(fVarsForOpt[9]){
209     iter++;
210     vars[iter]=dd->CosPointingAngle();
211   }
212   if(fVarsForOpt[10]){
213     iter++;
214     vars[iter]=dd->Getd0Prong(0)*dd->Getd0Prong(0)+dd->Getd0Prong(1)*dd->Getd0Prong(1)+dd->Getd0Prong(2)*dd->Getd0Prong(2);
215   }
216   if(fVarsForOpt[11]){
217     iter++;
218     vars[iter]=dd->GetDCA();
219   }
220   if(fVarsForOpt[12]){
221     iter++;
222     for(Int_t iprong=0;iprong<3;iprong++){
223       if(TMath::Abs(pdgdaughters[iprong])==211) {
224         vars[iter]=dd->PtProng(iprong);
225       }
226     }
227   }
228
229   return;
230 }
231 //---------------------------------------------------------------------------
232 Int_t AliRDHFCutsLctopKpi::IsSelected(TObject* obj,Int_t selectionLevel,AliAODEvent *aod) {
233   //
234   // Apply selection
235   //
236
237   if(!fCutsRD){
238     cout<<"Cut matrice not inizialized. Exit..."<<endl;
239     return 0;
240   }
241   //PrintAll();
242   AliAODRecoDecayHF3Prong* d=(AliAODRecoDecayHF3Prong*)obj;
243
244   if(!d){
245     cout<<"AliAODRecoDecayHF3Prong null"<<endl;
246     return 0;
247   }
248
249
250   if(fKeepSignalMC) if(IsSignalMC(d,aod,4122)) return 3;
251
252   Int_t returnvalue=3;
253   Int_t returnvaluePID=3;
254
255   if(d->Pt()<fMinPtCand) return 0;
256   if(d->Pt()>fMaxPtCand) return 0;
257
258   // selection on candidate
259   if(selectionLevel==AliRDHFCuts::kAll || 
260      selectionLevel==AliRDHFCuts::kCandidate) {
261
262     Double_t pt=d->Pt();
263     
264     Int_t ptbin=PtBin(pt);
265     
266     Double_t mLcpKpi,mLcpiKp;
267     Int_t okLcpKpi=1,okLcpiKp=1;
268
269     Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
270
271     mLcpKpi=d->InvMassLcpKpi();
272     mLcpiKp=d->InvMassLcpiKp();
273
274     if(TMath::Abs(mLcpKpi-mLcPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okLcpKpi = 0;
275     if(TMath::Abs(mLcpiKp-mLcPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) okLcpiKp = 0;
276     if(!okLcpKpi && !okLcpiKp) return 0;
277
278     if(TMath::Abs(d->PtProng(1)) < fCutsRD[GetGlobalIndex(1,ptbin)] || TMath::Abs(d->Getd0Prong(1))<fCutsRD[GetGlobalIndex(3,ptbin)]) return 0;//Kaon
279     if((TMath::Abs(d->PtProng(0)) < fCutsRD[GetGlobalIndex(2,ptbin)]) || (TMath::Abs(d->PtProng(2)) < fCutsRD[GetGlobalIndex(12,ptbin)])) okLcpKpi=0;
280     if((TMath::Abs(d->PtProng(2)) < fCutsRD[GetGlobalIndex(2,ptbin)]) || (TMath::Abs(d->PtProng(0)) < fCutsRD[GetGlobalIndex(12,ptbin)]))okLcpiKp=0;
281     if(!okLcpKpi && !okLcpiKp) return 0;
282
283     
284     if(fRecoKF){
285      Int_t valueTmp=3;
286      if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
287      if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
288      if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
289
290      Int_t valueTotTmp=CombinePIDCuts(valueTmp,returnvaluePID);
291      Int_t pdgs[3]={2212,321,211};
292      if(valueTotTmp>=2) {
293       pdgs[0]=211;
294       pdgs[2]=2212;
295      }
296      if(!d->GetOwnPrimaryVtx()){
297       AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex(); 
298       d->SetOwnPrimaryVtx(vtx1);
299      }
300      Double_t field=aod->GetMagneticField(); 
301      ReconstructKF(d,pdgs,field);
302     }
303     //2track cuts
304     if(d->GetDist12toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]|| d->GetDist23toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]) return 0;
305     if(d->GetDist12toPrim()>1.) return 0;
306     if(d->GetDist23toPrim()>1.) return 0;
307     if(d->Getd0Prong(0)*d->Getd0Prong(1)<0. && d->Getd0Prong(2)*d->Getd0Prong(1)<0.) return 0;
308     
309     //sec vert
310     if(d->GetSigmaVert()>fCutsRD[GetGlobalIndex(6,ptbin)]) return 0;
311
312     if(d->DecayLength()<fCutsRD[GetGlobalIndex(7,ptbin)]) return 0;
313     if(d->DecayLength()>0.5) return 0;
314     
315     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;
316     if(d->CosPointingAngle()< fCutsRD[GetGlobalIndex(9,ptbin)]) return 0;
317     Double_t sum2=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
318     if(sum2<fCutsRD[GetGlobalIndex(10,ptbin)]) return 0;
319     
320     //DCA
321     for(Int_t i=0;i<3;i++) if(d->GetDCA(i)>fCutsRD[GetGlobalIndex(11,ptbin)]) return 0;
322
323
324     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
325     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
326     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
327    
328   }
329
330   if(fUsePID || selectionLevel==AliRDHFCuts::kPID) returnvaluePID = IsSelectedPID(d);
331   //  if(fUsePID || selectionLevel==AliRDHFCuts::kPID) returnvaluePID = IsSelectedCombinedPID(d);   // to test!!
332   if(returnvaluePID==0) return 0;
333
334   // selection on daughter tracks 
335   if(selectionLevel==AliRDHFCuts::kAll || 
336      selectionLevel==AliRDHFCuts::kTracks) {
337     if(!AreDaughtersSelected(d)) return 0;
338   }
339
340
341   Int_t returnvalueTot=CombinePIDCuts(returnvalue,returnvaluePID);
342   return returnvalueTot;
343 }
344 //---------------------------------------------------------------------------
345 Int_t AliRDHFCutsLctopKpi::IsSelectedPID(AliAODRecoDecayHF* obj) {
346
347
348     if(!obj) {return 3;}
349     Int_t okLcpKpi=0,okLcpiKp=0;
350     Int_t returnvalue=0;
351     Bool_t isPeriodd=fPidHF->GetOnePad();
352     Bool_t isMC=fPidHF->GetMC();
353     Bool_t ispion0=kTRUE,ispion2=kTRUE;
354     Bool_t isproton0=kFALSE,isproton2=kFALSE;
355     Bool_t iskaon1=kFALSE;
356     if(isPeriodd) {
357      fPidObjprot->SetOnePad(kTRUE);
358      fPidObjpion->SetOnePad(kTRUE);
359     }
360     if(isMC) {
361      fPidObjprot->SetMC(kTRUE);
362      fPidObjpion->SetMC(kTRUE);
363     }
364
365     for(Int_t i=0;i<3;i++){
366      AliAODTrack *track=(AliAODTrack*)obj->GetDaughter(i);
367      if(!track) return 0;
368      // identify kaon
369      if(i==1) {
370       Int_t isKaon=fPidHF->MakeRawPid(track,3); 
371       if(isKaon>=1) {
372        iskaon1=kTRUE;
373       if(fPidHF->MakeRawPid(track,2)>=1) iskaon1=kFALSE;
374       }
375       if(!iskaon1) return 0;
376      
377      }else{
378      //pion or proton
379       
380      Int_t isProton=fPidObjprot->MakeRawPid(track,4);
381      if(isProton>=1){
382       if(fPidHF->MakeRawPid(track,2)>=1) isProton=-1;
383       if(fPidHF->MakeRawPid(track,3)>=1) isProton=-1;
384      }
385
386      Int_t isPion=fPidObjpion->MakeRawPid(track,2);
387      if(fPidHF->MakeRawPid(track,3)>=1) isPion=-1;
388      if(fPidObjprot->MakeRawPid(track,4)>=1) isPion=-1;
389
390
391      if(i==0) {
392       if(isPion<0) ispion0=kFALSE;
393       if(isProton>=1) isproton0=kTRUE;
394
395      }
396       if(!ispion0 && !isproton0) return 0;
397      if(i==2) {
398       if(isPion<0) ispion2=kFALSE;
399       if(isProton>=1) isproton2=kTRUE;
400      }
401
402     }
403    }
404
405     if(ispion2 && isproton0 && iskaon1) okLcpKpi=1;
406     if(ispion0 && isproton2 && iskaon1) okLcpiKp=1;
407     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
408     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
409     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
410
411  return returnvalue;
412 }
413 //---------------------------------------------------------------------------
414 Int_t AliRDHFCutsLctopKpi::IsSelectedCombinedPID(AliAODRecoDecayHF* obj) {
415
416   //  Printf(" -------- IsSelectedCombinedPID --------------");
417
418     if(!obj) {return 3;}
419     Int_t okLcpKpi=0,okLcpiKp=0;
420     Int_t returnvalue=0;
421     Bool_t isPeriodd=fPidHF->GetOnePad();
422     Bool_t isMC=fPidHF->GetMC();
423     Bool_t isKaon = kFALSE;
424     Bool_t isPion = kFALSE;
425     Bool_t isProton = kFALSE;
426
427     if(isPeriodd) {
428             fPidObjprot->SetOnePad(kTRUE);
429             fPidObjpion->SetOnePad(kTRUE);
430     }
431     if(isMC) {
432             fPidObjprot->SetMC(kTRUE);
433             fPidObjpion->SetMC(kTRUE);
434     }
435
436     Double_t probComb[AliPID::kSPECIES]={0.};  // array to store the info for the combined ITS|TPC|TOF probabilities
437     fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetITS|AliPIDResponse::kDetTOF|AliPIDResponse::kDetTPC);  // the mask could become a member of the cut object
438
439     for(Int_t i=0;i<3;i++){
440             AliAODTrack *track=(AliAODTrack*)obj->GetDaughter(i);
441             if(!track) return 0;
442             // identify kaon
443             UInt_t detUsed = fPidHF->GetPidCombined()->ComputeProbabilities(track, fPidHF->GetPidResponse(), probComb); // for the moment we don't check detUsed...
444             //      Printf("[%d] %x %f %f %f %f %f",i,detUsed,probComb[0],probComb[1],probComb[2],probComb[3],probComb[4]);
445             if(i==1) {
446                     if(TMath::MaxElement(AliPID::kSPECIES,probComb) == probComb[3]) {  // the probability to be a Kaon is the highest
447                       isKaon=kTRUE;
448                       //                      if ( probComb[3] > 0.8 ) isKaon=kTRUE;
449                       //                      else return 0;
450                     }
451                     else return 0; // prong at position 1 is not a Kaon, returning 0                
452             }
453             else {
454                     //pion or proton
455                     
456                     if(TMath::MaxElement(AliPID::kSPECIES,probComb) == probComb[4]) {  // the probability to be a proton is the highest
457                             isProton=kTRUE;
458                             if (isPion) okLcpiKp = 1;  // the pion was already identified, so here we must be at i == 2 --> Lc --> pi K p (K already found)
459                     }
460                     if(TMath::MaxElement(AliPID::kSPECIES,probComb) == probComb[2]) {  // the probability to be a pion is the highest
461                             isPion=kTRUE;
462                             if (isProton) okLcpKpi = 1;  // the proton was already identified, so here we must be at i == 2 --> Lc --> p K pi (K already found)
463                     }
464                     
465             }
466     }
467     
468     if(okLcpKpi) returnvalue=1; //cuts passed as Lc->pKpi
469     if(okLcpiKp) returnvalue=2; //cuts passed as Lc->piKp
470     if(okLcpKpi && okLcpiKp) returnvalue=3; //cuts passed as both pKpi and piKp
471     
472     return returnvalue;
473 }
474 //-----------------------
475 Int_t AliRDHFCutsLctopKpi::CombinePIDCuts(Int_t returnvalue, Int_t returnvaluePID) const {
476
477  Int_t returnvalueTot=0;
478  Int_t okLcpKpi=0,okLcpiKp=0;
479  if(returnvaluePID==1){
480    if(returnvalue==1 || returnvalue==3) okLcpKpi=1;
481  }
482  if(returnvaluePID==2){
483    if(returnvalue>=2) okLcpiKp=1;
484  }
485  if(returnvaluePID==3 && returnvalue>0){
486   if(returnvalue==1 || returnvalue==3) okLcpKpi=1;
487   if(returnvalue>=2) okLcpiKp=1;
488  } 
489
490  if(okLcpKpi) returnvalueTot=1; //cuts passed as Lc->pKpi
491  if(okLcpiKp) returnvalueTot=2; //cuts passed as Lc->piKp
492  if(okLcpKpi && okLcpiKp) returnvalueTot=3; //cuts passed as both pKpi and piKp
493  return returnvalueTot;
494 }
495 //----------------------------------
496 void AliRDHFCutsLctopKpi::SetStandardCutsPP2010() {
497
498  SetName("LctopKpiProdCuts");
499  SetTitle("Production cuts for Lc analysis");
500
501  AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
502  esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
503  esdTrackCuts->SetRequireTPCRefit(kTRUE);
504  esdTrackCuts->SetMinNClustersTPC(70);
505  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
506                                           AliESDtrackCuts::kAny);
507  esdTrackCuts->SetRequireITSRefit(kTRUE);
508  esdTrackCuts->SetMinNClustersITS(4);
509  esdTrackCuts->SetMinDCAToVertexXY(0.);
510  esdTrackCuts->SetEtaRange(-0.8,0.8);
511  esdTrackCuts->SetPtRange(0.3,1.e10);
512  AddTrackCuts(esdTrackCuts);
513
514  const Int_t nptbins=4;
515  const Int_t nvars=13;
516  Float_t* ptbins;
517  ptbins=new Float_t[nptbins+1];
518  
519  ptbins[0]=0.;
520  ptbins[1]=2.;
521  ptbins[2]=3.;
522  ptbins[3]=4.;
523  ptbins[4]=9999.;
524
525  SetGlobalIndex(nvars,nptbins);
526  SetPtBins(nptbins+1,ptbins);
527
528  Float_t** prodcutsval;
529  prodcutsval=new Float_t*[nvars];
530  for(Int_t iv=0;iv<nvars;iv++){
531   prodcutsval[iv]=new Float_t[nptbins];
532  }
533
534  for(Int_t ipt=0;ipt<nptbins;ipt++){
535   prodcutsval[0][ipt]=0.18;
536   prodcutsval[1][ipt]=0.4;
537   prodcutsval[2][ipt]=0.5;
538   prodcutsval[3][ipt]=0.;
539   prodcutsval[4][ipt]=0.;
540   prodcutsval[5][ipt]=0.01;
541   prodcutsval[6][ipt]=0.06;
542   prodcutsval[7][ipt]=0.005;
543   prodcutsval[8][ipt]=0.;
544   prodcutsval[9][ipt]=0.;
545   prodcutsval[10][ipt]=0.;
546   prodcutsval[11][ipt]=0.05;
547   prodcutsval[12][ipt]=0.4;
548  }
549  SetCuts(nvars,nptbins,prodcutsval);
550
551  AliAODPidHF* pidObjK=new AliAODPidHF();
552  Double_t sigmasK[5]={3.,1.,1.,3.,2.};
553  pidObjK->SetSigma(sigmasK);
554  pidObjK->SetAsym(kTRUE);
555  pidObjK->SetMatch(1);
556  pidObjK->SetTPC(kTRUE);
557  pidObjK->SetTOF(kTRUE);
558  pidObjK->SetITS(kTRUE);
559  Double_t plimK[2]={0.5,0.8};
560  pidObjK->SetPLimit(plimK,2);
561  pidObjK->SetTOFdecide(kTRUE);
562
563  SetPidHF(pidObjK);
564
565  AliAODPidHF* pidObjpi=new AliAODPidHF();
566  pidObjpi->SetTPC(kTRUE);
567  Double_t sigmaspi[5]={3.,0.,0.,0.,0.};
568  pidObjpi->SetSigma(sigmaspi);
569  pidObjpi->SetTOFdecide(kTRUE);
570  SetPidpion(pidObjpi);
571
572  AliAODPidHF* pidObjp=new AliAODPidHF();
573  Double_t sigmasp[5]={3.,1.,1.,3.,2.};
574  pidObjp->SetSigma(sigmasp);
575  pidObjp->SetAsym(kTRUE);
576  pidObjp->SetMatch(1);
577  pidObjp->SetTPC(kTRUE);
578  pidObjp->SetTOF(kTRUE);
579  pidObjp->SetITS(kTRUE);
580  Double_t plimp[2]={1.,2.};
581  pidObjp->SetPLimit(plimp,2);
582  pidObjp->SetTOFdecide(kTRUE);
583
584  SetPidprot(pidObjp);
585
586  SetUsePID(kTRUE);
587
588  PrintAll();
589
590  for(Int_t iiv=0;iiv<nvars;iiv++){
591   delete [] prodcutsval[iiv];
592  }
593  delete [] prodcutsval;
594  prodcutsval=NULL;
595  delete [] ptbins;
596  ptbins=NULL;
597
598  delete pidObjp;
599  pidObjp=NULL;
600
601  return;
602 }
603 //------------------
604 void AliRDHFCutsLctopKpi::SetStandardCutsPbPb2010() {
605
606  SetName("LctopKpiProdCuts");
607  SetTitle("Production cuts for Lc analysis");
608
609  AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
610
611  esdTrackCuts->SetRequireTPCRefit(kTRUE);
612  esdTrackCuts->SetMinNClustersTPC(70);
613  esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
614                                           AliESDtrackCuts::kAny);
615  esdTrackCuts->SetRequireITSRefit(kTRUE);
616  esdTrackCuts->SetMinNClustersITS(4);
617  esdTrackCuts->SetMinDCAToVertexXYPtDep("0.0100*TMath::Max(0.,(1-TMath::Floor(TMath::Abs(pt)/2.)))");
618  esdTrackCuts->SetEtaRange(-0.8,0.8);
619  esdTrackCuts->SetMaxDCAToVertexXY(1.);
620  esdTrackCuts->SetMaxDCAToVertexZ(1.);
621  esdTrackCuts->SetPtRange(0.8,1.e10);
622  AddTrackCuts(esdTrackCuts);
623
624  const Int_t nptbins=4;
625  const Int_t nvars=13;
626  Float_t* ptbins;
627  ptbins=new Float_t[nptbins+1];
628  
629  ptbins[0]=0.;
630  ptbins[1]=2.;
631  ptbins[2]=3.;
632  ptbins[3]=4.;
633  ptbins[4]=9999.;
634
635  SetGlobalIndex(nvars,nptbins);
636  SetPtBins(nptbins+1,ptbins);
637
638  Float_t** prodcutsval;
639  prodcutsval=new Float_t*[nvars];
640  for(Int_t iv=0;iv<nvars;iv++){
641   prodcutsval[iv]=new Float_t[nptbins];
642  }
643
644  for(Int_t ipt=0;ipt<nptbins;ipt++){
645   prodcutsval[0][ipt]=0.13;
646   prodcutsval[1][ipt]=0.5;
647   prodcutsval[2][ipt]=0.6;
648   prodcutsval[3][ipt]=0.;
649   prodcutsval[4][ipt]=0.;
650   prodcutsval[5][ipt]=0.01;
651   prodcutsval[6][ipt]=0.04;
652   prodcutsval[7][ipt]=0.006;
653   prodcutsval[8][ipt]=0.8;
654   prodcutsval[9][ipt]=0.3;
655   prodcutsval[10][ipt]=0.;
656   prodcutsval[11][ipt]=0.05;
657   prodcutsval[12][ipt]=0.4;
658  }
659  SetCuts(nvars,nptbins,prodcutsval);
660
661  AliAODPidHF* pidObjK=new AliAODPidHF();
662  Double_t sigmasK[5]={3.,1.,1.,3.,2.};
663  pidObjK->SetSigma(sigmasK);
664  pidObjK->SetAsym(kTRUE);
665  pidObjK->SetMatch(1);
666  pidObjK->SetTPC(kTRUE);
667  pidObjK->SetTOF(kTRUE);
668  pidObjK->SetITS(kTRUE);
669  Double_t plimK[2]={0.5,0.8};
670  pidObjK->SetPLimit(plimK,2);
671
672  SetPidHF(pidObjK);
673
674  AliAODPidHF* pidObjpi=new AliAODPidHF();
675  pidObjpi->SetTPC(kTRUE);
676  Double_t sigmaspi[5]={3.,0.,0.,0.,0.};
677  pidObjpi->SetSigma(sigmaspi);
678  SetPidpion(pidObjpi);
679
680  AliAODPidHF* pidObjp=new AliAODPidHF();
681  Double_t sigmasp[5]={3.,1.,1.,3.,2.};
682  pidObjp->SetSigma(sigmasp);
683  pidObjp->SetAsym(kTRUE);
684  pidObjp->SetMatch(1);
685  pidObjp->SetTPC(kTRUE);
686  pidObjp->SetTOF(kTRUE);
687  pidObjp->SetITS(kTRUE);
688  Double_t plimp[2]={1.,2.};
689  pidObjp->SetPLimit(plimp,2);
690
691  SetPidprot(pidObjp);
692
693  SetUsePID(kTRUE);
694
695  PrintAll();
696
697  for(Int_t iiv=0;iiv<nvars;iiv++){
698   delete [] prodcutsval[iiv];
699  }
700  delete [] prodcutsval;
701  prodcutsval=NULL;
702  delete [] ptbins;
703  ptbins=NULL;
704
705  delete pidObjp;
706  pidObjp=NULL;
707
708  return;
709 }
710 //------------------
711 Bool_t AliRDHFCutsLctopKpi::ReconstructKF(AliAODRecoDecayHF3Prong *d,Int_t *pdgs,Double_t field) const{
712
713  Int_t nprongs=d->GetNProngs();
714  Int_t iprongs[nprongs];
715  for(Int_t i=0;i<nprongs;i++) iprongs[i]=i;
716
717  Double_t mass[2]={0.,0.};
718
719  AliKFParticle *decay=d->ApplyVertexingKF(iprongs,nprongs,pdgs,kTRUE,field,mass);
720  if(!decay) return kTRUE;
721  AliESDVertex *vertexESD = new AliESDVertex(decay->Parameters(),
722                                             decay->CovarianceMatrix(),
723                                             decay->GetChi2(),
724                                             nprongs);
725  Double_t pos[3],cov[6],chi2perNDF;
726  vertexESD->GetXYZ(pos);
727  vertexESD->GetCovMatrix(cov);
728  chi2perNDF = vertexESD->GetChi2toNDF();
729  delete vertexESD; vertexESD=NULL;
730  AliAODVertex *vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
731  d->SetSecondaryVtx(vertexAOD);
732  return kTRUE;
733 }
734