]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/AliRDHFCutsDplustoKpipi.cxx
Code reworking to analize ESD and AOD (H.Qvigstad)
[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(pt > 5.) {
294     // applying cut for pt > 5 GeV
295     AliDebug(2,Form("pt of D+ = %f (> 5), cutting at |y| < 0.8",pt)); 
296     if (TMath::Abs(y) > 0.8) return kFALSE;
297     
298   } else {
299     // appliying smooth cut for pt < 5 GeV
300     Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5; 
301     Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;         
302     AliDebug(2,Form("pt of D+ = %f (< 5), cutting  according to the fiducial zone [%f, %f]\n",pt,minFiducialY,maxFiducialY)); 
303     if (y < minFiducialY || y > maxFiducialY) return kFALSE;    
304   }
305
306   return kTRUE;
307 }
308
309 //---------------------------------------------------------------------------
310 Int_t AliRDHFCutsDplustoKpipi::GetPIDBitMask(AliAODRecoDecayHF *rd)
311 {
312   if(!fUsePID || !rd) return -1;
313   //if(fUsePID)printf("i am inside the pid \n");
314   Int_t mask=0;
315   Int_t sign=rd->GetCharge(); 
316   for(Int_t daught=0;daught<3;daught++){
317     AliAODTrack *track=(AliAODTrack*)rd->GetDaughter(daught);
318
319     if(sign==track->Charge()){//pions
320       Int_t isPion=fPidHF->MakeRawPid(track,AliPID::kPion);
321       if(isPion==0)mask+=1;
322       else if(isPion>0)mask+=3;
323       mask=mask<<2;
324     }
325     else{//kaons
326       Int_t isKaon=fPidHF->MakeRawPid(track,AliPID::kKaon);
327       if(isKaon==0)mask+=1;
328       else if(isKaon>0)mask+=3;
329       mask=mask<<2;
330     }
331   }
332   mask=mask>>2;
333   return mask;   
334 }
335 //---------------------------------------------------------------------------
336 Int_t AliRDHFCutsDplustoKpipi::IsSelectedPID(AliAODRecoDecayHF *rd)
337 {
338   //
339   // PID selection, returns 3 if accepted, 0 if not accepted
340   // 
341   if(!fUsePID || !rd) return 3;
342   //if(fUsePID)printf("i am inside the pid \n");
343   Int_t nkaons=0;
344   Int_t nNotKaons=0;
345   Int_t sign= rd->GetCharge(); 
346   for(Int_t daught=0;daught<3;daught++){
347     AliAODTrack *track=(AliAODTrack*)rd->GetDaughter(daught);
348     Int_t isPion=fPidHF->MakeRawPid(track,AliPID::kPion);
349     Int_t isKaon=fPidHF->MakeRawPid(track,AliPID::kKaon);
350     Int_t isProton=fPidHF->MakeRawPid(track,AliPID::kProton);
351     
352     if(isProton>0 &&  isKaon<0  && isPion<0) return 0;
353     if(isKaon>0 && isPion<0) nkaons++;
354     if(isKaon<0) nNotKaons++;  
355     if(sign==track->Charge()){//pions
356       if(isPion<0)return 0;
357       if(rd->Pt()<fMaxPtStrongPid && isPion<=0 && fUseStrongPid&2 && track->P()<fMaxPStrongPidpi)return 0;
358     }
359     else{//kaons
360       if(isKaon<0)return 0;
361         if(rd->Pt()<fMaxPtStrongPid && isKaon<=0 && fUseStrongPid&1&& track->P()<fMaxPStrongPidK)return 0;
362     }
363   }
364   
365   if(nkaons>1)return 0;
366   if(nNotKaons==3)return 0;
367   
368   return 3;   
369 }
370
371
372 //---------------------------------------------------------------------------
373 Int_t AliRDHFCutsDplustoKpipi::IsSelected(TObject* obj,Int_t selectionLevel, AliAODEvent* aod) {
374   //
375   // Apply selection, returns 3 if accepted, 0 if not accepted
376   //
377
378
379   fIsSelectedCuts=0;
380   fIsSelectedPID=0;
381
382   if(!fCutsRD){
383     cout<<"Cut matrix not inizialized. Exit..."<<endl;
384     return 0;
385   }
386   //PrintAll();
387   AliAODRecoDecayHF3Prong* d=(AliAODRecoDecayHF3Prong*)obj; 
388
389   
390   if(!d){
391     cout<<"AliAODRecoDecayHF3Prong null"<<endl;
392     return 0;
393   }
394
395   if(fKeepSignalMC) if(IsSignalMC(d,aod,411)) return 3;
396
397   // PID selection
398   Int_t returnvaluePID=3;
399   Int_t returnvalueCuts=3;
400
401   Double_t pt=d->Pt();
402   if(pt<fMinPtCand) return 0;
403   if(pt>fMaxPtCand) return 0;
404
405   if(fUseTrackSelectionWithFilterBits && d->HasBadDaughters()) return 0;
406   
407   // selection on candidate
408   if(selectionLevel==AliRDHFCuts::kAll || 
409      selectionLevel==AliRDHFCuts::kCandidate) {
410     
411     //recalculate vertex w/o daughters
412     AliAODVertex *origownvtx=0x0;
413     if(fRemoveDaughtersFromPrimary && !fUseMCVertex) {
414       if(d->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*d->GetOwnPrimaryVtx());
415       if(!RecalcOwnPrimaryVtx(d,aod)) {
416         CleanOwnPrimaryVtx(d,aod,origownvtx);
417         return 0;
418       }
419     }
420
421     if(fUseMCVertex) {
422       if(d->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*d->GetOwnPrimaryVtx());
423       if(!SetMCPrimaryVtx(d,aod)) {
424         CleanOwnPrimaryVtx(d,aod,origownvtx);
425         return 0;
426       }
427     }
428
429     Int_t ptbin=PtBin(pt);
430     if (ptbin==-1) {
431       CleanOwnPrimaryVtx(d,aod,origownvtx);
432       return 0;
433     }
434     
435     Double_t mDplusPDG = TDatabasePDG::Instance()->GetParticle(411)->Mass();
436     Double_t mDplus=d->InvMassDplus();
437     if(TMath::Abs(mDplus-mDplusPDG)>fCutsRD[GetGlobalIndex(0,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
438
439     //2track cuts
440     if(d->GetDist12toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]|| d->GetDist23toPrim()<fCutsRD[GetGlobalIndex(5,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
441
442     Double_t sum2=d->Getd0Prong(0)*d->Getd0Prong(0)+d->Getd0Prong(1)*d->Getd0Prong(1)+d->Getd0Prong(2)*d->Getd0Prong(2);
443     if(sum2<fCutsRD[GetGlobalIndex(10,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
444
445     if(fUseImpParProdCorrCut){
446       if(d->Getd0Prong(0)*d->Getd0Prong(1)<0. && d->Getd0Prong(2)*d->Getd0Prong(1)<0.) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
447     }
448
449
450     //DCA
451     for(Int_t i=0;i<3;i++) if(d->GetDCA(i)>fCutsRD[GetGlobalIndex(11,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
452
453     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
454
455     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
456
457     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
458     
459     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;}
460
461     if(d->DecayLength2()<fCutsRD[GetGlobalIndex(7,ptbin)]*fCutsRD[GetGlobalIndex(7,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
462
463     if(d->CosPointingAngle()< fCutsRD[GetGlobalIndex(9,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
464
465     if(d->NormalizedDecayLengthXY()*d->P()/pt<fCutsRD[GetGlobalIndex(12,ptbin)]){CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
466
467     if(d->CosPointingAngleXY()<fCutsRD[GetGlobalIndex(13,ptbin)]){CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
468
469     //sec vert
470     Double_t sigmavert=d->GetSigmaVert(aod);
471     if(sigmavert>fCutsRD[GetGlobalIndex(6,ptbin)]) {CleanOwnPrimaryVtx(d,aod,origownvtx); return 0;}
472
473     // unset recalculated primary vertex when not needed any more
474     CleanOwnPrimaryVtx(d,aod,origownvtx);
475     
476     fIsSelectedCuts=returnvalueCuts;
477
478     //if(!returnvalueCuts) return 0; // returnvalueCuts cannot be 0 here
479   }
480   
481   if(selectionLevel==AliRDHFCuts::kAll || 
482      selectionLevel==AliRDHFCuts::kCandidate ||     
483      selectionLevel==AliRDHFCuts::kPID) {
484     returnvaluePID = IsSelectedPID(d);
485     fIsSelectedPID=returnvaluePID;
486   }
487   if(returnvaluePID==0)return 0;
488
489   // selection on daughter tracks 
490   if(selectionLevel==AliRDHFCuts::kAll || 
491      selectionLevel==AliRDHFCuts::kTracks) {
492     if(!AreDaughtersSelected(d)) return 0;
493   }
494   
495  
496
497
498   return 3;
499 }
500
501
502
503
504 //---------------------------------------------------------------------------
505
506
507 void AliRDHFCutsDplustoKpipi::SetStandardCutsPP2010() {
508   //
509   //STANDARD CUTS USED FOR 2010 pp analysis 
510   //                                            
511   
512   SetName("DplustoKpipiCutsStandard");
513   SetTitle("Standard Cuts for D+ analysis");
514   
515   // PILE UP REJECTION
516   SetOptPileup(AliRDHFCuts::kRejectPileupEvent);
517
518   // EVENT CUTS
519   SetMinVtxContr(1);
520
521   AliESDtrackCuts* esdTrackCuts=new AliESDtrackCuts();
522   esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
523   //default
524   esdTrackCuts->SetRequireTPCRefit(kTRUE);
525   esdTrackCuts->SetRequireITSRefit(kTRUE);
526   //esdTrackCuts->SetMinNClustersITS(4); // default is 5
527   esdTrackCuts->SetMinNClustersTPC(70);
528   esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
529                                          AliESDtrackCuts::kAny); 
530   // default is kBoth, otherwise kAny
531   esdTrackCuts->SetMinDCAToVertexXY(0.);
532   esdTrackCuts->SetPtRange(0.3,1.e10);
533   
534   AddTrackCuts(esdTrackCuts);
535   
536  
537   const Int_t nptbins =15;
538   const Int_t nvars=14;
539   Float_t ptbins[nptbins+1];
540   ptbins[0]=0.;
541   ptbins[1]=1;  
542   ptbins[2]=2.;
543   ptbins[3]=3.;
544   ptbins[4]=4.;
545   ptbins[5]=5.;
546   ptbins[6]=6.;
547   ptbins[7]=7.;
548   ptbins[8]=8.;
549   ptbins[9]=9.;
550   ptbins[10]=10.;
551   ptbins[11]=12.;
552   ptbins[12]=14.;
553   ptbins[13]=16.;
554   ptbins[14]=24.;
555   ptbins[15]=99999.;
556       
557     
558   Float_t** anacutsval;
559   anacutsval=new Float_t*[nvars];
560   
561   for(Int_t ic=0;ic<nvars;ic++){anacutsval[ic]=new Float_t[nptbins];}
562
563   //Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
564   for(Int_t ipt=0;ipt<nptbins;ipt++){
565     anacutsval[0][ipt]=0.2;
566     anacutsval[3][ipt]=0.;
567     anacutsval[4][ipt]=0.;
568     anacutsval[5][ipt]=0.01;
569     anacutsval[11][ipt]=10000000000.;
570     }
571
572   anacutsval[1][0]=0.3;
573   anacutsval[1][1]=0.4;
574   anacutsval[1][2]=0.4; 
575   anacutsval[2][0]=0.3;
576   anacutsval[2][1]=0.3;
577   anacutsval[2][2]=0.4;  
578   for(Int_t ipt=3;ipt<nptbins;ipt++){
579     anacutsval[1][ipt]=0.4;
580     anacutsval[2][ipt]=0.4;
581   }
582   
583   anacutsval[6][0]=0.022100;
584   anacutsval[6][1]=0.022100;
585   anacutsval[6][2]=0.034;
586   anacutsval[6][3]=0.020667;
587   anacutsval[6][4]=0.020667;
588   anacutsval[6][5]=0.023333;
589     
590   
591   anacutsval[7][0]=0.08;
592   anacutsval[7][1]=0.08;
593   anacutsval[7][2]=0.09;  
594   anacutsval[7][3]=0.095;
595   anacutsval[7][4]=0.095;
596    
597   anacutsval[8][0]=0.5;
598   anacutsval[8][1]=0.5;
599   anacutsval[8][2]=1.0;
600   anacutsval[8][3]=0.5;
601   anacutsval[8][4]=0.5;
602      
603     
604   anacutsval[9][0]=0.97;
605   anacutsval[9][1]=0.936;
606   anacutsval[9][2]=0.95; 
607   anacutsval[9][3]=0.95; 
608   anacutsval[9][4]= 0.95;
609   anacutsval[9][5]=0.92;
610   anacutsval[9][6]=0.92;
611   anacutsval[9][7]=0.92;
612   anacutsval[9][8]=0.92;
613   anacutsval[9][9]=0.90;
614  for(Int_t ipt=10;ipt<nptbins;ipt++){
615    anacutsval[9][ipt]=0.90; 
616  }
617   
618   
619   anacutsval[10][0]=0.0055;
620   anacutsval[10][1]=0.0055;
621   anacutsval[10][2]= 0.0028;
622   anacutsval[10][3]=0.000883;
623   anacutsval[10][4]=0.000883;
624
625   
626   for(Int_t ipt=5;ipt<nptbins;ipt++){
627     anacutsval[6][ipt]=0.02333;
628     anacutsval[7][ipt]=0.115;
629     anacutsval[8][ipt]=0.5;
630     anacutsval[10][ipt]=0.000883;
631     }   
632
633   anacutsval[12][0]=8;
634   anacutsval[12][1]=8;
635   
636   anacutsval[13][0]=0.98;
637   anacutsval[13][1]=0.98;
638   for(Int_t ipt=2;ipt<nptbins;ipt++){
639     anacutsval[12][ipt]=0.;
640     anacutsval[13][ipt]=0.;
641  }
642   
643   
644   
645   SetGlobalIndex(nvars,nptbins);
646   SetPtBins(nptbins+1,ptbins);
647   SetCuts(nvars,nptbins,anacutsval);
648   SetUsePID(kTRUE);
649   fPidHF->SetOldPid(kTRUE);
650   SetRemoveDaughtersFromPrim(kTRUE);
651   
652   PrintAll();
653
654   for(Int_t iic=0;iic<nvars;iic++){delete [] anacutsval[iic];}
655   delete [] anacutsval;
656   anacutsval=NULL;
657
658   return;
659 }
660
661
662 void AliRDHFCutsDplustoKpipi::SetStandardCutsPbPb2010() {
663   //
664   //STANDARD CUTS USED FOR 2010 Pb Pb analysis.... not optimized yet 
665   //                                              
666   
667   SetName("DplustoKpipiCutsStandard");
668   SetTitle("Standard Cuts for D+ analysis in PbPb2010 run");
669   
670   // PILE UP REJECTION
671   //SetOptPileup(AliRDHFCuts::kRejectPileupEvent);
672
673   // EVENT CUTS
674   SetMinVtxContr(1);
675
676   
677   AliESDtrackCuts* esdTrackCuts=new AliESDtrackCuts();
678   esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
679   //default
680   esdTrackCuts->SetRequireTPCRefit(kTRUE);
681   esdTrackCuts->SetRequireITSRefit(kTRUE);
682   //esdTrackCuts->SetMinNClustersITS(4); // default is 5
683   esdTrackCuts->SetMinNClustersTPC(70);
684   esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,
685                                          AliESDtrackCuts::kAny); 
686   // default is kBoth, otherwise kAny
687   esdTrackCuts->SetMinDCAToVertexXY(0.);
688   esdTrackCuts->SetPtRange(0.8,1.e10);
689     
690   AddTrackCuts(esdTrackCuts);
691     
692   const Int_t nptbins=10;
693   Float_t* ptbins;
694   ptbins=new Float_t[nptbins+1];
695
696   ptbins[0]=0.;
697   ptbins[1]=1.;
698   ptbins[2]=2.;
699   ptbins[3]=3.;
700   ptbins[4]=4.;
701   ptbins[5]=5.;
702   ptbins[6]=6.;
703   ptbins[7]=8.;
704   ptbins[8]=12.;
705   ptbins[9]=16.;
706   ptbins[10]=24.;
707   const Int_t nvars=14;
708     
709   Float_t** anacutsval;
710   anacutsval=new Float_t*[nvars];
711   
712   for(Int_t ic=0;ic<nvars;ic++){anacutsval[ic]=new Float_t[nptbins];}
713   //Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
714
715   for(Int_t ipt=0;ipt<nptbins;ipt++){
716     anacutsval[0][ipt]=0.2;
717     anacutsval[1][ipt]=0.8;
718     anacutsval[2][ipt]=0.8;
719     anacutsval[3][ipt]=0.;
720     anacutsval[4][ipt]=0.;
721     anacutsval[5][ipt]=0.01;
722     anacutsval[11][ipt]=10000000000.;
723     anacutsval[12][ipt]=0.;
724     anacutsval[13][ipt]=0.;
725   }
726   anacutsval[1][5]=0.9;
727
728   anacutsval[6][0]=0.022100;
729   anacutsval[6][1]=0.022100;
730   anacutsval[6][2]=0.034;
731   anacutsval[6][3]=0.020667;
732   anacutsval[6][4]=0.020667;
733   anacutsval[6][5]=0.023333;
734   
735   anacutsval[7][0]=0.08;
736   anacutsval[7][1]=0.08;
737   anacutsval[7][2]=0.17;  
738   anacutsval[7][3]=0.14;
739   anacutsval[7][4]=0.14;
740   anacutsval[7][5]=0.19;
741   
742   anacutsval[8][0]=0.8;
743   anacutsval[8][1]=0.8;
744   anacutsval[8][2]=1.1;
745   anacutsval[8][3]=0.5;
746   anacutsval[8][4]=0.5;
747   anacutsval[8][5]=0.5;
748   
749   anacutsval[9][0]=0.995;
750   anacutsval[9][1]=0.995;
751   anacutsval[9][2]=0.997; 
752   anacutsval[9][3]=0.998; 
753   anacutsval[9][4]=0.998;
754   anacutsval[9][5]=0.995;
755   
756   anacutsval[10][0]=0.0055;
757   anacutsval[10][1]=0.0055;
758   anacutsval[10][2]= 0.0028;
759   anacutsval[10][3]=0.000883;
760   anacutsval[10][4]=0.000883;
761   anacutsval[10][5]=0.000883;
762
763   anacutsval[12][5]=12.;
764   anacutsval[13][5]=0.998571;
765   anacutsval[12][6]=10.;
766   anacutsval[13][6]=0.997143;
767
768   for(Int_t ipt=6;ipt<nptbins;ipt++){
769     anacutsval[6][ipt]=0.02333;
770     anacutsval[7][ipt]=0.19;
771     anacutsval[8][ipt]=2.0;
772     anacutsval[9][ipt]=0.997;
773     anacutsval[10][ipt]=0.000883;
774   }   
775   anacutsval[7][6]=0.14;
776   anacutsval[9][6]=0.995;
777
778   SetPtBins(nptbins+1,ptbins);
779   SetCuts(nvars,nptbins,anacutsval);
780   SetUsePID(kTRUE);
781   fPidHF->SetOldPid(kTRUE);
782   SetMinCentrality(1E-10);
783   SetMaxCentrality(20.);
784   SetUseCentrality(AliRDHFCuts::kCentV0M);
785   SetRemoveDaughtersFromPrim(kFALSE);
786     
787   PrintAll();
788
789   for(Int_t iic=0;iic<nvars;iic++){delete [] anacutsval[iic];}
790   delete [] anacutsval;
791   anacutsval=NULL;
792
793   delete [] ptbins;
794   ptbins=NULL;
795
796   return;
797 }
798
799
800 void AliRDHFCutsDplustoKpipi::SetStandardCutsPbPb2011() {
801
802   // Default 2010 PbPb cut object
803   SetStandardCutsPbPb2010();
804
805   // Enable all 2011 PbPb run triggers
806   //  
807   SetTriggerClass("");
808   ResetMaskAndEnableMBTrigger();
809   EnableCentralTrigger();
810   EnableSemiCentralTrigger();
811
812   // new PID
813   fPidHF->SetOldPid(kFALSE);
814
815
816 //--------------------------------------------------------------------------
817
818 UInt_t AliRDHFCutsDplustoKpipi::GetPIDTrackTPCTOFBitMap(AliAODTrack *track) const{
819
820   UInt_t bitmap=0;
821
822   Double_t sigmaTPCPionHyp=-999.;
823   Double_t sigmaTPCKaonHyp=-999.;
824   Double_t sigmaTPCProtonHyp=-999.;
825   Double_t sigmaTOFPionHyp=-999.;
826   Double_t sigmaTOFKaonHyp=-999.;
827   Double_t sigmaTOFProtonHyp=-999.;
828   
829   Int_t oksigmaTPCPionHyp=fPidHF->GetnSigmaTPC(track,2,sigmaTPCPionHyp);
830   Int_t oksigmaTPCKaonHyp=fPidHF->GetnSigmaTPC(track,3,sigmaTPCKaonHyp);
831   Int_t oksigmaTPCProtonHyp=fPidHF->GetnSigmaTPC(track,4,sigmaTPCProtonHyp);
832   Int_t oksigmaTOFPionHyp=fPidHF->GetnSigmaTOF(track,2,sigmaTOFPionHyp);
833   Int_t oksigmaTOFKaonHyp=fPidHF->GetnSigmaTOF(track,3,sigmaTOFKaonHyp);
834   Int_t oksigmaTOFProtonHyp=fPidHF->GetnSigmaTOF(track,4,sigmaTOFProtonHyp);
835
836   sigmaTPCPionHyp=TMath::Abs(sigmaTPCPionHyp);
837   sigmaTPCKaonHyp=TMath::Abs(sigmaTPCKaonHyp);
838   sigmaTPCProtonHyp=TMath::Abs(sigmaTPCProtonHyp);
839   sigmaTOFPionHyp=TMath::Abs(sigmaTOFPionHyp);
840   sigmaTOFKaonHyp=TMath::Abs(sigmaTOFKaonHyp);
841   sigmaTOFProtonHyp=TMath::Abs(sigmaTOFProtonHyp);
842
843   if (oksigmaTPCPionHyp && sigmaTPCPionHyp>0.){
844     if (sigmaTPCPionHyp<1.) bitmap+=1<<kTPCPionLess1;
845     else{
846       if (sigmaTPCPionHyp<2.) bitmap+=1<<kTPCPionMore1Less2;
847       else { 
848         if (sigmaTPCPionHyp<3.) bitmap+=1<<kTPCPionMore2Less3; 
849         else bitmap+=1<<kTPCPionMore3;
850       }
851     }
852   }
853   
854   if (oksigmaTPCKaonHyp && sigmaTPCKaonHyp>0.){
855     if (sigmaTPCKaonHyp<1.) bitmap+=1<<kTPCKaonLess1;
856     else{
857       if (sigmaTPCKaonHyp<2.) bitmap+=1<<kTPCKaonMore1Less2;
858       else { 
859         if (sigmaTPCKaonHyp<3.) bitmap+=1<<kTPCKaonMore2Less3; 
860         else bitmap+=1<<kTPCKaonMore3;
861       }
862     }
863   }
864   
865   if (oksigmaTPCProtonHyp && sigmaTPCProtonHyp>0.){
866     if (sigmaTPCProtonHyp<1.) bitmap+=1<<kTPCProtonLess1;
867     else{
868       if (sigmaTPCProtonHyp<2.) bitmap+=1<<kTPCProtonMore1Less2;
869       else { 
870         if (sigmaTPCProtonHyp<3.) bitmap+=1<<kTPCProtonMore2Less3; 
871         else bitmap+=1<<kTPCProtonMore3;
872       }
873     }
874   }
875   
876   if (oksigmaTOFPionHyp && sigmaTOFPionHyp>0.){
877     if (sigmaTOFPionHyp<1.) bitmap+=1<<kTOFPionLess1;
878     else{
879       if (sigmaTOFPionHyp<2.) bitmap+=1<<kTOFPionMore1Less2;
880       else { 
881         if (sigmaTOFPionHyp<3.) bitmap+=1<<kTOFPionMore2Less3; 
882         else bitmap+=1<<kTOFPionMore3;
883       }
884     }
885   }
886   
887   if (oksigmaTOFKaonHyp && sigmaTOFKaonHyp>0.){
888     if (sigmaTOFKaonHyp<1.) bitmap+=1<<kTOFKaonLess1;
889     else{
890       if (sigmaTOFKaonHyp<2.) bitmap+=1<<kTOFKaonMore1Less2;
891       else { 
892         if (sigmaTOFKaonHyp<3.) bitmap+=1<<kTOFKaonMore2Less3; 
893         else bitmap+=1<<kTOFKaonMore3;
894       }
895     }
896   }
897   
898   if (oksigmaTOFProtonHyp && sigmaTOFProtonHyp>0.){
899     if (sigmaTOFProtonHyp<1.) bitmap+=1<<kTOFProtonLess1;
900     else{
901       if (sigmaTOFProtonHyp<2.) bitmap+=1<<kTOFProtonMore1Less2;
902       else { 
903         if (sigmaTOFProtonHyp<3.) bitmap+=1<<kTOFProtonMore2Less3; 
904         else bitmap+=1<<kTOFProtonMore3;
905       }
906     }
907   }
908   
909   
910   
911   return bitmap;
912
913 }