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