Jet and Particle identification tasks moved to different directories
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 24 Oct 2008 15:54:58 +0000 (15:54 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 24 Oct 2008 15:54:58 +0000 (15:54 +0000)
67 files changed:
PWG4/CMakeLists.txt
PWG4/CMake_libPWG4JetTasks.txt [new file with mode: 0644]
PWG4/CMake_libPWG4PartCorr.txt
PWG4/JetTasks/AliAnaESDSpectraQA.cxx [new file with mode: 0644]
PWG4/JetTasks/AliAnaESDSpectraQA.h [new file with mode: 0644]
PWG4/JetTasks/AliAnalysisHelperJetTasks.cxx [new file with mode: 0644]
PWG4/JetTasks/AliAnalysisHelperJetTasks.h [new file with mode: 0644]
PWG4/JetTasks/AliAnalysisTaskJetSpectrum.cxx [new file with mode: 0644]
PWG4/JetTasks/AliAnalysisTaskJetSpectrum.h [new file with mode: 0644]
PWG4/JetTasks/AliAnalysisTaskUE.cxx [new file with mode: 0644]
PWG4/JetTasks/AliAnalysisTaskUE.h [new file with mode: 0644]
PWG4/PROOF-INF.PWG4JetTasks/SETUP.C
PWG4/PROOF-INF.PWG4PartCorr/SETUP.C
PWG4/PartCorr/AliAODParticleCorrelation.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAODParticleCorrelation.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaCaloTrigger.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaCaloTrigger.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaCaloTriggerMC.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaCaloTriggerMC.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaExample.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaExample.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaGammaDirect.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaGammaDirect.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaPartCorrBaseClass.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaPartCorrBaseClass.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaPartCorrMaker.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaPartCorrMaker.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaParticleHadronCorrelation.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaParticleHadronCorrelation.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaParticleJetFinderCorrelation.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaParticleJetFinderCorrelation.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaParticleJetLeadingConeCorrelation.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaParticleJetLeadingConeCorrelation.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaParticlePartonCorrelation.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaParticlePartonCorrelation.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaPi0.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaPi0.h [new file with mode: 0644]
PWG4/PartCorr/AliAnaScale.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnaScale.h [new file with mode: 0644]
PWG4/PartCorr/AliAnalysisTaskGammaConversion.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnalysisTaskGammaConversion.h [new file with mode: 0644]
PWG4/PartCorr/AliAnalysisTaskPHOSExample.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnalysisTaskPHOSExample.h [new file with mode: 0644]
PWG4/PartCorr/AliAnalysisTaskParticleCorrelation.cxx [new file with mode: 0644]
PWG4/PartCorr/AliAnalysisTaskParticleCorrelation.h [new file with mode: 0644]
PWG4/PartCorr/AliCaloPID.cxx [new file with mode: 0644]
PWG4/PartCorr/AliCaloPID.h [new file with mode: 0644]
PWG4/PartCorr/AliCaloPhoton.cxx [new file with mode: 0644]
PWG4/PartCorr/AliCaloPhoton.h [new file with mode: 0644]
PWG4/PartCorr/AliCaloTrackAODReader.cxx [new file with mode: 0644]
PWG4/PartCorr/AliCaloTrackAODReader.h [new file with mode: 0644]
PWG4/PartCorr/AliCaloTrackESDReader.cxx [new file with mode: 0644]
PWG4/PartCorr/AliCaloTrackESDReader.h [new file with mode: 0644]
PWG4/PartCorr/AliCaloTrackMCReader.cxx [new file with mode: 0644]
PWG4/PartCorr/AliCaloTrackMCReader.h [new file with mode: 0644]
PWG4/PartCorr/AliCaloTrackReader.cxx [new file with mode: 0644]
PWG4/PartCorr/AliCaloTrackReader.h [new file with mode: 0644]
PWG4/PartCorr/AliFidutialCut.cxx [new file with mode: 0644]
PWG4/PartCorr/AliFidutialCut.h [new file with mode: 0644]
PWG4/PartCorr/AliGammaConversionHistograms.cxx [new file with mode: 0644]
PWG4/PartCorr/AliGammaConversionHistograms.h [new file with mode: 0644]
PWG4/PartCorr/AliIsolationCut.cxx [new file with mode: 0644]
PWG4/PartCorr/AliIsolationCut.h [new file with mode: 0644]
PWG4/PartCorr/AliNeutralMesonSelection.cxx [new file with mode: 0644]
PWG4/PartCorr/AliNeutralMesonSelection.h [new file with mode: 0644]
PWG4/PartCorr/AliV0Reader.cxx [new file with mode: 0644]
PWG4/PartCorr/AliV0Reader.h [new file with mode: 0644]

index 630260b..9467b82 100644 (file)
@@ -6,6 +6,8 @@
 
 set(INCLUDE_DIRECTORIES
 ${CMAKE_SOURCE_DIR}/PWG4
+${CMAKE_SOURCE_DIR}/PWG4/PartCorr
+${CMAKE_SOURCE_DIR}/PWG4/JetTasks
 ${CMAKE_SOURCE_DIR}/STEER
 ${CMAKE_SOURCE_DIR}/ANALYSIS 
 ${ROOT_INCLUDE_DIR}
@@ -22,4 +24,4 @@ link_directories( ${LINK_DIRECTORIES})
 SetModule()
 
 include(CMake_libPWG4PartCorr.txt)
-
+include(CMake_libPWG4JetTasks.txt)
diff --git a/PWG4/CMake_libPWG4JetTasks.txt b/PWG4/CMake_libPWG4JetTasks.txt
new file mode 100644 (file)
index 0000000..b76e6cc
--- /dev/null
@@ -0,0 +1,12 @@
+# -*- mode: cmake -*-
+
+set(SRCS
+       JetTasks/AliAnalysisTaskUE.cxx JetTasks/AliAnalysisTaskJetSpectrum.cxx JetTasks/AliAnalysisHelperJetTasks.cxx JetTasks/AliAnaESDSpectraQA.cxx
+)
+
+# fill list of header files from list of source files
+# by exchanging the file extension
+String(REPLACE ".cxx" ".h" HDRS "${SRCS}")
+
+AddLibrary(PWG4JetTasks "${SRCS}" "${HDRS}")
+
index 3634294..41cdcab 100644 (file)
@@ -1,17 +1,17 @@
 # -*- mode: cmake -*-
 
 set(SRCS
-       AliAnaCaloTrigger.cxx AliAnaCaloTriggerMC.cxx 
-       AliAODParticleCorrelation.cxx AliAnalysisTaskPHOSExample.cxx 
-       AliNeutralMesonSelection.cxx  AliFidutialCut.cxx AliCaloPID.cxx AliIsolationCut.cxx
-       AliAnaScale.cxx AliAnaPartCorrMaker.cxx 
-       AliAnaPartCorrBaseClass.cxx  AliAnaExample.cxx AliAnaGammaDirect.cxx  
-       AliAnaParticlePartonCorrelation.cxx AliAnaParticleHadronCorrelation.cxx 
-       AliAnaParticleJetFinderCorrelation.cxx 
-          AliAnaParticleJetLeadingConeCorrelation.cxx AliAnalysisTaskParticleCorrelation.cxx 
-       AliCaloTrackReader.cxx AliCaloTrackESDReader.cxx 
-       AliCaloTrackAODReader.cxx AliCaloTrackMCReader.cxx   AliAnaPi0.cxx AliCaloPhoton.cxx 
-       AliV0Reader.cxx AliAnalysisTaskGammaConversion.cxx AliGammaConversionHistograms.cxx
+       PartCorr/AliAnaCaloTrigger.cxx PartCorr/AliAnaCaloTriggerMC.cxx 
+       PartCorr/AliAODParticleCorrelation.cxx PartCorr/AliAnalysisTaskPHOSExample.cxx 
+       PartCorr/AliNeutralMesonSelection.cxx  PartCorr/AliFidutialCut.cxx PartCorr/AliCaloPID.cxx PartCorr/AliIsolationCut.cxx
+       PartCorr/AliAnaScale.cxx PartCorr/AliAnaPartCorrMaker.cxx 
+       PartCorr/AliAnaPartCorrBaseClass.cxx  PartCorr/AliAnaExample.cxx PartCorr/AliAnaGammaDirect.cxx  
+       PartCorr/AliAnaParticlePartonCorrelation.cxx PartCorr/AliAnaParticleHadronCorrelation.cxx 
+       PartCorr/AliAnaParticleJetFinderCorrelation.cxx 
+       PartCorr/AliAnaParticleJetLeadingConeCorrelation.cxx PartCorr/AliAnalysisTaskParticleCorrelation.cxx 
+       PartCorr/AliCaloTrackReader.cxx PartCorr/AliCaloTrackESDReader.cxx 
+       PartCorr/AliCaloTrackAODReader.cxx PartCorr/AliCaloTrackMCReader.cxx  PartCorr/AliCaloPhoton.cxx 
+       PartCorr/AliV0Reader.cxx PartCorr/AliAnalysisTaskGammaConversion.cxx PartCorr/AliGammaConversionHistograms.cxx
 )
 
 # fill list of header files from list of source files
diff --git a/PWG4/JetTasks/AliAnaESDSpectraQA.cxx b/PWG4/JetTasks/AliAnaESDSpectraQA.cxx
new file mode 100644 (file)
index 0000000..11813a2
--- /dev/null
@@ -0,0 +1,231 @@
+/**************************************************************************
+ * 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: $ */
+#include "AliAnaESDSpectraQA.h"
+
+#include "TH1.h"
+#include "TH2.h"
+#include "TH3.h"
+#include "TList.h"
+#include "TChain.h"
+#include "TDirectory.h"
+
+#include "AliAnalysisManager.h"
+#include "AliLog.h"
+#include "AliESDInputHandler.h"
+#include "AliESDEvent.h"
+#include "AliESDVertex.h"
+#include "AliESDtrack.h"
+#include "AliESDtrackCuts.h"
+
+
+const Int_t AliAnaESDSpectraQA::fgkNPtBins=38;
+const Float_t AliAnaESDSpectraQA::fgkPtMin=2;
+const Float_t AliAnaESDSpectraQA::fgkPtMax=40;
+const Int_t AliAnaESDSpectraQA::fgkNPhiBins=18;
+
+ClassImp(AliAnaESDSpectraQA)
+
+AliAnaESDSpectraQA::AliAnaESDSpectraQA(): AliAnalysisTask("AliAnaESDSpectraQA", ""), 
+  fESD(0), 
+  fTrackCuts(0), 
+  fNEvent(0), // just to avoid warnings, inititialized in InitPointers too
+  fPtAll(0),  //
+  fPtSel(0),  //
+  fHistList(0)
+{
+  InitHistPointers();
+}
+
+AliAnaESDSpectraQA::AliAnaESDSpectraQA(const char *name): 
+  AliAnalysisTask(name, ""), 
+  fESD(0),
+  fNEvent(0), // just to avoid warnings, inititialized in InitPointers too
+  fPtAll(0),  //
+  fPtSel(0),  // 
+  fHistList(0) {
+  // Input slot #0 works with a TChain ESD
+  DefineInput(0, TChain::Class());
+  // Output slot #0 writes into a TList
+  DefineOutput(0, TList::Class());
+  InitHistPointers();
+  fTrackCuts = new AliESDtrackCuts;
+  fTrackCuts->SetAcceptKingDaughters(kFALSE);
+  fTrackCuts->SetRequireTPCRefit(kTRUE);
+  fTrackCuts->SetEtaRange(-1,1);
+  // Add chisq criterium to reject 'bad' tracks that might not make it as prim
+}
+
+//________________________________________________________________________
+void AliAnaESDSpectraQA::ConnectInputData(Option_t *) 
+{
+  // Connect ESD here
+  // Called once
+  TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
+  
+  if( handler && handler->InheritsFrom("AliESDInputHandler") ) {
+     fESD  =  ((AliESDInputHandler*)handler)->GetEvent();
+  } 
+  else {
+    AliFatal("I can't get any ESD Event Handler");
+  }
+}
+
+void AliAnaESDSpectraQA::InitHistPointers() {
+  fNEvent = 0;
+  fPtAll = 0;
+  fPtSel = 0;
+  for (Int_t i=0; i< 4; i++) {
+    fHists[i].PhiPtNPointTPC = 0;
+    fHists[i].PhiPtNPointITS = 0;
+    fHists[i].PhiPtChisqC = 0;
+    fHists[i].PhiPtChisqTPC = 0;
+    fHists[i].PhiPtDCAR = 0;
+    fHists[i].PhiPtDCAZ = 0;
+  }
+}
+
+void AliAnaESDSpectraQA::CreateOutputObjects() {
+  fHistList = new TList();
+  //fDirectory = new TDirectory("trig_hists","Trigger histos");
+  //fDirectory->cd();
+  TString labels[4];
+  labels[kNegA]="NegA";
+  labels[kPosA]="PosA";
+  labels[kNegC]="NegC";
+  labels[kPosC]="PosC";
+
+  static const Float_t kMinPhi = 0;
+  static const Float_t kMaxPhi = 2*TMath::Pi();
+  fNEvent = new TH1F("NEvent","NEvent",1,-0.5,0.5);
+  fHistList->Add(fNEvent);
+  fPtAll = new TH1F("PtAll","PtAll",fgkNPtBins, fgkPtMin, fgkPtMax);
+  fHistList->Add(fPtAll);
+  fPtSel = new TH1F("PtSel","PtSel",fgkNPtBins, fgkPtMin, fgkPtMax);
+  fHistList->Add(fPtSel);
+  for (Int_t iSide = 0; iSide < 4; iSide++) {
+    TString hname="PhiPtNpointTPC";
+    hname += labels[iSide];
+    fHists[iSide].PhiPtNPointTPC = new TH3F(hname,hname+";#phi;p_{T} (GeV);N_{point,TPC}",fgkNPhiBins,kMinPhi,kMaxPhi,fgkNPtBins,fgkPtMin,fgkPtMax,160,0.5,160.5);
+    fHistList->Add(fHists[iSide].PhiPtNPointTPC);
+
+    hname="PhiPtNpointITS";
+    hname += labels[iSide];
+    fHists[iSide].PhiPtNPointITS = new TH3F(hname,hname+";#phi;p_{T} (GeV);N_{point,ITS}",fgkNPhiBins,kMinPhi,kMaxPhi,fgkNPtBins,fgkPtMin,fgkPtMax,9,-0.5,8.5);
+    fHistList->Add(fHists[iSide].PhiPtNPointITS);
+
+    hname="PhiPtChisqC";
+    hname += labels[iSide];
+    fHists[iSide].PhiPtChisqC = new TH3F(hname,hname+";#phi;p_{T} (GeV);#Chi^{2}/NDF",fgkNPhiBins,kMinPhi,kMaxPhi,fgkNPtBins,fgkPtMin,fgkPtMax,160,0,80);
+    fHistList->Add(fHists[iSide].PhiPtChisqC);
+
+    hname="PhiPtChisqTPC";
+    hname += labels[iSide];
+    fHists[iSide].PhiPtChisqTPC = new TH3F(hname,hname+";#phi;p_{T} (GeV);#Chi^{2}/NDF",fgkNPhiBins,kMinPhi,kMaxPhi,fgkNPtBins,fgkPtMin,fgkPtMax,50,0,5);
+    fHistList->Add(fHists[iSide].PhiPtChisqTPC);
+
+    hname="PhiPtDCAR";
+    hname += labels[iSide];
+    fHists[iSide].PhiPtDCAR = new TH3F(hname,hname+";#phi;p_{T} (GeV);DCAR",fgkNPhiBins,kMinPhi,kMaxPhi,fgkNPtBins,fgkPtMin,fgkPtMax,200,-1,1);
+    fHistList->Add(fHists[iSide].PhiPtDCAR);
+
+    hname="PhiPtDCAZ";
+    hname += labels[iSide];
+    fHists[iSide].PhiPtDCAZ = new TH3F(hname,hname+";#phi;p_{T} (GeV);DCAZ",fgkNPhiBins,kMinPhi,kMaxPhi,fgkNPtBins,fgkPtMin,fgkPtMax,200,-2,2);
+    fHistList->Add(fHists[iSide].PhiPtDCAZ);
+
+    hname="PhiPtSigmaToVertex";
+    hname += labels[iSide];
+    fHists[iSide].PhiPtSigmaToVertex = new TH3F(hname,hname+";#phi;p_{T} (GeV);n#sigma to vtx",fgkNPhiBins,kMinPhi,kMaxPhi,fgkNPtBins,fgkPtMin,fgkPtMax,50,0,5);
+    fHistList->Add(fHists[iSide].PhiPtSigmaToVertex);
+  }
+}
+
+void AliAnaESDSpectraQA::Exec(Option_t *) {  
+  // Main loop
+  // Called for each event
+
+  if (!fESD) {
+    Printf("ERROR: fESD not available");
+    return;
+  }
+
+  const AliESDVertex *vtx = fESD->GetPrimaryVertex();
+
+  // Need vertex cut
+  if (vtx->GetNContributors() < 2)
+    return;
+
+  printf("Vertex title %s, status %d, nCont %d\n",vtx->GetTitle(), vtx->GetStatus(), vtx->GetNContributors());
+  // Need to keep track of evts without vertex
+
+  Int_t nTracks = fESD->GetNumberOfTracks();
+  AliDebug(2,Form("nTracks %d", nTracks));
+  printf("nTracks %d\n", nTracks);
+  static Int_t Mult = 0;
+  Mult = 0;   // Need extra init bc of static
+  for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
+    AliESDtrack *track = fESD->GetTrack(iTrack);
+    hists *curTypeHists = 0;
+
+    if (fTrackCuts->AcceptTrack(track)) {
+      Mult++;
+
+      Float_t dca2D, dcaZ;
+      track->GetImpactParameters(dca2D,dcaZ);
+      fPtAll->Fill(track->Pt());
+
+      if (track->Eta() > 0) { // A side (crude for now)
+       if (track->Charge() > 0) 
+         curTypeHists = &fHists[kPosA];
+       else
+         curTypeHists = &fHists[kNegA];        
+      }
+      else { // C side
+       if (track->Charge() > 0) 
+         curTypeHists = &fHists[kPosC];
+       else
+         curTypeHists = &fHists[kNegC];        
+      }
+
+      Float_t phi = track->Phi();
+      Float_t pt = track->Pt();
+
+      UChar_t itsMap = track->GetITSClusterMap();
+      Int_t nPointITS = 0;
+      for (Int_t i=0; i < 6; i++) {
+       if (itsMap & (1 << i))
+         nPointITS ++;
+      }
+
+      Float_t sigToVertex = fTrackCuts->GetSigmaToVertex(track);
+      Float_t chisqC = 1000;
+      if (track->GetConstrainedParam())
+       chisqC = track->GetConstrainedChi2();
+
+      curTypeHists->PhiPtNPointTPC->Fill(phi,pt,track->GetTPCNcls());
+      curTypeHists->PhiPtNPointITS->Fill(phi,pt,nPointITS);
+      curTypeHists->PhiPtChisqC->Fill(phi,pt,chisqC);
+      curTypeHists->PhiPtChisqTPC->Fill(phi,pt,track->GetTPCchi2()/(track->GetTPCNclsF()-5));
+      curTypeHists->PhiPtDCAR->Fill(phi,pt,dca2D);
+      curTypeHists->PhiPtDCAZ->Fill(phi,pt,dcaZ);
+      curTypeHists->PhiPtSigmaToVertex->Fill(phi,pt,sigToVertex);
+    }
+  }
+  
+  // Post output data
+  PostData(0, fHistList);
+}
diff --git a/PWG4/JetTasks/AliAnaESDSpectraQA.h b/PWG4/JetTasks/AliAnaESDSpectraQA.h
new file mode 100644 (file)
index 0000000..61c0258
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef __AliAnaESDSpectraQA_hh__
+#define __AliAnaESDSpectraQA_hh__
+
+#include "AliAnalysisTask.h"
+
+class TH1F;
+class TH2F;
+class TH3F;
+class TList;
+class TDirectory;
+class AliESDEvent;
+class AliESDtrackCuts;
+
+class AliAnaESDSpectraQA: public AliAnalysisTask {
+
+ public:
+  AliAnaESDSpectraQA();
+  AliAnaESDSpectraQA(const char *name);
+  ~AliAnaESDSpectraQA() {;}
+
+  virtual void   ConnectInputData(Option_t *);
+  virtual void   CreateOutputObjects();
+  virtual void   Exec(Option_t *option);
+
+
+
+ private:
+
+  void InitHistPointers();
+  AliAnaESDSpectraQA(const AliAnaESDSpectraQA&);
+  AliAnaESDSpectraQA& operator=(const AliAnaESDSpectraQA&);
+
+
+  AliESDEvent *fESD;    //! ESD object
+  AliESDtrackCuts *fTrackCuts;
+
+  enum {kNegA,kPosA,kNegC,kPosC};
+  struct hists {
+    TH3F *PhiPtNPointTPC;
+    TH3F *PhiPtNPointITS;
+    TH3F *PhiPtChisqC;
+    TH3F *PhiPtChisqTPC;
+    TH3F *PhiPtDCAR;
+    TH3F *PhiPtDCAZ;
+    TH3F *PhiPtSigmaToVertex;
+  };
+
+  hists fHists[4];  //! Internal pointers to hists, do not stream
+
+  TH1F *fNEvent;
+  TH1F *fPtAll;
+  TH1F *fPtSel;
+
+  static const Int_t fgkNPtBins;
+  static const Float_t fgkPtMin;
+  static const Float_t fgkPtMax;
+  static const Int_t fgkNPhiBins;
+
+  TList *fHistList;
+
+  ClassDef(AliAnaESDSpectraQA,1) 
+  
+};
+#endif
diff --git a/PWG4/JetTasks/AliAnalysisHelperJetTasks.cxx b/PWG4/JetTasks/AliAnalysisHelperJetTasks.cxx
new file mode 100644 (file)
index 0000000..5a33e3d
--- /dev/null
@@ -0,0 +1,74 @@
+
+#include "TROOT.h"
+#include "TList.h"
+#include "AliMCEvent.h"
+#include "AliStack.h"
+#include "AliGenEventHeader.h"
+#include "AliGenCocktailEventHeader.h"
+#include "AliGenPythiaEventHeader.h"
+#include <fstream>
+#include <iostream>
+#include "AliAnalysisHelperJetTasks.h"
+
+
+ClassImp(AliAnalysisHelperJetTasks)
+
+
+
+AliGenPythiaEventHeader*  AliAnalysisHelperJetTasks::GetPythiaEventHeader(AliMCEvent *mcEvent){
+  
+  AliGenEventHeader* genHeader = mcEvent->GenEventHeader();
+  AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
+  if(!pythiaGenHeader){
+    // cocktail ??
+    AliGenCocktailEventHeader* genCocktailHeader = dynamic_cast<AliGenCocktailEventHeader*>(genHeader);
+    
+    if (!genCocktailHeader) {
+      Printf("%s %d: Unknown header type (not Pythia or Cocktail)",(char*)__FILE__,__LINE__);
+      return 0;
+    }
+    TList* headerList = genCocktailHeader->GetHeaders();
+    for (Int_t i=0; i<headerList->GetEntries(); i++) {
+      pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(headerList->At(i));
+      if (pythiaGenHeader)
+        break;
+    }
+    if(!pythiaGenHeader){
+      Printf("%s %d: PythiaHeader not found!",(char*)__FILE__,__LINE__);
+      return 0;
+    }
+  }
+  return pythiaGenHeader;
+
+}
+
+
+void AliAnalysisHelperJetTasks::PrintStack(AliMCEvent *mcEvent,Int_t iFirst,Int_t iLast,Int_t iMaxPrint){
+
+  AliStack *stack = mcEvent->Stack();
+  if(!stack){
+    Printf("%s%d No Stack available",(char*)__FILE__,__LINE__);
+    return;
+  }
+
+  static Int_t iCount = 0;
+  if(iCount>iMaxPrint)return;
+  Int_t nStack = stack->GetNtrack();
+  if(iLast == 0)iLast = nStack;
+  else if(iLast > nStack)iLast = nStack;
+
+
+  Printf("####################################################################");
+  for(Int_t np = iFirst;np<iLast;++np){
+    TParticle *p = stack->Particle(np);
+    Printf("Nr.%d --- Status %d ---- Mother1 %d Mother2 %d Daughter1 %d Daughter2 %d ",
+          np,p->GetStatusCode(),p->GetMother(0),p->GetMother(1),p->GetDaughter(0),p->GetDaughter(1));
+    Printf("Eta %3.3f Phi %3.3f ",p->Eta(),p->Phi()); 
+    p->Print();    
+    Printf("---------------------------------------");
+  }
+  iCount++;
+}
+
+
diff --git a/PWG4/JetTasks/AliAnalysisHelperJetTasks.h b/PWG4/JetTasks/AliAnalysisHelperJetTasks.h
new file mode 100644 (file)
index 0000000..b8a9361
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef  ALIANALYSISHELPERJETTASKS_H
+#define  ALIANALYSISHELPERJETTASKS_H
+
+
+#include "TObject.h"
+class AliMCEvent;
+class AliGenPythiaEventHeader;
+
+// Helper Class that contains a lot of usefull static functions (i.e. for Flavor selection.
+
+class AliAnalysisHelperJetTasks : public TObject {
+ public:
+  AliAnalysisHelperJetTasks() : TObject() {;}
+  virtual ~AliAnalysisHelperJetTasks(){;}
+  
+  static AliGenPythiaEventHeader*  GetPythiaEventHeader(AliMCEvent *mcEvent);
+  static void PrintStack(AliMCEvent *mcEvent,Int_t iFirst = 0,Int_t iLast = 0,Int_t iMaxPrint = 10);
+  
+
+  private:
+  
+  ClassDef(AliAnalysisHelperJetTasks, 1) // 
+};
+
+#endif // ALIANALYSISHELPERJETTASKS_H
diff --git a/PWG4/JetTasks/AliAnalysisTaskJetSpectrum.cxx b/PWG4/JetTasks/AliAnalysisTaskJetSpectrum.cxx
new file mode 100644 (file)
index 0000000..75c432c
--- /dev/null
@@ -0,0 +1,653 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TInterpreter.h>
+#include <TChain.h>
+#include <TFile.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TH3F.h>
+#include <TList.h>
+#include <TLorentzVector.h>
+#include <TClonesArray.h>
+#include  "TDatabasePDG.h"
+
+#include "AliAnalysisTaskJetSpectrum.h"
+#include "AliAnalysisManager.h"
+#include "AliJetFinder.h"
+#include "AliJetHeader.h"
+#include "AliJetReader.h"
+#include "AliJetReaderHeader.h"
+#include "AliUA1JetHeaderV1.h"
+#include "AliJet.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliAODHandler.h"
+#include "AliAODTrack.h"
+#include "AliAODJet.h"
+#include "AliMCEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliStack.h"
+#include "AliGenPythiaEventHeader.h"
+#include "AliJetKineReaderHeader.h"
+#include "AliGenCocktailEventHeader.h"
+#include "AliInputEventHandler.h"
+
+#include "AliAnalysisHelperJetTasks.h"
+
+ClassImp(AliAnalysisTaskJetSpectrum)
+
+AliAnalysisTaskJetSpectrum::AliAnalysisTaskJetSpectrum(): AliAnalysisTaskSE(),
+  fJetHeaderRec(0x0),
+  fJetHeaderGen(0x0),
+  fAOD(0x0),
+  fBranchRec("jets"),
+  fConfigRec("ConfigJets.C"),
+  fBranchGen(""),
+  fConfigGen(""),
+  fUseAODInput(kFALSE),
+  fUseExternalWeightOnly(kFALSE),
+  fLimitGenJetEta(kFALSE),
+  fAnalysisType(0),
+  fExternalWeight(1),    
+  fh1PtHard(0x0),
+  fh1PtHard_NoW(0x0),  
+  fh1PtHard_Trials(0x0),
+  fh1NGenJets(0x0),
+  fh1NRecJets(0x0),
+  fHistList(0x0)
+{
+  // Default constructor
+    for(int ij  = 0;ij<kMaxJets;++ij){
+    fh1E[ij] =  fh1PtRecIn[ij] = fh1PtRecOut[ij] = fh1PtGenIn[ij] = fh1PtGenOut[ij] = 0;
+    fh2PtFGen[ij] =  fh2Frag[ij] = fh2FragLn[ij] = 0;
+    fh3PtRecGenHard[ij] =  fh3PtRecGenHard_NoW[ij] = fh3RecEtaPhiPt[ij] = fh3RecEtaPhiPt_NoGen[ij] =fh3GenEtaPhiPt_NoFound[ij] =  fh3GenEtaPhiPt[ij] = 0;
+  }
+  
+}
+
+AliAnalysisTaskJetSpectrum::AliAnalysisTaskJetSpectrum(const char* name):
+  AliAnalysisTaskSE(name),
+  fJetHeaderRec(0x0),
+  fJetHeaderGen(0x0),
+  fAOD(0x0),
+  fBranchRec("jets"),
+  fConfigRec("ConfigJets.C"),
+  fBranchGen(""),
+  fConfigGen(""),
+  fUseAODInput(kFALSE),
+  fUseExternalWeightOnly(kFALSE),
+  fLimitGenJetEta(kFALSE),
+  fAnalysisType(0),
+  fExternalWeight(1),    
+  fh1PtHard(0x0),
+  fh1PtHard_NoW(0x0),  
+  fh1PtHard_Trials(0x0),
+  fh1NGenJets(0x0),
+  fh1NRecJets(0x0),
+  fHistList(0x0)
+{
+  // Default constructor
+  for(int ij  = 0;ij<kMaxJets;++ij){
+    fh1E[ij] = fh1PtRecIn[ij] = fh1PtRecOut[ij] = fh1PtGenIn[ij] = fh1PtGenOut[ij] = 0;
+    fh2PtFGen[ij] =  fh2Frag[ij] = fh2FragLn[ij] = 0;
+
+    fh3PtRecGenHard[ij] =  fh3PtRecGenHard_NoW[ij] = fh3RecEtaPhiPt[ij] = fh3RecEtaPhiPt_NoGen[ij] =fh3GenEtaPhiPt_NoFound[ij] =  fh3GenEtaPhiPt[ij] = 0;
+  }
+
+  DefineOutput(1, TList::Class());  
+}
+
+
+
+
+void AliAnalysisTaskJetSpectrum::UserCreateOutputObjects()
+{
+
+  //
+  // Create the output container
+  //
+
+  
+  // Connect the AOD
+
+  if(fUseAODInput){
+    fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
+    if(!fAOD){
+      Printf("%s:%d AODEvent not found in Input Manager %d",(char*)__FILE__,__LINE__,fUseAODInput);
+      return;
+    }
+    // fethc the header
+    fJetHeaderRec = dynamic_cast<AliJetHeader*>(fInputHandler->GetTree()->GetUserInfo()->FindObject(Form("AliJetHeader_%s",fBranchRec.Data())));
+    if(!fJetHeaderRec){
+      Printf("%s:%d Jet Header not found in the Input",(char*)__FILE__,__LINE__);
+    }
+  }
+  else{
+    //  assume that the AOD is in the general output...
+    fAOD  = AODEvent();
+    if(!fAOD){
+      Printf("%s:%d AODEvent not found in the Output",(char*)__FILE__,__LINE__);
+      return;
+    }
+    fJetHeaderRec = dynamic_cast<AliJetHeader*>(OutputTree()->GetUserInfo()->FindObject(Form("AliJetHeader_%s",fBranchRec.Data())));    
+    if(!fJetHeaderRec){
+      Printf("%s:%d Jet Header not found in the Output",(char*)__FILE__,__LINE__);
+    }
+    else{
+      if(fDebug>10)fJetHeaderRec->Dump();
+    }
+  }
+
+
+  if (fDebug > 1) printf("AnalysisTaskJetSpectrum::UserCreateOutputObjects() \n");
+
+  OpenFile(1);
+  if(!fHistList)fHistList = new TList();
+
+  Bool_t oldStatus = TH1::AddDirectoryStatus();
+  TH1::AddDirectory(kFALSE);
+
+  //
+  //  Histogram
+    
+  const Int_t nBinPt = 100;
+  Double_t binLimitsPt[nBinPt+1];
+  for(Int_t iPt = 0;iPt <= nBinPt;iPt++){
+    if(iPt == 0){
+      binLimitsPt[iPt] = 0.0;
+    }
+    else {// 1.0
+      binLimitsPt[iPt] =  binLimitsPt[iPt-1] + 2;
+    }
+  }
+  const Int_t nBinEta = 22;
+  Double_t binLimitsEta[nBinEta+1];
+  for(Int_t iEta = 0;iEta<=nBinEta;iEta++){
+    if(iEta==0){
+      binLimitsEta[iEta] = -2.2;
+    }
+    else{
+      binLimitsEta[iEta] = binLimitsEta[iEta-1] + 0.2;
+    }
+  }
+
+  const Int_t nBinPhi = 90;
+  Double_t binLimitsPhi[nBinPhi+1];
+  for(Int_t iPhi = 0;iPhi<=nBinPhi;iPhi++){
+    if(iPhi==0){
+      binLimitsPhi[iPhi] = 0;
+    }
+    else{
+      binLimitsPhi[iPhi] = binLimitsPhi[iPhi-1] + 1/(Float_t)nBinPhi * TMath::Pi()*2;
+    }
+  }
+
+  const Int_t nBinFrag = 25;
+
+
+  fh1PtHard = new TH1F("fh1PtHard","PYTHIA Pt hard;p_{T,hard}",nBinPt,binLimitsPt);
+
+  fh1PtHard_NoW = new TH1F("fh1PtHard_NoW","PYTHIA Pt hard no weight;p_{T,hard}",nBinPt,binLimitsPt);
+
+  fh1PtHard_Trials = new TH1F("fh1PtHard_Trials","PYTHIA Pt hard weight with trials;p_{T,hard}",nBinPt,binLimitsPt);
+
+  fh1NGenJets  = new TH1F("fh1NGenJets","N generated jets",20,-0.5,19.5);
+
+  fh1NRecJets = new TH1F("fh1NRecJets","N reconstructed jets",20,-0.5,19.5);
+
+
+  for(int ij  = 0;ij<kMaxJets;++ij){
+    fh1E[ij] = new TH1F(Form("fh1E_j%d",ij),"Jet Energy;E_{jet} (GeV);N",nBinPt,binLimitsPt);
+    fh1PtRecIn[ij] = new TH1F(Form("fh1PtRecIn_j%d",ij),"rec p_T input ;p_{T,rec}",nBinPt,binLimitsPt);
+    fh1PtRecOut[ij] = new TH1F(Form("fh1PtRecOut_j%d",ij),"rec p_T output jets;p_{T,rec}",nBinPt,binLimitsPt);
+    fh1PtGenIn[ij] = new TH1F(Form("fh1PtGenIn_j%d",ij),"found p_T input ;p_{T,gen}",nBinPt,binLimitsPt);
+    fh1PtGenOut[ij] = new TH1F(Form("fh1PtGenOut_j%d",ij),"found p_T output jets;p_{T,gen}",nBinPt,binLimitsPt);
+
+
+    fh2PtFGen[ij] = new TH2F(Form("fh2PtFGen_j%d",ij),"Pt Found vs. gen;p_{T,rec} (GeV/c);p_{T,gen} (GeV/c)",
+                            nBinPt,binLimitsPt,nBinPt,binLimitsPt);
+
+
+
+
+
+
+    fh3PtRecGenHard[ij] = new TH3F(Form("fh3PtRecGenHard_j%d",ij), "Pt hard vs. pt gen vs. pt rec;p_{T,rec};p_{T,gen} (GeV/c);p_{T,hard} (GeV/c)",nBinPt,binLimitsPt,nBinPt,binLimitsPt,nBinPt,binLimitsPt);
+
+
+
+    fh3PtRecGenHard_NoW[ij] = new TH3F(Form("fh3PtRecGenHard_NoW_j%d",ij), "Pt hard vs. pt gen vs. pt rec no weight;p_{T,rec};p_{T,gen} (GeV/c);p_{T,hard} (GeV/c)",nBinPt,binLimitsPt,nBinPt,binLimitsPt,nBinPt,binLimitsPt);
+
+       
+    fh2Frag[ij] = new TH2F(Form("fh2Frag_j%d",ij),"Jet Fragmentation;x=E_{i}/E_{jet};E_{jet};1/N_{jet}dN_{ch}/dx",
+                          nBinFrag,0.,1.,nBinPt,binLimitsPt);
+
+    fh2FragLn[ij] = new TH2F(Form("fh2FragLn_j%d",ij),"Jet Fragmentation Ln;#xi=ln(E_{jet}/E_{i});E_{jet}(GeV);1/N_{jet}dN_{ch}/d#xi",
+                            nBinFrag,0.,10.,nBinPt,binLimitsPt);
+
+    fh3RecEtaPhiPt[ij] = new TH3F(Form("fh3RecEtaPhiPt_j%d",ij),"Rec eta, phi, pt; #eta; #phi; p_{T,rec} (GeV/c)",
+                                 nBinEta,binLimitsEta,nBinPhi,binLimitsPhi,nBinPt,binLimitsPt);
+
+
+
+    fh3RecEtaPhiPt_NoGen[ij] = new TH3F(Form("fh3RecEtaPhiPt_NoGen_j%d",ij),"No generated for found jet Rec eta, phi, pt; #eta; #phi; p_{T,rec} (GeV/c)",
+                                       nBinEta,binLimitsEta,nBinPhi,binLimitsPhi,nBinPt,binLimitsPt);
+
+
+    fh3GenEtaPhiPt_NoFound[ij] = new TH3F(Form("fh3GenEtaPhiPt_NoFound_j%d",ij),"No found for generated jet eta, phi, pt; #eta; #phi; p_{T,rec} (GeV/c)",
+                                       nBinEta,binLimitsEta,nBinPhi,binLimitsPhi,nBinPt,binLimitsPt);
+
+
+
+    fh3GenEtaPhiPt[ij] = new TH3F(Form("fh3GenEtaPhiPt_j%d",ij),"Gen eta, phi, pt; #eta; #phi; p_{T,rec} (GeV/c)",
+                                nBinEta,binLimitsEta,nBinPhi,binLimitsPhi,nBinPt,binLimitsPt);
+
+  }
+
+  const Int_t saveLevel = 2; // large save level more histos
+
+  if(saveLevel>0){
+    fHistList->Add(fh1PtHard);
+    fHistList->Add(fh1PtHard_NoW);
+    fHistList->Add(fh1PtHard_Trials);
+    fHistList->Add(fh1NGenJets);
+    fHistList->Add(fh1NRecJets);
+    for(int ij  = 0;ij<kMaxJets;++ij){
+      fHistList->Add(fh1E[ij]);
+      fHistList->Add(fh1PtRecIn[ij]);
+      fHistList->Add(fh1PtRecOut[ij]);
+      fHistList->Add(fh1PtGenIn[ij]);
+      fHistList->Add(fh1PtGenOut[ij]);
+      fHistList->Add(fh2PtFGen[ij]);
+      if(saveLevel>2){
+       fHistList->Add(fh3RecEtaPhiPt[ij]);
+       fHistList->Add(fh3RecEtaPhiPt_NoGen[ij]);
+       fHistList->Add(fh3GenEtaPhiPt_NoFound[ij]);
+       fHistList->Add(fh3GenEtaPhiPt[ij]);      
+      }
+    }
+  }
+
+  // =========== Switch on Sumw2 for all histos ===========
+  for (Int_t i=0; i<fHistList->GetEntries(); ++i) {
+    TH1 *h1 = dynamic_cast<TH1*>(fHistList->At(i));
+    if (h1){
+      // Printf("%s ",h1->GetName());
+      h1->Sumw2();
+    }
+  }
+
+  TH1::AddDirectory(oldStatus);
+
+}
+
+void AliAnalysisTaskJetSpectrum::Init()
+{
+  //
+  // Initialization
+  //
+
+  Printf(">>> AnalysisTaskJetSpectrum::Init() debug level %d\n",fDebug);
+  if (fDebug > 1) printf("AnalysisTaskJetSpectrum::Init() \n");
+
+}
+
+void AliAnalysisTaskJetSpectrum::UserExec(Option_t */*option*/)
+{
+  //
+  // Execute analysis for current event
+  //
+
+
+
+  if (fDebug > 1)printf("Analysing event # %5d\n", (Int_t) fEntry);
+
+  
+  AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
+
+  if(!aodH){
+    Printf("%s:%d no output aodHandler found Jet",(char*)__FILE__,__LINE__);
+    return;
+  }
+
+
+  //  aodH->SelectEvent(kTRUE);
+
+  // ========= These pointers need to be valid in any case ======= 
+
+
+  /*
+  AliUA1JetHeaderV1 *jhRec = dynamic_cast<AliUA1JetHeaderV1*>(fJetFinderRec->GetHeader());
+  if(!jhRec){
+    Printf("%s:%d No Jet Header found",(char*)__FILE__,__LINE__);
+    return;
+  }
+  */
+  if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
+  TClonesArray *aodRecJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchRec.Data()));
+  if(!aodRecJets){
+    Printf("%s:%d no reconstructed Jet array with name %s in AOD",(char*)__FILE__,__LINE__,fBranchRec.Data());
+    return;
+  }
+
+  // ==== General variables needed
+
+
+  // We use statice array, not to fragment the memory
+  AliAODJet genJets[kMaxJets];
+  Int_t nGenJets = 0;
+  AliAODJet recJets[kMaxJets];
+  Int_t nRecJets = 0;
+
+  Double_t eventW = 1;
+  Double_t ptHard = 0; 
+  Double_t nTrials = 1; // Trials for MC trigger weigth for real data
+
+  if(fUseExternalWeightOnly){
+    eventW = fExternalWeight;
+  }
+
+
+  if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
+  if((fAnalysisType&kAnaMC)==kAnaMC){
+    // this is the part we only use when we have MC information
+    AliMCEvent* mcEvent = MCEvent();
+    //    AliStack *pStack = 0; 
+    if(!mcEvent){
+      Printf("%s:%d no mcEvent",(char*)__FILE__,__LINE__);
+      return;
+    }
+    AliGenPythiaEventHeader*  pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(mcEvent);
+    if(!pythiaGenHeader){
+      return;
+    }
+
+    nTrials = pythiaGenHeader->Trials();
+    ptHard  = pythiaGenHeader->GetPtHard();
+
+
+    if(fDebug>20)AliAnalysisHelperJetTasks::PrintStack(mcEvent);
+
+    if(!fUseExternalWeightOnly){
+       // case were we combine more than one p_T hard bin...
+    }
+
+    // fetch the pythia generated jets only to be used here
+    Int_t nPythiaGenJets = pythiaGenHeader->NTriggerJets();
+    AliAODJet pythiaGenJets[kMaxJets];
+    Int_t iCount = 0;
+    for(int ip = 0;ip < nPythiaGenJets;++ip){
+      if(iCount>=kMaxJets)continue;
+      Float_t p[4];
+      pythiaGenHeader->TriggerJet(ip,p);
+      pythiaGenJets[iCount].SetPxPyPzE(p[0],p[1],p[2],p[3]);
+
+      if(fLimitGenJetEta){
+       if(pythiaGenJets[iCount].Eta()>fJetHeaderRec->GetJetEtaMax()||
+          pythiaGenJets[iCount].Eta()<fJetHeaderRec->GetJetEtaMin())continue;
+      }
+
+
+      if(fBranchGen.Length()==0){
+       // if we have MC particles and we do not read from the aod branch
+       // use the pythia jets
+       genJets[iCount].SetPxPyPzE(p[0],p[1],p[2],p[3]);
+      }
+      iCount++;
+    }
+    if(fBranchGen.Length()==0)nGenJets = iCount;    
+
+  }// (fAnalysisType&kMC)==kMC)
+
+  if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
+  fh1PtHard->Fill(ptHard,eventW);
+  fh1PtHard_NoW->Fill(ptHard,1);
+  fh1PtHard_Trials->Fill(ptHard,nTrials);
+
+  // If we set a second branch for the input jets fetch this 
+  if(fBranchGen.Length()>0){
+    TClonesArray *aodGenJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchGen.Data()));
+    if(aodGenJets){
+      Int_t iCount = 0;
+      for(int ig = 0;ig < aodGenJets->GetEntries();++ig){
+       if(iCount>=kMaxJets)continue;
+       AliAODJet *tmp = dynamic_cast<AliAODJet*>(aodGenJets->At(ig));
+       if(!tmp)continue;
+       if(fLimitGenJetEta){
+         if(tmp->Eta()>fJetHeaderRec->GetJetEtaMax()||
+            tmp->Eta()<fJetHeaderRec->GetJetEtaMin())continue;
+       }
+       genJets[iCount] = *tmp;
+       iCount++;
+      }
+      nGenJets = iCount;
+    }
+    else{
+      Printf("%s:%d Generated jet branch %s not found",(char*)__FILE__,__LINE__,fBranchGen.Data());
+    }
+  }
+
+  fh1NGenJets->Fill(nGenJets);
+  // We do not want to exceed the maximum jet number
+  nGenJets = TMath::Min(nGenJets,kMaxJets);
+
+  // Fetch the reconstructed jets...
+
+
+  nRecJets = aodRecJets->GetEntries();
+  fh1NRecJets->Fill(nRecJets);
+  nRecJets = TMath::Min(nRecJets,kMaxJets);
+
+  for(int ir = 0;ir < nRecJets;++ir){
+    AliAODJet *tmp = dynamic_cast<AliAODJet*>(aodRecJets->At(ir));
+    if(!tmp)continue;
+    recJets[ir] = *tmp;
+  }
+
+
+  if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
+  // Relate the jets
+  Int_t iGenIndex[kMaxJets];    // Index of the generated jet for i-th rec -1 if none
+  Int_t iRecIndex[kMaxJets];    // Index of the rec jet for i-th gen -1 if none
+  
+  for(int i = 0;i<kMaxJets;++i){
+    iGenIndex[i] = iRecIndex[i] = -1;
+  }
+
+
+  GetClosestJets(genJets,nGenJets,recJets,nRecJets,
+                iGenIndex,iRecIndex,fDebug);
+  if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
+
+  if(fDebug){
+    for(int i = 0;i<kMaxJets;++i){
+      if(iGenIndex[i]>=0)Printf("iGenFound: %d -> %d",i,iGenIndex[i]); 
+      if(iRecIndex[i]>=0)Printf("iRecFound: %d -> %d",i,iRecIndex[i]); 
+    }
+  }
+
+  // loop over reconstructed jets
+  for(int ir = 0;ir < nRecJets;++ir){
+    Double_t ptRec = recJets[ir].Pt();
+    Double_t phiRec = recJets[ir].Phi();
+    if(phiRec<0)phiRec+=TMath::Pi()*2.;    
+    Double_t etaRec = recJets[ir].Eta();
+
+    fh1E[ir]->Fill(recJets[ir].E(),eventW);
+    fh1PtRecIn[ir]->Fill(ptRec,eventW);
+    fh3RecEtaPhiPt[ir]->Fill(etaRec,phiRec,ptRec,eventW);
+    // Fill Correlation
+    Int_t ig = iGenIndex[ir];
+    if(ig>=0&&ig<nGenJets){
+      fh1PtRecOut[ir]->Fill(ptRec,eventW);
+      Double_t ptGen = genJets[ig].Pt();
+      fh2PtFGen[ir]->Fill(ptRec,ptGen,eventW);
+      fh3PtRecGenHard[ir]->Fill(ptRec,ptGen,ptHard,eventW);
+      fh3PtRecGenHard_NoW[ir]->Fill(ptRec,ptGen,ptHard,1);
+    }
+    else{
+      fh3RecEtaPhiPt_NoGen[ir]->Fill(etaRec,phiRec,ptRec,eventW);
+    }
+  }// loop over reconstructed jets
+
+
+  if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
+  for(int ig = 0;ig < nGenJets;++ig){
+    Double_t ptGen = genJets[ig].Pt();
+    // Fill Correlation
+    Double_t phiGen = genJets[ig].Phi();
+    if(phiGen<0)phiGen+=TMath::Pi()*2.;    
+    Double_t etaGen = genJets[ig].Eta();
+    fh3GenEtaPhiPt[ig]->Fill(etaGen,phiGen,ptGen,eventW);
+    fh1PtGenIn[ig]->Fill(ptGen,eventW);
+    Int_t ir = iRecIndex[ig];
+    if(ir>=0&&ir<nRecJets){
+      fh1PtGenOut[ig]->Fill(ptGen,eventW);
+    }
+    else{
+      fh3GenEtaPhiPt_NoFound[ig]->Fill(etaGen,phiGen,ptGen,eventW);
+    }
+  }// loop over reconstructed jets
+
+  if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
+  PostData(1, fHistList);
+}
+
+void AliAnalysisTaskJetSpectrum::Terminate(Option_t */*option*/)
+{
+// Terminate analysis
+//
+    if (fDebug > 1) printf("AnalysisJetSpectrum: Terminate() \n");
+}
+
+
+void AliAnalysisTaskJetSpectrum::GetClosestJets(AliAODJet *genJets,Int_t &nGenJets,
+                                               AliAODJet *recJets,Int_t &nRecJets,
+                                               Int_t *iGenIndex,Int_t *iRecIndex,Int_t iDebug){
+
+  //
+  // Relate the two input jet Arrays
+  //
+
+  //
+  // The association has to be unique
+  // So check in two directions
+  // find the closest rec to a gen
+  // and check if there is no other rec which is closer
+  // Caveat: Close low energy/split jets may disturb this correlation
+
+  // Idea: search in two directions generated e.g (a--e) and rec (1--3)
+  // Fill a matrix with Flags (1 for closest rec jet, 2 for closest rec jet
+  // in the end we have something like this
+  //    1   2   3
+  // ------------
+  // a| 3   2   0
+  // b| 0   1   0
+  // c| 0   0   3
+  // d| 0   0   1
+  // e| 0   0   1
+  // Topology
+  //   1     2
+  //     a         b        
+  //
+  //  d      c
+  //        3     e
+  // Only entries with "3" match from both sides
+  
+  const int kMode = 3;
+
+  Int_t iFlag[kMaxJets][kMaxJets];
+
+
+
+  for(int i = 0;i < kMaxJets;++i){
+    iRecIndex[i] = -1;
+    iGenIndex[i] = -1;
+    for(int j = 0;j < kMaxJets;++j)iFlag[i][j] = 0;
+  }
+
+  if(nRecJets==0)return;
+  if(nGenJets==0)return;
+
+  const Float_t maxDist = 1.0;
+  // find the closest distance to the generated
+  for(int ig = 0;ig<nGenJets;++ig){
+    Float_t dist = maxDist;
+    if(iDebug>1)Printf("Gen (%d) p_T %3.3f eta %3.3f ph %3.3f ",ig,genJets[ig].Pt(),genJets[ig].Eta(),genJets[ig].Phi());
+    for(int ir = 0;ir<nRecJets;++ir){
+      Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
+      if(iDebug>1)Printf("Rec (%d) p_T %3.3f eta %3.3f ph %3.3f ",ir,recJets[ir].Pt(),recJets[ir].Eta(),recJets[ir].Phi());
+      if(iDebug>1)Printf("Distance (%d)--(%d) %3.3f ",ig,ir,dR);
+      if(dR<dist){
+       iRecIndex[ig] = ir;
+       dist = dR;
+      }        
+    }
+    if(iRecIndex[ig]>=0)iFlag[ig][iRecIndex[ig]]+=1;
+    // reset...
+    iRecIndex[ig] = -1;
+  }
+  // other way around
+  for(int ir = 0;ir<nRecJets;++ir){
+    Float_t dist = maxDist;
+    for(int ig = 0;ig<nGenJets;++ig){
+      Double_t dR = genJets[ig].DeltaR(&recJets[ir]);
+      if(dR<dist){
+       iGenIndex[ir] = ig;
+       dist = dR;
+      }        
+    }
+    if(iGenIndex[ir]>=0)iFlag[iGenIndex[ir]][ir]+=2;
+    // reset...
+    iGenIndex[ir] = -1;
+  }
+
+  // check for "true" correlations
+
+  if(iDebug>1)Printf(">>>>>> Matrix");
+
+  for(int ig = 0;ig<nGenJets;++ig){
+    for(int ir = 0;ir<nRecJets;++ir){
+      // Print
+      if(iDebug>1)printf("XFL %d ",iFlag[ig][ir]);
+
+      if(kMode==3){
+       // we have a uniqie correlation
+       if(iFlag[ig][ir]==3){
+         iGenIndex[ir] = ig;
+         iRecIndex[ig] = ir;
+       }
+      }
+      else{
+       // we just take the correlation from on side
+       if((iFlag[ig][ir]&2)==2){
+         iGenIndex[ir] = ig;
+       }
+       if((iFlag[ig][ir]&1)==1){
+         iRecIndex[ig] = ir;
+       }
+      }
+    }
+    if(iDebug>1)printf("\n");
+  }
+}
+
+
diff --git a/PWG4/JetTasks/AliAnalysisTaskJetSpectrum.h b/PWG4/JetTasks/AliAnalysisTaskJetSpectrum.h
new file mode 100644 (file)
index 0000000..a89345d
--- /dev/null
@@ -0,0 +1,110 @@
+#ifndef ALIANALYSISTASKJETSPECTRUM_H
+#define ALIANALYSISTASKJETSPECTRUM_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+#include "AliAnalysisTaskSE.h"
+class AliJetHeader;
+class AliESDEvent;
+class AliAODEvent;
+class AliAODJet;
+class AliGenPythiaEventHeader;
+
+class TList;
+class TChain;
+class TH2F;
+class TH3F;
+
+class AliAnalysisTaskJetSpectrum : public AliAnalysisTaskSE
+{
+ public:
+    AliAnalysisTaskJetSpectrum();
+    AliAnalysisTaskJetSpectrum(const char* name);
+    virtual ~AliAnalysisTaskJetSpectrum() {;}
+    // 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);
+
+    virtual void SetExternalWeight(Float_t f){fExternalWeight = f;}
+    virtual void SetUseExternalWeightOnly(Bool_t b){fUseExternalWeightOnly = b;}
+    virtual void SetAODInput(Bool_t b){fUseAODInput = b;}
+    virtual void SetLimitGenJetEta(Bool_t b){fLimitGenJetEta = b;}
+    virtual void SetAnalysisType(Int_t i){fAnalysisType = i;}
+    virtual void SetBranchGen(char* c){fBranchGen = c;}
+    virtual void SetBranchRec(char* c){fBranchRec = c;}
+
+    // Helper
+    static void GetClosestJets(AliAODJet *genJets,Int_t &nGenJets,
+                              AliAODJet *recJets,Int_t &nRecJets,
+                              Int_t *iGenIndex,Int_t *iRecIndex,Int_t iDebug = 0);
+
+  //
+
+    enum {kAnaMC =  0x1};
+
+ private:
+
+    AliAnalysisTaskJetSpectrum(const AliAnalysisTaskJetSpectrum&);
+    AliAnalysisTaskJetSpectrum& operator=(const AliAnalysisTaskJetSpectrum&);
+    
+
+    enum {kMaxJets =  5};
+
+    AliJetHeader *fJetHeaderRec;
+    AliJetHeader *fJetHeaderGen;
+    AliAODEvent  *fAOD; // where we take the jets from can be input or output AOD
+
+    TString       fBranchRec;  // AOD branch name for reconstructed
+    TString       fConfigRec;  // Name of the Config file 
+    TString       fBranchGen;  // AOD brnach for genereated
+    TString       fConfigGen;  // Name of the Config file (if any)
+
+    Bool_t        fUseAODInput;
+    Bool_t        fUseExternalWeightOnly;
+    Bool_t        fLimitGenJetEta;
+    Int_t         fAnalysisType;
+    Float_t       fExternalWeight;    
+
+    TH1F*         fh1PtHard;  // Pt har of the event...       
+    TH1F*         fh1PtHard_NoW;  // Pt har of the event...       
+    TH1F*         fh1PtHard_Trials;  // Number of trials 
+    TH1F*         fh1NGenJets;
+    TH1F*         fh1NRecJets;
+    TH1F*         fh1E[kMaxJets];       // Jet Energy       
+    TH1F*         fh1PtRecIn[kMaxJets];       // Jet pt for all      
+    TH1F*         fh1PtRecOut[kMaxJets];      // Jet pt with corellated generated jet    
+    TH1F*         fh1PtGenIn[kMaxJets];       // Detection efficiency for given p_T.gen
+    TH1F*         fh1PtGenOut[kMaxJets];      //
+
+
+    
+    TH2F*         fh2PtFGen[kMaxJets];  //
+    TH2F*         fh2Frag[kMaxJets];    // fragmentation function
+    TH2F*         fh2FragLn[kMaxJets];  //
+
+    TH3F*         fh3PtRecGenHard[kMaxJets];  //                              
+    TH3F*         fh3PtRecGenHard_NoW[kMaxJets];  //                  
+    TH3F*         fh3RecEtaPhiPt[kMaxJets]; // 
+    TH3F*         fh3RecEtaPhiPt_NoGen[kMaxJets]; // 
+    TH3F*         fh3GenEtaPhiPt_NoFound[kMaxJets]; //                    
+    TH3F*         fh3GenEtaPhiPt[kMaxJets]; //                                                                                                        
+    // ========= Multiplicity dependence ======
+
+    // ==========TODO , flavaor dependence ========                           
+    // ============================================                       
+                                     
+
+    // ============= TODO , phi dependence ========
+    // ============================================                            
+  
+    TList *fHistList; // Output list
+
+
+    ClassDef(AliAnalysisTaskJetSpectrum, 1) // Analysis task for standard jet analysis
+};
+#endif
diff --git a/PWG4/JetTasks/AliAnalysisTaskUE.cxx b/PWG4/JetTasks/AliAnalysisTaskUE.cxx
new file mode 100644 (file)
index 0000000..7ca9cc5
--- /dev/null
@@ -0,0 +1,725 @@
+/**************************************************************************
+ * 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:$ */
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TChain.h>
+#include <TFile.h>
+#include <TList.h>
+#include <TH1I.h>
+#include <TH1F.h>
+#include <TH2F.h>
+#include <TCanvas.h>
+#include <TVector3.h>
+#include <TLorentzVector.h>
+#include <TMath.h>
+
+#include "AliAnalysisTaskUE.h"
+#include "AliAnalysisManager.h"
+#include "AliMCEventHandler.h"
+#include "AliAODEvent.h"
+#include "AliAODInputHandler.h"
+#include "AliAODHandler.h"
+#include "AliStack.h"
+#include "AliAODJet.h"
+#include "AliAODTrack.h"
+
+#include "AliLog.h"
+
+//
+// Analysis class for Underlying Event studies
+//
+// Look for correlations on the tranverse regions to 
+// the leading charged jet
+//
+// This class needs as input AOD with track and Jets
+// the output is a list of histograms
+//
+// AOD can be either connected to the InputEventHandler  
+// for a chain of AOD files 
+// or 
+// to the OutputEventHandler
+// for a chain of ESD files, so this case class should be 
+// in the train after the Jet finder
+//
+//    Arian.Abrahantes.Quintana@cern.ch 
+//    Ernesto.Lopez.Torres@cern.ch
+// 
+
+
+ClassImp( AliAnalysisTaskUE)
+
+////////////////////////////////////////////////////////////////////////
+
+
+//____________________________________________________________________
+AliAnalysisTaskUE:: AliAnalysisTaskUE(const char* name):
+  AliAnalysisTask(name, ""),
+  fDebug(kFALSE),          
+  fAOD(0x0),            
+  fListOfHistos(0x0),  
+  fBinsPtInHist(30),     
+  fMinJetPtInHist(0.),
+  fMaxJetPtInHist(300.),  
+  fAnaType(1),         
+  fRegionType(1),
+  fConeRadius(0.7),
+  fOrdering(1),     
+  fJet1EtaCut(0.2),
+  fJet2DeltaPhiCut(2.616),    // 150 degrees
+  fJet2RatioPtCut(0.8),
+  fJet3PtCut(15.),
+  fTrackPtCut(0.),
+  fTrackEtaCut(0.9),
+  fhNJets(0x0),
+  fhEleadingPt(0x0),
+  fhMinRegPtDist(0x0),
+  fhRegionMultMin(0x0),
+  fhMinRegAvePt(0x0), 
+  fhMinRegSumPt(0x0),            
+  fhMinRegMaxPtPart(0x0),
+  fhMinRegSumPtvsMult(0x0),
+  fhdNdEta_PhiDist(0x0),        
+  fhFullRegPartPtDistVsEt(0x0), 
+  fhTransRegPartPtDistVsEt(0x0),
+  fhRegionSumPtMaxVsEt(0x0),
+  fhRegionMultMax(0x0),         
+  fhRegionMultMaxVsEt(0x0),     
+  fhRegionSumPtMinVsEt(0x0), //fhRegionMultMin(0x0),         
+  fhRegionMultMinVsEt(0x0),     
+  fhRegionAveSumPtVsEt(0x0),    
+  fhRegionDiffSumPtVsEt(0x0),   
+  fhRegionAvePartPtMaxVsEt(0x0),
+  fhRegionAvePartPtMinVsEt(0x0),
+  fhRegionMaxPartPtMaxVsEt(0x0)//,   fhValidRegion(0x0)
+{
+  // Default constructor
+  // Define input and output slots here
+  // Input slot #0 works with a TChain
+  DefineInput(0, TChain::Class());
+  // Output slot #0 writes into a TList container
+  DefineOutput(0, TList::Class());
+}
+
+
+//____________________________________________________________________
+void AliAnalysisTaskUE::ConnectInputData(Option_t* /*option*/)
+{
+// Connect the input data  
+
+// We need AOD with tracks and jets.
+// Since AOD can be either connected to the InputEventHandler or to the OutputEventHandler
+// we need to check where it is and get the pointer to AODEvent in the right way
+  
+  if (fDebug > 1) AliInfo("ConnectInputData() \n");
+  
+  
+  TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
+  
+  if( handler && handler->InheritsFrom("AliAODInputHandler") ) {
+     fAOD  =  ((AliAODInputHandler*)handler)->GetEvent();
+  } else {
+      handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
+      if( handler && handler->InheritsFrom("AliAODHandler") ) {
+         fAOD  = ((AliAODHandler*)handler)->GetAOD();
+      } else {
+        AliFatal("I can't get any AOD Event Handler");
+      }
+   }
+}
+
+//____________________________________________________________________
+void  AliAnalysisTaskUE::CreateOutputObjects()
+{
+// Create the output container
+//
+  if (fDebug > 1) AliInfo("CreateOutPutData()");
+  //
+  //  Histograms
+  CreateHistos();
+  fListOfHistos->SetOwner(kTRUE);  
+//  OpenFile(0);
+}
+
+
+//____________________________________________________________________
+void  AliAnalysisTaskUE::Exec(Option_t */*option*/)
+{
+// Execute analysis for current event
+//
+  AnalyseUE();   
+  // Post the data
+  PostData(0, fListOfHistos);
+}
+  
+  
+//____________________________________________________________________
+void  AliAnalysisTaskUE::Terminate(Option_t */*option*/)
+{
+// Terminate analysis
+//
+
+  // Normalize histos to region area TODO: 
+  Double_t areafactor = 1.;
+  if( fRegionType == 1 ) {
+    areafactor = 1./ (fTrackEtaCut *2. * TMath::Pi()*2.);
+  } else {
+    areafactor = 1./ ( fConeRadius * fConeRadius * TMath::Pi() );
+  }
+  
+  // Draw some Test plot to the screen
+  if (!gROOT->IsBatch()) {
+    
+    // Update pointers reading them from the output slot
+    fListOfHistos = dynamic_cast<TList*> (GetOutputData(0));
+    if( !fListOfHistos ) {
+      AliError("Histogram List is not available");
+      return;
+    }
+    fhEleadingPt         = (TH1F*)fListOfHistos->At(1);
+    fhdNdEta_PhiDist     = (TH1F*)fListOfHistos->At(8);
+    fhRegionSumPtMaxVsEt = (TH1F*)fListOfHistos->At(11);
+    fhRegionSumPtMinVsEt = (TH1F*)fListOfHistos->At(12);
+    fhRegionMultMaxVsEt  = (TH1F*)fListOfHistos->At(14);
+    fhRegionMultMinVsEt  = (TH1F*)fListOfHistos->At(15);
+    fhRegionAveSumPtVsEt = (TH1F*)fListOfHistos->At(16);
+
+    fhNJets              = (TH1F*)fListOfHistos->At(0);
+
+    // Canvas
+    TCanvas* c1 = new TCanvas("c1",Form("sumPt dist (%s)", GetTitle()),60,60,1200,800);
+    c1->Divide(2,2);
+    c1->cd(1);
+    TH1F *h1r = new TH1F("hRegionEtvsSumPtMax" , "", fBinsPtInHist,  fMinJetPtInHist, fMaxJetPtInHist);
+    h1r->Divide(fhRegionSumPtMaxVsEt,fhEleadingPt,1,1);
+    h1r->Scale( areafactor );
+    h1r->SetMarkerStyle(20);
+    h1r->SetXTitle("P_{T} of Leading Jet (GeV/c)");
+    h1r->SetYTitle("P_{T}^{90, max}");
+    h1r->DrawCopy("p");
+    
+    c1->cd(2);
+    
+    TH1F *h2r = new TH1F("hRegionEtvsSumPtMin" , "", fBinsPtInHist,  fMinJetPtInHist, fMaxJetPtInHist);
+    h2r->Divide(fhRegionSumPtMinVsEt,fhEleadingPt,1,1);
+    h2r->Scale( areafactor );
+    h2r->SetMarkerStyle(20);
+    h2r->SetXTitle("P_{T} of Leading Jet (GeV/c)");
+    h2r->SetYTitle("P_{T}^{90, min}");
+    h2r->DrawCopy("p");
+
+    c1->cd(3);
+    TH1F *h4r = new TH1F("hRegionEtvsDiffPt" , "", fBinsPtInHist,  fMinJetPtInHist, fMaxJetPtInHist);
+    h4r->Divide(fhRegionAveSumPtVsEt,fhEleadingPt,1,1);
+    h4r->Scale(2.); // make average
+    h4r->Scale( areafactor );
+    h4r->SetYTitle("#DeltaP_{T}^{90}");
+    h4r->SetXTitle("P_{T} of Leading Jet (GeV/c)");
+    h4r->SetMarkerStyle(20);
+    h4r->DrawCopy("p");
+    
+    c1->cd(4);
+    TH1F *h5r = new TH1F("hRegionMultMaxVsEtleading",   "",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+    TH1F *h6r = new TH1F("hRegionMultMinVsEtleading",   "",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+    
+    h5r->Divide(fhRegionMultMaxVsEt,fhEleadingPt,1,1);
+    h6r->Divide(fhRegionMultMinVsEt,fhEleadingPt,1,1);
+    h5r->Scale( areafactor );
+    h6r->Scale( areafactor );
+    h5r->SetYTitle("N_{Tracks}^{90}");
+    h5r->SetXTitle("P_{T} of Leading Jet (GeV/c)");
+    h5r->SetMarkerStyle(20);
+    h5r->DrawCopy("p");
+    h6r->SetMarkerStyle(21);
+    h6r->SetMarkerColor(2);
+    h6r->SetYTitle("N_{Tracks}^{90}");
+    h6r->SetXTitle("P_{T} of Leading Jet (GeV/c)");
+    h6r->DrawCopy("p same");
+    c1->Update();
+    
+    TCanvas* c2 = new TCanvas("c2","Jet Pt dist",160,160,1200,800);
+    c2->Divide(2,2);
+    c2->cd(1);
+    fhEleadingPt->SetMarkerStyle(20);
+    fhEleadingPt->SetMarkerColor(2);
+    fhEleadingPt->DrawCopy("p");
+    gPad->SetLogy();
+    
+    c2->cd(2);
+    fhdNdEta_PhiDist->SetMarkerStyle(20);
+    fhdNdEta_PhiDist->SetMarkerColor(2);
+    fhdNdEta_PhiDist->DrawCopy("p");
+    gPad->SetLogy();
+    
+    c2->cd(3);      
+    fhNJets->DrawCopy();
+    
+    //fhTransRegPartPtDist  = (TH1F*)fListOfHistos->At(2);
+    fhRegionMultMin          = (TH1F*)fListOfHistos->At(3);
+    fhMinRegAvePt     = (TH1F*)fListOfHistos->At(4);
+    fhMinRegSumPt     = (TH1F*)fListOfHistos->At(5);   
+    //fhMinRegMaxPtPart     = (TH1F*)fListOfHistos->At(6);
+    fhMinRegSumPtvsMult   = (TH1F*)fListOfHistos->At(7);
+
+    // Canvas
+    TCanvas* c3 = new TCanvas("c3"," p_{T} dist",160,160,1200,800);
+    c3->Divide(2,2);
+    c3->cd(1);
+    /*fhTransRegPartPtDist->SetMarkerStyle(20);
+    fhTransRegPartPtDist->SetMarkerColor(2); 
+    fhTransRegPartPtDist->Scale(areafactor/fhTransRegPartPtDist->GetEntries());
+    fhTransRegPartPtDist->DrawCopy("p");
+    gPad->SetLogy();
+    */
+    c3->cd(2); 
+    fhMinRegSumPt->SetMarkerStyle(20);
+    fhMinRegSumPt->SetMarkerColor(2);  
+    fhMinRegSumPt->Scale(areafactor);
+    fhMinRegSumPt->DrawCopy("p");
+    gPad->SetLogy();
+    
+    c3->cd(3);
+    fhMinRegAvePt->SetMarkerStyle(20);
+    fhMinRegAvePt->SetMarkerColor(2);  
+    fhMinRegAvePt->Scale(areafactor);
+    fhMinRegAvePt->DrawCopy("p");
+    gPad->SetLogy();
+    
+    c3->cd(4);
+    
+    TH1F *h7r = new TH1F("hRegionMultMinVsMult",   "",  21, -0.5,   20.5);
+    
+    h7r->Divide(fhMinRegSumPtvsMult,fhRegionMultMin,1,1);
+    
+    h7r->SetMarkerStyle(20);
+    h7r->SetMarkerColor(2);   
+    h7r->DrawCopy("p");
+
+    c3->Update();
+
+    
+/*    c2->cd(3);      
+    fhValidRegion->SetMarkerStyle(20);
+    fhValidRegion->SetMarkerColor(2);
+    fhValidRegion->DrawCopy("p");
+*/    
+    c2->Update();
+  } else {
+    AliInfo(" Batch mode, not histograms will shown...");
+  }
+  
+  if( fDebug > 1 ) 
+     AliInfo("End analysis");
+  
+}
+
+
+//____________________________________________________________________
+void  AliAnalysisTaskUE::AnalyseUE()
+{
+  //
+  // Look for correlations on the tranverse regions to 
+  // the leading charged jet
+  // 
+  // ------------------------------------------------
+  // Find Leading Jets 1,2,3 
+  // (could be skipped if Jets are sort by Pt...)
+  Double_t maxPtJet1 = 0.; 
+  Int_t    index1 = -1;
+  Double_t maxPtJet2 = 0.;   // jet 2 need for back to back inclusive
+  Int_t    index2 = -1;
+  Double_t maxPtJet3 = 0.;   // jet 3 need for back to back exclusive
+  Int_t    index3 = -1;
+  Int_t nJets = fAOD->GetNJets();
+  for( Int_t i=0; i<nJets; ++i ) {
+    AliAODJet* jet = fAOD->GetJet(i);
+    if( jet->Pt() > maxPtJet1 ) {
+      maxPtJet3 = maxPtJet2; index3 = index2;
+      maxPtJet2 = maxPtJet1; index2 = index1;
+      maxPtJet1 = jet->Pt(); index1 = i;
+    } else if( jet->Pt() > maxPtJet2 ) {
+      maxPtJet3 = maxPtJet2; index3 = index2;
+      maxPtJet2 = jet->Pt(); index2 = i;
+    } else if( jet->Pt() > maxPtJet3 ) {
+      maxPtJet3 = jet->Pt(); index3 = i;
+    }
+  }
+
+       if( index1 < 0 ) {
+      AliInfo("\nSkipping Event, not jet found...");
+      return;
+       } else
+      AliInfo(Form("\nPt Leading Jet = %6.1f eta=%5.1f ",  maxPtJet1, fAOD->GetJet(index1)->Eta() ));
+  
+  fhNJets->Fill(nJets);
+  
+  TVector3 jetVect[2];
+  
+  // ----------------------------------------------
+  // Cut events by jets topology 
+  // fAnaType:
+  //     1 = inclusive, 
+  //         - Jet1 |eta| < fJet1EtaCut
+  //     2 = back to back inclusive
+  //         - fulfill case 1
+  //         - |Jet1.Phi - Jet2.Phi| > fJet2DeltaPhiCut
+  //         - Jet2.Pt/Jet1Pt > fJet2RatioPtCut
+  //     3 = back to back exclusive   
+  //         - fulfill case 2
+  //         - Jet3.Pt < fJet3PtCut
+  
+  Bool_t isInclusive = kFALSE;
+  
+  if(  TMath::Abs(fAOD->GetJet(index1)->Eta()) > fJet1EtaCut) {
+    if( fDebug > 1 ) AliInfo("Skipping Event...Jet1 |eta| > fJet1EtaCut");
+    return;
+  }
+  isInclusive = kTRUE;
+  jetVect[0].SetXYZ(fAOD->GetJet(index1)->Px(),
+                    fAOD->GetJet(index1)->Py(),
+                    fAOD->GetJet(index1)->Pz());
+  // back to back inclusive
+  Bool_t isB2Binclusive = kFALSE;                  
+  if( fAnaType > 1 && index2 > 0 && isInclusive) {  
+    jetVect[1].SetXYZ(fAOD->GetJet(index2)->Px(),               
+                      fAOD->GetJet(index2)->Py(),
+                      fAOD->GetJet(index2)->Pz());
+    if( TMath::Abs(jetVect[0].DeltaPhi(jetVect[1])) < fJet2DeltaPhiCut ||
+        maxPtJet2/maxPtJet1 < fJet2RatioPtCut ) {
+      if( fDebug > 1 ) AliInfo("Skipping Event... |Jet1.Phi - Jet2.Phi| < fJet2DeltaPhiCut");
+      return;                 
+    }
+    isB2Binclusive = kTRUE;
+  }
+  if (isInclusive && !isB2Binclusive && fAnaType>1) return;
+  // back to back exclusive
+  Bool_t isB2Bexclusive = kFALSE;
+  if( fAnaType > 2 && index3 > 0 && isB2Binclusive) {  
+    if( fAOD->GetJet(index3)->Pt() > fJet3PtCut ) {
+      if( fDebug > 1 ) AliInfo("Skipping Event... Jet3.Pt > fJet3PtCut ");
+      return;
+    }
+    isB2Bexclusive = kTRUE;
+  }
+  if (isB2Binclusive && !isB2Bexclusive && fAnaType>2) return;
+  
+  AliInfo(Form("njets = %d",nJets));
+  fhEleadingPt->Fill( maxPtJet1 );
+
+  // ----------------------------------------------
+  // Find max and min regions
+  Double_t sumPtRegionPosit = 0.;
+  Double_t sumPtRegionNegat = 0.;
+  Double_t maxPartPtRegion  = 0.;
+  Int_t    nTrackRegionPosit = 0;
+  Int_t    nTrackRegionNegat = 0;
+  static const Double_t k270rad = 270.*TMath::Pi()/180.;
+  
+  Int_t nTracks = fAOD->GetNTracks();
+  for (Int_t ipart=0; ipart<nTracks; ++ipart) {
+    AliAODTrack* part = fAOD->GetTrack( ipart );
+      
+    if ( !part->Charge() ) continue; 
+    if ( part->Pt() < fTrackPtCut ) continue;
+
+    TVector3 partVect(part->Px(), part->Py(), part->Pz());
+    
+    Double_t deltaPhi = jetVect[0].DeltaPhi(partVect)+k270rad;
+    if( deltaPhi > 2.*TMath::Pi() )  deltaPhi-= 2.*TMath::Pi();
+    fhdNdEta_PhiDist->Fill( deltaPhi );
+    fhFullRegPartPtDistVsEt->Fill( part->Pt(), maxPtJet1 );
+     
+    Int_t region = IsTrackInsideRegion( jetVect, &partVect );  
+    
+    if (region > 0) {
+       if( maxPartPtRegion < part->Pt() ) maxPartPtRegion = part->Pt();
+       sumPtRegionPosit += part->Pt();
+       nTrackRegionPosit++;
+       fhTransRegPartPtDistVsEt->Fill( part->Pt(), maxPtJet1 );
+    }
+    if (region < 0) {
+       if( maxPartPtRegion < part->Pt() ) maxPartPtRegion = part->Pt();
+       sumPtRegionNegat += part->Pt();
+       nTrackRegionNegat++;
+       fhTransRegPartPtDistVsEt->Fill( part->Pt(), maxPtJet1 );
+    }
+  }
+
+  //How quantities will be sorted before Fill Min and Max Histogram
+  //  1=Plots will be CDF-like
+  //  2=Plots will be Marchesini-like
+  if (fOrdering==1){
+    if (sumPtRegionPosit > sumPtRegionNegat) {
+      FillSumPtRegion( maxPtJet1, sumPtRegionPosit, sumPtRegionNegat );
+    } else {
+      FillSumPtRegion( maxPtJet1, sumPtRegionNegat, sumPtRegionPosit );
+    }
+    if (nTrackRegionPosit > nTrackRegionNegat ) {
+      FillMultRegion( maxPtJet1, nTrackRegionPosit, nTrackRegionNegat, sumPtRegionNegat );
+    } else {
+      FillMultRegion( maxPtJet1, nTrackRegionNegat, nTrackRegionPosit, sumPtRegionPosit );
+    }
+  } else if (fOrdering==2) {
+    if (sumPtRegionPosit > sumPtRegionNegat) {
+      FillSumPtRegion( maxPtJet1, sumPtRegionPosit, sumPtRegionNegat );
+      FillMultRegion( maxPtJet1, nTrackRegionPosit, nTrackRegionNegat, sumPtRegionNegat );
+    } else {
+      FillSumPtRegion( maxPtJet1, sumPtRegionNegat, sumPtRegionPosit );
+      FillMultRegion( maxPtJet1, nTrackRegionNegat, nTrackRegionPosit, sumPtRegionPosit );
+    }
+  }
+  
+  Double_t avePosRegion = (nTrackRegionPosit) ? sumPtRegionPosit/nTrackRegionPosit : 0.;
+  Double_t aveNegRegion = (nTrackRegionNegat) ? sumPtRegionNegat/nTrackRegionNegat : 0.;
+  if (avePosRegion > aveNegRegion) {
+    FillAvePartPtRegion( maxPtJet1, avePosRegion, aveNegRegion );
+  } else {
+    FillAvePartPtRegion( maxPtJet1, aveNegRegion, avePosRegion );
+  }
+
+  fhRegionMaxPartPtMaxVsEt->Fill(maxPtJet1, maxPartPtRegion );
+       
+  // Compute pedestal like magnitude
+  fhRegionDiffSumPtVsEt->Fill(maxPtJet1, TMath::Abs(sumPtRegionPosit-sumPtRegionNegat)/2.0);
+  fhRegionAveSumPtVsEt->Fill(maxPtJet1, (sumPtRegionPosit+sumPtRegionNegat)/2.0);
+
+}
+
+
+//____________________________________________________________________
+void AliAnalysisTaskUE::FillSumPtRegion( Double_t leadingE, Double_t ptMax, Double_t ptMin  )
+{
+   // Fill sumPt of control regions
+   
+   // Max cone
+   fhRegionSumPtMaxVsEt->Fill( leadingE, ptMax );
+   // Min cone
+   fhRegionSumPtMinVsEt->Fill( leadingE, ptMin );
+   // MAke distributions for UE comparison with MB data
+   fhMinRegSumPt->Fill(ptMin);
+}
+
+//____________________________________________________________________
+void AliAnalysisTaskUE::FillAvePartPtRegion( Double_t leadingE, Double_t ptMax, Double_t ptMin  )
+{
+   // Fill average particle Pt of control regions
+   
+   // Max cone
+   fhRegionAvePartPtMaxVsEt->Fill( leadingE, ptMax );
+   // Min cone
+   fhRegionAvePartPtMinVsEt->Fill( leadingE, ptMin );
+   // MAke distributions for UE comparison with MB data
+   fhMinRegAvePt->Fill(ptMin);
+}
+
+//____________________________________________________________________
+void AliAnalysisTaskUE::FillMultRegion( Double_t leadingE, Double_t nTrackPtmax, Double_t nTrackPtmin, Double_t ptMin  )
+{
+   // Fill Nch multiplicity of control regions
+   
+   // Max cone
+   fhRegionMultMaxVsEt->Fill( leadingE, nTrackPtmax );
+   fhRegionMultMax->Fill( nTrackPtmax );
+   // Min cone
+   fhRegionMultMinVsEt->Fill( leadingE, nTrackPtmin );
+   fhRegionMultMin->Fill( nTrackPtmin );
+   // MAke distributions for UE comparison with MB data
+   fhMinRegSumPtvsMult->Fill(nTrackPtmin,ptMin);
+}
+
+//____________________________________________________________________
+Int_t AliAnalysisTaskUE::IsTrackInsideRegion(TVector3 *jetVect, TVector3 *partVect) 
+{  
+  // return de region in delta phi
+  // -1 negative delta phi 
+  //  1 positive delta phi
+  //  0 outside region
+  static const Double_t k60rad  = 60.*TMath::Pi()/180.;
+  static const Double_t k120rad = 120.*TMath::Pi()/180.;
+  
+  Int_t region = 0;
+  if( fRegionType == 1 ) {
+    if( TMath::Abs(partVect->Eta()) > fTrackEtaCut ) return 0;
+    // transverse regions
+    if (jetVect[0].DeltaPhi(*partVect) < -k60rad && jetVect[0].DeltaPhi(*partVect) > -k120rad ) region = -1;
+    if (jetVect[0].DeltaPhi(*partVect) > k60rad && jetVect[0].DeltaPhi(*partVect) < k120rad ) region = 1;
+  
+  } else if( fRegionType == 2 ) {
+    // Cone regions
+    Double_t deltaR = 0.;
+    
+    TVector3 positVect,negatVect;
+    positVect.SetMagThetaPhi(1, 2.*atan(exp(-jetVect[0].Eta())), jetVect[0].Phi()+TMath::PiOver2());
+    negatVect.SetMagThetaPhi(1, 2.*atan(exp(-jetVect[0].Eta())), jetVect[0].Phi()-TMath::PiOver2());
+    
+    if (TMath::Abs(positVect.DeltaPhi(*partVect)) < fConeRadius ) { 
+       region = 1;  
+       deltaR = positVect.DrEtaPhi(*partVect);
+    } else if (TMath::Abs(negatVect.DeltaPhi(*partVect)) < fConeRadius) { 
+       region = -1;  
+       deltaR = negatVect.DrEtaPhi(*partVect);
+    }
+    
+    if (deltaR > fConeRadius) region = 0;
+  
+  } else 
+    AliError("Unknow region type");
+
+  // For debug (to be removed)
+  //if( region != 0 )  fhValidRegion->Fill( partVect->Eta()-jetVect[0].Eta(), jetVect[0].DeltaPhi(*partVect) );
+  
+  return region;
+}
+
+//____________________________________________________________________
+void  AliAnalysisTaskUE::CreateHistos()
+{
+  fListOfHistos = new TList();
+  
+  
+  fhNJets = new TH1F("fhNJets", "n Jet",  10, 0, 10);
+  fhNJets->SetXTitle("# of jets");
+  fhNJets->Sumw2();
+  fhNJets->Sumw2();
+  fListOfHistos->Add( fhNJets );                 // At(0) 
+  
+  fhEleadingPt  = new TH1F("hEleadingPt",   "Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhEleadingPt->SetXTitle("P_{T} (GeV/c)");
+  fhEleadingPt->SetYTitle("dN/dP_{T}");
+  fhEleadingPt->Sumw2();
+  fListOfHistos->Add( fhEleadingPt );            // At(1)
+  
+  fhMinRegPtDist = new TH1F("hMinRegPtDist",   "P_{T} distribution in Min zone",  50,0.,20.);
+  fhMinRegPtDist->SetXTitle("P_{T} (GeV/c)");
+  fhMinRegPtDist->SetYTitle("dN/dP_{T}");
+  fhMinRegPtDist->Sumw2();
+  fListOfHistos->Add( fhMinRegPtDist );          // At(2)
+  
+  fhRegionMultMin = new TH1F("hRegionMultMin",      "N_{ch}^{90, min}",  21, -0.5,   20.5);
+  fhRegionMultMin->SetXTitle("N_{ch tracks}");
+  fhRegionMultMin->Sumw2();
+  fListOfHistos->Add( fhRegionMultMin );         // At(3)            
+  
+  fhMinRegAvePt = new TH1F("hMinRegAvePt", "#LTp_{T}#GT",  50, 0.,   20.);
+  fhMinRegAvePt->SetXTitle("P_{T} (GeV/c)");
+  fhMinRegAvePt->Sumw2();
+  fListOfHistos->Add( fhMinRegAvePt );           // At(4)
+  
+  fhMinRegSumPt = new TH1F("hMinRegSumPt", "#Sigma p_{T} ",  50, 0.,   20.);
+  fhMinRegSumPt->SetYTitle("Ed^{3}N_{tracks}/dp^{3} (c^{3}/GeV^{2})");  
+  fhMinRegSumPt->SetXTitle("#Sigma p_{T} (GeV/c)");
+  fhMinRegSumPt->Sumw2();
+  fListOfHistos->Add( fhMinRegSumPt );           // At(5)
+              
+  fhMinRegMaxPtPart = new TH1F("hMinRegMaxPtPart", "max(p_{T})|_{event} ",  50, 0.,   20.);
+  fhMinRegMaxPtPart->SetYTitle("Ed^{3}N_{tracks}/dp^{3} (c^{3}/GeV^{2})");  
+  fhMinRegMaxPtPart->SetXTitle("p_{T} (GeV/c)");
+  fhMinRegMaxPtPart->Sumw2();
+  fListOfHistos->Add( fhMinRegMaxPtPart );       // At(6)
+  
+  fhMinRegSumPtvsMult = new TH1F("hMinRegSumPtvsMult", "#Sigma p_{T} vs. Multiplicity ",  21, -0.5,   20.5);
+  fhMinRegSumPtvsMult->SetYTitle("#Sigma p_{T} (GeV/c)");  
+  fhMinRegSumPtvsMult->SetXTitle("N_{charge}");
+  fhMinRegSumPtvsMult->Sumw2();
+  fListOfHistos->Add( fhMinRegSumPtvsMult );     // At(7);
+
+  fhdNdEta_PhiDist  = new TH1F("hdNdEta_PhiDist",   "Charge particle density |#eta|< 1 vs #Delta#phi",  120, 0.,   2.*TMath::Pi());
+  fhdNdEta_PhiDist->SetXTitle("#Delta#phi");
+  fhdNdEta_PhiDist->SetYTitle("dN_{ch}/d#etad#phi");
+  fhdNdEta_PhiDist->Sumw2();
+  fListOfHistos->Add( fhdNdEta_PhiDist );        // At(8)
+   
+  // Can be use to get part pt distribution for differente Jet Pt bins
+  fhFullRegPartPtDistVsEt = new TH2F("hFullRegPartPtDistVsEt", "dN/dP_{T} |#eta|<1 vs Leading Jet P_{T}",  
+               50,0.,50., fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhFullRegPartPtDistVsEt->SetYTitle("Leading Jet P_{T}");
+  fhFullRegPartPtDistVsEt->SetXTitle("p_{T}");
+  fhFullRegPartPtDistVsEt->Sumw2();
+  fListOfHistos->Add( fhFullRegPartPtDistVsEt );  // At(9) 
+   
+   // Can be use to get part pt distribution for differente Jet Pt bins
+  fhTransRegPartPtDistVsEt = new TH2F("hTransRegPartPtDistVsEt", "dN/dP_{T} in tranvese regions |#eta|<1 vs Leading Jet P_{T}",  
+               50,0.,50., fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhTransRegPartPtDistVsEt->SetYTitle("Leading Jet P_{T}");
+  fhTransRegPartPtDistVsEt->SetXTitle("p_{T}");
+  fhTransRegPartPtDistVsEt->Sumw2();
+  fListOfHistos->Add( fhTransRegPartPtDistVsEt );  // At(10)
+  
+  
+  fhRegionSumPtMaxVsEt = new TH1F("hRegionSumPtMaxVsEt",  "P_{T}^{90, max} vs Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhRegionSumPtMaxVsEt->SetXTitle("P_{T} (GeV/c)");
+  fhRegionSumPtMaxVsEt->Sumw2();
+  fListOfHistos->Add( fhRegionSumPtMaxVsEt );      // At(11)
+
+  fhRegionSumPtMinVsEt = new TH1F("hRegionSumPtMinVsEt",   "P_{T}^{90, min} vs Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhRegionSumPtMinVsEt->SetXTitle("P_{T} (GeV/c)");
+  fhRegionSumPtMinVsEt->Sumw2();
+  fListOfHistos->Add( fhRegionSumPtMinVsEt );      // At(12)
+  
+  fhRegionMultMax = new TH1I("hRegionMultMax",      "N_{ch}^{90, max}",  21, -0.5,   20.5);
+  fhRegionMultMax->SetXTitle("N_{ch tracks}");
+  fhRegionMultMax->Sumw2();
+  fListOfHistos->Add( fhRegionMultMax );           // At(13)
+
+  fhRegionMultMaxVsEt = new TH1F("hRegionMultMaxVsEt",  "N_{ch}^{90, max} vs Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhRegionMultMaxVsEt->SetXTitle("E (GeV hRegionAveSumPtVsEt/c)");
+  fhRegionMultMaxVsEt->Sumw2();
+  fListOfHistos->Add( fhRegionMultMaxVsEt );       // At(14)
+
+  fhRegionMultMinVsEt = new TH1F("hRegionMultMinVsEt",  "N_{ch}^{90, min} vs Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhRegionMultMinVsEt->SetXTitle("E (GeV/c)");
+  fhRegionMultMinVsEt->Sumw2();
+  fListOfHistos->Add( fhRegionMultMinVsEt );      // At(15)
+         
+  fhRegionAveSumPtVsEt = new TH1F("hRegionAveSumPtVsEt", "(P_{T}^{90, max} + P_{T}^{90, min})/2 vs Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhRegionAveSumPtVsEt->SetXTitle("P_{T} (GeV/c)");
+  fhRegionAveSumPtVsEt->Sumw2();
+  fListOfHistos->Add( fhRegionAveSumPtVsEt );     // At(16)
+
+  fhRegionDiffSumPtVsEt= new TH1F("hRegionPtDiffVsEt", "(P_{T}^{90, max} - P_{T}^{90, min}) vs Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhRegionDiffSumPtVsEt->SetXTitle("P_{T} (GeV/c)");
+  fhRegionDiffSumPtVsEt->Sumw2();
+  fListOfHistos->Add( fhRegionDiffSumPtVsEt );    // At(17)
+  
+  fhRegionAvePartPtMaxVsEt = new TH1F("hRegionAvePartPtMaxVsEt", "#LTp_{T}#GT^{90, max} vs Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhRegionAvePartPtMaxVsEt->SetXTitle("P_{T} (GeV/c)");
+  fhRegionAvePartPtMaxVsEt->Sumw2();
+  fListOfHistos->Add( fhRegionAvePartPtMaxVsEt );  // At(18)
+
+  fhRegionAvePartPtMinVsEt = new TH1F("hRegionAvePartPtMinVsEt", "#LTp_{T}#GT^{90, min} vs Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhRegionAvePartPtMinVsEt->SetXTitle("P_{T} (GeV/c)");
+  fhRegionAvePartPtMinVsEt->Sumw2();
+  fListOfHistos->Add( fhRegionAvePartPtMinVsEt );   // At(19)
+
+  fhRegionMaxPartPtMaxVsEt = new TH1F("hRegionMaxPartPtMaxVsEt", "max(p_{T})^{90} vs Leading Jet P_{T}",  fBinsPtInHist, fMinJetPtInHist,   fMaxJetPtInHist);
+  fhRegionMaxPartPtMaxVsEt->SetXTitle("P_{T} (GeV/c)");
+  fhRegionMaxPartPtMaxVsEt->Sumw2();
+  fListOfHistos->Add( fhRegionMaxPartPtMaxVsEt );    // At(20)
+
+/*   
+  // For debug region selection
+  fhValidRegion = new TH2F("hValidRegion", "dN/d#eta/d#phi",      
+               20, -2.,2., 62, -TMath::Pi(),   TMath::Pi());
+  fhValidRegion->SetYTitle("#Delta#phi");
+  fhValidRegion->Sumw2();
+  fListOfHistos->Add( fhValidRegion );  // At(15)
+*/
+}
+
+
diff --git a/PWG4/JetTasks/AliAnalysisTaskUE.h b/PWG4/JetTasks/AliAnalysisTaskUE.h
new file mode 100644 (file)
index 0000000..0e3ad62
--- /dev/null
@@ -0,0 +1,138 @@
+#ifndef ALIANALYSISTASKUE_H
+#define ALIANALYSISTASKUE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+#include "AliAnalysisTaskSE.h"
+
+class AliESDEvent;
+class AliAODEvent;
+class TH1F;
+class TH2F;
+class TH1I;
+class TVector3;
+       
+class  AliAnalysisTaskUE : public AliAnalysisTask
+{
+ public:
+                     AliAnalysisTaskUE(const char* name="AliAnalysisTaskUE");
+  virtual           ~AliAnalysisTaskUE() {;}
+  
+  // Implementation of interface methods
+  virtual     void   ConnectInputData(Option_t *);
+  virtual     void   CreateOutputObjects();
+  virtual     void   Exec(Option_t *option);
+  virtual     void   Terminate(Option_t *);
+  
+  //  Setters
+  virtual     void   SetDebugLevel(Int_t level)      { fDebug = level; }
+              void   SetPtRangeInHist(Int_t bin, Double_t min, Double_t max) { 
+                                          fBinsPtInHist = bin; 
+                                          fMinJetPtInHist = min; 
+                                          fMaxJetPtInHist = max; 
+                                       }
+  
+              void   SetAnaTopology(Int_t val)    { fAnaType = val;    }          
+              void   SetRegionType(Int_t val)     { fRegionType = val; }
+              void   SetConeRadius(Double_t val)  { fConeRadius = val; }
+              void   SetPtSumOrdering(Int_t val)  { fOrdering = val;   }
+      // Jet cuts    
+              void   SetJet1EtaCut(Double_t val)      { fJet1EtaCut = val; }
+              void   SetJet2DeltaPhiCut(Double_t val) { fJet2DeltaPhiCut = val; }
+              void   SetJet2RatioPtCut(Double_t val)  { fJet2RatioPtCut = val; }
+              void   SetJet3PtCut(Double_t val)       { fJet3PtCut = val; }
+      // track cuts
+              void   SetTrackPtCut(Double_t val)  { fTrackPtCut = val; }
+              void   SetTrackEtaCut(Double_t val) { fTrackEtaCut = val; }
+
+private:
+                     AliAnalysisTaskUE(const  AliAnalysisTaskUE &det);
+AliAnalysisTaskUE&   operator=(const  AliAnalysisTaskUE &det);
+
+              void   AnalyseUE();
+             Int_t   IsTrackInsideRegion(TVector3 *jetVect, TVector3 *partVect);
+              void   CreateHistos();
+              void   FillSumPtRegion( Double_t leadingE, Double_t ptMax, Double_t ptMin );
+              void   FillAvePartPtRegion( Double_t leadingE, Double_t ptMax, Double_t ptMin );
+              void   FillMultRegion( Double_t leadingE, Double_t nTrackPtmax, Double_t nTrackPtmin, Double_t ptMin );
+    
+       
+             Int_t   fDebug;           //  Debug flag
+       AliAODEvent*  fAOD;             //! AOD Event 
+             TList*  fListOfHistos;    //  Output list of histograms
+      
+      // Config     
+             Int_t   fBinsPtInHist;     //  # bins for Pt histos range
+          Double_t   fMinJetPtInHist;   //  min Jet Pt value for histo range
+          Double_t   fMaxJetPtInHist;   //  max Jet Pt value for histo range
+      
+      // Cuts 
+             Int_t   fAnaType;          // Analysis type on jet topology: 
+                                        //     1=inclusive  (default) 
+                                        //     2=back to back inclusive
+                                        //     3=back to back exclusive
+                                        //     4=gama jet (back to back) ???
+                                        //  Minimum bias
+                                        //     31 = Semi jet (charged leading particle jets)
+                                        //     32 = Random jetcone  ?
+                                        //     33 = Swiss chees   ?
+
+             Int_t   fRegionType;       // 1 = transverse regions (default)
+                                        // 2 = cone regions   
+                                        
+             Double_t   fConeRadius;    // if selected Cone-like region type set Radius (=0.7 default)
+                                        
+             Int_t   fOrdering;         //  Pt and multiplicity summation ordering:
+                                        //     1=CDF-like -independent sorting according quantity to be scored: Double sorting- (default)
+                                        //       if Pt summation will be scored take Pt minimum between both zones and 
+                                        //          fill Pt Max. and Min. histog. accordingly
+                                        //       if Multiplicity summation will be scored take Mult. minimum between both zones and 
+                                        //          fill Mult Max and Min histog. accordingly
+                                        //     2=Marchesini-like (Only Pt sorting: Single sorting)
+                                        //          sort only according Pt summation scored, find minimum between both zones and
+                                        //          fill Pt and Multiplicity Max and Min summation histog. following only this criterium
+                                        //     3=User Selection sorting (NOTE: USER must implement it within cxx)
+                                        
+      // Jet cuts    
+          Double_t   fJet1EtaCut;        // |jet1 eta| < fJet1EtaCut   (fAnaType = 1,2,3)
+          Double_t   fJet2DeltaPhiCut;   // |Jet1.Phi - Jet2.Phi| < fJet2DeltaPhiCut (fAnaType = 2,3)
+          Double_t   fJet2RatioPtCut;    // Jet2.Pt/Jet1Pt > fJet2RatioPtCut  (fAnaType = 2,3)
+          Double_t   fJet3PtCut;         // Jet3.Pt < fJet3PtCut  (fAnaType = 3)
+      // track cuts
+          Double_t   fTrackPtCut;        // Pt cut of tracks in the regions
+          Double_t   fTrackEtaCut;       // Eta cut on tracks in the regions (fRegionType=1)
+
+      // Histograms    ( are owner by fListOfHistos TList )
+              TH1F*  fhNJets;                  //!
+              TH1F*  fhEleadingPt;             //!
+              
+              TH1F*  fhMinRegPtDist;
+              TH1F*  fhRegionMultMin;
+              TH1F*  fhMinRegAvePt; 
+              TH1F*  fhMinRegSumPt;            
+              TH1F*  fhMinRegMaxPtPart;
+              TH1F*  fhMinRegSumPtvsMult;
+              
+              TH1F*  fhdNdEta_PhiDist;         //!
+              TH2F*  fhFullRegPartPtDistVsEt;  //!
+              TH2F*  fhTransRegPartPtDistVsEt; //!
+              
+              TH1F*  fhRegionSumPtMaxVsEt;     //!
+              TH1I*  fhRegionMultMax;          //!
+              TH1F*  fhRegionMultMaxVsEt;      //!
+              TH1F*  fhRegionSumPtMinVsEt;     //!
+              TH1F*  fhRegionMultMinVsEt;      //!
+              TH1F*  fhRegionAveSumPtVsEt;     //!
+              TH1F*  fhRegionDiffSumPtVsEt;    //!
+                     
+              TH1F*  fhRegionAvePartPtMaxVsEt; //!
+              TH1F*  fhRegionAvePartPtMinVsEt; //!
+              TH1F*  fhRegionMaxPartPtMaxVsEt; //!
+              
+      //        TH2F*  fhValidRegion; //! test to be canceled
+         
+    ClassDef( AliAnalysisTaskUE, 1) // Analysis task for Underlying Event analysis
+};
+#endif
index 2c73d5e..1cd145f 100644 (file)
@@ -9,9 +9,9 @@ void SETUP()
    gROOT->ProcessLine(".include JETAN");
 
    // Set the Include paths
-   gSystem->AddIncludePath("-IPWG4");
-   gROOT->ProcessLine(".include PWG4");
+   gSystem->AddIncludePath("-IPWG4JetTasks");
+   gROOT->ProcessLine(".include PWG4JetTasks/JetTasks");
 
    // Set our location, so that other packages can find us
-   gSystem->Setenv("PWG4JetTasks_INCLUDE", "PWG4");
+   gSystem->Setenv("PWG4JetTasks_INCLUDE", "PWG4JetTasks");
 }
index 6cec925..bd7d27e 100644 (file)
@@ -5,9 +5,9 @@ void SETUP()
    gSystem->Load("libPWG4PartCorr");
 
    // Set the Include paths
-   gSystem->SetIncludePath("-I$ROOTSYS/include -IPWG4");
-   gROOT->ProcessLine(".include PWG4");
+   gSystem->SetIncludePath("-I$ROOTSYS/include -IPWG4PartCorr");
+   gROOT->ProcessLine(".include PWG4PartCorr/PartCorr");
 
    // Set our location, so that other packages can find us
-   gSystem->Setenv("PWG4PartCorr_INCLUDE", "PWG4");
+   gSystem->Setenv("PWG4PartCorr_INCLUDE", "PWG4PartCorr/PartCorr");
 }
diff --git a/PWG4/PartCorr/AliAODParticleCorrelation.cxx b/PWG4/PartCorr/AliAODParticleCorrelation.cxx
new file mode 100644 (file)
index 0000000..d9dcdb1
--- /dev/null
@@ -0,0 +1,160 @@
+/**************************************************************************
+ * 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:   AliAODParticleCorrelation.h $ */
+
+//-------------------------------------------------------------------------
+//     AOD class for photon and other particles storage and 
+//     correlation studies
+//     Author: Yves Schutz, CERN, Gustavo Conesa, INFN
+//-------------------------------------------------------------------------
+
+//-- ROOT system --
+
+//-- Analysis system
+#include "AliAODParticleCorrelation.h"
+
+ClassImp(AliAODParticleCorrelation)
+
+
+//______________________________________________________________________________
+AliAODParticleCorrelation::AliAODParticleCorrelation() :
+    AliVParticle(),
+    fMomentum(0),fPdg(-1), fTag(-1),fLabel(-1),fDetector(""),fR(0),
+    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
+}
+
+//______________________________________________________________________________
+AliAODParticleCorrelation::AliAODParticleCorrelation(Double_t px, Double_t py, Double_t pz, Double_t e):
+    AliVParticle(),
+    fMomentum(0),fPdg(-1), fTag(-1),fLabel(-1),fDetector(""),fR(0),
+    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
+    fMomentum = new TLorentzVector(px, py, pz, e);
+}
+
+//______________________________________________________________________________
+AliAODParticleCorrelation::AliAODParticleCorrelation(TLorentzVector & p):
+    AliVParticle(),
+    fMomentum(0),fPdg(-1), fTag(-1),fLabel(-1),fDetector(""),fR(0),
+    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
+    fMomentum = new TLorentzVector(p);
+}
+
+
+//______________________________________________________________________________
+AliAODParticleCorrelation::~AliAODParticleCorrelation() 
+{
+  // destructor
+    delete fMomentum;
+    delete fRefTracks;
+    delete fRefClusters;
+    delete fRefIsolationConeTracks;
+    delete fRefIsolationConeClusters;
+    delete fRefBackgroundTracks;
+    delete fRefBackgroundClusters;
+
+}
+
+//______________________________________________________________________________
+AliAODParticleCorrelation::AliAODParticleCorrelation(const AliAODParticleCorrelation& part) :
+    AliVParticle(part),
+    fMomentum(0) ,fPdg(part.fPdg), fTag(part.fTag),fLabel(part.fLabel),
+    fDetector(part.fDetector),
+    fR(part.fR),
+    fRefTracks(), fRefClusters(),
+    fRefIsolationConeTracks(), fRefIsolationConeClusters(),
+    fRefBackgroundTracks(), fRefBackgroundClusters(),   
+    fLeadingDetector(part.fLeadingDetector), fLeading(part.fLeading),  
+    fCorrJet(part.fCorrJet), fCorrBkg(part.fCorrBkg), fRefJet(part.fRefJet)
+{
+  // Copy constructor
+  fMomentum = new TLorentzVector(*part.fMomentum);
+  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);
+}
+
+//______________________________________________________________________________
+AliAODParticleCorrelation& AliAODParticleCorrelation::operator=(const AliAODParticleCorrelation& part)
+{
+  // Assignment operator
+  if(this!=&part) {
+  }
+  
+  fPdg = part.fPdg;
+  fTag = part.fTag;
+  fLabel = part.fLabel;
+  fR = part.fR;
+  fRefJet = part.fRefJet ;
+  fDetector =part.fDetector;
+  fLeadingDetector =part.fLeadingDetector;
+  fLeading = part.fLeading;
+  fCorrJet = part.fCorrJet ;
+  fCorrBkg = part.fCorrBkg;
+
+  if (fMomentum ) delete fMomentum;
+  if( fRefTracks ) delete fRefTracks ;
+  if( fRefClusters) delete fRefClusters ;
+  if( fRefIsolationConeTracks ) delete fRefIsolationConeTracks ;
+  if( fRefIsolationConeClusters) delete fRefIsolationConeClusters ;
+  if( fRefBackgroundTracks ) delete fRefBackgroundTracks ;
+  if( fRefBackgroundClusters ) delete fRefBackgroundClusters ;
+
+  fMomentum = new TLorentzVector(*part.fMomentum);
+  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 AliAODParticleCorrelation::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("pdg : %d\n",fPdg);
+  printf("tag : %d\n",fTag);
+  printf("R : %2.2f\n",fR);
+  printf("Trigger Detector : %s\n",fDetector.Data());
+  printf("Leading Detector : %s\n",fLeadingDetector.Data());
+  // if(fRefJet) fRefJet.Print();
+
+}
diff --git a/PWG4/PartCorr/AliAODParticleCorrelation.h b/PWG4/PartCorr/AliAODParticleCorrelation.h
new file mode 100644 (file)
index 0000000..7104419
--- /dev/null
@@ -0,0 +1,145 @@
+#ifndef AliAODParticleCorrelation_H
+#define AliAODParticleCorrelation_H
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliAODParticleCorrelation.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 "AliAODJet.h"
+#include "AliVParticle.h"
+
+class AliAODParticleCorrelation : public AliVParticle {
+
+ public:
+    AliAODParticleCorrelation();
+    AliAODParticleCorrelation(Double_t px, Double_t py, Double_t pz, Double_t e);
+    AliAODParticleCorrelation(TLorentzVector & p);  
+    virtual ~AliAODParticleCorrelation();
+    AliAODParticleCorrelation(const AliAODParticleCorrelation& photon); 
+    AliAODParticleCorrelation& operator=(const AliAODParticleCorrelation& 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 Float_t GetR()   const {return fR ; }
+    virtual Int_t GetPdg()   const {return fPdg ; }
+    virtual Int_t GetTag()   const {return fTag ; }
+    virtual Int_t GetLabel()   const {return fLabel ; }
+    virtual TString GetDetector()   const {return fDetector ; }
+
+    virtual void SetR(Float_t r)   {fR = r ; }
+    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 SetDetector(TString d)   {fDetector = d ; }
+
+    virtual TRefArray* GetRefTracks()           const { return  fRefTracks;}
+    virtual void     AddTrack(TObject *tr) {fRefTracks->Add(tr);}
+    TObject* GetTrack(Int_t i) {return fRefTracks->At(i);}
+
+    virtual TRefArray* GetRefClusters()           const { return  fRefClusters;}
+    virtual void     AddCluster(TObject *tr) {fRefClusters->Add(tr);}
+    TObject* GetCluster(Int_t i) {return fRefClusters->At(i);}
+
+    virtual TRefArray* GetRefIsolationConeTracks()           const { return  fRefIsolationConeTracks;}
+    virtual void     AddIsolationConeTrack(TObject *tr) {fRefIsolationConeTracks->Add(tr);}
+    TObject* GetIsolationConeTrack(Int_t i) {return fRefIsolationConeTracks->At(i);}
+
+    virtual TRefArray* GetRefIsolationConeClusters()           const { return  fRefIsolationConeClusters;}
+    virtual void     AddIsolationConeCluster(TObject *tr) {fRefIsolationConeClusters->Add(tr);}
+    TObject* GetIsolationConeCluster(Int_t i) {return fRefIsolationConeClusters->At(i);}
+
+    virtual TRefArray* GetRefBackgroundTracks()           const { return  fRefBackgroundTracks;}
+    virtual void     AddBackgroundTrack(TObject *tr) {fRefBackgroundTracks->Add(tr);}
+    TObject* GetBackgroundTrack(Int_t i) {return fRefBackgroundTracks->At(i);}
+
+    virtual TRefArray* GetRefBackgroundClusters()           const { return  fRefBackgroundClusters;}
+    virtual void     AddBackgroundCluster(TObject *tr) {fRefBackgroundClusters->Add(tr);}
+    TObject* GetBackgroundCluster(Int_t i) {return fRefBackgroundClusters->At(i);}
+
+    virtual void SetLeadingDetector(TString d)   {fLeadingDetector = d ; }
+    virtual TString GetLeadingDetector()   const {return fLeadingDetector ; }
+    
+    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;}
+
+    void SetRefJet(AliAODJet* jet)  { fRefJet = jet;}
+    AliAODJet* GetJet() {return ((AliAODJet*) fRefJet.GetObject());}
+    TRef GetRefJet() {return fRefJet;}
+
+ 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
+    TString         fDetector; // Detector where particle was measured.
+    Float_t         fR ; // Isolation cone size
+    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(AliAODParticleCorrelation,1);
+};
+
+inline Double_t AliAODParticleCorrelation::Phi() const
+{
+  // Return phi
+  Double_t phi = fMomentum->Phi();
+  if (phi < 0.) phi += 2. * TMath::Pi();
+  return phi;
+}
+
+#endif
diff --git a/PWG4/PartCorr/AliAnaCaloTrigger.cxx b/PWG4/PartCorr/AliAnaCaloTrigger.cxx
new file mode 100644 (file)
index 0000000..fcb747b
--- /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 *)
+{
+  // Processing when the event loop is ended
+
+}
diff --git a/PWG4/PartCorr/AliAnaCaloTrigger.h b/PWG4/PartCorr/AliAnaCaloTrigger.h
new file mode 100644 (file)
index 0000000..8ad9f0d
--- /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 = "") ;
+
+  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/PartCorr/AliAnaCaloTriggerMC.cxx b/PWG4/PartCorr/AliAnaCaloTriggerMC.cxx
new file mode 100644 (file)
index 0000000..65540b1
--- /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 *)
+{
+  // Processing when the event loop is ended
+
+}
diff --git a/PWG4/PartCorr/AliAnaCaloTriggerMC.h b/PWG4/PartCorr/AliAnaCaloTriggerMC.h
new file mode 100644 (file)
index 0000000..ce2f770
--- /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 = "") ;
+
+  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/PartCorr/AliAnaExample.cxx b/PWG4/PartCorr/AliAnaExample.cxx
new file mode 100644 (file)
index 0000000..d379201
--- /dev/null
@@ -0,0 +1,360 @@
+/**************************************************************************
+ * 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)
+//-- Author: Gustavo Conesa (LNF-INFN) 
+//_________________________________________________________________________
+
+
+// --- ROOT system ---
+#include "Riostream.h"
+#include "TClonesArray.h"
+#include "TH2F.h"
+#include "TParticle.h"
+
+//---- AliRoot system ----
+#include "AliAnaExample.h"
+#include "AliCaloTrackReader.h"
+#include "AliLog.h"
+#include "AliAODParticleCorrelation.h"
+#include "AliESDCaloCells.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") ; 
+
+  fhPt  = new TH1F ("hPt","p_T distribution", 100,0,100); 
+  fhPt->SetXTitle("p_{T} (GeV/c)");
+  outputContainer->Add(fhPt);
+  fhPhi  = new TH1F ("hPhi","#phi distribution", 100,0,TMath::TwoPi()); 
+  fhPhi->SetXTitle("#phi (rad)");
+  outputContainer->Add(fhPhi);
+
+  fhEta  = new TH1F ("hEta","#eta distribution", 100,-2,2); 
+  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", 100,0,100,100,0,100); 
+    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", 100,0,TMath::TwoPi(), 100,0,TMath::TwoPi()); 
+    fh2Phi->SetXTitle("#phi_{rec} (rad)");
+    fh2Phi->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fh2Phi);
+    
+    fh2Eta  = new TH2F ("h2Eta","#eta distribution, reconstructed vs generated", 100,-1,1,100,-1,1); 
+    fh2Eta->SetXTitle("#eta_{rec} ");
+    fh2Eta->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fh2Eta);
+    
+  }
+  return outputContainer;
+}
+
+ //__________________________________________________
+void AliAnaExample::InitParameters()
+{ 
+  //Initialize the parameters of the analysis.
+  
+  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 AODParticleCorrelation 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 =  dynamic_cast<AliAODCaloCluster*> (partList->At(i));
+      
+      //Fill AODCaloClusters  
+      if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC) 
+       AddAODCaloCluster(AliAODCaloCluster(*(calo)));
+      
+      //Fill AODParticleCorrelation 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());
+       cout<<"PDG "<<pdg<<endl;
+       //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) {
+       AliAODParticleCorrelation ph = AliAODParticleCorrelation(mom);
+       //AddAODParticleCorrelation(AliAODParticleCorrelation(mom));
+       ph.SetLabel(calo->GetLabel(0));
+       ph.SetPdg(pdg);
+       ph.SetDetector(fDetector);
+       AddAODParticleCorrelation(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();
+    }
+    //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 AODParticleCorrelation with CTS aods
+    TVector3 p3;
+    for(Int_t i = 0; i < GetAODCTS()->GetEntriesFast(); i++){
+      
+      AliAODTrack * track =  dynamic_cast<AliAODTrack*> (GetAODCTS()->At(i));
+      
+      //Fill AODParticleCorrelation 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) {
+       AliAODParticleCorrelation tr = AliAODParticleCorrelation(mom[0],mom[1],mom[2],0);
+       //AddAODParticleCorrelation(AliAODParticleCorrelation(mom));
+       tr.SetDetector("CTS");
+       AddAODParticleCorrelation(tr);
+       
+      }//selection
+    }//loop
+  }//CTS analysis
+  
+  if(GetDebug() > 0) {
+    printf("Example: final aod calocluster entries %d\n", GetAODCaloClusters()->GetEntriesFast());
+    printf("Example: final aod branch entries %d\n", GetAODBranch()->GetEntriesFast());
+    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 = GetAODBranch()->GetEntriesFast();
+  if(GetDebug() > 0) printf("histo aod branch entries %d\n", naod);
+  for(Int_t iaod = 0; iaod < naod ; iaod++){
+   AliAODParticleCorrelation* ph =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->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/PartCorr/AliAnaExample.h b/PWG4/PartCorr/AliAnaExample.h
new file mode 100644 (file)
index 0000000..23710ef
--- /dev/null
@@ -0,0 +1,68 @@
+#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)
+
+class TH1F ;
+
+#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/PartCorr/AliAnaGammaDirect.cxx b/PWG4/PartCorr/AliAnaGammaDirect.cxx
new file mode 100644 (file)
index 0000000..da8a4a2
--- /dev/null
@@ -0,0 +1,1039 @@
+/**************************************************************************
+ * 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 iGetEntriesFast(s 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: AliAnaGammaDirect.cxx 28688 2008-09-11 15:04:07Z gconesab $ */
+
+//_________________________________________________________________________
+// Class for the prompt gamma analysis, isolation cut
+//
+//  Class created from old AliPHOSGammaJet 
+//  (see AliRoot versions previous Release 4-09)
+//
+// -- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+  
+  
+// --- ROOT system --- 
+#include <TParticle.h>
+#include <TH2.h>
+#include <TList.h>
+#include "Riostream.h"
+
+// --- Analysis system --- 
+#include "AliAnaGammaDirect.h" 
+#include "AliLog.h"
+#include "AliCaloTrackReader.h"
+#include "AliIsolationCut.h"
+#include "AliNeutralMesonSelection.h"
+
+ClassImp(AliAnaGammaDirect)
+  
+//____________________________________________________________________________
+  AliAnaGammaDirect::AliAnaGammaDirect() : 
+    AliAnaPartCorrBaseClass(), fDetector(""), fMakeIC(0),  fReMakeIC(0), 
+    fMakeSeveralIC(0), fMakeInvMass(0),
+    fhPtGamma(0),fhPhiGamma(0),fhEtaGamma(0), fhConeSumPt(0),
+    //Several IC
+    fNCones(0),fNPtThresFrac(0), fConeSizes(),  fPtThresholds(),  fPtFractions(), 
+    fhPtThresIsolated(), fhPtFracIsolated(),  fhPtSumIsolated(),
+    //MC
+    fhPtPrompt(0),fhPhiPrompt(0),fhEtaPrompt(0), 
+    fhPtThresIsolatedPrompt(), fhPtFracIsolatedPrompt(),  fhPtSumIsolatedPrompt(),
+    fhPtFragmentation(0),fhPhiFragmentation(0),fhEtaFragmentation(0), 
+    fhPtThresIsolatedFragmentation(), fhPtFracIsolatedFragmentation(),  fhPtSumIsolatedFragmentation(),
+    fhPtPi0Decay(0),fhPhiPi0Decay(0),fhEtaPi0Decay(0), 
+    fhPtThresIsolatedPi0Decay(), fhPtFracIsolatedPi0Decay(),  fhPtSumIsolatedPi0Decay(),
+    fhPtOtherDecay(0),fhPhiOtherDecay(0),fhEtaOtherDecay(0), 
+    fhPtThresIsolatedOtherDecay(), fhPtFracIsolatedOtherDecay(),  fhPtSumIsolatedOtherDecay(),
+    fhPtConversion(0),fhPhiConversion(0),fhEtaConversion(0), 
+    fhPtThresIsolatedConversion(), fhPtFracIsolatedConversion(),  fhPtSumIsolatedConversion(),
+    fhPtUnknown(0),fhPhiUnknown(0),fhEtaUnknown(0), 
+    fhPtThresIsolatedUnknown(), fhPtFracIsolatedUnknown(),  fhPtSumIsolatedUnknown()
+{
+  //default ctor
+  
+  //Initialize parameters
+  InitParameters();
+
+  for(Int_t i = 0; i < 5 ; i++){ 
+    fConeSizes[i] = 0 ; 
+    fhPtSumIsolated[i] = 0 ;  
+    
+    fhPtSumIsolatedPrompt[i] = 0 ;  
+    fhPtSumIsolatedFragmentation[i] = 0 ;  
+    fhPtSumIsolatedPi0Decay[i] = 0 ;  
+    fhPtSumIsolatedOtherDecay[i] = 0 ;  
+    fhPtSumIsolatedConversion[i] = 0 ;  
+    fhPtSumIsolatedUnknown[i] = 0 ;  
+    
+    for(Int_t j = 0; j < 5 ; j++){ 
+      fhPtThresIsolated[i][j] = 0 ;  
+      fhPtFracIsolated[i][j] = 0 ; 
+      
+      fhPtThresIsolatedPrompt[i][j] = 0 ;  
+      fhPtThresIsolatedFragmentation[i][j] = 0 ; 
+      fhPtThresIsolatedPi0Decay[i][j] = 0 ;  
+      fhPtThresIsolatedOtherDecay[i][j] = 0 ;  
+      fhPtThresIsolatedConversion[i][j] = 0 ;  
+      fhPtThresIsolatedUnknown[i][j] = 0 ;  
+  
+      fhPtFracIsolatedPrompt[i][j] = 0 ;  
+      fhPtFracIsolatedFragmentation[i][j] = 0 ;  
+      fhPtFracIsolatedPi0Decay[i][j] = 0 ;  
+      fhPtFracIsolatedOtherDecay[i][j] = 0 ;  
+      fhPtFracIsolatedConversion[i][j] = 0 ;
+      fhPtFracIsolatedUnknown[i][j] = 0 ;  
+    }  
+  } 
+  
+  for(Int_t i = 0; i < 5 ; i++){ 
+    fPtFractions[i]=  0 ; 
+    fPtThresholds[i]= 0 ; 
+  } 
+
+
+}
+
+//____________________________________________________________________________
+AliAnaGammaDirect::AliAnaGammaDirect(const AliAnaGammaDirect & g) : 
+  AliAnaPartCorrBaseClass(g), fDetector(g.fDetector),
+  fMakeIC(g.fMakeIC),   fReMakeIC(g.fReMakeIC), 
+  fMakeSeveralIC(g.fMakeSeveralIC),  fMakeInvMass(g.fMakeInvMass),
+  fhPtGamma(g.fhPtGamma),fhPhiGamma(g.fhPhiGamma),
+  fhEtaGamma(g.fhEtaGamma), fhConeSumPt(g.fhConeSumPt),  
+  //Several IC
+  fNCones(g.fNCones),fNPtThresFrac(g.fNPtThresFrac), fConeSizes(), fPtThresholds(),  fPtFractions(), 
+  fhPtThresIsolated(),  fhPtFracIsolated(), fhPtSumIsolated(),
+  //MC
+  fhPtPrompt(g.fhPtPrompt),fhPhiPrompt(g.fhPhiPrompt),fhEtaPrompt(g.fhEtaPrompt), 
+  fhPtThresIsolatedPrompt(), fhPtFracIsolatedPrompt(),  fhPtSumIsolatedPrompt(),
+  fhPtFragmentation(g.fhPtFragmentation),fhPhiFragmentation(g.fhPhiFragmentation),fhEtaFragmentation(g.fhEtaFragmentation), 
+  fhPtThresIsolatedFragmentation(), fhPtFracIsolatedFragmentation(),  fhPtSumIsolatedFragmentation(),
+  fhPtPi0Decay(g.fhPtPi0Decay),fhPhiPi0Decay(g.fhPhiPi0Decay),fhEtaPi0Decay(g.fhEtaPi0Decay), 
+  fhPtThresIsolatedPi0Decay(), fhPtFracIsolatedPi0Decay(),  fhPtSumIsolatedPi0Decay(),
+  fhPtOtherDecay(g.fhPtOtherDecay),fhPhiOtherDecay(g.fhPhiOtherDecay),fhEtaOtherDecay(g.fhEtaOtherDecay), 
+  fhPtThresIsolatedOtherDecay(), fhPtFracIsolatedOtherDecay(),  fhPtSumIsolatedOtherDecay(),
+  fhPtConversion(g. fhPtConversion),fhPhiConversion(g.fhPhiConversion),fhEtaConversion(g.fhEtaConversion), 
+  fhPtThresIsolatedConversion(), fhPtFracIsolatedConversion(),  fhPtSumIsolatedConversion(),
+  fhPtUnknown(g.fhPtUnknown),fhPhiUnknown(g.fhPhiUnknown),fhEtaUnknown(g.fhEtaUnknown), 
+  fhPtThresIsolatedUnknown(), fhPtFracIsolatedUnknown(),  fhPtSumIsolatedUnknown()
+{
+  // cpy ctor
+  
+  //Several IC
+  for(Int_t i = 0; i < fNCones ; i++){
+    fConeSizes[i] =  g.fConeSizes[i];
+    fhPtSumIsolated[i] = g.fhPtSumIsolated[i]; 
+
+   fhPtSumIsolatedPrompt[i] = g.fhPtSumIsolatedPrompt[i]; 
+   fhPtSumIsolatedFragmentation[i] = g.fhPtSumIsolatedFragmentation[i]; 
+   fhPtSumIsolatedPi0Decay[i] = g.fhPtSumIsolatedPi0Decay[i]; 
+   fhPtSumIsolatedOtherDecay[i] = g.fhPtSumIsolatedOtherDecay[i]; 
+   fhPtSumIsolatedConversion[i] = g.fhPtSumIsolatedConversion[i]; 
+   fhPtSumIsolatedUnknown[i] = g.fhPtSumIsolatedUnknown[i]; 
+
+    for(Int_t j = 0; j < fNPtThresFrac ; j++){
+      fhPtThresIsolated[i][j] = g.fhPtThresIsolated[i][j]; 
+      fhPtFracIsolated[i][j] = g.fhPtFracIsolated[i][j];
+
+      fhPtThresIsolatedPrompt[i][j] = g.fhPtThresIsolatedPrompt[i][j]; 
+      fhPtThresIsolatedFragmentation[i][j] = g.fhPtThresIsolatedFragmentation[i][j]; 
+      fhPtThresIsolatedPi0Decay[i][j] = g.fhPtThresIsolatedPi0Decay[i][j]; 
+      fhPtThresIsolatedOtherDecay[i][j] = g.fhPtThresIsolatedOtherDecay[i][j]; 
+      fhPtThresIsolatedConversion[i][j] = g.fhPtThresIsolatedConversion[i][j]; 
+      fhPtThresIsolatedUnknown[i][j] = g.fhPtThresIsolatedUnknown[i][j]; 
+      fhPtFracIsolatedPrompt[i][j] = g.fhPtFracIsolatedPrompt[i][j]; 
+      fhPtFracIsolatedFragmentation[i][j] = g.fhPtFracIsolatedFragmentation[i][j]; 
+      fhPtFracIsolatedPi0Decay[i][j] = g.fhPtFracIsolatedPi0Decay[i][j]; 
+      fhPtFracIsolatedOtherDecay[i][j] = g.fhPtFracIsolatedOtherDecay[i][j]; 
+      fhPtFracIsolatedConversion[i][j] = g.fhPtFracIsolatedConversion[i][j]; 
+      fhPtFracIsolatedUnknown[i][j] = g.fhPtFracIsolatedUnknown[i][j]; 
+
+    } 
+  }
+  
+  for(Int_t i = 0; i < fNPtThresFrac ; i++){
+    fPtFractions[i]=   g.fPtFractions[i];
+    fPtThresholds[i]=   g.fPtThresholds[i];
+  }
+
+}
+
+//_________________________________________________________________________
+AliAnaGammaDirect & AliAnaGammaDirect::operator = (const AliAnaGammaDirect & g)
+{
+  // assignment operator
+  
+  if(&g == this) return *this;
+
+  fMakeIC = g.fMakeIC ;
+  fReMakeIC = g.fReMakeIC ;
+  fMakeSeveralIC = g.fMakeSeveralIC ;
+  fMakeInvMass = g.fMakeInvMass ;
+  fDetector = g.fDetector ;
+
+  fhPtGamma = g.fhPtGamma ; 
+  fhPhiGamma = g.fhPhiGamma ;
+  fhEtaGamma = g.fhEtaGamma ;
+  fhConeSumPt = g.fhConeSumPt ;
+
+  fhPtPrompt = g.fhPtPrompt;
+  fhPhiPrompt = g.fhPhiPrompt;
+  fhEtaPrompt = g.fhEtaPrompt; 
+  fhPtFragmentation = g.fhPtFragmentation;
+  fhPhiFragmentation = g.fhPhiFragmentation;
+  fhEtaFragmentation = g.fhEtaFragmentation; 
+  fhPtPi0Decay = g.fhPtPi0Decay;
+  fhPhiPi0Decay = g.fhPhiPi0Decay;
+  fhEtaPi0Decay = g.fhEtaPi0Decay; 
+  fhPtOtherDecay = g.fhPtOtherDecay;
+  fhPhiOtherDecay = g.fhPhiOtherDecay;
+  fhEtaOtherDecay = g.fhEtaOtherDecay; 
+  fhPtConversion = g. fhPtConversion;
+  fhPhiConversion = g.fhPhiConversion;
+  fhEtaConversion = g.fhEtaConversion; 
+  fhPtUnknown = g.fhPtUnknown;
+  fhPhiUnknown = g.fhPhiUnknown;
+  fhEtaUnknown = g.fhEtaUnknown; 
+
+  //Several IC
+  fNCones = g.fNCones ;
+  fNPtThresFrac = g.fNPtThresFrac ; 
+   
+  for(Int_t i = 0; i < fNCones ; i++){
+    fConeSizes[i] =  g.fConeSizes[i];
+    fhPtSumIsolated[i] = g.fhPtSumIsolated[i] ;
+
+   fhPtSumIsolatedPrompt[i] = g.fhPtSumIsolatedPrompt[i]; 
+   fhPtSumIsolatedFragmentation[i] = g.fhPtSumIsolatedFragmentation[i]; 
+   fhPtSumIsolatedPi0Decay[i] = g.fhPtSumIsolatedPi0Decay[i]; 
+   fhPtSumIsolatedOtherDecay[i] = g.fhPtSumIsolatedOtherDecay[i]; 
+   fhPtSumIsolatedConversion[i] = g.fhPtSumIsolatedConversion[i]; 
+   fhPtSumIsolatedUnknown[i] = g.fhPtSumIsolatedUnknown[i]; 
+
+    for(Int_t j = 0; j < fNPtThresFrac ; j++){
+      fhPtThresIsolated[i][j] = g.fhPtThresIsolated[i][j] ;
+      fhPtFracIsolated[i][j] = g.fhPtFracIsolated[i][j] ;
+
+      fhPtThresIsolatedPrompt[i][j] = g.fhPtThresIsolatedPrompt[i][j]; 
+      fhPtThresIsolatedFragmentation[i][j] = g.fhPtThresIsolatedFragmentation[i][j]; 
+      fhPtThresIsolatedPi0Decay[i][j] = g.fhPtThresIsolatedPi0Decay[i][j]; 
+      fhPtThresIsolatedOtherDecay[i][j] = g.fhPtThresIsolatedOtherDecay[i][j]; 
+      fhPtThresIsolatedConversion[i][j] = g.fhPtThresIsolatedConversion[i][j]; 
+      fhPtThresIsolatedUnknown[i][j] = g.fhPtThresIsolatedUnknown[i][j]; 
+      fhPtFracIsolatedPrompt[i][j] = g.fhPtFracIsolatedPrompt[i][j]; 
+      fhPtFracIsolatedFragmentation[i][j] = g.fhPtFracIsolatedFragmentation[i][j]; 
+      fhPtFracIsolatedPi0Decay[i][j] = g.fhPtFracIsolatedPi0Decay[i][j]; 
+      fhPtFracIsolatedOtherDecay[i][j] = g.fhPtFracIsolatedOtherDecay[i][j]; 
+      fhPtFracIsolatedConversion[i][j] = g.fhPtFracIsolatedConversion[i][j]; 
+      fhPtFracIsolatedUnknown[i][j] = g.fhPtFracIsolatedUnknown[i][j]; 
+
+    }
+  }
+  
+  for(Int_t i = 0; i < fNPtThresFrac ; i++){
+    fPtThresholds[i]=   g.fPtThresholds[i];
+    fPtFractions[i]=   g.fPtFractions[i];
+  }
+
+  return *this;
+  
+}
+
+//____________________________________________________________________________
+AliAnaGammaDirect::~AliAnaGammaDirect() 
+{
+  //dtor
+  //do not delete histograms
+
+ delete [] fConeSizes ; 
+ delete [] fPtThresholds ; 
+ delete [] fPtFractions ; 
+
+}
+//_________________________________________________________________________
+Bool_t AliAnaGammaDirect::CheckInvMass(const Int_t icalo,const TLorentzVector mom, Double_t *vertex, TClonesArray * pl){
+  //Search if there is a companion decay photon to the candidate 
+  // and discard it in such case
+  TLorentzVector mom2 ;
+  for(Int_t jcalo = 0; jcalo < pl->GetEntriesFast(); jcalo++){
+    if(icalo==jcalo) continue ;
+    AliAODCaloCluster * calo =  dynamic_cast<AliAODCaloCluster*> (pl->At(jcalo));
+  
+    //Cluster selection, not charged, with photon id and in fidutial cut, fill TLorentz
+    if(!SelectCluster(calo, vertex, mom2)) continue ;
+
+    //Select good pair (good phit, pt cuts, aperture and invariant mass)
+    if(GetNeutralMesonSelection()->SelectPair(mom, mom2)){
+      if(GetDebug()>1)printf("Selected gamma pair: pt %f, phi %f, eta%f",(mom+mom2).Pt(), (mom+mom2).Phi(), (mom+mom2).Eta());
+      return kTRUE ;
+    }
+  }//loop
+
+  return kFALSE;
+
+}
+//_________________________________________________________________________
+Int_t AliAnaGammaDirect::CheckOrigin(const Int_t label){
+  //Play with the MC stack if available
+  //Check origin of the candidates, good for PYTHIA
+  
+  AliStack * stack =  GetMCStack() ;
+  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(label < 8 ) printf("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
+      printf("Parent with label %d\n",iParent);
+    
+    //return tag
+    if(mPdg == 22){
+      if(mStatus == 1){
+       if(iParent < 8) {
+         if(pPdg == 22) return kPrompt;
+         else  return kFragmentation;
+       }
+       else if(pStatus == 11){
+         if(pPdg == 111) return kPi0Decay ;
+         else if (pPdg == 321)  return kEtaDecay ;
+         else  return kOtherDecay ;
+       }
+      }//Status 1 : Pythia generated
+      else if(mStatus == 0){
+       if(pPdg ==22 || pPdg ==11) return kConversion ;
+       if(pPdg == 111) return kPi0Decay ;
+       else if (pPdg == 221)  return kEtaDecay ;
+       else  return kOtherDecay ;
+      }//status 0 : geant generated
+    }//Mother gamma
+    else if(mPdg == 111)  return kPi0 ;
+    else if(mPdg == 221)  return kEta ;
+    else if(mPdg ==11){
+      if(mStatus == 0) return kConversion ;
+      else return kElectron ;
+    }
+    else return kUnknown;
+  }//Good label value
+  else{
+    if(label < 0 ) printf("*** bad label or no stack ***:  label %d \n", label);
+    if(label >=  stack->GetNtrack()) printf("*** large label ***:  label %d, n tracks %d \n", label, stack->GetNtrack());
+    return kUnknown;
+  }//Bad label
+  
+  return kUnknown;
+  
+}
+
+//________________________________________________________________________
+TList *  AliAnaGammaDirect::GetCreateOutputObjects()
+{  
+  // Create histograms to be saved in output file and 
+  // store them in outputContainer
+  TList * outputContainer = new TList() ; 
+  outputContainer->SetName("DirectGammaHistos") ; 
+
+  //Histograms of highest gamma identified in Event
+  fhPtGamma  = new TH1F("hPtGamma","Number of #gamma over calorimeter",240,0,120); 
+  fhPtGamma->SetYTitle("N");
+  fhPtGamma->SetXTitle("p_{T #gamma}(GeV/c)");
+  outputContainer->Add(fhPtGamma) ; 
+  
+  fhPhiGamma  = new TH2F
+    ("hPhiGamma","#phi_{#gamma}",200,0,120,200,0,7); 
+  fhPhiGamma->SetYTitle("#phi");
+  fhPhiGamma->SetXTitle("p_{T #gamma} (GeV/c)");
+  outputContainer->Add(fhPhiGamma) ; 
+  
+  fhEtaGamma  = new TH2F
+    ("hEtaGamma","#phi_{#gamma}",200,0,120,200,-0.8,0.8); 
+  fhEtaGamma->SetYTitle("#eta");
+  fhEtaGamma->SetXTitle("p_{T #gamma} (GeV/c)");
+  outputContainer->Add(fhEtaGamma) ;
+
+  if(!fMakeSeveralIC){
+    fhConeSumPt  = new TH2F
+      ("hConePtSum","#Sigma p_{T}  in cone ",200,0,120,100,0,100);
+    fhConeSumPt->SetYTitle("#Sigma p_{T}");
+    fhConeSumPt->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhConeSumPt) ;
+  }
+  
+  if(IsDataMC()){
+    
+    fhPtPrompt  = new TH1F("hPtPrompt","Number of #gamma over calorimeter",240,0,120); 
+    fhPtPrompt->SetYTitle("N");
+    fhPtPrompt->SetXTitle("p_{T #gamma}(GeV/c)");
+    outputContainer->Add(fhPtPrompt) ; 
+    
+    fhPhiPrompt  = new TH2F
+      ("hPhiPrompt","#phi_{#gamma}",200,0,120,200,0,7); 
+    fhPhiPrompt->SetYTitle("#phi");
+    fhPhiPrompt->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhPhiPrompt) ; 
+    
+    fhEtaPrompt  = new TH2F
+      ("hEtaPrompt","#phi_{#gamma}",200,0,120,200,-0.8,0.8); 
+    fhEtaPrompt->SetYTitle("#eta");
+    fhEtaPrompt->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhEtaPrompt) ;
+    
+    fhPtFragmentation  = new TH1F("hPtFragmentation","Number of #gamma over calorimeter",240,0,120); 
+    fhPtFragmentation->SetYTitle("N");
+    fhPtFragmentation->SetXTitle("p_{T #gamma}(GeV/c)");
+    outputContainer->Add(fhPtFragmentation) ; 
+    
+    fhPhiFragmentation  = new TH2F
+      ("hPhiFragmentation","#phi_{#gamma}",200,0,120,200,0,7); 
+    fhPhiFragmentation->SetYTitle("#phi");
+    fhPhiFragmentation->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhPhiFragmentation) ; 
+    
+    fhEtaFragmentation  = new TH2F
+      ("hEtaFragmentation","#phi_{#gamma}",200,0,120,200,-0.8,0.8); 
+    fhEtaFragmentation->SetYTitle("#eta");
+    fhEtaFragmentation->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhEtaFragmentation) ;
+    
+    fhPtPi0Decay  = new TH1F("hPtPi0Decay","Number of #gamma over calorimeter",240,0,120); 
+    fhPtPi0Decay->SetYTitle("N");
+    fhPtPi0Decay->SetXTitle("p_{T #gamma}(GeV/c)");
+    outputContainer->Add(fhPtPi0Decay) ; 
+    
+    fhPhiPi0Decay  = new TH2F
+      ("hPhiPi0Decay","#phi_{#gamma}",200,0,120,200,0,7); 
+    fhPhiPi0Decay->SetYTitle("#phi");
+    fhPhiPi0Decay->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhPhiPi0Decay) ; 
+    
+    fhEtaPi0Decay  = new TH2F
+      ("hEtaPi0Decay","#phi_{#gamma}",200,0,120,200,-0.8,0.8); 
+    fhEtaPi0Decay->SetYTitle("#eta");
+    fhEtaPi0Decay->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhEtaPi0Decay) ;
+    
+    fhPtOtherDecay  = new TH1F("hPtOtherDecay","Number of #gamma over calorimeter",240,0,120); 
+    fhPtOtherDecay->SetYTitle("N");
+    fhPtOtherDecay->SetXTitle("p_{T #gamma}(GeV/c)");
+    outputContainer->Add(fhPtOtherDecay) ; 
+    
+    fhPhiOtherDecay  = new TH2F
+      ("hPhiOtherDecay","#phi_{#gamma}",200,0,120,200,0,7); 
+    fhPhiOtherDecay->SetYTitle("#phi");
+    fhPhiOtherDecay->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhPhiOtherDecay) ; 
+    
+    fhEtaOtherDecay  = new TH2F
+      ("hEtaOtherDecay","#phi_{#gamma}",200,0,120,200,-0.8,0.8); 
+    fhEtaOtherDecay->SetYTitle("#eta");
+    fhEtaOtherDecay->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhEtaOtherDecay) ;
+    
+    fhPtConversion  = new TH1F("hPtConversion","Number of #gamma over calorimeter",240,0,120); 
+    fhPtConversion->SetYTitle("N");
+    fhPtConversion->SetXTitle("p_{T #gamma}(GeV/c)");
+    outputContainer->Add(fhPtConversion) ; 
+    
+    fhPhiConversion  = new TH2F
+      ("hPhiConversion","#phi_{#gamma}",200,0,120,200,0,7); 
+    fhPhiConversion->SetYTitle("#phi");
+    fhPhiConversion->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhPhiConversion) ; 
+    
+    fhEtaConversion  = new TH2F
+      ("hEtaConversion","#phi_{#gamma}",200,0,120,200,-0.8,0.8); 
+    fhEtaConversion->SetYTitle("#eta");
+    fhEtaConversion->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhEtaConversion) ;
+    
+    fhPtUnknown  = new TH1F("hPtUnknown","Number of #gamma over calorimeter",240,0,120); 
+    fhPtUnknown->SetYTitle("N");
+    fhPtUnknown->SetXTitle("p_{T #gamma}(GeV/c)");
+    outputContainer->Add(fhPtUnknown) ; 
+    
+    fhPhiUnknown  = new TH2F
+      ("hPhiUnknown","#phi_{#gamma}",200,0,120,200,0,7); 
+    fhPhiUnknown->SetYTitle("#phi");
+    fhPhiUnknown->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhPhiUnknown) ; 
+    
+    fhEtaUnknown  = new TH2F
+      ("hEtaUnknown","#phi_{#gamma}",200,0,120,200,-0.8,0.8); 
+    fhEtaUnknown->SetYTitle("#eta");
+    fhEtaUnknown->SetXTitle("p_{T #gamma} (GeV/c)");
+    outputContainer->Add(fhEtaUnknown) ;
+  }//Histos with MC
+  
+  if(fMakeSeveralIC){
+    char name[128];
+    char title[128];
+    for(Int_t icone = 0; icone<fNCones; icone++){
+      sprintf(name,"hPtSumIsolated_Cone_%d",icone);
+      sprintf(title,"Candidate cone sum p_{T} for cone size %d vs candidate p_{T}",icone);
+      fhPtSumIsolated[icone]  = new TH2F(name, title,240,0,120,120,0,10);
+      fhPtSumIsolated[icone]->SetYTitle("#Sigma p_{T} (GeV/c)");
+      fhPtSumIsolated[icone]->SetXTitle("p_{T} (GeV/c)");
+      outputContainer->Add(fhPtSumIsolated[icone]) ; 
+    
+      if(IsDataMC()){
+       sprintf(name,"hPtSumIsolatedPrompt_Cone_%d",icone);
+       sprintf(title,"Candidate Prompt cone sum p_{T} for cone size %d vs candidate p_{T}",icone);
+       fhPtSumIsolatedPrompt[icone]  = new TH2F(name, title,240,0,120,120,0,10);
+       fhPtSumIsolatedPrompt[icone]->SetYTitle("#Sigma p_{T} (GeV/c)");
+       fhPtSumIsolatedPrompt[icone]->SetXTitle("p_{T} (GeV/c)");
+       outputContainer->Add(fhPtSumIsolatedPrompt[icone]) ; 
+
+       sprintf(name,"hPtSumIsolatedFragmentation_Cone_%d",icone);
+       sprintf(title,"Candidate Fragmentation cone sum p_{T} for cone size %d vs candidate p_{T}",icone);
+       fhPtSumIsolatedFragmentation[icone]  = new TH2F(name, title,240,0,120,120,0,10);
+       fhPtSumIsolatedFragmentation[icone]->SetYTitle("#Sigma p_{T} (GeV/c)");
+       fhPtSumIsolatedFragmentation[icone]->SetXTitle("p_{T} (GeV/c)");
+       outputContainer->Add(fhPtSumIsolatedFragmentation[icone]) ; 
+
+       sprintf(name,"hPtSumIsolatedPi0Decay_Cone_%d",icone);
+       sprintf(title,"Candidate Pi0Decay cone sum p_{T} for cone size %d vs candidate p_{T}",icone);
+       fhPtSumIsolatedPi0Decay[icone]  = new TH2F(name, title,240,0,120,120,0,10);
+       fhPtSumIsolatedPi0Decay[icone]->SetYTitle("#Sigma p_{T} (GeV/c)");
+       fhPtSumIsolatedPi0Decay[icone]->SetXTitle("p_{T} (GeV/c)");
+       outputContainer->Add(fhPtSumIsolatedPi0Decay[icone]) ; 
+
+       sprintf(name,"hPtSumIsolatedOtherDecay_Cone_%d",icone);
+       sprintf(title,"Candidate OtherDecay cone sum p_{T} for cone size %d vs candidate p_{T}",icone);
+       fhPtSumIsolatedOtherDecay[icone]  = new TH2F(name, title,240,0,120,120,0,10);
+       fhPtSumIsolatedOtherDecay[icone]->SetYTitle("#Sigma p_{T} (GeV/c)");
+       fhPtSumIsolatedOtherDecay[icone]->SetXTitle("p_{T} (GeV/c)");
+       outputContainer->Add(fhPtSumIsolatedOtherDecay[icone]) ; 
+
+       sprintf(name,"hPtSumIsolatedConversion_Cone_%d",icone);
+       sprintf(title,"Candidate Conversion cone sum p_{T} for cone size %d vs candidate p_{T}",icone);
+       fhPtSumIsolatedConversion[icone]  = new TH2F(name, title,240,0,120,120,0,10);
+       fhPtSumIsolatedConversion[icone]->SetYTitle("#Sigma p_{T} (GeV/c)");
+       fhPtSumIsolatedConversion[icone]->SetXTitle("p_{T} (GeV/c)");
+       outputContainer->Add(fhPtSumIsolatedConversion[icone]) ; 
+
+       sprintf(name,"hPtSumIsolatedUnknown_Cone_%d",icone);
+       sprintf(title,"Candidate Unknown cone sum p_{T} for cone size %d vs candidate p_{T}",icone);
+       fhPtSumIsolatedUnknown[icone]  = new TH2F(name, title,240,0,120,120,0,10);
+       fhPtSumIsolatedUnknown[icone]->SetYTitle("#Sigma p_{T} (GeV/c)");
+       fhPtSumIsolatedUnknown[icone]->SetXTitle("p_{T} (GeV/c)");
+       outputContainer->Add(fhPtSumIsolatedUnknown[icone]) ; 
+
+      }//Histos with MC
+
+      for(Int_t ipt = 0; ipt<fNPtThresFrac;ipt++){ 
+       sprintf(name,"hPtThresIsol_Cone_%d_Pt%d",icone,ipt);
+       sprintf(title,"Isolated candidate p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+       fhPtThresIsolated[icone][ipt]  = new TH1F(name, title,240,0,120);
+       fhPtThresIsolated[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+       outputContainer->Add(fhPtThresIsolated[icone][ipt]) ; 
+
+       sprintf(name,"hPtFracIsol_Cone_%d_Pt%d",icone,ipt);
+       sprintf(title,"Isolated candidate p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+       fhPtFracIsolated[icone][ipt]  = new TH1F(name, title,240,0,120);
+       fhPtFracIsolated[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+       outputContainer->Add(fhPtFracIsolated[icone][ipt]) ; 
+
+       if(IsDataMC()){
+         sprintf(name,"hPtThresIsolPrompt_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Prompt p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtThresIsolatedPrompt[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtThresIsolatedPrompt[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtThresIsolatedPrompt[icone][ipt]) ; 
+         
+         sprintf(name,"hPtFracIsolPrompt_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Prompt p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtFracIsolatedPrompt[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtFracIsolatedPrompt[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtFracIsolatedPrompt[icone][ipt]) ; 
+
+         sprintf(name,"hPtThresIsolFragmentation_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Fragmentation p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtThresIsolatedFragmentation[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtThresIsolatedFragmentation[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtThresIsolatedFragmentation[icone][ipt]) ; 
+         
+         sprintf(name,"hPtFracIsolFragmentation_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Fragmentation p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtFracIsolatedFragmentation[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtFracIsolatedFragmentation[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtFracIsolatedFragmentation[icone][ipt]) ; 
+
+         sprintf(name,"hPtThresIsolPi0Decay_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Pi0Decay p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtThresIsolatedPi0Decay[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtThresIsolatedPi0Decay[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtThresIsolatedPi0Decay[icone][ipt]) ; 
+         
+         sprintf(name,"hPtFracIsolPi0Decay_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Pi0Decay p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtFracIsolatedPi0Decay[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtFracIsolatedPi0Decay[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtFracIsolatedPi0Decay[icone][ipt]) ; 
+
+         sprintf(name,"hPtThresIsolOtherDecay_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate OtherDecay p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtThresIsolatedOtherDecay[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtThresIsolatedOtherDecay[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtThresIsolatedOtherDecay[icone][ipt]) ; 
+         
+         sprintf(name,"hPtFracIsolOtherDecay_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate OtherDecay p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtFracIsolatedOtherDecay[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtFracIsolatedOtherDecay[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtFracIsolatedOtherDecay[icone][ipt]) ;
+
+         sprintf(name,"hPtThresIsolConversion_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Conversion p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtThresIsolatedConversion[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtThresIsolatedConversion[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtThresIsolatedConversion[icone][ipt]) ; 
+         
+         sprintf(name,"hPtFracIsolConversion_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Conversion p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtFracIsolatedConversion[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtFracIsolatedConversion[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtFracIsolatedConversion[icone][ipt]) ;
+
+         sprintf(name,"hPtThresIsolUnknown_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Unknown p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtThresIsolatedUnknown[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtThresIsolatedUnknown[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtThresIsolatedUnknown[icone][ipt]) ; 
+         
+         sprintf(name,"hPtFracIsolUnknown_Cone_%d_Pt%d",icone,ipt);
+         sprintf(title,"Isolated candidate Unknown p_{T} distribution for cone size %d and p_{T}^{th} %d",icone,ipt);
+         fhPtFracIsolatedUnknown[icone][ipt]  = new TH1F(name, title,240,0,120);
+         fhPtFracIsolatedUnknown[icone][ipt]->SetXTitle("p_{T} (GeV/c)");
+         outputContainer->Add(fhPtFracIsolatedUnknown[icone][ipt]) ;  
+       }//Histos with MC
+
+      }//icone loop
+    }//ipt loop
+  }
+
+  //Keep neutral meson selection histograms if requiered
+  //Setting done in AliNeutralMesonSelection
+  if(fMakeInvMass && GetNeutralMesonSelection()){
+    TList * nmsHistos = GetNeutralMesonSelection()->GetCreateOutputObjects() ;
+    cout<<"NMSHistos "<< nmsHistos<<endl;
+    if(GetNeutralMesonSelection()->AreNeutralMesonSelectionHistosKept())
+      for(Int_t i = 0; i < nmsHistos->GetEntries(); i++) outputContainer->Add(nmsHistos->At(i)) ;
+  }
+
+  return outputContainer ;
+
+}
+
+//__________________________________________________________________
+void  AliAnaGammaDirect::MakeAnalysisFillAOD() 
+{
+  //Do analysis and fill aods
+  //Search for the isolated photon in fDetector with pt > GetMinPt()
+
+  //Fill CaloClusters if working with ESDs
+  //if(GetReader()->GetDataType() == AliCaloTrackReader::kESD) ConnectAODCaloClusters(); 
+
+  Int_t n = 0, nfrac = 0;
+  Bool_t isolated = kFALSE ; 
+  Float_t coneptsum = 0 ;
+  TClonesArray * pl = new TClonesArray; 
+
+  //Get vertex for photon momentum calculation
+  Double_t vertex[]={0,0,0} ; //vertex ;
+  if(!GetReader()->GetDataType()== AliCaloTrackReader::kMC) GetReader()->GetVertex(vertex);
+
+  //Select the detector of the photon
+  if(fDetector == "PHOS")
+    pl = GetAODPHOS();
+  else if (fDetector == "EMCAL")
+    pl = GetAODEMCAL();
+  //cout<<"Number of entries "<<pl->GetEntriesFast()<<endl;
+  
+  //Fill AODCaloClusters and AODParticleCorrelation with PHOS aods
+  TLorentzVector mom ;
+  for(Int_t icalo = 0; icalo < pl->GetEntriesFast(); icalo++){
+    AliAODCaloCluster * calo =  dynamic_cast<AliAODCaloCluster*> (pl->At(icalo));
+  
+    //Cluster selection, not charged, with photon id and in fidutial cut
+    if(!SelectCluster(calo,vertex,mom)) continue ;
+    
+    //If too small pt, skip
+    if(mom.Pt() < GetMinPt() || mom.Pt() > GetMaxPt() ) continue ; 
+
+    //Play with the MC stack if available
+    Int_t tag =-1;
+    if(IsDataMC()){
+      //Check origin of the candidates
+      tag = CheckOrigin(calo->GetLabel(0));
+      if(GetDebug() > 0) printf("Origin of candidate %d\n",tag);
+    }//Work with stack also   
+
+    //Check invariant mass
+    Bool_t decay = kFALSE ;
+    if(fMakeInvMass) decay = CheckInvMass(icalo,mom,vertex,pl);
+    if(decay) continue ;
+
+    //Create AOD for analysis
+    AliAODParticleCorrelation ph = AliAODParticleCorrelation(mom);
+    ph.SetLabel(calo->GetLabel(0));
+    ph.SetPdg(AliCaloPID::kPhoton);
+    ph.SetDetector(fDetector);
+    ph.SetTag(tag);  
+    if(fMakeIC){
+      n=0; nfrac = 0; isolated = kFALSE; coneptsum = 0;
+      GetIsolationCut()->MakeIsolationCut((TSeqCollection*)GetAODCTS(), (TSeqCollection*)pl, 
+                                         vertex, kTRUE, &ph,icalo,-1,
+                                         n,nfrac,coneptsum, isolated);
+      if(isolated){
+       //cout<<"Isolated : E "<<mom.E()<<" ; Phi"<<mom.Phi()<< " ; Eta "<<mom.Eta()<<endl;
+       AddAODParticleCorrelation(ph);
+      }
+    }
+    else //Fill all if not isolation requested
+      AddAODParticleCorrelation(ph);
+
+  }//loop
+  
+  if(GetDebug() > 1) printf("End fill AODs ");  
+  
+}
+
+//__________________________________________________________________
+void  AliAnaGammaDirect::MakeAnalysisFillHistograms() 
+{
+  //Do analysis and fill histograms
+  Int_t n = 0, nfrac = 0;
+  Bool_t isolated = kFALSE ; 
+  Float_t coneptsum = 0 ;
+  //cout<<"MakeAnalysisFillHistograms"<<endl;
+
+  //Get vertex for photon momentum calculation
+  Double_t v[]={0,0,0} ; //vertex ;
+  if(!GetReader()->GetDataType()== AliCaloTrackReader::kMC) GetReader()->GetVertex(v);
+
+  //Loop on stored AOD photons
+  Int_t naod = GetAODBranch()->GetEntriesFast();
+  if(GetDebug() > 0) printf("histo aod branch entries %d\n", naod);
+  for(Int_t iaod = 0; iaod < naod ; iaod++){
+   AliAODParticleCorrelation* ph =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->At(iaod));
+   Int_t pdg = ph->GetPdg();
+
+   //Only isolate photons in detector fDetector
+   if(pdg != AliCaloPID::kPhoton || ph->GetDetector() != fDetector) continue;
+   
+   if(fMakeSeveralIC) {
+     //Analysis of multiple IC at same time
+     MakeSeveralICAnalysis(ph,v);
+     continue;
+   }
+   else if(fReMakeIC){
+     //In case a more strict IC is needed in the produced AOD
+     n=0; nfrac = 0; isolated = kFALSE; coneptsum = 0;
+     GetIsolationCut()->MakeIsolationCut((TSeqCollection*)ph->GetRefIsolationConeTracks(), 
+                                        (TSeqCollection*)ph->GetRefIsolationConeClusters(), 
+                                        v, kFALSE, ph,-1,-1,
+                                        n,nfrac,coneptsum, isolated);
+   }
+
+   //Fill histograms (normal case)
+   if(!fReMakeIC || (fReMakeIC && isolated)){
+     
+     //printf("Isolated Gamma: pt %f, phi %f, eta %f", ph->Pt(),ph->Phi(),ph->Eta()) ;
+     
+     //Fill prompt gamma histograms 
+     Float_t ptcluster = ph->Pt();
+     Float_t phicluster = ph->Phi();
+     Float_t etacluster = ph->Eta();
+     
+     fhPtGamma   ->Fill(ptcluster);
+     fhPhiGamma ->Fill(ptcluster,phicluster);
+     fhEtaGamma ->Fill(ptcluster,etacluster);
+     fhConeSumPt->Fill(ptcluster,coneptsum);
+
+     if(IsDataMC()){
+       Int_t tag =ph->GetTag();
+           
+       if(tag == kPrompt){
+        fhPtPrompt   ->Fill(ptcluster);
+        fhPhiPrompt ->Fill(ptcluster,phicluster);
+        fhEtaPrompt ->Fill(ptcluster,etacluster);
+       }
+       else if(tag==kFragmentation)
+        {
+          fhPtFragmentation   ->Fill(ptcluster);
+          fhPhiFragmentation ->Fill(ptcluster,phicluster);
+          fhEtaFragmentation ->Fill(ptcluster,etacluster);
+        }
+       else if(tag==kPi0Decay)
+        {
+          fhPtPi0Decay   ->Fill(ptcluster);
+          fhPhiPi0Decay ->Fill(ptcluster,phicluster);
+          fhEtaPi0Decay ->Fill(ptcluster,etacluster);
+        }
+       else if(tag==kEtaDecay || tag==kOtherDecay)
+        {
+          fhPtOtherDecay   ->Fill(ptcluster);
+          fhPhiOtherDecay ->Fill(ptcluster,phicluster);
+          fhEtaOtherDecay ->Fill(ptcluster,etacluster);
+        }
+       else if(tag==kConversion)
+        {
+          fhPtConversion   ->Fill(ptcluster);
+          fhPhiConversion ->Fill(ptcluster,phicluster);
+          fhEtaConversion ->Fill(ptcluster,etacluster);
+        }
+       else{
+        
+        fhPtUnknown   ->Fill(ptcluster);
+        fhPhiUnknown ->Fill(ptcluster,phicluster);
+        fhEtaUnknown ->Fill(ptcluster,etacluster);
+       }
+     }//Histograms with MC
+     
+   }
+  }// aod loop
+  
+}
+
+//____________________________________________________________________________
+void AliAnaGammaDirect::InitParameters()
+{
+  
+  //Initialize the parameters of the analysis.
+
+  fDetector = "PHOS" ;
+  fMakeIC = kTRUE;
+  fReMakeIC = kFALSE ;
+  fMakeSeveralIC = kFALSE ;
+  fMakeInvMass = kFALSE ;
+
+ //----------- Several IC-----------------
+  fNCones           = 5 ; 
+  fNPtThresFrac         = 6 ; 
+  fConeSizes[0] = 0.1; fConeSizes[1] = 0.2; fConeSizes[2] = 0.3; fConeSizes[3] = 0.4; fConeSizes[4] = 0.5;
+  fPtThresholds[0]=0.; fPtThresholds[1]=1.; fPtThresholds[2]=2.; fPtThresholds[3]=3.; fPtThresholds[4]=4.;fPtThresholds[5]=5.;
+  fPtFractions[0]=0.05; fPtFractions[1]=0.075; fPtFractions[2]=0.1; fPtFractions[3]=1.25; fPtFractions[4]=1.5;fPtFractions[5]=2.;
+
+}
+
+//__________________________________________________________________
+void  AliAnaGammaDirect::MakeSeveralICAnalysis(AliAODParticleCorrelation* ph, Double_t v[3]) 
+{
+  //Isolation Cut Analysis for both methods and different pt cuts and cones
+  Float_t ptC = ph->Pt();
+  Float_t phiC = ph->Phi();
+  Float_t etaC = ph->Eta();
+
+  fhPtGamma->Fill(ptC);
+  fhPhiGamma->Fill(ptC,ph->Phi());
+  fhEtaGamma->Fill(ptC,ph->Eta());
+  Int_t tag =ph->GetTag();
+
+  if(IsDataMC()){
+    if(tag == kPrompt){
+      fhPtPrompt   ->Fill(ptC);
+      fhPhiPrompt ->Fill(ptC,phiC);
+      fhEtaPrompt ->Fill(ptC,etaC);
+    }
+    else if(tag==kFragmentation)
+      {
+       fhPtFragmentation   ->Fill(ptC);
+       fhPhiFragmentation ->Fill(ptC,phiC);
+       fhEtaFragmentation ->Fill(ptC,etaC);
+      }
+    else if(tag==kPi0Decay)
+      {
+       fhPtPi0Decay   ->Fill(ptC);
+       fhPhiPi0Decay ->Fill(ptC,phiC);
+       fhEtaPi0Decay ->Fill(ptC,etaC);
+      }
+    else if(tag==kEtaDecay || tag==kOtherDecay)
+      {
+       fhPtOtherDecay   ->Fill(ptC);
+       fhPhiOtherDecay ->Fill(ptC,phiC);
+       fhEtaOtherDecay ->Fill(ptC,etaC);
+      }
+    else if(tag==kConversion)
+      {
+       fhPtConversion   ->Fill(ptC);
+       fhPhiConversion ->Fill(ptC,phiC);
+       fhEtaConversion ->Fill(ptC,etaC);
+      }
+    else{
+      
+      fhPtUnknown   ->Fill(ptC);
+      fhPhiUnknown ->Fill(ptC,phiC);
+      fhEtaUnknown ->Fill(ptC,etaC);
+    }
+  }//Histograms with MC
+  //Keep original setting used when filling AODs, reset at end of analysis  
+  Float_t ptthresorg = GetIsolationCut()->GetPtThreshold();
+  Float_t ptfracorg = GetIsolationCut()->GetPtFraction();
+  Float_t rorg = GetIsolationCut()->GetConeSize();
+
+  Float_t coneptsum = 0 ;  
+  Int_t n[10][10];//[fNCones][fNPtThresFrac];
+  Int_t nfrac[10][10];//[fNCones][fNPtThresFrac];
+  Bool_t  isolated   = kFALSE;
+
+  for(Int_t icone = 0; icone<fNCones; icone++){
+    GetIsolationCut()->SetConeSize(fConeSizes[icone]);
+    coneptsum = 0 ;
+    for(Int_t ipt = 0; ipt<fNPtThresFrac ;ipt++){
+      n[icone][ipt]=0;
+      nfrac[icone][ipt]=0;
+      GetIsolationCut()->SetPtThreshold(fPtThresholds[ipt]);
+      GetIsolationCut()->MakeIsolationCut((TSeqCollection*)ph->GetRefIsolationConeTracks(), 
+                                         (TSeqCollection*)ph->GetRefIsolationConeClusters(), 
+                                         v, kFALSE, ph,-1,-1,
+                                         n[icone][ipt],nfrac[icone][ipt],coneptsum, isolated);
+      if(n[icone][ipt] == 0) {
+       fhPtThresIsolated[icone][ipt]->Fill(ptC);
+       if(IsDataMC()){
+         if(tag==kPrompt) fhPtThresIsolatedPrompt[icone][ipt]->Fill(ptC,coneptsum) ;
+         else if(tag==kConversion) fhPtThresIsolatedConversion[icone][ipt]->Fill(ptC,coneptsum) ;
+         else if(tag==kFragmentation) fhPtThresIsolatedFragmentation[icone][ipt]->Fill(ptC,coneptsum) ;
+         else if(tag==kPi0Decay) fhPtThresIsolatedPi0Decay[icone][ipt]->Fill(ptC,coneptsum) ;
+         else if(tag==kOtherDecay || tag==kEtaDecay) fhPtThresIsolatedOtherDecay[icone][ipt]->Fill(ptC,coneptsum) ;
+         else  fhPtThresIsolatedUnknown[icone][ipt]->Fill(ptC,coneptsum) ;
+       }
+      }
+      if(nfrac[icone][ipt] == 0) {
+       fhPtFracIsolated[icone][ipt]->Fill(ptC);
+       if(IsDataMC()){
+         if(tag==kPrompt) fhPtFracIsolatedPrompt[icone][ipt]->Fill(ptC,coneptsum) ;
+         else if(tag==kConversion) fhPtFracIsolatedConversion[icone][ipt]->Fill(ptC,coneptsum) ;
+         else if(tag==kFragmentation) fhPtFracIsolatedFragmentation[icone][ipt]->Fill(ptC,coneptsum) ;
+         else if(tag==kPi0Decay) fhPtFracIsolatedPi0Decay[icone][ipt]->Fill(ptC,coneptsum) ;
+         else if(tag==kOtherDecay || tag==kEtaDecay) fhPtFracIsolatedOtherDecay[icone][ipt]->Fill(ptC,coneptsum) ;
+         else  fhPtFracIsolatedUnknown[icone][ipt]->Fill(ptC,coneptsum) ;
+       }
+      }
+    }//pt thresh loop
+    fhPtSumIsolated[icone]->Fill(ptC,coneptsum) ;
+    if(IsDataMC()){
+      if(tag==kPrompt) fhPtSumIsolatedPrompt[icone]->Fill(ptC,coneptsum) ;
+      else if(tag==kConversion) fhPtSumIsolatedConversion[icone]->Fill(ptC,coneptsum) ;
+      else if(tag==kFragmentation) fhPtSumIsolatedFragmentation[icone]->Fill(ptC,coneptsum) ;
+      else if(tag==kPi0Decay) fhPtSumIsolatedPi0Decay[icone]->Fill(ptC,coneptsum) ;
+      else if(tag==kOtherDecay || tag==kEtaDecay) fhPtSumIsolatedOtherDecay[icone]->Fill(ptC,coneptsum) ;
+      else  fhPtSumIsolatedUnknown[icone]->Fill(ptC,coneptsum) ;
+    }
+
+  }//cone size loop
+
+  //Reset original parameters for AOD analysis
+  GetIsolationCut()->SetPtThreshold(ptthresorg);
+  GetIsolationCut()->SetPtFraction(ptfracorg);
+  GetIsolationCut()->SetConeSize(rorg);
+
+}
+
+//__________________________________________________________________
+void AliAnaGammaDirect::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("Min Gamma pT       =     %2.2f\n",  GetMinPt()) ;
+  printf("Max Gamma pT       =     %3.2f\n",  GetMaxPt()) ;
+
+//   if(IsCaloPIDOn())printf("Check PID \n") ;
+//   if(IsCaloPIDRecalculationOn())printf("Recalculate PID \n") ;
+//   if(IsFidutialCutOn())printf("Check Fidutial cut \n") ;
+  printf("Make Isolation     =     %d \n",  fMakeIC) ;
+  printf("ReMake Isolation   =     %d \n",  fReMakeIC) ;
+  printf("Make Several Isolation = %d \n",  fMakeSeveralIC) ;
+  
+  if(fMakeSeveralIC){
+    printf("N Cone Sizes       =     %d\n", fNCones) ; 
+    printf("Cone Sizes          =    \n") ;
+    for(Int_t i = 0; i < fNCones; i++)
+      printf("  %1.2f;",  fConeSizes[i]) ;
+    printf("    \n") ;
+    
+    printf("N pT thresholds/fractions = %d\n", fNPtThresFrac) ;
+    printf(" pT thresholds         =    \n") ;
+    for(Int_t i = 0; i < fNPtThresFrac; i++)
+      printf("   %2.2f;",  fPtThresholds[i]) ;
+    
+    printf("    \n") ;
+    
+    printf(" pT fractions         =    \n") ;
+    for(Int_t i = 0; i < fNPtThresFrac; i++)
+      printf("   %2.2f;",  fPtFractions[i]) ;
+    
+  }  
+  
+  printf("    \n") ;
+  
+} 
+
+//____________________________________________________________________________
+Bool_t  AliAnaGammaDirect::SelectCluster(AliAODCaloCluster * calo, Double_t vertex[3], TLorentzVector & mom){
+   //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
+   Int_t pdg = AliCaloPID::kPhoton;   
+   if(IsCaloPIDOn()){
+     //Get most probable PID, 2 options check PID weights (in MC this option is mandatory)
+     //or redo PID, recommended option for EMCal.
+     if(!IsCaloPIDRecalculationOn() || GetReader()->GetDataType() == AliCaloTrackReader::kMC )
+       pdg = GetCaloPID()->GetPdg(fDetector,calo->PID(),mom.E());//PID with weights
+     else
+       pdg = GetCaloPID()->GetPdg(fDetector,mom,calo->GetM02(),0,0,0,0);//PID recalculated
+     
+     if(GetDebug() > 1) printf("PDG of identified particle %d\n",pdg);
+     
+     //If it does not pass pid, skip
+     if(pdg != AliCaloPID::kPhoton) return kFALSE ;
+   }
+   
+   //Check acceptance selection
+   if(IsFidutialCutOn()){
+     Bool_t in = GetFidutialCut()->IsInFidutialCut(mom,fDetector) ;
+     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/PartCorr/AliAnaGammaDirect.h b/PWG4/PartCorr/AliAnaGammaDirect.h
new file mode 100644 (file)
index 0000000..7c3667b
--- /dev/null
@@ -0,0 +1,157 @@
+#ifndef AliAnaGammaDirect_H
+#define AliAnaGammaDirect_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id: AliAnaGammaDirect.h 27413 2008-07-18 13:28:12Z gconesab $ */
+
+//_________________________________________________________________________
+
+// Class for the analysis of prompt gamma, isolation cut. 
+//
+//  Class created from old AliPHOSGammaJet
+//  (see AliRoot versions previous Release 4-09)
+
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+#include <TParticle.h> 
+#include <TClonesArray.h>  
+#include <TH2F.h>
+#include <TString.h>
+
+// --- ANALYSIS system ---
+#include "AliAnaPartCorrBaseClass.h"
+class AliAODParticleCorrelations ;
+
+class TList ;
+
+class AliAnaGammaDirect : public AliAnaPartCorrBaseClass {
+
+public: 
+
+  AliAnaGammaDirect() ; // default ctor
+  AliAnaGammaDirect(const AliAnaGammaDirect & g) ; // cpy ctor
+  AliAnaGammaDirect & operator = (const AliAnaGammaDirect & g) ;//cpy assignment
+  virtual ~AliAnaGammaDirect() ; //virtual dtor
+
+  enum mcTypes {kPrompt, kFragmentation, kPi0Decay, kEtaDecay, kOtherDecay, kPi0, kEta, kElectron, kConversion, kUnknown};
+
+  Bool_t CheckInvMass(const Int_t icalo,const TLorentzVector mom, Double_t *v, TClonesArray * pl);
+  Int_t CheckOrigin(const Int_t label);
+  
+  TList *  GetCreateOutputObjects();
+
+  void MakeAnalysisFillAOD()  ;
+  
+  void MakeAnalysisFillHistograms() ; 
+
+  void MakeSeveralICAnalysis(AliAODParticleCorrelation * ph, Double_t v[3]); 
+  
+  void Print(const Option_t * opt)const;
+  
+  TString GetDetector()   const {return fDetector ; }
+  void SetDetector(TString det)    {fDetector = det ; }
+
+  Int_t    GetNCones()                  const {return fNCones ; }
+  Int_t    GetNPtThresFrac()                const {return fNPtThresFrac ; }
+  Float_t GetConeSizes(Int_t i)      const {return fConeSizes[i] ; }
+  Float_t GetPtThresholds(Int_t i)  const {return fPtThresholds[i] ; }
+  Float_t GetPtFractions(Int_t i)  const {return fPtFractions[i] ; }
+
+  void InitParameters();
+  void SetNCones(Int_t ncs)              {fNCones = ncs ; }
+  void SetNPtThresFrac(Int_t npt)        {fNPtThresFrac = npt; }
+  void SetConeSizes(Int_t i, Float_t r)         {fConeSizes[i] = r ; }
+  void SetPtThresholds(Int_t i, Float_t pt)   {fPtThresholds[i] = pt; }
+  void SetPtFractions(Int_t i, Float_t pt)   {fPtFractions[i] = pt; } 
+
+  Bool_t IsIsolationOn() {return fMakeIC ; }
+  void SwitchOnIsolation() { fMakeIC = kTRUE;}
+  void SwitchOffIsolation() { fMakeIC = kFALSE;}
+
+  Bool_t IsReIsolationOn() {return fReMakeIC ; }
+  void SwitchOnReIsolation() { fReMakeIC = kTRUE;}
+  void SwitchOffReIsolation() { fReMakeIC = kFALSE;}
+
+  Bool_t IsSeveralIsolationOn() {return fMakeSeveralIC ; }
+  void SwitchOnSeveralIsolation() { fMakeSeveralIC = kTRUE;}
+  void SwitchOffSeveralIsolation() { fMakeSeveralIC = kFALSE;}
+
+  Bool_t IsInvariantMassOn() {return fMakeInvMass ; }
+  void SwitchOnInvariantMass() { fMakeInvMass = kTRUE;}
+  void SwitchOffInvariantMass() { fMakeInvMass = kFALSE;}
+
+  Bool_t SelectCluster(AliAODCaloCluster * calo, Double_t vertex[3], TLorentzVector & mom);
+
+  private:
+  TString fDetector ; // Detector where the gamma is searched;
+  Bool_t fMakeIC ; //Do isolation analysis
+  Bool_t fReMakeIC ; //Do isolation analysis
+  Bool_t fMakeSeveralIC ; //Do analysis for different IC
+  Bool_t fMakeInvMass; //Select candidate if no pair from decay
+
+  //Histograms  
+  TH1F * fhPtGamma    ;  //!Number of identified (isolated) gamma 
+  TH2F * fhPhiGamma  ; //! Phi of identified  (isolated) gamma
+  TH2F * fhEtaGamma  ; //! eta of identified  (isolated) gamma
+  TH2F * fhConeSumPt ; //! Sum Pt in the cone
+
+  //Prompt photon analysis data members for multiple cones and pt thresholds 
+  Int_t         fNCones   ; //!Number of cone sizes to test
+  Int_t         fNPtThresFrac ; //!Number of ptThres and ptFrac to test
+  Float_t     fConeSizes[5] ; //! Array with cones to test
+  Float_t     fPtThresholds[5] ; //! Array with pt thresholds to test
+  Float_t     fPtFractions[5] ; //! Array with pt thresholds to test
+
+  TH1F* fhPtThresIsolated[5][5]; //! Isolated gamma with pt threshold 
+  TH1F* fhPtFracIsolated[5][5]; //! Isolated gamma with pt threshold 
+  TH2F* fhPtSumIsolated[5] ;  //!  Isolated gamma with threshold on cone pt sume
+
+  //MC
+  TH1F * fhPtPrompt; //!Number of identified (isolated) prompt gamma 
+  TH2F * fhPhiPrompt;  //! Phi of identified  (isolated) prompt gamma
+  TH2F * fhEtaPrompt;  //! eta of identified  (isolated) prompt gamma
+  TH1F * fhPtThresIsolatedPrompt[5][5];  //! Isolated prompt gamma with pt threshold 
+  TH1F * fhPtFracIsolatedPrompt[5][5];    //! Isolated prompt gamma with pt frac
+  TH2F * fhPtSumIsolatedPrompt[5]; //!  Isolated prompt gamma with threshold on cone pt sume
+  TH1F * fhPtFragmentation; //!Number of identified (isolated) fragmentation gamma 
+  TH2F * fhPhiFragmentation;  //! Phi of identified  (isolated) fragmentation gamma
+  TH2F * fhEtaFragmentation;  //! eta of identified  (isolated) fragmentation gamma
+  TH1F * fhPtThresIsolatedFragmentation[5][5];  //! Isolated fragmentation gamma with pt threshold 
+  TH1F * fhPtFracIsolatedFragmentation[5][5];    //! Isolated fragmentation gamma with pt frac
+  TH2F * fhPtSumIsolatedFragmentation[5]; //!  Isolated fragmentation gamma with threshold on cone pt sume
+  TH1F * fhPtPi0Decay; //!Number of identified (isolated) Pi0Decay gamma 
+  TH2F * fhPhiPi0Decay;  //! Phi of identified  (isolated) Pi0Decay gamma
+  TH2F * fhEtaPi0Decay;  //! eta of identified  (isolated) Pi0Decay gamma
+  TH1F * fhPtThresIsolatedPi0Decay[5][5];  //! Isolated Pi0Decay gamma with pt threshold 
+  TH1F * fhPtFracIsolatedPi0Decay[5][5];    //! Isolated Pi0Decay gamma with pt frac
+  TH2F * fhPtSumIsolatedPi0Decay[5]; //!  Isolated Pi0Decay gamma with threshold on cone pt sume
+  TH1F * fhPtOtherDecay; //!Number of identified (isolated) OtherDecay gamma 
+  TH2F * fhPhiOtherDecay;  //! Phi of identified  (isolated) OtherDecay gamma
+  TH2F * fhEtaOtherDecay;  //! eta of identified  (isolated) OtherDecay gamma
+  TH1F * fhPtThresIsolatedOtherDecay[5][5];  //! Isolated OtherDecay gamma with pt threshold 
+  TH1F * fhPtFracIsolatedOtherDecay[5][5];    //! Isolated OtherDecay gamma with pt frac
+  TH2F * fhPtSumIsolatedOtherDecay[5]; //!  Isolated OtherDecay gamma with threshold on cone pt sume   
+  TH1F * fhPtConversion; //!Number of identified (isolated) Conversion gamma 
+  TH2F * fhPhiConversion;  //! Phi of identified  (isolated) Conversion gamma
+  TH2F * fhEtaConversion;  //! eta of identified  (isolated) Conversion gamma
+  TH1F * fhPtThresIsolatedConversion[5][5];  //! Isolated Conversion gamma with pt threshold 
+  TH1F * fhPtFracIsolatedConversion[5][5];    //! Isolated Conversion gamma with pt frac
+  TH2F * fhPtSumIsolatedConversion[5]; //!  Isolated Conversion gamma with threshold on cone pt sume
+  TH1F * fhPtUnknown; //!Number of identified (isolated) Unknown gamma 
+  TH2F * fhPhiUnknown;  //! Phi of identified  (isolated) Unknown gamma
+  TH2F * fhEtaUnknown;  //! eta of identified  (isolated) Unknown gamma
+  TH1F * fhPtThresIsolatedUnknown[5][5];  //! Isolated Unknown gamma with pt threshold 
+  TH1F * fhPtFracIsolatedUnknown[5][5];    //! Isolated Unknown gamma with pt frac
+  TH2F * fhPtSumIsolatedUnknown[5]; //!  Isolated Unknown gamma with threshold on cone pt sume
+                                               
+  ClassDef(AliAnaGammaDirect,1)
+} ;
+
+#endif //AliAnaGammaDirect_H
+
+
+
diff --git a/PWG4/PartCorr/AliAnaPartCorrBaseClass.cxx b/PWG4/PartCorr/AliAnaPartCorrBaseClass.cxx
new file mode 100644 (file)
index 0000000..8c5492d
--- /dev/null
@@ -0,0 +1,263 @@
+/**************************************************************************
+ * 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   *GetEntriesFast(
+ * 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>
+#include <Riostream.h>
+
+//---- AliRoot system ----
+#include "AliAODParticleCorrelation.h"
+#include "AliAODCaloCluster.h"
+#include "AliAODCaloCells.h"
+#include "AliAODTrack.h"
+#include "AliAnaPartCorrBaseClass.h"
+#include "AliCaloTrackReader.h"
+#include "AliFidutialCut.h"
+#include "AliIsolationCut.h"
+#include "AliNeutralMesonSelection.h"
+#include "AliLog.h"
+// #include "AliStack.h"
+// #include "AliHeader.h"
+// #include "AliGenEventHeader.h"
+
+ClassImp(AliAnaPartCorrBaseClass)
+  
+  
+//_______________________________________________
+  AliAnaPartCorrBaseClass::AliAnaPartCorrBaseClass() : 
+    TObject(), fDataMC(0), fDebug(0), fCheckFidCut(0),
+    fCheckCaloPID(0), fRecalculateCaloPID(0), fMinPt(0), fMaxPt(0),
+    fReader(0x0), fAODBranch(0x0),  fAODCaloClusters(0x0), fAODCaloCells(0x0), 
+    fCaloPID(0x0), fFidCut(0x0), fIC(0x0),fNMS(0x0) 
+{
+  //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),  
+  fAODBranch(new TClonesArray(*abc.fAODBranch)),
+  fAODCaloClusters(new TClonesArray(*abc.fAODCaloClusters)),
+  fAODCaloCells(new AliAODCaloCells(*abc.fAODCaloCells)),
+  fCaloPID(abc.fCaloPID), fFidCut(abc.fFidCut), fIC(abc.fIC),fNMS(abc.fNMS)
+{
+  // 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 ;
+  
+  fAODBranch = new TClonesArray(*abc.fAODBranch) ;
+  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;
+
+  return *this;
+  
+}
+
+//____________________________________________________________________________
+AliAnaPartCorrBaseClass::~AliAnaPartCorrBaseClass() 
+{
+  // Remove all pointers except analysis output pointers.
+  
+  if(fAODBranch){
+    fAODBranch->Clear() ; 
+    delete fAODBranch ;
+  }
+  
+  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::AddAODParticleCorrelation(AliAODParticleCorrelation pc) {
+  //Put AOD calo cluster in the AODParticleCorrelation array
+
+  Int_t i = fAODBranch->GetEntriesFast();
+  new((*fAODBranch)[i])  AliAODParticleCorrelation(pc);
+
+}
+
+//___________________________________________________
+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();
+
+}
+
+//__________________________________________________
+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(); 
+
+}
+
+//__________________________________________________
+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;
+
+}
+
diff --git a/PWG4/PartCorr/AliAnaPartCorrBaseClass.h b/PWG4/PartCorr/AliAnaPartCorrBaseClass.h
new file mode 100644 (file)
index 0000000..cdd948f
--- /dev/null
@@ -0,0 +1,143 @@
+#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 "AliAODParticleCorrelation.h"
+class AliCaloTrackReader ;   
+#include "AliCaloPID.h"
+class AliFidutialCut ;
+class AliIsolationCut ;
+class AliNeutralMesonSelection ;
+/* class AliStack ; */
+/* class AliHeader ; */
+/* class AliGenEventHeader ; */
+#include "AliStack.h"
+#include "AliHeader.h"
+#include "AliGenEventHeader.h"
+
+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 AddAODParticleCorrelation(AliAODParticleCorrelation pc) ;
+
+       virtual void ConnectAODCaloClusters();
+       virtual void ConnectAODPHOSCells();
+       virtual void ConnectAODEMCALCells();
+
+       virtual TList * GetCreateOutputObjects(){ return (new TList) ;}
+       
+       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 ; }
+
+       virtual TClonesArray* GetAODBranch() const {return fAODBranch ;}
+       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 TNamed * GetEMCALCells() const ;
+       virtual TNamed * GetPHOSCells() const ;
+
+       virtual AliStack * GetMCStack() const ;
+       virtual AliHeader* GetMCHeader() const ;
+       virtual AliGenEventHeader* GetMCGenEventHeader() const ;
+
+       virtual void SetAODBranch(TClonesArray * tca) { fAODBranch = tca ; }
+
+       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() {return fCheckFidCut ; }
+       virtual void SwitchOnFidutialCut() { fCheckFidCut = kTRUE;}
+       virtual void SwitchOffFidutialCut() { fCheckFidCut = kFALSE;}
+       
+       virtual Bool_t IsCaloPIDOn() {return fCheckCaloPID ; }
+       virtual void SwitchOnCaloPID() { fCheckCaloPID = kTRUE;}
+       virtual void SwitchOffCaloPID() { fCheckCaloPID = kFALSE;}
+       
+       virtual Bool_t IsCaloPIDRecalculationOn() {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;}
+       
+       virtual void InitParameters() ;
+    
+ 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* fAODBranch ;        //! selected particles branch
+       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
+
+       ClassDef(AliAnaPartCorrBaseClass,1)
+ } ;
+
+
+#endif //AliAnaPartCorrBaseClass_H
+
+
+
diff --git a/PWG4/PartCorr/AliAnaPartCorrMaker.cxx b/PWG4/PartCorr/AliAnaPartCorrMaker.cxx
new file mode 100644 (file)
index 0000000..f237dd9
--- /dev/null
@@ -0,0 +1,207 @@
+/**************************************************************************
+ * 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 ---
+#include <TClonesArray.h>
+#include <TString.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), fAODBranch(0x0), fAODBranchName("")
+{
+  //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), fAODBranch(g.fAODBranch), 
+  fAODBranchName(g.fAODBranchName)
+{
+  // 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;
+
+  fAODBranchName = source.fAODBranchName;
+  fAODBranch = source.fAODBranch;
+  fReader = source.fReader ;
+
+  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 (fAODBranch) {
+    fAODBranch->Clear();
+    delete fAODBranch ;
+  }
+
+}
+
+//________________________________________________________________________
+void AliAnaPartCorrMaker::Init()
+{  
+  //Init container histograms and other common variables
+
+  if(fMakeHisto){// Analysis with histograms as output on
+    
+    //Fill container with appropriate histograms
+    
+    if(!fAnalysisContainer || fAnalysisContainer->GetEntries()==0)
+      AliFatal("Analysis job list not initailized");
+
+    for(Int_t iana = 0; iana <  fAnalysisContainer->GetEntries(); iana++){
+      TList * templist =  ((AliAnaPartCorrBaseClass *) fAnalysisContainer->At(iana)) -> GetCreateOutputObjects(); 
+
+      for(Int_t i = 0; i < templist->GetEntries(); i++)
+       fOutputContainer->Add(templist->At(i)) ;
+    
+    }
+  }// Analysis with histograms as output on
+}
+
+//____________________________________________________________________________
+void AliAnaPartCorrMaker::InitParameters()
+{
+
+  //Init data members
+  fMakeHisto = kTRUE;
+  fMakeAOD = kTRUE; 
+  fAnaDebug = 0; // No debugging info displayed by default
+  fAODBranchName = "Photons" ;
+
+}
+
+//__________________________________________________________________
+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("New AOD branch  =     %s\n", fAODBranchName.Data()) ;
+  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
+  fAODBranch->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)) ; 
+    
+    //Set reader and aod branch for each analysis
+    ana->SetReader(fReader);
+    ana->SetAODBranch(fAODBranch);
+    
+    //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()  ;
+    
+  }
+
+  if(fAnaDebug > 0 ) printf("*** End analysis *** \n");
+
+  fReader->ResetLists();
+  
+  return kTRUE ;
+  
+}
diff --git a/PWG4/PartCorr/AliAnaPartCorrMaker.h b/PWG4/PartCorr/AliAnaPartCorrMaker.h
new file mode 100644 (file)
index 0000000..c93269e
--- /dev/null
@@ -0,0 +1,89 @@
+#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 ---
+#include "AliLog.h"
+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 * 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 SetAODBranch(TClonesArray* aodbranch) {fAODBranch = aodbranch;}
+  
+  void AddAnalysis(TObject* ana, Int_t n) {if ( fAnalysisContainer) fAnalysisContainer->AddAt(ana,n); 
+    else AliFatal("AnalysisContainer not initialized");}
+
+  TString GetAODBranchName() const {return  fAODBranchName;}
+  void SetAODBranchName(TString name)  {fAODBranchName = name ;}
+
+  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 
+  TClonesArray* fAODBranch ;        //! selected particles branch
+  TString fAODBranchName; // New AOD branch name
+
+  ClassDef(AliAnaPartCorrMaker,1)
+} ;
+
+#endif //AliAnaPartCorrMaker_H
+
+
+
diff --git a/PWG4/PartCorr/AliAnaParticleHadronCorrelation.cxx b/PWG4/PartCorr/AliAnaParticleHadronCorrelation.cxx
new file mode 100644 (file)
index 0000000..cd8f4b5
--- /dev/null
@@ -0,0 +1,524 @@
+/**************************************************************************
+ * 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 "Riostream.h"
+#include "TH2F.h"
+
+//---- ANALYSIS system ----
+#include "AliLog.h"
+#include "AliNeutralMesonSelection.h" 
+#include "AliAnaParticleHadronCorrelation.h" 
+#include "AliCaloTrackReader.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") ; 
+
+  //Correlation with charged hadrons
+  if(GetReader()->IsCTSSwitchedOn()) {
+    fhPhiCharged  = new TH2F
+      ("PhiCharged","#phi_{h^{#pm}}  vs p_{T trigger}",
+       120,0,120,120,0,7); 
+    fhPhiCharged->SetYTitle("#phi_{h^{#pm}} (rad)");
+    fhPhiCharged->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhEtaCharged  = new TH2F
+      ("EtaCharged","#eta_{h^{#pm}}  vs p_{T trigger}",
+       120,0,120,120,-1,1); 
+    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}",
+       200,0,120,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}}",
+       200,0,120,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}",
+       200,0,120,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}",
+              240,0.,120.,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}",
+       120,0,120,120,0,7); 
+    fhPhiNeutral->SetYTitle("#phi_{#pi^{0}} (rad)");
+    fhPhiNeutral->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhEtaNeutral  = new TH2F
+      ("EtaNeutral","#eta_{#pi^{0}}  vs p_{T trigger}",
+       120,0,120,120,-1,1); 
+    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}",
+       200,0,120,200,0,6.4); 
+    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}}}",
+       200,0,120,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}",
+       200,0,120,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}",
+              240,0.,120.,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() ;
+      cout<<"NMSHistos "<< nmsHistos<<endl;
+      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.
+
+  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(GetDebug() > 1){
+    printf("Begin hadron correlation analysis, fill AODs \n");
+    printf("In particle branch aod entries %d\n", GetAODBranch()->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 = GetAODBranch()->GetEntriesFast();
+  for(Int_t iaod = 0; iaod < naod ; iaod++){
+    AliAODParticleCorrelation* particle =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->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 AODs
+  if(GetDebug() > 1){
+    printf("Begin hadron correlation analysis, fill histograms \n");
+    printf("In particle branch aod entries %d\n", GetAODBranch()->GetEntriesFast());
+  }
+  
+  //Loop on stored AOD particles
+  Int_t naod = GetAODBranch()->GetEntriesFast();
+  for(Int_t iaod = 0; iaod < naod ; iaod++){
+    AliAODParticleCorrelation* particle =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->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(AliAODParticleCorrelation *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 = dynamic_cast<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(AliAODParticleCorrelation * 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 = dynamic_cast< 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 = dynamic_cast< 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){
+   //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->GetM02(),0,0,0,0);//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/PartCorr/AliAnaParticleHadronCorrelation.h b/PWG4/PartCorr/AliAnaParticleHadronCorrelation.h
new file mode 100644 (file)
index 0000000..4e72aa5
--- /dev/null
@@ -0,0 +1,74 @@
+#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 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(AliAODParticleCorrelation * aodParticle,TSeqCollection* pl, const Bool_t bFillHisto) ;
+  void MakeNeutralCorrelation(AliAODParticleCorrelation * aodParticle,TSeqCollection* pl, const Bool_t bFillHisto)  ;
+
+  void MakeAnalysisFillAOD()  ;
+  
+  void MakeAnalysisFillHistograms() ; 
+
+  Bool_t SelectCluster(AliAODCaloCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg);
+
+  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/PartCorr/AliAnaParticleJetFinderCorrelation.cxx b/PWG4/PartCorr/AliAnaParticleJetFinderCorrelation.cxx
new file mode 100644 (file)
index 0000000..2bcd9ca
--- /dev/null
@@ -0,0 +1,342 @@
+/**************************************************************************
+ * 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: AliAnaParticleJetFinderCorrelation.cxx 22232 2007-11-17 16:39:49Z gustavo $ */
+
+//_________________________________________________________________________
+// Class for the analysis of particle (direct gamma) -jet (jet found with finder) correlations
+//*-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+#include "TH2F.h"
+#include "Riostream.h"
+
+//---- AliRoot system ----
+#include "AliCaloTrackReader.h"
+#include "AliAODJet.h"
+#include "AliAnaParticleJetFinderCorrelation.h" 
+#include "AliLog.h"
+  
+  ClassImp(AliAnaParticleJetFinderCorrelation)
+  
+
+//____________________________________________________________________________
+  AliAnaParticleJetFinderCorrelation::AliAnaParticleJetFinderCorrelation() : 
+       AliAnaPartCorrBaseClass(),  
+    fDeltaPhiMaxCut(0.), fDeltaPhiMinCut(0.), fRatioMaxCut(0.),  fRatioMinCut(0.), 
+       fConeSize(0), fPtThresholdInCone(0),fUseJetRefTracks(0), fMakeCorrelationInHistoMaker(0),
+       fhDeltaEta(0), fhDeltaPhi(0), fhDeltaPt(0), fhPtRatio(0), fhPt(0),
+       fhFFz(0),fhFFxi(0),fhFFpt(0),fhNTracksInCone(0)
+{
+       //Default Ctor
+
+       //Initialize parameters
+       InitParameters();
+}
+
+//____________________________________________________________________________
+AliAnaParticleJetFinderCorrelation::AliAnaParticleJetFinderCorrelation(const AliAnaParticleJetFinderCorrelation & pjf) :   
+       AliAnaPartCorrBaseClass(pjf),  
+       fDeltaPhiMaxCut(pjf.fDeltaPhiMaxCut), fDeltaPhiMinCut(pjf.fDeltaPhiMinCut), 
+       fRatioMaxCut(pjf.fRatioMaxCut), fRatioMinCut(pjf.fRatioMinCut), 
+       fConeSize(pjf.fConeSize), fPtThresholdInCone(pjf.fPtThresholdInCone),   
+       fUseJetRefTracks(pjf.fUseJetRefTracks), fMakeCorrelationInHistoMaker(pjf.fMakeCorrelationInHistoMaker),
+       fhDeltaEta(pjf.fhDeltaEta), fhDeltaPhi(pjf.fhDeltaPhi), 
+       fhDeltaPt(pjf.fhDeltaPt), fhPtRatio(pjf.fhPtRatio), fhPt(pjf.fhPt), 
+       fhFFz(pjf.fhFFz),fhFFxi(pjf.fhFFxi),fhFFpt(pjf.fhFFpt),
+       fhNTracksInCone(pjf.fhNTracksInCone)
+{
+       // cpy ctor
+
+}
+
+//_________________________________________________________________________
+AliAnaParticleJetFinderCorrelation & AliAnaParticleJetFinderCorrelation::operator = (const AliAnaParticleJetFinderCorrelation & pjf)
+{
+       // assignment operator
+
+       if(this == &pjf)return *this;
+       ((AliAnaPartCorrBaseClass *)this)->operator=(pjf);
+  
+       fDeltaPhiMaxCut    = pjf.fDeltaPhiMaxCut ; 
+       fDeltaPhiMinCut    = pjf.fDeltaPhiMinCut ; 
+       fRatioMaxCut       = pjf.fRatioMaxCut ;
+       fRatioMinCut       = pjf.fRatioMinCut ; 
+       fConeSize          = pjf.fConeSize ; 
+       fPtThresholdInCone = pjf.fPtThresholdInCone ;
+       fUseJetRefTracks   = pjf.fUseJetRefTracks ;
+       fMakeCorrelationInHistoMaker = pjf.fMakeCorrelationInHistoMaker ;  
+         
+       //Histograms
+       fhDeltaEta = pjf.fhDeltaEta;
+       fhDeltaPhi = pjf.fhDeltaPhi;
+       fhDeltaPt  = pjf.fhDeltaPt;
+       fhPtRatio  = pjf.fhPtRatio;
+       fhPt       = pjf.fhPt;
+  
+       fhFFz   = pjf.fhFFz;
+       fhFFxi  = pjf.fhFFxi;
+       fhFFpt  = pjf.fhFFpt;
+       fhNTracksInCone = pjf.fhNTracksInCone;  
+  
+  return *this;
+
+}
+
+//____________________________________________________________________________
+//AliAnaParticleJetFinderCorrelation::~AliAnaParticleJetFinderCorrelation() 
+//{
+//   // Remove all pointers except analysis output pointers.
+// 
+//}
+
+
+//________________________________________________________________________
+TList *  AliAnaParticleJetFinderCorrelation::GetCreateOutputObjects()
+{  
+  // Create histograms to be saved in output file and 
+  // store them in fOutputContainer
+
+  if(GetDebug()>1) printf("Init histograms \n");
+
+  TList * outputContainer = new TList() ; 
+  outputContainer->SetName("ParticleJetFinderHistos") ; 
+
+  fhDeltaPhi  = new TH2F("DeltaPhi","#phi_{jet} - #phi_{trigger} vs p_{T trigger}",120,0,120,200,-4,4); 
+  fhDeltaPhi->SetYTitle("#Delta #phi");
+  fhDeltaPhi->SetXTitle("p_{T trigger} (GeV/c)");
+  outputContainer->Add(fhDeltaPhi);
+
+  fhDeltaEta  = new TH2F("DeltaEta","#eta_{jet} - #eta_{trigger} vs p_{T trigger}",120,0,120,200,-5,5); 
+  fhDeltaEta->SetYTitle("#Delta #eta");
+  fhDeltaEta->SetXTitle("p_{T trigger} (GeV/c)");
+  outputContainer->Add(fhDeltaEta);
+
+  fhDeltaPt  = new TH2F("DeltaPt","#p_{T trigger} - #p_{T jet} vs p_{T trigger}",120,0,120,200,-100,100); 
+  fhDeltaPt->SetYTitle("#Delta #p_{T}");
+  fhDeltaPt->SetXTitle("p_{T trigger} (GeV/c)"); 
+  outputContainer->Add(fhDeltaPt);
+
+  fhPtRatio  = new TH2F("PtRatio","#p_{T jet} / #p_{T trigger} vs p_{T trigger}",120,0,120,200,0,2.); 
+  fhPtRatio->SetYTitle("ratio");
+  fhPtRatio->SetXTitle("p_{T trigger} (GeV/c)");
+  outputContainer->Add(fhPtRatio);
+  
+  fhPt  = new TH2F("Pt","#p_{T jet} vs p_{T trigger}",120,0,120,120,0,120); 
+  fhPt->SetYTitle("#p_{T jet}(GeV/c)");
+  fhPt->SetXTitle("p_{T trigger} (GeV/c)");
+  outputContainer->Add(fhPt);
+  
+  fhFFz  = new TH2F("FFz","z = p_{T i charged}/p_{T trigger} vs p_{T trigger}", 120,0.,120.,200,0.,2);  
+  fhFFz->SetYTitle("z");
+  fhFFz->SetXTitle("p_{T trigger}");
+  outputContainer->Add(fhFFz) ;
+
+  fhFFxi  = new TH2F("FFxi","#xi = ln(p_{T trigger}/p_{T i charged}) vs p_{T trigger}", 120,0.,120.,100,0.,10.); 
+  fhFFxi->SetYTitle("#xi");
+  fhFFxi->SetXTitle("p_{T trigger}");
+  outputContainer->Add(fhFFxi) ;
+  
+  fhFFpt  = new TH2F("FFpt","#xi = p_{T i charged}) vs p_{T trigger}", 120,0.,120.,200,0.,50.); 
+  fhFFpt->SetYTitle("p_{T charged hadron}");
+  fhFFpt->SetXTitle("p_{T trigger}");
+  outputContainer->Add(fhFFpt) ;
+
+  fhNTracksInCone  = new TH2F("NTracksInCone","#xi = p_{T i charged}) vs p_{T trigger}", 120,0.,120.,200,0.,50.); 
+  fhNTracksInCone->SetYTitle("p_{T charged hadron}");
+  fhNTracksInCone->SetXTitle("p_{T trigger}");
+  outputContainer->Add(fhNTracksInCone) ;
+       
+  return outputContainer;
+}
+
+ //____________________________________________________________________________
+void AliAnaParticleJetFinderCorrelation::InitParameters()
+{
+  //Initialize the parameters of the analysis.
+
+  fDeltaPhiMinCut    = 1.5 ;
+  fDeltaPhiMaxCut    = 4.5 ; 
+  fRatioMaxCut       = 1.2 ; 
+  fRatioMinCut       = 0.3 ; 
+  fConeSize          = 0.3 ;
+  fPtThresholdInCone = 0.5 ;
+  fUseJetRefTracks   = kFALSE ;
+  fMakeCorrelationInHistoMaker = kFALSE ;
+  }
+
+//__________________________________________________________________
+Int_t  AliAnaParticleJetFinderCorrelation::SelectJet(AliAODParticleCorrelation * particle)
+{
+       //Returns the index of the jet that is opposite to the particle
+       
+       Int_t njets = (GetReader()->GetAOD())->GetNJets() ;     
+       cout<<">> Loop on Jets"<<endl;
+       AliAODJet * jet = new AliAODJet ;
+       Int_t index = -1;
+       for(Int_t ijet = 0; ijet < njets ; ijet++){
+               jet = (GetReader()->GetAOD())->GetJet(ijet) ;     
+               Float_t dphi  = TMath::Abs(particle->Phi()-jet->Phi());
+               Float_t ratio = jet->Pt()/particle->Pt();
+               if(GetDebug() > 3)
+                       printf("Jet %d, Ratio pT %2.3f, Delta phi %2.3f\n",ijet,ratio,dphi);      
+               Float_t dphiprev= 10000;
+               if((dphi > fDeltaPhiMinCut) && (dphi<fDeltaPhiMaxCut) &&
+                       (ratio > fRatioMinCut) && (ratio < fRatioMaxCut)  &&
+                       (TMath::Abs(dphi-3.14159) < TMath::Abs(dphiprev-3.14159))){//In case there is more than one jet select the most opposite.
+                       dphiprev = dphi;
+                       index = ijet ;  
+               }//Selection cuts
+       }//AOD Jet loop
+
+       return index ;
+
+}
+
+//__________________________________________________________________
+void  AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() 
+{  
+       //Particle-Jet Correlation Analysis, fill AODs
+       
+       Int_t ntrig =  GetAODBranch()->GetEntriesFast() ;  
+    if(GetDebug() > -3){
+    printf("Begin jet finder  correlation analysis, fill AODs \n");
+    printf("In particle branch aod entries %d\n", ntrig);
+    printf("In jet      branch aod entries %d\n", (GetReader()->GetAOD())->GetNJets());
+       }
+       
+       //Loop on stored AOD particles, trigger
+       for(Int_t iaod = 0; iaod < ntrig ; iaod++){
+               AliAODParticleCorrelation* particle =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->At(iaod));
+               //cout<<">> Test reference "<<particle->GetRefJet()<<endl;
+                       //Correlate with jets
+               Int_t ijet = SelectJet(particle);
+               if(ijet > -1){
+                       if(GetDebug() > 2) printf ("Jet with index %d selected \n",ijet);
+                       AliAODJet *jet = (GetReader()->GetAOD())->GetJet(ijet);
+                       particle->SetRefJet(jet);       
+               }
+       }                 
+       
+       if(GetDebug() >1)printf("End of jet leading cone analysis, fill AODs \n");
+} 
+
+//__________________________________________________________________
+void  AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms() 
+{
+       //Particle-Jet Correlation Analysis, fill histograms
+       Int_t ntrig   =  GetAODBranch()->GetEntriesFast() ;    
+       if(GetDebug() > 1){
+               printf("Begin jet finder  correlation analysis, fill histograms \n");
+               printf("In particle branch aod entries %d\n", ntrig);
+               printf("In jet      branch aod entries %d\n", (GetReader()->GetAOD())->GetNJets());
+       }
+       
+       //Loop on stored AOD particles, trigger
+       for(Int_t iaod = 0; iaod < ntrig ; iaod++){
+               AliAODParticleCorrelation* particle =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->At(iaod));
+               //cout<<">> Test reference "<<particle->GetRefJet()<<endl;
+               
+               //Recover the jet correlated, found previously.
+               AliAODJet       * jet = particle->GetJet();
+               //If correlation not made before, do it now.
+               if(fMakeCorrelationInHistoMaker){
+                       //Correlate with jets
+                       Int_t ijet = SelectJet(particle);
+                       if(ijet > -1){
+                               if(GetDebug() > 2) printf ("Jet with index %d selected \n",ijet);
+                               jet = (GetReader()->GetAOD())->GetJet(ijet);
+                               particle->SetRefJet(jet);       
+                       }
+               }
+               
+               if (!jet) continue ;
+       
+               //Fill Histograms
+         
+               Double_t ptTrig = particle->Pt();
+               Double_t ptJet = jet->Pt();
+               Double_t phiTrig = particle->Phi();
+               Double_t phiJet = jet->Phi();
+               Double_t etaTrig = particle->Eta();
+               Double_t etaJet = jet->Eta();
+               //printf("pT trigger %2.3f, pT jet %2.3f, Delta phi %2.3f, Delta eta %2.3f, Delta pT %2.3f, ratio %2.3f \n",
+               //      ptTrig,ptJet, phiJet-phiTrig, etaJet-etaTrig, ptTrig-ptJet, ptJet/ptTrig);
+               fhDeltaPt ->Fill(ptTrig, ptTrig-ptJet);
+               fhDeltaPhi->Fill(ptTrig, phiJet-phiTrig);
+               fhDeltaEta->Fill(ptTrig, etaJet-etaTrig);
+               fhPtRatio ->Fill(ptTrig, ptJet/ptTrig);
+               fhPt      ->Fill(ptTrig, ptJet);
+
+               //Fragmentation function
+               Float_t  rad = 0, pt = 0, eta = 0, phi = 0;
+               Int_t    npartcone = 0;
+               TVector3 p3;
+               AliAODTrack* track = new AliAODTrack ;
+       
+               Int_t ntracks =  0;
+               if(!fUseJetRefTracks)
+                       ntracks =GetAODCTS()->GetEntriesFast();
+               else //If you want to use jet tracks from JETAN
+                       ntracks =  (jet->GetRefTracks())->GetEntriesFast();
+       
+               for(Int_t ipr = 0;ipr < ntracks ; ipr ++ ){
+                       if(!fUseJetRefTracks)
+                               track = dynamic_cast<AliAODTrack *>(GetAODCTS()->At(ipr)) ; 
+                       else //If you want to use jet tracks from JETAN
+                               track = dynamic_cast<AliAODTrack *>((jet->GetRefTracks())->At(ipr));
+                                       
+                       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-etaJet)*(eta-etaJet)+ (phi-phiJet)*(phi-phiJet));
+                       if(rad < fConeSize  && pt > fPtThresholdInCone){        
+                               //printf("charged in jet cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
+                               npartcone++;
+                               fhFFz ->Fill(ptTrig, pt/ptTrig);
+                               fhFFxi->Fill(ptTrig, TMath::Log(ptTrig/pt));
+                               fhFFpt->Fill(ptTrig, pt);
+                       }
+               }//Tracks
+               fhNTracksInCone->Fill(ptTrig, npartcone);
+       }//AOD trigger particle loop
+       if(GetDebug() >1) printf("End of jet leading cone analysis, fill histograms \n");
+} 
+
+
+//__________________________________________________________________
+void AliAnaParticleJetFinderCorrelation::Print(const Option_t * opt) const
+{
+
+       //Print some relevant parameters set for the analysis
+       if(! opt)
+               return;
+  
+       printf("Phi trigger-jet        <     %3.2f\n", fDeltaPhiMaxCut) ; 
+       printf("Phi trigger-jet        >     %3.2f\n", fDeltaPhiMinCut) ;
+       printf("pT Ratio trigger/jet   <     %3.2f\n", fRatioMaxCut) ; 
+       printf("pT Ratio trigger/jet   >     %3.2f\n", fRatioMinCut) ;
+       printf("fConeSize              =     %3.2f\n", fConeSize) ; 
+       printf("fPtThresholdInCone     =     %3.2f\n", fPtThresholdInCone) ;
+       printf("fUseJetRefTracks           =     %d\n",    fUseJetRefTracks) ;
+       printf("fMakeCorrelationInHistoMaker       =     %d\n",    fMakeCorrelationInHistoMaker) ;      
+} 
+
diff --git a/PWG4/PartCorr/AliAnaParticleJetFinderCorrelation.h b/PWG4/PartCorr/AliAnaParticleJetFinderCorrelation.h
new file mode 100644 (file)
index 0000000..c61f241
--- /dev/null
@@ -0,0 +1,94 @@
+#ifndef AliAnaParticleJetFinderCorrelation_H
+#define AliAnaParticleJetFinderCorrelation_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+/* $Id: AliAnaParticleJetFinderCorrelation.h 21839 2007-10-29 13:49:42Z gustavo $ */
+
+
+//_________________________________________________________________________
+// Class that contains the algorithm for the analysis of particle (direct gamma) - jet 
+// (standard jet found with JETAN) correlation 
+// Particle and jet for correlation found by independent algorithms.
+// For Example direct isolated photon found in AliAnaGammaDirect and the jet with JETAN
+//
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+class TH2F;
+
+//---- Analysis system ----
+class AliLog;
+#include "AliAnaPartCorrBaseClass.h"
+     
+class AliAnaParticleJetFinderCorrelation : public AliAnaPartCorrBaseClass {
+       
+       public: 
+       
+               AliAnaParticleJetFinderCorrelation() ; // default ctor
+               AliAnaParticleJetFinderCorrelation(const AliAnaParticleJetFinderCorrelation & g) ; // cpy ctor
+               AliAnaParticleJetFinderCorrelation & operator = (const AliAnaParticleJetFinderCorrelation & g) ;//cpy assignment
+               virtual ~AliAnaParticleJetFinderCorrelation() {;} //virtual dtor
+              
+               TList * GetCreateOutputObjects();
+       
+               void InitParameters();
+       
+               void Print(const Option_t * opt) const;
+       
+               Float_t  GetConeSize() const {return fConeSize ; }
+               Float_t  GetPtThresholdInCone() const {return fPtThresholdInCone ; }       
+               Double_t GetDeltaPhiMaxCut() const {return fDeltaPhiMaxCut ; }
+               Double_t GetDeltaPhiMinCut() const {return fDeltaPhiMinCut ; }
+               Double_t GetRatioMaxCut() const {return fRatioMaxCut ; }
+               Double_t GetRatioMinCut() const {return fRatioMinCut ; }           
+               Bool_t   AreJetRefTracks() const {return fUseJetRefTracks ; }
+               Bool_t   IsCorrelationMadeInHistoMaker() const {return fMakeCorrelationInHistoMaker ;} 
+               
+               void SetConeSize(Float_t cone) {fConeSize = cone; }
+               void SetPtThresholdInCone(Float_t pt){fPtThresholdInCone = pt; };          
+               void SetDeltaPhiCutRange(Double_t phimin, Double_t phimax)
+                       {fDeltaPhiMaxCut =phimax;  fDeltaPhiMinCut =phimin;}
+               void SetRatioCutRange(Double_t ratiomin, Double_t ratiomax)
+                       {fRatioMaxCut =ratiomax;  fRatioMinCut = ratiomin ; }
+               void UseJetRefTracks(Bool_t use) {fUseJetRefTracks = use ; }    
+           void SetMakeCorrelationInHistoMaker(Bool_t make) {fMakeCorrelationInHistoMaker = make ;}    
+               
+        private:
+    
+               Int_t SelectJet(AliAODParticleCorrelation * particle) ;
+       
+           void MakeAnalysisFillAOD() ;
+        void MakeAnalysisFillHistograms() ;
+                       
+  private:
+       
+       //selection parameters  
+       Double_t   fDeltaPhiMaxCut ; //! Minimum Delta Phi Gamma-Leading
+       Double_t   fDeltaPhiMinCut ; //!  Maximum Delta Phi Gamma-Leading
+       Double_t   fRatioMaxCut ; //! Jet/ particle Ratio cut maximum
+       Double_t   fRatioMinCut ; //! Jet/particle Ratio cut minimum
+          
+       Double_t   fConeSize  ;         //! Jet cone size 
+       Double_t   fPtThresholdInCone ; //! Jet pT threshold in jet cone
+       Bool_t     fUseJetRefTracks ; //! Use track references from JETAN not the AOD tracks
+       Bool_t     fMakeCorrelationInHistoMaker ; //!Make particle-jet correlation in histogram maker
+          
+       TH2F * fhDeltaEta; //! Difference of jet eta and trigger particle eta as function of trigger particle pT
+       TH2F * fhDeltaPhi;  //! Difference of jet phi and trigger particle phi as function of trigger particle pT
+       TH2F * fhDeltaPt; //! Difference of jet pT and trigger particle pT as function of trigger particle pT
+       TH2F * fhPtRatio; //! Ratio of jet pT and trigger particle pT as function of trigger particle pT
+       TH2F * fhPt; //! jet pT vs trigger particle pT 
+               
+       TH2F * fhFFz ; //! Accepted reconstructed jet fragmentation function, z=ptjet/pttrig
+       TH2F * fhFFxi; //! Accepted reconstructed jet fragmentation function, xsi = ln(pttrig/ptjet)
+       TH2F * fhFFpt; //! Jet particle pt distribution in cone
+       TH2F * fhNTracksInCone   ; //! jet multiplicity in cone
+          
+       ClassDef(AliAnaParticleJetFinderCorrelation,1)
+ } ;
+
+
+#endif //AliAnaParticleJetFinderCorrelation_H
+
+
+
diff --git a/PWG4/PartCorr/AliAnaParticleJetLeadingConeCorrelation.cxx b/PWG4/PartCorr/AliAnaParticleJetLeadingConeCorrelation.cxx
new file mode 100644 (file)
index 0000000..1c4a9c7
--- /dev/null
@@ -0,0 +1,1509 @@
+/**************************************************************************
+ * 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 that contains the algorithm for the reconstruction of jet, cone around leading particle
+// The seed is a backward particle (direct photon)
+// 1)Take the trigger particle stored in AliAODParticleCorrelation,
+// 2) Search for the highest pt leading particle opposite to the photon within a phi, pt window
+// 3) Take all particles around leading in a cone R with pt larger than threshold and construct the jet
+//
+//  Class created from old AliPHOSGammaJet 
+//  (see AliRoot versions previous Release 4-09)
+//
+//*-- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+
+// --- ROOT system ---
+#include "TH2F.h"
+
+//---- Analysis system ----
+#include "AliAODTrack.h"
+#include "AliAODCaloCluster.h"
+#include "AliCaloTrackReader.h"
+#include "AliNeutralMesonSelection.h"
+#include "AliLog.h"
+#include "AliAnaParticleJetLeadingConeCorrelation.h"  
+
+
+ClassImp(AliAnaParticleJetLeadingConeCorrelation)
+
+
+//____________________________________________________________________________
+  AliAnaParticleJetLeadingConeCorrelation::AliAnaParticleJetLeadingConeCorrelation() : 
+    AliAnaPartCorrBaseClass(), fJetsOnlyInCTS(kFALSE), fPbPb(kFALSE),     
+    fSeveralConeAndPtCuts(0),  fReMakeJet(0),
+    fDeltaPhiMaxCut(0.), fDeltaPhiMinCut(0.), 
+    fLeadingRatioMaxCut(0.),  fLeadingRatioMinCut(0.), 
+    fJetCTSRatioMaxCut(0.), fJetCTSRatioMinCut(0.), 
+    fJetRatioMaxCut(0.),  fJetRatioMinCut(0.), 
+    fJetNCone(0),fJetNPt(0), fJetCone(0), 
+    fJetPtThreshold(0),fJetPtThresPbPb(0),
+    fPtTriggerSelectionCut(0.0), fSelect(0),
+    //Histograms
+    fOutCont(0x0),
+    fhChargedLeadingPt(0),fhChargedLeadingPhi(0),fhChargedLeadingEta(0),
+    fhChargedLeadingDeltaPt(0),fhChargedLeadingDeltaPhi(0),fhChargedLeadingDeltaEta(0),
+    fhChargedLeadingRatioPt(0),
+    fhNeutralLeadingPt(0),fhNeutralLeadingPhi(0),fhNeutralLeadingEta(0),
+    fhNeutralLeadingDeltaPt(0),fhNeutralLeadingDeltaPhi(0),fhNeutralLeadingDeltaEta(0),
+    fhNeutralLeadingRatioPt(0),
+    fhJetPt(0),fhJetRatioPt(0),fhJetDeltaPhi(0), fhJetDeltaEta(0),
+    fhJetLeadingRatioPt(0),fhJetLeadingDeltaPhi(0),fhJetLeadingDeltaEta(0),
+    fhJetFFz(0),fhJetFFxi(0),fhJetFFpt(0),fhJetNTracksInCone(0),
+    fhBkgPt(0),fhBkgRatioPt(0),fhBkgDeltaPhi(0), fhBkgDeltaEta(0),
+    fhBkgLeadingRatioPt(0),fhBkgLeadingDeltaPhi(0),fhBkgLeadingDeltaEta(0),
+    fhBkgFFz(0),fhBkgFFxi(0),fhBkgFFpt(0),fhBkgNTracksInCone(0),
+    //Several cones and thres histograms
+    fhJetPts(),fhJetRatioPts(),fhJetDeltaPhis(), fhJetDeltaEtas(),
+    fhJetLeadingRatioPts(),fhJetLeadingDeltaPhis(),fhJetLeadingDeltaEtas(),
+    fhJetFFzs(),fhJetFFxis(),fhJetFFpts(),fhJetNTracksInCones(),
+    fhBkgPts(),fhBkgRatioPts(),fhBkgDeltaPhis(), fhBkgDeltaEtas(),
+    fhBkgLeadingRatioPts(),fhBkgLeadingDeltaPhis(),fhBkgLeadingDeltaEtas(),
+    fhBkgFFzs(),fhBkgFFxis(),fhBkgFFpts(),fhBkgNTracksInCones()
+{
+  //Default Ctor
+
+  //Initialize parameters
+
+  for(Int_t i = 0; i<6; i++){
+    fJetXMin1[i]     = 0.0 ;
+    fJetXMin2[i]     = 0.0 ;
+    fJetXMax1[i]     = 0.0 ;
+    fJetXMax2[i]     = 0.0 ;
+    fBkgMean[i]      = 0.0 ;
+    fBkgRMS[i]       = 0.0 ;
+    if( i < 2 ){
+      fJetE1[i]        = 0.0 ;
+      fJetE2[i]        = 0.0 ;
+      fJetSigma1[i]    = 0.0 ;
+      fJetSigma2[i]    = 0.0 ;
+    }
+  }
+
+  //Several cones and thres histograms
+  for(Int_t i = 0; i<5; i++){
+    fJetCones[i]         = 0.0 ;
+    fJetNameCones[i]     = ""  ;
+    fJetPtThres[i]      = 0.0 ;
+    fJetNamePtThres[i]  = ""  ;
+    for(Int_t j = 0; j<5; j++){
+      fhJetPts[i][j]=0 ;
+      fhJetRatioPts[i][j]=0 ;
+      fhJetDeltaPhis[i][j]=0 ; 
+      fhJetDeltaEtas[i][j]=0 ;
+      fhJetLeadingRatioPts[i][j]=0 ;
+      fhJetLeadingDeltaPhis[i][j]=0 ;
+      fhJetLeadingDeltaEtas[i][j]=0 ;
+      fhJetFFzs[i][j]=0 ;
+      fhJetFFxis[i][j]=0 ;
+      fhJetFFpts[i][j]=0 ;
+      fhJetNTracksInCones[i][j]=0 ;
+      fhBkgPts[i][j]=0 ;
+      fhBkgRatioPts[i][j]=0 ;
+      fhBkgDeltaPhis[i][j]=0 ; 
+      fhBkgDeltaEtas[i][j]=0 ;
+      fhBkgLeadingRatioPts[i][j]=0 ;
+      fhBkgLeadingDeltaPhis[i][j]=0 ;
+      fhBkgLeadingDeltaEtas[i][j]=0 ;
+      fhBkgFFzs[i][j]=0 ;
+      fhBkgFFxis[i][j]=0 ;
+      fhBkgFFpts[i][j]=0 ;
+      fhBkgNTracksInCones[i][j]=0 ;
+    }
+  }
+
+  InitParameters();
+
+}
+
+//____________________________________________________________________________
+AliAnaParticleJetLeadingConeCorrelation::AliAnaParticleJetLeadingConeCorrelation(const AliAnaParticleJetLeadingConeCorrelation & jetlc) :   
+  AliAnaPartCorrBaseClass(jetlc), fJetsOnlyInCTS(jetlc.fJetsOnlyInCTS), fPbPb(jetlc.fPbPb), 
+  fSeveralConeAndPtCuts(jetlc.fSeveralConeAndPtCuts),  fReMakeJet(jetlc. fReMakeJet),
+  fDeltaPhiMaxCut(jetlc. fDeltaPhiMaxCut), fDeltaPhiMinCut(jetlc.fDeltaPhiMinCut), 
+  fLeadingRatioMaxCut(jetlc.fLeadingRatioMaxCut),  fLeadingRatioMinCut(jetlc.fLeadingRatioMinCut), 
+  fJetCTSRatioMaxCut(jetlc.fJetCTSRatioMaxCut),
+  fJetCTSRatioMinCut(jetlc.fJetCTSRatioMinCut), fJetRatioMaxCut(jetlc.fJetRatioMaxCut),
+  fJetRatioMinCut(jetlc.fJetRatioMinCut),  fJetNCone(jetlc.fJetNCone),
+  fJetNPt(jetlc.fJetNPt), fJetCone(jetlc.fJetCone),
+  fJetPtThreshold(jetlc.fJetPtThreshold),fJetPtThresPbPb(jetlc.fJetPtThresPbPb),
+  fPtTriggerSelectionCut(jetlc.fPtTriggerSelectionCut), fSelect(jetlc.fSelect),  
+  //Histograms
+  fOutCont(jetlc. fOutCont),
+  fhChargedLeadingPt(jetlc.fhChargedLeadingPt), fhChargedLeadingPhi(jetlc.fhChargedLeadingPhi),
+  fhChargedLeadingEta(jetlc.fhChargedLeadingEta), fhChargedLeadingDeltaPt(jetlc.fhChargedLeadingDeltaPt),
+  fhChargedLeadingDeltaPhi(jetlc.fhChargedLeadingDeltaPhi),fhChargedLeadingDeltaEta(jetlc.fhChargedLeadingDeltaEta),
+  fhChargedLeadingRatioPt(jetlc.fhChargedLeadingRatioPt),
+  fhNeutralLeadingPt(jetlc.fhNeutralLeadingPt),fhNeutralLeadingPhi(jetlc.fhNeutralLeadingPhi),
+  fhNeutralLeadingEta(jetlc.fhNeutralLeadingEta), fhNeutralLeadingDeltaPt(jetlc.fhNeutralLeadingDeltaPt),
+  fhNeutralLeadingDeltaPhi(jetlc.fhNeutralLeadingDeltaPhi),fhNeutralLeadingDeltaEta(jetlc.fhNeutralLeadingDeltaEta),
+  fhNeutralLeadingRatioPt(jetlc.fhNeutralLeadingRatioPt),
+  fhJetPt(jetlc.fhJetPt),fhJetRatioPt(jetlc.fhJetRatioPt),fhJetDeltaPhi(jetlc.fhJetDeltaPhi), 
+  fhJetDeltaEta(jetlc.fhJetDeltaEta), fhJetLeadingRatioPt(jetlc.fhJetLeadingRatioPt),
+  fhJetLeadingDeltaPhi(jetlc.fhJetLeadingDeltaPhi),fhJetLeadingDeltaEta(jetlc.fhJetLeadingDeltaEta),
+  fhJetFFz(jetlc.fhJetFFz),fhJetFFxi(jetlc.fhJetFFxi),fhJetFFpt(jetlc.fhJetFFpt),
+  fhJetNTracksInCone(jetlc.fhJetNTracksInCone),
+  fhBkgPt(jetlc.fhBkgPt),fhBkgRatioPt(jetlc.fhBkgRatioPt),fhBkgDeltaPhi(jetlc.fhBkgDeltaPhi), 
+  fhBkgDeltaEta(jetlc.fhBkgDeltaEta), fhBkgLeadingRatioPt(jetlc.fhBkgLeadingRatioPt),
+  fhBkgLeadingDeltaPhi(jetlc.fhBkgLeadingDeltaPhi),fhBkgLeadingDeltaEta(jetlc.fhBkgLeadingDeltaEta),
+  fhBkgFFz(jetlc.fhBkgFFz),fhBkgFFxi(jetlc.fhBkgFFxi),fhBkgFFpt(jetlc.fhBkgFFpt),
+  fhBkgNTracksInCone(jetlc.fhBkgNTracksInCone),
+  //Several cones and thres histograms
+  fhJetPts(),fhJetRatioPts(),fhJetDeltaPhis(), fhJetDeltaEtas(),
+  fhJetLeadingRatioPts(),fhJetLeadingDeltaPhis(),fhJetLeadingDeltaEtas(),
+  fhJetFFzs(),fhJetFFxis(),fhJetFFpts(),fhJetNTracksInCones(),
+  fhBkgPts(),fhBkgRatioPts(),fhBkgDeltaPhis(), fhBkgDeltaEtas(),
+  fhBkgLeadingRatioPts(),fhBkgLeadingDeltaPhis(),fhBkgLeadingDeltaEtas(),
+  fhBkgFFzs(),fhBkgFFxis(),fhBkgFFpts(),fhBkgNTracksInCones()
+{
+  // cpy ctor
+
+  for(Int_t i = 0; i<6; i++){
+    fJetXMin1[i]       = jetlc.fJetXMin1[i] ;
+    fJetXMin2[i]       = jetlc.fJetXMin2[i] ;
+    fJetXMax1[i]       = jetlc.fJetXMax1[i] ;
+    fJetXMax2[i]       = jetlc.fJetXMax2[i] ;
+    fBkgMean[i]        = jetlc.fBkgMean[i] ;
+    fBkgRMS[i]         = jetlc.fBkgRMS[i] ;
+    if( i < 2 ){
+      fJetE1[i]        = jetlc.fJetE1[i] ;
+      fJetE2[i]        = jetlc.fJetE2[i] ;
+      fJetSigma1[i]    = jetlc.fJetSigma1[i] ;
+      fJetSigma2[i]    = jetlc.fJetSigma2[i] ;
+    }
+  }          
+
+  //Several cones and thres histograms
+  for(Int_t i = 0; i<5; i++){
+    fJetCones[i]        = jetlc.fJetCones[i] ;
+    fJetNameCones[i]    = jetlc.fJetNameCones[i] ;
+    fJetPtThres[i]      = jetlc.fJetPtThres[i] ;
+    fJetNamePtThres[i]  = jetlc.fJetNamePtThres[i] ;
+    for(Int_t j = 0; j<5; j++){
+      fhJetPts[i][j] = jetlc.fhJetPts[i][j] ;
+      fhJetRatioPts[i][j] = jetlc.fhJetRatioPts[i][j] ;
+      fhJetDeltaPhis[i][j] = jetlc.fhJetDeltaPhis[i][j] ; 
+      fhJetDeltaEtas[i][j] = jetlc.fhJetDeltaEtas[i][j] ;
+      fhJetLeadingRatioPts[i][j] = jetlc.fhJetLeadingRatioPts[i][j] ;
+      fhJetLeadingDeltaPhis[i][j] = jetlc.fhJetLeadingDeltaPhis[i][j] ;
+      fhJetLeadingDeltaEtas[i][j] = jetlc.fhJetLeadingDeltaEtas[i][j] ;
+      fhJetFFzs[i][j] = jetlc.fhJetFFzs[i][j] ;
+      fhJetFFxis[i][j] = jetlc.fhJetFFxis[i][j] ;
+      fhJetFFpts[i][j] = jetlc.fhJetFFpts[i][j] ;
+      fhJetNTracksInCones[i][j] = fhJetNTracksInCones[i][j] ;
+      fhBkgPts[i][j] = jetlc.fhBkgPts[i][j] ;
+      fhBkgRatioPts[i][j] = jetlc.fhBkgRatioPts[i][j] ;
+      fhBkgDeltaPhis[i][j] = jetlc.fhBkgDeltaPhis[i][j] ; 
+      fhBkgDeltaEtas[i][j] = jetlc.fhBkgDeltaEtas[i][j] ;
+      fhBkgLeadingRatioPts[i][j] = jetlc.fhBkgLeadingRatioPts[i][j] ;
+      fhBkgLeadingDeltaPhis[i][j] = jetlc.fhBkgLeadingDeltaPhis[i][j] ;
+      fhBkgLeadingDeltaEtas[i][j] = jetlc.fhBkgLeadingDeltaEtas[i][j] ;
+      fhBkgFFzs[i][j] = jetlc.fhBkgFFzs[i][j] ;
+      fhBkgFFxis[i][j] = jetlc.fhBkgFFxis[i][j] ;
+      fhBkgFFpts[i][j] = jetlc.fhBkgFFpts[i][j] ;
+      fhBkgNTracksInCones[i][j] = jetlc.fhBkgNTracksInCones[i][j] ;
+    }
+  }  
+}
+
+//_________________________________________________________________________
+AliAnaParticleJetLeadingConeCorrelation & AliAnaParticleJetLeadingConeCorrelation::operator = (const AliAnaParticleJetLeadingConeCorrelation & jetlc)
+{
+  // assignment operator
+
+  if(this == &jetlc)return *this;
+  ((AliAnaPartCorrBaseClass *)this)->operator=(jetlc);
+
+  fSeveralConeAndPtCuts = jetlc.fSeveralConeAndPtCuts ; 
+  fPbPb = jetlc.fPbPb ;
+  fReMakeJet = jetlc.fReMakeJet ;
+  fJetsOnlyInCTS = jetlc.fJetsOnlyInCTS;
+
+  fDeltaPhiMaxCut = jetlc.fDeltaPhiMaxCut ; 
+  fDeltaPhiMinCut = jetlc.fDeltaPhiMinCut ; 
+  fLeadingRatioMaxCut = jetlc.fLeadingRatioMaxCut ;
+  fLeadingRatioMinCut = jetlc.fLeadingRatioMinCut ;
+  
+  fJetCTSRatioMaxCut = jetlc.fJetCTSRatioMaxCut ;
+  fJetCTSRatioMinCut = jetlc.fJetCTSRatioMinCut ; 
+  fJetRatioMaxCut = jetlc.fJetRatioMaxCut ;
+  fJetRatioMinCut = jetlc.fJetRatioMinCut ; 
+  fJetNCone = jetlc.fJetNCone ;
+  fJetNPt = jetlc.fJetNPt ; fJetCone = jetlc.fJetCone ; 
+  fJetPtThreshold = jetlc.fJetPtThreshold ;
+  fJetPtThresPbPb = jetlc.fJetPtThresPbPb ;
+  fPtTriggerSelectionCut = jetlc.fPtTriggerSelectionCut ;
+  fSelect = jetlc.fSelect ;  
+
+  for(Int_t i = 0; i<6; i++){
+    fJetXMin1[i]       = jetlc.fJetXMin1[i] ;
+    fJetXMin2[i]       = jetlc.fJetXMin2[i] ;
+    fJetXMax1[i]       = jetlc.fJetXMax1[i] ;
+    fJetXMax2[i]       = jetlc.fJetXMax2[i] ;
+    fBkgMean[i]        = jetlc.fBkgMean[i] ;
+    fBkgRMS[i]         = jetlc.fBkgRMS[i] ;
+    if( i < 2 ){
+      fJetE1[i]        = jetlc.fJetE1[i] ;
+      fJetE2[i]        = jetlc.fJetE2[i] ;
+      fJetSigma1[i]    = jetlc.fJetSigma1[i] ;
+      fJetSigma2[i]    = jetlc.fJetSigma2[i] ;
+    }
+  }     
+
+  //Histograms
+  fOutCont = jetlc. fOutCont ;
+  fhChargedLeadingPt = jetlc.fhChargedLeadingPt; fhChargedLeadingPhi = jetlc.fhChargedLeadingPhi;
+  fhChargedLeadingEta = jetlc.fhChargedLeadingEta; fhChargedLeadingDeltaPt = jetlc.fhChargedLeadingDeltaPt;
+  fhChargedLeadingDeltaPhi = jetlc.fhChargedLeadingDeltaPhi;fhChargedLeadingDeltaEta = jetlc.fhChargedLeadingDeltaEta;
+  fhChargedLeadingRatioPt = jetlc.fhChargedLeadingRatioPt;
+  fhNeutralLeadingPt = jetlc.fhNeutralLeadingPt;fhNeutralLeadingPhi = jetlc.fhNeutralLeadingPhi;
+  fhNeutralLeadingEta = jetlc.fhNeutralLeadingEta; fhNeutralLeadingDeltaPt = jetlc.fhNeutralLeadingDeltaPt;
+  fhNeutralLeadingDeltaPhi = jetlc.fhNeutralLeadingDeltaPhi;fhNeutralLeadingDeltaEta = jetlc.fhNeutralLeadingDeltaEta;
+  fhNeutralLeadingRatioPt = jetlc.fhNeutralLeadingRatioPt;
+  fhJetPt = jetlc.fhJetPt;fhJetRatioPt = jetlc.fhJetRatioPt;fhJetDeltaPhi = jetlc.fhJetDeltaPhi; 
+  fhJetDeltaEta = jetlc.fhJetDeltaEta; fhJetLeadingRatioPt = jetlc.fhJetLeadingRatioPt;
+  fhJetLeadingDeltaPhi = jetlc.fhJetLeadingDeltaPhi;fhJetLeadingDeltaEta = jetlc.fhJetLeadingDeltaEta;
+  fhJetFFz = jetlc.fhJetFFz;fhJetFFxi = jetlc.fhJetFFxi;fhJetFFpt = jetlc.fhJetFFpt;
+  fhJetNTracksInCone = jetlc.fhJetNTracksInCone;
+  fhBkgPt = jetlc.fhBkgPt;fhBkgRatioPt = jetlc.fhBkgRatioPt;fhBkgDeltaPhi = jetlc.fhBkgDeltaPhi; 
+  fhBkgDeltaEta = jetlc.fhBkgDeltaEta; fhBkgLeadingRatioPt = jetlc.fhBkgLeadingRatioPt;
+  fhBkgLeadingDeltaPhi = jetlc.fhBkgLeadingDeltaPhi;fhBkgLeadingDeltaEta = jetlc.fhBkgLeadingDeltaEta;
+  fhBkgFFz = jetlc.fhBkgFFz;fhBkgFFxi = jetlc.fhBkgFFxi;fhBkgFFpt = jetlc.fhBkgFFpt;
+  fhBkgNTracksInCone = jetlc.fhBkgNTracksInCone;
+
+
+  //Several cones and thres histograms
+  for(Int_t i = 0; i<5; i++){
+    fJetCones[i]        = jetlc.fJetCones[i] ;
+    fJetNameCones[i]    = jetlc.fJetNameCones[i] ;
+    fJetPtThres[i]      = jetlc.fJetPtThres[i] ;
+    fJetNamePtThres[i]  = jetlc.fJetNamePtThres[i] ;
+    
+    for(Int_t j = 0; j<5; j++){
+      fhJetPts[i][j] = jetlc.fhJetPts[i][j] ;
+      fhJetRatioPts[i][j] = jetlc.fhJetRatioPts[i][j] ;
+      fhJetDeltaPhis[i][j] = jetlc.fhJetDeltaPhis[i][j] ; 
+      fhJetDeltaEtas[i][j] = jetlc.fhJetDeltaEtas[i][j] ;
+      fhJetLeadingRatioPts[i][j] = jetlc.fhJetLeadingRatioPts[i][j] ;
+      fhJetLeadingDeltaPhis[i][j] = jetlc.fhJetLeadingDeltaPhis[i][j] ;
+      fhJetLeadingDeltaEtas[i][j] = jetlc.fhJetLeadingDeltaEtas[i][j] ;
+      fhJetFFzs[i][j] = jetlc.fhJetFFzs[i][j] ;
+      fhJetFFxis[i][j] = jetlc.fhJetFFxis[i][j] ;
+      fhJetFFpts[i][j] = jetlc.fhJetFFpts[i][j] ;
+      fhJetNTracksInCones[i][j] = fhJetNTracksInCones[i][j] ;
+      fhBkgPts[i][j] = jetlc.fhBkgPts[i][j] ;
+      fhBkgRatioPts[i][j] = jetlc.fhBkgRatioPts[i][j] ;
+      fhBkgDeltaPhis[i][j] = jetlc.fhBkgDeltaPhis[i][j] ; 
+      fhBkgDeltaEtas[i][j] = jetlc.fhBkgDeltaEtas[i][j] ;
+      fhBkgLeadingRatioPts[i][j] = jetlc.fhBkgLeadingRatioPts[i][j] ;
+      fhBkgLeadingDeltaPhis[i][j] = jetlc.fhBkgLeadingDeltaPhis[i][j] ;
+      fhBkgLeadingDeltaEtas[i][j] = jetlc.fhBkgLeadingDeltaEtas[i][j] ;
+      fhBkgFFzs[i][j] = jetlc.fhBkgFFzs[i][j] ;
+      fhBkgFFxis[i][j] = jetlc.fhBkgFFxis[i][j] ;
+      fhBkgFFpts[i][j] = jetlc.fhBkgFFpts[i][j] ;
+      fhBkgNTracksInCones[i][j] = jetlc.fhBkgNTracksInCones[i][j] ;
+    }
+  }      
+
+  return *this;
+
+}
+
+//____________________________________________________________________________
+AliAnaParticleJetLeadingConeCorrelation::~AliAnaParticleJetLeadingConeCorrelation() 
+{
+   // Remove all pointers except analysis output pointers.
+  delete [] fJetE1;  
+  delete [] fJetE2;    
+  delete [] fJetSigma1;
+  delete [] fJetSigma2;
+  delete [] fBkgMean; 
+  delete [] fBkgRMS;  
+  delete [] fJetXMin1;
+  delete [] fJetXMin2;
+  delete [] fJetXMax1;
+  delete [] fJetXMax2; 
+  delete [] fJetCones;         
+  delete [] fJetNameCones;   
+  delete [] fJetPtThres;       
+  delete [] fJetNamePtThres;  
+}
+
+//____________________________________________________________________________
+Double_t AliAnaParticleJetLeadingConeCorrelation::CalculateJetRatioLimit(const Double_t ptg, const Double_t *par, const Double_t *x) {
+  //Calculate the ratio of the jet and trigger particle limit for the selection
+  //WARNING: need to check what it does
+  //Info("CalculateLimit","x1 %f, x2%f",x[0],x[1]);
+  Double_t Epp = par[0] + par[1] * ptg ;
+  Double_t Spp = par[2] + par[3] * ptg ;
+  Double_t f   = x[0]   + x[1]   * ptg ;
+  Double_t Epb = Epp + par[4] ;
+  Double_t Spb = TMath::Sqrt(Spp*Spp+ par[5]*par[5]) ;
+  Double_t rat = (Epb - Spb * f) / ptg ;
+  //Info("CalculateLimit","Epp %f, Spp %f, f %f", Epp, Spp, f);
+  //Info("CalculateLimit","Epb %f, Spb %f, rat %f", Epb, Spb, rat);
+  return rat ;
+}
+
+//____________________________________________________________________________
+void AliAnaParticleJetLeadingConeCorrelation::FillJetHistos(AliAODParticleCorrelation * particle, const TLorentzVector  leading, const TLorentzVector jet, const TString type, const TString lastname)
+{
+  //Fill jet and background histograms 
+  Double_t ptTrig = particle->Pt();
+  Double_t ptJet = jet.Pt();
+  Double_t ptLead = leading.Pt();
+  Double_t phiTrig = particle->Phi();
+  Double_t phiJet = jet.Phi();
+  Double_t phiLead = leading.Phi();
+  Double_t etaTrig = particle->Eta();
+  Double_t etaJet = jet.Eta();
+  Double_t etaLead = leading.Eta();
+
+   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"Pt"+lastname))->
+     Fill(ptTrig,ptJet);
+   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"RatioPt"+lastname))->
+     Fill(ptTrig,ptJet/ptTrig);
+   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"LeadingRatioPt"+lastname))->
+     Fill(ptTrig,ptLead/ptJet);
+//   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"Phi"+lastname))->
+//     Fill(ptTrig,phiJet);
+   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"DeltaPhi"+lastname))->
+     Fill(ptTrig,phiJet-phiTrig);
+   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"LeadingDeltaPhi"+lastname))->
+     Fill(ptTrig,phiJet-phiLead);
+   
+   //   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"Eta"+lastname))->
+   //     Fill(ptTrig,etaJet);
+   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"DeltaEta"+lastname))->
+     Fill(ptTrig,etaJet-etaTrig);
+   dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"LeadingDeltaEta"+lastname))->
+     Fill(ptTrig,etaJet-etaLead);
+  
+  //Construct fragmentation function
+  TRefArray * pl = new TRefArray;
+  if(type == "Jet") pl = particle->GetRefTracks();
+  else if(type == "Bkg") pl = particle->GetRefBackgroundTracks();
+
+  //Different pt cut for jet particles in different collisions systems
+  //Only needed when jet is recalculated from AODs
+  Float_t ptcut = fJetPtThreshold;
+  if(fPbPb && !fSeveralConeAndPtCuts && ptTrig > fPtTriggerSelectionCut)  ptcut = fJetPtThresPbPb ;
+  
+  TVector3 p3;
+  Int_t nTracksInCone = 0; 
+  for(Int_t ipr = 0;ipr < pl->GetEntriesFast() ; ipr ++ ){
+    AliAODTrack* track = dynamic_cast<AliAODTrack *>(pl->At(ipr)) ;
+    p3.SetXYZ(track->Px(),track->Py(),track->Pz());
+    
+    //Recheck if particle is in jet cone
+    if(fReMakeJet || fSeveralConeAndPtCuts)
+      if(!IsParticleInJetCone(p3.Eta(), p3.Phi(), leading.Eta(), leading.Phi()) ) continue ; 
+    
+    nTracksInCone++; 
+   
+    dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"FFz"+lastname))
+      ->Fill(ptTrig,p3.Pt()/ptTrig);
+    dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"FFxi"+lastname))
+      ->Fill(ptTrig,TMath::Log(ptTrig/p3.Pt()));
+    dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"FFpt"+lastname))
+      ->Fill(ptTrig,p3.Pt());
+    
+  }//track loop
+
+  if(nTracksInCone > 0) dynamic_cast<TH2F*>(GetOutputContainer()->FindObject(type+"NTracksInCone"+lastname))
+    ->Fill(ptTrig, nTracksInCone);
+  
+}
+
+//________________________________________________________________________
+TList *  AliAnaParticleJetLeadingConeCorrelation::GetCreateOutputObjects()
+{  
+  // Create histograms to be saved in output file and 
+  // store them in fOutCont
+  if(GetDebug()>1) printf("Init histograms \n");
+  
+  fOutCont = new TList() ; 
+  fOutCont->SetName("ParticleJetLeadingInConeCorrelationHistograms") ; 
+
+  fhChargedLeadingPt  = new TH2F("ChargedLeadingPt","p_{T leading charge} vs p_{T trigger}",120,0,120,120,0,120); 
+  fhChargedLeadingPt->SetYTitle("p_{T leading charge} /p_{T trigger}");
+  fhChargedLeadingPt->SetXTitle("p_{T trigger} (GeV/c)");
+  
+  fhChargedLeadingPhi  = new TH2F("ChargedLeadingPhi","#phi_{h^{#pm}}  vs p_{T trigger}", 120,0,120,120,0,TMath::TwoPi()); 
+  fhChargedLeadingPhi->SetYTitle("#phi_{h^{#pm}} (rad)");
+  fhChargedLeadingPhi->SetXTitle("p_{T trigger} (GeV/c)");
+  
+  fhChargedLeadingEta  = new TH2F("ChargedLeadingEta","#eta_{h^{#pm}}  vs p_{T trigger}",120,0,120,120,-1,1); 
+  fhChargedLeadingEta->SetYTitle("#eta_{h^{#pm}} ");
+  fhChargedLeadingEta->SetXTitle("p_{T trigger} (GeV/c)");
+  
+  fhChargedLeadingDeltaPt  = new TH2F("ChargedLeadingDeltaPt","#p_{T trigger} - #p_{T h^{#pm}} vs p_{T trigger}",120,0,120,120,0,120); 
+  fhChargedLeadingDeltaPt->SetYTitle("#Delta p_{T} (GeV/c)");
+  fhChargedLeadingDeltaPt->SetXTitle("p_{T trigger} (GeV/c)");
+
+  fhChargedLeadingDeltaPhi  = new TH2F("ChargedLeadingDeltaPhi","#phi_{trigger} - #phi_{h^{#pm}} vs p_{T trigger}",120,0,120,120,0,TMath::TwoPi()); 
+  fhChargedLeadingDeltaPhi->SetYTitle("#Delta #phi (rad)");
+  fhChargedLeadingDeltaPhi->SetXTitle("p_{T trigger} (GeV/c)");
+  
+  fhChargedLeadingDeltaEta  = new TH2F("ChargedLeadingDeltaEta","#eta_{trigger} - #eta_{h^{#pm}} vs p_{T trigger}",120,0,120,120,-2,2); 
+  fhChargedLeadingDeltaEta->SetYTitle("#Delta #eta");
+  fhChargedLeadingDeltaEta->SetXTitle("p_{T trigger} (GeV/c)");
+  
+  fhChargedLeadingRatioPt  = new TH2F("ChargedLeadingRatioPt","p_{T leading charge} /p_{T trigger} vs p_{T trigger}",120,0,120,120,0,2); 
+  fhChargedLeadingRatioPt->SetYTitle("p_{T lead charge} /p_{T trigger}");
+  fhChargedLeadingRatioPt->SetXTitle("p_{T trigger} (GeV/c)");
+
+  fOutCont->Add(fhChargedLeadingPt) ;
+  fOutCont->Add(fhChargedLeadingPhi) ;
+  fOutCont->Add(fhChargedLeadingEta) ;
+  fOutCont->Add(fhChargedLeadingDeltaPt) ; 
+  fOutCont->Add(fhChargedLeadingDeltaPhi) ; 
+  fOutCont->Add(fhChargedLeadingDeltaEta) ; 
+  fOutCont->Add(fhChargedLeadingRatioPt) ;
+
+  if(!fJetsOnlyInCTS){
+    
+    fhNeutralLeadingPt  = new TH2F("NeutralLeadingPt","p_{T leading #pi^{0}} vs p_{T trigger}",120,0,120,120,0,120); 
+    fhNeutralLeadingPt->SetYTitle("p_{T leading #pi^{0}} /p_{T trigger}");
+    fhNeutralLeadingPt->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhNeutralLeadingPhi  = new TH2F("NeutralLeadingPhi","#phi_{#pi^{0}}  vs p_{T trigger}", 120,0,120,120,0,TMath::TwoPi()); 
+    fhNeutralLeadingPhi->SetYTitle("#phi_{#pi^{0}} (rad)");
+    fhNeutralLeadingPhi->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhNeutralLeadingEta  = new TH2F("NeutralLeadingEta","#eta_{#pi^{0}}  vs p_{T trigger}",120,0,120,120,-1,1); 
+    fhNeutralLeadingEta->SetYTitle("#eta_{#pi^{0}} ");
+    fhNeutralLeadingEta->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhNeutralLeadingDeltaPt  = new TH2F("NeutralLeadingDeltaPt","#p_{T trigger} - #p_{T #pi^{0}} vs p_{T trigger}",120,0,120,120,0,120); 
+    fhNeutralLeadingDeltaPt->SetYTitle("#Delta p_{T} (GeV/c)");
+    fhNeutralLeadingDeltaPt->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fhNeutralLeadingDeltaPhi  = new TH2F("NeutralLeadingDeltaPhi","#phi_{trigger} - #phi_{#pi^{0}} vs p_{T trigger}",120,0,120,120,0,TMath::TwoPi()); 
+    fhNeutralLeadingDeltaPhi->SetYTitle("#Delta #phi (rad)");
+    fhNeutralLeadingDeltaPhi->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhNeutralLeadingDeltaEta  = new TH2F("NeutralLeadingDeltaEta","#eta_{trigger} - #eta_{#pi^{0}} vs p_{T trigger}",120,0,120,120,-2,2); 
+    fhNeutralLeadingDeltaEta->SetYTitle("#Delta #eta");
+    fhNeutralLeadingDeltaEta->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhNeutralLeadingRatioPt  = new TH2F("NeutralLeadingRatioPt","p_{T leading #pi^{0}} /p_{T trigger} vs p_{T trigger}",120,0,120,120,0,2); 
+    fhNeutralLeadingRatioPt->SetYTitle("p_{T lead #pi^{0}} /p_{T trigger}");
+    fhNeutralLeadingRatioPt->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fOutCont->Add(fhNeutralLeadingPt) ;
+    fOutCont->Add(fhNeutralLeadingPhi) ;
+    fOutCont->Add(fhNeutralLeadingEta) ;
+    fOutCont->Add(fhNeutralLeadingDeltaPt) ; 
+    fOutCont->Add(fhNeutralLeadingDeltaPhi) ; 
+    fOutCont->Add(fhNeutralLeadingDeltaEta) ; 
+    fOutCont->Add(fhNeutralLeadingRatioPt) ;
+    
+  }
+  
+  if(!fSeveralConeAndPtCuts){// not several cones
+  
+    //Jet Distributions
+    fhJetPt  = new TH2F("JetPt","p_{T  jet} vs p_{T trigger}",120,0,120,120,0,120); 
+    fhJetPt->SetYTitle("p_{T  jet}");
+    fhJetPt->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fhJetRatioPt  = new TH2F("JetRatioPt","p_{T  jet}/p_{T trigger} vs p_{T trigger}",120,0,120,120,0,2); 
+    fhJetRatioPt->SetYTitle("p_{T  jet}/p_{T trigger}");
+    fhJetRatioPt->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fhJetDeltaPhi  = new TH2F("JetDeltaPhi","#phi_{jet} - #phi_{trigger} vs p_{T trigger}",120,0,120,120,0,TMath::TwoPi()); 
+    fhJetDeltaPhi->SetYTitle("#Delta #phi (rad)");
+    fhJetDeltaPhi->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhJetDeltaEta  = new TH2F("JetDeltaEta","#eta_{jet} - #eta_{trigger} vs p_{T trigger}",120,0,120,120,-2,2); 
+    fhJetDeltaEta->SetYTitle("#Delta #eta");
+    fhJetDeltaEta->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhJetLeadingRatioPt  = new TH2F("JetLeadingRatioPt","p_{T  jet} vs p_{T trigger}",120,0,120,120,0,2); 
+    fhJetLeadingRatioPt->SetYTitle("p_{T  leading}/p_{T jet}");
+    fhJetLeadingRatioPt->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fhJetLeadingDeltaPhi  = new TH2F("JetLeadingDeltaPhi","#phi_{jet} - #phi_{leading} vs p_{T trigger}",120,0,120,120,0,TMath::TwoPi()); 
+    fhJetLeadingDeltaPhi->SetYTitle("#Delta #phi (rad)");
+    fhJetLeadingDeltaPhi->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhJetLeadingDeltaEta  = new TH2F("JetLeadingDeltaEta","#eta_{jet} - #eta_{leading} vs p_{T trigger}",120,0,120,120,-2,2); 
+    fhJetLeadingDeltaEta->SetYTitle("#Delta #eta");
+    fhJetLeadingDeltaEta->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fhJetFFz  = new TH2F("JetFFz","z = p_{T i charged}/p_{T trigger} vs p_{T trigger}", 120,0.,120.,200,0.,2); 
+    fhJetFFz->SetYTitle("z");
+    fhJetFFz->SetXTitle("p_{T trigger}");
+
+    fhJetFFxi  = new TH2F("JetFFxi","#xi = ln(p_{T trigger}/p_{T i charged}) vs p_{T trigger}", 120,0.,120.,100,0.,10.); 
+    fhJetFFxi->SetYTitle("#xi");
+    fhJetFFxi->SetXTitle("p_{T trigger}");
+
+    fhJetFFpt  = new TH2F("JetFFpt","#xi = p_{T i charged}) vs p_{T trigger}", 120,0.,120.,200,0.,50.); 
+    fhJetFFpt->SetYTitle("p_{T charged hadron}");
+    fhJetFFpt->SetXTitle("p_{T trigger}");
+
+    fhJetNTracksInCone  = new TH2F("JetNTracksInCone","N particles in cone vs p_{T trigger}",120,0,120,5000,0, 5000); 
+    fhJetNTracksInCone->SetYTitle("N tracks in jet cone");
+    fhJetNTracksInCone->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fOutCont->Add(fhJetPt) ; 
+    fOutCont->Add(fhJetRatioPt) ; 
+    fOutCont->Add(fhJetDeltaPhi) ;
+    fOutCont->Add(fhJetDeltaEta) ;
+    fOutCont->Add(fhJetLeadingRatioPt) ;
+    fOutCont->Add(fhJetLeadingDeltaPhi) ;
+    fOutCont->Add(fhJetLeadingDeltaEta) ;
+    fOutCont->Add(fhJetFFz) ;
+    fOutCont->Add(fhJetFFxi) ;
+    fOutCont->Add(fhJetFFpt) ;
+    fOutCont->Add(fhJetNTracksInCone) ;
+
+    //Bkg Distributions
+    fhBkgPt  = new TH2F("BkgPt","p_{T  bkg} vs p_{T trigger}",120,0,120,120,0,120); 
+    fhBkgPt->SetYTitle("p_{T  bkg}");
+    fhBkgPt->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fhBkgRatioPt  = new TH2F("BkgRatioPt","p_{T  bkg}/p_{T trigger} vs p_{T trigger}",120,0,120,120,0,2); 
+    fhBkgRatioPt->SetYTitle("p_{T  bkg}/p_{T trigger}");
+    fhBkgRatioPt->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fhBkgDeltaPhi  = new TH2F("BkgDeltaPhi","#phi_{bkg} - #phi_{trigger} vs p_{T trigger}",120,0,120,120,0,TMath::TwoPi()); 
+    fhBkgDeltaPhi->SetYTitle("#Delta #phi (rad)");
+    fhBkgDeltaPhi->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhBkgDeltaEta  = new TH2F("BkgDeltaEta","#eta_{bkg} - #eta_{trigger} vs p_{T trigger}",120,0,120,120,-2,2); 
+    fhBkgDeltaEta->SetYTitle("#Delta #eta");
+    fhBkgDeltaEta->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhBkgLeadingRatioPt  = new TH2F("BkgLeadingRatioPt","p_{T  bkg} vs p_{T trigger}",120,0,120,120,0,2); 
+    fhBkgLeadingRatioPt->SetYTitle("p_{T  leading}/p_{T bkg}");
+    fhBkgLeadingRatioPt->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fhBkgLeadingDeltaPhi  = new TH2F("BkgLeadingDeltaPhi","#phi_{bkg} - #phi_{leading} vs p_{T trigger}",120,0,120,120,0,TMath::TwoPi()); 
+    fhBkgLeadingDeltaPhi->SetYTitle("#Delta #phi (rad)");
+    fhBkgLeadingDeltaPhi->SetXTitle("p_{T trigger} (GeV/c)");
+    
+    fhBkgLeadingDeltaEta  = new TH2F("BkgLeadingDeltaEta","#eta_{bkg} - #eta_{leading} vs p_{T trigger}",120,0,120,120,-2,2); 
+    fhBkgLeadingDeltaEta->SetYTitle("#Delta #eta");
+    fhBkgLeadingDeltaEta->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fhBkgFFz  = new TH2F("BkgFFz","z = p_{T i charged}/p_{T trigger} vs p_{T trigger}", 120,0.,120.,200,0.,2); 
+    fhBkgFFz->SetYTitle("z");
+    fhBkgFFz->SetXTitle("p_{T trigger}");
+
+    fhBkgFFxi  = new TH2F("BkgFFxi","#xi = ln(p_{T trigger}/p_{T i charged}) vs p_{T trigger}", 120,0.,120.,100,0.,10.); 
+    fhBkgFFxi->SetYTitle("#xi");
+    fhBkgFFxi->SetXTitle("p_{T trigger}");
+
+    fhBkgFFpt  = new TH2F("BkgFFpt","p_{T charged hadron } vs p_{T trigger}", 120,0.,120.,200,0.,50.); 
+    fhBkgFFpt->SetYTitle("p_{T charged} hadron");
+    fhBkgFFpt->SetXTitle("p_{T trigger}");
+
+    fhBkgNTracksInCone  = new TH2F("BkgNTracksInCone","N particles in cone vs p_{T trigger}",120,0,120,5000,0, 5000); 
+    fhBkgNTracksInCone->SetYTitle("N tracks in bkg cone");
+    fhBkgNTracksInCone->SetXTitle("p_{T trigger} (GeV/c)");
+
+    fOutCont->Add(fhBkgPt) ; 
+    fOutCont->Add(fhBkgRatioPt) ; 
+    fOutCont->Add(fhBkgDeltaPhi) ;
+    fOutCont->Add(fhBkgDeltaEta) ;
+    fOutCont->Add(fhBkgLeadingRatioPt) ;
+    fOutCont->Add(fhBkgLeadingDeltaPhi) ;
+    fOutCont->Add(fhBkgLeadingDeltaEta) ;
+    fOutCont->Add(fhBkgFFz) ;
+    fOutCont->Add(fhBkgFFxi) ;
+    fOutCont->Add(fhBkgFFpt) ;
+    fOutCont->Add(fhBkgNTracksInCone) ;
+
+  }//not several cones
+  else{ //If we want to study the jet for different cones and pt
+    for(Int_t icone = 0; icone<fJetNCone; icone++){//icone
+      for(Int_t ipt = 0; ipt<fJetNPt;ipt++){ //ipt
+       
+       TString lastnamehist ="Cone"+ fJetNameCones[icone]+"Pt"+ fJetNamePtThres[ipt];
+       TString lastnametitle =", cone ="+fJetNameCones[icone]+", pt > " +fJetNamePtThres[ipt]+" GeV/c";
+       
+       //Jet Distributions
+       fhJetPts[icone][ipt] = new TH2F("JetPt"+lastnamehist,"p_{T  jet} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,120); 
+       fhJetPts[icone][ipt]->SetYTitle("p_{T  jet}");
+       fhJetPts[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhJetRatioPts[icone][ipt] = new TH2F("JetRatioPt"+lastnamehist,"p_{T  jet}/p_{T trigger} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,2); 
+       fhJetRatioPts[icone][ipt]->SetYTitle("p_{T  jet}/p_{T trigger}");
+       fhJetRatioPts[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhJetDeltaPhis[icone][ipt] = new TH2F("JetDeltaPhi"+lastnamehist,"#phi_{jet} - #phi_{trigger} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,TMath::TwoPi()); 
+       fhJetDeltaPhis[icone][ipt]->SetYTitle("#Delta #phi (rad)");
+       fhJetDeltaPhis[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhJetDeltaEtas[icone][ipt] = new TH2F("JetDeltaEta"+lastnamehist,"#eta_{jet} - #eta_{trigger} vs p_{T trigger}"+lastnametitle,120,0,120,120,-2,2); 
+       fhJetDeltaEtas[icone][ipt]->SetYTitle("#Delta #eta");
+       fhJetDeltaEtas[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhJetLeadingRatioPts[icone][ipt] = new TH2F("JetLeadingRatioPt"+lastnamehist,"p_{T  jet} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,2); 
+       fhJetLeadingRatioPts[icone][ipt]->SetYTitle("p_{T  leading}/p_{T jet}");
+       fhJetLeadingRatioPts[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhJetLeadingDeltaPhis[icone][ipt] = new TH2F("JetLeadingDeltaPhi"+lastnamehist,"#phi_{jet} - #phi_{leading} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,TMath::TwoPi()); 
+       fhJetLeadingDeltaPhis[icone][ipt]->SetYTitle("#Delta #phi (rad)");
+       fhJetLeadingDeltaPhis[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhJetLeadingDeltaEtas[icone][ipt] = new TH2F("JetLeadingDeltaEta"+lastnamehist,"#eta_{jet} - #eta_{leading} vs p_{T trigger}"+lastnametitle,120,0,120,120,-2,2); 
+       fhJetLeadingDeltaEtas[icone][ipt]->SetYTitle("#Delta #eta");
+       fhJetLeadingDeltaEtas[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhJetFFzs[icone][ipt] = new TH2F("JetFFz"+lastnamehist,"z = p_{T i charged}/p_{T trigger} vs p_{T trigger}", 120,0.,120.,200,0.,2); 
+       fhJetFFzs[icone][ipt]->SetYTitle("z");
+       fhJetFFzs[icone][ipt]->SetXTitle("p_{T trigger}");
+       
+       fhJetFFxis[icone][ipt] = new TH2F("JetFFxi"+lastnamehist,"#xi = ln(p_{T trigger}/p_{T i charged}) vs p_{T trigger}", 120,0.,120.,100,0.,10.); 
+       fhJetFFxis[icone][ipt]->SetYTitle("#xi");
+       fhJetFFxis[icone][ipt]->SetXTitle("p_{T trigger}");
+       
+       fhJetFFpts[icone][ipt] = new TH2F("JetFFpt"+lastnamehist,"p_{T charged hadron } in jet vs p_{T trigger}", 120,0.,120.,200,0.,50.); 
+       fhJetFFpts[icone][ipt]->SetYTitle("p_{T charged hadron}");
+       fhJetFFpts[icone][ipt]->SetXTitle("p_{T trigger}");
+       
+       fhJetNTracksInCones[icone][ipt] = new TH2F("JetNTracksInCone"+lastnamehist,"N particles in cone vs p_{T trigger}"+lastnametitle,120,0,120,5000,0, 5000); 
+       fhJetNTracksInCones[icone][ipt]->SetYTitle("N tracks in jet cone");
+       fhJetNTracksInCones[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fOutCont->Add(fhJetPts[icone][ipt]) ; 
+       fOutCont->Add(fhJetRatioPts[icone][ipt]) ; 
+       fOutCont->Add(fhJetDeltaPhis[icone][ipt]) ;
+       fOutCont->Add(fhJetDeltaEtas[icone][ipt]) ;
+       fOutCont->Add(fhJetLeadingRatioPts[icone][ipt]) ;
+       fOutCont->Add(fhJetLeadingDeltaPhis[icone][ipt]) ;
+       fOutCont->Add(fhJetLeadingDeltaEtas[icone][ipt]) ;
+       fOutCont->Add(fhJetFFzs[icone][ipt]) ;
+       fOutCont->Add(fhJetFFxis[icone][ipt]) ;
+       fOutCont->Add(fhJetFFpts[icone][ipt]) ;
+       fOutCont->Add(fhJetNTracksInCones[icone][ipt]) ;
+       
+       //Bkg Distributions
+       fhBkgPts[icone][ipt] = new TH2F("BkgPt"+lastnamehist,"p_{T  bkg} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,120); 
+       fhBkgPts[icone][ipt]->SetYTitle("p_{T  bkg}");
+       fhBkgPts[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhBkgRatioPts[icone][ipt] = new TH2F("BkgRatioPt"+lastnamehist,"p_{T  bkg}/p_{T trigger} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,2); 
+       fhBkgRatioPts[icone][ipt]->SetYTitle("p_{T  bkg}/p_{T trigger}");
+       fhBkgRatioPts[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhBkgDeltaPhis[icone][ipt] = new TH2F("BkgDeltaPhi"+lastnamehist,"#phi_{bkg} - #phi_{trigger} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,TMath::TwoPi()); 
+       fhBkgDeltaPhis[icone][ipt]->SetYTitle("#Delta #phi (rad)");
+       fhBkgDeltaPhis[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhBkgDeltaEtas[icone][ipt] = new TH2F("BkgDeltaEta"+lastnamehist,"#eta_{bkg} - #eta_{trigger} vs p_{T trigger}"+lastnametitle,120,0,120,120,-2,2); 
+       fhBkgDeltaEtas[icone][ipt]->SetYTitle("#Delta #eta");
+       fhBkgDeltaEtas[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhBkgLeadingRatioPts[icone][ipt] = new TH2F("BkgLeadingRatioPt"+lastnamehist,"p_{T  bkg} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,2); 
+       fhBkgLeadingRatioPts[icone][ipt]->SetYTitle("p_{T  leading}/p_{T bkg}");
+       fhBkgLeadingRatioPts[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhBkgLeadingDeltaPhis[icone][ipt] = new TH2F("BkgLeadingDeltaPhi"+lastnamehist,"#phi_{bkg} - #phi_{leading} vs p_{T trigger}"+lastnametitle,120,0,120,120,0,TMath::TwoPi()); 
+       fhBkgLeadingDeltaPhis[icone][ipt]->SetYTitle("#Delta #phi (rad)");
+       fhBkgLeadingDeltaPhis[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhBkgLeadingDeltaEtas[icone][ipt] = new TH2F("BkgLeadingDeltaEta"+lastnamehist,"#eta_{bkg} - #eta_{leading} vs p_{T trigger}"+lastnametitle,120,0,120,120,-2,2); 
+       fhBkgLeadingDeltaEtas[icone][ipt]->SetYTitle("#Delta #eta");
+       fhBkgLeadingDeltaEtas[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fhBkgFFzs[icone][ipt] = new TH2F("BkgFFz"+lastnamehist,"z = p_{T i charged}/p_{T trigger} vs p_{T trigger}", 120,0.,120.,200,0.,2); 
+       fhBkgFFzs[icone][ipt]->SetYTitle("z");
+       fhBkgFFzs[icone][ipt]->SetXTitle("p_{T trigger}");
+       
+       fhBkgFFxis[icone][ipt] = new TH2F("BkgFFxi"+lastnamehist,"#xi = ln(p_{T trigger}/p_{T i charged}) vs p_{T trigger}", 120,0.,120.,100,0.,10.); 
+       fhBkgFFxis[icone][ipt]->SetYTitle("#xi");
+       fhBkgFFxis[icone][ipt]->SetXTitle("p_{T trigger}");
+       
+       fhBkgFFpts[icone][ipt] = new TH2F("BkgFFpt"+lastnamehist,"p_{T charged hadron} in jet vs p_{T trigger}", 120,0.,120.,200,0.,50.); 
+       fhBkgFFpts[icone][ipt]->SetYTitle("p_{T charged hadron}");
+       fhBkgFFpts[icone][ipt]->SetXTitle("p_{T trigger}");
+       
+       fhBkgNTracksInCones[icone][ipt] = new TH2F("BkgNTracksInCone"+lastnamehist,"N particles in cone vs p_{T trigger}"+lastnametitle,120,0,120,5000,0, 5000); 
+       fhBkgNTracksInCones[icone][ipt]->SetYTitle("N tracks in bkg cone");
+       fhBkgNTracksInCones[icone][ipt]->SetXTitle("p_{T trigger} (GeV/c)");
+       
+       fOutCont->Add(fhBkgPts[icone][ipt]) ; 
+       fOutCont->Add(fhBkgRatioPts[icone][ipt]) ; 
+       fOutCont->Add(fhBkgDeltaPhis[icone][ipt]) ;
+       fOutCont->Add(fhBkgDeltaEtas[icone][ipt]) ;
+       fOutCont->Add(fhBkgLeadingRatioPts[icone][ipt]) ;
+       fOutCont->Add(fhBkgLeadingDeltaPhis[icone][ipt]) ;
+       fOutCont->Add(fhBkgLeadingDeltaEtas[icone][ipt]) ;
+       fOutCont->Add(fhBkgFFzs[icone][ipt]) ;
+       fOutCont->Add(fhBkgFFxis[icone][ipt]) ;
+       fOutCont->Add(fhBkgFFpts[icone][ipt]) ;
+       fOutCont->Add(fhBkgNTracksInCones[icone][ipt]) ;
+       
+      }//ipt
+    } //icone
+  }//If we want to study any cone or pt threshold
+  
+  if(GetDebug()>2){
+    printf("All histograms names \n");
+  
+    for(Int_t i  = 0 ;  i<  fOutCont->GetEntries(); i++)
+      printf("Histo i %d name %s",i,((fOutCont->At(i))->GetName()));
+      //cout<< (fOutCont->At(i))->GetName()<<endl;
+  }
+
+  return fOutCont;
+}
+
+//____________________________________________________________________________
+Bool_t  AliAnaParticleJetLeadingConeCorrelation::GetLeadingParticle(AliAODParticleCorrelation *particle, TLorentzVector & pLeading) 
+{
+  //Search Charged or Neutral leading particle, select the highest one and fill AOD
+  
+  TLorentzVector pLeadingCh(0,0,0,0) ;
+  TLorentzVector pLeadingPi0(0,0,0,0) ;
+  
+  GetLeadingCharge(particle, pLeadingCh) ;
+  if(!fJetsOnlyInCTS) GetLeadingPi0(particle, pLeadingPi0) ;
+  
+  Double_t ptch = pLeadingCh.Pt(); 
+  Double_t ptpi = pLeadingPi0.Pt(); 
+  
+  if (ptch > 0 || ptpi > 0){
+    if((ptch >= ptpi)){
+      if(GetDebug() > 1)printf("Leading found in CTS \n");
+      pLeading = pLeadingCh;
+      if(GetDebug() > 1) printf("Found Leading: pt %f, phi %f deg, eta %f\n", pLeading.Pt(),pLeading.Phi()*TMath::RadToDeg(),pLeading.Eta()) ;
+      //Put leading in AOD
+       particle->SetLeading(pLeadingCh);
+       particle->SetLeadingDetector("CTS");
+       return kTRUE;
+    }
+    else{
+      if(GetDebug() > 1)printf("Leading found in EMCAL \n");
+      pLeading = pLeadingPi0;
+      if(GetDebug() > 1) printf("Found Leading: pt %f, phi %f, eta %f\n", pLeading.Pt(),pLeading.Phi()*TMath::RadToDeg(),pLeading.Eta()) ;
+      //Put leading in AOD
+      particle->SetLeading(pLeadingPi0);
+      particle->SetLeadingDetector("EMCAL");
+      return kTRUE;   
+    }
+  }  
+  
+  if(GetDebug() > 1)printf ("NO LEADING PARTICLE FOUND \n");
+  
+  return kFALSE; 
+  
+}
+
+//____________________________________________________________________________
+void  AliAnaParticleJetLeadingConeCorrelation::GetLeadingCharge(AliAODParticleCorrelation * particle, TLorentzVector & pLeading) 
+{  
+  //Search for the charged particle with highest pt and with 
+  //Phi=Phi_trigger-Pi and pT=0.1E_gamma 
+  
+  if(GetAODCTS()){
+    Double_t ptTrig = particle->Pt();
+    Double_t phiTrig = particle->Phi();
+    Double_t rat  = -100 ;
+    Double_t ptl  = -100 ;
+    Double_t phil = -100 ;
+    Double_t pt  = -100.;
+    Double_t phi = -100.;
+    TVector3 p3;
+    
+    for(Int_t ipr = 0;ipr < GetAODCTS()->GetEntriesFast() ; ipr ++ ){
+      AliAODTrack* track = dynamic_cast<AliAODTrack *>(GetAODCTS()->At(ipr)) ;
+      p3.SetXYZ(track->Px(),track->Py(),track->Pz());
+      pt    = p3.Pt();
+      phi  = p3.Phi() ;
+      if(phi<0) phi+=TMath::TwoPi();
+      rat  = pt/ptTrig ;
+
+      //Selection within angular and energy limits
+      if(((phiTrig-phi) > fDeltaPhiMinCut) && ((phiTrig-phi)<fDeltaPhiMaxCut) &&
+        (rat > fLeadingRatioMinCut) && (rat < fLeadingRatioMaxCut)  && (pt  > ptl)) {
+       phil = phi ;
+       ptl  = pt ;
+       pLeading.SetVect(p3);
+      }
+    }// track loop
+    
+    if(GetDebug() > 1&& ptl>0 ) printf("Leading in CTS: pt %f eta %f phi %f pt/ptTrig %f \n", ptl, pLeading.Eta(), phil,ptl/ptTrig) ;
+    
+  }//CTS list exist
+}
+
+//____________________________________________________________________________
+void  AliAnaParticleJetLeadingConeCorrelation::GetLeadingPi0(AliAODParticleCorrelation * particle, TLorentzVector & pLeading) 
+{  
+  //Search for the neutral pion with highest pt and with 
+  //Phi=Phi_trigger-Pi and pT=0.1E_gamma
+  if(GetAODEMCAL()){
+    Double_t ptTrig = particle->Pt();
+    Double_t phiTrig = particle->Phi();
+    Double_t rat  = -100 ;
+    Double_t ptl  = -100 ;
+    Double_t phil = -100 ;
+    Double_t pt  = -100.;
+    Double_t phi = -100.;
+    
+    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 < GetAODEMCAL()->GetEntriesFast() ; iclus ++ ){
+      AliAODCaloCluster * calo = dynamic_cast< AliAODCaloCluster *>(GetAODEMCAL()->At(iclus)) ;
+      
+      //Cluster selection, not charged, with photon or pi0 id and in fidutial cut
+      Int_t pdgi=0;
+      if(!SelectCluster(calo,vertex, gammai, pdgi)) continue ;
+      
+      if(GetDebug() > 2) printf("neutral cluster: pt %f, phi %f \n", gammai.Pt(),gammai.Phi());
+      
+      //2 gamma overlapped, found with PID
+      if(pdgi == AliCaloPID::kPi0){ 
+       pt = gammai.Pt();
+       rat = pt/ptTrig;
+       phi = gammai.Phi();
+       if(phi<0) phi+=TMath::TwoPi();
+       
+       //Selection within angular and energy limits
+       if(ptl > pt  && rat > fLeadingRatioMinCut  && rat < fLeadingRatioMaxCut  && 
+          (phiTrig-phil) > fDeltaPhiMinCut && (phiTrig-phil) < fDeltaPhiMaxCut )
+         {
+           phi = phil ;
+           pt  = ptl ;
+           pLeading.SetPxPyPzE(gammai.Px(),gammai.Py(),gammai.Pz(),gammai.E());
+         }// cuts
+      }// pdg = AliCaloPID::kPi0
+         //Make invariant mass analysis
+      else if(pdgi == AliCaloPID::kPhoton){    
+       //Search the photon companion in case it comes from  a Pi0 decay
+       //Apply several cuts to select the good pair
+       for(Int_t jclus = iclus+1; jclus < GetAODEMCAL()->GetEntriesFast() ; jclus ++ ){
+         AliAODCaloCluster * calo2 = dynamic_cast< AliAODCaloCluster *>(GetAODEMCAL()->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 ){
+           
+           pt  = (gammai+gammaj).Pt();
+           phi = (gammai+gammaj).Phi();
+           rat = pt/ptTrig;
+           
+           //Selection within angular and energy limits
+           if(ptl > pt  && rat > fLeadingRatioMinCut  && rat < fLeadingRatioMaxCut  && 
+              (phiTrig-phil) > fDeltaPhiMinCut && (phiTrig-phil) < fDeltaPhiMaxCut ){
+             //Select good pair (aperture and invariant mass)
+             if(GetNeutralMesonSelection()->SelectPair(gammai, gammaj)){
+               phi = phil ;
+               pt  = ptl ;
+               pLeading=(gammai+gammaj);
+             }//pi0 selection
+             
+             if(GetDebug() > 3 ) printf("Neutral Hadron Correlation: Selected gamma pair: pt %2.2f, phi %2.2f, eta %2.2f, M %2.3f\n",
+                                        (gammai+gammaj).Pt(),(gammai+gammaj).Phi(),(gammai+gammaj).Eta(), (gammai+gammaj).M());
+           }//Pair selected as leading
+         }//if pair of gammas
+       }//2nd loop
+      }// if pdg = 22
+    }// 1st Loop
+    
+    if(GetDebug()>2 && pLeading.Pt() >0 ) printf("Leading EMCAL: pt %f eta %f phi %f pt/Eg %f \n",  pLeading.Pt(), pLeading.Eta(),  pLeading.Phi(),  pLeading.Pt()/ptTrig) ;
+    
+  }//EMCAL list exists
+  
+}
+
+//____________________________________________________________________________
+void AliAnaParticleJetLeadingConeCorrelation::InitParameters()
+{
+  
+  //Initialize the parameters of the analysis.
+  fJetsOnlyInCTS      = kFALSE ;
+  fPbPb               = kFALSE ;
+  fReMakeJet          = kFALSE ;
+
+  //Leading selection parameters
+  fDeltaPhiMinCut     = 2.9 ;
+  fDeltaPhiMaxCut     = 3.4 ; 
+  fLeadingRatioMinCut = 0.1;
+  fLeadingRatioMaxCut = 1.5; 
+
+  //Jet selection parameters
+  //Fixed cut   
+  fJetRatioMaxCut     = 1.2 ; 
+  fJetRatioMinCut     = 0.3 ; 
+  fJetCTSRatioMaxCut  = 1.2 ;
+  fJetCTSRatioMinCut  = 0.3 ;
+  fSelect               = 0  ; //0, Accept all jets, 1, selection depends on energy, 2 fixed selection
+
+  //Cut depending on gamma energy
+  fPtTriggerSelectionCut = 10.; //For Low pt jets+BKG, another limits applied
+  //Reconstructed jet energy dependence parameters 
+  //e_jet = a1+e_gamma b2. 
+  //Index 0-> Pt>2 GeV r = 0.3; Index 1-> Pt>0.5 GeV r = 0.3
+  fJetE1[0] = -5.75; fJetE1[1] = -4.1;
+  fJetE2[0] = 1.005; fJetE2[1] = 1.05;
+  
+  //Reconstructed sigma of jet energy dependence parameters 
+  //s_jet = a1+e_gamma b2. 
+  //Index 0-> Pt>2 GeV r = 0.3; Index 1-> Pt>0.5 GeV r = 0.3
+  fJetSigma1[0] = 2.65;   fJetSigma1[1] = 2.75;
+  fJetSigma2[0] = 0.0018; fJetSigma2[1] = 0.033;
+  
+  //Background mean energy and RMS
+  //Index 0-> No BKG; Index 1-> BKG > 2 GeV; 
+  //Index 2-> (low pt jets)BKG > 0.5 GeV;
+  //Index > 2, same for CTS conf
+  fBkgMean[0] = 0.; fBkgMean[1] = 8.8 ; fBkgMean[2] = 69.5;
+  fBkgMean[3] = 0.; fBkgMean[4] = 6.4;  fBkgMean[5] = 48.6;
+  fBkgRMS[0]  = 0.; fBkgRMS[1]  = 7.5;  fBkgRMS[2]  = 22.0; 
+  fBkgRMS[3]  = 0.; fBkgRMS[4]  = 5.4;  fBkgRMS[5]  = 13.2; 
+
+  //Factor x of min/max = E -+ x * sigma. Obtained after selecting the
+  //limits for monoenergetic jets.
+  //Index 0-> No BKG; Index 1-> BKG > 2 GeV; 
+  //Index 2-> (low pt jets) BKG > 0.5 GeV;
+  //Index > 2, same for CTS conf
+
+  fJetXMin1[0] =-0.69 ; fJetXMin1[1] = 0.39 ; fJetXMin1[2] =-0.88 ; 
+  fJetXMin1[3] =-2.0  ; fJetXMin1[4] =-0.442 ; fJetXMin1[5] =-1.1  ;
+  fJetXMin2[0] = 0.066; fJetXMin2[1] = 0.038; fJetXMin2[2] = 0.034; 
+  fJetXMin2[3] = 0.25 ; fJetXMin2[4] = 0.113; fJetXMin2[5] = 0.077 ;
+  fJetXMax1[0] =-3.8  ; fJetXMax1[1] =-0.76 ; fJetXMax1[2] =-3.6  ; 
+  fJetXMax1[3] =-2.7  ; fJetXMax1[4] =-1.21 ; fJetXMax1[5] =-3.7  ;
+  fJetXMax2[0] =-0.012; fJetXMax2[1] =-0.022; fJetXMax2[2] = 0.016; 
+  fJetXMax2[3] =-0.024; fJetXMax2[4] =-0.008; fJetXMax2[5] = 0.027;
+
+
+  //Different cones and pt thresholds to construct the jet
+
+  fJetCone        = 0.3  ;
+  fJetPtThreshold = 0.5   ;
+  fJetPtThresPbPb = 2.   ;
+  fJetNCone       = 4    ;
+  fJetNPt         = 4    ;
+  fJetCones[0]    = 0.2  ; fJetNameCones[0]   = "02" ;
+  fJetCones[1]    = 0.3  ; fJetNameCones[1]   = "03" ;
+  fJetCones[2]    = 0.4  ; fJetNameCones[2]   = "04" ;
+  fJetCones[2]    = 0.5  ; fJetNameCones[2]   = "05" ;
+
+  fJetPtThres[0]  = 0.0  ; fJetNamePtThres[0] = "00" ;
+  fJetPtThres[1]  = 0.5  ; fJetNamePtThres[1] = "05" ;
+  fJetPtThres[2]  = 1.0  ; fJetNamePtThres[2] = "10" ;
+  fJetPtThres[3]  = 2.0  ; fJetNamePtThres[3] = "20" ;
+}
+
+//__________________________________________________________________________-
+Bool_t AliAnaParticleJetLeadingConeCorrelation::IsJetSelected(const Double_t ptTrig, const Double_t ptjet){
+  //Given the pt of the jet and the trigger particle, select the jet or not
+  //3 options, fSelect=0 accepts all, fSelect=1 selects jets depending on a 
+  //function energy dependent and fSelect=2 selects on simple fixed cuts
+
+  if(ptjet == 0) return kFALSE;
+
+  Double_t rat = ptTrig / ptjet ;
+  
+  //###############################################################
+  if(fSelect == 0)
+    return kTRUE; //Accept all jets, no restriction
+  //###############################################################
+  else if(fSelect == 1){
+    //Check if the energy of the reconstructed jet is within an energy window
+    //WARNING: to be rechecked, don't remember what all the steps mean
+    Double_t par[6];
+    Double_t xmax[2];
+    Double_t xmin[2];
+    
+    Int_t iCTS = 0;
+    if(fJetsOnlyInCTS)
+      iCTS = 3 ;
+    
+    if(!fPbPb){
+      //Phythia alone, jets with pt_th > 0.2, r = 0.3 
+      par[0] = fJetE1[0]; par[1] = fJetE2[0]; 
+      //Energy of the jet peak
+      //e_jet = fJetE1[0]+fJetE2[0]*e_gamma, simulation fit
+      par[2] = fJetSigma1[0]; par[3] = fJetSigma2[0];
+      //Sigma  of the jet peak
+      //sigma_jet = fJetSigma1[0]+fJetSigma2[0]*e_gamma, simulation fit
+      par[4] = fBkgMean[0 + iCTS]; par[5] = fBkgRMS[0 + iCTS];
+      //Parameters reserved for PbPb bkg.
+      xmax[0] = fJetXMax1[0 + iCTS]; xmax[1] = fJetXMax2[0 + iCTS];
+      xmin[0] = fJetXMin1[0 + iCTS]; xmin[1] = fJetXMin2[0 + iCTS];
+      //Factor that multiplies sigma to obtain the best limits, 
+      //by observation, of mono jet ratios (ptjet/ptTrig)
+      //X_jet = fJetX1[0]+fJetX2[0]*e_gamma
+      
+    }
+    else{
+      if(ptTrig > fPtTriggerSelectionCut){
+       //Phythia +PbPb with  pt_th > 2 GeV/c, r = 0.3 
+       par[0] = fJetE1[0]; par[1] = fJetE2[0]; 
+       //Energy of the jet peak, same as in pp
+       //e_jet = fJetE1[0]+fJetE2[0]*e_gamma, simulation fit
+       par[2] = fJetSigma1[0]; par[3] = fJetSigma2[0];
+       //Sigma  of the jet peak, same as in pp
+       //sigma_jet = fJetSigma1[0]+fJetSigma2[0]*e_gamma, simulation fit
+       par[4] = fBkgMean[1 + iCTS]; par[5] = fBkgRMS[1 + iCTS];
+       //Mean value and RMS of PbPb Bkg 
+       xmax[0] = fJetXMax1[1 + iCTS]; xmax[1] = fJetXMax2[1 + iCTS];
+       xmin[0] = fJetXMin1[1 + iCTS]; xmin[1] = fJetXMin2[1 + iCTS];
+       //Factor that multiplies sigma to obtain the best limits, 
+       //by observation, of mono jet ratios (ptjet/ptTrig) mixed with PbPb Bkg, 
+       //pt_th > 2 GeV, r = 0.3
+       //X_jet = fJetX1[0]+fJetX2[0]*e_gamma
+       
+      }
+      else{
+       //Phythia + PbPb with  pt_th > 0.5 GeV/c, r = 0.3
+       par[0] = fJetE1[1]; par[1] = fJetE2[1]; 
+       //Energy of the jet peak, pt_th > 2 GeV/c, r = 0.3 
+       //e_jet = fJetE1[0]+fJetE2[0]*e_gamma, simulation fit
+       par[2] = fJetSigma1[1]; par[3] = fJetSigma2[1];
+       //Sigma  of the jet peak, pt_th > 2 GeV/c, r = 0.3
+       //sigma_jet = fJetSigma1[0]+fJetSigma2[0]*e_gamma, simulation fit
+       par[4] = fBkgMean[2 + iCTS]; par[5] = fBkgRMS[2 + iCTS];
+       //Mean value and RMS of PbPb Bkg in a 0.3 cone, pt > 2 GeV.
+       xmax[0] = fJetXMax1[2 + iCTS]; xmax[1] = fJetXMax2[2 + iCTS];
+       xmin[0] = fJetXMin1[2 + iCTS]; xmin[1] = fJetXMin2[2 + iCTS];
+       //Factor that multiplies sigma to obtain the best limits, 
+       //by observation, of mono jet ratios (ptjet/ptTrig) mixed with PbPb Bkg, 
+       //pt_th > 2 GeV, r = 0.3
+       //X_jet = fJetX1[0]+fJetX2[0]*e_gamma
+       
+      }//If low pt jet in bkg
+    }//if Bkg
+    
+    //Calculate minimum and maximum limits of the jet ratio.
+    Double_t min = CalculateJetRatioLimit(ptTrig, par, xmin);
+    Double_t max = CalculateJetRatioLimit(ptTrig, par, xmax);
+    
+    AliDebug(3,Form("Jet selection?  : Limits min %f, max %f,  pt_jet %f,  pt_gamma %f, pt_jet / pt_gamma %f",min,max,ptjet,ptTrig,rat));
+    
+    if(( min < rat ) && ( max > ptjet/rat))
+      return kTRUE;
+    else
+      return kFALSE;
+  }//fSelect = 1
+  //###############################################################
+  else if(fSelect == 2){
+    //Simple selection
+    if(!fJetsOnlyInCTS){
+      if((rat <  fJetRatioMaxCut) && (rat > fJetRatioMinCut )) return kTRUE;
+    }
+    else{
+      if((rat <  fJetCTSRatioMaxCut) && (rat > fJetCTSRatioMinCut )) return kTRUE;
+    }
+  }// fSelect = 2
+  //###############################################################
+  else{
+    AliError("Jet selection option larger than 2, DON'T SELECT JETS");
+    return kFALSE ;
+  }
+  
+  return kFALSE;
+  
+}
+
+//___________________________________________________________________
+Bool_t AliAnaParticleJetLeadingConeCorrelation::IsParticleInJetCone(const Double_t eta, Double_t phi, const Double_t etal,  Double_t phil)
+{
+  //Check if the particle is inside the cone defined by the leading particle
+  //WARNING: To be rechecked
+
+  if(phi < 0) phi+=TMath::TwoPi();
+  if(phil < 0) phil+=TMath::TwoPi();  
+  Double_t  rad = 10000 + fJetCone;
+  
+  if(TMath::Abs(phi-phil) <= (TMath::TwoPi() - fJetCone))
+    rad = TMath::Sqrt(TMath::Power(eta-etal,2)+TMath::Power(phi-phil,2));
+  else{
+    if(phi-phil > TMath::TwoPi() - fJetCone)
+      rad = TMath::Sqrt(TMath::Power(eta-etal,2)+TMath::Power((phi-TMath::TwoPi())-phil,2));
+    if(phi-phil < -(TMath::TwoPi() - fJetCone))
+      rad = TMath::Sqrt(TMath::Power(eta-etal,2)+TMath::Power((phi+TMath::TwoPi())-phil,2));
+  }
+  
+  if(rad < fJetCone) return kTRUE ;
+  else return kFALSE ;
+  
+}
+
+//__________________________________________________________________
+void  AliAnaParticleJetLeadingConeCorrelation::MakeAnalysisFillAOD() 
+{  
+  //Particle-Hadron Correlation Analysis, fill AODs
+  if(GetDebug() > 1){
+    printf("Begin jet leading cone  correlation analysis, fill AODs \n");
+    printf("In particle branch aod entries %d\n", GetAODBranch()->GetEntriesFast());
+    printf("In CTS aod entries %d\n", GetAODCTS()->GetEntriesFast());
+    printf("In EMCAL aod entries %d\n", GetAODEMCAL()->GetEntriesFast());
+  }
+  
+  TLorentzVector pLeading(0,0,0,0); //It will contain the kinematics of the found leading particle
+  
+  //Loop on stored AOD particles, trigger
+  Int_t naod = GetAODBranch()->GetEntriesFast();
+  for(Int_t iaod = 0; iaod < naod ; iaod++){
+    AliAODParticleCorrelation* particle =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->At(iaod));
+    
+    //Search leading particles in CTS and EMCAL 
+    if(GetLeadingParticle(particle, pLeading)){
+      
+      //Construct the jet around the leading, Fill AOD jet particle list, select jet 
+      //and fill AOD with jet and background     
+      MakeAODJet(particle, pLeading);
+      
+    }//Leading found
+  }//AOD trigger particle loop
+  
+  if(GetDebug() >1)printf("End of jet leading cone analysis, fill AODs \n");
+  
+} 
+
+//__________________________________________________________________
+void  AliAnaParticleJetLeadingConeCorrelation::MakeAnalysisFillHistograms() 
+{
+  
+  //Particle-Hadron Correlation Analysis, fill AODs
+  if(GetDebug() > 1){
+    printf("Begin jet leading cone  correlation analysis, fill histograms \n");
+    printf("In particle branch aod entries %d\n", GetAODBranch()->GetEntriesFast());
+    printf("In CTS aod entries %d\n", GetAODCTS()->GetEntriesFast());
+    printf("In EMCAL aod entries %d\n", GetAODEMCAL()->GetEntriesFast());
+  }
+  TLorentzVector pLeading(0,0,0,0) ;
+  
+  //Loop on stored AOD particles, trigger
+  Int_t naod = GetAODBranch()->GetEntriesFast();
+  for(Int_t iaod = 0; iaod < naod ; iaod++){
+    AliAODParticleCorrelation* particle =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->At(iaod));
+    
+    Double_t pt = particle->Pt();
+    Double_t phi = particle->Phi();
+    Double_t eta = particle->Eta();
+    
+    //Get leading particle, fill histograms
+    pLeading = particle->GetLeading();
+    TString det = particle->GetLeadingDetector();      
+
+    if(det!="" && pLeading.Pt() > 0){
+      Double_t ptL = pLeading.Pt(); 
+      Double_t phiL = pLeading.Phi(); 
+      if(phiL < 0 ) phiL+=TMath::TwoPi();
+      Double_t etaL = pLeading.Eta(); 
+      
+      if(GetDebug() > 1) printf("Leading found in %s, with pt %3.2f, phi %2.2f, eta %2.2f\n",det.Data(), ptL, phiL, etaL);
+      if(det == "CTS"){
+       fhChargedLeadingPt->Fill(pt,ptL);
+       fhChargedLeadingPhi->Fill(pt,phiL);
+       fhChargedLeadingEta->Fill(pt,etaL);
+       fhChargedLeadingDeltaPt->Fill(pt,pt-ptL);
+       fhChargedLeadingDeltaPhi->Fill(pt,phi-phiL);
+       fhChargedLeadingDeltaEta->Fill(pt,eta-etaL);
+       fhChargedLeadingRatioPt->Fill(pt,ptL/pt);
+      }
+      else if(det== "EMCAL"){
+       fhNeutralLeadingPt->Fill(pt,ptL);
+       fhNeutralLeadingPhi->Fill(pt,phiL);
+       fhNeutralLeadingEta->Fill(pt,etaL);
+       fhNeutralLeadingDeltaPt->Fill(pt,pt-ptL);
+       fhNeutralLeadingDeltaPhi->Fill(pt,phi-phiL);
+       fhNeutralLeadingDeltaEta->Fill(pt,eta-etaL);
+       fhNeutralLeadingRatioPt->Fill(pt,ptL/pt);
+      }
+      
+      //Fill Jet histograms
+      TLorentzVector bkg(0,0,0,0);
+      TLorentzVector jet(0,0,0,0);
+      if(!fSeveralConeAndPtCuts){//just fill histograms      
+       if(!fReMakeJet){
+         jet=particle->GetCorrelatedJet();
+         bkg=particle->GetCorrelatedBackground();
+       }
+       else  MakeJetFromAOD(particle, pLeading, jet,bkg);
+       
+       if(jet.Pt() > 0){//Jet was found
+         FillJetHistos(particle, pLeading, jet,"Jet","");
+         FillJetHistos(particle, pLeading, bkg,"Bkg","");
+       }
+      }
+      else if(fSeveralConeAndPtCuts){
+       for(Int_t icone = 0; icone<fJetNCone; icone++) {
+         fJetCone=fJetCones[icone];      
+         for(Int_t ipt = 0; ipt<fJetNPt;ipt++) {  
+           TString lastname ="Cone"+ fJetNameCones[icone]+"Pt"+ fJetNamePtThres[ipt];
+           fJetPtThreshold=fJetPtThres[ipt];
+           MakeJetFromAOD(particle, pLeading, jet,bkg);
+           if(jet.Pt() > 0) {//Jet was found
+             FillJetHistos(particle, pLeading, jet,"Jet",lastname);
+             FillJetHistos(particle, pLeading, bkg,"Bkg",lastname);
+           }
+         }//icone
+       }//ipt
+      }//fSeveralConeAndPtCuts
+    }//Leading
+  }//AOD trigger particle loop
+  
+  if(GetDebug() >1)printf("End of jet leading cone analysis, fill histograms \n");
+  
+} 
+
+//____________________________________________________________________________
+void AliAnaParticleJetLeadingConeCorrelation::MakeAODJet(AliAODParticleCorrelation *particle, const TLorentzVector  pLeading)
+{
+  //Fill the jet with the particles around the leading particle with 
+  //R=fJetCone and pt_th = fJetPtThres. Calculate the energy of the jet and 
+  //fill aod with found information 
+  
+  TLorentzVector bkg(0,0,0,0);
+  TLorentzVector jet(0,0,0,0);
+  TLorentzVector lv (0,0,0,0); //Temporal container for jet particles kinematics 
+  
+  Double_t ptTrig  = particle->Pt();
+  Double_t phiTrig = particle->Phi();
+  Double_t phil = pLeading.Phi();
+  if(phil<0) phil+=TMath::TwoPi();
+  Double_t etal = pLeading.Eta();
+  
+  //Different pt cut for jet particles in different collisions systems
+  Float_t ptcut = fJetPtThreshold;
+  if(fPbPb && !fSeveralConeAndPtCuts && ptTrig > fPtTriggerSelectionCut)  ptcut = fJetPtThresPbPb ;
+  
+  //Add charged particles to jet if they are in cone around the leading particle
+  if(!GetAODCTS()) {
+    AliFatal("Cannot construct jets without tracks, STOP analysis");
+    return;
+  }
+  
+  //Fill jet with tracks
+  TVector3 p3;
+  for(Int_t ipr = 0;ipr < (GetAODCTS())->GetEntriesFast() ; ipr ++ ){
+    AliAODTrack* track = dynamic_cast<AliAODTrack *>((GetAODCTS())->At(ipr)) ;
+    p3.SetXYZ(track->Px(),track->Py(),track->Pz());
+    
+    //Particles in jet 
+    if(IsParticleInJetCone(p3.Eta(), p3.Phi(), etal, phil)){
+      particle->AddTrack(track); 
+      if(p3.Pt() > ptcut ){
+       lv.SetVect(p3);
+       jet+=lv;
+      }
+    } 
+    //Background around (phi_gamma-pi, eta_leading)
+    else if(IsParticleInJetCone(p3.Eta(),p3.Phi(),etal, phiTrig)) { 
+      particle->AddBackgroundTrack(track); 
+      if(p3.Pt() > ptcut ){
+       lv.SetVect(p3);
+       bkg+=lv;
+      }
+    }
+  }//Track loop
+  
+  //Add neutral particles to jet
+  if(!fJetsOnlyInCTS && GetAODEMCAL()){
+    
+    Double_t vertex[] = {0,0,0};
+    if(!GetReader()->GetDataType()== AliCaloTrackReader::kMC) GetReader()->GetVertex(vertex);
+    
+    for(Int_t iclus = 0;iclus < (GetAODEMCAL())->GetEntriesFast() ; iclus ++ ){
+      AliAODCaloCluster * calo = dynamic_cast< AliAODCaloCluster *>(GetAODEMCAL()->At(iclus)) ;
+      
+      //Cluster selection, not charged
+      if(calo->GetNTracksMatched() > 0) continue ;
+      
+      calo->GetMomentum(lv,vertex);
+      //Particles in jet 
+      if(IsParticleInJetCone(lv.Eta(),lv.Phi(), etal, phil)){
+       particle->AddCluster(calo); 
+       if(lv.Pt() > ptcut )  jet+=lv;
+      }
+      //Background around (phi_gamma-pi, eta_leading)
+      else if(IsParticleInJetCone(lv.Eta(),lv.Phi(),etal, phiTrig)){
+       particle->AddBackgroundCluster(calo); 
+       if(lv.Pt() > ptcut )  bkg+=lv;
+      }
+    }//cluster loop
+  }//jets with neutral particles
+  
+  //If there is any jet found, select after some criteria and 
+  //and fill AOD with corresponding TLorentzVector kinematics
+  if(IsJetSelected(particle->Pt(), jet.Pt())) {
+    particle->SetCorrelatedJet(jet);
+    particle->SetCorrelatedBackground(bkg);
+    if(GetDebug()>1) printf("Found jet: Trigger  pt %f, Jet pt %f, Bkg pt %f\n",ptTrig,jet.Pt(),bkg.Pt());
+  }  
+  
+}
+
+//____________________________________________________________________________
+void AliAnaParticleJetLeadingConeCorrelation::MakeJetFromAOD(AliAODParticleCorrelation *particle, const TLorentzVector  pLeading, TLorentzVector & jet, TLorentzVector & bkg)
+{
+  //Fill the jet with the particles around the leading particle with 
+  //R=fJetCone and pt_th = fJetPtThres. Calculate the energy of the jet and 
+  //fill aod tlorentzvectors with jet and bakcground found
+
+  TLorentzVector lv (0,0,0,0); //Temporal container for jet particles kinematics 
+  
+  Double_t ptTrig  = particle->Pt();
+  Double_t phiTrig = particle->Phi();
+  Double_t phil = pLeading.Phi();
+  Double_t etal = pLeading.Eta();
+  
+  //Different pt cut for jet particles in different collisions systems
+  Float_t ptcut = fJetPtThreshold;
+  if(fPbPb && !fSeveralConeAndPtCuts && ptTrig > fPtTriggerSelectionCut)  ptcut = fJetPtThresPbPb ;
+
+  //Fill jet with tracks
+  //Particles in jet   
+  TVector3 p3;
+  for(Int_t ipr = 0;ipr < (particle->GetRefTracks())->GetEntriesFast() ; ipr ++ ){
+    AliAODTrack* track = dynamic_cast<AliAODTrack *>((particle-> GetRefTracks())->At(ipr)) ;
+    p3.SetXYZ(track->Px(),track->Py(),track->Pz());
+    if(p3.Pt() > ptcut && IsParticleInJetCone(p3.Eta(), p3.Phi(), etal, phil) ){
+      lv.SetVect(p3);
+      jet+=lv;
+    }
+  }//jet Track loop
+  
+  //Particles in background   
+  for(Int_t ipr = 0;ipr < (particle-> GetRefBackgroundTracks())->GetEntriesFast() ; ipr ++ ){
+    AliAODTrack* track = dynamic_cast<AliAODTrack *>((particle->GetRefBackgroundTracks())->At(ipr)) ;
+    p3.SetXYZ(track->Px(),track->Py(),track->Pz());
+    if(p3.Pt() > ptcut && IsParticleInJetCone(p3.Eta(),p3.Phi(),etal, phiTrig) ) {  
+      lv.SetVect(p3);
+      bkg+=lv;   
+    }
+  }//background Track loop
+  
+  //Add neutral particles to jet
+  if(!fJetsOnlyInCTS && (particle->GetRefClusters())){
+    
+    Double_t vertex[] = {0,0,0};
+    if(!GetReader()->GetDataType()== AliCaloTrackReader::kMC) GetReader()->GetVertex(vertex);
+    
+    //Loop on jet particles
+    for(Int_t iclus = 0;iclus < (particle->GetRefClusters())->GetEntriesFast() ; iclus ++ ){
+      AliAODCaloCluster * calo = dynamic_cast< AliAODCaloCluster *>((particle->GetRefClusters())->At(iclus)) ;
+      calo->GetMomentum(lv,vertex); 
+      if(lv.Pt() > ptcut && IsParticleInJetCone(lv.Eta(),lv.Phi(), etal, phil)) jet+=lv;   
+    }//jet cluster loop
+    
+     //Loop on background particles
+    for(Int_t iclus = 0;iclus < (particle->GetRefClusters())->GetEntriesFast() ; iclus ++ ){
+      AliAODCaloCluster * calo = dynamic_cast< AliAODCaloCluster *>((particle->GetRefClusters())->At(iclus)) ;
+      calo->GetMomentum(lv,vertex);
+      if( lv.Pt() > ptcut &&IsParticleInJetCone(lv.Eta(),lv.Phi(),etal, phiTrig)) bkg+=lv;
+    }//background cluster loop 
+  }//clusters in jet
+  
+  //If there is any jet found, leave jet and bkg as they are, 
+  //if not set them to 0.
+  if(!IsJetSelected(particle->Pt(), jet.Pt())) {
+    jet.SetPxPyPzE(0.,0.,0.,0.);
+    bkg.SetPxPyPzE(0.,0.,0.,0.);
+  }
+  else
+    if(GetDebug()>1) printf("Found jet: Trigger  pt %f, Jet pt %f, Bkg pt %f\n",ptTrig,jet.Pt(),bkg.Pt());
+  
+}
+
+//____________________________________________________________________________
+Bool_t  AliAnaParticleJetLeadingConeCorrelation::SelectCluster(AliAODCaloCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg){
+  //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.
+     if(!IsCaloPIDRecalculationOn() || GetReader()->GetDataType() == AliCaloTrackReader::kMC )
+       pdg = GetCaloPID()->GetPdg("EMCAL",calo->PID(),mom.E());//PID with weights
+     else
+       pdg = GetCaloPID()->GetPdg("EMCAL",mom,calo->GetM02(),0,0,0,0);//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 ;
+   }//CaloPID
+   
+   //Check acceptance selection
+   if(IsFidutialCutOn()){
+     Bool_t in = GetFidutialCut()->IsInFidutialCut(mom,"EMCAL") ;
+     if(! in ) return kFALSE ;
+   }
+   
+   if(GetDebug() > 1) printf("cluster selection cuts passed: pT %3.2f, pdg %d\n",mom.Pt(), pdg);
+   
+   return kTRUE; 
+   
+}
+
+//__________________________________________________________________
+void AliAnaParticleJetLeadingConeCorrelation::Print(const Option_t * opt) const
+{
+
+  //Print some relevant parameters set for the analysis
+  if(! opt)
+    return;
+  
+  Info("Print", "%s %s", GetName(), GetTitle() ) ;
+  
+  if(fJetsOnlyInCTS)printf("Jets reconstructed in CTS \n");
+  else printf("Jets reconstructed in CTS+EMCAL \n");
+
+  if(fPbPb) printf("PbPb events, pT cut in jet cone energy reconstruction %2.1f \n", fJetPtThreshold);
+  else printf("pp events, pT cut in jet cone energy reconstruction %2.1f \n", fJetPtThresPbPb);
+
+  printf("If pT of trigger < %f, select jets as in pp? \n", fPtTriggerSelectionCut);
+
+  printf("Phi gamma-Leading        <     %3.2f\n", fDeltaPhiMaxCut) ; 
+  printf("Phi gamma-Leading        >     %3.2f\n", fDeltaPhiMinCut) ;
+  printf("pT Leading / pT Trigger  <     %3.2f\n", fLeadingRatioMaxCut) ; 
+  printf("pT Leading / pT Trigger  >     %3.2f\n", fLeadingRatioMinCut) ;
+  
+  if(fSelect == 2){
+    printf("pT Jet / pT Gamma                     <    %3.2f\n", fJetRatioMaxCut) ; 
+    printf("pT Jet / pT Gamma                     >    %3.2f\n", fJetRatioMinCut) ;
+    printf("pT Jet (Only CTS)/ pT Trigger   <    %3.2f\n", fJetCTSRatioMaxCut) ; 
+    printf("pT Jet (Only CTS)/ pT Trigger   >    %3.2f\n", fJetCTSRatioMinCut) ;
+  }
+  else if(fSelect == 0)
+    printf("Accept all reconstructed jets \n") ;
+  else   if(fSelect == 1)
+    printf("Accept jets depending on trigger energy \n") ;
+  else 
+    printf("Wrong jet selection option:   %d \n", fSelect) ;
+
+} 
diff --git a/PWG4/PartCorr/AliAnaParticleJetLeadingConeCorrelation.h b/PWG4/PartCorr/AliAnaParticleJetLeadingConeCorrelation.h
new file mode 100644 (file)
index 0000000..88b6fd0
--- /dev/null
@@ -0,0 +1,253 @@
+#ifndef AliAnaParticleJetLeadingConeCorrelation_H
+#define AliAnaParticleJetLeadingConeCorrelation_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 reconstruction of jet, cone around leading particle
+// The seed is a backward particle (direct photon)
+// 1)Take the a trigger particle found stored in AliAODParticleCorrelation,
+// 2) Search for the highest pt leading particle opposite to the trigger within a phi, pt window
+// 3) Take all particles around leading in a cone R with pt larger than threshold and construct the jet
+//
+//  Class created from old AliPHOSGammaJet
+//  (see AliRoot versions previous Release 4-09)
+//
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT system ---
+class TH2F;
+
+//---- Analysis system ----
+class AliAODTrack;
+class AliAODCaloCluster;
+class AliCaloTrackReader;
+class AliNeutralMesonSelection;
+class AliLog;
+
+#include "AliAnaPartCorrBaseClass.h"
+
+class AliAnaParticleJetLeadingConeCorrelation : public AliAnaPartCorrBaseClass {
+
+public: 
+  
+  AliAnaParticleJetLeadingConeCorrelation() ; // default ctor
+  AliAnaParticleJetLeadingConeCorrelation(const AliAnaParticleJetLeadingConeCorrelation & g) ; // cpy ctor
+  AliAnaParticleJetLeadingConeCorrelation & operator = (const AliAnaParticleJetLeadingConeCorrelation & g) ;//cpy assignment
+  virtual ~AliAnaParticleJetLeadingConeCorrelation() ; //virtual dtor
+  
+  TList * GetCreateOutputObjects();
+
+  void InitParameters();
+  
+  void Print(const Option_t * opt) const;
+  
+  Bool_t     AreJetsRecalculated() const {return fReMakeJet ; } 
+  void SwitchOnJetsRecalculation(){fReMakeJet = kTRUE; }
+  void SwitchOffJetsRecalculation(){fReMakeJet = kFALSE; }
+  
+  Bool_t     AreJetsOnlyInCTS() const {return fJetsOnlyInCTS ; } 
+  void SwitchOnJetsOnlyInCTS(){fJetsOnlyInCTS = kTRUE; }
+  void SwitchOffJetsOnlyInCTS(){fJetsOnlyInCTS = kFALSE; }
+  
+  Bool_t   AreSeveralConeAndPtCuts() const {return fSeveralConeAndPtCuts ; }
+  void SwitchOnSeveralConeAndPtCuts(){fSeveralConeAndPtCuts = kTRUE ;}
+  void SwitchOffSeveralConeAndPtCuts(){fSeveralConeAndPtCuts = kFALSE ;}
+  
+  Bool_t   IsPbPb() const {return fPbPb ; }
+  void SetppCollisions(){fPbPb = kFALSE; }
+  void SetPbPbCollisions(){fPbPb = kTRUE; }
+  
+  Double_t GetDeltaPhiMaxCut() const {return fDeltaPhiMaxCut ; }
+  Double_t GetDeltaPhiMinCut() const {return fDeltaPhiMinCut ; }
+  Double_t GetLeadingRatioMaxCut() const {return fLeadingRatioMaxCut ; }
+  Double_t GetLeadingRatioMinCut() const {return fLeadingRatioMinCut ; }
+
+  Double_t GetPtTriggerSelectionCut() const {return fPtTriggerSelectionCut ; }
+  Double_t GetJetRatioMaxCut() const {return fJetRatioMaxCut ; }
+  Double_t GetJetRatioMinCut() const {return fJetRatioMinCut ; }  
+
+  void SetPtTriggerSelectionCut(Double_t cut){fPtTriggerSelectionCut = cut; }
+  void SetJetSelectionMode(UInt_t select){ fSelect= select ; }
+  
+  Int_t       GetJetNCones() const {return fJetNCone ; }
+  Int_t       GetJetNPtThres() const {return fJetNPt ; }
+  Float_t    GetJetCone() const {return fJetCone ; }
+  Float_t    GetJetPtThreshold() const {return fJetPtThreshold ; }
+  Float_t    GetJetPtThresPbPb() const {return fJetPtThresPbPb ; }
+  Float_t    GetJetCones(Int_t i) const {return fJetCones[i] ; }
+  Float_t    GetJetPtThreshold(Int_t i) const {return fJetPtThres[i] ; }
+  TString   GetJetConeName(Int_t i) const {return fJetNameCones[i] ; }
+  TString   GetJetPtThresName(Int_t i) const {return fJetNamePtThres[i] ; }
+  
+
+  void SetDeltaPhiCutRange(Double_t phimin, Double_t phimax)
+  {fDeltaPhiMaxCut =phimax;  fDeltaPhiMinCut =phimin;}
+  void SetLeadingRatioCutRange(Double_t ratiomin, Double_t ratiomax)
+  {fLeadingRatioMaxCut =ratiomax;  fLeadingRatioMinCut = ratiomin ; }
+
+  void SetJetNCones(Int_t n){fJetNCone = n ; }
+  void SetJetNPtThresholds(Int_t n){fJetNPt = n ; }
+  void SetJetCones(Int_t i, Float_t cone, TString sc)
+  {fJetCones[i] = cone ; fJetNameCones[i] = sc; };
+  void SetCone(Float_t cone)
+  {fJetCone = cone; }
+  void SetJetPtThreshold(Float_t pt){fJetPtThreshold = pt; };
+  void SetJetPtThresPbPb(Float_t pt){fJetPtThresPbPb = pt; };
+  void SetJetPtThresholds(Int_t i,Float_t pt, TString spt){fJetPtThres[i] = pt ; 
+    fJetNamePtThres[i] = spt; };
+  
+  void SetJetRatioCutRange(Double_t ratiomin, Double_t ratiomax)
+  {fJetRatioMaxCut =ratiomax;  fJetRatioMinCut = ratiomin ; }
+  void SetJetCTSRatioCutRange(Double_t ratiomin, Double_t ratiomax)
+  {fJetCTSRatioMaxCut =ratiomax;  fJetCTSRatioMinCut = ratiomin ; }
+  
+ private:
+  
+  Double_t CalculateJetRatioLimit(const Double_t ptTrig, const Double_t *param, const Double_t *x);
+  
+  void FillJetHistos(AliAODParticleCorrelation * particle, const TLorentzVector  leading, const TLorentzVector jet, const TString type, const TString lastname);
+  
+  TList * GetOutputContainer() {return fOutCont; }
+  
+  Bool_t IsJetSelected(const Double_t ptTrig, const Double_t ptjet);
+  Bool_t IsParticleInJetCone(const Double_t eta, Double_t phi, const Double_t etal, Double_t phil);
+  
+  void GetLeadingCharge(AliAODParticleCorrelation *particle, TLorentzVector & pLeading) ;
+  void GetLeadingPi0   (AliAODParticleCorrelation *particle, TLorentzVector & pLeading)  ;
+  Bool_t GetLeadingParticle(AliAODParticleCorrelation *particle, TLorentzVector &  pLeading) ;
+  
+  void MakeAnalysisFillAOD();
+  void MakeAnalysisFillHistograms();   
+  void MakeAODJet(AliAODParticleCorrelation * particle, const TLorentzVector pLeading); 
+  void MakeJetFromAOD(AliAODParticleCorrelation * particle, const TLorentzVector pLeading, 
+                     TLorentzVector & jet, TLorentzVector & bkg); 
+  
+  Bool_t  SelectCluster(AliAODCaloCluster * calo, Double_t *vertex, TLorentzVector & mom, Int_t & pdg) ;
+  
+ private:
+  
+  Bool_t     fJetsOnlyInCTS ;    // Jets measured only in TPC+ITS.
+  Bool_t     fPbPb;          // PbPb event
+  Bool_t     fSeveralConeAndPtCuts;     //  To play with the jet cone size and pt th.
+  Bool_t     fReMakeJet ; //Re make the jet reconstruction from AODParticleCorrelation input
+
+  //Leading particle selection parameters  
+  Double_t   fDeltaPhiMaxCut ;      // Minimum Delta Phi Gamma-Leading
+  Double_t   fDeltaPhiMinCut ;      //  Maximum Delta Phi Gamma-Leading
+  Double_t   fLeadingRatioMaxCut ; // Leading /gamma Ratio cut maximum
+  Double_t   fLeadingRatioMinCut ; // Leading/gamma Ratio cut minimum
+
+  //Jet selection parameters
+  //Fixed cuts (old)
+  Double_t   fJetCTSRatioMaxCut ; // Jet(CTS) /gamma Ratio cut maximum
+  Double_t   fJetCTSRatioMinCut ; // Jet(CTS) /gamma Ratio cut maximum
+  Double_t   fJetRatioMaxCut ; // Jet(EMCAL+CTS)/gamma Ratio cut maximum
+  Double_t   fJetRatioMinCut ; // Jet(EMCAL+CTS)/gamma Ratio cut minimum
+  
+  //Cuts depending on jet pt
+  Double_t   fJetE1[2];    //Rec. jet energy parameters
+  Double_t   fJetE2[2];    //Rec. jet energy parameters
+  Double_t   fJetSigma1[2];//Rec. sigma of jet energy  parameters
+  Double_t   fJetSigma2[2];//Rec. sigma of jet energy  parameters
+  Double_t   fBkgMean[6];  //Background mean energy 
+  Double_t   fBkgRMS[6];   //Background RMS
+  Double_t   fJetXMin1[6]; //X Factor to set jet min limit for pp
+  Double_t   fJetXMin2[6]; //X Factor to set jet min limit for PbPb
+  Double_t   fJetXMax1[6]; //X Factor to set jet max limit for pp
+  Double_t   fJetXMax2[6]; //X Factor to set jet max limit for PbPb
+  
+  Int_t      fJetNCone ;            // Number of jet cones sizes, maximum 5
+  Int_t      fJetNPt   ;            // Number of jet particle pT threshold, maximum 5
+  Double_t   fJetCone  ;            // Jet cone sizes under study (!fSeveralConeAndPtCuts)
+  Double_t   fJetCones[5];         // Jet cone sizes under study (fSeveralConeAndPtCuts)
+  TString    fJetNameCones[5];     // String name of cone to append to histos
+  Double_t   fJetPtThreshold;       // Jet pT threshold under study(!fSeveralConeAndPtCuts)
+  Double_t   fJetPtThresPbPb;       // Jet pT threshold under study(!fSeveralConeAndPtCuts)
+  Double_t   fJetPtThres[5];       // Jet pT threshold under study(fSeveralConeAndPtCuts)
+  TString    fJetNamePtThres[5];   // String name of pt th to append to histos
+  Double_t   fPtTriggerSelectionCut; // Jet pt to change to low pt jets analysis
+  UInt_t     fSelect  ;   //kTRUE: Selects all jets, no limits.
+  
+  //Histograms
+  //Leading particle distributions
+  TList *  fOutCont ; //! Container for histograms
+
+  TH2F * fhChargedLeadingPt  ;    //! Pt(Pt trigger) distribution of charged hadrons
+  TH2F * fhChargedLeadingPhi  ;   //! Phi(Pt trigger) distribution of charged hadrons
+  TH2F * fhChargedLeadingEta  ;   //! Eta(Pt trigger) distribution of charged hadrons
+  TH2F * fhChargedLeadingDeltaPt  ;   //! Difference of charged hadron and trigger  pT as function of trigger p
+  TH2F * fhChargedLeadingDeltaPhi  ;  //! Difference of charged hadron and trigger  phi as function of trigger pT
+  TH2F * fhChargedLeadingDeltaEta ;   //! Difference of charged particle and trigger eta as function of trigger pT
+  TH2F * fhChargedLeadingRatioPt  ; //! Ratio of Pt leading charge and trigger
+
+  TH2F * fhNeutralLeadingPt   ;   //! Pt(Pt trigger) distribution of neutral hadrons
+  TH2F * fhNeutralLeadingPhi   ;  //! Phi(Pt trigger) distribution of neutral hadrons
+  TH2F * fhNeutralLeadingEta   ;  //! Eta(Pt trigger) distribution of neutral hadrons
+  TH2F * fhNeutralLeadingDeltaPt   ;  //! Difference of neutral hadron and trigger pT as function of trigger pT
+  TH2F * fhNeutralLeadingDeltaPhi  ;  //! Difference of neutral hadron and trigger phi as function of trigger pT
+  TH2F * fhNeutralLeadingDeltaEta ;   //! Difference of charged particle and trigger eta as function of trigger pT
+  TH2F * fhNeutralLeadingRatioPt   ;  //! Ratio of Pt leading neutral and trigger
+
+  // Jet distributions
+  // Fixed cone and pt threshold
+  TH2F * fhJetPt  ; //! leading pt jet vs pt trigger
+  TH2F * fhJetRatioPt  ; //! Ratio of pt jet and pt trigger
+  TH2F * fhJetDeltaPhi  ; //! Delta phi jet-trigger
+  TH2F * fhJetDeltaEta  ; //! Delta eta jet-trigger
+  TH2F * fhJetLeadingRatioPt  ; //! Ratio of pt leading and pt jet
+  TH2F * fhJetLeadingDeltaPhi  ; //! Delta phi jet-leading
+  TH2F * fhJetLeadingDeltaEta  ; //! Delta eta jet-leading
+  TH2F * fhJetFFz; //! Accepted reconstructed jet fragmentation function, z=ptjet/pttrig
+  TH2F * fhJetFFxi; //! Accepted reconstructed jet fragmentation function, xsi = ln(pttrig/ptjet)
+  TH2F * fhJetFFpt; //! Jet particle pt distribution in cone
+  TH2F * fhJetNTracksInCone   ; //! jet multiplicity in cone
+
+  TH2F * fhBkgPt  ; //! leading pt bakground vs pt trigger
+  TH2F * fhBkgRatioPt  ; //! Ratio of pt background and pt trigger
+  TH2F * fhBkgDeltaPhi  ; //! Delta phi background-trigger
+  TH2F * fhBkgDeltaEta  ; //! Delta eta background-trigger
+  TH2F * fhBkgLeadingRatioPt  ; //! Ratio of pt leading and pt background
+  TH2F * fhBkgLeadingDeltaPhi  ; //! Delta phi background-leading
+  TH2F * fhBkgLeadingDeltaEta  ; //! Delta eta background-leading
+  TH2F * fhBkgFFz; //! Accepted reconstructed background fragmentation function, z=ptjet/pttrig
+  TH2F * fhBkgFFxi; //! Accepted reconstructed background fragmentation function, xsi = ln(pttrig/ptjet)
+  TH2F * fhBkgFFpt; //! Background particle pt distribution in cone
+  TH2F * fhBkgNTracksInCone   ; //! Background multiplicity in cone
+
+  // Variable cone and pt threshold
+
+  TH2F * fhJetPts[5][5]; //! leading pt jet vs pt trigger
+  TH2F * fhJetRatioPts[5][5]; //! Ratio of pt jet and pt trigger
+  TH2F * fhJetDeltaPhis[5][5]; //! Delta phi jet-trigger
+  TH2F * fhJetDeltaEtas[5][5]; //! Delta eta jet-trigger
+  TH2F * fhJetLeadingRatioPts[5][5]; //! Ratio of pt leading and pt jet
+  TH2F * fhJetLeadingDeltaPhis[5][5]; //! Delta phi jet-leading
+  TH2F * fhJetLeadingDeltaEtas[5][5]; //! Delta eta jet-leading
+  TH2F * fhJetFFzs[5][5]; //! Accepted reconstructed jet fragmentation function, z=ptjet/pttrig
+  TH2F * fhJetFFxis[5][5]; //! Accepted reconstructed jet fragmentation function, xsi = ln(pttrig/ptjet)
+  TH2F * fhJetFFpts[5][5]; //! Jet particle pt distribution in cone
+  TH2F * fhJetNTracksInCones[5][5]; //! jet multiplicity in cone
+
+  TH2F * fhBkgPts[5][5]; //! leading pt bakground vs pt trigger
+  TH2F * fhBkgRatioPts[5][5]; //! Ratio of pt background and pt trigger
+  TH2F * fhBkgDeltaPhis[5][5]; //! Delta phi background-trigger
+  TH2F * fhBkgDeltaEtas[5][5]; //! Delta eta background-trigger
+  TH2F * fhBkgLeadingRatioPts[5][5]; //! Ratio of pt leading and pt background
+  TH2F * fhBkgLeadingDeltaPhis[5][5]; //! Delta phi background-leading
+  TH2F * fhBkgLeadingDeltaEtas[5][5]; //! Delta eta background-leading
+  TH2F * fhBkgFFzs[5][5]; //! Accepted reconstructed background fragmentation function, z=ptjet/pttrig
+  TH2F * fhBkgFFxis[5][5]; //! Accepted reconstructed background fragmentation function, xsi = ln(pttrig/ptjet)
+  TH2F * fhBkgFFpts[5][5]; //! Background particle pt distribution in cone
+  TH2F * fhBkgNTracksInCones[5][5]; //! Background multiplicity in cone
+  
+  
+  ClassDef(AliAnaParticleJetLeadingConeCorrelation,1)
+ } ;
+
+#endif //AliAnaParticleJetLeadingConeCorrelation_H
+
+
+
diff --git a/PWG4/PartCorr/AliAnaParticlePartonCorrelation.cxx b/PWG4/PartCorr/AliAnaParticlePartonCorrelation.cxx
new file mode 100644 (file)
index 0000000..89b1ee7
--- /dev/null
@@ -0,0 +1,295 @@
+/**************************************************************************
+ * 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-parton correlations
+// Particle (for example direct gamma) must be found in a previous analysis 
+// -- Author: Gustavo Conesa (LNF-INFN) 
+//////////////////////////////////////////////////////////////////////////////
+
+// --- ROOT system ---
+#include "Riostream.h"
+#include "TH2F.h"
+#include "TParticle.h"
+
+//---- ANALYSIS system ----
+#include "AliAnaParticlePartonCorrelation.h" 
+#include "AliLog.h"
+#include "AliStack.h"  
+
+  ClassImp(AliAnaParticlePartonCorrelation)
+  
+
+//____________________________________________________________________________
+  AliAnaParticlePartonCorrelation::AliAnaParticlePartonCorrelation() : 
+    AliAnaPartCorrBaseClass(),   
+    fhDeltaEtaNearParton(0), fhDeltaPhiNearParton(0), 
+    fhDeltaPtNearParton(0), fhPtRatNearParton(0),
+    fhDeltaEtaAwayParton(0), fhDeltaPhiAwayParton(0), 
+    fhDeltaPtAwayParton(0), fhPtRatAwayParton(0)
+{
+  //Default Ctor
+
+  //Initialize parameters
+  InitParameters();
+}
+
+//____________________________________________________________________________
+AliAnaParticlePartonCorrelation::AliAnaParticlePartonCorrelation(const AliAnaParticlePartonCorrelation & g) :   
+  AliAnaPartCorrBaseClass(g),   
+  fhDeltaEtaNearParton(g.fhDeltaEtaNearParton), fhDeltaPhiNearParton(g.fhDeltaPhiNearParton), 
+  fhDeltaPtNearParton(g.fhDeltaPtNearParton), fhPtRatNearParton(g.fhPtRatNearParton),
+  fhDeltaEtaAwayParton(g.fhDeltaEtaAwayParton), fhDeltaPhiAwayParton(g.fhDeltaPhiAwayParton), 
+  fhDeltaPtAwayParton(g.fhDeltaPtAwayParton), fhPtRatAwayParton(g.fhPtRatAwayParton)
+{
+  // cpy ctor
+
+}
+
+//_________________________________________________________________________
+AliAnaParticlePartonCorrelation & AliAnaParticlePartonCorrelation::operator = (const AliAnaParticlePartonCorrelation & source)
+{
+  // assignment operator
+
+  if(this == &source)return *this;
+  ((AliAnaPartCorrBaseClass *)this)->operator=(source);
+
+  fhDeltaEtaAwayParton = source.fhDeltaEtaAwayParton;
+  fhDeltaPhiAwayParton = source.fhDeltaPhiAwayParton;
+  fhDeltaPtAwayParton = source.fhDeltaPtAwayParton;
+  fhPtRatAwayParton = source.fhPtRatAwayParton;
+  fhDeltaEtaNearParton = source.fhDeltaEtaNearParton;
+  fhDeltaPhiNearParton = source.fhDeltaPhiNearParton;
+  fhDeltaPtNearParton = source.fhDeltaPtNearParton;
+  fhPtRatNearParton = source.fhPtRatNearParton;
+
+  return *this;
+
+}
+
+
+//________________________________________________________________________
+TList *  AliAnaParticlePartonCorrelation::GetCreateOutputObjects()
+{  
+  // Create histograms to be saved in output file 
+
+  AliDebug(1,"Init parton histograms");
+
+  TList * outputContainer = new TList() ; 
+  outputContainer->SetName("ParticlePartonHistos") ; 
+  
+  fhDeltaPhiNearParton  = new TH2F
+    ("DeltaPhiNearParton","#phi_{particle} - #phi_{parton} vs p_{T particle}",
+     200,0,120,200,0,6.4); 
+  fhDeltaPhiNearParton->SetYTitle("#Delta #phi");
+  fhDeltaPhiNearParton->SetXTitle("p_{T particle} (GeV/c)");
+  outputContainer->Add(fhDeltaPhiNearParton);
+  
+  fhDeltaEtaNearParton  = new TH2F
+    ("DeltaEtaNearParton","#eta_{particle} - #eta_{parton} vs p_{T particle}",
+     200,0,120,200,-2,2); 
+  fhDeltaEtaNearParton->SetYTitle("#Delta #eta");
+  fhDeltaEtaNearParton->SetXTitle("p_{T particle} (GeV/c)");
+  outputContainer->Add(fhDeltaEtaNearParton);
+  
+  fhDeltaPtNearParton  = new TH2F
+    ("DeltaPtNearParton","#p_{T particle} - #p_{T parton} vs p_{T particle}",
+     200,0,120,100,-10,10); 
+  fhDeltaPtNearParton->SetYTitle("#Delta #p_{T}");
+  fhDeltaPtNearParton->SetXTitle("p_{T particle} (GeV/c)"); 
+  outputContainer->Add(fhDeltaPtNearParton);
+  
+  fhPtRatNearParton  = new TH2F
+    ("PtRatNearParton","#p_{T parton} / #p_{T particle} vs p_{T particle}",
+     200,0,120,200,0,5); 
+  fhPtRatNearParton->SetYTitle("ratio");
+  fhPtRatNearParton->SetXTitle("p_{T particle} (GeV/c)");
+  outputContainer->Add(fhPtRatNearParton);
+  
+  fhDeltaPhiAwayParton  = new TH2F
+    ("DeltaPhiAwayParton","#phi_{particle} - #phi_{parton} vs p_{T particle}",
+     200,0,120,200,0,6.4); 
+  fhDeltaPhiAwayParton->SetYTitle("#Delta #phi");
+  fhDeltaPhiAwayParton->SetXTitle("p_{T particle} (GeV/c)");
+  outputContainer->Add(fhDeltaPhiAwayParton);
+  
+  fhDeltaEtaAwayParton  = new TH2F
+    ("DeltaEtaAwayParton","#eta_{particle} - #eta_{parton} vs p_{T particle}",
+     200,0,120,200,-2,2); 
+  fhDeltaEtaAwayParton->SetYTitle("#Delta #eta");
+  fhDeltaEtaAwayParton->SetXTitle("p_{T particle} (GeV/c)");
+  outputContainer->Add(fhDeltaEtaAwayParton);
+  
+  fhDeltaPtAwayParton  = new TH2F
+    ("DeltaPtAwayParton","#p_{T particle} - #p_{T parton} vs p_{T particle}",
+     200,0,120,100,-10,10); 
+  fhDeltaPtAwayParton->SetYTitle("#Delta #p_{T}");
+  fhDeltaPtAwayParton->SetXTitle("p_{T particle} (GeV/c)"); 
+  outputContainer->Add(fhDeltaPtAwayParton);
+  
+  fhPtRatAwayParton  = new TH2F
+    ("PtRatAwayParton","#p_{T parton} / #p_{T particle} vs p_{T particle}",
+     200,0,120,200,0,5); 
+  fhPtRatAwayParton->SetYTitle("ratio");
+  fhPtRatAwayParton->SetXTitle("p_{T particle} (GeV/c)");
+  outputContainer->Add(fhPtRatAwayParton);
+  
+  return outputContainer;
+}
+
+//____________________________________________________________________________
+void AliAnaParticlePartonCorrelation::InitParameters()
+{
+  
+  //Initialize the parameters of the analysis.
+  ;
+  
+}
+
+//__________________________________________________________________
+void AliAnaParticlePartonCorrelation::Print(const Option_t * opt) const
+{
+  
+  //Print some relevant parameters set for the analysis
+  if(! opt)
+    return;
+  
+} 
+
+//__________________________________________________________________
+void  AliAnaParticlePartonCorrelation::MakeAnalysisFillAOD()  
+{
+  //Particle-Parton Correlation Analysis, create AODs
+  //Add partons to the reference list of the trigger particle
+  //Partons are considered those in the first eight possitions in the stack
+  //being 0, and 1 the 2 protons, and 6 and 7 the outgoing final partons.
+
+  if(GetDebug() > 1){
+    printf("Begin parton correlation analysis, fill AODs \n");
+    printf("In particle branch aod entries %d\n", GetAODBranch()->GetEntriesFast());
+  }
+  
+  //Loop on stored AOD particles
+  Int_t naod = GetAODBranch()->GetEntriesFast();
+  for(Int_t iaod = 0; iaod < naod ; iaod++){
+    AliAODParticleCorrelation* particle =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->At(iaod));
+    
+    AliStack * stack =  GetMCStack() ;
+    if(!stack) AliFatal("No Stack available, STOP");
+    
+    if(stack->GetNtrack() < 8) {
+      printf("*** small number of particles, not a PYTHIA simulation? ***:  n tracks %d \n", stack->GetNprimary());
+      continue ;
+    }
+    
+    //Fill AOD reference only with partons
+    TParticle * parton = new TParticle ;
+    
+    for(Int_t ipr = 0;ipr < 8; ipr ++ ){
+      parton = stack->Particle(ipr) ;
+      particle->AddTrack(parton);
+      //parton->Print();
+    }
+
+  }//Aod branch loop
+
+ if(GetDebug() > 1) printf("End parton correlation analysis, fill AODs \n");
+}
+//__________________________________________________________________
+void  AliAnaParticlePartonCorrelation::MakeAnalysisFillHistograms()  
+{
+  //Particle-Parton Correlation Analysis, fill histograms
+  if(GetDebug() > 1){
+    printf("Begin parton correlation analysis, fill histograms \n");
+    printf("In particle branch aod entries %d\n", GetAODBranch()->GetEntriesFast());
+  }
+
+  AliStack * stack =  GetMCStack() ;
+  if(!stack) AliFatal("No Stack available, STOP");
+
+  //Loop on stored AOD particles
+  Int_t naod = GetAODBranch()->GetEntriesFast();
+  TParticle *  mom =new TParticle ;
+
+  for(Int_t iaod = 0; iaod < naod ; iaod++){
+    AliAODParticleCorrelation* particle =  dynamic_cast<AliAODParticleCorrelation*> (GetAODBranch()->At(iaod));
+    
+    Float_t ptTrigg  = particle->Pt();
+    Float_t phiTrigg = particle->Phi();
+    Float_t etaTrigg = particle->Eta(); 
+    Int_t imom = particle->GetLabel();
+    Int_t iparent  = 2000;
+    Int_t iawayparent = -1;
+
+    if(!(particle->GetRefTracks()) || (particle->GetRefTracks())->GetEntriesFast() < 7) AliFatal("Reference list with partons not filled, STOP analysis");
+
+    //Check and get indeces of mother and parton    
+    if(imom < 8 ) iparent = imom ;   //mother is already a parton
+    else if (imom <  stack->GetNtrack()) {
+      mom =  stack->Particle(imom);
+      iparent=mom->GetFirstMother();
+      cout<<" iparent "<<iparent<<endl;
+      while(iparent > 7 ){
+       mom = stack->Particle(iparent);
+       imom = iparent ; //Mother label is of the inmediate parton daughter
+       iparent = mom->GetFirstMother();
+       cout<<" while iparent "<<iparent<<endl;
+      }   
+    }
+    
+    if(GetDebug() > 1) printf("N reference partons %d; labels:  mother %d, parent %d \n", (particle->GetRefTracks())->GetEntriesFast(), imom, iparent);
+
+    
+    if(iparent < 0 || iparent > 8) { 
+      if(GetDebug() > 0 ) printf("Failed to find appropriate parton, index %d", iparent);
+      continue ;
+    }
+
+    //Near parton is the parton that fragmented and created the mother    
+    TParticle * nearParton = (TParticle*) (particle->GetRefTracks())->At(iparent);
+    Float_t  ptNearParton    = nearParton->Pt();
+    Float_t  phiNearParton   = nearParton->Phi() ;
+    Float_t  etaNearParton   = nearParton->Eta() ;
+    
+    fhDeltaEtaNearParton->Fill(ptTrigg,etaTrigg-etaNearParton);
+    fhDeltaPhiNearParton->Fill(ptTrigg,phiTrigg-phiNearParton);
+    fhDeltaPtNearParton->Fill(ptTrigg,ptTrigg-ptNearParton);
+    fhPtRatNearParton->Fill(ptTrigg,ptNearParton/ptTrigg);
+    
+    if(iparent == 7) iawayparent =6;
+    else if(iparent == 6) iawayparent =7;
+    else{
+      printf("Parent parton is not final state, skip \n");
+      continue;
+    }
+
+    //Away parton is the other final parton.
+    TParticle * awayParton = (TParticle*) (particle->GetRefTracks())->At(iawayparent);
+    Float_t  ptAwayParton    = awayParton->Pt();
+    Float_t  phiAwayParton   = awayParton->Phi() ;
+    Float_t  etaAwayParton   = awayParton->Eta() ;
+    fhDeltaEtaAwayParton->Fill(ptTrigg,etaTrigg-etaAwayParton);
+    fhDeltaPhiAwayParton->Fill(ptTrigg,phiTrigg-phiAwayParton);
+    fhDeltaPtAwayParton->Fill(ptTrigg,ptTrigg-ptAwayParton);
+    fhPtRatAwayParton->Fill(ptTrigg,ptAwayParton/ptTrigg);
+    
+  }
+
+  if(GetDebug() > 1) printf("End parton correlation analysis, fill histograms \n");
+  
+} 
diff --git a/PWG4/PartCorr/AliAnaParticlePartonCorrelation.h b/PWG4/PartCorr/AliAnaParticlePartonCorrelation.h
new file mode 100644 (file)
index 0000000..0eecbbd
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef AliAnaParticlePartonCorrelation_H
+#define AliAnaParticlePartonCorrelation_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-parton correlation
+// Particle (for example direct gamma) must be found in a previous analysis 
+//-- Author: Gustavo Conesa (INFN-LNF)
+
+// --- ROOT ---
+class TH2F ;
+
+// --- ANALYSIS ---
+#include "AliAnaPartCorrBaseClass.h"
+     
+class AliAnaParticlePartonCorrelation : public AliAnaPartCorrBaseClass {
+       
+  public: 
+       
+       AliAnaParticlePartonCorrelation() ; // default ctor
+       AliAnaParticlePartonCorrelation(const AliAnaParticlePartonCorrelation & g) ; // cpy ctor
+       AliAnaParticlePartonCorrelation & operator = (const AliAnaParticlePartonCorrelation & g) ;//cpy assignment
+       virtual ~AliAnaParticlePartonCorrelation() {;} //virtual dtor
+              
+       TList * GetCreateOutputObjects();
+       
+       void InitParameters();
+       
+       void Print(const Option_t * opt) const;
+       
+       void MakeAnalysisFillAOD()  ;
+       
+       void MakeAnalysisFillHistograms() ; 
+       
+  private:
+       
+       TH2F * fhDeltaEtaNearParton; //! Difference of parton eta and prompt trigger particle eta
+       TH2F * fhDeltaPhiNearParton; //! Difference of parton phi and prompt trigger particle phi
+       TH2F * fhDeltaPtNearParton; //! Difference of parton pT and prompt trigger particle pT
+       TH2F * fhPtRatNearParton; //! Ratio of parton pT and prompt trigger particle pT
+       
+       TH2F * fhDeltaEtaAwayParton; //! Difference of parton eta and prompt trigger particle eta
+       TH2F * fhDeltaPhiAwayParton; //! Difference of parton phi and prompt trigger particle phi
+       TH2F * fhDeltaPtAwayParton; //! Difference of parton pT and prompt trigger particle pT
+       TH2F * fhPtRatAwayParton; //! Ratio of parton pT and prompt trigger particle pT
+
+       ClassDef(AliAnaParticlePartonCorrelation,1)
+ } ;
+
+
+#endif //AliAnaParticlePartonCorrelation_H
+
+
+
diff --git a/PWG4/PartCorr/AliAnaPi0.cxx b/PWG4/PartCorr/AliAnaPi0.cxx
new file mode 100644 (file)
index 0000000..e4a4c76
--- /dev/null
@@ -0,0 +1,557 @@
+/**************************************************************************
+ * 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 to collect two-photon invariant mass distributions for
+// extractin raw pi0 yield.
+//
+//-- Author: Dmitri Peressounko (RRC "KI") 
+//_________________________________________________________________________
+
+
+// --- ROOT system ---
+#include "TClonesArray.h"
+#include "TRefArray.h"
+#include "TH3.h"
+
+//---- AliRoot system ----
+#include "AliAnaPi0.h"
+#include "AliLog.h"
+#include "AliCaloPhoton.h"
+#include "AliESDEvent.h"
+#include "AliAODEvent.h"
+#include "AliESDVertex.h"
+#include "AliAODVertex.h"
+#include "AliESDCaloCluster.h"
+#include "AliAODCaloCluster.h"
+
+ClassImp(AliAnaPi0)
+  
+//____________________________________________________________________________
+  AliAnaPi0::AliAnaPi0() : AliAnalysisTaskSE(),
+  fNCentrBin(1),fNZvertBin(1),fNrpBin(1),fNPID(2),fNmaxMixEv(10),
+  fCurCentrBin(0),fCurZvertBin(0),fCurRPBin(0),fPtMin(0.),fZvtxCut(40.),
+  fMinDist(2.),fMinDist2(4.),fMinDist3(5.),fDispCut(1.5),fTOFCut(5.e-9),fPhotPID(0.6),
+  fEventsList(0x0),fCurrentEvent(0x0),fOutputList(0x0),fhEtalon(0x0),
+  fhRe1(0x0),fhMi1(0x0),fhRe2(0x0),fhMi2(0x0),fhRe3(0x0),fhMi3(0x0),fhEvents(0x0) 
+{
+  //Default Ctor
+
+}
+//____________________________________________________________________________
+  AliAnaPi0::AliAnaPi0(const char *name): AliAnalysisTaskSE(name),
+  fNCentrBin(1),fNZvertBin(1),fNrpBin(1),fNPID(9),fNmaxMixEv(10),
+  fCurCentrBin(0),fCurZvertBin(0),fCurRPBin(0),fPtMin(0.),fZvtxCut(40.),
+  fMinDist(2.),fMinDist2(4.),fMinDist3(5.),fDispCut(1.5),fTOFCut(5.e-9),fPhotPID(0.6),
+  fEventsList(0x0),fCurrentEvent(0x0),fOutputList(0x0),fhEtalon(0x0),
+  fhRe1(0x0),fhMi1(0x0),fhRe2(0x0),fhMi2(0x0),fhRe3(0x0),fhMi3(0x0),fhEvents(0x0) 
+{
+  //Ctor
+  DefineOutput(1,TList::Class());
+}
+
+//____________________________________________________________________________
+AliAnaPi0::AliAnaPi0(const AliAnaPi0 & ex) : AliAnalysisTaskSE(ex),  
+  fNCentrBin(1),fNZvertBin(1),fNrpBin(1),fNPID(9),fNmaxMixEv(10),
+  fCurCentrBin(0),fCurZvertBin(0),fCurRPBin(0),fPtMin(0.),fZvtxCut(40.),
+  fMinDist(2.),fMinDist2(4.),fMinDist3(5.),fDispCut(1.5),fTOFCut(5.e-9),fPhotPID(0.6),
+  fEventsList(0x0),fCurrentEvent(0x0),fOutputList(0x0),fhEtalon(0x0),
+  fhRe1(0x0),fhMi1(0x0),fhRe2(0x0),fhMi2(0x0),fhRe3(0x0),fhMi3(0x0),fhEvents(0x0) 
+{
+  // cpy ctor
+  //Do not need it
+}
+//_________________________________________________________________________
+AliAnaPi0 & AliAnaPi0::operator = (const AliAnaPi0 & ex)
+{
+  // assignment operator
+
+  if(this == &ex)return *this;
+  ((AliAnalysisTaskSE *)this)->operator=(ex);
+  return *this;
+
+}
+//____________________________________________________________________________
+AliAnaPi0::~AliAnaPi0() {
+  // Remove event containers
+  if(fEventsList){
+    for(Int_t ic=0; ic<fNCentrBin; ic++){
+      for(Int_t iz=0; iz<fNZvertBin; iz++){
+        for(Int_t irp=0; irp<fNrpBin; irp++){
+          fEventsList[ic*fNZvertBin*fNrpBin+iz*fNrpBin+irp]->Delete() ;
+          delete fEventsList[ic*fNZvertBin*fNrpBin+iz*fNrpBin+irp] ;
+        }
+      }
+    }
+    delete[] fEventsList; 
+    fEventsList=0 ;
+  }
+
+  if(fhEtalon){
+    delete fhEtalon ;
+    fhEtalon = 0; 
+  }
+  if(fhRe1) delete[] fhRe1 ; //Do not delete histograms!
+  if(fhRe2) delete[] fhRe2 ; //Do not delete histograms!
+  if(fhRe3) delete[] fhRe3 ; //Do not delete histograms!
+  if(fhMi1) delete[] fhMi1 ; //Do not delete histograms!
+  if(fhMi2) delete[] fhMi2 ; //Do not delete histograms!
+  if(fhMi3) delete[] fhMi3 ; //Do not delete histograms!
+
+}
+//________________________________________________________________________
+void  AliAnaPi0::UserCreateOutputObjects()
+{  
+  // Create histograms to be saved in output file and 
+  // store them in fOutputContainer
+
+  AliDebug(1,"Init inv. mass histograms");
+  OpenFile(1) ; 
+
+  //create event containers
+  fEventsList = new TList*[fNCentrBin*fNZvertBin*fNrpBin] ;
+  for(Int_t ic=0; ic<fNCentrBin; ic++){
+    for(Int_t iz=0; iz<fNZvertBin; iz++){
+      for(Int_t irp=0; irp<fNrpBin; irp++){
+        fEventsList[ic*fNZvertBin*fNrpBin+iz*fNrpBin+irp] = new TList() ;
+      }
+    }
+  }
+
+  fOutputList = new TList() ;
+  fOutputList->SetName(GetName()) ;
+  fhRe1=new TH3D*[fNCentrBin*fNPID] ;
+  fhRe2=new TH3D*[fNCentrBin*fNPID] ;
+  fhRe3=new TH3D*[fNCentrBin*fNPID] ;
+  fhMi1=new TH3D*[fNCentrBin*fNPID] ;
+  fhMi2=new TH3D*[fNCentrBin*fNPID] ;
+  fhMi3=new TH3D*[fNCentrBin*fNPID] ;
+
+  char key[255] ;
+  char title[255] ;
+  for(Int_t ic=0; ic<fNCentrBin; ic++){
+    for(Int_t ipid=0; ipid<fNPID; ipid++){
+      //Distance to bad module 1
+      sprintf(key,"hRe_cen%d_pid%d_dist1",ic,ipid) ;
+      sprintf(title,"Real m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
+      fhRe1[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
+      fhRe1[ic*fNPID+ipid]->SetName(key) ;
+      fhRe1[ic*fNPID+ipid]->SetTitle(title) ;
+      fOutputList->Add(fhRe1[ic*fNPID+ipid]) ;
+
+      sprintf(key,"hMi_cen%d_pid%d_dist1",ic,ipid) ;
+      sprintf(title,"Mixed m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
+      fhMi1[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
+      fhMi1[ic*fNPID+ipid]->SetName(key) ;
+      fhMi1[ic*fNPID+ipid]->SetTitle(title) ;
+      fOutputList->Add(fhMi1[ic*fNPID+ipid]) ;
+
+      //Distance to bad module 2
+      sprintf(key,"hRe_cen%d_pid%d_dist2",ic,ipid) ;
+      sprintf(title,"Real m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
+      fhRe2[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
+      fhRe2[ic*fNPID+ipid]->SetName(key) ;
+      fhRe2[ic*fNPID+ipid]->SetTitle(title) ;
+      fOutputList->Add(fhRe2[ic*fNPID+ipid]) ;
+
+      sprintf(key,"hMi_cen%d_pid%d_dist2",ic,ipid) ;
+      sprintf(title,"Mixed m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
+      fhMi2[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
+      fhMi2[ic*fNPID+ipid]->SetName(key) ;
+      fhMi2[ic*fNPID+ipid]->SetTitle(title) ;
+      fOutputList->Add(fhMi2[ic*fNPID+ipid]) ;
+
+      //Distance to bad module 3
+      sprintf(key,"hRe_cen%d_pid%d_dist3",ic,ipid) ;
+      sprintf(title,"Real m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
+      fhRe3[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
+      fhRe3[ic*fNPID+ipid]->SetName(key) ; 
+      fhRe3[ic*fNPID+ipid]->SetTitle(title) ;
+      fOutputList->Add(fhRe3[ic*fNPID+ipid]) ;
+
+      sprintf(key,"hMi_cen%d_pid%d_dist3",ic,ipid) ;
+      sprintf(title,"Mixed m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
+      fhMi3[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
+      fhMi3[ic*fNPID+ipid]->SetName(key) ;
+      fhMi3[ic*fNPID+ipid]->SetTitle(title) ;
+      fOutputList->Add(fhMi3[ic*fNPID+ipid]) ;
+    }
+  }
+
+  fhEvents=new TH3D("hEvents","Number of events",fNCentrBin,0.,1.*fNCentrBin,
+                    fNZvertBin,0.,1.*fNZvertBin,fNrpBin,0.,1.*fNrpBin) ;
+  fOutputList->Add(fhEvents) ;
+
+  //Save parameters used for analysis
+  TString parList ; //this will be list of parameters used for this analysis.
+  char onePar[255] ;
+  sprintf(onePar,"Number of bins in Centrality:  %d \n",fNCentrBin) ;
+  parList+=onePar ;
+  sprintf(onePar,"Number of bins in Z vert. pos: %d \n",fNZvertBin) ;
+  parList+=onePar ;
+  sprintf(onePar,"Number of bins in Reac. Plain: %d \n",fNrpBin) ;
+  parList+=onePar ;
+  sprintf(onePar,"Depth of event buffer: %d \n",fNmaxMixEv) ;
+  parList+=onePar ;
+  sprintf(onePar,"Number of different PID used:  %d \n",fNPID) ;
+  parList+=onePar ;
+  sprintf(onePar,"Cuts: \n") ;
+  parList+=onePar ;
+  sprintf(onePar,"Z vertex position: -%f < z < %f \n",fZvtxCut,fZvtxCut) ;
+  parList+=onePar ;
+  sprintf(onePar,"Minimal P_t: %f \n", fPtMin) ;
+  parList+=onePar ;
+  sprintf(onePar,"fMinDist =%f (Minimal distance to bad channel to accept cluster) \n",fMinDist) ;
+  parList+=onePar ;
+  sprintf(onePar,"fMinDist2=%f (Cuts on Minimal distance to study acceptance evaluation) \n",fMinDist2) ;
+  parList+=onePar ;
+  sprintf(onePar,"fMinDist3=%f (One more cut on distance used for acceptance-efficiency study) \n",fMinDist3) ;
+  parList+=onePar ;
+  sprintf(onePar,"fDispCut =%f (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,"fPhotPID =%f (limit for Baesian PID for photon) \n",fPhotPID) ;
+  parList+=onePar ;
+  TObjString *oString= new TObjString(parList) ;
+  fOutputList->Add(oString);
+}
+//__________________________________________________
+void AliAnaPi0::InitParameters()
+{ 
+  //Initialize the parameters of the analysis.
+  
+}
+ //__________________________________________________
+void AliAnaPi0::Init()
+{ 
+  //Make here all memory allocations
+  //create etalon histo for all later histograms
+  if(!fhEtalon){                                                   //  p_T      alpha   d m_gg    
+    fhEtalon = new TH3D("hEtalon","Histo with binning parameters",20,0.,10.,10,0.,1.,200,0.,1.) ; 
+    fhEtalon->SetXTitle("P_{T} (GeV)") ;
+    fhEtalon->SetYTitle("#alpha") ;
+    fhEtalon->SetZTitle("m_{#gamma#gamma} (GeV)") ;
+  }
+  
+}
+//__________________________________________________________________
+void AliAnaPi0::Print(const Option_t * /*opt*/) const
+{
+  //Print some relevant parameters set for the analysis
+  printf("Class AliAnaPi0 for gamma-gamma inv.mass construction \n") ;
+  printf("Number of bins in Centrality:  %d \n",fNCentrBin) ;
+  printf("Number of bins in Z vert. pos: %d \n",fNZvertBin) ;
+  printf("Number of bins in Reac. Plain: %d \n",fNrpBin) ;
+  printf("Depth of event buffer: %d \n",fNmaxMixEv) ;
+  printf("Number of different PID used:  %d \n",fNPID) ;
+  printf("Cuts: \n") ;
+  printf("Z vertex position: -%f < z < %f \n",fZvtxCut,fZvtxCut) ;
+  printf("Minimal P_t: %f \n", fPtMin) ;
+  printf("fMinDist =%f (Minimal distance to bad channel to accept cluster) \n",fMinDist) ;
+  printf("fMinDist2=%f (Cuts on Minimal distance to study acceptance evaluation) \n",fMinDist2) ;
+  printf("fMinDist3=%f (One more cut on distance used for acceptance-efficiency study) \n",fMinDist3) ;
+  printf("fDispCut =%f (Cut on dispersion, used in PID evaluation) \n",fDispCut) ;
+  printf("fTOFCut  =%e (Cut on TOF, used in PID evaluation) \n",fTOFCut) ;
+  printf("fPhotPID =%f (limit for Baesian PID for photon) \n",fPhotPID) ;
+  printf("------------------------------------------------------\n") ;
+  
+} 
+//__________________________________________________________________
+void AliAnaPi0::UserExec(Option_t *)
+{
+  //Process one event and extract photons 
+  //impose cuts on bad modules and bad runs
+  //fill internal storage for subsequent histo filling
+
+  AliVEvent* event = InputEvent();
+  //Apply some cuts on event: vertex position and centrality range  
+  Int_t iRun=event->GetRunNumber() ;
+  if(IsBadRun(iRun))
+    return ;
+
+  AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event) ;
+  AliAODEvent* aod = dynamic_cast<AliAODEvent*>(event) ;
+  if(esd){
+     if(!FillFromESD(esd))
+      return  ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
+   }
+   else if(aod){
+     if(!FillFromAOD(aod))
+       return ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
+   }
+   else{
+     printf("Input neither ESD nor AOD, do nothing \n") ;
+     return ;
+   }
+
+
+  fhEvents->Fill(fCurCentrBin+0.5,fCurZvertBin+0.5,fCurRPBin+0.5) ;
+
+  if(fCurrentEvent->GetEntriesFast()>0){
+    //Reduce size for storing
+    fCurrentEvent->Expand(fCurrentEvent->GetEntriesFast()) ;
+    FillHistograms() ;
+  }
+
+  PostData(1, fOutputList);
+} 
+//__________________________________________________________________
+Bool_t AliAnaPi0::FillFromESD(AliESDEvent * esd){
+  //Fill photon list from ESD applying 
+  //some cut should be applyed
+
+  //Impose cut on vertex and calculate Zvertex bin
+  const AliESDVertex *esdV = esd->GetVertex() ;
+  esdV->GetXYZ(fVert);
+  if(fVert[2]<-fZvtxCut || fVert[2]> fZvtxCut)
+    return kFALSE ;
+  fCurZvertBin=(Int_t)(0.5*fNZvertBin*(fVert[2]+fZvtxCut)/fZvtxCut) ;
+    
+  //Get Centrality and calculate centrality bin
+  //Does not exist in ESD yet???????
+  fCurCentrBin=0 ;
+  //Get Reaction Plain position and calculate RP bin
+  //does not exist in ESD yet????
+  fCurRPBin=0 ;
+  //************************  PHOS *************************************
+  TRefArray * caloClustersArr  = new TRefArray();
+  esd->GetPHOSClusters(caloClustersArr);
+  const Int_t kNumberOfPhosClusters   = caloClustersArr->GetEntries() ;
+  //if fCurrentEvent!=0 it was not filled in previous event, still empty and can be used
+  if(!fCurrentEvent) 
+    fCurrentEvent = new TClonesArray("AliCaloPhoton",kNumberOfPhosClusters) ;
+  Int_t inList=0 ;
+  // loop over the PHOS Cluster
+  for(Int_t i = 0 ; i < kNumberOfPhosClusters ; i++) {
+    AliESDCaloCluster * calo = (AliESDCaloCluster *) caloClustersArr->At(i) ;
+    //Make some tests
+    if(calo->E()<fPtMin)
+      continue ;
+
+    Double_t distBad=calo->GetDistanceToBadChannel() ; //Distance to bad in cm
+    if(distBad<0.)distBad=9999. ; //workout strange convension dist = -1. ;
+    if(distBad<fMinDist) //In bad channel (cristall size 2.2x2.2 cm)
+      continue ;
+
+    new((*fCurrentEvent)[inList])AliCaloPhoton() ;
+    AliCaloPhoton * ph = static_cast<AliCaloPhoton*>(fCurrentEvent->At(inList)) ;
+    inList++ ;
+
+    //Set Momentu