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