]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
PartCorr split in 2 Base and Dep; coding violations corrected; PHOS geometry can...
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 2 Dec 2008 10:25:57 +0000 (10:25 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 2 Dec 2008 10:25:57 +0000 (10:25 +0000)
64 files changed:
PWG4/CMakeLists.txt
PWG4/CMake_libPWG4PartCorrBase.txt [new file with mode: 0755]
PWG4/CMake_libPWG4PartCorrDep.txt [new file with mode: 0755]
PWG4/Makefile
PWG4/PROOF-INF.PWG4PartCorrBase/BUILD.sh [new file with mode: 0755]
PWG4/PROOF-INF.PWG4PartCorrBase/SETUP.C [new file with mode: 0755]
PWG4/PROOF-INF.PWG4PartCorrDep/BUILD.sh [new file with mode: 0755]
PWG4/PROOF-INF.PWG4PartCorrDep/SETUP.C [new file with mode: 0755]
PWG4/PWG4PartCorrBaseLinkDef.h [new file with mode: 0755]
PWG4/PWG4PartCorrDepLinkDef.h [new file with mode: 0755]
PWG4/PartCorrBase/AliAODPWG4Particle.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliAODPWG4Particle.h [new file with mode: 0755]
PWG4/PartCorrBase/AliAODPWG4ParticleCorrelation.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliAODPWG4ParticleCorrelation.h [new file with mode: 0755]
PWG4/PartCorrBase/AliAnaPartCorrBaseClass.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliAnaPartCorrBaseClass.h [new file with mode: 0755]
PWG4/PartCorrBase/AliAnaPartCorrMaker.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliAnaPartCorrMaker.h [new file with mode: 0755]
PWG4/PartCorrBase/AliAnaScale.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliAnaScale.h [new file with mode: 0755]
PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelation.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelation.h [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloPID.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloPID.h [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloTrackAODReader.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloTrackAODReader.h [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloTrackESDReader.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloTrackESDReader.h [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloTrackMCReader.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloTrackMCReader.h [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloTrackReader.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliCaloTrackReader.h [new file with mode: 0755]
PWG4/PartCorrBase/AliFidutialCut.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliFidutialCut.h [new file with mode: 0755]
PWG4/PartCorrBase/AliIsolationCut.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliIsolationCut.h [new file with mode: 0755]
PWG4/PartCorrBase/AliNeutralMesonSelection.cxx [new file with mode: 0755]
PWG4/PartCorrBase/AliNeutralMesonSelection.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaCaloTrigger.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaCaloTrigger.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaCaloTriggerMC.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaCaloTriggerMC.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaExample.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaExample.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticleHadronCorrelation.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticleHadronCorrelation.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticleIsolation.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticleIsolation.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticleJetFinderCorrelation.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticleJetFinderCorrelation.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticleJetLeadingConeCorrelation.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticleJetLeadingConeCorrelation.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticlePartonCorrelation.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaParticlePartonCorrelation.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaPhoton.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaPhoton.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaPi0.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaPi0.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaPi0EbE.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnaPi0EbE.h [new file with mode: 0755]
PWG4/PartCorrDep/AliAnalysisTaskPHOSExample.cxx [new file with mode: 0755]
PWG4/PartCorrDep/AliAnalysisTaskPHOSExample.h [new file with mode: 0755]
PWG4/libPWG4PartCorrBase.pkg [new file with mode: 0755]
PWG4/libPWG4PartCorrDep.pkg [new file with mode: 0755]

index e43a3f9a2f46ebd1bf775d03c38478739afa1fe3..da66df4f8af64845b50c8ec53c0048f2ff7543e2 100644 (file)
@@ -6,9 +6,11 @@
 
 set(INCLUDE_DIRECTORIES
 ${CMAKE_SOURCE_DIR}/PWG4
-${CMAKE_SOURCE_DIR}/PWG4/PartCorr
+${CMAKE_SOURCE_DIR}/PWG4/PartCorrBase
+${CMAKE_SOURCE_DIR}/PWG4/PartCorrDep
 ${CMAKE_SOURCE_DIR}/PWG4/JetTasks
 ${CMAKE_SOURCE_DIR}/PWG4/GammaConv
+${CMAKE_SOURCE_DIR}/PHOS
 ${CMAKE_SOURCE_DIR}/STEER
 ${CMAKE_SOURCE_DIR}/ANALYSIS 
 ${CMAKE_SOURCE_DIR}/JETAN 
@@ -25,6 +27,7 @@ link_directories( ${LINK_DIRECTORIES})
 
 SetModule()
 
-include(CMake_libPWG4PartCorr.txt)
+include(CMake_libPWG4PartCorrBase.txt)
+include(CMake_libPWG4PartCorrDep.txt)
 include(CMake_libPWG4JetTasks.txt)
 include(CMake_libPWG4GammaConv.txt)
diff --git a/PWG4/CMake_libPWG4PartCorrBase.txt b/PWG4/CMake_libPWG4PartCorrBase.txt
new file mode 100755 (executable)
index 0000000..4fd80f3
--- /dev/null
@@ -0,0 +1,18 @@
+# -*- mode: cmake -*-
+
+set(SRCS
+       PartCorrBase/AliAODPWG4Particle.cxx PartCorrBase/AliAODPWG4ParticleCorrelation.cxx 
+       PartCorrBase/AliNeutralMesonSelection.cxx  PartCorrBase/AliFidutialCut.cxx 
+       PartCorrBase/AliCaloPID.cxx  PartCorrBase/AliIsolationCut.cxx
+       PartCorrBase/AliAnaScale.cxx PartCorrBase/AliAnaPartCorrMaker.cxx
+       PartCorrBase/AliAnaPartCorrBaseClass.cxx PartCorrBase/AliAnalysisTaskParticleCorrelation.cxx
+       PartCorrBase/AliCaloTrackReader.cxx    PartCorrBase/AliCaloTrackESDReader.cxx
+       PartCorrBase/AliCaloTrackAODReader.cxx PartCorrBase/AliCaloTrackMCReader.cxx
+)
+
+# fill list of header files from list of source files
+# by exchanging the file extension
+String(REPLACE ".cxx" ".h" HDRS "${SRCS}")
+
+AddLibrary(PWG4PartCorrBase "${SRCS}" "${HDRS}")
+
diff --git a/PWG4/CMake_libPWG4PartCorrDep.txt b/PWG4/CMake_libPWG4PartCorrDep.txt
new file mode 100755 (executable)
index 0000000..fbb4f66
--- /dev/null
@@ -0,0 +1,18 @@
+# -*- mode: cmake -*-
+
+set(SRCS
+       PartCorrDep/AliAnaCaloTrigger.cxx PartCorrDep/AliAnaCaloTriggerMC.cxx
+       PartCorrDep/AliAnalysisTaskPHOSExample.cxx PartCorrDep/AliAnaExample.cxx
+       PartCorrDep/AliAnaPhoton.cxx PartCorrDep/AliAnaPi0.cxx PartCorrDep/AliAnaPi0EbE.cxx 
+       PartCorrDep/AliAnaParticleIsolation.cxx PartCorrDep/AliAnaParticlePartonCorrelation.cxx 
+       PartCorrDep/AliAnaParticleHadronCorrelation.cxx PartCorrDep/AliAnaParticleJetFinderCorrelation.cxx
+       PartCorrDep/AliAnaParticleJetLeadingConeCorrelation.cxx
+      
+)
+
+# fill list of header files from list of source files
+# by exchanging the file extension
+String(REPLACE ".cxx" ".h" HDRS "${SRCS}")
+
+AddLibrary(PWG4PartCorrDep "${SRCS}" "${HDRS}")
+
index 638e74dcc3b3abb184cc5cd9bf2edd9f83c087c1..43ebfe337a2606ac40e7ba4b7dfe5150095c6d55 100644 (file)
@@ -34,8 +34,18 @@ ifneq ($(JETAN_INCLUDE),)
   ALICEINC += -I../$(JETAN_INCLUDE)
 endif
 
-ifneq ($(PWG4PartCorr_INCLUDE),)
-  ALICEINC += -I../$(PWG4PartCorr_INCLUDE)
+ifneq ($(PHOSUtils_INCLUDE),)
+  ALICEINC += -I../$(PHOSUtils_INCLUDE)
+  CXXFLAGS+=-D__PHOSGEO__
+endif
+
+ifneq ($(PWG4PartCorrBase_INCLUDE),)
+  ALICEINC += -I../$(PWG4PartCorrBase_INCLUDE)
+endif
+
+ifneq ($(PWG4PartCorrDep_INCLUDE),)
+ ALICEINC += -I../$(PWG4PartCorrBase_INCLUDE) 
+ ALICEINC += -I../$(PWG4PartCorrDep_INCLUDE)
 endif
 
 ifneq ($(PWG4GammaConv_INCLUDE),)
diff --git a/PWG4/PROOF-INF.PWG4PartCorrBase/BUILD.sh b/PWG4/PROOF-INF.PWG4PartCorrBase/BUILD.sh
new file mode 100755 (executable)
index 0000000..fc9490a
--- /dev/null
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+make 
diff --git a/PWG4/PROOF-INF.PWG4PartCorrBase/SETUP.C b/PWG4/PROOF-INF.PWG4PartCorrBase/SETUP.C
new file mode 100755 (executable)
index 0000000..c91b29d
--- /dev/null
@@ -0,0 +1,13 @@
+void SETUP()
+{
+
+   // Load the ESD library
+   gSystem->Load("libPWG4PartCorrBase");
+
+   // Set the Include paths
+   gSystem->SetIncludePath("-I$ROOTSYS/include -IPWG4PartCorrBase");
+   gROOT->ProcessLine(".include PWG4PartCorrBase/PartCorrBase");
+
+   // Set our location, so that other packages can find us
+   gSystem->Setenv("PWG4PartCorrBase_INCLUDE", "PWG4PartCorrBase/PartCorrBase");
+}
diff --git a/PWG4/PROOF-INF.PWG4PartCorrDep/BUILD.sh b/PWG4/PROOF-INF.PWG4PartCorrDep/BUILD.sh
new file mode 100755 (executable)
index 0000000..fc9490a
--- /dev/null
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+make 
diff --git a/PWG4/PROOF-INF.PWG4PartCorrDep/SETUP.C b/PWG4/PROOF-INF.PWG4PartCorrDep/SETUP.C
new file mode 100755 (executable)
index 0000000..fbc2d01
--- /dev/null
@@ -0,0 +1,13 @@
+void SETUP()
+{
+
+   // Load the ESD library
+   gSystem->Load("libPWG4PartCorrDep");
+
+   // Set the Include paths
+   gSystem->SetIncludePath("-I$ROOTSYS/include -IPWG4PartCorrDep");
+   gROOT->ProcessLine(".include PWG4PartCorrDep/PartCorrDep");
+
+   // Set our location, so that other packages can find us
+   gSystem->Setenv("PWG4PartCorrDep_INCLUDE", "PWG4PartCorrDep/PartCorrDep");
+}
diff --git a/PWG4/PWG4PartCorrBaseLinkDef.h b/PWG4/PWG4PartCorrBaseLinkDef.h
new file mode 100755 (executable)
index 0000000..316ae4c
--- /dev/null
@@ -0,0 +1,22 @@
+#ifdef __CINT__
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliAODPWG4Particle+;
+#pragma link C++ class AliAODPWG4ParticleCorrelation+;
+#pragma link C++ class AliAnaScale+;
+#pragma link C++ class AliNeutralMesonSelection+;
+#pragma link C++ class AliFidutialCut+;
+#pragma link C++ class AliCaloPID+;
+#pragma link C++ class AliIsolationCut+;
+#pragma link C++ class AliAnaPartCorrMaker+;
+#pragma link C++ class AliAnaPartCorrBaseClass+;
+#pragma link C++ class AliAnalysisTaskParticleCorrelation+;
+#pragma link C++ class AliCaloTrackReader+;
+#pragma link C++ class AliCaloTrackESDReader+;
+#pragma link C++ class AliCaloTrackAODReader+;
+#pragma link C++ class AliCaloTrackMCReader+;
+
+#endif
diff --git a/PWG4/PWG4PartCorrDepLinkDef.h b/PWG4/PWG4PartCorrDepLinkDef.h
new file mode 100755 (executable)
index 0000000..90ffaa9
--- /dev/null
@@ -0,0 +1,20 @@
+#ifdef __CINT__
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliAnaCaloTrigger+;
+#pragma link C++ class AliAnaCaloTriggerMC+;
+#pragma link C++ class AliAnalysisTaskPHOSExample+;
+#pragma link C++ class AliAnaExample+;
+#pragma link C++ class AliAnaPhoton+;
+#pragma link C++ class AliAnaPi0+;
+#pragma link C++ class AliAnaPi0EbE+;
+#pragma link C++ class AliAnaParticleIsolation+;
+#pragma link C++ class AliAnaParticlePartonCorrelation+;
+#pragma link C++ class AliAnaParticleHadronCorrelation+;
+#pragma link C++ class AliAnaParticleJetFinderCorrelation+;
+#pragma link C++ class AliAnaParticleJetLeadingConeCorrelation+;
+
+#endif
diff --git a/PWG4/PartCorrBase/AliAODPWG4Particle.cxx b/PWG4/PartCorrBase/AliAODPWG4Particle.cxx
new file mode 100755 (executable)
index 0000000..b42a171
--- /dev/null
@@ -0,0 +1,164 @@
+/**************************************************************************
+ * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id:   AliAODPWG4Particle.h $ */
+
+//-------------------------------------------------------------------------
+//     AOD class for photon and other particles storage and 
+//     correlation studies
+//     Author: Yves Schutz, CERN, Gustavo Conesa, INFN
+//-------------------------------------------------------------------------
+
+//-- ROOT system --
+
+//-- Analysis system
+#include "AliAODPWG4Particle.h"
+
+ClassImp(AliAODPWG4Particle)
+
+
+//______________________________________________________________________________
+AliAODPWG4Particle::AliAODPWG4Particle() :
+AliVParticle(),
+fMomentum(0),fPdg(-1), fTag(-1), fLabel(-1), fCaloLabel(), fTrackLabel(),
+fDetector(""), fDisp(0), fTof(0), fCharged(0), fBadDist(0)
+{
+       // constructor
+       fCaloLabel [0] = -1;
+       fCaloLabel [1] = -1;
+       fTrackLabel[0] = -1;
+       fTrackLabel[1] = -1;
+}
+
+//______________________________________________________________________________
+AliAODPWG4Particle::AliAODPWG4Particle(Double_t px, Double_t py, Double_t pz, Double_t e):
+AliVParticle(),
+fMomentum(0),fPdg(-1), fTag(-1),fLabel(-1),fCaloLabel(), fTrackLabel(),
+fDetector(""), fDisp(0),fTof(0),fCharged(0), fBadDist(0)
+{
+       // constructor
+       fMomentum = new TLorentzVector(px, py, pz, e);
+       
+       fCaloLabel [0] = -1;
+       fCaloLabel [1] = -1;
+       fTrackLabel[0] = -1;
+       fTrackLabel[1] = -1;    
+}
+
+//______________________________________________________________________________
+AliAODPWG4Particle::AliAODPWG4Particle(TLorentzVector & p):
+AliVParticle(),
+fMomentum(0),fPdg(-1), fTag(-1),fLabel(-1),fCaloLabel(), fTrackLabel(),
+fDetector(""), fDisp(0),fTof(0),fCharged(0),fBadDist(0)
+{
+       // constructor
+    fMomentum = new TLorentzVector(p);
+       
+       fCaloLabel [0] = -1;
+       fCaloLabel [1] = -1;
+       fTrackLabel[0] = -1;
+       fTrackLabel[1] = -1;
+}
+
+
+//______________________________________________________________________________
+AliAODPWG4Particle::~AliAODPWG4Particle() 
+{
+       // destructor
+    delete fMomentum;
+}
+
+//______________________________________________________________________________
+AliAODPWG4Particle::AliAODPWG4Particle(const AliAODPWG4Particle& part) :
+AliVParticle(part),
+fMomentum(0), fPdg(part.fPdg), fTag(part.fTag), fLabel(part.fLabel), fCaloLabel(), fTrackLabel(),
+fDetector(part.fDetector),fDisp(part.fDisp), fTof(part.fTof), fCharged(part.fCharged),  fBadDist(part.fBadDist)
+
+{
+       // Copy constructor
+       fMomentum = new TLorentzVector(*part.fMomentum);
+       
+       fCaloLabel [0] = part.fCaloLabel[0];
+       fCaloLabel [1] = part.fCaloLabel[1];
+       fTrackLabel[0] = part.fTrackLabel[0];
+       fTrackLabel[1] = part.fTrackLabel[1];
+}
+
+//______________________________________________________________________________
+AliAODPWG4Particle& AliAODPWG4Particle::operator=(const AliAODPWG4Particle& part)
+{
+       // Assignment operator
+       if(this!=&part) {
+               
+               fPdg = part.fPdg;
+               fTag = part.fTag;
+               fLabel = part.fLabel;
+               fCaloLabel [0] = part.fCaloLabel[0];
+               fCaloLabel [1] = part.fCaloLabel[1];
+               fTrackLabel[0] = part.fTrackLabel[0];
+               fTrackLabel[1] = part.fTrackLabel[1];
+               fDetector =part.fDetector;
+               
+               fDisp = part.fDisp; 
+               fTof = part.fTof; 
+               fCharged = part.fCharged; 
+               fBadDist=part.fBadDist;
+               
+               if (fMomentum ) delete fMomentum;       
+               fMomentum = new TLorentzVector(*part.fMomentum);
+       }
+       
+       return *this;
+}
+
+
+//_______________________________________________________________
+Bool_t AliAODPWG4Particle::IsPIDOK(const Int_t ipid, const Int_t pdgwanted) const{
+       // returns true if particle satisfies given PID criterium
+       switch(ipid){
+               case 0: return kTRUE ; //No PID at all
+               case 1: 
+               {
+                       if (fPdg == pdgwanted) return kTRUE; 
+                       else return kFALSE; //Overall PID calculated with bayesian methods.
+               }
+               case 2: return fDisp ;   //only dispersion cut
+               case 3: return fTof ;    //Only TOF cut
+               case 4: return fCharged ;    //Only Charged cut
+               case 5: return fDisp && fTof ;  //Dispersion and TOF
+               case 6: return fDisp && fCharged ;  //Dispersion and Charged
+               case 7: return fTof  && fCharged ;  //TOF and Charged
+               case 8: return fDisp && fTof && fCharged ; // all 3 cuts
+               default: return kFALSE ; //Not known combination
+       }
+}
+
+//______________________________________________________________________________
+void AliAODPWG4Particle::Print(Option_t* /*option*/) const 
+{
+       // Print information of all data members
+       printf("Particle 4-vector:\n");
+       printf("     E  = %13.3f\n", E() );
+       printf("     Px = %13.3f\n", Px());
+       printf("     Py = %13.3f\n", Py());
+       printf("     Pz = %13.3f\n", Pz());
+       printf("TOF bit        : %d\n",fTof);
+       printf("Charged bit    : %d\n",fCharged);
+       printf("Dispersion bit : %d\n",fDisp);
+       printf("pdg : %d\n",fPdg);
+       printf("tag : %d\n",fTag);  
+       printf("Trigger Detector : %s\n",fDetector.Data());
+       
+}
diff --git a/PWG4/PartCorrBase/AliAODPWG4Particle.h b/PWG4/PartCorrBase/AliAODPWG4Particle.h
new file mode 100755 (executable)
index 0000000..40547b8
--- /dev/null
@@ -0,0 +1,111 @@
+#ifndef ALIAODPWG4PARTICLE_H
+#define ALIAODPWG4PARTICLE_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliAODPWG4Particle.h  $ */
+
+//-------------------------------------------------------------------------
+//     Copy of AOD photon class, adapted for particle identification
+//     and correlations analysis
+//     Author: Yves Schutz, CERN, Gustavo Conesa, INFN
+//-------------------------------------------------------------------------
+
+//-- ROOT system --
+#include <TLorentzVector.h>
+class TString;
+
+//-- Analysis system
+#include "AliVParticle.h"
+
+class AliAODPWG4Particle : public AliVParticle {
+
+ public:
+    AliAODPWG4Particle();
+    AliAODPWG4Particle(Double_t px, Double_t py, Double_t pz, Double_t e);
+    AliAODPWG4Particle(TLorentzVector & p);  
+    virtual ~AliAODPWG4Particle();
+    AliAODPWG4Particle(const AliAODPWG4Particle& photon); 
+    AliAODPWG4Particle& operator=(const AliAODPWG4Particle& photon);
+
+    // AliVParticle methods
+    virtual Double_t Px()         const { return fMomentum->Px();      }
+    virtual Double_t Py()         const { return fMomentum->Py();      }
+    virtual Double_t Pz()         const { return fMomentum->Pz();      }
+    virtual Double_t Pt()         const { return fMomentum->Pt();      }
+    virtual Double_t P()          const { return fMomentum->P();       }
+    virtual Bool_t   PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE; }
+    virtual Double_t OneOverPt()  const { return 1. / fMomentum->Pt(); }
+    virtual Double_t Phi()        const;
+    virtual Double_t Theta()      const { return fMomentum->Theta();   }
+    virtual Double_t E()          const { return fMomentum->E();       }
+    virtual Double_t M()          const { return fMomentum->M();       }
+    virtual Double_t Eta()        const { return fMomentum->Eta();     }
+    virtual Double_t Y()          const { return fMomentum->Rapidity();}
+    virtual Double_t Xv()         const {return -999.;} // put reasonable values here
+    virtual Double_t Yv()         const {return -999.;} //
+    virtual Double_t Zv()         const {return -999.;} //
+    virtual Bool_t   XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE; }  
+    virtual void     Print(Option_t* /*option*/) const;
+
+    //
+    //Dummy
+    virtual Short_t Charge()      const { return 0;}
+    virtual const Double_t* PID() const { return NULL;}
+    //
+
+    virtual Int_t GetPdg()   const {return fPdg ; }
+    virtual Int_t GetTag()   const {return fTag ; }
+    virtual Int_t GetLabel()   const {return fLabel ; }
+       virtual Int_t GetCaloLabel (Int_t i) const {return fCaloLabel[i];}
+       virtual Int_t GetTrackLabel(Int_t i) const {return fTrackLabel[i];}
+    virtual TString GetDetector()   const {return fDetector ; }
+
+    virtual Bool_t   GetDispBit(void) const {return fDisp;}
+    virtual Bool_t   GetTOFBit(void) const {return fTof;}
+    virtual Bool_t   GetChargedBit(void) const {return fCharged;}
+    virtual Int_t    DistToBad() const  {return fBadDist ;} 
+
+    virtual void SetPdg(Int_t pdg)   {fPdg = pdg ; }
+    virtual void SetTag(Int_t tag)   {fTag = tag ; }
+    virtual void SetLabel(Int_t l)   {fLabel = l ; }
+       virtual void SetCaloLabel (Int_t a, Int_t b)   {fCaloLabel [0] = a; fCaloLabel [1] = b  ; }
+       virtual void SetTrackLabel(Int_t a, Int_t b)   {fTrackLabel[0] = a; fTrackLabel[1] = b  ; }
+       virtual void SetDetector(TString d)   {fDetector = d ; }
+
+    virtual void SetDispBit(Bool_t chi2){fDisp = chi2 ;} 
+    virtual void SetTOFBit(Bool_t tof){fTof = tof ;} 
+    virtual void SetChargedBit(Bool_t ch){fCharged = ch; }
+    virtual void SetDistToBad(Int_t dist){fBadDist=dist;} 
+  
+       TLorentzVector  * Momentum() const {return fMomentum ; }
+    virtual void SetMomentum(TLorentzVector *lv) {fMomentum = lv ; }
+  
+       Bool_t IsPIDOK(const Int_t ipid, const Int_t pdgwanted) const;
+  
+ private:
+    TLorentzVector* fMomentum;  // Photon 4-momentum vector
+    Int_t           fPdg;       // id of particle
+    Int_t           fTag;       // tag of particle (decay, fragment, prompt photon)
+    Int_t           fLabel;     // MC label
+       Int_t                   fCaloLabel[2];  // CaloCluster index, 1 for photons, 2 for pi0.
+       Int_t           fTrackLabel[2]; // Track lable, 1 for pions, 2 for conversion photons 
+    TString         fDetector;  // Detector where particle was measured.
+       
+    Bool_t                     fDisp ;     //Dispersion bit
+    Bool_t                     fTof ;      //TOF bit
+    Bool_t                     fCharged ;  //Charged bit
+    Int_t           fBadDist ;  //Distance to bad module in module units
+       
+       ClassDef(AliAODPWG4Particle,1);
+};
+
+inline Double_t AliAODPWG4Particle::Phi() const
+{
+  // Return phi
+  Double_t phi = fMomentum->Phi();
+  if (phi < 0.) phi += 2. * TMath::Pi();
+  return phi;
+}
+
+#endif //ALIAODPWG4PARTICLE_H
diff --git a/PWG4/PartCorrBase/AliAODPWG4ParticleCorrelation.cxx b/PWG4/PartCorrBase/AliAODPWG4ParticleCorrelation.cxx
new file mode 100755 (executable)
index 0000000..60f0675
--- /dev/null
@@ -0,0 +1,152 @@
+/**************************************************************************
+ * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id:   AliAODPWG4ParticleCorrelation.h $ */
+
+//-------------------------------------------------------------------------
+//     AOD class for photon and other particles storage and 
+//     correlation studies
+//     Author: Yves Schutz, CERN, Gustavo Conesa, INFN
+//-------------------------------------------------------------------------
+
+//-- ROOT system --
+
+//-- Analysis system
+#include "AliAODPWG4ParticleCorrelation.h"
+#include "AliAODJet.h"
+
+ClassImp(AliAODPWG4ParticleCorrelation)
+
+
+//______________________________________________________________________________
+AliAODPWG4ParticleCorrelation::AliAODPWG4ParticleCorrelation() :
+    AliAODPWG4Particle(), fIsolated(kFALSE),
+    fRefTracks(new TRefArray()), fRefClusters(new TRefArray()),
+    fRefIsolationConeTracks(new TRefArray()), fRefIsolationConeClusters(new TRefArray()),
+    fRefBackgroundTracks(new TRefArray()), fRefBackgroundClusters(new TRefArray()),  
+    fLeadingDetector(""), fLeading(), fCorrJet(),  fCorrBkg(), fRefJet(0)
+{
+  // constructor
+}
+
+//______________________________________________________________________________
+AliAODPWG4ParticleCorrelation::AliAODPWG4ParticleCorrelation(Double_t px, Double_t py, Double_t pz, Double_t e):
+    AliAODPWG4Particle(), fIsolated(kFALSE),
+    fRefTracks(new TRefArray()), fRefClusters(new TRefArray()),
+    fRefIsolationConeTracks(new TRefArray()), fRefIsolationConeClusters(new TRefArray()),
+    fRefBackgroundTracks(new TRefArray()), fRefBackgroundClusters(new TRefArray()),
+    fLeadingDetector(""),  fLeading(), fCorrJet(),
+    fCorrBkg(), fRefJet(0)
+{
+  // constructor
+    SetMomentum(new TLorentzVector(px, py, pz, e));
+}
+
+//______________________________________________________________________________
+AliAODPWG4ParticleCorrelation::AliAODPWG4ParticleCorrelation(TLorentzVector & p):
+    AliAODPWG4Particle(p), fIsolated(kFALSE),
+    fRefTracks(new TRefArray()), fRefClusters(new TRefArray()),
+    fRefIsolationConeTracks(new TRefArray()), fRefIsolationConeClusters(new TRefArray()),
+    fRefBackgroundTracks(new TRefArray()), fRefBackgroundClusters(new TRefArray()),  
+    fLeadingDetector(""),  fLeading(), fCorrJet(), fCorrBkg(),fRefJet(0)
+{
+  // constructor
+}
+
+//______________________________________________________________________________
+AliAODPWG4ParticleCorrelation::AliAODPWG4ParticleCorrelation(AliAODPWG4Particle & p):
+    AliAODPWG4Particle(p), fIsolated(kFALSE),
+    fRefTracks(new TRefArray()), fRefClusters(new TRefArray()),
+    fRefIsolationConeTracks(new TRefArray()), fRefIsolationConeClusters(new TRefArray()),
+    fRefBackgroundTracks(new TRefArray()), fRefBackgroundClusters(new TRefArray()),  
+    fLeadingDetector(""),  fLeading(), fCorrJet(), fCorrBkg(),fRefJet(0)
+{
+  // constructor
+
+}
+
+//______________________________________________________________________________
+AliAODPWG4ParticleCorrelation::~AliAODPWG4ParticleCorrelation() 
+{
+  // destructor
+    delete fRefTracks;
+    delete fRefClusters;
+    delete fRefIsolationConeTracks;
+    delete fRefIsolationConeClusters;
+    delete fRefBackgroundTracks;
+    delete fRefBackgroundClusters;
+
+}
+
+//______________________________________________________________________________
+AliAODPWG4ParticleCorrelation::AliAODPWG4ParticleCorrelation(const AliAODPWG4ParticleCorrelation& part) :
+    AliAODPWG4Particle(part), fIsolated(part.fIsolated),
+    fRefTracks(), fRefClusters(),
+    fRefIsolationConeTracks(), fRefIsolationConeClusters(),
+    fRefBackgroundTracks(), fRefBackgroundClusters(),   
+    fLeadingDetector(part.fLeadingDetector), fLeading(part.fLeading),  
+    fCorrJet(part.fCorrJet), fCorrBkg(part.fCorrBkg), fRefJet(part.fRefJet)
+{
+  // Copy constructor
+  fRefTracks                = new TRefArray(*part.fRefTracks);
+  fRefClusters              = new TRefArray(*part.fRefClusters);
+  fRefIsolationConeTracks   = new TRefArray(*part.fRefIsolationConeTracks);
+  fRefIsolationConeClusters = new TRefArray(*part.fRefIsolationConeClusters);
+  fRefBackgroundTracks      = new TRefArray(*part.fRefBackgroundTracks);
+  fRefBackgroundClusters    = new TRefArray(*part.fRefBackgroundClusters);
+}
+
+//______________________________________________________________________________
+AliAODPWG4ParticleCorrelation& AliAODPWG4ParticleCorrelation::operator=(const AliAODPWG4ParticleCorrelation& part)
+{
+  // Assignment operator
+  if(this!=&part) {
+  
+       fIsolated = part.fIsolated;
+       fRefJet   = part.fRefJet ;
+       fLeadingDetector =part.fLeadingDetector;
+       fLeading  = part.fLeading;
+       fCorrJet  = part.fCorrJet ;
+       fCorrBkg  = part.fCorrBkg;
+
+       if( fRefTracks )               delete fRefTracks ;
+       if( fRefClusters)              delete fRefClusters ;
+       if( fRefIsolationConeTracks )  delete fRefIsolationConeTracks ;
+       if( fRefIsolationConeClusters) delete fRefIsolationConeClusters ;
+       if( fRefBackgroundTracks )     delete fRefBackgroundTracks ;
+       if( fRefBackgroundClusters )   delete fRefBackgroundClusters ;
+
+       fRefTracks                = new TRefArray(*part.fRefTracks);
+       fRefClusters              = new TRefArray(*part.fRefClusters);
+       fRefIsolationConeTracks   = new TRefArray(*part.fRefIsolationConeTracks);
+       fRefIsolationConeClusters = new TRefArray(*part.fRefIsolationConeClusters);
+       fRefBackgroundTracks      = new TRefArray(*part.fRefBackgroundTracks);
+       fRefBackgroundClusters    = new TRefArray(*part.fRefBackgroundClusters);  
+  
+  }
+  
+  return *this;
+}
+
+//______________________________________________________________________________
+void AliAODPWG4ParticleCorrelation::Print(Option_t* /*option*/) const 
+{
+  // Print information of all data members
+  AliAODPWG4Particle::Print("");
+  if(fIsolated) printf("Isolated! \n");
+  printf("Leading Detector : %s\n",fLeadingDetector.Data());
+  // if(fRefJet) fRefJet.Print();
+
+}
diff --git a/PWG4/PartCorrBase/AliAODPWG4ParticleCorrelation.h b/PWG4/PartCorrBase/AliAODPWG4ParticleCorrelation.h
new file mode 100755 (executable)
index 0000000..618e78b
--- /dev/null
@@ -0,0 +1,102 @@
+#ifndef ALIAODPWG4PARTICLECORRELATION_H
+#define ALIAODPWG4PARTICLECORRELATION_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliAODPWG4ParticleCorrelation.h  $ */
+
+//-------------------------------------------------------------------------
+//     Copy of AOD photon class, adapted for particle identification
+//     and correlations analysis
+//     Author: Yves Schutz, CERN, Gustavo Conesa, INFN
+//-------------------------------------------------------------------------
+
+//-- ROOT system --
+
+//-- Analysis system
+#include "AliAODJet.h" 
+#include "AliAODPWG4Particle.h"
+
+class AliAODPWG4ParticleCorrelation : public AliAODPWG4Particle {
+
+ public:
+    AliAODPWG4ParticleCorrelation();
+    AliAODPWG4ParticleCorrelation(Double_t px, Double_t py, Double_t pz, Double_t e);
+    AliAODPWG4ParticleCorrelation(TLorentzVector & p);  
+    AliAODPWG4ParticleCorrelation(AliAODPWG4Particle & p);  
+
+    virtual ~AliAODPWG4ParticleCorrelation();
+    AliAODPWG4ParticleCorrelation(const AliAODPWG4ParticleCorrelation& photon); 
+    AliAODPWG4ParticleCorrelation& operator=(const AliAODPWG4ParticleCorrelation& photon);
+
+    virtual Float_t IsIsolated() const { return fIsolated ;}
+    virtual void    SetIsolated(Bool_t iso) {fIsolated = iso ;}
+
+    virtual TRefArray* GetRefTracks()    const { return  fRefTracks;}
+    virtual void       AddTrack(TObject *tr) {fRefTracks->Add(tr);}
+    virtual TObject*   GetTrack(Int_t i) const { return fRefTracks->At(i);}
+
+    virtual TRefArray* GetRefClusters()    const { return  fRefClusters;}
+    virtual void       AddCluster(TObject *tr) {fRefClusters->Add(tr);}
+    virtual TObject*   GetCluster(Int_t i) const { return fRefClusters->At(i);}
+
+    virtual TRefArray* GetRefIsolationConeTracks()  const { return  fRefIsolationConeTracks;}
+    virtual void     AddIsolationConeTrack(TObject *tr) {fRefIsolationConeTracks->Add(tr);}
+    virtual TObject* GetIsolationConeTrack(Int_t i) const { return fRefIsolationConeTracks->At(i);}
+
+    virtual TRefArray* GetRefIsolationConeClusters()  const { return  fRefIsolationConeClusters;}
+    virtual void     AddIsolationConeCluster(TObject *tr) {fRefIsolationConeClusters->Add(tr);}
+    virtual TObject* GetIsolationConeCluster(Int_t i) const { return fRefIsolationConeClusters->At(i);}
+
+    virtual TRefArray* GetRefBackgroundTracks()  const { return  fRefBackgroundTracks;}
+    virtual void     AddBackgroundTrack(TObject *tr) {fRefBackgroundTracks->Add(tr);}
+    virtual TObject* GetBackgroundTrack(Int_t i) const { return fRefBackgroundTracks->At(i);}
+
+    virtual TRefArray* GetRefBackgroundClusters()    const { return  fRefBackgroundClusters;}
+    virtual void       AddBackgroundCluster(TObject *tr) {fRefBackgroundClusters->Add(tr);}
+    virtual TObject*   GetBackgroundCluster(Int_t i) const { return fRefBackgroundClusters->At(i);}
+
+    virtual TString GetLeadingDetector()   const {return fLeadingDetector ; }
+    virtual void SetLeadingDetector(TString d)   {fLeadingDetector = d ; }
+    
+    virtual TLorentzVector  GetLeading()               const { return  fLeading;}
+    virtual void  SetLeading(TLorentzVector lead) {fLeading = lead;}
+
+    virtual TLorentzVector  GetCorrelatedJet()         const { return  fCorrJet;}
+    virtual void  SetCorrelatedJet(TLorentzVector jet) {fCorrJet = jet;}
+
+    virtual TLorentzVector  GetCorrelatedBackground()  const { return  fCorrBkg;}
+    virtual void  SetCorrelatedBackground(TLorentzVector bkg) {fCorrBkg = bkg;}
+
+    virtual void SetRefJet(AliAODJet* jet)  { fRefJet = jet;}
+    virtual      AliAODJet* GetJet() const {return ((AliAODJet*) fRefJet.GetObject());}
+    virtual TRef GetRefJet()         const {return fRefJet;}
+
+    virtual void   Print(Option_t* /*option*/) const;
+
+ private:
+
+       Float_t            fIsolated ; //Particle is isolated or not
+       
+    TRefArray*     fRefTracks;  // array of references to the tracks belonging to the jet / all selected hadrons  
+    TRefArray*     fRefClusters; // array of references to the clusters belonging to the jet / all selected hadrons  
+    
+    TRefArray*     fRefIsolationConeTracks;  // array of references to the tracks belonging to the cone around direct particle candidate  
+    TRefArray*     fRefIsolationConeClusters; // array of references to the clusters belonging to the  cone around direct particle candidate  
+
+    TRefArray*     fRefBackgroundTracks;  // array of references to the tracks for background stimation
+    TRefArray*     fRefBackgroundClusters; // array of references to the clusters for background stimation 
+
+    TString        fLeadingDetector; // Detector where leading particle was measured.
+    TLorentzVector fLeading;     // Leading Particle 4-momentum vector
+    
+    TLorentzVector fCorrJet;     // Jet  4-momentum vector
+    TLorentzVector fCorrBkg;     // Background  4-momentum vector
+
+    TRef           fRefJet; // Rerence to jet found with JETAN and correlated with particle
+
+    ClassDef(AliAODPWG4ParticleCorrelation,1);
+};
+
+
+#endif //ALIAODPWG4PARTICLECORRELATION_H
diff --git a/PWG4/PartCorrBase/AliAnaPartCorrBaseClass.cxx b/PWG4/PartCorrBase/AliAnaPartCorrBaseClass.cxx
new file mode 100755 (executable)
index 0000000..ed52d4a
--- /dev/null
@@ -0,0 +1,389 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Base class for analysis algorithms
+//-- Author: Gustavo Conesa (LNF-INFN) 
+//_________________________________________________________________________
+  
+
+// --- ROOT system ---
+#include <TClonesArray.h>
+
+//---- AliRoot system ----
+#include "AliAODPWG4Particle.h"
+#include "AliAODCaloCluster.h"
+#include "AliAODCaloCells.h"
+#include "AliAODTrack.h"
+#include "AliAnaPartCorrBaseClass.h"
+#include "AliCaloTrackReader.h"
+#include "AliCaloPID.h"
+#include "AliFidutialCut.h"
+#include "AliIsolationCut.h"
+#include "AliNeutralMesonSelection.h"
+#include "AliLog.h"
+#include "AliAODPWG4ParticleCorrelation.h"
+
+ClassImp(AliAnaPartCorrBaseClass)
+  
+  
+//_______________________________________________
+  AliAnaPartCorrBaseClass::AliAnaPartCorrBaseClass() : 
+    TObject(), fDataMC(0), fDebug(0), fCheckFidCut(0),
+    fCheckCaloPID(0), fRecalculateCaloPID(0), fMinPt(0), fMaxPt(0),
+    fReader(0x0),
+       fInputAODBranch(0x0), fInputAODName(""),
+       fOutputAODBranch(0x0), fNewAOD(kFALSE),
+       fOutputAODName(""), fOutputAODClassName(""),
+       fAODCaloClusters(0x0), fAODCaloCells(0x0), 
+    fCaloPID(0x0), fFidCut(0x0), fIC(0x0),fNMS(0x0),
+       fHistoNPtBins(0),  fHistoPtMax(0.),  fHistoPtMin(0.),
+       fHistoNPhiBins(0), fHistoPhiMax(0.), fHistoPhiMin(0.),
+       fHistoNEtaBins(0), fHistoEtaMax(0.), fHistoEtaMin(0.)
+{
+  //Default Ctor
+  
+  fReader  = new AliCaloTrackReader();
+  fCaloPID = new AliCaloPID();
+  fFidCut  = new AliFidutialCut();
+  fIC      = new AliIsolationCut();
+  
+  //Initialize parameters
+  InitParameters();
+}
+
+//___________________________________________________________
+AliAnaPartCorrBaseClass::AliAnaPartCorrBaseClass(const AliAnaPartCorrBaseClass & abc) :   
+  TObject(), fDataMC(abc.fDataMC), fDebug(abc.fDebug),
+  fCheckFidCut(abc.fCheckFidCut),  fCheckCaloPID(abc. fCheckCaloPID),
+  fRecalculateCaloPID(abc.fRecalculateCaloPID),
+  fMinPt(abc.fMinPt), fMaxPt(abc.fMaxPt), fReader(abc.fReader),  
+  fInputAODBranch(new TClonesArray(*abc.fInputAODBranch)), fInputAODName(abc.fInputAODName),
+  fOutputAODBranch(new TClonesArray(*abc.fOutputAODBranch)),fNewAOD(abc.fNewAOD), 
+  fOutputAODName(abc.fOutputAODName), fOutputAODClassName(abc.fOutputAODClassName),
+  fAODCaloClusters(new TClonesArray(*abc.fAODCaloClusters)),
+  fAODCaloCells(new AliAODCaloCells(*abc.fAODCaloCells)),
+  fCaloPID(abc.fCaloPID), fFidCut(abc.fFidCut), fIC(abc.fIC),fNMS(abc.fNMS),
+  fHistoNPtBins(abc.fHistoNPtBins),   fHistoPtMax(abc.fHistoPtMax),   fHistoPtMin(abc.fHistoPtMin),
+  fHistoNPhiBins(abc.fHistoNPhiBins), fHistoPhiMax(abc.fHistoPhiMax), fHistoPhiMin(abc.fHistoPhiMin),
+  fHistoNEtaBins(abc.fHistoNEtaBins), fHistoEtaMax(abc.fHistoEtaMax), fHistoEtaMin(abc.fHistoEtaMin)
+{
+  // cpy ctor
+  
+}
+
+//_________________________________________________________________________
+AliAnaPartCorrBaseClass & AliAnaPartCorrBaseClass::operator = (const AliAnaPartCorrBaseClass & abc)
+{
+       // assignment operator
+       
+       if(this == &abc) return *this;
+       ((TObject *)this)->operator=(abc);
+       
+       fDataMC             = abc.fDataMC;
+       fDebug              = abc.fDebug ;
+       fRecalculateCaloPID = abc.fRecalculateCaloPID ;
+       fCheckCaloPID       = abc.fCheckCaloPID ;
+       fCheckFidCut        = abc.fCheckFidCut ; 
+       
+       fReader             = abc.fReader ;
+       fAODCaloClusters   = new TClonesArray(*abc.fAODCaloClusters) ;
+       fAODCaloCells      = new AliAODCaloCells(*abc.fAODCaloCells) ;
+       
+       fMinPt   = abc.fMinPt;
+       fMaxPt   = abc.fMaxPt;
+       fCaloPID = abc.fCaloPID;  
+       fFidCut  = abc.fFidCut;
+       fIC      = abc.fIC;
+       fNMS     = abc.fNMS;
+       
+       fInputAODBranch     = new TClonesArray(*abc.fInputAODBranch) ;
+       fInputAODName       = abc.fInputAODName;
+       fOutputAODBranch    = new TClonesArray(*abc.fOutputAODBranch) ;
+       fNewAOD             = abc.fNewAOD ; 
+       fOutputAODName      = abc.fOutputAODName; 
+       fOutputAODClassName = abc.fOutputAODClassName;
+       
+       
+       fHistoNPtBins  = abc.fHistoNPtBins;  fHistoPtMax  = abc.fHistoPtMax;  fHistoPtMin  = abc.fHistoPtMin;
+       fHistoNPhiBins = abc.fHistoNPhiBins; fHistoPhiMax = abc.fHistoPhiMax; fHistoPhiMin = abc.fHistoPhiMin;
+       fHistoNEtaBins = abc.fHistoNEtaBins; fHistoEtaMax = abc.fHistoEtaMax; fHistoEtaMin = abc.fHistoEtaMin;
+       
+       return *this;
+       
+}
+
+//____________________________________________________________________________
+AliAnaPartCorrBaseClass::~AliAnaPartCorrBaseClass() 
+{
+  // Remove all pointers except analysis output pointers.
+       
+    if(fOutputAODBranch){
+               fOutputAODBranch->Clear() ; 
+               delete fOutputAODBranch ;
+       }
+       
+    if(fInputAODBranch){
+               fInputAODBranch->Clear() ; 
+               delete fInputAODBranch ;
+       }
+       
+       if(fAODCaloClusters){
+               fAODCaloClusters->Clear() ; 
+               delete fAODCaloClusters ;
+       }
+       
+       if(fAODCaloCells){
+               fAODCaloCells->Clear() ; 
+               delete fAODCaloCells ;
+       }
+       
+       if(fReader) delete fReader ;
+       if(fCaloPID) delete fCaloPID ;
+       if(fFidCut) delete fFidCut ;
+       if(fIC) delete fIC ;
+       if(fNMS) delete fNMS ;
+
+}
+
+//____________________________________________________________________________
+void AliAnaPartCorrBaseClass::AddAODCaloCluster(AliAODCaloCluster calo) {
+  //Put AOD calo cluster in the CaloClusters array
+
+  Int_t i = fAODCaloClusters->GetEntriesFast();
+  new((*fAODCaloClusters)[i])  AliAODCaloCluster(calo);
+
+}
+
+
+//____________________________________________________________________________
+void AliAnaPartCorrBaseClass::AddAODParticle(AliAODPWG4Particle pc) {
+  //Put AOD calo cluster in the AODParticleCorrelation array
+  
+       if(fOutputAODBranch){
+               
+               Int_t i = fOutputAODBranch->GetEntriesFast();
+               //new((*fOutputAODBranch)[i])  AliAODPWG4Particle(pc);
+               if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4Particle")==0)
+                       new((*fOutputAODBranch)[i])  AliAODPWG4Particle(pc);
+               else   if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4ParticleCorrelation")==0)
+                       new((*fOutputAODBranch)[i])  AliAODPWG4ParticleCorrelation(pc);
+               else 
+                       AliFatal(Form(">>> Cannot add an object of type < %s >, to the AOD TClonesArray \n", 
+                                                 fOutputAODBranch->GetClass()->GetName()));
+       }
+       else AliFatal("AddAODParticle: No AOD branch available!!!");
+       
+}      
+
+
+//___________________________________________________
+void AliAnaPartCorrBaseClass::ConnectAODCaloClusters() {
+  //Recover the list of AODCaloClusters
+
+  fAODCaloClusters = fReader->GetAOD()->GetCaloClusters();
+
+}
+
+//___________________________________________________
+void AliAnaPartCorrBaseClass::ConnectAODPHOSCells() {
+  //Recover the list of PHOS AODCaloCells 
+
+  fAODCaloCells = fReader->GetAOD()->GetPHOSCells();
+
+}
+
+//___________________________________________________
+void AliAnaPartCorrBaseClass::ConnectAODEMCALCells() {
+  //Recover the list of EMCAL AODCaloCells 
+
+  fAODCaloCells = fReader->GetAOD()->GetEMCALCells();
+
+}
+
+//___________________________________________________
+void AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() {
+       //Recover ouput and input AOD pointers for each event in the maker
+       fOutputAODBranch =  (TClonesArray *) fReader->GetAOD()->FindListObject(fOutputAODName);
+       fInputAODBranch  =  (TClonesArray *) fReader->GetAOD()->FindListObject(fInputAODName);          
+}
+
+//__________________________________________________
+TClonesArray *  AliAnaPartCorrBaseClass::GetAODCTS() const {
+  //Get list of tracks from reader
+
+  return fReader->GetAODCTS(); 
+
+}
+
+//__________________________________________________
+TClonesArray *  AliAnaPartCorrBaseClass::GetAODPHOS() const {
+  //Get list of PHOS calo clusters from reader
+
+  return fReader->GetAODPHOS(); 
+
+}
+
+
+//__________________________________________________
+TClonesArray *  AliAnaPartCorrBaseClass::GetAODEMCAL() const {
+  //Get list of emcal caloclusters from reader
+
+  return fReader->GetAODEMCAL(); 
+
+}
+
+//__________________________________________________
+TString  AliAnaPartCorrBaseClass::GetBaseParametersList()  {
+  //Put data member values in string to keep in output container
+
+       TString parList ; //this will be list of parameters used for this analysis.
+       char onePar[255] ;
+       sprintf(onePar,"--- AliAnaPartCorrBaseClass ---\n") ;
+       parList+=onePar ;       
+       sprintf(onePar,"Minimal P_t: %2.2f ; Max\n", fMinPt) ;
+       parList+=onePar ;
+       sprintf(onePar,"Minimal P_t: %2.2f ; Max\n", fMaxPt) ;
+       parList+=onePar ;
+       sprintf(onePar,"fDataMC =%d (Check MC information, on/off) \n",fDataMC) ;
+       parList+=onePar ;
+       sprintf(onePar,"fCheckFidCut=%d (Check Fidutial cut selection on/off) \n",fCheckFidCut) ;
+       parList+=onePar ;
+       sprintf(onePar,"fCheckCaloPIC =%d (Use Bayesian PID in calorimetes, on/off) \n",fCheckCaloPID) ;
+       parList+=onePar ;
+       sprintf(onePar,"fRecalculateCaloPID  =%d (Calculate PID from shower/tof/tracking parameters, on/off) \n",fRecalculateCaloPID) ;
+       parList+=onePar ;
+
+  return parList; 
+
+}
+
+//__________________________________________________
+ TClonesArray * AliAnaPartCorrBaseClass::GetCreateOutputAODBranch() {
+        //Create AOD branch filled in the analysis
+        
+        //if(fDebug > 0 )
+        printf("Create AOD branch of %s objects and with name < %s >\n",
+                       fOutputAODClassName.Data(),fOutputAODName.Data()) ;
+        
+        TClonesArray * aodBranch = new TClonesArray(fOutputAODClassName, 0);
+        aodBranch->SetName(fOutputAODName);
+        
+        return aodBranch ;
+        
+ }
+
+//__________________________________________________
+TNamed *  AliAnaPartCorrBaseClass::GetPHOSCells() const {
+  //Get list of PHOS calo cells (ESD or AOD) from reader
+  
+  return fReader->GetPHOSCells(); 
+  
+}
+
+
+//__________________________________________________
+TNamed *  AliAnaPartCorrBaseClass::GetEMCALCells() const {
+  //Get list of emcal calo cells (ESD or AOD) from reader
+  
+  return fReader->GetEMCALCells(); 
+
+}
+
+//__________________________________________________
+AliStack *  AliAnaPartCorrBaseClass::GetMCStack() const {
+  //Get stack pointer from reader
+
+  return fReader->GetStack(); 
+
+}
+//__________________________________________________
+AliHeader *  AliAnaPartCorrBaseClass::GetMCHeader() const {
+  //Get header pointer from reader
+
+  return fReader->GetHeader(); 
+
+}
+
+//__________________________________________________
+AliGenEventHeader *  AliAnaPartCorrBaseClass::GetMCGenEventHeader() const {
+  //Get GenEventHeader pointer from reader
+
+  return fReader->GetGenEventHeader(); 
+
+}
+
+//__________________________________________________
+void AliAnaPartCorrBaseClass::InitParameters()
+{ 
+  //Initialize the parameters of the analysis.
+  fDataMC = kFALSE;
+  fDebug = -1;
+  fCheckCaloPID = kTRUE ;
+  fCheckFidCut = kFALSE ;
+  fRecalculateCaloPID = kFALSE ;
+  fMinPt = 0.2 ; //Min pt in particle analysis
+  fMaxPt = 300. ; //Max pt in particle analysis
+
+  fCaloPID = new AliCaloPID ;  
+  fFidCut = new AliFidutialCut;
+  fIC = new AliIsolationCut;
+  fNMS = new AliNeutralMesonSelection;
+  fNewAOD = kFALSE ;
+  fOutputAODName = "PartCorr";
+  fOutputAODClassName = "AliAODPWG4Particle";
+  fInputAODName = "PartCorr";
+  
+  //Histogrammes settings
+  fHistoNPtBins = 240 ;
+  fHistoPtMax   = 120 ;
+  fHistoPtMin   = 0.  ;
+
+  fHistoNPhiBins = 120 ;
+  fHistoPhiMax   = TMath::TwoPi();
+  fHistoPhiMin   = 0.  ;
+
+  fHistoNEtaBins = 100 ;
+  fHistoEtaMax   =  1  ;
+  fHistoEtaMin   = -1  ;
+
+}
+
+//__________________________________________________________________
+void AliAnaPartCorrBaseClass::Print(const Option_t * opt) const
+{
+       //Print some relevant parameters set for the analysis
+       
+       if(! opt)
+               return;
+       printf("New AOD:            =     %d\n",fNewAOD);
+       printf("Input AOD name:     =     %s\n",fInputAODName.Data());
+       printf("Output AOD name:    =     %s\n",fOutputAODName.Data());
+       printf("Output AOD Class name: =  %s\n",fOutputAODClassName.Data());
+       printf("Min Photon pT       =     %2.2f\n",  fMinPt) ;
+       printf("Max Photon pT       =     %3.2f\n",  fMaxPt) ;
+       printf("Check PID           =     %d\n",     fCheckCaloPID) ;
+       printf("Recalculate PID     =     %d\n",     fRecalculateCaloPID) ;
+       printf("Check Fidutial cut  =     %d\n",     fCheckFidCut) ;
+       printf("Check MC labels     =     %d\n",     fDataMC);
+       printf("Debug Level         =     %d\n",     fDebug);
+       printf("Histograms: %3.1f < pT < %3.1f,  Nbin = %d\n", fHistoPtMin,  fHistoPtMax,  fHistoNPtBins);
+       printf("Histograms: %3.1f < phi < %3.1f, Nbin = %d\n", fHistoPhiMin, fHistoPhiMax, fHistoNPhiBins);
+       printf("Histograms: %3.1f < eta < %3.1f, Nbin = %d\n", fHistoEtaMin, fHistoEtaMax, fHistoNEtaBins);
+
+       printf("    \n") ;
+       
+} 
diff --git a/PWG4/PartCorrBase/AliAnaPartCorrBaseClass.h b/PWG4/PartCorrBase/AliAnaPartCorrBaseClass.h
new file mode 100755 (executable)
index 0000000..3766480
--- /dev/null
@@ -0,0 +1,207 @@
+#ifndef ALIANAPARTCORRBASECLASS_H
+#define ALIANAPARTCORRBASECLASS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Base class for analysis algorithms
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+//ROOT
+class TClonesArray ;
+#include <TList.h>
+#include <TObject.h>
+
+//Analysis
+class AliAODCaloCluster;
+class AliAODCaloCells;
+#include "AliAODPWG4Particle.h"
+class AliCaloTrackReader ;   
+class AliCaloPID ;
+class AliFidutialCut ;
+class AliIsolationCut ;
+class AliNeutralMesonSelection ;
+class AliStack ; 
+class AliHeader ; 
+class AliGenEventHeader ; 
+
+
+class AliAnaPartCorrBaseClass : public TObject {
+       
+public: 
+       
+       AliAnaPartCorrBaseClass() ; // default ctor
+       AliAnaPartCorrBaseClass(const AliAnaPartCorrBaseClass & g) ; // cpy ctor
+       AliAnaPartCorrBaseClass & operator = (const AliAnaPartCorrBaseClass & g) ;//cpy assignment
+       virtual ~AliAnaPartCorrBaseClass() ; //virtual dtor
+       
+       virtual void AddAODCaloCluster(AliAODCaloCluster calo) ;
+       virtual void AddAODParticle(AliAODPWG4Particle pc) ;
+
+       virtual void ConnectAODCaloClusters();
+       virtual void ConnectAODPHOSCells();
+       virtual void ConnectAODEMCALCells();
+       virtual void ConnectInputOutputAODBranches();
+       
+       virtual TList * GetCreateOutputObjects() { return (new TList) ;}
+       
+       virtual void Init() {;}
+       virtual void InitParameters() ;
+       
+       virtual void Print(const Option_t * ) const ;
+       
+       virtual void MakeAnalysisFillAOD()  {;}
+       
+       virtual void MakeAnalysisFillHistograms() {;}
+               
+       virtual Int_t GetDebug() const  { return fDebug ; }
+       virtual void SetDebug(Int_t d)   { fDebug = d ; }
+       
+       virtual AliCaloTrackReader * GetReader() const {return fReader ; }
+       virtual void SetReader(AliCaloTrackReader * reader) { fReader = reader ; }
+               
+       //analysis AOD branch
+       virtual TClonesArray * GetCreateOutputAODBranch() ;
+       //{return (new TClonesArray("AliAODPWG4Particle",0)) ;}
+       virtual TString GetInputAODName() const {return fInputAODName ; }
+       virtual void SetInputAODName(TString name)   { fInputAODName = name; }  
+       virtual TString GetOutputAODName()  const {return fOutputAODName ; }
+       virtual void SetOutputAODName(TString name)   { fNewAOD = kTRUE ; fOutputAODName = name; }
+       virtual Bool_t NewOutputAOD() const {return fNewAOD;}
+       virtual TString GetOutputAODClassName() const {return fOutputAODClassName;}
+       virtual void SetOutputAODClassName(TString name) {fOutputAODClassName = name; }
+       
+    virtual TClonesArray* GetInputAODBranch() const {return fInputAODBranch ;}
+       virtual TClonesArray* GetOutputAODBranch() const {return fOutputAODBranch ;}
+
+       virtual TClonesArray* GetAODCaloClusters() const {return fAODCaloClusters ;}
+       virtual AliAODCaloCells* GetAODCaloCells() const {return fAODCaloCells ;}
+       
+       virtual TClonesArray* GetAODCTS() const ;
+       virtual TClonesArray* GetAODEMCAL() const ;
+       virtual TClonesArray* GetAODPHOS() const ;
+       
+       virtual TString GetBaseParametersList();
+       
+       virtual TNamed * GetEMCALCells() const ;
+       virtual TNamed * GetPHOSCells() const ;
+       
+       virtual AliStack * GetMCStack() const ;
+       virtual AliHeader* GetMCHeader() const ;
+       virtual AliGenEventHeader* GetMCGenEventHeader() const ;
+       
+       
+       virtual AliCaloPID * GetCaloPID() const {return  fCaloPID ;}
+       virtual void SetCaloPID(AliCaloPID * pid) { fCaloPID = pid ;}
+       
+       virtual AliFidutialCut * GetFidutialCut() const {return  fFidCut ;}
+       virtual void SetFidutialCut(AliFidutialCut * fc) { fFidCut = fc ;}
+       
+       virtual AliIsolationCut * GetIsolationCut() const {return  fIC ;}
+       virtual void SetIsolationCut(AliIsolationCut * fc) { fIC = fc ;}
+       
+       virtual AliNeutralMesonSelection * GetNeutralMesonSelection() const {return  fNMS ;}
+       virtual void SetNeutralMesonSelection(AliNeutralMesonSelection * nms) { fNMS = nms ;}
+       
+       virtual Bool_t     IsDataMC() const {return fDataMC ; }
+       virtual void SwitchOnDataMC()    {fDataMC = kTRUE ; }
+       virtual void SwitchOffDataMC()    {fDataMC = kFALSE ; }
+       
+       virtual Bool_t IsFidutialCutOn() const {return fCheckFidCut ; }
+       virtual void SwitchOnFidutialCut() { fCheckFidCut = kTRUE;}
+       virtual void SwitchOffFidutialCut() { fCheckFidCut = kFALSE;}
+       
+       virtual Bool_t IsCaloPIDOn() const {return fCheckCaloPID ; }
+       virtual void SwitchOnCaloPID() { fCheckCaloPID = kTRUE;}
+       virtual void SwitchOffCaloPID() { fCheckCaloPID = kFALSE;}
+       
+       virtual Bool_t IsCaloPIDRecalculationOn() const {return fRecalculateCaloPID ; }
+       virtual void SwitchOnCaloPIDRecalculation() { fRecalculateCaloPID  = kTRUE;}
+       virtual void SwitchOffCaloPIDRecalculation() { fRecalculateCaloPID  = kFALSE;}
+       
+       virtual Float_t    GetMaxPt()         const {return fMaxPt ; }
+       virtual Float_t    GetMinPt()         const {return fMinPt ; }
+       virtual void SetMaxPt(Float_t pt)              {fMaxPt = pt ; }
+       virtual void SetMinPt(Float_t pt)              {fMinPt = pt ; }
+       void SetPtCutRange(Double_t ptmin, Double_t ptmax)
+       {  fMaxPt=ptmax;   fMinPt=ptmin;}
+       
+       
+       //Histogrammes setters and getters
+       virtual void SetHistoPtRangeAndNBins(Float_t min, Float_t max, Int_t n) {
+               fHistoNPtBins = n ;
+               fHistoPtMax = max ;
+               fHistoPtMin = min ;
+       }
+       
+       Int_t   GetHistoNPtBins() const { return fHistoNPtBins ; }
+       Float_t GetHistoPtMin()   const { return fHistoPtMin ; }
+       Float_t GetHistoPtMax()   const { return fHistoPtMax ; }
+
+       virtual void SetHistoPhiRangeAndNBins(Float_t min, Float_t max, Int_t n) {
+               fHistoNPhiBins = n ;
+               fHistoPhiMax = max ;
+               fHistoPhiMin = min ;
+       }
+       
+       Int_t   GetHistoNPhiBins() const { return fHistoNPhiBins ; }
+       Float_t GetHistoPhiMin()   const { return fHistoPhiMin ; }
+       Float_t GetHistoPhiMax()   const { return fHistoPhiMax ; }
+
+       virtual void SetHistoEtaRangeAndNBins(Float_t min, Float_t max, Int_t n) {
+               fHistoNEtaBins = n ;
+               fHistoEtaMax = max ;
+               fHistoEtaMin = min ;
+       }
+       
+       Int_t   GetHistoNEtaBins() const { return fHistoNEtaBins ; }
+       Float_t GetHistoEtaMin()   const { return fHistoEtaMin ; }
+       Float_t GetHistoEtaMax()   const { return fHistoEtaMax ; }
+
+
+       private:    
+       
+       Bool_t fDataMC ;        //Flag to access MC data when using ESD or AOD     
+       Int_t fDebug ;          // Debug level
+       Bool_t fCheckFidCut ;   // Do analysis for clusters in defined region         
+       Bool_t fCheckCaloPID ;  // Do analysis for calorimeters
+       Bool_t fRecalculateCaloPID ; //Recalculate PID or use PID weights in calorimeters
+       Float_t fMinPt ; //Maximum pt of (trigger) particles in the analysis
+       Float_t fMaxPt ; //Minimum pt of (trigger) particles in the analysis
+       
+       AliCaloTrackReader * fReader;     //Acces to ESD/AOD/MC data
+       
+       TClonesArray* fInputAODBranch ;   //! Selected input particles branch
+       TString fInputAODName ;           // Name of input AOD branch;
+       TClonesArray* fOutputAODBranch ;  //! Selected output particles branch
+       Bool_t fNewAOD ;                  // Flag, new aod branch added to the analysis or not.
+       TString fOutputAODName ;          // Name of output AOD branch;
+       TString fOutputAODClassName;      // Type of aod objects to be stored in the TClonesArray (AliAODPWG4Particle, AliAODPWG4ParticleCorrelation ...)       
+
+       TClonesArray* fAODCaloClusters ;  //! selected PHOS/EMCAL CaloClusters
+       AliAODCaloCells * fAODCaloCells ; //! selected PHOS/EMCAL CaloCells
+       AliCaloPID * fCaloPID;            // PID calculation
+       AliFidutialCut * fFidCut;         // Acceptance cuts
+       AliIsolationCut * fIC;            // Isolation cut 
+       AliNeutralMesonSelection * fNMS;  // Neutral Meson Selection
+       
+       //Histograms binning and range    
+       Int_t   fHistoNPtBins ;  //Number of bins in pt axis
+       Float_t fHistoPtMax ;    //Maximum value of pt histogram range
+       Float_t fHistoPtMin ;    //Minimum value of pt histogram range
+       Int_t   fHistoNPhiBins ; //Number of bins in phi axis
+       Float_t fHistoPhiMax ;   //Maximum value of phi histogram range
+       Float_t fHistoPhiMin ;   //Minimum value of phi histogram range
+       Int_t   fHistoNEtaBins ; //Number of bins in eta axis
+       Float_t fHistoEtaMax ;   //Maximum value of eta histogram range
+       Float_t fHistoEtaMin ;   //Minimum value of eta histogram range
+                                               
+       ClassDef(AliAnaPartCorrBaseClass,2)
+} ;
+
+
+#endif //ALIANAPARTCORRBASECLASS_H
+
+
+
diff --git a/PWG4/PartCorrBase/AliAnaPartCorrMaker.cxx b/PWG4/PartCorrBase/AliAnaPartCorrMaker.cxx
new file mode 100755 (executable)
index 0000000..22104e8
--- /dev/null
@@ -0,0 +1,225 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Steering class for particle (gamma, hadron) identification and correlation analysis
+// It is called by the task class AliAnalysisTaskParticleCorrelation and it connects the input 
+// (ESD/AOD/MonteCarlo) got with AliCaloTrackReader (produces TClonesArrays of AODs 
+// (TParticles in MC case if requested)), with the 
+// analysis classes that derive from AliAnaPartCorrBaseClass
+//
+// -- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+class TClonesArray;
+class TString ;
+//#include "Riostream.h"
+
+//---- AliRoot system ---- 
+#include "AliAnaPartCorrBaseClass.h" 
+#include "AliAnaPartCorrMaker.h" 
+#include "AliCaloTrackReader.h" 
+#include "AliLog.h"
+
+
+ClassImp(AliAnaPartCorrMaker)
+
+
+//____________________________________________________________________________
+AliAnaPartCorrMaker::AliAnaPartCorrMaker() : 
+TObject(),
+fOutputContainer(new TList ), fAnalysisContainer(new TList ),
+fMakeHisto(0), fMakeAOD(0), fAnaDebug(0), 
+fReader(0x0), fAODBranchList(new TList )
+{
+       //Default Ctor
+       if(fAnaDebug > 1 ) printf("*** Analysis Maker  Constructor *** \n");
+       
+       //Initialize parameters, pointers and histograms
+       if(!fReader)
+               fReader = new AliCaloTrackReader();
+       
+       InitParameters();
+}
+
+//____________________________________________________________________________
+AliAnaPartCorrMaker::AliAnaPartCorrMaker(const AliAnaPartCorrMaker & g) :   
+TObject(),
+fOutputContainer(g. fOutputContainer), fAnalysisContainer(g.fAnalysisContainer), 
+fMakeHisto(g.fMakeHisto), fMakeAOD(fMakeAOD), fAnaDebug(g. fAnaDebug),
+fReader(g.fReader), fAODBranchList(g.fAODBranchList)
+{
+       // cpy ctor
+       
+}
+
+//_________________________________________________________________________
+AliAnaPartCorrMaker & AliAnaPartCorrMaker::operator = (const AliAnaPartCorrMaker & source)
+{
+       // assignment operator
+       
+       if(this == &source)return *this;
+       ((TObject *)this)->operator=(source);
+       
+       fOutputContainer    = source.fOutputContainer ;
+       fAnalysisContainer  = source.fAnalysisContainer ;
+       fAnaDebug           = source.fAnaDebug;
+       fMakeHisto          = source.fMakeHisto;
+       fMakeAOD            = source.fMakeAOD;
+       
+       fReader             = source.fReader ;
+       fAODBranchList      = source.fAODBranchList;
+       
+       return *this;
+       
+}
+
+//____________________________________________________________________________
+AliAnaPartCorrMaker::~AliAnaPartCorrMaker() 
+{
+       // Remove all pointers.
+       
+       // Protection added in case of NULL pointers (MG)
+       if (fOutputContainer) {
+               fOutputContainer->Clear();
+               delete fOutputContainer ;
+       }   
+       
+       if (fAnalysisContainer) {
+               fAnalysisContainer->Clear();
+               delete fAnalysisContainer ;
+       }   
+       
+       if (fReader) delete fReader ;
+       
+       
+       if(fAODBranchList){
+//             for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
+//                     fAODBranchList->At(iaod)->Clear();
+       
+               fAODBranchList->Clear();
+               delete fAODBranchList ;
+       }
+       
+}
+
+//________________________________________________________________________
+TList * AliAnaPartCorrMaker::GetAODBranchList()
+{ 
+
+// Get any new output AOD branches from analysis and put them in a list
+// The list is filled in the maker, and new branch passed to the analysis frame
+// AliAnalysisTaskPartCorr
+       for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
+                       
+               AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
+               if(ana->NewOutputAOD()) fAODBranchList->Add(ana->GetCreateOutputAODBranch());
+       }
+
+       return fAODBranchList ;
+
+}
+
+//________________________________________________________________________
+void AliAnaPartCorrMaker::Init()
+{  
+       //Init container histograms and other common variables
+       
+       if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0)
+                       AliFatal("Analysis job list not initialized");
+                       
+       for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
+                       
+               AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ;
+               ana->SetReader(fReader); //SetReader for each analysis
+               ana->Init();
+               
+               if(fMakeHisto){// Analysis with histograms as output on
+                       //Fill container with appropriate histograms                    
+                       TList * templist =  ana -> GetCreateOutputObjects(); 
+                               for(Int_t i = 0; i < templist->GetEntries(); i++)
+                                       fOutputContainer->Add(templist->At(i)) ;
+               }// Analysis with histograms as output on
+       }//Loop on analysis defined
+}
+
+//____________________________________________________________________________
+void AliAnaPartCorrMaker::InitParameters()
+{
+       
+       //Init data members
+       fMakeHisto = kTRUE;
+       fMakeAOD = kTRUE; 
+       fAnaDebug = 0; // No debugging info displayed by default
+
+}
+
+//__________________________________________________________________
+void AliAnaPartCorrMaker::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", fAnaDebug) ;
+       printf("Produce Histo              =     %d\n", fMakeHisto) ;
+       printf("Produce AOD                =     %d\n", fMakeAOD) ;
+       
+} 
+
+
+//____________________________________________________________________________
+Bool_t AliAnaPartCorrMaker::ProcessEvent(Int_t iEntry){
+       //Process analysis for this event
+       
+       if(fMakeHisto && !fOutputContainer)
+               AliFatal("Histograms not initialized");
+       
+       if(fAnaDebug >= 0 ) printf("***  Event %d   ***  \n",iEntry);
+       
+       //Each event needs an empty branch      
+       for(Int_t iaod = 0; iaod < fAODBranchList->GetEntries(); iaod++)
+               fAODBranchList->At(iaod)->Clear();
+       
+       //Tell the reader to fill the data in the 3 detector lists
+       fReader->FillInputEvent();
+       
+       //Loop on analysis algorithms
+       if(fAnaDebug > 0 ) printf("*** Begin analysis *** \n");
+       Int_t nana = fAnalysisContainer->GetEntries() ;
+       for(Int_t iana = 0; iana <  nana; iana++){
+               
+               AliAnaPartCorrBaseClass * ana =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) ; 
+               
+               ana->ConnectInputOutputAODBranches(); //Sets branches for each analysis
+               
+               //Make analysis, create aods in aod branch or AODCaloClusters
+               if(fMakeAOD) ana->MakeAnalysisFillAOD()  ;
+               //Make further analysis with aod branch and fill histograms
+               if(fMakeHisto) ana->MakeAnalysisFillHistograms()  ;
+               
+       }
+               
+       fReader->ResetLists();
+       
+       if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
+       
+       return kTRUE ;
+       
+}
diff --git a/PWG4/PartCorrBase/AliAnaPartCorrMaker.h b/PWG4/PartCorrBase/AliAnaPartCorrMaker.h
new file mode 100755 (executable)
index 0000000..f453e78
--- /dev/null
@@ -0,0 +1,86 @@
+#ifndef ALIANAPARTCORRMAKER_H
+#define ALIANAPARTCORRMAKER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Steering class for particle (gamma, hadron) identification and correlation analysis
+// It is called by the task class AliAnalysisTaskParticleCorrelation and it connects the input 
+// (ESD/AOD/MonteCarlo) got with AliCaloTrackReader (produces TClonesArrays of AODs 
+// (TParticles in MC case if requested)), with the 
+// analysis classes that derive from AliAnaPartCorrBaseClass
+//
+// -- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+class TList; 
+class TClonesArray;
+#include<TObject.h>
+class TString;
+
+// --- Analysis system ---
+class AliCaloTrackReader ;
+
+class AliAnaPartCorrMaker : public TObject {
+
+public: 
+  
+  AliAnaPartCorrMaker() ; // default ctor
+  AliAnaPartCorrMaker(const AliAnaPartCorrMaker & g) ; // cpy ctor
+  AliAnaPartCorrMaker & operator = (const AliAnaPartCorrMaker & g) ;//cpy assignment
+  virtual ~AliAnaPartCorrMaker() ; //virtual dtor
+
+  //Setter and getters
+  TList * GetAODBranchList() ;
+  TList * GetOutputContainer()    const {return fOutputContainer ; }
+
+  Int_t GetAnaDebug() const  { return fAnaDebug ; }
+  void SetAnaDebug(Int_t d)   { fAnaDebug = d ; }
+
+  Bool_t AreHistogramsMade() const  { return fMakeHisto ; }
+  void SwitchOnHistogramsMaker()   { fMakeHisto = kTRUE ; }
+  void SwitchOffHistogramsMaker()   { fMakeHisto = kFALSE ; }
+  Bool_t AreAODsMade() const  { return fMakeAOD ; }
+  void SwitchOnAODsMaker()   { fMakeAOD = kTRUE ; }
+  void SwitchOffAODsMaker()   { fMakeAOD = kFALSE ; }
+  
+  void AddAnalysis(TObject* ana, Int_t n) {
+       if ( fAnalysisContainer) fAnalysisContainer->AddAt(ana,n); 
+    else { printf("AnalysisContainer not initialized");
+              abort();}
+       }
+
+  AliCaloTrackReader * GetReader() const {return fReader ; }
+  void SetReader(AliCaloTrackReader * reader) { fReader = reader ; }
+
+  //Others
+  void Init();
+  void InitParameters();
+
+  void Print(const Option_t * opt) const;
+
+  Bool_t ProcessEvent(Int_t iEntry) ;
+
+ private:
+  
+  //General Data members
+
+  TList * fOutputContainer ; // output histograms container
+  TList * fAnalysisContainer ; // List with analysis pointers
+  Bool_t  fMakeHisto ; // If true makes final analysis with histograms as output
+  Bool_t  fMakeAOD ; // If true makes analysis generating AODs
+  Int_t   fAnaDebug; // Debugging info.
+  AliCaloTrackReader *  fReader ;   // Pointer to reader 
+  TList * fAODBranchList ;          //! List with AOD branches created and needed in analysis
+  
+  ClassDef(AliAnaPartCorrMaker,2)
+} ;
+
+#endif //ALIANAPARTCORRMAKER_H
+
+
+
diff --git a/PWG4/PartCorrBase/AliAnaScale.cxx b/PWG4/PartCorrBase/AliAnaScale.cxx
new file mode 100755 (executable)
index 0000000..b2cbc20
--- /dev/null
@@ -0,0 +1,138 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id: */
+
+//_________________________________________________________________________
+// A basic analysis task to analyse photon detected by PHOS
+//
+//*-- Yves Schutz 
+//////////////////////////////////////////////////////////////////////////////
+
+#include <TFile.h> 
+#include <TH1.h>
+#include <TH1F.h>
+#include <TH1I.h>
+#include <TCanvas.h> 
+
+#include "AliAnaScale.h" 
+#include "AliAnalysisManager.h"
+
+//______________________________________________________________________________
+AliAnaScale::AliAnaScale() : 
+  fDebug(0),
+  fScale(1.0),
+  fInputList(0x0), 
+  fOutputList(0x0),
+  fSumw2(0),
+  fhCount() 
+{
+  //Default constructor
+}
+//______________________________________________________________________________
+AliAnaScale::AliAnaScale(const char *name) : 
+  AliAnalysisTask(name,""),  
+  fDebug(0),
+  fScale(1.0), 
+  fInputList(0x0), 
+  fOutputList(0x0), 
+  fSumw2(0),
+  fhCount(0) 
+{
+  // Constructor.
+  // Called only after the event loop
+  SetPostEventLoop(kTRUE);
+  // Input slot #0 
+  DefineInput(0,  TList::Class()) ; 
+  // Output slot 
+  DefineOutput(0,  TList::Class()) ; 
+}
+
+//______________________________________________________________________________
+AliAnaScale::~AliAnaScale()
+{
+  // dtor
+  
+}
+
+
+//______________________________________________________________________________
+void AliAnaScale::ConnectInputData(const Option_t*)
+{
+  // Initialisation of branch container and histograms 
+    
+  if(fDebug > 1) printf("*** Initialization of %s \n", GetName()) ; 
+  fInputList     = dynamic_cast<TList*>(GetInputData(0)) ;  
+}
+//________________________________________________________________________
+void AliAnaScale::CreateOutputObjects()
+{  
+  // Create the outputs containers
+
+  fOutputList = new TList() ; 
+  fOutputList->SetName(GetName()) ; 
+
+  fhCount =new TH1F("hCount","count files",1,0,1);  
+  fOutputList->Add(fhCount);
+
+}
+
+//______________________________________________________________________________
+void AliAnaScale::Exec(Option_t *) 
+{
+  // Do the Scaling
+
+  if(fDebug > 0 ) printf(">>>>> Scaling factor %e, do Sumw2 %d <<<<< \n",fScale,fSumw2) ;
+
+  TIter next(fInputList) ;     
+  TObject * h ; 
+  while ( (h = next()) ) { 
+    if(h){
+      if ( strcmp(h->ClassName(),"TNtuple") ) {
+      char name[128] ; 
+      sprintf(name, "%sScaled", h->GetName()) ; 
+      TH1 * hout = dynamic_cast<TH1*> (h->Clone(name)) ; 
+     
+      if(fSumw2) hout->Sumw2();
+      hout->Scale(fScale) ;  
+      fOutputList->Add(hout) ; 
+      } 
+      else  fOutputList->Add(h) ; 
+    }
+  }
+  // number of files
+
+  //File scaled, needed for file merging on grid
+  fhCount->Fill(0);
+  PostData(0, fOutputList);
+}
+
+
+//______________________________________________________________________________
+void AliAnaScale::Init()
+{
+  // Intialisation of parameters
+  if(fDebug > 0 )printf("No initialization in scale class \n") ;
+
+}
+
+//______________________________________________________________________________
+//void AliAnaScale::Terminate(Option_t *)
+//{
+//  // Processing when the event loop is ended
+//  
+//
+//}
diff --git a/PWG4/PartCorrBase/AliAnaScale.h b/PWG4/PartCorrBase/AliAnaScale.h
new file mode 100755 (executable)
index 0000000..5d3e08d
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef ALIANASCALE_H
+#define ALIANASCALE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+//______________________________________________________________________________
+// An post event loop analysis task that scales the input histograms 
+//
+//*-- Yves Schutz 
+//////////////////////////////////////////////////////////////////////////////
+
+#include "AliAnalysisTask.h"  
+
+class TH1D ; 
+class TH1I ; 
+class TH1F ; 
+
+class AliAnaScale : public AliAnalysisTask {
+
+public:
+  AliAnaScale() ;
+  AliAnaScale(const char *name) ;
+  virtual ~AliAnaScale() ;
+   
+  virtual void ConnectInputData(Option_t * = "");
+  virtual void CreateOutputObjects(); 
+  virtual void Init() ;        
+  virtual void LocalInit() { Init() ; }
+  virtual void Exec(Option_t * opt = "") ;
+  void Set(const Double_t val) { fScale = val ; }
+  void SetDebugLevel(Int_t level) { fDebug = level ; }
+//  virtual void Terminate(Option_t * opt = "") ;
+
+  void MakeSumw2(Bool_t sum) {fSumw2 = sum;}
+
+private:
+  AliAnaScale(const AliAnaScale&); // Not implemented
+  AliAnaScale& operator=(const AliAnaScale&); // Not implemented
+
+
+  // input and output
+  Int_t          fDebug ;         // Debug flag
+  // task parameters
+  Float_t   fScale ;  // Scaling factor 
+
+  // Histograms
+  TList   * fInputList ;  //! input data list
+  TList   * fOutputList ; //! output data list
+  Bool_t fSumw2; //compute sum of squares of weights for bin content error calculation
+  TH1F * fhCount; //! counter histogram for file merging
+
+  ClassDef(AliAnaScale, 2); // a post event loop scaling 
+};
+#endif // ALIANASCALE_H
diff --git a/PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelation.cxx b/PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelation.cxx
new file mode 100755 (executable)
index 0000000..744405f
--- /dev/null
@@ -0,0 +1,173 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Analysis task that executes the analysis classes
+// that depend on the PartCorr frame, frame for Particle identification and correlations.
+// Specially designed for calorimeters but also can be used for charged tracks
+// Input of this task is a configuration file that contains all the settings of the analyis
+//
+// -- Author: Gustavo Conesa (INFN-LNF)
+
+
+// root
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TInterpreter.h>
+#include <TChain.h>
+#include <TFile.h>
+//#include <Riostream.h>
+
+// analysis
+#include "AliAnalysisTaskParticleCorrelation.h"
+#include "AliAnalysisManager.h"
+#include "AliESDInputHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliAnaPartCorrMaker.h"
+#include "AliCaloTrackReader.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliAODHandler.h"
+#include "AliStack.h"
+#include "AliLog.h"
+
+ClassImp(AliAnalysisTaskParticleCorrelation)
+
+////////////////////////////////////////////////////////////////////////
+
+  AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation():
+    AliAnalysisTaskSE(),
+    fAna(0x0),
+    fOutputContainer(0x0),
+    //fAODBranch(0x0),
+    fConfigName(0)
+{
+  // Default constructor
+}
+
+//_____________________________________________________
+AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation(const char* name):
+    AliAnalysisTaskSE(name),
+    fAna(0x0),
+    fOutputContainer(0x0),
+   // fAODBranch(0x0),
+    fConfigName("ConfigAnalysis")
+{
+  // Default constructor
+
+  DefineOutput(1, TList::Class());
+
+}
+
+//_____________________________________________________
+AliAnalysisTaskParticleCorrelation::~AliAnalysisTaskParticleCorrelation() 
+{
+  // Remove all pointers
+  if(fOutputContainer){
+    fOutputContainer->Clear() ; 
+    delete fOutputContainer ;
+  }
+
+}
+
+//_____________________________________________________
+void AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects()
+{
+       // Create the output container
+       if (fDebug > 1) printf("AnalysisTaskParticleCorrelation::CreateOutputData() \n");
+       
+       
+//     TClonesArray * aodBranch = new TClonesArray(fAna->GetAODBranchClassName(), 0);
+//     aodBranch->SetName(fAna->GetAODBranchName());
+//     AddAODBranch("TClonesArray", &aodBranch);
+//     fAna->SetAODBranch(aodBranch);
+       
+       //Get list of aod arrays, add each aod array to analysis frame 
+       TClonesArray * array = 0;
+       TList * list = fAna->GetAODBranchList();
+       for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++){
+               array = (TClonesArray*) list->At(iaod);
+               AddAODBranch("TClonesArray", &array);
+       } 
+       
+       //Histograms container
+       OpenFile(1);
+       fOutputContainer = fAna->GetOutputContainer();
+       
+}
+
+//_____________________________________________________
+void AliAnalysisTaskParticleCorrelation::Init()
+{
+  // Initialization
+  if (fDebug > 1) printf("AnalysisTaskParticleCorrelation::Init() \n");
+  
+  // Call configuration file
+
+  if(fConfigName == ""){
+    fConfigName="ConfigAnalysis";
+  }
+  AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
+  gROOT->LoadMacro(fConfigName+".C");
+  fAna = (AliAnaPartCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
+  
+  if(!fAna)
+    AliFatal("Analysis pointer not initialized, abort analysis!");
+  
+  // Initialise analysis
+  fAna->Init();
+  
+  AliDebug(1,"End");
+  
+}
+
+
+//_____________________________________________________
+void AliAnalysisTaskParticleCorrelation::UserExec(Option_t */*option*/)
+{
+  // Execute analysis for current event
+  //
+  if (fDebug > 1) printf("AnalysisTaskParticleCorrelation::Exec() \n");
+
+  //Get the type of data, check if type is correct
+  Int_t  datatype = fAna->GetReader()->GetDataType();
+  if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
+     datatype != AliCaloTrackReader::kMC){
+    AliFatal("Wrong type of data");
+    return ;
+  }
+  
+  fAna->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
+
+  //Process event
+  fAna->ProcessEvent((Int_t) Entry());
+  
+  PostData(1, fOutputContainer);
+  
+}
+
+//_____________________________________________________
+void AliAnalysisTaskParticleCorrelation::Terminate(Option_t */*option*/)
+{
+  // Terminate analysis
+  //
+  AliDebug(1,"Do nothing in Terminate");
+  //fAna->Terminate();
+}
+
diff --git a/PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelation.h b/PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelation.h
new file mode 100755 (executable)
index 0000000..757f4d2
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef ALIANALYSISTASKPARTICLECORRELATION_H
+#define ALIANALYSISTASKPARTICLECORRELATION_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+//_________________________________________________________________________
+// Analysis task that executes the analysis classes
+// that depend on the PartCorr frame, frame for Particle identification and correlations.
+// Specially designed for calorimeters but also can be used for charged tracks
+// Input of this task is a configuration file that contains all the settings of the analyis
+//
+// -- Author: Gustavo Conesa (INFN-LNF)
+#include "AliAnalysisTaskSE.h"
+class AliAnaPartCorrMaker;
+class AliESDEvent;
+class AliAODEvent;
+class TList;
+
+class AliAnalysisTaskParticleCorrelation : public AliAnalysisTaskSE
+{
+ public:
+    AliAnalysisTaskParticleCorrelation();
+    AliAnalysisTaskParticleCorrelation(const char* name);
+    virtual ~AliAnalysisTaskParticleCorrelation() ;// virtual dtor
+    // Implementation of interface methods
+    virtual void UserCreateOutputObjects();
+    virtual void Init();
+    virtual void LocalInit() {Init();}
+    virtual void UserExec(Option_t *option);
+    virtual void Terminate(Option_t *option);
+
+    void SetConfigFileName(TString name ) {fConfigName = name ; }
+    TString GetConfigFileName() const {return fConfigName ; }
+
+ private:
+    AliAnalysisTaskParticleCorrelation(const AliAnalysisTaskParticleCorrelation&); // Not implemented
+    AliAnalysisTaskParticleCorrelation& operator=(const AliAnalysisTaskParticleCorrelation&); // Not implemented
+
+    AliAnaPartCorrMaker* fAna; //  Pointer to the jet finder 
+    TList * fOutputContainer ; //! Histogram container
+    //TClonesArray * fAODBranch; //! AOD branch
+    TString fConfigName ; //Configuration file name
+
+    ClassDef(AliAnalysisTaskParticleCorrelation, 2); // Analysis task for standard gamma correlation analysis
+};
+#endif //ALIANALYSISTASKPARTICLECORRELATION_H
diff --git a/PWG4/PartCorrBase/AliCaloPID.cxx b/PWG4/PartCorrBase/AliCaloPID.cxx
new file mode 100755 (executable)
index 0000000..040dcca
--- /dev/null
@@ -0,0 +1,411 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: AliCaloPID.cxx 21839 2007-10-29 13:49:42Z gustavo $ */
+
+//_________________________________________________________________________
+// Class for track/cluster acceptance selection
+// Selection in Central barrel, EMCAL and PHOS
+//                
+//*-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+#include <TMath.h>
+#include <TLorentzVector.h>
+#include <TString.h>
+#include <TFormula.h>
+
+//---- ANALYSIS system ----
+#include "AliLog.h"
+#include "AliCaloPID.h"
+#include "AliAODCaloCluster.h"
+#include "AliAODPWG4Particle.h"
+#include "AliStack.h"
+#include "TParticle.h"
+
+ClassImp(AliCaloPID)
+
+
+//________________________________________________
+AliCaloPID::AliCaloPID() : 
+TObject(), fEMCALPhotonWeight(0.), fEMCALPi0Weight(0.),  
+fEMCALElectronWeight(0.),  fEMCALChargeWeight(0.),
+fEMCALNeutralWeight(0.),
+fPHOSPhotonWeight(0.), fPHOSPi0Weight(0.),  
+fPHOSElectronWeight(0.), fPHOSChargeWeight(0.) , 
+fPHOSNeutralWeight(0.), fPHOSWeightFormula(0), 
+fPHOSPhotonWeightFormula(0x0), fPHOSPi0WeightFormula(0x0),
+fDispCut(0.),fTOFCut(0.), fDebug(-1)
+{
+       //Ctor
+       
+       //Initialize parameters
+       InitParameters();
+}
+
+//____________________________________________________________________________
+AliCaloPID::AliCaloPID(const AliCaloPID & pid) :   
+TObject(pid), fEMCALPhotonWeight(pid.fEMCALPhotonWeight), 
+fEMCALPi0Weight(pid.fEMCALPi0Weight), 
+fEMCALElectronWeight(pid.fEMCALElectronWeight), 
+fEMCALChargeWeight(pid.fEMCALChargeWeight), 
+fEMCALNeutralWeight(pid.fEMCALNeutralWeight), 
+fPHOSPhotonWeight(pid.fPHOSPhotonWeight),
+fPHOSPi0Weight(pid.fPHOSPi0Weight),
+fPHOSElectronWeight(pid.fPHOSElectronWeight), 
+fPHOSChargeWeight(pid.fPHOSChargeWeight),
+fPHOSNeutralWeight(pid.fPHOSNeutralWeight),
+fPHOSWeightFormula(pid.fPHOSWeightFormula), 
+fPHOSPhotonWeightFormula(pid.fPHOSPhotonWeightFormula), 
+fPHOSPi0WeightFormula(pid.fPHOSPi0WeightFormula), 
+fDispCut(pid.fDispCut),fTOFCut(pid.fTOFCut),
+fDebug(pid.fDebug)
+{
+       // cpy ctor
+       
+}
+
+//_________________________________________________________________________
+AliCaloPID & AliCaloPID::operator = (const AliCaloPID & pid)
+{
+       // assignment operator
+       
+       if(&pid == this) return *this;
+       
+       fEMCALPhotonWeight = pid. fEMCALPhotonWeight ;
+       fEMCALPi0Weight = pid.fEMCALPi0Weight ;
+       fEMCALElectronWeight = pid.fEMCALElectronWeight; 
+       fEMCALChargeWeight = pid.fEMCALChargeWeight;
+       fEMCALNeutralWeight = pid.fEMCALNeutralWeight;
+       
+       fPHOSPhotonWeight = pid.fPHOSPhotonWeight ;
+       fPHOSPi0Weight = pid.fPHOSPi0Weight ;
+       fPHOSElectronWeight = pid.fPHOSElectronWeight; 
+       fPHOSChargeWeight = pid.fPHOSChargeWeight;
+       fPHOSNeutralWeight = pid.fPHOSNeutralWeight;
+       
+       fPHOSWeightFormula       = pid.fPHOSWeightFormula; 
+       fPHOSPhotonWeightFormula = pid.fPHOSPhotonWeightFormula; 
+       fPHOSPi0WeightFormula    = pid.fPHOSPi0WeightFormula;
+       
+       fDispCut  = pid.fDispCut;
+       fTOFCut   = pid.fTOFCut;
+       fDebug    = pid.fDebug;
+       
+       return *this;
+       
+}
+
+//_________________________________
+AliCaloPID::~AliCaloPID() {
+       //Dtor
+       
+       if(fPHOSPhotonWeightFormula) delete  fPHOSPhotonWeightFormula ;
+       if(fPHOSPi0WeightFormula) delete  fPHOSPi0WeightFormula ;
+       
+}
+
+
+//_________________________________________________________________________
+Int_t AliCaloPID::CheckOrigin(const Int_t label, AliStack * stack) const {
+       //Play with the MC stack if available
+       //Check origin of the candidates, good for PYTHIA
+       
+       if(!stack) AliFatal("Stack is not available, check analysis settings in configuration file, STOP!!");
+       
+       if(label >= 0 && label <  stack->GetNtrack()){
+               //Mother
+               TParticle * mom = stack->Particle(label);
+               Int_t mPdg = TMath::Abs(mom->GetPdgCode());
+               Int_t mStatus =  mom->GetStatusCode() ;
+               Int_t iParent =  mom->GetFirstMother() ;
+               if(fDebug > 0 && label < 8 ) printf("AliCaloPID::CheckOrigin: Mother is parton %d\n",iParent);
+               
+               //GrandParent
+               TParticle * parent = new TParticle ;
+               Int_t pPdg = -1;
+               Int_t pStatus =-1;
+               if(iParent > 0){
+                       parent = stack->Particle(iParent);
+                       pPdg = TMath::Abs(parent->GetPdgCode());
+                       pStatus = parent->GetStatusCode();  
+               }
+               else if(fDebug > 0 ) printf("AliCaloPID::CheckOrigin: Parent with label %d\n",iParent);
+               
+               //return tag
+               if(mPdg == 22){
+                       if(mStatus == 1){
+                               if(iParent < 8) {
+                                       if(pPdg == 22) return kMCPrompt;
+                                       else  return kMCFragmentation;
+                               }
+                               else if(pStatus == 11){
+                                       if(pPdg == 111) return kMCPi0Decay ;
+                                       else if (pPdg == 321)  return kMCEtaDecay ;
+                                       else  return kMCOtherDecay ;
+                               }
+                       }//Status 1 : Pythia generated
+                       else if(mStatus == 0){
+                               if(pPdg ==22 || pPdg ==11) return kMCConversion ;
+                               if(pPdg == 111) return kMCPi0Decay ;
+                               else if (pPdg == 221)  return kMCEtaDecay ;
+                               else  return kMCOtherDecay ;
+                       }//status 0 : geant generated
+               }//Mother Photon
+               else if(mPdg == 111)  return kMCPi0 ;
+               else if(mPdg == 221)  return kMCEta ;
+               else if(mPdg ==11){
+                       if(mStatus == 0) return kMCConversion ;
+                       else return kMCElectron ;
+               }
+               else return kMCUnknown;
+       }//Good label value
+       else{
+               if(label < 0 ) printf("AliCaloPID::CheckOrigin: *** bad label or no stack ***:  label %d \n", label);
+               if(label >=  stack->GetNtrack()) printf("AliCaloPID::CheckOrigin: *** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
+               return kMCUnknown;
+       }//Bad label
+       
+       return kMCUnknown;
+       
+}
+
+//_______________________________________________________________
+void AliCaloPID::InitParameters()
+{
+       //Initialize the parameters of the PID.
+       
+       fEMCALPhotonWeight   = 0.8 ;
+       fEMCALPi0Weight      = 0.5 ;
+       fEMCALElectronWeight = 0.8 ;
+       fEMCALChargeWeight   = 0.5 ;
+       fEMCALNeutralWeight  = 0.5 ;
+       
+       fPHOSPhotonWeight    = 0.75 ;
+       fPHOSPi0Weight       = 0.8 ;
+       fPHOSElectronWeight  = 0.5 ;
+       fPHOSChargeWeight    = 0.5 ;
+       fPHOSNeutralWeight   = 0.5 ;
+       
+       //Formula to set the PID weight threshold for photon or pi0
+       fPHOSWeightFormula = kTRUE;
+       fPHOSPhotonWeightFormula = 
+    new TFormula("photonWeight","0.98*(x<40)+ 0.68*(x>=100)+(x>=40 && x<100)*(0.98+x*(6e-3)-x*x*(2e-04)+x*x*x*(1.1e-06))");
+       fPHOSPi0WeightFormula = 
+    new TFormula("pi0Weight","0.98*(x<65)+ 0.915*(x>=100)+(x>=65 && x-x*(1.95e-3)-x*x*(4.31e-05)+x*x*x*(3.61e-07))");
+       
+    fDispCut  = 1.5;
+       fTOFCut   = 5.e-9;
+       fDebug = -1;
+}
+
+//_______________________________________________________________
+Int_t AliCaloPID::GetPdg(const TString calo, const Double_t * pid, const Float_t energy) const {
+       //Return most probable identity of the particle.
+       
+       if(!pid) AliFatal("pid pointer not initialized!!!");
+       
+       Float_t wPh =  fPHOSPhotonWeight ;
+       Float_t wPi0 =  fPHOSPi0Weight ;
+       Float_t wE =  fPHOSElectronWeight ;
+       Float_t wCh =  fPHOSChargeWeight ;
+       Float_t wNe =  fPHOSNeutralWeight ;
+       
+       
+       if(calo == "PHOS" && fPHOSWeightFormula){
+               wPh  = fPHOSPhotonWeightFormula->Eval(energy) ;
+               wPi0 = fPHOSPi0WeightFormula->Eval(energy);
+       }
+       
+       if(calo == "EMCAL"){
+               
+               wPh  =  fEMCALPhotonWeight ;
+               wPi0 =  fEMCALPi0Weight ;
+               wE   =  fEMCALElectronWeight ;
+               wCh  =  fEMCALChargeWeight ;
+               wNe  =  fEMCALNeutralWeight ;
+               
+       }
+       
+       if(fDebug > 0)  printf("AliCaloPID::GetPdg: calo %s, ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f, hadrons: pion %0.2f, kaon %0.2f, proton %0.2f , neutron %0.2f, kaon %0.2f \n",
+                                                  calo.Data(),pid[AliAODCluster::kPhoton], pid[AliAODCluster::kPi0],
+                                                  pid[AliAODCluster::kElectron], pid[AliAODCluster::kEleCon],
+                                                  pid[AliAODCluster::kPion], pid[AliAODCluster::kKaon], pid[AliAODCluster::kProton],
+                                                  pid[AliAODCluster::kNeutron], pid[AliAODCluster::kKaon0]);
+       
+       Int_t pdg = kNeutralUnknown ;
+       Float_t chargedHadronWeight = pid[AliAODCluster::kProton]+pid[AliAODCluster::kKaon]+
+    pid[AliAODCluster::kPion]+pid[AliAODCluster::kMuon];
+       Float_t neutralHadronWeight = pid[AliAODCluster::kNeutron]+pid[AliAODCluster::kKaon0];
+       Float_t allChargedWeight    = pid[AliAODCluster::kElectron]+pid[AliAODCluster::kEleCon]+ chargedHadronWeight;
+       Float_t allNeutralWeight    = pid[AliAODCluster::kPhoton]+pid[AliAODCluster::kPi0]+ neutralHadronWeight;
+       
+       //Select most probable ID
+       if(calo=="PHOS"){
+               if(pid[AliAODCluster::kPhoton] > wPh) pdg = kPhoton ;
+               else if(pid[AliAODCluster::kPi0] > wPi0) pdg = kPi0 ; 
+               else if(pid[AliAODCluster::kElectron] > wE)  pdg = kElectron ;
+               else if(pid[AliAODCluster::kEleCon] >  wE) pdg = kEleCon ;
+               else if(chargedHadronWeight > wCh) pdg = kChargedHadron ;  
+               else if(neutralHadronWeight > wNe) pdg = kNeutralHadron ; 
+               else if(allChargedWeight >  allNeutralWeight)
+                       pdg = kChargedUnknown ; 
+               else 
+                       pdg = kNeutralUnknown ;
+       }
+       else{//EMCAL
+               //Temporal solution, electrons and photons not differenciated
+               if(pid[AliAODCluster::kPhoton] + pid[AliAODCluster::kElectron]  > wPh) pdg = kPhoton ;
+               else if(pid[AliAODCluster::kPi0] > wPi0) pdg = kPi0 ; 
+               else if(chargedHadronWeight + neutralHadronWeight > wCh) pdg = kChargedHadron ;  
+               else if(neutralHadronWeight + chargedHadronWeight > wNe) pdg = kNeutralHadron ; 
+               else pdg =  kNeutralUnknown ;
+               
+       }
+       
+       
+       if(fDebug > 0)printf("AliCaloPID::GetPdg:Final Pdg: %d \n", pdg);
+       
+       
+       
+       return pdg ;
+       
+}
+
+//_______________________________________________________________
+Int_t AliCaloPID::GetPdg(const TString calo,const TLorentzVector mom, const AliAODCaloCluster * cluster) const {
+       //Recalculated PID with all parameters
+       if(fDebug > 0)printf("AliCaloPID::GetPdg: Calorimeter %s, E %3.2f, l0 %3.2f, l1 %3.2f, disp %3.2f, tof %1.11f, distCPV %3.2f, distToBC %1.1f, NMax %d\n",
+                                                calo.Data(),mom.E(),cluster->GetM02(),cluster->GetM20(),cluster->GetDispersion(),cluster->GetTOF(), 
+                                                cluster->GetEmcCpvDistance(), cluster->GetDistToBadChannel(),cluster->GetNExMax());
+       
+       if(calo == "EMCAL") {
+               if(cluster->GetM02()< 0.25) return kPhoton ;
+               else return  kNeutralHadron ; 
+       }
+       
+       //   if(calo == "PHOS") {
+       //    if(cluster->GetM02()< 0.25) return kPhoton ;
+       //    else return  kNeutralHadron ; 
+       //  }
+       
+       return  kNeutralHadron ; 
+       
+}
+
+//__________________________________________________
+TString  AliCaloPID::GetPIDParametersList()  {
+       //Put data member values in string to keep in output container
+       
+       TString parList ; //this will be list of parameters used for this analysis.
+       char onePar[255] ;
+       sprintf(onePar,"--- AliCaloPID ---\n") ;
+       parList+=onePar ;       
+       sprintf(onePar,"fDispCut =%2.2f (Cut on dispersion, used in PID evaluation) \n",fDispCut) ;
+       parList+=onePar ;
+       sprintf(onePar,"fTOFCut  =%e (Cut on TOF, used in PID evaluation) \n",fTOFCut) ;
+       parList+=onePar ;
+       sprintf(onePar,"fEMCALPhotonWeight =%2.2f (EMCAL bayesian weight for photons)\n",fEMCALPhotonWeight) ;
+       parList+=onePar ;
+       sprintf(onePar,"fEMCALPi0Weight =%2.2f (EMCAL bayesian weight for pi0)\n",fEMCALPi0Weight) ;
+       parList+=onePar ;
+       sprintf(onePar,"fEMCALElectronWeight =%2.2f(EMCAL bayesian weight for electrons)\n",fEMCALElectronWeight) ;
+       parList+=onePar ;
+       sprintf(onePar,"fEMCALChargeWeight =%2.2f (EMCAL bayesian weight for charged hadrons)\n",fEMCALChargeWeight) ;
+       parList+=onePar ;
+       sprintf(onePar,"fEMCALNeutralWeight =%2.2f (EMCAL bayesian weight for neutral hadrons)\n",fEMCALNeutralWeight) ;
+       parList+=onePar ;
+       sprintf(onePar,"fPHOSPhotonWeight =%2.2f (PHOS bayesian weight for photons)\n",fPHOSPhotonWeight) ;
+       parList+=onePar ;
+       sprintf(onePar,"fPHOSPi0Weight =%2.2f (PHOS bayesian weight for pi0)\n",fPHOSPi0Weight) ;
+       parList+=onePar ;
+       sprintf(onePar,"fPHOSElectronWeight =%2.2f(PHOS bayesian weight for electrons)\n",fPHOSElectronWeight) ;
+       parList+=onePar ;
+       sprintf(onePar,"fPHOSChargeWeight =%2.2f (PHOS bayesian weight for charged hadrons)\n",fPHOSChargeWeight) ;
+       parList+=onePar ;
+       sprintf(onePar,"fPHOSNeutralWeight =%2.2f (PHOS bayesian weight for neutral hadrons)\n",fPHOSNeutralWeight) ;
+       parList+=onePar ;
+       
+       if(fPHOSWeightFormula){
+               parList+="PHOS Photon Weight Formula: "+(fPHOSPhotonWeightFormula->GetExpFormula("p"));
+               parList+="PHOS Pi0    Weight Formula: "+(fPHOSPi0WeightFormula->GetExpFormula("p"));
+       }
+       
+       return parList; 
+       
+}
+
+//________________________________________________________________
+void AliCaloPID::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("PHOS PID weight , photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f \n",  
+                  fPHOSPhotonWeight,  fPHOSPi0Weight, 
+                  fPHOSElectronWeight,  fPHOSChargeWeight,   fPHOSNeutralWeight) ; 
+       printf("EMCAL PID weight, photon %0.2f, pi0 %0.2f, e %0.2f, charge %0.2f, neutral %0.2f\n",   
+                  fEMCALPhotonWeight,  fEMCALPi0Weight, 
+                  fEMCALElectronWeight,  fEMCALChargeWeight,  fEMCALNeutralWeight) ; 
+       
+       printf("PHOS Parametrized weight on?  =     %d\n",  fPHOSWeightFormula) ; 
+       if(fPHOSWeightFormula){
+               printf("Photon weight formula = %s\n", (fPHOSPhotonWeightFormula->GetExpFormula("p")).Data());
+               printf("Pi0    weight formula = %s\n", (fPHOSPhotonWeightFormula->GetExpFormula("p")).Data());
+    }
+       
+       printf("TOF cut        = %e\n",fTOFCut);
+       printf("Dispersion cut = %2.2f\n",fDispCut);
+       printf("Debug level    = %d\n",fDebug);
+       
+       printf(" \n");
+       
+} 
+
+//_______________________________________________________________
+void AliCaloPID::SetPIDBits(const TString calo, const AliAODCaloCluster * cluster, AliAODPWG4Particle * ph) {
+       //Set Bits for PID selection
+       
+       //Dispersion/lambdas
+    Double_t disp=cluster->GetDispersion()  ;
+       //    Double_t m20=calo->GetM20() ;
+       //    Double_t m02=calo->GetM02() ; 
+    ph->SetDispBit(disp<fDispCut) ;  
+       
+    //TOF
+    Double_t tof=cluster->GetTOF()  ;
+    ph->SetTOFBit(TMath::Abs(tof)<fTOFCut) ; 
+       
+    //Charged veto
+       //    Double_t cpvR=calo->GetEmcCpvDistance() ; 
+    Int_t ntr=cluster->GetNTracksMatched();  //number of track matched
+    ph->SetChargedBit(ntr>0) ;  //Temporary cut, should we evaluate distance?
+       
+    //Set PID pdg
+       ph->SetPdg(GetPdg(calo,cluster->PID(),ph->E()));
+       
+       if(fDebug > 0){ 
+               printf("AliCaloPID::SetPIDBits: TOF %e, Dispersion %2.2f, NTracks %d\n",tof , disp, ntr);       
+               printf("AliCaloPID::SetPIDBits: pdg %d, bits: TOF %d, Dispersion %d, Charge %d\n",
+                          ph->GetPdg(), ph->GetTOFBit() , ph->GetDispBit() , ph->GetChargedBit()); 
+       }
+}
+
+
diff --git a/PWG4/PartCorrBase/AliCaloPID.h b/PWG4/PartCorrBase/AliCaloPID.h
new file mode 100755 (executable)
index 0000000..b55c1a2
--- /dev/null
@@ -0,0 +1,133 @@
+#ifndef ALICALOPID_H
+#define ALICALOPID_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Class for track/cluster acceptance selection
+// Selection in Central barrel, EMCAL and PHOS
+//
+//*-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+#include <TObject.h> 
+class TString ;
+class TLorentzVector ;
+class TFormula ;
+
+//--- AliRoot system ---
+class AliLog ;
+class AliAODCaloCluster;
+class AliAODPWG4Particle;
+#include "AliStack.h"
+
+class AliCaloPID : public TObject {
+       
+public: 
+       
+       AliCaloPID() ; // ctor
+       AliCaloPID(const AliCaloPID & g) ; // cpy ctor
+       AliCaloPID & operator = (const AliCaloPID & g) ;//cpy assignment
+       virtual ~AliCaloPID() ;//virtual dtor
+       
+       enum PidType {
+               kPhoton = 22,
+               kPi0 = 111,
+               kEta = 221, 
+               kElectron = 11, 
+               kEleCon = -11, 
+               kNeutralHadron = 2112, 
+               kChargedHadron = 211, 
+               kNeutralUnknown = 130, 
+               kChargedUnknown=321
+       };
+       
+       
+       enum mcTypes {kMCPrompt, kMCFragmentation, kMCPi0Decay, kMCEtaDecay, kMCOtherDecay, kMCPi0, kMCEta, kMCElectron, kMCConversion, kMCUnknown};
+       
+       void InitParameters();
+       Int_t CheckOrigin(const Int_t label, AliStack *  stack) const ;
+       
+       Int_t GetPdg(const TString calo, const Double_t * pid, const Float_t energy) const ;
+       
+       Int_t GetPdg(const TString calo,const TLorentzVector mom, const AliAODCaloCluster * cluster) const ;
+       
+       TString GetPIDParametersList();
+               
+       void SetPIDBits(const TString calo,  const AliAODCaloCluster * cluster, AliAODPWG4Particle *aodph);
+       
+       void Print(const Option_t * opt)const;
+       
+       //Weight getters
+       Float_t  GetEMCALPhotonWeight() const  { return  fEMCALPhotonWeight  ; }
+       Float_t  GetEMCALPi0Weight() const     {  return fEMCALPi0Weight  ; }
+       Float_t  GetEMCALElectronWeight() const  { return  fEMCALElectronWeight  ; }
+       Float_t  GetEMCALChargeWeight() const     {  return fEMCALChargeWeight  ; }
+       Float_t  GetEMCALNeutralWeight() const     {  return fEMCALNeutralWeight  ; }
+       Float_t  GetPHOSPhotonWeight() const   {  return fPHOSPhotonWeight  ; }
+       Float_t  GetPHOSPi0Weight() const   {  return fPHOSPi0Weight  ; }
+       Float_t  GetPHOSElectronWeight() const   {  return fPHOSElectronWeight  ; }
+       Float_t  GetPHOSChargeWeight() const   {  return fPHOSChargeWeight  ; }
+       Float_t  GetPHOSNeutralWeight() const   {  return fPHOSNeutralWeight  ; }
+       
+       Bool_t  IsPHOSPIDWeightFormulaOn() const   {  return fPHOSWeightFormula  ; } 
+       TFormula * GetPHOSPhotonWeightFormula() const     {  return fPHOSPhotonWeightFormula  ; } 
+       TFormula * GetPHOSPi0WeightFormula() const    {  return fPHOSPi0WeightFormula  ; }
+       
+       //Weight setters
+       void SetEMCALPhotonWeight(Float_t  w){  fEMCALPhotonWeight = w ; }
+       void SetEMCALPi0Weight(Float_t  w){  fEMCALPi0Weight = w ; }
+       void SetEMCALElectronWeight(Float_t  w){  fEMCALElectronWeight = w ; }
+       void SetEMCALChargeWeight(Float_t  w){  fEMCALChargeWeight = w ; }
+       void SetEMCALNeutralWeight(Float_t  w){  fEMCALNeutralWeight = w ; }
+       void SetPHOSPhotonWeight(Float_t  w){  fPHOSPhotonWeight = w ; }
+       void SetPHOSPi0Weight(Float_t  w){  fPHOSPi0Weight = w ; }
+       void SetPHOSElectronWeight(Float_t  w){  fPHOSElectronWeight = w ; }
+       void SetPHOSChargeWeight(Float_t  w){  fPHOSChargeWeight = w ; }
+       void SetPHOSNeutralWeight(Float_t  w){  fPHOSNeutralWeight = w ; }
+       
+       void UsePHOSPIDWeightFormula(Bool_t par)  { fPHOSWeightFormula  = par; } 
+       void SetPHOSPhotonWeightFormula(TFormula * photon)    {  fPHOSPhotonWeightFormula  = photon; } 
+       void SetPHOSPi0WeightFormula(TFormula * pi0)   {  fPHOSPi0WeightFormula  = pi0; }
+       
+       //PID bits setters and getters
+       void SetDispersionCut(Float_t dcut ) {fDispCut = dcut; }
+       Float_t GetDispersionCut() const {return fDispCut ;}   
+       
+       void SetTOFCut(Float_t tcut ) {fTOFCut = tcut; }
+       Float_t GetTOFCut() const {return fTOFCut ;}   
+       
+       void SetDebug(Int_t deb) {fDebug=deb;}
+       Int_t GetDebug() const {return fDebug;} 
+       
+private:
+       
+       Float_t      fEMCALPhotonWeight; //Bayesian PID weight for photons in EMCAL 
+       Float_t      fEMCALPi0Weight;  //Bayesian PID weight for pi0 in EMCAL 
+       Float_t      fEMCALElectronWeight; //Bayesian PID weight for electrons in EMCAL 
+       Float_t      fEMCALChargeWeight;  //Bayesian PID weight for charged hadrons in EMCAL 
+       Float_t      fEMCALNeutralWeight;  //Bayesian PID weight for neutral hadrons in EMCAL 
+       Float_t      fPHOSPhotonWeight; //Bayesian PID weight for photons in PHOS 
+       Float_t      fPHOSPi0Weight; //Bayesian PID weight for pi0 in PHOS 
+       Float_t      fPHOSElectronWeight; //Bayesian PID weight for electrons in PHOS 
+       Float_t      fPHOSChargeWeight; //Bayesian PID weight for charged hadrons in PHOS 
+       Float_t      fPHOSNeutralWeight; //Bayesian PID weight for neutral hadrons in PHOS 
+       
+       Bool_t  fPHOSWeightFormula ; //Use parametrized weight threshold, function of energy
+       TFormula * fPHOSPhotonWeightFormula ; //Formula for photon weight
+       TFormula * fPHOSPi0WeightFormula ; //Formula for pi0 weight
+       
+       Float_t fDispCut;    //Cut on dispersion, used in PID evaluation
+       Float_t fTOFCut;     //Cut on TOF, used in PID evaluation
+       
+       Int_t    fDebug; //Debug level
+       
+       ClassDef(AliCaloPID,2)
+} ;
+
+
+#endif //ALICALOPID_H
+
+
+
diff --git a/PWG4/PartCorrBase/AliCaloTrackAODReader.cxx b/PWG4/PartCorrBase/AliCaloTrackAODReader.cxx
new file mode 100755 (executable)
index 0000000..74a5f60
--- /dev/null
@@ -0,0 +1,214 @@
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Class for reading data (AODs) in order to do prompt gamma
+//  or other particle identification and correlations
+// 
+//
+//*-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+//#include "Riostream.h"
+
+//---- ANALYSIS system ----
+#include "AliCaloTrackAODReader.h" 
+#include "AliAODEvent.h"
+#include "AliAODVertex.h"
+#include "AliAODCaloCluster.h"
+#include "AliAODCaloCluster.h"
+#include "AliAODTrack.h"
+#include "AliMCEvent.h"
+#include "AliLog.h"
+
+ClassImp(AliCaloTrackAODReader)
+
+//____________________________________________________________________________
+AliCaloTrackAODReader::AliCaloTrackAODReader() : 
+  AliCaloTrackReader()
+{
+  //Default Ctor
+  
+  //Initialize parameters
+  fDataType=kAOD;
+  
+}
+
+//____________________________________________________________________________
+AliCaloTrackAODReader::AliCaloTrackAODReader(const AliCaloTrackAODReader & g) :   
+  AliCaloTrackReader(g)
+{
+  // cpy ctor
+}
+
+//_________________________________________________________________________
+//AliCaloTrackAODReader & AliCaloTrackAODReader::operator = (const AliCaloTrackAODReader & source)
+//{
+//  // assignment operator
+//
+//  if(&source == this) return *this;
+//
+//  return *this;
+//
+//}
+
+//____________________________________________________________________________
+void AliCaloTrackAODReader::FillInputCTS() {
+  //Return array with CTS tracks
+  fAODCTS = new TClonesArray("AliAODTrack",0);
+
+  Int_t nTracks   = fAOD->GetNumberOfTracks() ;
+  Int_t naod = 0;
+  Double_t p[3];
+  
+  for (Int_t itrack =  0; itrack <  nTracks; itrack++) {////////////// track loop
+    AliAODTrack * track = fAOD->GetTrack(itrack) ; // retrieve track from esd
+    
+    //     //We want tracks fitted in the detectors:
+    //     ULong_t status=AliAODTrack::kTPCrefit;
+    //     status|=AliAODTrack::kITSrefit;
+    
+    //We want tracks whose PID bit is set:
+    //     ULong_t status =AliAODTrack::kITSpid;
+    //     status|=AliAODTrack::kTPCpid;
+    
+    //   if ( (track->GetStatus() & status) == status) {//Check if the bits we want are set
+    
+    track->GetPxPyPz(p) ;
+    TLorentzVector momentum(p[0],p[1],p[2],0);
+    
+    if(fCTSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"CTS")){
+      
+      if(fDebug > 2 && momentum.Pt() > 0.1)printf("FillInputCTS():: Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                 momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
+      
+      new((*fAODCTS)[naod++])  AliAODTrack(*track);
+      
+    }//Pt and Fidutial cut passed. 
+    //}// track status
+  }// track loop
+  if(fDebug > 1) printf("FillInputCTS():: aod entries %d\n", fAODCTS->GetEntriesFast());
+}
+
+//____________________________________________________________________________
+void AliCaloTrackAODReader::FillInputEMCAL() {
+  //Return array with EMCAL clusters in aod format
+
+   fAODEMCAL = new TClonesArray("AliAODCaloCluster",0);
+   TRefArray * caloClusters = new TRefArray();
+   fAOD->GetEMCALClusters(caloClusters);
+
+  //Get vertex for momentum calculation  
+  Double_t v[3] ; //vertex ;
+  GetVertex(v);
+
+  //Loop to select clusters in fidutial cut and fill container with aodClusters
+  Int_t naod = 0;
+  for (Int_t iclus =  0; iclus <  caloClusters->GetEntriesFast(); iclus++) {
+    AliAODCaloCluster * clus = (AliAODCaloCluster *) caloClusters->At(iclus) ;
+    TLorentzVector momentum ;
+    clus->GetMomentum(momentum, v);      
+    
+    if(fEMCALPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"EMCAL")){
+    
+      if(fDebug > 2 && momentum.E() > 0.1)printf("FillInputEMCAL():: Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
+
+      new((*fAODEMCAL)[naod++]) AliAODCaloCluster(*clus);
+
+    }//Pt and Fidutial cut passed.
+  }//esd cluster loop
+  
+  if(fDebug > 1) printf("FillInputEMCAL():: aod entries %d\n", fAODEMCAL->GetEntriesFast());
+
+}
+
+//____________________________________________________________________________
+void AliCaloTrackAODReader::FillInputPHOS() {
+  //Return array with PHOS clusters in aod format
+
+  fAODPHOS = new TClonesArray("AliAODCaloCluster",0);
+  TRefArray * caloClusters = new TRefArray();
+  fAOD->GetPHOSClusters(caloClusters);
+
+  //Get vertex for momentum calculation  
+  Double_t v[3] ; //vertex ;
+  GetVertex(v);
+
+  //Loop to select clusters in fidutial cut and fill container with aodClusters
+  Int_t naod = 0;
+
+  for (Int_t iclus =  0; iclus <  caloClusters->GetEntriesFast(); iclus++) {
+    AliAODCaloCluster * clus = (AliAODCaloCluster *) caloClusters->At(iclus) ;
+    TLorentzVector momentum ;
+    clus->GetMomentum(momentum, v);      
+    
+    if(fPHOSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"PHOS")){
+      
+      if(fDebug > 2 && momentum.E() > 0.1)printf("FillInputPHOS():: Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
+
+      new((*fAODPHOS)[naod++])  AliAODCaloCluster(*clus);
+      
+    }//Pt and Fidutial cut passed.
+  }//esd cluster loop
+  
+  if(fDebug > 1) printf("FillInputPHOS():: aod entries %d\n", fAODPHOS->GetEntriesFast());
+
+
+}
+
+//____________________________________________________________________________
+void AliCaloTrackAODReader::FillInputEMCALCells() {
+  //Return array with EMCAL cells in aod format
+
+  fEMCALCells = (TNamed*) fAOD->GetEMCALCells(); 
+
+}
+
+//____________________________________________________________________________
+void AliCaloTrackAODReader::FillInputPHOSCells() {
+  //Return array with PHOS cells in aod format
+
+  fPHOSCells = (TNamed*) fAOD->GetPHOSCells(); 
+
+}
+
+//____________________________________________________________________________
+void AliCaloTrackAODReader::GetVertex(Double_t  v[3]) const {
+  //Return vertex position
+
+  v[0]=fAOD->GetVertex(0)->GetX() ;//CHECK!!!
+  v[1]=fAOD->GetVertex(0)->GetY() ;//CHECK!!!
+  v[2]=fAOD->GetVertex(0)->GetZ() ;//CHECK!!!
+}
+
+
+//____________________________________________________________________________
+void AliCaloTrackAODReader::SetInputEvent(TObject* input, TObject* aod, TObject* mc) {
+  // Connect the data pointers
+
+  //If input is AOD, do analysis with input, if not, do analysis with the output aod.
+  if(!strcmp(input->GetName(),"AliESDEvent"))   SetAOD((AliAODEvent*) aod);
+  else if(!strcmp(input->GetName(),"AliAODEvent")) SetAOD((AliAODEvent*) input);
+  else AliFatal(Form("Unknown data format: %s",input->GetName()));
+  
+  SetMC((AliMCEvent*) mc);
+
+}
diff --git a/PWG4/PartCorrBase/AliCaloTrackAODReader.h b/PWG4/PartCorrBase/AliCaloTrackAODReader.h
new file mode 100755 (executable)
index 0000000..e8ebc8c
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef ALICALOTRACKAODREADER_H
+#define ALICALOTRACKAODREADER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Class for reading data (AODs) in order to do prompt gamma or other particle
+// identification and correlations
+//
+//
+// -- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system --- 
+
+// --- AliRoot system ---
+#include "AliCaloTrackReader.h" 
+
+class AliCaloTrackAODReader : public AliCaloTrackReader {
+       
+public: 
+       
+       AliCaloTrackAODReader() ; // ctor
+       AliCaloTrackAODReader(const AliCaloTrackAODReader & g)  ; // cpy ctor
+       //AliCaloTrackAODReader & operator = (const AliCaloTrackAODReader & g) ;//cpy assignment
+       virtual ~AliCaloTrackAODReader() {;} //virtual dtor
+       
+       void FillInputCTS()   ;
+       void FillInputEMCAL() ;
+       void FillInputPHOS()  ;
+       void FillInputEMCALCells() ;
+       void FillInputPHOSCells()  ;
+       
+       void GetVertex(Double_t v[3]) const ;
+       
+       AliVEvent*  GetInputEvent()   const {return GetAOD();}
+       void SetInputEvent(TObject* esd, TObject* aod, TObject* mc) ; 
+       
+       
+       ClassDef(AliCaloTrackAODReader,1)
+} ;
+
+
+#endif //ALICALOTRACKAODREADER_H
+
+
+
diff --git a/PWG4/PartCorrBase/AliCaloTrackESDReader.cxx b/PWG4/PartCorrBase/AliCaloTrackESDReader.cxx
new file mode 100755 (executable)
index 0000000..ad4791d
--- /dev/null
@@ -0,0 +1,319 @@
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Class for reading data (ESDs) in order to do prompt gamma 
+// or other particle identification and correlations
+//
+//
+//*-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+//#include "Riostream.h"
+
+//---- ANALYSIS system ----
+#include "AliCaloTrackESDReader.h" 
+#include "AliESDEvent.h"
+#include "AliESDVertex.h"
+#include "AliESDCaloCluster.h"
+#include "AliAODCaloCluster.h"
+#include "AliAODTrack.h"
+#include "AliAODEvent.h"
+#include "AliMCEvent.h"
+#include "AliLog.h"
+
+ClassImp(AliCaloTrackESDReader)
+
+//____________________________________________________________________________
+AliCaloTrackESDReader::AliCaloTrackESDReader() : 
+AliCaloTrackReader()
+{
+       //Default Ctor
+       
+       //Initialize parameters
+       fDataType=kESD;
+       
+}
+
+//____________________________________________________________________________
+AliCaloTrackESDReader::AliCaloTrackESDReader(const AliCaloTrackESDReader & g) :   
+AliCaloTrackReader(g)
+{
+       // cpy ctor
+}
+
+//_________________________________________________________________________
+//AliCaloTrackESDReader & AliCaloTrackESDReader::operator = (const AliCaloTrackESDReader & source)
+//{
+//     // assignment operator
+//     
+//     if(&source == this) return *this;
+//     
+//     return *this;
+//     
+//}
+
+//____________________________________________________________________________
+void AliCaloTrackESDReader::FillInputCTS() {
+       //Return array with CTS tracks
+       
+       fAODCTS = new TClonesArray("AliAODTrack",0);
+       
+       Int_t nTracks   = fESD->GetNumberOfTracks() ;
+       Int_t naod = 0;
+       Double_t pos[3];
+       Double_t p[3];
+       Double_t covTr[21];
+       Double_t pid[10];
+       for (Int_t itrack =  0; itrack <  nTracks; itrack++) {////////////// track loop
+               AliESDtrack * track = fESD->GetTrack(itrack) ; // retrieve track from esd
+               
+               //We want tracks fitted in the detectors:
+               ULong_t status=AliESDtrack::kTPCrefit;
+               status|=AliESDtrack::kITSrefit;
+               
+               if ( (track->GetStatus() & status) == status) {//Check if the bits we want are set
+                       
+                       track->GetPxPyPz(p) ;
+                       TLorentzVector momentum(p[0],p[1],p[2],0);
+                       
+                       if(fCTSPtMin < momentum.Pt() &&fFidutialCut->IsInFidutialCut(momentum,"CTS")){
+                               
+                               if(fDebug > 3 && momentum.Pt() > 0.2)printf("FillInputCTS():: Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                                                                                       momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
+                               
+                               track->GetXYZ(pos);
+                               track->GetCovarianceXYZPxPyPz(covTr);
+                               track->GetESDpid(pid);
+                               
+                               Float_t impactXY, impactZ;
+                               
+                               track->GetImpactParameters(impactXY,impactZ);
+                               
+                               if (impactXY<3) {
+                                       // track inside the beam pipe
+                                       
+                                       AliAODTrack *aodTrack = new((*fAODCTS)[naod++]) 
+                                       AliAODTrack(track->GetID(), track->GetLabel(), p, kTRUE, pos, kFALSE,covTr, (Short_t)track->GetSign(), track->GetITSClusterMap(), 
+                                                               pid,
+                                                               0x0,//primary,
+                                                               kTRUE, // check if this is right
+                                                               kTRUE, // check if this is right
+                                                               AliAODTrack::kPrimary, 
+                                                               0);
+                                       
+                                       aodTrack->SetFlags(track->GetStatus());
+                                       aodTrack->ConvertAliPIDtoAODPID();
+                               }
+                               else continue;   // outside the beam pipe: orphan track 
+                       }//Pt and Fidutial cut passed. 
+               }// track status
+       }// track loop
+       if(fDebug > 1) printf("FillInputCTS():: aod entries %d\n", fAODCTS->GetEntriesFast());
+}
+
+//____________________________________________________________________________
+void AliCaloTrackESDReader::FillInputEMCAL() {
+       //Return array with EMCAL clusters in aod format
+       
+       fAODEMCAL = new TClonesArray("AliAODCaloCluster",0);
+       
+       TRefArray * caloClusters = new TRefArray();
+       fESD->GetEMCALClusters(caloClusters);
+       
+       //Get vertex for momentum calculation  
+       Double_t v[3] ; //vertex ;
+       GetVertex(v);
+       
+       //Loop to select clusters in fidutial cut and fill container with aodClusters
+       Int_t naod = 0;
+       Float_t pos[3] ;
+       //   Double_t * pid = new Double_t[AliPID::kSPECIESN];
+       
+       for (Int_t iclus =  0; iclus <  caloClusters->GetEntriesFast(); iclus++) {
+               AliESDCaloCluster * clus = (AliESDCaloCluster *) caloClusters->At(iclus) ;
+               TLorentzVector momentum ;
+               clus->GetMomentum(momentum, v);      
+               if(fDebug > 3 && momentum.E() > 0.1)printf("FillInputEMCAL():: all clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                                                                  momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta()); 
+               if(fEMCALPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"EMCAL")){
+                       
+                       if(fDebug > 2 && momentum.E() > 0.2)printf("FillInputEMCAL():: Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                                                                          momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
+                       //       pid=clus->GetPid();      
+                       clus->GetPosition(pos) ;
+                       //       printf("Reader PID ESD: ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f,pi %0.2f, k %0.2f, p %0.2f, k0 %0.2f, n %0.2f, mu %0.2f \n",
+                       //           pid[AliPID::kPhoton],pid[AliPID::kPi0],
+                       //           pid[AliPID::kElectron],pid[AliPID::kEleCon],pid[AliPID::kPion],
+                       //           pid[AliPID::kKaon],pid[AliPID::kProton], pid[AliPID::kKaon0],
+                       //           pid[AliPID::kNeutron], pid[AliPID::kMuon]);
+                       Int_t id = clus->GetID();
+                       Int_t nLabel = clus->GetNLabels();
+                       Int_t *labels=0x0;
+                       if(clus->GetLabels()) labels =  (clus->GetLabels())->GetArray();
+                       
+                       Float_t energy = clus->E();
+                       Char_t ttype= AliAODCluster::kEMCALClusterv1;
+                       AliAODCaloCluster *caloCluster = new((*fAODEMCAL)[naod++]) 
+                       AliAODCaloCluster(id,nLabel,labels,energy, pos, NULL,ttype,0);
+                       
+                       caloCluster->SetPIDFromESD(clus->GetPid());
+                       caloCluster->SetCaloCluster(clus->GetDistanceToBadChannel(), clus->GetClusterDisp(), 
+                                                                               clus->GetM20(), clus->GetM02(),   
+                                                                               clus->GetEmcCpvDistance(),  clus->GetNExMax(), clus->GetTOF()) ;
+                                                                               
+                                                                                       
+                       if(fDebug > 3 && momentum.E() > 0.2)
+                               printf("FillInputEMCAL():: Selected clusters Distance BC %2.2f, dispersion %2.2f, M20 %f, M02 %3.2f, NexMax %d, TOF %e\n",
+                                               clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),clus->GetM20(), clus->GetM02(),
+                                               clus->GetNExMax(), clus->GetTOF());
+                                                                               
+                       caloCluster->SetNCells(clus->GetNCells());
+                       caloCluster->SetCellsAbsId(clus->GetCellsAbsId());
+                       caloCluster->SetCellsAmplitudeFraction(clus->GetCellsAmplitudeFraction());
+                       
+                       TArrayI* matchedT =     clus->GetTracksMatched();
+                       if (matchedT && clus->GetTrackMatched() > 0) {  
+                               for (Int_t im = 0; im < matchedT->GetSize(); im++) {
+                                       caloCluster->AddTrackMatched((fESD->GetTrack(im)));
+                               }
+                       }
+                       
+               }//Pt and Fidutial cut passed.
+       }//esd cluster loop
+       
+       if(fDebug > 1) printf("FillInputEMCAL():: aod entries %d\n", fAODEMCAL->GetEntriesFast());
+       
+}
+
+//____________________________________________________________________________
+void AliCaloTrackESDReader::FillInputPHOS() {
+       //Return array with PHOS clusters in aod format
+       fAODPHOS = new TClonesArray("AliAODCaloCluster",0);
+       
+       TRefArray * caloClusters = new TRefArray();
+       fESD->GetPHOSClusters(caloClusters);
+       
+       //Get vertex for momentum calculation  
+       Double_t v[3] ; //vertex ;
+       GetVertex(v);
+       
+       //Loop to select clusters in fidutial cut and fill container with aodClusters
+       Int_t naod = 0;
+       Float_t pos[3] ;
+       Double_t * pid = new Double_t[AliPID::kSPECIESN];
+       
+       for (Int_t iclus =  0; iclus <  caloClusters->GetEntriesFast(); iclus++) {
+               AliESDCaloCluster * clus = (AliESDCaloCluster *) caloClusters->At(iclus) ;
+               TLorentzVector momentum ;
+               clus->GetMomentum(momentum, v);      
+               if(fDebug > 3 && momentum.E() > 0.1)printf("FillInputPHOS():: all clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                                                                  momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
+               if(fPHOSPtMin < momentum.Pt() && fFidutialCut->IsInFidutialCut(momentum,"PHOS")){
+                       
+                       if(fDebug > 2 && momentum.E() > 0.1)printf("FillInputPHOS():: Selected clusters E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                                                                          momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
+                       
+                       pid=clus->GetPid();      
+                       // printf("Reader PID ESD: ph %0.2f, pi0 %0.2f, el %0.2f, conv el %0.2f,pi %0.2f, k %0.2f, p %0.2f, k0 %0.2f, n %0.2f, mu %0.2f \n",
+                       //       pid[AliPID::kPhoton],pid[AliPID::kPi0],
+                       //       pid[AliPID::kElectron],pid[AliPID::kEleCon],pid[AliPID::kPion],
+                       //       pid[AliPID::kKaon],pid[AliPID::kProton], pid[AliPID::kKaon0],
+                       //       pid[AliPID::kNeutron], pid[AliPID::kMuon]);
+                       
+                       clus->GetPosition(pos) ;
+                       Int_t id = clus->GetID();
+                       Int_t nLabel = clus->GetNLabels();
+                       Int_t *labels=0x0;
+                       if(clus->GetLabels()) labels =  (clus->GetLabels())->GetArray();
+                       Float_t energy = clus->E();
+                       
+                       //Phos cluster type
+                       Char_t ttype= AliAODCluster::kPHOSNeutral;
+                       Float_t wNeutral = pid[AliPID::kNeutron]+ pid[AliPID::kKaon0]+pid[AliPID::kPhoton]+pid[AliPID::kPi0];
+                       Float_t wCharged = pid[AliPID::kMuon] + pid[AliPID::kElectron] + pid[AliPID::kEleCon]+ 
+                       pid[AliPID::kProton]+pid[AliPID::kKaon]+pid[AliPID::kPion];
+                       if( wCharged > wNeutral)  ttype= AliAODCluster::kPHOSCharged;
+                       
+                       AliAODCaloCluster *caloCluster = new((*fAODPHOS)[naod++]) 
+                       AliAODCaloCluster(id,nLabel,labels,energy, pos, NULL, ttype, 0);
+                       caloCluster->SetPIDFromESD(clus->GetPid());   
+                       caloCluster->SetCaloCluster(clus->GetDistanceToBadChannel(), clus->GetClusterDisp(), 
+                                                                               clus->GetM20(), clus->GetM02(),  
+                                                                               clus->GetEmcCpvDistance(),  clus->GetNExMax()) ;
+                                                                               
+                       if(fDebug > 3 && momentum.E() > 0.2)
+                               printf("FillInputPHOS():: Selected clusters Distance BC %2.2f, dispersion %2.2f, M20 %f, M02 %3.2f, EmcCpvDist %3.3f, NexMax %d, TOF %e\n",
+                                               clus->GetDistanceToBadChannel(), clus->GetClusterDisp(),clus->GetM20(), clus->GetM02(),
+                                               clus->GetEmcCpvDistance(),  clus->GetNExMax(), clus->GetTOF());
+
+                       caloCluster->SetNCells(clus->GetNCells());
+                       caloCluster->SetCellsAbsId(clus->GetCellsAbsId());
+                       caloCluster->SetCellsAmplitudeFraction(clus->GetCellsAmplitudeFraction());
+                       TArrayI* matchedT =     clus->GetTracksMatched();
+                       if (matchedT) { 
+                               for (Int_t im = 0; im < matchedT->GetSize(); im++) {
+                                       caloCluster->AddTrackMatched((fESD->GetTrack(im)));
+                               }
+                       }
+                       
+               }//Pt and Fidutial cut passed.
+       }//esd cluster loop
+       if(fDebug > 1) printf("FillInputPHOS():: aod entries %d\n", fAODPHOS->GetEntriesFast());
+       
+       
+}
+
+//____________________________________________________________________________
+void AliCaloTrackESDReader::FillInputEMCALCells() {
+       //Return array with EMCAL cells in esd format
+       
+       fEMCALCells = (TNamed*) fESD->GetEMCALCells(); 
+       
+}
+
+//____________________________________________________________________________
+void AliCaloTrackESDReader::FillInputPHOSCells() {
+       //Return array with PHOS cells in esd format
+       
+       fPHOSCells = (TNamed*) fESD->GetPHOSCells(); 
+       
+}
+
+//____________________________________________________________________________
+void AliCaloTrackESDReader::GetVertex(Double_t  v[3]) const {
+       //Return vertex position
+       
+       fESD->GetVertex()->GetXYZ(v) ;
+       
+}
+
+
+//____________________________________________________________________________
+void AliCaloTrackESDReader::SetInputEvent(TObject* esd, TObject* aod, TObject* mc) {
+       // Connect the data pointers
+       
+       if(strcmp(esd->GetName(),"AliESDEvent"))
+               AliFatal(Form("Wrong reader, here only ESDs. Input name: %s != AliESDEvent \n",esd->GetName()));
+       
+       SetESD((AliESDEvent*) esd);
+       SetAOD ((AliAODEvent*) aod);
+       SetMC((AliMCEvent*) mc);
+       
+}
diff --git a/PWG4/PartCorrBase/AliCaloTrackESDReader.h b/PWG4/PartCorrBase/AliCaloTrackESDReader.h
new file mode 100755 (executable)
index 0000000..6c7135f
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef ALICALOTRACKESDREADER_H
+#define ALICALOTRACKESDREADER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Class for reading data (ESDs) in order to do prompt gamma 
+//  or other particle identification and correlations
+// 
+
+//*-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system --- 
+
+// --- AliRoot system ---
+#include "AliCaloTrackReader.h" 
+
+class AliCaloTrackESDReader : public AliCaloTrackReader {
+       
+public: 
+       
+       AliCaloTrackESDReader() ; // ctor
+       AliCaloTrackESDReader(const AliCaloTrackESDReader & g) ; // cpy ctor
+       //AliCaloTrackESDReader & operator = (const AliCaloTrackESDReader & g) ;//cpy assignment
+       virtual ~AliCaloTrackESDReader() {;} //virtual dtor
+       
+       void FillInputCTS  () ;
+       void FillInputEMCAL() ;
+       void FillInputPHOS () ;  
+       void FillInputEMCALCells() ;
+       void FillInputPHOSCells() ;
+       
+       void GetVertex(Double_t v[3]) const ;
+       
+       AliVEvent*  GetInputEvent() const {return GetESD();}
+       void SetInputEvent(TObject* esd, TObject* aod, TObject* mc) ; 
+       
+       ClassDef(AliCaloTrackESDReader,1)
+} ;
+
+
+#endif //ALICALOTRACKESDREADER_H
+
+
+
diff --git a/PWG4/PartCorrBase/AliCaloTrackMCReader.cxx b/PWG4/PartCorrBase/AliCaloTrackMCReader.cxx
new file mode 100755 (executable)
index 0000000..600a52a
--- /dev/null
@@ -0,0 +1,846 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is         *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Class for reading data (Kinematics) in order to do prompt gamma 
+// or other particle identification and correlations
+//
+//*-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+
+#include <TParticle.h>
+#include <TRandom.h>
+#include <TClonesArray.h>
+//#include "Riostream.h"
+
+//---- ANALYSIS system ----
+#include "AliCaloTrackMCReader.h" 
+#include "AliLog.h"
+#include "AliGenEventHeader.h"
+#include "AliStack.h"
+#include "AliAODCaloCluster.h"
+#include "AliAODTrack.h"
+
+ClassImp(AliCaloTrackMCReader)
+
+//____________________________________________________________________________
+AliCaloTrackMCReader::AliCaloTrackMCReader() : 
+  AliCaloTrackReader(), fDecayPi0(0), 
+  fNeutralParticlesArray(0x0),    fChargedParticlesArray(0x0), 
+  fStatusArray(0x0), fKeepAllStatus(0), fClonesArrayType(0)
+{
+  //Ctor
+  
+  //Initialize parameters
+  InitParameters();
+  fDataType = kMC;  
+  
+}
+
+//____________________________________________________________________________
+AliCaloTrackMCReader::AliCaloTrackMCReader(const AliCaloTrackMCReader & g) :   
+  AliCaloTrackReader(g), fDecayPi0(g.fDecayPi0), 
+  fNeutralParticlesArray(g.fNeutralParticlesArray?new TArrayI(*g.fNeutralParticlesArray):0x0),
+  fChargedParticlesArray(g.fChargedParticlesArray?new TArrayI(*g.fChargedParticlesArray):0x0),
+  fStatusArray(g.fStatusArray?new TArrayI(*g.fStatusArray):0x0),
+  fKeepAllStatus(g.fKeepAllStatus), fClonesArrayType(g.fClonesArrayType)
+{
+  // cpy ctor
+}
+
+//_________________________________________________________________________
+AliCaloTrackMCReader & AliCaloTrackMCReader::operator = (const AliCaloTrackMCReader & source)
+{
+  // assignment operator
+
+  if(&source == this) return *this;
+
+  fDecayPi0 = source.fDecayPi0; 
+
+  delete fChargedParticlesArray;
+  fChargedParticlesArray = source.fChargedParticlesArray?new TArrayI(*source.fChargedParticlesArray):0x0;
+
+  delete fNeutralParticlesArray;
+  fNeutralParticlesArray = source.fNeutralParticlesArray?new TArrayI(*source.fNeutralParticlesArray):0x0;
+
+  delete fStatusArray;
+  fStatusArray = source.fStatusArray?new TArrayI(*source.fStatusArray):0x0;
+  fKeepAllStatus = source.fKeepAllStatus ;
+  fClonesArrayType = source.fClonesArrayType ;
+
+  return *this;
+
+}
+
+//_________________________________
+AliCaloTrackMCReader::~AliCaloTrackMCReader() {
+  //Dtor
+
+  if(fChargedParticlesArray) delete fChargedParticlesArray ;
+  if(fNeutralParticlesArray) delete fNeutralParticlesArray ;
+  if(fStatusArray) delete fStatusArray ;
+
+}
+
+//____________________________________________________________________________
+void AliCaloTrackMCReader::GetVertex(Double_t  v[3]) const {
+  //Return vertex position
+
+  TArrayF pv;
+  GetGenEventHeader()->PrimaryVertex(pv);
+  v[0]=pv.At(0);
+  v[1]=pv.At(1);
+  v[2]=pv.At(2);
+
+}
+
+
+//_______________________________________________________________
+void AliCaloTrackMCReader::InitParameters()
+{
+  
+  //Initialize the parameters of the analysis.
+
+  fDecayPi0 = kFALSE;
+
+  fChargedParticlesArray = new TArrayI(1);
+  fChargedParticlesArray->SetAt(11,0);  
+  //Int_t pdgarray[]={12,14,16};// skip neutrinos
+  //fNeutralParticlesArray = new TArrayI(3, pdgarray);
+  fNeutralParticlesArray = new TArrayI(3);
+  fNeutralParticlesArray->SetAt(12,0); fNeutralParticlesArray->SetAt(14,1); fNeutralParticlesArray->SetAt(16,2); 
+  fStatusArray = new TArrayI(1);
+  fStatusArray->SetAt(1,0); 
+  fKeepAllStatus = kTRUE;
+  fClonesArrayType = kAliAOD ;
+
+}
+
+//____________________________________________________________________________
+void  AliCaloTrackMCReader::FillCalorimeters(const Int_t iParticle, TParticle* particle, TLorentzVector momentum,
+                                            Int_t &indexPHOS, Int_t &indexEMCAL) {
+       //Fill AODCaloClusters or TParticles lists of PHOS or EMCAL
+       
+       //In PHOS
+       if(fFillPHOS && fFidutialCut->IsInFidutialCut(momentum,"PHOS") && momentum.Pt() > fPHOSPtMin){
+               
+               if(fClonesArrayType == kTParticle) new((*fAODPHOS)[indexPHOS++])       TParticle(*particle) ;
+               else{
+                       
+                       Char_t ttype= AliAODCluster::kPHOSNeutral;
+                       Int_t labels[] = {iParticle};
+                       Float_t x[] = {momentum.X(), momentum.Y(), momentum.Z()};                       
+                       AliAODCaloCluster *calo = new((*fAODPHOS)[indexPHOS++]) 
+                       AliAODCaloCluster(iParticle,1,labels,momentum.E(), x, NULL, ttype, 0);
+                       SetCaloClusterPID(particle->GetPdgCode(),calo) ;
+                       if(fDebug > 3 && momentum.Pt() > 0.2)
+                                       printf("Fill MC PHOS :: Selected tracks %s E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                       particle->GetName(),momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());                        
+               }
+       }
+       //In EMCAL
+       else if(fFillEMCAL && fFidutialCut->IsInFidutialCut(momentum,"EMCAL") && momentum.Pt() > fEMCALPtMin){
+               if(fClonesArrayType == kTParticle) new((*fAODEMCAL)[indexEMCAL++])       TParticle(*particle) ;
+               else{
+                       Char_t ttype= AliAODCluster::kEMCALClusterv1;
+                       Int_t labels[] = {iParticle};
+                       Float_t x[] = {momentum.X(), momentum.Y(), momentum.Z()};
+                       AliAODCaloCluster *calo = new((*fAODEMCAL)[indexEMCAL++]) 
+                       AliAODCaloCluster(iParticle,1,labels,momentum.E(), x, NULL, ttype, 0);
+                       SetCaloClusterPID(particle->GetPdgCode(),calo) ;
+                       if(fDebug > 3 && momentum.Pt() > 0.2)
+                                       printf("Fill MC EMCAL :: Selected tracks %s E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                       particle->GetName(),momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());        
+               }
+       }
+}
+
+//____________________________________________________________________________
+void AliCaloTrackMCReader::FillInputEvent()
+{
+       //Create list of particles from EMCAL, PHOS and CTS. 
+       
+       if(fClonesArrayType == kTParticle){
+               fAODCTS = new TClonesArray("TParticle",0);
+               fAODEMCAL = new TClonesArray("TParticle",0);
+               fAODPHOS = new TClonesArray("TParticle",0);
+       }
+       else if(fClonesArrayType == kAliAOD){
+               fAODCTS = new TClonesArray("AliAODTrack",0);
+               fAODPHOS = new TClonesArray("AliAODCaloCluster",0);
+               fAODEMCAL = new TClonesArray("AliAODCaloCluster",0);
+       }
+       else {AliFatal("Wrong clones type");}
+       
+       
+       Int_t indexCh      = 0 ;
+       Int_t indexEMCAL = 0 ;
+       Int_t indexPHOS = 0 ;
+       
+       Int_t iParticle = 0 ;
+       Double_t charge = 0.;
+
+       for (iParticle=0 ; iParticle <  GetStack()->GetNtrack() ; iParticle++) {
+               TParticle * particle = GetStack()->Particle(iParticle);
+               TLorentzVector momentum;
+               Float_t p[3];
+               Float_t x[3];
+               Int_t pdg = particle->GetPdgCode();
+               
+               //Keep particles with a given status 
+               if(KeepParticleWithStatus(particle->GetStatusCode()) && (particle->Pt() > 0) ){
+               
+                   //Skip bizarre particles, they crash when charge is calculated
+                       if(TMath::Abs(pdg) == 3124 || TMath::Abs(pdg) > 10000000) continue ;
+                       
+                       charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
+                       particle->Momentum(momentum);
+                       //---------- Charged particles ----------------------
+                       if((charge != 0) && (momentum.Pt() > fCTSPtMin) && (fFidutialCut->IsInFidutialCut(momentum,"CTS"))){
+                               if(fFillCTS){
+                                       //Particles in CTS acceptance
+                                       if(fDebug > 3 && momentum.Pt() > 0.2)
+                                               printf("Fill MC CTS :: Selected tracks E %3.2f, pt %3.2f, phi %3.2f, eta %3.2f\n",
+                                                               momentum.E(),momentum.Pt(),momentum.Phi()*TMath::RadToDeg(),momentum.Eta());
+                                       
+                                       if(fClonesArrayType == kTParticle) new((*fAODCTS)[indexCh++])       TParticle(*particle) ;
+                                       else{
+                                               x[0] = particle->Vx(); x[1] = particle->Vy(); x[2] = particle->Vz();
+                                               p[0] = particle->Px(); p[1] = particle->Py(); p[2] = particle->Pz();
+                                               AliAODTrack *aodTrack = new((*fAODCTS)[indexCh++]) 
+                                               AliAODTrack(0, iParticle, p, kTRUE, x, kFALSE,NULL, 0, 0, 
+                                                                       NULL,
+                                                                       0x0,//primary,
+                                                                       kFALSE, // No fit performed
+                                                                       kFALSE, // No fit performed
+                                                                       AliAODTrack::kPrimary, 
+                                                                       0);
+                                               SetTrackChargeAndPID(pdg, aodTrack);
+                                       }
+                               }
+                               //Keep some charged particles in calorimeters lists
+                               if((fFillPHOS || fFillEMCAL) && KeepChargedParticles(pdg)) FillCalorimeters(iParticle, particle, momentum, indexPHOS, indexEMCAL);
+                               
+                       }//Charged
+                       
+                       //-------------Neutral particles ----------------------
+                       else if(charge == 0 && (fFillPHOS || fFillEMCAL)){
+                               //Skip neutrinos or other neutral particles
+                               //if(SkipNeutralParticles(pdg) || particle->IsPrimary()) continue ; // protection added (MG)
+                               if(SkipNeutralParticles(pdg)) continue ;
+                                                               
+                               //Fill particle/calocluster arrays
+                               if(!fDecayPi0) {
+                                       FillCalorimeters(iParticle, particle, momentum, indexPHOS, indexEMCAL);
+                               }
+                               else {
+                                       //Sometimes pi0 are stable for the generator, if needed decay it by hand
+                                       if(pdg == 111 ){
+                                               if(momentum.Pt() >  fPHOSPtMin || momentum.Pt() >  fEMCALPtMin){
+                                                       TLorentzVector lvGamma1, lvGamma2 ;
+                                                       //Double_t angle = 0;
+                                                       
+                                                       //Decay
+                                                       MakePi0Decay(momentum,lvGamma1,lvGamma2);//,angle);
+                                                       
+                                                       //Check if Pi0 is in the acceptance of the calorimeters, if aperture angle is small, keep it
+                                                       TParticle * pPhoton1 = new TParticle(22,1,iParticle,0,0,0,lvGamma1.Px(),lvGamma1.Py(),
+                                                                                                                                lvGamma1.Pz(),lvGamma1.E(),0,0,0,0);   
+                                                       TParticle * pPhoton2 = new TParticle(22,1,iParticle,0,0,0,lvGamma2.Px(),lvGamma2.Py(),
+                                                                                                                                lvGamma2.Pz(),lvGamma2.E(),0,0,0,0);
+                                                       //Fill particle/calocluster arrays
+                                                       FillCalorimeters(iParticle,pPhoton1,lvGamma1, indexPHOS, indexEMCAL);
+                                                       FillCalorimeters(iParticle,pPhoton2,lvGamma2, indexPHOS, indexEMCAL);
+                                               }//pt cut
+                                       }//pi0
+                                       else FillCalorimeters(iParticle,particle, momentum, indexPHOS, indexEMCAL); //Add the rest
+                               }
+                       }//neutral particles
+               } //particle with correct status
+       }//particle loop
+       
+}
+
+//________________________________________________________________
+Bool_t AliCaloTrackMCReader::KeepParticleWithStatus(Int_t status) const {
+  //Check if status is equal to one of the  list
+  //These particles will be used in analysis.
+  if(!fKeepAllStatus){
+    for(Int_t i= 0; i < fStatusArray->GetSize(); i++)
+      if(status ==  fStatusArray->At(i)) return kTRUE ;
+
+    return kFALSE; 
+    
+  }
+  else
+    return kTRUE ;  
+}
+
+//________________________________________________________________
+Bool_t AliCaloTrackMCReader::KeepChargedParticles(Int_t pdg) const {
+  //Check if pdg is equal to one of the charged particles list
+  //These particles will be added to the calorimeters lists.
+
+  for(Int_t i= 0; i < fChargedParticlesArray->GetSize(); i++)
+    if(TMath::Abs(pdg) ==  fChargedParticlesArray->At(i)) return kTRUE ;
+  
+  return kFALSE; 
+  
+}
+
+//________________________________________________________________
+void AliCaloTrackMCReader::Print(const Option_t * opt) const
+{
+  //Print some relevant parameters set for the analysis
+  if(! opt)
+    return;
+  
+  Info("**** Print **** ", "%s %s", GetName(), GetTitle() ) ;
+  
+  printf("Decay Pi0?          : %d\n", fDecayPi0) ;
+  printf("TClonesArray type   : %d\n", fClonesArrayType) ;
+  printf("Keep all status?    : %d\n", fKeepAllStatus) ;
+  
+  if(!fKeepAllStatus) printf("Keep particles with status : ");
+  for(Int_t i= 0; i < fStatusArray->GetSize(); i++)
+    printf(" %d ; ", fStatusArray->At(i));
+  printf("\n");
+  
+  printf("Skip neutral particles in calo : ");
+  for(Int_t i= 0; i < fNeutralParticlesArray->GetSize(); i++)
+    printf(" %d ; ", fNeutralParticlesArray->At(i));
+  printf("\n");
+  
+  printf("Keep charged particles in calo : ");
+  for(Int_t i= 0; i < fChargedParticlesArray->GetSize(); i++)
+    printf(" %d ; ", fChargedParticlesArray->At(i));
+  printf("\n");
+
+}
+
+//____________________________________________________________________________
+void AliCaloTrackMCReader::MakePi0Decay(TLorentzVector &p0, TLorentzVector &p1, 
+                               TLorentzVector &p2) const {//, Double_t &angle) {
+  // Perform isotropic decay pi0 -> 2 photons
+  // p0 is pi0 4-momentum (inut)
+  // p1 and p2 are photon 4-momenta (output)
+  //  cout<<"Boost vector"<<endl;
+  Double_t mPi0 = TDatabasePDG::Instance()->GetParticle(111)->Mass();
+  TVector3 b = p0.BoostVector();
+  //cout<<"Parameters"<<endl;
+  //Double_t mPi0   = p0.M();
+  Double_t phi    = TMath::TwoPi() * gRandom->Rndm();
+  Double_t cosThe = 2 * gRandom->Rndm() - 1;
+  Double_t cosPhi = TMath::Cos(phi);
+  Double_t sinPhi = TMath::Sin(phi);
+  Double_t sinThe = TMath::Sqrt(1-cosThe*cosThe);
+  Double_t ePi0   = mPi0/2.;
+  //cout<<"ePi0 "<<ePi0<<endl;
+  //cout<<"Components"<<endl;
+  p1.SetPx(+ePi0*cosPhi*sinThe);
+  p1.SetPy(+ePi0*sinPhi*sinThe);
+  p1.SetPz(+ePi0*cosThe);
+  p1.SetE(ePi0);
+  //cout<<"p1: "<<p1.Px()<<" "<<p1.Py()<<" "<<p1.Pz()<<" "<<p1.E()<<endl;
+  //cout<<"p1 Mass: "<<p1.Px()*p1.Px()+p1.Py()*p1.Py()+p1.Pz()*p1.Pz()-p1.E()*p1.E()<<endl;
+  p2.SetPx(-ePi0*cosPhi*sinThe);
+  p2.SetPy(-ePi0*sinPhi*sinThe);
+  p2.SetPz(-ePi0*cosThe);
+  p2.SetE(ePi0);
+  //cout<<"p2: "<<p2.Px()<<" "<<p2.Py()<<" "<<p2.Pz()<<" "<<p2.E()<<endl;
+  //cout<<"p2 Mass: "<<p2.Px()*p2.Px()+p2.Py()*p2.Py()+p2.Pz()*p2.Pz()-p2.E()*p2.E()<<endl;
+  //cout<<"Boost "<<b.X()<<" "<<b.Y()<<" "<<b.Z()<<endl;
+  p1.Boost(b);
+  //cout<<"p1: "<<p1.Px()<<" "<<p1.Py()<<" "<<p1.Pz()<<" "<<p1.E()<<endl;
+  p2.Boost(b);
+  //cout<<"p2: "<<p2.Px()<<" "<<p2.Py()<<" "<<p2.Pz()<<" "<<p2.E()<<endl;
+  //cout<<"angle"<<endl;
+  //angle = p1.Angle(p2.Vect());
+  //cout<<angle<<endl;
+}
+
+//____________________________________________________________________________
+void AliCaloTrackMCReader::SetInputEvent(TObject* /*esd*/, TObject* aod, TObject* mc) {
+  // Connect the data pointer
+  SetMC((AliMCEvent*) mc);
+  SetAOD((AliAODEvent*) aod);
+}
+
+
+//________________________________________________________________
+Bool_t AliCaloTrackMCReader::SkipNeutralParticles(Int_t pdg) const {
+  //Check if pdg is equal to one of the neutral particles list
+  //These particles will be skipped from analysis.
+
+  for(Int_t i= 0; i < fNeutralParticlesArray->GetSize(); i++)
+    if(TMath::Abs(pdg) ==  fNeutralParticlesArray->At(i)) return kTRUE ;
+  
+  return kFALSE; 
+  
+}
+
+
+//____________________________________________________________________
+void AliCaloTrackMCReader::SetTrackChargeAndPID(const Int_t pdgCode, AliAODTrack *track) const {
+//Give a PID weight for tracks equal to 1 depending on the particle type
+
+  Float_t pid[10] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
+
+  switch (pdgCode) {
+
+  case 22: // gamma
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 11: // e- 
+    track->SetCharge(-1);
+    pid[AliAODTrack::kElectron] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case -11: // e+
+    track->SetCharge(+1);
+    pid[AliAODTrack::kElectron] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case 13: // mu- 
+    track->SetCharge(-1);
+    pid[AliAODTrack::kMuon] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case -13: // mu+
+    track->SetCharge(+1);
+    pid[AliAODTrack::kMuon] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case 111: // pi0
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case 211: // pi+
+    track->SetCharge(+1);
+    pid[AliAODTrack::kPion] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case -211: // pi-
+    track->SetCharge(-1);
+    pid[AliAODTrack::kPion] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case 130: // K0L
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case 321: // K+
+    track->SetCharge(+1);
+    pid[AliAODTrack::kKaon] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case -321: // K- 
+    track->SetCharge(-1);
+    pid[AliAODTrack::kKaon] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case 2112: // n
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case 2212: // p
+    track->SetCharge(+1);
+    pid[AliAODTrack::kProton] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case -2212: // anti-p
+    track->SetCharge(-1);
+    pid[AliAODTrack::kProton] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 310: // K0S
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case 311: // K0
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case -311: // anti-K0
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+    
+  case 221: // eta
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 3122: // lambda
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 3222: // Sigma+
+    track->SetCharge(+1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 3212: // Sigma0
+    track->SetCharge(-1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 3112: // Sigma-
+    track->SetCharge(-1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 3322: // Xi0
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 3312: // Xi-
+    track->SetCharge(-1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 3334: // Omega-
+    track->SetCharge(-1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case -2112: // n-bar
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case -3122: // anti-Lambda
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case -3222: // anti-Sigma-
+    track->SetCharge(-1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case -3212: // anti-Sigma0
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case -3112: // anti-Sigma+
+    track->SetCharge(+1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case -3322: // anti-Xi0
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case -3312: // anti-Xi+
+    track->SetCharge(+1);
+    break;
+
+  case -3334: // anti-Omega+
+    track->SetCharge(+1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 411: // D+
+    track->SetCharge(+1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case -411: // D- 
+    track->SetCharge(-1);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case 421: // D0
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  case -421: // anti-D0
+    track->SetCharge(0);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+    break;
+
+  default : // unknown
+    track->SetCharge(-99);
+    pid[AliAODTrack::kUnknown] = 1.;
+    track->SetPID(pid);
+ }
+
+  track->SetPID(pid);
+
+  return;
+}
+
+//____________________________________________________________________
+void AliCaloTrackMCReader::SetCaloClusterPID(const Int_t pdgCode, AliAODCaloCluster *calo) const {
+//Give a PID weight for CaloClusters equal to 1 depending on the particle type
+
+  Float_t pid[13] = {0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.};
+
+  switch (pdgCode) {
+
+  case 22: // gamma
+    pid[AliAODCaloCluster::kPhoton] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 11: // e- 
+    pid[AliAODCaloCluster::kElectron] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case -11: // e+
+    pid[AliAODCaloCluster::kElectron] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case 13: // mu- 
+    pid[AliAODCaloCluster::kCharged] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case -13: // mu+
+    pid[AliAODCaloCluster::kCharged] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case 111: // pi0
+    pid[AliAODCaloCluster::kPi0] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case 211: // pi+
+    pid[AliAODCaloCluster::kCharged] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case -211: // pi-
+    pid[AliAODCaloCluster::kCharged] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case 130: // K0L
+    pid[AliAODCaloCluster::kKaon0] = 1.;
+    pid[AliAODCaloCluster::kNeutral] = 1;
+    calo->SetPID(pid);
+    break;
+    
+  case 321: // K+
+    pid[AliAODCaloCluster::kCharged] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case -321: // K- 
+    pid[AliAODCaloCluster::kCharged] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case 2112: // n
+    pid[AliAODCaloCluster::kNeutron] = 1.;
+    pid[AliAODCaloCluster::kNeutral] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case 2212: // p
+    pid[AliAODCaloCluster::kCharged] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case -2212: // anti-p
+    pid[AliAODCaloCluster::kCharged] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 310: // K0S
+    pid[AliAODCaloCluster::kKaon0] = 1.;
+    pid[AliAODCaloCluster::kNeutral] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case 311: // K0
+    pid[AliAODCaloCluster::kKaon0] = 1.;
+    pid[AliAODCaloCluster::kNeutral] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case -311: // anti-K0
+    pid[AliAODCaloCluster::kKaon0] = 1.;
+    pid[AliAODCaloCluster::kNeutral] = 1.;
+    calo->SetPID(pid);
+    break;
+    
+  case 221: // eta
+    pid[AliAODCaloCluster::kNeutral] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 3122: // lambda
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 3222: // Sigma+
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 3212: // Sigma0
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 3112: // Sigma-
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 3322: // Xi0
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 3312: // Xi-
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 3334: // Omega-
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -2112: // n-bar
+    pid[AliAODCaloCluster::kNeutron] = 1.;
+    pid[AliAODCaloCluster::kNeutral] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -3122: // anti-Lambda
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -3222: // anti-Sigma-
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -3212: // anti-Sigma0
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -3112: // anti-Sigma+
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -3322: // anti-Xi0
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -3312: // anti-Xi+
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -3334: // anti-Omega+
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 411: // D+
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -411: // D- 
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case 421: // D0
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  case -421: // anti-D0
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+    break;
+
+  default : // unknown
+    pid[AliAODCaloCluster::kUnknown] = 1.;
+    calo->SetPID(pid);
+ }
+
+  return;
+}
diff --git a/PWG4/PartCorrBase/AliCaloTrackMCReader.h b/PWG4/PartCorrBase/AliCaloTrackMCReader.h
new file mode 100755 (executable)
index 0000000..48077d6
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef ALICALOTRACKMCREADER_H
+#define ALICALOTRACKMCREADER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Class for reading data (Kinematics) in order to do prompt gamma or other particle  correlations
+//
+
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+
+// --- AliRoot system ---
+#include "AliCaloTrackReader.h" 
+class AliAODCaloCluster ;
+class AliAODTrack ;
+
+class AliCaloTrackMCReader : public AliCaloTrackReader {
+  
+ public: 
+  
+  AliCaloTrackMCReader() ; // ctor
+  AliCaloTrackMCReader(const AliCaloTrackMCReader & g) ; // cpy ctor
+  AliCaloTrackMCReader & operator = (const AliCaloTrackMCReader & g) ;//cpy assignment
+  virtual ~AliCaloTrackMCReader() ;//virtual dtor
+  
+  enum clonesType {kTParticle, kAliAOD};
+  
+  void InitParameters();
+  
+  void Print(const Option_t * opt) const; 
+  
+  void SwitchOnPi0Decay()  { fDecayPi0 = kTRUE ; } 
+  void SwitchOffPi0Decay() { fDecayPi0 = kFALSE ; } 
+  Int_t IsPi0DecaySwitchedOn() const { return fDecayPi0 ; } 
+  
+  void SetClonesArrayType(Int_t type){fClonesArrayType = type ;} 
+  Bool_t GetClonesArrayType() const {return fClonesArrayType ;} 
+    
+  void AddNeutralParticlesArray(TArrayI & array)  
+  { fNeutralParticlesArray   = new TArrayI(array) ; }
+  TArrayI * GetNeutralParticlesArray() const   {return  fNeutralParticlesArray;}
+  Bool_t SkipNeutralParticles(Int_t pdg) const ;
+  
+  void AddChargedParticlesArray(TArrayI & array)  
+  { fChargedParticlesArray   = new TArrayI(array) ; }
+  TArrayI * GetChargedParticlesArray() const   {return  fChargedParticlesArray;}
+  Bool_t KeepChargedParticles(Int_t pdg) const ;
+
+  void AddStatusArray(TArrayI & array)  
+  { fStatusArray   = new TArrayI(array) ; }
+  TArrayI * GetStatusArray() const   {return  fStatusArray;}
+  
+  void SwitchOnStatusSelection()  {fKeepAllStatus = kFALSE;}
+  void SwitchOffStatusSelection() {fKeepAllStatus = kTRUE;}
+  Bool_t KeepParticleWithStatus(Int_t status) const ;
+  
+  void GetVertex(Double_t v[3]) const ;
+
+  void FillInputEvent() ;
+  AliVEvent*  GetInputEvent() const {return GetMC();}
+  void SetInputEvent(TObject* esd, TObject* aod, TObject* mc) ;
+  
+  void SetCaloClusterPID(const Int_t pdgCode, AliAODCaloCluster *calo) const ;
+  void SetTrackChargeAndPID(const Int_t pdgCode, AliAODTrack *track) const ;
+  
+ private:
+  
+  void MakePi0Decay(TLorentzVector &p0, TLorentzVector &p1, TLorentzVector &p2) const ;//, Double_t &angle); 
+  void FillCalorimeters(const Int_t iParticle, TParticle* particle, TLorentzVector momentum,   
+                       Int_t &indexPHOS, Int_t &indexEMCAL) ;
+  
+  private:
+  Bool_t      fDecayPi0; //If not decayed, decay pi0 by hand
+  TArrayI * fNeutralParticlesArray ; //Do not keep neutral particles of this list in calorimeter.
+  TArrayI * fChargedParticlesArray ; //Keep charged particles of this list in calorimeter.
+  TArrayI * fStatusArray ; //Keep particles with status of the list.
+  Bool_t fKeepAllStatus ; //Do or do not select particles depending on their status code.
+  Int_t fClonesArrayType; //Analysis with TParticles or AliAODCaloCluster/Track?
+  
+  ClassDef(AliCaloTrackMCReader,1)
+    } ;
+
+
+#endif //ALICALOTRACKMCREADER_H
+
+
+
diff --git a/PWG4/PartCorrBase/AliCaloTrackReader.cxx b/PWG4/PartCorrBase/AliCaloTrackReader.cxx
new file mode 100755 (executable)
index 0000000..1e85be8
--- /dev/null
@@ -0,0 +1,246 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Base class for reading data: MonteCarlo, ESD or AOD, of PHOS EMCAL and 
+// Central Barrel Tracking detectors (CTS).
+// Not all MC particles/tracks/clusters are kept, some kinematical/fidutial restrictions are done.
+// Mother class of : AliCaloTrackESDReader: Fills ESD data in 3 TClonesArrays (PHOS, EMCAL, CTS)
+//                 : AliCaloTrackMCReader: Fills Kinematics data in 3 TClonesArrays (PHOS, EMCAL, CTS)
+//                 : AliCaloTrackAODReader: Fills AOD data in 3 TClonesArrays (PHOS, EMCAL, CTS) 
+//                
+//-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+#include <TMath.h>
+#include <TLorentzVector.h>
+#include <TString.h>
+
+//---- ANALYSIS system ----
+#include "AliCaloTrackReader.h"
+#include "AliLog.h"
+#include "AliStack.h"  
+#include "AliHeader.h"  
+#include "AliGenEventHeader.h"  
+
+ClassImp(AliCaloTrackReader)
+  
+  
+//____________________________________________________________________________
+  AliCaloTrackReader::AliCaloTrackReader() : 
+    TObject(), fDataType(0), fDebug(0), fFidutialCut(0x0),
+    fCTSPtMin(0), fEMCALPtMin(0),fPHOSPtMin(0),
+    fAODCTS(0x0), fAODEMCAL(0x0), fAODPHOS(0x0),
+    fEMCALCells(0x0), fPHOSCells(0x0),
+    fESD(0x0), fAOD(0x0),fMC(0x0),
+    fFillCTS(0),fFillEMCAL(0),fFillPHOS(0),
+    fFillEMCALCells(0),fFillPHOSCells(0)
+{
+  //Ctor
+  
+  //Initialize parameters
+  InitParameters();
+}
+
+//____________________________________________________________________________
+AliCaloTrackReader::AliCaloTrackReader(const AliCaloTrackReader & g) :   
+  TObject(g), fDataType(g.fDataType), fDebug(g.fDebug),fFidutialCut(g.fFidutialCut),
+  fCTSPtMin(g.fCTSPtMin), fEMCALPtMin(g.fEMCALPtMin),fPHOSPtMin(g.fPHOSPtMin), 
+  fAODCTS(new TClonesArray(*g.fAODCTS)),  
+  fAODEMCAL(new TClonesArray(*g.fAODEMCAL)),
+  fAODPHOS(new TClonesArray(*g.fAODPHOS)),
+  fEMCALCells(new TNamed(*g.fEMCALCells)),
+  fPHOSCells(new TNamed(*g.fPHOSCells)),
+  fESD(g.fESD), fAOD(g.fAOD), fMC(g.fMC),
+  fFillCTS(g.fFillCTS),fFillEMCAL(g.fFillEMCAL),fFillPHOS(g.fFillPHOS),
+  fFillEMCALCells(g.fFillEMCALCells),fFillPHOSCells(g.fFillPHOSCells)
+{
+  // cpy ctor
+  
+}
+
+//_________________________________________________________________________
+AliCaloTrackReader & AliCaloTrackReader::operator = (const AliCaloTrackReader & source)
+{
+  // assignment operator
+  
+  if(&source == this) return *this;
+  
+  fDataType = source.fDataType ;
+  fDebug = source.fDebug ;
+  
+  fFidutialCut = source.fFidutialCut;
+  
+  fCTSPtMin = source.fCTSPtMin ;
+  fEMCALPtMin = source.fEMCALPtMin ;
+  fPHOSPtMin = source.fPHOSPtMin ; 
+  
+  fAODCTS = new TClonesArray(*source.fAODCTS) ;
+  fAODEMCAL = new TClonesArray(*source.fAODEMCAL) ;
+  fAODPHOS = new TClonesArray(*source.fAODPHOS) ;
+  fEMCALCells = new TNamed(*source.fEMCALCells) ;
+  fPHOSCells = new TNamed(*source.fPHOSCells) ;
+
+  fESD = source.fESD;
+  fAOD= source.fAOD;
+  fMC = source.fMC;
+  
+  fFillCTS = source.fFillCTS;
+  fFillEMCAL = source.fFillEMCAL;
+  fFillPHOS = source.fFillPHOS;
+  fFillEMCALCells = source.fFillEMCALCells;
+  fFillPHOSCells = source.fFillPHOSCells;
+
+  return *this;
+  
+}
+
+//_________________________________
+AliCaloTrackReader::~AliCaloTrackReader() {
+  //Dtor
+  
+  if(fFidutialCut) delete fFidutialCut ;
+  
+  if(fAODCTS){
+    fAODCTS->Clear() ; 
+    delete fAODCTS ;
+  }
+  
+  if(fAODEMCAL){
+    fAODEMCAL->Clear() ; 
+    delete fAODEMCAL ;
+  }
+  
+  if(fAODPHOS){
+    fAODPHOS->Clear() ; 
+    delete fAODPHOS ;
+  }
+  
+  if(fEMCALCells){
+    fEMCALCells->Clear() ; 
+    delete fEMCALCells ;
+  }
+  
+  if(fPHOSCells){
+    fPHOSCells->Clear() ; 
+    delete fPHOSCells ;
+  }
+
+  if(fESD) delete fESD ;
+  if(fAOD) delete fAOD ;
+  if(fMC) delete fMC ;
+}
+
+//____________________________________________________________________________
+AliStack* AliCaloTrackReader::GetStack() const {
+  //Return pointer to stack
+  if(fMC)
+    return fMC->Stack();
+  else{
+    printf("stack is not available"); 
+    return 0x0 ;
+  }
+}
+
+//____________________________________________________________________________
+AliHeader* AliCaloTrackReader::GetHeader() const {
+  //Return pointer to header
+  if(fMC)
+    return fMC->Header();
+  else{
+    printf("header is not available"); 
+    return 0x0 ;
+  }
+}
+//____________________________________________________________________________
+AliGenEventHeader* AliCaloTrackReader::GetGenEventHeader() const {
+  //Return pointer to Generated event header
+  if(fMC)
+    return fMC->GenEventHeader();
+  else{
+    printf("GenEventHeader is not available"); 
+    return 0x0 ;
+  }
+}
+
+//_______________________________________________________________
+void AliCaloTrackReader::InitParameters()
+{
+  //Initialize the parameters of the analysis.
+  fDataType = kESD ;
+
+  fCTSPtMin   = 0.2 ;
+  fEMCALPtMin   = 0.5 ;
+  fPHOSPtMin   = 0.5 ;
+
+  fFillEMCAL = kTRUE;
+  fFillPHOS = kTRUE;
+  fFillCTS = kTRUE;
+  fFillEMCALCells = kFALSE;
+  fFillPHOSCells = kFALSE;
+
+  fFidutialCut = new AliFidutialCut();
+
+}
+
+
+//________________________________________________________________
+void AliCaloTrackReader::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("Data type      : %d\n", fDataType) ;
+  printf("CTS Min pT     : %2.1f GeV/c\n", fCTSPtMin) ;
+  printf("EMCAL Min pT   : %2.1f GeV/c\n", fEMCALPtMin) ;
+  printf("PHOS Min pT    : %2.1f GeV/c\n", fPHOSPtMin) ;
+  printf("Use CTS         =     %d\n", fFillCTS) ;
+  printf("Use EMCAL       =     %d\n", fFillEMCAL) ;
+  printf("Use PHOS        =     %d\n", fFillPHOS) ;
+  printf("Use EMCAL Cells =     %d\n", fFillEMCALCells) ;
+  printf("Use PHOS  Cells =     %d\n", fFillPHOSCells) ;
+  printf("    \n") ;
+} 
+
+//___________________________________________________
+void AliCaloTrackReader::FillInputEvent() {
+  //Fill the input lists that are needed, called by the analysis maker.
+
+  if(fFillCTS) FillInputCTS();
+  if(fFillEMCAL) FillInputEMCAL();
+  if(fFillPHOS) FillInputPHOS();
+  if(fFillEMCALCells) FillInputEMCALCells();
+  if(fFillPHOSCells) FillInputPHOSCells();
+
+}
+
+//__________________________________________________
+void AliCaloTrackReader::ResetLists() {
+  //  Reset lists, called by the analysis maker 
+
+  if(fAODCTS) fAODCTS -> Clear();
+  if(fAODEMCAL) fAODEMCAL -> Clear();
+  if(fAODPHOS) fAODPHOS -> Clear();
+  if(fEMCALCells) fEMCALCells -> Clear();
+  if(fPHOSCells) fPHOSCells -> Clear();
+
+}
diff --git a/PWG4/PartCorrBase/AliCaloTrackReader.h b/PWG4/PartCorrBase/AliCaloTrackReader.h
new file mode 100755 (executable)
index 0000000..7d38375
--- /dev/null
@@ -0,0 +1,151 @@
+#ifndef ALICALOTRACKREADER_H
+#define ALICALOTRACKREADER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Base class for reading data: MonteCarlo, ESD or AOD, of PHOS EMCAL and 
+// Central Barrel Tracking detectors.
+// Not all MC particles/tracks/clusters are kept, some kinematical restrictions are done.
+// Mother class of : AliCaloTrackESDReader: Fills ESD data in 3 TClonesArrays (PHOS, EMCAL, CTS)
+//                 : AliCaloTrackMCReader: Fills Kinematics data in 3 TClonesArrays (PHOS, EMCAL, CTS)
+//                 : AliCaloTrackAODReader: Fills AOD data in 3 TClonesArrays (PHOS, EMCAL, CTS) 
+//                          
+// -- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+#include "TObject.h" 
+class TClonesArray ; 
+class TLorentzVector ;
+class TString ;
+#include "TArrayF.h"  
+
+//--- ANALYSIS system ---
+class AliStack ; 
+class AliHeader ; 
+class AliGenEventHeader ; 
+#include "AliESDEvent.h" 
+#include "AliAODEvent.h" 
+#include "AliMCEvent.h" 
+class AliLog ;
+#include "AliFidutialCut.h"
+
+class AliCaloTrackReader : public TObject {
+
+public: 
+
+  AliCaloTrackReader() ; // ctor
+  AliCaloTrackReader(const AliCaloTrackReader & g) ; // cpy ctor
+  AliCaloTrackReader & operator = (const AliCaloTrackReader & g) ;//cpy assignment
+  virtual ~AliCaloTrackReader() ;//virtual dtor
+
+  enum inputDataType {kESD, kAOD, kMC};
+  
+  virtual void InitParameters();
+  virtual void Print(const Option_t * opt) const;
+
+  virtual Int_t GetDebug()         const { return fDebug ; }
+  virtual void  SetDebug(Int_t d)        { fDebug = d ; }
+  virtual Int_t GetDataType()      const { return fDataType ; }
+  virtual void  SetDataType(Int_t data ) { fDataType = data ; }
+
+
+  //Minimum pt setters and getters 
+  virtual Float_t  GetEMCALPtMin() const { return fEMCALPtMin  ; }
+  virtual Float_t  GetPHOSPtMin()  const { return fPHOSPtMin  ; }
+  virtual Float_t  GetCTSPtMin()   const { return fCTSPtMin  ; }
+
+  virtual void SetEMCALPtMin(Float_t  pt) { fEMCALPtMin = pt ; }
+  virtual void SetPHOSPtMin(Float_t  pt)  { fPHOSPtMin = pt ; }
+  virtual void SetCTSPtMin(Float_t  pt)   { fCTSPtMin = pt ; }
+  
+  //Input setters and getters
+
+  Bool_t IsCTSSwitchedOn()  const { return fFillCTS ; }
+  void SwitchOnCTS()    {fFillCTS = kTRUE ; }
+  void SwitchOffCTS()   {fFillCTS = kFALSE ; }
+
+  Bool_t IsEMCALSwitchedOn() const { return fFillEMCAL ; }
+  void SwitchOnEMCAL()  {fFillEMCAL = kTRUE ; }
+  void SwitchOffEMCAL() {fFillEMCAL = kFALSE ; }
+
+  Bool_t IsPHOSSwitchedOn()  const { return fFillPHOS ; }
+  void SwitchOnPHOS()   {fFillPHOS = kTRUE ; }
+  void SwitchOffPHOS()  {fFillPHOS = kFALSE ; }
+
+  Bool_t IsEMCALCellsSwitchedOn() const { return fFillEMCALCells ; }
+  void SwitchOnEMCALCells()  {fFillEMCALCells = kTRUE ; }
+  void SwitchOffEMCALCells() {fFillEMCALCells = kFALSE ; }
+
+  Bool_t IsPHOSCellsSwitchedOn()  const { return fFillPHOSCells ; }
+  void SwitchOnPHOSCells()   {fFillPHOSCells = kTRUE ; }
+  void SwitchOffPHOSCells()  {fFillPHOSCells = kFALSE ; }
+
+  virtual void FillInputEvent()  ;
+  virtual void FillInputCTS()   {;}
+  virtual void FillInputEMCAL() {;}
+  virtual void FillInputPHOS()  {;}
+  virtual void FillInputEMCALCells() {;}
+  virtual void FillInputPHOSCells()  {;}
+
+  virtual TClonesArray* GetAODCTS()   const {return fAODCTS ;}
+  virtual TClonesArray* GetAODEMCAL() const {return fAODEMCAL ;}
+  virtual TClonesArray* GetAODPHOS()  const {return fAODPHOS ;}
+  virtual TNamed* GetEMCALCells()     const {return fEMCALCells ;}
+  virtual TNamed* GetPHOSCells()      const {return fPHOSCells ;}
+
+  virtual AliStack*          GetStack()  const ;
+  virtual AliHeader*         GetHeader() const ;
+  virtual AliGenEventHeader* GetGenEventHeader() const ;
+  virtual AliESDEvent* GetESD() const {return fESD;}
+  virtual AliAODEvent* GetAOD() const {return fAOD;}
+  virtual AliMCEvent*  GetMC()  const {return fMC;}
+  virtual AliVEvent*   GetInputEvent()        const {return (new AliESDEvent());}
+  virtual void         GetVertex(Double_t * ) const {;}
+
+  virtual void SetESD( AliESDEvent* esd) {fESD = esd;}
+  virtual void SetAOD(AliAODEvent* aod)  {fAOD = aod;}
+  virtual void SetMC(AliMCEvent* mc)     {fMC  = mc;}
+
+  virtual void ResetLists();
+
+  virtual AliFidutialCut * GetFidutialCut() const {return  fFidutialCut ;}
+  virtual void SetFidutialCut(AliFidutialCut * fc) { fFidutialCut = fc ;}
+
+  virtual void SetInputEvent(TObject* /*esd*/, TObject* /*aod*/, TObject* /*mc*/) {;}
+
+ protected:
+  
+  Int_t            fDataType ;   // Select MC:Kinematics, Data:ESD/AOD, MCData:Both
+  Int_t            fDebug;       // Debugging level
+  AliFidutialCut * fFidutialCut; // Acceptance cuts
+
+  Float_t        fCTSPtMin;      // pT  Threshold on charged particles 
+  Float_t        fEMCALPtMin;    // pT Threshold on emcal clusters
+  Float_t        fPHOSPtMin;     // pT  Threshold on phos clusters
+
+  TClonesArray * fAODCTS ;        //! temporal array with tracks
+  TClonesArray * fAODEMCAL ;      //! temporal array with EMCAL CaloClusters
+  TClonesArray * fAODPHOS ;       //! temporal array with PHOS CaloClusters
+  TNamed *       fEMCALCells ;    //! temporal array with EMCAL CaloCells, ESD or AOD
+  TNamed *       fPHOSCells ;     //! temporal array with PHOS CaloCells, ESD or AOD
+
+  AliESDEvent *  fESD;            //! pointer to esd
+  AliAODEvent *  fAOD;            //! pointer to aod
+  AliMCEvent  *  fMC;             //! Monte Carlo Event Handler  
+
+  Bool_t         fFillCTS;        // use data from CTS
+  Bool_t         fFillEMCAL;      // use data from EMCAL
+  Bool_t         fFillPHOS;       // use data from PHOS
+  Bool_t         fFillEMCALCells; // use data from EMCAL
+  Bool_t         fFillPHOSCells;  // use data from PHOS
+
+  ClassDef(AliCaloTrackReader,1)
+} ;
+
+
+#endif //ALICALOTRACKREADER_H
+
+
+
diff --git a/PWG4/PartCorrBase/AliFidutialCut.cxx b/PWG4/PartCorrBase/AliFidutialCut.cxx
new file mode 100755 (executable)
index 0000000..b6f73a9
--- /dev/null
@@ -0,0 +1,353 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: AliFidutialCut.cxx 21839 2007-10-29 13:49:42Z gustavo $ */
+
+//_________________________________________________________________________
+// Class for track/cluster acceptance selection
+// Selection in Central barrel, EMCAL and PHOS
+//                
+//*-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+#include <TMath.h>
+#include <TLorentzVector.h>
+#include <TString.h>
+//#include <TArrayF.h>
+  
+//---- ANALYSIS system ----
+#include "AliLog.h"
+#include "AliFidutialCut.h"
+
+ClassImp(AliFidutialCut)
+
+
+//____________________________________________________________________________
+AliFidutialCut::AliFidutialCut() : 
+  TObject(),
+  fEMCALFidutialCut(0),  fPHOSFidutialCut(0),  fCTSFidutialCut(0),
+  fCTSFidCutMinEta(0x0),fCTSFidCutMinPhi(0x0),fCTSFidCutMaxEta(0x0), fCTSFidCutMaxPhi(0x0),
+  fEMCALFidCutMinEta(0x0),fEMCALFidCutMinPhi(0x0),fEMCALFidCutMaxEta(0x0), fEMCALFidCutMaxPhi(0x0),
+  fPHOSFidCutMinEta(0x0),fPHOSFidCutMinPhi(0x0),fPHOSFidCutMaxEta(0x0), fPHOSFidCutMaxPhi(0x0)
+
+{
+  //Ctor
+
+  //Initialize parameters
+  InitParameters();
+}
+
+//____________________________________________________________________________
+AliFidutialCut::AliFidutialCut(const AliFidutialCut & g) :   
+  TObject(g), 
+  fEMCALFidutialCut(g.fEMCALFidutialCut),  fPHOSFidutialCut(g.fPHOSFidutialCut),  fCTSFidutialCut(g. fCTSFidutialCut),
+  fCTSFidCutMinEta(g.fCTSFidCutMinEta?new TArrayF(*g.fCTSFidCutMinEta):0x0),
+  fCTSFidCutMinPhi(g.fCTSFidCutMinPhi?new TArrayF(*g.fCTSFidCutMinPhi):0x0),
+  fCTSFidCutMaxEta(g.fCTSFidCutMaxEta?new TArrayF(*g.fCTSFidCutMaxEta):0x0),
+  fCTSFidCutMaxPhi(g.fCTSFidCutMaxPhi?new TArrayF(*g.fCTSFidCutMaxPhi):0x0),
+  fEMCALFidCutMinEta(g.fEMCALFidCutMinEta?new TArrayF(*g.fEMCALFidCutMinEta):0x0),
+  fEMCALFidCutMinPhi(g.fEMCALFidCutMinPhi?new TArrayF(*g.fEMCALFidCutMinPhi):0x0),
+  fEMCALFidCutMaxEta(g.fEMCALFidCutMaxEta?new TArrayF(*g.fEMCALFidCutMaxEta):0x0),
+  fEMCALFidCutMaxPhi(g.fEMCALFidCutMaxPhi?new TArrayF(*g.fEMCALFidCutMaxPhi):0x0),
+  fPHOSFidCutMinEta(g.fPHOSFidCutMinEta?new TArrayF(*g.fPHOSFidCutMinEta):0x0),
+  fPHOSFidCutMinPhi(g.fPHOSFidCutMinPhi?new TArrayF(*g.fPHOSFidCutMinPhi):0x0),
+  fPHOSFidCutMaxEta(g.fPHOSFidCutMaxEta?new TArrayF(*g.fPHOSFidCutMaxEta):0x0),
+  fPHOSFidCutMaxPhi(g.fPHOSFidCutMaxPhi?new TArrayF(*g.fPHOSFidCutMaxPhi):0x0)
+
+{
+  // cpy ctor
+
+}
+
+//_________________________________________________________________________
+AliFidutialCut & AliFidutialCut::operator = (const AliFidutialCut & source)
+{
+  // assignment operator
+  
+  if(&source == this) return *this;
+  
+  fEMCALFidutialCut = source.fEMCALFidutialCut;  
+  fPHOSFidutialCut = source.fPHOSFidutialCut;
+  fCTSFidutialCut = source.fCTSFidutialCut;
+  
+  fCTSFidCutMinEta = source.fCTSFidCutMinEta?new TArrayF(*source.fCTSFidCutMinEta):0x0;
+  fCTSFidCutMinPhi = source.fCTSFidCutMinPhi?new TArrayF(*source.fCTSFidCutMinPhi):0x0;
+  fCTSFidCutMaxEta = source.fCTSFidCutMaxEta?new TArrayF(*source.fCTSFidCutMaxEta):0x0;
+  fCTSFidCutMaxPhi = source.fCTSFidCutMaxPhi?new TArrayF(*source.fCTSFidCutMaxPhi):0x0;
+  fEMCALFidCutMinEta = source.fEMCALFidCutMinEta?new TArrayF(*source.fEMCALFidCutMinEta):0x0;
+  fEMCALFidCutMinPhi = source.fEMCALFidCutMinPhi?new TArrayF(*source.fEMCALFidCutMinPhi):0x0;
+  fEMCALFidCutMaxEta = source.fEMCALFidCutMaxEta?new TArrayF(*source.fEMCALFidCutMaxEta):0x0;
+  fEMCALFidCutMaxPhi = source.fEMCALFidCutMaxPhi?new TArrayF(*source.fEMCALFidCutMaxPhi):0x0;
+  fPHOSFidCutMinEta = source.fPHOSFidCutMinEta?new TArrayF(*source.fPHOSFidCutMinEta):0x0;
+  fPHOSFidCutMinPhi = source.fPHOSFidCutMinPhi?new TArrayF(*source.fPHOSFidCutMinPhi):0x0;
+  fPHOSFidCutMaxEta = source.fPHOSFidCutMaxEta?new TArrayF(*source.fPHOSFidCutMaxEta):0x0;
+  fPHOSFidCutMaxPhi = source.fPHOSFidCutMaxPhi?new TArrayF(*source.fPHOSFidCutMaxPhi):0x0;
+
+  return *this;
+
+}
+
+//_________________________________
+AliFidutialCut::~AliFidutialCut() {
+  //Dtor
+
+  delete fCTSFidCutMinEta ;
+  delete fCTSFidCutMinPhi ;
+  delete fCTSFidCutMaxEta ;
+  delete fCTSFidCutMaxPhi ;
+  
+  delete fEMCALFidCutMinEta ;
+  delete fEMCALFidCutMinPhi ;
+  delete fEMCALFidCutMaxEta ; 
+  delete fEMCALFidCutMaxPhi ;
+  
+  delete fPHOSFidCutMinEta ; 
+  delete fPHOSFidCutMinPhi ; 
+  delete fPHOSFidCutMaxEta ;
+  delete fPHOSFidCutMaxPhi ;
+
+}
+
+
+//_______________________________________________________________
+Bool_t AliFidutialCut::IsInFidutialCut(TLorentzVector momentum, TString det) const
+{
+  //Selects EMCAL or PHOS cluster or CTS track if it is inside eta-phi defined regions
+
+  Double_t phi = momentum.Phi();
+  if(phi<0) phi+=TMath::TwoPi() ;
+  Double_t eta =  momentum.Eta();
+  //printf("IsInFidutialCut::Det: %s, phi = %f, eta = %f\n", det.Data(),phi*TMath::RadToDeg(), eta);
+
+  Float_t * maxeta = new Float_t;
+  Float_t * maxphi = new Float_t;
+  Float_t * mineta = new Float_t;
+  Float_t * minphi = new Float_t;
+  Int_t nphiregions = 0;
+  Int_t netaregions = 0;
+  Bool_t selection = kFALSE;
+
+  if(det == "CTS"){
+    netaregions =  fCTSFidCutMaxEta->GetSize();
+    nphiregions =  fCTSFidCutMaxPhi->GetSize();
+    if(netaregions !=  fCTSFidCutMinEta->GetSize() || nphiregions !=  fCTSFidCutMinPhi->GetSize())
+      AliFatal(Form("Wrong number of CTS fidutial cut regions: nmaxeta %d != nmineta %d; nmaxphi %d != nminphi %d",
+                   netaregions, fCTSFidCutMinEta->GetSize(),  nphiregions, fCTSFidCutMinPhi->GetSize()));
+    
+    maxeta = fCTSFidCutMaxEta->GetArray();
+    maxphi = fCTSFidCutMaxPhi->GetArray();
+    mineta = fCTSFidCutMinEta->GetArray();
+    minphi = fCTSFidCutMinPhi->GetArray();
+    selection =  fCTSFidutialCut ; 
+  }
+  else   if(det == "EMCAL"){
+    netaregions =  fEMCALFidCutMaxEta->GetSize();
+    nphiregions =  fEMCALFidCutMaxPhi->GetSize();
+    if(netaregions !=  fEMCALFidCutMinEta->GetSize() || nphiregions !=  fEMCALFidCutMinPhi->GetSize())
+      AliFatal(Form("Wrong number of EMCAL fidutial cut regions: nmaxeta %d != nmineta %d; nmaxphi %d != nminphi %d",
+                   netaregions, fEMCALFidCutMinEta->GetSize(),  nphiregions, fEMCALFidCutMinPhi->GetSize()));
+    
+    maxeta = fEMCALFidCutMaxEta->GetArray();
+    maxphi = fEMCALFidCutMaxPhi->GetArray();
+    mineta = fEMCALFidCutMinEta->GetArray();
+    minphi = fEMCALFidCutMinPhi->GetArray();
+    selection =  fEMCALFidutialCut ; 
+  }
+  else   if(det == "PHOS"){
+    netaregions =  fPHOSFidCutMaxEta->GetSize();
+    nphiregions =  fPHOSFidCutMaxPhi->GetSize();
+    if(netaregions !=  fPHOSFidCutMinEta->GetSize() || nphiregions !=  fPHOSFidCutMinPhi->GetSize())
+      AliFatal(Form("Wrong number of PHOS fidutial cut regions: nmaxeta %d != nmineta %d; nmaxphi %d != nminphi %d",
+                   netaregions, fPHOSFidCutMinEta->GetSize(),  nphiregions, fPHOSFidCutMinPhi->GetSize()));
+    
+    maxeta = fPHOSFidCutMaxEta->GetArray();
+    maxphi = fPHOSFidCutMaxPhi->GetArray();
+    mineta = fPHOSFidCutMinEta->GetArray();
+    minphi = fPHOSFidCutMinPhi->GetArray();
+    selection =  fPHOSFidutialCut ; 
+  }
+  else
+    AliFatal(Form("Wrong detector name = %s", det.Data()));
+
+  //printf("IsInFidutialCut::nphiregions = %d, netaregions = %d\n",nphiregions, netaregions);
+
+  if(!selection) return kTRUE; //No cuts applied, all tracks/clusters used
+
+  //Eta fidutial cut
+  Bool_t bInEtaFidCut = kFALSE;
+  for(Int_t ieta = 0; ieta < netaregions; ieta++)
+    if(eta > mineta[ieta] && eta < maxeta[ieta]) bInEtaFidCut = kTRUE;
+
+  if(bInEtaFidCut){
+    //printf("Eta cut passed\n");
+    //Phi fidutial cut
+    Bool_t bInPhiFidCut = kFALSE;
+    for(Int_t iphi = 0; iphi < nphiregions; iphi++)
+      if(phi > minphi[iphi] *TMath::DegToRad()&& phi < maxphi[iphi]*TMath::DegToRad()) bInPhiFidCut = kTRUE ;
+    
+    if(bInPhiFidCut) {
+      //printf("IsInFidutialCut:: %s cluster/track accepted\n",det.Data());
+      return kTRUE;
+    }
+    else return kFALSE;
+    
+  }//In eta fid cut
+  else
+    return kFALSE;
+  
+}
+
+
+//_______________________________________________________________
+void AliFidutialCut::InitParameters()
+{
+  //Initialize the parameters of the analysis.
+
+  fEMCALFidutialCut = kTRUE ;  
+  fPHOSFidutialCut = kTRUE ;
+  fCTSFidutialCut = kTRUE ;
+
+  fCTSFidCutMinEta = new TArrayF(1);
+  fCTSFidCutMinEta->SetAt(-0.9,0); 
+  fCTSFidCutMaxEta = new TArrayF(1);
+  fCTSFidCutMaxEta->SetAt(0.9,0); 
+
+  fCTSFidCutMinPhi = new TArrayF(1);
+  fCTSFidCutMinPhi->SetAt(0,0); 
+  fCTSFidCutMaxPhi = new TArrayF(1);
+  fCTSFidCutMaxPhi->SetAt(360.,0); 
+
+  fEMCALFidCutMinEta = new TArrayF(1);
+  fEMCALFidCutMinEta->SetAt(-0.7,0); 
+  fEMCALFidCutMaxEta = new TArrayF(1);
+  fEMCALFidCutMaxEta->SetAt(0.7,0); 
+
+  fEMCALFidCutMinPhi = new TArrayF(1);
+  fEMCALFidCutMinPhi->SetAt(80.,0); 
+  fEMCALFidCutMaxPhi = new TArrayF(1);
+  fEMCALFidCutMaxPhi->SetAt(190.,0); 
+
+  fPHOSFidCutMinEta = new TArrayF(1);
+  fPHOSFidCutMinEta->SetAt(-0.13,0); 
+  fPHOSFidCutMaxEta = new TArrayF(1);
+  fPHOSFidCutMaxEta->SetAt(0.13,0); 
+
+  fPHOSFidCutMinPhi = new TArrayF(1);
+  fPHOSFidCutMinPhi->SetAt(220.,0); 
+  fPHOSFidCutMaxPhi = new TArrayF(1);
+  fPHOSFidCutMaxPhi->SetAt(320.,0); 
+
+}
+
+
+//________________________________________________________________
+void AliFidutialCut::Print(const Option_t * opt) const
+{
+
+  //Print some relevant parameters set for the analysis
+  if(! opt)
+    return;
+
+  printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
+
+  if(fCTSFidutialCut){
+    Int_t netaregions =  fCTSFidCutMaxEta->GetSize();
+    Int_t nphiregions =  fCTSFidCutMaxPhi->GetSize();
+    printf(">> CTS Fidutial regions : phi %d eta %d\n", netaregions, nphiregions) ;
+    for(Int_t ieta = 0; ieta < netaregions; ieta++)
+      printf(" region %d : %3.2f < eta < %3.2f\n", ieta, fCTSFidCutMinEta->GetAt(ieta), fCTSFidCutMaxEta->GetAt(ieta)) ;
+    for(Int_t iphi = 0; iphi < nphiregions; iphi++)
+      printf(" region %d : %3.1f < phi < %3.1f\n", iphi, fCTSFidCutMinPhi->GetAt(iphi), fCTSFidCutMaxPhi->GetAt(iphi)) ; 
+  }
+  else printf(">>No fidutial cuts in CTS\n");
+
+  if(fEMCALFidutialCut){
+    Int_t netaregions =  fEMCALFidCutMaxEta->GetSize();
+    Int_t nphiregions =  fEMCALFidCutMaxPhi->GetSize();
+    printf(">>EMCAL Fidutial regions : phi %d eta %d\n", netaregions, nphiregions) ;
+    for(Int_t ieta = 0; ieta < netaregions; ieta++)
+      printf(" region %d : %3.2f < eta < %3.2f\n", ieta, fEMCALFidCutMinEta->GetAt(ieta), fEMCALFidCutMaxEta->GetAt(ieta)) ;
+    for(Int_t iphi = 0; iphi < nphiregions; iphi++)
+      printf(" region %d : %3.1f < phi < %3.1f\n", iphi, fEMCALFidCutMinPhi->GetAt(iphi), fEMCALFidCutMaxPhi->GetAt(iphi)) ; 
+  }
+  else printf(">>No fidutial cuts in EMCAL\n");
+
+  if(fPHOSFidutialCut){
+    Int_t netaregions =  fPHOSFidCutMaxEta->GetSize();
+    Int_t nphiregions =  fPHOSFidCutMaxPhi->GetSize();
+    printf(">>PHOS Fidutial regions : phi %d eta %d\n", netaregions, nphiregions) ;
+    for(Int_t ieta = 0; ieta < netaregions; ieta++)
+      printf(" region %d : %3.2f < eta < %3.2f\n", ieta, fPHOSFidCutMinEta->GetAt(ieta), fPHOSFidCutMaxEta->GetAt(ieta)) ;
+    for(Int_t iphi = 0; iphi < nphiregions; iphi++)
+      printf(" region %d : %3.1f < phi < %3.1f\n", iphi, fPHOSFidCutMinPhi->GetAt(iphi), fPHOSFidCutMaxPhi->GetAt(iphi)) ; 
+  }
+  else printf(">>No fidutial cuts in PHOS\n");
+  printf("    \n") ;
+} 
+
+
+//_______________________________________________________________
+void AliFidutialCut::SetSimpleCTSFidutialCut(const Float_t eta, const Float_t minphi, const Float_t maxphi){
+
+  //Method to set simple acceptance cut to CTS
+  fCTSFidCutMinEta->Set(1);
+  fCTSFidCutMaxEta->Set(1);
+  fCTSFidCutMinPhi->Set(1);
+  fCTSFidCutMaxPhi->Set(1);
+
+  fCTSFidCutMinEta->SetAt(-eta,0);
+  fCTSFidCutMaxEta->SetAt(eta,0);
+  fCTSFidCutMinPhi->SetAt(minphi,0);
+  fCTSFidCutMaxPhi->SetAt(maxphi,0);
+
+
+}
+
+
+//_______________________________________________________________
+void AliFidutialCut::SetSimpleEMCALFidutialCut(const Float_t eta, const Float_t minphi, const Float_t maxphi){
+  //Method to set simple acceptance cut to EMCAL
+
+  fEMCALFidCutMinEta->Set(1);
+  fEMCALFidCutMaxEta->Set(1);
+  fEMCALFidCutMinPhi->Set(1);
+  fEMCALFidCutMaxPhi->Set(1);
+
+  fEMCALFidCutMinEta->SetAt(-eta,0);
+  fEMCALFidCutMaxEta->SetAt(eta,0);
+  fEMCALFidCutMinPhi->SetAt(minphi,0);
+  fEMCALFidCutMaxPhi->SetAt(maxphi,0);
+
+
+}
+
+//_______________________________________________________________
+void AliFidutialCut::SetSimplePHOSFidutialCut(const Float_t eta, const Float_t minphi, const Float_t maxphi){
+
+  //Method to set simple acceptance cut to PHOS
+  fPHOSFidCutMinEta->Set(1);
+  fPHOSFidCutMaxEta->Set(1);
+  fPHOSFidCutMinPhi->Set(1);
+  fPHOSFidCutMaxPhi->Set(1);
+
+  fPHOSFidCutMinEta->SetAt(-eta,0);
+  fPHOSFidCutMaxEta->SetAt(eta,0);
+  fPHOSFidCutMinPhi->SetAt(minphi,0);
+  fPHOSFidCutMaxPhi->SetAt(maxphi,0);
+
+
+}
diff --git a/PWG4/PartCorrBase/AliFidutialCut.h b/PWG4/PartCorrBase/AliFidutialCut.h
new file mode 100755 (executable)
index 0000000..881c524
--- /dev/null
@@ -0,0 +1,131 @@
+#ifndef ALIFIDUTIALCUT_H
+#define ALIFIDUTIALCUT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Class for track/cluster acceptance selection
+// Selection in Central barrel, EMCAL and PHOS
+//
+//*-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+#include <TObject.h> 
+#include <TArrayF.h> 
+
+class TString ;
+class TLorentzVector ;
+
+//--- AliRoot system ---
+
+class AliLog ;
+
+class AliFidutialCut : public TObject {
+
+public: 
+
+  AliFidutialCut() ; // ctor
+  AliFidutialCut(const AliFidutialCut & g) ; // cpy ctor
+  AliFidutialCut & operator = (const AliFidutialCut & g) ;//cpy assignment
+  virtual ~AliFidutialCut() ;//virtual dtor
+
+  void InitParameters();
+  
+  void Print(const Option_t * opt)const;
+  
+  Bool_t IsInFidutialCut(TLorentzVector l, TString det) const ;
+  
+  void DoCTSFidutialCut(Bool_t b) {fCTSFidutialCut = b; }
+  void DoEMCALFidutialCut(Bool_t b) {fEMCALFidutialCut = b; }
+  void DoPHOSFidutialCut(Bool_t b) {fPHOSFidutialCut = b; }
+
+  Bool_t GetCTSFidutialCutStatus() const {return fCTSFidutialCut ; }
+  Bool_t GetEMCALFidutialCut() const {return fEMCALFidutialCut ; }
+  Bool_t GetPHOSFidutialCutStatus() const {return fPHOSFidutialCut ; }
+
+  void SetSimpleCTSFidutialCut(const Float_t abseta, const Float_t phimin, const Float_t phimax) ;
+  void SetSimpleEMCALFidutialCut(const Float_t abseta, const Float_t phimin, const Float_t phimax) ;
+  void SetSimplePHOSFidutialCut(const Float_t abseta, const Float_t phimin, const Float_t phimax) ;
+
+  void AddCTSFidCutMaxEtaArray(TArrayF & array)  
+  {  fCTSFidCutMaxEta  = new TArrayF(array) ; } 
+  TArrayF * GetCTSFidCutMaxEtaArray() const   {return   fCTSFidCutMaxEta;}
+  
+  void AddCTSFidCutMaxPhiArray(TArrayF & array)  
+  {  fCTSFidCutMaxPhi  = new TArrayF(array) ; }
+  TArrayF * GetCTSFidCutMaxPhiArray() const   {return   fCTSFidCutMaxPhi;}
+  
+  void AddCTSFidCutMinEtaArray(TArrayF & array)  
+  {  fCTSFidCutMinEta  = new TArrayF(array) ; } 
+  TArrayF * GetCTSFidCutMinEtaArray() const   {return   fCTSFidCutMinEta;}
+  void AddCTSFidCutMinPhiArray(TArrayF & array)  
+  {  fCTSFidCutMinPhi  = new TArrayF(array) ; }
+  TArrayF * GetCTSFidCutMinPhiArray() const   {return   fCTSFidCutMinPhi;}
+  
+  void AddEMCALFidCutMaxEtaArray(TArrayF & array)  
+  {  fEMCALFidCutMaxEta  = new TArrayF(array) ; } 
+  TArrayF * GetEMCALFidCutMaxEtaArray() const   {return   fEMCALFidCutMaxEta;}
+  
+  void AddEMCALFidCutMaxPhiArray(TArrayF & array)  
+  {  fEMCALFidCutMaxPhi  = new TArrayF(array) ; }
+  TArrayF * GetEMCALFidCutMaxPhiArray() const   {return   fEMCALFidCutMaxPhi;}
+  void AddEMCALFidCutMinEtaArray(TArrayF & array)  
+  {  fEMCALFidCutMinEta  = new TArrayF(array) ; } 
+  TArrayF * GetEMCALFidCutMinEtaArray() const   {return   fEMCALFidCutMinEta;}
+  
+  void AddEMCALFidCutMinPhiArray(TArrayF & array)  
+  {  fEMCALFidCutMinPhi  = new TArrayF(array) ; }
+  TArrayF * GetEMCALFidCutMinPhiArray() const   {return   fEMCALFidCutMinPhi;}
+  
+  void AddPHOSFidCutMaxEtaArray(TArrayF & array)  
+  {  fPHOSFidCutMaxEta  = new TArrayF(array) ; } 
+  TArrayF * GetPHOSFidCutMaxEtaArray() const   {return   fPHOSFidCutMaxEta;}
+  
+   void AddPHOSFidCutMaxPhiArray(TArrayF & array)  
+   {  fPHOSFidCutMaxPhi  = new TArrayF(array) ; }
+   TArrayF * GetPHOSFidCutMaxPhiArray() const   {return   fPHOSFidCutMaxPhi;}
+   
+   void AddPHOSFidCutMinEtaArray(TArrayF & array)  
+   {  fPHOSFidCutMinEta  = new TArrayF(array) ; } 
+   TArrayF * GetPHOSFidCutMinEtaArray() const   {return   fPHOSFidCutMinEta;}
+   void AddPHOSFidCutMinPhiArray(TArrayF & array)  
+   {  fPHOSFidCutMinPhi  = new TArrayF(array) ; }
+   TArrayF * GetPHOSFidCutMinPhiArray() const   {return   fPHOSFidCutMinPhi;}
+   
+   
+ protected:
+   
+   //Detector acceptance cuts
+   Bool_t     fEMCALFidutialCut ; // Apply fidutial cuts to EMCAL clusters
+  Bool_t     fPHOSFidutialCut ;// Apply fidutial cuts to PHOS clusters
+  Bool_t     fCTSFidutialCut ;//Apply fidutial cuts to  CTS tracks
+  
+  TArrayF * fCTSFidCutMinEta ; //Take particles in CTS with eta > fCTSFidCutMinEta
+  TArrayF * fCTSFidCutMinPhi ; //Take particles in CTS with phi > fCTSFidCutMinPhi
+  TArrayF * fCTSFidCutMaxEta ; //Take particles in CTS with eta < fCTSFidCutMaxEta
+  TArrayF * fCTSFidCutMaxPhi ; //Take particles in CTS with phi > fCTSFidCutMaxPhi
+  
+  TArrayF * fEMCALFidCutMinEta ; //Take particles in EMCAL with eta > fEMCALFidCutMinEta
+  TArrayF * fEMCALFidCutMinPhi ; //Take particles in EMCAL with phi > fEMCALFidCutMinPhi
+  TArrayF * fEMCALFidCutMaxEta ; //Take particles in EMCAL with eta < fEMCALFidCutMaxEta
+  TArrayF * fEMCALFidCutMaxPhi ; //Take particles in EMCAL with phi > fEMCALFidCutMaxPhi
+  
+  TArrayF * fPHOSFidCutMinEta ; //Take particles in PHOS with eta > fPHOSFidCutMinEta
+  TArrayF * fPHOSFidCutMinPhi ; //Take particles in PHOS with phi > fPHOSFidCutMinPhi
+  TArrayF * fPHOSFidCutMaxEta ; //Take particles in PHOS with eta < fPHOSFidCutMaxEta
+  TArrayF * fPHOSFidCutMaxPhi ; //Take particles in PHOS with phi > fPHOSFidCutMaxPhi
+
+  
+  ClassDef(AliFidutialCut,1)
+} ;
+
+
+#endif //ALIFIDUTIALCUT_H
+
+
+
diff --git a/PWG4/PartCorrBase/AliIsolationCut.cxx b/PWG4/PartCorrBase/AliIsolationCut.cxx
new file mode 100755 (executable)
index 0000000..51aa77b
--- /dev/null
@@ -0,0 +1,225 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Class containing methods for the isolation cut. 
+//
+//
+//*-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+  
+  
+// --- ROOT system --- 
+//#include <Riostream.h>
+#include <TLorentzVector.h>
+#include <TSeqCollection.h>
+
+// --- AliRoot system --- 
+#include "AliIsolationCut.h" 
+class AliLog ;
+#include "AliAODPWG4ParticleCorrelation.h"
+#include "AliAODTrack.h"
+#include "AliAODCaloCluster.h"
+
+ClassImp(AliIsolationCut)
+  
+//____________________________________________________________________________
+  AliIsolationCut::AliIsolationCut() : 
+    TObject(),
+    fConeSize(0.),fPtThreshold(0.), fPtFraction(0.), fICMethod(0)
+{
+  //default ctor
+  
+  //Initialize parameters
+  InitParameters();
+
+}
+
+//____________________________________________________________________________
+AliIsolationCut::AliIsolationCut(const AliIsolationCut & g) : 
+  TObject(g),
+  fConeSize(g.fConeSize),
+  fPtThreshold(g.fPtThreshold),
+  fPtFraction(g.fPtFraction), 
+  fICMethod(g.fICMethod)
+{
+  // cpy ctor
+
+}
+
+//_________________________________________________________________________
+AliIsolationCut & AliIsolationCut::operator = (const AliIsolationCut & source)
+{
+  // assignment operator
+  
+  if(&source == this) return *this;
+   
+  fConeSize = source.fConeSize ;
+  fPtThreshold = source.fPtThreshold ; 
+  fICMethod = source.fICMethod ;
+  fPtFraction = source.fPtFraction ;
+
+  return *this;
+  
+}
+
+
+//____________________________________________________________________________
+TString AliIsolationCut::GetICParametersList()
+{
+       //Put data member values in string to keep in output container
+
+       TString parList ; //this will be list of parameters used for this analysis.
+       char onePar[255] ;
+       
+       sprintf(onePar,"--- AliIsolationCut ---\n") ;
+       parList+=onePar ;       
+       sprintf(onePar,"fConeSize: (isolation cone size) %1.2f\n",fConeSize) ;
+       parList+=onePar ;
+       sprintf(onePar,"fPtThreshold =%1.2f (isolation pt threshold) \n",fPtThreshold) ;
+       parList+=onePar ;
+       sprintf(onePar,"fPtFraction=%1.2f (isolation pt threshold fraction ) \n",fPtFraction) ;
+       parList+=onePar ;
+       sprintf(onePar,"fICMethod=%d (isolation cut case) \n",fICMethod) ;
+       parList+=onePar ;
+
+    return parList; 
+}
+
+//____________________________________________________________________________
+void AliIsolationCut::InitParameters()
+{
+  //Initialize the parameters of the analysis.
+
+  fConeSize             = 0.4 ; 
+  fPtThreshold         = 1. ; 
+  fPtFraction        = 0.1 ; 
+
+  fICMethod = kPtThresIC; // 0 pt threshol method, 1 cone pt sum method
+
+}
+
+//__________________________________________________________________
+void  AliIsolationCut::MakeIsolationCut(TSeqCollection * plCTS,  TSeqCollection * plNe, Double_t * vertex, 
+                                       const Bool_t fillAOD, AliAODPWG4ParticleCorrelation  *pCandidate, 
+                                       Int_t & n, Int_t & nfrac, Float_t &coneptsum,  Bool_t  &isolated) const
+{  
+       //Search in cone around a candidate particle if it is isolated 
+       Float_t phiC  = pCandidate->Phi() ;
+       Float_t etaC = pCandidate->Eta() ;
+       Float_t ptC = pCandidate->Pt() ;
+       Float_t pt     = -100. ;
+       Float_t eta   = -100.  ;
+       Float_t phi    = -100.  ;
+       Float_t rad   = -100 ;
+       
+       n = 0 ;
+       coneptsum = 0.; 
+       isolated = kFALSE;
+       
+       //Check charged particles in cone.
+       if(plCTS){
+               TVector3 p3;
+               for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ ){
+                       AliAODTrack* track = (AliAODTrack *)(plCTS->At(ipr)) ; 
+                       //Do not count the candidate (pion, conversion photon) or the daughters of the candidate
+                       if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1)) continue ;
+                       p3.SetXYZ(track->Px(),track->Py(),track->Pz());
+                       pt   = p3.Pt();
+                       eta  = p3.Eta();
+                       phi  = p3.Phi() ;
+                       if(phi<0) phi+=TMath::TwoPi();
+                       
+                       //Check if there is any particle inside cone with pt larger than  fPtThreshold
+                       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
+                       
+                       if(rad < fConeSize){
+                               if(fillAOD) pCandidate->AddIsolationConeTrack(track);
+                               //printf("charged in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
+                               coneptsum+=pt;
+                               if(pt > fPtThreshold ) n++;
+                               if(pt > fPtFraction*ptC ) nfrac++;  
+                       }
+               }// charged particle loop
+       }//Tracks
+       
+       //Check neutral particles in cone.  
+       if(plNe){
+               TLorentzVector mom ;
+               for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){
+                       AliAODCaloCluster * calo = (AliAODCaloCluster *)(plNe->At(ipr)) ;
+                       
+                       //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 ; 
+                       
+                       calo->GetMomentum(mom,vertex);//Assume that come from vertex in straight line
+                       pt   = mom.Pt();
+                       eta  = mom.Eta();
+                       phi  = mom.Phi() ;
+                       if(phi<0) phi+=TMath::TwoPi();
+                       
+                       //Check if there is any particle inside cone with pt larger than  fPtThreshold
+                       rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
+                       if(rad < fConeSize){
+                               if(fillAOD) pCandidate->AddIsolationConeCluster(calo);
+                               //printf("neutral in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
+                               coneptsum+=pt;
+                               if(pt > fPtThreshold ) n++;
+                               if(pt > fPtFraction*ptC ) nfrac++;
+                       }//in cone
+               }// neutral particle loop
+       }//neutrals
+       
+       //printf("Isolation Cut: in cone with: pT>pTthres %d, pT > pTfrac*pTcandidate %d \n",n,nfrac);
+       
+       //Check isolation, depending on method.
+       if( fICMethod == kPtThresIC){
+               if(n==0) isolated = kTRUE ;
+       }
+       else if( fICMethod == kSumPtIC){
+               if(coneptsum < fPtThreshold)
+                       isolated  =  kTRUE ;
+       }
+       else if( fICMethod == kPtFracIC){
+               if(nfrac==0) isolated = kTRUE ;
+       }
+       else if( fICMethod == kSumPtFracIC){
+               if(coneptsum < fPtFraction*ptC)
+                       isolated  =  kTRUE ;
+       }
+}
+
+//__________________________________________________________________
+void AliIsolationCut::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("IC method          =     %d\n", fICMethod) ; 
+  printf("Cone Size          =     %1.2f\n", fConeSize) ; 
+  printf("pT threshold       =     %2.1f\n", fPtThreshold) ;
+  printf("pT fraction        =     %3.1f\n", fPtFraction) ;
+
+  printf("    \n") ;
+  
+} 
diff --git a/PWG4/PartCorrBase/AliIsolationCut.h b/PWG4/PartCorrBase/AliIsolationCut.h
new file mode 100755 (executable)
index 0000000..c464f48
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef ALIISOLATIONCUT_H
+#define ALIISOLATIONCUT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id:  */
+
+//_________________________________________________________________________
+
+// Class containing methods for the isolation cut. 
+//
+//
+// 
+
+// -- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system --- 
+#include <TObject.h>
+class TSeqCollection ;
+
+// --- ANALYSIS system ---
+class AliAODPWG4ParticleCorrelation ;
+
+class AliIsolationCut : public TObject {
+  
+ public: 
+  
+       AliIsolationCut() ; // default ctor
+       AliIsolationCut(const AliIsolationCut & g) ; // cpy ctor
+       AliIsolationCut & operator = (const AliIsolationCut & g) ;//cpy assignment
+       virtual ~AliIsolationCut() {;} //virtual dtalr
+       
+       enum type {kPtThresIC, kSumPtIC, kPtFracIC, kSumPtFracIC};
+       
+       Float_t    GetConeSize()        const {return fConeSize ; }
+       Float_t    GetPtThreshold()     const {return fPtThreshold ; }
+       Float_t    GetPtFraction()      const {return fPtFraction ; }
+       Int_t      GetICMethod()        const {return fICMethod ; }
+       TString    GetICParametersList() ; 
+       
+       void MakeIsolationCut(TSeqCollection * plCTS, TSeqCollection * plNe, Double_t * vertex, 
+                                                 const Bool_t fillAOD, AliAODPWG4ParticleCorrelation  * pCandidate,
+                                                 Int_t &n, Int_t & nfrac, Float_t &ptsum, Bool_t & isolated) const ;  
+       
+       void Print(const Option_t * opt)const;
+       
+       void SetConeSize(Float_t r)       {fConeSize = r ; }
+       void SetPtThreshold(Float_t pt)   {fPtThreshold = pt; }
+       void SetPtFraction(Float_t pt)    {fPtFraction = pt; }
+       void SetICMethod(Int_t i )        {fICMethod = i ; }
+       
+       void InitParameters();
+       
+  
+  private:
+     
+  Float_t      fConeSize ; //Size of the isolation cone 
+  Float_t      fPtThreshold ; //Mimium pt of the particles in the cone or sum in cone 
+  Float_t      fPtFraction ; //Fraction of the momentum of particles in cone or sum in cone
+  Int_t        fICMethod ; //Isolation cut method to be used
+                                           // kPtIC: Pt threshold method
+                                           // kSumPtIC: Cone pt sum method
+                                           // kPtFracIC:   Pt threshold, fraction of candidate pt, method
+                                           // kSumPtFracIC:   Cone pt sum , fraction of cone sum, method
+
+  ClassDef(AliIsolationCut,1)
+} ;
+
+#endif //ALIISOLATIONCUT_H
+
+
+
diff --git a/PWG4/PartCorrBase/AliNeutralMesonSelection.cxx b/PWG4/PartCorrBase/AliNeutralMesonSelection.cxx
new file mode 100755 (executable)
index 0000000..93f8b4b
--- /dev/null
@@ -0,0 +1,313 @@
+ /**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: AliNeutralMesonSelection.cxx 27413 2008-07-18 13:28:12Z gconesab $ */
+
+//_________________________________________________________________________
+// Class that contains methods to select candidate pairs to neutral meson 
+// 2 main selections, invariant mass around pi0 (also any other mass),
+// apperture angle to distinguish from combinatorial.
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+#include <TLorentzVector.h>
+#include <TH2.h>
+#include <TList.h>
+#include <TArrayD.h>
+//---- AliRoot system ----
+#include "AliNeutralMesonSelection.h" 
+#include "AliLog.h"
+
+ClassImp(AliNeutralMesonSelection)
+  
+  
+//____________________________________________________________________________
+  AliNeutralMesonSelection::AliNeutralMesonSelection() : 
+    TObject(), fM(0),
+    fInvMassMaxCut(0.), fInvMassMinCut(0.),
+    fAngleMaxParam(),  fKeepNeutralMesonHistos(0), 
+    fhAnglePairNoCut(0), fhAnglePairOpeningAngleCut(0), 
+    fhAnglePairAllCut(0), 
+    fhInvMassPairNoCut(0), fhInvMassPairOpeningAngleCut(0), 
+    fhInvMassPairAllCut(0),
+       fHistoNEBins(0),   fHistoEMax(0.),   fHistoEMin(0.),
+       fHistoNPtBins(0),  fHistoPtMax(0.),  fHistoPtMin(0.),
+       fHistoNAngleBins(0), fHistoAngleMax(0.), fHistoAngleMin(0.),
+       fHistoNIMBins(0), fHistoIMMax(0.), fHistoIMMin(0.){
+  //Default Ctor
+  
+  //Initialize parameters
+  
+  // kGammaHadron and kGammaJet 
+  fAngleMaxParam.Set(4) ;
+  fAngleMaxParam.Reset(0.);
+  
+  //Initialize parameters
+  InitParameters();
+}
+
+//____________________________________________________________________________
+AliNeutralMesonSelection::AliNeutralMesonSelection(const AliNeutralMesonSelection & g) :   
+  TObject(), fM(g.fM),
+  fInvMassMaxCut(g.fInvMassMaxCut), fInvMassMinCut(g.fInvMassMinCut),
+  fAngleMaxParam(g.fAngleMaxParam),
+  fKeepNeutralMesonHistos(g.fKeepNeutralMesonHistos),
+  fhAnglePairNoCut(g. fhAnglePairNoCut), 
+  fhAnglePairOpeningAngleCut(g. fhAnglePairOpeningAngleCut), 
+  fhAnglePairAllCut(g. fhAnglePairAllCut), 
+  fhInvMassPairNoCut(g.fhInvMassPairNoCut),  
+  fhInvMassPairOpeningAngleCut(g.fhInvMassPairOpeningAngleCut), 
+  fhInvMassPairAllCut(g.fhInvMassPairAllCut),
+  fHistoNEBins(g.fHistoNEBins),   fHistoEMax(g.fHistoEMax),   fHistoEMin(g.fHistoEMin),
+  fHistoNPtBins(g.fHistoNPtBins),   fHistoPtMax(g.fHistoPtMax),   fHistoPtMin(g.fHistoPtMin),
+  fHistoNAngleBins(g.fHistoNAngleBins), fHistoAngleMax(g.fHistoAngleMax), fHistoAngleMin(g.fHistoAngleMin),
+  fHistoNIMBins(g.fHistoNIMBins), fHistoIMMax(g.fHistoIMMax), fHistoIMMin(g.fHistoIMMin)
+{
+  // cpy ctor
+}
+
+//_________________________________________________________________________
+AliNeutralMesonSelection & AliNeutralMesonSelection::operator = (const AliNeutralMesonSelection & source)
+{
+  // assignment operator
+  
+  if(this == &source)return *this;
+  ((TObject *)this)->operator=(source);
+
+  fM = source.fM ;
+  fInvMassMaxCut = source.fInvMassMaxCut ; 
+  fInvMassMinCut = source.fInvMassMinCut ;
+  fAngleMaxParam = source.fAngleMaxParam ;
+  fKeepNeutralMesonHistos = source.fKeepNeutralMesonHistos;
+  fhAnglePairNoCut = source. fhAnglePairNoCut ; 
+  fhAnglePairOpeningAngleCut = source. fhAnglePairOpeningAngleCut ; 
+  fhAnglePairAllCut = source. fhAnglePairAllCut ; 
+  fhInvMassPairNoCut = source.fhInvMassPairNoCut ; 
+  fhInvMassPairOpeningAngleCut = source.fhInvMassPairOpeningAngleCut ; 
+  fhInvMassPairAllCut = source.fhInvMassPairAllCut ; 
+  
+  fHistoNEBins = source.fHistoNEBins;   fHistoEMax = source.fHistoEMax;   fHistoEMin = source.fHistoEMin;
+  fHistoNPtBins = source.fHistoNPtBins;   fHistoPtMax = source.fHistoPtMax;   fHistoPtMin = source.fHistoPtMin;
+  fHistoNAngleBins = source.fHistoNAngleBins; fHistoAngleMax = source.fHistoAngleMax; fHistoAngleMin = source.fHistoAngleMin;
+  fHistoNIMBins = source.fHistoNIMBins; fHistoIMMax = source.fHistoIMMax; fHistoIMMin = source.fHistoIMMin;
+  
+  return *this;
+  
+}
+
+//____________________________________________________________________________
+AliNeutralMesonSelection::~AliNeutralMesonSelection() 
+{
+  //dtor
+
+  if(!fKeepNeutralMesonHistos){
+    //Histograms initialized and filled but not passed to output container
+    //delete here, I am not sure this is correct
+    
+    if(fhAnglePairNoCut) delete fhAnglePairNoCut;
+    if(fhAnglePairOpeningAngleCut) delete fhAnglePairOpeningAngleCut; 
+    if(fhAnglePairAllCut) delete fhAnglePairAllCut;
+    if(fhInvMassPairNoCut) delete fhInvMassPairNoCut;
+    if(fhInvMassPairOpeningAngleCut) delete fhInvMassPairOpeningAngleCut;
+    if(fhInvMassPairAllCut) delete fhInvMassPairAllCut; 
+
+  }
+  
+}
+//________________________________________________________________________
+TList *  AliNeutralMesonSelection::GetCreateOutputObjects()
+{  
+       
+       // Create histograms to be saved in output file and 
+       // store them in outputContainer of the analysis class that calls this class.
+       
+       TList * outputContainer = new TList() ; 
+       outputContainer->SetName("MesonDecayHistos") ; 
+                         
+       fhAnglePairNoCut  = new TH2F
+    ("AnglePairNoCut",
+     "Angle between all #gamma pair vs E_{#pi^{0}}",fHistoNEBins,fHistoEMin,fHistoEMax,fHistoNAngleBins,fHistoAngleMin,fHistoAngleMax); 
+       fhAnglePairNoCut->SetYTitle("Angle (rad)");
+       fhAnglePairNoCut->SetXTitle("E_{ #pi^{0}} (GeV)");
+       
+       fhAnglePairOpeningAngleCut  = new TH2F
+    ("AnglePairOpeningAngleCut",
+     "Angle between all #gamma pair (opening angle + azimuth cut) vs E_{#pi^{0}}"
+     ,fHistoNEBins,fHistoEMin,fHistoEMax,fHistoNAngleBins,fHistoAngleMin,fHistoAngleMax); 
+       fhAnglePairOpeningAngleCut->SetYTitle("Angle (rad)");
+       fhAnglePairOpeningAngleCut->SetXTitle("E_{ #pi^{0}} (GeV)");
+       
+       fhAnglePairAllCut  = new TH2F
+    ("AnglePairAllCut",
+     "Angle between all #gamma pair (opening angle + inv mass cut+azimuth) vs E_{#pi^{0}}"
+     ,fHistoNEBins,fHistoEMin,fHistoEMax,fHistoNAngleBins,fHistoAngleMin,fHistoAngleMax); 
+       fhAnglePairAllCut->SetYTitle("Angle (rad)");
+       fhAnglePairAllCut->SetXTitle("E_{ #pi^{0}} (GeV)");    
+       
+       //
+       fhInvMassPairNoCut  = new TH2F
+    ("InvMassPairNoCut","Invariant Mass of all #gamma pair vs E_{#pi^{0}}",
+     fHistoNPtBins,fHistoPtMin,fHistoPtMax,fHistoNIMBins,fHistoIMMin,fHistoIMMax); 
+       fhInvMassPairNoCut->SetYTitle("Invariant Mass (GeV/c^{2})");
+       fhInvMassPairNoCut->SetXTitle("E_{ #pi^{0}} (GeV)");
+       
+       fhInvMassPairOpeningAngleCut  = new TH2F
+    ("InvMassPairOpeningAngleCut",
+     "Invariant Mass of #gamma pair (angle cut) vs E_{#pi^{0}}",
+     fHistoNPtBins,fHistoPtMin,fHistoPtMax,fHistoNIMBins,fHistoIMMin,fHistoIMMax); 
+       fhInvMassPairOpeningAngleCut->SetYTitle("Invariant Mass (GeV/c^{2})");
+       fhInvMassPairOpeningAngleCut->SetXTitle(" E_{#pi^{0}}(GeV)");
+       
+       fhInvMassPairAllCut  = new TH2F
+    ("InvMassPairAllCut",
+     "Invariant Mass of #gamma pair (opening angle+invmass cut) vs E_{#pi^{0}}",
+     fHistoNPtBins,fHistoPtMin,fHistoPtMax,fHistoNIMBins,fHistoIMMin,fHistoIMMax); 
+       fhInvMassPairAllCut->SetYTitle("Invariant Mass (GeV/c^{2})");
+       fhInvMassPairAllCut->SetXTitle("E_{#pi^{0}}(GeV)");
+       
+       outputContainer->Add(fhAnglePairNoCut) ; 
+       outputContainer->Add(fhAnglePairOpeningAngleCut) ;
+       outputContainer->Add(fhAnglePairAllCut) ; 
+       
+       outputContainer->Add(fhInvMassPairNoCut) ; 
+       outputContainer->Add(fhInvMassPairOpeningAngleCut) ; 
+       outputContainer->Add(fhInvMassPairAllCut) ; 
+       
+       return outputContainer;
+}
+
+ //____________________________________________________________________________
+void AliNeutralMesonSelection::InitParameters()
+{
+  //Initialize the parameters of the analysis.
+  fKeepNeutralMesonHistos = kFALSE ;
+
+  fAngleMaxParam.Set(4) ;
+  fAngleMaxParam.AddAt(0.4,0);//={0.4,-0.25,0.025,-2e-4};
+  fAngleMaxParam.AddAt(-0.25,1) ;
+  fAngleMaxParam.AddAt(0.025,2) ;
+  fAngleMaxParam.AddAt(-2e-4,3) ;
+
+  fInvMassMaxCut  = 0.16 ;
+  fInvMassMinCut  = 0.11 ;
+
+  fM = 0.1349766;//neutralMeson mass, pi0
+  
+ //Histogrammes settings
+  fHistoNEBins = 100 ;
+  fHistoEMax   = 50 ;
+  fHistoEMin   = 0.  ;  
+  
+  fHistoNPtBins = 240 ;
+  fHistoPtMax   = 120 ;
+  fHistoPtMin   = 0.  ;
+
+  fHistoNAngleBins = 200 ;
+  fHistoAngleMax   = 0.2;
+  fHistoAngleMin   = 0.  ;
+
+  fHistoNIMBins = 300 ;
+  fHistoIMMax   = 0.5   ;
+  fHistoIMMin   = 0.  ;  
+}
+
+//__________________________________________________________________________-
+Bool_t AliNeutralMesonSelection::IsAngleInWindow(const Float_t angle,const Float_t e) const {
+  //Check if the opening angle of the candidate pairs is inside 
+  //our selection windowd
+
+  Bool_t result = kFALSE;
+  Double_t max =  fAngleMaxParam.At(0)*TMath::Exp(fAngleMaxParam.At(1)*e)
+    +fAngleMaxParam.At(2)+fAngleMaxParam.At(3)*e;
+  Double_t arg = (e*e-2*fM*fM)/(e*e);
+  Double_t min = 100. ;
+  if(arg>0.)
+    min = TMath::ACos(arg);
+
+  if((angle<max)&&(angle>=min))
+    result = kTRUE;
+  return result;
+}
+
+//____________________________________________________________________________
+Bool_t  AliNeutralMesonSelection::SelectPair(TLorentzVector gammai, TLorentzVector gammaj)  
+{  
+  
+  //Search for the neutral pion within selection cuts
+  Bool_t goodpair = kFALSE ;
+  
+  Double_t pt  = (gammai+gammaj).Pt();
+  Double_t phi = (gammai+gammaj).Phi();
+  if(phi < 0)
+    phi+=TMath::TwoPi();
+  Double_t invmass = (gammai+gammaj).M();
+  Double_t angle   = gammaj.Angle(gammai.Vect());
+  Double_t e       = (gammai+gammaj).E();
+  
+  //Fill histograms with no cuts applied.
+  fhAnglePairNoCut->Fill(e,angle);
+  fhInvMassPairNoCut->Fill(e,invmass);
+    
+  //Cut on the aperture of the pair
+  if(IsAngleInWindow(angle,e)){
+    fhAnglePairOpeningAngleCut     ->Fill(e,angle);
+    fhInvMassPairOpeningAngleCut->Fill(e,invmass);
+    AliDebug(2,Form("Angle cut: pt %f, phi %f",pt,phi));
+    
+    //Cut on the invariant mass of the pair
+    if((invmass>fInvMassMinCut) && (invmass<fInvMassMaxCut)){ 
+      fhInvMassPairAllCut  ->Fill(e,invmass);
+      fhAnglePairAllCut       ->Fill(e,angle);
+      goodpair = kTRUE;
+      AliDebug(2,Form("IM cut: pt %f, phi %f",pt,phi));
+    }//(invmass>0.125) && (invmass<0.145)
+  }//Opening angle cut
+  
+  return goodpair; 
+  
+}
+
+//__________________________________________________________________
+void AliNeutralMesonSelection::Print(const Option_t * opt) const
+{
+
+  //Print some relevant parameters set for the analysis
+  if(! opt)
+    return;
+  
+  Info("Print", "%s %s", GetName(), GetTitle() ) ;
+
+  printf("mass : %f  \n", fM );
+  printf("Invariant mass limits : %f < m < %f \n", fInvMassMinCut , fInvMassMinCut );
+  printf("Angle selection param: \n");
+  printf("p0 :     %f", fAngleMaxParam.At(0));
+  printf("p1 :     %f", fAngleMaxParam.At(1));
+  printf("p2 :     %f", fAngleMaxParam.At(2));
+  printf("p3 :     %f", fAngleMaxParam.At(3));
+
+  printf("Keep Neutral Meson Histos = %d\n",fKeepNeutralMesonHistos);
+  
+  if(fKeepNeutralMesonHistos){
+       printf("Histograms: %3.1f < E  < %3.1f,  Nbin = %d\n", fHistoEMin,  fHistoEMax,  fHistoNEBins);
+       printf("Histograms: %3.1f < pT < %3.1f,  Nbin = %d\n", fHistoPtMin,  fHistoPtMax,  fHistoNPtBins);
+       printf("Histograms: %3.1f < angle < %3.1f, Nbin = %d\n", fHistoAngleMin, fHistoAngleMax, fHistoNAngleBins);
+       printf("Histograms: %3.1f < IM < %3.1f, Nbin = %d\n", fHistoIMMin, fHistoIMMax, fHistoNIMBins);
+  
+  }
+
+} 
diff --git a/PWG4/PartCorrBase/AliNeutralMesonSelection.h b/PWG4/PartCorrBase/AliNeutralMesonSelection.h
new file mode 100755 (executable)
index 0000000..e26b3d2
--- /dev/null
@@ -0,0 +1,137 @@
+#ifndef ALINEUTRALMESONSELECTION_H
+#define ALINEUTRALMESONSELECTION_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id: AliNeutralMesonSelection.h 27413 2008-07-18 13:28:12Z gconesab $ */
+
+//_________________________________________________________________________
+// Class that contains methods to select candidate pairs to neutral meson 
+// 2 main selections, invariant mass around pi0 (also any other mass),
+// apperture angle to distinguish from combinatorial.
+// There is a 3rd cut based on the gamma correlation on phi or pt.
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+#include<TObject.h>
+#include<TArrayD.h>
+
+class TLorentzVector ;
+class TList ;
+class TH2F ;
+
+//--- ANALYSIS system ---
+class AliLog ;
+
+class AliNeutralMesonSelection : public TObject {
+       
+public: 
+       
+       AliNeutralMesonSelection() ; // default ctor
+       AliNeutralMesonSelection(const AliNeutralMesonSelection & g) ; // cpy ctor
+       AliNeutralMesonSelection & operator = (const AliNeutralMesonSelection & g) ;//cpy assignment
+       virtual ~AliNeutralMesonSelection() ; //virtual dtor
+       
+       TList * GetCreateOutputObjects();
+       
+       Double_t GetAngleMaxParam(Int_t i) const {return fAngleMaxParam.At(i) ; }
+       void SetAngleMaxParam(Int_t i, Double_t par){fAngleMaxParam.AddAt(par,i) ; }
+       
+       Double_t GetInvMassMaxCut() const {return fInvMassMaxCut ; }
+       Double_t GetInvMassMinCut() const {return fInvMassMinCut ; }
+       void SetInvMassCutRange(Double_t invmassmin, Double_t invmassmax)
+       {fInvMassMaxCut =invmassmax;  fInvMassMinCut =invmassmin;}      
+       
+       Double_t GetMass() const {return fM ; }
+       void SetMass(Double_t m) { fM =m ; }
+       
+       Bool_t AreNeutralMesonSelectionHistosKept() const { return fKeepNeutralMesonHistos ; }
+       void KeepNeutralMesonSelectionHistos(Bool_t keep) { fKeepNeutralMesonHistos = keep ; }
+       
+       void InitParameters();  
+       Bool_t IsAngleInWindow(const Float_t angle, const Float_t e) const ;
+       void Print(const Option_t * opt) const;
+       
+       Bool_t  SelectPair(TLorentzVector particlei,  TLorentzVector particlej)  ;
+       
+       //Histogrammes setters and getters
+       
+       virtual void SetHistoERangeAndNBins(Float_t min, Float_t max, Int_t n) {
+               fHistoNEBins = n ;
+               fHistoEMax = max ;
+               fHistoEMin = min ;
+       }
+       
+       Int_t   GetHistoNEBins() const { return fHistoNEBins ; }
+       Float_t GetHistoEMin()   const { return fHistoEMin ; }
+       Float_t GetHistoEMax()   const { return fHistoEMax ; }
+
+       virtual void SetHistoPtRangeAndNBins(Float_t min, Float_t max, Int_t n) {
+               fHistoNPtBins = n ;
+               fHistoPtMax = max ;
+               fHistoPtMin = min ;
+       }
+       
+       Int_t   GetHistoNPtBins() const { return fHistoNPtBins ; }
+       Float_t GetHistoPtMin()   const { return fHistoPtMin ; }
+       Float_t GetHistoPtMax()   const { return fHistoPtMax ; }
+
+       virtual void SetHistoAngleRangeAndNBins(Float_t min, Float_t max, Int_t n) {
+               fHistoNAngleBins = n ;
+               fHistoAngleMax = max ;
+               fHistoAngleMin = min ;
+       }
+       
+       Int_t   GetHistoNAngleBins() const { return fHistoNAngleBins ; }
+       Float_t GetHistoAngleMin()   const { return fHistoAngleMin ; }
+       Float_t GetHistoAngleMax()   const { return fHistoAngleMax ; }
+
+       virtual void SetHistoIMRangeAndNBins(Float_t min, Float_t max, Int_t n) {
+               fHistoNIMBins = n ;
+               fHistoIMMax = max ;
+               fHistoIMMin = min ;
+       }
+       
+       Int_t   GetHistoNIMBins() const { return fHistoNIMBins ; }
+       Float_t GetHistoIMMin()   const { return fHistoIMMin ; }
+       Float_t GetHistoIMMax()   const { return fHistoIMMax ; }
+       
+       
+private:
+       Double_t fM ; //mass of the neutral meson
+       Double_t   fInvMassMaxCut ;  // Invariant Mass cut maximum
+       Double_t   fInvMassMinCut ;  // Invariant Masscut minimun
+       TArrayD    fAngleMaxParam ; //Max opening angle selection parameters
+       
+       Bool_t  fKeepNeutralMesonHistos ; // Keep neutral meson selection histograms
+       
+       //Histograms
+       TH2F * fhAnglePairNoCut  ;  //Aperture angle of decay photons, no cuts
+       TH2F * fhAnglePairOpeningAngleCut   ;  //Aperture angle of decay photons, cut on opening angle
+       TH2F * fhAnglePairAllCut   ;  //Aperture angle of decay photons, all cuts
+       TH2F * fhInvMassPairNoCut    ;  //Invariant mass of decay photons, no cuts
+       TH2F * fhInvMassPairOpeningAngleCut  ;  //Invariant mass of decay photons, cut on opening angle
+       TH2F * fhInvMassPairAllCut   ;  //Invariant mass of decay photons, all cuts
+       
+       //Histograms binning and range    
+       Int_t   fHistoNEBins ;  //Number of bins in pi0 E axis
+       Float_t fHistoEMax ;    //Maximum value of pi0 E histogram range
+       Float_t fHistoEMin ;    //Minimum value of pi0 E histogram range
+       Int_t   fHistoNPtBins ;  //Number of bins in Pt trigger axis
+       Float_t fHistoPtMax ;    //Maximum value of Pt trigger histogram range
+       Float_t fHistoPtMin ;    //Minimum value of Pt trigger histogram range          
+       Int_t   fHistoNAngleBins ; //Number of bins in angle axis
+       Float_t fHistoAngleMax ;//Maximum value of angle histogram range
+       Float_t fHistoAngleMin ;//Minimum value of angle histogram range
+       Int_t   fHistoNIMBins ; //Number of bins in Invariant Mass axis
+       Float_t fHistoIMMax ;   //Maximum value of Invariant Mass histogram range
+       Float_t fHistoIMMin ;   //Minimum value of Invariant Mass histogram range
+       
+       ClassDef(AliNeutralMesonSelection,2)
+    
+} ;
+
+
+#endif //ALINEUTRALMESONSELECTION_H
+
+
+
diff --git a/PWG4/PartCorrDep/AliAnaCaloTrigger.cxx b/PWG4/PartCorrDep/AliAnaCaloTrigger.cxx
new file mode 100755 (executable)
index 0000000..140ce55
--- /dev/null
@@ -0,0 +1,258 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//_________________________________________________________________________
+// An analysis task to check the trigger data in ESD
+// Creates an ntuple for 2x2 and NxN triggers
+// Each ntuple connects the maximum trigger amplitudes 
+// and its positions with reconstructed clusters
+//
+//*-- Yves Schutz (CERN) & Gustavo Conesa Balbastre (INFN-LNF)
+//////////////////////////////////////////////////////////////////////////////
+
+#include <TChain.h>
+#include <TFile.h> 
+#include <TNtuple.h>
+#include <TVector3.h> 
+
+#include "AliAnaCaloTrigger.h" 
+#include "AliAnalysisManager.h"
+#include "AliESDEvent.h" 
+#include "AliLog.h"
+#include "AliESDCaloCluster.h"
+
+//______________________________________________________________________________
+AliAnaCaloTrigger::AliAnaCaloTrigger() :  
+  fChain(0),
+  fESD(0), 
+  fOutputContainer(0),
+  fCalorimeter("PHOS"),
+  fNtTrigger22(0), 
+  fNtTriggerNN(0)
+
+{
+  // Default Constructor.
+
+}
+
+//______________________________________________________________________________
+AliAnaCaloTrigger::AliAnaCaloTrigger(const char *name) : 
+  AliAnalysisTask(name,"AnaCaloTrigger"),  
+  fChain(0),
+  fESD(0), 
+  fOutputContainer(0),
+  fCalorimeter("PHOS"),
+  fNtTrigger22(0), 
+  fNtTriggerNN(0)
+
+{
+  // Constructor.
+  // Input slot #0 works with an Ntuple
+  DefineInput(0, TChain::Class());
+  // Output slot #0 writes into a TH1 container
+  DefineOutput(0,  TObjArray::Class()) ; 
+}
+//____________________________________________________________________________
+AliAnaCaloTrigger::AliAnaCaloTrigger(const AliAnaCaloTrigger & ct) : 
+  AliAnalysisTask(ct), fChain(ct.fChain), fESD(ct.fESD),
+  fOutputContainer(ct.fOutputContainer), fCalorimeter(ct. fCalorimeter),
+  fNtTrigger22(ct.fNtTrigger22), fNtTriggerNN(ct.fNtTriggerNN)
+{
+
+  // cpy ctor
+  SetName (ct.GetName()) ; 
+  SetTitle(ct.GetTitle()) ;
+}
+
+//_________________________________________________________________________
+AliAnaCaloTrigger & AliAnaCaloTrigger::operator = (const AliAnaCaloTrigger & source)
+{
+  // assignment operator
+  
+  if(&source == this) return *this;
+
+  fChain = source.fChain ; 
+  fESD = source.fESD ;
+  fOutputContainer = source.fOutputContainer ;
+  fCalorimeter = source. fCalorimeter ;
+  fNtTrigger22 = source.fNtTrigger22 ;
+  fNtTriggerNN = source.fNtTriggerNN ;
+
+  return *this;
+  
+}
+
+//______________________________________________________________________________
+AliAnaCaloTrigger::~AliAnaCaloTrigger()
+{
+  // dtor
+  //fOutputContainer->Clear() ; 
+  //delete fOutputContainer ;
+
+}
+
+
+//______________________________________________________________________________
+void AliAnaCaloTrigger::ConnectInputData(const Option_t*)
+{
+  // Initialisation of branch container and histograms 
+    
+  AliInfo(Form("*** Initialization of %s", GetName())) ; 
+  
+  // Get input data
+  fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
+  if (!fChain) {
+    AliError(Form("Input 0 for %s not found\n", GetName()));
+    return ;
+  }
+  
+  fESD = new AliESDEvent();
+  fESD->ReadFromTree(fChain);
+
+}
+
+//________________________________________________________________________
+
+void AliAnaCaloTrigger::CreateOutputObjects()
+{  
+
+  // Create the outputs containers
+  OpenFile(0) ;
+
+  // create histograms 
+  fNtTrigger22 = new TNtuple(fCalorimeter+"trigger22", "Trigger data 2x2 patch", "a22:a220:enMax:phEnMax:eta22:phi22:etaMax:phiMax:phEtaMax:phPhiMax");
+  fNtTriggerNN = new TNtuple(fCalorimeter+"triggerNN", "Trigger data NxN patch", "aNN:aNN0:enMax:phEnMax:etaNN:phiNN:etaMax:phiMax:phEtaMax:phPhiMax");
+  
+  // create output container
+  
+  fOutputContainer = new TObjArray(2) ; 
+  fOutputContainer->SetName(GetName()) ; 
+  
+  fOutputContainer->AddAt(fNtTrigger22,             0) ; 
+  fOutputContainer->AddAt(fNtTriggerNN,             1) ; 
+
+}
+
+//______________________________________________________________________________
+void AliAnaCaloTrigger::Exec(Option_t *) 
+{
+  // Processing of one event
+  
+  Long64_t entry = fChain->GetReadEntry() ;
+  
+  if (!fESD) {
+    AliError("fESD is not connected to the input!") ; 
+    return ; 
+  }
+  
+  if ( !((entry-1)%100) ) 
+    AliInfo(Form("%s ----> Processing event # %lld",  (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ; 
+  
+  // Get trigger information of fCalorimeter 
+  TArrayF * triggerAmplitudes = 0x0 ;
+  TArrayF * triggerPosition   = 0x0 ;
+  Int_t numberOfCaloClusters  =  fESD->GetNumberOfCaloClusters() ;
+
+  if(fCalorimeter == "PHOS"){
+    triggerAmplitudes      = fESD->GetPHOSTriggerAmplitudes();
+    triggerPosition        = fESD->GetPHOSTriggerPosition();
+  }
+  else if(fCalorimeter == "EMCAL"){
+    triggerAmplitudes    = fESD->GetEMCALTriggerAmplitudes();
+    triggerPosition      = fESD->GetEMCALTriggerPosition();
+  }
+
+  if( triggerAmplitudes && triggerPosition ){
+  // trigger amplitudes
+  const Float_t ka22    = static_cast<Float_t>(triggerAmplitudes->At(0)) ; 
+  const Float_t ka22O   = static_cast<Float_t>(triggerAmplitudes->At(1)) ; 
+  const Float_t kaNN    = static_cast<Float_t>(triggerAmplitudes->At(2)) ; 
+  const Float_t kaNNO   = static_cast<Float_t>(triggerAmplitudes->At(3)) ; 
+
+  // trigger position
+  const Float_t kx22  =  static_cast<Float_t>(triggerPosition->At(0)) ; 
+  const Float_t ky22  =  static_cast<Float_t>(triggerPosition->At(1)) ;
+  const Float_t kz22  =  static_cast<Float_t>(triggerPosition->At(2)) ;
+  const Float_t kxNN  =  static_cast<Float_t>(triggerPosition->At(3)) ; 
+  const Float_t kyNN  =  static_cast<Float_t>(triggerPosition->At(4)) ;
+  const Float_t kzNN  =  static_cast<Float_t>(triggerPosition->At(5)) ; 
+  
+  Float_t enMax       = 0. ;
+  Float_t phEnMax     = 0. ;
+  Float_t etaMax      = 0.5 ;
+  Float_t phiMax      = 0. ; 
+  Float_t phEtaMax    = 0.5 ;
+  Float_t phPhiMax    = 0. ; 
+  
+  TVector3 vpos22(kx22, ky22, kz22) ;
+  TVector3 vposNN(kxNN, kyNN, kzNN) ;
+  Float_t eta22 = vpos22.Eta() ; 
+  Float_t phi22 = vpos22.Phi() * TMath::RadToDeg() + 360. ; 
+  Float_t etaNN = vposNN.Eta() ; 
+  Float_t phiNN = vposNN.Phi() * TMath::RadToDeg() + 360. ; 
+
+  Int_t      icaloCluster ; 
+  
+  // loop over the Calorimeters Clusters
+  
+  for(icaloCluster = 0 ; icaloCluster < numberOfCaloClusters ; icaloCluster++) {
+    
+    AliESDCaloCluster * cluster = fESD->GetCaloCluster(icaloCluster) ;
+    
+    if (cluster && ( (fCalorimeter == "PHOS" && cluster->IsPHOS())  ||  
+                    (fCalorimeter == "EMCAL" && cluster->IsEMCAL()))) {
+         
+      Float_t cluEnergy = cluster->E() ; 
+      Float_t pos[3] ;
+      TVector3 vpos ;
+      
+      cluster->GetPosition( pos ) ;
+      
+      if ( cluEnergy > enMax) { 
+       enMax = cluEnergy ; 
+       vpos.SetXYZ(pos[0], pos[1], pos[2]) ; 
+       etaMax = vpos.Eta() ; 
+       phiMax = vpos.Phi() ; 
+      }
+
+      Double_t * pid = cluster->GetPid() ;
+      
+      if(pid[AliPID::kPhoton] > 0.9) {
+       if ( cluEnergy > phEnMax) { 
+         phEnMax = cluEnergy ; 
+         vpos.SetXYZ(pos[0], pos[1], pos[2]) ; 
+         phEtaMax = vpos.Eta() ; 
+         phPhiMax = vpos.Phi() ; 
+       }
+      }
+    }//if cluster
+    
+    fNtTrigger22->Fill(ka22, ka22O, enMax, phEnMax, eta22, phi22, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
+    fNtTriggerNN->Fill(kaNN, kaNNO, enMax, phEnMax, etaNN, phiNN, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
+  }//CaloCluster loop
+  
+  }//If trigger arrays filled
+  
+  PostData(0, fOutputContainer);
+  
+}
+
+//______________________________________________________________________________
+//void AliAnaCaloTrigger::Terminate(Option_t *) const
+//{
+//  // Processing when the event loop is ended
+//
+//}
diff --git a/PWG4/PartCorrDep/AliAnaCaloTrigger.h b/PWG4/PartCorrDep/AliAnaCaloTrigger.h
new file mode 100755 (executable)
index 0000000..c173eac
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef ALIANACALOTRIGGER_H
+#define ALIANACALOTRIGGER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+//______________________________________________________________________________
+// An analysis task to check the trigger data in ESD
+// Creates an ntuple for 2x2 and NxN triggers
+// Each ntuple connects the maximum trigger amplitudes 
+// and its positions with reconstructed clusters
+//
+//*-- Yves Schutz (CERN) & Gustavo Conesa Balbastre (INFN-LNF)
+//////////////////////////////////////////////////////////////////////////////
+
+
+#include "AliAnalysisTask.h"  
+class TFile ;
+class TNtuple ;
+class TH1D ; 
+class TH1I ; 
+class TChain;
+
+class AliAnalysisManager ;
+class AliESDEvent ; 
+
+class AliAnaCaloTrigger : public AliAnalysisTask {
+
+public:
+  AliAnaCaloTrigger() ;
+  AliAnaCaloTrigger(const char *name) ;
+  AliAnaCaloTrigger(const AliAnaCaloTrigger & trig) ;
+  AliAnaCaloTrigger & operator=(const AliAnaCaloTrigger& source);
+  virtual ~AliAnaCaloTrigger() ;
+   
+  virtual void Exec(Option_t * opt = "") ;
+  virtual void ConnectInputData(Option_t *);
+  virtual void CreateOutputObjects();
+//  virtual void Terminate(Option_t * opt = "") const ;
+
+  TString GetCalorimeter()     const   {return fCalorimeter ; }
+  void    SetCalorimeter(TString calo) {fCalorimeter = calo ; }
+
+private:
+  TChain       * fChain ;            //!pointer to the analyzed TTree or TChain
+  AliESDEvent  * fESD ;              //! Declaration of leave types
+
+  TObjArray * fOutputContainer ; //! output data container
+
+  TString fCalorimeter ; // "PHOS" or "EMCAL"
+
+  // Histograms
+  TNtuple * fNtTrigger22 ; //Ntuple with 2x2 max dig amplitude and cluster energy, and positions.
+  TNtuple * fNtTriggerNN ; //Ntuple with NxN max dig amplitude and cluster energy, and positions.
+
+  ClassDef(AliAnaCaloTrigger, 1); // a photon analysis task 
+};
+#endif // ALIANACALOTRIGGER_H
diff --git a/PWG4/PartCorrDep/AliAnaCaloTriggerMC.cxx b/PWG4/PartCorrDep/AliAnaCaloTriggerMC.cxx
new file mode 100755 (executable)
index 0000000..277624c
--- /dev/null
@@ -0,0 +1,283 @@
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//_________________________________________________________________________
+// An analysis task to check the trigger data in ESD with MC data
+// Creates an ntuple for 2x2 and NxN triggers
+// Each ntuple connects the maximum trigger amplitudes 
+// and its positions with reconstructed clusters and MC 
+//
+//*-- Yves Schutz (CERN) & Gustavo Conesa Balbastre (INFN-LNF)
+//////////////////////////////////////////////////////////////////////////////
+
+#include <TChain.h>
+#include <TFile.h> 
+#include <TNtuple.h>
+#include <TVector3.h> 
+
+#include "AliAnalysisManager.h"
+#include "AliMCEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliAnaCaloTriggerMC.h" 
+#include "AliESDEvent.h" 
+#include "AliESDCaloCluster.h"
+#include "AliLog.h"
+#include "AliStack.h"
+#include "TParticle.h"
+
+//______________________________________________________________________________
+AliAnaCaloTriggerMC::AliAnaCaloTriggerMC() : 
+  fChain(0),
+  fESD(0), 
+  fOutputContainer(0),
+  fCalorimeter("PHOS"),
+  fNtTrigger22(0), 
+  fNtTriggerNN(0)
+
+{
+  // Default constructor.
+
+}
+//______________________________________________________________________________
+AliAnaCaloTriggerMC::AliAnaCaloTriggerMC(const char *name) : 
+  AliAnalysisTask(name, "AnaCaloTriggerMC"),
+  fChain(0),
+  fESD(0), 
+  fOutputContainer(0),
+  fCalorimeter("PHOS"),
+  fNtTrigger22(0), 
+  fNtTriggerNN(0)
+
+{
+  // Constructor.
+  // Input slot #0 works with an Ntuple
+  DefineInput(0, TChain::Class());
+  // Output slot #0 writes into a TH1 container
+  DefineOutput(0,  TObjArray::Class()) ; 
+}
+//____________________________________________________________________________
+AliAnaCaloTriggerMC::AliAnaCaloTriggerMC(const AliAnaCaloTriggerMC & ct) : 
+  AliAnalysisTask(ct),fChain(ct.fChain), fESD(ct.fESD),
+  fOutputContainer(ct.fOutputContainer), fCalorimeter(ct. fCalorimeter),
+  fNtTrigger22(ct.fNtTrigger22), fNtTriggerNN(ct.fNtTriggerNN)
+{
+
+  // cpy ctor
+  SetName (ct.GetName()) ; 
+  SetTitle(ct.GetTitle()) ;
+}
+
+//_________________________________________________________________________
+AliAnaCaloTriggerMC & AliAnaCaloTriggerMC::operator = (const AliAnaCaloTriggerMC & source)
+{
+  // assignment operator
+  
+  if(&source == this) return *this;
+
+  fChain = source.fChain ; 
+  fESD = source.fESD ;
+  fOutputContainer = source.fOutputContainer ;
+  fCalorimeter = source. fCalorimeter ;
+  fNtTrigger22 = source.fNtTrigger22 ;
+  fNtTriggerNN = source.fNtTriggerNN ;
+
+  return *this;
+  
+}
+
+//______________________________________________________________________________
+AliAnaCaloTriggerMC::~AliAnaCaloTriggerMC()
+{
+  // dtor
+  //  fOutputContainer->Clear() ; 
+  //  delete fOutputContainer ;
+
+}
+
+
+//______________________________________________________________________________
+void AliAnaCaloTriggerMC::ConnectInputData(const Option_t*)
+{
+  // Initialisation of branch container and histograms 
+    
+  AliInfo(Form("*** Initialization of %s", GetName())) ; 
+  
+  // Get input data
+  fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
+  if (!fChain) {
+    AliError(Form("Input 0 for %s not found\n", GetName()));
+    return ;
+  }
+  
+  fESD = new AliESDEvent();
+  fESD->ReadFromTree(fChain);
+
+}
+
+//________________________________________________________________________
+
+void AliAnaCaloTriggerMC::CreateOutputObjects()
+{ 
+  // Create the output container
+  OpenFile(0);
+  // create histograms 
+  fNtTrigger22 = new TNtuple(fCalorimeter+"trigger22", "Trigger data 2x2 patch", "a22:a220:enMax:phEnMax:eta22:phi22:etaMax:phiMax:phEtaMax:phPhiMax");
+  fNtTriggerNN = new TNtuple(fCalorimeter+"triggerNN", "Trigger data NxN patch", "aNN:aNN0:enMax:phEnMax:etaNN:phiNN:etaMax:phiMax:phEtaMax:phPhiMax");
+  
+  // create output container
+  
+  fOutputContainer = new TObjArray(2) ; 
+  fOutputContainer->SetName(GetName()) ; 
+
+  fOutputContainer->AddAt(fNtTrigger22,             0) ; 
+  fOutputContainer->AddAt(fNtTriggerNN,             1) ; 
+
+}
+
+//______________________________________________________________________________
+void AliAnaCaloTriggerMC::Exec(Option_t *) 
+{
+
+  // Processing of one event
+   
+  Long64_t entry = fChain->GetReadEntry() ;
+  if (!fESD) {
+    AliError("fESD is not connected to the input!") ; 
+    return ; 
+  }
+
+  if ( !((entry-1)%100) ) 
+    AliInfo(Form("%s ----> Processing event # %lld",  (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ; 
+
+  //Get MC data
+  AliStack* stack = 0x0; 
+  AliMCEventHandler*    mctruth = (AliMCEventHandler*) 
+    ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
+  
+  if(mctruth)
+    stack = mctruth->MCEvent()->Stack();
+  
+  if (!stack) {
+    AliError("Stack not found") ; 
+    return ; 
+  }
+  
+  // Get trigger information of fCalorimeter 
+  TArrayF * triggerAmplitudes = 0x0 ;
+  TArrayF * triggerPosition   = 0x0 ;
+  Int_t numberOfCaloClusters  = 0 ;
+  
+  if(fCalorimeter == "PHOS"){
+    triggerAmplitudes      = fESD->GetPHOSTriggerAmplitudes();
+    triggerPosition        = fESD->GetPHOSTriggerPosition();
+  }
+  else if(fCalorimeter == "EMCAL"){
+    triggerAmplitudes    = fESD->GetEMCALTriggerAmplitudes();
+    triggerPosition      = fESD->GetEMCALTriggerPosition();
+  }
+
+  if( triggerAmplitudes && triggerPosition ){
+    // trigger amplitudes
+    const Float_t ka22    = static_cast<Float_t>(triggerAmplitudes->At(0)) ; 
+    const Float_t ka22O   = static_cast<Float_t>(triggerAmplitudes->At(1)) ; 
+    const Float_t kaNN    = static_cast<Float_t>(triggerAmplitudes->At(2)) ; 
+    const Float_t kaNNO   = static_cast<Float_t>(triggerAmplitudes->At(3)) ; 
+    
+    // trigger position
+    const Float_t kx22  =  static_cast<Float_t>(triggerPosition->At(0)) ; 
+    const Float_t ky22  =  static_cast<Float_t>(triggerPosition->At(1)) ;
+    const Float_t kz22  =  static_cast<Float_t>(triggerPosition->At(2)) ;
+    const Float_t kxNN  =  static_cast<Float_t>(triggerPosition->At(3)) ; 
+    const Float_t kyNN  =  static_cast<Float_t>(triggerPosition->At(4)) ;
+    const Float_t kzNN  =  static_cast<Float_t>(triggerPosition->At(5)) ; 
+    
+    Float_t enMax       = 0. ;
+    Float_t phEnMax     = 0. ;
+    Float_t etaMax      = 0.5 ;
+    Float_t phiMax      = 0. ; 
+    Float_t phEtaMax    = 0.5 ;
+    Float_t phPhiMax    = 0. ; 
+    
+    TVector3 vpos22(kx22, ky22, kz22) ;
+    TVector3 vposNN(kxNN, kyNN, kzNN) ;
+    Float_t eta22 = vpos22.Eta() ; 
+    Float_t phi22 = vpos22.Phi() * TMath::RadToDeg() + 360. ; 
+    Float_t etaNN = vposNN.Eta() ; 
+    Float_t phiNN = vposNN.Phi() * TMath::RadToDeg() + 360. ; 
+    
+    Int_t      icaloCluster ; 
+    
+    // loop over the Calorimeters Clusters
+    Float_t cluEnergy = 0;
+    Int_t labelmax = -5;
+    for(icaloCluster = 0 ; icaloCluster < numberOfCaloClusters ; icaloCluster++) {
+
+      AliESDCaloCluster * cluster = fESD->GetCaloCluster(icaloCluster) ;
+
+      if (cluster && ( (fCalorimeter == "PHOS" && cluster->IsPHOS())  ||  
+                      (fCalorimeter == "EMCAL" && cluster->IsEMCAL()))) {
+
+       cluEnergy = cluster->E() ; 
+       Float_t pos[3] ;
+       TVector3 vpos ;
+       
+       cluster->GetPosition( pos ) ;
+       
+       if ( cluEnergy > enMax) { 
+         enMax = cluEnergy ; 
+         vpos.SetXYZ(pos[0], pos[1], pos[2]) ; 
+         etaMax = vpos.Eta() ; 
+         phiMax = vpos.Phi() ; 
+         labelmax = cluster->GetLabel();
+       }
+       
+       Double_t * pid = cluster->GetPid() ;
+       
+       if(pid[AliPID::kPhoton] > 0.9) {
+         if ( cluEnergy > phEnMax) { 
+           phEnMax = cluEnergy ; 
+           vpos.SetXYZ(pos[0], pos[1], pos[2]) ; 
+           phEtaMax = vpos.Eta() ; 
+           phPhiMax = vpos.Phi() ; 
+         }
+       }
+      }//if cluster
+    }//CaloCluster loop
+
+    if(labelmax < stack->GetNtrack() && labelmax >= 0 ){
+      TParticle * particle = stack->Particle(labelmax); 
+      Float_t ptgen = particle->Energy();
+      fNtTrigger22->Fill(ka22, ka22O, ptgen, enMax, phEnMax, eta22, phi22, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
+      fNtTriggerNN->Fill(kaNN, kaNNO, ptgen, enMax, phEnMax, etaNN, phiNN, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
+    }
+    else AliDebug(1, Form("Wrong label %d, ntrack %d, Emax %f ",labelmax, stack->GetNtrack(), phEnMax));
+  }//If trigger arrays filled
+    
+  PostData(0, fOutputContainer);
+  
+}
+
+
+//______________________________________________________________________________
+//void AliAnaCaloTriggerMC::Terminate(Option_t *) const
+//{
+//  // Processing when the event loop is ended
+//
+//}
diff --git a/PWG4/PartCorrDep/AliAnaCaloTriggerMC.h b/PWG4/PartCorrDep/AliAnaCaloTriggerMC.h
new file mode 100755 (executable)
index 0000000..4a8a254
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef ALIANACALOTRIGGERMC_H
+#define ALIANACALOTRIGGERMC_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+//______________________________________________________________________________
+// An analysis task to check the trigger data in ESD with MC data
+// Creates an ntuple for 2x2 and NxN triggers
+// Each ntuple connects the maximum trigger amplitudes 
+// and its positions with reconstructed clusters and MC
+//
+//*-- Yves Schutz (CERN) & Gustavo Conesa Balbastre (INFN-LNF)
+//////////////////////////////////////////////////////////////////////////////
+
+#include "AliAnalysisTask.h"  
+
+class TFile ;
+class TNtuple ;
+class TH1D ; 
+class TH1I ; 
+class TChain;
+
+class AliMCEvent ;
+class AliESDEvent ; 
+
+class AliAnaCaloTriggerMC : public AliAnalysisTask {
+
+public:
+  AliAnaCaloTriggerMC();
+  AliAnaCaloTriggerMC(const char *name) ;
+  AliAnaCaloTriggerMC(const AliAnaCaloTriggerMC & trig) ;
+  AliAnaCaloTriggerMC & operator=(const AliAnaCaloTriggerMC& source);
+  virtual ~AliAnaCaloTriggerMC() ;
+   
+  virtual void Exec(Option_t * opt = "") ;
+  virtual void ConnectInputData(Option_t *);
+  virtual void CreateOutputObjects();
+//  virtual void Terminate(Option_t * opt = "") const ;
+
+  TString GetCalorimeter()     const   {return fCalorimeter ; }
+  void    SetCalorimeter(TString calo) {fCalorimeter = calo ; }
+
+private:
+  TChain   * fChain ;            //!pointer to the analyzed TTree or TChain
+  AliESDEvent  * fESD ;              //! Declaration of leave types
+
+  TObjArray * fOutputContainer ; //! output data container
+
+  TString fCalorimeter ; // "PHOS" or "EMCAL"
+
+  // Histograms
+  TNtuple * fNtTrigger22 ; //Ntuple with 2x2 max dig amplitude and MC particle and cluster energy, and positions.
+  TNtuple * fNtTriggerNN ; //Ntuple with NxN max dig amplitude  and MC particle and cluster energy, and positions.
+
+  ClassDef(AliAnaCaloTriggerMC, 1); // a photon analysis task 
+};
+#endif // ALIANACALOTRIGGERMC_H
diff --git a/PWG4/PartCorrDep/AliAnaExample.cxx b/PWG4/PartCorrDep/AliAnaExample.cxx
new file mode 100755 (executable)
index 0000000..f77a62e
--- /dev/null
@@ -0,0 +1,374 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Example class on how to read AODCaloClusters, ESDCaloCells and AODTracks and how 
+// fill AODs with PWG4PartCorr analysis frame
+// Select the type of detector information that you want to analyze, CTS (tracking), PHOS or EMCAL
+// Select the PID custer type of the calorimeters
+// Set min momentum of the cluster/tracks
+// Fill few histograms
+//
+//-- Author: Gustavo Conesa (INFN-LNF)
+//_________________________________________________________________________
+
+
+// --- ROOT system ---
+//#include "Riostream.h"
+#include "TClonesArray.h"
+#include "TParticle.h"
+
+//---- AliRoot system ----
+#include "AliAnaExample.h"
+#include "AliCaloTrackReader.h"
+#include "AliLog.h"
+#include "AliAODPWG4Particle.h"
+#include "AliESDCaloCells.h"
+#include "AliStack.h"
+#include "AliCaloPID.h"
+
+ClassImp(AliAnaExample)
+  
+//____________________________________________________________________________
+  AliAnaExample::AliAnaExample() : 
+    AliAnaPartCorrBaseClass(),fPdg(0),  fDetector(""), fhPt(0),fhPhi(0),fhEta(0),  fh2Pt(0),fh2Phi(0),fh2Eta(0),
+    fhNCells(0), fhAmplitude(0)
+{
+  //Default Ctor
+
+  //Initialize parameters
+  InitParameters();
+}
+
+//____________________________________________________________________________
+AliAnaExample::AliAnaExample(const AliAnaExample & ex) :   
+  AliAnaPartCorrBaseClass(ex), fPdg(ex.fPdg), fDetector(ex.fDetector), fhPt(ex.fhPt),  fhPhi(ex.fhPhi),fhEta(ex.fhEta), 
+  fh2Pt(ex.fh2Pt),  fh2Phi(ex.fh2Phi),fh2Eta(ex.fh2Eta), fhNCells(ex.fhNCells), fhAmplitude(ex.fhAmplitude)
+{
+  // cpy ctor
+  
+}
+
+//_________________________________________________________________________
+AliAnaExample & AliAnaExample::operator = (const AliAnaExample & ex)
+{
+  // assignment operator
+
+  if(this == &ex)return *this;
+  ((AliAnaPartCorrBaseClass *)this)->operator=(ex);
+  fPdg = ex.fPdg;
+  fDetector = ex.fDetector;
+  fhPt = ex.fhPt;
+  fhPhi = ex.fhPhi;
+  fhEta = ex.fhEta;
+  fh2Pt = ex.fh2Pt;
+  fh2Phi = ex.fh2Phi;
+  fh2Eta = ex.fh2Eta;
+  fhNCells = ex.fhNCells;
+  fhAmplitude = ex.fhAmplitude;
+
+  return *this;
+
+}
+
+// //____________________________________________________________________________
+// AliAnaExample::~AliAnaExample() 
+// {
+//   // Remove all pointers except analysis output pointers.
+
+//   ;
+// }
+
+
+//________________________________________________________________________
+TList *  AliAnaExample::GetCreateOutputObjects()
+{  
+       // Create histograms to be saved in output file and 
+       // store them in fOutputContainer
+       
+       AliDebug(1,"Init parton histograms");
+       
+       TList * outputContainer = new TList() ; 
+       outputContainer->SetName("ExampleHistos") ; 
+       
+       Int_t nptbins  = GetHistoNPtBins();
+       Int_t nphibins = GetHistoNPhiBins();
+       Int_t netabins = GetHistoNEtaBins();
+       Float_t ptmax  = GetHistoPtMax();
+       Float_t phimax = GetHistoPhiMax();
+       Float_t etamax = GetHistoEtaMax();
+       Float_t ptmin  = GetHistoPtMin();
+       Float_t phimin = GetHistoPhiMin();
+       Float_t etamin = GetHistoEtaMin();      
+       
+       fhPt  = new TH1F ("hPt","p_T distribution", nptbins,ptmin,ptmax); 
+       fhPt->SetXTitle("p_{T} (GeV/c)");
+       outputContainer->Add(fhPt);
+       
+       fhPhi  = new TH1F ("hPhi","#phi distribution",nphibins,phimin,phimax); 
+       fhPhi->SetXTitle("#phi (rad)");
+       outputContainer->Add(fhPhi);
+       
+       fhEta  = new TH1F ("hEta","#eta distribution",netabins,etamin,etamax); 
+       fhEta->SetXTitle("#eta ");
+       outputContainer->Add(fhEta);
+       
+       if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC) {
+               
+               //Calo cells
+               fhNCells  = new TH1F ("hNCells","# cells per event", 100,0,1000); 
+               fhNCells->SetXTitle("n cells");
+               outputContainer->Add(fhNCells);
+               
+               fhAmplitude  = new TH1F ("hAmplitude","#eta distribution", 100,0,1000); 
+               fhAmplitude->SetXTitle("Amplitude ");
+               outputContainer->Add(fhAmplitude);
+       } 
+       
+       if(IsDataMC()){
+               fh2Pt  = new TH2F ("h2Pt","p_T distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
+               fh2Pt->SetXTitle("p_{T,rec} (GeV/c)");
+               fh2Pt->SetYTitle("p_{T,gen} (GeV/c)");
+               outputContainer->Add(fh2Pt);
+               
+               fh2Phi  = new TH2F ("h2Phi","#phi distribution, reconstructed vs generated", nphibins,phimin,phimax, nphibins,phimin,phimax); 
+               fh2Phi->SetXTitle("#phi_{rec} (rad)");
+               fh2Phi->SetYTitle("#phi_{gen} (rad)");
+               outputContainer->Add(fh2Phi);
+               
+               fh2Eta  = new TH2F ("h2Eta","#eta distribution, reconstructed vs generated", netabins,etamin,etamax,netabins,etamin,etamax); 
+               fh2Eta->SetXTitle("#eta_{rec} ");
+               fh2Eta->SetYTitle("#eta_{gen} ");
+               outputContainer->Add(fh2Eta);
+               
+       }
+       return outputContainer;
+}
+
+ //__________________________________________________
+void AliAnaExample::InitParameters()
+{ 
+  //Initialize the parameters of the analysis.
+  SetOutputAODClassName("AliAODPWG4Particle");
+  SetOutputAODName("example");
+  fPdg = 22; //Keep photons
+  fDetector = "PHOS";
+  
+}
+
+//__________________________________________________________________
+void AliAnaExample::Print(const Option_t * opt) const
+{
+  //Print some relevant parameters set for the analysis
+  if(! opt)
+    return;
+  
+  printf("Min Pt = %3.2f\n", GetMinPt());
+  printf("Max Pt = %3.2f\n", GetMaxPt());
+  printf("Select clusters with pdg %d \n",fPdg);
+  printf("Select detector %s \n",fDetector.Data());
+  
+} 
+
+//__________________________________________________________________
+void  AliAnaExample::MakeAnalysisFillAOD() 
+{
+       //Do analysis and fill aods
+       
+       //Some prints
+       if(GetDebug() > 0){
+               if(fDetector == "EMCAL" && GetAODEMCAL())printf("Example : in EMCAL aod entries %d\n", GetAODEMCAL()->GetEntriesFast());
+               if(fDetector == "CTS" && GetAODCTS())printf("Example : in CTS aod entries %d\n", GetAODCTS()->GetEntriesFast());
+               if(fDetector == "PHOS" && GetAODPHOS())printf("Example : in PHOS aod entries %d\n", GetAODPHOS()->GetEntriesFast());
+       }
+       
+       //Get List with tracks or clusters  
+       TClonesArray * partList = new TClonesArray;
+       if(fDetector == "CTS") partList = GetAODCTS();
+       else if(fDetector == "EMCAL") partList = GetAODEMCAL();
+       else if(fDetector == "PHOS") partList = GetAODPHOS();
+       
+       if(!partList || partList->GetEntriesFast() == 0) return ;
+       
+       //Fill AODCaloClusters and AODParticle with PHOS/EMCAL aods
+       if(fDetector == "EMCAL" || fDetector == "PHOS"){
+               
+               //WORK WITH CALOCLUSTERS 
+               if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC){ 
+                       ConnectAODCaloClusters(); //Do Only when filling AODCaloClusters 
+                       if(GetDebug() > 0) printf("Example: in calo clusters aod entries %d\n", GetAODCaloClusters()->GetEntriesFast());
+               }
+               //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++){
+                       
+                       AliAODCaloCluster * calo =  (AliAODCaloCluster*) (partList->At(i));
+                       
+                       //Fill AODCaloClusters  
+                       if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC) 
+                               AddAODCaloCluster(AliAODCaloCluster(*(calo)));
+                       
+                       //Fill AODParticle after some selection
+                       calo->GetMomentum(mom,v);
+                       Int_t pdg = fPdg;
+                       
+                       if(IsCaloPIDOn()){
+                               Double_t pid[13];
+                               calo->GetPID(pid);
+                               pdg = GetCaloPID()->GetPdg(fDetector,pid,mom.E());
+                               //pdg = GetCaloPID()->GetPdg(fDetector,mom,
+                               //                calo->GetM02(), calo->GetM02(),
+                               //                calo->GetDispersion(), 0, 0); 
+                       }
+                       
+                       //Acceptance selection   
+                       Bool_t in = kTRUE;
+                       if(IsFidutialCutOn())
+                               in =  GetFidutialCut()->IsInFidutialCut(mom,fDetector) ;
+                       
+                       if(GetDebug() > 1) printf("cluster pt %2.2f, phi %2.2f, pdg %d, in fidutial cut %d \n",mom.Pt(), mom.Phi(), pdg, in);
+                       
+                       //Select cluster if momentum, pdg and acceptance are good
+                       if(mom.Pt() > GetMinPt() && pdg ==fPdg && in) {
+                               AliAODPWG4Particle ph = AliAODPWG4Particle(mom);
+                               //AddAODParticleCorrelation(AliAODPWG4ParticleCorrelation(mom));
+                               ph.SetLabel(calo->GetLabel(0));
+                               ph.SetPdg(pdg);
+                               ph.SetDetector(fDetector);
+                               AddAODParticle(ph);
+                       }//selection
+               }//loop
+               
+               if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC) {
+                       //WORK WITH ESDCALOCELLS
+                       //Don't connect in the same analysis PHOS and EMCAL cells.
+                       
+                       AliESDCaloCells * esdCell = new AliESDCaloCells ;
+                       if(fDetector == "PHOS") {
+                               ConnectAODPHOSCells(); //Do Only when filling AODCaloCells
+                               esdCell = (AliESDCaloCells *) GetPHOSCells();
+                       }
+                       else  {
+                               ConnectAODEMCALCells(); //Do Only when filling AODCaloCells
+                               esdCell = (AliESDCaloCells *) GetEMCALCells();
+                       }
+                       
+                       if(!esdCell) AliFatal("No CELLS available for analysis");
+                       
+                       //Some prints
+                       if(GetDebug() > 0 && esdCell )
+                               printf("Example : in ESD %s cell entries %d\n", fDetector.Data(), esdCell->GetNumberOfCells());    
+                       
+                       //Fill AODCells in file
+                       Int_t ncells = esdCell->GetNumberOfCells() ;
+                       GetAODCaloCells()->CreateContainer(ncells);
+                       
+                       GetAODCaloCells()->SetType((AliAODCaloCells::AODCells_t) esdCell->GetType());
+                       
+                       for (Int_t iCell = 0; iCell < ncells; iCell++) {      
+                               if(GetDebug() > 2)  printf("cell : amp %f, absId %d,  time %f\n", esdCell->GetAmplitude(iCell), esdCell->GetCellNumber(iCell), esdCell->GetTime(iCell));
+                               
+                               GetAODCaloCells()->SetCell(iCell,esdCell->GetCellNumber(iCell),esdCell->GetAmplitude(iCell));
+                       }
+                       GetAODCaloCells()->Sort();
+               } 
+       }//cluster-cell analysis
+       else if(fDetector == "CTS"){ //Track analysis
+               //Fill AODParticle with CTS aods
+               TVector3 p3;
+               for(Int_t i = 0; i < GetAODCTS()->GetEntriesFast(); i++){
+                       
+                       AliAODTrack * track =  (AliAODTrack*) (GetAODCTS()->At(i));
+                       
+                       //Fill AODParticle after some selection       
+                       Double_t mom[3] = {track->Px(),track->Py(),track->Pz()};
+                       p3.SetXYZ(mom[0],mom[1],mom[2]);
+                       
+                       //Acceptance selection
+                       Bool_t in =  GetFidutialCut()->IsInFidutialCut(mom,"CTS") ;
+                       if(GetDebug() > 1) printf("track pt %2.2f, phi %2.2f, in fidutial cut %d\n",p3.Pt(), p3.Phi(), in);
+                       if(p3.Pt() > GetMinPt() && in) {
+                               AliAODPWG4Particle tr = AliAODPWG4Particle(mom[0],mom[1],mom[2],0);
+                               tr.SetDetector("CTS");
+                               AddAODParticle(tr);
+                       }//selection
+               }//loop
+       }//CTS analysis
+       
+       if(GetDebug() > 0) {
+               if(fDetector!="CTS" && GetReader()->GetDataType()!= AliCaloTrackReader::kMC) 
+                       printf("Example: final aod calocluster entries %d\n", GetAODCaloClusters()->GetEntriesFast());
+               printf("Example: final aod branch entries %d\n", GetOutputAODBranch()->GetEntriesFast());  
+               if(fDetector!="CTS" && GetReader()->GetDataType()!= AliCaloTrackReader::kMC) 
+                       printf("Example: final aod cell  entries %d\n", GetAODCaloCells()->GetNumberOfCells());
+       }
+} 
+
+//__________________________________________________________________
+void  AliAnaExample::MakeAnalysisFillHistograms() 
+{
+       //Do analysis and fill histograms
+       
+       //Loop on stored AODParticles
+       Int_t naod = GetOutputAODBranch()->GetEntriesFast();
+       if(GetDebug() > 0) printf("histo aod branch entries %d\n", naod);
+       for(Int_t iaod = 0; iaod < naod ; iaod++){
+               AliAODPWG4Particle* ph =  (AliAODPWG4Particle*) (GetOutputAODBranch()->At(iaod));
+               
+               fhPt->Fill(ph->Pt());
+               fhPhi->Fill(ph->Phi());
+               fhEta->Fill(ph->Eta());
+               
+               if(IsDataMC()){
+                       //Play with the MC stack if available
+                       AliStack * stack =  GetMCStack() ;
+                       
+                       if(ph->GetLabel() < 0 || !stack) {
+                               printf("*** bad label or no stack ***:  label %d \n", ph->GetLabel());
+                               continue;
+                       }
+                       
+                       if(ph->GetLabel() >=  stack->GetNtrack()) {
+                               printf("*** large label ***:  label %d, n tracks %d \n", ph->GetLabel(), stack->GetNtrack());
+                               continue ;
+                       }
+                       
+                       TParticle * mom = GetMCStack()->Particle(ph->GetLabel());
+                       
+                       fh2Pt->Fill(ph->Pt(), mom->Pt());
+                       fh2Phi->Fill(ph->Phi(), mom->Phi());
+                       fh2Eta->Fill(ph->Eta(), mom->Eta());
+               }//Work with stack also
+       }// aod branch loop
+       
+       // CaloCells histograms
+       if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC) {
+               if(GetAODCaloCells()){
+                       
+                       Int_t ncells = GetAODCaloCells()->GetNumberOfCells();
+                       fhNCells->Fill(ncells) ;
+                       
+                       for (Int_t iCell = 0; iCell < ncells; iCell++) {      
+                               if(GetDebug() > 2)  printf("cell : amp %f, absId %d \n", GetAODCaloCells()->GetAmplitude(iCell), GetAODCaloCells()->GetCellNumber(iCell));
+                               fhAmplitude->Fill(GetAODCaloCells()->GetAmplitude(iCell));
+                       }
+               }//calo cells container exist
+       }
+}
diff --git a/PWG4/PartCorrDep/AliAnaExample.h b/PWG4/PartCorrDep/AliAnaExample.h
new file mode 100755 (executable)
index 0000000..cac88c1
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef ALIANAEXAMPLE_H
+#define ALIANAEXAMPLE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Example class on how to read AODCaloClusters, ESDCaloCells and AODTracks and how 
+// fill AODs with PWG4PartCorr analysis frame
+// Select the type of detector information that you want to analyze, CTS (tracking), PHOS or EMCAL
+// Select the PID custer type of the calorimeters
+// Set min momentum of the cluster/tracks
+// Fill few histograms
+//
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+#include "TH2F.h" 
+#include "AliAnaPartCorrBaseClass.h"
+class AliAnaExample : public AliAnaPartCorrBaseClass {
+       
+  public: 
+       
+       AliAnaExample() ; // default ctor
+       AliAnaExample(const AliAnaExample & g) ; // cpy ctor
+       AliAnaExample & operator = (const AliAnaExample & g) ;//cpy assignment
+       virtual ~AliAnaExample() {;} //virtual dtor
+              
+       TList * GetCreateOutputObjects();
+       
+       void InitParameters();
+       
+       void Print(const Option_t * opt) const;
+       
+       void MakeAnalysisFillAOD()  ;
+       
+       void MakeAnalysisFillHistograms() ; 
+       Int_t GetPdg() const {return fPdg ;}
+       void SetPdg( Int_t pdg ) {fPdg = pdg; }
+
+       TString GetDetector() const {return fDetector ;}
+       void SetDetector( TString calo ) {fDetector = calo; }
+
+ private:
+       
+       Int_t  fPdg ; //identified particle id
+       TString fDetector ; //detector selection
+       //Histograms
+       //CaloClusters 
+       TH1F * fhPt; //! pT distribution
+       TH1F * fhPhi; //! phi distribution
+       TH1F * fhEta; //! eta distribution
+       TH2F * fh2Pt; //!pT distribution, reconstructed vs generated
+       TH2F * fh2Phi; //! phi distribution, reconstructed vs generated
+       TH2F * fh2Eta; //! eta distribution, reconstructed vs generated
+       //Calo Cells
+       TH1F * fhNCells; //! Number of towers/crystals with signal
+       TH1F * fhAmplitude; //! Amplitude measured in towers/crystals
+       ClassDef(AliAnaExample,1)
+ } ;
+
+
+#endif //ALIANAEXAMPLE_H
+
+
+
diff --git a/PWG4/PartCorrDep/AliAnaParticleHadronCorrelation.cxx b/PWG4/PartCorrDep/AliAnaParticleHadronCorrelation.cxx
new file mode 100755 (executable)
index 0000000..bc5c925
--- /dev/null
@@ -0,0 +1,542 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Class for the analysis of particle - hadron correlations
+// Particle (for example direct gamma) must be found in a previous analysis 
+//-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+#include "TH2F.h"
+
+//---- ANALYSIS system ----
+#include "AliLog.h"
+#include "AliNeutralMesonSelection.h" 
+#include "AliAnaParticleHadronCorrelation.h" 
+#include "AliCaloTrackReader.h"
+#include "AliCaloPID.h"
+#include "AliAODPWG4ParticleCorrelation.h"
+
+ClassImp(AliAnaParticleHadronCorrelation)
+
+
+//____________________________________________________________________________
+  AliAnaParticleHadronCorrelation::AliAnaParticleHadronCorrelation() : 
+    AliAnaPartCorrBaseClass(),
+    fDeltaPhiMaxCut(0.), fDeltaPhiMinCut(0.), 
+    fhPhiCharged(0), fhPhiNeutral(0), fhEtaCharged(0), fhEtaNeutral(0), 
+    fhDeltaPhiCharged(0), fhDeltaPhiNeutral(0), 
+    fhDeltaEtaCharged(0), fhDeltaEtaNeutral(0),
+    fhDeltaPhiChargedPt(0), fhDeltaPhiNeutralPt(0), 
+    fhPtImbalanceNeutral(0), fhPtImbalanceCharged(0)
+{
+  //Default Ctor
+  //Initialize parameters
+  InitParameters();
+}
+
+//____________________________________________________________________________
+AliAnaParticleHadronCorrelation::AliAnaParticleHadronCorrelation(const AliAnaParticleHadronCorrelation & g) :   
+  AliAnaPartCorrBaseClass(g),
+  fDeltaPhiMaxCut(g.fDeltaPhiMaxCut), fDeltaPhiMinCut(g.fDeltaPhiMinCut), 
+  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), 
+  fhPtImbalanceNeutral(g.fhPtImbalanceNeutral), 
+  fhPtImbalanceCharged(g.fhPtImbalanceCharged)
+{
+  // 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 ; 
+
+  fhPhiCharged = source.fhPhiCharged ; fhPhiNeutral = source.fhPhiNeutral ; 
+  fhEtaCharged = source.fhEtaCharged ; fhEtaNeutral = source.fhEtaNeutral ; 
+  fhDeltaPhiCharged = source.fhDeltaPhiCharged ;  
+  fhDeltaPhiNeutral = source.fhDeltaPhiNeutral ; 
+  fhDeltaPhiNeutralPt = source.fhDeltaPhiNeutralPt ; 
+  fhDeltaEtaCharged = source.fhDeltaEtaCharged ; 
+  fhDeltaEtaNeutral = source.fhDeltaEtaNeutral ; 
+  fhDeltaPhiChargedPt = source.fhDeltaPhiChargedPt ;
+
+  fhPtImbalanceNeutral = source.fhPtImbalanceNeutral ; 
+  fhPtImbalanceCharged = source.fhPtImbalanceCharged ; 
+
+  return *this;
+
+}
+
+//________________________________________________________________________
+TList *  AliAnaParticleHadronCorrelation::GetCreateOutputObjects()
+{  
+       
+       // Create histograms to be saved in output file and 
+       // store them in fOutputContainer
+       TList * outputContainer = new TList() ; 
+       outputContainer->SetName("CorrelationHistos") ; 
+       
+       Int_t nptbins  = GetHistoNPtBins();
+       Int_t nphibins = GetHistoNPhiBins();
+       Int_t netabins = GetHistoNEtaBins();
+       Float_t ptmax  = GetHistoPtMax();
+       Float_t phimax = GetHistoPhiMax();
+       Float_t etamax = GetHistoEtaMax();
+       Float_t ptmin  = GetHistoPtMin();
+       Float_t phimin = GetHistoPhiMin();
+       Float_t etamin = GetHistoEtaMin();      
+       
+       //Correlation with charged hadrons
+       if(GetReader()->IsCTSSwitchedOn()) {
+               fhPhiCharged  = new TH2F
+               ("PhiCharged","#phi_{h^{#pm}}  vs p_{T trigger}",
+                nptbins,ptmin,ptmax,nphibins,phimin,phimax); 
+               fhPhiCharged->SetYTitle("#phi_{h^{#pm}} (rad)");
+               fhPhiCharged->SetXTitle("p_{T trigger} (GeV/c)");
+               
+               fhEtaCharged  = new TH2F
+               ("EtaCharged","#eta_{h^{#pm}}  vs p_{T trigger}",
+                nptbins,ptmin,ptmax,netabins,etamin,etamax); 
+               fhEtaCharged->SetYTitle("#eta_{h^{#pm}} (rad)");
+               fhEtaCharged->SetXTitle("p_{T trigger} (GeV/c)");
+               
+               fhDeltaPhiCharged  = new TH2F
+               ("DeltaPhiCharged","#phi_{trigger} - #phi_{h^{#pm}} vs p_{T trigger}",
+               nptbins,ptmin,ptmax,200,0,6.4); 
+               fhDeltaPhiCharged->SetYTitle("#Delta #phi");
+               fhDeltaPhiCharged->SetXTitle("p_{T trigger} (GeV/c)");
+               
+               fhDeltaPhiChargedPt  = new TH2F
+               ("DeltaPhiChargedPt","#phi_{trigger} - #phi_{#p^{#pm}i} vs p_{T h^{#pm}}",
+                nptbins,ptmin,ptmax,200,0,6.4);
+               fhDeltaPhiChargedPt->SetYTitle("#Delta #phi");
+               fhDeltaPhiChargedPt->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); 
+               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,1000,0.,1.2); 
+               fhPtImbalanceCharged->SetYTitle("z_{trigger h^{#pm}}");
+               fhPtImbalanceCharged->SetXTitle("p_{T trigger}");
+               
+               outputContainer->Add(fhPhiCharged) ;
+               outputContainer->Add(fhEtaCharged) ;
+               outputContainer->Add(fhDeltaPhiCharged) ; 
+               outputContainer->Add(fhDeltaEtaCharged) ;
+               outputContainer->Add(fhPtImbalanceCharged) ;
+               outputContainer->Add(fhDeltaPhiChargedPt) ;
+       }  //Correlation with charged hadrons
+       
+       //Correlation with neutral hadrons
+       if(GetReader()->IsEMCALSwitchedOn() || GetReader()->IsPHOSSwitchedOn()){
+               
+               fhPhiNeutral  = new TH2F
+               ("PhiNeutral","#phi_{#pi^{0}}  vs p_{T trigger}",
+               nptbins,ptmin,ptmax,nphibins,phimin,phimax); 
+               fhPhiNeutral->SetYTitle("#phi_{#pi^{0}} (rad)");
+               fhPhiNeutral->SetXTitle("p_{T trigger} (GeV/c)");
+               
+               fhEtaNeutral  = new TH2F
+               ("EtaNeutral","#eta_{#pi^{0}}  vs p_{T trigger}",
+                nptbins,ptmin,ptmax,netabins,etamin,etamax); 
+               fhEtaNeutral->SetYTitle("#eta_{#pi^{0}} (rad)");
+               fhEtaNeutral->SetXTitle("p_{T trigger} (GeV/c)");
+               
+               fhDeltaPhiNeutral  = new TH2F
+               ("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,200,0,6.4); 
+               fhDeltaPhiNeutralPt->SetYTitle("#Delta #phi");
+               fhDeltaPhiNeutralPt->SetXTitle("p_{T trigger} (GeV/c)");
+               
+               fhDeltaEtaNeutral  = new TH2F
+               ("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,1000,0.,1.2); 
+               fhPtImbalanceNeutral->SetYTitle("z_{trigger #pi^{0}}");
+               fhPtImbalanceNeutral->SetXTitle("p_{T trigger}");
+               
+               outputContainer->Add(fhPhiNeutral) ;  
+               outputContainer->Add(fhEtaNeutral) ;   
+               outputContainer->Add(fhDeltaPhiNeutral) ; 
+               outputContainer->Add(fhDeltaEtaNeutral) ; 
+               outputContainer->Add(fhPtImbalanceNeutral) ;
+               
+               
+               //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)) ;
+               }
+               
+       }//Correlation with neutral hadrons
+       
+       return outputContainer;
+}
+
+ //____________________________________________________________________________
+void AliAnaParticleHadronCorrelation::InitParameters()
+{
+  //Initialize the parameters of the analysis.
+  SetInputAODName("photons");
+  SetPtCutRange(2,300);
+  fDeltaPhiMinCut = 1.5 ;
+  fDeltaPhiMaxCut = 4.5 ;
+
+}
+
+//__________________________________________________________________
+void AliAnaParticleHadronCorrelation::Print(const Option_t * opt) const
+{
+
+  //Print some relevant parameters set for the analysis
+  if(! opt)
+    return;
+  
+  Info("*** Print *** ", "%s %s", GetName(), GetTitle() ) ;
+  printf("pT Hadron       >    %2.2f\n", GetMinPt()) ; 
+  printf("pT Hadron       <    %2.2f\n", GetMaxPt()) ; 
+  printf("Phi trigger particle-Hadron      <     %3.2f\n", fDeltaPhiMaxCut) ; 
+  printf("Phi trigger particle-Hadron      >     %3.2f\n", fDeltaPhiMinCut) ;
+  
+
+} 
+
+//____________________________________________________________________________
+void  AliAnaParticleHadronCorrelation::MakeAnalysisFillAOD()  
+{  
+       //Particle-Hadron Correlation Analysis, fill AODs
+       
+       if(!GetInputAODBranch())
+               AliFatal(Form("ParticleHadronCorrelation::FillAOD: No input particles in AOD with name branch < %s > \n",GetInputAODName().Data()));
+       
+       if(GetDebug() > 1){
+               printf("Begin hadron correlation analysis, fill AODs \n");
+               printf("In particle branch aod entries %d\n", GetInputAODBranch()->GetEntriesFast());
+               printf("In CTS aod entries %d\n", GetAODCTS()->GetEntriesFast());
+               printf("In EMCAL aod entries %d\n", GetAODEMCAL()->GetEntriesFast());
+               printf("In PHOS aod entries %d\n", GetAODPHOS()->GetEntriesFast());
+       }
+       
+       //Loop on stored AOD particles, trigger
+       Int_t naod = GetInputAODBranch()->GetEntriesFast();
+       for(Int_t iaod = 0; iaod < naod ; iaod++){
+               AliAODPWG4ParticleCorrelation* particle =  (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(iaod));
+               //Make correlation with charged hadrons
+               if(GetReader()->IsCTSSwitchedOn() )
+                       MakeChargedCorrelation(particle, (TSeqCollection*)GetAODCTS(),kFALSE);
+               
+               //Make correlation with neutral pions
+               //Trigger particle in PHOS, correlation with EMCAL
+               if(particle->GetDetector()=="PHOS" && GetReader()->IsEMCALSwitchedOn() && GetAODEMCAL()->GetEntriesFast() > 0)
+                       MakeNeutralCorrelation(particle,(TSeqCollection*)GetAODEMCAL(),kFALSE);
+               //Trigger particle in EMCAL, correlation with PHOS
+               else if(particle->GetDetector()=="EMCAL" && GetReader()->IsPHOSSwitchedOn() && GetAODPHOS()->GetEntriesFast() > 0)
+                       MakeNeutralCorrelation(particle,(TSeqCollection*)GetAODPHOS(),kFALSE);
+               //Trigger particle in CTS, correlation with PHOS, EMCAL and CTS
+               else if(particle->GetDetector()=="CTS" ){
+                       if(GetReader()->IsPHOSSwitchedOn() && GetAODPHOS()->GetEntriesFast() > 0) 
+                               MakeNeutralCorrelation(particle,(TSeqCollection*)GetAODPHOS(),kFALSE);
+                       if(GetReader()->IsEMCALSwitchedOn() && GetAODEMCAL()->GetEntriesFast() > 0) 
+                               MakeNeutralCorrelation(particle,(TSeqCollection*)GetAODEMCAL(),kFALSE);
+               }
+               
+       }//Aod branch loop
+       
+       if(GetDebug() > 1) printf("End hadron correlation analysis, fill AODs \n");
+       
+}
+
+//____________________________________________________________________________
+void  AliAnaParticleHadronCorrelation::MakeAnalysisFillHistograms()  
+{  
+       //Particle-Hadron Correlation Analysis, fill histograms
+       
+       if(!GetInputAODBranch())
+               AliFatal(Form("ParticleHadronCorrelation::FillHistos: No input particles in AOD with name branch < %s > \n",GetInputAODName().Data()));
+       
+       if(GetDebug() > 1){
+               printf("Begin hadron correlation analysis, fill histograms \n");
+               printf("In particle branch aod entries %d\n", GetInputAODBranch()->GetEntriesFast());
+       }
+       
+       //Loop on stored AOD particles
+       Int_t naod = GetInputAODBranch()->GetEntriesFast();
+       for(Int_t iaod = 0; iaod < naod ; iaod++){
+               AliAODPWG4ParticleCorrelation* particle =  (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(iaod));
+               
+               if(GetDebug() > 1){
+                       printf("Particle %d, In Track Refs  entries %d\n", iaod, (particle->GetRefTracks())->GetEntriesFast());
+                       printf("Particle %d, In Cluster Refs entries %d\n",iaod, (particle->GetRefClusters())->GetEntriesFast());
+               }
+               
+               //Make correlation with charged hadrons
+               if((particle->GetRefTracks())->GetEntriesFast() > 0)
+                       MakeChargedCorrelation(particle, (TSeqCollection*) (particle->GetRefTracks()),kTRUE);
+               
+               //Make correlation with neutral pions
+               if((particle->GetRefClusters())->GetEntriesFast() > 0)
+                       MakeNeutralCorrelation(particle,  (TSeqCollection*) (particle->GetRefClusters()), kTRUE);
+               
+       }//Aod branch loop
+       
+       if(GetDebug() > 1) printf("End hadron correlation analysis, fill histograms \n");
+       
+}
+
+//____________________________________________________________________________
+void  AliAnaParticleHadronCorrelation::MakeChargedCorrelation(AliAODPWG4ParticleCorrelation *aodParticle, TSeqCollection* pl, const Bool_t bFillHisto)
+{  
+  // Charged Hadron Correlation Analysis
+  if(GetDebug() > 1)printf("Make trigger particle - charged hadron correlation \n");
+  
+  Double_t ptTrig  = aodParticle->Pt();
+  Double_t phiTrig = aodParticle->Phi();
+  Double_t pt   = -100.;
+  Double_t rat  = -100.; 
+  Double_t phi  = -100. ;
+  Double_t eta  = -100. ;
+  Double_t p[3];
+  
+  //Track loop, select tracks with good pt, phi and fill AODs or histograms
+  for(Int_t ipr = 0;ipr < pl->GetEntries() ; ipr ++ ){
+    AliAODTrack * track = (AliAODTrack *) (pl->At(ipr)) ;
+    track->GetPxPyPz(p) ;
+    TLorentzVector mom(p[0],p[1],p[2],0);
+    pt    = mom.Pt();
+    eta  = mom.Eta();
+    phi  = mom.Phi() ;
+    if(phi<0) phi+=TMath::TwoPi();
+    rat   = pt/ptTrig ;
+
+    if(IsFidutialCutOn()){
+      Bool_t in = GetFidutialCut()->IsInFidutialCut(mom,"CTS") ;
+      if(! in ) continue ;
+    }    
+
+    //Select only hadrons in pt range
+    if(pt < GetMinPt() || pt > GetMaxPt()) continue ;
+    
+    if(GetDebug() > 2)
+      printf("charged hadron: pt %f, phi %f, phi trigger %f. Cuts:  delta phi min %2.2f,  max%2.2f, pT min %2.2f \n",
+            pt,phi,phiTrig,fDeltaPhiMinCut, fDeltaPhiMaxCut, GetMinPt());
+
+    if(bFillHisto){
+      // Fill Histograms
+      fhEtaCharged->Fill(ptTrig,eta);
+      fhPhiCharged->Fill(ptTrig,phi);
+      fhDeltaEtaCharged->Fill(ptTrig,aodParticle->Eta()-eta);
+      fhDeltaPhiCharged->Fill(ptTrig,phiTrig-phi);
+      fhDeltaPhiChargedPt->Fill(pt,phiTrig-phi);
+      //Selection within angular range
+      if(((phiTrig-phi)> fDeltaPhiMinCut) && ((phiTrig-phi)<fDeltaPhiMaxCut) ){
+       if(GetDebug() > 2 ) printf("Selected charge for momentum imbalance: pt %2.2f, phi %2.2f, eta %2.2f ",pt,phi,eta);
+       fhPtImbalanceCharged->Fill(ptTrig,rat);
+      } 
+    }
+    else{
+      //Fill AODs
+      aodParticle->AddTrack(track);
+      
+    }//aod particle loop
+  }// track loop
+
+}  
+//____________________________________________________________________________
+void  AliAnaParticleHadronCorrelation::MakeNeutralCorrelation(AliAODPWG4ParticleCorrelation * aodParticle,TSeqCollection* pl, const Bool_t bFillHisto)  
+{  
+  // Neutral Pion Correlation Analysis
+  if(GetDebug() > 1) printf("Make trigger particle - neutral hadron correlation \n");
+  
+  Double_t pt = -100.;
+  Double_t rat = -100.; 
+  Double_t phi = -100. ;
+  Double_t eta = -100. ;
+  Double_t ptTrig  = aodParticle->Pt();
+  Double_t phiTrig = aodParticle->Phi();
+  Double_t etaTrig = aodParticle->Eta();
+  
+  TLorentzVector gammai;
+  TLorentzVector gammaj;
+  
+  Double_t vertex[] = {0,0,0};
+
+  if(!GetReader()->GetDataType()== AliCaloTrackReader::kMC) GetReader()->GetVertex(vertex);
+  
+  //Cluster loop, select pairs with good pt, phi and fill AODs or histograms
+  for(Int_t iclus = 0;iclus < pl->GetEntries() ; iclus ++ ){
+    AliAODCaloCluster * calo = (AliAODCaloCluster *) (pl->At(iclus)) ;
+    if(!bFillHisto){
+
+      //Cluster selection, not charged, with photon or pi0 id and in fidutial cut
+      Int_t pdg=0;
+      if(!SelectCluster(calo, vertex, gammai, pdg)) continue ;
+      
+    if(GetDebug() > 2)
+      printf("neutral cluster: pt %f, phi %f, phi trigger %f. Cuts:  delta phi min %2.2f,  max%2.2f, pT min %2.2f \n",
+            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 ;
+
+       aodParticle->AddCluster(calo);
+       if(GetDebug() > 2) printf("Correlated with selected pi0 (pid): pt %f, phi %f",gammai.Pt(),gammai.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 ++ ){
+         AliAODCaloCluster * calo2 = (AliAODCaloCluster *) (pl->At(jclus)) ;
+         
+         //Cluster selection, not charged with photon or pi0 id and in fidutial cut
+         Int_t pdgj=0;
+         if(!SelectCluster(calo2,vertex, gammaj, pdgj)) continue ;
+
+         if(pdgj == AliCaloPID::kPhoton ){
+           
+           if((gammai+gammaj).Pt() < GetMinPt() || (gammai+gammaj).Pt() > GetMaxPt()) continue ;
+           
+           //Select good pair (aperture and invariant mass)
+           if(GetNeutralMesonSelection()->SelectPair(gammai, gammaj)){
+
+             if(GetDebug() > 2 ) printf("Neutral Hadron Correlation: AOD Selected gamma pair: pt %2.2f, phi %2.2f, eta %2.2f, M %2.3f",
+                                        (gammai+gammaj).Pt(),(gammai+gammaj).Phi(),(gammai+gammaj).Eta(), (gammai+gammaj).M());
+             Int_t labels[]={calo->GetLabel(0),calo2->GetLabel(0)};
+             Float_t pid[]={0,0,0,0,0,0,1,0,0,0,0,0,0};//Pi0 weight 1
+             Float_t pos[]={(gammai+gammaj).X(), (gammai+gammaj).Y(), (gammai+gammaj).Z()};
+
+             AliAODCaloCluster *caloCluster =  new AliAODCaloCluster(0,2,labels,(gammai+gammaj).E(), pos, pid,calo->GetType(),0);
+             aodParticle->AddCluster(caloCluster);
+           }//Pair selected
+         }//if pair of gammas
+       }//2nd loop
+      }// if pdg = 22
+    }// Fill AODs
+    else{ //Fill histograms
+      
+      calo->GetMomentum(gammai,vertex);//Assume that come from vertex in straight line
+      pt  = gammai.Pt();
+      
+      if(pt < GetMinPt() || pt > GetMaxPt()) continue ;
+      
+      rat = pt/ptTrig ;
+      phi = gammai.Phi() ;
+      eta = gammai.Eta() ;
+
+      if(GetDebug() > 2 ) printf("Neutral Hadron Correlation: Histograms selected gamma pair: pt %2.2f, phi %2.2f, eta %2.2f",pt,phi,eta);
+      
+      fhEtaNeutral->Fill(ptTrig,eta);
+      fhPhiNeutral->Fill(ptTrig,phi);
+      fhDeltaEtaNeutral->Fill(ptTrig,etaTrig-eta);
+      fhDeltaPhiNeutral->Fill(ptTrig,phiTrig-phi);
+      fhDeltaPhiNeutralPt->Fill(pt,phiTrig-phi);
+      //Selection within angular range
+      if(((phiTrig-phi)> fDeltaPhiMinCut) && ((phiTrig-phi)<fDeltaPhiMaxCut) ){
+       if(GetDebug() > 2 ) printf("Selected neutral for momentum imbalance: pt %2.2f, phi %2.2f, eta %2.2f ",pt,phi,eta);
+       fhPtImbalanceNeutral->Fill(ptTrig,rat);
+      }    
+    }//Fill histograms
+  }//1st loop
+  
+}
+
+//____________________________________________________________________________
+Bool_t  AliAnaParticleHadronCorrelation::SelectCluster(AliAODCaloCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg) const {
+   //Select cluster depending on its pid and acceptance selections
+   
+   //Skip matched clusters with tracks
+  if(calo->GetNTracksMatched() > 0) {
+  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.
+     TString detector = "";
+     if(calo->IsPHOSCluster()) detector= "PHOS";
+     else if(calo->IsEMCALCluster()) detector= "EMCAL";
+
+     if(!IsCaloPIDRecalculationOn() || GetReader()->GetDataType() == AliCaloTrackReader::kMC )
+       pdg = GetCaloPID()->GetPdg(detector,calo->PID(),mom.E());//PID with weights
+     else
+       pdg = GetCaloPID()->GetPdg(detector,mom,calo);//PID recalculated
+     
+     if(GetDebug() > 1) printf("PDG of identified particle %d\n",pdg);
+     
+     //If it does not pass pid, skip
+     if(pdg != AliCaloPID::kPhoton || pdg != AliCaloPID::kPi0) {
+       return kFALSE ;
+     }
+   }
+   
+   //Check acceptance selection
+   if(IsFidutialCutOn()){
+     Bool_t in = kFALSE;
+     if(calo->IsPHOSCluster())
+       in = GetFidutialCut()->IsInFidutialCut(mom,"PHOS") ;
+     else if(calo->IsEMCALCluster())
+       in = GetFidutialCut()->IsInFidutialCut(mom,"EMCAL") ;
+     if(! in ) { return kFALSE ;}
+   }
+   
+   if(GetDebug() > 1) printf("Correlation photon selection cuts passed: pT %3.2f, pdg %d\n",mom.Pt(), pdg);
+   
+   return kTRUE;
+   
+ }
diff --git a/PWG4/PartCorrDep/AliAnaParticleHadronCorrelation.h b/PWG4/PartCorrDep/AliAnaParticleHadronCorrelation.h
new file mode 100755 (executable)
index 0000000..27333aa
--- /dev/null
@@ -0,0 +1,75 @@
+#ifndef ALIANAPARTICLEHADRONCORRELATION_H
+#define ALIANAPARTICLEHADRONCORRELATION_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Class that contains the algorithm for the analysis of particle - hadron correlations
+// Particle (for example direct gamma) must be found in a previous analysis 
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+class TH2F;
+
+// --- Analysis system ---
+#include "AliAnaPartCorrBaseClass.h"
+class AliAODPWG4ParticleCorrelation ;
+
+class AliAnaParticleHadronCorrelation : public AliAnaPartCorrBaseClass {
+
+public: 
+  
+  AliAnaParticleHadronCorrelation() ; // default ctor
+  AliAnaParticleHadronCorrelation(const AliAnaParticleHadronCorrelation & ph) ; // cpy ctor
+  AliAnaParticleHadronCorrelation & operator = (const AliAnaParticleHadronCorrelation & ph) ;//cpy assignment
+  virtual ~AliAnaParticleHadronCorrelation() {;} //virtual dtor
+
+  TList * GetCreateOutputObjects();
+
+  Double_t GetDeltaPhiMaxCut() const {return fDeltaPhiMaxCut ; }
+  Double_t GetDeltaPhiMinCut() const {return fDeltaPhiMinCut ; }
+  void SetDeltaPhiCutRange(Double_t phimin, Double_t phimax)
+  {fDeltaPhiMaxCut =phimax;  fDeltaPhiMinCut =phimin;}
+
+  void InitParameters();
+
+  void Print(const Option_t * opt) const;
+  void MakeChargedCorrelation(AliAODPWG4ParticleCorrelation * aodParticle,TSeqCollection* pl, const Bool_t bFillHisto) ;
+  void MakeNeutralCorrelation(AliAODPWG4ParticleCorrelation * aodParticle,TSeqCollection* pl, const Bool_t bFillHisto)  ;
+
+  void MakeAnalysisFillAOD()  ;
+  
+  void MakeAnalysisFillHistograms() ; 
+
+  Bool_t SelectCluster(AliAODCaloCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg) const ;
+
+  private:
+  
+  Double_t   fDeltaPhiMaxCut ;      // Minimum Delta Phi Gamma-Hadron
+  Double_t   fDeltaPhiMinCut ;      //  Maximum Delta Phi Gamma-Hadron
+
+  //Histograms
+  TH2F * fhPhiCharged  ; //! Phi distribution of selected charged particles
+  TH2F * fhPhiNeutral   ;  //! Phi distribution of selected neutral particles
+  TH2F * fhEtaCharged  ; //! Eta distribution of selected charged particles
+  TH2F * fhEtaNeutral   ; //! Eta distribution of selected 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 * fhPtImbalanceNeutral  ; //! Trigger particle - neutral hadron momentum imbalance histogram 
+  TH2F * fhPtImbalanceCharged  ; //! Trigger particle -charged hadron momentim imbalance histogram
+  
+  ClassDef(AliAnaParticleHadronCorrelation,1)
+} ;
+
+#endif //ALIANAPARTICLEHADRONCORRELATION_H
+
+
+
diff --git a/PWG4/PartCorrDep/AliAnaParticleIsolation.cxx b/PWG4/PartCorrDep/AliAnaParticleIsolation.cxx
new file mode 100755 (executable)
index 0000000..293539d
--- /dev/null
@@ -0,0 +1,988 @@
+/**************************************************************************\r
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+ *                                                                        *\r
+ * Author: The ALICE Off-line Project.                                    *\r
+ * Contributors are mentioned in the code where appropriate.              *\r
+ *                                                                        *\r
+ * Permission to use, copy, modify and distribute this software and its   *\r
+ * documentation strictly for non-commercial purposes hereby granted      *\r
+ * without fee, provided that the above copyright notice appears in all   *\r
+ * copies and that both the copyright notice and this permission notice   *\r
+ * appear in the supporting documentation. The authors make no claims     *\r
+ * about the suitability of this software for any purpose. It is          *\r
+ * provided "as is" without express or implied warranty.                  *\r
+ **************************************************************************/\r
+/* $Id: AliAnaParticleIsolation.cxx 28688 2008-09-11 15:04:07Z gconesab $ */\r
+\r
+//_________________________________________________________________________\r
+// Class for analysis of particle isolation\r
+// Input is selected particles put in AOD branch (AliAODPWG4ParticleCorrelation)\r
+//\r
+//  Class created from old AliPHOSGammaJet \r
+//  (see AliRoot versions previous Release 4-09)\r
+//\r
+// -- Author: Gustavo Conesa (LNF-INFN) \r
+//////////////////////////////////////////////////////////////////////////////\r
+  \r
+  \r
+// --- ROOT system --- \r
+#include <TList.h>\r
+\r
+// --- Analysis system --- \r
+#include "AliAnaParticleIsolation.h" \r
+#include "AliLog.h"\r
+#include "AliCaloTrackReader.h"\r
+#include "AliIsolationCut.h"\r
+#include "AliNeutralMesonSelection.h"\r
+#include "AliAODPWG4ParticleCorrelation.h"\r
+#include "AliCaloPID.h"\r
+\r
+ClassImp(AliAnaParticleIsolation)\r
+  \r
+//____________________________________________________________________________\r
+  AliAnaParticleIsolation::AliAnaParticleIsolation() : \r
+    AliAnaPartCorrBaseClass(), fCalorimeter(""), fVertex(),\r
+       fReMakeIC(0), fMakeSeveralIC(0), fMakeInvMass(0),\r
+    fhPtIso(0),fhPhiIso(0),fhEtaIso(0), fhConeSumPt(0), fhPtInCone(0),\r
+    //Several IC\r
+    fNCones(0),fNPtThresFrac(0), fConeSizes(),  fPtThresholds(),  fPtFractions(), \r
+    //MC\r
+       fhPtIsoPrompt(0),fhPhiIsoPrompt(0),fhEtaIsoPrompt(0), \r
+    fhPtThresIsolatedPrompt(), fhPtFracIsolatedPrompt(),  fhPtSumIsolatedPrompt(),\r
+       fhPtIsoFragmentation(0),fhPhiIsoFragmentation(0),fhEtaIsoFragmentation(0), \r
+    fhPtThresIsolatedFragmentation(), fhPtFracIsolatedFragmentation(),  fhPtSumIsolatedFragmentation(),\r
+       fhPtIsoPi0Decay(0),fhPhiIsoPi0Decay(0),fhEtaIsoPi0Decay(0),\r
+    fhPtThresIsolatedPi0Decay(), fhPtFracIsolatedPi0Decay(),  fhPtSumIsolatedPi0Decay(),\r
+       fhPtIsoOtherDecay(0),fhPhiIsoOtherDecay(0),fhEtaIsoOtherDecay(0), \r
+    fhPtThresIsolatedOtherDecay(), fhPtFracIsolatedOtherDecay(),  fhPtSumIsolatedOtherDecay(),\r
+       fhPtIsoConversion(0),fhPhiIsoConversion(0),fhEtaIsoConversion(0), \r
+    fhPtThresIsolatedConversion(), fhPtFracIsolatedConversion(),  fhPtSumIsolatedConversion(),\r
+       fhPtIsoUnknown(0),fhPhiIsoUnknown(0),fhEtaIsoUnknown(0), \r
+    fhPtThresIsolatedUnknown(), fhPtFracIsolatedUnknown(),  fhPtSumIsolatedUnknown(),\r
+       //Histograms settings\r
+       fHistoNPtSumBins(0),    fHistoPtSumMax(0.),    fHistoPtSumMin(0.),\r
+       fHistoNPtInConeBins(0), fHistoPtInConeMax(0.), fHistoPtInConeMin(0.)\r
+{\r
+  //default ctor\r
+  \r
+  //Initialize parameters\r
+  InitParameters();\r
+  \r
+  fVertex[0] = 0.;  fVertex[1] = 0.;  fVertex[2] = 0.;  \r
+         \r
+  for(Int_t i = 0; i < 5 ; i++){ \r
+    fConeSizes[i] = 0 ; \r
+    fhPtSumIsolated[i] = 0 ;  \r
+    \r
+    fhPtSumIsolatedPrompt[i] = 0 ;  \r
+    fhPtSumIsolatedFragmentation[i] = 0 ;  \r
+    fhPtSumIsolatedPi0Decay[i] = 0 ;  \r
+    fhPtSumIsolatedOtherDecay[i] = 0 ;  \r
+    fhPtSumIsolatedConversion[i] = 0 ;  \r
+    fhPtSumIsolatedUnknown[i] = 0 ;  \r
+    \r
+    for(Int_t j = 0; j < 5 ; j++){ \r
+      fhPtThresIsolated[i][j] = 0 ;  \r
+      fhPtFracIsolated[i][j] = 0 ; \r
+      \r
+      fhPtThresIsolatedPrompt[i][j] = 0 ;  \r
+      fhPtThresIsolatedFragmentation[i][j] = 0 ; \r
+      fhPtThresIsolatedPi0Decay[i][j] = 0 ;  \r
+      fhPtThresIsolatedOtherDecay[i][j] = 0 ;  \r
+      fhPtThresIsolatedConversion[i][j] = 0 ;  \r
+      fhPtThresIsolatedUnknown[i][j] = 0 ;  \r
+  \r
+      fhPtFracIsolatedPrompt[i][j] = 0 ;  \r
+      fhPtFracIsolatedFragmentation[i][j] = 0 ;  \r
+      fhPtFracIsolatedPi0Decay[i][j] = 0 ;  \r
+      fhPtFracIsolatedOtherDecay[i][j] = 0 ;  \r
+      fhPtFracIsolatedConversion[i][j] = 0 ;\r
+      fhPtFracIsolatedUnknown[i][j] = 0 ;  \r
\r
+    }  \r
+  } \r
+  \r
+  for(Int_t i = 0; i < 5 ; i++){ \r
+    fPtFractions[i]=  0 ; \r
+    fPtThresholds[i]= 0 ; \r
+  } \r
+\r
+\r
+}\r
+\r
+//____________________________________________________________________________\r
+AliAnaParticleIsolation::AliAnaParticleIsolation(const AliAnaParticleIsolation & g) : \r
+  AliAnaPartCorrBaseClass(g), fCalorimeter(g.fCalorimeter),fVertex(),\r
+  fReMakeIC(g.fReMakeIC), fMakeSeveralIC(g.fMakeSeveralIC),  fMakeInvMass(g.fMakeInvMass),\r
+  fhPtIso(g.fhPtIso),fhPhiIso(g.fhPhiIso),fhEtaIso(g.fhEtaIso), \r
+  fhConeSumPt(g.fhConeSumPt), fhPtInCone(g.fhPtInCone),\r
+  //Several IC\r
+  fNCones(g.fNCones),fNPtThresFrac(g.fNPtThresFrac), fConeSizes(), fPtThresholds(),  fPtFractions(), \r
+  fhPtThresIsolated(),  fhPtFracIsolated(), fhPtSumIsolated(),\r
+  //MC\r
+  fhPtIsoPrompt(g.fhPtIsoPrompt),fhPhiIsoPrompt(g.fhPhiIsoPrompt),fhEtaIsoPrompt(g.fhEtaIsoPrompt), \r
+  fhPtThresIsolatedPrompt(), fhPtFracIsolatedPrompt(),  fhPtSumIsolatedPrompt(),\r
+  fhPtIsoFragmentation(g.fhPtIsoFragmentation),fhPhiIsoFragmentation(g.fhPhiIsoFragmentation),fhEtaIsoFragmentation(g.fhEtaIsoFragmentation),\r
+  fhPtThresIsolatedFragmentation(), fhPtFracIsolatedFragmentation(),  fhPtSumIsolatedFragmentation(),\r
+  fhPtIsoPi0Decay(g.fhPtIsoPi0Decay),fhPhiIsoPi0Decay(g.fhPhiIsoPi0Decay),fhEtaIsoPi0Decay(g.fhEtaIsoPi0Decay), \r
+  fhPtThresIsolatedPi0Decay(), fhPtFracIsolatedPi0Decay(),  fhPtSumIsolatedPi0Decay(),\r
+  fhPtIsoOtherDecay(g.fhPtIsoOtherDecay),fhPhiIsoOtherDecay(g.fhPhiIsoOtherDecay),fhEtaIsoOtherDecay(g.fhEtaIsoOtherDecay), \r
+  fhPtThresIsolatedOtherDecay(), fhPtFracIsolatedOtherDecay(),  fhPtSumIsolatedOtherDecay(),\r
+  fhPtIsoConversion(g. fhPtIsoConversion),fhPhiIsoConversion(g.fhPhiIsoConversion),fhEtaIsoConversion(g.fhEtaIsoConversion), \r
+  fhPtThresIsolatedConversion(), fhPtFracIsolatedConversion(),  fhPtSumIsolatedConversion(),\r
+  fhPtIsoUnknown(g.fhPtIsoUnknown),fhPhiIsoUnknown(g.fhPhiIsoUnknown),fhEtaIsoUnknown(g.fhEtaIsoUnknown), \r
+  fhPtThresIsolatedUnknown(), fhPtFracIsolatedUnknown(),  fhPtSumIsolatedUnknown(),\r
+  //Histograms\r
+  fHistoNPtSumBins(g.fHistoNPtSumBins), fHistoPtSumMax(g.fHistoPtSumMax), fHistoPtSumMin(g.fHistoPtSumMax),\r
+  fHistoNPtInConeBins(g.fHistoNPtInConeBins), fHistoPtInConeMax(g.fHistoPtInConeMax), fHistoPtInConeMin(g.fHistoPtInConeMin)\r
+{  \r
+  // cpy ctor\r
+  \r
+       fVertex[0] = g.fVertex[0];  \r
+       fVertex[1] = g.fVertex[1];  \r
+       fVertex[2] = g.fVertex[2];  \r
+\r
+       //Several IC\r
+       for(Int_t i = 0; i < fNCones ; i++){\r
+               fConeSizes[i] =  g.fConeSizes[i];\r
+               fhPtSumIsolated[i] = g.fhPtSumIsolated[i]; \r
+               \r
+               fhPtSumIsolatedPrompt[i] = g.fhPtSumIsolatedPrompt[i]; \r
+               fhPtSumIsolatedFragmentation[i] = g.fhPtSumIsolatedFragmentation[i]; \r
+               fhPtSumIsolatedPi0Decay[i] = g.fhPtSumIsolatedPi0Decay[i]; \r
+               fhPtSumIsolatedOtherDecay[i] = g.fhPtSumIsolatedOtherDecay[i]; \r
+               fhPtSumIsolatedConversion[i] = g.fhPtSumIsolatedConversion[i]; \r
+               fhPtSumIsolatedUnknown[i] = g.fhPtSumIsolatedUnknown[i]; \r
+               \r
+               for(Int_t j = 0; j < fNPtThresFrac ; j++){\r
+                       fhPtThresIsolated[i][j] = g.fhPtThresIsolated[i][j]; \r
+                       fhPtFracIsolated[i][j] = g.fhPtFracIsolated[i][j];\r
+                       \r
+                       fhPtThresIsolatedPrompt[i][j] = g.fhPtThresIsolatedPrompt[i][j]; \r
+                       fhPtThresIsolatedFragmentation[i][j] = g.fhPtThresIsolatedFragmentation[i][j]; \r
+                       fhPtThresIsolatedPi0Decay[i][j] = g.fhPtThresIsolatedPi0Decay[i][j]; \r
+                       fhPtThresIsolatedOtherDecay[i][j] = g.fhPtThresIsolatedOtherDecay[i][j]; \r
+                       fhPtThresIsolatedConversion[i][j] = g.fhPtThresIsolatedConversion[i][j]; \r
+                       fhPtThresIsolatedUnknown[i][j] = g.fhPtThresIsolatedUnknown[i][j]; \r
+                       \r
+                       fhPtFracIsolatedPrompt[i][j] = g.fhPtFracIsolatedPrompt[i][j]; \r
+                       fhPtFracIsolatedFragmentation[i][j] = g.fhPtFracIsolatedFragmentation[i][j]; \r
+                       fhPtFracIsolatedPi0Decay[i][j] = g.fhPtFracIsolatedPi0Decay[i][j]; \r
+                       fhPtFracIsolatedOtherDecay[i][j] = g.fhPtFracIsolatedOtherDecay[i][j]; \r
+                       fhPtFracIsolatedConversion[i][j] = g.fhPtFracIsolatedConversion[i][j]; \r
+                       fhPtFracIsolatedUnknown[i][j] = g.fhPtFracIsolatedUnknown[i][j]; \r
+                       \r
+               } \r
+       }\r
+       \r
+       for(Int_t i = 0; i < fNPtThresFrac ; i++){\r
+               fPtFractions[i]=   g.fPtFractions[i];\r
+               fPtThresholds[i]=   g.fPtThresholds[i];\r
+       }\r
+       \r
+}\r
+\r
+//_________________________________________________________________________\r
+AliAnaParticleIsolation & AliAnaParticleIsolation::operator = (const AliAnaParticleIsolation & g)\r
+{\r
+       // assignment operator\r
+  \r
+       if(&g == this) return *this;\r
+\r
+       fReMakeIC = g.fReMakeIC ;\r
+       fMakeSeveralIC = g.fMakeSeveralIC ;\r
+       fMakeInvMass = g.fMakeInvMass ;\r
+       fCalorimeter = g.fCalorimeter ;\r
+       fVertex[0] = g.fVertex[0];  \r
+       fVertex[1] = g.fVertex[1];  \r
+       fVertex[2] = g.fVertex[2]; \r
+        \r
+       fhConeSumPt = g.fhConeSumPt ;\r
+       fhPtInCone = g.fhPtInCone;\r
+       \r
+       fhPtIso = g.fhPtIso ; \r
+       fhPhiIso = g.fhPhiIso ;\r
+       fhEtaIso = g.fhEtaIso ;\r
+       \r
+       fhPtIsoPrompt = g.fhPtIsoPrompt;\r
+       fhPhiIsoPrompt = g.fhPhiIsoPrompt;\r
+       fhEtaIsoPrompt = g.fhEtaIsoPrompt; \r
+       fhPtIsoFragmentation = g.fhPtIsoFragmentation;\r
+       fhPhiIsoFragmentation = g.fhPhiIsoFragmentation;\r
+       fhEtaIsoFragmentation = g.fhEtaIsoFragmentation; \r
+       fhPtIsoPi0Decay = g.fhPtIsoPi0Decay;\r
+       fhPhiIsoPi0Decay = g.fhPhiIsoPi0Decay;\r
+       fhEtaIsoPi0Decay = g.fhEtaIsoPi0Decay; \r
+       fhPtIsoOtherDecay = g.fhPtIsoOtherDecay;\r
+       fhPhiIsoOtherDecay = g.fhPhiIsoOtherDecay;\r
+       fhEtaIsoOtherDecay = g.fhEtaIsoOtherDecay; \r
+       fhPtIsoConversion = g. fhPtIsoConversion;\r
+       fhPhiIsoConversion = g.fhPhiIsoConversion;\r
+       fhEtaIsoConversion = g.fhEtaIsoConversion; \r
+       fhPtIsoUnknown = g.fhPtIsoUnknown;\r
+       fhPhiIsoUnknown = g.fhPhiIsoUnknown;\r
+       fhEtaIsoUnknown = g.fhEtaIsoUnknown; \r
+       \r
+       //Several IC\r
+       fNCones = g.fNCones ;\r
+       fNPtThresFrac = g.fNPtThresFrac ; \r
+       \r
+       for(Int_t i = 0; i < fNCones ; i++){\r
+               fConeSizes[i] =  g.fConeSizes[i];\r
+               fhPtSumIsolated[i] = g.fhPtSumIsolated[i] ;\r
+               \r
+               fhPtSumIsolatedPrompt[i] = g.fhPtSumIsolatedPrompt[i]; \r
+               fhPtSumIsolatedFragmentation[i] = g.fhPtSumIsolatedFragmentation[i]; \r
+               fhPtSumIsolatedPi0Decay[i] = g.fhPtSumIsolatedPi0Decay[i]; \r
+               fhPtSumIsolatedOtherDecay[i] = g.fhPtSumIsolatedOtherDecay[i]; \r
+               fhPtSumIsolatedConversion[i] = g.fhPtSumIsolatedConversion[i]; \r
+               fhPtSumIsolatedUnknown[i] = g.fhPtSumIsolatedUnknown[i]; \r
+               \r
+               for(Int_t j = 0; j < fNPtThresFrac ; j++){\r
+                       fhPtThresIsolated[i][j] = g.fhPtThresIsolated[i][j] ;\r
+                       fhPtFracIsolated[i][j] = g.fhPtFracIsolated[i][j] ;\r
+                       \r
+                       fhPtThresIsolatedPrompt[i][j] = g.fhPtThresIsolatedPrompt[i][j]; \r
+                       fhPtThresIsolatedFragmentation[i][j] = g.fhPtThresIsolatedFragmentation[i][j]; \r
+                       fhPtThresIsolatedPi0Decay[i][j] = g.fhPtThresIsolatedPi0Decay[i][j]; \r
+                       fhPtThresIsolatedOtherDecay[i][j] = g.fhPtThresIsolatedOtherDecay[i][j]; \r
+                       fhPtThresIsolatedConversion[i][j] = g.fhPtThresIsolatedConversion[i][j]; \r
+                       fhPtThresIsolatedUnknown[i][j] = g.fhPtThresIsolatedUnknown[i][j]; \r
+                       \r
+                       fhPtFracIsolatedPrompt[i][j] = g.fhPtFracIsolatedPrompt[i][j]; \r
+                       fhPtFracIsolatedFragmentation[i][j] = g.fhPtFracIsolatedFragmentation[i][j]; \r
+                       fhPtFracIsolatedPi0Decay[i][j] = g.fhPtFracIsolatedPi0Decay[i][j]; \r
+                       fhPtFracIsolatedOtherDecay[i][j] = g.fhPtFracIsolatedOtherDecay[i][j]; \r
+                       fhPtFracIsolatedConversion[i][j] = g.fhPtFracIsolatedConversion[i][j]; \r
+                       fhPtFracIsolatedUnknown[i][j] = g.fhPtFracIsolatedUnknown[i][j]; \r
+                       \r
+               }\r
+       }\r
+       \r
+       for(Int_t i = 0; i < fNPtThresFrac ; i++){\r
+               fPtThresholds[i]=   g.fPtThresholds[i];\r
+               fPtFractions[i]=   g.fPtFractions[i];\r
+       }\r
+       \r
+       \r
+       fHistoNPtSumBins    = g.fHistoNPtSumBins;\r
+       fHistoPtSumMax      = g.fHistoPtSumMax; \r
+       fHistoPtSumMin      = g.fHistoPtSumMax;\r
+       fHistoNPtInConeBins = g.fHistoNPtInConeBins;\r
+       fHistoPtInConeMax   = g.fHistoPtInConeMax;\r
+       fHistoPtInConeMin   = g.fHistoPtInConeMin;      \r
+       \r
+       return *this;\r
+       \r
+}\r
+\r
+//____________________________________________________________________________\r
+AliAnaParticleIsolation::~AliAnaParticleIsolation() \r
+{\r
+  //dtor\r
+  //do not delete histograms\r
+\r
+ delete [] fConeSizes ; \r
+ delete [] fPtThresholds ; \r
+ delete [] fPtFractions ; \r
+ delete [] fVertex ;\r
+}\r
+\r
+//_________________________________________________________________________\r
+Bool_t AliAnaParticleIsolation::CheckInvMass(const Int_t iaod, const AliAODPWG4ParticleCorrelation * part1) const\r
+{\r
+       // Search if there is a companion decay photon to the candidate \r
+       // and discard it in such case\r
+       // Use it only if isolation candidates are photons\r
+       // Make sure that no selection on photon pt is done in the input aod photon list.\r
+       TLorentzVector mom1 = *(part1->Momentum());\r
+       TLorentzVector mom2 ;\r
+       for(Int_t jaod = 0; jaod < GetInputAODBranch()->GetEntriesFast(); jaod++){\r
+               if(iaod == jaod) continue ;\r
+               AliAODPWG4ParticleCorrelation * part2 =  (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(jaod));\r
+               mom2 = *(part2->Momentum());\r
+               //Select good pair (good phi, pt cuts, aperture and invariant mass)\r
+               if(GetNeutralMesonSelection()->SelectPair(mom1, mom2)){\r
+                       if(GetDebug() > 1)printf("Selected gamma pair: pt %f, phi %f, eta%f",(mom1+mom2).Pt(), (mom1+mom2).Phi()*180./3.1416, (mom1+mom2).Eta());\r
+                       return kTRUE ;\r
+               }\r
+       }//loop\r
+       \r
+  return kFALSE;\r
+}\r
+\r
+//________________________________________________________________________\r
+TList *  AliAnaParticleIsolation::GetCreateOutputObjects()\r
+{  \r
+       // Create histograms to be saved in output file and \r
+       // store them in outputContainer\r
+       TList * outputContainer = new TList() ; \r
+       outputContainer->SetName("IsolatedParticleHistos") ; \r
+       \r
+       Int_t nptbins  = GetHistoNPtBins();\r
+       Int_t nphibins = GetHistoNPhiBins();\r
+       Int_t netabins = GetHistoNEtaBins();\r
+       Float_t ptmax  = GetHistoPtMax();\r
+       Float_t phimax = GetHistoPhiMax();\r
+       Float_t etamax = GetHistoEtaMax();\r
+       Float_t ptmin  = GetHistoPtMin();\r
+       Float_t phimin = GetHistoPhiMin();\r
+       Float_t etamin = GetHistoEtaMin();      \r
+       \r
+       Int_t nptsumbins    = fHistoNPtSumBins;\r
+       Float_t ptsummax    = fHistoPtSumMax;\r
+       Float_t ptsummin    = fHistoPtSumMin;   \r
+       Int_t nptinconebins = fHistoNPtInConeBins;\r
+       Float_t ptinconemax = fHistoPtInConeMax;\r
+       Float_t ptinconemin = fHistoPtInConeMin;\r
+       \r
+       if(!fMakeSeveralIC){\r
+               \r
+               fhConeSumPt  = new TH2F\r
+               ("hConePtSum","#Sigma p_{T}  in cone ",nptbins,ptmin,ptmax,nptsumbins,ptsummin,ptsummax);\r
+               fhConeSumPt->SetYTitle("#Sigma p_{T}");\r
+               fhConeSumPt->SetXTitle("p_{T #gamma} (GeV/c)");\r
+               outputContainer->Add(fhConeSumPt) ;\r
+               \r
+               fhPtInCone  = new TH2F\r
+               ("hPtInCone","p_{T} in cone ",nptbins,ptmin,ptmax,nptinconebins,ptinconemin,ptinconemax);\r
+               fhPtInCone->SetYTitle("p_{T in cone} (GeV/c)");\r
+               fhPtInCone->SetXTitle("p_{T #gamma} (GeV/c)");\r
+               outputContainer->Add(fhPtInCone) ;\r
+               \r
+               fhPtIso  = new TH1F("hPtIso","Isolated Number of #gamma over calorimeter",nptbins,ptmin,ptmax); \r
+               fhPtIso->SetYTitle("N");\r
+               fhPtIso->SetXTitle("p_{T #gamma}(GeV/c)");\r
+               outputContainer->Add(fhPtIso) ; \r
+               \r
+               fhPhiIso  = new TH2F\r
+               ("hPhiIso","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,nphibins,phimin,phimax); \r
+               fhPhiIso->SetYTitle("#phi");\r
+               fhPhiIso->SetXTitle("p_{T #gamma} (GeV/c)");\r
+               outputContainer->Add(fhPhiIso) ; \r
+               \r
+               fhEtaIso  = new TH2F\r
+               ("hEtaIso","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,netabins,etamin,etamax); \r
+               fhEtaIso->SetYTitle("#eta");\r
+               fhEtaIso->SetXTitle("p_{T #gamma} (GeV/c)");\r
+               outputContainer->Add(fhEtaIso) ;\r
+               \r
+               if(IsDataMC()){\r
+                       \r
+                       fhPtIsoPrompt  = new TH1F("hPtIsoPrompt","Isolated Number of #gamma over calorimeter",nptbins,ptmin,ptmax); \r
+                       fhPtIsoPrompt->SetYTitle("N");\r
+                       fhPtIsoPrompt->SetXTitle("p_{T #gamma}(GeV/c)");\r
+                       outputContainer->Add(fhPtIsoPrompt) ; \r
+                       \r
+                       fhPhiIsoPrompt  = new TH2F\r
+                       ("hPhiIsoPrompt","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,nphibins,phimin,phimax); \r
+                       fhPhiIsoPrompt->SetYTitle("#phi");\r
+                       fhPhiIsoPrompt->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhPhiIsoPrompt) ; \r
+                       \r
+                       fhEtaIsoPrompt  = new TH2F\r
+                       ("hEtaIsoPrompt","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,netabins,etamin,etamax); \r
+                       fhEtaIsoPrompt->SetYTitle("#eta");\r
+                       fhEtaIsoPrompt->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhEtaIsoPrompt) ;\r
+                       \r
+                       fhPtIsoFragmentation  = new TH1F("hPtIsoFragmentation","Isolated Number of #gamma over calorimeter",nptbins,ptmin,ptmax); \r
+                       fhPtIsoFragmentation->SetYTitle("N");\r
+                       fhPtIsoFragmentation->SetXTitle("p_{T #gamma}(GeV/c)");\r
+                       outputContainer->Add(fhPtIsoFragmentation) ; \r
+                       \r
+                       fhPhiIsoFragmentation  = new TH2F\r
+                       ("hPhiIsoFragmentation","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,nphibins,phimin,phimax); \r
+                       fhPhiIsoFragmentation->SetYTitle("#phi");\r
+                       fhPhiIsoFragmentation->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhPhiIsoFragmentation) ; \r
+                       \r
+                       fhEtaIsoFragmentation  = new TH2F\r
+                       ("hEtaIsoFragmentation","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,netabins,etamin,etamax); \r
+                       fhEtaIsoFragmentation->SetYTitle("#eta");\r
+                       fhEtaIsoFragmentation->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhEtaIsoFragmentation) ;\r
+                       \r
+                       fhPtIsoPi0Decay  = new TH1F("hPtIsoPi0Decay","Isolated Number of #gamma over calorimeter",nptbins,ptmin,ptmax); \r
+                       fhPtIsoPi0Decay->SetYTitle("N");\r
+                       fhPtIsoPi0Decay->SetXTitle("p_{T #gamma}(GeV/c)");\r
+                       outputContainer->Add(fhPtIsoPi0Decay) ; \r
+                       \r
+                       fhPhiIsoPi0Decay  = new TH2F\r
+                       ("hPhiIsoPi0Decay","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,nphibins,phimin,phimax); \r
+                       fhPhiIsoPi0Decay->SetYTitle("#phi");\r
+                       fhPhiIsoPi0Decay->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhPhiIsoPi0Decay) ; \r
+                       \r
+                       fhEtaIsoPi0Decay  = new TH2F\r
+                       ("hEtaIsoPi0Decay","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,netabins,etamin,etamax); \r
+                       fhEtaIsoPi0Decay->SetYTitle("#eta");\r
+                       fhEtaIsoPi0Decay->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhEtaIsoPi0Decay) ;\r
+                       \r
+                       fhPtIsoOtherDecay  = new TH1F("hPtIsoOtherDecay","Isolated Number of #gamma over calorimeter",nptbins,ptmin,ptmax); \r
+                       fhPtIsoOtherDecay->SetYTitle("N");\r
+                       fhPtIsoOtherDecay->SetXTitle("p_{T #gamma}(GeV/c)");\r
+                       outputContainer->Add(fhPtIsoOtherDecay) ; \r
+                       \r
+                       fhPhiIsoOtherDecay  = new TH2F\r
+                       ("hPhiIsoOtherDecay","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,nphibins,phimin,phimax); \r
+                       fhPhiIsoOtherDecay->SetYTitle("#phi");\r
+                       fhPhiIsoOtherDecay->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhPhiIsoOtherDecay) ; \r
+                       \r
+                       fhEtaIsoOtherDecay  = new TH2F\r
+                       ("hEtaIsoOtherDecay","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,netabins,etamin,etamax); \r
+                       fhEtaIsoOtherDecay->SetYTitle("#eta");\r
+                       fhEtaIsoOtherDecay->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhEtaIsoOtherDecay) ;\r
+                       \r
+                       fhPtIsoConversion  = new TH1F("hPtIsoConversion","Isolated Number of #gamma over calorimeter",nptbins,ptmin,ptmax); \r
+                       fhPtIsoConversion->SetYTitle("N");\r
+                       fhPtIsoConversion->SetXTitle("p_{T #gamma}(GeV/c)");\r
+                       outputContainer->Add(fhPtIsoConversion) ; \r
+                       \r
+                       fhPhiIsoConversion  = new TH2F\r
+                       ("hPhiIsoConversion","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,nphibins,phimin,phimax); \r
+                       fhPhiIsoConversion->SetYTitle("#phi");\r
+                       fhPhiIsoConversion->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhPhiIsoConversion) ; \r
+                       \r
+                       fhEtaIsoConversion  = new TH2F\r
+                       ("hEtaIsoConversion","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,netabins,etamin,etamax); \r
+                       fhEtaIsoConversion->SetYTitle("#eta");\r
+                       fhEtaIsoConversion->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhEtaIsoConversion) ;\r
+                       \r
+                       fhPtIsoUnknown  = new TH1F("hPtIsoUnknown","Isolated Number of #gamma over calorimeter",nptbins,ptmin,ptmax); \r
+                       fhPtIsoUnknown->SetYTitle("N");\r
+                       fhPtIsoUnknown->SetXTitle("p_{T #gamma}(GeV/c)");\r
+                       outputContainer->Add(fhPtIsoUnknown) ; \r
+                       \r
+                       fhPhiIsoUnknown  = new TH2F\r
+                       ("hPhiIsoUnknown","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,nphibins,phimin,phimax); \r
+                       fhPhiIsoUnknown->SetYTitle("#phi");\r
+                       fhPhiIsoUnknown->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhPhiIsoUnknown) ; \r
+                       \r
+                       fhEtaIsoUnknown  = new TH2F\r
+                       ("hEtaIsoUnknown","Isolated #phi_{#gamma}",nptbins,ptmin,ptmax,netabins,etamin,etamax); \r
+                       fhEtaIsoUnknown->SetYTitle("#eta");\r
+                       fhEtaIsoUnknown->SetXTitle("p_{T #gamma} (GeV/c)");\r
+                       outputContainer->Add(fhEtaIsoUnknown) ;\r
+               }//Histos with MC\r
+               \r
+       }\r
+       \r
+       if(fMakeSeveralIC){\r
+               char name[128];\r
+               char title[128];\r
+               for(Int_t icone = 0; icone<fNCones; icone++){\r
+                       sprintf(name,"hPtSumIsolated_Cone_%d",icone);\r
+                       sprintf(title,"Candidate cone sum p_{T} for cone size %d vs candidate p_{T}",icone);\r
+                       fhPtSumIsolated[icone]  = new TH2F(name, title,nptbins,ptmin,ptmax,nptsumbins,ptsummin,ptsummax);\r
+                       fhPtSumIsolated[icone]->SetYTitle("#Sigma p_{T} (GeV/c)");\r
+                       fhPtSumIsolated[icone]->SetXTitle("p_{T} (GeV/c)");\r
+                       outputContainer->Add(fhPtSumIsolated[icone]) ; \r
+                       \r
+                       if(IsDataMC()){\r
+                               sprintf(name,"hPtSumIsolatedPrompt_Cone_%d",icone);\r
+                               sprintf(title,"Candidate Prompt cone sum p_{T} for cone size %d vs candidate p_{T}",icone);\r
+                               fhPtSumIsolatedPrompt[icone]  = new TH2F(name, title,nptbins,ptmin,ptmax,nptsumbins,ptsummin,ptsummax);\r
+                               fhPtSumIsolatedPrompt[icone]->SetY