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