]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/PartCorrDep/AliAnaPi0EbE.cxx
Remove/comment out the code related to signal plus bacround mixing, since it is avail...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaPi0EbE.cxx
index 7b32d587dfdf2984b08cfbcfea1a6b18cd60085d..4de6c122e89e69c6a88a60ac60ee606fb4d9a0ab 100755 (executable)
@@ -40,7 +40,7 @@
 #include "AliCaloPID.h"
 #include "AliMCAnalysisUtils.h"
 #include "AliStack.h"
-#include "AliFidutialCut.h"
+#include "AliFiducialCut.h"
 #include "TParticle.h"
 #include "AliAODCaloCluster.h"
 #include "AliAODEvent.h"
@@ -63,7 +63,7 @@ fhPtMCPi0(0),fhPhiMCPi0(0),fhEtaMCPi0(0)
   InitParameters();
   
 }
-
+/*
 //____________________________________________________________________________
 AliAnaPi0EbE::AliAnaPi0EbE(const AliAnaPi0EbE & p) : 
 AliAnaPartCorrBaseClass(p),  fAnaType(p.fAnaType), fCalorimeter(p.fCalorimeter),
@@ -100,7 +100,7 @@ AliAnaPi0EbE & AliAnaPi0EbE::operator = (const AliAnaPi0EbE & p)
   return *this;
   
 }
-
+*/
 //____________________________________________________________________________
 AliAnaPi0EbE::~AliAnaPi0EbE() 
 {
@@ -111,6 +111,38 @@ AliAnaPi0EbE::~AliAnaPi0EbE()
   }
 }
 
+//________________________________________________________________________
+TObjString *  AliAnaPi0EbE::GetAnalysisCuts()
+{      
+       //Save parameters used for analysis
+        TString parList ; //this will be list of parameters used for this analysis.
+        char onePar[255] ;
+        
+        sprintf(onePar,"--- AliAnaPi0EbE ---\n") ;
+        parList+=onePar ;      
+        sprintf(onePar,"fAnaType=%d (Pi0 selection type) \n",fAnaType) ;
+        parList+=onePar ;
+        
+        if(fAnaType == kSSCalo){
+          sprintf(onePar,"Calorimeter: %s\n",fCalorimeter.Data()) ;
+          parList+=onePar ;
+          sprintf(onePar,"fMinDist =%2.2f (Minimal distance to bad channel to accept cluster) \n",fMinDist) ;
+          parList+=onePar ;
+          sprintf(onePar,"fMinDist2=%2.2f (Cuts on Minimal distance to study acceptance evaluation) \n",fMinDist2) ;
+          parList+=onePar ;
+          sprintf(onePar,"fMinDist3=%2.2f (One more cut on distance used for acceptance-efficiency study) \n",fMinDist3) ;
+          parList+=onePar ;
+        }
+        
+        //Get parameters set in base class.
+        parList += GetBaseParametersList() ;
+        
+        //Get parameters set in PID class.
+        if(fAnaType == kSSCalo) parList += GetCaloPID()->GetPIDParametersList() ;
+        
+        return new TObjString(parList) ;
+}
+
 //________________________________________________________________________
 TList *  AliAnaPi0EbE::GetCreateOutputObjects()
 {  
@@ -119,9 +151,9 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
   TList * outputContainer = new TList() ; 
   outputContainer->SetName("Pi0EbEHistos") ; 
   
-  Int_t nptbins  = GetHistoNPtBins();
-  Int_t nphibins = GetHistoNPhiBins();
-  Int_t netabins = GetHistoNEtaBins();
+  Int_t nptbins  = GetHistoPtBins();
+  Int_t nphibins = GetHistoPhiBins();
+  Int_t netabins = GetHistoEtaBins();
   Float_t ptmax  = GetHistoPtMax();
   Float_t phimax = GetHistoPhiMax();
   Float_t etamax = GetHistoEtaMax();
@@ -196,37 +228,10 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     TList * nmsHistos = GetNeutralMesonSelection()->GetCreateOutputObjects() ;
     if(GetNeutralMesonSelection()->AreNeutralMesonSelectionHistosKept())
       for(Int_t i = 0; i < nmsHistos->GetEntries(); i++) outputContainer->Add(nmsHistos->At(i)) ;
+       delete nmsHistos;
+         
   }
   
-  //Save parameters used for analysis
-  TString parList ; //this will be list of parameters used for this analysis.
-  char onePar[255] ;
-  
-  sprintf(onePar,"--- AliAnaPi0EbE ---\n") ;
-  parList+=onePar ;    
-  sprintf(onePar,"fAnaType=%d (Pi0 selection type) \n",fAnaType) ;
-  parList+=onePar ;
-  
-  if(fAnaType == kSSCalo){
-    sprintf(onePar,"Calorimeter: %s\n",fCalorimeter.Data()) ;
-    parList+=onePar ;
-    sprintf(onePar,"fMinDist =%2.2f (Minimal distance to bad channel to accept cluster) \n",fMinDist) ;
-    parList+=onePar ;
-    sprintf(onePar,"fMinDist2=%2.2f (Cuts on Minimal distance to study acceptance evaluation) \n",fMinDist2) ;
-    parList+=onePar ;
-    sprintf(onePar,"fMinDist3=%2.2f (One more cut on distance used for acceptance-efficiency study) \n",fMinDist3) ;
-    parList+=onePar ;
-  }
-  
-  //Get parameters set in base class.
-  parList += GetBaseParametersList() ;
-  
-  //Get parameters set in PID class.
-  if(fAnaType == kSSCalo) parList += GetCaloPID()->GetPIDParametersList() ;
-  
-  TObjString *oString= new TObjString(parList) ;
-  outputContainer->Add(oString);
-  
   return outputContainer ;
   
 }
@@ -256,10 +261,10 @@ void  AliAnaPi0EbE::MakeAnalysisFillAOD()
 //__________________________________________________________________
 void  AliAnaPi0EbE::MakeInvMassInCalorimeter() 
 {
-  //Do analysis and fill aods
-  //Search for the photon decay in calorimeters
-  //Read photon list from AOD, produced in class AliAnaPhoton
-  //Check if 2 photons have the mass of the pi0.
+    //Do analysis and fill aods
+    //Search for the photon decay in calorimeters
+    //Read photon list from AOD, produced in class AliAnaPhoton
+    //Check if 2 photons have the mass of the pi0.
   
   TLorentzVector mom1;
   TLorentzVector mom2;
@@ -274,78 +279,82 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeter()
   }
   for(Int_t iphoton = 0; iphoton < GetInputAODBranch()->GetEntriesFast(); iphoton++){
     AliAODPWG4Particle * photon1 =  (AliAODPWG4Particle*) (GetInputAODBranch()->At(iphoton));
+    
+    Int_t evtIndex1 = 0 ; 
+    if(GetMixedEvent())
+      evtIndex1 = GetMixedEvent()->EventIndexForCaloCluster(photon1->GetCaloLabel(0)) ;
+    
     mom1 = *(photon1->Momentum());
     
     
     for(Int_t jphoton = iphoton+1; jphoton < GetInputAODBranch()->GetEntriesFast()-1; jphoton++){
       
       AliAODPWG4Particle * photon2 =  (AliAODPWG4Particle*) (GetInputAODBranch()->At(jphoton));
+      Int_t evtIndex2 = 0 ; 
+      if(GetMixedEvent())
+        evtIndex2 = GetMixedEvent()->EventIndexForCaloCluster(photon2->GetCaloLabel(0)) ;
+      if(GetMixedEvent() && (evtIndex1 == evtIndex2))
+        continue ; 
+      
       mom2 = *(photon2->Momentum());
+      Int_t input = -1;        //if -1 photons come from different files, not a pi0
+      if(photon1->GetInputFileIndex() == photon2->GetInputFileIndex()) 
+        input = photon1->GetInputFileIndex();
       
-      //Select good pair (good phi, pt cuts, aperture and invariant mass)
+        //Select good pair (good phi, pt cuts, aperture and invariant mass)
       if(GetNeutralMesonSelection()->SelectPair(mom1, mom2))
-       {
-         if(GetDebug()>1) 
-           printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Selected gamma pair: pt %f, phi %f, eta%f \n",(mom1+mom2).Pt(), (mom1+mom2).Phi()*180./3.1416, (mom1+mom2).Eta());
-         
-         //Play with the MC stack if available
-         if(IsDataMC()){
-           //Check origin of the candidates
-                 Int_t input1 = 0;
-                 Int_t label1 = photon1->GetLabel();
-                 if(label1 > GetLabelShift()){ 
-                         input1 = 1;
-                         label1-=GetLabelShift();
-                 }
-                 Int_t input2 = 0;
-                 Int_t label2 = photon2->GetLabel();
-                 if(label2 > GetLabelShift()){ 
-                         input2 = 1;
-                         label2-=GetLabelShift();
-                 }
-                 
-           tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), input1);
-           tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), input2);
-           
-           if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Origin of: photon1 %d; photon2 %d \n",tag1, tag2);
-           if(GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCPi0Decay) && GetMCAnalysisUtils()->CheckTagBit(tag2,AliMCAnalysisUtils::kMCPi0Decay)){
-             
-             //Check if pi0 mother is the same
-                 if(GetReader()->ReadStack()){ 
-                               TParticle * mother1 = GetMCStack()->Particle(label1);//photon in kine tree
-                               label1 = mother1->GetFirstMother();
-                               //mother1 = GetMCStack()->Particle(label1);//pi0
-                               
-                               TParticle * mother2 = GetMCStack()->Particle(label2);//photon in kine tree
-                               label2 = mother2->GetFirstMother();
-                               //mother2 = GetMCStack()->Particle(label2);//pi0
-                 }
-                 else if(GetReader()->ReadAODMCParticles()){
-                               AliAODMCParticle * mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(input1))->At(label1);//photon in kine tree
-                               label1 = mother1->GetMother();
-                               //mother1 = GetMCStack()->Particle(label1);//pi0
-                               AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(input2))->At(label2);//photon in kine tree
-                               label2 = mother2->GetMother();
-                               //mother2 = GetMCStack()->Particle(label2);//pi0
-                 }
-                       
-             //printf("mother1 %d, mother2 %d\n",label1,label2);
-             if(label1 == label2)
-                         GetMCAnalysisUtils()->SetTagBit(tag,AliMCAnalysisUtils::kMCPi0);
-           }
-         }//Work with stack also   
-         
-         //Create AOD for analysis
-         mom = mom1+mom2;
-         AliAODPWG4Particle pi0 = AliAODPWG4Particle(mom);
-         //pi0.SetLabel(calo->GetLabel(0));
-         pi0.SetPdg(AliCaloPID::kPi0);
-         pi0.SetDetector(photon1->GetDetector());
-         pi0.SetTag(tag);  
-         //Set the indeces of the original caloclusters  
-         pi0.SetCaloLabel(photon1->GetCaloLabel(0), photon2->GetCaloLabel(0));
-         AddAODParticle(pi0);
-       }//pi0
+      {
+        if(GetDebug()>1) 
+          printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Selected gamma pair: pt %f, phi %f, eta%f \n",(mom1+mom2).Pt(), (mom1+mom2).Phi()*180./3.1416, (mom1+mom2).Eta());
+        
+          //Play with the MC stack if available
+        if(IsDataMC()){
+            //Check origin of the candidates
+          Int_t  label1 = photon1->GetLabel();
+          Int_t  label2 = photon2->GetLabel();
+          tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), photon1->GetInputFileIndex());
+          tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), photon2->GetInputFileIndex());
+          
+          if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Origin of: photon1 %d; photon2 %d \n",tag1, tag2);
+          if(GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCPi0Decay) && GetMCAnalysisUtils()->CheckTagBit(tag2,AliMCAnalysisUtils::kMCPi0Decay)){
+            
+              //Check if pi0 mother is the same
+            if(GetReader()->ReadStack()){ 
+              TParticle * mother1 = GetMCStack()->Particle(label1);//photon in kine tree
+              label1 = mother1->GetFirstMother();
+                //mother1 = GetMCStack()->Particle(label1);//pi0
+              
+              TParticle * mother2 = GetMCStack()->Particle(label2);//photon in kine tree
+              label2 = mother2->GetFirstMother();
+                //mother2 = GetMCStack()->Particle(label2);//pi0
+            }
+            else if(GetReader()->ReadAODMCParticles() && (input > -1)){
+              AliAODMCParticle * mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon1->GetInputFileIndex()))->At(label1);//photon in kine tree
+              label1 = mother1->GetMother();
+                //mother1 = GetMCStack()->Particle(label1);//pi0
+              AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon2->GetInputFileIndex()))->At(label2);//photon in kine tree
+              label2 = mother2->GetMother();
+                //mother2 = GetMCStack()->Particle(label2);//pi0
+            }
+            
+              //printf("mother1 %d, mother2 %d\n",label1,label2);
+            if(label1 == label2)
+              GetMCAnalysisUtils()->SetTagBit(tag,AliMCAnalysisUtils::kMCPi0);
+          }
+        }//Work with stack also   
+        
+          //Create AOD for analysis
+        mom = mom1+mom2;
+        AliAODPWG4Particle pi0 = AliAODPWG4Particle(mom);
+          //pi0.SetLabel(calo->GetLabel());
+        pi0.SetPdg(AliCaloPID::kPi0);
+        pi0.SetDetector(photon1->GetDetector());
+        pi0.SetTag(tag);  
+          //Set the indeces of the original caloclusters  
+        pi0.SetCaloLabel(photon1->GetCaloLabel(0), photon2->GetCaloLabel(0));
+        pi0.SetInputFileIndex(input);
+        AddAODParticle(pi0);
+      }//pi0
     }//2n photon loop
     
   }//1st photon loop
@@ -386,27 +395,19 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
     for(Int_t jphoton = iphoton+1; jphoton < fInputAODGammaConv->GetEntriesFast()-1; jphoton++){
       AliAODPWG4Particle * photon2 =  (AliAODPWG4Particle*) (fInputAODGammaConv->At(jphoton));
       mom2 = *(photon2->Momentum());
+               
+         Int_t input = -1;     //if -1 photons come from different files, not a pi0
+         if(photon1->GetInputFileIndex() == photon2->GetInputFileIndex()) input = photon1->GetInputFileIndex();
+
       //Select good pair (good phi, pt cuts, aperture and invariant mass)
       if(GetNeutralMesonSelection()->SelectPair(mom1, mom2)){
        if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - Selected gamma pair: pt %f, phi %f, eta%f\n",(mom1+mom2).Pt(), (mom1+mom2).Phi()*180./3.1416, (mom1+mom2).Eta());
        
        if(IsDataMC()){
-         //Check origin of the candidates
-         Int_t input1 = 0;
-         Int_t label1 = photon1->GetLabel();
-         if(label1 > GetLabelShift()){ 
-                       input1 = 1;
-                       label1-=GetLabelShift();
-         }
-         Int_t input2 = 0;
-         Int_t label2 = photon2->GetLabel();
-         if(label2 > GetLabelShift()){ 
-                 input2 = 1;
-                 label2-=GetLabelShift();
-         }
-               
-         tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), input1);
-         tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), input2);
+         Int_t label1 = photon1->GetLabel();
+         Int_t label2 = photon2->GetLabel();
+         tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), photon1->GetInputFileIndex());
+         tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), photon2->GetInputFileIndex());
          if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - Origin of: photon1 %d; photon2 %d \n",tag1, tag2);
          if(GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCPi0Decay) && GetMCAnalysisUtils()->CheckTagBit(tag2,AliMCAnalysisUtils::kMCPi0Decay)){
            //Check if pi0 mother is the same
@@ -420,11 +421,11 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
                        label2 = mother2->GetFirstMother();
                        //mother2 = GetMCStack()->Particle(label2);//pi0
            }
-               else if(GetReader()->ReadAODMCParticles()){
-                       AliAODMCParticle * mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(input1))->At(label1);//photon in kine tree
+               else if(GetReader()->ReadAODMCParticles() && (input > -1)){
+                       AliAODMCParticle * mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon1->GetInputFileIndex()))->At(label1);//photon in kine tree
                        label1 = mother1->GetMother();
                        //mother1 = GetMCStack()->Particle(label1);//pi0
-                       AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(input2))->At(label2);//photon in kine tree
+                       AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon2->GetInputFileIndex()))->At(label2);//photon in kine tree
                        label2 = mother2->GetMother();
                        //mother2 = GetMCStack()->Particle(label2);//pi0
                }
@@ -438,13 +439,14 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
        //Create AOD for analysis
        mom = mom1+mom2;
        AliAODPWG4Particle pi0 = AliAODPWG4Particle(mom);
-       //pi0.SetLabel(calo->GetLabel(0));
+       //pi0.SetLabel(calo->GetLabel());
        pi0.SetPdg(AliCaloPID::kPi0);
        pi0.SetDetector(photon1->GetDetector());
        pi0.SetTag(tag);
        //Set the indeces of the original tracks or caloclusters  
        pi0.SetCaloLabel(photon1->GetCaloLabel(0), -1);
        pi0.SetTrackLabel(photon2->GetTrackLabel(0), photon2->GetTrackLabel(1));
+       pi0.SetInputFileIndex(input);
        AddAODParticle(pi0);
       }//pi0
     }//2n photon loop
@@ -461,12 +463,17 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
 {
   //Search for pi0 in fCalorimeter with shower shape analysis 
   
-  TObjArray * pl = new TObjArray
+  TObjArray * pl = 0x0
   
   //Get vertex for photon momentum calculation
-  Double_t vertex[]={0,0,0} ; //vertex ;
-  if(!GetReader()->GetDataType()== AliCaloTrackReader::kMC) GetReader()->GetVertex(vertex);
-  
+  Double_t vertex[]  = {0,0,0} ; //vertex 
+  Double_t vertex2[] = {0,0,0} ; //vertex from second aod input
+  if(GetReader()->GetDataType() != AliCaloTrackReader::kMC) 
+  {
+         GetReader()->GetVertex(vertex);
+         //if(GetReader()->GetSecondInputAODTree()) GetReader()->GetSecondInputAODVertex(vertex2);
+  }
+       
   //Select the Calorimeter of the photon
   if(fCalorimeter == "PHOS")
     pl = GetAODPHOS();
@@ -477,28 +484,36 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
   for(Int_t icalo = 0; icalo < pl->GetEntriesFast(); icalo++){
     AliAODCaloCluster * calo = (AliAODCaloCluster*) (pl->At(icalo));   
     
-    //Cluster selection, not charged, with pi0 id and in fidutial cut
-    //Get Momentum vector, 
-    calo->GetMomentum(mom,vertex);//Assume that come from vertex in straight line
-    //If too small or big pt, skip it
+    //Cluster selection, not charged, with pi0 id and in fiducial cut
+         
+       //Input from second AOD?
+       Int_t input = 0;
+//     if     (fCalorimeter == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= icalo) input = 1 ;
+//     else if(fCalorimeter == "PHOS"  && GetReader()->GetAODPHOSNormalInputEntries()  <= icalo) input = 1;
+         
+       //Get Momentum vector, 
+       if     (input == 0) calo->GetMomentum(mom,vertex) ;//Assume that come from vertex in straight line
+       //else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line  
+         
+       //If too small or big pt, skip it
     if(mom.Pt() < GetMinPt() || mom.Pt() > GetMaxPt() ) continue ; 
     //Check acceptance selection
-    if(IsFidutialCutOn()){
-      Bool_t in = GetFidutialCut()->IsInFidutialCut(mom,fCalorimeter) ;
+    if(IsFiducialCutOn()){
+      Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
       if(! in ) continue ;
     }
     
     //Create AOD for analysis
     AliAODPWG4Particle aodpi0 = AliAODPWG4Particle(mom);
-    aodpi0.SetLabel(calo->GetLabel(0));
+    aodpi0.SetLabel(calo->GetLabel());
     //Set the indeces of the original caloclusters  
     aodpi0.SetCaloLabel(calo->GetID(),-1);
     aodpi0.SetDetector(fCalorimeter);
     if(GetDebug() > 1) 
-      printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: Min pt cut and fidutial cut passed: pt %3.2f, phi %2.2f, eta %1.2f\n",aodpi0.Pt(),aodpi0.Phi(),aodpi0.Eta());   
+      printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: Min pt cut and fiducial cut passed: pt %3.2f, phi %2.2f, eta %1.2f\n",aodpi0.Pt(),aodpi0.Phi(),aodpi0.Eta());   
     
     //Check Distance to Bad channel, set bit.
-    Double_t distBad=calo->GetDistToBadChannel() ; //Distance to bad channel
+    Double_t distBad=calo->GetDistanceToBadChannel() ; //Distance to bad channel
     if(distBad < 0.) distBad=9999. ; //workout strange convension dist = -1. ;
     if(distBad < fMinDist) //In bad channel (PHOS cristal size 2.2x2.2 cm)
       continue ;
@@ -513,7 +528,7 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
     //PID selection or bit setting
     if(GetReader()->GetDataType() == AliCaloTrackReader::kMC){
       //Get most probable PID, check PID weights (in MC this option is mandatory)
-      aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->PID(),mom.E()));//PID with weights
+      aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->GetPID(),mom.E()));//PID with weights
       if(GetDebug() > 1) 
        printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: PDG of identified particle %d\n",aodpi0.GetPdg());
       //If primary is not pi0, skip it.
@@ -526,7 +541,7 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
       //Get most probable PID, 2 options check PID weights 
       //or redo PID, recommended option for EMCal.             
       if(!IsCaloPIDRecalculationOn())
-       aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->PID(),mom.E()));//PID with weights
+       aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->GetPID(),mom.E()));//PID with weights
       else
        aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,mom,calo));//PID recalculated
       
@@ -549,15 +564,13 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
     //Check origin of the candidates
     if(IsDataMC()){
       if((GetReader()->GetDataType() == AliCaloTrackReader::kMC && fAnaType!=kSSCalo) || 
-        GetReader()->GetDataType() != AliCaloTrackReader::kMC){
-                 
-        Int_t input = 0;
-        //Input from second AOD?
-        if     (fCalorimeter == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= icalo) input = 1;
-        else if(fCalorimeter == "PHOS"  && GetReader()->GetAODPHOSNormalInputEntries()  <= icalo) input = 1;
-                 
-       aodpi0.SetTag(GetMCAnalysisUtils()->CheckOrigin(calo->GetLabel(0),GetReader(), input));
-       if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - Origin of candidate %d\n",aodpi0.GetTag());
+                GetReader()->GetDataType() != AliCaloTrackReader::kMC){
+                 aodpi0.SetInputFileIndex(input);
+                 Int_t tag     =0;
+                 tag = GetMCAnalysisUtils()->CheckOrigin(calo->GetLabel(),GetReader(), aodpi0.GetInputFileIndex());
+                 //GetMCAnalysisUtils()->CheckMultipleOrigin(calo->GetLabels(),calo->GetNLabels(), GetReader(), aodpi0.GetInputFileIndex(), tag);
+                 aodpi0.SetTag(tag);
+                 if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - Origin of candidate %d\n",aodpi0.GetTag());
       }
     }//Work with stack also   
     
@@ -590,11 +603,10 @@ void  AliAnaPi0EbE::MakeAnalysisFillHistograms()
     if(IsCaloPIDOn() && pdg != AliCaloPID::kPi0) continue;              
     
     //Fill pi0 histograms 
-    Float_t pt = pi0->Pt();
+    Float_t pt  = pi0->Pt();
     Float_t phi = pi0->Phi();
     Float_t eta = pi0->Eta();
     
-    
     fhPtPi0  ->Fill(pt);
     fhPhiPi0 ->Fill(pt,phi);
     fhEtaPi0 ->Fill(pt,eta);
@@ -625,11 +637,11 @@ void AliAnaPi0EbE::Init()
 { 
   //Init
   //Do some checks
-  if(fCalorimeter == "PHOS" && !GetReader()->IsPHOSSwitchedOn()){
+  if(fCalorimeter == "PHOS" && !GetReader()->IsPHOSSwitchedOn() && NewOutputAOD()){
     printf("AliAnaPi0EbE::Init() - !!STOP: You want to use PHOS in analysis but it is not read!! \n!!Check the configuration file!!\n");
     abort();
   }
-  else  if(fCalorimeter == "EMCAL" && !GetReader()->IsEMCALSwitchedOn()){
+  else  if(fCalorimeter == "EMCAL" && !GetReader()->IsEMCALSwitchedOn() && NewOutputAOD()){
     printf("AliAnaPi0EbE::Init() - !!STOP: You want to use EMCAL in analysis but it is not read!! \n!!Check the configuration file!!\n");
     abort();
   }
@@ -639,10 +651,7 @@ void AliAnaPi0EbE::Init()
 //____________________________________________________________________________
 void AliAnaPi0EbE::InitParameters()
 {
-  //Initialize the parameters of the analysis.
-  SetOutputAODClassName("AliAODPWG4Particle");
-  SetOutputAODName("Pi0");
-  
+  //Initialize the parameters of the analysis.  
   AddToHistogramsName("AnaPi0EbE_");
 
   fInputAODGammaConvName = "gammaconv" ;