AliPhysics  9c66e61 (9c66e61)
AliCFVertexingHF.cxx
Go to the documentation of this file.
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 
16 // $Id$
17 
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"
32 #include "AliAODRecoCascadeHF.h"
33 #include "AliAODMCHeader.h"
34 #include "AliAODEvent.h"
35 #include "AliLog.h"
36 #include "AliESDtrackCuts.h"
37 #include "AliESDtrack.h"
38 #include "AliCFTaskVertexingHF.h"
39 
40 #include "AliCFVertexingHF.h"
41 
42 //___________________________________________________________
44  fmcArray(0x0),
45  fRecoCandidate(0),
46  fmcPartCandidate(0x0),
47  fNDaughters(0),
48  fNVar(0),
49  fzPrimVertex(0),
50  fzMCVertex(0),
51  fFillFromGenerated(0),
52  fOriginDselection(0),
53  fKeepDfromB(kFALSE),
54  fKeepDfromBOnly(kFALSE),
55  fmcLabel(0),
56  fProngs(-1),
57  fLabelArray(0x0),
58  fCentValue(0.),
59  fPtAccCut(0x0),
60  fEtaAccCut(0x0),
61  fFakeSelection(0),
62  fFake(1.), // setting to MC value
63  fRejectIfNoQuark(kFALSE),
64  fMultiplicity(0.),
65  fq2(0.),
66  fTrackArray(0x0),
67  fConfiguration(AliCFTaskVertexingHF::kCheetah) // by default, setting the fast configuration
68 {
69  //
71  //
72 
73 
74  return;
75 }
76 
77 
78 
79 //_____________________________________________________
80 AliCFVertexingHF::AliCFVertexingHF(TClonesArray *mcArray, UShort_t originDselection) :
81  fmcArray(mcArray),
82  fRecoCandidate(0),
83  fmcPartCandidate(0x0),
84  fNDaughters(0),
85  fNVar(0),
86  fzPrimVertex(0),
87  fzMCVertex(0),
90  fKeepDfromB(kFALSE),
91  fKeepDfromBOnly(kFALSE),
92  fmcLabel(0),
93  fProngs(-1),
94  fLabelArray(0x0),
95  fCentValue(0.),
96  fPtAccCut(0x0),
97  fEtaAccCut(0x0),
98  fFakeSelection(0),
99  fFake(1.), // setting to MC value
100  fRejectIfNoQuark(kFALSE),
101  fMultiplicity(0.),
102  fq2(0.),
103  fTrackArray(0x0),
104  fConfiguration(AliCFTaskVertexingHF::kCheetah) // by default, setting the fast configuration
105 {
106  //
108  //
109 
110  SetDselection(originDselection);
111  return;
112 }
113 
114 //_______________________________________________________
116 {
117  //
119  //
120 
121  if (fmcArray) fmcArray = 0x0;
122  if (fRecoCandidate) fRecoCandidate = 0x0;
124  if (fLabelArray){
125  delete [] fLabelArray;
126  fLabelArray = 0x0;
127  }
128  if (fPtAccCut){
129  delete [] fPtAccCut;
130  fPtAccCut = 0x0;
131  }
132  if (fEtaAccCut){
133  delete [] fEtaAccCut;
134  fEtaAccCut = 0x0;
135  }
136  if(fTrackArray) fTrackArray = 0x0;
137 }
138 
139 //_____________________________________________________
141 {
142  //
144  //
145 
146  if (this!= &c){
147  TObject::operator=(c);
148  delete fmcArray;
149  fmcArray = new TClonesArray(*(c.fmcArray));
150  delete fRecoCandidate;
152  delete fmcPartCandidate;
153  fmcPartCandidate = new AliAODMCParticle(*(c.fmcPartCandidate));
155  fNVar = c.fNVar;
162  fmcLabel = c.fmcLabel;
163  fProngs=c.fProngs;
166  fFake=c.fFake;
168  if (fProngs > 0){
169  delete [] fLabelArray;
170  delete [] fPtAccCut;
171  delete [] fEtaAccCut;
172  fLabelArray = new Int_t[fProngs];
173  fPtAccCut = new Float_t[fProngs];
174  fEtaAccCut = new Float_t[fProngs];
175  for(Int_t iP=0; iP<fProngs; iP++){
176  fLabelArray[iP]=c.fLabelArray[iP];
177  fPtAccCut[iP]=c.fPtAccCut[iP];
178  fEtaAccCut[iP]=c.fEtaAccCut[iP];
179  }
180  }
182  fq2=c.fq2;
183  delete fTrackArray;
184  fTrackArray = new TClonesArray(*(c.fTrackArray));
186  }
187 
188  return *this;
189 }
190 
191 //____________________________________________________
193  TObject(c),
194  fmcArray(0),
195  fRecoCandidate(0),
196  fmcPartCandidate(0),
198  fNVar(c.fNVar),
205  fmcLabel(c.fmcLabel),
206  fProngs(c.fProngs),
207  fLabelArray(0x0),
209  fPtAccCut(0x0),
210  fEtaAccCut(0x0),
212  fFake(c.fFake),
215  fq2(c.fq2),
216  fTrackArray(0),
218 {
219  //
221  //
222  delete fmcArray;
223  fmcArray = new TClonesArray(*(c.fmcArray));
224  delete fRecoCandidate;
226  delete fmcPartCandidate;
227  fmcPartCandidate = new AliAODMCParticle(*(c.fmcPartCandidate));
228  if (fProngs > 0){
229  delete [] fLabelArray;
230  delete [] fPtAccCut;
231  delete [] fEtaAccCut;
232  fLabelArray = new Int_t[fProngs];
233  fPtAccCut = new Float_t[fProngs];
234  fEtaAccCut = new Float_t[fProngs];
235  if (c.fLabelArray) memcpy(fLabelArray,c.fLabelArray,fProngs*sizeof(Int_t));
236  if (c.fPtAccCut) memcpy(fPtAccCut,c.fPtAccCut,fProngs*sizeof(Int_t));
237  if (c.fEtaAccCut) memcpy(fEtaAccCut,c.fEtaAccCut,fProngs*sizeof(Int_t));
238  }
239  delete fTrackArray;
240  fTrackArray = new TClonesArray(*(c.fTrackArray));
241 }
242 
243 //___________________________________________________________
245 {
250 
251  fOriginDselection = originDselection;
252 
253  if (fOriginDselection == 0) {
254  fKeepDfromB = kFALSE;
255  fKeepDfromBOnly = kFALSE;
256  }
257 
258  if (fOriginDselection == 1) {
259  fKeepDfromB = kTRUE;
260  fKeepDfromBOnly = kTRUE;
261  }
262 
263  if (fOriginDselection == 2) {
264  fKeepDfromB = kTRUE;
265  fKeepDfromBOnly = kFALSE;
266  }
267 
268  return;
269 }
270 
271 //______________________________________________________
273 {
274  //
276  //
277 
278  fmcPartCandidate = dynamic_cast <AliAODMCParticle*> (fmcArray->At(label));
279  if (fmcPartCandidate){
280  fNDaughters = fmcPartCandidate->GetNDaughters();
281  }
282  else {
283  AliError(Form("Dynamic cast failed, fNdaughters will remain set to %d",fNDaughters));
284  }
285  return;
286 }
287 
288 //____________________________________________________________
289 Int_t AliCFVertexingHF::MCcquarkCounting(AliAODMCParticle* mcPart) const
290 {
291  //
293  //
294 
295  Int_t cquarks = 0;
296  if (mcPart) {
297  if (mcPart->GetPdgCode() == 4) cquarks++;
298  if (mcPart->GetPdgCode() == -4) cquarks++;
299  }
300  else {
301  AliWarning("Particle not found in tree, skipping\n");
302  return cquarks;
303  }
304 
305  return cquarks;
306 }
307 
308 //________________________________________________________
309 Bool_t AliCFVertexingHF::CheckMCPartFamily(AliAODMCParticle */*mcPart*/, TClonesArray */*mcArray*/) const
310 {
311  //
313  //
314 
315  Int_t pdgGranma = CheckOrigin();
316 
317  AliDebug(3, Form("pdgGranma = %d", pdgGranma));
318 
319  if (pdgGranma == -99999){
320  AliDebug(2, "This particle does not have a quark in his genealogy\n");
321  return kFALSE;
322  }
323  if (pdgGranma == -9999){
324  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");
325  return kFALSE;
326  }
327 
328  if (pdgGranma == -999){
329  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");
330  return kFALSE;
331  }
332 
333  if (!CheckMCDaughters()) {
334  AliDebug(3, "CheckMCDaughters false");
335  return kFALSE;
336  }
337  if (!CheckMCChannelDecay()) {
338  AliDebug(3, "CheckMCChannelDecay false");
339  return kFALSE;
340  }
341  return kTRUE;
342 }
343 
344 //_________________________________________________________________________________________________
346 {
347  //
349  //
350 
351  Int_t pdgGranma = 0;
352  Int_t mother = 0;
353  mother = fmcPartCandidate->GetMother();
354  Int_t istep = 0;
355  Int_t abspdgGranma =0;
356  Bool_t isFromB=kFALSE;
357  Bool_t isQuarkFound=kFALSE;
358  while (mother >=0 ){
359  istep++;
360  AliDebug(2,Form("mother at step %d = %d", istep, mother));
361  AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother));
362  if (mcGranma){
363  pdgGranma = mcGranma->GetPdgCode();
364  AliDebug(2,Form("Pdg mother at step %d = %d", istep, pdgGranma));
365  abspdgGranma = TMath::Abs(pdgGranma);
366  if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)){
367  isFromB=kTRUE;
368  }
369  if(abspdgGranma==4 || abspdgGranma==5) isQuarkFound=kTRUE;
370  mother = mcGranma->GetMother();
371  AliDebug(3, Form("mother = %d", mother));
372  }else{
373  AliError("Failed casting the mother particle!");
374  break;
375  }
376  }
377 
378  if(fRejectIfNoQuark && !isQuarkFound) {
379  return -99999;
380  }
381  if(isFromB){
382  if (!fKeepDfromB) {
383  return -9999; //skip particle if come from a B meson.
384  }
385  }
386  else{
387  if (fKeepDfromBOnly) {
388  return -999;
389  }
390  }
391  return pdgGranma;
392 }
393 
394 //___________________________________________
396 {
397  //
400 
401  AliAODMCParticle *mcPartDaughter;
402  Bool_t checkDaughters = kFALSE;
403 
404  Int_t label0 = fmcPartCandidate->GetDaughter(0);
405  Int_t label1 = fmcPartCandidate->GetDaughter(1);
406  AliDebug(3,Form("label0 = %d, label1 = %d", label0, label1));
407  if (label1<=0 || label0 <= 0){
408  AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!"));
409  return checkDaughters;
410  }
411 
412  if (fLabelArray == 0x0) {
413  return checkDaughters;
414  }
415 
416  for (Int_t iProng = 0; iProng<fProngs; iProng++){
417  AliDebug(3, Form("fLabelArray[%d] = %d", iProng, fLabelArray[iProng]));
418  }
419  AliDebug(3, Form("Entries in MC array = %d (fast = %d)", fmcArray->GetEntries(), fmcArray->GetEntriesFast()));
420  for (Int_t iProng = 0; iProng<fProngs; iProng++){
421  AliDebug(3, Form("fLabelArray[%d] = %d", iProng, fLabelArray[iProng]));
422  mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[iProng]));
423  if (!mcPartDaughter) {
424  AliWarning("At least one Daughter Particle not found in tree, skipping");
425  return checkDaughters;
426  }
427  }
428 
429  checkDaughters = kTRUE;
430  return checkDaughters;
431 }
432 
433 //______________________________________________________
435 {
436  //
438  //
439 
440  Bool_t mcContainerFilled = kFALSE;
441 
442  Double_t* vectorMC = new Double_t[fNVar];
443  for (Int_t iVar = 0; iVar<fNVar; iVar++) vectorMC[iVar]= 9999.;
444 
445  if (GetGeneratedValuesFromMCParticle(&vectorMC[0])){
446  for (Int_t iVar = 0; iVar<fNVar; iVar++){
447  containerInputMC[iVar] = vectorMC[iVar];
448  }
449  mcContainerFilled = kTRUE;
450  }
451  else {
452  AliDebug(3, "We could not fill the array for the container");
453  }
454  delete [] vectorMC;
455  vectorMC = 0x0;
456  return mcContainerFilled;
457 }
458 
459 //______________________________________________________
461 {
462  //
463  // fill the container for Reconstrucred level selection
464  //
465 
466  Bool_t recoContainerFilled = kFALSE;
467  Double_t* vectorValues = new Double_t[fNVar];
468  Double_t* vectorReco = new Double_t[fNVar];
469  for (Int_t iVar = 0; iVar<fNVar; iVar++) {
470 
471  vectorValues[iVar]= 9999.;
472  vectorReco[iVar]=9999.;
473  }
474 
475  if(fFillFromGenerated){
476  //filled with MC values
477  if (GetGeneratedValuesFromMCParticle(&vectorValues[0])){
478  for (Int_t iVar = 0; iVar<fNVar; iVar++){
479  containerInput[iVar] = vectorValues[iVar];
480  }
481  recoContainerFilled = kTRUE;
482  }
483  }
484  else{
485  //filled with Reco values
486 
487  if (GetRecoValuesFromCandidate(&vectorReco[0])){
488  for (Int_t iVar = 0; iVar<fNVar; iVar++){
489  containerInput[iVar] = vectorReco[iVar];
490  }
491  recoContainerFilled = kTRUE;
492  }
493  }
494 
495  delete [] vectorValues;
496  delete [] vectorReco;
497  vectorValues = 0x0;
498  vectorReco = 0x0;
499 
500  return recoContainerFilled;
501 }
502 
503 //_____________________________________________________
505 {
509 
510  Bool_t bMCAccStep = kFALSE;
511 
512  AliAODMCParticle *mcPartDaughter;
513  Int_t label0 = fmcPartCandidate->GetDaughter(0);
514  Int_t label1 = fmcPartCandidate->GetDaughter(1);
515  if (label1<=0 || label0 <= 0){
516  AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!"));
517  return bMCAccStep;
518  }
519 
520  if (fLabelArray == 0x0) {
521  return bMCAccStep;
522  }
523 
524  for (Int_t iProng = 0; iProng<fProngs; iProng++){
525  mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[iProng]));
526  if (!mcPartDaughter) {
527  AliWarning("At least one Daughter Particle not found in tree, skipping");
528  return bMCAccStep;
529  }
530  Double_t eta = mcPartDaughter->Eta();
531  Double_t pt = mcPartDaughter->Pt();
532 
533  //set values of eta and pt in the constructor.
534  // if (TMath::Abs(eta) > 0.9 || pt < 0.1){
535  if (TMath::Abs(eta) > fEtaAccCut[iProng] || pt < fPtAccCut[iProng]){
536  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]));
537  return bMCAccStep;
538  }
539  }
540  bMCAccStep = kTRUE;
541  return bMCAccStep;
542 
543 }
544  //_____________________________________________________
545 Bool_t AliCFVertexingHF::MCRefitStep(AliAODEvent *aodEvent, AliESDtrackCuts **trackCuts) const
546 {
550  Bool_t bRefitStep = kFALSE;
551 
552  Int_t label0 = fmcPartCandidate->GetDaughter(0);
553  Int_t label1 = fmcPartCandidate->GetDaughter(1);
554 
555  if (label1<=0 || label0 <= 0){
556  AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!"));
557  return bRefitStep;
558  }
559 
560  if (fLabelArray == 0x0) {
561  return bRefitStep;
562  }
563 
564  Int_t foundDaughters = 0;
565  Int_t* temp = new Int_t[fProngs];
566  for (Int_t ilabel = 0; ilabel<fProngs; ilabel++){
567  temp[ilabel] = fLabelArray[ilabel];
568  }
569 
570  // if (trackCuts->GetRequireTPCRefit() || trackCuts->GetRequireITSRefit()){
571 
572  for(Int_t iaod =0; iaod<aodEvent->GetNumberOfTracks(); iaod++){
573  AliAODTrack *track = (AliAODTrack*)aodEvent->GetTrack(iaod);
574  if(track->GetStatus()&AliESDtrack::kITSpureSA) continue;
575  Bool_t foundTrack = kFALSE;
576  Int_t prongindex;
577  for (Int_t ilabel = 0; ilabel<fProngs; ilabel++){
578  AliDebug(3,Form("fLabelArray[%d] = %d, track->GetLabel() = %d",ilabel,fLabelArray[ilabel],TMath::Abs(track->GetLabel())));
579  if ((track->GetLabel()<0)&&(fFakeSelection==1)) continue;
580  if ((track->GetLabel()>0)&&(fFakeSelection==2)) continue;
581 
582  if (TMath::Abs(track->GetLabel()) == temp[ilabel]) {
583  foundTrack = kTRUE;
584  temp[ilabel] = 0;
585  prongindex=ilabel;
586  break;
587  }
588  }
589  if (foundTrack){
590  foundDaughters++;
591  AliDebug(4,Form("daughter %d \n",foundDaughters));
592  if(trackCuts[prongindex]->GetRequireTPCRefit()){
593  if(track->GetStatus()&AliESDtrack::kTPCrefit) {
594  bRefitStep = kTRUE;
595  }
596  else {
597  AliDebug(3, "Refit cut not passed , missing TPC refit\n");
598  delete [] temp;
599  temp = 0x0;
600  return kFALSE;
601  }
602  }
603 
604  if (trackCuts[prongindex]->GetRequireITSRefit()) {
605  if(track->GetStatus()&AliESDtrack::kITSrefit){
606  bRefitStep = kTRUE;
607  }
608  else {
609  AliDebug(3, "Refit cut not passed , missing ITS refit\n");
610  delete [] temp;
611  temp = 0x0;
612  return kFALSE;
613  }
614  }
615  }
616  if (foundDaughters == fProngs){
617  break;
618  }
619  }
620  //}
621  delete [] temp;
622  temp = 0x0;
623  if (foundDaughters== fProngs) return bRefitStep;
624  else return kFALSE;
625 }
626 
627 //____________________________________________________________________________
628 
630 {
634 
635  Bool_t bRecoStep = kFALSE;
636  Int_t mcLabel = GetMCLabel();
637 
638  if (mcLabel == -1) {
639  AliDebug(2,"No MC particle found");
640  return bRecoStep;
641  }
642  else{
643  fmcPartCandidate = (AliAODMCParticle*)fmcArray->At(mcLabel);
644  if (!fmcPartCandidate){
645  AliWarning("Could not find associated MC in AOD MC tree");
646  return bRecoStep;
647  }
648  }
649 
650  Int_t pdgGranma = CheckOrigin();
651 
652  if (pdgGranma == -99999){
653  AliDebug(2,"This particle does not have a quark in his genealogy\n");
654  return bRecoStep;
655  }
656  if (pdgGranma == -9999){
657  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");
658  return bRecoStep;
659  }
660 
661  if (pdgGranma == -999){
662  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");
663  return bRecoStep;
664  }
665 
666  bRecoStep=kTRUE;
667  return bRecoStep;
668 }
669 //____________________________________________
671 {
675 
676  if (fRecoCandidate){
677  Double_t etaProng = fRecoCandidate->EtaProng(iProng);
678  return etaProng;
679  }
680  return 999999;
681 }
682 //______________________________________________________
684 {
688 
689  if (fRecoCandidate){
690  Double_t ptProng = fRecoCandidate->PtProng(iProng);
691  return ptProng;
692  }
693  return 999999;
694 
695 }
696 
697 //____________________________________________________________________
698 
699 Bool_t AliCFVertexingHF::RecoAcceptStep(AliESDtrackCuts **trackCuts) const
700 {
704 
705  Bool_t bRecoAccStep = kFALSE;
706 
707  Float_t etaCutMin=0, ptCutMin=0, etaCutMax=0, ptCutMax=0;
708 
709  Float_t etaProng=0., ptProng=0.;
710 
711  for (Int_t iProng =0; iProng<fProngs; iProng++){
712 
713  trackCuts[iProng]->GetEtaRange(etaCutMin, etaCutMax);
714  trackCuts[iProng]->GetPtRange(ptCutMin, ptCutMax);
715  etaProng = GetEtaProng(iProng);
716  ptProng = GetPtProng(iProng);
717 
718  Bool_t acceptanceProng = (etaProng>etaCutMin && etaProng<etaCutMax && ptProng>ptCutMin && ptProng<ptCutMax);
719  if (!acceptanceProng) {
720  AliDebug(2,"At least one reconstructed prong isn't in the acceptance\n");
721  return bRecoAccStep;
722  }
723  }
724 
725  bRecoAccStep=kTRUE;
726  return bRecoAccStep;
727 }
728 //___________________________________________________________
729 
731 {
735 
736  if(fmcPartCandidate){
737 
738  fill[0] = GetPtCand();
739  fill[1] = GetYCand(pdg);
740 
741  fill[2] = fmcPartCandidate->Pt();
742  fill[3] = fmcPartCandidate->Y();
743 
744  return kTRUE;
745  }
746 
747  return kFALSE;
748 }
749 //___________________________________________________________
750 
752 {
756 
757  Int_t mcLabel = GetMCLabel();
758 
759  if (mcLabel == -1) {
760  AliDebug(2,"No MC particle found");
761  return 0;
762  }
763  else{
764  fmcPartCandidate = (AliAODMCParticle*)fmcArray->At(mcLabel);
765  if (!fmcPartCandidate){
766  AliWarning("Could not find associated MC in AOD MC tree");
767  return 0;
768  }
769  }
770 
771  if(fmcPartCandidate->GetPdgCode()>0) {
772  if (isSign == 1){ // I ask for antiparticle only
773  AliDebug(2,"candidate is particle, I ask for antiparticle only");
774  return 0;
775  }
776  return 1; // particle
777  }
778  else if(fmcPartCandidate->GetPdgCode()<0) {
779  if (isSign == 0){ // I ask for particle only
780  AliDebug(2,"candidate is antiparticle, I ask for particle only");
781  return 0;
782  }
783  return 2; // antiparticle
784  }
785  else return 0; // ....shouldn't be...
786 
787 }
788 //___________________________________________________________
789 
791 {
795 
796  Bool_t bLabelArray = kFALSE;
797 
798  fLabelArray = new Int_t[fProngs];
799 
800  AliAODMCParticle *mcPartDaughter;
801  Int_t label0 = fmcPartCandidate->GetDaughter(0);
802  Int_t label1 = fmcPartCandidate->GetDaughter(1);
803  AliDebug(2, Form("label0 = %d, label1 = %d", label0, label1));
804  if (label1<=0 || label0 <= 0){
805  AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!"));
806  delete [] fLabelArray;
807  fLabelArray = 0x0;
808  return bLabelArray;
809  }
810  AliAODMCParticle* tmp0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(label0));
811  AliAODMCParticle* tmp1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(label1));
812  AliDebug(2, Form("label0 = %d (pdg = %d), label1 = %d (pdg = %d)", label0, tmp0->GetPdgCode(), label1, tmp1->GetPdgCode()));
813 
814  if (label1 - label0 == fProngs-1){
815  for (Int_t iProng = 0; iProng<fProngs; iProng++){
816  mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(label0+iProng));
817  if (mcPartDaughter){
818  fLabelArray[iProng] = mcPartDaughter->GetLabel();
819  }
820  else{
821  AliError("Failed casting the daughter particle, returning a NULL label array");
822  delete [] fLabelArray;
823  fLabelArray = 0x0;
824  return bLabelArray;
825  }
826  }
827 
828  }
829  // resonant decay channel
830  else if (label1 - label0 == fProngs-2 && fProngs > 2){
831  AliDebug(3, "In the resonance decay channel");
832  Int_t labelFirstDau = fmcPartCandidate->GetDaughter(0);
833  Int_t foundDaughters = 0;
834  for(Int_t iDau=0; iDau<fProngs-1; iDau++){
835  Int_t iLabelDau = labelFirstDau+iDau;
836  AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(fmcArray->At(iLabelDau));
837  if ( ! part ) {
838  AliError("Wrong particle type in fmcArray");
839  delete [] fLabelArray;
840  fLabelArray = 0x0;
841  return bLabelArray;
842  }
843  Int_t pdgCode=TMath::Abs(part->GetPdgCode());
844  AliDebug(3, Form("Prong %d had pdg = %d", iDau, pdgCode));
845  if(pdgCode==211 || pdgCode==321 || pdgCode==2212){
846  if (part) {
847  fLabelArray[foundDaughters] = part->GetLabel();
848  AliDebug(3, Form("part found at %d has label = %d", iLabelDau, part->GetLabel()));
849  AliDebug(3, Form("fLabelArray[%d] = %d", foundDaughters, fLabelArray[foundDaughters]));
850  foundDaughters++;
851  }
852  else{
853  AliError("Error while casting particle! returning a NULL array");
854  delete [] fLabelArray;
855  fLabelArray = 0x0;
856  return bLabelArray;
857  }
858  }
859  // added K0S case - Start
860  else if (pdgCode==311) {
861  AliDebug(3, Form("K0S case, foundDaughters = %d", foundDaughters));
862  if (part->GetNDaughters()!=1) {
863  delete [] fLabelArray;
864  fLabelArray = 0x0;
865  return bLabelArray;
866  }
867  Int_t labelK0Dau = part->GetDaughter(0);
868  AliAODMCParticle* partK0S = dynamic_cast<AliAODMCParticle*>(fmcArray->At(labelK0Dau));
869  if(!partK0S){
870  AliError("Error while casting particle! returning a NULL array");
871  delete [] fLabelArray;
872  fLabelArray = 0x0;
873  return bLabelArray;
874  }
875  Int_t nDauRes = partK0S->GetNDaughters();
876  AliDebug(3, Form("nDauRes = %d", nDauRes));
877  if (nDauRes!=2 || partK0S->GetPdgCode() != 310) {
878  AliDebug(2, "No K0S on no 2-body decay");
879  delete [] fLabelArray;
880  fLabelArray = 0x0;
881  return bLabelArray;
882  }
883  Int_t labelFirstDauRes = partK0S->GetDaughter(0);
884  AliDebug(2, Form("Found K0S (%d)", labelK0Dau));
885  for(Int_t iDauRes=0; iDauRes<nDauRes; iDauRes++){
886  Int_t iLabelDauRes = labelFirstDauRes+iDauRes;
887  AliAODMCParticle* dauRes = dynamic_cast<AliAODMCParticle*>(fmcArray->At(iLabelDauRes));
888  AliDebug(3, Form("daughter = %d, pointer = %p, with label = %d", iLabelDauRes, dauRes, dauRes->GetLabel()));
889  if (dauRes){
890  AliDebug(3, Form("PDG code = %d", dauRes->GetPdgCode()));
891  if (TMath::Abs(dauRes->GetPdgCode())!=211) {
892  AliDebug(2,"K0S doesn't decay in 2 charged pions!");
893  delete [] fLabelArray;
894  fLabelArray = 0x0;
895  return bLabelArray;
896  }
897  else {
898  fLabelArray[foundDaughters] = iLabelDauRes; // N.B.: do not use dauRes->GetLabel()!!!! it is wrong!!!
899  AliDebug(3, Form("Setting fLabelArray[%d] = %d (before it was %d)", foundDaughters, iLabelDauRes, dauRes->GetLabel()));
900  foundDaughters++;
901  }
902  }
903  else {
904  AliError("Error while casting resonant daughter! returning a NULL array");
905  delete [] fLabelArray;
906  fLabelArray = 0x0;
907  return bLabelArray;
908  }
909  }
910  }
911  // added K0S case - End
912  else{
913  Int_t nDauRes=part->GetNDaughters();
914  AliDebug(3, Form("nDauRes = %d", nDauRes));
915  if(nDauRes!=2) {
916  AliDebug(3, Form("nDauRes = %d, different from 2", nDauRes));
917  Int_t labelFirstDauResTest = part->GetDaughter(0);
918  for(Int_t iDauRes=0; iDauRes<nDauRes; iDauRes++){
919  Int_t iLabelDauResTest = labelFirstDauResTest+iDauRes;
920  AliAODMCParticle* dauRes = dynamic_cast<AliAODMCParticle*>(fmcArray->At(iLabelDauResTest));
921  if (dauRes){
922  AliDebug(3, Form("pdg of daugh %d = %d", iDauRes, dauRes->GetPdgCode()));
923  }
924  }
925  delete [] fLabelArray;
926  fLabelArray = 0x0;
927  return bLabelArray;
928  }
929  Int_t labelFirstDauRes = part->GetDaughter(0);
930  for(Int_t iDauRes=0; iDauRes<nDauRes; iDauRes++){
931  Int_t iLabelDauRes = labelFirstDauRes+iDauRes;
932  AliAODMCParticle* dauRes = dynamic_cast<AliAODMCParticle*>(fmcArray->At(iLabelDauRes));
933  if (dauRes){
934  fLabelArray[foundDaughters] = dauRes->GetLabel();
935  foundDaughters++;
936  }
937  else{
938  AliError("Error while casting resonant daughter! returning a NULL array");
939  delete [] fLabelArray;
940  fLabelArray = 0x0;
941  return bLabelArray;
942  }
943  }
944  }
945  }
946  if (foundDaughters != fProngs){
947  AliDebug(3, Form("foundDaughters (%d) != fProngs (%d)", foundDaughters, fProngs));
948  delete [] fLabelArray;
949  fLabelArray = 0x0;
950  return bLabelArray;
951  }
952  }
953  // wrong correspondance label <--> prongs
954  else{
955  delete [] fLabelArray;
956  fLabelArray = 0x0;
957  return bLabelArray;
958  }
959  AliDebug(3, "Setting AccCuts");
960  SetAccCut(); // setting the pt and eta acceptance cuts
961  bLabelArray = kTRUE;
962  return bLabelArray;
963 }
964 
965 //___________________________________________________________
966 
968 {
972 
973  if (fProngs>0){
974  for (Int_t iP=0; iP<fProngs; iP++){
975  fPtAccCut[iP]=ptAccCut[iP];
976  }
977  }
978  return;
979 }
980 
981 
982 
983 //___________________________________________________________
984 
986 {
990 
991  if (fProngs>0){
992  for (Int_t iP=0; iP<fProngs; iP++){
993  fEtaAccCut[iP]=etaAccCut[iP];
994  }
995  }
996  return;
997 }
998 //___________________________________________________________
999 
1000 void AliCFVertexingHF::SetAccCut(Float_t* ptAccCut, Float_t* etaAccCut)
1001 {
1005 
1006  if (fProngs>0){
1007  for (Int_t iP=0; iP<fProngs; iP++){
1008  fPtAccCut[iP]=ptAccCut[iP];
1009  fEtaAccCut[iP]=etaAccCut[iP];
1010  }
1011  }
1012  return;
1013 }
1014 
1015 //___________________________________________________________
1016 
1018 {
1022 
1023  if (fProngs>0){
1024  for (Int_t iP=0; iP<fProngs; iP++){
1025  fPtAccCut[iP]=0.1;
1026  fEtaAccCut[iP]=0.9;
1027  }
1028  }
1029  return;
1030 }
1031 
1032 //___________________________________________________________
1034 
1035  Int_t mult=0;
1036  if(!fTrackArray) {
1037  AliWarning("Track array not found, local multiplicity not computed\n");
1038  return -1;
1039  }
1040  for(Int_t it=0; it<fTrackArray->GetEntriesFast(); it++) {
1041  AliAODTrack* track=(AliAODTrack*)fTrackArray->UncheckedAt(it);
1042  if(!track) continue;
1043  if(!track->TestFilterBit(BIT(8)) && !track->TestFilterBit(BIT(9))) continue;
1044  Double_t eta=track->Eta();
1045  Double_t phi=track->Phi();
1046  if(TMath::Sqrt((eta-etaD)*(eta-etaD)+(phi-phiD)*(phi-phiD))<R) mult++;
1047  }
1048 
1049  return mult;
1050 }
1051 
Bool_t fFillFromGenerated
MC z primary vertex.
Int_t pdg
AliCFVertexingHF & operator=(const AliCFVertexingHF &c)
Double_t GetPtCand() const
Bool_t CheckMCDaughters() const
double Double_t
Definition: External.C:58
Bool_t FillUnfoldingMatrix(UInt_t pdg, Double_t fill[4]) const
TClonesArray * fmcArray
Int_t GetMCLabel() const
Int_t MCcquarkCounting(AliAODMCParticle *mcPart) const
Int_t ComputeLocalMultiplicity(Double_t etaD, Double_t phiD, Double_t R) const
Bool_t FillRecoContainer(Double_t *containerInput)
virtual void SetPtAccCut(Float_t *ptAccCut)
char Char_t
Definition: External.C:18
AliAODMCParticle * fmcPartCandidate
Reconstructed HF candidate.
TCanvas * c
Definition: TestFitELoss.C:172
virtual Bool_t SetLabelArray()
Bool_t fKeepDfromBOnly
flag for the feed down from b quark decay.
virtual Bool_t GetRecoValuesFromCandidate(Double_t *) const
Float_t * fPtAccCut
centrality value
virtual Double_t GetPtProng(Int_t iProng) const
virtual Bool_t CheckMCChannelDecay() const
Float_t fFake
fakes selection: 0 –> all, 1 –> non-fake, 2 –> fake
Int_t fConfiguration
array of tracks
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
UShort_t fOriginDselection
flag to indicate whether data container should be filled
Int_t CheckOrigin() const
void SetDselection(UShort_t originDselection)
TClonesArray * fTrackArray
magnitude of the reduced flow vector (computed using TPC tracks)
virtual Bool_t GetGeneratedValuesFromMCParticle(Double_t *)
Int_t * fLabelArray
n. of prongs
void SetMCCandidateParam(Int_t label)
Bool_t CheckMCPartFamily(AliAODMCParticle *, TClonesArray *) const
AliAODRecoDecayHF * fRecoCandidate
mcArray candidate
Int_t CheckReflexion(Char_t isSign)
Bool_t MCAcceptanceStep() const
Bool_t RecoAcceptStep(AliESDtrackCuts **trackCuts) const
Int_t fmcLabel
flag to keep only the charm particles that comes from beauty decays
Double_t fzPrimVertex
get Number of variables for the container from the channel decay
Int_t fProngs
results of the MatchToMC()
Double_t GetYCand(UInt_t pdg) const
unsigned short UShort_t
Definition: External.C:28
Bool_t MCRefitStep(AliAODEvent *aodEvent, AliESDtrackCuts **trackCuts) const
virtual void SetAccCut()
Double_t fq2
multiplicity of the event
bool Bool_t
Definition: External.C:53
Double_t fzMCVertex
Reco z primary vertex.
Bool_t fKeepDfromB
flag to select D0 origins. 0 Only from charm 1 only from beauty 2 both from charm and beauty ...
Double_t fMultiplicity
flag to remove events not geenrated with PYTHIA
virtual void SetEtaAccCut(Float_t *etaAccCut)
Bool_t FillMCContainer(Double_t *containerInputMC)
Bool_t fRejectIfNoQuark
variable to indicate whether the D0 was a fake or not: 0 –> fake, 1 –> MC, 2 –> non-fake ...
virtual Double_t GetEtaProng(Int_t iProng) const
Class for HF corrections as a function of many variables and step.