]>
Commit | Line | Data |
---|---|---|
7a1c0c33 | 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 | ||
27de2dfb | 16 | /* $Id$ */ |
17 | ||
7a1c0c33 | 18 | ///////////////////////////////////////////////////////////// |
19 | // | |
20 | // Base class for cuts on AOD reconstructed heavy-flavour decay | |
21 | // | |
22 | // Author: A.Dainese, andrea.dainese@pd.infn.it | |
23 | ///////////////////////////////////////////////////////////// | |
24 | #include <Riostream.h> | |
25 | ||
26 | #include "AliVEvent.h" | |
27 | #include "AliESDEvent.h" | |
28 | #include "AliAODEvent.h" | |
29 | #include "AliVVertex.h" | |
30 | #include "AliESDVertex.h" | |
31 | #include "AliLog.h" | |
32 | #include "AliAODVertex.h" | |
33 | #include "AliESDtrack.h" | |
34 | #include "AliAODTrack.h" | |
35 | #include "AliESDtrackCuts.h" | |
36 | #include "AliCentrality.h" | |
37 | #include "AliAODRecoDecayHF.h" | |
77c65905 | 38 | #include "AliAnalysisVertexingHF.h" |
7a1c0c33 | 39 | #include "AliRDHFCuts.h" |
40 | ||
41 | ClassImp(AliRDHFCuts) | |
42 | ||
43 | //-------------------------------------------------------------------------- | |
44 | AliRDHFCuts::AliRDHFCuts(const Char_t* name, const Char_t* title) : | |
45 | AliAnalysisCuts(name,title), | |
46 | fMinVtxType(3), | |
47 | fMinVtxContr(1), | |
48 | fMaxVtxRedChi2(1e6), | |
49 | fMaxVtxZ(1e6), | |
50 | fMinSPDMultiplicity(0), | |
51 | fTriggerMask(0), | |
52 | fTrackCuts(0), | |
53 | fnPtBins(1), | |
54 | fnPtBinLimits(1), | |
55 | fPtBinLimits(0), | |
56 | fnVars(1), | |
57 | fVarNames(0), | |
58 | fnVarsForOpt(0), | |
59 | fVarsForOpt(0), | |
60 | fGlobalIndex(1), | |
61 | fCutsRD(0), | |
62 | fIsUpperCut(0), | |
63 | fUsePID(kFALSE), | |
64 | fPidHF(0), | |
65 | fWhyRejection(0), | |
66 | fRemoveDaughtersFromPrimary(kFALSE), | |
67 | fOptPileup(0), | |
68 | fMinContrPileup(3), | |
69 | fMinDzPileup(0.6), | |
70 | fUseCentrality(0), | |
71 | fMinCentrality(0.), | |
77c65905 | 72 | fMaxCentrality(100.), |
892e16af | 73 | fFixRefs(kFALSE), |
74 | fIsSelectedCuts(0), | |
47aa3d55 | 75 | fIsSelectedPID(0), |
76 | fMinPtCand(-1.), | |
77 | fMaxPtCand(100000.) | |
7a1c0c33 | 78 | { |
79 | // | |
80 | // Default Constructor | |
81 | // | |
82 | } | |
83 | //-------------------------------------------------------------------------- | |
84 | AliRDHFCuts::AliRDHFCuts(const AliRDHFCuts &source) : | |
85 | AliAnalysisCuts(source), | |
86 | fMinVtxType(source.fMinVtxType), | |
87 | fMinVtxContr(source.fMinVtxContr), | |
88 | fMaxVtxRedChi2(source.fMaxVtxRedChi2), | |
89 | fMaxVtxZ(source.fMaxVtxZ), | |
90 | fMinSPDMultiplicity(source.fMinSPDMultiplicity), | |
91 | fTriggerMask(source.fTriggerMask), | |
92 | fTrackCuts(0), | |
93 | fnPtBins(source.fnPtBins), | |
94 | fnPtBinLimits(source.fnPtBinLimits), | |
95 | fPtBinLimits(0), | |
96 | fnVars(source.fnVars), | |
97 | fVarNames(0), | |
98 | fnVarsForOpt(source.fnVarsForOpt), | |
99 | fVarsForOpt(0), | |
100 | fGlobalIndex(source.fGlobalIndex), | |
101 | fCutsRD(0), | |
102 | fIsUpperCut(0), | |
103 | fUsePID(source.fUsePID), | |
104 | fPidHF(0), | |
105 | fWhyRejection(source.fWhyRejection), | |
106 | fRemoveDaughtersFromPrimary(source.fRemoveDaughtersFromPrimary), | |
107 | fOptPileup(source.fOptPileup), | |
108 | fMinContrPileup(source.fMinContrPileup), | |
109 | fMinDzPileup(source.fMinDzPileup), | |
110 | fUseCentrality(source.fUseCentrality), | |
111 | fMinCentrality(source.fMinCentrality), | |
77c65905 | 112 | fMaxCentrality(source.fMaxCentrality), |
892e16af | 113 | fFixRefs(source.fFixRefs), |
114 | fIsSelectedCuts(source.fIsSelectedCuts), | |
47aa3d55 | 115 | fIsSelectedPID(source.fIsSelectedPID), |
116 | fMinPtCand(source.fMinPtCand), | |
117 | fMaxPtCand(source.fMaxPtCand) | |
7a1c0c33 | 118 | { |
119 | // | |
120 | // Copy constructor | |
121 | // | |
122 | cout<<"Copy constructor"<<endl; | |
123 | if(source.GetTrackCuts()) AddTrackCuts(source.GetTrackCuts()); | |
124 | if(source.fPtBinLimits) SetPtBins(source.fnPtBinLimits,source.fPtBinLimits); | |
125 | if(source.fVarNames) SetVarNames(source.fnVars,source.fVarNames,source.fIsUpperCut); | |
126 | if(source.fCutsRD) SetCuts(source.fGlobalIndex,source.fCutsRD); | |
127 | if(source.fVarsForOpt) SetVarsForOpt(source.fnVarsForOpt,source.fVarsForOpt); | |
128 | if(source.fPidHF) SetPidHF(source.fPidHF); | |
129 | PrintAll(); | |
130 | ||
131 | } | |
132 | //-------------------------------------------------------------------------- | |
133 | AliRDHFCuts &AliRDHFCuts::operator=(const AliRDHFCuts &source) | |
134 | { | |
135 | // | |
136 | // assignment operator | |
137 | // | |
138 | if(&source == this) return *this; | |
139 | ||
140 | AliAnalysisCuts::operator=(source); | |
141 | ||
142 | fMinVtxType=source.fMinVtxType; | |
143 | fMinVtxContr=source.fMinVtxContr; | |
144 | fMaxVtxRedChi2=source.fMaxVtxRedChi2; | |
145 | fMaxVtxZ=source.fMaxVtxZ; | |
146 | fMinSPDMultiplicity=source.fMinSPDMultiplicity; | |
147 | fTriggerMask=source.fTriggerMask; | |
148 | fnPtBins=source.fnPtBins; | |
149 | fnVars=source.fnVars; | |
150 | fGlobalIndex=source.fGlobalIndex; | |
151 | fnVarsForOpt=source.fnVarsForOpt; | |
152 | fUsePID=source.fUsePID; | |
153 | SetPidHF(source.GetPidHF()); | |
154 | fWhyRejection=source.fWhyRejection; | |
155 | fRemoveDaughtersFromPrimary=source.fRemoveDaughtersFromPrimary; | |
156 | fOptPileup=source.fOptPileup; | |
157 | fMinContrPileup=source.fMinContrPileup; | |
158 | fMinDzPileup=source.fMinDzPileup; | |
159 | fUseCentrality=source.fUseCentrality; | |
160 | fMinCentrality=source.fMinCentrality; | |
161 | fMaxCentrality=source.fMaxCentrality; | |
77c65905 | 162 | fFixRefs=source.fFixRefs; |
892e16af | 163 | fIsSelectedCuts=source.fIsSelectedCuts; |
164 | fIsSelectedPID=source.fIsSelectedPID; | |
47aa3d55 | 165 | fMinPtCand=source.fMinPtCand; |
166 | fMaxPtCand=source.fMaxPtCand; | |
7a1c0c33 | 167 | |
168 | if(source.GetTrackCuts()) AddTrackCuts(source.GetTrackCuts()); | |
169 | if(source.fPtBinLimits) SetPtBins(source.fnPtBinLimits,source.fPtBinLimits); | |
170 | if(source.fVarNames) SetVarNames(source.fnVars,source.fVarNames,source.fIsUpperCut); | |
171 | if(source.fCutsRD) SetCuts(source.fGlobalIndex,source.fCutsRD); | |
172 | if(source.fVarsForOpt) SetVarsForOpt(source.fnVarsForOpt,source.fVarsForOpt); | |
173 | PrintAll(); | |
174 | ||
175 | return *this; | |
176 | } | |
177 | //-------------------------------------------------------------------------- | |
178 | AliRDHFCuts::~AliRDHFCuts() { | |
179 | // | |
180 | // Default Destructor | |
181 | // | |
182 | if(fPtBinLimits) {delete [] fPtBinLimits; fPtBinLimits=0;} | |
183 | if(fVarNames) {delete [] fVarNames; fVarNames=0;} | |
184 | if(fVarsForOpt) {delete [] fVarsForOpt; fVarsForOpt=0;} | |
185 | if(fCutsRD) { | |
186 | delete [] fCutsRD; | |
187 | fCutsRD=0; | |
188 | } | |
189 | if(fIsUpperCut) {delete [] fIsUpperCut; fIsUpperCut=0;} | |
190 | if(fPidHF){ | |
191 | delete fPidHF; | |
192 | fPidHF=0; | |
193 | } | |
194 | } | |
195 | //--------------------------------------------------------------------------- | |
892e16af | 196 | Int_t AliRDHFCuts::IsEventSelectedInCentrality(AliVEvent *event) { |
197 | // | |
198 | // Centrality selection | |
199 | // | |
200 | ||
201 | if(fUseCentrality<kCentOff||fUseCentrality>=kCentInvalid){ | |
202 | AliWarning("Centrality estimator not valid"); | |
203 | return 3; | |
204 | }else{ | |
205 | Float_t centvalue=GetCentrality((AliAODEvent*)event); | |
206 | if (centvalue<0.){ | |
207 | return 0; | |
208 | }else{ | |
209 | if (centvalue<fMinCentrality || centvalue>fMaxCentrality){ | |
210 | return 2; | |
211 | } | |
212 | } | |
213 | } | |
214 | return 0; | |
215 | } | |
216 | //--------------------------------------------------------------------------- | |
7a1c0c33 | 217 | Bool_t AliRDHFCuts::IsEventSelected(AliVEvent *event) { |
218 | // | |
219 | // Event selection | |
220 | // | |
221 | //if(fTriggerMask && event->GetTriggerMask()!=fTriggerMask) return kFALSE; | |
222 | ||
77c65905 | 223 | // TEMPORARY FIX FOR REFERENCES |
224 | // Fix references to daughter tracks | |
225 | if(fFixRefs) { | |
226 | AliAnalysisVertexingHF *fixer = new AliAnalysisVertexingHF(); | |
227 | fixer->FixReferences((AliAODEvent*)event); | |
228 | delete fixer; | |
229 | } | |
230 | // | |
231 | ||
232 | ||
7a1c0c33 | 233 | fWhyRejection=0; |
234 | ||
235 | // multiplicity cuts no implemented yet | |
236 | ||
237 | const AliVVertex *vertex = event->GetPrimaryVertex(); | |
238 | ||
239 | if(!vertex) return kFALSE; | |
240 | ||
241 | TString title=vertex->GetTitle(); | |
242 | if(title.Contains("Z") && fMinVtxType>1) return kFALSE; | |
243 | if(title.Contains("3D") && fMinVtxType>2) return kFALSE; | |
244 | ||
245 | if(vertex->GetNContributors()<fMinVtxContr) return kFALSE; | |
246 | ||
247 | if(TMath::Abs(vertex->GetZ())>fMaxVtxZ) return kFALSE; | |
248 | ||
249 | // switch to settings for 1-pad cls in TPC | |
250 | if(fPidHF) { | |
251 | if(event->GetRunNumber()>121693 && event->GetRunNumber()<136851) | |
252 | fPidHF->SetOnePad(kTRUE); | |
253 | if(event->GetRunNumber()>=136851 && event->GetRunNumber()<=139517) | |
254 | fPidHF->SetPbPb(kTRUE); | |
255 | } | |
256 | ||
257 | if(fOptPileup==kRejectPileupEvent){ | |
258 | Int_t cutc=(Int_t)fMinContrPileup; | |
259 | Double_t cutz=(Double_t)fMinDzPileup; | |
260 | if(event->IsPileupFromSPD(cutc,cutz,3.,2.,10.)) { | |
261 | fWhyRejection=1; | |
262 | return kFALSE; | |
263 | } | |
264 | } | |
265 | ||
266 | //centrality selection | |
892e16af | 267 | if (fUseCentrality!=kCentOff) { |
268 | Int_t rejection=IsEventSelectedInCentrality(event); | |
269 | if(rejection>1){ | |
270 | fWhyRejection=rejection; | |
271 | return kFALSE; | |
7a1c0c33 | 272 | } |
273 | } | |
274 | ||
7a1c0c33 | 275 | return kTRUE; |
276 | } | |
277 | //--------------------------------------------------------------------------- | |
278 | Bool_t AliRDHFCuts::AreDaughtersSelected(AliAODRecoDecayHF *d) const { | |
279 | // | |
280 | // Daughter tracks selection | |
281 | // | |
282 | if(!fTrackCuts) return kTRUE; | |
dc222f77 | 283 | |
7a1c0c33 | 284 | Int_t ndaughters = d->GetNDaughters(); |
285 | AliAODVertex *vAOD = d->GetPrimaryVtx(); | |
286 | Double_t pos[3],cov[6]; | |
287 | vAOD->GetXYZ(pos); | |
288 | vAOD->GetCovarianceMatrix(cov); | |
289 | const AliESDVertex vESD(pos,cov,100.,100); | |
dc222f77 | 290 | |
7a1c0c33 | 291 | Bool_t retval=kTRUE; |
dc222f77 | 292 | |
7a1c0c33 | 293 | for(Int_t idg=0; idg<ndaughters; idg++) { |
294 | AliAODTrack *dgTrack = (AliAODTrack*)d->GetDaughter(idg); | |
fd20854c | 295 | if(!dgTrack) {retval = kFALSE; continue;} |
7a1c0c33 | 296 | //printf("charge %d\n",dgTrack->Charge()); |
297 | if(dgTrack->Charge()==0) continue; // it's not a track, but a V0 | |
298 | ||
299 | if(!IsDaughterSelected(dgTrack,&vESD,fTrackCuts)) retval = kFALSE; | |
300 | } | |
dc222f77 | 301 | |
7a1c0c33 | 302 | return retval; |
303 | } | |
304 | //--------------------------------------------------------------------------- | |
305 | Bool_t AliRDHFCuts::IsDaughterSelected(AliAODTrack *track,const AliESDVertex *primary,AliESDtrackCuts *cuts) const { | |
306 | // | |
307 | // Convert to ESDtrack, relate to vertex and check cuts | |
308 | // | |
309 | if(!cuts) return kTRUE; | |
310 | ||
311 | Bool_t retval=kTRUE; | |
312 | ||
313 | // convert to ESD track here | |
314 | AliESDtrack esdTrack(track); | |
84d5345b | 315 | // set the TPC cluster info |
316 | esdTrack.SetTPCClusterMap(track->GetTPCClusterMap()); | |
317 | esdTrack.SetTPCSharedMap(track->GetTPCSharedMap()); | |
318 | esdTrack.SetTPCPointsF(track->GetTPCNclsF()); | |
7a1c0c33 | 319 | // needed to calculate the impact parameters |
320 | esdTrack.RelateToVertex(primary,0.,3.); | |
84d5345b | 321 | |
7a1c0c33 | 322 | if(!cuts->IsSelected(&esdTrack)) retval = kFALSE; |
323 | ||
324 | if(fOptPileup==kRejectTracksFromPileupVertex){ | |
325 | // to be implemented | |
326 | // we need either to have here the AOD Event, | |
327 | // or to have the pileup vertex object | |
328 | } | |
329 | return retval; | |
330 | } | |
331 | //--------------------------------------------------------------------------- | |
332 | void AliRDHFCuts::SetPtBins(Int_t nPtBinLimits,Float_t *ptBinLimits) { | |
333 | // Set the pt bins | |
334 | ||
335 | if(fPtBinLimits) { | |
336 | delete [] fPtBinLimits; | |
337 | fPtBinLimits = NULL; | |
338 | printf("Changing the pt bins\n"); | |
339 | } | |
340 | ||
341 | if(nPtBinLimits != fnPtBins+1){ | |
342 | cout<<"Warning: ptBinLimits dimention "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBins+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl; | |
343 | SetNPtBins(nPtBinLimits-1); | |
344 | } | |
345 | ||
346 | fnPtBinLimits = nPtBinLimits; | |
347 | SetGlobalIndex(); | |
348 | //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl; | |
349 | fPtBinLimits = new Float_t[fnPtBinLimits]; | |
350 | for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimits[ib]=ptBinLimits[ib]; | |
351 | ||
352 | return; | |
353 | } | |
354 | //--------------------------------------------------------------------------- | |
355 | void AliRDHFCuts::SetVarNames(Int_t nVars,TString *varNames,Bool_t *isUpperCut){ | |
356 | // Set the variable names | |
357 | ||
358 | if(fVarNames) { | |
359 | delete [] fVarNames; | |
360 | fVarNames = NULL; | |
361 | //printf("Changing the variable names\n"); | |
362 | } | |
363 | if(nVars!=fnVars){ | |
364 | printf("Wrong number of variables: it has to be %d\n",fnVars); | |
365 | return; | |
366 | } | |
367 | //fnVars=nVars; | |
368 | fVarNames = new TString[nVars]; | |
369 | fIsUpperCut = new Bool_t[nVars]; | |
370 | for(Int_t iv=0; iv<nVars; iv++) { | |
371 | fVarNames[iv] = varNames[iv]; | |
372 | fIsUpperCut[iv] = isUpperCut[iv]; | |
373 | } | |
374 | ||
375 | return; | |
376 | } | |
377 | //--------------------------------------------------------------------------- | |
378 | void AliRDHFCuts::SetVarsForOpt(Int_t nVars,Bool_t *forOpt) { | |
379 | // Set the variables to be used for cuts optimization | |
380 | ||
381 | if(fVarsForOpt) { | |
382 | delete [] fVarsForOpt; | |
383 | fVarsForOpt = NULL; | |
384 | //printf("Changing the variables for cut optimization\n"); | |
385 | } | |
386 | ||
387 | if(nVars==0){//!=fnVars) { | |
388 | printf("%d not accepted as number of variables: it has to be %d\n",nVars,fnVars); | |
389 | return; | |
390 | } | |
391 | ||
392 | fnVarsForOpt = 0; | |
393 | fVarsForOpt = new Bool_t[fnVars]; | |
394 | for(Int_t iv=0; iv<fnVars; iv++) { | |
395 | fVarsForOpt[iv]=forOpt[iv]; | |
396 | if(fVarsForOpt[iv]) fnVarsForOpt++; | |
397 | } | |
398 | ||
399 | return; | |
400 | } | |
401 | ||
402 | //--------------------------------------------------------------------------- | |
403 | void AliRDHFCuts::SetUseCentrality(Int_t flag) { | |
404 | // | |
405 | // set centrality estimator | |
406 | // | |
407 | fUseCentrality=flag; | |
408 | if(fUseCentrality<kCentOff||fUseCentrality>=kCentInvalid) AliWarning("Centrality estimator not valid"); | |
409 | ||
410 | return; | |
411 | } | |
412 | ||
413 | ||
414 | //--------------------------------------------------------------------------- | |
415 | void AliRDHFCuts::SetCuts(Int_t nVars,Int_t nPtBins,Float_t **cutsRD) { | |
416 | // | |
417 | // store the cuts | |
418 | // | |
419 | if(nVars!=fnVars) { | |
420 | printf("Wrong number of variables: it has to be %d\n",fnVars); | |
421 | return; | |
422 | } | |
423 | if(nPtBins!=fnPtBins) { | |
424 | printf("Wrong number of pt bins: it has to be %d\n",fnPtBins); | |
425 | return; | |
426 | } | |
427 | ||
428 | if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex]; | |
429 | ||
430 | ||
431 | for(Int_t iv=0; iv<fnVars; iv++) { | |
432 | ||
433 | for(Int_t ib=0; ib<fnPtBins; ib++) { | |
434 | ||
435 | //check | |
436 | if(GetGlobalIndex(iv,ib)>=fGlobalIndex) { | |
437 | cout<<"Overflow, exit..."<<endl; | |
438 | return; | |
439 | } | |
440 | ||
441 | fCutsRD[GetGlobalIndex(iv,ib)] = cutsRD[iv][ib]; | |
442 | ||
443 | } | |
444 | } | |
445 | return; | |
446 | } | |
447 | //--------------------------------------------------------------------------- | |
448 | void AliRDHFCuts::SetCuts(Int_t glIndex,Float_t* cutsRDGlob){ | |
449 | // | |
450 | // store the cuts | |
451 | // | |
452 | if(glIndex != fGlobalIndex){ | |
453 | cout<<"Wrong array size: it has to be "<<fGlobalIndex<<endl; | |
454 | return; | |
455 | } | |
456 | if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex]; | |
457 | ||
458 | for(Int_t iGl=0;iGl<fGlobalIndex;iGl++){ | |
459 | fCutsRD[iGl] = cutsRDGlob[iGl]; | |
460 | } | |
461 | return; | |
462 | } | |
463 | //--------------------------------------------------------------------------- | |
464 | void AliRDHFCuts::PrintAll() const { | |
465 | // | |
466 | // print all cuts values | |
467 | // | |
468 | ||
469 | printf("Minimum vtx type %d\n",fMinVtxType); | |
470 | printf("Minimum vtx contr %d\n",fMinVtxContr); | |
471 | printf("Max vtx red chi2 %f\n",fMaxVtxRedChi2); | |
472 | printf("Min SPD mult %d\n",fMinSPDMultiplicity); | |
473 | printf("Use PID %d\n",(Int_t)fUsePID); | |
474 | printf("Remove daughters from vtx %d\n",(Int_t)fRemoveDaughtersFromPrimary); | |
475 | printf("Pileup rejection: %s\n",(fOptPileup > 0) ? "Yes" : "No"); | |
476 | if(fOptPileup==1) printf(" -- Reject pileup event"); | |
477 | if(fOptPileup==2) printf(" -- Reject tracks from pileup vtx"); | |
478 | if(fUseCentrality>0) { | |
479 | TString estimator=""; | |
480 | if(fUseCentrality==1) estimator = "V0"; | |
481 | if(fUseCentrality==2) estimator = "Tracks"; | |
482 | if(fUseCentrality==3) estimator = "Tracklets"; | |
483 | if(fUseCentrality==4) estimator = "SPD clusters outer"; | |
484 | printf("Centrality class considered: %.1f-%.1f, estimated with %s",fMinCentrality,fMaxCentrality,estimator.Data()); | |
485 | } | |
486 | ||
487 | if(fVarNames){ | |
488 | cout<<"Array of variables"<<endl; | |
489 | for(Int_t iv=0;iv<fnVars;iv++){ | |
490 | cout<<fVarNames[iv]<<"\t"; | |
491 | } | |
492 | cout<<endl; | |
493 | } | |
494 | if(fVarsForOpt){ | |
495 | cout<<"Array of optimization"<<endl; | |
496 | for(Int_t iv=0;iv<fnVars;iv++){ | |
497 | cout<<fVarsForOpt[iv]<<"\t"; | |
498 | } | |
499 | cout<<endl; | |
500 | } | |
501 | if(fIsUpperCut){ | |
502 | cout<<"Array of upper/lower cut"<<endl; | |
503 | for(Int_t iv=0;iv<fnVars;iv++){ | |
504 | cout<<fIsUpperCut[iv]<<"\t"; | |
505 | } | |
506 | cout<<endl; | |
507 | } | |
508 | if(fPtBinLimits){ | |
509 | cout<<"Array of ptbin limits"<<endl; | |
510 | for(Int_t ib=0;ib<fnPtBinLimits;ib++){ | |
511 | cout<<fPtBinLimits[ib]<<"\t"; | |
512 | } | |
513 | cout<<endl; | |
514 | } | |
515 | if(fCutsRD){ | |
516 | cout<<"Matrix of cuts"<<endl; | |
517 | for(Int_t iv=0;iv<fnVars;iv++){ | |
518 | for(Int_t ib=0;ib<fnPtBins;ib++){ | |
519 | cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<"\t"; | |
77c65905 | 520 | } |
7a1c0c33 | 521 | cout<<endl; |
522 | } | |
523 | cout<<endl; | |
524 | } | |
525 | return; | |
526 | } | |
527 | //--------------------------------------------------------------------------- | |
528 | void AliRDHFCuts::GetCuts(Float_t**& cutsRD) const{ | |
529 | // | |
530 | // get the cuts | |
531 | // | |
532 | ||
533 | //cout<<"Give back a "<<fnVars<<"x"<<fnPtBins<<" matrix."<<endl; | |
534 | ||
535 | ||
536 | Int_t iv,ib; | |
537 | if(!cutsRD) { | |
538 | //cout<<"Initialization..."<<endl; | |
539 | cutsRD=new Float_t*[fnVars]; | |
540 | for(iv=0; iv<fnVars; iv++) { | |
541 | cutsRD[iv] = new Float_t[fnPtBins]; | |
542 | } | |
543 | } | |
544 | ||
545 | for(Int_t iGlobal=0; iGlobal<fGlobalIndex; iGlobal++) { | |
546 | GetVarPtIndex(iGlobal,iv,ib); | |
547 | cutsRD[iv][ib] = fCutsRD[iGlobal]; | |
548 | } | |
549 | ||
550 | return; | |
551 | } | |
552 | ||
553 | //--------------------------------------------------------------------------- | |
554 | Int_t AliRDHFCuts::GetGlobalIndex(Int_t iVar,Int_t iPtBin) const{ | |
555 | // | |
556 | // give the global index from variable and pt bin | |
557 | // | |
558 | return iPtBin*fnVars+iVar; | |
559 | } | |
560 | ||
561 | //--------------------------------------------------------------------------- | |
562 | void AliRDHFCuts::GetVarPtIndex(Int_t iGlob, Int_t& iVar, Int_t& iPtBin) const { | |
563 | // | |
564 | //give the index of the variable and of the pt bin from the global index | |
565 | // | |
566 | iPtBin=(Int_t)iGlob/fnVars; | |
567 | iVar=iGlob%fnVars; | |
568 | ||
569 | return; | |
570 | } | |
571 | ||
572 | //--------------------------------------------------------------------------- | |
573 | Int_t AliRDHFCuts::PtBin(Double_t pt) const { | |
574 | // | |
575 | //give the pt bin where the pt lies. | |
576 | // | |
577 | Int_t ptbin=-1; | |
5639e412 | 578 | if(pt<fPtBinLimits[0])return ptbin; |
7a1c0c33 | 579 | for (Int_t i=0;i<fnPtBins;i++){ |
580 | if(pt<fPtBinLimits[i+1]) { | |
581 | ptbin=i; | |
582 | break; | |
583 | } | |
584 | } | |
585 | return ptbin; | |
586 | } | |
587 | //------------------------------------------------------------------- | |
588 | Float_t AliRDHFCuts::GetCutValue(Int_t iVar,Int_t iPtBin) const { | |
589 | // | |
590 | // Give the value of cut set for the variable iVar and the pt bin iPtBin | |
591 | // | |
592 | if(!fCutsRD){ | |
593 | cout<<"Cuts not iniziaisez yet"<<endl; | |
594 | return 0; | |
595 | } | |
596 | return fCutsRD[GetGlobalIndex(iVar,iPtBin)]; | |
597 | } | |
598 | //------------------------------------------------------------------- | |
599 | Float_t AliRDHFCuts::GetCentrality(AliAODEvent* aodEvent,AliRDHFCuts::ECentrality estimator) const { | |
600 | // | |
601 | // Get centrality percentile | |
602 | // | |
603 | AliAODHeader *header=aodEvent->GetHeader(); | |
604 | AliCentrality *centrality=header->GetCentralityP(); | |
605 | Float_t cent=-999.; | |
606 | if(!centrality) return cent; | |
607 | else{ | |
608 | if (estimator==kCentV0M) cent=(Float_t)(centrality->GetCentralityPercentile("V0M")); | |
609 | else { | |
610 | if (estimator==kCentTRK) cent=(Float_t)(centrality->GetCentralityPercentile("TRK")); | |
611 | else{ | |
612 | if (estimator==kCentTKL) cent=(Float_t)(centrality->GetCentralityPercentile("TKL")); | |
613 | else{ | |
614 | if (estimator==kCentCL1) cent=(Float_t)(centrality->GetCentralityPercentile("CL1")); | |
615 | else { | |
616 | AliWarning("Centrality estimator not valid"); | |
617 | ||
618 | } | |
619 | } | |
620 | } | |
621 | } | |
622 | } | |
623 | return cent; | |
624 | } | |
625 | //------------------------------------------------------------------- | |
626 | Bool_t AliRDHFCuts::CompareCuts(const AliRDHFCuts *obj) const { | |
627 | // | |
628 | // Compare two cuts objects | |
629 | // | |
630 | ||
631 | Bool_t areEqual=kTRUE; | |
632 | ||
633 | if(fMinVtxType!=obj->fMinVtxType) { printf("Minimum vtx type %d %d\n",fMinVtxType,obj->fMinVtxType); areEqual=kFALSE;} | |
634 | ||
635 | if(fMinVtxContr!=obj->fMinVtxContr) { printf("Minimum vtx contr %d %d\n",fMinVtxContr,obj->fMinVtxContr); areEqual=kFALSE;} | |
636 | ||
637 | if(TMath::Abs(fMaxVtxRedChi2-obj->fMaxVtxRedChi2)>1.e-10) { printf("Max vtx red chi2 %f %f\n",fMaxVtxRedChi2,obj->fMaxVtxRedChi2);areEqual=kFALSE;} | |
638 | ||
639 | if(fMinSPDMultiplicity!=obj->fMinSPDMultiplicity) { printf("Min SPD mult %d\n %d",fMinSPDMultiplicity,obj->fMinSPDMultiplicity);areEqual=kFALSE;} | |
640 | ||
641 | if(fUsePID!=obj->fUsePID) { printf("Use PID %d %d\n",(Int_t)fUsePID,(Int_t)obj->fUsePID); areEqual=kFALSE;} | |
642 | ||
643 | if(fRemoveDaughtersFromPrimary!=obj->fRemoveDaughtersFromPrimary) {printf("Remove daughters from vtx %d %d\n",(Int_t)fRemoveDaughtersFromPrimary,(Int_t)obj->fRemoveDaughtersFromPrimary); areEqual=kFALSE;} | |
644 | if(fTrackCuts){ | |
645 | if(fTrackCuts->GetMinNClusterTPC()!=obj->fTrackCuts->GetMinNClusterTPC()) {printf("MinNClsTPC %d %d\n",fTrackCuts->GetMinNClusterTPC(),obj->fTrackCuts->GetMinNClusterTPC()); areEqual=kFALSE;} | |
646 | ||
647 | if(fTrackCuts->GetMinNClustersITS()!=obj->fTrackCuts->GetMinNClustersITS()) {printf("MinNClsITS %d %d\n",fTrackCuts->GetMinNClustersITS(),obj->fTrackCuts->GetMinNClustersITS()); areEqual=kFALSE;} | |
648 | ||
649 | if(TMath::Abs(fTrackCuts->GetMaxChi2PerClusterTPC()-obj->fTrackCuts->GetMaxChi2PerClusterTPC())>1.e-10) {printf("MaxChi2ClsTPC %f %f\n",fTrackCuts->GetMaxChi2PerClusterTPC(),obj->fTrackCuts->GetMaxChi2PerClusterTPC()); areEqual=kFALSE;} | |
650 | ||
651 | if(fTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD)!=obj->fTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD)) {printf("ClusterReq SPD %d %d\n",fTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD),obj->fTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD)); areEqual=kFALSE;} | |
652 | } | |
653 | ||
654 | if(fCutsRD) { | |
655 | for(Int_t iv=0;iv<fnVars;iv++) { | |
656 | for(Int_t ib=0;ib<fnPtBins;ib++) { | |
657 | if(TMath::Abs(fCutsRD[GetGlobalIndex(iv,ib)]-obj->fCutsRD[GetGlobalIndex(iv,ib)])>1.e-10) { | |
658 | cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<" "<<obj->fCutsRD[GetGlobalIndex(iv,ib)]<<"\n"; | |
659 | areEqual=kFALSE; | |
660 | } | |
661 | } | |
662 | } | |
663 | } | |
664 | ||
665 | return areEqual; | |
666 | } | |
667 | //--------------------------------------------------------------------------- | |
668 | void AliRDHFCuts::MakeTable() const { | |
669 | // | |
670 | // print cuts values in table format | |
671 | // | |
672 | ||
673 | TString ptString = "pT range"; | |
674 | if(fVarNames && fPtBinLimits && fCutsRD){ | |
675 | TString firstLine(Form("* %-15s",ptString.Data())); | |
676 | for (Int_t ivar=0; ivar<fnVars; ivar++){ | |
677 | firstLine+=Form("* %-15s ",fVarNames[ivar].Data()); | |
678 | if (ivar == fnVars){ | |
679 | firstLine+="*\n"; | |
680 | } | |
681 | } | |
682 | Printf("%s",firstLine.Data()); | |
683 | ||
684 | for (Int_t ipt=0; ipt<fnPtBins; ipt++){ | |
685 | TString line; | |
686 | if (ipt==fnPtBins-1){ | |
687 | line=Form("* %5.1f < pt < inf ",fPtBinLimits[ipt]); | |
688 | } | |
689 | else{ | |
690 | line=Form("* %5.1f < pt < %4.1f ",fPtBinLimits[ipt],fPtBinLimits[ipt+1]); | |
691 | } | |
692 | for (Int_t ivar=0; ivar<fnVars; ivar++){ | |
693 | line+=Form("* %-15f ",fCutsRD[GetGlobalIndex(ivar,ipt)]); | |
694 | } | |
695 | Printf("%s",line.Data()); | |
696 | } | |
697 | ||
698 | } | |
699 | ||
700 | ||
701 | return; | |
702 | } | |
eb497c14 | 703 | //-------------------------------------------------------------------------- |
704 | Bool_t AliRDHFCuts::RecalcOwnPrimaryVtx(AliAODRecoDecayHF *d,AliAODEvent *aod, | |
705 | AliAODVertex *origownvtx,AliAODVertex *recvtx) const | |
706 | { | |
707 | // | |
708 | // Recalculate primary vertex without daughters | |
709 | // | |
710 | ||
711 | if(!aod) { | |
712 | AliError("Can not remove daughters from vertex without AOD event"); | |
713 | return kFALSE; | |
714 | } | |
715 | if(d->GetOwnPrimaryVtx()) origownvtx=new AliAODVertex(*d->GetOwnPrimaryVtx()); | |
716 | recvtx=d->RemoveDaughtersFromPrimaryVtx(aod); | |
717 | if(!recvtx){ | |
718 | AliDebug(2,"Removal of daughter tracks failed"); | |
719 | if(origownvtx){ | |
720 | delete origownvtx; | |
721 | origownvtx=NULL; | |
722 | } | |
723 | return kFALSE; | |
724 | } | |
725 | //set recalculed primary vertex | |
726 | d->SetOwnPrimaryVtx(recvtx); | |
727 | delete recvtx; recvtx=NULL; | |
728 | ||
729 | return kTRUE; | |
730 | } | |
731 | //-------------------------------------------------------------------------- | |
732 | void AliRDHFCuts::CleanOwnPrimaryVtx(AliAODRecoDecayHF *d,AliAODVertex *origownvtx) const | |
733 | { | |
734 | // | |
735 | // Clean-up own primary vertex if needed | |
736 | // | |
737 | ||
738 | if(origownvtx) { | |
739 | d->SetOwnPrimaryVtx(origownvtx); | |
740 | delete origownvtx; | |
741 | origownvtx=NULL; | |
742 | } else if(fRemoveDaughtersFromPrimary) { | |
743 | d->UnsetOwnPrimaryVtx(); | |
744 | AliDebug(3,"delete new vertex\n"); | |
745 | } | |
746 | ||
747 | return; | |
748 | } | |
749 | ||
750 | ||
751 |