Fixed bug that returned different labels for ESD and AOD clusters,
authorkharlov <Yuri.Kharlov@cern.ch>
Wed, 26 Feb 2014 17:21:20 +0000 (21:21 +0400)
committerkharlov <Yuri.Kharlov@cern.ch>
Wed, 26 Feb 2014 17:21:20 +0000 (21:21 +0400)
different behaviour of GetFirstMother for AOD and ESD MC particles
taken into account (P.Batzhing, B.Polishchuk).

PWGGA/PHOSTasks/PHOS_PbPb/AliAnalysisTaskPi0FlowMC.cxx
PWGGA/PHOSTasks/PHOS_PbPb/AliAnalysisTaskPi0FlowMCHijing.cxx
PWGGA/PHOSTasks/PHOS_PbPb/AliAnalysisTaskPi0FlowMCHijing.h

index 3e757ad..aabc119 100644 (file)
@@ -1137,7 +1137,7 @@ void AliAnalysisTaskPi0FlowMC::FillSecondaries()
            continue ;
          }
          //Common particle pi0, created off-vertex
-         Int_t primPi0=particle->GetFirstMother();
+         Int_t primPi0=(fEventESD ? particle->GetFirstMother() : ((AliAODMCParticle*)particle)->GetMother());
          if(primPi0==-1){
             FillHistogram(Form("hParentPi0NoPrim_cen%d",fCentBin),p12.M(),p12.Pt(),w) ;
          }
@@ -1188,11 +1188,11 @@ void AliAnalysisTaskPi0FlowMC::FillSecondaries()
     else{
       //Find primary at vertex
       TParticle * primPHOS = GetParticle(iprim);
-      Int_t iprimV=primPHOS->GetFirstMother();
+      Int_t iprimV=(fEventESD ? primPHOS->GetFirstMother() : ((AliAODMCParticle*)primPHOS)->GetMother());
       TParticle * primVtx = primPHOS ;
       while((iprimV>-1) && primVtx->R()>kRCut){
        primVtx = GetParticle(iprimV);
-        iprimV=primVtx->GetFirstMother();
+        iprimV=(fEventESD ? primVtx->GetFirstMother() : ((AliAODMCParticle*)primVtx)->GetMother());
       }
     
       //photon
@@ -1398,22 +1398,26 @@ TParticle* AliAnalysisTaskPi0FlowMC::GetParticle(Int_t particlepos)
 Int_t AliAnalysisTaskPi0FlowMC::FindPrimary(AliVCluster*clu,  Bool_t&sure){
   //Finds primary and estimates if it unique one?
   //First check can it be photon/electron
+
   const Double_t emFraction=0.9; //part of energy of cluster to be assigned to EM particle
-  Int_t n=clu->GetNLabels() ;
+  Int_t n=(fEventESD ? ((AliESDCaloCluster*)clu)->GetNLabels() : ((AliAODCluster*)clu)->GetNLabels());
+
   for(Int_t i=0;  i<n;  i++){
-    TParticle*  p=  GetParticle(clu->GetLabelAt(i)) ;
+    Int_t label = (fEventESD ? ((AliESDCaloCluster*)clu)->GetLabelAt(i) : ((AliAODCluster*)clu)->GetLabelAt(i));
+    TParticle*  p=  GetParticle(label) ;
     Int_t pdg = p->GetPdgCode() ;
     if(pdg==22  ||  pdg==11 || pdg == -11){
       if(p->Energy()>emFraction*clu->E()){
        sure=kTRUE ;
-       return clu->GetLabelAt(i);
+       return label;
       }
     }
   }
 
   Double_t*  Ekin=  new  Double_t[n] ;
+
   for(Int_t i=0;  i<n;  i++){
-    TParticle*  p=  GetParticle(clu->GetLabelAt(i)) ;
+    TParticle*  p=  GetParticle((fEventESD ? ((AliESDCaloCluster*)clu)->GetLabelAt(i) : ((AliAODCluster*)clu)->GetLabelAt(i))) ;
     Ekin[i]=p->P() ;  // estimate of kinetic energy
     if(p->GetPdgCode()==-2212  ||  p->GetPdgCode()==-2112){
       Ekin[i]+=1.8  ;  //due to annihilation
@@ -1433,7 +1437,7 @@ Int_t AliAnalysisTaskPi0FlowMC::FindPrimary(AliVCluster*clu,  Bool_t&sure){
   else
     sure=kTRUE;
   delete[]  Ekin;
-  return  clu->GetLabelAt(iMax) ;
+  return  (fEventESD ? ((AliESDCaloCluster*)clu)->GetLabelAt(iMax) : ((AliAODCluster*)clu)->GetLabelAt(iMax));
 }
 
 //________________________________________________________________________
@@ -1453,9 +1457,9 @@ Int_t AliAnalysisTaskPi0FlowMC::FindCommonParent(Int_t iPart, Int_t jPart){
      while(iprim2>-1){
        if(iprim1==iprim2)
         return iprim1 ;
-       iprim2=((TParticle *)GetParticle(iprim2))->GetFirstMother();
+       iprim2=(fEventESD ? (((TParticle*)GetParticle(iprim2))->GetFirstMother()) : (((AliAODMCParticle*)GetParticle(iprim2))->GetMother()));
      }
-     iprim1=((TParticle *)GetParticle(iprim1))->GetFirstMother();
+     iprim1= (fEventESD ? (((TParticle*)GetParticle(iprim1))->GetFirstMother()) : (((AliAODMCParticle*)GetParticle(iprim1))->GetMother()));
   }
   return -1;
 }
@@ -1473,7 +1477,7 @@ Bool_t AliAnalysisTaskPi0FlowMC::HaveParent(Int_t iPart, Int_t pdgParent){
     TParticle * tmp = GetParticle(iprim1) ;
     if(tmp->GetPdgCode()==pdgParent)
       return kTRUE ;
-    iprim1=tmp->GetFirstMother();
+    iprim1=(fEventESD ? tmp->GetFirstMother() : ((AliAODMCParticle*)tmp)->GetMother());
   }
   return kFALSE;
 }
index 2ce369c..3d70891 100644 (file)
@@ -22,6 +22,7 @@
 #include "AliStack.h"
 #include "TParticle.h"
 #include "AliCaloPhoton.h"
+#include "AliAODMCParticle.h"
 
 #include "AliAnalysisTaskPi0FlowMCHijing.h"
 
@@ -40,22 +41,25 @@ AliAnalysisTaskPi0FlowMCHijing::~AliAnalysisTaskPi0FlowMCHijing()
 Double_t AliAnalysisTaskPi0FlowMCHijing::PrimaryWeight(Int_t primary)
 {
   //Check who is the primary and introduce weight to correct primary spectrum
-  
-  if(primary<0 || primary>=fStack->GetNtrack())
+  Int_t ntrack=0;
+  if(fEventESD&&fStack){ntrack = fStack->GetNtrack();}
+  if(fEventAOD&&fMcArray){ntrack = fMcArray->GetEntriesFast();}
+  if(primary<0 || primary>=ntrack)
     return 1 ;
   //trace primaries up to IP
-  TParticle* particle =  fStack->Particle(primary);
+  TParticle* particle=GetParticle(primary);
+  
   Double_t r=particle->R() ;
-  Int_t mother = particle->GetFirstMother() ;
+  Int_t mother = (fEventESD ? particle->GetFirstMother() : ((AliAODMCParticle*)particle)->GetMother());
   while(mother>-1){
     if(r<1. && particle->GetPdgCode()==111)
       break ;
-    particle =  fStack->Particle(mother);
-    mother = particle->GetFirstMother() ;
+    particle =  GetParticle(mother);
+    mother = (fEventESD ? particle->GetFirstMother() : ((AliAODMCParticle*)particle)->GetMother());
     r=particle->R() ;
   }
-
-  return TMath::Max(0.,PrimaryParticleWeight(particle)) ;
+  
+  return TMath::Max(0.,PrimaryParticleWeight(particle)) ;  
 }
 
 
@@ -118,4 +122,4 @@ Double_t AliAnalysisTaskPi0FlowMCHijing::PrimaryParticleWeight(TParticle* partic
      return (-0.518126+1.327628*pt-0.130881*pt*pt)/(1.-0.665649*pt+0.184300*pt*pt)+0.081701*pt ;   
   }
   return 1. ;  
-}
\ No newline at end of file
+}
index 0dbe5f0..e465f2b 100644 (file)
@@ -18,7 +18,10 @@ public:
   virtual ~AliAnalysisTaskPi0FlowMCHijing();
 
 protected: // member functions:
-  AliAnalysisTaskPi0FlowMCHijing(const AliAnalysisTaskPi0FlowMC&); // not implemented
+  
+
+  
+  AliAnalysisTaskPi0FlowMCHijing(const AliAnalysisTaskPi0FlowMCHijing&); // not implemented
   AliAnalysisTaskPi0FlowMCHijing& operator=(const AliAnalysisTaskPi0FlowMC&); // not implemented
 
   virtual Double_t PrimaryWeight(Int_t primary);