]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/PartCorrBase/AliMCAnalysisUtils.cxx
changed cut calue
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliMCAnalysisUtils.cxx
index ea5054495306f2355d46c427c3088abe29825c67..22ca9abe158bb8260f67b65b38b9e6fd4e05da96 100755 (executable)
@@ -42,9 +42,9 @@
 ClassImp(AliMCAnalysisUtils)
 
 //________________________________________________
-AliMCAnalysisUtils::AliMCAnalysisUtils() : 
-TObject(), fCurrentEvent(-1), fDebug(-1), 
-fJetsList(new TList), fMCGenerator("PYTHIA")
+  AliMCAnalysisUtils::AliMCAnalysisUtils() : 
+    TObject(), fCurrentEvent(-1), fDebug(-1), 
+    fJetsList(new TList), fMCGenerator("PYTHIA")
 {
   //Ctor
 }
@@ -60,31 +60,10 @@ AliMCAnalysisUtils::~AliMCAnalysisUtils()
   }     
 }
 
-
-//_________________________________________________________________________
-Int_t AliMCAnalysisUtils::CheckOrigin(const Int_t * label, const Int_t nlabels, AliCaloTrackReader* reader, const Int_t input = 0) {
-       //Play with the montecarlo particles if available
-       Int_t tag = 0;
-       
-  if(nlabels<=0) {
-    printf("AliMCAnalysisUtils::CheckOrigin(nlabel<=0) - No MC labels available, please check!!!\n");
-    return kMCBadLabel;
-  }
-
-       //Select where the information is, ESD-galice stack or AOD mcparticles branch
-       if(reader->ReadStack()){
-               tag = CheckOriginInStack(label, nlabels, reader->GetStack());
-       }
-       else if(reader->ReadAODMCParticles()){
-               tag = CheckOriginInAOD(label, nlabels, reader->GetAODMCParticles(input));
-       }
-       
-       return tag ;
-}
-
 //_________________________________________________________________________
 Int_t AliMCAnalysisUtils::CheckCommonAncestor(const Int_t index1, const Int_t index2, AliCaloTrackReader* reader, 
-                                              Int_t & ancPDG, Int_t & ancStatus, TLorentzVector & momentum, TVector3 & prodVertex) {
+                                              Int_t & ancPDG, Int_t & ancStatus, TLorentzVector & momentum, TVector3 & prodVertex) 
+{
   //Check the first common ancestor of 2 clusters, given the most likely labels of the primaries generating such clusters.
   Int_t label1[100];
   Int_t label2[100];
@@ -92,7 +71,7 @@ Int_t AliMCAnalysisUtils::CheckCommonAncestor(const Int_t index1, const Int_t in
   label2[0]= index2;
   Int_t counter1 = 0;
   Int_t counter2 = 0;
-
+  
   if(label1[0]==label2[0]) {
     //printf("AliMCAnalysisUtils::CheckCommonAncestor() - Already the same label: %d\n",label1[0]);
     counter1=1;
@@ -107,8 +86,8 @@ Int_t AliMCAnalysisUtils::CheckCommonAncestor(const Int_t index1, const Int_t in
         counter1++;
         AliAODMCParticle * mom = (AliAODMCParticle *) mcparticles->At(label);
         if(mom){
-         label  = mom->GetMother() ;
-         label1[counter1]=label;
+          label  = mom->GetMother() ;
+          label1[counter1]=label;
         }
         //printf("\t counter %d, label %d\n", counter1,label);
       }
@@ -189,30 +168,54 @@ Int_t AliMCAnalysisUtils::CheckCommonAncestor(const Int_t index1, const Int_t in
 }
 
 //_________________________________________________________________________
-Int_t AliMCAnalysisUtils::CheckOrigin(const Int_t label, AliCaloTrackReader* reader, const Int_t input = 0) {
-       //Play with the montecarlo particles if available
-       Int_t tag = 0;
+Int_t AliMCAnalysisUtils::CheckOrigin(const Int_t * label, const Int_t nlabels, AliCaloTrackReader* reader, const Int_t input = 0) 
+{
+  //Play with the montecarlo particles if available
+  Int_t tag = 0;
+  
+  if(nlabels<=0) {
+    printf("AliMCAnalysisUtils::CheckOrigin(nlabel<=0) - No MC labels available, please check!!!\n");
+    return kMCBadLabel;
+  }
+  
+  //Select where the information is, ESD-galice stack or AOD mcparticles branch
+  if(reader->ReadStack()){
+    tag = CheckOriginInStack(label, nlabels, reader->GetStack());
+  }
+  else if(reader->ReadAODMCParticles()){
+    tag = CheckOriginInAOD(label, nlabels, reader->GetAODMCParticles(input));
+  }
+  
+  return tag ;
+}
+
+//_________________________________________________________________________
+Int_t AliMCAnalysisUtils::CheckOrigin(const Int_t label, AliCaloTrackReader* reader, const Int_t input = 0) 
+{
+  //Play with the montecarlo particles if available
+  Int_t tag = 0;
   
   if(label<0) {
     printf("AliMCAnalysisUtils::CheckOrigin(label<0) - No MC labels available, please check!!!\n");
     return kMCBadLabel;
   }
   
-       Int_t labels[]={label};
-       
-       //Select where the information is, ESD-galice stack or AOD mcparticles branch
-       if(reader->ReadStack()){
-               tag = CheckOriginInStack(labels, 1,reader->GetStack());
-       }
-       else if(reader->ReadAODMCParticles()){
-               tag = CheckOriginInAOD(labels, 1,reader->GetAODMCParticles(input));
-       }
-       
-       return tag ;
+  Int_t labels[]={label};
+  
+  //Select where the information is, ESD-galice stack or AOD mcparticles branch
+  if(reader->ReadStack()){
+    tag = CheckOriginInStack(labels, 1,reader->GetStack());
+  }
+  else if(reader->ReadAODMCParticles()){
+    tag = CheckOriginInAOD(labels, 1,reader->GetAODMCParticles(input));
+  }
+  
+  return tag ;
 }      
 
 //_________________________________________________________________________
-Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nlabels, AliStack* stack) {
+Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nlabels, AliStack* stack) 
+{
   // Play with the MC stack if available. Tag particles depending on their origin.
   // Do same things as in CheckOriginInAOD but different input.
   
@@ -229,7 +232,7 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
   
   Int_t tag = 0;
   Int_t label=labels[0];//Most significant particle contributing to the cluster
-       
+  
   if(label >= 0 && label < stack->GetNtrack()){
     //MC particle of interest is the "mom" of the entity
     TParticle * mom = stack->Particle(label);
@@ -254,9 +257,9 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
     else if(fDebug > 0 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - Parent with label %d\n",iParent);
     
     if(fDebug > 2 ) {
-                 printf("AliMCAnalysisUtils::CheckOriginInStack() - Cluster most contributing mother and its parent: \n");
-                 printf("\t Mother label %d, pdg %d, status %d\n",iMom, mPdg, mStatus);
-                 printf("\t Parent label %d, pdg %d, status %d\n",iParent, pPdg, pStatus);
+      printf("AliMCAnalysisUtils::CheckOriginInStack() - Cluster most contributing mother and its parent: \n");
+      printf("\t Mother label %d, pdg %d, status %d\n",iMom, mPdg, mStatus);
+      printf("\t Parent label %d, pdg %d, status %d\n",iParent, pPdg, pStatus);
     }
          
     //Check if "mother" of entity is converted, if not, get the first non converted mother
@@ -330,7 +333,7 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
     else if(mPdgSign == -2212) SetTagBit(tag,kMCAntiProton);
     else if(mPdgSign ==  2112) SetTagBit(tag,kMCNeutron);
     else if(mPdgSign == -2112) SetTagBit(tag,kMCAntiNeutron);
-
+    
     //check for pi0 and eta (shouldn't happen unless their decays were turned off)
     else if(mPdg == 111)  {
       SetTagBit(tag,kMCPi0Decay);
@@ -369,7 +372,7 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
           }//Decay
           else {
             if(fDebug > 1 && parent) printf("AliMCAnalysisUtils::CheckOrigingInStack() - what is it in PYTHIA? Wrong generator setting? Mother mPdg %d, status %d \n    Parent  iParent %d, pPdg %d %s, status %d\n",
-                                   mPdg, mStatus,iParent, pPdg, parent->GetName(),pStatus);
+                                            mPdg, mStatus,iParent, pPdg, parent->GetName(),pStatus);
             if(pPdg == 111) {
               SetTagBit(tag,kMCPi0Decay);
               if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - PYTHIA pi0 decay photon,  parent pi0 with status 11 \n");
@@ -492,7 +495,8 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
 
 
 //_________________________________________________________________________
-Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlabels, TClonesArray *mcparticles) {
+Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlabels, TClonesArray *mcparticles) 
+{
   // Play with the MCParticles in AOD if available. Tag particles depending on their origin.
   // Do same things as in CheckOriginInStack but different input.
   if(!mcparticles) {
@@ -524,9 +528,9 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
     else if(fDebug > 0 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Parent with label %d\n",iParent);
     
     if(fDebug > 2 ) {
-                 printf("AliMCAnalysisUtils::CheckOriginInAOD() - Cluster most contributing mother and its parent: \n");
-                 printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
-                 if(parent)
+      printf("AliMCAnalysisUtils::CheckOriginInAOD() - Cluster most contributing mother and its parent: \n");
+      printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
+      if(parent)
         printf("\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
     }
          
@@ -588,6 +592,8 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
       //}
     }  
     
+    //printf("Final mother mPDG %d\n",mPdg);
+
     // conversion into electrons/photons checked  
     
     //first check for typical charged particles
@@ -613,12 +619,13 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
     //Photons  
     else if(mPdg == 22){
       SetTagBit(tag,kMCPhoton);
-      if(mom->IsPhysicalPrimary()){ //undecayed particle
-        if(iParent < 8 && iParent > 5) {//outgoing partons
+      if(mom->IsPhysicalPrimary() && (fMCGenerator=="PYTHIA" || fMCGenerator=="HERWIG")) //undecayed particle
+      {
+        if(iParent < 8 && iParent > 5 ) {//outgoing partons
           if(pPdg == 22) SetTagBit(tag,kMCPrompt);
           else SetTagBit(tag,kMCFragmentation);
         }//Outgoing partons
-        else if(iParent <= 5) {
+        else if(iParent <= 5 && (fMCGenerator=="PYTHIA" || fMCGenerator=="HERWIG")) {
           SetTagBit(tag, kMCISR); //Initial state radiation
         }
         else if(parent && parent->IsPrimary() && !parent->IsPhysicalPrimary()){//Decay
@@ -635,16 +642,17 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
           else SetTagBit(tag,kMCOtherDecay);
         }//Decay
         else {
-          if(parent)printf("AliMCAnalysisUtils::ChecOrigingInAOD() - what is it? Mother mPdg %d, is primary? %d, is physical %d \n    Parent  iParent %d, pPdg %d, is primary? %d, is physical? %d\n",
-                 mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary(),iParent, pPdg,parent->IsPrimary(), parent->IsPhysicalPrimary());
+          if(parent)printf("AliMCAnalysisUtils::CheckOriginInAOD() - what is it? Mother mPdg %d, is primary? %d, is physical %d \n    Parent  iParent %d, pPdg %d, is primary? %d, is physical? %d\n",
+                           mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary(),iParent, pPdg,parent->IsPrimary(), parent->IsPhysicalPrimary());
           SetTagBit(tag,kMCOtherDecay);//Check
         }
-      }// Pythia generated
-      else if(!mom->IsPrimary()){      //Decays
+      }//Physical primary
+      else if(!mom->IsPrimary()){      //Decays  
         if(pPdg == 111){ 
           SetTagBit(tag,kMCPi0Decay); 
-          if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Transport MC pi0 decay photon \n");
-          CheckOverlapped2GammaDecay(labels,nlabels, iParent, mcparticles, tag); //set to kMCPi0 if 2 gammas in same cluster
+          if(fDebug > 2 ) 
+            printf("AliMCAnalysisUtils::CheckOriginInAOD() - Transport MC pi0 decay photon \n");
+          CheckOverlapped2GammaDecay(labels,nlabels, iParent, mcparticles, tag); //set to kMCPi0 if 2 gammas in same cluster          
         }
         else if (pPdg == 221) {
           SetTagBit(tag,kMCEtaDecay);
@@ -717,213 +725,232 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
 
 //_________________________________________________________________________
 void AliMCAnalysisUtils::CheckOverlapped2GammaDecay(const Int_t *labels, const Int_t nlabels, const Int_t mesonIndex, 
-                                                    AliStack *stack, Int_t &tag) {
-       //Check if cluster is formed from the contribution of 2 decay photons from pi0 or eta. Input in stack
-       
-       if(labels[0] < 0 || labels[0] > stack->GetNtrack() || nlabels <= 1) {
-               if(fDebug > 2) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Exit : label[0] %d, n primaries %d, nlabels %d \n",
+                                                    AliStack *stack, Int_t &tag)
+{
+  //Check if cluster is formed from the contribution of 2 decay photons from pi0 or eta. Input in stack
+  
+  if(labels[0] < 0 || labels[0] > stack->GetNtrack() || nlabels <= 1) {
+    if(fDebug > 2) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Exit : label[0] %d, n primaries %d, nlabels %d \n",
                           labels[0],stack->GetNtrack(), nlabels);
-               return;
-       }
-       
-       TParticle * meson = stack->Particle(mesonIndex);
-       Int_t mesonPdg    = meson->GetPdgCode();
-       if(mesonPdg!=111 && mesonPdg!=221){ 
-               printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Wrong pi0/eta PDG : %d \n",mesonPdg);
-               return;
-       }
-       
-       if(fDebug > 2) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - %s, label %d\n",meson->GetName(), mesonIndex);
+    return;
+  }
+  
+  TParticle * meson = stack->Particle(mesonIndex);
+  Int_t mesonPdg    = meson->GetPdgCode();
+  if(mesonPdg!=111 && mesonPdg!=221){ 
+    printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Wrong pi0/eta PDG : %d \n",mesonPdg);
+    return;
+  }
+  
+  if(fDebug > 2) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - %s, label %d\n",meson->GetName(), mesonIndex);
+  
+  //Check if meson decayed into 2 daughters or if both were kept.
+  if(meson->GetNDaughters() != 2){
+    if(fDebug > 2) 
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Not overalapped. Number of daughters is %d, not 2 \n",meson->GetNDaughters());
+    return;
+  }
+  
+  //Get the daughters
+  Int_t iPhoton0 = meson->GetDaughter(0);
+  Int_t iPhoton1 = meson->GetDaughter(1);
+  TParticle *photon0 = stack->Particle(iPhoton0);
+  TParticle *photon1 = stack->Particle(iPhoton1);
+  
+  //Check if both daughters are photons
+  if(photon0->GetPdgCode() != 22 || photon1->GetPdgCode()!=22){
+    if(fDebug > 2) 
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Not overalapped. PDG:  daughter 1 = %d, of daughter 2 = %d \n",photon0->GetPdgCode(),photon1->GetPdgCode());
+    return;
+  }
+  
+  if(fDebug > 2) 
+    printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Daughter labels : photon0 = %d, photon1 = %d \n",iPhoton0,iPhoton1);
+  
+  //Check if both photons contribute to the cluster
+  Bool_t okPhoton0 = kFALSE;
+  Bool_t okPhoton1 = kFALSE;
+  
+  if(fDebug > 3) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Labels loop:\n");
+  
+  for(Int_t i = 0; i < nlabels; i++){
+    if(fDebug > 3) printf("\t  at begin:label %d/%d: %d, ok? photon1 %d, photon2 %d\n", i+1, nlabels, labels[i], okPhoton0, okPhoton1);
+    
+    //If we already found both, break the loop
+    if(okPhoton0 && okPhoton1) break;
+    
+    Int_t index =      labels[i];
+    if      (iPhoton0 == index) {
+      okPhoton0 = kTRUE;
+      continue;
+    }
+    else if (iPhoton1 == index) {
+      okPhoton1 = kTRUE;
+      continue;
+    }
+    
+    //Trace back the mother in case it was a conversion
+    
+    if(index >= stack->GetNtrack()){
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(ESD) Particle index %d larger than size of list %d !!\n",index,stack->GetNtrack());
+      continue;
+    }
+    
+    TParticle * daught = stack->Particle(index);
+    Int_t tmpindex = daught->GetFirstMother();         
+    if(fDebug > 3) printf("\t Conversion? : mother %d\n",tmpindex);
+    while(tmpindex>=0){
+      //MC particle of interest is the mother
+      if(fDebug > 3) printf("\t \t parent index %d\n",tmpindex);
+      daught   = stack->Particle(tmpindex);
+      if      (iPhoton0 == tmpindex) {
+       okPhoton0 = kTRUE;
+       break;
+      }
+      else if (iPhoton1 == tmpindex) {
+       okPhoton1 = kTRUE;
+       break;
+      }
+      tmpindex = daught->GetFirstMother();
+    }//While to check if pi0/eta daughter was one of these contributors to the cluster
+    
+    if(i == 0 && (!okPhoton0 && !okPhoton1) && fDebug>=0) 
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Something happens, first label should be from a photon decay!\n");
+    
+  }//loop on list of labels
+  
+  //If both photons contribute tag as the corresponding meson.
+  if(okPhoton0 && okPhoton1){
+    if(fDebug > 2) 
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - %s OVERLAPPED DECAY \n", meson->GetName());
+    
+    if(mesonPdg == 111) SetTagBit(tag,kMCPi0);
+    else  SetTagBit(tag,kMCEta);
+  }
   
-       //Check if meson decayed into 2 daughters or if both were kept.
-       if(meson->GetNDaughters() != 2){
-               if(fDebug > 2) 
-                       printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Not overalapped. Number of daughters is %d, not 2 \n",meson->GetNDaughters());
-               return;
-       }
-       
-       //Get the daughters
-       Int_t iPhoton0 = meson->GetDaughter(0);
-       Int_t iPhoton1 = meson->GetDaughter(1);
-       TParticle *photon0 = stack->Particle(iPhoton0);
-       TParticle *photon1 = stack->Particle(iPhoton1);
-       
-       //Check if both daughters are photons
-       if(photon0->GetPdgCode() != 22 || photon1->GetPdgCode()!=22){
-               if(fDebug > 2) 
-                       printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Not overalapped. PDG:  daughter 1 = %d, of daughter 2 = %d \n",photon0->GetPdgCode(),photon1->GetPdgCode());
-               return;
-       }
-       
-       if(fDebug > 2) 
-               printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Daughter labels : photon0 = %d, photon1 = %d \n",iPhoton0,iPhoton1);
-       
-       //Check if both photons contribute to the cluster
-       Bool_t okPhoton0 = kFALSE;
-       Bool_t okPhoton1 = kFALSE;
-       
-       if(fDebug > 3) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Labels loop:\n");
-       
-       for(Int_t i = 0; i < nlabels; i++){
-               if(fDebug > 3) printf("\t  at begin:label %d/%d: %d, ok? photon1 %d, photon2 %d\n", i+1, nlabels, labels[i], okPhoton0, okPhoton1);
-               
-               //If we already found both, break the loop
-               if(okPhoton0 && okPhoton1) break;
-               
-               Int_t index =   labels[i];
-               if      (iPhoton0 == index) {
-                       okPhoton0 = kTRUE;
-                       continue;
-               }
-               else if (iPhoton1 == index) {
-                       okPhoton1 = kTRUE;
-                       continue;
-               }
-               
-               //Trace back the mother in case it was a conversion
-               TParticle * daught = stack->Particle(index);
-               Int_t tmpindex = daught->GetFirstMother();              
-               if(fDebug > 3) printf("\t Conversion? : mother %d\n",tmpindex);
-               while(tmpindex>=0){
-                       //MC particle of interest is the mother
-                       if(fDebug > 3) printf("\t \t parent index %d\n",tmpindex);
-                       daught   = stack->Particle(tmpindex);
-                       if      (iPhoton0 == tmpindex) {
-                               okPhoton0 = kTRUE;
-                               break;
-                       }
-                       else if (iPhoton1 == tmpindex) {
-                               okPhoton1 = kTRUE;
-                               break;
-                       }
-                       tmpindex = daught->GetFirstMother();
-               }//While to check if pi0/eta daughter was one of these contributors to the cluster
-               
-               if(i == 0 && (!okPhoton0 && !okPhoton1) && fDebug>=0) 
-                       printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Something happens, first label should be from a photon decay!\n");
-               
-       }//loop on list of labels
-       
-       //If both photons contribute tag as the corresponding meson.
-       if(okPhoton0 && okPhoton1){
-               if(fDebug > 2) 
-                       printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - %s OVERLAPPED DECAY \n", meson->GetName());
-               
-               if(mesonPdg == 111) SetTagBit(tag,kMCPi0);
-               else  SetTagBit(tag,kMCEta);
-       }
-       
 }      
 
 //_________________________________________________________________________
 void AliMCAnalysisUtils::CheckOverlapped2GammaDecay(const Int_t *labels, const Int_t nlabels, const Int_t mesonIndex, 
-                                                    TClonesArray *mcparticles, Int_t &tag) {
-       //Check if cluster is formed from the contribution of 2 decay photons from pi0 or eta. Input in AODMCParticles
+                                                    TClonesArray *mcparticles, Int_t &tag)
+{
+  //Check if cluster is formed from the contribution of 2 decay photons from pi0 or eta. Input in AODMCParticles
   
-       if(labels[0] < 0 || labels[0] > mcparticles->GetEntriesFast() || nlabels <= 1) {
-               if(fDebug > 2) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Exit : label[0] %d, n primaries %d, nlabels %d \n",
-                          labels[0],mcparticles->GetEntriesFast(), nlabels);
-               return;
-       }
-       
-       
+  if(labels[0] < 0 || labels[0] > mcparticles->GetEntriesFast() || nlabels <= 1) {
+    if(fDebug > 2) 
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Exit : label[0] %d, n primaries %d, nlabels %d \n",
+             labels[0],mcparticles->GetEntriesFast(), nlabels);
+    return;
+  }
+    
   AliAODMCParticle * meson = (AliAODMCParticle *) mcparticles->At(mesonIndex);
-       Int_t mesonPdg = meson->GetPdgCode();
-       if(mesonPdg != 111 && mesonPdg != 221) {
-               printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Wrong pi0/eta PDG : %d \n",mesonPdg);
-               return;
-       }
-       
-       if(fDebug > 2) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - pdg %d, label %d, ndaughters %d\n", mesonPdg, mesonIndex, meson->GetNDaughters());
-       
-       
-       //Get the daughters
-       if(meson->GetNDaughters() != 2){
-               if(fDebug > 2) 
-                       printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Not overalapped. Number of daughters is %d, not 2 \n",meson->GetNDaughters());
-               return;
-       }
-       Int_t iPhoton0 = meson->GetDaughter(0);
-       Int_t iPhoton1 = meson->GetDaughter(1);
-       //if((iPhoton0 == -1) || (iPhoton1 == -1)){
-       //      if(fDebug > 2) 
-       //              printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Exit : Not overalapped. At least a daughter do not exists : d1 %d, d2 %d \n", iPhoton0, iPhoton1);
-       //      return;
-       //}     
-       AliAODMCParticle *photon0 = (AliAODMCParticle *) mcparticles->At(iPhoton0);
-       AliAODMCParticle *photon1 = (AliAODMCParticle *) mcparticles->At(iPhoton1);
-       
-       //Check if both daughters are photons
-       if(photon0->GetPdgCode() != 22 && photon1->GetPdgCode()!=22){
-               printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Not overalapped. PDG:  daughter 1 = %d, of daughter 2 = %d \n",photon0->GetPdgCode(),photon1->GetPdgCode());
-               return;
-       }
-       
-       if(fDebug > 2) 
-               printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Daughter labels : photon0 = %d, photon1 = %d \n",iPhoton0,iPhoton1);
-       
-       //Check if both photons contribute to the cluster
-       Bool_t okPhoton0 = kFALSE;
-       Bool_t okPhoton1 = kFALSE;
-       
-       if(fDebug > 3) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Labels loop:\n");
-       
-       for(Int_t i = 0; i < nlabels; i++){
-               if(fDebug > 3) printf("\t label %d/%d: %d, ok? %d, %d\n", i, nlabels, labels[i], okPhoton0, okPhoton1);
+  Int_t mesonPdg = meson->GetPdgCode();
+  if(mesonPdg != 111 && mesonPdg != 221) {
+    printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Wrong pi0/eta PDG : %d \n",mesonPdg);
+    return;
+  }
+  
+  if(fDebug > 2) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - pdg %d, label %d, ndaughters %d\n", mesonPdg, mesonIndex, meson->GetNDaughters());
+  
+  
+  //Get the daughters
+  if(meson->GetNDaughters() != 2){
+    if(fDebug > 2) 
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(stack) - Not overalapped. Number of daughters is %d, not 2 \n",meson->GetNDaughters());
+    return;
+  }
+  Int_t iPhoton0 = meson->GetDaughter(0);
+  Int_t iPhoton1 = meson->GetDaughter(1);
+  //if((iPhoton0 == -1) || (iPhoton1 == -1)){
+  //   if(fDebug > 2) 
+  //           printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Exit : Not overlapped. At least a daughter do not exists : d1 %d, d2 %d \n", iPhoton0, iPhoton1);
+  //   return;
+  //}  
+  AliAODMCParticle *photon0 = (AliAODMCParticle *) mcparticles->At(iPhoton0);
+  AliAODMCParticle *photon1 = (AliAODMCParticle *) mcparticles->At(iPhoton1);
+  
+  //Check if both daughters are photons
+  if(photon0->GetPdgCode() != 22 && photon1->GetPdgCode()!=22){
+    printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Not overlapped. PDG:  daughter 1 = %d, of daughter 2 = %d \n",photon0->GetPdgCode(),photon1->GetPdgCode());
+    return;
+  }
+  
+  if(fDebug > 2) 
+    printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Daughter labels : photon0 = %d, photon1 = %d \n",iPhoton0,iPhoton1);
+  
+  //Check if both photons contribute to the cluster
+  Bool_t okPhoton0 = kFALSE;
+  Bool_t okPhoton1 = kFALSE;
+  
+  if(fDebug > 3) 
+    printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Labels loop:\n");
+  
+  for(Int_t i = 0; i < nlabels; i++){
+    if(fDebug > 3) 
+      printf("\t label %d/%d: %d, ok? %d, %d\n", i, nlabels, labels[i], okPhoton0, okPhoton1);
     
-               //If we already found both, break the loop
-               if(okPhoton0 && okPhoton1) break;
-               
-               Int_t index =   labels[i];
-               if      (iPhoton0 == index) {
-                       okPhoton0 = kTRUE;
-                       continue;
-               }
-               else if (iPhoton1 == index) {
-                       okPhoton1 = kTRUE;
-                       continue;
-               }
-               
-               //Trace back the mother in case it was a conversion
-               AliAODMCParticle * daught = (AliAODMCParticle*) mcparticles->At(index);
-               Int_t tmpindex = daught->GetMother();
-               if(fDebug > 3) printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Conversion? : mother %d\n",tmpindex);
+    //If we already found both, break the loop
+    if(okPhoton0 && okPhoton1) break;
     
-               while(tmpindex>=0){
-                       
-                       //MC particle of interest is the mother
-                       if(fDebug > 3) printf("\t parent index %d\n",tmpindex);
-                       daught   = (AliAODMCParticle*) mcparticles->At(tmpindex);
-                       //printf("tmpindex %d\n",tmpindex);
-                       if      (iPhoton0 == tmpindex) {
-                               okPhoton0 = kTRUE;
-                               break;
-                       }
-                       else if (iPhoton1 == tmpindex) {
-                               okPhoton1 = kTRUE;
-                               break;
-                       }               
-                       tmpindex = daught->GetMother();
-               }//While to check if pi0/eta daughter was one of these contributors to the cluster
-               
-               if(i == 0 && (!okPhoton0 && !okPhoton1) && fDebug>=0 ) 
-                       printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Something happens, first label should be from a photon decay!\n");
-               
-       }//loop on list of labels
-       
-       //If both photons contribute tag as the corresponding meson.
-       if(okPhoton0 && okPhoton1){
-               if(fDebug > 2) 
-                       printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - %s OVERLAPPED DECAY \n",(TDatabasePDG::Instance()->GetParticle(mesonPdg))->GetName());
-               
-               if(mesonPdg == 111) SetTagBit(tag,kMCPi0);
-               else  SetTagBit(tag,kMCEta);
-       }       
-       
+    Int_t index =      labels[i];
+    if      (iPhoton0 == index) {
+      okPhoton0 = kTRUE;
+      continue;
+    }
+    else if (iPhoton1 == index) {
+      okPhoton1 = kTRUE;
+      continue;
+    }
+    
+    //Trace back the mother in case it was a conversion
+    
+    if(index >= mcparticles->GetEntriesFast()){
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) Particle index %d larger than size of list %d !!\n",index,mcparticles->GetEntriesFast());
+      continue;
+    }
+    
+    AliAODMCParticle * daught = (AliAODMCParticle*) mcparticles->At(index);
+    Int_t tmpindex = daught->GetMother();
+    if(fDebug > 3) 
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Conversion? : mother %d\n",tmpindex);
+    
+    while(tmpindex>=0){
+      
+      //MC particle of interest is the mother
+      if(fDebug > 3) 
+        printf("\t parent index %d\n",tmpindex);
+      daught   = (AliAODMCParticle*) mcparticles->At(tmpindex);
+      //printf("tmpindex %d\n",tmpindex);
+      if      (iPhoton0 == tmpindex) {
+        okPhoton0 = kTRUE;
+        break;
+      }
+      else if (iPhoton1 == tmpindex) {
+        okPhoton1 = kTRUE;
+        break;
+      }                
+      tmpindex = daught->GetMother();
+    }//While to check if pi0/eta daughter was one of these contributors to the cluster
+    
+    if(i == 0 && (!okPhoton0 && !okPhoton1) && fDebug>=-1 ) 
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - Something happens, first label should be from a photon decay!\n");
+    
+  }//loop on list of labels
+  
+  //If both photons contribute tag as the corresponding meson.
+  if(okPhoton0 && okPhoton1){
+    if(fDebug > 2) 
+      printf("AliMCAnalysisUtils::CheckOverlapped2GammaDecay(AOD) - %s OVERLAPPED DECAY \n",(TDatabasePDG::Instance()->GetParticle(mesonPdg))->GetName());
+    
+    if(mesonPdg == 111) SetTagBit(tag,kMCPi0);
+    else                SetTagBit(tag,kMCEta);
+  }    
+  
 }
 
 //_________________________________________________________________________
-TList * AliMCAnalysisUtils::GetJets(AliCaloTrackReader * const reader){
+TList * AliMCAnalysisUtils::GetJets(AliCaloTrackReader * const reader)
+{
   //Return list of jets (TParticles) and index of most likely parton that originated it.
   AliStack * stack = reader->GetStack();
   Int_t iEvent = reader->GetEventNumber();