Major update of cuts classes; now they are used in AliAnalysisVertexingHF and stored...
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliRDHFCutsD0toKpi.cxx
CommitLineData
650b3ced 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/////////////////////////////////////////////////////////////
17//
18// Class for cuts on AOD reconstructed D0->Kpi
19//
20// Author: A.Dainese, andrea.dainese@pd.infn.it
21/////////////////////////////////////////////////////////////
22
23#include <TDatabasePDG.h>
24#include <Riostream.h>
25
26#include "AliRDHFCutsD0toKpi.h"
27#include "AliAODRecoDecayHF2Prong.h"
28#include "AliAODTrack.h"
29#include "AliESDtrack.h"
30
31ClassImp(AliRDHFCutsD0toKpi)
32
33//--------------------------------------------------------------------------
a9b75906 34AliRDHFCutsD0toKpi::AliRDHFCutsD0toKpi(const char* name) :
35AliRDHFCuts(name)
650b3ced 36{
37 //
38 // Default Constructor
39 //
40 Int_t nvars=9;
41 SetNVars(nvars);
42 TString varNames[9]={"inv. mass [GeV]",
43 "dca [cm]",
44 "cosThetaStar",
45 "pTK [GeV/c]",
46 "pTPi [GeV/c]",
47 "d0K [cm]",
48 "d0Pi [cm]",
49 "d0d0 [cm^2]",
50 "cosThetaPoint"};
51 Bool_t isUpperCut[9]={kTRUE,
52 kTRUE,
53 kTRUE,
54 kFALSE,
55 kFALSE,
56 kTRUE,
57 kTRUE,
58 kTRUE,
59 kFALSE};
60 SetVarNames(nvars,varNames,isUpperCut);
61 Bool_t forOpt[9]={kFALSE,
62 kTRUE,
63 kTRUE,
64 kFALSE,
65 kFALSE,
66 kFALSE,
67 kFALSE,
68 kTRUE,
69 kTRUE};
70 SetVarsForOpt(4,forOpt);
71 Float_t limits[2]={0,999999999.};
72 SetPtBins(2,limits);
73}
74//--------------------------------------------------------------------------
75AliRDHFCutsD0toKpi::AliRDHFCutsD0toKpi(const AliRDHFCutsD0toKpi &source) :
76 AliRDHFCuts(source)
77{
78 //
79 // Copy constructor
80 //
81
82}
83//--------------------------------------------------------------------------
84AliRDHFCutsD0toKpi &AliRDHFCutsD0toKpi::operator=(const AliRDHFCutsD0toKpi &source)
85{
86 //
87 // assignment operator
88 //
89 if(&source == this) return *this;
90
91 AliRDHFCuts::operator=(source);
92
93 return *this;
94}
95
96
97//---------------------------------------------------------------------------
98void AliRDHFCutsD0toKpi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters) {
99 //
100 // Fills in vars the values of the variables
101 //
102
650b3ced 103 if(nvars!=fnVarsForOpt) {
104 printf("AliRDHFCutsD0toKpi::GetCutsVarsForOpt: wrong number of variables\n");
105 return;
106 }
107
108 AliAODRecoDecayHF2Prong *dd = (AliAODRecoDecayHF2Prong*)d;
650b3ced 109
650b3ced 110 Int_t iter=-1;
111 if(fVarsForOpt[0]){
112 iter++;
113 if(TMath::Abs(pdgdaughters[0])==211) {
114 vars[iter]=dd->InvMassD0();
115 } else {
116 vars[iter]=dd->InvMassD0bar();
117 }
118 }
119 if(fVarsForOpt[1]){
120 iter++;
121 vars[iter]=dd->GetDCA();
122 }
123 if(fVarsForOpt[2]){
124 iter++;
125 if(TMath::Abs(pdgdaughters[0])==211) {
126 vars[iter] = dd->CosThetaStarD0();
127 } else {
128 vars[iter] = dd->CosThetaStarD0bar();
129 }
130 }
131 if(fVarsForOpt[3]){
132 iter++;
133 if(TMath::Abs(pdgdaughters[0])==321) {
134 vars[iter]=dd->PtProng(0);
135 }
136 else{
137 vars[iter]=dd->PtProng(1);
138 }
139 }
140 if(fVarsForOpt[4]){
141 iter++;
142 if(TMath::Abs(pdgdaughters[0])==211) {
143 vars[iter]=dd->PtProng(0);
144 }
145 else{
146 vars[iter]=dd->PtProng(1);
147 }
148 }
149 if(fVarsForOpt[5]){
150 iter++;
151 if(TMath::Abs(pdgdaughters[0])==321) {
152 vars[iter]=dd->Getd0Prong(0);
153 }
154 else{
155 vars[iter]=dd->Getd0Prong(1);
156 }
157 }
158 if(fVarsForOpt[6]){
159 iter++;
160 if(TMath::Abs(pdgdaughters[0])==211) {
161 vars[iter]=dd->Getd0Prong(0);
162 }
163 else{
164 vars[iter]=dd->Getd0Prong(1);
165 }
166 }
167 if(fVarsForOpt[7]){
168 iter++;
169 vars[iter]= dd->Prodd0d0();
170 }
171 if(fVarsForOpt[8]){
172 iter++;
173 vars[iter]=dd->CosPointingAngle();
174 }
175
176 return;
177}
178//---------------------------------------------------------------------------
179Int_t AliRDHFCutsD0toKpi::IsSelected(TObject* obj,Int_t selectionLevel) {
180 //
181 // Apply selection
182 //
183
184 if(!fCutsRD){
185 cout<<"Cut matrice not inizialized. Exit..."<<endl;
3cbc09cd 186 return 0;
650b3ced 187 }
188 //PrintAll();
3cbc09cd 189 AliAODRecoDecayHF2Prong* d=(AliAODRecoDecayHF2Prong*)obj;
650b3ced 190
650b3ced 191 if(!d){
192 cout<<"AliAODRecoDecayHF2Prong null"<<endl;
193 return 0;
194 }
195
3cbc09cd 196
650b3ced 197 // selection on daughter tracks
198 if(selectionLevel==AliRDHFCuts::kAll ||
199 selectionLevel==AliRDHFCuts::kTracks) {
3cbc09cd 200 if(!AreDaughtersSelected(d)) return 0;
650b3ced 201 }
202
203
3cbc09cd 204 Int_t returnvalue=1;
650b3ced 205
206 // selection on candidate
207 if(selectionLevel==AliRDHFCuts::kAll ||
208 selectionLevel==AliRDHFCuts::kCandidate) {
209
210 Double_t pt=d->Pt();
211
212 Int_t okD0=0,okD0bar=0;
213
214 Int_t ptbin=PtBin(pt);
215
216 Double_t mD0,mD0bar,ctsD0,ctsD0bar;
217 okD0=1; okD0bar=1;
218
219 Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
220
221 if(d->PtProng(1) < fCutsRD[GetGlobalIndex(3,ptbin)] || d->PtProng(0) < fCutsRD[GetGlobalIndex(4,ptbin)]) okD0 = 0;
222 if(d->PtProng(0) < fCutsRD[GetGlobalIndex(3,ptbin)] || d->PtProng(1) < fCutsRD[GetGlobalIndex(4,ptbin)]) okD0bar = 0;
223
4755453e 224 if(!okD0 && !okD0bar) return 0;
650b3ced 225
226 if(TMath::Abs(d->Getd0Prong(1)) > fCutsRD[GetGlobalIndex(5,ptbin)] ||
227 TMath::Abs(d->Getd0Prong(0)) > fCutsRD[GetGlobalIndex(6,ptbin)]) okD0 = 0;
228 if(TMath::Abs(d->Getd0Prong(0)) > fCutsRD[GetGlobalIndex(6,ptbin)] ||
229 TMath::Abs(d->Getd0Prong(1)) > fCutsRD[GetGlobalIndex(5,ptbin)]) okD0bar = 0;
4755453e 230 if(!okD0 && !okD0bar) return 0;
650b3ced 231
4755453e 232 if(d->GetDCA() > fCutsRD[GetGlobalIndex(1,ptbin)]) return 0;
650b3ced 233
234 d->InvMassD0(mD0,mD0bar);
235 if(TMath::Abs(mD0-mD0PDG) > fCutsRD[GetGlobalIndex(0,ptbin)]) okD0 = 0;
236 if(TMath::Abs(mD0bar-mD0PDG) > fCutsRD[GetGlobalIndex(0,ptbin)]) okD0bar = 0;
4755453e 237 if(!okD0 && !okD0bar) return 0;
650b3ced 238
239 d->CosThetaStarD0(ctsD0,ctsD0bar);
240 if(TMath::Abs(ctsD0) > fCutsRD[GetGlobalIndex(2,ptbin)]) okD0 = 0;
241 if(TMath::Abs(ctsD0bar) > fCutsRD[GetGlobalIndex(2,ptbin)]) okD0bar = 0;
4755453e 242 if(!okD0 && !okD0bar) return 0;
650b3ced 243
4755453e 244 if(d->Prodd0d0() > fCutsRD[GetGlobalIndex(7,ptbin)]) return 0;
650b3ced 245
4755453e 246 if(d->CosPointingAngle() < fCutsRD[GetGlobalIndex(8,ptbin)]) return 0;
650b3ced 247
248 if (okD0) returnvalue=1; //cuts passed as D0
249 if (okD0bar) returnvalue=2; //cuts passed as D0bar
250 if (okD0 && okD0bar) returnvalue=3; //cuts passed as D0 and D0bar
251 }
252
650b3ced 253 return returnvalue;
650b3ced 254}
255//---------------------------------------------------------------------------