Major update of cuts classes; now they are used in AliAnalysisVertexingHF and stored...
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliRDHFCutsD0toKpipipi.cxx
1 /**************************************************************************\r
2  * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *\r
3  *                                                                        *\r
4  * Author: The ALICE Off-line Project.                                    *\r
5  * Contributors are mentioned in the code where appropriate.              *\r
6  *                                                                        *\r
7  * Permission to use, copy, modify and distribute this software and its   *\r
8  * documentation strictly for non-commercial purposes is hereby granted   *\r
9  * without fee, provided that the above copyright notice appears in all   *\r
10  * copies and that both the copyright notice and this permission notice   *\r
11  * appear in the supporting documentation. The authors make no claims     *\r
12  * about the suitability of this software for any purpose. It is          *\r
13  * provided "as is" without express or implied warranty.                  *\r
14  **************************************************************************/\r
15 \r
16 /////////////////////////////////////////////////////////////\r
17 //\r
18 // Class for cuts on AOD reconstructed D0->Kpipipi\r
19 //\r
20 // Author: r.romita@gsi.de, andrea.dainese@pd.infn.it\r
21 /////////////////////////////////////////////////////////////\r
22 \r
23 #include <TDatabasePDG.h>\r
24 #include <Riostream.h>\r
25 \r
26 #include "AliRDHFCutsD0toKpipipi.h"\r
27 #include "AliAODRecoDecayHF4Prong.h"\r
28 #include "AliAODTrack.h"\r
29 #include "AliESDtrack.h"\r
30 \r
31 ClassImp(AliRDHFCutsD0toKpipipi)\r
32 \r
33 //--------------------------------------------------------------------------\r
34 AliRDHFCutsD0toKpipipi::AliRDHFCutsD0toKpipipi(const char* name) : \r
35 AliRDHFCuts(name)\r
36 {\r
37   //\r
38   // Default Constructor\r
39   //\r
40   Int_t nvars=9;\r
41   SetNVars(nvars);\r
42   TString varNames[9]={"inv. mass [GeV]",   \r
43                        "dca [cm]",\r
44                        "Dist 2-trk Vtx to PrimVtx [cm]",\r
45                        "Dist 3-trk Vtx to PrimVtx [cm]",\r
46                        "Dist 4-trk Vtx to PrimVtx [cm]",\r
47                        "cosThetaPoint",\r
48                        "pt [GeV/c]",\r
49                        "rho mass [GeV]",\r
50                        "PID cut"};\r
51   Bool_t isUpperCut[9]={kTRUE,\r
52                         kTRUE,\r
53                         kFALSE,\r
54                         kFALSE,\r
55                         kFALSE,\r
56                         kFALSE,\r
57                         kFALSE,\r
58                         kTRUE,\r
59                         kFALSE};\r
60   SetVarNames(nvars,varNames,isUpperCut);\r
61   Bool_t forOpt[9]={kFALSE,\r
62                     kTRUE,\r
63                     kTRUE,\r
64                     kTRUE,\r
65                     kTRUE,\r
66                     kTRUE,\r
67                     kFALSE,\r
68                     kFALSE,\r
69                     kFALSE};\r
70   SetVarsForOpt(5,forOpt);\r
71   Float_t limits[2]={0,999999999.};\r
72   SetPtBins(2,limits);\r
73 }\r
74 //--------------------------------------------------------------------------\r
75 AliRDHFCutsD0toKpipipi::AliRDHFCutsD0toKpipipi(const AliRDHFCutsD0toKpipipi &source) :\r
76   AliRDHFCuts(source)\r
77 {\r
78   //\r
79   // Copy constructor\r
80   //\r
81 \r
82 }\r
83 //--------------------------------------------------------------------------\r
84 AliRDHFCutsD0toKpipipi &AliRDHFCutsD0toKpipipi::operator=(const AliRDHFCutsD0toKpipipi &source)\r
85 {\r
86   //\r
87   // assignment operator\r
88   //\r
89   if(&source == this) return *this;\r
90 \r
91   AliRDHFCuts::operator=(source);\r
92 \r
93   return *this;\r
94 }\r
95 \r
96 \r
97 //---------------------------------------------------------------------------\r
98 void AliRDHFCutsD0toKpipipi::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters) {\r
99   // \r
100   // Fills in vars the values of the variables \r
101   //\r
102 \r
103   if(nvars!=fnVarsForOpt) {\r
104     printf("AliRDHFCutsD0toKpipipi::GetCutsVarsForOpt: wrong number of variables\n");\r
105     return;\r
106   }\r
107 \r
108   AliAODRecoDecayHF4Prong *dd = (AliAODRecoDecayHF4Prong*)d;\r
109 \r
110   Int_t iter=-1;\r
111 \r
112   if(fVarsForOpt[0]) {\r
113     iter++;\r
114     Double_t mD0[2],mD0bar[2];\r
115     if(TMath::Abs(pdgdaughters[1])==321 || TMath::Abs(pdgdaughters[3])==321) {\r
116       dd->InvMassD0(mD0);\r
117       if(TMath::Abs(pdgdaughters[1])==321) {\r
118        vars[iter]=mD0[0];\r
119       }else{\r
120        vars[iter]=mD0[1];\r
121       }\r
122     } else {\r
123       dd->InvMassD0bar(mD0bar);\r
124       if(TMath::Abs(pdgdaughters[0])==321) {\r
125        vars[iter]=mD0[0];\r
126       }else{\r
127        vars[iter]=mD0[1];\r
128       }\r
129    }\r
130   }\r
131 \r
132   if(fVarsForOpt[1]){\r
133     iter++;\r
134     vars[iter]=dd->GetDCA();\r
135   }\r
136 \r
137   if(fVarsForOpt[2]){\r
138     iter++;\r
139     vars[iter]=dd->GetDist12toPrim();\r
140   }\r
141   if(fVarsForOpt[3]){\r
142     iter++;\r
143     vars[iter]=dd->GetDist3toPrim();\r
144   }\r
145   if(fVarsForOpt[4]){\r
146     iter++;\r
147     vars[iter]=dd->GetDist4toPrim();\r
148   }\r
149   if(fVarsForOpt[5]){\r
150     iter++;\r
151     vars[iter]=dd->CosPointingAngle();\r
152   }\r
153   if(fVarsForOpt[6]){\r
154     iter++;\r
155     vars[iter]=dd->Pt();\r
156   }\r
157   if(fVarsForOpt[7]){\r
158     iter++;\r
159     vars[iter]=999999999.;\r
160     printf("ERROR: optmization for rho mass cut not implemented\n");\r
161   }\r
162   if(fVarsForOpt[8]){\r
163     iter++;\r
164     vars[iter]=999999999.;\r
165     printf("ERROR: optmization for PID cut not implemented\n");\r
166   }\r
167   \r
168   return;\r
169 }\r
170 //---------------------------------------------------------------------------\r
171 Int_t AliRDHFCutsD0toKpipipi::IsSelected(TObject* obj,Int_t selectionLevel) {\r
172   //\r
173   // Apply selection\r
174   //\r
175 \r
176   if(!fCutsRD){\r
177     cout<<"Cut matrix not inizialized. Exit..."<<endl;\r
178     return 0;\r
179   }\r
180   //PrintAll();\r
181   AliAODRecoDecayHF4Prong* d=(AliAODRecoDecayHF4Prong*)obj;\r
182 \r
183   if(!d){\r
184     cout<<"AliAODRecoDecayHF4Prong null"<<endl;\r
185     return 0;\r
186   }\r
187 \r
188 \r
189   // selection on daughter tracks \r
190   if(selectionLevel==AliRDHFCuts::kAll || \r
191      selectionLevel==AliRDHFCuts::kTracks) {\r
192     if(!AreDaughtersSelected(d)) return 0;\r
193   }\r
194 \r
195 \r
196   Int_t returnvalue=1;\r
197 \r
198   // selection on candidate\r
199   if(selectionLevel==AliRDHFCuts::kAll || \r
200      selectionLevel==AliRDHFCuts::kCandidate) {\r
201 \r
202     Int_t ptbin=PtBin(d->Pt());\r
203     \r
204     Int_t okD0=1,okD0bar=1;    \r
205     Double_t mD0[2],mD0bar[2];\r
206     Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();\r
207 \r
208     d->InvMassD0(mD0);\r
209     if(TMath::Abs(mD0[0]-mD0PDG) > fCutsRD[GetGlobalIndex(0,ptbin)] &&\r
210        TMath::Abs(mD0[1]-mD0PDG) > fCutsRD[GetGlobalIndex(0,ptbin)]) okD0 = 0;\r
211     d->InvMassD0bar(mD0bar);\r
212     if(TMath::Abs(mD0bar[0]-mD0PDG) > fCutsRD[GetGlobalIndex(0,ptbin)] &&\r
213        TMath::Abs(mD0bar[1]-mD0PDG) > fCutsRD[GetGlobalIndex(0,ptbin)]) okD0bar = 0;\r
214     if(!okD0 && !okD0bar) return 0;\r
215     \r
216     if(d->GetDCA() > fCutsRD[GetGlobalIndex(1,ptbin)]) return 0;\r
217     if(d->GetDist12toPrim() < fCutsRD[GetGlobalIndex(2,ptbin)]) return 0;\r
218     if(d->GetDist3toPrim() < fCutsRD[GetGlobalIndex(3,ptbin)]) return 0;\r
219     if(d->GetDist4toPrim() < fCutsRD[GetGlobalIndex(4,ptbin)]) return 0;\r
220     if(d->CosPointingAngle() < fCutsRD[GetGlobalIndex(5,ptbin)]) return 0;\r
221     if(d->Pt() < fCutsRD[GetGlobalIndex(6,ptbin)]) return 0;\r
222     if(!d->CutRhoMass(mD0,mD0bar,fCutsRD[GetGlobalIndex(0,ptbin)],fCutsRD[GetGlobalIndex(7,ptbin)])) return 0;\r
223 \r
224     if (okD0) returnvalue=1; //cuts passed as D0\r
225     if (okD0bar) returnvalue=2; //cuts passed as D0bar\r
226     if (okD0 && okD0bar) returnvalue=3; //cuts passed as D0 and D0bar\r
227   }\r
228 \r
229   return returnvalue;\r
230 }\r
231 //---------------------------------------------------------------------------\r