]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/AliRDHFCutsDplustoKpipi.cxx
Updated PID information in D+ ntuple (Giacomo)
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliRDHFCutsDplustoKpipi.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 D+->Kpipi
21 //
22 // Author: R. Bala, bala@to.infn.it
23 //         G. Ortona, ortona@to.infn.it
24 /////////////////////////////////////////////////////////////
25
26 #include <TDatabasePDG.h>
27 #include <Riostream.h>
28
29 #include "AliAODPidHF.h"
30 #include "AliRDHFCutsDplustoKpipi.h"
31 #include "AliAODRecoDecayHF3Prong.h"
32 #include "AliAODTrack.h"
33 #include "AliESDtrack.h"
34
35
36 ClassImp(AliRDHFCutsDplustoKpipi)
37
38 //--------------------------------------------------------------------------
39 AliRDHFCutsDplustoKpipi::AliRDHFCutsDplustoKpipi(const char* name) : 
40 AliRDHFCuts(name),
41   fUseStrongPid(0),
42   fMaxPtStrongPid(0.),
43   fMaxPStrongPidK(0.),
44   fMaxPStrongPidpi(0.),
45   fUseImpParProdCorrCut(kFALSE)
46 {
47   //
48   // Default Constructor
49   //
50   Int_t nvars=14;
51   SetNVars(nvars);
52   TString varNames[14]={"inv. mass [GeV]",
53                         "pTK [GeV/c]",
54                         "pTPi [GeV/c]",
55                         "d0K [cm]   lower limit!",
56                         "d0Pi [cm]  lower limit!",
57                         "dist12 (cm)",
58                         "sigmavert (cm)",
59                         "dist prim-sec (cm)",
60                         "pM=Max{pT1,pT2,pT3} (GeV/c)",
61                         "cosThetaPoint",
62                         "Sum d0^2 (cm^2)",
63                         "dca cut (cm)",
64                         "dec len XY (cm)",
65                         "cosThetaPointXY"};
66   Bool_t isUpperCut[14]={kTRUE,
67                          kFALSE,
68                          kFALSE,
69                          kFALSE,
70                          kFALSE,
71                          kFALSE,
72                          kTRUE,
73                          kFALSE,
74                          kFALSE,
75                          kFALSE,
76                          kFALSE,
77                          kTRUE,
78                          kFALSE,
79                          kFALSE};
80   SetVarNames(nvars,varNames,isUpperCut);
81   Bool_t forOpt[14]={kFALSE,
82                      kFALSE,
83                      kFALSE,
84                      kFALSE,
85                      kFALSE,
86                      kFALSE,
87                      kTRUE,
88                      kTRUE,
89                      kTRUE,
90                      kTRUE,
91                      kTRUE,
92                      kFALSE,
93                      kTRUE,
94                      kTRUE};
95   SetVarsForOpt(7,forOpt);
96   Float_t limits[2]={0,999999999.};
97   SetPtBins(2,limits);
98   if(fPidHF)delete fPidHF;
99   fPidHF=new AliAODPidHF();
100   Double_t plim[2]={0.6,0.8};
101   Double_t nsigma[5]={2.,1.,2.,3.,0.};
102   
103   fPidHF->SetPLimit(plim);
104   fPidHF->SetAsym(kTRUE);
105   fPidHF->SetSigma(nsigma);
106   fPidHF->SetMatch(1);
107   fPidHF->SetTPC(1);
108   fPidHF->SetTOF(1);
109   fPidHF->SetITS(0);
110   fPidHF->SetTRD(0);
111   fPidHF->SetCompat(kTRUE);
112
113   
114 }
115
116
117
118
119
120
121
122
123 //--------------------------------------------------------------------------
124 AliRDHFCutsDplustoKpipi::AliRDHFCutsDplustoKpipi(const AliRDHFCutsDplustoKpipi &source) :
125   AliRDHFCuts(source),
126   fUseStrongPid(source.fUseStrongPid),
127   fMaxPtStrongPid(source.fMaxPtStrongPid),
128   fMaxPStrongPidK(source.fMaxPStrongPidK),
129   fMaxPStrongPidpi(source.fMaxPStrongPidpi),
130   fUseImpParProdCorrCut(source.fUseImpParProdCorrCut)
131 {
132   //
133   // Copy constructor
134   //
135
136 }
137 //--------------------------------------------------------------------------
138 AliRDHFCutsDplustoKpipi &AliRDHFCutsDplustoKpipi::operator=(const AliRDHFCutsDplustoKpipi &source)
139 {
140   //
141   // assignment operator
142   //
143   if(&source == this) return *this;
144
145   AliRDHFCuts::operator=(source);
146
147   fUseStrongPid=source.fUseStrongPid;
148   fMaxPtStrongPid=source.fMaxPtStrongPid;
149   fMaxPStrongPidK=source.fMaxPStrongPidK;
150   fMaxPStrongPidpi=source.fMaxPStrongPidpi;
151   fUseImpParProdCorrCut=source.fUseImpParProdCorrCut;
152
153   return *this;
154 }
155 //
156
157
158 //---------------------------------------------------------------------------
159 void AliRDHFCutsDplustoKpipi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters,AliAODEvent *aod) {
160   // 
161   // Fills in vars the values of the variables 
162   //
163
164
165   if(nvars!=fnVarsForOpt) {
166     printf("AliRDHFCutsDplustoKpipi::GetCutsVarsForOpt: wrong number of variables\n");
167     return;
168   }
169
170   AliAODRecoDecayHF3Prong *dd = (AliAODRecoDecayHF3Prong*)d;
171  
172   //recalculate vertex w/o daughters
173   Bool_t cleanvtx=kFALSE;
174   AliAODVertex *origownvtx=0x0;
175   if(fRemoveDaughtersFromPrimary) {
176     if(dd->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*dd->GetOwnPrimaryVtx());
177     cleanvtx=kTRUE;
178     if(!RecalcOwnPrimaryVtx(dd,aod)) {
179       CleanOwnPrimaryVtx(dd,aod,origownvtx);
180       cleanvtx=kFALSE;
181     }
182   }
183
184   Int_t iter=-1;
185   if(fVarsForOpt[0]){
186     iter++;
187     vars[iter]=dd->InvMassDplus();
188   }
189   if(fVarsForOpt[1]){
190     iter++;
191     for(Int_t iprong=0;iprong<3;iprong++){
192       if(TMath::Abs(pdgdaughters[iprong])==321) {
193         vars[iter]=dd->PtProng(iprong);
194       }
195     }
196   }
197   if(fVarsForOpt[2]){
198     iter++;
199     Float_t minPtDau=1000000.0;
200     for(Int_t iprong=0;iprong<3;iprong++){
201       if(TMath::Abs(pdgdaughters[iprong])==211) {
202         if(dd->PtProng(iprong)<minPtDau){
203           minPtDau=dd->PtProng(iprong);
204         }
205       }
206     }
207     vars[iter]=minPtDau;
208   }
209   if(fVarsForOpt[3]){
210     iter++;
211     for(Int_t iprong=0;iprong<3;iprong++){
212       if(TMath::Abs(pdgdaughters[iprong])==321) {
213         vars[iter]=dd->Getd0Prong(iprong);
214       }
215     }
216   }
217   if(fVarsForOpt[4]){
218     iter++;
219     Float_t minImpParDau=1000000.0;
220     for(Int_t iprong=0;iprong<3;iprong++){
221       if(TMath::Abs(pdgdaughters[iprong])==211) {
222         if(dd->Getd0Prong(iprong)<minImpParDau){
223           minImpParDau=dd->Getd0Prong(iprong);
224         }
225       }
226     }
227    vars[iter]=minImpParDau;
228   }
229   if(fVarsForOpt[5]){
230     iter++;
231     Float_t dist12 = dd->GetDist12toPrim();
232     Float_t dist23 = dd->GetDist23toPrim();
233     if(dist12<dist23)vars[iter]=dist12;
234     else vars[iter]=dist23;
235   }
236   if(fVarsForOpt[6]){
237     iter++;
238     vars[iter]=dd->GetSigmaVert(aod);
239   }
240   if(fVarsForOpt[7]){
241     iter++;
242     vars[iter] = dd->DecayLength();
243   }
244   if(fVarsForOpt[8]){
245     iter++;
246     Float_t ptmax=0;
247     for(Int_t i=0;i<3;i++){
248       if(dd->PtProng(i)>ptmax)ptmax=dd->PtProng(i);
249     }
250     vars[iter]=ptmax;
251   }
252   if(fVarsForOpt[9]){
253     iter++;
254     vars[iter]=dd->CosPointingAngle();
255   }
256   if(fVarsForOpt[10]){
257     iter++;
258     vars[iter]=dd->Getd0Prong(0)*dd->Getd0Prong(0)+dd->Getd0Prong(1)*dd->Getd0Prong(1)+dd->Getd0Prong(2)*dd->Getd0Prong(2);
259   }
260   if(fVarsForOpt[11]){
261     iter++;
262     Float_t maxDCA=0;
263     for(Int_t iprong=0;iprong<3;iprong++){
264       if(dd->GetDCA(iprong)<maxDCA){
265         maxDCA=dd->GetDCA(iprong);
266       }
267     }
268     vars[iter]=maxDCA;
269   }
270   if(fVarsForOpt[12]){
271     iter++;
272     vars[iter]=dd->NormalizedDecayLengthXY()*dd->P()/dd->Pt();
273   }
274   if(fVarsForOpt[13]){
275     iter++;
276     vars[iter]=dd->CosPointingAngleXY();
277   }
278
279   if(cleanvtx)CleanOwnPrimaryVtx(dd,aod,origownvtx);
280
281   return;
282 }
283 //---------------------------------------------------------------------------
284 Bool_t AliRDHFCutsDplustoKpipi::IsInFiducialAcceptance(Double_t pt, Double_t y) const
285 {
286   //
287   // Checking if Dplus is in fiducial acceptance region 
288   //
289
290   if(pt > 5.) {
291     // applying cut for pt > 5 GeV
292     AliDebug(2,Form("pt of D+ = %f (> 5), cutting at |y| < 0.8",pt)); 
293     if (TMath::Abs(y) > 0.8) return kFALSE;
294     
295   } else {
296     // appliying smooth cut for pt < 5 GeV
297     Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5; 
298     Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;         
299     AliDebug(2,Form("pt of D+ = %f (< 5), cutting  according to the fiducial zone [%f, %f]\n",pt,minFiducialY,maxFiducialY)); 
300     if (y < minFiducialY || y > maxFiducialY) return kFALSE;    
301   }
302
303   return kTRUE;
304 }
305
306 //---------------------------------------------------------------------------
307 Int_t AliRDHFCutsDplustoKpipi::GetPIDBitMask(AliAODRecoDecayHF *rd)
308 {
309   if(!fUsePID || !rd) return -1;
310   //if(fUsePID)printf("i am inside the pid \n");
311   Int_t mask=0;
312   Int_t sign=rd->GetCharge(); 
313   for(Int_t daught=0;daught<3;daught++){
314     AliAODTrack *track=(AliAODTrack*)rd->GetDaughter(daught);
315
316     if(sign==track->Charge()){//pions
317       Int_t isPion=fPidHF->MakeRawPid(track,AliPID::kPion);
318       if(isPion==0)mask+=1;
319       else if(isPion>0)mask+=3;
320       mask=mask<<2;
321     }
322     else{//kaons
323       Int_t isKaon=fPidHF->MakeRawPid(track,AliPID::kKaon);
324       if(isKaon==0)mask+=1;
325       else if(isKaon>0)mask+=3;
326       mask=mask<<2;
327     }
328   }
329   mask=mask>>2;
330   return mask;   
331 }
332 //---------------------------------------------------------------------------
333 Int_t AliRDHFCutsDplustoKpipi::IsSelectedPID(AliAODRecoDecayHF *rd)
334 {
335   //
336   // PID selection, returns 3 if accepted, 0 if not accepted
337   // 
338   if(!fUsePID || !rd) return 3;
339   //if(fUsePID)printf("i am inside the pid \n");
340   Int_t nkaons=0;
341   Int_t nNotKaons=0;
342   Int_t sign= rd->GetCharge(); 
343   for(Int_t daught=0;daught<3;daught++){
344     AliAODTrack *track=(AliAODTrack*)rd->GetDaughter(daught);
345     Int_t isPion=fPidHF->MakeRawPid(track,AliPID::kPion);
346     Int_t isKaon=fPidHF->MakeRawPid(track,AliPID::kKaon);
347     Int_t isProton=fPidHF->MakeRawPid(track,AliPID::kProton);
348     
349     if(isProton>0 &&  isKaon<0  && isPion<0) return 0;
350     if(isKaon>0 && isPion<0) nkaons++;
351     if(isKaon<0) nNotKaons++;  
352     if(sign==track->Charge()){//pions
353       if(isPion<0)return 0;
354       if(rd->Pt()<fMaxPtStrongPid && isPion<=0 && fUseStrongPid&2 && track->P()<fMaxPStrongPidpi)return 0;
355     }
356     else{//kaons
357       if(isKaon<0)return 0;
358         if(rd->Pt()<fMaxPtStrongPid && isKaon<=0 && fUseStrongPid&1&& track->P()<fMaxPStrongPidK)return 0;
359     }
360   }
361   
362   if(nkaons>1)return 0;
363   if(nNotKaons==3)return 0;
364   
365   return 3;   
366 }
367
368
369 //---------------------------------------------------------------------------
370 Int_t AliRDHFCutsDplustoKpipi::IsSelected(TObject* obj,Int_t selectionLevel, AliAODEvent* aod) {
371   //
372   // Apply selection, returns 3 if accepted, 0 if not accepted
373   //
374
375
376   fIsSelectedCuts=0;
377   fIsSelectedPID=0;
378
379   if(!fCutsRD){
380     cout<<"Cut matrix not inizialized. Exit..."<<endl;
381     return 0;
382   }
383   //PrintAll();
384   AliAODRecoDecayHF3Prong* d=(AliAODRecoDecayHF3Prong*)obj; 
385
386   
387   if(!d){
388     cout<<"AliAODRecoDecayHF3Prong null"<<endl;
389     return 0;
390   }
391
392   if(fKeepSignalMC) if(IsSignalMC(d,aod,411)) return 3;
393
394   // PID selection
395   Int_t returnvaluePID=3;
396   Int_t returnvalueCuts=3;
397
398   Double_t pt=d->Pt();
399   if(pt<fMinPtCand) return 0;
400   if(pt>fMaxPtCand) return 0;
401
402   if(d->HasBadDaughters()) return 0;
403   
404   // selection on candidate
405   if(selectionLevel==AliRDHFCuts::kAll || 
406      selectionLevel==AliRDHFCuts::kCandidate) {
407     
408     //recalculate vertex w/o daughters
409     AliAODVertex *origownvtx=0x0;
410     if(fRemoveDaughtersFromPrimary) {
411       if(d->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*d->GetOwnPrimaryVtx());
412       if(!RecalcOwnPrimaryVtx(d,aod)) {
413         CleanOwnPrimaryVtx(d,aod,origownvtx);
414         return 0;
415       }
416     }
417
418     Int_t ptbin=PtBin(pt);
419     if (ptbin==-1) {
420       CleanOwnPrimaryVtx(d,aod,origownvtx);
421       return 0;
422     }
423     
424     Double_t mDplusPDG = TDatabasePDG::Instance()->GetParticle(411)->Mass();
425     Double_t mDplus=d->InvMassDplus();
426     if(TMath::Abs(mDplus-mDplusPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
427
428     //2track cuts
429     if(d->GetDist12toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]|| d->GetDist23toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
430
431     Double_t sum2=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
432     if(sum2<fCutsRD[GetGlobalIndex(10,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
433
434     if(fUseImpParProdCorrCut){
435       if(d->Getd0Prong(0)*d->Getd0Prong(1)<0. && d->Getd0Prong(2)*d->Getd0Prong(1)<0.) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
436     }
437
438
439     //DCA
440     for(Int_t i=0;i<3;i++) if(d->GetDCA(i)>fCutsRD[GetGlobalIndex(11,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
441
442     if(d->Pt2Prong(1) < fCutsRD[GetGlobalIndex(1,ptbin)]*fCutsRD[GetGlobalIndex(1,ptbin)] || TMath::Abs(d->Getd0Prong(1))<fCutsRD[GetGlobalIndex(3,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}//Kaon
443
444     if(d->Pt2Prong(0) < fCutsRD[GetGlobalIndex(2,ptbin)]*fCutsRD[GetGlobalIndex(2,ptbin)] || TMath::Abs(d->Getd0Prong(0))<fCutsRD[GetGlobalIndex(4,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}//Pion1
445
446     if(d->Pt2Prong(2) < fCutsRD[GetGlobalIndex(2,ptbin)]*fCutsRD[GetGlobalIndex(2,ptbin)] || TMath::Abs(d->Getd0Prong(2))<fCutsRD[GetGlobalIndex(4,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}//Pion2
447     
448     if(d->Pt2Prong(0)<fCutsRD[GetGlobalIndex(8,ptbin)]*fCutsRD[GetGlobalIndex(8,ptbin)] && d->Pt2Prong(1)<fCutsRD[GetGlobalIndex(8,ptbin)]*fCutsRD[GetGlobalIndex(8,ptbin)] && d->Pt2Prong(2)<fCutsRD[GetGlobalIndex(8,ptbin)]*fCutsRD[GetGlobalIndex(8,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
449
450     if(d->DecayLength2()<fCutsRD[GetGlobalIndex(7,ptbin)]*fCutsRD[GetGlobalIndex(7,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
451
452     if(d->CosPointingAngle()< fCutsRD[GetGlobalIndex(9,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
453
454     if(d->NormalizedDecayLengthXY()*d->P()/pt<fCutsRD[GetGlobalIndex(12,ptbin)]){CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
455
456     if(d->CosPointingAngleXY()<fCutsRD[GetGlobalIndex(13,ptbin)]){CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
457
458     //sec vert
459     Double_t sigmavert=d->GetSigmaVert(aod);
460     if(sigmavert>fCutsRD[GetGlobalIndex(6,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
461
462     // unset recalculated primary vertex when not needed any more
463     CleanOwnPrimaryVtx(d,aod,origownvtx);
464     
465     fIsSelectedCuts=returnvalueCuts;
466
467     //if(!returnvalueCuts) return 0; // returnvalueCuts cannot be 0 here
468   }
469   
470   if(selectionLevel==AliRDHFCuts::kAll || 
471      selectionLevel==AliRDHFCuts::kCandidate ||     
472      selectionLevel==AliRDHFCuts::kPID) {
473     returnvaluePID = IsSelectedPID(d);
474     fIsSelectedPID=returnvaluePID;
475   }
476   if(returnvaluePID==0)return 0;
477
478   // selection on daughter tracks 
479   if(selectionLevel==AliRDHFCuts::kAll || 
480      selectionLevel==AliRDHFCuts::kTracks) {
481     if(!AreDaughtersSelected(d)) return 0;
482   }
483   
484  
485
486
487   return 3;
488 }
489
490
491
492
493 //---------------------------------------------------------------------------
494
495
496 void AliRDHFCutsDplustoKpipi::SetStandardCutsPP2010() {
497   //
498   //STANDARD CUTS USED FOR 2010 pp analysis 
499   //                                            
500   
501   SetName("DplustoKpipiCutsStandard");
502   SetTitle("Standard Cuts for D+ analysis");
503   
504   // PILE UP REJECTION
505   SetOptPileup(AliRDHFCuts::kRejectPileupEvent);
506
507   // EVENT CUTS
508   SetMinVtxContr(1);
509
510   AliESDtrackCuts* esdTrackCuts=new AliESDtrackCuts();
511   esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
512   //default
513   esdTrackCuts->SetRequireTPCRefit(kTRUE);
514   esdTrackCuts->SetRequireITSRefit(kTRUE);
515   //esdTrackCuts->SetMinNClustersITS(4); // default is 5
516   esdTrackCuts->SetMinNClustersTPC(70);
517   esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
518                                          AliESDtrackCuts::kAny); 
519   // default is kBoth, otherwise kAny
520   esdTrackCuts->SetMinDCAToVertexXY(0.);
521   esdTrackCuts->SetPtRange(0.3,1.e10);
522   
523   AddTrackCuts(esdTrackCuts);
524   
525  
526   const Int_t nptbins =15;
527   const Int_t nvars=14;
528   Float_t ptbins[nptbins+1];
529   ptbins[0]=0.;
530   ptbins[1]=1;  
531   ptbins[2]=2.;
532   ptbins[3]=3.;
533   ptbins[4]=4.;
534   ptbins[5]=5.;
535   ptbins[6]=6.;
536   ptbins[7]=7.;
537   ptbins[8]=8.;
538   ptbins[9]=9.;
539   ptbins[10]=10.;
540   ptbins[11]=12.;
541   ptbins[12]=14.;
542   ptbins[13]=16.;
543   ptbins[14]=24.;
544   ptbins[15]=99999.;
545       
546     
547   Float_t** anacutsval;
548   anacutsval=new Float_t*[nvars];
549   
550   for(Int_t ic=0;ic<nvars;ic++){anacutsval[ic]=new Float_t[nptbins];}
551
552   //Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
553   for(Int_t ipt=0;ipt<nptbins;ipt++){
554     anacutsval[0][ipt]=0.2;
555     anacutsval[3][ipt]=0.;
556     anacutsval[4][ipt]=0.;
557     anacutsval[5][ipt]=0.01;
558     anacutsval[11][ipt]=10000000000.;
559     }
560
561   anacutsval[1][0]=0.3;
562   anacutsval[1][1]=0.4;
563   anacutsval[1][2]=0.4; 
564   anacutsval[2][0]=0.3;
565   anacutsval[2][1]=0.3;
566   anacutsval[2][2]=0.4;  
567   for(Int_t ipt=3;ipt<nptbins;ipt++){
568     anacutsval[1][ipt]=0.4;
569     anacutsval[2][ipt]=0.4;
570   }
571   
572   anacutsval[6][0]=0.022100;
573   anacutsval[6][1]=0.022100;
574   anacutsval[6][2]=0.034;
575   anacutsval[6][3]=0.020667;
576   anacutsval[6][4]=0.020667;
577   anacutsval[6][5]=0.023333;
578     
579   
580   anacutsval[7][0]=0.08;
581   anacutsval[7][1]=0.08;
582   anacutsval[7][2]=0.09;  
583   anacutsval[7][3]=0.095;
584   anacutsval[7][4]=0.095;
585    
586   anacutsval[8][0]=0.5;
587   anacutsval[8][1]=0.5;
588   anacutsval[8][2]=1.0;
589   anacutsval[8][3]=0.5;
590   anacutsval[8][4]=0.5;
591      
592     
593   anacutsval[9][0]=0.97;
594   anacutsval[9][1]=0.936;
595   anacutsval[9][2]=0.95; 
596   anacutsval[9][3]=0.95; 
597   anacutsval[9][4]= 0.95;
598   anacutsval[9][5]=0.92;
599   anacutsval[9][6]=0.92;
600   anacutsval[9][7]=0.92;
601   anacutsval[9][8]=0.92;
602   anacutsval[9][9]=0.90;
603  for(Int_t ipt=10;ipt<nptbins;ipt++){
604    anacutsval[9][ipt]=0.90; 
605  }
606   
607   
608   anacutsval[10][0]=0.0055;
609   anacutsval[10][1]=0.0055;
610   anacutsval[10][2]= 0.0028;
611   anacutsval[10][3]=0.000883;
612   anacutsval[10][4]=0.000883;
613
614   
615   for(Int_t ipt=5;ipt<nptbins;ipt++){
616     anacutsval[6][ipt]=0.02333;
617     anacutsval[7][ipt]=0.115;
618     anacutsval[8][ipt]=0.5;
619     anacutsval[10][ipt]=0.000883;
620     }   
621
622   anacutsval[12][0]=8;
623   anacutsval[12][1]=8;
624   
625   anacutsval[13][0]=0.98;
626   anacutsval[13][1]=0.98;
627   for(Int_t ipt=2;ipt<nptbins;ipt++){
628     anacutsval[12][ipt]=0.;
629     anacutsval[13][ipt]=0.;
630  }
631   
632   
633   
634   SetGlobalIndex(nvars,nptbins);
635   SetPtBins(nptbins+1,ptbins);
636   SetCuts(nvars,nptbins,anacutsval);
637   SetUsePID(kTRUE);
638   SetRemoveDaughtersFromPrim(kTRUE);
639   
640   PrintAll();
641
642   for(Int_t iic=0;iic<nvars;iic++){delete [] anacutsval[iic];}
643   delete [] anacutsval;
644   anacutsval=NULL;
645
646   return;
647 }
648
649
650 void AliRDHFCutsDplustoKpipi::SetStandardCutsPbPb2010() {
651   //
652   //STANDARD CUTS USED FOR 2010 Pb Pb analysis.... not optimized yet 
653   //                                              
654   
655   SetName("DplustoKpipiCutsStandard");
656   SetTitle("Standard Cuts for D+ analysis in PbPb2010 run");
657   
658   // PILE UP REJECTION
659   //SetOptPileup(AliRDHFCuts::kRejectPileupEvent);
660
661   // EVENT CUTS
662   SetMinVtxContr(1);
663
664   
665   AliESDtrackCuts* esdTrackCuts=new AliESDtrackCuts();
666   esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
667   //default
668   esdTrackCuts->SetRequireTPCRefit(kTRUE);
669   esdTrackCuts->SetRequireITSRefit(kTRUE);
670   //esdTrackCuts->SetMinNClustersITS(4); // default is 5
671   esdTrackCuts->SetMinNClustersTPC(70);
672   esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
673                                          AliESDtrackCuts::kAny); 
674   // default is kBoth, otherwise kAny
675   esdTrackCuts->SetMinDCAToVertexXY(0.);
676   esdTrackCuts->SetPtRange(0.8,1.e10);
677     
678   AddTrackCuts(esdTrackCuts);
679     
680   const Int_t nptbins=10;
681   Float_t* ptbins;
682   ptbins=new Float_t[nptbins+1];
683
684   ptbins[0]=0.;
685   ptbins[1]=1.;
686   ptbins[2]=2.;
687   ptbins[3]=3.;
688   ptbins[4]=4.;
689   ptbins[5]=5.;
690   ptbins[6]=6.;
691   ptbins[7]=8.;
692   ptbins[8]=12.;
693   ptbins[9]=16.;
694   ptbins[10]=24.;
695   const Int_t nvars=14;
696     
697   Float_t** anacutsval;
698   anacutsval=new Float_t*[nvars];
699   
700   for(Int_t ic=0;ic<nvars;ic++){anacutsval[ic]=new Float_t[nptbins];}
701   //Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
702
703   for(Int_t ipt=0;ipt<nptbins;ipt++){
704     anacutsval[0][ipt]=0.2;
705     anacutsval[1][ipt]=0.8;
706     anacutsval[2][ipt]=0.8;
707     anacutsval[3][ipt]=0.;
708     anacutsval[4][ipt]=0.;
709     anacutsval[5][ipt]=0.01;
710     anacutsval[11][ipt]=10000000000.;
711     anacutsval[12][ipt]=0.;
712     anacutsval[13][ipt]=0.;
713   }
714   anacutsval[1][5]=0.9;
715
716   anacutsval[6][0]=0.022100;
717   anacutsval[6][1]=0.022100;
718   anacutsval[6][2]=0.034;
719   anacutsval[6][3]=0.020667;
720   anacutsval[6][4]=0.020667;
721   anacutsval[6][5]=0.023333;
722   
723   anacutsval[7][0]=0.08;
724   anacutsval[7][1]=0.08;
725   anacutsval[7][2]=0.17;  
726   anacutsval[7][3]=0.14;
727   anacutsval[7][4]=0.14;
728   anacutsval[7][5]=0.19;
729   
730   anacutsval[8][0]=0.8;
731   anacutsval[8][1]=0.8;
732   anacutsval[8][2]=1.1;
733   anacutsval[8][3]=0.5;
734   anacutsval[8][4]=0.5;
735   anacutsval[8][5]=0.5;
736   
737   anacutsval[9][0]=0.995;
738   anacutsval[9][1]=0.995;
739   anacutsval[9][2]=0.997; 
740   anacutsval[9][3]=0.998; 
741   anacutsval[9][4]=0.998;
742   anacutsval[9][5]=0.995;
743   
744   anacutsval[10][0]=0.0055;
745   anacutsval[10][1]=0.0055;
746   anacutsval[10][2]= 0.0028;
747   anacutsval[10][3]=0.000883;
748   anacutsval[10][4]=0.000883;
749   anacutsval[10][5]=0.000883;
750
751   anacutsval[12][5]=12.;
752   anacutsval[13][5]=0.998571;
753   anacutsval[12][6]=10.;
754   anacutsval[13][6]=0.997143;
755
756   for(Int_t ipt=6;ipt<nptbins;ipt++){
757     anacutsval[6][ipt]=0.02333;
758     anacutsval[7][ipt]=0.19;
759     anacutsval[8][ipt]=2.0;
760     anacutsval[9][ipt]=0.997;
761     anacutsval[10][ipt]=0.000883;
762   }   
763   anacutsval[7][6]=0.14;
764   anacutsval[9][6]=0.995;
765
766   SetPtBins(nptbins+1,ptbins);
767   SetCuts(nvars,nptbins,anacutsval);
768   SetUsePID(kTRUE);
769   SetMinCentrality(1E-10);
770   SetMaxCentrality(20.);
771   SetUseCentrality(AliRDHFCuts::kCentV0M);
772   SetRemoveDaughtersFromPrim(kFALSE);
773     
774   PrintAll();
775
776   for(Int_t iic=0;iic<nvars;iic++){delete [] anacutsval[iic];}
777   delete [] anacutsval;
778   anacutsval=NULL;
779
780   delete [] ptbins;
781   ptbins=NULL;
782
783   return;
784 }
785
786
787 void AliRDHFCutsDplustoKpipi::SetStandardCutsPbPb2011() {
788
789   // Default 2010 PbPb cut object
790   SetStandardCutsPbPb2010();
791
792   // Enable all 2011 PbPb run triggers
793   //  
794   SetTriggerClass("");
795   ResetMaskAndEnableMBTrigger();
796   EnableCentralTrigger();
797   EnableSemiCentralTrigger();
798
799
800 //--------------------------------------------------------------------------
801
802 UInt_t AliRDHFCutsDplustoKpipi::GetPIDTrackTPCTOFBitMap(AliAODTrack *track) const{
803
804   UInt_t bitmap=0;
805
806   Double_t sigmaTPCPionHyp=-999.;
807   Double_t sigmaTPCKaonHyp=-999.;
808   Double_t sigmaTPCProtonHyp=-999.;
809   Double_t sigmaTOFPionHyp=-999.;
810   Double_t sigmaTOFKaonHyp=-999.;
811   Double_t sigmaTOFProtonHyp=-999.;
812   
813   Int_t oksigmaTPCPionHyp=fPidHF->GetnSigmaTPC(track,2,sigmaTPCPionHyp);
814   Int_t oksigmaTPCKaonHyp=fPidHF->GetnSigmaTPC(track,3,sigmaTPCKaonHyp);
815   Int_t oksigmaTPCProtonHyp=fPidHF->GetnSigmaTPC(track,4,sigmaTPCProtonHyp);
816   Int_t oksigmaTOFPionHyp=fPidHF->GetnSigmaTOF(track,2,sigmaTOFPionHyp);
817   Int_t oksigmaTOFKaonHyp=fPidHF->GetnSigmaTOF(track,3,sigmaTOFKaonHyp);
818   Int_t oksigmaTOFProtonHyp=fPidHF->GetnSigmaTOF(track,4,sigmaTOFProtonHyp);
819   
820   if (oksigmaTPCPionHyp && sigmaTPCPionHyp>0.){
821     if (sigmaTPCPionHyp<1.) bitmap+=1<<kTPCPionLess1;
822     else{
823       if (sigmaTPCPionHyp<2.) bitmap+=1<<kTPCPionMore1Less2;
824       else { 
825         if (sigmaTPCPionHyp<3.) bitmap+=1<<kTPCPionMore2Less3; 
826         else bitmap+=1<<kTPCPionMore3;
827       }
828     }
829   }
830   
831   if (oksigmaTPCKaonHyp && sigmaTPCKaonHyp>0.){
832     if (sigmaTPCKaonHyp<1.) bitmap+=1<<kTPCKaonLess1;
833     else{
834       if (sigmaTPCKaonHyp<2.) bitmap+=1<<kTPCKaonMore1Less2;
835       else { 
836         if (sigmaTPCKaonHyp<3.) bitmap+=1<<kTPCKaonMore2Less3; 
837         else bitmap+=1<<kTPCKaonMore3;
838       }
839     }
840   }
841   
842   if (oksigmaTPCProtonHyp && sigmaTPCProtonHyp>0.){
843     if (sigmaTPCProtonHyp<1.) bitmap+=1<<kTPCProtonLess1;
844     else{
845       if (sigmaTPCProtonHyp<2.) bitmap+=1<<kTPCProtonMore1Less2;
846       else { 
847         if (sigmaTPCProtonHyp<3.) bitmap+=1<<kTPCProtonMore2Less3; 
848         else bitmap+=1<<kTPCProtonMore3;
849       }
850     }
851   }
852   
853   if (oksigmaTOFPionHyp && sigmaTOFPionHyp>0.){
854     if (sigmaTOFPionHyp<1.) bitmap+=1<<kTOFPionLess1;
855     else{
856       if (sigmaTOFPionHyp<2.) bitmap+=1<<kTOFPionMore1Less2;
857       else { 
858         if (sigmaTOFPionHyp<3.) bitmap+=1<<kTOFPionMore2Less3; 
859         else bitmap+=1<<kTOFPionMore3;
860       }
861     }
862   }
863   
864   if (oksigmaTOFKaonHyp && sigmaTOFKaonHyp>0.){
865     if (sigmaTOFKaonHyp<1.) bitmap+=1<<kTOFKaonLess1;
866     else{
867       if (sigmaTOFKaonHyp<2.) bitmap+=1<<kTOFKaonMore1Less2;
868       else { 
869         if (sigmaTOFKaonHyp<3.) bitmap+=1<<kTOFKaonMore2Less3; 
870         else bitmap+=1<<kTOFKaonMore3;
871       }
872     }
873   }
874   
875   if (oksigmaTOFProtonHyp && sigmaTOFProtonHyp>0.){
876     if (sigmaTOFProtonHyp<1.) bitmap+=1<<kTOFProtonLess1;
877     else{
878       if (sigmaTOFProtonHyp<2.) bitmap+=1<<kTOFProtonMore1Less2;
879       else { 
880         if (sigmaTOFProtonHyp<3.) bitmap+=1<<kTOFProtonMore2Less3; 
881         else bitmap+=1<<kTOFProtonMore3;
882       }
883     }
884   }
885   
886   
887   
888   return bitmap;
889
890 }