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