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