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