]>
Commit | Line | Data |
---|---|---|
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 | // Base class for cuts on AOD reconstructed heavy-flavour decay | |
19 | // | |
20 | // Author: A.Dainese, andrea.dainese@pd.infn.it | |
21 | ///////////////////////////////////////////////////////////// | |
22 | #include <Riostream.h> | |
23 | ||
24 | #include "AliVEvent.h" | |
25 | #include "AliESDEvent.h" | |
26 | #include "AliAODEvent.h" | |
27 | #include "AliVVertex.h" | |
28 | #include "AliESDVertex.h" | |
29 | #include "AliAODVertex.h" | |
3cbc09cd | 30 | #include "AliESDtrack.h" |
31 | #include "AliAODTrack.h" | |
650b3ced | 32 | #include "AliESDtrackCuts.h" |
33 | #include "AliAODRecoDecayHF.h" | |
34 | #include "AliRDHFCuts.h" | |
35 | ||
36 | ClassImp(AliRDHFCuts) | |
37 | ||
38 | //-------------------------------------------------------------------------- | |
39 | AliRDHFCuts::AliRDHFCuts(const Char_t* name, const Char_t* title) : | |
40 | AliAnalysisCuts(name,title), | |
41 | fMinVtxType(3), | |
42 | fMinVtxContr(1), | |
43 | fMaxVtxRedChi2(1e6), | |
44 | fMinSPDMultiplicity(0), | |
45 | fTriggerMask(0), | |
46 | fTrackCuts(0), | |
47 | fnPtBins(1), | |
48 | fnPtBinLimits(1), | |
49 | fPtBinLimits(0), | |
50 | fnVars(1), | |
51 | fVarNames(0), | |
52 | fnVarsForOpt(0), | |
53 | fVarsForOpt(0), | |
54 | fGlobalIndex(1), | |
55 | fCutsRD(0), | |
c96634a2 | 56 | fIsUpperCut(0), |
57 | fUsePID(kFALSE) | |
650b3ced | 58 | { |
59 | // | |
60 | // Default Constructor | |
61 | // | |
62 | } | |
63 | //-------------------------------------------------------------------------- | |
64 | AliRDHFCuts::AliRDHFCuts(const AliRDHFCuts &source) : | |
65 | AliAnalysisCuts(source), | |
66 | fMinVtxType(source.fMinVtxType), | |
67 | fMinVtxContr(source.fMinVtxContr), | |
68 | fMaxVtxRedChi2(source.fMaxVtxRedChi2), | |
69 | fMinSPDMultiplicity(source.fMinSPDMultiplicity), | |
70 | fTriggerMask(source.fTriggerMask), | |
71 | fTrackCuts(0), | |
72 | fnPtBins(source.fnPtBins), | |
73 | fnPtBinLimits(source.fnPtBinLimits), | |
74 | fPtBinLimits(0), | |
75 | fnVars(source.fnVars), | |
76 | fVarNames(0), | |
77 | fnVarsForOpt(source.fnVarsForOpt), | |
78 | fVarsForOpt(0), | |
79 | fGlobalIndex(source.fGlobalIndex), | |
80 | fCutsRD(0), | |
c96634a2 | 81 | fIsUpperCut(0), |
82 | fUsePID(source.fUsePID) | |
650b3ced | 83 | { |
84 | // | |
85 | // Copy constructor | |
86 | // | |
87 | cout<<"Copy constructor"<<endl; | |
88 | if(source.GetTrackCuts()) AddTrackCuts(source.GetTrackCuts()); | |
650b3ced | 89 | if(source.fPtBinLimits) SetPtBins(source.fnPtBinLimits,source.fPtBinLimits); |
90 | if(source.fVarNames) SetVarNames(source.fnVars,source.fVarNames,source.fIsUpperCut); | |
91 | if(source.fCutsRD) SetCuts(source.fGlobalIndex,source.fCutsRD); | |
92 | if(source.fVarsForOpt) SetVarsForOpt(source.fnVarsForOpt,source.fVarsForOpt); | |
93 | PrintAll(); | |
650b3ced | 94 | |
95 | } | |
96 | //-------------------------------------------------------------------------- | |
97 | AliRDHFCuts &AliRDHFCuts::operator=(const AliRDHFCuts &source) | |
98 | { | |
99 | // | |
100 | // assignment operator | |
101 | // | |
102 | if(&source == this) return *this; | |
103 | ||
104 | AliAnalysisCuts::operator=(source); | |
105 | ||
106 | fMinVtxType=source.fMinVtxType; | |
107 | fMinVtxContr=source.fMinVtxContr; | |
108 | fMaxVtxRedChi2=source.fMaxVtxRedChi2; | |
109 | fMinSPDMultiplicity=source.fMinSPDMultiplicity; | |
110 | fTriggerMask=source.fTriggerMask; | |
111 | fnPtBins=source.fnPtBins; | |
112 | fnVars=source.fnVars; | |
113 | fGlobalIndex=source.fGlobalIndex; | |
114 | fnVarsForOpt=source.fnVarsForOpt; | |
c96634a2 | 115 | fUsePID=source.fUsePID; |
650b3ced | 116 | |
bbbf8c32 | 117 | if(source.GetTrackCuts()) AddTrackCuts(source.GetTrackCuts()); |
650b3ced | 118 | if(source.fPtBinLimits) SetPtBins(source.fnPtBinLimits,source.fPtBinLimits); |
119 | if(source.fVarNames) SetVarNames(source.fnVars,source.fVarNames,source.fIsUpperCut); | |
120 | if(source.fCutsRD) SetCuts(source.fGlobalIndex,source.fCutsRD); | |
121 | if(source.fVarsForOpt) SetVarsForOpt(source.fnVarsForOpt,source.fVarsForOpt); | |
122 | PrintAll(); | |
123 | ||
650b3ced | 124 | return *this; |
125 | } | |
126 | //-------------------------------------------------------------------------- | |
127 | AliRDHFCuts::~AliRDHFCuts() { | |
128 | // | |
129 | // Default Destructor | |
130 | // | |
131 | if(fPtBinLimits) {delete [] fPtBinLimits; fPtBinLimits=0;} | |
132 | if(fVarNames) {delete [] fVarNames; fVarNames=0;} | |
133 | if(fVarsForOpt) {delete [] fVarsForOpt; fVarsForOpt=0;} | |
134 | if(fCutsRD) { | |
135 | delete [] fCutsRD; | |
136 | fCutsRD=0; | |
137 | } | |
138 | if(fIsUpperCut) {delete [] fIsUpperCut; fIsUpperCut=0;} | |
139 | ||
140 | } | |
141 | //--------------------------------------------------------------------------- | |
142 | Bool_t AliRDHFCuts::IsEventSelected(AliVEvent *event) const { | |
143 | // | |
144 | // Event selection | |
145 | // | |
3cbc09cd | 146 | //if(fTriggerMask && event->GetTriggerMask()!=fTriggerMask) return kFALSE; |
650b3ced | 147 | |
148 | // multiplicity cuts no implemented yet | |
149 | ||
150 | const AliVVertex *vertex = event->GetPrimaryVertex(); | |
151 | ||
152 | if(!vertex) return kFALSE; | |
153 | ||
154 | TString title=vertex->GetTitle(); | |
155 | if(title.Contains("Z") && fMinVtxType>1) return kFALSE; | |
156 | if(title.Contains("3D") && fMinVtxType>2) return kFALSE; | |
157 | ||
158 | if(vertex->GetNContributors()<fMinVtxContr) return kFALSE; | |
159 | ||
160 | return kTRUE; | |
161 | } | |
162 | //--------------------------------------------------------------------------- | |
3cbc09cd | 163 | Bool_t AliRDHFCuts::AreDaughtersSelected(AliAODRecoDecayHF *d) const { |
164 | // | |
165 | // Daughter tracks selection | |
166 | // | |
85d335a7 | 167 | if(!fTrackCuts) return kTRUE; |
168 | ||
3cbc09cd | 169 | Int_t ndaughters = d->GetNDaughters(); |
170 | AliESDtrack* esdTrack=0; | |
85d335a7 | 171 | AliAODVertex *vAOD = d->GetPrimaryVtx(); |
172 | Double_t pos[3],cov[6]; | |
173 | vAOD->GetXYZ(pos); | |
174 | vAOD->GetCovarianceMatrix(cov); | |
175 | const AliESDVertex *vESD = new AliESDVertex(pos,cov,100.,100); | |
176 | ||
177 | Bool_t retval=kTRUE; | |
3cbc09cd | 178 | |
179 | for(Int_t idg=0; idg<ndaughters; idg++) { | |
180 | AliAODTrack *dgTrack = (AliAODTrack*)d->GetDaughter(idg); | |
85d335a7 | 181 | if(!dgTrack) retval = kFALSE; |
3cbc09cd | 182 | //printf("charge %d\n",dgTrack->Charge()); |
183 | if(dgTrack->Charge()==0) continue; // it's not a track, but a V0 | |
184 | // convert to ESD track here | |
85d335a7 | 185 | esdTrack=new AliESDtrack(dgTrack); |
186 | // needed to calculate the impact parameters | |
187 | esdTrack->RelateToVertex(vESD,0.,3.); | |
188 | if(!fTrackCuts->IsSelected(esdTrack)) retval = kFALSE; | |
3cbc09cd | 189 | delete esdTrack; esdTrack=0; |
190 | } | |
85d335a7 | 191 | |
192 | delete vESD; vESD=0; | |
193 | ||
194 | return retval; | |
3cbc09cd | 195 | } |
196 | //--------------------------------------------------------------------------- | |
650b3ced | 197 | void AliRDHFCuts::SetPtBins(Int_t nPtBinLimits,Float_t *ptBinLimits) { |
198 | // Set the pt bins | |
199 | ||
200 | if(fPtBinLimits) { | |
201 | delete [] fPtBinLimits; | |
202 | fPtBinLimits = NULL; | |
203 | printf("Changing the pt bins\n"); | |
204 | } | |
205 | ||
206 | if(nPtBinLimits != fnPtBins+1){ | |
207 | cout<<"Warning: ptBinLimits dimention "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBins+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl; | |
208 | SetNPtBins(nPtBinLimits-1); | |
209 | } | |
210 | ||
211 | fnPtBinLimits = nPtBinLimits; | |
212 | SetGlobalIndex(); | |
213 | cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl; | |
214 | fPtBinLimits = new Float_t[fnPtBinLimits]; | |
215 | for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimits[ib]=ptBinLimits[ib]; | |
216 | ||
217 | return; | |
218 | } | |
219 | //--------------------------------------------------------------------------- | |
220 | void AliRDHFCuts::SetVarNames(Int_t nVars,TString *varNames,Bool_t *isUpperCut){ | |
221 | // Set the variable names | |
222 | ||
223 | if(fVarNames) { | |
224 | delete [] fVarNames; | |
225 | fVarNames = NULL; | |
226 | printf("Changing the variable names\n"); | |
227 | } | |
228 | if(nVars!=fnVars){ | |
229 | printf("Wrong number of variables: it has to be %d\n",fnVars); | |
230 | return; | |
231 | } | |
232 | //fnVars=nVars; | |
233 | fVarNames = new TString[nVars]; | |
234 | fIsUpperCut = new Bool_t[nVars]; | |
235 | for(Int_t iv=0; iv<nVars; iv++) { | |
236 | fVarNames[iv] = varNames[iv]; | |
237 | fIsUpperCut[iv] = isUpperCut[iv]; | |
238 | } | |
239 | ||
240 | return; | |
241 | } | |
242 | //--------------------------------------------------------------------------- | |
243 | void AliRDHFCuts::SetVarsForOpt(Int_t nVars,Bool_t *forOpt) { | |
244 | // Set the variables to be used for cuts optimization | |
245 | ||
246 | if(fVarsForOpt) { | |
247 | delete [] fVarsForOpt; | |
248 | fVarsForOpt = NULL; | |
249 | printf("Changing the variables for cut optimization\n"); | |
250 | } | |
251 | ||
252 | if(nVars==0){//!=fnVars) { | |
253 | printf("%d not accepted as number of variables: it has to be %d\n",nVars,fnVars); | |
254 | return; | |
255 | } | |
256 | ||
257 | fnVarsForOpt = 0; | |
258 | fVarsForOpt = new Bool_t[fnVars]; | |
259 | for(Int_t iv=0; iv<fnVars; iv++) { | |
260 | fVarsForOpt[iv]=forOpt[iv]; | |
261 | if(fVarsForOpt[iv]) fnVarsForOpt++; | |
262 | } | |
263 | ||
264 | return; | |
265 | } | |
266 | //--------------------------------------------------------------------------- | |
267 | void AliRDHFCuts::SetCuts(Int_t nVars,Int_t nPtBins,Float_t **cutsRD) { | |
4edfaee0 | 268 | // |
269 | // store the cuts | |
270 | // | |
650b3ced | 271 | if(nVars!=fnVars) { |
272 | printf("Wrong number of variables: it has to be %d\n",fnVars); | |
273 | return; | |
274 | } | |
275 | if(nPtBins!=fnPtBins) { | |
276 | printf("Wrong number of pt bins: it has to be %d\n",fnPtBins); | |
277 | return; | |
278 | } | |
279 | ||
280 | if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex]; | |
281 | ||
4edfaee0 | 282 | |
650b3ced | 283 | for(Int_t iv=0; iv<fnVars; iv++) { |
284 | ||
285 | for(Int_t ib=0; ib<fnPtBins; ib++) { | |
286 | ||
650b3ced | 287 | //check |
4edfaee0 | 288 | if(GetGlobalIndex(iv,ib)>=fGlobalIndex) { |
650b3ced | 289 | cout<<"Overflow, exit..."<<endl; |
290 | return; | |
291 | } | |
4edfaee0 | 292 | |
293 | fCutsRD[GetGlobalIndex(iv,ib)] = cutsRD[iv][ib]; | |
294 | ||
650b3ced | 295 | } |
296 | } | |
650b3ced | 297 | return; |
298 | } | |
299 | //--------------------------------------------------------------------------- | |
300 | void AliRDHFCuts::SetCuts(Int_t glIndex,Float_t* cutsRDGlob){ | |
4edfaee0 | 301 | // |
302 | // store the cuts | |
303 | // | |
650b3ced | 304 | if(glIndex != fGlobalIndex){ |
305 | cout<<"Wrong array size: it has to be "<<fGlobalIndex<<endl; | |
306 | return; | |
307 | } | |
308 | if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex]; | |
309 | ||
310 | for(Int_t iGl=0;iGl<fGlobalIndex;iGl++){ | |
311 | fCutsRD[iGl] = cutsRDGlob[iGl]; | |
312 | } | |
650b3ced | 313 | return; |
650b3ced | 314 | } |
650b3ced | 315 | //--------------------------------------------------------------------------- |
4edfaee0 | 316 | void AliRDHFCuts::PrintAll() const { |
317 | // | |
318 | // print all cuts values | |
319 | // | |
650b3ced | 320 | if(fVarNames){ |
321 | cout<<"Array of variables"<<endl; | |
322 | for(Int_t iv=0;iv<fnVars;iv++){ | |
323 | cout<<fVarNames[iv]<<"\t"; | |
324 | } | |
325 | cout<<endl; | |
326 | } | |
327 | if(fVarsForOpt){ | |
328 | cout<<"Array of optimization"<<endl; | |
329 | for(Int_t iv=0;iv<fnVars;iv++){ | |
330 | cout<<fVarsForOpt[iv]<<"\t"; | |
331 | } | |
332 | cout<<endl; | |
333 | } | |
334 | if(fIsUpperCut){ | |
335 | cout<<"Array of upper/lower cut"<<endl; | |
336 | for(Int_t iv=0;iv<fnVars;iv++){ | |
337 | cout<<fIsUpperCut[iv]<<"\t"; | |
338 | } | |
339 | cout<<endl; | |
340 | } | |
341 | if(fPtBinLimits){ | |
342 | cout<<"Array of ptbin limits"<<endl; | |
343 | for(Int_t ib=0;ib<fnPtBinLimits;ib++){ | |
344 | cout<<fPtBinLimits[ib]<<"\t"; | |
345 | } | |
346 | cout<<endl; | |
347 | } | |
348 | if(fCutsRD){ | |
349 | cout<<"Matrix of cuts"<<endl; | |
350 | for(Int_t iv=0;iv<fnVars;iv++){ | |
351 | for(Int_t ib=0;ib<fnPtBins;ib++){ | |
352 | cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<"\t"; | |
353 | } | |
354 | cout<<endl; | |
355 | } | |
356 | cout<<endl; | |
357 | } | |
4edfaee0 | 358 | return; |
650b3ced | 359 | } |
650b3ced | 360 | //--------------------------------------------------------------------------- |
361 | void AliRDHFCuts::GetCuts(Float_t**& cutsRD) const{ | |
4edfaee0 | 362 | // |
650b3ced | 363 | // get the cuts |
4edfaee0 | 364 | // |
650b3ced | 365 | |
4edfaee0 | 366 | //cout<<"Give back a "<<fnVars<<"x"<<fnPtBins<<" matrix."<<endl; |
650b3ced | 367 | |
650b3ced | 368 | |
4edfaee0 | 369 | Int_t iv,ib; |
650b3ced | 370 | if(!cutsRD) { |
4edfaee0 | 371 | //cout<<"Initialization..."<<endl; |
650b3ced | 372 | cutsRD=new Float_t*[fnVars]; |
4edfaee0 | 373 | for(iv=0; iv<fnVars; iv++) { |
650b3ced | 374 | cutsRD[iv] = new Float_t[fnPtBins]; |
375 | } | |
376 | } | |
377 | ||
4edfaee0 | 378 | for(Int_t iGlobal=0; iGlobal<fGlobalIndex; iGlobal++) { |
379 | GetVarPtIndex(iGlobal,iv,ib); | |
380 | cutsRD[iv][ib] = fCutsRD[iGlobal]; | |
650b3ced | 381 | } |
382 | ||
4edfaee0 | 383 | return; |
650b3ced | 384 | } |
385 | ||
386 | //--------------------------------------------------------------------------- | |
387 | Int_t AliRDHFCuts::GetGlobalIndex(Int_t iVar,Int_t iPtBin) const{ | |
4edfaee0 | 388 | // |
3cbc09cd | 389 | // give the global index from variable and pt bin |
4edfaee0 | 390 | // |
650b3ced | 391 | return iPtBin*fnVars+iVar; |
392 | } | |
393 | ||
394 | //--------------------------------------------------------------------------- | |
395 | void AliRDHFCuts::GetVarPtIndex(Int_t iGlob, Int_t& iVar, Int_t& iPtBin) const { | |
4edfaee0 | 396 | // |
650b3ced | 397 | //give the index of the variable and of the pt bin from the global index |
4edfaee0 | 398 | // |
650b3ced | 399 | iPtBin=(Int_t)iGlob/fnVars; |
400 | iVar=iGlob%fnVars; | |
401 | ||
4edfaee0 | 402 | return; |
650b3ced | 403 | } |
404 | ||
405 | //--------------------------------------------------------------------------- | |
406 | Int_t AliRDHFCuts::PtBin(Double_t pt) const { | |
4edfaee0 | 407 | // |
650b3ced | 408 | //give the pt bin where the pt lies. |
4edfaee0 | 409 | // |
eaa73e44 | 410 | Int_t ptbin=-1; |
650b3ced | 411 | for (Int_t i=0;i<fnPtBins;i++){ |
412 | if(pt<fPtBinLimits[i+1]) { | |
413 | ptbin=i; | |
414 | break; | |
415 | } | |
416 | } | |
417 | return ptbin; | |
418 | } | |
aaf4e30f | 419 | //------------------------------------------------------------------- |
420 | Float_t AliRDHFCuts::GetCutValue(Int_t iVar,Int_t iPtBin) const { | |
421 | // | |
422 | // Give the value of cut set for the variable iVar and the pt bin iPtBin | |
423 | // | |
424 | if(!fCutsRD){ | |
425 | cout<<"Cuts not iniziaisez yet"<<endl; | |
426 | return 0; | |
427 | } | |
428 | return fCutsRD[GetGlobalIndex(iVar,iPtBin)]; | |
429 | } | |
430 |