]>
Commit | Line | Data |
---|---|---|
379592af | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2009, 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 | ||
661d6c29 | 16 | // $Id$ |
17 | ||
379592af | 18 | //----------------------------------------------------------------------- |
19 | // Class for HF corrections as a function of many variables and step | |
20 | // Author : C. Zampolli, CERN | |
21 | // D. Caffarri, Univ & INFN Padova caffarri@pd.infn.it | |
22 | // Base class for HF Unfolding - agrelli@uu.nl | |
23 | //----------------------------------------------------------------------- | |
24 | ||
25 | #include "TParticle.h" | |
26 | #include "TClonesArray.h" | |
27 | #include "AliAODMCParticle.h" | |
28 | #include "AliAODRecoDecayHF.h" | |
29 | #include "AliAODRecoDecayHF2Prong.h" | |
30 | #include "AliAODRecoDecayHF3Prong.h" | |
31 | #include "AliAODRecoDecayHF4Prong.h" | |
367e9aa3 | 32 | #include "AliAODRecoCascadeHF.h" |
379592af | 33 | #include "AliAODMCHeader.h" |
34 | #include "AliAODEvent.h" | |
35 | #include "AliLog.h" | |
36 | #include "AliESDtrackCuts.h" | |
37 | #include "AliESDtrack.h" | |
38 | ||
39 | #include "AliCFVertexingHF.h" | |
40 | ||
41 | //___________________________________________________________ | |
42 | AliCFVertexingHF::AliCFVertexingHF() : | |
43 | fmcArray(0x0), | |
44 | fRecoCandidate(0), | |
45 | fmcPartCandidate(0x0), | |
46 | fNDaughters(0), | |
47 | fNVar(0), | |
48 | fzPrimVertex(0), | |
49 | fzMCVertex(0), | |
50 | fFillFromGenerated(0), | |
51 | fOriginDselection(0), | |
52 | fKeepDfromB(kFALSE), | |
53 | fKeepDfromBOnly(kFALSE), | |
54 | fmcLabel(0), | |
6e2e4f50 | 55 | fProngs(-1), |
b7af2639 | 56 | fLabelArray(0x0), |
2bf2e62b | 57 | fCentValue(0.), |
58 | fPtAccCut(0x0), | |
fbec9fa9 | 59 | fEtaAccCut(0x0), |
1f780958 | 60 | fFakeSelection(0), |
0ada222f | 61 | fFake(1.), // setting to MC value |
62 | fRejectIfNoQuark(kFALSE) | |
379592af | 63 | { |
f2703bd2 | 64 | // |
65 | // constructor | |
66 | // | |
67 | ||
6e2e4f50 | 68 | |
379592af | 69 | return; |
70 | } | |
71 | ||
72 | ||
73 | ||
74 | //_____________________________________________________ | |
75 | AliCFVertexingHF::AliCFVertexingHF(TClonesArray *mcArray, UShort_t originDselection) : | |
76 | fmcArray(mcArray), | |
77 | fRecoCandidate(0), | |
78 | fmcPartCandidate(0x0), | |
79 | fNDaughters(0), | |
80 | fNVar(0), | |
81 | fzPrimVertex(0), | |
82 | fzMCVertex(0), | |
83 | fFillFromGenerated(0), | |
84 | fOriginDselection(0), | |
85 | fKeepDfromB(kFALSE), | |
86 | fKeepDfromBOnly(kFALSE), | |
87 | fmcLabel(0), | |
6e2e4f50 | 88 | fProngs(-1), |
b7af2639 | 89 | fLabelArray(0x0), |
2bf2e62b | 90 | fCentValue(0.), |
91 | fPtAccCut(0x0), | |
fbec9fa9 | 92 | fEtaAccCut(0x0), |
1f780958 | 93 | fFakeSelection(0), |
0ada222f | 94 | fFake(1.), // setting to MC value |
95 | fRejectIfNoQuark(kFALSE) | |
379592af | 96 | { |
f2703bd2 | 97 | // |
98 | // constructor with mcArray | |
99 | // | |
100 | ||
101 | SetDselection(originDselection); | |
102 | return; | |
379592af | 103 | } |
104 | ||
379592af | 105 | //_______________________________________________________ |
106 | AliCFVertexingHF::~AliCFVertexingHF() | |
107 | { | |
f2703bd2 | 108 | // |
109 | // destructor | |
110 | // | |
379592af | 111 | |
f2703bd2 | 112 | if (fmcArray) fmcArray = 0x0; |
113 | if (fRecoCandidate) fRecoCandidate = 0x0; | |
114 | if (fmcPartCandidate) fmcPartCandidate = 0x0; | |
6e2e4f50 | 115 | if (fLabelArray){ |
b7af2639 | 116 | delete [] fLabelArray; |
117 | fLabelArray = 0x0; | |
6e2e4f50 | 118 | } |
2bf2e62b | 119 | if (fPtAccCut){ |
120 | delete [] fPtAccCut; | |
121 | fPtAccCut = 0x0; | |
122 | } | |
123 | if (fEtaAccCut){ | |
124 | delete [] fEtaAccCut; | |
125 | fEtaAccCut = 0x0; | |
126 | } | |
f2703bd2 | 127 | } |
379592af | 128 | |
129 | //_____________________________________________________ | |
f2703bd2 | 130 | AliCFVertexingHF& AliCFVertexingHF::operator=(const AliCFVertexingHF& c) |
131 | { | |
132 | // | |
133 | // assigment operator | |
134 | // | |
135 | ||
379592af | 136 | if (this!= &c){ |
137 | TObject::operator=(c); | |
138 | fmcArray = c.fmcArray; | |
139 | fRecoCandidate = c.fRecoCandidate; | |
140 | fmcPartCandidate = c.fmcPartCandidate; | |
141 | fNDaughters = c.fNDaughters; | |
142 | fNVar = c.fNVar; | |
143 | fzPrimVertex = c.fzPrimVertex; | |
144 | fzMCVertex = c.fzMCVertex; | |
145 | fFillFromGenerated = c.fFillFromGenerated; | |
146 | fOriginDselection = c.fOriginDselection; | |
147 | fKeepDfromB = c.fKeepDfromB; | |
148 | fKeepDfromBOnly = c.fKeepDfromBOnly; | |
149 | fmcLabel = c.fmcLabel; | |
6e2e4f50 | 150 | fProngs=c.fProngs; |
b7af2639 | 151 | fCentValue=c.fCentValue; |
fbec9fa9 | 152 | fFakeSelection=c.fFakeSelection; |
1f780958 | 153 | fFake=c.fFake; |
0ada222f | 154 | fRejectIfNoQuark=c.fRejectIfNoQuark; |
6e2e4f50 | 155 | if (fProngs > 0){ |
156 | fLabelArray = new Int_t[fProngs]; | |
661d6c29 | 157 | fPtAccCut = new Float_t[fProngs]; |
158 | fEtaAccCut = new Float_t[fProngs]; | |
2bf2e62b | 159 | for(Int_t iP=0; iP<fProngs; iP++){ |
160 | fLabelArray[iP]=c.fLabelArray[iP]; | |
161 | fPtAccCut[iP]=c.fPtAccCut[iP]; | |
162 | fEtaAccCut[iP]=c.fEtaAccCut[iP]; | |
163 | } | |
6e2e4f50 | 164 | } |
379592af | 165 | } |
166 | ||
167 | return *this; | |
168 | } | |
169 | ||
170 | //____________________________________________________ | |
171 | AliCFVertexingHF::AliCFVertexingHF(const AliCFVertexingHF &c) : | |
172 | TObject(c), | |
173 | fmcArray(c.fmcArray), | |
174 | fRecoCandidate(c.fRecoCandidate), | |
175 | fmcPartCandidate(c.fmcPartCandidate), | |
176 | fNDaughters(c.fNDaughters), | |
177 | fNVar(c.fNVar), | |
178 | fzPrimVertex(c.fzPrimVertex), | |
179 | fzMCVertex(c.fzMCVertex), | |
180 | fFillFromGenerated(c.fFillFromGenerated), | |
181 | fOriginDselection (c.fOriginDselection), | |
182 | fKeepDfromB (c.fKeepDfromB), | |
183 | fKeepDfromBOnly (c.fKeepDfromBOnly), | |
184 | fmcLabel(c.fmcLabel), | |
6e2e4f50 | 185 | fProngs(c.fProngs), |
b7af2639 | 186 | fLabelArray(0x0), |
2bf2e62b | 187 | fCentValue(c.fCentValue), |
188 | fPtAccCut(0x0), | |
fbec9fa9 | 189 | fEtaAccCut(0x0), |
1f780958 | 190 | fFakeSelection(c.fFakeSelection), |
0ada222f | 191 | fFake(c.fFake), |
192 | fRejectIfNoQuark(c.fRejectIfNoQuark) | |
f2703bd2 | 193 | { |
194 | // | |
195 | //copy constructor | |
196 | // | |
6e2e4f50 | 197 | if (fProngs > 0){ |
198 | fLabelArray = new Int_t[fProngs]; | |
661d6c29 | 199 | fPtAccCut = new Float_t[fProngs]; |
200 | fEtaAccCut = new Float_t[fProngs]; | |
6e2e4f50 | 201 | if (c.fLabelArray) memcpy(fLabelArray,c.fLabelArray,fProngs*sizeof(Int_t)); |
2bf2e62b | 202 | if (c.fPtAccCut) memcpy(fPtAccCut,c.fPtAccCut,fProngs*sizeof(Int_t)); |
203 | if (c.fEtaAccCut) memcpy(fEtaAccCut,c.fEtaAccCut,fProngs*sizeof(Int_t)); | |
6e2e4f50 | 204 | } |
379592af | 205 | } |
206 | ||
207 | //___________________________________________________________ | |
f2703bd2 | 208 | void AliCFVertexingHF::SetDselection(UShort_t originDselection) |
209 | { | |
210 | // setting the way the D0 will be selected | |
211 | // 0 --> only from c quarks | |
212 | // 1 --> only from b quarks | |
213 | // 2 --> from both c quarks and b quarks | |
214 | ||
215 | fOriginDselection = originDselection; | |
216 | ||
217 | if (fOriginDselection == 0) { | |
218 | fKeepDfromB = kFALSE; | |
219 | fKeepDfromBOnly = kFALSE; | |
220 | } | |
221 | ||
222 | if (fOriginDselection == 1) { | |
223 | fKeepDfromB = kTRUE; | |
224 | fKeepDfromBOnly = kTRUE; | |
225 | } | |
226 | ||
227 | if (fOriginDselection == 2) { | |
228 | fKeepDfromB = kTRUE; | |
229 | fKeepDfromBOnly = kFALSE; | |
230 | } | |
231 | ||
232 | return; | |
379592af | 233 | } |
234 | ||
235 | //______________________________________________________ | |
f2703bd2 | 236 | void AliCFVertexingHF::SetMCCandidateParam(Int_t label) |
237 | { | |
238 | // | |
239 | // setting the parameters (candidate and n. daughters) | |
240 | // | |
379592af | 241 | |
8a983038 | 242 | fmcPartCandidate = dynamic_cast <AliAODMCParticle*> (fmcArray->At(label)); |
243 | if (fmcPartCandidate){ | |
244 | fNDaughters = fmcPartCandidate->GetNDaughters(); | |
245 | } | |
246 | else { | |
247 | AliError(Form("Dynamic cast failed, fNdaughters will remain set to %d",fNDaughters)); | |
248 | } | |
f2703bd2 | 249 | return; |
379592af | 250 | } |
251 | ||
379592af | 252 | //____________________________________________________________ |
f2703bd2 | 253 | Int_t AliCFVertexingHF::MCcquarkCounting(AliAODMCParticle* mcPart) const |
254 | { | |
255 | // | |
256 | // counting the c-quarks | |
257 | // | |
258 | ||
259 | Int_t cquarks = 0; | |
8a983038 | 260 | if (mcPart) { |
261 | if (mcPart->GetPdgCode() == 4) cquarks++; | |
262 | if (mcPart->GetPdgCode() == -4) cquarks++; | |
263 | } | |
264 | else { | |
f2703bd2 | 265 | AliWarning("Particle not found in tree, skipping\n"); |
266 | return cquarks; | |
267 | } | |
268 | ||
269 | return cquarks; | |
379592af | 270 | } |
271 | ||
379592af | 272 | //________________________________________________________ |
f2703bd2 | 273 | Bool_t AliCFVertexingHF::CheckMCPartFamily(AliAODMCParticle */*mcPart*/, TClonesArray */*mcArray*/) const |
274 | { | |
275 | // | |
276 | //checking the family | |
277 | // | |
278 | ||
279 | Int_t pdgGranma = CheckOrigin(); | |
0ada222f | 280 | |
281 | if (pdgGranma == -99999){ | |
282 | AliDebug(2,"This particle does not have a quark in his genealogy\n"); | |
283 | return kFALSE; | |
284 | } | |
f2703bd2 | 285 | if (pdgGranma == -9999){ |
286 | AliDebug(2,"This particle come from a B decay channel but according to the settings of the task, we keep only the prompt charm particles\n"); | |
f2703bd2 | 287 | return kFALSE; |
288 | } | |
289 | ||
290 | if (pdgGranma == -999){ | |
f036863c | 291 | AliDebug(2,"This particle come from a prompt charm particles but according to the settings of the task, we want only the ones coming from B\n"); |
f2703bd2 | 292 | return kFALSE; |
293 | } | |
294 | ||
295 | if (!CheckMCDaughters()) { | |
b7af2639 | 296 | AliDebug(3, "CheckMCDaughters false"); |
297 | return kFALSE; | |
f2703bd2 | 298 | } |
299 | if (!CheckMCChannelDecay()) { | |
6e2e4f50 | 300 | AliDebug(3,"CheckMCChannelDecay false"); |
f2703bd2 | 301 | return kFALSE; |
302 | } | |
303 | return kTRUE; | |
379592af | 304 | } |
305 | ||
306 | //_________________________________________________________________________________________________ | |
f2703bd2 | 307 | Int_t AliCFVertexingHF::CheckOrigin() const |
308 | { | |
309 | // | |
310 | // checking whether the mother of the particles come from a charm or a bottom quark | |
311 | // | |
312 | ||
313 | Int_t pdgGranma = 0; | |
314 | Int_t mother = 0; | |
315 | mother = fmcPartCandidate->GetMother(); | |
316 | Int_t istep = 0; | |
f036863c | 317 | Int_t abspdgGranma =0; |
0ada222f | 318 | Bool_t isFromB=kFALSE; |
319 | Bool_t isQuarkFound=kFALSE; | |
f2703bd2 | 320 | while (mother >0 ){ |
321 | istep++; | |
322 | AliDebug(2,Form("mother at step %d = %d", istep, mother)); | |
323 | AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother)); | |
8a983038 | 324 | if (mcGranma){ |
325 | pdgGranma = mcGranma->GetPdgCode(); | |
326 | AliDebug(2,Form("Pdg mother at step %d = %d", istep, pdgGranma)); | |
327 | abspdgGranma = TMath::Abs(pdgGranma); | |
0ada222f | 328 | if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)){ |
329 | isFromB=kTRUE; | |
f2703bd2 | 330 | } |
0ada222f | 331 | if(abspdgGranma==4 || abspdgGranma==5) isQuarkFound=kTRUE; |
8a983038 | 332 | mother = mcGranma->GetMother(); |
0ada222f | 333 | }else{ |
8a983038 | 334 | AliError("Failed casting the mother particle!"); |
335 | break; | |
f2703bd2 | 336 | } |
f2703bd2 | 337 | } |
0ada222f | 338 | |
339 | if(fRejectIfNoQuark && !isQuarkFound) return -99999; | |
340 | if(isFromB){ | |
341 | if (!fKeepDfromB) return -9999; //skip particle if come from a B meson. | |
342 | } | |
343 | else{ | |
344 | if (fKeepDfromBOnly) return -999; | |
f036863c | 345 | } |
379592af | 346 | return pdgGranma; |
379592af | 347 | } |
348 | ||
379592af | 349 | //___________________________________________ |
f2703bd2 | 350 | Bool_t AliCFVertexingHF::CheckMCDaughters()const |
351 | { | |
352 | // | |
353 | // checking the daughters | |
354 | // at MC level | |
379592af | 355 | |
f2703bd2 | 356 | AliAODMCParticle *mcPartDaughter; |
357 | Bool_t checkDaughters = kFALSE; | |
358 | ||
359 | Int_t label0 = fmcPartCandidate->GetDaughter(0); | |
360 | Int_t label1 = fmcPartCandidate->GetDaughter(1); | |
6e2e4f50 | 361 | AliDebug(3,Form("label0 = %d, label1 = %d",label0,label1)); |
f2703bd2 | 362 | if (label1==0 || label0 == 0){ |
6e2e4f50 | 363 | AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!")); |
f2703bd2 | 364 | return checkDaughters; |
365 | } | |
379592af | 366 | |
6e2e4f50 | 367 | if (fLabelArray == 0x0) { |
368 | return checkDaughters; | |
369 | } | |
370 | ||
f2703bd2 | 371 | for (Int_t iProng = 0; iProng<fProngs; iProng++){ |
6e2e4f50 | 372 | mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[iProng])); |
f2703bd2 | 373 | if (!mcPartDaughter) { |
374 | AliWarning("At least one Daughter Particle not found in tree, skipping"); | |
375 | return checkDaughters; | |
376 | } | |
377 | } | |
378 | ||
379 | checkDaughters = kTRUE; | |
380 | return checkDaughters; | |
381 | } | |
379592af | 382 | |
383 | //______________________________________________________ | |
384 | Bool_t AliCFVertexingHF::FillMCContainer(Double_t *containerInputMC) | |
385 | { | |
f2703bd2 | 386 | // |
387 | // fill the container for Generator level selection | |
388 | // | |
379592af | 389 | |
f2703bd2 | 390 | Bool_t mcContainerFilled = kFALSE; |
391 | ||
392 | Double_t* vectorMC = new Double_t[fNVar]; | |
393 | for (Int_t iVar = 0; iVar<fNVar; iVar++) vectorMC[iVar]= 9999.; | |
394 | ||
395 | if (GetGeneratedValuesFromMCParticle(&vectorMC[0])){ | |
396 | for (Int_t iVar = 0; iVar<fNVar; iVar++){ | |
397 | containerInputMC[iVar] = vectorMC[iVar]; | |
398 | } | |
399 | mcContainerFilled = kTRUE; | |
400 | } | |
401 | delete [] vectorMC; | |
402 | vectorMC = 0x0; | |
403 | return mcContainerFilled; | |
379592af | 404 | } |
405 | ||
406 | //______________________________________________________ | |
f2703bd2 | 407 | Bool_t AliCFVertexingHF::FillRecoContainer(Double_t *containerInput) |
408 | { | |
409 | // | |
410 | // fill the container for Reconstrucred level selection | |
411 | // | |
412 | ||
413 | Bool_t recoContainerFilled = kFALSE; | |
414 | Double_t* vectorValues = new Double_t[fNVar]; | |
415 | Double_t* vectorReco = new Double_t[fNVar]; | |
f2703bd2 | 416 | for (Int_t iVar = 0; iVar<fNVar; iVar++) { |
b7af2639 | 417 | |
f2703bd2 | 418 | vectorValues[iVar]= 9999.; |
419 | vectorReco[iVar]=9999.; | |
420 | } | |
421 | ||
422 | if(fFillFromGenerated){ | |
423 | //filled with MC values | |
424 | if (GetGeneratedValuesFromMCParticle(&vectorValues[0])){ | |
425 | for (Int_t iVar = 0; iVar<fNVar; iVar++){ | |
426 | containerInput[iVar] = vectorValues[iVar]; | |
427 | } | |
428 | recoContainerFilled = kTRUE; | |
379592af | 429 | } |
430 | } | |
431 | else{ | |
f2703bd2 | 432 | //filled with Reco values |
379592af | 433 | |
434 | if (GetRecoValuesFromCandidate(&vectorReco[0])){ | |
435 | for (Int_t iVar = 0; iVar<fNVar; iVar++){ | |
b7af2639 | 436 | containerInput[iVar] = vectorReco[iVar]; |
379592af | 437 | } |
438 | recoContainerFilled = kTRUE; | |
439 | } | |
440 | } | |
f2703bd2 | 441 | |
442 | delete [] vectorValues; | |
443 | delete [] vectorReco; | |
444 | vectorValues = 0x0; | |
445 | vectorReco = 0x0; | |
446 | return recoContainerFilled; | |
379592af | 447 | } |
448 | ||
449 | //_____________________________________________________ | |
450 | Bool_t AliCFVertexingHF::MCAcceptanceStep() const | |
451 | { | |
f2703bd2 | 452 | // |
453 | // checking the MC acceptance step | |
454 | // | |
455 | ||
456 | Bool_t bMCAccStep = kFALSE; | |
457 | ||
458 | AliAODMCParticle *mcPartDaughter; | |
459 | Int_t label0 = fmcPartCandidate->GetDaughter(0); | |
460 | Int_t label1 = fmcPartCandidate->GetDaughter(1); | |
461 | if (label1==0 || label0 == 0){ | |
462 | AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!")); | |
463 | return bMCAccStep; | |
464 | } | |
465 | ||
6e2e4f50 | 466 | if (fLabelArray == 0x0) { |
467 | return bMCAccStep; | |
468 | } | |
469 | ||
f2703bd2 | 470 | for (Int_t iProng = 0; iProng<fProngs; iProng++){ |
6e2e4f50 | 471 | mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[iProng])); |
f2703bd2 | 472 | if (!mcPartDaughter) { |
473 | AliWarning("At least one Daughter Particle not found in tree, skipping"); | |
474 | return bMCAccStep; | |
475 | } | |
476 | Double_t eta = mcPartDaughter->Eta(); | |
477 | Double_t pt = mcPartDaughter->Pt(); | |
478 | ||
479 | //set values of eta and pt in the constructor. | |
2bf2e62b | 480 | // if (TMath::Abs(eta) > 0.9 || pt < 0.1){ |
481 | if (TMath::Abs(eta) > fEtaAccCut[iProng] || pt < fPtAccCut[iProng]){ | |
482 | AliDebug(3,Form("At least one daughter has eta or pt outside the required range (|eta| = %f, pt = %f, should be |eta| < %f, pt > %f \n", TMath::Abs(eta), pt, fEtaAccCut[iProng], fPtAccCut[iProng])); | |
f2703bd2 | 483 | return bMCAccStep; |
484 | } | |
485 | } | |
486 | bMCAccStep = kTRUE; | |
487 | return bMCAccStep; | |
488 | ||
489 | } | |
f2703bd2 | 490 | //_____________________________________________________ |
2bf2e62b | 491 | Bool_t AliCFVertexingHF::MCRefitStep(AliAODEvent *aodEvent, AliESDtrackCuts **trackCuts) const |
379592af | 492 | { |
f2703bd2 | 493 | // |
494 | // check on the kTPCrefit and kITSrefit conditions of the daughters | |
495 | // | |
379592af | 496 | Bool_t bRefitStep = kFALSE; |
f2703bd2 | 497 | |
379592af | 498 | Int_t label0 = fmcPartCandidate->GetDaughter(0); |
499 | Int_t label1 = fmcPartCandidate->GetDaughter(1); | |
f2703bd2 | 500 | |
379592af | 501 | if (label1==0 || label0 == 0){ |
f2703bd2 | 502 | AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!")); |
503 | return bRefitStep; | |
379592af | 504 | } |
f2703bd2 | 505 | |
6e2e4f50 | 506 | if (fLabelArray == 0x0) { |
507 | return bRefitStep; | |
508 | } | |
f2703bd2 | 509 | |
379592af | 510 | Int_t foundDaughters = 0; |
6e2e4f50 | 511 | Int_t* temp = new Int_t[fProngs]; |
512 | for (Int_t ilabel = 0; ilabel<fProngs; ilabel++){ | |
513 | temp[ilabel] = fLabelArray[ilabel]; | |
514 | } | |
515 | ||
2bf2e62b | 516 | // if (trackCuts->GetRequireTPCRefit() || trackCuts->GetRequireITSRefit()){ |
f2703bd2 | 517 | |
2bf2e62b | 518 | for(Int_t iaod =0; iaod<aodEvent->GetNumberOfTracks(); iaod++){ |
519 | AliAODTrack *track = (AliAODTrack*)aodEvent->GetTrack(iaod); | |
520 | if(track->GetStatus()&AliESDtrack::kITSpureSA) continue; | |
521 | Bool_t foundTrack = kFALSE; | |
522 | Int_t prongindex; | |
523 | for (Int_t ilabel = 0; ilabel<fProngs; ilabel++){ | |
524 | AliDebug(3,Form("fLabelArray[%d] = %d, track->GetLabel() = %d",ilabel,fLabelArray[ilabel],TMath::Abs(track->GetLabel()))); | |
fbec9fa9 | 525 | if ((track->GetLabel()<0)&&(fFakeSelection==1)) continue; |
526 | if ((track->GetLabel()>0)&&(fFakeSelection==2)) continue; | |
527 | ||
2bf2e62b | 528 | if (TMath::Abs(track->GetLabel()) == temp[ilabel]) { |
529 | foundTrack = kTRUE; | |
530 | temp[ilabel] = 0; | |
531 | prongindex=ilabel; | |
532 | break; | |
6e2e4f50 | 533 | } |
2bf2e62b | 534 | } |
535 | if (foundTrack){ | |
536 | foundDaughters++; | |
537 | AliDebug(4,Form("daughter %d \n",foundDaughters)); | |
538 | if(trackCuts[prongindex]->GetRequireTPCRefit()){ | |
539 | if(track->GetStatus()&AliESDtrack::kTPCrefit) { | |
540 | bRefitStep = kTRUE; | |
379592af | 541 | } |
2bf2e62b | 542 | else { |
543 | AliDebug(3, "Refit cut not passed , missing TPC refit\n"); | |
544 | delete [] temp; | |
545 | temp = 0x0; | |
546 | return kFALSE; | |
379592af | 547 | } |
2bf2e62b | 548 | } |
549 | ||
550 | if (trackCuts[prongindex]->GetRequireITSRefit()) { | |
551 | if(track->GetStatus()&AliESDtrack::kITSrefit){ | |
552 | bRefitStep = kTRUE; | |
553 | } | |
554 | else { | |
555 | AliDebug(3, "Refit cut not passed , missing ITS refit\n"); | |
556 | delete [] temp; | |
557 | temp = 0x0; | |
558 | return kFALSE; | |
559 | } | |
560 | } | |
561 | } | |
562 | if (foundDaughters == fProngs){ | |
563 | break; | |
564 | } | |
565 | } | |
566 | //} | |
6e2e4f50 | 567 | delete [] temp; |
568 | temp = 0x0; | |
f2703bd2 | 569 | if (foundDaughters== fProngs) return bRefitStep; |
570 | else return kFALSE; | |
379592af | 571 | } |
572 | ||
573 | //____________________________________________________________________________ | |
574 | ||
575 | Bool_t AliCFVertexingHF::RecoStep() | |
379592af | 576 | { |
f2703bd2 | 577 | // |
578 | //check also vertex and ITS Refit and TPC Refit | |
579 | // | |
379592af | 580 | |
f2703bd2 | 581 | Bool_t bRecoStep = kFALSE; |
582 | Int_t mcLabel = GetMCLabel(); | |
583 | ||
584 | if (mcLabel == -1) { | |
585 | AliDebug(2,"No MC particle found"); | |
586 | return bRecoStep; | |
587 | } | |
588 | else{ | |
589 | fmcPartCandidate = (AliAODMCParticle*)fmcArray->At(mcLabel); | |
590 | if (!fmcPartCandidate){ | |
591 | AliWarning("Could not find associated MC in AOD MC tree"); | |
592 | return bRecoStep; | |
593 | } | |
594 | } | |
595 | ||
596 | Int_t pdgGranma = CheckOrigin(); | |
597 | ||
0ada222f | 598 | if (pdgGranma == -99999){ |
599 | AliDebug(2,"This particle does not have a quark in his genealogy\n"); | |
600 | return bRecoStep; | |
601 | } | |
f2703bd2 | 602 | if (pdgGranma == -9999){ |
603 | AliDebug(2,"This particle come from a B decay channel but according to the settings of the task, we keep only prompt charm particles\n"); | |
604 | return bRecoStep; | |
605 | } | |
606 | ||
607 | if (pdgGranma == -999){ | |
608 | AliDebug(2,"This particle come from a prompt charm particle but according to the settings of the task, we want only the ones coming from B\n"); | |
609 | return bRecoStep; | |
610 | } | |
379592af | 611 | |
f2703bd2 | 612 | bRecoStep=kTRUE; |
613 | return bRecoStep; | |
379592af | 614 | } |
615 | //____________________________________________ | |
f2703bd2 | 616 | Double_t AliCFVertexingHF::GetEtaProng(Int_t iProng) const |
617 | { | |
618 | // | |
619 | // getting eta of the prong | |
620 | // | |
621 | ||
622 | if (fRecoCandidate){ | |
623 | Double_t etaProng = fRecoCandidate->EtaProng(iProng); | |
624 | return etaProng; | |
625 | } | |
626 | return 999999; | |
379592af | 627 | } |
628 | //______________________________________________________ | |
f2703bd2 | 629 | Double_t AliCFVertexingHF::GetPtProng(Int_t iProng) const |
630 | { | |
631 | // | |
632 | // getting pt of the prong | |
633 | // | |
379592af | 634 | |
f2703bd2 | 635 | if (fRecoCandidate){ |
636 | Double_t ptProng = fRecoCandidate->PtProng(iProng); | |
637 | return ptProng; | |
638 | } | |
639 | return 999999; | |
640 | ||
379592af | 641 | } |
642 | ||
643 | //____________________________________________________________________ | |
644 | ||
2bf2e62b | 645 | Bool_t AliCFVertexingHF::RecoAcceptStep(AliESDtrackCuts **trackCuts) const |
379592af | 646 | { |
f2703bd2 | 647 | // |
648 | // reco Acceptance step | |
649 | // | |
650 | ||
651 | Bool_t bRecoAccStep = kFALSE; | |
652 | ||
653 | Float_t etaCutMin, ptCutMin, etaCutMax, ptCutMax; | |
f2703bd2 | 654 | |
655 | Float_t etaProng=0., ptProng=0.; | |
656 | ||
657 | for (Int_t iProng =0; iProng<fProngs; iProng++){ | |
658 | ||
2bf2e62b | 659 | trackCuts[iProng]->GetEtaRange(etaCutMin, etaCutMax); |
660 | trackCuts[iProng]->GetPtRange(ptCutMin, ptCutMax); | |
f2703bd2 | 661 | etaProng = GetEtaProng(iProng); |
662 | ptProng = GetPtProng(iProng); | |
663 | ||
664 | Bool_t acceptanceProng = (etaProng>etaCutMin && etaProng<etaCutMax && ptProng>ptCutMin && ptProng<ptCutMax); | |
665 | if (!acceptanceProng) { | |
666 | AliDebug(2,"At least one reconstructed prong isn't in the acceptance\n"); | |
667 | return bRecoAccStep; | |
668 | } | |
669 | } | |
670 | ||
671 | bRecoAccStep=kTRUE; | |
672 | return bRecoAccStep; | |
379592af | 673 | } |
674 | //___________________________________________________________ | |
675 | ||
e11ae259 | 676 | Bool_t AliCFVertexingHF::FillUnfoldingMatrix(Double_t fill[4]) const |
f2703bd2 | 677 | { |
678 | // | |
679 | // filling the unfolding matrix | |
680 | // | |
681 | ||
f2703bd2 | 682 | if(fmcPartCandidate){ |
683 | ||
684 | fill[0] = GetPtCand(); | |
685 | fill[1] = GetYCand(); | |
686 | ||
687 | fill[2] = fmcPartCandidate->Pt(); | |
688 | fill[3] = fmcPartCandidate->Y(); | |
689 | ||
690 | return kTRUE; | |
691 | } | |
692 | ||
f2703bd2 | 693 | return kFALSE; |
379592af | 694 | } |
f2703bd2 | 695 | //___________________________________________________________ |
379592af | 696 | |
3ee5eb83 | 697 | Int_t AliCFVertexingHF::CheckReflexion(Char_t isSign) |
f2703bd2 | 698 | { |
699 | // | |
700 | // check for reflexion (particle/antiparticle) | |
701 | // | |
379592af | 702 | |
f2703bd2 | 703 | Int_t mcLabel = GetMCLabel(); |
704 | ||
705 | if (mcLabel == -1) { | |
706 | AliDebug(2,"No MC particle found"); | |
707 | return 0; | |
708 | } | |
709 | else{ | |
710 | fmcPartCandidate = (AliAODMCParticle*)fmcArray->At(mcLabel); | |
711 | if (!fmcPartCandidate){ | |
712 | AliWarning("Could not find associated MC in AOD MC tree"); | |
713 | return 0; | |
714 | } | |
715 | } | |
716 | ||
3ee5eb83 | 717 | if(fmcPartCandidate->GetPdgCode()>0) { |
718 | if (isSign == 1){ // I ask for antiparticle only | |
719 | AliDebug(2,"candidate is particle, I ask for antiparticle only"); | |
720 | return 0; | |
721 | } | |
722 | return 1; // particle | |
723 | } | |
724 | else if(fmcPartCandidate->GetPdgCode()<0) { | |
725 | if (isSign == 0){ // I ask for particle only | |
726 | AliDebug(2,"candidate is antiparticle, I ask for particle only"); | |
727 | return 0; | |
728 | } | |
729 | return 2; // antiparticle | |
730 | } | |
f2703bd2 | 731 | else return 0; // ....shouldn't be... |
3ee5eb83 | 732 | |
f2703bd2 | 733 | } |
6e2e4f50 | 734 | //___________________________________________________________ |
735 | ||
736 | Bool_t AliCFVertexingHF::SetLabelArray() | |
737 | { | |
738 | // | |
739 | // setting the label arrays | |
740 | // | |
741 | ||
742 | Bool_t bLabelArray = kFALSE; | |
743 | ||
744 | fLabelArray = new Int_t[fProngs]; | |
745 | ||
746 | AliAODMCParticle *mcPartDaughter; | |
747 | Int_t label0 = fmcPartCandidate->GetDaughter(0); | |
748 | Int_t label1 = fmcPartCandidate->GetDaughter(1); | |
749 | AliDebug(2,Form("label0 = %d, label1 = %d",label0,label1)); | |
750 | if (label1==0 || label0 == 0){ | |
f036863c | 751 | AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!")); |
6e2e4f50 | 752 | delete [] fLabelArray; |
753 | fLabelArray = 0x0; | |
754 | return bLabelArray; | |
755 | } | |
756 | ||
757 | if (label1 - label0 == fProngs-1){ | |
758 | for (Int_t iProng = 0; iProng<fProngs; iProng++){ | |
759 | mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(label0+iProng)); | |
8a983038 | 760 | if (mcPartDaughter){ |
761 | fLabelArray[iProng] = mcPartDaughter->GetLabel(); | |
762 | } | |
763 | else{ | |
764 | AliError("Failed casting the daughter particle, returning a NULL label array"); | |
2bf2e62b | 765 | delete [] fLabelArray; |
766 | fLabelArray = 0x0; | |
8a983038 | 767 | return bLabelArray; |
768 | } | |
6e2e4f50 | 769 | } |
770 | ||
771 | } | |
772 | // resonant decay channel | |
773 | else if (label1 - label0 == fProngs-2 && fProngs > 2){ | |
774 | Int_t labelFirstDau = fmcPartCandidate->GetDaughter(0); | |
775 | Int_t foundDaughters = 0; | |
776 | for(Int_t iDau=0; iDau<fProngs-1; iDau++){ | |
777 | Int_t iLabelDau = labelFirstDau+iDau; | |
778 | AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(fmcArray->At(iLabelDau)); | |
661d6c29 | 779 | if ( ! part ) { |
780 | AliError("Wrong particle type in fmcArray"); | |
781 | delete [] fLabelArray; | |
782 | fLabelArray = 0x0; | |
783 | return bLabelArray; | |
784 | } | |
6e2e4f50 | 785 | Int_t pdgCode=TMath::Abs(part->GetPdgCode()); |
786 | if(pdgCode==211 || pdgCode==321 || pdgCode==2212){ | |
8a983038 | 787 | if (part) { |
788 | fLabelArray[foundDaughters] = part->GetLabel(); | |
789 | foundDaughters++; | |
790 | } | |
791 | else{ | |
792 | AliError("Error while casting particle! returning a NULL array"); | |
2bf2e62b | 793 | delete [] fLabelArray; |
794 | fLabelArray = 0x0; | |
8a983038 | 795 | return bLabelArray; |
796 | } | |
6e2e4f50 | 797 | } |
798 | else{ | |
799 | Int_t nDauRes=part->GetNDaughters(); | |
800 | if(nDauRes!=2) { | |
801 | delete [] fLabelArray; | |
802 | fLabelArray = 0x0; | |
803 | return bLabelArray; | |
804 | } | |
805 | Int_t labelFirstDauRes = part->GetDaughter(0); | |
9e6f6c1a | 806 | for(Int_t iDauRes=0; iDauRes<nDauRes; iDauRes++){ |
6e2e4f50 | 807 | Int_t iLabelDauRes = labelFirstDauRes+iDauRes; |
808 | AliAODMCParticle* dauRes = dynamic_cast<AliAODMCParticle*>(fmcArray->At(iLabelDauRes)); | |
8a983038 | 809 | if (dauRes){ |
810 | fLabelArray[foundDaughters] = dauRes->GetLabel(); | |
811 | foundDaughters++; | |
812 | } | |
813 | else{ | |
814 | AliError("Error while casting resonant daughter! returning a NULL array"); | |
2bf2e62b | 815 | delete [] fLabelArray; |
816 | fLabelArray = 0x0; | |
8a983038 | 817 | return bLabelArray; |
818 | } | |
6e2e4f50 | 819 | } |
820 | } | |
821 | } | |
822 | if (foundDaughters != fProngs){ | |
823 | delete [] fLabelArray; | |
824 | fLabelArray = 0x0; | |
825 | return bLabelArray; | |
826 | } | |
827 | } | |
828 | // wrong correspondance label <--> prongs | |
829 | else{ | |
830 | delete [] fLabelArray; | |
831 | fLabelArray = 0x0; | |
832 | return bLabelArray; | |
833 | } | |
2bf2e62b | 834 | SetAccCut(); // setting the pt and eta acceptance cuts |
6e2e4f50 | 835 | bLabelArray = kTRUE; |
836 | return bLabelArray; | |
837 | } | |
2bf2e62b | 838 | |
839 | //___________________________________________________________ | |
840 | ||
841 | void AliCFVertexingHF::SetPtAccCut(Float_t* ptAccCut) | |
842 | { | |
843 | // | |
844 | // setting the pt cut to be used in the Acceptance steps (MC+Reco) | |
845 | // | |
846 | ||
847 | if (fProngs>0){ | |
848 | for (Int_t iP=0; iP<fProngs; iP++){ | |
849 | fPtAccCut[iP]=ptAccCut[iP]; | |
850 | } | |
851 | } | |
852 | return; | |
853 | } | |
854 | ||
855 | ||
856 | ||
857 | //___________________________________________________________ | |
858 | ||
859 | void AliCFVertexingHF::SetEtaAccCut(Float_t* etaAccCut) | |
860 | { | |
861 | // | |
862 | // setting the eta cut to be used in the Acceptance steps (MC+Reco) | |
863 | // | |
864 | ||
865 | if (fProngs>0){ | |
866 | for (Int_t iP=0; iP<fProngs; iP++){ | |
867 | fEtaAccCut[iP]=etaAccCut[iP]; | |
868 | } | |
869 | } | |
870 | return; | |
871 | } | |
872 | //___________________________________________________________ | |
873 | ||
874 | void AliCFVertexingHF::SetAccCut(Float_t* ptAccCut, Float_t* etaAccCut) | |
875 | { | |
876 | // | |
877 | // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco) | |
878 | // | |
879 | ||
880 | if (fProngs>0){ | |
881 | for (Int_t iP=0; iP<fProngs; iP++){ | |
882 | fPtAccCut[iP]=ptAccCut[iP]; | |
883 | fEtaAccCut[iP]=etaAccCut[iP]; | |
884 | } | |
885 | } | |
886 | return; | |
887 | } | |
888 | ||
889 | //___________________________________________________________ | |
890 | ||
891 | void AliCFVertexingHF::SetAccCut() | |
892 | { | |
893 | // | |
894 | // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco) | |
895 | // | |
896 | ||
897 | if (fProngs>0){ | |
898 | for (Int_t iP=0; iP<fProngs; iP++){ | |
899 | fPtAccCut[iP]=0.1; | |
900 | fEtaAccCut[iP]=0.9; | |
901 | } | |
902 | } | |
903 | return; | |
904 | } |