Correct and clean the vertex retrieval in case of SE or ME analysis
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 18 Sep 2010 16:18:44 +0000 (16:18 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 18 Sep 2010 16:18:44 +0000 (16:18 +0000)
AliAnaParticleHadronCorrelation: Decay photon analysis added
                                 Correlation with pi0 now done with a AOD branch produced in another task
Many coverity reports corrections.

24 files changed:
PWG4/PartCorrBase/AliAnaPartCorrBaseClass.cxx
PWG4/PartCorrBase/AliAnaPartCorrBaseClass.h
PWG4/PartCorrBase/AliAnaPartCorrMaker.cxx
PWG4/PartCorrBase/AliAnaScale.cxx
PWG4/PartCorrBase/AliCaloTrackMCReader.h
PWG4/PartCorrBase/AliCaloTrackReader.cxx
PWG4/PartCorrBase/AliCaloTrackReader.h
PWG4/PartCorrBase/AliIsolationCut.cxx
PWG4/PartCorrBase/AliMCAnalysisUtils.cxx
PWG4/PartCorrBase/AliMCAnalysisUtils.h
PWG4/PartCorrDep/AliAnaBtag.cxx
PWG4/PartCorrDep/AliAnaCalorimeterQA.cxx
PWG4/PartCorrDep/AliAnaElectron.cxx
PWG4/PartCorrDep/AliAnaExample.cxx
PWG4/PartCorrDep/AliAnaOmegaToPi0Gamma.cxx
PWG4/PartCorrDep/AliAnaParticleHadronCorrelation.cxx
PWG4/PartCorrDep/AliAnaParticleHadronCorrelation.h
PWG4/PartCorrDep/AliAnaParticleJetFinderCorrelation.cxx
PWG4/PartCorrDep/AliAnaParticleJetLeadingConeCorrelation.cxx
PWG4/PartCorrDep/AliAnaParticlePartonCorrelation.cxx
PWG4/PartCorrDep/AliAnaPhoton.cxx
PWG4/PartCorrDep/AliAnaPi0.cxx
PWG4/PartCorrDep/AliAnaPi0EbE.cxx
PWG4/PartCorrDep/AliAnalysisTaskPHOSExample.cxx

index 005f75c..fb02b29 100755 (executable)
@@ -37,7 +37,6 @@
 #include "AliAODEvent.h"
 #include "AliAODHandler.h"
 #include "AliAnalysisManager.h"
-#include "AliMixedEvent.h"
 #include "AliAODPWG4Particle.h"
 
 ClassImp(AliAnaPartCorrBaseClass)
@@ -57,7 +56,7 @@ ClassImp(AliAnaPartCorrBaseClass)
     fHistoPhiBins(0),  fHistoPhiMax(0.),  fHistoPhiMin(0.),
     fHistoEtaBins(0),  fHistoEtaMax(0.),  fHistoEtaMin(0.),
     fHistoMassBins(0), fHistoMassMax(0.), fHistoMassMin(0.),
-    fHistoAsymBins(0), fHistoAsymMax(0.), fHistoAsymMin(0.), fMixedEvent(NULL), fNMixedEvent(1), fVertex(NULL)
+    fHistoAsymBins(0), fHistoAsymMax(0.), fHistoAsymMin(0.)
 {
   //Default Ctor
     
@@ -157,11 +156,6 @@ AliAnaPartCorrBaseClass::~AliAnaPartCorrBaseClass()
   if(fMCUtils)   delete fMCUtils ;
   if(fNMS)       delete fNMS ;
   
-  for (Int_t i = 0; i < fNMixedEvent; i++) {
-     delete [] fVertex[i] ; 
-  }
-  delete [] fVertex ;  
-  
 //   printf("--- analysis deleted \n");
 }
 
@@ -528,34 +522,5 @@ void AliAnaPartCorrBaseClass::Print(const Option_t * opt) const
   
 } 
 
-//__________________________________________________________________
-AliMixedEvent * AliAnaPartCorrBaseClass::GetMixedEvent() 
-{ 
-  //gets the mixed event objects and does some setting
-  if (!fMixedEvent) {
-    fMixedEvent = dynamic_cast<AliMixedEvent*>(GetReader()->GetInputEvent()) ; 
-    if (fMixedEvent) {
-      fNMixedEvent = fMixedEvent->GetNumberOfEvents() ; 
-    }
-    
-    //Delete previous vertex
-    if(fVertex){
-      for (Int_t i = 0; i < fNMixedEvent; i++) {
-       delete [] fVertex[i] ; 
-      }
-      delete [] fVertex ;  
-    }
-    
-    fVertex = new Double_t*[fNMixedEvent] ; 
-    for (Int_t i = 0; i < fNMixedEvent; i++) {
-      fVertex[i] = new Double_t[3] ; 
-      fVertex[i][0] = 0.0 ; 
-      fVertex[i][1] = 0.0 ; 
-      fVertex[i][2] = 0.0 ; 
-    }          
-  }  
-  return fMixedEvent ; 
-}
-
 
 
index 2628915..bea69e4 100755 (executable)
@@ -216,9 +216,12 @@ public:
   virtual Float_t GetHistoAsymmetryMin()   const { return fHistoAsymMin ; }
   virtual Float_t GetHistoAsymmetryMax()   const { return fHistoAsymMax ; }    
   
-  virtual AliMixedEvent * GetMixedEvent() ; 
-  Int_t       GetNMixedEvent() const { return fNMixedEvent ; } 
-  Double_t *  GetVertex(Int_t i) const { return fVertex[i] ; } 
+  virtual AliMixedEvent * GetMixedEvent()          { return GetReader()->GetMixedEvent() ; } 
+  virtual Int_t           GetNMixedEvent()   const { return GetReader()->GetNMixedEvent() ; } 
+  
+  virtual void      GetVertex(Double_t vertex[3])   const { GetReader()->GetVertex(vertex) ; } 
+  virtual void      GetVertex(Double_t vertex[3],const Int_t evtIndex) const { GetReader()->GetVertex(vertex,evtIndex) ; } 
+  virtual Double_t* GetVertex(const Int_t evtIndex) const { return GetReader()->GetVertex(evtIndex) ; } 
 
        virtual Bool_t IsTrackMatched(const AliVCluster * cluster) const { return fCaloPID->IsTrackMatched(cluster); } 
   
@@ -269,13 +272,7 @@ private:
   Float_t fHistoAsymMax  ;  // Maximum value of asymmetry histogram range
   Float_t fHistoAsymMin  ;  // Minimum value of asymmetry histogram range
   
-  AliMixedEvent * fMixedEvent ;  //! mixed event object
-  Int_t           fNMixedEvent ; //! number of events in mixed event buffer
-  Double_t **     fVertex ;      //! vertex array 3 dim for each mixed event buffer
-
-  
-       
-  ClassDef(AliAnaPartCorrBaseClass,8)
+  ClassDef(AliAnaPartCorrBaseClass,9)
 } ;
 
 
index cdfa952..3bb7877 100755 (executable)
@@ -160,42 +160,44 @@ TList * AliAnaPartCorrMaker::FillAndGetAODBranchList()
 //________________________________________________________________________
 TList *AliAnaPartCorrMaker::GetOutputContainer()
 {
-// Fill the output list of histograms during the CreateOutputObjects stage.
-  if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
-    printf("AliAnaPartCorrMaker::GetOutputContainer() - Analysis job list not initialized!!!\n");
-    //abort();
-  }
-
+  // Fill the output list of histograms during the CreateOutputObjects stage.
+  
   //Initialize calorimeters  geometry pointers
   GetCaloUtils()->InitPHOSGeometry();
   GetCaloUtils()->InitEMCALGeometry();
-
-  char newname[128];
-  for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
-    AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
-    if(fMakeHisto){// Analysis with histograms as output on
-      //Fill container with appropriate histograms                     
-      TList * templist =  ana ->GetCreateOutputObjects(); 
-         templist->SetOwner(kFALSE); //Owner is fOutputContainer.
-      for(Int_t i = 0; i < templist->GetEntries(); i++){
-
-       //Add only  to the histogram name the name of the task
-       if(   strcmp((templist->At(i))->ClassName(),"TObjString")   ) {
-         sprintf(newname,"%s%s", (ana->GetAddedHistogramsStringToName()).Data(), (templist->At(i))->GetName());  
-         ((TH1*) templist->At(i))->SetName(newname);
-       }
-       //Add histogram to general container
-       fOutputContainer->Add(templist->At(i)) ;
-      }
-               delete templist;
-    }// Analysis with histograms as output on
-  }//Loop on analysis defined
   
+  if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
+    printf("AliAnaPartCorrMaker::GetOutputContainer() - Analysis job list not initialized!!!\n");
+    //abort();
+  }
+  else{
+    const Int_t buffersize = 255;
+    char newname[255];
+    for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
+      AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
+      if(fMakeHisto){// Analysis with histograms as output on
+        //Fill container with appropriate histograms                   
+        TList * templist =  ana ->GetCreateOutputObjects(); 
+        templist->SetOwner(kFALSE); //Owner is fOutputContainer.
+        for(Int_t i = 0; i < templist->GetEntries(); i++){
+          
+          //Add only  to the histogram name the name of the task
+          if(   strcmp((templist->At(i))->ClassName(),"TObjString")   ) {
+            snprintf(newname,buffersize, "%s%s", (ana->GetAddedHistogramsStringToName()).Data(), (templist->At(i))->GetName());  
+            ((TH1*) templist->At(i))->SetName(newname);
+          }
+          //Add histogram to general container
+          fOutputContainer->Add(templist->At(i)) ;
+        }
+        delete templist;
+      }// Analysis with histograms as output on
+    }//Loop on analysis defined
+  }//Analysis list available
   fhNEvents        = new TH1I("hNEvents", "Number of analyzed events"   , 1 , 0 , 1  ) ;
   fOutputContainer->Add(fhNEvents);
        
   return fOutputContainer;
-
+  
 }
 
 //________________________________________________________________________
@@ -203,26 +205,28 @@ void AliAnaPartCorrMaker::Init()
 {  
   //Init container histograms and other common variables
   // Fill the output list of histograms during the CreateOutputObjects stage.
-  if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
-    printf("AliAnaPartCorrMaker::GetOutputInit() - Analysis job list not initialized!!!\n");
-    //abort();
-  }
-       
+  
   //Initialize reader
   GetReader()->Init();
   GetReader()->SetCaloUtils(GetCaloUtils()); // pass the calo utils pointer to the reader
        
-  //fCaloUtils->Init();
-  for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
-    
-    AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
-    ana->SetReader(fReader); //SetReader for each analysis
-    ana->SetCaloUtils(fCaloUtils); //Set CaloUtils for each analysis
+  
+  if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0){
+    printf("AliAnaPartCorrMaker::GetOutputInit() - Analysis job list not initialized!!!\n");
+    //abort();
+  }
+       else{
 
-    ana->Init();
-    
-  }//Loop on analysis defined
+    for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
+      
+      AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
+      ana->SetReader(fReader); //SetReader for each analysis
+      ana->SetCaloUtils(fCaloUtils); //Set CaloUtils for each analysis
+      
+      ana->Init();
+      
+    }//Loop on analysis defined
+  }//Analysis list available
 }
 
 //____________________________________________________________________________
@@ -297,7 +301,7 @@ void AliAnaPartCorrMaker::ProcessEvent(const Int_t iEntry, const char * currentF
   }
        
   fCaloUtils->SetGeometryTransformationMatrices(fReader->GetInputEvent());     
-       
+  
   //printf(">>>>>>>>>> BEFORE >>>>>>>>>>>\n");
   //gObjectTable->Print();
   //Loop on analysis algorithms
index 625d646..6dd1ab7 100755 (executable)
@@ -94,18 +94,22 @@ void AliAnaScale::Exec(Option_t *)
   // Do the Scaling
 
   if(fDebug > 0 ) printf(">>>>> Scaling factor %e, do Sumw2 %d <<<<< \n",fScale,fSumw2) ;
+  
+  const Int_t buffersize = 255;
+  char name[buffersize] ; 
 
   TIter next(fInputList) ;     
   TObject * h ; 
   while ( (h = next()) ) { 
     if(h){
       if ( !strncmp(h->ClassName(),"TH",2) ) {
-      char name[128] ; 
-      sprintf(name, "%sScaled", h->GetName()) ; 
+      snprintf(name, buffersize, "%sScaled", h->GetName()) ; 
       TH1 * hout = dynamic_cast<TH1*> (h->Clone(name)) ; 
-      if(fSumw2) hout->Sumw2();
-      hout->Scale(fScale) ;  
-      fOutputList->Add(hout) ; 
+      if(hout){
+        if(fSumw2) hout->Sumw2();
+        hout->Scale(fScale) ;  
+        fOutputList->Add(hout) ;
+        }// casting not null
       } 
       else  fOutputList->Add(h) ; 
     }
index 1496464..67dafe6 100755 (executable)
@@ -64,7 +64,10 @@ public:
   Bool_t KeepParticleWithStatus(Int_t status) const ;
   
   void GetVertex(Double_t v[3]) const ;
-
+  Double_t* GetVertex(const Int_t evtIndex) const {return fVertex[evtIndex];}
+  void GetVertex(Double_t vertex[3], const Int_t evtIndex) const 
+    {vertex[0]=fVertex[evtIndex][0];  vertex[1]=fVertex[evtIndex][1];  vertex[2]=fVertex[evtIndex][2];}   
+  
   Bool_t FillInputEvent(const Int_t iEntry, const char * currentFileName) ;
   AliVEvent*  GetInputEvent() const {return (AliVEvent *) GetMC();}
   void SetInputOutputMCEvent(AliVEvent* esd, AliAODEvent* aod, AliMCEvent* mc) ;
index 3a610c3..5380ef2 100755 (executable)
@@ -508,16 +508,12 @@ Bool_t AliCaloTrackReader::FillInputEvent(const Int_t iEntry, const char * curre
 //    
 //  }
        
-
-  for (Int_t iev = 0; iev < fNMixedEvent; iev++) {
-    if (!fMixedEvent) {
-      GetVertex() ;
-    }      
-    else 
-      fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);     
-  }
+  //Fill Vertex array
+  
+  FillVertexArray();
   
-  if(fFillEMCALCells) 
+  //Fill the arrays with cluster/tracks/cells data
+   if(fFillEMCALCells) 
     FillInputEMCALCells();
   if(fFillPHOSCells)  
     FillInputPHOSCells();
@@ -571,19 +567,67 @@ void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
 }
 
 //____________________________________________________________________________
-Double_t * AliCaloTrackReader::GetVertex() {
-    //Return vertex position
-  if (fMixedEvent)
-    return NULL ; 
-  if(fInputEvent->GetPrimaryVertex())
+void AliCaloTrackReader::GetVertex(Double_t vertex[3]) const {
+  //Return vertex position to be used for single event analysis
+  vertex[0]=fVertex[0][0];  
+  vertex[1]=fVertex[0][1];  
+  vertex[2]=fVertex[0][2];
+}
+
+//____________________________________________________________________________
+void AliCaloTrackReader::GetVertex(Double_t vertex[3], const Int_t evtIndex) const {
+  //Return vertex position for mixed event, recover the vertex in a particular event.
+  
+  //Int_t evtIndex = 0; // for single events only one vertex stored in position 0, default value
+  //if (fMixedEvent && clusterID >=0) {
+  //  evtIndex=GetMixedEvent()->EventIndexForCaloCluster(clusterID) ; 
+  //}
+  
+  vertex[0]=fVertex[evtIndex][0];  vertex[1]=fVertex[evtIndex][1];  vertex[2]=fVertex[evtIndex][2];
+  
+}
+//
+
+
+//____________________________________________________________________________
+void AliCaloTrackReader::FillVertexArray() {
+  
+  //Fill data member with vertex
+  //In case of Mixed event, multiple vertices
+  
+  //Delete previous vertex
+  if(fVertex){
+    for (Int_t i = 0; i < fNMixedEvent; i++) {
+      delete [] fVertex[i] ; 
+    }
+    delete [] fVertex ;  
+  }
+  
+  fVertex = new Double_t*[fNMixedEvent] ; 
+  for (Int_t i = 0; i < fNMixedEvent; i++) {
+    fVertex[i] = new Double_t[3] ; 
+    fVertex[i][0] = 0.0 ; 
+    fVertex[i][1] = 0.0 ; 
+    fVertex[i][2] = 0.0 ; 
+  }          
+  
+  if (!fMixedEvent) { //Single event analysis
     fInputEvent->GetPrimaryVertex()->GetXYZ(fVertex[0]); 
-  else {
-    printf("AliCaloTrackReader::GetVertex() - No vertex available, InputEvent()->GetPrimaryVertex() = 0, return (0,0,0)\n");
-    fVertex[0][0]=0.0; fVertex[0][1]=0.0; fVertex[0][2]=0.0;
+    if(fDebug > 1)
+      printf("AliCaloTrackReader::FillVertexArray() - Single Event Vertex : %f,%f,%f\n",fVertex[0][0],fVertex[0][1],fVertex[0][2]);
+
+  } else { // MultiEvent analysis
+    for (Int_t iev = 0; iev < fNMixedEvent; iev++) {
+      fMixedEvent->GetVertexOfEvent(iev)->GetXYZ(fVertex[iev]);
+      if(fDebug > 1)
+        printf("AliCaloTrackReader::FillVertexArray() - Multi Event %d Vertex : %f,%f,%f\n",iev,fVertex[iev][0],fVertex[iev][1],fVertex[iev][2]);
+
+    }
   }
-  return fVertex[0] ; 
+  
 }
 
+
 //____________________________________________________________________________
 void AliCaloTrackReader::FillInputCTS() {
   //Return array with Central Tracking System (CTS) tracks
@@ -870,5 +914,3 @@ Bool_t AliCaloTrackReader::IsPHOSCluster(AliVCluster * cluster) const {
   
 }
 
-
-
index da564d8..b73cc64 100755 (executable)
@@ -125,15 +125,16 @@ public:
   virtual TClonesArray*   GetAODMCParticles(Int_t input = 0) const ;
   virtual AliAODMCHeader* GetAODMCHeader(Int_t input = 0)    const ;
        
-  virtual AliVEvent*   GetInputEvent()  const {return fInputEvent;}
-  virtual AliAODEvent* GetOutputEvent() const {return fOutputEvent;}
-  virtual AliMCEvent*  GetMC()          const {return fMC;}
-  virtual void         GetVertex(Double_t *) const {;}
-  virtual void         GetSecondInputAODVertex(Double_t *) const {;}
-  virtual Double_t     GetBField() const { return 0.;}
+  virtual AliVEvent*     GetInputEvent()  const {return fInputEvent;}
+  virtual AliAODEvent*   GetOutputEvent() const {return fOutputEvent;}
+  virtual AliMCEvent*    GetMC()          const {return fMC;}
+  virtual AliMixedEvent* GetMixedEvent()  const {return fMixedEvent;}
+  virtual Int_t          GetNMixedEvent() const {return fNMixedEvent ; } 
+
+  virtual Double_t       GetBField() const { return 0.;}
        
   virtual void Init();
-       
+
 //  virtual void SetInputEvent(AliVEvent* const input)  {fInputEvent  = input;}
   virtual void SetInputEvent(AliVEvent* const input) ;
   virtual void SetOutputEvent(AliAODEvent* const aod) {fOutputEvent = aod;}
@@ -196,8 +197,12 @@ public:
   AliCalorimeterUtils * GetCaloUtils() const {return fCaloUtils ; }
   void SetCaloUtils(AliCalorimeterUtils * caloutils) { fCaloUtils = caloutils ; }
   
-  Double_t * GetVertex() ;  
-    
+  virtual void GetVertex(Double_t v[3]) const ;
+  virtual Double_t* GetVertex(const Int_t evtIndex) const {return fVertex[evtIndex];}
+  virtual void GetVertex(Double_t vertex[3], const Int_t evtIndex) const ;
+  virtual void FillVertexArray();
+ // virtual void       GetSecondInputAODVertex(Double_t *) const {;}
+  
   void SwitchOnWriteDeltaAOD()  {fWriteOutputDeltaAOD = kTRUE ;  }
   void SwitchOffWriteDeltaAOD() {fWriteOutputDeltaAOD = kFALSE ; }
   Bool_t WriteDeltaAODToFile() const {return fWriteOutputDeltaAOD ; } 
index c17d73d..63408b2 100755 (executable)
@@ -36,6 +36,7 @@
 #include "AliAODTrack.h"
 #include "AliVCluster.h"
 #include "AliCaloTrackReader.h"
+#include "AliMixedEvent.h"
 
 ClassImp(AliIsolationCut)
   
@@ -180,29 +181,35 @@ void  AliIsolationCut::MakeIsolationCut(TObjArray * const plCTS,  TObjArray * co
   if(plNe && (fPartInCone==kOnlyNeutral || fPartInCone==kNeutralAndCharged)){
          
     //Get vertex for photon momentum calculation
-    Double_t vertex[]  = {0,0,0} ; //vertex ;
-    Double_t vertex2[] = {0,0,0} ; //vertex second AOD input ;
-    if(reader->GetDataType()!= AliCaloTrackReader::kMC) 
-    {
-      reader->GetVertex(vertex);
+    //Double_t vertex2[] = {0,0,0} ; //vertex second AOD input ;
+    //if(reader->GetDataType()!= AliCaloTrackReader::kMC) 
+    //{
       //if(reader->GetSecondInputAODTree()) reader->GetSecondInputAODVertex(vertex2);
-    }
+    //}
     TLorentzVector mom ;
     for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){
       AliVCluster * calo = (AliVCluster *)(plNe->At(ipr)) ;
       
+      //Get the index where the cluster comes, to retrieve the corresponding vertex
+      Int_t evtIndex = 0 ; 
+      if (reader->GetMixedEvent()) {
+        evtIndex=reader->GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
+      }
+      
       //Do not count the candidate (photon or pi0) or the daughters of the candidate
       if(calo->GetID() == pCandidate->GetCaloLabel(0) || calo->GetID() == pCandidate->GetCaloLabel(1)) continue ;      //Skip matched clusters with tracks
       
       if(calo->GetNTracksMatched() > 0) continue ; 
+      
       //Input from second AOD?
-      Int_t input = 0;
+      //Int_t input = 0;
       //      if     (pCandidate->GetDetector() == "EMCAL" && reader->GetAODEMCALNormalInputEntries() <= ipr) input = 1 ;
       //      else if(pCandidate->GetDetector() == "PHOS"  && reader->GetAODPHOSNormalInputEntries()  <= ipr) 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     (input == 0) 
+      calo->GetMomentum(mom,reader->GetVertex(evtIndex)) ;//Assume that come from vertex in straight line
+      //else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line  
       
       pt   = mom.Pt();
       eta  = mom.Eta();
@@ -234,7 +241,7 @@ void  AliIsolationCut::MakeIsolationCut(TObjArray * const plCTS,  TObjArray * co
   //Add reference arrays to AOD when filling AODs only
   if(fillAOD) {
     if(refclusters)    pCandidate->AddObjArray(refclusters);
-    if(reftracks)      pCandidate->AddObjArray(reftracks);
+    if(reftracks)        pCandidate->AddObjArray(reftracks);
   }
   
   //Check isolation, depending on method.
index aa2058d..0ce2bb1 100755 (executable)
@@ -23,7 +23,7 @@
 //                
 //*-- Author: Gustavo Conesa (LNF-INFN) 
 //////////////////////////////////////////////////////////////////////////////
-  
+
 
 // --- ROOT system ---
 #include <TMath.h>
 #include "AliGenPythiaEventHeader.h"
 #include "AliAODMCParticle.h"
 
-  ClassImp(AliMCAnalysisUtils)
+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
 }
 /*
-//____________________________________________________________________________
-AliMCAnalysisUtils::AliMCAnalysisUtils(const AliMCAnalysisUtils & mcutils) :   
-  TObject(mcutils), fCurrentEvent(mcutils.fCurrentEvent), fDebug(mcutils.fDebug),
-  fJetsList(new TList), fMCGenerator(mcutils.fMCGenerator)
-{
-  // cpy ctor
-  
-}
-*/
+ //____________________________________________________________________________
+ AliMCAnalysisUtils::AliMCAnalysisUtils(const AliMCAnalysisUtils & mcutils) :   
+ TObject(mcutils), fCurrentEvent(mcutils.fCurrentEvent), fDebug(mcutils.fDebug),
+ fJetsList(new TList), fMCGenerator(mcutils.fMCGenerator)
+ {
+ // cpy ctor
+ }
+ */
 
 //_________________________________________________________________________
 //AliMCAnalysisUtils & AliMCAnalysisUtils::operator = (const AliMCAnalysisUtils & mcutils)
@@ -126,20 +126,20 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
   //entity (track, cluster, etc) for which we want to know something 
   //about its heritage, but one can also use it directly with stack 
   //particles not connected to reconstructed entities
-
+  
   if(!stack) {
     if (fDebug >=0) 
-               printf("AliMCAnalysisUtils::CheckOriginInStack() - Stack is not available, check analysis settings in configuration file, STOP!!\n");
-       return -1;
+      printf("AliMCAnalysisUtils::CheckOriginInStack() - Stack is not available, check analysis settings in configuration file, STOP!!\n");
+    return -1;
   }
-
+  
   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);
-       Int_t iMom = label;
+    Int_t iMom = label;
     Int_t mPdg = TMath::Abs(mom->GetPdgCode());
     Int_t mStatus =  mom->GetStatusCode() ;
     Int_t iParent =  mom->GetFirstMother() ;
@@ -156,54 +156,54 @@ 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 ) {
+    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);
-       }
+    }
          
     //Check if "mother" of entity is converted, if not, get the first non converted mother
     if((mPdg == 22 || mPdg == 11) && (pPdg == 22 || pPdg == 11) && mStatus == 0){
       SetTagBit(tag,kMCConversion);
       //Check if the mother is photon or electron with status not stable
       while ((pPdg == 22 || pPdg == 11) && mStatus != 1) {
-       //Mother
-       iMom = mom->GetFirstMother();
-       mom = stack->Particle(iMom);
-       mPdg = TMath::Abs(mom->GetPdgCode());
-       mStatus =  mom->GetStatusCode() ;
-       iParent =  mom->GetFirstMother() ;
-       if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - Mother is parton %d\n",iParent);
-       
-       //GrandParent
-       if(iParent >= 0){
-         parent = stack->Particle(iParent);
-         pPdg = TMath::Abs(parent->GetPdgCode());
-         pStatus = parent->GetStatusCode();  
-       }
+        //Mother
+        iMom = mom->GetFirstMother();
+        mom = stack->Particle(iMom);
+        mPdg = TMath::Abs(mom->GetPdgCode());
+        mStatus =  mom->GetStatusCode() ;
+        iParent =  mom->GetFirstMother() ;
+        if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - Mother is parton %d\n",iParent);
+        
+        //GrandParent
+        if(iParent >= 0){
+          parent = stack->Particle(iParent);
+          pPdg = TMath::Abs(parent->GetPdgCode());
+          pStatus = parent->GetStatusCode();  
+        }
       }//while   
-               if(fDebug > 2 ) {
-                       printf("AliMCAnalysisUtils::CheckOriginInStack() - Converted photon/electron: \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);
-               }
-               
+      if(fDebug > 2 ) {
+        printf("AliMCAnalysisUtils::CheckOriginInStack() - Converted photon/electron: \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);
+      }
+      
     }//mother and parent are electron or photon and have status 0
     else if((mPdg == 22 || mPdg == 11) && mStatus == 0){       
       //Still a conversion but only one electron/photon generated. Just from hadrons but not decays.
       if(pPdg == 2112 ||  pPdg == 211  ||  pPdg == 321 ||
-                pPdg == 2212 ||  pPdg == 130  ||  pPdg == 13 ) {
-                 SetTagBit(tag,kMCConversion);
-                 iMom = mom->GetFirstMother();
-                 mom  = stack->Particle(iMom);
-                 mPdg = TMath::Abs(mom->GetPdgCode());
-               
-                 if(fDebug > 2 ) {
-                         printf("AliMCAnalysisUtils::CheckOriginInStack() - Converted hadron: \n");
-                         printf("\t Mother label %d, pdg %d, status %d\n",iMom, mPdg, mStatus);
-                 }
-         }//hadron converted
-               
+         pPdg == 2212 ||  pPdg == 130  ||  pPdg == 13 ) {
+        SetTagBit(tag,kMCConversion);
+        iMom = mom->GetFirstMother();
+        mom  = stack->Particle(iMom);
+        mPdg = TMath::Abs(mom->GetPdgCode());
+        
+        if(fDebug > 2 ) {
+          printf("AliMCAnalysisUtils::CheckOriginInStack() - Converted hadron: \n");
+          printf("\t Mother label %d, pdg %d, status %d\n",iMom, mPdg, mStatus);
+        }
+      }//hadron converted
+      
       //Comment for the next lines, we do not check the parent of the hadron for the moment.
       //iParent =  mom->GetFirstMother() ;
       //if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - Mother is parton %d\n",iParent);
@@ -223,104 +223,104 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
     else if(mPdg == 2212) SetTagBit(tag,kMCProton);
     //check for pi0 and eta (shouldn't happen unless their decays were turned off)
     else if(mPdg == 111)  {
-               SetTagBit(tag,kMCPi0Decay);
-               if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - First mother is directly pi0, not decayed by generator \n");
-               CheckOverlapped2GammaDecay(labels,nlabels, iMom, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
-       }
+      SetTagBit(tag,kMCPi0Decay);
+      if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - First mother is directly pi0, not decayed by generator \n");
+      CheckOverlapped2GammaDecay(labels,nlabels, iMom, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
+    }
     else if(mPdg == 221) {
-               SetTagBit(tag,kMCEtaDecay);
-               if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - First mother is directly eta, not decayed by generator \n");
-               CheckOverlapped2GammaDecay(labels,nlabels, iMom, stack, tag); //set to kMCEta if 2 gammas in same cluster
-       }
+      SetTagBit(tag,kMCEtaDecay);
+      if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - First mother is directly eta, not decayed by generator \n");
+      CheckOverlapped2GammaDecay(labels,nlabels, iMom, stack, tag); //set to kMCEta if 2 gammas in same cluster
+    }
     //Photons  
     else if(mPdg == 22){
       SetTagBit(tag,kMCPhoton);
       if(mStatus == 1){ //undecayed particle
-       if(fMCGenerator == "PYTHIA"){
-         if(iParent < 8 && iParent > 5) {//outgoing partons
-           if(pPdg == 22) SetTagBit(tag,kMCPrompt);
-           else SetTagBit(tag,kMCFragmentation);
-         }//Outgoing partons 
-         else  if(iParent <= 5) {
-           SetTagBit(tag, kMCISR); //Initial state radiation
-         }
-         else if(pStatus == 11){//Decay
-                 if(pPdg == 111) {
-                         SetTagBit(tag,kMCPi0Decay);
-                         if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - PYTHIA pi0 decay photon,  parent pi0 with status 11 \n");
-                         CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
-                 }
-                 else if (pPdg == 221) {
-                         SetTagBit(tag, kMCEtaDecay);
-                         if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - PYTHIA eta decay photon,  parent pi0 with status 11 \n");
-                         CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag);//set to kMCEta if 2 gammas in same cluster
-                 }
-                 else SetTagBit(tag,kMCOtherDecay);
-         }//Decay
-         else {
-           if(fDebug > 1 ) 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);
-                 if(pPdg == 111) {
-                         SetTagBit(tag,kMCPi0Decay);
-                         if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - PYTHIA pi0 decay photon,  parent pi0 with status 11 \n");
-                         CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
-                 }
-                 else if (pPdg == 221) {
-                         SetTagBit(tag, kMCEtaDecay);
-                         if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - PYTHIA eta decay photon,  parent pi0 with status 11 \n");
-                         CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag);//set to kMCEta if 2 gammas in same cluster
-                 }
-                 else SetTagBit(tag,kMCOtherDecay);
-         }
-       }//PYTHIA
-       
-       else if(fMCGenerator == "HERWIG"){        
-         if(pStatus < 197){//Not decay
-           while(1){
-             if(parent->GetFirstMother()<=5) break;
-             iParent = parent->GetFirstMother();
-             parent=stack->Particle(iParent);
-             pStatus= parent->GetStatusCode();
-                       pPdg = TMath::Abs(parent->GetPdgCode());
-           }//Look for the parton
-           
-           if(iParent < 8 && iParent > 5) {
-             if(pPdg == 22) SetTagBit(tag,kMCPrompt);
-             else SetTagBit(tag,kMCFragmentation);
-           }
-           else SetTagBit(tag,kMCISR);//Initial state radiation
-         }//Not decay
-         else{//Decay
-                 if(pPdg == 111) {
-                         SetTagBit(tag,kMCPi0Decay);
-                         if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - HERWIG pi0 decay photon \n");
-                         CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
-                 }
-                 else if (pPdg == 221) {
-                         SetTagBit(tag,kMCEtaDecay);
-                         if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - HERWIG eta decay photon \n");
-                         CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCEta if 2 gammas in same cluster
-                 }
-           else SetTagBit(tag,kMCOtherDecay);
-         }//Decay
-       }//HERWIG
-       
-       else SetTagBit(tag,kMCUnknown);
-       
+        if(fMCGenerator == "PYTHIA"){
+          if(iParent < 8 && iParent > 5) {//outgoing partons
+            if(pPdg == 22) SetTagBit(tag,kMCPrompt);
+            else SetTagBit(tag,kMCFragmentation);
+          }//Outgoing partons 
+          else  if(iParent <= 5) {
+            SetTagBit(tag, kMCISR); //Initial state radiation
+          }
+          else if(pStatus == 11){//Decay
+            if(pPdg == 111) {
+              SetTagBit(tag,kMCPi0Decay);
+              if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - PYTHIA pi0 decay photon,  parent pi0 with status 11 \n");
+              CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
+            }
+            else if (pPdg == 221) {
+              SetTagBit(tag, kMCEtaDecay);
+              if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - PYTHIA eta decay photon,  parent pi0 with status 11 \n");
+              CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag);//set to kMCEta if 2 gammas in same cluster
+            }
+            else SetTagBit(tag,kMCOtherDecay);
+          }//Decay
+          else {
+            if(fDebug > 1 ) 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);
+            if(pPdg == 111) {
+              SetTagBit(tag,kMCPi0Decay);
+              if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - PYTHIA pi0 decay photon,  parent pi0 with status 11 \n");
+              CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
+            }
+            else if (pPdg == 221) {
+              SetTagBit(tag, kMCEtaDecay);
+              if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - PYTHIA eta decay photon,  parent pi0 with status 11 \n");
+              CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag);//set to kMCEta if 2 gammas in same cluster
+            }
+            else SetTagBit(tag,kMCOtherDecay);
+          }
+        }//PYTHIA
+        
+        else if(fMCGenerator == "HERWIG"){       
+          if(pStatus < 197){//Not decay
+            while(1){
+              if(parent->GetFirstMother()<=5) break;
+              iParent = parent->GetFirstMother();
+              parent=stack->Particle(iParent);
+              pStatus= parent->GetStatusCode();
+              pPdg = TMath::Abs(parent->GetPdgCode());
+            }//Look for the parton
+            
+            if(iParent < 8 && iParent > 5) {
+              if(pPdg == 22) SetTagBit(tag,kMCPrompt);
+              else SetTagBit(tag,kMCFragmentation);
+            }
+            else SetTagBit(tag,kMCISR);//Initial state radiation
+          }//Not decay
+          else{//Decay
+            if(pPdg == 111) {
+              SetTagBit(tag,kMCPi0Decay);
+              if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - HERWIG pi0 decay photon \n");
+              CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
+            }
+            else if (pPdg == 221) {
+              SetTagBit(tag,kMCEtaDecay);
+              if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - HERWIG eta decay photon \n");
+              CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCEta if 2 gammas in same cluster
+            }
+            else SetTagBit(tag,kMCOtherDecay);
+          }//Decay
+        }//HERWIG
+        
+        else SetTagBit(tag,kMCUnknown);
+        
       }//Status 1 : created by event generator
       
       else if(mStatus == 0){ // geant
-       if(pPdg == 111) {
-               SetTagBit(tag,kMCPi0Decay);
-               if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - Transport MC pi0 decay photon \n");
-               CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
-       }
-       else if (pPdg == 221) {
-               SetTagBit(tag,kMCEtaDecay);
-               if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - Transport MC eta decay photon \n");
-               CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCEta if 2 gammas in same cluster
-       }
-       else  SetTagBit(tag,kMCOtherDecay);     
+        if(pPdg == 111) {
+          SetTagBit(tag,kMCPi0Decay);
+          if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - Transport MC pi0 decay photon \n");
+          CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCPi0 if 2 gammas in same cluster
+        }
+        else if (pPdg == 221) {
+          SetTagBit(tag,kMCEtaDecay);
+          if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInStack() - Transport MC eta decay photon \n");
+          CheckOverlapped2GammaDecay(labels,nlabels, iParent, stack, tag); //set to kMCEta if 2 gammas in same cluster
+        }
+        else  SetTagBit(tag,kMCOtherDecay);    
       }//status 0 : geant generated
       
     }//Mother Photon
@@ -332,7 +332,7 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
         if(iGrandma >= 0) {
           TParticle* gma = (TParticle*)stack->Particle(iGrandma); //get mother
           Int_t gPdg = TMath::Abs(gma->GetPdgCode());
-
+          
           if (gPdg == 23) { SetTagBit(tag,kMCZDecay); } //parent is Z-boson
           else if (gPdg == 24) { SetTagBit(tag,kMCWDecay); } //parent is W-boson
         }
@@ -343,18 +343,18 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
       else if (pPdg == 221) { SetTagBit(tag,kMCEtaDecay); } //Eta Dalitz decay
       else if((499 < pPdg && pPdg < 600)||(4999 < pPdg && pPdg < 6000)) { SetTagBit(tag,kMCEFromB); } //b-->e decay
       else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000)) { //check charm decay
-       Int_t iGrandma = parent->GetFirstMother();
-       if(iGrandma >= 0) {
-         TParticle* gma = (TParticle*)stack->Particle(iGrandma); //get mother of charm
-         Int_t gPdg = TMath::Abs(gma->GetPdgCode());
-         if((499 < gPdg && gPdg < 600)||(4999 < gPdg && gPdg < 6000)) SetTagBit(tag,kMCEFromCFromB); //b-->c-->e
-         else SetTagBit(tag,kMCEFromC); //c-->e 
-       } else SetTagBit(tag,kMCEFromC); //c-->e 
+        Int_t iGrandma = parent->GetFirstMother();
+        if(iGrandma >= 0) {
+          TParticle* gma = (TParticle*)stack->Particle(iGrandma); //get mother of charm
+          Int_t gPdg = TMath::Abs(gma->GetPdgCode());
+          if((499 < gPdg && gPdg < 600)||(4999 < gPdg && gPdg < 6000)) SetTagBit(tag,kMCEFromCFromB); //b-->c-->e
+          else SetTagBit(tag,kMCEFromC); //c-->e 
+        } else SetTagBit(tag,kMCEFromC); //c-->e 
       } else {
-       //if it is not from any of the above, where is it from?
-       if(pPdg > 10000) SetTagBit(tag,kMCUnknown);
-       else SetTagBit(tag,kMCOtherDecay);
-       if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOriginInStack() - Status %d Electron from other origin: %s (pPdg = %d) %s (mpdg = %d)\n",mStatus,parent->GetName(),pPdg,mom->GetName(),mPdg);
+        //if it is not from any of the above, where is it from?
+        if(pPdg > 10000) SetTagBit(tag,kMCUnknown);
+        else SetTagBit(tag,kMCOtherDecay);
+        if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOriginInStack() - Status %d Electron from other origin: %s (pPdg = %d) %s (mpdg = %d)\n",mStatus,parent->GetName(),pPdg,mom->GetName(),mPdg);
       }
     }//electron check
     //Cluster was made by something else
@@ -366,9 +366,9 @@ Int_t AliMCAnalysisUtils::CheckOriginInStack(const Int_t *labels, const Int_t nl
   else{// Bad label 
          
     if(label < 0 && (fDebug >= 0)) 
-               printf("AliMCAnalysisUtils::CheckOriginInStack() *** bad label or no stack ***:  label %d \n", label);
+      printf("AliMCAnalysisUtils::CheckOriginInStack() *** bad label or no stack ***:  label %d \n", label);
     if(label >=  stack->GetNtrack() &&  (fDebug >= 0)) 
-               printf("AliMCAnalysisUtils::CheckOriginInStack() *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
+      printf("AliMCAnalysisUtils::CheckOriginInStack() *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
     SetTagBit(tag,kMCUnknown);
   }//Bad label
   
@@ -383,18 +383,18 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
   // Do same things as in CheckOriginInStack but different input.
   if(!mcparticles) {
     if(fDebug >= 0)
-               printf("AliMCAnalysisUtils::CheckOriginInAOD() - AODMCParticles is not available, check analysis settings in configuration file!!\n");
-       return -1;
+      printf("AliMCAnalysisUtils::CheckOriginInAOD() - AODMCParticles is not available, check analysis settings in configuration file!!\n");
+    return -1;
   }
        
   Int_t tag = 0;
   Int_t label=labels[0];//Most significant particle contributing to the cluster
-
+  
   Int_t nprimaries = mcparticles->GetEntriesFast();
   if(label >= 0 && label < nprimaries){
     //Mother
     AliAODMCParticle * mom = (AliAODMCParticle *) mcparticles->At(label);
-       Int_t iMom = label;
+    Int_t iMom = label;
     Int_t mPdg = TMath::Abs(mom->GetPdgCode());
     Int_t iParent =  mom->GetMother() ;
     if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Mother is parton %d\n",iParent);
@@ -407,57 +407,57 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
       pPdg = TMath::Abs(parent->GetPdgCode());
     }
     else if(fDebug > 0 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Parent with label %d\n",iParent);
-       if(fDebug > 2 ) {
+    
+    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());
                  printf("\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
-       }
+    }
          
     //Check if mother is converted, if not, get the first non converted mother
     if((mPdg == 22 || mPdg == 11) && (pPdg == 22 || pPdg == 11) && !mom->IsPrimary()){
       SetTagBit(tag,kMCConversion);
       //Check if the mother is photon or electron with status not stable
       while ((pPdg == 22 || pPdg == 11) && !mom->IsPhysicalPrimary()) {
-       //Mother
-       iMom = mom->GetMother();
-       mom = (AliAODMCParticle *) mcparticles->At(iMom);
-       mPdg = TMath::Abs(mom->GetPdgCode());
-       iParent =  mom->GetMother() ;
-       if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Mother is parton %d\n",iParent);
-       
-       //GrandParent
-       if(iParent >= 0){
-         parent = (AliAODMCParticle *) mcparticles->At(iParent);
-         pPdg = TMath::Abs(parent->GetPdgCode());
-       }
-                // printf("\t While Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
-                // printf("\t While Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary()); 
-                 
+        //Mother
+        iMom = mom->GetMother();
+        mom = (AliAODMCParticle *) mcparticles->At(iMom);
+        mPdg = TMath::Abs(mom->GetPdgCode());
+        iParent =  mom->GetMother() ;
+        if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Mother is parton %d\n",iParent);
+        
+        //GrandParent
+        if(iParent >= 0){
+          parent = (AliAODMCParticle *) mcparticles->At(iParent);
+          pPdg = TMath::Abs(parent->GetPdgCode());
+        }
+        // printf("\t While Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
+        // printf("\t While Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary()); 
+        
       }//while 
-               
-               if(fDebug > 2 ) {
-                       printf("AliMCAnalysisUtils::CheckOriginInAOD() - Converted photon/electron : \n");
-                       printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
-                       printf("\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
-               }
-               
+      
+      if(fDebug > 2 ) {
+        printf("AliMCAnalysisUtils::CheckOriginInAOD() - Converted photon/electron : \n");
+        printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
+        printf("\t Parent label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
+      }
+      
     }//mother and parent are electron or photon and have status 0 and parent is photon or electron
     else if((mPdg == 22 || mPdg == 11) && !mom->IsPrimary()){  
       //Still a conversion but only one electron/photon generated. Just from hadrons
       if(pPdg == 2112 ||  pPdg == 211 ||  pPdg == 321 ||  
-                pPdg == 2212 ||  pPdg == 130 ||  pPdg == 13 ) {
-                 SetTagBit(tag,kMCConversion);
-                 iMom = mom->GetMother();
-                 mom = (AliAODMCParticle *) mcparticles->At(iMom);
-                 mPdg = TMath::Abs(mom->GetPdgCode());
-               
-               if(fDebug > 2 ) {
-                       printf("AliMCAnalysisUtils::CheckOriginInAOD() - Converted hadron : \n");
-                       printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
-               }
-         }//hadron converted
-               
+         pPdg == 2212 ||  pPdg == 130 ||  pPdg == 13 ) {
+        SetTagBit(tag,kMCConversion);
+        iMom = mom->GetMother();
+        mom = (AliAODMCParticle *) mcparticles->At(iMom);
+        mPdg = TMath::Abs(mom->GetPdgCode());
+        
+        if(fDebug > 2 ) {
+          printf("AliMCAnalysisUtils::CheckOriginInAOD() - Converted hadron : \n");
+          printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d\n",iMom, mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary());
+        }
+      }//hadron converted
+      
       //Comment for next lines, we do not check the parent of the hadron for the moment.
       //iParent =  mom->GetMother() ;
       //if(fDebug > 0 && label < 8 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Mother is parton %d\n",iParent);
@@ -478,62 +478,62 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
     else if(mPdg == 2212) SetTagBit(tag,kMCProton);
     //check for pi0 and eta (shouldn't happen unless their decays were turned off)
     else if(mPdg == 111)  {
-               SetTagBit(tag,kMCPi0Decay);
-               if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - First mother is directly pi0, not decayed by generator \n");
-               CheckOverlapped2GammaDecay(labels,nlabels, iMom, mcparticles, tag); //set to kMCPi0 if 2 gammas in same cluster
-       }
+      SetTagBit(tag,kMCPi0Decay);
+      if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - First mother is directly pi0, not decayed by generator \n");
+      CheckOverlapped2GammaDecay(labels,nlabels, iMom, mcparticles, tag); //set to kMCPi0 if 2 gammas in same cluster
+    }
     else if(mPdg == 221)  {
-               SetTagBit(tag,kMCEtaDecay);   
-               if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - First mother is directly eta, not decayed by generator \n");
-               CheckOverlapped2GammaDecay(labels,nlabels, iMom, mcparticles, tag); //set to kMCEta if 2 gammas in same cluster
-       }
+      SetTagBit(tag,kMCEtaDecay);   
+      if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - First mother is directly eta, not decayed by generator \n");
+      CheckOverlapped2GammaDecay(labels,nlabels, iMom, mcparticles, tag); //set to kMCEta if 2 gammas in same cluster
+    }
     //Photons  
     else if(mPdg == 22){
       SetTagBit(tag,kMCPhoton);
       if(mom->IsPhysicalPrimary()){ //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) {
-         SetTagBit(tag, kMCISR); //Initial state radiation
-       }
-       else if(parent->IsPrimary() && !parent->IsPhysicalPrimary()){//Decay
-         if(pPdg == 111){
-                       SetTagBit(tag,kMCPi0Decay);
-                       if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Generator 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);
-                 if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Generator eta decay photon \n");
-                 CheckOverlapped2GammaDecay(labels,nlabels, iParent, mcparticles, tag); //set to kMCEta if 2 gammas in same cluster
-         }
-         else SetTagBit(tag,kMCOtherDecay);
-       }//Decay
-       else {
-         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());
-         SetTagBit(tag,kMCOtherDecay);//Check
-       }
+        if(iParent < 8 && iParent > 5) {//outgoing partons
+          if(pPdg == 22) SetTagBit(tag,kMCPrompt);
+          else SetTagBit(tag,kMCFragmentation);
+        }//Outgoing partons
+        else if(iParent <= 5) {
+          SetTagBit(tag, kMCISR); //Initial state radiation
+        }
+        else if(parent->IsPrimary() && !parent->IsPhysicalPrimary()){//Decay
+          if(pPdg == 111){
+            SetTagBit(tag,kMCPi0Decay);
+            if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Generator 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);
+            if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Generator eta decay photon \n");
+            CheckOverlapped2GammaDecay(labels,nlabels, iParent, mcparticles, tag); //set to kMCEta if 2 gammas in same cluster
+          }
+          else SetTagBit(tag,kMCOtherDecay);
+        }//Decay
+        else {
+          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());
+          SetTagBit(tag,kMCOtherDecay);//Check
+        }
       }// Pythia generated
       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
-               }
-               else if (pPdg == 221) {
-                       SetTagBit(tag,kMCEtaDecay);
-                       if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Transport MC eta decay photon \n");
-                       CheckOverlapped2GammaDecay(labels,nlabels, iParent, mcparticles, tag); //set to kMCEta if 2 gammas in same cluster
-               }
-       else  SetTagBit(tag,kMCOtherDecay);
+        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
+        }
+        else if (pPdg == 221) {
+          SetTagBit(tag,kMCEtaDecay);
+          if(fDebug > 2 ) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Transport MC eta decay photon \n");
+          CheckOverlapped2GammaDecay(labels,nlabels, iParent, mcparticles, tag); //set to kMCEta if 2 gammas in same cluster
+        }
+        else  SetTagBit(tag,kMCOtherDecay);
       }//not primary : geant generated, decays
       else  {
-       //printf("UNKNOWN 1, mom  pdg %d, primary %d, physical primary %d; parent %d, pdg %d, primary %d, physical primary %d \n",
-       //mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary(), iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
-       SetTagBit(tag,kMCUnknown);
+        //printf("UNKNOWN 1, mom  pdg %d, primary %d, physical primary %d; parent %d, pdg %d, primary %d, physical primary %d \n",
+        //mPdg, mom->IsPrimary(), mom->IsPhysicalPrimary(), iParent, pPdg, parent->IsPrimary(), parent->IsPhysicalPrimary());
+        SetTagBit(tag,kMCUnknown);
       }
     }//Mother Photon
     
@@ -544,7 +544,7 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
         if(iGrandma >= 0) {
           AliAODMCParticle* gma = (AliAODMCParticle*)mcparticles->At(iGrandma);
           Int_t gPdg = TMath::Abs(gma->GetPdgCode());
-
+          
           if (gPdg == 23) { SetTagBit(tag,kMCZDecay); } //parent is Z-boson
           else if (gPdg == 24) { SetTagBit(tag,kMCWDecay); } //parent is W-boson
         }
@@ -555,19 +555,19 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
       else if (pPdg == 221) { SetTagBit(tag,kMCEtaDecay); } //Eta Dalitz decay
       else if((499 < pPdg && pPdg < 600)||(4999 < pPdg && pPdg < 6000)) { SetTagBit(tag,kMCEFromB);} //b-hadron decay
       else if((399 < pPdg && pPdg < 500)||(3999 < pPdg && pPdg < 5000)) { //c-hadron decay check
-       Int_t iGrandma = parent->GetMother();
-       if(iGrandma >= 0) {
-         AliAODMCParticle* gma = (AliAODMCParticle*)mcparticles->At(iGrandma); //charm's mother
-         Int_t gPdg = TMath::Abs(gma->GetPdgCode());
-         if((499 < gPdg && gPdg < 600)||(4999 < gPdg && gPdg < 6000)) SetTagBit(tag,kMCEFromCFromB); //b-->c-->e decay
-         else SetTagBit(tag,kMCEFromC); //c-hadron decay
-       } else SetTagBit(tag,kMCEFromC); //c-hadron decay
+        Int_t iGrandma = parent->GetMother();
+        if(iGrandma >= 0) {
+          AliAODMCParticle* gma = (AliAODMCParticle*)mcparticles->At(iGrandma); //charm's mother
+          Int_t gPdg = TMath::Abs(gma->GetPdgCode());
+          if((499 < gPdg && gPdg < 600)||(4999 < gPdg && gPdg < 6000)) SetTagBit(tag,kMCEFromCFromB); //b-->c-->e decay
+          else SetTagBit(tag,kMCEFromC); //c-hadron decay
+        } else SetTagBit(tag,kMCEFromC); //c-hadron decay
       } else { //prompt or other decay
-       TParticlePDG* foo = TDatabasePDG::Instance()->GetParticle(pPdg);
-       TParticlePDG* foo1 = TDatabasePDG::Instance()->GetParticle(mPdg);
-       if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Electron from other origin: %s (pPdg = %d) %s (mPdg = %d)\n",foo->GetName(), pPdg,foo1->GetName(),mPdg);
-       if(pPdg > 10000) SetTagBit(tag,kMCUnknown);
-       else SetTagBit(tag,kMCOtherDecay);
+        TParticlePDG* foo = TDatabasePDG::Instance()->GetParticle(pPdg);
+        TParticlePDG* foo1 = TDatabasePDG::Instance()->GetParticle(mPdg);
+        if(fDebug > 0) printf("AliMCAnalysisUtils::CheckOriginInAOD() - Electron from other origin: %s (pPdg = %d) %s (mPdg = %d)\n",foo->GetName(), pPdg,foo1->GetName(),mPdg);
+        if(pPdg > 10000) SetTagBit(tag,kMCUnknown);
+        else SetTagBit(tag,kMCOtherDecay);
       }      
     }//electron check
     //cluster was made by something else
@@ -579,11 +579,11 @@ Int_t AliMCAnalysisUtils::CheckOriginInAOD(const Int_t *labels, const Int_t nlab
   else{//Bad label
          
     if(label < 0 && (fDebug >= 0) ) 
-               printf("AliMCAnalysisUtils::CheckOriginInAOD() *** bad label or no mcparticles ***:  label %d \n", label);
+      printf("AliMCAnalysisUtils::CheckOriginInAOD() *** bad label or no mcparticles ***:  label %d \n", label);
     if(label >=  mcparticles->GetEntriesFast() &&  (fDebug >= 0) ) 
-               printf("AliMCAnalysisUtils::CheckOriginInAOD() *** large label ***:  label %d, n tracks %d \n", label, mcparticles->GetEntriesFast());
+      printf("AliMCAnalysisUtils::CheckOriginInAOD() *** large label ***:  label %d, n tracks %d \n", label, mcparticles->GetEntriesFast());
     SetTagBit(tag,kMCUnknown);
-  
+    
   }//Bad label
   
   return tag;
@@ -592,12 +592,12 @@ 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) {
+                                                    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);
+                          labels[0],stack->GetNtrack(), nlabels);
                return;
        }
        
@@ -609,7 +609,7 @@ void AliMCAnalysisUtils::CheckOverlapped2GammaDecay(const Int_t *labels, const I
        }
        
        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) 
@@ -692,17 +692,17 @@ void AliMCAnalysisUtils::CheckOverlapped2GammaDecay(const Int_t *labels, const I
 
 //_________________________________________________________________________
 void AliMCAnalysisUtils::CheckOverlapped2GammaDecay(const Int_t *labels, const Int_t nlabels, const Int_t mesonIndex, 
-                                                                                                               TClonesArray *mcparticles, Int_t &tag) {
+                                                    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);
+                          labels[0],mcparticles->GetEntriesFast(), nlabels);
                return;
        }
        
        
-    AliAODMCParticle * meson = (AliAODMCParticle *) mcparticles->At(mesonIndex);
+  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);
@@ -745,7 +745,7 @@ void AliMCAnalysisUtils::CheckOverlapped2GammaDecay(const Int_t *labels, const I
        
        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;
                
@@ -763,7 +763,7 @@ void AliMCAnalysisUtils::CheckOverlapped2GammaDecay(const Int_t *labels, const I
                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
@@ -799,7 +799,7 @@ void AliMCAnalysisUtils::CheckOverlapped2GammaDecay(const Int_t *labels, const I
 
 //_________________________________________________________________________
 TList * AliMCAnalysisUtils::GetJets(AliCaloTrackReader * const reader){
- //Return list of jets (TParticles) and index of most likely parton that originated it.
+  //Return list of jets (TParticles) and index of most likely parton that originated it.
   AliStack * stack = reader->GetStack();
   Int_t iEvent = reader->GetEventNumber();     
   AliGenEventHeader * geh = reader->GetGenEventHeader();
@@ -816,71 +816,71 @@ TList * AliMCAnalysisUtils::GetJets(AliCaloTrackReader * const reader){
     TParticle * parton2 =  stack->Particle(7);
     if(fDebug > 2){
       printf("AliMCAnalysisUtils::GetJets() - parton 6 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-            parton1->GetName(),parton1->Pt(),parton1->Energy(),parton1->Phi()*TMath::RadToDeg(),parton1->Eta());
+             parton1->GetName(),parton1->Pt(),parton1->Energy(),parton1->Phi()*TMath::RadToDeg(),parton1->Eta());
       printf("AliMCAnalysisUtils::GetJets() - parton 7 : %s, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-            parton2->GetName(),parton2->Pt(),parton2->Energy(),parton2->Phi()*TMath::RadToDeg(),parton2->Eta());
+             parton2->GetName(),parton2->Pt(),parton2->Energy(),parton2->Phi()*TMath::RadToDeg(),parton2->Eta());
                }
-//             //Trace the jet from the mother parton
-//             Float_t pt  = 0;
-//             Float_t pt1 = 0;
-//             Float_t pt2 = 0;
-//             Float_t e   = 0;
-//             Float_t e1  = 0;
-//             Float_t e2  = 0;
-//             TParticle * tmptmp = new TParticle;
-//             for(Int_t i = 0; i< stack->GetNprimary(); i++){
-//                     tmptmp = stack->Particle(i);
+    //                 //Trace the jet from the mother parton
+    //                 Float_t pt  = 0;
+    //                 Float_t pt1 = 0;
+    //                 Float_t pt2 = 0;
+    //                 Float_t e   = 0;
+    //                 Float_t e1  = 0;
+    //                 Float_t e2  = 0;
+    //                 TParticle * tmptmp = new TParticle;
+    //                 for(Int_t i = 0; i< stack->GetNprimary(); i++){
+    //                         tmptmp = stack->Particle(i);
                
-//                     if(tmptmp->GetStatusCode() == 1){
-//                             pt = tmptmp->Pt();
-//                             e =  tmptmp->Energy();                  
-//                             Int_t imom = tmptmp->GetFirstMother();
-//                             Int_t imom1 = 0;
-//                             //printf("1st imom %d\n",imom);
-//                             while(imom > 5){
-//                                     imom1=imom;
-//                                     tmptmp = stack->Particle(imom);
-//                                     imom = tmptmp->GetFirstMother();
-//                                     //printf("imom %d       \n",imom);
-//                             }
-//                             //printf("Last imom %d %d\n",imom1, imom);
-//                             if(imom1 == 6) {
-//                                     pt1+=pt;
-//                                     e1+=e;                          
-//                             }
-//                             else if (imom1 == 7){
-//                                     pt2+=pt;
-//                                     e2+=e;                                  }
-//                     }// status 1
-                               
-//             }// for
+    //                         if(tmptmp->GetStatusCode() == 1){
+    //                                 pt = tmptmp->Pt();
+    //                                 e =  tmptmp->Energy();                  
+    //                                 Int_t imom = tmptmp->GetFirstMother();
+    //                                 Int_t imom1 = 0;
+    //                                 //printf("1st imom %d\n",imom);
+    //                                 while(imom > 5){
+    //                                         imom1=imom;
+    //                                         tmptmp = stack->Particle(imom);
+    //                                         imom = tmptmp->GetFirstMother();
+    //                                         //printf("imom %d       \n",imom);
+    //                                 }
+    //                                 //printf("Last imom %d %d\n",imom1, imom);
+    //                                 if(imom1 == 6) {
+    //                                         pt1+=pt;
+    //                                         e1+=e;                          
+    //                                 }
+    //                                 else if (imom1 == 7){
+    //                                         pt2+=pt;
+    //                                         e2+=e;                                  }
+    //                         }// status 1
+    
+    //                 }// for
                
-//             printf("JET 1, pt %2.2f, e %2.2f; JET 2, pt %2.2f, e %2.2f \n",pt1,e1,pt2,e2);
+    //                 printf("JET 1, pt %2.2f, e %2.2f; JET 2, pt %2.2f, e %2.2f \n",pt1,e1,pt2,e2);
                
                //Get the jet, different way for different generator
                //PYTHIA
     if(fMCGenerator == "PYTHIA"){
-      TParticle * jet =  new TParticle;
+      TParticle * jet =  0x0;
       AliGenPythiaEventHeader* pygeh= (AliGenPythiaEventHeader*) geh;
       nTriggerJets =  pygeh->NTriggerJets();
       if(fDebug > 1)
-         printf("AliMCAnalysisUtils::GetJets() - PythiaEventHeader: Njets: %d\n",nTriggerJets);
-               
+        printf("AliMCAnalysisUtils::GetJets() - PythiaEventHeader: Njets: %d\n",nTriggerJets);
+      
       Int_t iparton = -1;
       for(Int_t i = 0; i< nTriggerJets; i++){
-       iparton=-1;
-       pygeh->TriggerJet(i, tmpjet);
-       jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
-       //Assign an outgoing parton as mother
-       Float_t phidiff1 = TMath::Abs(jet->Phi()-parton1->Phi());               
-       Float_t phidiff2 = TMath::Abs(jet->Phi()-parton2->Phi());
-       if(phidiff1 > phidiff2) jet->SetFirstMother(7);
-       else  jet->SetFirstMother(6);
-       //jet->Print();
-       if(fDebug > 1)
-         printf("AliMCAnalysisUtils::GetJets() - PYTHIA Jet %d: mother %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-                i, jet->GetFirstMother(),jet->Pt(),jet->Energy(),jet->Phi()*TMath::RadToDeg(),jet->Eta());
-       fJetsList->Add(jet);                    
+        iparton=-1;
+        pygeh->TriggerJet(i, tmpjet);
+        jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
+        //Assign an outgoing parton as mother
+        Float_t phidiff1 = TMath::Abs(jet->Phi()-parton1->Phi());              
+        Float_t phidiff2 = TMath::Abs(jet->Phi()-parton2->Phi());
+        if(phidiff1 > phidiff2) jet->SetFirstMother(7);
+        else  jet->SetFirstMother(6);
+        //jet->Print();
+        if(fDebug > 1)
+          printf("AliMCAnalysisUtils::GetJets() - PYTHIA Jet %d: mother %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
+                 i, jet->GetFirstMother(),jet->Pt(),jet->Energy(),jet->Phi()*TMath::RadToDeg(),jet->Eta());
+        fJetsList->Add(jet);                   
       }
     }//Pythia triggered jets
     //HERWIG
@@ -889,23 +889,23 @@ TList * AliMCAnalysisUtils::GetJets(AliCaloTrackReader * const reader){
       //Check parton 1
       TParticle * tmp = parton1;
       if(parton1->GetPdgCode()!=22){
-       while(pdg != 94){
-         if(tmp->GetFirstDaughter()==-1) return fJetsList;
-         tmp = stack->Particle(tmp->GetFirstDaughter());
-         pdg = tmp->GetPdgCode();
-       }//while
-       
-       //Add found jet to list
-       TParticle *jet1 = new TParticle(*tmp);
-       jet1->SetFirstMother(6);
-       fJetsList->Add(jet1);
-       //printf("jet 1:  first daughter %d, last daughter %d\n", tmp->GetFirstDaughter(), tmp->GetLastDaughter());
-       //tmp = stack->Particle(tmp->GetFirstDaughter());
-       //tmp->Print();
-       //jet1->Print();
-       if(fDebug > 1)                  
-         printf("AliMCAnalysisUtils::GetJets() - HERWIG Jet 1: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-                jet1->GetFirstMother(),jet1->GetStatusCode(),jet1->Pt(),jet1->Energy(),jet1->Phi()*TMath::RadToDeg(),jet1->Eta());
+        while(pdg != 94){
+          if(tmp->GetFirstDaughter()==-1) return fJetsList;
+          tmp = stack->Particle(tmp->GetFirstDaughter());
+          pdg = tmp->GetPdgCode();
+        }//while
+        
+        //Add found jet to list
+        TParticle *jet1 = new TParticle(*tmp);
+        jet1->SetFirstMother(6);
+        fJetsList->Add(jet1);
+        //printf("jet 1:  first daughter %d, last daughter %d\n", tmp->GetFirstDaughter(), tmp->GetLastDaughter());
+        //tmp = stack->Particle(tmp->GetFirstDaughter());
+        //tmp->Print();
+        //jet1->Print();
+        if(fDebug > 1)                 
+          printf("AliMCAnalysisUtils::GetJets() - HERWIG Jet 1: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
+                 jet1->GetFirstMother(),jet1->GetStatusCode(),jet1->Pt(),jet1->Energy(),jet1->Phi()*TMath::RadToDeg(),jet1->Eta());
       }//not photon
       
       //Check parton 2
@@ -913,30 +913,30 @@ TList * AliMCAnalysisUtils::GetJets(AliCaloTrackReader * const reader){
       tmp = parton2;
       Int_t i = -1;
       if(parton2->GetPdgCode()!=22){
-       while(pdg != 94){
-         if(tmp->GetFirstDaughter()==-1) return fJetsList;
-         i = tmp->GetFirstDaughter();
-         tmp = stack->Particle(tmp->GetFirstDaughter());
-         pdg = tmp->GetPdgCode();
-       }//while
-       //Add found jet to list
-       TParticle *jet2 = new TParticle(*tmp);
-       jet2->SetFirstMother(7);
-       fJetsList->Add(jet2);
-       //jet2->Print();
-       if(fDebug > 1)
-         printf("AliMCAnalysisUtils::GetJets() - HERWIG Jet 2: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-                jet2->GetFirstMother(),jet2->GetStatusCode(),jet2->Pt(),jet2->Energy(),jet2->Phi()*TMath::RadToDeg(),jet2->Eta());
-       //Int_t first =  tmp->GetFirstDaughter();
-       //Int_t last  =  tmp->GetLastDaughter();
-       //printf("jet 2:  first daughter %d, last daughter %d, pdg %d\n",first, last, tmp->GetPdgCode());
+        while(pdg != 94){
+          if(tmp->GetFirstDaughter()==-1) return fJetsList;
+          i = tmp->GetFirstDaughter();
+          tmp = stack->Particle(tmp->GetFirstDaughter());
+          pdg = tmp->GetPdgCode();
+        }//while
+        //Add found jet to list
+        TParticle *jet2 = new TParticle(*tmp);
+        jet2->SetFirstMother(7);
+        fJetsList->Add(jet2);
+        //jet2->Print();
+        if(fDebug > 1)
+          printf("AliMCAnalysisUtils::GetJets() - HERWIG Jet 2: mother %d, status %d, pt %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
+                 jet2->GetFirstMother(),jet2->GetStatusCode(),jet2->Pt(),jet2->Energy(),jet2->Phi()*TMath::RadToDeg(),jet2->Eta());
+        //Int_t first =  tmp->GetFirstDaughter();
+        //Int_t last  =  tmp->GetLastDaughter();
+        //printf("jet 2:  first daughter %d, last daughter %d, pdg %d\n",first, last, tmp->GetPdgCode());
                                //      for(Int_t d = first ; d < last+1; d++){
-//                                             tmp = stack->Particle(d);
-//                                             if(i == tmp->GetFirstMother())
-//                                                     printf("Daughter n %d, Mother %d, name %s, status %d, pT %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
-//                                                     d,tmp->GetFirstMother(), tmp->GetName(), tmp->GetStatusCode(),tmp->Pt(),tmp->Energy(),tmp->Phi()*TMath::RadToDeg(),tmp->Eta());                    
-//                        }
-                                                  //tmp->Print();
+        //                                             tmp = stack->Particle(d);
+        //                                             if(i == tmp->GetFirstMother())
+        //                                                     printf("Daughter n %d, Mother %d, name %s, status %d, pT %2.2f,E %2.2f, phi %2.2f, eta %2.2f \n",
+        //                                                     d,tmp->GetFirstMother(), tmp->GetName(), tmp->GetStatusCode(),tmp->Pt(),tmp->Energy(),tmp->Phi()*TMath::RadToDeg(),tmp->Eta());                    
+        //                        }
+        //tmp->Print();
       }//not photon
     }//Herwig generated jets
   }
@@ -949,16 +949,16 @@ TList * AliMCAnalysisUtils::GetJets(AliCaloTrackReader * const reader){
 void AliMCAnalysisUtils::Print(const Option_t * opt) const
 {
   //Print some relevant parameters set for the analysis
- if(! opt)
-   return;
- printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
- printf("Debug level    = %d\n",fDebug);
- printf("MC Generator   = %s\n",fMCGenerator.Data());
- printf(" \n");
+  
+  if(! opt)
+    return;
+  
+  printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
+  
+  printf("Debug level    = %d\n",fDebug);
+  printf("MC Generator   = %s\n",fMCGenerator.Data());
+  printf(" \n");
+  
 } 
 
 
index a634ff1..4df8752 100755 (executable)
@@ -65,8 +65,7 @@ class AliMCAnalysisUtils : public TObject {
                // Check if in tag the bit test (mcTypes) is set.
                if (tag & (1<<test) ) return  kTRUE ;    
                else return kFALSE ;
-   }
-  
+  }
        
        void Print(const Option_t * opt)const;
        
@@ -78,7 +77,7 @@ class AliMCAnalysisUtils : public TObject {
 
 private:
        Int_t   fCurrentEvent;        // Current Event
-       Int_t   fDebug;               // Debug level
+       Int_t     fDebug;               // Debug level
        TList * fJetsList;            // List of jets
        TString fMCGenerator;         // MC geneator used to generate data in simulation
        
index 1bcfa10..dac5e61 100644 (file)
@@ -567,9 +567,9 @@ Int_t AliAnaBtag::GetDVMBtag(AliAODTrack * tr )
   if (TMath::Abs(imp[0])   > fImpactCut ) return 0;\r
   if (TMath::Abs(imp[1])   > fImpactCut ) return 0;\r
 \r
-  Int_t nvtx1 = 0;\r
+//  Int_t nvtx1 = 0;\r
   Int_t nvtx2 = 0;\r
-  Int_t nvtx3 = 0;\r
+//  Int_t nvtx3 = 0;\r
 \r
   for (Int_t k2 =0; k2 < GetAODCTS()->GetEntriesFast() ; k2++) {\r
     //loop over assoc\r
@@ -612,14 +612,11 @@ Int_t AliAnaBtag::GetDVMBtag(AliAODTrack * tr )
   } //loop over hadrons\r
 \r
   if(GetDebug() > 0) {\r
-    if (nvtx1>0) printf("result1 of btagging: %d \n",nvtx1);\r
+//    if (nvtx1>0) printf("result1 of btagging: %d \n",nvtx1);\r
     if (nvtx2>0) printf("result2 of btagging: %d \n",nvtx2);\r
-    if (nvtx3>0) printf("result3 of btagging: %d \n",nvtx3);\r
+//    if (nvtx3>0) printf("result3 of btagging: %d \n",nvtx3);\r
   }\r
 \r
-\r
-\r
-\r
   return nvtx2;\r
 \r
 }\r
@@ -639,7 +636,7 @@ Double_t AliAnaBtag::ComputeSignDca(AliAODTrack *tr, AliAODTrack *tr2 , float ma
 \r
   Double_t vertex[3] = {-999.,-999.,-999}; //vertex\r
   if(GetReader()->GetDataType() != AliCaloTrackReader::kMC) {\r
-    GetReader()->GetVertex(vertex); //If only one file, get the vertex from there\r
+    GetVertex(vertex); //If only one file, get the vertex from there\r
     //FIXME:  Add a check for whether file 2 is PYTHIA or HIJING\r
     //If PYTHIA, then set the vertex from file 2, if not, use the\r
     //vertex from file 1\r
@@ -807,39 +804,40 @@ Bool_t AliAnaBtag::CheckIfBjet(const AliAODTrack* track)
 AliAODMCParticle* AliAnaBtag::GetMCParticle(Int_t ipart) \r
 {\r
   //Get the MC particle at position ipart\r
-\r
+  \r
   AliAODMCParticle* aodprimary = 0x0;\r
   TClonesArray * mcparticles0 = 0x0;\r
-  TClonesArray * mcparticles1 = 0x0;\r
-\r
+  //TClonesArray * mcparticles1 = 0x0;\r
+  \r
   if(GetReader()->ReadAODMCParticles()){\r
     //Get the list of MC particles                                                                                                                           \r
     mcparticles0 = GetReader()->GetAODMCParticles(0);\r
-    if(!mcparticles0 && GetDebug() > 0) {\r
-      printf("AliAnaBtag::MakeAnalysisFillHistograms() -  Standard MCParticles not available!\n");\r
+    if(!mcparticles0) {\r
+      if(GetDebug() > 0)printf("AliAnaBtag::MakeAnalysisFillHistograms() -  Standard MCParticles not available!\n");\r
     }\r
-//    if(GetReader()->GetSecondInputAODTree()){\r
-//      mcparticles1 = GetReader()->GetAODMCParticles(1);\r
-//      if(!mcparticles1 && GetDebug() > 0) {\r
-//     printf("AliAnaBtag::MakeAnalysisFillHistograms() -  Second input MCParticles not available!\n");\r
-//      }\r
-//    }\r
-\r
-    Int_t npart0 = mcparticles0->GetEntriesFast();\r
-    Int_t npart1 = 0;\r
-    if(mcparticles1) npart1 = mcparticles1->GetEntriesFast();\r
-    if(ipart < npart0) aodprimary = (AliAODMCParticle*)mcparticles0->At(ipart);\r
-    else aodprimary = (AliAODMCParticle*)mcparticles1->At(ipart-npart0);\r
-    if(!aodprimary) {\r
-      printf("AliAnaBtag::GetMCParticle() *** no primary ***:  label %d \n", ipart);\r
-      return 0x0;\r
+    //    if(GetReader()->GetSecondInputAODTree()){\r
+    //      mcparticles1 = GetReader()->GetAODMCParticles(1);\r
+    //      if(!mcparticles1 && GetDebug() > 0) {\r
+    // printf("AliAnaBtag::MakeAnalysisFillHistograms() -  Second input MCParticles not available!\n");\r
+    //      }\r
+    //    }\r
+    \r
+    else{\r
+      Int_t npart0 = mcparticles0->GetEntriesFast();\r
+      //Int_t npart1 = 0;\r
+      //if(mcparticles1) npart1 = mcparticles1->GetEntriesFast();\r
+      if(ipart < npart0) aodprimary = (AliAODMCParticle*)mcparticles0->At(ipart);\r
+      //else aodprimary = (AliAODMCParticle*)mcparticles1->At(ipart-npart0);\r
+      if(!aodprimary) {\r
+        printf("AliAnaBtag::GetMCParticle() *** no primary ***:  label %d \n", ipart);\r
+        return 0x0;\r
+      }\r
     }\r
-\r
   } else {\r
     printf("AliAnaBtag::GetMCParticle() - Asked for AliAODMCParticle but we have a stack reader.\n");\r
   }\r
   return aodprimary;\r
-\r
+  \r
 }\r
 \r
 //__________________________________________________________________\r
index c70da9b..4af5d60 100755 (executable)
@@ -126,13 +126,14 @@ TObjString *  AliAnaCalorimeterQA::GetAnalysisCuts()
 {      
   //Save parameters used for analysis
        TString parList ; //this will be list of parameters used for this analysis.
-       char onePar[255] ;
+  const Int_t buffersize = 255;
+       char onePar[buffersize] ;
        
-       sprintf(onePar,"--- AliAnaCalorimeterQA ---\n") ;
+       snprintf(onePar,buffersize,"--- AliAnaCalorimeterQA ---\n") ;
        parList+=onePar ;       
-       sprintf(onePar,"Calorimeter: %s\n",fCalorimeter.Data()) ;
+       snprintf(onePar,buffersize,"Calorimeter: %s\n",fCalorimeter.Data()) ;
        parList+=onePar ;
-       sprintf(onePar,"Time Cut : %2.2f < T < %2.2f ns  \n",fTimeCutMin, fTimeCutMax) ;
+       snprintf(onePar,buffersize,"Time Cut : %2.2f < T < %2.2f ns  \n",fTimeCutMin, fTimeCutMax) ;
        parList+=onePar ;
   
   //Get parameters set in base class.
@@ -1258,265 +1259,264 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   //Get List with CaloClusters  
   if      (fCalorimeter == "PHOS")  caloClusters = GetAODPHOS();
   else if (fCalorimeter == "EMCAL") caloClusters = GetAODEMCAL();
- else 
-      AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
+  else 
+    AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
   
-//  if     (fCalorimeter == "EMCAL") GetReader()->GetInputEvent()->GetEMCALClusters(caloClusters);//GetAODEMCAL();
-//  else if(fCalorimeter == "PHOS")  GetReader()->GetInputEvent()->GetPHOSClusters (caloClusters);//GetAODPHOS();
-//  else 
-//    AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
+  //  if     (fCalorimeter == "EMCAL") GetReader()->GetInputEvent()->GetEMCALClusters(caloClusters);//GetAODEMCAL();
+  //  else if(fCalorimeter == "PHOS")  GetReader()->GetInputEvent()->GetPHOSClusters (caloClusters);//GetAODPHOS();
+  //  else 
+  //    AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
        
-       if(!caloClusters) 
+       if(!caloClusters) {
                AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - No CaloClusters available\n"));
-       
-  //----------------------------------------------------------
-  //Correlate Calorimeters
-  //----------------------------------------------------------
-       //if(fCorrelateCalos)   CorrelateCalorimeters(caloClusters);
-  if(fCorrelateCalos)  CorrelateCalorimeters();
-
-       
-  //----------------------------------------------------------
-  // CALOCLUSTERS
-  //----------------------------------------------------------
-       
-       nCaloClusters = caloClusters->GetEntriesFast() ; 
-       fhNClusters->Fill(nCaloClusters);
-       Int_t *nClustersInModule = new Int_t[fNModules];
-       for(Int_t imod = 0; imod < fNModules; imod++ ) nClustersInModule[imod] = 0;
-       
-       if(GetDebug() > 0)
-               printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In %s there are %d clusters \n", fCalorimeter.Data(), nCaloClusters);
-       
-  //Get vertex for photon momentum calculation
-       Double_t v[3] = {0,0,0}; //vertex ;
-       GetReader()->GetVertex(v);
-       AliVTrack * track = 0x0;
-       
-       Float_t pos[3] ;
-       Float_t showerShape[3] ;
-       Double_t tof = 0;
-  //Loop over CaloClusters
-  //if(nCaloClusters > 0)printf("QA  : Vertex Cut passed %f, cut %f, entries %d, %s\n",v[2], 40., nCaloClusters, fCalorimeter.Data());
-       for(Int_t iclus = 0; iclus < nCaloClusters; iclus++){
-               
-               if(GetDebug() > 0) printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - cluster: %d/%d, data %d \n",
-                              iclus+1,nCaloClusters,GetReader()->GetDataType());
-               
-               if(GetReader()->GetDataType()==AliCaloTrackReader::kESD){
-                       AliVCluster* clus =  (AliVCluster*)caloClusters->At(iclus);
-                       AliVCaloCells * cell = 0x0; 
-                       if(fCalorimeter == "PHOS") cell =  GetPHOSCells();
-                       else                                     cell =  GetEMCALCells();
-                                               
-      //Get cluster kinematics
-                       clus->GetPosition(pos);
-                       clus->GetMomentum(mom,v);
-                       tof = clus->GetTOF()*1e9;
-                       if(tof < fTimeCutMin || tof > fTimeCutMax) continue;
-                       
-      //Check only certain regions
-                       Bool_t in = kTRUE;
-                       if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
-                       if(!in) continue;
-      //Get module of cluster
-                       nModule = GetModuleNumber(clus);
-                       if(nModule < fNModules) nClustersInModule[nModule]++;
-      //MC labels
-                       nLabel = clus->GetNLabels();
-                       labels = clus->GetLabels();
-      //Cells per cluster
-                       nCaloCellsPerCluster =  clus->GetNCells();
-      //if(mom.E() > 10 && nCaloCellsPerCluster == 1 ) printf("%s:************** E = %f ********** ncells = %d\n",fCalorimeter.Data(), mom.E(),nCaloCellsPerCluster);
-      //matched cluster with tracks
-                       nTracksMatched = clus->GetNTracksMatched();
-                       trackIndex     = clus->GetTrackMatchedIndex();
-                       if(trackIndex >= 0){
-                               track = (AliVTrack*)GetReader()->GetInputEvent()->GetTrack(trackIndex);
-                       }
-                       else{
-                               if(nTracksMatched == 1) nTracksMatched = 0;
-                               track = 0;
-                       }
-                       
-      //Shower shape parameters
-                       showerShape[0] = clus->GetM20();
-                       showerShape[1] = clus->GetM02();
-                       showerShape[2] = clus->GetDispersion();
+       }
+  else{
+    //----------------------------------------------------------
+    //Correlate Calorimeters
+    //----------------------------------------------------------
+    //if(fCorrelateCalos)      CorrelateCalorimeters(caloClusters);
+    if(fCorrelateCalos)        CorrelateCalorimeters();
+    
+    
+    //----------------------------------------------------------
+    // CALOCLUSTERS
+    //----------------------------------------------------------
+    
+    nCaloClusters = caloClusters->GetEntriesFast() ; 
+    fhNClusters->Fill(nCaloClusters);
+    Int_t *nClustersInModule = new Int_t[fNModules];
+    for(Int_t imod = 0; imod < fNModules; imod++ ) nClustersInModule[imod] = 0;
+    
+    if(GetDebug() > 0)
+      printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In %s there are %d clusters \n", fCalorimeter.Data(), nCaloClusters);
+    
+    //Get vertex for photon momentum calculation
+    Double_t v[3] = {0,0,0}; //vertex ;
+    GetReader()->GetVertex(v);
+    AliVTrack * track = 0x0;
+    
+    Float_t pos[3] ;
+    Float_t showerShape[3] ;
+    Double_t tof = 0;
+    //Loop over CaloClusters
+    //if(nCaloClusters > 0)printf("QA  : Vertex Cut passed %f, cut %f, entries %d, %s\n",v[2], 40., nCaloClusters, fCalorimeter.Data());
+    for(Int_t iclus = 0; iclus < nCaloClusters; iclus++){
       
-      //======================
-      //Cells in cluster
-      //======================
+      if(GetDebug() > 0) printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - cluster: %d/%d, data %d \n",
+                                iclus+1,nCaloClusters,GetReader()->GetDataType());
       
-      //Get list of contributors
-                       UShort_t * indexList = clus->GetCellsAbsId() ;
-      // check time of cells respect to max energy cell
-      //Get maximum energy cell
-                       Float_t emax  = -1;
-                       Double_t tmax = -1;
-                       Int_t imax    = -1;
-                       Int_t absId   = -1 ;
-      //printf("nCaloCellsPerCluster %d\n",nCaloCellsPerCluster);
-      //Loop on cluster cells
-                       for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
-        //     printf("Index %d\n",ipos);
-                         absId  = indexList[ipos]; 
-                         
-        //Get position of cell compare to cluster
-        if(fFillAllPosHisto){
-          if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
-            
-            Double_t cellpos[] = {0, 0, 0};
-            GetEMCALGeometry()->GetGlobal(absId, cellpos);
-            
-            fhDeltaCellClusterXNCells->Fill(pos[0]-cellpos[0],nCaloCellsPerCluster) ; 
-            fhDeltaCellClusterYNCells->Fill(pos[1]-cellpos[1],nCaloCellsPerCluster) ; 
-            fhDeltaCellClusterZNCells->Fill(pos[2]-cellpos[2],nCaloCellsPerCluster) ;
-            
-            fhDeltaCellClusterXE->Fill(pos[0]-cellpos[0],mom.E())  ; 
-            fhDeltaCellClusterYE->Fill(pos[1]-cellpos[1],mom.E())  ; 
-            fhDeltaCellClusterZE->Fill(pos[2]-cellpos[2],mom.E())  ; 
-            
-            Float_t r     = TMath::Sqrt(pos[0]*pos[0]        +pos[1]*pos[1]);//     +pos[2]*pos[2]);
-            Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
-            fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
-            fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
-            
-            //                                 Float_t celleta = 0, cellphi = 0;
-            //                                 GetEMCALGeometry()->EtaPhiFromIndex(absId, celleta, cellphi); 
-            //                                 Int_t imod = -1, iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1;
-            //                                 GetEMCALGeometry()->GetCellIndex(absId,imod,iTower,iIphi,iIeta); 
-            //                                 GetEMCALGeometry()->GetCellPhiEtaIndexInSModule(imod,iTower,
-            //                                                                                                                                                          iIphi, iIeta,iphi,ieta);
-            //                                 printf("AbsId %d, SM %d, Index eta %d, phi %d\n", absId, imod, ieta, iphi);
-            //                                 printf("Cluster E %f, eta %f, phi %f; Cell: Amp %f, eta %f, phi%f\n", mom.E(),mom.Eta(), mom.Phi()*TMath::RadToDeg(), cell->GetCellAmplitude(absId),celleta, cellphi*TMath::RadToDeg());
-            //                                 printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
-            //                                 printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
-            //                                 printf("z cluster %f, z cell %f, cluster-cell %f\n",pos[2], cellpos[2],pos[2]-cellpos[2]);
-            //                                 printf("r cluster %f, r cell %f, cluster-cell %f\n",r,      rcell,     r-rcell);
-            //                                 
-            
-          }//EMCAL and its matrices are available
-          else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
-            TVector3 xyz;
-            Int_t relId[4], module;
-            Float_t xCell, zCell;
-            
-            GetPHOSGeometry()->AbsToRelNumbering(absId,relId);
-            module = relId[0];
-            GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
-            GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
-            
-            fhDeltaCellClusterXNCells->Fill(pos[0]-xyz.X(),nCaloCellsPerCluster) ; 
-            fhDeltaCellClusterYNCells->Fill(pos[1]-xyz.Y(),nCaloCellsPerCluster) ; 
-            fhDeltaCellClusterZNCells->Fill(pos[2]-xyz.Z(),nCaloCellsPerCluster) ;
-            
-            fhDeltaCellClusterXE->Fill(pos[0]-xyz.X(),mom.E())  ; 
-            fhDeltaCellClusterYE->Fill(pos[1]-xyz.Y(),mom.E())  ; 
-            fhDeltaCellClusterZE->Fill(pos[2]-xyz.Z(),mom.E())  ; 
-            
-            Float_t r     = TMath::Sqrt(pos[0]*pos[0]  +pos[1]*pos[1]);//     +pos[2]*pos[2]);
-            Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());//+xyz.Z()*xyz.Z());
-            fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
-            fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
-            
-            //                   printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
-            //                 printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
-            //                 printf("z cluster %f, z cell %f, cluster-cell %f\n",pos[2], cellpos[2],pos[2]-cellpos[2]);
-            //                                 printf("r cluster %f, r cell %f, cluster-cell %f\n",r,      rcell,     r-rcell);
-          }//PHOS and its matrices are available
-        }//Fill all position histograms
+      if(GetReader()->GetDataType()==AliCaloTrackReader::kESD){
+        AliVCluster* clus =  (AliVCluster*)caloClusters->At(iclus);
+        AliVCaloCells * cell = 0x0; 
+        if(fCalorimeter == "PHOS") cell =  GetPHOSCells();
+        else                                    cell =  GetEMCALCells();
         
-        //Find maximum energy cluster
-                         if(cell->GetCellAmplitude(absId) > emax) {
-                           imax = ipos;
-                           emax = cell->GetCellAmplitude(absId);
-                           tmax = cell->GetCellTime(absId);
-                         } 
+        //Get cluster kinematics
+        clus->GetPosition(pos);
+        clus->GetMomentum(mom,v);
+        tof = clus->GetTOF()*1e9;
+        if(tof < fTimeCutMin || tof > fTimeCutMax) continue;
         
-                       }// cluster cell loop
-                       
-      // check time of cells respect to max energy cell
-                       if(nCaloCellsPerCluster > 1){
-                         for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
-                           if(imax == ipos) continue;
-                           absId  = indexList[ipos]; 
-                           Float_t diff = (tmax-cell->GetCellTime(absId))*1e9;
-                           fhCellTimeSpreadRespectToCellMax->Fill(diff);
-                           if(TMath::Abs(TMath::Abs(diff) > 100)) fhCellIdCellLargeTimeSpread->Fill(absId);
-                         }// fill cell-cluster histogram loop
-                         
-                       }//check time of cells respect to max energy cell
-      
-      //-----------------------------------------------------------
-      //Fill histograms related to single cluster or track matching
-      //-----------------------------------------------------------
-      
-      ClusterHistograms(mom, tof, pos, showerShape, nCaloCellsPerCluster, nModule, nTracksMatched, track, labels, nLabel);     
-      
-      
-      //-----------------------------------------------------------
-      //Invariant mass
-      //-----------------------------------------------------------
-      if(GetDebug()>1) printf("Invariant mass \n");
-      
-      //do not do for bad vertex
-      Float_t fZvtxCut = 40. ; 
-      if(v[2]<-fZvtxCut || v[2]> fZvtxCut) continue ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
-      
-      Int_t nModule2 = -1;
-      Int_t nCaloCellsPerCluster2=0;
-      if (nCaloClusters > 1 ) {
-        for(Int_t jclus = iclus + 1 ; jclus < nCaloClusters ; jclus++) {
-                                       AliVCluster* clus2 =  (AliVCluster*)caloClusters->At(jclus);
-                                       AliVCaloCells  * cell2 = 0x0; 
-                                       if(fCalorimeter == "PHOS") cell2 =  GetPHOSCells();
-                                       else                                     cell2 =  GetEMCALCells();
-          
-          //Get cluster kinematics
-                                       clus2->GetMomentum(mom2,v);
-          //Check only certain regions
-                                       Bool_t in2 = kTRUE;
-                                       if(IsFiducialCutOn()) in2 =  GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
-                                       if(!in2) continue;      
-          //Get module of cluster
-                                       nModule2 = GetModuleNumber(clus2);
-          //Cells per cluster
-                                       nCaloCellsPerCluster2 = clus2->GetNCells();
+        //Check only certain regions
+        Bool_t in = kTRUE;
+        if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
+        if(!in) continue;
+        //Get module of cluster
+        nModule = GetModuleNumber(clus);
+        if(nModule >=0 && nModule < fNModules) nClustersInModule[nModule]++;
+        //MC labels
+        nLabel = clus->GetNLabels();
+        labels = clus->GetLabels();
+        //Cells per cluster
+        nCaloCellsPerCluster =  clus->GetNCells();
+        //if(mom.E() > 10 && nCaloCellsPerCluster == 1 ) printf("%s:************** E = %f ********** ncells = %d\n",fCalorimeter.Data(), mom.E(),nCaloCellsPerCluster);
+        //matched cluster with tracks
+        nTracksMatched = clus->GetNTracksMatched();
+        trackIndex     = clus->GetTrackMatchedIndex();
+        if(trackIndex >= 0){
+          track = (AliVTrack*)GetReader()->GetInputEvent()->GetTrack(trackIndex);
+        }
+        else{
+          if(nTracksMatched == 1) nTracksMatched = 0;
+          track = 0;
         }
-        //Fill invariant mass histograms
-        //All modules
         
-        //printf("QA : Fill inv mass histo: pt1 %f, pt2 %f, pt12 %f, mass %f, calo %s \n",mom.Pt(),mom2.Pt(),(mom+mom2).Pt(),(mom+mom2).M(), fCalorimeter.Data());
-                               fhIM  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
-        //Single module
-                               if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
-                                 fhIMMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
+        //Shower shape parameters
+        showerShape[0] = clus->GetM20();
+        showerShape[1] = clus->GetM02();
+        showerShape[2] = clus->GetDispersion();
         
-        //Select only clusters with at least 2 cells
-                               if(nCaloCellsPerCluster > 1 && nCaloCellsPerCluster2 > 1) {
-          //All modules
-                                 fhIMCellCut  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
-          //Single modules
-                                 if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
-                                   fhIMCellCutMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
-                               }
+        //======================
+        //Cells in cluster
+        //======================
         
-        //Asymetry histograms
-        fhAsym->Fill((mom+mom2).Pt(),TMath::Abs((mom.E()-mom2.E())/(mom.E()+mom2.E())));
+        //Get list of contributors
+        UShort_t * indexList = clus->GetCellsAbsId() ;
+        // check time of cells respect to max energy cell
+        //Get maximum energy cell
+        Float_t emax  = -1;
+        Double_t tmax = -1;
+        Int_t imax    = -1;
+        Int_t absId   = -1 ;
+        //printf("nCaloCellsPerCluster %d\n",nCaloCellsPerCluster);
+        //Loop on cluster cells
+        for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
+          //   printf("Index %d\n",ipos);
+          absId  = indexList[ipos]; 
+          
+          //Get position of cell compare to cluster
+          if(fFillAllPosHisto){
+            if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
+              
+              Double_t cellpos[] = {0, 0, 0};
+              GetEMCALGeometry()->GetGlobal(absId, cellpos);
+              
+              fhDeltaCellClusterXNCells->Fill(pos[0]-cellpos[0],nCaloCellsPerCluster) ; 
+              fhDeltaCellClusterYNCells->Fill(pos[1]-cellpos[1],nCaloCellsPerCluster) ; 
+              fhDeltaCellClusterZNCells->Fill(pos[2]-cellpos[2],nCaloCellsPerCluster) ;
+              
+              fhDeltaCellClusterXE->Fill(pos[0]-cellpos[0],mom.E())  ; 
+              fhDeltaCellClusterYE->Fill(pos[1]-cellpos[1],mom.E())  ; 
+              fhDeltaCellClusterZE->Fill(pos[2]-cellpos[2],mom.E())  ; 
+              
+              Float_t r     = TMath::Sqrt(pos[0]*pos[0]        +pos[1]*pos[1]);//     +pos[2]*pos[2]);
+              Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
+              fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
+              fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
+              
+              //                                       Float_t celleta = 0, cellphi = 0;
+              //                                       GetEMCALGeometry()->EtaPhiFromIndex(absId, celleta, cellphi); 
+              //                                       Int_t imod = -1, iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1;
+              //                                       GetEMCALGeometry()->GetCellIndex(absId,imod,iTower,iIphi,iIeta); 
+              //                                       GetEMCALGeometry()->GetCellPhiEtaIndexInSModule(imod,iTower,
+              //                                                                                                                                                                iIphi, iIeta,iphi,ieta);
+              //                                       printf("AbsId %d, SM %d, Index eta %d, phi %d\n", absId, imod, ieta, iphi);
+              //                                       printf("Cluster E %f, eta %f, phi %f; Cell: Amp %f, eta %f, phi%f\n", mom.E(),mom.Eta(), mom.Phi()*TMath::RadToDeg(), cell->GetCellAmplitude(absId),celleta, cellphi*TMath::RadToDeg());
+              //                                       printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
+              //                                       printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
+              //                                       printf("z cluster %f, z cell %f, cluster-cell %f\n",pos[2], cellpos[2],pos[2]-cellpos[2]);
+              //                                       printf("r cluster %f, r cell %f, cluster-cell %f\n",r,      rcell,     r-rcell);
+              //                                       
+              
+            }//EMCAL and its matrices are available
+            else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
+              TVector3 xyz;
+              Int_t relId[4], module;
+              Float_t xCell, zCell;
+              
+              GetPHOSGeometry()->AbsToRelNumbering(absId,relId);
+              module = relId[0];
+              GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
+              GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
+              
+              fhDeltaCellClusterXNCells->Fill(pos[0]-xyz.X(),nCaloCellsPerCluster) ; 
+              fhDeltaCellClusterYNCells->Fill(pos[1]-xyz.Y(),nCaloCellsPerCluster) ; 
+              fhDeltaCellClusterZNCells->Fill(pos[2]-xyz.Z(),nCaloCellsPerCluster) ;
+              
+              fhDeltaCellClusterXE->Fill(pos[0]-xyz.X(),mom.E())  ; 
+              fhDeltaCellClusterYE->Fill(pos[1]-xyz.Y(),mom.E())  ; 
+              fhDeltaCellClusterZE->Fill(pos[2]-xyz.Z(),mom.E())  ; 
+              
+              Float_t r     = TMath::Sqrt(pos[0]*pos[0]  +pos[1]*pos[1]);//     +pos[2]*pos[2]);
+              Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());//+xyz.Z()*xyz.Z());
+              fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
+              fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
+              
+              //                         printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
+              //                       printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
+              //                       printf("z cluster %f, z cell %f, cluster-cell %f\n",pos[2], cellpos[2],pos[2]-cellpos[2]);
+              //                               printf("r cluster %f, r cell %f, cluster-cell %f\n",r,      rcell,     r-rcell);
+            }//PHOS and its matrices are available
+          }//Fill all position histograms
+          
+          //Find maximum energy cluster
+          if(cell->GetCellAmplitude(absId) > emax) {
+            imax = ipos;
+            emax = cell->GetCellAmplitude(absId);
+            tmax = cell->GetCellTime(absId);
+          } 
+          
+        }// cluster cell loop
         
-                       }// 2nd cluster loop
-               }////more than 1 cluster in calorimeter         
-       }//cluster loop
-       
-  //Number of clusters per module
-       for(Int_t imod = 0; imod < fNModules; imod++ ){ 
-               if(GetDebug() > 1) 
-                       printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - module %d calo %s clusters %d\n", imod, fCalorimeter.Data(), nClustersInModule[imod]); 
-               fhNClustersMod[imod]->Fill(nClustersInModule[imod]);
-       }
-       delete [] nClustersInModule;
-       //delete caloClusters;
+        // check time of cells respect to max energy cell
+        if(nCaloCellsPerCluster > 1){
+          for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
+            if(imax == ipos) continue;
+            absId  = indexList[ipos]; 
+            Float_t diff = (tmax-cell->GetCellTime(absId))*1e9;
+            fhCellTimeSpreadRespectToCellMax->Fill(diff);
+            if(TMath::Abs(TMath::Abs(diff) > 100)) fhCellIdCellLargeTimeSpread->Fill(absId);
+          }// fill cell-cluster histogram loop
+          
+        }//check time of cells respect to max energy cell
+        
+        //-----------------------------------------------------------
+        //Fill histograms related to single cluster or track matching
+        //-----------------------------------------------------------
+        
+        ClusterHistograms(mom, tof, pos, showerShape, nCaloCellsPerCluster, nModule, nTracksMatched, track, labels, nLabel);   
+        
+        
+        //-----------------------------------------------------------
+        //Invariant mass
+        //-----------------------------------------------------------
+        if(GetDebug()>1) printf("Invariant mass \n");
+        
+        //do not do for bad vertex
+        Float_t fZvtxCut = 40. ;       
+        if(v[2]<-fZvtxCut || v[2]> fZvtxCut) continue ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
+        
+        Int_t nModule2 = -1;
+        Int_t nCaloCellsPerCluster2=0;
+        if (nCaloClusters > 1 ) {
+          for(Int_t jclus = iclus + 1 ; jclus < nCaloClusters ; jclus++) {
+            AliVCluster* clus2 =  (AliVCluster*)caloClusters->At(jclus);
+            
+            //Get cluster kinematics
+            clus2->GetMomentum(mom2,v);
+            //Check only certain regions
+            Bool_t in2 = kTRUE;
+            if(IsFiducialCutOn()) in2 =  GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
+            if(!in2) continue; 
+            //Get module of cluster
+            nModule2 = GetModuleNumber(clus2);
+            //Cells per cluster
+            nCaloCellsPerCluster2 = clus2->GetNCells();
+          }
+          //Fill invariant mass histograms
+          //All modules
+          
+          //printf("QA : Fill inv mass histo: pt1 %f, pt2 %f, pt12 %f, mass %f, calo %s \n",mom.Pt(),mom2.Pt(),(mom+mom2).Pt(),(mom+mom2).M(), fCalorimeter.Data());
+          fhIM  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
+          //Single module
+          if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
+            fhIMMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
+          
+          //Select only clusters with at least 2 cells
+          if(nCaloCellsPerCluster > 1 && nCaloCellsPerCluster2 > 1) {
+            //All modules
+            fhIMCellCut  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
+            //Single modules
+            if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
+              fhIMCellCutMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
+          }
+          
+          //Asymetry histograms
+          fhAsym->Fill((mom+mom2).Pt(),TMath::Abs((mom.E()-mom2.E())/(mom.E()+mom2.E())));
+          
+        }// 2nd cluster loop
+      }////more than 1 cluster in calorimeter          
+    }//cluster loop
+    
+    //Number of clusters per module
+    for(Int_t imod = 0; imod < fNModules; imod++ ){ 
+      if(GetDebug() > 1) 
+        printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - module %d calo %s clusters %d\n", imod, fCalorimeter.Data(), nClustersInModule[imod]); 
+      fhNClustersMod[imod]->Fill(nClustersInModule[imod]);
+    }
+    delete [] nClustersInModule;
+    //delete caloClusters;
+  }// calo clusters array exists
   
   //----------------------------------------------------------
   // CALOCELLS
@@ -1720,7 +1720,7 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
        }
   
        fhE     ->Fill(e);      
-       if(nModule < fNModules) fhEMod[nModule]->Fill(e);
+       if(nModule >=0 && nModule < fNModules) fhEMod[nModule]->Fill(e);
   if(fFillAllTH12){
     fhPt     ->Fill(pt);
     fhPhi    ->Fill(phi);
@@ -1754,7 +1754,7 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
        fhLambda->Fill(showerShape[0], showerShape[1], e);
        fhDispersion->Fill(showerShape[2],e);
   
-       if(nModule < fNModules) fhNCellsPerClusterMod[nModule]->Fill(e, nCaloCellsPerCluster);
+       if(nModule >=0 && nModule < fNModules) fhNCellsPerClusterMod[nModule]->Fill(e, nCaloCellsPerCluster);
        
   //Fill histograms only possible when simulation
        if(IsDataMC() && nLabels > 0 && labels){
index d0ad62b..00aa6ff 100755 (executable)
@@ -309,39 +309,40 @@ TObjString *  AliAnaElectron::GetAnalysisCuts()
 {\r
        //Save parameters used for analysis\r
         TString parList ; //this will be list of parameters used for this analysis.\r
-        char onePar[500] ;\r
+  const Int_t buffersize = 255; \r
+        char onePar[buffersize] ;\r
         \r
-        sprintf(onePar,"--- AliAnaElectron ---\n") ;\r
+        snprintf(onePar,buffersize,"--- AliAnaElectron ---\n") ;\r
         parList+=onePar ;      \r
-        sprintf(onePar,"fCalorimeter: %s\n",fCalorimeter.Data()) ;\r
+        snprintf(onePar,buffersize,"fCalorimeter: %s\n",fCalorimeter.Data()) ;\r
         parList+=onePar ;  \r
-        sprintf(onePar,"fpOverEmin: %f\n",fpOverEmin) ;\r
+        snprintf(onePar,buffersize,"fpOverEmin: %f\n",fpOverEmin) ;\r
         parList+=onePar ;  \r
-        sprintf(onePar,"fpOverEmax: %f\n",fpOverEmax) ;\r
+        snprintf(onePar,buffersize,"fpOverEmax: %f\n",fpOverEmax) ;\r
         parList+=onePar ;  \r
-        sprintf(onePar,"fResidualCut: %f\n",fResidualCut) ;\r
+        snprintf(onePar,buffersize,"fResidualCut: %f\n",fResidualCut) ;\r
         parList+=onePar ;  \r
-        sprintf(onePar,"fMinClusEne: %f\n",fMinClusEne) ;\r
+        snprintf(onePar,buffersize,"fMinClusEne: %f\n",fMinClusEne) ;\r
         parList+=onePar ;\r
-        sprintf(onePar,"---DVM Btagging\n");\r
+        snprintf(onePar,buffersize,"---DVM Btagging\n");\r
         parList+=onePar ;\r
-        sprintf(onePar,"max IP-cut (e,h): %f\n",fImpactCut);\r
+        snprintf(onePar,buffersize,"max IP-cut (e,h): %f\n",fImpactCut);\r
         parList+=onePar ;\r
-        sprintf(onePar,"min ITS-hits: %d\n",fITSCut);\r
+        snprintf(onePar,buffersize,"min ITS-hits: %d\n",fITSCut);\r
         parList+=onePar ;\r
-        sprintf(onePar,"max dR (e,h): %f\n",fDrCut);\r
+        snprintf(onePar,buffersize,"max dR (e,h): %f\n",fDrCut);\r
         parList+=onePar ;\r
-        sprintf(onePar,"max pairDCA: %f\n",fPairDcaCut);\r
+        snprintf(onePar,buffersize,"max pairDCA: %f\n",fPairDcaCut);\r
         parList+=onePar ;\r
-        sprintf(onePar,"max decaylength: %f\n",fDecayLenCut);\r
+        snprintf(onePar,buffersize,"max decaylength: %f\n",fDecayLenCut);\r
         parList+=onePar ;\r
-        sprintf(onePar,"min Associated Pt: %f\n",fAssocPtCut);\r
+        snprintf(onePar,buffersize,"min Associated Pt: %f\n",fAssocPtCut);\r
         parList+=onePar ;\r
-        sprintf(onePar,"---IPSig Btagging\n");\r
+        snprintf(onePar,buffersize,"---IPSig Btagging\n");\r
         parList+=onePar ;\r
-        sprintf(onePar,"min tag track: %d\n",fNTagTrkCut);\r
+        snprintf(onePar,buffersize,"min tag track: %d\n",fNTagTrkCut);\r
         parList+=onePar ;\r
-        sprintf(onePar,"min IP significance: %f\n",fIPSigCut);\r
+        snprintf(onePar,buffersize,"min IP significance: %f\n",fIPSigCut);\r
         parList+=onePar ;\r
        //\r
         //Get parameters set in base class.\r
@@ -1392,7 +1393,7 @@ Double_t AliAnaElectron::ComputeSignDca(AliAODTrack *tr, AliAODTrack *tr2 , floa
 \r
   Double_t vertex[3] = {-999.,-999.,-999}; //vertex\r
   if(GetReader()->GetDataType() != AliCaloTrackReader::kMC) {\r
-    GetReader()->GetVertex(vertex); //If only one file, get the vertex from there\r
+    GetVertex(vertex); //If only one file, get the vertex from there\r
     //FIXME:  Add a check for whether file 2 is PYTHIA or HIJING\r
     //If PYTHIA, then set the vertex from file 2, if not, use the\r
     //vertex from file 1\r
@@ -1813,16 +1814,16 @@ Int_t AliAnaElectron::GetNumAODMCParticles()
 {\r
   //Get the number of AliAODMCParticles, if any\r
   Int_t num = 0;\r
-\r
+  Int_t npart0 = 0;\r
   TClonesArray * mcparticles0 = 0x0;\r
-  TClonesArray * mcparticles1 = 0x0;\r
+//  TClonesArray * mcparticles1 = 0x0;\r
 \r
   if(GetReader()->ReadAODMCParticles()){\r
     //Get the list of MC particles\r
     //                                                                                                 \r
     mcparticles0 = GetReader()->GetAODMCParticles(0);\r
-    if(!mcparticles0 && GetDebug() > 0) {\r
-      printf("AliAnaElectron::MakeAnalysisFillHistograms() -  Standard MCParticles not available!\n");\r
+    if(!mcparticles0) {\r
+     if(GetDebug() > 0) printf("AliAnaElectron::MakeAnalysisFillHistograms() -  Standard MCParticles not available!\n");\r
     }\r
 //    if(GetReader()->GetSecondInputAODTree()){\r
 //      mcparticles1 = GetReader()->GetAODMCParticles(1);\r
@@ -1830,12 +1831,13 @@ Int_t AliAnaElectron::GetNumAODMCParticles()
 //        printf("AliAnaElectron::MakeAnalysisFillHistograms() -  Second input MCParticles not available!\n");\r
 //      }\r
 //    }\r
-\r
-    Int_t npart0 = mcparticles0->GetEntriesFast();\r
-    Int_t npart1 = 0;\r
-    if(mcparticles1) npart1 = mcparticles1->GetEntriesFast();\r
-    Int_t npart = npart0+npart1;\r
-    return npart;\r
+    else{\r
+      npart0 = mcparticles0->GetEntriesFast();\r
+    }\r
+    //Int_t npart1 = 0;\r
+    //if(mcparticles1) npart1 = mcparticles1->GetEntriesFast();\r
+    //Int_t npart = npart0;//+npart1;\r
+    return npart0;\r
 \r
   }\r
 \r
@@ -1845,39 +1847,39 @@ Int_t AliAnaElectron::GetNumAODMCParticles()
 AliAODMCParticle* AliAnaElectron::GetMCParticle(Int_t ipart) \r
 {\r
   //Get the MC particle at position ipart\r
-\r
+  \r
   AliAODMCParticle* aodprimary = 0x0;\r
   TClonesArray * mcparticles0 = 0x0;\r
-  TClonesArray * mcparticles1 = 0x0;\r
-\r
+  //TClonesArray * mcparticles1 = 0x0;\r
+  \r
   if(GetReader()->ReadAODMCParticles()){\r
     //Get the list of MC particles                                                                                                                           \r
     mcparticles0 = GetReader()->GetAODMCParticles(0);\r
-    if(!mcparticles0 && GetDebug() > 0) {\r
-      printf("AliAnaElectron::MakeAnalysisFillHistograms() -  Standard MCParticles not available!\n");\r
+    if(!mcparticles0) {\r
+      if (GetDebug() > 0) printf("AliAnaElectron::MakeAnalysisFillHistograms() -  Standard MCParticles not available!\n");\r
     }\r
-//    if(GetReader()->GetSecondInputAODTree()){\r
-//      mcparticles1 = GetReader()->GetAODMCParticles(1);\r
-//      if(!mcparticles1 && GetDebug() > 0) {\r
-//     printf("AliAnaElectron::MakeAnalysisFillHistograms() -  Second input MCParticles not available!\n");\r
-//      }\r
-//    }\r
-\r
-    Int_t npart0 = mcparticles0->GetEntriesFast();\r
-    Int_t npart1 = 0;\r
-    if(mcparticles1) npart1 = mcparticles1->GetEntriesFast();\r
-    if(ipart < npart0) aodprimary = (AliAODMCParticle*)mcparticles0->At(ipart);\r
-    else aodprimary = (AliAODMCParticle*)mcparticles1->At(ipart-npart0);\r
-    if(!aodprimary) {\r
-      printf("AliAnaElectron::GetMCParticle() *** no primary ***:  label %d \n", ipart);\r
-      return 0x0;\r
+    //    if(GetReader()->GetSecondInputAODTree()){\r
+    //      mcparticles1 = GetReader()->GetAODMCParticles(1);\r
+    //      if(!mcparticles1 && GetDebug() > 0) {\r
+    // printf("AliAnaElectron::MakeAnalysisFillHistograms() -  Second input MCParticles not available!\n");\r
+    //      }\r
+    //    }\r
+    else{\r
+      Int_t npart0 = mcparticles0->GetEntriesFast();\r
+      //Int_t npart1 = 0;\r
+      //if(mcparticles1) npart1 = mcparticles1->GetEntriesFast();\r
+      if(ipart < npart0) aodprimary = (AliAODMCParticle*)mcparticles0->At(ipart);\r
+      //else aodprimary = (AliAODMCParticle*)mcparticles1->At(ipart-npart0);\r
+      if(!aodprimary) {\r
+        printf("AliAnaElectron::GetMCParticle() *** no primary ***:  label %d \n", ipart);\r
+        return 0x0;\r
+      }\r
     }\r
-\r
   } else {\r
     printf("AliAnaElectron::GetMCParticle() - Asked for AliAODMCParticle but we have a stack reader.\n");\r
   }\r
   return aodprimary;\r
-\r
+  \r
 }\r
 \r
 //__________________________________________________________________\r
index 8336a62..505cf48 100755 (executable)
@@ -161,16 +161,27 @@ void  AliAnaExample::MakeAnalysisFillAOD()
   if(fDetector == "EMCAL" || fDetector == "PHOS"){
     
     //Get vertex for photon momentum calculation
-    Double_t v[3] ; //vertex ;
-    GetReader()->GetVertex(v);
+
     
     TLorentzVector mom ;
     for(Int_t i = 0; i < partList->GetEntriesFast(); i++){
       
       AliVCluster * calo =  (AliVCluster*) (partList->At(i));
       
+      //Get the index where the cluster comes, to retrieve the corresponding vertex
+      Int_t evtIndex = 0 ; 
+      if (GetMixedEvent()) {
+        evtIndex=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
+      }
+
       //Fill AODParticle after some selection
-      calo->GetMomentum(mom,v);
+      if(GetReader()->GetDataType() != AliCaloTrackReader::kMC){
+        calo->GetMomentum(mom,GetVertex(evtIndex)) ;}//Assume that come from vertex in straight line
+      else{
+        Double_t vertex[]={0,0,0};
+        calo->GetMomentum(mom,vertex) ;
+      }
+      
       Int_t pdg = fPdg;
       
       if(IsCaloPIDOn()){
@@ -330,11 +341,12 @@ void  AliAnaExample::Terminate(TList* outputList)
   fhEta->Draw();
  
   c->Print("Example.eps");
-  char line[1024] ; 
-  sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; 
+  
+  const Int_t buffersize = 1024;
+  char line[buffersize] ; 
+  snprintf(line,buffersize, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; 
   gROOT->ProcessLine(line);
-  sprintf(line, ".!rm -fR *.eps"); 
+  snprintf(line,buffersize, ".!rm -fR *.eps"); 
   gROOT->ProcessLine(line);
  
   printf("AliAnaExample::Terminate() - !! All the eps files are in %s.tar.gz !!!", GetName());
index 5145d5d..c897bad 100644 (file)
@@ -188,178 +188,179 @@ TList * AliAnaOmegaToPi0Gamma::GetCreateOutputObjects()
   //\r
   fVtxZCut = new Double_t [fNVtxZBin];\r
   for(Int_t i=0;i<fNVtxZBin;i++) fVtxZCut[i]=10*(i+1);\r
-\r
+  \r
   fCent=new Double_t[fNCentBin];\r
   for(int i = 0;i<fNCentBin;i++)fCent[i]=0;\r
-\r
+  \r
   fRp=new Double_t[fNRpBin];\r
   for(int i = 0;i<fNRpBin;i++)fRp[i]=0;\r
   //\r
   Int_t nptbins   = GetHistoPtBins();\r
   Float_t ptmax   = GetHistoPtMax();\r
   Float_t ptmin  = GetHistoPtMin();\r
-\r
+  \r
   Int_t nmassbins = GetHistoMassBins();\r
   Float_t massmin = GetHistoMassMin();\r
   Float_t massmax = GetHistoMassMax();\r
-\r
+  \r
   fhEtalon = new TH2F("hEtalon","Histo with binning parameters", nptbins,ptmin,ptmax,nmassbins,massmin,massmax) ;\r
   fhEtalon->SetXTitle("P_{T} (GeV)") ;\r
   fhEtalon->SetYTitle("m_{inv} (GeV)") ;\r
\r
- // store them in fOutputContainer\r
- fEventsList = new TList*[fNVtxZBin*fNCentBin*fNRpBin];\r
- for(Int_t i=0;i<fNVtxZBin;i++){\r
-     for(Int_t j=0;j<fNCentBin;j++){\r
-         for(Int_t k=0;k<fNRpBin;k++){\r
-             fEventsList[i*fNCentBin*fNRpBin+j*fNRpBin+k]=new TList();\r
-         }\r
-     }\r
- }\r
+  \r
+  // store them in fOutputContainer\r
+  fEventsList = new TList*[fNVtxZBin*fNCentBin*fNRpBin];\r
+  for(Int_t i=0;i<fNVtxZBin;i++){\r
+    for(Int_t j=0;j<fNCentBin;j++){\r
+      for(Int_t k=0;k<fNRpBin;k++){\r
+        fEventsList[i*fNCentBin*fNRpBin+j*fNRpBin+k]=new TList();\r
+      }\r
+    }\r
+  }\r
        \r
- TList * outputContainer = new TList() ; \r
- outputContainer->SetName(GetName());\r
- char key[255] ;\r
- char title[255] ;\r
- const char * detector= fInputAODGammaName.Data();\r
- Int_t ndim=fNVtxZBin*fNCentBin*fNRpBin*fNBadChDistBin*fNpid;\r
-\r
- fRealOmega0 =new TH2F*[ndim];\r
- fMixAOmega0 =new TH2F*[ndim];\r
- fMixBOmega0 =new TH2F*[ndim];\r
- fMixCOmega0 =new TH2F*[ndim];\r
\r
- fRealOmega1 =new TH2F*[ndim];\r
- fMixAOmega1 =new TH2F*[ndim];\r
- fMixBOmega1 =new TH2F*[ndim];\r
- fMixCOmega1 =new TH2F*[ndim];\r
-\r
- fRealOmega2 =new TH2F*[ndim];\r
- fMixAOmega2 =new TH2F*[ndim];\r
- fMixBOmega2 =new TH2F*[ndim];\r
- fMixCOmega2 =new TH2F*[ndim];\r
-\r
- for(Int_t i=0;i<fNVtxZBin;i++){\r
-     for(Int_t j=0;j<fNCentBin;j++){\r
-         for(Int_t k=0;k<fNRpBin;k++){ //at event level\r
-             Int_t idim=i*fNCentBin*fNRpBin+j*fNRpBin+k;\r
-             for(Int_t ipid=0;ipid<fNpid;ipid++){\r
-                for(Int_t idist=0;idist<fNBadChDistBin;idist++){ //at particle level\r
-\r
-                     Int_t index=idim*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
-\r
-                    sprintf(key,"RealToPi0Gamma_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s Real Pi0GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fRealOmega0[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fRealOmega0[index]->SetName(key) ;\r
-                     fRealOmega0[index]->SetTitle(title);\r
-                     outputContainer->Add(fRealOmega0[index]);\r
-\r
-                    sprintf(key,"MixAToPi0Gamma_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s MixA Pi0GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fMixAOmega0[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fMixAOmega0[index]->SetName(key) ;\r
-                     fMixAOmega0[index]->SetTitle(title);\r
-                     outputContainer->Add(fMixAOmega0[index]);\r
-\r
-                    sprintf(key,"MixBToPi0Gamma_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s MixB Pi0GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fMixBOmega0[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fMixBOmega0[index]->SetName(key) ;\r
-                     fMixBOmega0[index]->SetTitle(title);\r
-                     outputContainer->Add(fMixBOmega0[index]);\r
-\r
-                    sprintf(key,"MixCToPi0Gamma_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s MixC Pi0GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fMixCOmega0[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fMixCOmega0[index]->SetName(key) ;\r
-                     fMixCOmega0[index]->SetTitle(title);\r
-                     outputContainer->Add(fMixCOmega0[index]);\r
-\r
-                    sprintf(key,"RealToPi0Gamma1_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s Real Pi0(A<0.7)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fRealOmega1[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fRealOmega1[index]->SetName(key) ;\r
-                     fRealOmega1[index]->SetTitle(title);\r
-                     outputContainer->Add(fRealOmega1[index]);\r
-\r
-                     sprintf(key,"MixAToPi0Gamma1_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s MixA Pi0(A<0.7)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fMixAOmega1[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fMixAOmega1[index]->SetName(key) ;\r
-                     fMixAOmega1[index]->SetTitle(title);\r
-                     outputContainer->Add(fMixAOmega1[index]);\r
-\r
-                     sprintf(key,"MixBToPi0Gamma1_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s MixB Pi0(A<0.7)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fMixBOmega1[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fMixBOmega1[index]->SetName(key) ;\r
-                     fMixBOmega1[index]->SetTitle(title);\r
-                     outputContainer->Add(fMixBOmega1[index]);\r
-\r
-                     sprintf(key,"MixCToPi0Gamma1_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s MixC Pi0(A<0.7)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fMixCOmega1[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fMixCOmega1[index]->SetName(key) ;\r
-                     fMixCOmega1[index]->SetTitle(title);\r
-                     outputContainer->Add(fMixCOmega1[index]);\r
-\r
-                    sprintf(key,"RealToPi0Gamma2_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s Real Pi0(A<0.8)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fRealOmega2[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fRealOmega2[index]->SetName(key) ;\r
-                     fRealOmega2[index]->SetTitle(title);\r
-                     outputContainer->Add(fRealOmega2[index]);\r
-\r
-                     sprintf(key,"MixAToPi0Gamma2_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s MixA Pi0(A<0.8)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fMixAOmega2[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fMixAOmega2[index]->SetName(key) ;\r
-                     fMixAOmega2[index]->SetTitle(title);\r
-                     outputContainer->Add(fMixAOmega2[index]);\r
-\r
-                     sprintf(key,"MixBToPi0Gamma2_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s MixB Pi0(A<0.8)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fMixBOmega2[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fMixBOmega2[index]->SetName(key) ;\r
-                     fMixBOmega2[index]->SetTitle(title);\r
-                     outputContainer->Add(fMixBOmega2[index]);\r
-\r
-                     sprintf(key,"MixCToPi0Gamma2_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
-                     sprintf(title, "%s MixC Pi0(A<0.8)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
-                     fhEtalon->Clone(key);\r
-                     fMixCOmega2[index]=(TH2F*)fhEtalon->Clone(key) ;\r
-                     fMixCOmega2[index]->SetName(key) ;\r
-                     fMixCOmega2[index]->SetTitle(title);\r
-                     outputContainer->Add(fMixCOmega2[index]);\r
-                 }\r
-             }\r
-         }\r
-     }  \r
- }\r
-\r
- if(IsDataMC()){\r
-    sprintf(key, "%sOmegaPri",detector);\r
-    sprintf(title,"primary #omega in %s",detector);\r
+  TList * outputContainer = new TList() ; \r
+  outputContainer->SetName(GetName());\r
+  const Int_t buffersize = 255;\r
+  char key[buffersize] ;\r
+  char title[buffersize] ;\r
+  const char * detector= fInputAODGammaName.Data();\r
+  Int_t ndim=fNVtxZBin*fNCentBin*fNRpBin*fNBadChDistBin*fNpid;\r
+  \r
+  fRealOmega0 =new TH2F*[ndim];\r
+  fMixAOmega0 =new TH2F*[ndim];\r
+  fMixBOmega0 =new TH2F*[ndim];\r
+  fMixCOmega0 =new TH2F*[ndim];\r
+  \r
+  fRealOmega1 =new TH2F*[ndim];\r
+  fMixAOmega1 =new TH2F*[ndim];\r
+  fMixBOmega1 =new TH2F*[ndim];\r
+  fMixCOmega1 =new TH2F*[ndim];\r
+  \r
+  fRealOmega2 =new TH2F*[ndim];\r
+  fMixAOmega2 =new TH2F*[ndim];\r
+  fMixBOmega2 =new TH2F*[ndim];\r
+  fMixCOmega2 =new TH2F*[ndim];\r
+  \r
+  for(Int_t i=0;i<fNVtxZBin;i++){\r
+    for(Int_t j=0;j<fNCentBin;j++){\r
+      for(Int_t k=0;k<fNRpBin;k++){ //at event level\r
+        Int_t idim=i*fNCentBin*fNRpBin+j*fNRpBin+k;\r
+        for(Int_t ipid=0;ipid<fNpid;ipid++){\r
+          for(Int_t idist=0;idist<fNBadChDistBin;idist++){ //at particle level\r
+            \r
+            Int_t index=idim*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
+            \r
+            snprintf(key,buffersize,"RealToPi0Gamma_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s Real Pi0GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fRealOmega0[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fRealOmega0[index]->SetName(key) ;\r
+            fRealOmega0[index]->SetTitle(title);\r
+            outputContainer->Add(fRealOmega0[index]);\r
+            \r
+            snprintf(key,buffersize,"MixAToPi0Gamma_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s MixA Pi0GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fMixAOmega0[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fMixAOmega0[index]->SetName(key) ;\r
+            fMixAOmega0[index]->SetTitle(title);\r
+            outputContainer->Add(fMixAOmega0[index]);\r
+            \r
+            snprintf(key,buffersize,"MixBToPi0Gamma_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s MixB Pi0GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fMixBOmega0[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fMixBOmega0[index]->SetName(key) ;\r
+            fMixBOmega0[index]->SetTitle(title);\r
+            outputContainer->Add(fMixBOmega0[index]);\r
+            \r
+            snprintf(key,buffersize,"MixCToPi0Gamma_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s MixC Pi0GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fMixCOmega0[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fMixCOmega0[index]->SetName(key) ;\r
+            fMixCOmega0[index]->SetTitle(title);\r
+            outputContainer->Add(fMixCOmega0[index]);\r
+            \r
+            snprintf(key,buffersize,"RealToPi0Gamma1_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s Real Pi0(A<0.7)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fRealOmega1[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fRealOmega1[index]->SetName(key) ;\r
+            fRealOmega1[index]->SetTitle(title);\r
+            outputContainer->Add(fRealOmega1[index]);\r
+            \r
+            snprintf(key,buffersize,"MixAToPi0Gamma1_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s MixA Pi0(A<0.7)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fMixAOmega1[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fMixAOmega1[index]->SetName(key) ;\r
+            fMixAOmega1[index]->SetTitle(title);\r
+            outputContainer->Add(fMixAOmega1[index]);\r
+            \r
+            snprintf(key,buffersize,"MixBToPi0Gamma1_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s MixB Pi0(A<0.7)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fMixBOmega1[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fMixBOmega1[index]->SetName(key) ;\r
+            fMixBOmega1[index]->SetTitle(title);\r
+            outputContainer->Add(fMixBOmega1[index]);\r
+            \r
+            snprintf(key,buffersize,"MixCToPi0Gamma1_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s MixC Pi0(A<0.7)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fMixCOmega1[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fMixCOmega1[index]->SetName(key) ;\r
+            fMixCOmega1[index]->SetTitle(title);\r
+            outputContainer->Add(fMixCOmega1[index]);\r
+            \r
+            snprintf(key,buffersize,"RealToPi0Gamma2_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s Real Pi0(A<0.8)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fRealOmega2[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fRealOmega2[index]->SetName(key) ;\r
+            fRealOmega2[index]->SetTitle(title);\r
+            outputContainer->Add(fRealOmega2[index]);\r
+            \r
+            snprintf(key,buffersize,"MixAToPi0Gamma2_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s MixA Pi0(A<0.8)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fMixAOmega2[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fMixAOmega2[index]->SetName(key) ;\r
+            fMixAOmega2[index]->SetTitle(title);\r
+            outputContainer->Add(fMixAOmega2[index]);\r
+            \r
+            snprintf(key,buffersize,"MixBToPi0Gamma2_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s MixB Pi0(A<0.8)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fMixBOmega2[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fMixBOmega2[index]->SetName(key) ;\r
+            fMixBOmega2[index]->SetTitle(title);\r
+            outputContainer->Add(fMixBOmega2[index]);\r
+            \r
+            snprintf(key,buffersize,"MixCToPi0Gamma2_Vz%dC%dRp%dPid%dDist%d",i,j,k,ipid,idist);\r
+            snprintf(title,buffersize, "%s MixC Pi0(A<0.8)GammaIVM vz_%2.1f_ct_%2.1f_Rp_%2.1f_pid_%d_dist_%d",detector,fVtxZCut[i],fCent[j],fRp[k],ipid,idist);\r
+            fhEtalon->Clone(key);\r
+            fMixCOmega2[index]=(TH2F*)fhEtalon->Clone(key) ;\r
+            fMixCOmega2[index]->SetName(key) ;\r
+            fMixCOmega2[index]->SetTitle(title);\r
+            outputContainer->Add(fMixCOmega2[index]);\r
+          }\r
+        }\r
+      }\r
+    }  \r
+  }\r
+  \r
+  if(IsDataMC()){\r
+    snprintf(key,buffersize, "%sOmegaPri",detector);\r
+    snprintf(title,buffersize,"primary #omega in %s",detector);\r
     fhOmegaPriPt=new TH1F(key, title,nptbins,ptmin,ptmax);\r
     fhOmegaPriPt->GetXaxis()->SetTitle("P_{T}");\r
     fhOmegaPriPt->GetYaxis()->SetTitle("dN/P_{T}");\r
     outputContainer->Add(fhOmegaPriPt);\r
- }\r
-\r
- delete fhEtalon;\r
- return outputContainer;\r
+  }\r
+  \r
+  delete fhEtalon;\r
+  return outputContainer;\r
 }\r
 \r
 //______________________________________________________________________________\r
@@ -382,339 +383,344 @@ void AliAnaOmegaToPi0Gamma::Print(const Option_t * /*opt*/) const
 //______________________________________________________________________________\r
 void AliAnaOmegaToPi0Gamma::MakeAnalysisFillHistograms() \r
 {\r
- //fill the MC AOD if needed first\r
- //-----------\r
- //need to be further implemented\r
- AliStack * stack = 0x0;\r
-// TParticle * primary = 0x0;\r
- TClonesArray * mcparticles0 = 0x0;\r
- //TClonesArray * mcparticles1 = 0x0;\r
- AliAODMCParticle * aodprimary = 0x0;\r
- Int_t pdg=0;\r
- Double_t pt=0;\r
- Double_t eta=0;\r
-\r
- if(IsDataMC()){\r
-     if(GetReader()->ReadStack()){\r
-        stack =  GetMCStack() ;\r
-        if(!stack)\r
+  //fill the MC AOD if needed first\r
+  //-----------\r
+  //need to be further implemented\r
+  AliStack * stack = 0x0;\r
+  // TParticle * primary = 0x0;\r
+  TClonesArray * mcparticles0 = 0x0;\r
+  //TClonesArray * mcparticles1 = 0x0;\r
+  AliAODMCParticle * aodprimary = 0x0;\r
+  Int_t pdg=0;\r
+  Double_t pt=0;\r
+  Double_t eta=0;\r
+  \r
+  if(IsDataMC()){\r
+    if(GetReader()->ReadStack()){\r
+      stack =  GetMCStack() ;\r
+      if(!stack){\r
         printf("AliAnaAcceptance::MakeAnalysisFillHistograms() - There is no stack!\n");\r
+      }\r
+      else{\r
         for(Int_t i=0 ; i<stack->GetNtrack(); i++){\r
-            TParticle * prim = stack->Particle(i) ;\r
-            pdg = prim->GetPdgCode() ;\r
-            eta=prim->Eta();\r
-            pt=prim->Pt();\r
-            if(TMath::Abs(eta)<0.5) {\r
-               if(pdg==223) fhOmegaPriPt->Fill(pt);\r
-            }\r
+          TParticle * prim = stack->Particle(i) ;\r
+          pdg = prim->GetPdgCode() ;\r
+          eta=prim->Eta();\r
+          pt=prim->Pt();\r
+          if(TMath::Abs(eta)<0.5) {\r
+            if(pdg==223) fhOmegaPriPt->Fill(pt);\r
+          }\r
         }\r
       }\r
-      else if(GetReader()->ReadAODMCParticles()){\r
-          //Get the list of MC particles\r
-          mcparticles0 = GetReader()->GetAODMCParticles(0);\r
-          if(!mcparticles0 && GetDebug() > 0)     {\r
-             printf("AliAnaAcceptance::MakeAnalysisFillHistograms() -  Standard MCParticles not available!\n");\r
-           }\r
-//           if(GetReader()->GetSecondInputAODTree()){\r
-//               mcparticles1 = GetReader()->GetAODMCParticles(1);\r
-//               if(!mcparticles1 && GetDebug() > 0)     {\r
-//                   printf("AliAnaAcceptance::MakeAnalysisFillHistograms() -  Second input MCParticles not available!\n");\r
-//                }\r
-//           }\r
-           for(Int_t i=0;i<mcparticles0->GetEntries();i++){\r
-               aodprimary =(AliAODMCParticle*)mcparticles0->At(i);\r
-               pdg = aodprimary->GetPdgCode() ;\r
-               eta=aodprimary->Eta();\r
-               pt=aodprimary->Pt();\r
-               if(TMath::Abs(eta)<0.5) {\r
-                  if(pdg==223) fhOmegaPriPt->Fill(pt);\r
-                }\r
-\r
-           }\r
-     }\r
- }// is data and MC\r
+    }\r
+    else if(GetReader()->ReadAODMCParticles()){\r
+      //Get the list of MC particles\r
+      mcparticles0 = GetReader()->GetAODMCParticles(0);\r
+      if(!mcparticles0 )     {\r
+        if(GetDebug() > 0) printf("AliAnaAcceptance::MakeAnalysisFillHistograms() -  Standard MCParticles not available!\n");\r
+      }\r
+      //           if(GetReader()->GetSecondInputAODTree()){\r
+      //               mcparticles1 = GetReader()->GetAODMCParticles(1);\r
+      //               if(!mcparticles1 && GetDebug() > 0)     {\r
+      //                   printf("AliAnaAcceptance::MakeAnalysisFillHistograms() -  Second input MCParticles not available!\n");\r
+      //                }\r
+      //           }\r
+      else{\r
+        for(Int_t i=0;i<mcparticles0->GetEntries();i++){\r
+          aodprimary =(AliAODMCParticle*)mcparticles0->At(i);\r
+          pdg = aodprimary->GetPdgCode() ;\r
+          eta=aodprimary->Eta();\r
+          pt=aodprimary->Pt();\r
+          if(TMath::Abs(eta)<0.5) {\r
+            if(pdg==223) fhOmegaPriPt->Fill(pt);\r
+          }\r
+          \r
+        }\r
+      }//mcparticles0 exists\r
+    }//AOD MC Particles\r
+  }// is data and MC\r
   \r
-\r
- //process event from AOD brach \r
- //extract pi0, eta and omega analysis\r
- Int_t iRun=(GetReader()->GetInputEvent())->GetRunNumber() ;\r
- if(IsBadRun(iRun)) return ;   \r
-\r
- //vertex z\r
- Double_t vert[]={0,0,0} ;\r
- GetReader()->GetVertex(vert);\r
- Int_t curEventBin =0;\r
-\r
- Int_t ivtxzbin=(Int_t)TMath::Abs(vert[2])/10;\r
- if(ivtxzbin>=fNVtxZBin)return;\r
-\r
- //centrality\r
- Int_t icentbin=0;\r
-\r
- //reaction plane\r
- Int_t irpbin=0;\r
-\r
- if(ivtxzbin==-1) return; \r
- curEventBin = ivtxzbin*fNCentBin*fNRpBin + icentbin*fNRpBin + irpbin;\r
+  \r
+  //process event from AOD brach \r
+  //extract pi0, eta and omega analysis\r
+  Int_t iRun=(GetReader()->GetInputEvent())->GetRunNumber() ;\r
+  if(IsBadRun(iRun)) return ;  \r
+  \r
+  //vertex z\r
+  Double_t vert[]={0,0,0} ;\r
+  GetVertex(vert);\r
+  Int_t curEventBin =0;\r
+  \r
+  Int_t ivtxzbin=(Int_t)TMath::Abs(vert[2])/10;\r
+  if(ivtxzbin>=fNVtxZBin)return;\r
+  \r
+  //centrality\r
+  Int_t icentbin=0;\r
+  \r
+  //reaction plane\r
+  Int_t irpbin=0;\r
+  \r
+  if(ivtxzbin==-1) return; \r
+  curEventBin = ivtxzbin*fNCentBin*fNRpBin + icentbin*fNRpBin + irpbin;\r
   TClonesArray *aodGamma = (TClonesArray*) GetAODBranch(fInputAODGammaName); //photon array\r
-//  TClonesArray *aodGamma = (TClonesArray *) GetReader()->GetOutputEvent()->FindListObject(fInputAODGammaName); //photon array\r
- Int_t nphotons =0;\r
- if(aodGamma) nphotons= aodGamma->GetEntries(); \r
- else return;\r
-\r
- fInputAODPi0 = (TClonesArray*)GetInputAODBranch();  //pi0 array\r
- Int_t npi0s = 0;\r
- if(fInputAODPi0) npi0s= fInputAODPi0 ->GetEntries();\r
- else return;\r
-\r
- if(nphotons<3 || npi0s<1)return; //for pi0, eta and omega->pi0+gamma->3gamma reconstruction\r
-\r
- //reconstruction of omega(782)->pi0+gamma->3gamma\r
- //loop for pi0 and photon\r
- if(GetDebug() > 0) printf("omega->pi0+gamma->3gamma invariant mass analysis ! This event have %d photons and %d pi0 \n", nphotons, npi0s);\r
- for(Int_t i=0;i<npi0s;i++){\r
-     AliAODPWG4Particle * pi0 = (AliAODPWG4Particle*) (fInputAODPi0->At(i)) ; //pi0\r
-     TLorentzVector vpi0(pi0->Px(),pi0->Py(),pi0->Pz(),pi0->E());\r
-     Int_t lab1=pi0->GetCaloLabel(0);  // photon1 from pi0 decay\r
-     Int_t lab2=pi0->GetCaloLabel(1);  // photon2 from pi0 decay\r
-     //for omega->pi0+gamma, it needs at least three photons per event\r
-     //Get the two decay photons from pi0\r
-     AliAODPWG4Particle * photon1 =0;\r
-     AliAODPWG4Particle * photon2 =0;\r
-     for(Int_t d1=0;d1<nphotons;d1++){\r
-         for(Int_t d2=0;d2<nphotons;d2++){\r
-             AliAODPWG4Particle * dp1 = (AliAODPWG4Particle*) (aodGamma->At(d1));\r
-             AliAODPWG4Particle * dp2 = (AliAODPWG4Particle*) (aodGamma->At(d2));\r
-             Int_t dlab1=dp1->GetCaloLabel(0);\r
-             Int_t dlab2=dp2->GetCaloLabel(0);\r
-             if(dlab1==lab1 && dlab2==lab2){\r
-                photon1=dp1;\r
-                photon2=dp2;\r
-             }\r
-             else continue;\r
-         }\r
+  //  TClonesArray *aodGamma = (TClonesArray *) GetReader()->GetOutputEvent()->FindListObject(fInputAODGammaName); //photon array\r
+  Int_t nphotons =0;\r
+  if(aodGamma) nphotons= aodGamma->GetEntries(); \r
+  else return;\r
+  \r
+  fInputAODPi0 = (TClonesArray*)GetInputAODBranch();  //pi0 array\r
+  Int_t npi0s = 0;\r
+  if(fInputAODPi0) npi0s= fInputAODPi0 ->GetEntries();\r
+  else return;\r
+  \r
+  if(nphotons<3 || npi0s<1)return; //for pi0, eta and omega->pi0+gamma->3gamma reconstruction\r
+  \r
+  //reconstruction of omega(782)->pi0+gamma->3gamma\r
+  //loop for pi0 and photon\r
+  if(GetDebug() > 0) printf("omega->pi0+gamma->3gamma invariant mass analysis ! This event have %d photons and %d pi0 \n", nphotons, npi0s);\r
+  for(Int_t i=0;i<npi0s;i++){\r
+    AliAODPWG4Particle * pi0 = (AliAODPWG4Particle*) (fInputAODPi0->At(i)) ; //pi0\r
+    TLorentzVector vpi0(pi0->Px(),pi0->Py(),pi0->Pz(),pi0->E());\r
+    Int_t lab1=pi0->GetCaloLabel(0);  // photon1 from pi0 decay\r
+    Int_t lab2=pi0->GetCaloLabel(1);  // photon2 from pi0 decay\r
+    //for omega->pi0+gamma, it needs at least three photons per event\r
+    //Get the two decay photons from pi0\r
+    AliAODPWG4Particle * photon1 =0;\r
+    AliAODPWG4Particle * photon2 =0;\r
+    for(Int_t d1=0;d1<nphotons;d1++){\r
+      for(Int_t d2=0;d2<nphotons;d2++){\r
+        AliAODPWG4Particle * dp1 = (AliAODPWG4Particle*) (aodGamma->At(d1));\r
+        AliAODPWG4Particle * dp2 = (AliAODPWG4Particle*) (aodGamma->At(d2));\r
+        Int_t dlab1=dp1->GetCaloLabel(0);\r
+        Int_t dlab2=dp2->GetCaloLabel(0);\r
+        if(dlab1==lab1 && dlab2==lab2){\r
+          photon1=dp1;\r
+          photon2=dp2;\r
+        }\r
+        else continue;\r
+      }\r
     }\r
     //caculate the asy and dist of the two photon from pi0 decay\r
     TLorentzVector dph1(photon1->Px(),photon1->Py(),photon1->Pz(),photon1->E());\r
     TLorentzVector dph2(photon2->Px(),photon2->Py(),photon2->Pz(),photon2->E());\r
-\r
+    \r
     Double_t pi0asy= TMath::Abs(dph1.E()-dph2.E())/(dph1.E()+dph2.E());\r
-//    Double_t phi1=dph1.Phi();\r
-//    Double_t phi2=dph2.Phi();\r
-//    Double_t eta1=dph1.Eta();\r
-//    Double_t eta2=dph2.Eta();\r
-//    Double_t pi0dist=TMath::Sqrt((phi1-phi2)*(phi1-phi2)+(eta1-eta2)*(eta1-eta2));\r
-\r
-    if(pi0->GetPdg()==111  && nphotons>2 && npi0s\r
-           && TMath::Abs(vpi0.M()-fPi0Mass)<fPi0MassWindow) { //pi0 candidates\r
-\r
-         //avoid the double counting\r
-         Int_t * dc1= new Int_t[nphotons];\r
-         Int_t * dc2= new Int_t[nphotons];\r
-         Int_t index1=0;\r
-         Int_t index2=0;\r
-         for(Int_t k=0;k<i;k++){\r
-             AliAODPWG4Particle * p3=(AliAODPWG4Particle*)(fInputAODPi0->At(k));\r
-             Int_t lab4=p3->GetCaloLabel(0);\r
-             Int_t lab5=p3->GetCaloLabel(1);\r
-             if(lab1==lab4){ dc1[index1]=lab5;  index1++;  }\r
-             if(lab2==lab5){ dc2[index2]=lab4;  index2++;  }\r
-         }\r
-\r
-\r
-        //loop the pi0 with third gamma\r
-        for(Int_t j=0;j<nphotons;j++){\r
-             AliAODPWG4Particle *photon3 = (AliAODPWG4Particle*) (aodGamma->At(j));\r
-            TLorentzVector dph3(photon3->Px(),photon3->Py(),photon3->Pz(),photon3->E());\r
-            Int_t lab3=photon3->GetCaloLabel(0);\r
-             Double_t pi0gammapt=(vpi0+dph3).Pt();\r
-             Double_t pi0gammamass=(vpi0+dph3).M();\r
-             Double_t pi0OverOmegaPtRatio =vpi0.Pt()/pi0gammapt; \r
-             Double_t gammaOverOmegaPtRatio= dph3.Pt()/pi0gammapt;\r
-\r
-             //pi0, gamma pt cut             \r
-             if(pi0OverOmegaPtRatio>fPi0OverOmegaPtCut || \r
-                gammaOverOmegaPtRatio<fGammaOverOmegaPtCut) continue;\r
-\r
-            for(Int_t l=0;l<index1;l++) if(lab3==dc1[l]) lab3=-1;\r
-             for(Int_t l=0;l<index2;l++) if(lab3==dc2[l]) lab3=-1;\r
+    //    Double_t phi1=dph1.Phi();\r
+    //    Double_t phi2=dph2.Phi();\r
+    //    Double_t eta1=dph1.Eta();\r
+    //    Double_t eta2=dph2.Eta();\r
+    //    Double_t pi0dist=TMath::Sqrt((phi1-phi2)*(phi1-phi2)+(eta1-eta2)*(eta1-eta2));\r
     \r
-            if(lab3>0 && lab3!=lab1 && lab3!=lab2){\r
+    if(pi0->GetPdg()==111  && nphotons>2 && npi0s\r
+       && TMath::Abs(vpi0.M()-fPi0Mass)<fPi0MassWindow) { //pi0 candidates\r
+      \r
+      //avoid the double counting\r
+      Int_t * dc1= new Int_t[nphotons];\r
+      Int_t * dc2= new Int_t[nphotons];\r
+      Int_t index1=0;\r
+      Int_t index2=0;\r
+      for(Int_t k=0;k<i;k++){\r
+        AliAODPWG4Particle * p3=(AliAODPWG4Particle*)(fInputAODPi0->At(k));\r
+        Int_t lab4=p3->GetCaloLabel(0);\r
+        Int_t lab5=p3->GetCaloLabel(1);\r
+        if(lab1==lab4){ dc1[index1]=lab5;  index1++;  }\r
+        if(lab2==lab5){ dc2[index2]=lab4;  index2++;  }\r
+      }\r
+      \r
+      \r
+      //loop the pi0 with third gamma\r
+      for(Int_t j=0;j<nphotons;j++){\r
+        AliAODPWG4Particle *photon3 = (AliAODPWG4Particle*) (aodGamma->At(j));\r
+        TLorentzVector dph3(photon3->Px(),photon3->Py(),photon3->Pz(),photon3->E());\r
+        Int_t lab3=photon3->GetCaloLabel(0);\r
+        Double_t pi0gammapt=(vpi0+dph3).Pt();\r
+        Double_t pi0gammamass=(vpi0+dph3).M();\r
+        Double_t pi0OverOmegaPtRatio =vpi0.Pt()/pi0gammapt; \r
+        Double_t gammaOverOmegaPtRatio= dph3.Pt()/pi0gammapt;\r
+        \r
+        //pi0, gamma pt cut             \r
+        if(pi0OverOmegaPtRatio>fPi0OverOmegaPtCut || \r
+           gammaOverOmegaPtRatio<fGammaOverOmegaPtCut) continue;\r
+        \r
+        for(Int_t l=0;l<index1;l++) if(lab3==dc1[l]) lab3=-1;\r
+        for(Int_t l=0;l<index2;l++) if(lab3==dc2[l]) lab3=-1;\r
+        \r
+        if(lab3>0 && lab3!=lab1 && lab3!=lab2){\r
                for(Int_t ipid=0;ipid<fNpid;ipid++){\r
-                   for(Int_t idist=0;idist<fNBadChDistBin;idist++){\r
-                       Int_t index=curEventBin*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
-                       if(photon1->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
-                          photon2->IsPIDOK(ipid,AliCaloPID::kPhoton) && \r
-                          photon3->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
-                          photon1->DistToBad()>=idist &&\r
-                          photon2->DistToBad()>=idist &&\r
-                          photon3->DistToBad()>=idist ){\r
-                          //fill the histograms\r
-                           if(GetDebug() > 2) printf("Real: index  %d  pt  %2.3f  mass   %2.3f \n", index, pi0gammapt, pi0gammamass);\r
-                          fRealOmega0[index]->Fill(pi0gammapt,pi0gammamass);\r
-                          if(pi0asy<0.7) fRealOmega1[index]->Fill(pi0gammapt,pi0gammamass);\r
-                          if(pi0asy<0.8) fRealOmega2[index]->Fill(pi0gammapt,pi0gammamass);\r
-                       }\r
-                    }\r
+            for(Int_t idist=0;idist<fNBadChDistBin;idist++){\r
+              Int_t index=curEventBin*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
+              if(photon1->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
+                 photon2->IsPIDOK(ipid,AliCaloPID::kPhoton) && \r
+                 photon3->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
+                 photon1->DistToBad()>=idist &&\r
+                 photon2->DistToBad()>=idist &&\r
+                 photon3->DistToBad()>=idist ){\r
+                //fill the histograms\r
+                if(GetDebug() > 2) printf("Real: index  %d  pt  %2.3f  mass   %2.3f \n", index, pi0gammapt, pi0gammamass);\r
+                fRealOmega0[index]->Fill(pi0gammapt,pi0gammamass);\r
+                if(pi0asy<0.7) fRealOmega1[index]->Fill(pi0gammapt,pi0gammamass);\r
+                if(pi0asy<0.8) fRealOmega2[index]->Fill(pi0gammapt,pi0gammamass);\r
+              }\r
+            }\r
                }\r
-             }\r
-         }     \r
-         delete []dc1;\r
-        delete []dc2;\r
- if(GetDebug() > 0) printf("MixA: (r1_event1+r2_event1)+r3_event2 \n");\r
-        //-------------------------\r
-        //background analysis\r
-        //three background\r
-        // --A   (r1_event1+r2_event1)+r3_event2\r
-         Int_t nMixed = fEventsList[curEventBin]->GetSize();\r
-         for(Int_t im=0;im<nMixed;im++){\r
-             TClonesArray* ev2= (TClonesArray*) (fEventsList[curEventBin]->At(im));\r
-            for(Int_t mix1=0;mix1<ev2->GetEntries();mix1++){\r
-                AliAODPWG4Particle *mix1ph = (AliAODPWG4Particle*) (ev2->At(mix1));     \r
-               TLorentzVector vmixph(mix1ph->Px(),mix1ph->Py(),mix1ph->Pz(),mix1ph->E());\r
-                Double_t pi0gammapt=(vpi0+vmixph).Pt();\r
-                Double_t pi0gammamass=(vpi0+vmixph).M();\r
-                Double_t pi0OverOmegaPtRatio =vpi0.Pt()/pi0gammapt;\r
-                Double_t gammaOverOmegaPtRatio= vmixph.Pt()/pi0gammapt;\r
-\r
-              //pi0, gamma pt cut             \r
-               if(pi0OverOmegaPtRatio>fPi0OverOmegaPtCut || \r
-                  gammaOverOmegaPtRatio<fGammaOverOmegaPtCut) continue;\r
-\r
+        }\r
+      }        \r
+      delete []dc1;\r
+      delete []dc2;\r
+      if(GetDebug() > 0) printf("MixA: (r1_event1+r2_event1)+r3_event2 \n");\r
+      //-------------------------\r
+      //background analysis\r
+      //three background\r
+      // --A   (r1_event1+r2_event1)+r3_event2\r
+      Int_t nMixed = fEventsList[curEventBin]->GetSize();\r
+      for(Int_t im=0;im<nMixed;im++){\r
+        TClonesArray* ev2= (TClonesArray*) (fEventsList[curEventBin]->At(im));\r
+        for(Int_t mix1=0;mix1<ev2->GetEntries();mix1++){\r
+          AliAODPWG4Particle *mix1ph = (AliAODPWG4Particle*) (ev2->At(mix1));     \r
+          TLorentzVector vmixph(mix1ph->Px(),mix1ph->Py(),mix1ph->Pz(),mix1ph->E());\r
+          Double_t pi0gammapt=(vpi0+vmixph).Pt();\r
+          Double_t pi0gammamass=(vpi0+vmixph).M();\r
+          Double_t pi0OverOmegaPtRatio =vpi0.Pt()/pi0gammapt;\r
+          Double_t gammaOverOmegaPtRatio= vmixph.Pt()/pi0gammapt;\r
+          \r
+          //pi0, gamma pt cut             \r
+          if(pi0OverOmegaPtRatio>fPi0OverOmegaPtCut || \r
+             gammaOverOmegaPtRatio<fGammaOverOmegaPtCut) continue;\r
+          \r
                for(Int_t ipid=0;ipid<fNpid;ipid++){\r
-                  for(Int_t idist=0;idist<fNBadChDistBin;idist++){\r
-                      Int_t index=curEventBin*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
-                       if(photon1->IsPIDOK(ipid,AliCaloPID::kPhoton)&&\r
-                          photon2->IsPIDOK(ipid,AliCaloPID::kPhoton)&&\r
-                          mix1ph->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
-                          photon1->DistToBad()>=idist &&\r
-                          photon2->DistToBad()>=idist &&\r
-                          mix1ph->DistToBad()>=idist ){\r
-                          if(GetDebug() > 2) printf("MixA: index  %d   pt  %2.3f  mass   %2.3f \n",index, pi0gammapt, pi0gammamass);\r
-                         //fill the histograms\r
-                         fMixAOmega0[index]->Fill(pi0gammapt,pi0gammamass);\r
-                          if(pi0asy<0.7)fMixAOmega1[index]->Fill(pi0gammapt,pi0gammamass);\r
-                          if(pi0asy<0.8)fMixAOmega2[index]->Fill(pi0gammapt,pi0gammamass);\r
-//printf("mix A  %d  %2.2f \n", index, pi0gammamass);\r
-                         \r
-                       }\r
-                  }\r
-                }\r
-            }\r
-         }\r
-     }\r
- }\r
-\r
- //\r
- // --B   (r1_event1+r2_event2)+r3_event2\r
- //\r
- if(GetDebug() >0)printf("MixB:  (r1_event1+r2_event2)+r3_event2 \n");\r
- for(Int_t i=0;i<nphotons;i++){\r
-     AliAODPWG4Particle *ph1 = (AliAODPWG4Particle*) (aodGamma->At(i)); \r
-     TLorentzVector vph1(ph1->Px(),ph1->Py(),ph1->Pz(),ph1->E());\r
-\r
-     Int_t nMixed = fEventsList[curEventBin]->GetSize();\r
-     for(Int_t ie=0;ie<nMixed;ie++){\r
-         TClonesArray* ev2= (TClonesArray*) (fEventsList[curEventBin]->At(ie));\r
-         for(Int_t mix1=0;mix1<ev2->GetEntries();mix1++){\r
-             AliAODPWG4Particle *ph2 = (AliAODPWG4Particle*) (ev2->At(mix1));\r
-            TLorentzVector vph2(ph2->Px(),ph2->Py(),ph2->Pz(),ph2->E());\r
-            Double_t pi0asy = TMath::Abs(vph1.E()-vph2.E())/(vph1.E()+vph2.E());            \r
-            Double_t pi0mass=(vph1+vph2).M();\r
-               \r
-            if(TMath::Abs(pi0mass-fPi0Mass)<fPi0MassWindow){//for pi0 selection\r
-               for(Int_t mix2=(mix1+1);mix2<ev2->GetEntries();mix2++){\r
-                    AliAODPWG4Particle *ph3 = (AliAODPWG4Particle*) (ev2->At(mix2));\r
-                    TLorentzVector vph3(ph3->Px(),ph3->Py(),ph3->Pz(),ph3->E());\r
-                   \r
-                    Double_t pi0gammapt=(vph1+vph2+vph3).Pt();\r
-                    Double_t pi0gammamass=(vph1+vph2+vph3).M(); \r
-                    Double_t pi0OverOmegaPtRatio =(vph1+vph2).Pt()/pi0gammapt;\r
-                    Double_t gammaOverOmegaPtRatio= vph3.Pt()/pi0gammapt;\r
-                   //pi0, gamma pt cut             \r
-                   if(pi0OverOmegaPtRatio>fPi0OverOmegaPtCut ||\r
-                       gammaOverOmegaPtRatio<fGammaOverOmegaPtCut) continue;\r
-\r
-                   for(Int_t ipid=0;ipid<fNpid;ipid++){\r
-                        for(Int_t idist=0;idist<fNBadChDistBin;idist++){\r
-                            Int_t index=curEventBin*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
-                           if(ph1->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
+            for(Int_t idist=0;idist<fNBadChDistBin;idist++){\r
+              Int_t index=curEventBin*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
+              if(photon1->IsPIDOK(ipid,AliCaloPID::kPhoton)&&\r
+                 photon2->IsPIDOK(ipid,AliCaloPID::kPhoton)&&\r
+                 mix1ph->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
+                 photon1->DistToBad()>=idist &&\r
+                 photon2->DistToBad()>=idist &&\r
+                 mix1ph->DistToBad()>=idist ){\r
+                if(GetDebug() > 2) printf("MixA: index  %d   pt  %2.3f  mass   %2.3f \n",index, pi0gammapt, pi0gammamass);\r
+                //fill the histograms\r
+                fMixAOmega0[index]->Fill(pi0gammapt,pi0gammamass);\r
+                if(pi0asy<0.7)fMixAOmega1[index]->Fill(pi0gammapt,pi0gammamass);\r
+                if(pi0asy<0.8)fMixAOmega2[index]->Fill(pi0gammapt,pi0gammamass);\r
+                //printf("mix A  %d  %2.2f \n", index, pi0gammamass);\r
+                \r
+              }\r
+            }\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+  \r
+  //\r
+  // --B   (r1_event1+r2_event2)+r3_event2\r
+  //\r
+  if(GetDebug() >0)printf("MixB:  (r1_event1+r2_event2)+r3_event2 \n");\r
+  for(Int_t i=0;i<nphotons;i++){\r
+    AliAODPWG4Particle *ph1 = (AliAODPWG4Particle*) (aodGamma->At(i)); \r
+    TLorentzVector vph1(ph1->Px(),ph1->Py(),ph1->Pz(),ph1->E());\r
+    \r
+    Int_t nMixed = fEventsList[curEventBin]->GetSize();\r
+    for(Int_t ie=0;ie<nMixed;ie++){\r
+      TClonesArray* ev2= (TClonesArray*) (fEventsList[curEventBin]->At(ie));\r
+      for(Int_t mix1=0;mix1<ev2->GetEntries();mix1++){\r
+        AliAODPWG4Particle *ph2 = (AliAODPWG4Particle*) (ev2->At(mix1));\r
+        TLorentzVector vph2(ph2->Px(),ph2->Py(),ph2->Pz(),ph2->E());\r
+        Double_t pi0asy = TMath::Abs(vph1.E()-vph2.E())/(vph1.E()+vph2.E());        \r
+        Double_t pi0mass=(vph1+vph2).M();\r
+        \r
+        if(TMath::Abs(pi0mass-fPi0Mass)<fPi0MassWindow){//for pi0 selection\r
+          for(Int_t mix2=(mix1+1);mix2<ev2->GetEntries();mix2++){\r
+            AliAODPWG4Particle *ph3 = (AliAODPWG4Particle*) (ev2->At(mix2));\r
+            TLorentzVector vph3(ph3->Px(),ph3->Py(),ph3->Pz(),ph3->E());\r
+            \r
+            Double_t pi0gammapt=(vph1+vph2+vph3).Pt();\r
+            Double_t pi0gammamass=(vph1+vph2+vph3).M(); \r
+            Double_t pi0OverOmegaPtRatio =(vph1+vph2).Pt()/pi0gammapt;\r
+            Double_t gammaOverOmegaPtRatio= vph3.Pt()/pi0gammapt;\r
+            //pi0, gamma pt cut             \r
+            if(pi0OverOmegaPtRatio>fPi0OverOmegaPtCut ||\r
+               gammaOverOmegaPtRatio<fGammaOverOmegaPtCut) continue;\r
+            \r
+            for(Int_t ipid=0;ipid<fNpid;ipid++){\r
+              for(Int_t idist=0;idist<fNBadChDistBin;idist++){\r
+                Int_t index=curEventBin*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
+                if(ph1->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
                               ph2->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
-                               ph3->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
-                              ph1->DistToBad()>=idist &&\r
-                               ph2->DistToBad()>=idist &&\r
-                               ph3->DistToBad()>=idist ){\r
-                               if(GetDebug() > 2) printf("MixB: index  %d   pt  %2.3f  mass   %2.3f \n", index, pi0gammapt, pi0gammamass);\r
-                              //fill histograms\r
-                              fMixBOmega0[index]->Fill(pi0gammapt,pi0gammamass);\r
-                               if(pi0asy<0.7) fMixBOmega1[index]->Fill(pi0gammapt,pi0gammamass);\r
-                               if(pi0asy<0.8) fMixBOmega2[index]->Fill(pi0gammapt,pi0gammamass);\r
-//printf("mix B  %d  %2.2f \n", index, pi0gammamass);\r
-                           }\r
-                       }                   \r
-                   }\r
-               }\r
-       \r
-               //\r
+                   ph3->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
+                   ph1->DistToBad()>=idist &&\r
+                   ph2->DistToBad()>=idist &&\r
+                   ph3->DistToBad()>=idist ){\r
+                  if(GetDebug() > 2) printf("MixB: index  %d   pt  %2.3f  mass   %2.3f \n", index, pi0gammapt, pi0gammamass);\r
+                  //fill histograms\r
+                  fMixBOmega0[index]->Fill(pi0gammapt,pi0gammamass);\r
+                  if(pi0asy<0.7) fMixBOmega1[index]->Fill(pi0gammapt,pi0gammamass);\r
+                  if(pi0asy<0.8) fMixBOmega2[index]->Fill(pi0gammapt,pi0gammamass);\r
+                  //printf("mix B  %d  %2.2f \n", index, pi0gammamass);\r
+                }\r
+              }                    \r
+            }\r
+          }\r
+          \r
+          //\r
                // --C   (r1_event1+r2_event2)+r3_event3\r
-                //\r
-                if(GetDebug() >0)printf("MixC: (r1_event1+r2_event2)+r3_event3\n");\r
-               for(Int_t je=(ie+1);je<nMixed;je++){\r
-                   TClonesArray* ev3= (TClonesArray*) (fEventsList[curEventBin]->At(je));\r
-                   for(Int_t mix3=0;mix3<ev3->GetEntries();mix3++){\r
-                       AliAODPWG4Particle *ph3 = (AliAODPWG4Particle*) (ev3->At(mix3));\r
-                       TLorentzVector vph3(ph3->Px(),ph3->Py(),ph3->Pz(),ph3->E());\r
-                       \r
-                        Double_t pi0gammapt=(vph1+vph2+vph3).Pt();\r
-                       Double_t pi0gammamass=(vph1+vph2+vph3).M();\r
-                       Double_t pi0OverOmegaPtRatio =(vph1+vph2).Pt()/pi0gammapt;\r
-                        Double_t gammaOverOmegaPtRatio= vph3.Pt()/pi0gammapt;\r
-                        //pi0, gamma pt cut             \r
-                        if(pi0OverOmegaPtRatio>fPi0OverOmegaPtCut ||\r
-                          gammaOverOmegaPtRatio<fGammaOverOmegaPtCut) continue;\r
-       \r
-                       for(Int_t ipid=0;ipid<fNpid;ipid++){\r
-                           for(Int_t idist=0;idist<fNBadChDistBin;idist++){\r
-                                Int_t index=curEventBin*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
-                                if(ph1->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
-                                   ph2->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
-                                   ph3->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
-                                  ph1->DistToBad()>=idist &&\r
-                                   ph2->DistToBad()>=idist &&\r
-                                   ph3->DistToBad()>=idist ){\r
-                                   if(GetDebug() > 2) printf("MixC: index  %d  pt  %2.3f  mass   %2.3f \n", index, pi0gammapt, pi0gammamass);\r
-                                  //fill histograms\r
-                                 fMixCOmega0[index]->Fill(pi0gammapt,pi0gammamass);\r
-                                  if(pi0asy<0.7) fMixCOmega1[index]->Fill(pi0gammapt,pi0gammamass);\r
-                                 if(pi0asy<0.8) fMixCOmega2[index]->Fill(pi0gammapt,pi0gammamass);\r
-//printf("mix C  %d  %2.2f \n", index, pi0gammamass);\r
-                               }\r
-                          }\r
-                        }\r
-                   }\r
-               }\r
-            } //for pi0 selecton               \r
-        }\r
-     }\r
- }\r
-\r
-\r
- //event buffer \r
- TClonesArray *currentEvent = new TClonesArray(*aodGamma);\r
- if(currentEvent->GetEntriesFast()>0){\r
-        fEventsList[curEventBin]->AddFirst(currentEvent) ;\r
-        currentEvent=0 ; \r
-        if(fEventsList[curEventBin]->GetSize()>=fNmaxMixEv) {\r
-            TClonesArray * tmp = (TClonesArray*) (fEventsList[curEventBin]->Last()) ;\r
-            fEventsList[curEventBin]->RemoveLast() ;\r
-            delete tmp ;\r
-        }\r
- }\r
- else{ \r
-       delete currentEvent ;\r
-       currentEvent=0 ;\r
- }\r
\r
+          //\r
+          if(GetDebug() >0)printf("MixC: (r1_event1+r2_event2)+r3_event3\n");\r
+          for(Int_t je=(ie+1);je<nMixed;je++){\r
+            TClonesArray* ev3= (TClonesArray*) (fEventsList[curEventBin]->At(je));\r
+            for(Int_t mix3=0;mix3<ev3->GetEntries();mix3++){\r
+              AliAODPWG4Particle *ph3 = (AliAODPWG4Particle*) (ev3->At(mix3));\r
+              TLorentzVector vph3(ph3->Px(),ph3->Py(),ph3->Pz(),ph3->E());\r
+              \r
+              Double_t pi0gammapt=(vph1+vph2+vph3).Pt();\r
+              Double_t pi0gammamass=(vph1+vph2+vph3).M();\r
+              Double_t pi0OverOmegaPtRatio =(vph1+vph2).Pt()/pi0gammapt;\r
+              Double_t gammaOverOmegaPtRatio= vph3.Pt()/pi0gammapt;\r
+              //pi0, gamma pt cut             \r
+              if(pi0OverOmegaPtRatio>fPi0OverOmegaPtCut ||\r
+                 gammaOverOmegaPtRatio<fGammaOverOmegaPtCut) continue;\r
+              \r
+              for(Int_t ipid=0;ipid<fNpid;ipid++){\r
+                for(Int_t idist=0;idist<fNBadChDistBin;idist++){\r
+                  Int_t index=curEventBin*fNpid*fNBadChDistBin+ipid*fNBadChDistBin+idist;\r
+                  if(ph1->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
+                     ph2->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
+                     ph3->IsPIDOK(ipid,AliCaloPID::kPhoton) &&\r
+                     ph1->DistToBad()>=idist &&\r
+                     ph2->DistToBad()>=idist &&\r
+                     ph3->DistToBad()>=idist ){\r
+                    if(GetDebug() > 2) printf("MixC: index  %d  pt  %2.3f  mass   %2.3f \n", index, pi0gammapt, pi0gammamass);\r
+                    //fill histograms\r
+                    fMixCOmega0[index]->Fill(pi0gammapt,pi0gammamass);\r
+                    if(pi0asy<0.7) fMixCOmega1[index]->Fill(pi0gammapt,pi0gammamass);\r
+                    if(pi0asy<0.8) fMixCOmega2[index]->Fill(pi0gammapt,pi0gammamass);\r
+                    //printf("mix C  %d  %2.2f \n", index, pi0gammamass);\r
+                  }\r
+                }\r
+              }\r
+            }\r
+          }\r
+        } //for pi0 selecton           \r
+      }\r
+    }\r
+  }\r
+  \r
+  \r
+  //event buffer \r
+  TClonesArray *currentEvent = new TClonesArray(*aodGamma);\r
+  if(currentEvent->GetEntriesFast()>0){\r
+    fEventsList[curEventBin]->AddFirst(currentEvent) ;\r
+    currentEvent=0 ; \r
+    if(fEventsList[curEventBin]->GetSize()>=fNmaxMixEv) {\r
+      TClonesArray * tmp = (TClonesArray*) (fEventsList[curEventBin]->Last()) ;\r
+      fEventsList[curEventBin]->RemoveLast() ;\r
+      delete tmp ;\r
+    }\r
+  }\r
+  else{ \r
+    delete currentEvent ;\r
+    currentEvent=0 ;\r
+  }\r
+  \r
 }\r
 \r
 //______________________________________________________________________________\r
@@ -783,15 +789,16 @@ void AliAnaOmegaToPi0Gamma::Terminate(TList * outputList)
 // //Do some calculations and plots from the final histograms.\r
   if(GetDebug() >= 0) printf("AliAnaOmegaToPi0Gamma::Terminate() \n");\r
   ReadHistograms(outputList);\r
-  char cvs1[128];  \r
+  const Int_t buffersize = 255;\r
+  char cvs1[buffersize];  \r
   sprintf(cvs1, "Neutral_%s_IVM",fInputAODGammaName.Data());\r
 \r
   TCanvas * cvsIVM = new TCanvas(cvs1, cvs1, 400, 10, 600, 700) ;\r
   cvsIVM->Divide(2, 2);\r
 \r
   cvsIVM->cd(1);\r
-  char dec[128];\r
-  sprintf(dec,"h2Real_%s",fInputAODGammaName.Data());\r
+  char dec[buffersize];\r
+  snprintf(dec,buffersize,"h2Real_%s",fInputAODGammaName.Data());\r
   TH2F * h2Real= (TH2F*)fRealOmega0[0]->Clone(dec);\r
   h2Real->GetXaxis()->SetRangeUser(4,6);\r
   TH1F * hRealOmega = (TH1F*) h2Real->ProjectionY();\r
@@ -800,7 +807,7 @@ void AliAnaOmegaToPi0Gamma::Terminate(TList * outputList)
   hRealOmega->Draw();\r
 \r
   cvsIVM->cd(2);\r
-  sprintf(dec,"hMixA_%s",fInputAODGammaName.Data());\r
+  snprintf(dec,buffersize,"hMixA_%s",fInputAODGammaName.Data());\r
   TH2F *h2MixA= (TH2F*)fMixAOmega0[0]->Clone(dec);\r
   h2MixA->GetXaxis()->SetRangeUser(4,6);\r
   TH1F * hMixAOmega = (TH1F*) h2MixA->ProjectionY();\r
@@ -809,7 +816,7 @@ void AliAnaOmegaToPi0Gamma::Terminate(TList * outputList)
   hMixAOmega->Draw();\r
 \r
   cvsIVM->cd(3);\r
-  sprintf(dec,"hMixB_%s",fInputAODGammaName.Data());\r
+  snprintf(dec,buffersize,"hMixB_%s",fInputAODGammaName.Data());\r
   TH2F * h2MixB= (TH2F*)fMixBOmega0[0]->Clone(dec);\r
   h2MixB->GetXaxis()->SetRangeUser(4,6);\r
   TH1F * hMixBOmega = (TH1F*) h2MixB->ProjectionY();\r
@@ -818,7 +825,7 @@ void AliAnaOmegaToPi0Gamma::Terminate(TList * outputList)
   hMixBOmega->Draw();\r
 \r
   cvsIVM->cd(4);\r
-  sprintf(dec,"hMixC_%s",fInputAODGammaName.Data());\r
+  snprintf(dec,buffersize,"hMixC_%s",fInputAODGammaName.Data());\r
   TH2F *h2MixC= (TH2F*)fMixCOmega0[0]->Clone(dec);\r
   h2MixC->GetXaxis()->SetRangeUser(4,6);\r
   TH1F * hMixCOmega = (TH1F*) h2MixC->ProjectionY();\r
@@ -826,8 +833,8 @@ void AliAnaOmegaToPi0Gamma::Terminate(TList * outputList)
   hMixCOmega->SetLineColor(2);\r
   hMixCOmega->Draw();\r
 \r
-  char eps[128 ];\r
-  sprintf(eps,"CVS_%s_IVM.eps",fInputAODGammaName.Data());\r
+  char eps[buffersize];\r
+  snprintf(eps,buffersize,"CVS_%s_IVM.eps",fInputAODGammaName.Data());\r
   cvsIVM->Print(eps);\r
   cvsIVM->Modified();\r
  \r
index 5cca750..3f1cb36 100755 (executable)
 // 1. add the UE subtraction for corrlation study
 // 2. change the correlation variable
 // 3. Only use leading particle(cluster/track) as trigger for correlation (2010/07/02)
+// 4. Make decay photon-hadron correlations where decay contribute pi0 mass (2010/09/09)
 //////////////////////////////////////////////////////////////////////////////
 
 
 // --- ROOT system ---
-#include "TH2F.h"
-#include "TClonesArray.h"
+//#include "TClonesArray.h"
 #include "TClass.h"
 #include "TMath.h"
+#include "TH3D.h"
 
 //---- ANALYSIS system ----
 #include "AliNeutralMesonSelection.h" 
@@ -55,6 +56,7 @@ ClassImp(AliAnaParticleHadronCorrelation)
     AliAnaPartCorrBaseClass(),
     fDeltaPhiMaxCut(0.), fDeltaPhiMinCut(0.), fSelectIsolated(0),
     fMakeSeveralUE(0),  fUeDeltaPhiMaxCut(0.), fUeDeltaPhiMinCut(0.), 
+    fPi0AODBranchName(""),fPi0Trigger(0),
     fhPtLeading(0),fhPhiLeading(0),fhEtaLeading(0), 
     fhDeltaPhiDeltaEtaCharged(0),fhDeltaPhiDeltaEtaNeutral(0),
     fhPhiCharged(0), fhPhiNeutral(0), fhEtaCharged(0), fhEtaNeutral(0), 
@@ -71,112 +73,19 @@ ClassImp(AliAnaParticleHadronCorrelation)
     fhPtImbalanceUeLeftCharged(0),fhPtImbalanceUeRightCharged(0),
     fhPtImbalanceUeLeftNeutral(0),fhPtImbalanceUeRightNeutral(0),
     fhPtHbpUeLeftCharged(0),fhPtHbpUeRightCharged(0),
-    fhPtHbpUeLeftNeutral(0),fhPtHbpUeRightNeutral(0)
+    fhPtHbpUeLeftNeutral(0),fhPtHbpUeRightNeutral(0),
+    fhPtPi0DecayRatio(0),
+    fhDeltaPhiDecay1Charged(0),fhDeltaPhiDecay2Charged(0),
+    fhPtImbalanceDecay1Charged(0), fhPtImbalanceDecay2Charged(0),
+    fhDeltaPhiDecay1Neutral(0),fhDeltaPhiDecay2Neutral(0),
+    fhPtImbalanceDecay1Neutral(0), fhPtImbalanceDecay2Neutral(0)
 {
   //Default Ctor
   
   //Initialize parameters
   InitParameters();
 }
-/*
-//____________________________________________________________________________
-AliAnaParticleHadronCorrelation::AliAnaParticleHadronCorrelation(const AliAnaParticleHadronCorrelation & g):   
-  AliAnaPartCorrBaseClass(g),
-  fDeltaPhiMaxCut(g.fDeltaPhiMaxCut), fDeltaPhiMinCut(g.fDeltaPhiMinCut), 
-  fSelectIsolated(g.fSelectIsolated),
-  fMakeSeveralUE(g.fMakeSeveralUE),  fUeDeltaPhiMaxCut(g.fUeDeltaPhiMaxCut), 
-  fUeDeltaPhiMinCut(g.fUeDeltaPhiMinCut), 
-  fhPtLeading(g.fhPtLeading),fhPhiLeading(g.fhPhiLeading),fhEtaLeading(g.fhEtaLeading), 
-  fhDeltaPhiDeltaEtaCharged(g.fhDeltaPhiDeltaEtaCharged),fhDeltaPhiDeltaEtaNeutral(g.fhDeltaPhiDeltaEtaNeutral),
-  fhPhiCharged(g.fhPhiCharged), fhPhiNeutral(g.fhPhiNeutral), 
-  fhEtaCharged(g.fhEtaCharged), fhEtaNeutral(g.fhEtaNeutral), 
-  fhDeltaPhiCharged(g.fhDeltaPhiCharged),  
-  fhDeltaPhiNeutral(g.fhDeltaPhiNeutral), 
-  fhDeltaEtaCharged(g.fhDeltaEtaCharged), 
-  fhDeltaEtaNeutral(g.fhDeltaEtaNeutral), 
-  fhDeltaPhiChargedPt(g.fhDeltaPhiChargedPt),
-  fhDeltaPhiNeutralPt(g.fhDeltaPhiNeutralPt), 
-  fhDeltaPhiUeChargedPt(g.fhDeltaPhiUeChargedPt), 
-  fhDeltaPhiUeNeutralPt(g.fhDeltaPhiUeNeutralPt), 
-  fhPtImbalanceNeutral(g.fhPtImbalanceNeutral), 
-  fhPtImbalanceCharged(g.fhPtImbalanceCharged),
-  fhPtImbalanceUeCharged(g.fhPtImbalanceUeCharged),
-  fhPtImbalanceUeNeutral(g.fhPtImbalanceUeNeutral), 
-  fhPtHbpCharged(g.fhPtHbpCharged), 
-  fhPtHbpUeCharged(g.fhPtHbpUeCharged),
-  fhPtHbpNeutral(g.fhPtHbpNeutral), 
-  fhPtHbpUeNeutral(g.fhPtHbpUeNeutral),
-  fhDeltaPhiUeLeftCharged(g.fhDeltaPhiUeLeftCharged),
-  fhDeltaPhiUeRightCharged(g.fhDeltaPhiUeRightCharged),
-  fhDeltaPhiUeLeftNeutral(g.fhDeltaPhiUeLeftNeutral),
-  fhDeltaPhiUeRightNeutral(g.fhDeltaPhiUeRightNeutral),
-  fhPtImbalanceUeLeftCharged(g.fhPtImbalanceUeLeftCharged),
-  fhPtImbalanceUeRightCharged(g.fhPtImbalanceUeRightCharged),
-  fhPtImbalanceUeLeftNeutral(g.fhPtImbalanceUeLeftNeutral),
-  fhPtImbalanceUeRightNeutral(g.fhPtImbalanceUeRightNeutral),
-  fhPtHbpUeLeftCharged(g.fhPtHbpUeLeftCharged),
-  fhPtHbpUeRightCharged(g.fhPtHbpUeRightCharged),
-  fhPtHbpUeLeftNeutral(g.fhPtHbpUeLeftNeutral),
-  fhPtHbpUeRightNeutral(g.fhPtHbpUeRightNeutral)
-{
-  // cpy ctor
-  
-}
 
-//_________________________________________________________________________
-AliAnaParticleHadronCorrelation & AliAnaParticleHadronCorrelation::operator = (const AliAnaParticleHadronCorrelation & source)
-{
-  // assignment operator
-  
-  if(this == &source)return *this;
-  ((AliAnaPartCorrBaseClass *)this)->operator=(source);
-  
-  fDeltaPhiMaxCut = source.fDeltaPhiMaxCut ; 
-  fDeltaPhiMinCut = source.fDeltaPhiMinCut ; 
-  fSelectIsolated = source.fSelectIsolated ;
-  fMakeSeveralUE = source.fMakeSeveralUE ;
-  fUeDeltaPhiMaxCut = source.fUeDeltaPhiMaxCut ; 
-  fUeDeltaPhiMinCut = source.fUeDeltaPhiMinCut ;  
-  fhPtLeading = source.fhPtLeading;
-  fhPhiLeading = source.fhPhiLeading;
-  fhEtaLeading = source.fhEtaLeading;  
-  fhDeltaPhiDeltaEtaCharged = source.fhDeltaPhiDeltaEtaCharged ;
-  fhDeltaPhiDeltaEtaNeutral = source.fhDeltaPhiDeltaEtaNeutral ;  
-  fhPhiCharged = source.fhPhiCharged ; fhPhiNeutral = source.fhPhiNeutral ; 
-  fhEtaCharged = source.fhEtaCharged ; fhEtaNeutral = source.fhEtaNeutral ; 
-  fhDeltaPhiCharged = source.fhDeltaPhiCharged ;  
-  fhDeltaPhiNeutral = source.fhDeltaPhiNeutral ; 
-  fhDeltaEtaCharged = source.fhDeltaEtaCharged ; 
-  fhDeltaEtaNeutral = source.fhDeltaEtaNeutral ; 
-  fhDeltaPhiChargedPt = source.fhDeltaPhiChargedPt ;
-  fhDeltaPhiNeutralPt = source.fhDeltaPhiNeutralPt ; 
-  fhDeltaPhiUeChargedPt = source.fhDeltaPhiUeChargedPt ; 
-  fhDeltaPhiUeNeutralPt = source.fhDeltaPhiUeNeutralPt ; 
-  fhPtImbalanceNeutral = source.fhPtImbalanceNeutral ; 
-  fhPtImbalanceCharged = source.fhPtImbalanceCharged ; 
-  fhPtImbalanceUeCharged = source.fhPtImbalanceUeCharged ;
-  fhPtImbalanceUeNeutral = source.fhPtImbalanceUeNeutral ; 
-  fhPtHbpCharged = source.fhPtHbpCharged ;
-  fhPtHbpUeCharged = source.fhPtHbpUeCharged;
-  fhPtHbpNeutral = source.fhPtHbpNeutral ;
-  fhPtHbpUeNeutral = source.fhPtHbpUeNeutral;
-  fhDeltaPhiUeLeftCharged = source.fhDeltaPhiUeLeftCharged ;
-  fhDeltaPhiUeRightCharged = source.fhDeltaPhiUeRightCharged ;
-  fhDeltaPhiUeLeftNeutral = source.fhDeltaPhiUeLeftNeutral ;
-  fhDeltaPhiUeRightNeutral = source.fhDeltaPhiUeRightNeutral ;
-  fhPtImbalanceUeLeftCharged = source.fhPtImbalanceUeLeftCharged ;
-  fhPtImbalanceUeRightCharged = source.fhPtImbalanceUeRightCharged ;
-  fhPtImbalanceUeLeftNeutral = source.fhPtImbalanceUeLeftNeutral ;
-  fhPtImbalanceUeRightNeutral = source.fhPtImbalanceUeRightNeutral ;
-  fhPtHbpUeLeftCharged = source.fhPtHbpUeLeftCharged ;
-  fhPtHbpUeRightCharged = source.fhPtHbpUeRightCharged ;
-  fhPtHbpUeLeftNeutral = source.fhPtHbpUeLeftNeutral ;
-  fhPtHbpUeRightNeutral = source.fhPtHbpUeRightNeutral ;
-       
-  return *this;
-
-}
-*/
 //________________________________________________________________________
 TList *  AliAnaParticleHadronCorrelation::GetCreateOutputObjects()
 {  
@@ -195,7 +104,7 @@ TList *  AliAnaParticleHadronCorrelation::GetCreateOutputObjects()
   Float_t ptmin  = GetHistoPtMin();
   Float_t phimin = GetHistoPhiMin();
   Float_t etamin = GetHistoEtaMin();   
-
+  
   fhPtLeading  = new TH1F ("hPtLeading","p_T distribution of leading particles", nptbins,ptmin,ptmax); 
   fhPtLeading->SetXTitle("p_{T}^{trig} (GeV/c)");
   
@@ -211,68 +120,68 @@ TList *  AliAnaParticleHadronCorrelation::GetCreateOutputObjects()
   //Correlation with charged hadrons
   if(GetReader()->IsCTSSwitchedOn()) {
     fhDeltaPhiDeltaEtaCharged  = new TH2F
-      ("DeltaPhiDeltaEtaCharged","#phi_{trigger} - #phi_{h^{#pm}} vs #eta_{trigger} - #eta_{h^{#pm}}",
-       140,-2.,5.,200,-2,2); 
+    ("DeltaPhiDeltaEtaCharged","#phi_{trigger} - #phi_{h^{#pm}} vs #eta_{trigger} - #eta_{h^{#pm}}",
+     140,-2.,5.,200,-2,2); 
     fhDeltaPhiDeltaEtaCharged->SetXTitle("#Delta #phi");
     fhDeltaPhiDeltaEtaCharged->SetYTitle("#Delta #eta");    
     
     fhPhiCharged  = new TH2F
-      ("PhiCharged","#phi_{h^{#pm}}  vs p_{T #pm}",
-       nptbins,ptmin,ptmax,nphibins,phimin,phimax); 
+    ("PhiCharged","#phi_{h^{#pm}}  vs p_{T #pm}",
+     nptbins,ptmin,ptmax,nphibins,phimin,phimax); 
     fhPhiCharged->SetYTitle("#phi_{h^{#pm}} (rad)");
     fhPhiCharged->SetXTitle("p_{T #pm} (GeV/c)");
     
     fhEtaCharged  = new TH2F
-      ("EtaCharged","#eta_{h^{#pm}}  vs p_{T #pm}",
-       nptbins,ptmin,ptmax,netabins,etamin,etamax); 
+    ("EtaCharged","#eta_{h^{#pm}}  vs p_{T #pm}",
+     nptbins,ptmin,ptmax,netabins,etamin,etamax); 
     fhEtaCharged->SetYTitle("#eta_{h^{#pm}} (rad)");
     fhEtaCharged->SetXTitle("p_{T #pm} (GeV/c)");
     
     fhDeltaPhiCharged  = new TH2F
-      ("DeltaPhiCharged","#phi_{trigger} - #phi_{h^{#pm}} vs p_{T trigger}",
-       nptbins,ptmin,ptmax,140,-2.,5.); 
+    ("DeltaPhiCharged","#phi_{trigger} - #phi_{h^{#pm}} vs p_{T trigger}",
+     nptbins,ptmin,ptmax,140,-2.,5.); 
     fhDeltaPhiCharged->SetYTitle("#Delta #phi");
     fhDeltaPhiCharged->SetXTitle("p_{T trigger} (GeV/c)");
     
     fhDeltaPhiChargedPt  = new TH2F
-      ("DeltaPhiChargedPt","#phi_{trigger} - #phi_{#h^{#pm}} vs p_{T h^{#pm}}",
-       nptbins,ptmin,ptmax,140,-2.,5.);
+    ("DeltaPhiChargedPt","#phi_{trigger} - #phi_{#h^{#pm}} vs p_{T h^{#pm}}",
+     nptbins,ptmin,ptmax,140,-2.,5.);
     fhDeltaPhiChargedPt->SetYTitle("#Delta #phi");
     fhDeltaPhiChargedPt->SetXTitle("p_{T h^{#pm}} (GeV/c)");
-
+    
     fhDeltaPhiUeChargedPt  = new TH2F
-      ("DeltaPhiUeChargedPt","#phi_{trigger} - #phi_{#Ueh^{#pm}} vs p_{T Ueh^{#pm}}",
-       nptbins,ptmin,ptmax,140,-2.,5.);
+    ("DeltaPhiUeChargedPt","#phi_{trigger} - #phi_{#Ueh^{#pm}} vs p_{T Ueh^{#pm}}",
+     nptbins,ptmin,ptmax,140,-2.,5.);
     fhDeltaPhiUeChargedPt->SetYTitle("#Delta #phi");
     fhDeltaPhiUeChargedPt->SetXTitle("p_{T h^{#pm}} (GeV/c)");
     
     fhDeltaEtaCharged  = new TH2F
-      ("DeltaEtaCharged","#eta_{trigger} - #eta_{h^{#pm}} vs p_{T trigger}",
-       nptbins,ptmin,ptmax,200,-2,2); 
+    ("DeltaEtaCharged","#eta_{trigger} - #eta_{h^{#pm}} vs p_{T trigger}",
+     nptbins,ptmin,ptmax,200,-2,2); 
     fhDeltaEtaCharged->SetYTitle("#Delta #eta");
     fhDeltaEtaCharged->SetXTitle("p_{T trigger} (GeV/c)");
     
     fhPtImbalanceCharged  = 
-      new TH2F("CorrelationCharged","z_{trigger h^{#pm}} = p_{T h^{#pm}} / p_{T trigger}",
-              nptbins,ptmin,ptmax,200,0.,2.); 
+    new TH2F("CorrelationCharged","z_{trigger h^{#pm}} = p_{T h^{#pm}} / p_{T trigger}",
+             nptbins,ptmin,ptmax,200,0.,2.); 
     fhPtImbalanceCharged->SetYTitle("z_{trigger h^{#pm}}");
     fhPtImbalanceCharged->SetXTitle("p_{T trigger}");
     
     fhPtImbalanceUeCharged  = 
-      new TH2F("CorrelationUeCharged","z_{trigger h^{#pm}} = p_{T Ueh^{#pm}} / p_{T trigger}",
-              nptbins,ptmin,ptmax,200,0.,2.); 
+    new TH2F("CorrelationUeCharged","z_{trigger h^{#pm}} = p_{T Ueh^{#pm}} / p_{T trigger}",
+             nptbins,ptmin,ptmax,200,0.,2.); 
     fhPtImbalanceUeCharged->SetYTitle("z_{trigger Ueh^{#pm}}");
     fhPtImbalanceUeCharged->SetXTitle("p_{T trigger}");
-
-   fhPtHbpCharged  = 
-      new TH2F("HbpCharged","#xi = ln(1/x_{E}) with charged hadrons",
-              nptbins,ptmin,ptmax,200,0.,10.); 
+    
+    fhPtHbpCharged  = 
+    new TH2F("HbpCharged","#xi = ln(1/x_{E}) with charged hadrons",
+             nptbins,ptmin,ptmax,200,0.,10.); 
     fhPtHbpCharged->SetYTitle("ln(1/x_{E})");
     fhPtHbpCharged->SetXTitle("p_{T trigger}");
     
     fhPtHbpUeCharged  = 
-      new TH2F("HbpUeCharged","#xi = ln(1/x_{E}) with charged hadrons",
-              nptbins,ptmin,ptmax,200,0.,10.); 
+    new TH2F("HbpUeCharged","#xi = ln(1/x_{E}) with charged hadrons",
+             nptbins,ptmin,ptmax,200,0.,10.); 
     fhPtHbpUeCharged->SetYTitle("ln(1/x_{E})");
     fhPtHbpUeCharged->SetXTitle("p_{T trigger}");
          
@@ -287,49 +196,89 @@ TList *  AliAnaParticleHadronCorrelation::GetCreateOutputObjects()
     outputContainer->Add(fhPtImbalanceUeCharged) ;
     outputContainer->Add(fhPtHbpCharged) ;
     outputContainer->Add(fhPtHbpUeCharged) ;
+    
+    if(fPi0Trigger){
+      fhPtPi0DecayRatio  = new TH3D
+      ("hPtPi0DecayRatio","p_T of #pi^{0} and the ratio of pt for two decay", 
+       nptbins,ptmin,ptmax, 100,0.,2.,100,0., 2.); 
+      fhPtPi0DecayRatio->SetXTitle("p_{T}^{#pi^{0}} (GeV/c)");
+      fhPtPi0DecayRatio->SetYTitle("p_{T}^{Decay1}/p_{T}^{#pi^{0}}");
+      fhPtPi0DecayRatio->SetZTitle("p_{T}^{Decay2}/p_{T}^{#pi^{0}}");
+      
+      fhDeltaPhiDecay1Charged  = new TH2F
+      ("DeltaPhiDecay1Charged","#phi_{Decay} - #phi_{h^{#pm}} vs p_{T Decay}",
+       nptbins,ptmin,ptmax,140,-2.,5.); 
+      fhDeltaPhiDecay1Charged->SetYTitle("#Delta #phi");
+      fhDeltaPhiDecay1Charged->SetXTitle("p_{T Decay} (GeV/c)");
+      
+      fhDeltaPhiDecay2Charged  = new TH2F
+      ("DeltaPhiDecay2Charged","#phi_{Decay} - #phi_{h^{#pm}} vs p_{T Decay}",
+       nptbins,ptmin,ptmax,140,-2.,5.); 
+      fhDeltaPhiDecay2Charged->SetYTitle("#Delta #phi");
+      fhDeltaPhiDecay2Charged->SetXTitle("p_{T Decay} (GeV/c)");
+      
+      fhPtImbalanceDecay1Charged  = 
+      new TH2F("CorrelationDecay1Charged","z_{trigger h^{#pm}} = p_{T h^{#pm}} / p_{T Decay}",
+               nptbins,ptmin,ptmax,200,0.,2.); 
+      fhPtImbalanceDecay1Charged->SetYTitle("z_{decay h^{#pm}}");
+      fhPtImbalanceDecay1Charged->SetXTitle("p_{T decay}");
+      
+      fhPtImbalanceDecay2Charged  = 
+      new TH2F("CorrelationDecay2Charged","z_{trigger h^{#pm}} = p_{T h^{#pm}} / p_{T Decay}",
+               nptbins,ptmin,ptmax,200,0.,2.); 
+      fhPtImbalanceDecay2Charged->SetYTitle("z_{decay h^{#pm}}");
+      fhPtImbalanceDecay2Charged->SetXTitle("p_{T decay}");
+      outputContainer->Add(fhPtPi0DecayRatio) ; 
+      outputContainer->Add(fhDeltaPhiDecay1Charged) ; 
+      outputContainer->Add(fhDeltaPhiDecay2Charged) ; 
+      outputContainer->Add(fhPtImbalanceDecay1Charged) ;
+      outputContainer->Add(fhPtImbalanceDecay2Charged) ;
+    }    
+    
+    
     if(fMakeSeveralUE){ 
       fhDeltaPhiUeLeftCharged  = new TH2F
-       ("DeltaPhiUeLeftChargedPt","#phi_{trigger} - #phi_{#Ueh^{#pm}} vs p_{T Ueh^{#pm}} with UE left side range of trigger particles",
-        nptbins,ptmin,ptmax,140,-2.,5.);
+      ("DeltaPhiUeLeftChargedPt","#phi_{trigger} - #phi_{#Ueh^{#pm}} vs p_{T Ueh^{#pm}} with UE left side range of trigger particles",
+       nptbins,ptmin,ptmax,140,-2.,5.);
       fhDeltaPhiUeLeftCharged->SetYTitle("#Delta #phi");
       fhDeltaPhiUeLeftCharged->SetXTitle("p_{T h^{#pm}} (GeV/c)");
       outputContainer->Add(fhDeltaPhiUeLeftCharged) ;
-
+      
       fhDeltaPhiUeRightCharged  = new TH2F
-       ("DeltaPhiUeRightChargedPt","#phi_{trigger} - #phi_{#Ueh^{#pm}} vs p_{T Ueh^{#pm}} with UE right side range of trigger particles",
-        nptbins,ptmin,ptmax,140,-2.,5.);
+      ("DeltaPhiUeRightChargedPt","#phi_{trigger} - #phi_{#Ueh^{#pm}} vs p_{T Ueh^{#pm}} with UE right side range of trigger particles",
+       nptbins,ptmin,ptmax,140,-2.,5.);
       fhDeltaPhiUeRightCharged->SetYTitle("#Delta #phi");
       fhDeltaPhiUeRightCharged->SetXTitle("p_{T h^{#pm}} (GeV/c)");
       outputContainer->Add(fhDeltaPhiUeRightCharged) ;
       
       fhPtImbalanceUeLeftCharged  = 
-       new TH2F("CorrelationUeChargedLeft","z_{trigger h^{#pm}} = p_{T Ueh^{#pm}} / p_{T trigger} with UE left side of trigger",
-                nptbins,ptmin,ptmax,200,0.,2.); 
+      new TH2F("CorrelationUeChargedLeft","z_{trigger h^{#pm}} = p_{T Ueh^{#pm}} / p_{T trigger} with UE left side of trigger",
+               nptbins,ptmin,ptmax,200,0.,2.); 
       fhPtImbalanceUeLeftCharged->SetYTitle("z_{trigger Ueh^{#pm}}");
       fhPtImbalanceUeLeftCharged->SetXTitle("p_{T trigger}");
       outputContainer->Add(fhPtImbalanceUeLeftCharged) ;
       
       fhPtImbalanceUeRightCharged  = 
-       new TH2F("CorrelationUeChargedRight","z_{trigger h^{#pm}} = p_{T Ueh^{#pm}} / p_{T trigger} with UE right side of trigger",
-                nptbins,ptmin,ptmax,200,0.,2.); 
+      new TH2F("CorrelationUeChargedRight","z_{trigger h^{#pm}} = p_{T Ueh^{#pm}} / p_{T trigger} with UE right side of trigger",
+               nptbins,ptmin,ptmax,200,0.,2.); 
       fhPtImbalanceUeRightCharged->SetYTitle("z_{trigger Ueh^{#pm}}");
       fhPtImbalanceUeRightCharged->SetXTitle("p_{T trigger}");
       outputContainer->Add(fhPtImbalanceUeRightCharged) ;
-               
-               fhPtHbpUeLeftCharged  = 
-               new TH2F("HbpUeChargedLeft","#xi = ln(1/x_{E}) with charged UE left side of trigger",
-                                nptbins,ptmin,ptmax,200,0.,10.); 
-               fhPtHbpUeLeftCharged->SetYTitle("ln(1/x_{E})");
-               fhPtHbpUeLeftCharged->SetXTitle("p_{T trigger}");
-               outputContainer->Add(fhPtHbpUeLeftCharged) ;
-               
-               fhPtHbpUeRightCharged  = 
-               new TH2F("HbpUeChargedRight","#xi = ln(1/x_{E}) with charged UE right side of trigger",
-                                nptbins,ptmin,ptmax,200,0.,10.); 
-               fhPtHbpUeRightCharged->SetYTitle("ln(1/x_{E})");
-               fhPtHbpUeRightCharged->SetXTitle("p_{T trigger}");
-               outputContainer->Add(fhPtHbpUeRightCharged) ;
-               
+      
+      fhPtHbpUeLeftCharged  = 
+      new TH2F("HbpUeChargedLeft","#xi = ln(1/x_{E}) with charged UE left side of trigger",
+               nptbins,ptmin,ptmax,200,0.,10.); 
+      fhPtHbpUeLeftCharged->SetYTitle("ln(1/x_{E})");
+      fhPtHbpUeLeftCharged->SetXTitle("p_{T trigger}");
+      outputContainer->Add(fhPtHbpUeLeftCharged) ;
+      
+      fhPtHbpUeRightCharged  = 
+      new TH2F("HbpUeChargedRight","#xi = ln(1/x_{E}) with charged UE right side of trigger",
+               nptbins,ptmin,ptmax,200,0.,10.); 
+      fhPtHbpUeRightCharged->SetYTitle("ln(1/x_{E})");
+      fhPtHbpUeRightCharged->SetXTitle("p_{T trigger}");
+      outputContainer->Add(fhPtHbpUeRightCharged) ;
+      
     }  
   }  //Correlation with charged hadrons
   
@@ -337,68 +286,68 @@ TList *  AliAnaParticleHadronCorrelation::GetCreateOutputObjects()
   if(GetReader()->IsEMCALSwitchedOn() || GetReader()->IsPHOSSwitchedOn()){
     
     fhDeltaPhiDeltaEtaNeutral  = new TH2F
-      ("DeltaPhiDeltaEtaNeutral","#phi_{trigger} - #phi_{h^{0}} vs #eta_{trigger} - #eta_{h^{0}}",
-       140,-2.,5.,200,-2,2); 
+    ("DeltaPhiDeltaEtaNeutral","#phi_{trigger} - #phi_{h^{0}} vs #eta_{trigger} - #eta_{h^{0}}",
+     140,-2.,5.,200,-2,2); 
     fhDeltaPhiDeltaEtaNeutral->SetXTitle("#Delta #phi");
     fhDeltaPhiDeltaEtaNeutral->SetYTitle("#Delta #eta");   
          
     fhPhiNeutral  = new TH2F
-      ("PhiNeutral","#phi_{#pi^{0}}  vs p_{T #pi^{0}}",
-       nptbins,ptmin,ptmax,nphibins,phimin,phimax); 
+    ("PhiNeutral","#phi_{#pi^{0}}  vs p_{T #pi^{0}}",
+     nptbins,ptmin,ptmax,nphibins,phimin,phimax); 
     fhPhiNeutral->SetYTitle("#phi_{#pi^{0}} (rad)");
     fhPhiNeutral->SetXTitle("p_{T #pi^{0}} (GeV/c)");
     
     fhEtaNeutral  = new TH2F
-      ("EtaNeutral","#eta_{#pi^{0}}  vs p_{T #pi^{0}}",
-       nptbins,ptmin,ptmax,netabins,etamin,etamax); 
+    ("EtaNeutral","#eta_{#pi^{0}}  vs p_{T #pi^{0}}",
+     nptbins,ptmin,ptmax,netabins,etamin,etamax); 
     fhEtaNeutral->SetYTitle("#eta_{#pi^{0}} (rad)");
     fhEtaNeutral->SetXTitle("p_{T #pi^{0}} (GeV/c)");
     
     fhDeltaPhiNeutral  = new TH2F
-      ("DeltaPhiNeutral","#phi_{trigger} - #phi_{#pi^{0}} vs p_{T trigger}",
-       nptbins,ptmin,ptmax,nphibins,phimin,phimax); 
+    ("DeltaPhiNeutral","#phi_{trigger} - #phi_{#pi^{0}} vs p_{T trigger}",
+     nptbins,ptmin,ptmax,nphibins,phimin,phimax); 
     fhDeltaPhiNeutral->SetYTitle("#Delta #phi");
     fhDeltaPhiNeutral->SetXTitle("p_{T trigger} (GeV/c)");
     
     fhDeltaPhiNeutralPt  = new TH2F
-      ("DeltaPhiNeutralPt","#phi_{trigger} - #phi_{#pi^{0}} vs p_{T #pi^{0}}}",
-       nptbins,ptmin,ptmax,140,-2.,5.); 
+    ("DeltaPhiNeutralPt","#phi_{trigger} - #phi_{#pi^{0}} vs p_{T #pi^{0}}}",
+     nptbins,ptmin,ptmax,140,-2.,5.); 
     fhDeltaPhiNeutralPt->SetYTitle("#Delta #phi");
     fhDeltaPhiNeutralPt->SetXTitle("p_{T h^{0}} (GeV/c)");
-
+    
     fhDeltaPhiUeNeutralPt  = new TH2F
-      ("DeltaPhiUeNeutralPt","#phi_{trigger} - #phi_{#pi^{0}} vs p_{T #pi^{0}}}",
-       nptbins,ptmin,ptmax,140,-2.,5.); 
+    ("DeltaPhiUeNeutralPt","#phi_{trigger} - #phi_{#pi^{0}} vs p_{T #pi^{0}}}",
+     nptbins,ptmin,ptmax,140,-2.,5.); 
     fhDeltaPhiUeNeutralPt->SetYTitle("#Delta #phi");
     fhDeltaPhiUeNeutralPt->SetXTitle("p_{T h^{0}} (GeV/c)");
     
     fhDeltaEtaNeutral  = new TH2F
-      ("DeltaEtaNeutral","#eta_{trigger} - #eta_{#pi^{0}} vs p_{T trigger}",
-       nptbins,ptmin,ptmax,200,-2,2); 
+    ("DeltaEtaNeutral","#eta_{trigger} - #eta_{#pi^{0}} vs p_{T trigger}",
+     nptbins,ptmin,ptmax,200,-2,2); 
     fhDeltaEtaNeutral->SetYTitle("#Delta #eta");
     fhDeltaEtaNeutral->SetXTitle("p_{T trigger} (GeV/c)");
     
     fhPtImbalanceNeutral  = 
-      new TH2F("CorrelationNeutral","z_{trigger #pi} = p_{T #pi^{0}} / p_{T trigger}",
-              nptbins,ptmin,ptmax,200,0.,2.); 
+    new TH2F("CorrelationNeutral","z_{trigger #pi} = p_{T #pi^{0}} / p_{T trigger}",
+             nptbins,ptmin,ptmax,200,0.,2.); 
     fhPtImbalanceNeutral->SetYTitle("z_{trigger #pi^{0}}");
     fhPtImbalanceNeutral->SetXTitle("p_{T trigger}");
+    
     fhPtImbalanceUeNeutral  = 
-      new TH2F("CorrelationUeNeutral","z_{trigger #pi} = p_{T #pi^{0}} / p_{T trigger}",
-              nptbins,ptmin,ptmax,200,0.,2.); 
+    new TH2F("CorrelationUeNeutral","z_{trigger #pi} = p_{T #pi^{0}} / p_{T trigger}",
+             nptbins,ptmin,ptmax,200,0.,2.); 
     fhPtImbalanceUeNeutral->SetYTitle("z_{trigger #pi^{0}}");
     fhPtImbalanceUeNeutral->SetXTitle("p_{T trigger}");
     
     fhPtHbpNeutral  = 
-      new TH2F("HbpNeutral","#xi = ln(1/x_{E}) with neutral particles",
-              nptbins,ptmin,ptmax,200,0.,10.); 
+    new TH2F("HbpNeutral","#xi = ln(1/x_{E}) with neutral particles",
+             nptbins,ptmin,ptmax,200,0.,10.); 
     fhPtHbpNeutral->SetYTitle("ln(1/x_{E})");
     fhPtHbpNeutral->SetXTitle("p_{T trigger}");
     
     fhPtHbpUeNeutral  = 
-      new TH2F("HbpUeNeutral","#xi = ln(1/x_{E}) with neutral particles",
-              nptbins,ptmin,ptmax,200,0.,10.); 
+    new TH2F("HbpUeNeutral","#xi = ln(1/x_{E}) with neutral particles",
+             nptbins,ptmin,ptmax,200,0.,10.); 
     fhPtHbpUeNeutral->SetYTitle("ln(1/x_{E})");
     fhPtHbpUeNeutral->SetXTitle("p_{T trigger}");
     
@@ -414,65 +363,97 @@ TList *  AliAnaParticleHadronCorrelation::GetCreateOutputObjects()
     outputContainer->Add(fhPtImbalanceUeNeutral) ;  
     outputContainer->Add(fhPtHbpNeutral) ;
     outputContainer->Add(fhPtHbpUeNeutral) ;    
+    
+    if(fPi0Trigger){
+      fhDeltaPhiDecay1Neutral  = new TH2F
+      ("DeltaPhiDecay1Neutral","#phi_{Decay} - #phi_{h^{0}} vs p_{T Decay}",
+       nptbins,ptmin,ptmax,140,-2.,5.); 
+      fhDeltaPhiDecay1Neutral->SetYTitle("#Delta #phi");
+      fhDeltaPhiDecay1Neutral->SetXTitle("p_{T Decay} (GeV/c)");
+      
+      fhDeltaPhiDecay2Neutral  = new TH2F
+      ("DeltaPhiDecay2Neutral","#phi_{Decay} - #phi_{h^{0}} vs p_{T Decay}",
+       nptbins,ptmin,ptmax,140,-2.,5.); 
+      fhDeltaPhiDecay2Neutral->SetYTitle("#Delta #phi");
+      fhDeltaPhiDecay2Neutral->SetXTitle("p_{T Decay} (GeV/c)");
+      
+      fhPtImbalanceDecay1Neutral  = 
+      new TH2F("CorrelationDecay1Neutral","z_{trigger h^{0}} = p_{T h^{0}} / p_{T Decay}",
+               nptbins,ptmin,ptmax,200,0.,2.); 
+      fhPtImbalanceDecay1Neutral->SetYTitle("z_{decay h^{0}}");
+      fhPtImbalanceDecay1Neutral->SetXTitle("p_{T decay}");
+      
+      fhPtImbalanceDecay2Neutral  = 
+      new TH2F("CorrelationDecay2Neutral","z_{trigger h^{0}} = p_{T h^{0}} / p_{T Decay}",
+               nptbins,ptmin,ptmax,200,0.,2.); 
+      fhPtImbalanceDecay2Neutral->SetYTitle("z_{decay h^{0}}");
+      fhPtImbalanceDecay2Neutral->SetXTitle("p_{T decay}");
+      
+      outputContainer->Add(fhDeltaPhiDecay1Neutral) ; 
+      outputContainer->Add(fhDeltaPhiDecay2Neutral) ; 
+      outputContainer->Add(fhPtImbalanceDecay1Neutral) ;
+      outputContainer->Add(fhPtImbalanceDecay2Neutral) ;
+    }
+    
+    
     if(fMakeSeveralUE){ 
       fhDeltaPhiUeLeftNeutral  = new TH2F
-       ("DeltaPhiUeLeftNeutralPt","#phi_{trigger} - #phi_{#Ueh^{0}} vs p_{T h^{0}} with neutral UE left side range of trigger particles",
-        nptbins,ptmin,ptmax,140,-2.,5.);
+      ("DeltaPhiUeLeftNeutralPt","#phi_{trigger} - #phi_{#Ueh^{0}} vs p_{T h^{0}} with neutral UE left side range of trigger particles",
+       nptbins,ptmin,ptmax,140,-2.,5.);
       fhDeltaPhiUeLeftNeutral->SetYTitle("#Delta #phi");
       fhDeltaPhiUeLeftNeutral->SetXTitle("p_{T h^{0}} (GeV/c)");
       outputContainer->Add(fhDeltaPhiUeLeftNeutral) ;
-
+      
       fhDeltaPhiUeRightNeutral  = new TH2F
-       ("DeltaPhiUeRightNeutralPt","#phi_{trigger} - #phi_{#Ueh^{0}} vs p_{T Ueh^{0}} with neutral UE right side range of trigger particles",
-        nptbins,ptmin,ptmax,140,-2.,5.);
+      ("DeltaPhiUeRightNeutralPt","#phi_{trigger} - #phi_{#Ueh^{0}} vs p_{T Ueh^{0}} with neutral UE right side range of trigger particles",
+       nptbins,ptmin,ptmax,140,-2.,5.);
       fhDeltaPhiUeRightNeutral->SetYTitle("#Delta #phi");
       fhDeltaPhiUeRightNeutral->SetXTitle("p_{T h^{0}} (GeV/c)");
       outputContainer->Add(fhDeltaPhiUeRightNeutral) ;
       
       fhPtImbalanceUeLeftNeutral  = 
-       new TH2F("CorrelationUeNeutralLeft","z_{trigger h^{0}} = p_{T Ueh^{0}} / p_{T trigger} with neutral UE left side of trigger",
-                nptbins,ptmin,ptmax,140,0.,2.); 
+      new TH2F("CorrelationUeNeutralLeft","z_{trigger h^{0}} = p_{T Ueh^{0}} / p_{T trigger} with neutral UE left side of trigger",
+               nptbins,ptmin,ptmax,140,0.,2.); 
       fhPtImbalanceUeLeftNeutral->SetYTitle("z_{trigger Ueh^{0}}");
       fhPtImbalanceUeLeftNeutral->SetXTitle("p_{T trigger}");
       outputContainer->Add(fhPtImbalanceUeLeftNeutral) ;
       
       fhPtImbalanceUeRightNeutral  = 
-       new TH2F("CorrelationUeNeutralRight","z_{trigger h^{0}} = p_{T Ueh^{0}} / p_{T trigger} with neutral UE right side of trigger",
-                nptbins,ptmin,ptmax,200,0.,2.); 
+      new TH2F("CorrelationUeNeutralRight","z_{trigger h^{0}} = p_{T Ueh^{0}} / p_{T trigger} with neutral UE right side of trigger",
+               nptbins,ptmin,ptmax,200,0.,2.); 
       fhPtImbalanceUeRightNeutral->SetYTitle("z_{trigger Ueh^{0}}");
       fhPtImbalanceUeRightNeutral->SetXTitle("p_{T trigger}");
       outputContainer->Add(fhPtImbalanceUeRightNeutral) ;
-               
+      
       fhPtHbpUeLeftNeutral  = 
-       new TH2F("HbpUeNeutralLeft","#xi = ln(1/x_{E}) with neutral UE left side of trigger",
-                nptbins,ptmin,ptmax,200,0.,10.); 
+      new TH2F("HbpUeNeutralLeft","#xi = ln(1/x_{E}) with neutral UE left side of trigger",
+               nptbins,ptmin,ptmax,200,0.,10.); 
       fhPtHbpUeLeftNeutral->SetYTitle("ln(1/x_{E})");
       fhPtHbpUeLeftNeutral->SetXTitle("p_{T trigger}");
       outputContainer->Add(fhPtHbpUeLeftNeutral) ;
       
       fhPtHbpUeRightNeutral  = 
-       new TH2F("HbpUeNeutralRight","#xi = ln(1/x_{E}) with neutral UE right side of trigger",
-                nptbins,ptmin,ptmax,200,0.,10.); 
+      new TH2F("HbpUeNeutralRight","#xi = ln(1/x_{E}) with neutral UE right side of trigger",
+               nptbins,ptmin,ptmax,200,0.,10.); 
       fhPtHbpUeRightNeutral->SetYTitle("ln(1/x_{E})");
       fhPtHbpUeRightNeutral->SetXTitle("p_{T trigger}");
       outputContainer->Add(fhPtHbpUeRightNeutral) ;
       
     }  
-   
+    
     //Keep neutral meson selection histograms if requiered
     //Setting done in AliNeutralMesonSelection
     if(GetNeutralMesonSelection()){
       TList * nmsHistos = GetNeutralMesonSelection()->GetCreateOutputObjects() ;
       if(GetNeutralMesonSelection()->AreNeutralMesonSelectionHistosKept())
-       for(Int_t i = 0; i < nmsHistos->GetEntries(); i++) outputContainer->Add(nmsHistos->At(i)) ;
-         delete nmsHistos;
+        for(Int_t i = 0; i < nmsHistos->GetEntries(); i++) outputContainer->Add(nmsHistos->At(i)) ;
+      delete nmsHistos;
     }
-       
+    
   }//Correlation with neutral hadrons
   
   return outputContainer;
-
+  
 }
 
 //____________________________________________________________________________
@@ -484,10 +465,6 @@ void AliAnaParticleHadronCorrelation::InitParameters()
   SetAODObjArrayName("Hadrons");  
   AddToHistogramsName("AnaHadronCorr_");
 
-  //Correlation with neutrals
-  //SetOutputAODClassName("AliAODPWG4Particle");
-  //SetOutputAODName("Pi0Correlated");
-       
   SetPtCutRange(0.,300);
   fDeltaPhiMinCut = 1.5 ;
   fDeltaPhiMaxCut = 4.5 ;
@@ -495,6 +472,8 @@ void AliAnaParticleHadronCorrelation::InitParameters()
   fMakeSeveralUE = kFALSE;
   fUeDeltaPhiMinCut = 1. ;
   fUeDeltaPhiMaxCut = 1.5 ;
+  fPi0Trigger = kFALSE ;
+
 }
 
 //__________________________________________________________________
@@ -514,12 +493,57 @@ void AliAnaParticleHadronCorrelation::Print(const Option_t * opt) const
   printf("Phi trigger particle-UeHadron    <    %3.2f\n", fUeDeltaPhiMaxCut) ; 
   printf("Phi trigger particle-UeHadron    >    %3.2f\n", fUeDeltaPhiMinCut) ;
   printf("Several UE?  %d\n", fMakeSeveralUE) ;
+  printf("Name of AOD Pi0 Branch %s \n",fPi0AODBranchName.Data());
+  printf("Do Decay-hadron correlation ?  %d\n", fPi0Trigger) ;
+
+  
+} 
+
+//__________________________________________________________________
+TObjString* AliAnaParticleHadronCorrelation::GetAnalysisCuts()
+{
+  //Save parameters used for analysis
+  TString parList ; //this will be list of parameters used for this analysis.
+  const Int_t buffersize = 255;
+  char onePar[buffersize] ;
+  snprintf(onePar,buffersize,"--- AliAnaPaticleHadronCorrelation ---\n") ;
+  parList+=onePar ;    
+  snprintf(onePar,buffersize,"Phi trigger particle-Hadron      <     %3.2f ", fDeltaPhiMaxCut) ; 
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"Phi trigger particle-Hadron      >     %3.2f ", fDeltaPhiMinCut) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"Isolated Trigger?  %d\n", fSelectIsolated) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"Phi trigger particle-UeHadron    <    %3.2f ", fUeDeltaPhiMaxCut) ; 
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"Phi trigger particle-UeHadron    >    %3.2f ", fUeDeltaPhiMinCut) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"Several UE?  %d\n", fMakeSeveralUE) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"Name of AOD Pi0 Branch %s ",fPi0AODBranchName.Data());
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"Do Decay-hadron correlation ?  %d", fPi0Trigger) ;
+  parList+=onePar ;
+
+  //Get parameters set in base class.
+  parList += GetBaseParametersList() ;
+  
+  //Get parameters set in PID class.
+  //parList += GetCaloPID()->GetPIDParametersList() ;
+  
+  //Get parameters set in FiducialCut class (not available yet)
+  //parlist += GetFidCut()->GetFidCutParametersList() 
+  
+  return new TObjString(parList) ;  
+
 } 
 
+
 //____________________________________________________________________________
 void  AliAnaParticleHadronCorrelation::MakeAnalysisFillAOD()  
 {  
-    //Particle-Hadron Correlation Analysis, fill AODs
+  //Particle-Hadron Correlation Analysis, fill AODs
   
   if(!GetInputAODBranch()){
     printf("AliAnaParticleHadronCorrelation::MakeAnalysisFillAOD() - No input particles in AOD with name branch < %s >, STOP \n",GetInputAODName().Data());
@@ -539,42 +563,30 @@ void  AliAnaParticleHadronCorrelation::MakeAnalysisFillAOD()
     printf("AliAnaParticleHadronCorrelation::MakeAnalysisFillAOD() - In PHOS aod entries %d\n", GetAODPHOS()->GetEntriesFast());
   }
   
-    //Loop on stored AOD particles, trigger
+  //Loop on stored AOD particles, trigger
   Double_t ptTrig    = 0.;
   Int_t    trigIndex = -1;
   Int_t naod = GetInputAODBranch()->GetEntriesFast();
   for(Int_t iaod = 0; iaod < naod ; iaod++){
     AliAODPWG4ParticleCorrelation* particle =  (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(iaod));
-      //find the leading particles with highest momentum
+    //find the leading particles with highest momentum
     if (particle->Pt()>ptTrig) {
       ptTrig = particle->Pt() ;
       trigIndex = iaod ;
     }
   }//Aod branch loop
        
-    //Do correlation with leading particle
+  //Do correlation with leading particle
   if(trigIndex!=-1){
          
     AliAODPWG4ParticleCorrelation* particle =  (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(trigIndex));
-      //Make correlation with charged hadrons
+    //Make correlation with charged hadrons
     if(GetReader()->IsCTSSwitchedOn() )
       MakeChargedCorrelation(particle, GetAODCTS(),kFALSE);
     
-      //Make correlation with neutral pions
-      //Trigger particle in PHOS, correlation with EMCAL
-    if(particle->GetDetector()=="PHOS" && GetReader()->IsEMCALSwitchedOn() && GetAODEMCAL()->GetEntriesFast() > 0)
-      MakeNeutralCorrelationFillAOD(particle, GetAODEMCAL(),"EMCAL");
-      //Trigger particle in EMCAL, correlation with PHOS
-    else if(particle->GetDetector()=="EMCAL" && GetReader()->IsPHOSSwitchedOn() && GetAODPHOS()->GetEntriesFast() > 0)
-      MakeNeutralCorrelationFillAOD(particle, GetAODPHOS(),"PHOS");
-      //Trigger particle in CTS, correlation with PHOS, EMCAL and CTS
-    else if(particle->GetDetector()=="CTS" ){
-      if(GetReader()->IsPHOSSwitchedOn() && GetAODPHOS()->GetEntriesFast() > 0) 
-        MakeNeutralCorrelationFillAOD(particle, GetAODPHOS(),"PHOS");
-      if(GetReader()->IsEMCALSwitchedOn() && GetAODEMCAL()->GetEntriesFast() > 0) 
-        MakeNeutralCorrelationFillAOD(particle, GetAODEMCAL(),"EMCAL");
-    }
-    
+    TObjArray * pi0list = (TObjArray*) GetAODBranch(fPi0AODBranchName); //For the future, foresee more possible pi0 lists
+    if(pi0list && pi0list->GetEntriesFast() > 0)
+      MakeNeutralCorrelation(particle, pi0list,kFALSE);
     
   }//Correlate leading
   
@@ -631,9 +643,10 @@ void  AliAnaParticleHadronCorrelation::MakeAnalysisFillHistograms()
     }
     
     //Make correlation with neutral pions
-    if(GetOutputAODBranch() && GetOutputAODBranch()->GetEntriesFast() > 0){
-      if(GetDebug() > 1) printf("AliAnaParticleHadronCorrelation::MakeAnalysisFillHistograms() - Leading %d, In Cluster Refs entries %d\n",trigIndex, GetOutputAODBranch()->GetEntriesFast());      
-      MakeNeutralCorrelationFillHistograms(particle);
+    TObjArray * refpi0   = particle->GetObjArray(GetAODObjArrayName()+"Pi0s");
+    if(refpi0){
+      if(GetDebug() > 1) printf("AliAnaParticleHadronCorrelation::MakeAnalysisFillHistograms() - Leading %d, In Pi0 Refs entries %d\n",trigIndex, refpi0->GetEntriesFast());      
+      MakeNeutralCorrelation(particle, refpi0, kTRUE);
     }
     
   }//Aod branch loop
@@ -645,11 +658,14 @@ void  AliAnaParticleHadronCorrelation::MakeAnalysisFillHistograms()
 //____________________________________________________________________________
 void  AliAnaParticleHadronCorrelation::MakeChargedCorrelation(AliAODPWG4ParticleCorrelation *aodParticle, TObjArray* const pl, const Bool_t bFillHisto)
 {  
-    // Charged Hadron Correlation Analysis
+  // Charged Hadron Correlation Analysis
   if(GetDebug() > 1)printf("AliAnaParticleHadronCorrelation::MakeChargedCorrelation() - Make trigger particle - charged hadron correlation \n");
   
   Int_t evtIndex11 = 0 ; 
-  Int_t evtIndex12 = 0 ; 
+  Int_t evtIndex12 = 0 ;
+  Int_t indexPhoton1 = -1 ;
+  Int_t indexPhoton2 = -1 ;  
+  
   if (GetMixedEvent()) {
     evtIndex11 = GetMixedEvent()->EventIndexForCaloCluster(aodParticle->GetCaloLabel(0)) ;
     evtIndex12 = GetMixedEvent()->EventIndexForCaloCluster(aodParticle->GetCaloLabel(1)) ;    
@@ -671,10 +687,56 @@ void  AliAnaParticleHadronCorrelation::MakeChargedCorrelation(AliAODPWG4Particle
   Double_t eta  = -100. ;
   TVector3 p3;  
        
-  TObjArray * reftracks    =0x0;
+  TObjArray * reftracks = 0x0;
   Int_t nrefs = 0;
        
-    //Track loop, select tracks with good pt, phi and fill AODs or histograms
+  Double_t ptDecay1  = 0. ;
+  Double_t pxDecay1  = 0. ;
+  Double_t pyDecay1  = 0. ;
+  Double_t phiDecay1 = 0. ;
+  Double_t ptDecay2  = 0. ;
+  Double_t pxDecay2  = 0. ;
+  Double_t pyDecay2  = 0. ;
+  Double_t phiDecay2 = 0. ;
+  
+  Double_t ratDecay1  = -100.;  
+  Double_t ratDecay2  = -100.; 
+  Float_t deltaphi    = -100. ;
+  Float_t deltaphiDecay1 = -100. ;
+  Float_t deltaphiDecay2 = -100. ;
+  TObjArray * clusters   = 0x0 ;  
+  TLorentzVector photonMom ;   
+  
+  if(fPi0Trigger){
+    indexPhoton1 = aodParticle->GetCaloLabel (0);
+    indexPhoton2 = aodParticle->GetCaloLabel (1);
+    if(GetDebug() > 1)printf("indexPhoton1 = %d, indexPhoton2 = %d \n", indexPhoton1, indexPhoton2);
+    
+    if(indexPhoton1!=-1 && indexPhoton2!=-1){
+      if(aodParticle->GetDetector()=="EMCAL") clusters = GetAODEMCAL() ;
+      else  clusters = GetAODPHOS() ;
+      for(Int_t iclus = 0; iclus < clusters->GetEntriesFast(); iclus++){
+        AliVCluster * photon =  (AliVCluster*) (clusters->At(iclus));  
+        photon->GetMomentum(photonMom,GetVertex(0)) ;
+        if(photon->GetID()==indexPhoton1) {
+          ptDecay1  = photonMom.Pt();
+          pxDecay1  = photonMom.Px();
+          pyDecay1  = photonMom.Py();
+          phiDecay1 = photonMom.Phi();
+        }
+        if(photon->GetID()==indexPhoton2) {
+          ptDecay2  = photonMom.Pt();
+          pxDecay2  = photonMom.Px();
+          pyDecay2  = photonMom.Py();
+          phiDecay2 = photonMom.Phi();
+        } 
+        if(GetDebug() > 1)printf("Photon1 = %f, Photon2 = %f \n", ptDecay1, ptDecay2);
+      } //cluster loop        
+    } //index of decay photons found
+    if(ptTrig && bFillHisto) fhPtPi0DecayRatio->Fill(ptTrig, ptDecay1/ptTrig, ptDecay2/ptTrig);
+  } //make decay-hadron correlation
+  
+  //Track loop, select tracks with good pt, phi and fill AODs or histograms
   //Int_t currentIndex = -1 ; 
   for(Int_t ipr = 0;ipr < pl->GetEntriesFast() ; ipr ++ ){
     AliAODTrack * track = (AliAODTrack *) (pl->At(ipr)) ;
@@ -683,14 +745,16 @@ void  AliAnaParticleHadronCorrelation::MakeChargedCorrelation(AliAODPWG4Particle
       evtIndex2 = GetMixedEvent()->EventIndex(track->GetID()) ;
       if (evtIndex11 == evtIndex2 || evtIndex12 == evtIndex2) // photon and track from different events
         continue ; 
-//      if(currentIndex == evtIndex2) // tracks from different event 
-//        continue ;
-//      currentIndex = evtIndex2 ;
+      //      if(currentIndex == evtIndex2) // tracks from different event 
+      //        continue ;
+      //      currentIndex = evtIndex2 ;
     }
     if(track->GetID()==aodParticle->GetTrackLabel(0)) 
       continue ;
-    if(track->Pt()>ptTrig) 
-      continue ;
+    
+    //if(track->Pt()>ptTrig) 
+    //continue ;
+    
     Double_t mom[3] = {track->Px(),track->Py(),track->Pz()};
     p3.SetXYZ(mom[0],mom[1],mom[2]);
     pt   = p3.Pt();
@@ -703,19 +767,32 @@ void  AliAnaParticleHadronCorrelation::MakeChargedCorrelation(AliAODPWG4Particle
     xE    = -(px*pxTrig+py*pyTrig)/(ptTrig*ptTrig);
     if(xE <0.)xE =-xE;
     cosi = TMath::Log(1/xE);
-      // printf("rat = %f, xE = %f, cosi =%f \n", rat, xE, cosi);
-      // printf("phi = %f \n", phi);
+    // printf("rat = %f, xE = %f, cosi =%f \n", rat, xE, cosi);
+    // printf("phi = %f \n", phi);
+    
+    if(fPi0Trigger){
+      if(indexPhoton1!=-1 && indexPhoton2!=-1){
+        if(ptDecay1) ratDecay1 = pt/ptDecay1 ;
+        if(ptDecay2) ratDecay2 = pt/ptDecay2 ; 
+        deltaphiDecay1 = phiDecay1-phi;
+        deltaphiDecay2 = phiDecay2-phi;
+        if(deltaphiDecay1< -TMath::PiOver2()) deltaphiDecay1+=TMath::TwoPi();
+        if(deltaphiDecay1>3*TMath::PiOver2()) deltaphiDecay1-=TMath::TwoPi();
+        if(deltaphiDecay2< -TMath::PiOver2()) deltaphiDecay2+=TMath::TwoPi();
+        if(deltaphiDecay2>3*TMath::PiOver2()) deltaphiDecay2-=TMath::TwoPi();    
+      }
+    } //do decay-hadron correlation    
     
     if(IsFiducialCutOn()){
       Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,"CTS") ;
       if(! in ) continue ;
     }    
     
-      //Select only hadrons in pt range
+    //Select only hadrons in pt range
     if(pt < GetMinPt() || pt > GetMaxPt()) continue ;
     
-      //Selection within angular range
-    Float_t deltaphi = phiTrig-phi;
+    //Selection within angular range
+    deltaphi = phiTrig-phi;
     if(deltaphi< -TMath::PiOver2()) deltaphi+=TMath::TwoPi();
     if(deltaphi>3*TMath::PiOver2()) deltaphi-=TMath::TwoPi();
     
@@ -724,7 +801,7 @@ void  AliAnaParticleHadronCorrelation::MakeChargedCorrelation(AliAODPWG4Particle
              pt,phi, phiTrig,fDeltaPhiMinCut, deltaphi, fDeltaPhiMaxCut, GetMinPt());
     
     if(bFillHisto){
-        // Fill Histograms
+      // Fill Histograms
       fhEtaCharged->Fill(pt,eta);
       fhPhiCharged->Fill(pt,phi);
       fhDeltaEtaCharged->Fill(ptTrig,aodParticle->Eta()-eta);
@@ -733,7 +810,7 @@ void  AliAnaParticleHadronCorrelation::MakeChargedCorrelation(AliAODPWG4Particle
       
       if(GetDebug() > 2 ) printf("AliAnaParticleHadronCorrelation::MakeChargedCorrelation() - Selected charge for momentum imbalance: pt %2.2f, phi %2.2f, eta %2.2f \n",pt,phi,eta);
       
-        //delta phi cut for correlation
+      //delta phi cut for correlation
       if( (deltaphi > fDeltaPhiMinCut) && ( deltaphi < fDeltaPhiMaxCut) ) {
         fhDeltaPhiChargedPt->Fill(pt,deltaphi);
         fhPtImbalanceCharged->Fill(ptTrig,rat); 
@@ -744,7 +821,21 @@ void  AliAnaParticleHadronCorrelation::MakeChargedCorrelation(AliAODPWG4Particle
         fhPtImbalanceUeCharged->Fill(ptTrig,rat);
         fhPtHbpUeCharged->Fill(ptTrig,cosi);
       }
-        //several UE calculation 
+      
+      if(fPi0Trigger){
+        if(indexPhoton1!=-1 && indexPhoton2!=-1){
+          fhDeltaPhiDecay1Charged->Fill(ptDecay1, deltaphiDecay1);
+          fhDeltaPhiDecay2Charged->Fill(ptDecay2, deltaphiDecay2);
+          if(GetDebug() > 1)printf("deltaPhoton1 = %f, deltaPhoton2 = %f \n", deltaphiDecay1, deltaphiDecay2);
+          if( (deltaphiDecay1 > fDeltaPhiMinCut) && ( deltaphiDecay1 < fDeltaPhiMaxCut) )
+            fhPtImbalanceDecay1Charged->Fill(ptDecay1,ratDecay1); 
+          if( (deltaphiDecay2 > fDeltaPhiMinCut) && ( deltaphiDecay2 < fDeltaPhiMaxCut) )
+            fhPtImbalanceDecay2Charged->Fill(ptDecay2,ratDecay2);
+          if(GetDebug() > 1)printf("ratPhoton1 = %f, ratPhoton2 = %f \n", pt/ptDecay1, pt/ptDecay2);
+        } //index of decay photons found
+      } //make decay-hadron correlation          
+      
+      //several UE calculation 
       if(fMakeSeveralUE){
         if((deltaphi<-fUeDeltaPhiMinCut) && (deltaphi >-fUeDeltaPhiMaxCut)){  
           fhDeltaPhiUeLeftCharged->Fill(pt,deltaphi);
@@ -771,220 +862,235 @@ void  AliAnaParticleHadronCorrelation::MakeChargedCorrelation(AliAODPWG4Particle
     }//aod particle loop
   }// track loop
   
-    //Fill AOD with reference tracks, if not filling histograms
+  //Fill AOD with reference tracks, if not filling histograms
   if(!bFillHisto && reftracks) {
     aodParticle->AddObjArray(reftracks);
   }
   
-    //delete reftracks;
+  //delete reftracks;
   
 }  
 
-  //____________________________________________________________________________
-void  AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD(AliAODPWG4ParticleCorrelation* const aodParticle,TObjArray* const pl, TString detector)  
-{  
-    // Neutral Pion Correlation Analysis, find pi0, put them in new output aod, if correlation cuts passed
-  if(GetDebug() > 1) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Make trigger particle - neutral hadron correlation \n");
-  
-  if(!NewOutputAOD()){
-    printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Output aod not created, set AOD class name and branch name in the configuration file, STOP! \n");
-    abort();
-  }
-  
-  Double_t phiTrig = aodParticle->Phi();
-  Int_t        tag = 0;
-  TLorentzVector gammai;
-  TLorentzVector gammaj;
-  
-    //Get vertex for photon momentum calculation
-  
-  if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC) 
-  {
-    for (Int_t iev = 0; iev < GetNMixedEvent(); iev++) {
-      if (!GetMixedEvent()) 
-        GetReader()->GetVertex(GetVertex(iev));
-      else 
-        GetMixedEvent()->GetVertexOfEvent(iev)->GetXYZ(GetVertex(iev)); 
-    }
-  }
+
+
+//____________________________________________________________________________
+//void  AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD(AliAODPWG4ParticleCorrelation* const aodParticle,TObjArray* const pl, TString detector)  
+//{  
+//    // Neutral Pion Correlation Analysis, find pi0, put them in new output aod, if correlation cuts passed
+//  if(GetDebug() > 1) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Make trigger particle - neutral hadron correlation \n");
+//  
+//  if(!NewOutputAOD()){
+//    printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Output aod not created, set AOD class name and branch name in the configuration file, STOP! \n");
+//    abort();
+//  }
+//  
+//  Double_t phiTrig = aodParticle->Phi();
+//  Int_t      tag = 0;
+//  TLorentzVector gammai;
+//  TLorentzVector gammaj;
+//  
+//  //Get vertex for photon momentum calculation
+//  
+//  if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC) 
+//  {
+//    for (Int_t iev = 0; iev < GetNMixedEvent(); iev++) {
+//      if (!GetMixedEvent()) 
+//        GetReader()->GetVertex(GetVertex(iev));
+//      else 
+//        GetMixedEvent()->GetVertexOfEvent(iev)->GetXYZ(GetVertex(iev)); 
+//    }
+//  }
 //  Double_t vertex2[] = {0.0,0.0,0.0} ; //vertex of second input aod
 //  if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC) 
 //  {
 //     if(GetReader()->GetSecondInputAODTree()) GetReader()->GetSecondInputAODVertex(vertex2);
 //  }
-       
-    //Cluster loop, select pairs with good pt, phi and fill AODs or histograms
-    //Int_t iEvent= GetReader()->GetEventNumber() ;
-  Int_t nclus = pl->GetEntriesFast();
-  for(Int_t iclus = 0;iclus < nclus ; iclus ++ ){
-    AliVCluster * calo = (AliVCluster *) (pl->At(iclus)) ;
-    
-    Int_t evtIndex1 = 0 ; 
-    if (GetMixedEvent()) {
-      evtIndex1=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
-    }
-    
-
-      //Input from second AOD?
-    Int_t inputi = 0;
+//     
+//    //Cluster loop, select pairs with good pt, phi and fill AODs or histograms
+//    //Int_t iEvent= GetReader()->GetEventNumber() ;
+//  Int_t nclus = pl->GetEntriesFast();
+//  for(Int_t iclus = 0;iclus < nclus ; iclus ++ ){
+//    AliVCluster * calo = (AliVCluster *) (pl->At(iclus)) ;
+//    
+//    Int_t evtIndex1 = 0 ; 
+//    if (GetMixedEvent()) {
+//      evtIndex1=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
+//    }
+//    
+//
+//      //Input from second AOD?
+//    Int_t inputi = 0;
 //    if     (aodParticle->GetDetector() == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= iclus) 
 //      inputi = 1 ;
 //    else if(aodParticle->GetDetector() == "PHOS"  && GetReader()->GetAODPHOSNormalInputEntries()  <= iclus) 
 //      inputi = 1;
-    
-      //Cluster selection, not charged, with photon or pi0 id and in fiducial cut
-    Int_t pdg=0;
-    if     (inputi == 0 && !SelectCluster(calo, GetVertex(evtIndex1),  gammai, pdg))  
-      continue ;
+//    
+//      //Cluster selection, not charged, with photon or pi0 id and in fiducial cut
+//    //FIXME
+//    Int_t pdg=0;
+//    //if     (inputi == 0 && !SelectCluster(calo, GetVertex(evtIndex1),  gammai, pdg))  
+//      continue ;
+//    //MEFIX
 //    else if(inputi == 1 && !SelectCluster(calo, vertex2, gammai, pdg))  
 //      continue ;
-    
-    if(GetDebug() > 2)
-      printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Neutral cluster in %s: pt %f, phi %f, phi trigger %f. Cuts:  delta phi min %2.2f,  max %2.2f, pT min %2.2f \n",
-             detector.Data(), gammai.Pt(),gammai.Phi(),phiTrig,fDeltaPhiMinCut, fDeltaPhiMaxCut, GetMinPt());
-    
-      //2 gamma overlapped, found with PID
-    if(pdg == AliCaloPID::kPi0){ 
-      
-        //Select only hadrons in pt range
-      if(gammai.Pt() < GetMinPt() || gammai.Pt() > GetMaxPt()) 
-        continue ;
-      
-        //Selection within angular range
-      Float_t phi = gammai.Phi();
-      if(phi < 0) phi+=TMath::TwoPi();
-        //Float_t deltaphi = TMath::Abs(phiTrig-phi);
-        //if( (deltaphi < fDeltaPhiMinCut) || ( deltaphi > fDeltaPhiMaxCut) ) continue ;
-      
-      AliAODPWG4Particle pi0 = AliAODPWG4Particle(gammai);
-        //pi0.SetLabel(calo->GetLabel());
-      pi0.SetPdg(AliCaloPID::kPi0);
-      pi0.SetDetector(detector);
-      
-      if(IsDataMC()){
-        pi0.SetTag(GetMCAnalysisUtils()->CheckOrigin(calo->GetLabel(),GetReader(),inputi));
-        if(GetDebug() > 0) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Origin of candidate %d\n",pi0.GetTag());
-      }//Work with stack also 
-       //Set the indeces of the original caloclusters  
-      pi0.SetCaloLabel(calo->GetID(),-1);
-      AddAODParticle(pi0);
-      
-      if(GetDebug() > 2) 
-        printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Correlated with selected pi0 (pid): pt %f, phi %f\n",pi0.Pt(),pi0.Phi());
-      
-    }// pdg = 111
-    
-      //Make invariant mass analysis
-    else if(pdg == AliCaloPID::kPhoton){       
-        //Search the photon companion in case it comes from  a Pi0 decay
-        //Apply several cuts to select the good pair;
-      for(Int_t jclus = iclus+1; jclus < pl->GetEntries() ; jclus ++ ){
-        AliVCluster * calo2 = (AliVCluster *) (pl->At(jclus)) ;
-        Int_t evtIndex2 = 0 ; 
-        if (GetMixedEvent()) {
-          evtIndex2=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
-        }
-        if (GetMixedEvent() && (evtIndex1 == evtIndex2))
-          continue ;
-        
-          //Input from second AOD?
-        Int_t inputj = 0;
+//    
+//    if(GetDebug() > 2)
+//      printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Neutral cluster in %s: pt %f, phi %f, phi trigger %f. Cuts:  delta phi min %2.2f,  max %2.2f, pT min %2.2f \n",
+//             detector.Data(), gammai.Pt(),gammai.Phi(),phiTrig,fDeltaPhiMinCut, fDeltaPhiMaxCut, GetMinPt());
+//    
+//      //2 gamma overlapped, found with PID
+//    if(pdg == AliCaloPID::kPi0){ 
+//      
+//        //Select only hadrons in pt range
+//      if(gammai.Pt() < GetMinPt() || gammai.Pt() > GetMaxPt()) 
+//        continue ;
+//      
+//        //Selection within angular range
+//      Float_t phi = gammai.Phi();
+//      if(phi < 0) phi+=TMath::TwoPi();
+//        //Float_t deltaphi = TMath::Abs(phiTrig-phi);
+//        //if( (deltaphi < fDeltaPhiMinCut) || ( deltaphi > fDeltaPhiMaxCut) ) continue ;
+//      
+//      AliAODPWG4Particle pi0 = AliAODPWG4Particle(gammai);
+//        //pi0.SetLabel(calo->GetLabel());
+//      pi0.SetPdg(AliCaloPID::kPi0);
+//      pi0.SetDetector(detector);
+//      
+//      if(IsDataMC()){
+//        pi0.SetTag(GetMCAnalysisUtils()->CheckOrigin(calo->GetLabel(),GetReader(),inputi));
+//        if(GetDebug() > 0) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Origin of candidate %d\n",pi0.GetTag());
+//      }//Work with stack also 
+//       //Set the indeces of the original caloclusters  
+//      pi0.SetCaloLabel(calo->GetID(),-1);
+//      AddAODParticle(pi0);
+//      
+//      if(GetDebug() > 2) 
+//        printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Correlated with selected pi0 (pid): pt %f, phi %f\n",pi0.Pt(),pi0.Phi());
+//      
+//    }// pdg = 111
+//    
+//      //Make invariant mass analysis
+//    else if(pdg == AliCaloPID::kPhoton){     
+//        //Search the photon companion in case it comes from  a Pi0 decay
+//        //Apply several cuts to select the good pair;
+//      for(Int_t jclus = iclus+1; jclus < pl->GetEntries() ; jclus ++ ){
+//        AliVCluster * calo2 = (AliVCluster *) (pl->At(jclus)) ;
+//        Int_t evtIndex2 = 0 ; 
+//        if (GetMixedEvent()) {
+//          evtIndex2=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
+//        }
+//        if (GetMixedEvent() && (evtIndex1 == evtIndex2))
+//          continue ;
+//        
+//          //Input from second AOD?
+//        Int_t inputj = 0;
 //        if     (aodParticle->GetDetector() == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= jclus) 
 //          inputj = 1;
 //        else if(aodParticle->GetDetector() == "PHOS"  && GetReader()->GetAODPHOSNormalInputEntries()  <= jclus) 
 //          inputj = 1;
-        
-          //Cluster selection, not charged with photon or pi0 id and in fiducial cut
-        Int_t pdgj=0;
-        if     (inputj == 0 && !SelectCluster(calo2, GetVertex(evtIndex2),  gammaj, pdgj))  
-          continue ;
+//        
+//          //Cluster selection, not charged with photon or pi0 id and in fiducial cut
+//        Int_t pdgj=0;
+//        //FIXME
+//        //if     (inputj == 0 && !SelectCluster(calo2, GetVertex(evtIndex2),  gammaj, pdgj))  
+//          continue ;
+//        //MEFIX
+//
 //        else if(inputj == 1 && !SelectCluster(calo2, vertex2, gammaj, pdgj))  
 //          continue ;
-        
-        if(!SelectCluster(calo2,GetVertex(evtIndex2), gammaj, pdgj)) 
-          continue ;
-        
-        if(pdgj == AliCaloPID::kPhoton ){
-          
-          if((gammai+gammaj).Pt() < GetMinPt() || (gammai+gammaj).Pt() > GetMaxPt()) 
-            continue ;
-          
-            //Selection within angular range
-          Float_t phi = (gammai+gammaj).Phi();
-          if(phi < 0) phi+=TMath::TwoPi();
-            //Float_t deltaphi = TMath::Abs(phiTrig-phi);
-            //if( (deltaphi < fDeltaPhiMinCut) || ( deltaphi > fDeltaPhiMaxCut) ) continue ;
-          
-            //Select good pair (aperture and invariant mass)
-          if(GetNeutralMesonSelection()->SelectPair(gammai, gammaj)){
-            
-            if(GetDebug() > 2 ) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Neutral Hadron Correlation: AOD Selected gamma pair: pt %2.2f, phi %2.2f, eta %2.2f, M %2.3f\n",
-                                       (gammai+gammaj).Pt(),(gammai+gammaj).Phi(),(gammai+gammaj).Eta(), (gammai+gammaj).M());
-            
-            TLorentzVector pi0mom = gammai+gammaj;
-            AliAODPWG4Particle pi0 = AliAODPWG4Particle(pi0mom);
-              //pi0.SetLabel(calo->GetLabel());
-            pi0.SetPdg(AliCaloPID::kPi0);
-            pi0.SetDetector(detector); 
-            if(IsDataMC()){
-                //Check origin of the candidates
-              
-              Int_t label1 = calo->GetLabel();
-              Int_t label2 = calo2->GetLabel();
-              Int_t tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), inputi);
-              Int_t tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), inputj);
-              
-              if(GetDebug() > 0) 
-                printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - 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(inputi))->At(label1);//photon in kine tree
-                  label1 = mother1->GetMother();
-                    //mother1 = GetMCStack()->Particle(label1);//pi0
-                  AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(inputj))->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 mc information also   
-            pi0.SetTag(tag);
-              //Set the indeces of the original caloclusters  
-            pi0.SetCaloLabel(calo->GetID(), calo2->GetID());
-            AddAODParticle(pi0);
-            
-            
-          }//Pair selected
-        }//if pair of gammas
-      }//2nd loop
-    }// if pdg = 22
-  }//1st loop
-  
-  if(GetDebug() > 1) 
-    printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - End, %d pi0's found \n",GetOutputAODBranch()->GetEntriesFast());
-}
+//        //FIXME
+//        //if(!SelectCluster(calo2,GetVertex(evtIndex2), gammaj, pdgj)) 
+//        //MEFIX
+//          continue ;
+//        
+//        if(pdgj == AliCaloPID::kPhoton ){
+//          
+//          if((gammai+gammaj).Pt() < GetMinPt() || (gammai+gammaj).Pt() > GetMaxPt()) 
+//            continue ;
+//          
+//            //Selection within angular range
+//          Float_t phi = (gammai+gammaj).Phi();
+//          if(phi < 0) phi+=TMath::TwoPi();
+//            //Float_t deltaphi = TMath::Abs(phiTrig-phi);
+//            //if( (deltaphi < fDeltaPhiMinCut) || ( deltaphi > fDeltaPhiMaxCut) ) continue ;
+//          
+//            //Select good pair (aperture and invariant mass)
+//          if(GetNeutralMesonSelection()->SelectPair(gammai, gammaj)){
+//            
+//            if(GetDebug() > 2 ) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - Neutral Hadron Correlation: AOD Selected gamma pair: pt %2.2f, phi %2.2f, eta %2.2f, M %2.3f\n",
+//                                       (gammai+gammaj).Pt(),(gammai+gammaj).Phi(),(gammai+gammaj).Eta(), (gammai+gammaj).M());
+//            
+//            TLorentzVector pi0mom = gammai+gammaj;
+//            AliAODPWG4Particle pi0 = AliAODPWG4Particle(pi0mom);
+//              //pi0.SetLabel(calo->GetLabel());
+//            pi0.SetPdg(AliCaloPID::kPi0);
+//            pi0.SetDetector(detector);       
+//            if(IsDataMC()){
+//                //Check origin of the candidates
+//              
+//              Int_t label1 = calo->GetLabel();
+//              Int_t label2 = calo2->GetLabel();
+//              Int_t tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), inputi);
+//              Int_t tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), inputj);
+//              
+//              if(GetDebug() > 0) 
+//                printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - 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(inputi))->At(label1);//photon in kine tree
+//                  label1 = mother1->GetMother();
+//                    //mother1 = GetMCStack()->Particle(label1);//pi0
+//                  AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(inputj))->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 mc information also   
+//            pi0.SetTag(tag);
+//              //Set the indeces of the original caloclusters  
+//            pi0.SetCaloLabel(calo->GetID(), calo2->GetID());
+//            AddAODParticle(pi0);
+//            
+//            
+//          }//Pair selected
+//        }//if pair of gammas
+//      }//2nd loop
+//    }// if pdg = 22
+//  }//1st loop
+//  
+//  if(GetDebug() > 1) 
+//    printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillAOD() - End, %d pi0's found \n",GetOutputAODBranch()->GetEntriesFast());
+//}
 
 //____________________________________________________________________________
-void  AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillHistograms(AliAODPWG4ParticleCorrelation * const aodParticle)  
+void  AliAnaParticleHadronCorrelation::MakeNeutralCorrelation(AliAODPWG4ParticleCorrelation * const aodParticle, TObjArray* pi0list, const Bool_t bFillHisto)  
 {  
   // Neutral Pion Correlation Analysis
-  if(GetDebug() > 1) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillHistogramS() - Make trigger particle - pi0 correlation, %d pi0's \n",GetOutputAODBranch()->GetEntriesFast());
+  if(GetDebug() > 1) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelation() - Make trigger particle - pi0 correlation, %d pi0's \n",pi0list->GetEntriesFast());
+  
+  Int_t evtIndex11 = 0 ; 
+  Int_t evtIndex12 = 0 ; 
+  if (GetMixedEvent()) {
+    evtIndex11 = GetMixedEvent()->EventIndexForCaloCluster(aodParticle->GetCaloLabel(0)) ;
+    evtIndex12 = GetMixedEvent()->EventIndexForCaloCluster(aodParticle->GetCaloLabel(1)) ;    
+  }  
   
-  Double_t pt  = -100.;
+  Double_t pt   = -100.;
   Double_t px   = -100.;
   Double_t py   = -100.;
   Double_t rat = -100.; 
@@ -992,124 +1098,213 @@ void  AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillHistograms(AliA
   Double_t eta = -100.;
   Double_t xE  = -100.; 
   Double_t cosi  = -100.; 
-
+  
   Double_t ptTrig  = aodParticle->Pt();
   Double_t phiTrig = aodParticle->Phi();
   Double_t etaTrig = aodParticle->Eta();
   Double_t pxTrig  = aodParticle->Px();
   Double_t pyTrig  = aodParticle->Py();
-
   
-  if(!GetOutputAODBranch()){
-    printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillHistograms() - No output pi0 in AOD branch with name < %s >,STOP \n",GetOutputAODName().Data());
-    abort();
-  }
+  
+  Int_t indexPhoton1 = -1 ;
+  Int_t indexPhoton2 = -1 ;    
+  Double_t ptDecay1 = 0. ;
+  Double_t pxDecay1  = 0. ;
+  Double_t pyDecay1  = 0. ;
+  Double_t phiDecay1  = 0. ;
+  Double_t ptDecay2 = 0. ;
+  Double_t pxDecay2  = 0. ;
+  Double_t pyDecay2  = 0. ;
+  Double_t phiDecay2  = 0. ;
+  
+  Double_t ratDecay1  = -100.;  
+  Double_t ratDecay2  = -100.; 
+  Float_t deltaphi = -100. ;
+  Float_t deltaphiDecay1 = -100. ;
+  Float_t deltaphiDecay2 = -100. ;
+  TObjArray * clusters = 0x0 ;  
+  TLorentzVector photonMom ;   
+  if(fPi0Trigger){
+    indexPhoton1 = aodParticle->GetCaloLabel (0);
+    indexPhoton2 = aodParticle->GetCaloLabel (1);
+    if(GetDebug() > 1)printf("indexPhoton1 = %d, indexPhoton2 = %d \n", indexPhoton1, indexPhoton2);
+    
+    if(indexPhoton1!=-1 && indexPhoton2!=-1){
+      if(aodParticle->GetDetector()=="EMCAL") clusters = GetAODEMCAL() ;
+      else                                    clusters = GetAODPHOS() ;
+      for(Int_t iclus = 0; iclus < clusters->GetEntriesFast(); iclus++){
+        AliVCluster * photon =  (AliVCluster*) (clusters->At(iclus));  
+        photon->GetMomentum(photonMom,GetVertex(0)) ;
+        if(photon->GetID()==indexPhoton1) {
+          ptDecay1  = photonMom.Pt();
+          pxDecay1  = photonMom.Px();
+          pyDecay1  = photonMom.Py();
+          phiDecay1 = photonMom.Phi();
+        }
+        if(photon->GetID()==indexPhoton2) {
+          ptDecay2  = photonMom.Pt();
+          pxDecay2  = photonMom.Px();
+          pyDecay2  = photonMom.Py();
+          phiDecay2 = photonMom.Phi();
+        } 
+        if(GetDebug() > 1)printf("Photon1 = %f, Photon2 = %f \n", ptDecay1, ptDecay2);
+      } //photonAOD loop        
+    } //index of decay photons found
+    if(ptTrig && bFillHisto) fhPtPi0DecayRatio->Fill(ptTrig, ptDecay1/ptTrig, ptDecay2/ptTrig);
+  } //make decay-hadron correlation
+  
+  TObjArray * refpi0    =0x0;
+  Int_t nrefs = 0;
   
   //Loop on stored AOD pi0
-  Int_t naod = GetOutputAODBranch()->GetEntriesFast();
+  Int_t naod = pi0list->GetEntriesFast();
   if(GetDebug() > 0) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelationFillHistograms() -  aod branch entries %d\n", naod);
   for(Int_t iaod = 0; iaod < naod ; iaod++){
-    AliAODPWG4Particle* pi0 =  (AliAODPWG4Particle*) (GetOutputAODBranch()->At(iaod));
-    Int_t pdg = pi0->GetPdg();
+    AliAODPWG4Particle* pi0 =  (AliAODPWG4Particle*) (pi0list->At(iaod));
+    
+    Int_t evtIndex2 = 0 ; 
+    Int_t evtIndex3 = 0 ; 
+    if (GetMixedEvent()) {
+      evtIndex2 = GetMixedEvent()->EventIndexForCaloCluster(pi0->GetCaloLabel(0)) ;
+      evtIndex3 = GetMixedEvent()->EventIndexForCaloCluster(pi0->GetCaloLabel(1)) ;
+      
+      if (evtIndex11 == evtIndex2 || evtIndex12 == evtIndex2 || evtIndex11 == evtIndex3 || evtIndex12 == evtIndex3) // trigger and pi0 are not from different events
+        continue ; 
+    }      
+    
+    //Int_t pdg = pi0->GetPdg();
+    //if(pdg != AliCaloPID::kPi0) continue;  
     
-    if(pdg != AliCaloPID::kPi0) continue;              
     pt  = pi0->Pt();
-    px   = pi0->Px();
-       py   = pi0->Py();    
+    px  = pi0->Px();
+    py  = pi0->Py();    
     if(pt < GetMinPt() || pt > GetMaxPt()) continue ;
     
     //Selection within angular range
     phi = pi0->Phi();
     //Float_t deltaphi = TMath::Abs(phiTrig-phi);
     //if( (deltaphi < fDeltaPhiMinCut) || ( deltaphi > fDeltaPhiMaxCut) ) continue ;
-    Float_t deltaphi = phiTrig-phi;
-    if(deltaphi<-TMath::PiOver2()) deltaphi+=TMath::TwoPi();
-    if(deltaphi>3*TMath::PiOver2()) deltaphi-=TMath::TwoPi();
-         
-    rat = pt/ptTrig ;
-    phi = pi0->Phi() ;
-    eta = pi0->Eta() ;
-       xE   = -(px*pxTrig+py*pyTrig)/(ptTrig*ptTrig);
-       if(xE <0.)xE =-xE;
-       cosi = TMath::Log(1/xE);
     
-    fhEtaNeutral->Fill(pt,eta);
-    fhPhiNeutral->Fill(pt,phi);
-    fhDeltaEtaNeutral->Fill(ptTrig,etaTrig-eta);
-    fhDeltaPhiNeutral->Fill(ptTrig,deltaphi);
-       fhDeltaPhiDeltaEtaNeutral->Fill(deltaphi,etaTrig-eta);
-         
-       //delta phi cut for correlation
-       if( (deltaphi > fDeltaPhiMinCut) && ( deltaphi < fDeltaPhiMaxCut) ) {
-        fhDeltaPhiNeutralPt->Fill(pt,deltaphi);
-        fhPtImbalanceNeutral->Fill(ptTrig,rat); 
-        fhPtHbpNeutral->Fill(ptTrig,cosi); 
-       }
+    if(bFillHisto){
+      
+      deltaphi = phiTrig-phi;
+      if(deltaphi<-TMath::PiOver2()) deltaphi+=TMath::TwoPi();
+      if(deltaphi>3*TMath::PiOver2()) deltaphi-=TMath::TwoPi();
+      
+      rat = pt/ptTrig ;
+      phi = pi0->Phi() ;
+      eta = pi0->Eta() ;
+      xE   = -(px*pxTrig+py*pyTrig)/(ptTrig*ptTrig);
+      if(xE <0.)xE =-xE;
+      cosi = TMath::Log(1/xE);
+      
+      if(fPi0Trigger){
+        if(indexPhoton1!=-1 && indexPhoton2!=-1){
+          if(ptDecay1) ratDecay1 = pt/ptDecay1 ;
+          if(ptDecay2) ratDecay2 = pt/ptDecay2 ; 
+          deltaphiDecay1 = phiDecay1-phi;
+          deltaphiDecay2 = phiDecay2-phi;
+          if(deltaphiDecay1< -TMath::PiOver2()) deltaphiDecay1+=TMath::TwoPi();
+          if(deltaphiDecay1>3*TMath::PiOver2()) deltaphiDecay1-=TMath::TwoPi();
+          if(deltaphiDecay2< -TMath::PiOver2()) deltaphiDecay2+=TMath::TwoPi();
+          if(deltaphiDecay2>3*TMath::PiOver2()) deltaphiDecay2-=TMath::TwoPi();   
+          fhDeltaPhiDecay1Neutral->Fill(ptDecay1, deltaphiDecay1);
+          fhDeltaPhiDecay2Neutral->Fill(ptDecay2, deltaphiDecay2);
+          if(GetDebug() > 1)printf("deltaPhoton1 = %f, deltaPhoton2 = %f \n", deltaphiDecay1, deltaphiDecay2);
+          if( (deltaphiDecay1 > fDeltaPhiMinCut) && ( deltaphiDecay1 < fDeltaPhiMaxCut) )
+            fhPtImbalanceDecay1Neutral->Fill(ptDecay1,ratDecay1); 
+          if( (deltaphiDecay2 > fDeltaPhiMinCut) && ( deltaphiDecay2 < fDeltaPhiMaxCut) )
+            fhPtImbalanceDecay2Neutral->Fill(ptDecay2,ratDecay2);
+          if(GetDebug() > 1)printf("ratPhoton1 = %f, ratPhoton2 = %f \n", pt/ptDecay1, pt/ptDecay2);
+        }
+      } //do decay-hadron correlation
+      
+      fhEtaNeutral->Fill(pt,eta);
+      fhPhiNeutral->Fill(pt,phi);
+      fhDeltaEtaNeutral->Fill(ptTrig,etaTrig-eta);
+      fhDeltaPhiNeutral->Fill(ptTrig,deltaphi);
+      fhDeltaPhiDeltaEtaNeutral->Fill(deltaphi,etaTrig-eta);
+      
+      //delta phi cut for correlation
+      if( (deltaphi > fDeltaPhiMinCut) && ( deltaphi < fDeltaPhiMaxCut) ) {
+        fhDeltaPhiNeutralPt->Fill(pt,deltaphi);
+        fhPtImbalanceNeutral->Fill(ptTrig,rat); 
+        fhPtHbpNeutral->Fill(ptTrig,cosi); 
+      }
       else {
-       fhDeltaPhiUeNeutralPt->Fill(pt,deltaphi);
-       fhPtImbalanceUeNeutral->Fill(ptTrig,rat);
-       fhPtHbpUeNeutral->Fill(ptTrig,cosi); 
+        fhDeltaPhiUeNeutralPt->Fill(pt,deltaphi);
+        fhPtImbalanceUeNeutral->Fill(ptTrig,rat);
+        fhPtHbpUeNeutral->Fill(ptTrig,cosi); 
       }
-       //several UE calculation 
+      //several UE calculation 
       if(fMakeSeveralUE){
-        if((deltaphi<-fUeDeltaPhiMinCut) && (deltaphi >-fUeDeltaPhiMaxCut)){  
-          fhDeltaPhiUeLeftNeutral->Fill(pt,deltaphi);
-          fhPtImbalanceUeLeftNeutral->Fill(ptTrig,rat);
-          fhPtHbpUeLeftNeutral->Fill(ptTrig,cosi);
-       }
-        if((deltaphi>fUeDeltaPhiMinCut) && (deltaphi <fUeDeltaPhiMaxCut)){  
-          fhDeltaPhiUeRightNeutral->Fill(pt,deltaphi);
-          fhPtImbalanceUeRightNeutral->Fill(ptTrig,rat);
-          fhPtHbpUeRightNeutral->Fill(ptTrig,cosi);
-        }
+        if((deltaphi<-fUeDeltaPhiMinCut) && (deltaphi >-fUeDeltaPhiMaxCut)){  
+          fhDeltaPhiUeLeftNeutral->Fill(pt,deltaphi);
+          fhPtImbalanceUeLeftNeutral->Fill(ptTrig,rat);
+          fhPtHbpUeLeftNeutral->Fill(ptTrig,cosi);
+        }
+        if((deltaphi>fUeDeltaPhiMinCut) && (deltaphi <fUeDeltaPhiMaxCut)){  
+          fhDeltaPhiUeRightNeutral->Fill(pt,deltaphi);
+          fhPtImbalanceUeRightNeutral->Fill(ptTrig,rat);
+          fhPtHbpUeRightNeutral->Fill(ptTrig,cosi);
+        }
       } //several UE calculation
-         
-         
-    if(GetDebug() > 2 ) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelation() - Selected neutral for momentum imbalance: pt %2.2f, phi %2.2f, eta %2.2f \n",pt,phi,eta);
-    
-  }//loop
+         }
+    else{
+      nrefs++;
+      if(nrefs==1){
+        refpi0 = new TObjArray(0);
+        refpi0->SetName(GetAODObjArrayName()+"Pi0s");
+        refpi0->SetOwner(kFALSE);
+      }
+      refpi0->Add(pi0);
+    }//put references in trigger AOD 
+      
+     //if(GetDebug() > 2 ) printf("AliAnaParticleHadronCorrelation::MakeNeutralCorrelation() - Selected neutral for momentum imbalance: pt %2.2f, phi %2.2f, eta %2.2f \n",pt,phi,eta);
+      
+    }//loop
 }
-
+  
 
 //____________________________________________________________________________
-Bool_t  AliAnaParticleHadronCorrelation::SelectCluster(AliVCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg) {
-  //Select cluster depending on its pid and acceptance selections
-  
-  //Skip matched clusters with tracks
-  if(IsTrackMatched(calo)) return kFALSE;
-  
-  TString detector = "";
-  if     (calo->IsPHOS())  detector= "PHOS";
-  else if(calo->IsEMCAL()) detector= "EMCAL";
-               
-  //Check PID
-  calo->GetMomentum(mom,vertex);//Assume that come from vertex in straight line
-  pdg = AliCaloPID::kPhoton;   
-  if(IsCaloPIDOn()){
-    //Get most probable PID, 2 options check PID weights (in MC this option is mandatory)
-    //or redo PID, recommended option for EMCal.
-    
-    if(!IsCaloPIDRecalculationOn() || GetReader()->GetDataType() == AliCaloTrackReader::kMC )
-      pdg = GetCaloPID()->GetPdg(detector,calo->GetPID(),mom.E());//PID with weights
-    else
-      pdg = GetCaloPID()->GetPdg(detector,mom,calo);//PID recalculated
-    
-    if(GetDebug() > 5) printf("AliAnaParticleHadronCorrelation::SelectCluster() - PDG of identified particle %d\n",pdg);
-    
-    //If it does not pass pid, skip
-    if(pdg != AliCaloPID::kPhoton && pdg != AliCaloPID::kPi0) {
-      return kFALSE ;
-    }
-  }//PID on
-  
-  //Check acceptance selection
-  if(IsFiducialCutOn()){
-    Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,detector) ;
-    if(! in ) return kFALSE ;
-  }
-  
-  if(GetDebug() > 5) printf("AliAnaParticleHadronCorrelation::SelectCluster() - Correlation photon selection cuts passed: pT %3.2f, pdg %d\n",mom.Pt(), pdg);
-  
-  return kTRUE;
-  
-}
+//Bool_t  AliAnaParticleHadronCorrelation::SelectCluster(AliVCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg) {
+//  //Select cluster depending on its pid and acceptance selections
+//  
+//  //Skip matched clusters with tracks
+//  if(IsTrackMatched(calo)) return kFALSE;
+//  
+//  TString detector = "";
+//  if     (calo->IsPHOS())  detector= "PHOS";
+//  else if(calo->IsEMCAL()) detector= "EMCAL";
+//             
+//  //Check PID
+//  calo->GetMomentum(mom,vertex);//Assume that come from vertex in straight line
+//  pdg = AliCaloPID::kPhoton;   
+//  if(IsCaloPIDOn()){
+//    //Get most probable PID, 2 options check PID weights (in MC this option is mandatory)
+//    //or redo PID, recommended option for EMCal.
+//    
+//    if(!IsCaloPIDRecalculationOn() || GetReader()->GetDataType() == AliCaloTrackReader::kMC )
+//      pdg = GetCaloPID()->GetPdg(detector,calo->GetPID(),mom.E());//PID with weights
+//    else
+//      pdg = GetCaloPID()->GetPdg(detector,mom,calo);//PID recalculated
+//    
+//    if(GetDebug() > 5) printf("AliAnaParticleHadronCorrelation::SelectCluster() - PDG of identified particle %d\n",pdg);
+//    
+//    //If it does not pass pid, skip
+//    if(pdg != AliCaloPID::kPhoton && pdg != AliCaloPID::kPi0) {
+//      return kFALSE ;
+//    }
+//  }//PID on
+//  
+//  //Check acceptance selection
+//  if(IsFiducialCutOn()){
+//    Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,detector) ;
+//    if(! in ) return kFALSE ;
+//  }
+//  
+//  if(GetDebug() > 5) printf("AliAnaParticleHadronCorrelation::SelectCluster() - Correlation photon selection cuts passed: pT %3.2f, pdg %d\n",mom.Pt(), pdg);
+//  
+//  return kTRUE;
+//  
+//}
index 941a9a6..2c1d49b 100755 (executable)
 // 1. add the UE subtraction for corrlation study
 // 2. change the correlation variable
 // 3. Only use leading particle(cluster/track) as trigger for correlation (2010/07/02)
+// 4. Make decay photon-hadron correlations where decay contribute pi0 mass (2010/09/09)
 
 // --- ROOT system ---
-class TH2F;
+class TH3D;
 
 // --- Analysis system ---
 #include "AliAnaPartCorrBaseClass.h"
@@ -31,7 +32,8 @@ class AliAnaParticleHadronCorrelation : public AliAnaPartCorrBaseClass {
   AliAnaParticleHadronCorrelation & operator = (const AliAnaParticleHadronCorrelation & ph) ;//cpy assignment
 
  public:
-
+  
+  TObjString * GetAnalysisCuts();
   TList * GetCreateOutputObjects();
   
   Double_t GetDeltaPhiMaxCut() const {return fDeltaPhiMaxCut ; }
@@ -47,6 +49,11 @@ class AliAnaParticleHadronCorrelation : public AliAnaPartCorrBaseClass {
   void SwitchOnSeveralUECalculation()  { fMakeSeveralUE = kTRUE;}
   void SwitchOffSeveralUECalculation() { fMakeSeveralUE = kFALSE;}
 
+  // Do decay-hadron correlation if it is pi0 trigger
+  Bool_t IsPi0Trigger() const {return fPi0Trigger ; }
+  void SwitchOnDecayCorr()  { fPi0Trigger = kTRUE;}
+  void SwitchOffDecayCorr() { fPi0Trigger = kFALSE;}  
+  
   Bool_t OnlyIsolated() const {return fSelectIsolated ; }
   void SelectIsolated(Bool_t select) {fSelectIsolated = select ; }
   
@@ -54,14 +61,18 @@ class AliAnaParticleHadronCorrelation : public AliAnaPartCorrBaseClass {
   
   void Print(const Option_t * opt) const;
   
-  void MakeChargedCorrelation(AliAODPWG4ParticleCorrelation * aodParticle,TObjArray* const pl, const Bool_t bFillHisto) ;
-  void MakeNeutralCorrelationFillAOD(AliAODPWG4ParticleCorrelation* const aodParticle, TObjArray* const pl, TString detector)  ;
-  void MakeNeutralCorrelationFillHistograms(AliAODPWG4ParticleCorrelation* const aodParticle)  ;
+  void MakeChargedCorrelation(AliAODPWG4ParticleCorrelation * aodParticle,TObjArray* const pl,   const Bool_t bFillHisto) ;
+  void MakeNeutralCorrelation(AliAODPWG4ParticleCorrelation * aodParticle,TObjArray* const pl, const Bool_t bFillHisto) ;
+
+  //void MakeNeutralCorrelationFillAOD(AliAODPWG4ParticleCorrelation* const aodParticle, TObjArray* const pl, TString detector)  ;
+  //void MakeNeutralCorrelationFillHistograms(AliAODPWG4ParticleCorrelation* const aodParticle)  ;
        
   void MakeAnalysisFillAOD()  ;
   void MakeAnalysisFillHistograms() ; 
   
-  Bool_t SelectCluster(AliVCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg) ;
+  //Bool_t SelectCluster(AliVCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg) ;
+  
+  void SetPi0AODBranchName(TString pi0list) {fPi0AODBranchName = pi0list;}
   
  private:
   
@@ -71,8 +82,9 @@ class AliAnaParticleHadronCorrelation : public AliAnaPartCorrBaseClass {
   Bool_t     fMakeSeveralUE ;       // Do analysis for several underlying events contribution
   Double_t   fUeDeltaPhiMaxCut ;    // Minimum Delta Phi Gamma-Underlying Hadron
   Double_t   fUeDeltaPhiMinCut ;    // Maximum Delta Phi Gamma-Underlying Hadron
+  TString    fPi0AODBranchName;     // Name of AOD branch with pi0, not trigger
+  Bool_t     fPi0Trigger ;          // Do analysis with decay photon from pi0 trigger
 
-  
   //Histograms
   //leading particles 
   TH1F * fhPtLeading;         //! pT distribution of leading particles
@@ -81,46 +93,57 @@ class AliAnaParticleHadronCorrelation : public AliAnaPartCorrBaseClass {
   TH2F * fhDeltaPhiDeltaEtaCharged ; //! differences of eta and phi between trigger and charged hadrons
   TH2F * fhDeltaPhiDeltaEtaNeutral ; //! differences of eta and phi between trigger and neutral hadrons (pi0)
        
-  TH2F * fhPhiCharged  ; //! Phi distribution of charged particles
-  TH2F * fhPhiNeutral   ;  //! Phi distribution of neutral particles
-  TH2F * fhEtaCharged  ; //! Eta distribution of charged particles
-  TH2F * fhEtaNeutral   ; //! Eta distribution of neutral particles
-  TH2F * fhDeltaPhiCharged  ;  //! Difference of charged particle phi and trigger particle  phi as function of  trigger particle pT
-  TH2F * fhDeltaPhiNeutral   ;  //! Difference of neutral particle phi and trigger particle  phi as function of  trigger particle pT
-  TH2F * fhDeltaEtaCharged  ;  //! Difference of charged particle eta and trigger particle  eta as function of  trigger particle pT
-  TH2F * fhDeltaEtaNeutral  ;  //! Difference of neutral particle eta and trigger particle  eta as function of  trigger particle pT
+  TH2F * fhPhiCharged  ;         //! Phi distribution of charged particles
+  TH2F * fhPhiNeutral   ;        //! Phi distribution of neutral particles
+  TH2F * fhEtaCharged  ;         //! Eta distribution of charged particles
+  TH2F * fhEtaNeutral   ;        //! Eta distribution of neutral particles
+  TH2F * fhDeltaPhiCharged  ;    //! Difference of charged particle phi and trigger particle  phi as function of  trigger particle pT
+  TH2F * fhDeltaPhiNeutral   ;   //! Difference of neutral particle phi and trigger particle  phi as function of  trigger particle pT
+  TH2F * fhDeltaEtaCharged  ;    //! Difference of charged particle eta and trigger particle  eta as function of  trigger particle pT
+  TH2F * fhDeltaEtaNeutral  ;    //! Difference of neutral particle eta and trigger particle  eta as function of  trigger particle pT
   TH2F * fhDeltaPhiChargedPt  ;  //! Difference of charged particle phi and trigger particle  phi as function of charged particle pT
   TH2F * fhDeltaPhiNeutralPt  ;  //! Difference of neutral particle phi and trigger particle  phi as function of neutral particle particle pT
-  TH2F * fhDeltaPhiUeChargedPt  ;  //! Difference of charged particle from underlying events phi and trigger particle  phi as function of charged particle pT
-  TH2F * fhDeltaPhiUeNeutralPt  ;  //! Difference of neutral particle phi and trigger particle  phi as function of neutral particle particle pT
+  TH2F * fhDeltaPhiUeChargedPt ; //! Difference of charged particle from underlying events phi and trigger particle  phi as function of charged particle pT
+  TH2F * fhDeltaPhiUeNeutralPt ; //! Difference of neutral particle phi and trigger particle  phi as function of neutral particle particle pT
 
-  TH2F * fhPtImbalanceNeutral  ; //! Trigger particle - neutral hadron momentum imbalance histogram 
-  TH2F * fhPtImbalanceCharged  ; //! Trigger particle -charged hadron momentim imbalance histogram
+  TH2F * fhPtImbalanceNeutral  ;   //! Trigger particle - neutral hadron momentum imbalance histogram 
+  TH2F * fhPtImbalanceCharged  ;   //! Trigger particle -charged hadron momentim imbalance histogram
   TH2F * fhPtImbalanceUeCharged  ; //! Trigger particle -underlying charged hadron momentim imbalance histogram  
   TH2F * fhPtImbalanceUeNeutral  ; //! Trigger particle - neutral hadron momentum imbalance histogram 
 
   //with different imblance varible defination HBP distribution
-  TH2F * fhPtHbpCharged  ; //! Trigger particle -charged hadron momentim HBP histogram
+  TH2F * fhPtHbpCharged  ;   //! Trigger particle -charged hadron momentim HBP histogram
   TH2F * fhPtHbpUeCharged  ; //! Trigger particle -underlying charged hadron momentim HBP histogram  
-  TH2F * fhPtHbpNeutral  ; //! Trigger particle -neutral particle momentim HBP histogram
+  TH2F * fhPtHbpNeutral  ;   //! Trigger particle -neutral particle momentim HBP histogram
   TH2F * fhPtHbpUeNeutral  ; //! Trigger particle -underlying neutral hadron momentim HBP histogram  
 
   //if several UE calculation is on, most useful for jet-jet events contribution
-  TH2F * fhDeltaPhiUeLeftCharged  ;  //! Difference of charged particle from underlying events phi and trigger particle  phi as function of charged particle pT
-  TH2F * fhDeltaPhiUeRightCharged  ;  //! Difference of charged particle from underlying events phi and trigger particle  phi 
-  TH2F * fhDeltaPhiUeLeftNeutral  ;  //! Difference of charged particle from underlying events phi and trigger particle  phi as function of neutral particle pT
-  TH2F * fhDeltaPhiUeRightNeutral  ;  //! Difference of charged particle from underlying events phi and trigger particle  phi 
+  TH2F * fhDeltaPhiUeLeftCharged  ;    //! Difference of charged particle from underlying events phi and trigger particle  phi as function of charged particle pT
+  TH2F * fhDeltaPhiUeRightCharged  ;   //! Difference of charged particle from underlying events phi and trigger particle  phi 
+  TH2F * fhDeltaPhiUeLeftNeutral  ;    //! Difference of charged particle from underlying events phi and trigger particle  phi as function of neutral particle pT
+  TH2F * fhDeltaPhiUeRightNeutral  ;   //! Difference of charged particle from underlying events phi and trigger particle  phi 
   TH2F * fhPtImbalanceUeLeftCharged  ; //! Trigger particle -underlying charged hadron momentim imbalance histogram 
-  TH2F * fhPtImbalanceUeRightCharged  ; //! Trigger particle -underlying charged hadron momentim imbalance histogram  
+  TH2F * fhPtImbalanceUeRightCharged ; //! Trigger particle -underlying charged hadron momentim imbalance histogram  
   TH2F * fhPtImbalanceUeLeftNeutral  ; //! Trigger particle -underlying neutral hadron momentim imbalance histogram 
-  TH2F * fhPtImbalanceUeRightNeutral  ; //! Trigger particle -underlying neutral hadron momentim imbalance histogram 
-  TH2F * fhPtHbpUeLeftCharged  ; //! Trigger particle -underlying charged hadron momentim HBP histogram 
-  TH2F * fhPtHbpUeRightCharged  ; //! Trigger particle -underlying charged hadron momentim HBP histogram  
-  TH2F * fhPtHbpUeLeftNeutral  ; //! Trigger particle -underlying neutral hadron momentim HBP histogram 
-  TH2F * fhPtHbpUeRightNeutral  ; //! Trigger particle -underlying neutral hadron momentim HBP histogram  
+  TH2F * fhPtImbalanceUeRightNeutral ; //! Trigger particle -underlying neutral hadron momentim imbalance histogram 
+  TH2F * fhPtHbpUeLeftCharged  ;       //! Trigger particle -underlying charged hadron momentim HBP histogram 
+  TH2F * fhPtHbpUeRightCharged  ;      //! Trigger particle -underlying charged hadron momentim HBP histogram  
+  TH2F * fhPtHbpUeLeftNeutral  ;       //! Trigger particle -underlying neutral hadron momentim HBP histogram 
+  TH2F * fhPtHbpUeRightNeutral  ;      //! Trigger particle -underlying neutral hadron momentim HBP histogram  
        
+  //for decay photon trigger correlation
+  TH3D * fhPtPi0DecayRatio ;          //! for pi0 pt and ratio of decay photon pt
+  TH2F * fhDeltaPhiDecay1Charged  ;   //! Difference of charged particle phi and decay trigger
+  TH2F * fhDeltaPhiDecay2Charged  ;   //! Difference of charged particle phi and decay trigger
+  TH2F * fhPtImbalanceDecay1Charged ; //! Trigger particle (decay 1 from pi0)-charged hadron momentim imbalance histogram  
+  TH2F * fhPtImbalanceDecay2Charged ; //! Trigger particle (decay 2 from pi0) -charged hadron momentim imbalance histogram
+  
+  TH2F * fhDeltaPhiDecay1Neutral  ;   //! Difference of neutral particle phi and decay trigger
+  TH2F * fhDeltaPhiDecay2Neutral  ;   //! Difference of neutral particle phi and decay trigger
+  TH2F * fhPtImbalanceDecay1Neutral ; //! Trigger particle (decay 1 from pi0)-neutral hadron momentim imbalance histogram  
+  TH2F * fhPtImbalanceDecay2Neutral ; //! Trigger particle (decay 2 from pi0) -neutral hadron momentim imbalance histogram  
        
-  ClassDef(AliAnaParticleHadronCorrelation,3)
+  ClassDef(AliAnaParticleHadronCorrelation,4)
 } ;
  
 
index d57105c..7f40db8 100755 (executable)
@@ -247,7 +247,7 @@ void  AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD()
     return;
   }
     
-  if(!GetInputAODBranch()){
+  if(!GetInputAODBranch() || !event){
     printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() - No input particles in AOD with name branch < %s > \n",GetInputAODName().Data());
     abort();
   }
@@ -300,7 +300,7 @@ void  AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms()
     return;
   }
   
-  if(!GetInputAODBranch()){
+  if(!GetInputAODBranch() || !event){
     printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms() - No input particles in AOD with name branch < %s > \n",GetInputAODName().Data());
     abort();
   }
@@ -353,7 +353,6 @@ void  AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms()
     Float_t     rad = 0, pt = 0, eta = 0, phi = 0;
     Int_t       npartcone = 0;
     TVector3 p3;
-    AliAODTrack* track = new AliAODTrack ;
     
     Int_t ntracks =  0;
     if(!fUseJetRefTracks)
@@ -361,6 +360,7 @@ void  AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms()
     else //If you want to use jet tracks from JETAN
       ntracks =  (jet->GetRefTracks())->GetEntriesFast();
     
+    AliAODTrack* track = 0x0 ;
     for(Int_t ipr = 0;ipr < ntracks ; ipr ++ ){
       if(!fUseJetRefTracks)
         track = (AliAODTrack *) (GetAODCTS()->At(ipr)) ; 
index 4c8d64e..3b1f4c5 100755 (executable)
@@ -388,26 +388,35 @@ void AliAnaParticleJetLeadingConeCorrelation::FillJetHistos(AliAODPWG4ParticleCo
   Double_t etaJet = jet.Eta();
   Double_t etaLead = leading.Eta();
   
-  dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sPt%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))->
-    Fill(ptTrig,ptJet);
+  TH2F *h1 = 0x0;
+  h1 = dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sPt%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+  if(h1)h1->Fill(ptTrig,ptJet);
+  
+  TH2F *h2 = 0x0;
+  h2 = dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sRatioPt%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+  if(h2) h2->Fill(ptTrig,ptJet/ptTrig);
+  
+  TH2F *h3 = 0x0;
+  h3 = dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sLeadingRatioPt%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+  if(h3)h3->Fill(ptTrig,ptLead/ptJet);
   
-  dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sRatioPt%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))->
-    Fill(ptTrig,ptJet/ptTrig);
-  dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sLeadingRatioPt%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))->
-    Fill(ptTrig,ptLead/ptJet);
   //   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sPhi%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))->
   //     Fill(ptTrig,phiJet);
-  dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sDeltaPhi%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))->
-    Fill(ptTrig,phiJet-phiTrig);
-  dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sLeadingDeltaPhi%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))->
-    Fill(ptTrig,phiJet-phiLead);
+  TH2F *h4 = 0x0;
+  h4 = dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sDeltaPhi%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+  if(h4) h4->Fill(ptTrig,phiJet-phiTrig);
+  TH2F *h5 = 0x0;
+  h5 = dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sLeadingDeltaPhi%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+  if(h5) h5->Fill(ptTrig,phiJet-phiLead);
   
   //   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sEta%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))->
   //     Fill(ptTrig,etaJet);
-  dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sDeltaEta%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))->
-    Fill(ptTrig,etaJet-etaTrig);
-  dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sLeadingDeltaEta%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))->
-    Fill(ptTrig,etaJet-etaLead);
+  TH2F *h6 = 0x0;
+  h6 = dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sDeltaEta%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+  if(h6) h6->Fill(ptTrig,etaJet-etaTrig);
+  TH2F *h7 = 0x0;
+  h7 = dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sLeadingDeltaEta%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+  if(h7) h7->Fill(ptTrig,etaJet-etaLead);
   
   //Construct fragmentation function
   TObjArray * pl = new TObjArray;
@@ -435,12 +444,15 @@ void AliAnaParticleJetLeadingConeCorrelation::FillJetHistos(AliAODPWG4ParticleCo
     
     nTracksInCone++; 
     
-    dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sFFz%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))
-      ->Fill(ptTrig,p3.Pt()/ptTrig);
-    dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sFFxi%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))
-      ->Fill(ptTrig,TMath::Log(ptTrig/p3.Pt()));
-    dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sFFpt%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())))
-      ->Fill(ptTrig,p3.Pt());
+    TH2F *ha = 0x0;
+    ha =dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sFFz%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+    if(ha) ha->Fill(ptTrig,p3.Pt()/ptTrig);
+    TH2F *hb = 0x0;
+    hb =dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sFFxi%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+    if(hb) hb->Fill(ptTrig,TMath::Log(ptTrig/p3.Pt()));
+    TH2F *hc = 0x0;
+    hc =dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(Form("%s%sFFpt%s",GetAddedHistogramsStringToName().Data(),type.Data(),lastname.Data())));
+    if(hc) hc->Fill(ptTrig,p3.Pt());
     
   }//track loop
   
@@ -941,102 +953,104 @@ void  AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0(AliAODPWG4ParticleC
     TLorentzVector gammai;
     TLorentzVector gammaj;
          
-       //Get vertex for photon momentum calculation
-       Double_t vertex [] = {0,0,0} ; //vertex 
-       //Double_t vertex2[] = {0,0,0} ; //vertex of second input AOD 
-       if(GetReader()->GetDataType() != AliCaloTrackReader::kMC) 
-       {
-               GetReader()->GetVertex(vertex);
-               //if(GetReader()->GetSecondInputAODTree()) GetReader()->GetSecondInputAODVertex(vertex2);
-       }
+    //Get vertex for photon momentum calculation
+    Double_t vertex [] = {0,0,0} ; //vertex 
+    //Double_t vertex2[] = {0,0,0} ; //vertex of second input AOD 
+    if(GetReader()->GetDataType() != AliCaloTrackReader::kMC) 
+    {
+      GetVertex(vertex);
+      //if(GetReader()->GetSecondInputAODTree()) GetReader()->GetSecondInputAODVertex(vertex2);
+    }
          
     //Cluster loop, select pairs with good pt, phi and fill AODs or histograms
     for(Int_t iclus = 0;iclus < GetAODEMCAL()->GetEntriesFast() ; iclus ++ ){
       AliVCluster * calo = (AliVCluster *)(GetAODEMCAL()->At(iclus)) ;
       
-         //Input from second AOD?
-         Int_t inputi = 0;
-//       if     (particle->GetDetector() == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= iclus) inputi = 1 ;
-//       else if(particle->GetDetector() == "PHOS"  && GetReader()->GetAODPHOSNormalInputEntries()  <= iclus) inputi = 1;
-               
-         //Cluster selection, not charged, with photon or pi0 id and in fiducial cut
-         Int_t pdgi=0;
-         if     (inputi == 0 && !SelectCluster(calo, vertex,  gammai, pdgi))  continue ;
-         //else if(inputi == 1 && !SelectCluster(calo, vertex2, gammai, pdgi))  continue ;     
+      //Input from second AOD?
+      //Int_t inputi = 0;
+      //         if     (particle->GetDetector() == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= iclus) inputi = 1 ;
+      //         else if(particle->GetDetector() == "PHOS"  && GetReader()->GetAODPHOSNormalInputEntries()  <= iclus) inputi = 1;
+      
+      //Cluster selection, not charged, with photon or pi0 id and in fiducial cut
+      Int_t pdgi=0;
+      //if     (inputi == 0 && !SelectCluster(calo, vertex,  gammai, pdgi))  continue ;
+      //else if(inputi == 1 && !SelectCluster(calo, vertex2, gammai, pdgi))  continue ;        
+      if(!SelectCluster(calo, vertex,  gammai, pdgi))  continue ;
       
       if(GetDebug() > 2) printf("AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0() - Neutral cluster: pt %2.3f, phi %2.3f \n", 
-                               gammai.Pt(),gammai.Phi());
+                                gammai.Pt(),gammai.Phi());
       
       //2 gamma overlapped, found with PID
       if(pdgi == AliCaloPID::kPi0){ 
-       
-       if(GetDebug() > 2) printf("AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0() - Neutral cluster ID as Pi0 \n");
-       
-       pt  = gammai.Pt();
-       rat = pt/ptTrig;
-       phi = gammai.Phi();
-       if(phi < 0) phi+=TMath::TwoPi();
-       
-       //Selection within angular and energy limits
-       Float_t deltaphi = TMath::Abs(phiTrig-phi);
-       if(pt > ptl  && rat > fLeadingRatioMinCut  && rat < fLeadingRatioMaxCut  && 
-          deltaphi > fDeltaPhiMinCut && deltaphi < fDeltaPhiMaxCut )
-         {
-           phil = phi ;
-           ptl  = pt ;
-           pLeading.SetPxPyPzE(gammai.Px(),gammai.Py(),gammai.Pz(),gammai.E());
-         }// cuts
+        
+        if(GetDebug() > 2) printf("AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0() - Neutral cluster ID as Pi0 \n");
+        
+        pt  = gammai.Pt();
+        rat = pt/ptTrig;
+        phi = gammai.Phi();
+        if(phi < 0) phi+=TMath::TwoPi();
+        
+        //Selection within angular and energy limits
+        Float_t deltaphi = TMath::Abs(phiTrig-phi);
+        if(pt > ptl  && rat > fLeadingRatioMinCut  && rat < fLeadingRatioMaxCut  && 
+           deltaphi > fDeltaPhiMinCut && deltaphi < fDeltaPhiMaxCut )
+        {
+          phil = phi ;
+          ptl  = pt ;
+          pLeading.SetPxPyPzE(gammai.Px(),gammai.Py(),gammai.Pz(),gammai.E());
+        }// cuts
       }// pdg = AliCaloPID::kPi0
       //Make invariant mass analysis
       else if(pdgi == AliCaloPID::kPhoton){    
-       //Search the photon companion in case it comes from  a Pi0 decay
-       //Apply several cuts to select the good pair
-       for(Int_t jclus = iclus+1; jclus < GetAODEMCAL()->GetEntriesFast() ; jclus ++ ){
-         AliVCluster * calo2 = (AliVCluster *) (GetAODEMCAL()->At(jclus)) ;
-         
-         //Input from second AOD?
-         Int_t inputj = 0;
-//       if     (particle->GetDetector() == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= jclus) inputj = 1;
-//       else if(particle->GetDetector() == "PHOS"  && GetReader()->GetAODPHOSNormalInputEntries()  <= jclus) inputj = 1;
-               
-         //Cluster selection, not charged with photon or pi0 id and in fiducial cut
-         Int_t pdgj=0;
-         if     (inputj == 0 && !SelectCluster(calo2, vertex,  gammaj, pdgj))  continue ;
-         //else if(inputj == 1 && !SelectCluster(calo2, vertex2, gammaj, pdgj))  continue ;
-         
-         if(pdgj == AliCaloPID::kPhoton ){
-           
-           pt  = (gammai+gammaj).Pt();
-           phi = (gammai+gammaj).Phi();
-               if(phi < 0) phi+=TMath::TwoPi();  
-               rat = pt/ptTrig;
-               
-               //Selection within angular and energy limits
-               Float_t deltaphi = TMath::Abs(phiTrig-phi);  
-               if(GetDebug() > 3 ) printf("AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0() - Neutral Hadron Correlation: gamma pair: pt %2.2f, phi %2.2f, eta %2.2f, |phiTrig-phi| %2.3f, pt/ptTrig %2.3f, M %2.3f\n",
-                                          pt,phi,(gammai+gammaj).Eta(), deltaphi, rat, (gammai+gammaj).M());
-               
-               if(pt > ptl  && rat > fLeadingRatioMinCut  && rat < fLeadingRatioMaxCut  && 
-                  deltaphi > fDeltaPhiMinCut && deltaphi < fDeltaPhiMaxCut ){
-                 //Select good pair (aperture and invariant mass)
-                 if(GetNeutralMesonSelection()->SelectPair(gammai, gammaj)){
-                   phil = phi ;
-                   ptl  = pt ;
-                   pLeading=(gammai+gammaj);   
-                   
-                   if(GetDebug() > 3 ) printf("AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0() - Neutral Hadron Correlation: Selected gamma pair: pt %2.2f, phi %2.2f, eta %2.2f, M %2.3f\n",
-                                              ptl,phil,(gammai+gammaj).Eta(), (gammai+gammaj).M());
-                 }//pi0 selection
-                 
-                 
-               }//Pair selected as leading
-         }//if pair of gammas
-       }//2nd loop
+        //Search the photon companion in case it comes from  a Pi0 decay
+        //Apply several cuts to select the good pair
+        for(Int_t jclus = iclus+1; jclus < GetAODEMCAL()->GetEntriesFast() ; jclus ++ ){
+          AliVCluster * calo2 = (AliVCluster *) (GetAODEMCAL()->At(jclus)) ;
+          
+          //Input from second AOD?
+          //Int_t inputj = 0;
+          //     if     (particle->GetDetector() == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= jclus) inputj = 1;
+          //     else if(particle->GetDetector() == "PHOS"  && GetReader()->GetAODPHOSNormalInputEntries()  <= jclus) inputj = 1;
+          
+          //Cluster selection, not charged with photon or pi0 id and in fiducial cut
+          Int_t pdgj=0;
+          //if     (inputj == 0 && !SelectCluster(calo2, vertex,  gammaj, pdgj))  continue ;
+          //else if(inputj == 1 && !SelectCluster(calo2, vertex2, gammaj, pdgj))  continue ;
+          if     (!SelectCluster(calo2, vertex,  gammaj, pdgj))  continue ;
+
+          if(pdgj == AliCaloPID::kPhoton ){
+            
+            pt  = (gammai+gammaj).Pt();
+            phi = (gammai+gammaj).Phi();
+            if(phi < 0) phi+=TMath::TwoPi();  
+            rat = pt/ptTrig;
+            
+            //Selection within angular and energy limits
+            Float_t deltaphi = TMath::Abs(phiTrig-phi);  
+            if(GetDebug() > 3 ) printf("AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0() - Neutral Hadron Correlation: gamma pair: pt %2.2f, phi %2.2f, eta %2.2f, |phiTrig-phi| %2.3f, pt/ptTrig %2.3f, M %2.3f\n",
+                                       pt,phi,(gammai+gammaj).Eta(), deltaphi, rat, (gammai+gammaj).M());
+            
+            if(pt > ptl  && rat > fLeadingRatioMinCut  && rat < fLeadingRatioMaxCut  && 
+               deltaphi > fDeltaPhiMinCut && deltaphi < fDeltaPhiMaxCut ){
+              //Select good pair (aperture and invariant mass)
+              if(GetNeutralMesonSelection()->SelectPair(gammai, gammaj)){
+                phil = phi ;
+                ptl  = pt ;
+                pLeading=(gammai+gammaj);      
+                
+                if(GetDebug() > 3 ) printf("AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0() - Neutral Hadron Correlation: Selected gamma pair: pt %2.2f, phi %2.2f, eta %2.2f, M %2.3f\n",
+                                           ptl,phil,(gammai+gammaj).Eta(), (gammai+gammaj).M());
+              }//pi0 selection
+              
+              
+            }//Pair selected as leading
+          }//if pair of gammas
+        }//2nd loop
       }// if pdg = 22
     }// 1st Loop
     
     if(GetDebug() > 2 && pLeading.Pt() > 0 ) printf("AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0() - Leading EMCAL: pt %2.3f eta %2.3f phi %2.3f pt/Eg %2.3f \n",  
-                                                   pLeading.Pt(), pLeading.Eta(), phil,  pLeading.Pt()/ptTrig) ;
+                                                    pLeading.Pt(), pLeading.Eta(), phil,  pLeading.Pt()/ptTrig) ;
     
   }//EMCAL list exists
 }
@@ -1667,40 +1681,40 @@ void AliAnaParticleJetLeadingConeCorrelation::MakeJetFromAOD(AliAODPWG4ParticleC
 }
 
 //____________________________________________________________________________
-Bool_t  AliAnaParticleJetLeadingConeCorrelation::SelectCluster(AliVCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg) {
-  //Select cluster depending on its pid and acceptance selections
-  
-  //Skip matched clusters with tracks
-  if(IsTrackMatched(calo)) return kFALSE;
-  
-  //Check PID
-  calo->GetMomentum(mom,vertex);//Assume that come from vertex in straight line
-  pdg = AliCaloPID::kPhoton;   
-  if(IsCaloPIDOn()){
-    //Get most probable PID, 2 options check PID weights (in MC this option is mandatory)
-    //or redo PID, recommended option for EMCal.
-    if(!IsCaloPIDRecalculationOn() || GetReader()->GetDataType() == AliCaloTrackReader::kMC )
-      pdg = GetCaloPID()->GetPdg("EMCAL",calo->GetPID(),mom.E());//PID with weights
-    else
-      pdg = GetCaloPID()->GetPdg("EMCAL",mom,calo);//PID recalculated
-    
-  //  if(GetDebug() > 3) printf("AliAnaParticleJetLeadingConeCorrelation::SelectCluster() - PDG of identified particle %d\n",pdg);
-    //If it does not pass pid, skip
-    if(pdg != AliCaloPID::kPhoton && pdg != AliCaloPID::kPi0) 
-      return kFALSE ;
-  }//CaloPID
-  
-   //Check acceptance selection
-  if(IsFiducialCutOn()){
-    Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,"EMCAL") ;
-    if(! in ) return kFALSE ;
-  }
-  
-  //if(GetDebug() > 3) printf("AliAnaParticleJetLeadingConeCorrelation::SelectCluster() - Cluster selection cuts passed: pT %3.2f, pdg %d\n",mom.Pt(), pdg);
-  
-  return kTRUE; 
-  
-}
+//Bool_t  AliAnaParticleJetLeadingConeCorrelation::SelectCluster(AliVCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg) {
+//  //Select cluster depending on its pid and acceptance selections
+//  
+//  //Skip matched clusters with tracks
+//  if(IsTrackMatched(calo)) return kFALSE;
+//  
+//  //Check PID
+//  calo->GetMomentum(mom,vertex);//Assume that come from vertex in straight line
+//  pdg = AliCaloPID::kPhoton;   
+//  if(IsCaloPIDOn()){
+//    //Get most probable PID, 2 options check PID weights (in MC this option is mandatory)
+//    //or redo PID, recommended option for EMCal.
+//    if(!IsCaloPIDRecalculationOn() || GetReader()->GetDataType() == AliCaloTrackReader::kMC )
+//      pdg = GetCaloPID()->GetPdg("EMCAL",calo->GetPID(),mom.E());//PID with weights
+//    else
+//      pdg = GetCaloPID()->GetPdg("EMCAL",mom,calo);//PID recalculated
+//    
+//  //  if(GetDebug() > 3) printf("AliAnaParticleJetLeadingConeCorrelation::SelectCluster() - PDG of identified particle %d\n",pdg);
+//    //If it does not pass pid, skip
+//    if(pdg != AliCaloPID::kPhoton && pdg != AliCaloPID::kPi0) 
+//      return kFALSE ;
+//  }//CaloPID
+//  
+//   //Check acceptance selection
+//  if(IsFiducialCutOn()){
+//    Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,"EMCAL") ;
+//    if(! in ) return kFALSE ;
+//  }
+//  
+//  //if(GetDebug() > 3) printf("AliAnaParticleJetLeadingConeCorrelation::SelectCluster() - Cluster selection cuts passed: pT %3.2f, pdg %d\n",mom.Pt(), pdg);
+//  
+//  return kTRUE; 
+//  
+//}
 
 //__________________________________________________________________
 void AliAnaParticleJetLeadingConeCorrelation::Print(const Option_t * opt) const
index a806579..5580cb8 100755 (executable)
@@ -212,17 +212,23 @@ void  AliAnaParticlePartonCorrelation::MakeAnalysisFillAOD()
     }
     
     //Fill AOD reference only with partons
-    TParticle * parton = new TParticle ;
 
     //Array with reference to partons, initialize
-    TObjArray * objarray  = new TObjArray;
-
+    TObjArray * objarray  = NULL;
+    Int_t nrefs = 0;
+    
+    TParticle * parton    = NULL ;
     for(Int_t ipr = 0;ipr < 8; ipr ++ ){
       parton = stack->Particle(ipr) ;
-         objarray->Add(parton);
+      nrefs++;
+      if(nrefs==1){
+        objarray = new TObjArray(0);
+        objarray->SetName(GetAODObjArrayName());
+        objarray->SetOwner(kFALSE);
+      }
+      objarray->Add(parton);
     }//parton loop
        
-    objarray->SetName(GetAODObjArrayName());
     if(objarray->GetEntriesFast() > 0) particle->AddObjArray(objarray);
 
   }//Aod branch loop
index ca3393e..cbe4220 100755 (executable)
@@ -358,27 +358,10 @@ void AliAnaPhoton::InitParameters()
 //__________________________________________________________________
 void  AliAnaPhoton::MakeAnalysisFillAOD() 
 {
-  //Do analysis and fill aods
-  //Search for photons in fCalorimeter 
-  
-  //Get vertex for photon momentum calculation
-  
-  for (Int_t iev = 0; iev < GetNMixedEvent(); iev++) {
-    if (!GetMixedEvent()) 
-      GetReader()->GetVertex(GetVertex(iev));
-    else 
-      GetMixedEvent()->GetVertexOfEvent(iev)->GetXYZ(GetVertex(iev)); 
-  } 
+  //Do photon analysis and fill aods
   
   //  Double_t vertex2[] = {0,0,0} ; //vertex from second input aod
-  //  
-  //  if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC) 
-  //  {
-  //     if(GetReader()->GetSecondInputAODTree()) 
-  //      GetReader()->GetSecondInputAODVertex(vertex2);
-  //  }
-  //printf("Vertex 0: %f,%f,%f\n",vertex[0],vertex[1],vertex[2]);
-  //printf("Vertex 1: %f,%f,%f\n",vertex2[0],vertex2[1],vertex2[2]);
+  
   //Select the Calorimeter of the photon
   TObjArray * pl = 0x0; 
   if(fCalorimeter == "PHOS")
@@ -403,22 +386,32 @@ void  AliAnaPhoton::MakeAnalysisFillAOD()
          
          AliVCluster * calo =  (AliVCluster*) (pl->At(icalo)); 
     //printf("calo %d, %f\n",icalo,calo->E());
+    
+    //Get the index where the cluster comes, to retrieve the corresponding vertex
     Int_t evtIndex = 0 ; 
     if (GetMixedEvent()) {
       evtIndex=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
     }
+
     //Cluster selection, not charged, with photon id and in fiducial cut
          
     //Input from second AOD?
-    Int_t input = 0;
+    //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,GetVertex(evtIndex)) ;//Assume that come from vertex in straight line
+    //if (input == 0) 
+    if(GetReader()->GetDataType() != AliCaloTrackReader::kMC){
+      calo->GetMomentum(mom,GetVertex(evtIndex)) ;}//Assume that come from vertex in straight line
+    else{
+      Double_t vertex[]={0,0,0};
+      calo->GetMomentum(mom,vertex) ;
+    }
+    //printf("AliAnaPhoton::MakeAnalysisFillAOD(): Vertex : %f,%f,%f\n",GetVertex(evtIndex)[0] ,GetVertex(evtIndex)[1],GetVertex(evtIndex)[2]);
+
     //    else if(input == 1) 
     //      calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line  
     
@@ -444,7 +437,7 @@ void  AliAnaPhoton::MakeAnalysisFillAOD()
     AliAODPWG4Particle aodph = AliAODPWG4Particle(mom);
     Int_t label = calo->GetLabel();
     aodph.SetLabel(label);
-    aodph.SetInputFileIndex(input);
+    //aodph.SetInputFileIndex(input);
     
     //printf("Index %d, Id %d\n",icalo, calo->GetID());
     //Set the indeces of the original caloclusters  
@@ -529,8 +522,16 @@ void  AliAnaPhoton::MakeAnalysisFillAOD()
         Int_t evtIndex2 = 0 ; 
         if (GetMixedEvent()) {
           evtIndex2=GetMixedEvent()->EventIndexForCaloCluster(calo2->GetID()) ; 
+          
         }        
-        calo2->GetMomentum(mom2,GetVertex(evtIndex2));
+
+        if(GetReader()->GetDataType() != AliCaloTrackReader::kMC){
+          calo->GetMomentum(mom2,GetVertex(evtIndex2)) ;}//Assume that come from vertex in straight line
+        else{
+          Double_t vertex[]={0,0,0};
+          calo->GetMomentum(mom2,vertex) ;
+        }
+        
         //Check only certain regions
         Bool_t in2 = kTRUE;
         if(IsFiducialCutOn()) in2 =  GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
@@ -553,7 +554,7 @@ void  AliAnaPhoton::MakeAnalysisFillAOD()
           TLorentzVector mpair = mom+mom2;
           AliAODPWG4Particle aodpair = AliAODPWG4Particle(mpair);
           aodpair.SetLabel(aodph.GetLabel());
-          aodpair.SetInputFileIndex(input);
+          //aodpair.SetInputFileIndex(input);
           
           //printf("Index %d, Id %d\n",icalo, calo->GetID());
           //Set the indeces of the original caloclusters  
@@ -587,13 +588,13 @@ void  AliAnaPhoton::MakeAnalysisFillAOD()
 //__________________________________________________________________
 void  AliAnaPhoton::MakeAnalysisFillHistograms() 
 {
-    //Do analysis and fill histograms
-           
+  //Do analysis and fill histograms
+  
        // Access MC information in stack if requested, check that it exists.   
        AliStack * stack = 0x0;
        TParticle * primary = 0x0;   
        TClonesArray * mcparticles0 = 0x0;
-       TClonesArray * mcparticles1 = 0x0;
+       //TClonesArray * mcparticles1 = 0x0;
        AliAODMCParticle * aodprimary = 0x0; 
        if(IsDataMC()){
                
@@ -603,21 +604,21 @@ void  AliAnaPhoton::MakeAnalysisFillHistograms()
                                printf("AliAnaPhoton::MakeAnalysisFillHistograms() - Stack not available, is the MC handler called? STOP\n");
                                abort();
                        }
-               
+      
                }
                else if(GetReader()->ReadAODMCParticles()){
-       
+      
                        //Get the list of MC particles
                        mcparticles0 = GetReader()->GetAODMCParticles(0);
                        if(!mcparticles0 && GetDebug() > 0)     {
                                printf("AliAnaPhoton::MakeAnalysisFillHistograms() -  Standard MCParticles not available!\n");
                        }       
-//                     if(GetReader()->GetSecondInputAODTree()){
-//                             mcparticles1 = GetReader()->GetAODMCParticles(1);
-//                             if(!mcparticles1 && GetDebug() > 0)     {
-//                                     printf("AliAnaPhoton::MakeAnalysisFillHistograms() -  Second input MCParticles not available!\n");
-//                             }
-//                     }               
+      //                       if(GetReader()->GetSecondInputAODTree()){
+      //                               mcparticles1 = GetReader()->GetAODMCParticles(1);
+      //                               if(!mcparticles1 && GetDebug() > 0)     {
+      //                                       printf("AliAnaPhoton::MakeAnalysisFillHistograms() -  Second input MCParticles not available!\n");
+      //                               }
+      //                       }               
                        
                }
        }// is data and MC
@@ -656,60 +657,60 @@ void  AliAnaPhoton::MakeAnalysisFillHistograms()
            Int_t tag =ph->GetTag();
            
            if( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPhoton))
-             {
-               fhPtMCPhoton  ->Fill(ptcluster);
-               fhPhiMCPhoton ->Fill(ptcluster,phicluster);
-               fhEtaMCPhoton ->Fill(ptcluster,etacluster);
-               
-               if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCConversion))
-                 {
-                   fhPtConversion  ->Fill(ptcluster);
-                   fhPhiConversion ->Fill(ptcluster,phicluster);
-                   fhEtaConversion ->Fill(ptcluster,etacluster);
-                 }                     
-               
-               if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPrompt)){
-                 fhPtPrompt  ->Fill(ptcluster);
-                 fhPhiPrompt ->Fill(ptcluster,phicluster);
-                 fhEtaPrompt ->Fill(ptcluster,etacluster);
-               }
-               else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCFragmentation))
-                 {
-                   fhPtFragmentation  ->Fill(ptcluster);
-                   fhPhiFragmentation ->Fill(ptcluster,phicluster);
-                   fhEtaFragmentation ->Fill(ptcluster,etacluster);
-                 }
-               else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCISR))
-                 {
-                   fhPtISR  ->Fill(ptcluster);
-                   fhPhiISR ->Fill(ptcluster,phicluster);
-                   fhEtaISR ->Fill(ptcluster,etacluster);
-                 }
-               else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPi0Decay))
-                 {
-                   fhPtPi0Decay  ->Fill(ptcluster);
-                   fhPhiPi0Decay ->Fill(ptcluster,phicluster);
-                   fhEtaPi0Decay ->Fill(ptcluster,etacluster);
-                 }
-               else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCEtaDecay) || GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCOtherDecay))
-                 {
-                   fhPtOtherDecay  ->Fill(ptcluster);
-                   fhPhiOtherDecay ->Fill(ptcluster,phicluster);
-                   fhEtaOtherDecay ->Fill(ptcluster,etacluster);
-                 }
-             }
+      {
+        fhPtMCPhoton  ->Fill(ptcluster);
+        fhPhiMCPhoton ->Fill(ptcluster,phicluster);
+        fhEtaMCPhoton ->Fill(ptcluster,etacluster);
+        
+        if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCConversion))
+        {
+          fhPtConversion  ->Fill(ptcluster);
+          fhPhiConversion ->Fill(ptcluster,phicluster);
+          fhEtaConversion ->Fill(ptcluster,etacluster);
+        }                      
+        
+        if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPrompt)){
+          fhPtPrompt  ->Fill(ptcluster);
+          fhPhiPrompt ->Fill(ptcluster,phicluster);
+          fhEtaPrompt ->Fill(ptcluster,etacluster);
+        }
+        else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCFragmentation))
+        {
+          fhPtFragmentation  ->Fill(ptcluster);
+          fhPhiFragmentation ->Fill(ptcluster,phicluster);
+          fhEtaFragmentation ->Fill(ptcluster,etacluster);
+        }
+        else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCISR))
+        {
+          fhPtISR  ->Fill(ptcluster);
+          fhPhiISR ->Fill(ptcluster,phicluster);
+          fhEtaISR ->Fill(ptcluster,etacluster);
+        }
+        else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPi0Decay))
+        {
+          fhPtPi0Decay  ->Fill(ptcluster);
+          fhPhiPi0Decay ->Fill(ptcluster,phicluster);
+          fhEtaPi0Decay ->Fill(ptcluster,etacluster);
+        }
+        else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCEtaDecay) || GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCOtherDecay))
+        {
+          fhPtOtherDecay  ->Fill(ptcluster);
+          fhPhiOtherDecay ->Fill(ptcluster,phicluster);
+          fhEtaOtherDecay ->Fill(ptcluster,etacluster);
+        }
+      }
            else{
              fhPtUnknown  ->Fill(ptcluster);
              fhPhiUnknown ->Fill(ptcluster,phicluster);
              fhEtaUnknown ->Fill(ptcluster,etacluster);
              
-//              printf(" AliAnaPhoton::MakeAnalysisFillHistograms() - Label %d, pT %2.3f Unknown, bits set: ",
-//                                     ph->GetLabel(),ph->Pt());
-//               for(Int_t i = 0; i < 20; i++) {
-//                       if(GetMCAnalysisUtils()->CheckTagBit(tag,i)) printf(" %d, ",i);
-//               }
-//               printf("\n");
-       
+        //              printf(" AliAnaPhoton::MakeAnalysisFillHistograms() - Label %d, pT %2.3f Unknown, bits set: ",
+        //                                     ph->GetLabel(),ph->Pt());
+        //               for(Int_t i = 0; i < 20; i++) {
+        //                       if(GetMCAnalysisUtils()->CheckTagBit(tag,i)) printf(" %d, ",i);
+        //               }
+        //               printf("\n");
+        
            }
            
            
@@ -725,14 +726,14 @@ void  AliAnaPhoton::MakeAnalysisFillHistograms()
            if(GetReader()->ReadStack()){
              
              if(label >=  stack->GetNtrack()) {
-               if(GetDebug() > 2)  printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
-               continue ;
+          if(GetDebug() > 2)  printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
+          continue ;
              }
              
              primary = stack->Particle(label);
              if(!primary){
-               printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** no primary ***:  label %d \n", label);
-               continue;
+          printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** no primary ***:  label %d \n", label);
+          continue;
              }
              eprim   = primary->Energy();
              ptprim  = primary->Pt();          
@@ -741,31 +742,31 @@ void  AliAnaPhoton::MakeAnalysisFillHistograms()
            else if(GetReader()->ReadAODMCParticles()){
              //Check which is the input
              if(ph->GetInputFileIndex() == 0){
-               if(!mcparticles0) continue;
-               if(label >=  mcparticles0->GetEntriesFast()) {
-                 if(GetDebug() > 2)  printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** large label ***:  label %d, n tracks %d \n", 
-                                            label, mcparticles0->GetEntriesFast());
-                 continue ;
-               }
-               //Get the particle
-               aodprimary = (AliAODMCParticle*) mcparticles0->At(label);
-               
+          if(!mcparticles0) continue;
+          if(label >=  mcparticles0->GetEntriesFast()) {
+            if(GetDebug() > 2)  printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** large label ***:  label %d, n tracks %d \n", 
+                                       label, mcparticles0->GetEntriesFast());
+            continue ;
+          }
+          //Get the particle
+          aodprimary = (AliAODMCParticle*) mcparticles0->At(label);
+          
              }
-             else {//Second input
-               if(!mcparticles1) continue;
-               if(label >=  mcparticles1->GetEntriesFast()) {
-                 if(GetDebug() > 2)  printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** large label ***:  label %d, n tracks %d \n", 
-                                            label, mcparticles1->GetEntriesFast());
-                 continue ;
-               }
-               //Get the particle
-               aodprimary = (AliAODMCParticle*) mcparticles1->At(label);
-               
-             }//second input
+//           else {//Second input
+//          if(!mcparticles1) continue;
+//          if(label >=  mcparticles1->GetEntriesFast()) {
+//            if(GetDebug() > 2)  printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** large label ***:  label %d, n tracks %d \n", 
+//                                       label, mcparticles1->GetEntriesFast());
+//            continue ;
+//          }
+//          //Get the particle
+//          aodprimary = (AliAODMCParticle*) mcparticles1->At(label);
+//          
+//           }//second input
              
              if(!aodprimary){
-               printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** no primary ***:  label %d \n", label);
-               continue;
+          printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** no primary ***:  label %d \n", label);
+          continue;
              }
              
              eprim   = aodprimary->E();
index d0ef480..e9c81c7 100755 (executable)
@@ -569,7 +569,6 @@ void AliAnaPi0::MakeAnalysisFillHistograms()
     // get the event index in the mixed buffer where the photon comes from 
     // in case of mixing with analysis frame, not own mixing
     evtIndex1 = GetEventIndex(p1, vert) ; 
-    if(vert[2]<-fZvtxCut || vert[2]> fZvtxCut) return ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
     if ( evtIndex1 == -1 )
       return ; 
     if ( evtIndex1 == -2 )
@@ -584,6 +583,8 @@ void AliAnaPi0::MakeAnalysisFillHistograms()
       currentEvtIndex = evtIndex1 ; 
     }
     
+    //printf("AliAnaPi0::MakeAnalysisFillHistograms(): Photon 1 Evt %d  Vertex : %f,%f,%f\n",evtIndex1, GetVertex(evtIndex1)[0] ,GetVertex(evtIndex1)[1],GetVertex(evtIndex1)[2]);
+
     TLorentzVector photon1(p1->Px(),p1->Py(),p1->Pz(),p1->E());
     //Get Module number
     module1 = GetModuleNumber(p1);
@@ -596,6 +597,7 @@ void AliAnaPi0::MakeAnalysisFillHistograms()
         continue ;    
       if (GetMixedEvent() && (evtIndex1 == evtIndex2))
         continue ;
+      //printf("AliAnaPi0::MakeAnalysisFillHistograms(): Photon 2 Evt %d  Vertex : %f,%f,%f\n",evtIndex2, GetVertex(evtIndex2)[0] ,GetVertex(evtIndex2)[1],GetVertex(evtIndex2)[2]);
       TLorentzVector photon2(p2->Px(),p2->Py(),p2->Pz(),p2->E());
       //Get module number
       module2 = GetModuleNumber(p2);
@@ -756,12 +758,12 @@ void AliAnaPi0::ReadHistograms(TList* outputList)
   if(!fhMi1) fhMi1 = new TH3D*[fNCentrBin*fNPID] ;
   if(!fhMi2) fhMi2 = new TH3D*[fNCentrBin*fNPID] ;
   if(!fhMi3) fhMi3 = new TH3D*[fNCentrBin*fNPID] ;     
-  if(!fhReInvPt1) fhRe1 = new TH3D*[fNCentrBin*fNPID] ;
-  if(!fhReInvPt2) fhRe2 = new TH3D*[fNCentrBin*fNPID] ;
-  if(!fhReInvPt3) fhRe3 = new TH3D*[fNCentrBin*fNPID] ;
-  if(!fhMiInvPt1) fhMi1 = new TH3D*[fNCentrBin*fNPID] ;
-  if(!fhMiInvPt2) fhMi2 = new TH3D*[fNCentrBin*fNPID] ;
-  if(!fhMiInvPt3) fhMi3 = new TH3D*[fNCentrBin*fNPID] ;        
+  if(!fhReInvPt1) fhReInvPt1 = new TH3D*[fNCentrBin*fNPID] ;
+  if(!fhReInvPt2) fhReInvPt2 = new TH3D*[fNCentrBin*fNPID] ;
+  if(!fhReInvPt3) fhReInvPt3 = new TH3D*[fNCentrBin*fNPID] ;
+  if(!fhMiInvPt1) fhMiInvPt1 = new TH3D*[fNCentrBin*fNPID] ;
+  if(!fhMiInvPt2) fhMiInvPt2 = new TH3D*[fNCentrBin*fNPID] ;
+  if(!fhMiInvPt3) fhMiInvPt3 = new TH3D*[fNCentrBin*fNPID] ;   
   if(!fhReMod)  fhReMod = new TH3D*[fNModules] ;       
     
   for(Int_t ic=0; ic<fNCentrBin; ic++){
@@ -932,35 +934,37 @@ void AliAnaPi0::Terminate(TList* outputList)
   //____________________________________________________________________________________________________________________________________________________
 Int_t AliAnaPi0::GetEventIndex(AliAODPWG4Particle * part, Double_t * vert)  
 {
-    // retieves the event index and checks the vertex
-    //    in the mixed buffer returns -2 if vertex NOK
-    //    for normal events   returns 0 if vertex OK and -1 if vertex NOK
-  
-  Int_t rv = -1 ; 
-  if (GetMixedEvent()){
-    TObjArray * pl = 0x0; 
-    if (part->GetDetector().Contains("PHOS")) {
-      pl = GetAODPHOS();
-    } else if (part->GetDetector().Contains("EMCAL")) {
-      pl = GetAODEMCAL();
-    } else {
-      AliFatal(Form("%s is an unknown calorimeter", part->GetDetector().Data())) ; 
+  // retieves the event index and checks the vertex
+  //    in the mixed buffer returns -2 if vertex NOK
+  //    for normal events   returns 0 if vertex OK and -1 if vertex NOK
+  
+  Int_t evtIndex = -1 ; 
+  if(GetReader()->GetDataType()!=AliCaloTrackReader::kMC){
+    
+    if (GetMixedEvent()){
+      
+      evtIndex = GetMixedEvent()->EventIndexForCaloCluster(part->GetCaloLabel(0)) ;
+      GetVertex(vert,evtIndex); 
+      
+      if(vert[2] < -fZvtxCut || vert[2] > fZvtxCut)
+        evtIndex = -2 ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
+    } else {// Single event
+      
+      GetVertex(vert);
+      
+      if(vert[2] < -fZvtxCut || vert[2] > fZvtxCut)
+        evtIndex = -1 ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
+      else 
+        evtIndex = 0 ;
     }
-    rv = GetMixedEvent()->EventIndexForCaloCluster(part->GetCaloLabel(0)) ;
-    GetMixedEvent()->GetVertexOfEvent(rv)->GetXYZ(vert); 
-    if(vert[2] < -fZvtxCut || vert[2] > fZvtxCut)
-      rv = -2 ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
-  } else if(GetReader()->GetDataType()!=AliCaloTrackReader::kMC){
-    Double_t * tempo = GetReader()->GetVertex() ;
-    vert[0] = tempo[0] ; 
-    vert[1] = tempo[1] ; 
-    vert[2] = tempo[2] ; 
-    if(vert[2] < -fZvtxCut || vert[2] > fZvtxCut)
-      rv = -1 ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
-    else 
-      rv = 0 ;
   }//No MC reader
-  else rv = 0;
+  else {
+    evtIndex = 0;
+    vert[0] = 0. ; 
+    vert[1] = 0. ; 
+    vert[2] = 0. ; 
+  }
   
-  return rv ; 
+  return evtIndex ; 
 }
+
index 817e957..45505b5 100755 (executable)
@@ -269,6 +269,7 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeter()
     printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - No input calo photons in AOD with name branch < %s >, STOP \n",GetInputAODName().Data());
     abort();
   }
+  
   for(Int_t iphoton = 0; iphoton < GetInputAODBranch()->GetEntriesFast(); iphoton++){
     AliAODPWG4Particle * photon1 =  (AliAODPWG4Particle*) (GetInputAODBranch()->At(iphoton));
     
@@ -278,7 +279,6 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeter()
     
     mom1 = *(photon1->Momentum());
     
-    
     for(Int_t jphoton = iphoton+1; jphoton < GetInputAODBranch()->GetEntriesFast()-1; jphoton++){
       
       AliAODPWG4Particle * photon2 =  (AliAODPWG4Particle*) (GetInputAODBranch()->At(jphoton));
@@ -289,9 +289,9 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeter()
         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();
+      //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))
@@ -320,7 +320,7 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeter()
               label2 = mother2->GetFirstMother();
               //mother2 = GetMCStack()->Particle(label2);//pi0
             }
-            else if(GetReader()->ReadAODMCParticles() && (input > -1)){
+            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
@@ -354,7 +354,7 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeter()
         pi0.SetTag(tag);  
         //Set the indeces of the original caloclusters  
         pi0.SetCaloLabel(photon1->GetCaloLabel(0), photon2->GetCaloLabel(0));
-        pi0.SetInputFileIndex(input);
+        //pi0.SetInputFileIndex(input);
         AddAODParticle(pi0);
       }//pi0
       else{
@@ -416,8 +416,8 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
       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();
+      //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)){
@@ -441,7 +441,7 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
               label2 = mother2->GetFirstMother();
               //mother2 = GetMCStack()->Particle(label2);//pi0
             }
-            else if(GetReader()->ReadAODMCParticles() && (input > -1)){
+            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
@@ -466,7 +466,7 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
         //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);
+        //pi0.SetInputFileIndex(input);
         AddAODParticle(pi0);
       }//pi0
     }//2n photon loop
@@ -496,28 +496,37 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
   }  
   
   //Get vertex for photon momentum calculation
-  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);
-  }
+  //if(GetReader()->GetDataType() != AliCaloTrackReader::kMC) 
+  //{
+  //if(GetReader()->GetSecondInputAODTree()) GetReader()->GetSecondInputAODVertex(vertex2);
+  //}
        
   
   TLorentzVector mom ;
   for(Int_t icalo = 0; icalo < pl->GetEntriesFast(); icalo++){
     AliVCluster * calo = (AliVCluster*) (pl->At(icalo));       
     
+    Int_t evtIndex = 0 ; 
+    if (GetMixedEvent()) {
+      evtIndex=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
+    }
+    
     //Cluster selection, not charged, with pi0 id and in fiducial cut
          
     //Input from second AOD?
-    Int_t input = 0;
+    //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
+    //if     (input == 0) 
+    if(GetReader()->GetDataType() != AliCaloTrackReader::kMC){
+      calo->GetMomentum(mom,GetVertex(evtIndex)) ;}//Assume that come from vertex in straight line
+    else{
+      Double_t vertex[]={0,0,0};
+      calo->GetMomentum(mom,vertex) ;
+    }
     //else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line  
          
     //If too small or big pt, skip it
@@ -590,7 +599,7 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
     if(IsDataMC()){
       if((GetReader()->GetDataType() == AliCaloTrackReader::kMC && fAnaType!=kSSCalo) || 
          GetReader()->GetDataType() != AliCaloTrackReader::kMC){
-        aodpi0.SetInputFileIndex(input);
+        //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);
index 9f828dc..41d0834 100755 (executable)
@@ -259,7 +259,7 @@ void AliAnalysisTaskPHOSExample::Terminate(Option_t *)
 {
   // Processing when the event loop is ended
   
-  Bool_t problem = kFALSE ; 
+//  Bool_t problem = kFALSE ; 
   AliInfo(Form(" *** %s Report:", GetName())) ; 
   printf("        PHOSEnergy Mean         : %5.3f , RMS : %5.3f \n", fhPHOSEnergy->GetMean(),         fhPHOSEnergy->GetRMS()         ) ;
   printf("        PHOSDigits Mean         : %5.3f , RMS : %5.3f \n", fhPHOSDigits->GetMean(),         fhPHOSDigits->GetRMS()         ) ;
@@ -311,18 +311,18 @@ void AliAnalysisTaskPHOSExample::Terminate(Option_t *)
   cPHOS->Print("PHOS.eps");
  
   char line[1024] ; 
-  sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; 
+  snprintf(line,1024, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; 
   gROOT->ProcessLine(line);
-  sprintf(line, ".!rm -fR *.eps"); 
+  snprintf(line,1024, ".!rm -fR *.eps"); 
   gROOT->ProcessLine(line);
  
   AliInfo(Form("!!! All the eps files are in %s.tar.gz !!!", GetName())) ;
 
-  char * report = 0x0 ; 
-  if(problem)
-    sprintf(report,"Problems found, please check!!!");  
-  else 
-    sprintf(report,"OK");
+//  char * report = 0x0 ; 
+// if(problem)
+//    sprintf(report,"Problems found, please check!!!");  
+//  else 
+//    sprintf(report,"OK");
 
-  AliInfo(Form("*** %s Summary Report: %s \n",GetName(), report)) ; 
+//  AliInfo(Form("*** %s Summary Report: %s \n",GetName(), report)) ; 
 }