Added a new class for the AOD information
authorkaamodt <kaamodt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Jun 2009 05:36:08 +0000 (05:36 +0000)
committerkaamodt <kaamodt@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 12 Jun 2009 05:36:08 +0000 (05:36 +0000)
Added new macro: AddTaskGammaConversion
Modified code to include jet analysis

PWG4/GammaConv/AliAnalysisTaskGammaConversion.cxx
PWG4/GammaConv/AliAnalysisTaskGammaConversion.h
PWG4/GammaConv/AliGammaConversionAODObject.cxx [new file with mode: 0644]
PWG4/GammaConv/AliGammaConversionAODObject.h [new file with mode: 0644]
PWG4/GammaConv/AliGammaConversionHistograms.cxx
PWG4/GammaConv/AliGammaConversionHistograms.h
PWG4/PWG4GammaConvLinkDef.h
PWG4/libPWG4GammaConv.pkg
PWG4/macros/AddTaskGammaConversion.C [new file with mode: 0644]
PWG4/macros/ConfigGammaConversion.C

index 65a0b3bd77d7a5da3610e6fb793a67cb9890961e..38da271331080bacbf26f1e3501ec18febabb0a2 100644 (file)
-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- *                                                                        *\r
- * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt                        *\r
- * Version 1.1                                                            *\r
- *                                                                        *\r
- * Permission to use, copy, modify and distribute this software and its   *\r
- * documentation strictly for non-commercial purposes is hereby granted   *\r
- * without fee, provided that the above copyright notice appears in all   *\r
- * copies and that both the copyright notice and this permission notice   *\r
- * appear in the supporting documentation. The authors make no claims     *\r
- * about the suitability of this software for any purpose. It is          *\r
- * provided "as is" without express or implied warranty.                  *\r
- **************************************************************************/\r
-\r
-////////////////////////////////////////////////\r
-//--------------------------------------------- \r
-// Class used to do analysis on conversion pairs\r
-//---------------------------------------------\r
-////////////////////////////////////////////////\r
-\r
-// root\r
-#include <TChain.h>\r
-\r
-// analysis\r
-#include "AliAnalysisTaskGammaConversion.h"\r
-#include "AliStack.h"\r
-#include "AliLog.h"\r
-#include "TNtuple.h"\r
-\r
-class AliKFVertex;\r
-class AliAODHandler;\r
-class AliAODEvent;\r
-class ALiESDEvent;\r
-class AliMCEvent;\r
-class AliMCEventHandler;\r
-class AliESDInputHandler;\r
-class AliAnalysisManager;\r
-class Riostream;\r
-class TFile;\r
-class TInterpreter;\r
-class TSystem;\r
-class TROOT;\r
-\r
-ClassImp(AliAnalysisTaskGammaConversion)\r
-\r
-\r
-AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():\r
-AliAnalysisTaskSE(),\r
-  fV0Reader(NULL),\r
-  fStack(NULL),\r
-  fESDEvent(NULL),     \r
-  fOutputContainer(NULL),\r
-  fHistograms(NULL),\r
-  fDoMCTruth(kFALSE),\r
-  fMCAllGammas(),\r
-  fMCPi0s(),\r
-  fMCEtas(),\r
-  fMCGammaChic(),\r
-  fKFReconstructedGammas(),\r
-  fIsTrueReconstructedGammas(),\r
-  fElectronv1(),\r
-  fElectronv2(),\r
-  fCurrentEventPosElectron(),\r
-  fPreviousEventPosElectron(),\r
-  fCurrentEventNegElectron(),\r
-  fPreviousEventNegElectron(),\r
-  fKFReconstructedGammasCut(),                 \r
-  fPreviousEventTLVNegElectron(),\r
-  fPreviousEventTLVPosElectron(),      \r
-  fElectronMass(-1),\r
-  fGammaMass(-1),\r
-  fPi0Mass(-1),\r
-  fEtaMass(-1),\r
-  fGammaWidth(-1),\r
-  fPi0Width(-1),\r
-  fEtaWidth(-1),\r
-  fMinOpeningAngleGhostCut(0.),\r
-  fCalculateBackground(kFALSE),\r
-  fWriteNtuple(kFALSE),\r
-  fGammaNtuple(NULL),\r
-  fNeutralMesonNtuple(NULL),\r
-  fTotalNumberOfAddedNtupleEntries(0)\r
-{\r
-  // Default constructor\r
-  // Common I/O in slot 0\r
-  DefineInput (0, TChain::Class());\r
-  DefineOutput(0, TTree::Class());\r
-       \r
-  // Your private output\r
-  DefineOutput(1, TList::Class());\r
-}\r
-\r
-AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name):\r
-  AliAnalysisTaskSE(name),\r
-  fV0Reader(NULL),\r
-  fStack(NULL),\r
-  fESDEvent(NULL),     \r
-  fOutputContainer(0x0),\r
-  fHistograms(NULL),\r
-  fDoMCTruth(kFALSE),\r
-  fMCAllGammas(),\r
-  fMCPi0s(),\r
-  fMCEtas(),\r
-  fMCGammaChic(),\r
-  fKFReconstructedGammas(),\r
-  fIsTrueReconstructedGammas(),\r
-  fElectronv1(),\r
-  fElectronv2(),\r
-  fCurrentEventPosElectron(),\r
-  fPreviousEventPosElectron(),\r
-  fCurrentEventNegElectron(),\r
-  fPreviousEventNegElectron(),\r
-  fKFReconstructedGammasCut(), \r
-  fPreviousEventTLVNegElectron(),\r
-  fPreviousEventTLVPosElectron(),\r
-  fElectronMass(-1),\r
-  fGammaMass(-1),\r
-  fPi0Mass(-1),\r
-  fEtaMass(-1),\r
-  fGammaWidth(-1),\r
-  fPi0Width(-1),\r
-  fEtaWidth(-1),\r
-  fMinOpeningAngleGhostCut(0.),\r
-  fCalculateBackground(kFALSE),\r
-  fWriteNtuple(kFALSE),\r
-  fGammaNtuple(NULL),\r
-  fNeutralMesonNtuple(NULL),\r
-  fTotalNumberOfAddedNtupleEntries(0)\r
-{\r
-  // Common I/O in slot 0\r
-  DefineInput (0, TChain::Class());\r
-  DefineOutput(0, TTree::Class());\r
-       \r
-  // Your private output\r
-  DefineOutput(1, TList::Class());\r
-}\r
-\r
-AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion() \r
-{\r
-  // Remove all pointers\r
-       \r
-  if(fOutputContainer){\r
-    fOutputContainer->Clear() ; \r
-    delete fOutputContainer ;\r
-  }\r
-  if(fHistograms){\r
-    delete fHistograms;\r
-  }\r
-  if(fV0Reader){\r
-    delete fV0Reader;\r
-  }\r
-}\r
-\r
-\r
-void AliAnalysisTaskGammaConversion::Init()\r
-{\r
-  // Initialization\r
-  AliLog::SetGlobalLogLevel(AliLog::kError);\r
-}\r
-\r
-\r
-void AliAnalysisTaskGammaConversion::Exec(Option_t */*option*/)\r
-{\r
-  // Execute analysis for current event\r
-       \r
-  ConnectInputData("");\r
-       \r
-  //clear vectors\r
-  fMCAllGammas.clear();\r
-  fMCPi0s.clear();\r
-  fMCEtas.clear();\r
-  fMCGammaChic.clear();\r
-       \r
-  fKFReconstructedGammas.clear();\r
-  fIsTrueReconstructedGammas.clear();\r
-  fElectronv1.clear();\r
-  fElectronv2.clear();\r
-  fCurrentEventPosElectron.clear();\r
-  fCurrentEventNegElectron.clear();    \r
-  fKFReconstructedGammasCut.clear(); \r
-       \r
-  //Clear the data in the v0Reader\r
-  fV0Reader->UpdateEventByEventData();\r
-\r
-  \r
-  // Process the MC information\r
-  if(fDoMCTruth){\r
-    ProcessMCData();\r
-  }\r
-  \r
-  //Process the v0 information with no cuts\r
-  ProcessV0sNoCut();\r
-  \r
-  // Process the v0 information\r
-  ProcessV0s();\r
-  \r
-  //calculate background if flag is set\r
-  if(fCalculateBackground){\r
-    CalculateBackground();\r
-  }\r
-  \r
-  // Process reconstructed gammas\r
-  ProcessGammasForNeutralMesonAnalysis();\r
-\r
-  CheckV0Efficiency();\r
-  \r
-  //Process reconstructed gammas electrons for Chi_c Analysis\r
-  ProcessGammaElectronsForChicAnalysis();\r
-\r
-  PostData(1, fOutputContainer);\r
-       \r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t */*option*/){\r
-  // see header file for documentation\r
-       \r
-  if(fV0Reader == NULL){\r
-    // Write warning here cuts and so on are default if this ever happens\r
-  }\r
-  fV0Reader->Initialize();\r
-}\r
-\r
-\r
-\r
-void AliAnalysisTaskGammaConversion::ProcessMCData(){\r
-  // see header file for documentation\r
-       \r
-  fStack = fV0Reader->GetMCStack();\r
-\r
-  if(fV0Reader->CheckForPrimaryVertex() == kFALSE){\r
-    return; // aborts if the primary vertex does not have contributors.\r
-  }\r
-\r
-  for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {\r
-    TParticle* particle = (TParticle *)fStack->Particle(iTracks);\r
-               \r
-    if (!particle) {\r
-      //print warning here\r
-      continue;\r
-    }\r
-\r
-    ///////////////////////Begin Chic Analysis/////////////////////////////\r
-\r
-\r
-    if(particle->GetPdgCode() == 443){//Is JPsi\r
-\r
-      if(particle->GetNDaughters()==2){\r
-       if(TMath::Abs(fStack->Particle(particle->GetFirstDaughter())->GetPdgCode()) == 11 &&\r
-          TMath::Abs(fStack->Particle(particle->GetLastDaughter())->GetPdgCode()) == 11){\r
-         TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());\r
-         TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());\r
-         if(TMath::Abs(daug0->Eta()) < 0.9 && TMath::Abs(daug1->Eta()) < 0.9)\r
-           fHistograms->FillTable("Table_Electrons",3);//e+ e-  from J/Psi inside acceptance\r
-\r
-         if( TMath::Abs(daug0->Eta()) < 0.9){\r
-           if(daug0->GetPdgCode() == -11)\r
-             fHistograms->FillTable("Table_Electrons",1);//e+  from J/Psi inside acceptance\r
-           else\r
-             fHistograms->FillTable("Table_Electrons",2);//e-   from J/Psi inside acceptance\r
-\r
-         }\r
-         if(TMath::Abs(daug1->Eta()) < 0.9){\r
-           if(daug1->GetPdgCode() == -11)\r
-             fHistograms->FillTable("Table_Electrons",1);//e+  from J/Psi inside acceptance\r
-           else\r
-             fHistograms->FillTable("Table_Electrons",2);//e-   from J/Psi inside acceptance\r
-         }\r
-       }\r
-      }\r
-    }\r
-    //              const int CHI_C0   = 10441;\r
-    //              const int CHI_C1   = 20443;\r
-    //              const int CHI_C2   = 445\r
-    if(particle->GetPdgCode() == 22){//gamma from JPsi\r
-      if(particle->GetMother(0) > -1){\r
-       if(fStack->Particle(particle->GetMother(0))->GetPdgCode() == 10441 ||\r
-          fStack->Particle(particle->GetMother(0))->GetPdgCode() == 20443 ||\r
-          fStack->Particle(particle->GetMother(0))->GetPdgCode() == 445){\r
-         if(TMath::Abs(particle->Eta()) < 1.2)\r
-           fHistograms->FillTable("Table_Electrons",17);// gamma from chic inside accptance\r
-       }\r
-      }\r
-    }\r
-    if(particle->GetPdgCode() == 10441 || particle->GetPdgCode() == 20443 || particle->GetPdgCode() == 445){\r
-      if( particle->GetNDaughters() == 2){\r
-       TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());\r
-       TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());\r
-\r
-       if( (daug0->GetPdgCode() == 443 || daug0->GetPdgCode() == 22) && (daug1->GetPdgCode() == 443 || daug1->GetPdgCode() == 22) ){\r
-         if( daug0->GetPdgCode() == 443){\r
-           TParticle* daugE0 = fStack->Particle(daug0->GetFirstDaughter());\r
-           TParticle* daugE1 = fStack->Particle(daug0->GetLastDaughter());\r
-           if( TMath::Abs(daug1->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )\r
-             fHistograms->FillTable("Table_Electrons",18);\r
-\r
-         }//if\r
-         else if (daug1->GetPdgCode() == 443){\r
-           TParticle* daugE0 = fStack->Particle(daug1->GetFirstDaughter());\r
-           TParticle* daugE1 = fStack->Particle(daug1->GetLastDaughter());\r
-           if( TMath::Abs(daug0->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )\r
-             fHistograms->FillTable("Table_Electrons",18);\r
-         }//else if\r
-       }//gamma o Jpsi\r
-      }//GetNDaughters\r
-    }\r
-\r
-\r
-    /////////////////////End Chic Analysis////////////////////////////\r
-\r
-\r
-    if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() )   continue;\r
-                                       \r
-    if(particle->R()>fV0Reader->GetMaxRCut())  continue; // cuts on distance from collision point\r
-               \r
-    Double_t tmpPhi=particle->Phi();\r
-               \r
-    if(particle->Phi()> TMath::Pi()){\r
-      tmpPhi = particle->Phi()-(2*TMath::Pi());\r
-    }\r
-               \r
-    Double_t rapidity;\r
-    if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){\r
-      rapidity=0;\r
-    }\r
-    else{\r
-      rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));\r
-    }  \r
-               \r
-    //process the gammas\r
-    if (particle->GetPdgCode() == 22){\r
-                       \r
-      if(particle->GetMother(0) >-1 && fStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){\r
-       continue; // no photon as mothers!\r
-      }\r
-\r
-      if(particle->GetMother(0) >= fStack->GetNprimary()){\r
-       continue; // the gamma has a mother, and it is not a primary particle\r
-      }\r
-\r
-      fMCAllGammas.push_back(particle);\r
-                       \r
-      fHistograms->FillHistogram("MC_allGamma_Energy", particle->Energy());\r
-      fHistograms->FillHistogram("MC_allGamma_Pt", particle->Pt());\r
-      fHistograms->FillHistogram("MC_allGamma_Eta", particle->Eta());\r
-      fHistograms->FillHistogram("MC_allGamma_Phi", tmpPhi);\r
-      fHistograms->FillHistogram("MC_allGamma_Rapid", rapidity);\r
-                       \r
-                       \r
-      if(particle->GetMother(0) < 0){   // direct gamma\r
-       fHistograms->FillHistogram("MC_allDirectGamma_Energy",particle->Energy());\r
-       fHistograms->FillHistogram("MC_allDirectGamma_Pt", particle->Pt());\r
-       fHistograms->FillHistogram("MC_allDirectGamma_Eta", particle->Eta());\r
-       fHistograms->FillHistogram("MC_allDirectGamma_Phi", tmpPhi);\r
-       fHistograms->FillHistogram("MC_allDirectGamma_Rapid", rapidity);                                \r
-      }\r
-                       \r
-                       \r
-      // looking for conversion (electron + positron from pairbuilding (= 5) )\r
-      TParticle* ePos = NULL;\r
-      TParticle* eNeg = NULL;\r
-                       \r
-      if(particle->GetNDaughters() >= 2){\r
-       for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){\r
-         TParticle *tmpDaughter = fStack->Particle(daughterIndex);\r
-         if(tmpDaughter->GetUniqueID() == 5){\r
-           if(tmpDaughter->GetPdgCode() == 11){\r
-             eNeg = tmpDaughter;\r
-           }\r
-           else if(tmpDaughter->GetPdgCode() == -11){\r
-             ePos = tmpDaughter;\r
-           }\r
-         }\r
-       }\r
-      }\r
-                       \r
-                       \r
-      if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production\r
-       continue;\r
-      }\r
-                       \r
-                       \r
-      Double_t ePosPhi = ePos->Phi();\r
-      if(ePos->Phi()> TMath::Pi()) ePosPhi = ePos->Phi()-(2*TMath::Pi());\r
-                       \r
-      Double_t eNegPhi = eNeg->Phi();\r
-      if(eNeg->Phi()> TMath::Pi()) eNegPhi = eNeg->Phi()-(2*TMath::Pi());\r
-                       \r
-                       \r
-      if(ePos->Pt()<fV0Reader->GetPtCut() || eNeg->Pt()<fV0Reader->GetPtCut()){\r
-       continue; // no reconstruction below the Pt cut\r
-      }\r
-                                       \r
-      if(TMath::Abs(ePos->Eta())> fV0Reader->GetEtaCut() || TMath::Abs(eNeg->Eta())> fV0Reader->GetEtaCut()){\r
-       continue;\r
-      }        \r
-                               \r
-      if(ePos->R()>fV0Reader->GetMaxRCut()){\r
-       continue; // cuts on distance from collision point\r
-      }\r
-      \r
-      \r
-      if((TMath::Abs(ePos->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  > ePos->R()){\r
-       continue;               // line cut to exclude regions where we do not reconstruct\r
-      }                \r
-               \r
-      fHistograms->FillHistogram("MC_ConvGamma_Energy", particle->Energy());\r
-      fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());\r
-      fHistograms->FillHistogram("MC_ConvGamma_Eta", particle->Eta());\r
-      fHistograms->FillHistogram("MC_ConvGamma_Phi", tmpPhi);\r
-      fHistograms->FillHistogram("MC_ConvGamma_Rapid", rapidity);\r
-      fHistograms->FillHistogram("MC_ConvGamma_Pt_Eta", particle->Pt(),particle->Eta());\r
-                       \r
-      fHistograms->FillHistogram("MC_E_Energy", eNeg->Energy());\r
-      fHistograms->FillHistogram("MC_E_Pt", eNeg->Pt());\r
-      fHistograms->FillHistogram("MC_E_Eta", eNeg->Eta());\r
-      fHistograms->FillHistogram("MC_E_Phi", eNegPhi);\r
-                       \r
-      fHistograms->FillHistogram("MC_P_Energy", ePos->Energy());\r
-      fHistograms->FillHistogram("MC_P_Pt", ePos->Pt());\r
-      fHistograms->FillHistogram("MC_P_Eta", ePos->Eta());\r
-      fHistograms->FillHistogram("MC_P_Phi", ePosPhi);\r
-                       \r
-                       \r
-                       \r
-      //cout << "filled histos for converted gamma, ePos, eNeg" << endl;\r
-                       \r
-      // begin Mapping \r
-      Int_t rBin    = fHistograms->GetRBin(ePos->R());\r
-      Int_t phiBin  = fHistograms->GetPhiBin(particle->Phi());\r
-                       \r
-      TString nameMCMappingPhiR="";\r
-      nameMCMappingPhiR.Form("MC_Conversion_Mapping-Phi%02d-R%02d",phiBin,rBin);\r
-      fHistograms->FillHistogram(nameMCMappingPhiR, ePos->Vz(), particle->Eta());\r
-                       \r
-      TString nameMCMappingPhi="";\r
-      nameMCMappingPhi.Form("MC_Conversion_Mapping-Phi%02d",phiBin);\r
-      fHistograms->FillHistogram(nameMCMappingPhi, particle->Eta());\r
-                       \r
-      TString nameMCMappingR="";\r
-      nameMCMappingR.Form("MC_Conversion_Mapping-R%02d",rBin);\r
-      fHistograms->FillHistogram(nameMCMappingR, particle->Eta());\r
-                       \r
-      TString nameMCMappingPhiInR="";\r
-      nameMCMappingPhiInR.Form("MC_Conversion_Mapping_Phi_R-%02d",rBin);\r
-      fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);\r
-      //end mapping\r
-                       \r
-      fHistograms->FillHistogram("MC_Conversion_R",ePos->R());\r
-      fHistograms->FillHistogram("MC_Conversion_ZR",ePos->Vz(),ePos->R());\r
-      fHistograms->FillHistogram("MC_Conversion_XY",ePos->Vx(),ePos->Vy());\r
-      fHistograms->FillHistogram("MC_Conversion_OpeningAngle",GetMCOpeningAngle(ePos, eNeg));\r
-                       \r
-      //cout << "mapping is done" << endl;\r
-                       \r
-                       \r
-      if(particle->GetMother(0) < 0){ // no mother = direct gamma, still inside converted\r
-       fHistograms->FillHistogram("MC_ConvDirectGamma_Energy",particle->Energy());\r
-       fHistograms->FillHistogram("MC_ConvDirectGamma_Pt", particle->Pt());\r
-       fHistograms->FillHistogram("MC_ConvDirectGamma_Eta", particle->Eta());\r
-       fHistograms->FillHistogram("MC_ConvDirectGamma_Phi", tmpPhi);\r
-       fHistograms->FillHistogram("MC_ConvDirectGamma_Rapid", rapidity);\r
-                               \r
-      } // end direct gamma\r
-      else{   // mother exits \r
-       if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==10441 ||//chic0 \r
-           fStack->Particle(particle->GetMother(0))->GetPdgCode()==20443 ||//psi2S\r
-           fStack->Particle(particle->GetMother(0))->GetPdgCode()==445  //chic2\r
-           ){ \r
-         fMCGammaChic.push_back(particle);\r
-       }\r
-      }  // end if mother exits\r
-    } // end if particle is a photon\r
-               \r
-    if(particle->GetNDaughters() == 2){\r
-                       \r
-      TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());\r
-      TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());\r
-                       \r
-      if(daughter0->GetPdgCode() != 22 || daughter1->GetPdgCode() != 22) continue; //check for gamma gamma daughters\r
-                       \r
-                       \r
-                       \r
-      // check for conversions now -> have to pass eta and line cut!\r
-      Bool_t daughter0Electron = kFALSE;\r
-      Bool_t daughter0Positron = kFALSE;\r
-      Bool_t daughter1Electron = kFALSE;\r
-      Bool_t daughter1Positron = kFALSE;\r
-                       \r
-                       \r
-                       \r
-      if(daughter0->GetNDaughters() >= 2){\r
-       for(Int_t TrackIndex=daughter0->GetFirstDaughter();TrackIndex<=daughter0->GetLastDaughter();TrackIndex++){\r
-         TParticle *tmpDaughter = fStack->Particle(TrackIndex);\r
-         if(tmpDaughter->GetUniqueID() == 5){\r
-           if(tmpDaughter->GetPdgCode() == 11){\r
-             if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){\r
-               if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  < tmpDaughter->R() ){\r
-                 daughter0Electron = kTRUE;\r
-               }\r
-                                                               \r
-             }\r
-           }\r
-           else if(tmpDaughter->GetPdgCode() == -11){\r
-             if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){\r
-               if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  < tmpDaughter->R() ){\r
-                 daughter0Positron = kTRUE;\r
-               }\r
-                                                               \r
-             }\r
-                                                       \r
-           }\r
-         }\r
-       }\r
-      }\r
-                       \r
-                       \r
-       \r
-      if(daughter1->GetNDaughters() >= 2){\r
-       for(Int_t TrackIndex=daughter1->GetFirstDaughter();TrackIndex<=daughter1->GetLastDaughter();TrackIndex++){\r
-         TParticle *tmpDaughter = fStack->Particle(TrackIndex);\r
-         if(tmpDaughter->GetUniqueID() == 5){\r
-           if(tmpDaughter->GetPdgCode() == 11){\r
-             if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){\r
-               if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  < tmpDaughter->R() ){\r
-                 daughter1Electron = kTRUE;\r
-               }\r
-                                                               \r
-             }\r
-           }\r
-           else if(tmpDaughter->GetPdgCode() == -11){\r
-             if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){\r
-               if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  < tmpDaughter->R() ){\r
-                 daughter1Positron = kTRUE;\r
-               }\r
-                                                               \r
-             }\r
-                                                       \r
-           }\r
-         }\r
-       }\r
-      }\r
-                       \r
-                                                                                               \r
-                       \r
-                       \r
-      if(particle->GetPdgCode()==111){     //Pi0\r
-       if( iTracks >= fStack->GetNprimary()){\r
-         fHistograms->FillHistogram("MC_Pi0_Secondaries_Eta", particle->Eta());\r
-         fHistograms->FillHistogram("MC_Pi0_Secondaries_Rapid", rapidity);\r
-         fHistograms->FillHistogram("MC_Pi0_Secondaries_Phi", tmpPhi);\r
-         fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt", particle->Pt());\r
-         fHistograms->FillHistogram("MC_Pi0_Secondaries_Energy", particle->Energy());\r
-         fHistograms->FillHistogram("MC_Pi0_Secondaries_R", particle->R());\r
-         fHistograms->FillHistogram("MC_Pi0_Secondaries_ZR", particle->Vz(),particle->R());\r
-         fHistograms->FillHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));\r
-         fHistograms->FillHistogram("MC_Pi0_Secondaries_XY", particle->Vx(),particle->Vy());//only fill from one daughter to avoid multiple filling\r
-                                       \r
-         if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){\r
-           fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());\r
-           fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);\r
-           if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){\r
-             fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());\r
-             fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);\r
-           }\r
-         }\r
-       }\r
-       else{\r
-         fHistograms->FillHistogram("MC_Pi0_Eta", particle->Eta());    \r
-         fHistograms->FillHistogram("MC_Pi0_Rapid", rapidity);\r
-         fHistograms->FillHistogram("MC_Pi0_Phi", tmpPhi);\r
-         fHistograms->FillHistogram("MC_Pi0_Pt", particle->Pt());\r
-         fHistograms->FillHistogram("MC_Pi0_Energy", particle->Energy());\r
-         fHistograms->FillHistogram("MC_Pi0_R", particle->R());\r
-         fHistograms->FillHistogram("MC_Pi0_ZR", particle->Vz(),particle->R());\r
-         fHistograms->FillHistogram("MC_Pi0_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));\r
-         fHistograms->FillHistogram("MC_Pi0_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling\r
-                                       \r
-         if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){\r
-           fHistograms->FillHistogram("MC_Pi0_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());\r
-           fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);\r
-           if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){\r
-             fHistograms->FillHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());\r
-             fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);\r
-           }\r
-         }\r
-       }\r
-      }\r
-                       \r
-      if(particle->GetPdgCode()==221){   //Eta\r
-       fHistograms->FillHistogram("MC_Eta_Eta", particle->Eta());\r
-       fHistograms->FillHistogram("MC_Eta_Rapid", rapidity);\r
-       fHistograms->FillHistogram("MC_Eta_Phi",tmpPhi);\r
-       fHistograms->FillHistogram("MC_Eta_Pt", particle->Pt());\r
-       fHistograms->FillHistogram("MC_Eta_Energy", particle->Energy());\r
-       fHistograms->FillHistogram("MC_Eta_R", particle->R());\r
-       fHistograms->FillHistogram("MC_Eta_ZR", particle->Vz(),particle->R());\r
-       fHistograms->FillHistogram("MC_Eta_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));\r
-       fHistograms->FillHistogram("MC_Eta_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling\r
-                               \r
-       if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){\r
-         fHistograms->FillHistogram("MC_Eta_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());\r
-         fHistograms->FillHistogram("MC_Eta_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);\r
-         if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){\r
-           fHistograms->FillHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());\r
-           fHistograms->FillHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);\r
-         }\r
-                                       \r
-       }\r
-                               \r
-      }\r
-                       \r
-      // all motherparticles with 2 gammas as daughters\r
-      fHistograms->FillHistogram("MC_Mother_R", particle->R());\r
-      fHistograms->FillHistogram("MC_Mother_ZR", particle->Vz(),particle->R());\r
-      fHistograms->FillHistogram("MC_Mother_XY", particle->Vx(),particle->Vy());\r
-      fHistograms->FillHistogram("MC_Mother_Mass", particle->GetCalcMass());\r
-      fHistograms->FillHistogram("MC_Mother_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));\r
-      fHistograms->FillHistogram("MC_Mother_Energy", particle->Energy());\r
-      fHistograms->FillHistogram("MC_Mother_Pt", particle->Pt());\r
-      fHistograms->FillHistogram("MC_Mother_Eta", particle->Eta());\r
-      fHistograms->FillHistogram("MC_Mother_Rapid", rapidity);\r
-      fHistograms->FillHistogram("MC_Mother_Phi",tmpPhi);\r
-      fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt",particle->GetMass(),particle->Pt());                        \r
-      if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){\r
-       fHistograms->FillHistogram("MC_Mother_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());\r
-       fHistograms->FillHistogram("MC_Mother_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);\r
-       fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance",particle->GetMass(),particle->Pt());                      \r
-       if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){\r
-         fHistograms->FillHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());\r
-         fHistograms->FillHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);\r
-         fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance",particle->GetMass(),particle->Pt());                  \r
-\r
-       }\r
-                               \r
-                               \r
-      }\r
-                       \r
-      //cout << "mother histos are filled" << endl;\r
-                       \r
-    } // end if(particle->GetNDaughters() == 2)\r
-               \r
-  }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)\r
-       \r
-  //cout << "right before the end of processMCdata" << endl;\r
-       \r
-} // end ProcessMCData\r
-\r
-\r
-\r
-void AliAnalysisTaskGammaConversion::FillNtuple(){\r
-  //Fills the ntuple with the different values\r
-\r
-  if(fGammaNtuple == NULL){\r
-    return;\r
-  }\r
-  Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();\r
-  for(Int_t i=0;i<numberOfV0s;i++){\r
-    Float_t values[27] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\r
-    AliESDv0 * cV0 = fV0Reader->GetV0(i);\r
-    Double_t negPID=0;\r
-    Double_t posPID=0;\r
-    fV0Reader->GetPIDProbability(negPID,posPID);\r
-    values[0]=cV0->GetOnFlyStatus();\r
-    values[1]=fV0Reader->CheckForPrimaryVertex();\r
-    values[2]=negPID;\r
-    values[3]=posPID;\r
-    values[4]=fV0Reader->GetX();\r
-    values[5]=fV0Reader->GetY();\r
-    values[6]=fV0Reader->GetZ();\r
-    values[7]=fV0Reader->GetXYRadius();\r
-    values[8]=fV0Reader->GetMotherCandidateNDF();\r
-    values[9]=fV0Reader->GetMotherCandidateChi2();\r
-    values[10]=fV0Reader->GetMotherCandidateEnergy();\r
-    values[11]=fV0Reader->GetMotherCandidateEta();\r
-    values[12]=fV0Reader->GetMotherCandidatePt();\r
-    values[13]=fV0Reader->GetMotherCandidateMass();\r
-    values[14]=fV0Reader->GetMotherCandidateWidth();\r
-    //    values[15]=fV0Reader->GetMotherMCParticle()->Pt();   MOVED TO THE END, HAS TO BE CALLED AFTER HasSameMother NB: still has the same entry in the array\r
-    values[16]=fV0Reader->GetOpeningAngle();\r
-    values[17]=fV0Reader->GetNegativeTrackEnergy();\r
-    values[18]=fV0Reader->GetNegativeTrackPt();\r
-    values[19]=fV0Reader->GetNegativeTrackEta();\r
-    values[20]=fV0Reader->GetNegativeTrackPhi();\r
-    values[21]=fV0Reader->GetPositiveTrackEnergy();\r
-    values[22]=fV0Reader->GetPositiveTrackPt();\r
-    values[23]=fV0Reader->GetPositiveTrackEta();\r
-    values[24]=fV0Reader->GetPositiveTrackPhi();\r
-    values[25]=fV0Reader->HasSameMCMother();\r
-    if(values[25] != 0){\r
-      values[26]=fV0Reader->GetMotherMCParticlePDGCode();\r
-      values[15]=fV0Reader->GetMotherMCParticle()->Pt();\r
-    }\r
-    fTotalNumberOfAddedNtupleEntries++;\r
-    fGammaNtuple->Fill(values);\r
-  }\r
-  fV0Reader->ResetV0IndexNumber();\r
-       \r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){\r
-  // Process all the V0's without applying any cuts to it\r
-\r
-  Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();\r
-  for(Int_t i=0;i<numberOfV0s;i++){\r
-    /*AliESDv0 * cV0 = */fV0Reader->GetV0(i);\r
-\r
-    if(fV0Reader->CheckForPrimaryVertex() == kFALSE){\r
-      return;\r
-    }\r
-    \r
-    if(fDoMCTruth){\r
-      \r
-      if(fV0Reader->HasSameMCMother() == kFALSE){\r
-       continue;\r
-      }\r
-               \r
-      TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();\r
-      TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();\r
-\r
-      if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){\r
-       continue;\r
-      }\r
-      if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){\r
-       continue;\r
-      }\r
-       \r
-      if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){\r
-      \r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt", fV0Reader->GetMotherCandidatePt());\r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());\r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta", fV0Reader->GetMotherCandidateEta());                               \r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());\r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_Mass", fV0Reader->GetMotherCandidateMass());\r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_Width", fV0Reader->GetMotherCandidateWidth());\r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());\r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());\r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());\r
-       fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());\r
-       \r
-       fHistograms->FillHistogram("ESD_NoCutConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());\r
-       fHistograms->FillHistogram("ESD_NoCutConversion_R", fV0Reader->GetXYRadius());\r
-       fHistograms->FillHistogram("ESD_NoCutConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());\r
-       fHistograms->FillHistogram("ESD_NoCutConversion_OpeningAngle", fV0Reader->GetOpeningAngle());\r
-       \r
-       /*\r
-         ESD_NoCutConvGamma_Pt\r
-         ESD_NoCutConvGamma_Energy\r
-         ESD_NoCutConvGamma_Eta\r
-         ESD_NoCutConvGamma_Phi\r
-         ESD_NoCutConvGamma_Mass\r
-         ESD_NoCutConvGamma_Width\r
-         ESD_NoCutConvGamma_Chi2\r
-         ESD_NoCutConvGamma_NDF\r
-         ESD_NoCutConvGamma_PtvsEta\r
-         ESD_NoCutConversion_XY\r
-         ESD_NoCutConversion_R\r
-         ESD_NoCutConversion_ZR\r
-         ESD_NoCutConversion_OpeningAngle\r
-       */\r
-      }\r
-    }\r
-  }\r
-  fV0Reader->ResetV0IndexNumber();\r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::ProcessV0s(){\r
-  // see header file for documentation\r
-       \r
-  if(fWriteNtuple == kTRUE){\r
-    FillNtuple();\r
-  }\r
-       \r
-  Int_t nSurvivingV0s=0;\r
-  while(fV0Reader->NextV0()){\r
-    nSurvivingV0s++;\r
-               \r
-               \r
-    //-------------------------- filling v0 information -------------------------------------\r
-    fHistograms->FillHistogram("ESD_Conversion_R", fV0Reader->GetXYRadius());\r
-    fHistograms->FillHistogram("ESD_Conversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());\r
-    fHistograms->FillHistogram("ESD_Conversion_XY", fV0Reader->GetX(),fV0Reader->GetY());\r
-    fHistograms->FillHistogram("ESD_Conversion_OpeningAngle", fV0Reader->GetOpeningAngle());    \r
-               \r
-    fHistograms->FillHistogram("ESD_E_Energy", fV0Reader->GetNegativeTrackEnergy());\r
-    fHistograms->FillHistogram("ESD_E_Pt", fV0Reader->GetNegativeTrackPt());\r
-    fHistograms->FillHistogram("ESD_E_Eta", fV0Reader->GetNegativeTrackEta());\r
-    fHistograms->FillHistogram("ESD_E_Phi", fV0Reader->GetNegativeTrackPhi());\r
-               \r
-    fHistograms->FillHistogram("ESD_P_Energy", fV0Reader->GetPositiveTrackEnergy());\r
-    fHistograms->FillHistogram("ESD_P_Pt", fV0Reader->GetPositiveTrackPt());\r
-    fHistograms->FillHistogram("ESD_P_Eta", fV0Reader->GetPositiveTrackEta());\r
-    fHistograms->FillHistogram("ESD_P_Phi", fV0Reader->GetPositiveTrackPhi());\r
-               \r
-    fHistograms->FillHistogram("ESD_ConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());\r
-    fHistograms->FillHistogram("ESD_ConvGamma_Pt", fV0Reader->GetMotherCandidatePt());\r
-    fHistograms->FillHistogram("ESD_ConvGamma_Eta", fV0Reader->GetMotherCandidateEta());\r
-    fHistograms->FillHistogram("ESD_ConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());\r
-    fHistograms->FillHistogram("ESD_ConvGamma_Mass", fV0Reader->GetMotherCandidateMass());\r
-    fHistograms->FillHistogram("ESD_ConvGamma_Width", fV0Reader->GetMotherCandidateWidth());\r
-    fHistograms->FillHistogram("ESD_ConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());\r
-    fHistograms->FillHistogram("ESD_ConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());\r
-    fHistograms->FillHistogram("ESD_ConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());\r
-    fHistograms->FillHistogram("ESD_ConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());\r
-               \r
-               \r
-    // begin mapping\r
-    Int_t rBin    = fHistograms->GetRBin(fV0Reader->GetXYRadius());\r
-    Int_t phiBin  = fHistograms->GetPhiBin(fV0Reader->GetNegativeTrackPhi());\r
-    Double_t motherCandidateEta= fV0Reader->GetMotherCandidateEta();\r
-               \r
-    TString nameESDMappingPhiR="";\r
-    nameESDMappingPhiR.Form("ESD_Conversion_Mapping-Phi%02d-R%02d",phiBin,rBin);\r
-    fHistograms->FillHistogram(nameESDMappingPhiR, fV0Reader->GetZ(), motherCandidateEta);\r
-               \r
-    TString nameESDMappingPhi="";\r
-    nameESDMappingPhi.Form("ESD_Conversion_Mapping-Phi%02d",phiBin);\r
-    fHistograms->FillHistogram(nameESDMappingPhi, fV0Reader->GetZ(), motherCandidateEta);\r
-               \r
-    TString nameESDMappingR="";\r
-    nameESDMappingR.Form("ESD_Conversion_Mapping-R%02d",rBin);\r
-    fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);  \r
-               \r
-    TString nameESDMappingPhiInR="";\r
-    nameESDMappingPhiInR.Form("ESD_Conversion_Mapping_Phi_R-%02d",rBin);\r
-    fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());\r
-    // end mapping\r
-               \r
-    fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());\r
-    fElectronv1.push_back(fV0Reader->GetCurrentV0()->GetPindex());\r
-    fElectronv2.push_back(fV0Reader->GetCurrentV0()->GetNindex());\r
-\r
-               \r
-    //----------------------------------- checking for "real" conversions (MC match) --------------------------------------\r
-    if(fDoMCTruth){\r
-                       \r
-      if(fV0Reader->HasSameMCMother() == kFALSE){\r
-       fIsTrueReconstructedGammas.push_back(kFALSE);\r
-       continue;\r
-      }\r
-      \r
-               \r
-      TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();\r
-      TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();\r
-\r
-      if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){\r
-       fIsTrueReconstructedGammas.push_back(kFALSE);\r
-       continue;\r
-      }\r
-      if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){\r
-       fIsTrueReconstructedGammas.push_back(kFALSE);\r
-       continue;\r
-      }\r
-       \r
-      if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){\r
-       fIsTrueReconstructedGammas.push_back(kTRUE);\r
-                               \r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_Pt", fV0Reader->GetMotherCandidatePt());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_Eta", fV0Reader->GetMotherCandidateEta());                                \r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_Mass", fV0Reader->GetMotherCandidateMass());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_Width", fV0Reader->GetMotherCandidateWidth());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters(),fV0Reader->GetMotherCandidateMass());\r
-       fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters(),fV0Reader->GetMotherCandidateMass());\r
-       \r
-       fHistograms->FillHistogram("ESD_TrueConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());\r
-       fHistograms->FillHistogram("ESD_TrueConversion_R", fV0Reader->GetXYRadius());\r
-       fHistograms->FillHistogram("ESD_TrueConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());\r
-       fHistograms->FillHistogram("ESD_TrueConversion_OpeningAngle", fV0Reader->GetOpeningAngle());\r
-\r
-       \r
-       /*\r
-         fHistograms->FillHistogram("ESD_TrueConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());\r
-         fHistograms->FillHistogram("ESD_TrueConversion_R", fV0Reader->GetXYRadius());\r
-         fHistograms->FillHistogram("ESD_TrueConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());\r
-         fHistograms->FillHistogram("ESD_TrueConversion_OpeningAngle", fV0Reader->GetOpeningAngle());\r
-       */\r
-\r
-\r
-\r
-       //resolution\r
-       Double_t mcpt   = fV0Reader->GetMotherMCParticle()->Pt();\r
-       Double_t esdpt  = fV0Reader->GetMotherCandidatePt();\r
-       Double_t resdPt = 0;\r
-       if(mcpt != 0){\r
-         resdPt = ((esdpt - mcpt)/mcpt)*100;\r
-       }\r
-                               \r
-       fHistograms->FillHistogram("Resolution_dPt", mcpt, resdPt);\r
-       fHistograms->FillHistogram("Resolution_MC_Pt", mcpt);\r
-       fHistograms->FillHistogram("Resolution_ESD_Pt", esdpt);\r
-                               \r
-       Double_t resdZ = 0;\r
-       if(fV0Reader->GetNegativeMCParticle()->Vz() != 0){\r
-         resdZ = ((fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz())/fV0Reader->GetNegativeMCParticle()->Vz())*100;\r
-       }\r
-                               \r
-       fHistograms->FillHistogram("Resolution_dZ", fV0Reader->GetNegativeMCParticle()->Vz(), resdZ);\r
-       fHistograms->FillHistogram("Resolution_MC_Z", fV0Reader->GetNegativeMCParticle()->Vz());\r
-       fHistograms->FillHistogram("Resolution_ESD_Z", fV0Reader->GetZ());\r
-                               \r
-       Double_t resdR = 0;\r
-       if(fV0Reader->GetNegativeMCParticle()->R() != 0){\r
-         resdR = ((fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R())/fV0Reader->GetNegativeMCParticle()->R())*100;\r
-       }\r
-\r
-       fHistograms->FillHistogram("Resolution_dR", fV0Reader->GetNegativeMCParticle()->R(), resdR);\r
-       fHistograms->FillHistogram("Resolution_MC_R", fV0Reader->GetNegativeMCParticle()->R());\r
-       fHistograms->FillHistogram("Resolution_ESD_R", fV0Reader->GetXYRadius());\r
-       fHistograms->FillHistogram("Resolution_dR_dPt", resdR, resdPt);\r
-      }//if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22)\r
-      else{\r
-       fIsTrueReconstructedGammas.push_back(kFALSE);\r
-      }\r
-    }//if(fDoMCTruth)\r
-  }//while(fV0Reader->NextV0)\r
-  fHistograms->FillHistogram("ESD_NumberOfSurvivingV0s", nSurvivingV0s);\r
-  fHistograms->FillHistogram("ESD_NumberOfV0s", fV0Reader->GetNumberOfV0s());\r
-       \r
-  //cout << "nearly at the end of doMCTruth" << endl;\r
-       \r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){\r
-  // see header file for documentation\r
-       \r
-  for(UInt_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammas.size();firstGammaIndex++){\r
-    for(UInt_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammas.size();secondGammaIndex++){\r
-                       \r
-      AliKFParticle * twoGammaDecayCandidateDaughter0 = &fKFReconstructedGammas[firstGammaIndex];\r
-      AliKFParticle * twoGammaDecayCandidateDaughter1 = &fKFReconstructedGammas[secondGammaIndex];\r
-      \r
-      if(fElectronv1[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv1[firstGammaIndex]==fElectronv2[secondGammaIndex]){\r
-       continue;\r
-      }\r
-      if(fElectronv2[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv2[firstGammaIndex]==fElectronv2[secondGammaIndex]){\r
-       continue;\r
-      }\r
-\r
-      /*\r
-       if(fIsTrueReconstructedGammas[firstGammaIndex] == kFALSE || fIsTrueReconstructedGammas[secondGammaIndex] == kFALSE){\r
-       continue;\r
-       }\r
-      */\r
-\r
-      AliKFParticle *twoGammaCandidate = new AliKFParticle(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);\r
-                       \r
-      Double_t massTwoGammaCandidate = 0.;\r
-      Double_t widthTwoGammaCandidate = 0.;\r
-      Double_t chi2TwoGammaCandidate =10000.;  \r
-      twoGammaCandidate->GetMass(massTwoGammaCandidate,widthTwoGammaCandidate);\r
-      if(twoGammaCandidate->GetNDF()>0){\r
-       chi2TwoGammaCandidate = twoGammaCandidate->GetChi2()/twoGammaCandidate->GetNDF();\r
-                               \r
-       if(chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()){                                      \r
-                                       \r
-         TVector3 momentumVectorTwoGammaCandidate(twoGammaCandidate->GetPx(),twoGammaCandidate->GetPy(),twoGammaCandidate->GetPz());\r
-         TVector3 spaceVectorTwoGammaCandidate(twoGammaCandidate->GetX(),twoGammaCandidate->GetY(),twoGammaCandidate->GetZ());\r
-                                       \r
-         Double_t openingAngleTwoGammaCandidate = twoGammaDecayCandidateDaughter0->GetAngle(*twoGammaDecayCandidateDaughter1);                                 \r
-         Double_t rapidity;\r
-         if(twoGammaCandidate->GetE() - twoGammaCandidate->GetPz() == 0 || twoGammaCandidate->GetE() + twoGammaCandidate->GetPz() == 0){\r
-           rapidity=0;\r
-         }\r
-         else{\r
-           rapidity = 0.5*(TMath::Log((twoGammaCandidate->GetE() +twoGammaCandidate->GetPz()) / (twoGammaCandidate->GetE()-twoGammaCandidate->GetPz())));\r
-         }\r
-                                       \r
-         if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut) continue;   // minimum opening angle to avoid using ghosttracks\r
-\r
-         fHistograms->FillHistogram("ESD_Mother_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);\r
-         fHistograms->FillHistogram("ESD_Mother_Energy", twoGammaCandidate->GetE());\r
-         fHistograms->FillHistogram("ESD_Mother_Pt", momentumVectorTwoGammaCandidate.Pt());\r
-         fHistograms->FillHistogram("ESD_Mother_Eta", momentumVectorTwoGammaCandidate.Eta());\r
-         fHistograms->FillHistogram("ESD_Mother_Rapid", rapidity);                                     \r
-         fHistograms->FillHistogram("ESD_Mother_Phi", spaceVectorTwoGammaCandidate.Phi());\r
-         fHistograms->FillHistogram("ESD_Mother_Mass", massTwoGammaCandidate);\r
-         fHistograms->FillHistogram("ESD_Mother_R", spaceVectorTwoGammaCandidate.Pt());    // Pt in Space == R!!!\r
-         fHistograms->FillHistogram("ESD_Mother_ZR", twoGammaCandidate->GetZ(), spaceVectorTwoGammaCandidate.Pt());\r
-         fHistograms->FillHistogram("ESD_Mother_XY", twoGammaCandidate->GetX(), twoGammaCandidate->GetY());\r
-         fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());\r
-         fHistograms->FillHistogram("ESD_Mother_InvMass",massTwoGammaCandidate);\r
-       }\r
-      }\r
-      delete twoGammaCandidate;\r
-                       \r
-      //cout << "nearly at the end of processgamma for neutral meson ..." << endl;\r
-                       \r
-                       \r
-    }\r
-  }\r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::CalculateBackground(){\r
-  // see header file for documentation\r
-       \r
-  vector<AliKFParticle> vectorCurrentEventGoodV0s = fV0Reader->GetCurrentEventGoodV0s();\r
-  vector<AliKFParticle> vectorPreviousEventGoodV0s = fV0Reader->GetPreviousEventGoodV0s();\r
-  for(UInt_t iCurrent=0;iCurrent<vectorCurrentEventGoodV0s.size();iCurrent++){\r
-    AliKFParticle * currentEventGoodV0 = &vectorCurrentEventGoodV0s.at(iCurrent);\r
-    for(UInt_t iPrevious=0;iPrevious<vectorPreviousEventGoodV0s.size();iPrevious++){\r
-      AliKFParticle * previousGoodV0 = &vectorPreviousEventGoodV0s.at(iPrevious);\r
-\r
-      AliKFParticle *backgroundCandidate = new AliKFParticle(*currentEventGoodV0,*previousGoodV0);\r
-                       \r
-      Double_t massBG =0.;\r
-      Double_t widthBG = 0.;\r
-      Double_t chi2BG =10000.; \r
-      backgroundCandidate->GetMass(massBG,widthBG);\r
-      if(backgroundCandidate->GetNDF()>0){\r
-       chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();\r
-       if(chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()){\r
-                                       \r
-         TVector3 MomentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());\r
-         TVector3 SpaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());\r
-                                       \r
-         Double_t openingAngleBG = currentEventGoodV0->GetAngle(*previousGoodV0);\r
-\r
-         Double_t rapidity;\r
-         if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;\r
-         else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));\r
-\r
-                                       \r
-                                       \r
-                                       \r
-         if(openingAngleBG < fMinOpeningAngleGhostCut ) continue;   // minimum opening angle to avoid using ghosttracks\r
-                       \r
-                                       \r
-         fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);\r
-         fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());\r
-         fHistograms->FillHistogram("ESD_Background_Pt",  MomentumVectorbackgroundCandidate.Pt());\r
-         fHistograms->FillHistogram("ESD_Background_Eta", MomentumVectorbackgroundCandidate.Eta());\r
-         fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);\r
-         fHistograms->FillHistogram("ESD_Background_Phi", SpaceVectorbackgroundCandidate.Phi());\r
-         fHistograms->FillHistogram("ESD_Background_Mass", massBG);\r
-         fHistograms->FillHistogram("ESD_Background_R", SpaceVectorbackgroundCandidate.Pt());  // Pt in Space == R!!!!\r
-         fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), SpaceVectorbackgroundCandidate.Pt());\r
-         fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());\r
-         fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,MomentumVectorbackgroundCandidate.Pt());\r
-         fHistograms->FillHistogram("ESD_Background_InvMass",massBG);\r
-       }\r
-      }\r
-      delete backgroundCandidate;   \r
-      //cout << "nearly at the end of background" << endl;\r
-                       \r
-    }\r
-  }\r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::Terminate(Option_t */*option*/)\r
-{\r
-  // Terminate analysis\r
-  //\r
-  AliDebug(1,"Do nothing in Terminate");\r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()\r
-{\r
-  // Create the output container\r
-  if(fOutputContainer != NULL){\r
-    delete fOutputContainer;\r
-    fOutputContainer = NULL;\r
-  }\r
-  if(fOutputContainer == NULL){\r
-    fOutputContainer = new TList();\r
-  }\r
-       \r
-  //Adding the histograms to the output container\r
-  fHistograms->GetOutputContainer(fOutputContainer);\r
-       \r
-       \r
-  if(fWriteNtuple){\r
-    if(fGammaNtuple == NULL){\r
-      fGammaNtuple = new TNtuple("V0ntuple","V0ntuple","OnTheFly:HasVertex:NegPIDProb:PosPIDProb:X:Y:Z:R:MotherCandidateNDF:MotherCandidateChi2:MotherCandidateEnergy:MotherCandidateEta:MotherCandidatePt:MotherCandidateMass:MotherCandidateWidth:MCMotherCandidatePT:EPOpeningAngle:ElectronEnergy:ElectronPt:ElectronEta:ElectronPhi:PositronEnergy:PositronPt:PositronEta:PositronPhi:HasSameMCMother:MotherMCParticlePIDCode",50000);\r
-    }\r
-    if(fNeutralMesonNtuple == NULL){\r
-      fNeutralMesonNtuple = new TNtuple("NeutralMesonNtuple","NeutralMesonNtuple","test");\r
-    }\r
-    TList * ntupleTList = new TList();\r
-    ntupleTList->SetName("Ntuple");\r
-    ntupleTList->Add((TNtuple*)fGammaNtuple);\r
-    fOutputContainer->Add(ntupleTList);\r
-  }\r
-       \r
-  fOutputContainer->SetName(GetName());\r
-}\r
-\r
-Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(TParticle* const daughter0, TParticle* const daughter1) const{\r
-  //helper function\r
-  TVector3 v3D0(daughter0->Px(),daughter0->Py(),daughter0->Pz());\r
-  TVector3 v3D1(daughter1->Px(),daughter1->Py(),daughter1->Pz());\r
-  return v3D0.Angle(v3D1);\r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::CheckV0Efficiency(){\r
-  // see header file for documentation\r
-\r
-  vector<Int_t> indexOfGammaParticle;\r
-\r
-  fStack = fV0Reader->GetMCStack();\r
-\r
-  if(fV0Reader->CheckForPrimaryVertex() == kFALSE){\r
-    return; // aborts if the primary vertex does not have contributors.\r
-  }\r
-\r
-  for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {\r
-    TParticle* particle = (TParticle *)fStack->Particle(iTracks);\r
-    if(particle->GetPdgCode()==22){     //Gamma\r
-      if(particle->GetNDaughters() >= 2){\r
-       TParticle* electron=NULL;\r
-       TParticle* positron=NULL; \r
-       for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){\r
-         TParticle *tmpDaughter = fStack->Particle(daughterIndex);\r
-         if(tmpDaughter->GetUniqueID() == 5){\r
-           if(tmpDaughter->GetPdgCode() == 11){\r
-             electron = tmpDaughter;\r
-           }\r
-           else if(tmpDaughter->GetPdgCode() == -11){\r
-             positron = tmpDaughter;\r
-           }\r
-         }\r
-       }\r
-       if(electron!=NULL && positron!=0){\r
-         if(electron->R()<160){\r
-           indexOfGammaParticle.push_back(iTracks);\r
-         }\r
-       }\r
-      }\r
-    }\r
-  }\r
-\r
-  Int_t nFoundGammas=0;\r
-  Int_t nNotFoundGammas=0;\r
-\r
-  Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();\r
-  for(Int_t i=0;i<numberOfV0s;i++){\r
-    fV0Reader->GetV0(i);\r
-    \r
-    if(fV0Reader->HasSameMCMother() == kFALSE){\r
-      continue;\r
-    }\r
-    \r
-    TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();\r
-    TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();\r
-    \r
-    if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){\r
-      continue;\r
-    }\r
-    if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){\r
-      continue;\r
-    }\r
-    \r
-    if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){\r
-      //TParticle * v0Gamma = fV0Reader->GetMotherMCParticle();\r
-      for(UInt_t mcIndex=0;mcIndex<indexOfGammaParticle.size();mcIndex++){\r
-       if(negativeMC->GetFirstMother()==indexOfGammaParticle[mcIndex]){\r
-         nFoundGammas++;\r
-       }\r
-       else{\r
-         nNotFoundGammas++;\r
-       }\r
-      }\r
-    }\r
-  }\r
-  //  cout<<"Found: "<<nFoundGammas<<"  of: "<<indexOfGammaParticle.size()<<endl;\r
-}\r
-\r
-\r
-void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){\r
-  // see header file for documantation\r
-\r
-  fESDEvent = fV0Reader->GetESDEvent();\r
-\r
-\r
-  vector <AliESDtrack*> vESDeNegTemp(0);\r
-  vector <AliESDtrack*> vESDePosTemp(0);\r
-  vector <AliESDtrack*> vESDxNegTemp(0);\r
-  vector <AliESDtrack*> vESDxPosTemp(0);\r
-  vector <AliESDtrack*> vESDeNegNoJPsi(0);\r
-  vector <AliESDtrack*> vESDePosNoJPsi(0); \r
-\r
-\r
-\r
-  fHistograms->FillTable("Table_Electrons",0);//Count number of Events\r
-\r
-  for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){\r
-    AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);\r
-\r
-    if(!curTrack){\r
-      //print warning here\r
-      continue;\r
-    }\r
-\r
-    double p[3];if(!curTrack->GetConstrainedPxPyPz(p))continue;\r
-    double r[3];curTrack->GetConstrainedXYZ(r);\r
-\r
-    TVector3 rXYZ(r);\r
-\r
-    fHistograms->FillTable("Table_Electrons",4);//Count number of ESD tracks\r
-\r
-    Bool_t flagKink       =  kTRUE;\r
-    Bool_t flagTPCrefit   =  kTRUE;\r
-    Bool_t flagTRDrefit   =  kTRUE;\r
-    Bool_t flagITSrefit   =  kTRUE;\r
-    Bool_t flagTRDout     =  kTRUE;\r
-    Bool_t flagVertex     =  kTRUE;\r
-\r
-\r
-    //Cuts ---------------------------------------------------------------\r
-\r
-    if(curTrack->GetKinkIndex(0) > 0){\r
-      fHistograms->FillHistogram("Table_Electrons",5);//Count kink\r
-      flagKink = kFALSE;\r
-    }\r
-\r
-    ULong_t trkStatus = curTrack->GetStatus();\r
-\r
-    ULong_t tpcRefit = (trkStatus & AliESDtrack::kTPCrefit);\r
-\r
-    if(!tpcRefit){\r
-      fHistograms->FillHistogram("Table_Electrons",9);//Count not TPCrefit\r
-      flagTPCrefit = kFALSE;\r
-    }\r
-\r
-    ULong_t itsRefit = (trkStatus & AliESDtrack::kITSrefit);\r
-    if(!itsRefit){\r
-      fHistograms->FillHistogram("Table_Electrons",10);//Count not ITSrefit\r
-      flagITSrefit = kFALSE;\r
-    }\r
-\r
-    ULong_t trdRefit = (trkStatus & AliESDtrack::kTRDrefit);\r
-\r
-    if(!trdRefit){\r
-      fHistograms->FillHistogram("Table_Electrons",8); //Count not TRDrefit\r
-      flagTRDrefit = kFALSE;\r
-    }\r
-\r
-    ULong_t trdOut = (trkStatus & AliESDtrack::kTRDout);\r
-\r
-    if(!trdOut) {\r
-      fHistograms->FillHistogram("Table_Electrons",7); //Count not TRDout\r
-      flagTRDout = kFALSE;\r
-    }\r
-\r
-    double nsigmaToVxt = GetSigmaToVertex(curTrack);\r
-\r
-    if(nsigmaToVxt > 3){\r
-      fHistograms->FillHistogram("Table_Electrons",6); //Count Tracks with number of sigmas > 3\r
-      flagVertex = kFALSE;\r
-    }\r
-\r
-    if(! (flagKink && flagTPCrefit && flagITSrefit && flagTRDrefit && flagTRDout && flagVertex ) ) continue;\r
-    fHistograms->FillHistogram("Table_Electrons",11);//Count Tracks passed Cuts\r
-\r
-\r
-    Stat_t pid, weight;\r
-    GetPID(curTrack, pid, weight);\r
-\r
-    if(pid!=0){\r
-      fHistograms->FillHistogram("Table_Electrons",12); //Count Tracks with pid != 0\r
-    }\r
-\r
-    if(pid == 0){\r
-      fHistograms->FillHistogram("Table_Electrons",13); //Count Tracks with pid != 0\r
-    }\r
-\r
-\r
-\r
-\r
-    Int_t labelMC = TMath::Abs(curTrack->GetLabel());\r
-    TParticle* curParticle = fStack->Particle(labelMC);\r
-\r
-\r
-\r
-\r
-    TLorentzVector curElec;\r
-    curElec.SetXYZM(p[0],p[1],p[2],fElectronMass);\r
-\r
-\r
-\r
-\r
-    if(curTrack->GetSign() > 0){\r
-\r
-      vESDxPosTemp.push_back(curTrack);\r
-\r
-      if( pid == 0){\r
-\r
-       fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());\r
-       fHistograms->FillHistogram("ESD_ElectronPosPt",curElec.Pt());\r
-       fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());\r
-       fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());\r
-       fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());\r
-       vESDePosTemp.push_back(curTrack);\r
-\r
-\r
-\r
-      }\r
-\r
-    }\r
-    else {\r
-      vESDxNegTemp.push_back(curTrack);\r
-\r
-      if( pid == 0){\r
-\r
-       fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());\r
-       fHistograms->FillHistogram("ESD_ElectronNegPt",curElec.Pt());\r
-       fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());\r
-       fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());\r
-       fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());\r
-       vESDeNegTemp.push_back(curTrack);\r
-\r
-\r
-\r
-\r
-      }\r
-    }\r
-\r
-  }\r
-\r
-\r
-  Bool_t ePosJPsi = kFALSE;\r
-  Bool_t eNegJPsi = kFALSE;            \r
-  Bool_t ePosPi0  = kFALSE;\r
-  Bool_t eNegPi0  = kFALSE;\r
-       \r
-  UInt_t iePosJPsi=0,ieNegJPsi=0,iePosPi0=0,ieNegPi0=0;\r
\r
-  for(UInt_t iNeg=0; iNeg < vESDeNegTemp.size(); iNeg++){\r
-    if(fStack->Particle(TMath::Abs(vESDeNegTemp[iNeg]->GetLabel()))->GetPdgCode() == 11)\r
-      if(fStack->Particle(TMath::Abs(vESDeNegTemp[iNeg]->GetLabel()))->GetMother(0) > -1){\r
-       Int_t labelMother = fStack->Particle(TMath::Abs(vESDeNegTemp[iNeg]->GetLabel()))->GetMother(0);\r
-       TParticle* partMother = fStack ->Particle(labelMother);\r
-       if (partMother->GetPdgCode() == 111){\r
-         ieNegPi0 = iNeg;\r
-         eNegPi0 = kTRUE;\r
-       }\r
-       if(partMother->GetPdgCode() == 443){ //Mother JPsi\r
-         fHistograms->FillTable("Table_Electrons",14);\r
-         ieNegJPsi = iNeg;\r
-         eNegJPsi = kTRUE;\r
-       }\r
-       else{   \r
-         vESDeNegNoJPsi.push_back(vESDeNegTemp[iNeg]);\r
-         //            cout<<"ESD No Positivo JPsi "<<endl;\r
-       }\r
-\r
-      }\r
-  }    \r
-\r
-  for(UInt_t iPos=0; iPos < vESDePosTemp.size(); iPos++){\r
-    if(fStack->Particle(TMath::Abs(vESDePosTemp[iPos]->GetLabel()))->GetPdgCode() == -11)\r
-      if(fStack->Particle(TMath::Abs(vESDePosTemp[iPos]->GetLabel()))->GetMother(0) > -1){\r
-       Int_t labelMother = fStack->Particle(TMath::Abs(vESDePosTemp[iPos]->GetLabel()))->GetMother(0);\r
-       TParticle* partMother = fStack ->Particle(labelMother);\r
-       if (partMother->GetPdgCode() == 111){\r
-         iePosPi0 = iPos;\r
-         ePosPi0 = kTRUE;\r
-       }\r
-       if(partMother->GetPdgCode() == 443){ //Mother JPsi\r
-         fHistograms->FillTable("Table_Electrons",15);\r
-         iePosJPsi = iPos;\r
-         ePosJPsi = kTRUE;\r
-       }\r
-       else{\r
-         vESDePosNoJPsi.push_back(vESDePosTemp[iPos]);\r
-         //            cout<<"ESD No Negativo JPsi "<<endl;\r
-       }\r
-\r
-      }\r
-  }\r
-       \r
-  if( eNegJPsi && ePosJPsi ){\r
-    TVector3 tempeNegV,tempePosV;\r
-    tempeNegV.SetXYZ(vESDeNegTemp[ieNegJPsi]->Px(),vESDeNegTemp[ieNegJPsi]->Py(),vESDeNegTemp[ieNegJPsi]->Pz());                       \r
-    tempePosV.SetXYZ(vESDePosTemp[iePosJPsi]->Px(),vESDePosTemp[iePosJPsi]->Py(),vESDePosTemp[iePosJPsi]->Pz());\r
-    fHistograms->FillTable("Table_Electrons",16);\r
-    fHistograms->FillHistogram("ESD_ElectronPosNegJPsiAngle",tempeNegV.Angle(tempePosV));      \r
-    fHistograms->FillHistogram("MC_ElectronPosNegJPsiAngle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(vESDeNegTemp[ieNegJPsi]->GetLabel())),\r
-                                                                             fStack->Particle(TMath::Abs(vESDePosTemp[iePosJPsi]->GetLabel()))));      \r
-  }\r
-       \r
-  if( eNegPi0 && ePosPi0 ){\r
-    TVector3 tempeNegV,tempePosV;\r
-    tempeNegV.SetXYZ(vESDeNegTemp[ieNegPi0]->Px(),vESDeNegTemp[ieNegPi0]->Py(),vESDeNegTemp[ieNegPi0]->Pz());\r
-    tempePosV.SetXYZ(vESDePosTemp[iePosPi0]->Px(),vESDePosTemp[iePosPi0]->Py(),vESDePosTemp[iePosPi0]->Pz());\r
-    fHistograms->FillHistogram("ESD_ElectronPosNegPi0Angle",tempeNegV.Angle(tempePosV));\r
-    fHistograms->FillHistogram("MC_ElectronPosNegPi0Angle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(vESDeNegTemp[ieNegPi0]->GetLabel())),\r
-                                                                            fStack->Particle(TMath::Abs(vESDePosTemp[iePosPi0]->GetLabel()))));   \r
-  }\r
-        \r
-\r
-  FillAngle("ESD_eNegePosAngleBeforeCut",GetTLorentzVector(vESDeNegTemp),GetTLorentzVector(vESDePosTemp));\r
-\r
-  CleanWithAngleCuts(vESDeNegTemp,vESDePosTemp,fKFReconstructedGammas);\r
-       \r
-  vector <TLorentzVector> vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectron);\r
-  vector <TLorentzVector> vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectron);\r
-\r
-\r
-  FillAngle("ESD_eNegePosAngleAfterCut",vCurrentTLVeNeg,vCurrentTLVePos);\r
-\r
\r
-\r
-\r
-  //FillAngle("ESD_eNegePosAngleAfterCut",CurrentTLVeNeg,CurrentTLVePos);\r
-\r
-\r
-  FillElectronInvMass("ESD_InvMass_ePluseMinus",vCurrentTLVeNeg,vCurrentTLVePos);\r
-  FillElectronInvMass("ESD_InvMass_xPlusxMinus",GetTLorentzVector(vESDxNegTemp),GetTLorentzVector(vESDxPosTemp));\r
-\r
-       \r
-\r
-  FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusChiC","ESD_InvMass_GammaePluseMinusChiCDiff",\r
-                          fKFReconstructedGammasCut,vCurrentTLVeNeg,vCurrentTLVePos);\r
-\r
-  FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusPi0","ESD_InvMass_GammaePluseMinusPi0Diff",\r
-                          fKFReconstructedGammasCut,vCurrentTLVeNeg,vCurrentTLVePos);\r
-\r
-  //BackGround\r
-\r
-  //Like Sign e+e-\r
-  ElectronBackground("ESD_ENegBackground",vCurrentTLVeNeg);\r
-  ElectronBackground("ESD_EPosBackground",vCurrentTLVePos);\r
-  ElectronBackground("ESD_EPosENegBackground",vCurrentTLVeNeg);\r
-  ElectronBackground("ESD_EPosENegBackground",vCurrentTLVePos);\r
-\r
-  //        Like Sign e+e- no JPsi\r
-  ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDeNegNoJPsi));\r
-  ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDePosNoJPsi));\r
-\r
-  //Mixed Event\r
-\r
-  if( fCurrentEventPosElectron.size() > 0 && fCurrentEventNegElectron.size() > 0 && fKFReconstructedGammasCut.size() > 0 ){\r
-    FillGammaElectronInvMass("ESD_EPosENegGammaBackgroundMX","ESD_EPosENegGammaBackgroundMXDiff",\r
-                            fKFReconstructedGammasCut,fPreviousEventTLVNegElectron,fPreviousEventTLVPosElectron);\r
-    fPreviousEventTLVNegElectron = vCurrentTLVeNeg;\r
-    fPreviousEventTLVPosElectron = vCurrentTLVePos;\r
-\r
-  }\r
-\r
-  /*\r
-  //Photons P\r
-  Double_t vtx[3];\r
-  vtx[0]=0;vtx[1]=0;vtx[2]=0;\r
-  for(UInt_t i=0;i<fKFReconstructedGammasChic.size();i++){\r
-\r
-  //      if(fMCGammaChicTempCut[i]->GetMother(0) < 0) continue;\r
-\r
-\r
-\r
-  Int_t tempLabel = fStack->Particle(fMCGammaChicTempCut[i]->GetMother(0))->GetPdgCode();\r
-  //      cout<<" Label Pedro Gonzalez " <<tempLabel <<endl;\r
-\r
-  //      cout<<" Label Distance"<<fKFReconstructedGammasChic[i].GetDistanceFromVertex(vtx)<<endl;\r
-\r
-  if( tempLabel == 10441 || tempLabel == 20443 || tempLabel == 445 )\r
-\r
-  fHistograms->FillHistogram("ESD_PhotonsMomentum",fKFReconstructedGammasChic[i].GetMomentum());\r
-\r
-\r
-  }\r
-\r
-\r
-  */\r
-\r
-\r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,vector <TLorentzVector> tlVeNeg, vector <TLorentzVector> tlVePos){\r
-  //see header file for documentation\r
-  for( UInt_t iNeg=0; iNeg < tlVeNeg.size(); iNeg++){\r
-    for (UInt_t iPos=0; iPos < tlVePos.size(); iPos++){\r
-      fHistograms->FillHistogram(histoName.Data(),tlVeNeg[iNeg].Vect().Angle(tlVePos[iPos].Vect()));\r
-    }\r
-  }\r
-}\r
-void AliAnalysisTaskGammaConversion::FillElectronInvMass(TString histoName, vector <TLorentzVector> eNeg, vector <TLorentzVector> ePos){\r
-  //see header file for documentation\r
-  for( UInt_t n=0; n < eNeg.size(); n++){\r
-\r
-    TLorentzVector en = eNeg.at(n);\r
-    for (UInt_t p=0; p < ePos.size(); p++){\r
-      TLorentzVector ep = ePos.at(p);\r
-      TLorentzVector np = ep + en;\r
-      fHistograms->FillHistogram(histoName.Data(),np.M());\r
-    }\r
-  }\r
-\r
-}\r
-\r
-void AliAnalysisTaskGammaConversion::FillGammaElectronInvMass(TString histoMass,TString histoDiff,vector <AliKFParticle> fKFGammas,\r
-                                                             vector <TLorentzVector> tlVeNeg,vector<TLorentzVector> tlVePos)\r
-{\r
-  //see header file for documentation\r
-\r
-  for( UInt_t iNeg=0; iNeg < tlVeNeg.size(); iNeg++ ){\r
-\r
-    for (UInt_t iPos=0; iPos < tlVePos.size(); iPos++){\r
-\r
-      TLorentzVector xy = tlVePos[iPos] + tlVeNeg[iNeg];\r
-\r
-      for (UInt_t iGam=0; iGam < fKFGammas.size(); iGam++){\r
-\r
-       AliKFParticle * gammaCandidate = &fKFGammas[iGam];\r
-       TLorentzVector g;\r
-\r
-       g.SetXYZM(gammaCandidate->GetPx(),gammaCandidate->GetPy(),gammaCandidate->GetPz(),fGammaMass);\r
-       TLorentzVector xyg = xy + g;\r
-       fHistograms->FillHistogram(histoMass.Data(),xyg.M());\r
-       fHistograms->FillHistogram(histoDiff.Data(),(xyg.M()-xy.M()));\r
-      }\r
-    }\r
-  }\r
-\r
-}\r
-void AliAnalysisTaskGammaConversion::ElectronBackground(TString hBg, vector <TLorentzVector> e)\r
-{\r
-  // see header file for documentation\r
-  for(UInt_t i=0; i < e.size(); i++)\r
-    {\r
-      for (UInt_t j=i+1; j < e.size(); j++)\r
-       {\r
-         TLorentzVector ee = e[i] + e[j];\r
-\r
-         fHistograms->FillHistogram(hBg.Data(),ee.M());\r
-       }\r
-    }\r
-}\r
-\r
-\r
-void AliAnalysisTaskGammaConversion::CleanWithAngleCuts(vector <AliESDtrack*> negativeElectrons,\r
-                                                       vector <AliESDtrack*> positiveElectrons, vector <AliKFParticle> gammas){\r
-  // see header file for documentation\r
-\r
-  UInt_t  sizeN = negativeElectrons.size();\r
-  UInt_t  sizeP = positiveElectrons.size();\r
-  UInt_t  sizeG = gammas.size();\r
-\r
-\r
-\r
-  vector <Bool_t> xNegBand(sizeN);\r
-  vector <Bool_t> xPosBand(sizeP);\r
-  vector <Bool_t> gammaBand(sizeG);\r
-\r
-\r
-  for(UInt_t iNeg=0; iNeg < sizeN; iNeg++) xNegBand[iNeg]=kTRUE;\r
-  for(UInt_t iPos=0; iPos < sizeP; iPos++) xPosBand[iPos]=kTRUE;\r
-  for(UInt_t iGam=0; iGam < sizeG; iGam++) gammaBand[iGam]=kTRUE;\r
-\r
-\r
-  for(UInt_t iPos=0; iPos < sizeP; iPos++){\r
-       \r
-    Double_t aP[3]; positiveElectrons[iPos]->GetConstrainedPxPyPz(aP); \r
-\r
-    TVector3 ePosV(aP[0],aP[1],aP[2]);\r
-\r
-    for(UInt_t iNeg=0; iNeg < sizeN; iNeg++){\r
-       \r
-      Double_t aN[3]; negativeElectrons[iNeg]->GetConstrainedPxPyPz(aN); \r
-      TVector3 eNegV(aN[0],aN[1],aN[2]);\r
-\r
-      if(ePosV.Angle(eNegV) < 0.05){ //e+e- from gamma\r
-       xPosBand[iPos]=kFALSE;\r
-       xNegBand[iNeg]=kFALSE;\r
-      }\r
-\r
-      for(UInt_t iGam=0; iGam < sizeG; iGam++){\r
-       AliKFParticle* gammaCandidate = &gammas[iGam];\r
-       TVector3 gammaCandidateVector(gammaCandidate->Px(),gammaCandidate->Py(),gammaCandidate->Pz());\r
-       if(ePosV.Angle(gammaCandidateVector) < 0.05 || eNegV.Angle(gammaCandidateVector) < 0.05)\r
-         gammaBand[iGam]=kFALSE;\r
-      }\r
-    }\r
-  }\r
-\r
-\r
-\r
-\r
-  for(UInt_t iPos=0; iPos < sizeP; iPos++){\r
-    if(xPosBand[iPos]){\r
-      fCurrentEventPosElectron.push_back(positiveElectrons[iPos]);\r
-    }\r
-  }\r
-  for(UInt_t iNeg=0;iNeg < sizeN; iNeg++){\r
-    if(xNegBand[iNeg]){\r
-      fCurrentEventNegElectron.push_back(negativeElectrons[iNeg]);\r
-    }\r
-  }\r
-  for(UInt_t iGam=0; iGam < sizeG; iGam++){\r
-    if(gammaBand[iGam]){\r
-      fKFReconstructedGammasCut.push_back(gammas[iGam]);\r
-    }\r
-  }\r
-}\r
-\r
-\r
-void  AliAnalysisTaskGammaConversion::GetPID(AliESDtrack *track, Stat_t &pid, Stat_t &weight)\r
-{\r
-  // see header file for documentation\r
-  pid = -1;\r
-  weight = -1;\r
-\r
-  double wpart[5];\r
-  double wpartbayes[5];\r
-\r
-  //get probability of the diffenrent particle types\r
-  track->GetESDpid(wpart);\r
-\r
-  // Tentative particle type "concentrations"\r
-  double c[5]={0.01, 0.01, 0.85, 0.10, 0.05};\r
-\r
-  //Bayes' formula\r
-  double rcc = 0.;\r
-  for (int i = 0; i < 5; i++)\r
-    {\r
-      rcc+=(c[i] * wpart[i]);\r
-    }\r
-\r
-\r
-\r
-  for (int i=0; i<5; i++) {\r
-    if( rcc!=0){\r
-      wpartbayes[i] = c[i] * wpart[i] / rcc;\r
-    }\r
-  }\r
-\r
-\r
-\r
-  Float_t max=0.;\r
-  int ipid=-1;\r
-  //find most probable particle in ESD pid\r
-  //0:Electron - 1:Muon - 2:Pion - 3:Kaon - 4:Proton\r
-  for (int i = 0; i < 5; i++)\r
-    {\r
-      if (wpartbayes[i] > max)\r
-        {\r
-          ipid = i;\r
-          max = wpartbayes[i];\r
-        }\r
-    }\r
-\r
-  pid = ipid;\r
-  weight = max;\r
-}\r
-double AliAnalysisTaskGammaConversion::GetSigmaToVertex(AliESDtrack* t)\r
-{\r
-  // Calculates the number of sigma to the vertex.\r
-\r
-  Float_t b[2];\r
-  Float_t bRes[2];\r
-  Float_t bCov[3];\r
-  t->GetImpactParameters(b,bCov);\r
-  if (bCov[0]<=0 || bCov[2]<=0) {\r
-    AliDebug(1, "Estimated b resolution lower or equal zero!");\r
-    bCov[0]=0; bCov[2]=0;\r
-  }\r
-  bRes[0] = TMath::Sqrt(bCov[0]);\r
-  bRes[1] = TMath::Sqrt(bCov[2]);\r
-\r
-  // -----------------------------------\r
-  // How to get to a n-sigma cut?\r
-  //\r
-  // The accumulated statistics from 0 to d is\r
-  //\r
-  // ->  Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)\r
-  // ->  1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)\r
-  //\r
-  // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)\r
-  // Can this be expressed in a different way?\r
-\r
-  if (bRes[0] == 0 || bRes[1] ==0)\r
-    return -1;\r
-\r
-  double d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));\r
-\r
-  // stupid rounding problem screws up everything:\r
-  // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(\r
-  if (TMath::Exp(-d * d / 2) < 1e-10)\r
-    return 1000;\r
-\r
-\r
-  d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);\r
-  return d;\r
-}\r
-vector <TLorentzVector> AliAnalysisTaskGammaConversion::GetTLorentzVector(vector <AliESDtrack*> esdTrack){\r
-\r
-  vector <TLorentzVector> tlVtrack(0);\r
-\r
-  for(UInt_t itrack=0; itrack < esdTrack.size(); itrack++){\r
-    double P[3]; esdTrack[itrack]->GetConstrainedPxPyPz(P);\r
-    TLorentzVector currentTrack;\r
-    currentTrack.SetXYZM(P[0],P[1],P[2],fElectronMass);\r
-    tlVtrack.push_back(currentTrack);\r
-  }\r
-\r
-  return tlVtrack;\r
-}\r
-\r
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt                        *
+ * Version 1.1                                                            *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class used to do analysis on conversion pairs
+//---------------------------------------------
+////////////////////////////////////////////////
+
+// root
+#include <TChain.h>
+
+// analysis
+#include "AliAnalysisTaskGammaConversion.h"
+#include "AliStack.h"
+#include "AliLog.h"
+#include "AliESDtrackCuts.h"
+#include "TNtuple.h"
+
+class AliKFVertex;
+class AliAODHandler;
+class AliAODEvent;
+class ALiESDEvent;
+class AliMCEvent;
+class AliMCEventHandler;
+class AliESDInputHandler;
+class AliAnalysisManager;
+class Riostream;
+class TFile;
+class TInterpreter;
+class TSystem;
+class TROOT;
+
+ClassImp(AliAnalysisTaskGammaConversion)
+
+
+AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
+AliAnalysisTaskSE(),
+  fV0Reader(NULL),
+  fStack(NULL),
+  fESDEvent(NULL),     
+  fOutputContainer(NULL),
+  fHistograms(NULL),
+  fDoMCTruth(kFALSE),
+  fDoNeutralMeson(kFALSE),
+  fDoJet(kFALSE),
+  fDoChic(kFALSE),
+  fMCAllGammas(),
+  fMCPi0s(),
+  fMCEtas(),
+  fMCGammaChic(),
+  fKFReconstructedGammas(),
+  fIsTrueReconstructedGammas(),
+  fElectronv1(),
+  fElectronv2(),
+  fCurrentEventPosElectron(),
+  fPreviousEventPosElectron(),
+  fCurrentEventNegElectron(),
+  fPreviousEventNegElectron(),
+  fKFReconstructedGammasCut(),                 
+  fPreviousEventTLVNegElectron(),
+  fPreviousEventTLVPosElectron(),      
+  fElectronMass(-1),
+  fGammaMass(-1),
+  fPi0Mass(-1),
+  fEtaMass(-1),
+  fGammaWidth(-1),
+  fPi0Width(-1),
+  fEtaWidth(-1),
+  fMinOpeningAngleGhostCut(0.),
+  fEsdTrackCuts(0),
+  fCalculateBackground(kFALSE),
+  fWriteNtuple(kFALSE),
+  fGammaNtuple(NULL),
+  fNeutralMesonNtuple(NULL),
+  fTotalNumberOfAddedNtupleEntries(0),
+  fChargedParticles(),
+  fChargedParticlesId(),
+  fGammaPtHighest(0.),
+  fMinPtForGammaJet(1.),
+  fMinIsoConeSize(0.2),
+  fMinPtIsoCone(0.7),
+  fMinPtGamChargedCorr(0.5),
+  fMinPtJetCone(0.5),
+  fLeadingChargedIndex(-1),
+  fAODBranch(NULL),
+  fAODBranchName("GammaConv"),
+  fAODObjects()
+{
+  // Default constructor
+  // Common I/O in slot 0
+  DefineInput (0, TChain::Class());
+  DefineOutput(0, TTree::Class());
+       
+  // Your private output
+  DefineOutput(1, TList::Class());
+
+  // Define standard ESD track cuts for Gamma-hadron correlation 
+  SetESDtrackCuts();
+}
+
+AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name):
+  AliAnalysisTaskSE(name),
+  fV0Reader(NULL),
+  fStack(NULL),
+  fESDEvent(NULL),     
+  fOutputContainer(0x0),
+  fHistograms(NULL),
+  fDoMCTruth(kFALSE),
+  fDoNeutralMeson(kFALSE),
+  fDoJet(kFALSE),
+  fDoChic(kFALSE),
+  fMCAllGammas(),
+  fMCPi0s(),
+  fMCEtas(),
+  fMCGammaChic(),
+  fKFReconstructedGammas(),
+  fIsTrueReconstructedGammas(),
+  fElectronv1(),
+  fElectronv2(),
+  fCurrentEventPosElectron(),
+  fPreviousEventPosElectron(),
+  fCurrentEventNegElectron(),
+  fPreviousEventNegElectron(),
+  fKFReconstructedGammasCut(), 
+  fPreviousEventTLVNegElectron(),
+  fPreviousEventTLVPosElectron(),
+  fElectronMass(-1),
+  fGammaMass(-1),
+  fPi0Mass(-1),
+  fEtaMass(-1),
+  fGammaWidth(-1),
+  fPi0Width(-1),
+  fEtaWidth(-1),
+  fMinOpeningAngleGhostCut(0.),
+  fEsdTrackCuts(0),
+  fCalculateBackground(kFALSE),
+  fWriteNtuple(kFALSE),
+  fGammaNtuple(NULL),
+  fNeutralMesonNtuple(NULL),
+  fTotalNumberOfAddedNtupleEntries(0),
+  fChargedParticles(),
+  fChargedParticlesId(),
+  fGammaPtHighest(0.),
+  fMinPtForGammaJet(1.),
+  fMinIsoConeSize(0.2),
+  fMinPtIsoCone(0.7),
+  fMinPtGamChargedCorr(0.5),
+  fMinPtJetCone(0.5),
+  fLeadingChargedIndex(-1),
+  fAODBranch(NULL),
+  fAODBranchName("GammaConv"),
+  fAODObjects()
+{
+  // Common I/O in slot 0
+  DefineInput (0, TChain::Class());
+  DefineOutput(0, TTree::Class());
+       
+  // Your private output
+  DefineOutput(1, TList::Class());
+
+  // Define standard ESD track cuts for Gamma-hadron correlation 
+  SetESDtrackCuts();
+}
+
+AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion() 
+{
+  // Remove all pointers
+       
+  if(fOutputContainer){
+    fOutputContainer->Clear() ; 
+    delete fOutputContainer ;
+  }
+  if(fHistograms){
+    delete fHistograms;
+  }
+  if(fV0Reader){
+    delete fV0Reader;
+  }
+  if (fAODBranch) {
+    fAODBranch->Clear();
+    delete fAODBranch ;
+  }
+}
+
+
+void AliAnalysisTaskGammaConversion::Init()
+{
+  // Initialization
+  AliLog::SetGlobalLogLevel(AliLog::kError);
+}
+void AliAnalysisTaskGammaConversion::SetESDtrackCuts()
+{
+  // SetESDtrackCuts
+
+  fEsdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
+//standard cuts from:
+//http://aliceinfo.cern.ch/alicvs/viewvc/PWG0/dNdEta/CreateCuts.C?revision=1.4&view=markup
+//fEsdTrackCuts->SetMinNClustersTPC(50);
+//fEsdTrackCuts->SetMaxChi2PerClusterTPC(3.5);
+//fEsdTrackCuts->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
+  fEsdTrackCuts->SetRequireTPCRefit(kTRUE);
+  fEsdTrackCuts->SetRequireITSRefit(kTRUE);
+  fEsdTrackCuts->SetMaxNsigmaToVertex(3);
+  fEsdTrackCuts->SetRequireSigmaToVertex(kTRUE);
+  //  fEsdTrackCuts->SetAcceptKinkDaughters(kFALSE);
+
+}
+
+void AliAnalysisTaskGammaConversion::Exec(Option_t */*option*/)
+{
+  // Execute analysis for current event
+       
+  ConnectInputData("");
+       
+  //Each event needs an empty branch
+  fAODBranch->Clear();
+
+  //clear vectors
+  fMCAllGammas.clear();
+  fMCPi0s.clear();
+  fMCEtas.clear();
+  fMCGammaChic.clear();
+       
+  fKFReconstructedGammas.clear();
+  fIsTrueReconstructedGammas.clear();
+  fElectronv1.clear();
+  fElectronv2.clear();
+  fCurrentEventPosElectron.clear();
+  fCurrentEventNegElectron.clear();    
+  fKFReconstructedGammasCut.clear(); 
+       
+
+  fChargedParticles.clear();   
+  fChargedParticlesId.clear(); 
+
+  //Clear the data in the v0Reader
+  fV0Reader->UpdateEventByEventData();
+
+  
+  // Process the MC information
+  if(fDoMCTruth){
+    ProcessMCData();
+  }
+  
+  //Process the v0 information with no cuts
+  ProcessV0sNoCut();
+  
+  // Process the v0 information
+  ProcessV0s();
+
+  //Fill Gamma AOD
+  FillAODWithConversionGammas() ; 
+  
+  //calculate background if flag is set
+  if(fCalculateBackground){
+    CalculateBackground();
+  }
+  
+
+  
+  
+  // Process reconstructed gammas
+  if(fDoNeutralMeson == kTRUE){
+      ProcessGammasForNeutralMesonAnalysis();
+  }
+  
+  CheckV0Efficiency();
+  
+  //Process reconstructed gammas electrons for Chi_c Analysis
+  if(fDoChic ==kFALSE){
+    ProcessGammaElectronsForChicAnalysis();
+  }
+  // Process reconstructed gammas for gamma Jet/hadron correlations
+  if(fDoJet == kTRUE){
+    ProcessGammasForGammaJetAnalysis();
+  }
+
+  PostData(1, fOutputContainer);
+       
+}
+
+void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t */*option*/){
+  // see header file for documentation
+       
+  if(fV0Reader == NULL){
+    // Write warning here cuts and so on are default if this ever happens
+  }
+  fV0Reader->Initialize();
+}
+
+
+
+void AliAnalysisTaskGammaConversion::ProcessMCData(){
+  // see header file for documentation
+       
+  fStack = fV0Reader->GetMCStack();
+
+  if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
+    return; // aborts if the primary vertex does not have contributors.
+  }
+
+  for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++) {
+    TParticle* particle = (TParticle *)fStack->Particle(iTracks);
+               
+    if (!particle) {
+      //print warning here
+      continue;
+    }
+
+    ///////////////////////Begin Chic Analysis/////////////////////////////
+
+
+    if(particle->GetPdgCode() == 443){//Is JPsi
+
+      if(particle->GetNDaughters()==2){
+       if(TMath::Abs(fStack->Particle(particle->GetFirstDaughter())->GetPdgCode()) == 11 &&
+          TMath::Abs(fStack->Particle(particle->GetLastDaughter())->GetPdgCode()) == 11){
+         TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
+         TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
+         if(TMath::Abs(daug0->Eta()) < 0.9 && TMath::Abs(daug1->Eta()) < 0.9)
+           fHistograms->FillTable("Table_Electrons",3);//e+ e-  from J/Psi inside acceptance
+
+         if( TMath::Abs(daug0->Eta()) < 0.9){
+           if(daug0->GetPdgCode() == -11)
+             fHistograms->FillTable("Table_Electrons",1);//e+  from J/Psi inside acceptance
+           else
+             fHistograms->FillTable("Table_Electrons",2);//e-   from J/Psi inside acceptance
+
+         }
+         if(TMath::Abs(daug1->Eta()) < 0.9){
+           if(daug1->GetPdgCode() == -11)
+             fHistograms->FillTable("Table_Electrons",1);//e+  from J/Psi inside acceptance
+           else
+             fHistograms->FillTable("Table_Electrons",2);//e-   from J/Psi inside acceptance
+         }
+       }
+      }
+    }
+    //              const int CHI_C0   = 10441;
+    //              const int CHI_C1   = 20443;
+    //              const int CHI_C2   = 445
+    if(particle->GetPdgCode() == 22){//gamma from JPsi
+      if(particle->GetMother(0) > -1){
+       if(fStack->Particle(particle->GetMother(0))->GetPdgCode() == 10441 ||
+          fStack->Particle(particle->GetMother(0))->GetPdgCode() == 20443 ||
+          fStack->Particle(particle->GetMother(0))->GetPdgCode() == 445){
+         if(TMath::Abs(particle->Eta()) < 1.2)
+           fHistograms->FillTable("Table_Electrons",17);// gamma from chic inside accptance
+       }
+      }
+    }
+    if(particle->GetPdgCode() == 10441 || particle->GetPdgCode() == 20443 || particle->GetPdgCode() == 445){
+      if( particle->GetNDaughters() == 2){
+       TParticle* daug0 = fStack->Particle(particle->GetFirstDaughter());
+       TParticle* daug1 = fStack->Particle(particle->GetLastDaughter());
+
+       if( (daug0->GetPdgCode() == 443 || daug0->GetPdgCode() == 22) && (daug1->GetPdgCode() == 443 || daug1->GetPdgCode() == 22) ){
+         if( daug0->GetPdgCode() == 443){
+           TParticle* daugE0 = fStack->Particle(daug0->GetFirstDaughter());
+           TParticle* daugE1 = fStack->Particle(daug0->GetLastDaughter());
+           if( TMath::Abs(daug1->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
+             fHistograms->FillTable("Table_Electrons",18);
+
+         }//if
+         else if (daug1->GetPdgCode() == 443){
+           TParticle* daugE0 = fStack->Particle(daug1->GetFirstDaughter());
+           TParticle* daugE1 = fStack->Particle(daug1->GetLastDaughter());
+           if( TMath::Abs(daug0->Eta()) < 1.2 && TMath::Abs(daugE0->Eta()) < 0.9 && TMath::Abs(daugE1->Eta()) < 0.9 )
+             fHistograms->FillTable("Table_Electrons",18);
+         }//else if
+       }//gamma o Jpsi
+      }//GetNDaughters
+    }
+
+
+    /////////////////////End Chic Analysis////////////////////////////
+
+
+    if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut() )   continue;
+                                       
+    if(particle->R()>fV0Reader->GetMaxRCut())  continue; // cuts on distance from collision point
+               
+    Double_t tmpPhi=particle->Phi();
+               
+    if(particle->Phi()> TMath::Pi()){
+      tmpPhi = particle->Phi()-(2*TMath::Pi());
+    }
+               
+    Double_t rapidity;
+    if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
+      rapidity=0;
+    }
+    else{
+      rapidity = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())));
+    }  
+               
+    //process the gammas
+    if (particle->GetPdgCode() == 22){
+                       
+      if(particle->GetMother(0) >-1 && fStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
+       continue; // no photon as mothers!
+      }
+
+      if(particle->GetMother(0) >= fStack->GetNprimary()){
+       continue; // the gamma has a mother, and it is not a primary particle
+      }
+
+      fMCAllGammas.push_back(particle);
+                       
+      fHistograms->FillHistogram("MC_allGamma_Energy", particle->Energy());
+      fHistograms->FillHistogram("MC_allGamma_Pt", particle->Pt());
+      fHistograms->FillHistogram("MC_allGamma_Eta", particle->Eta());
+      fHistograms->FillHistogram("MC_allGamma_Phi", tmpPhi);
+      fHistograms->FillHistogram("MC_allGamma_Rapid", rapidity);
+                       
+                       
+      if(particle->GetMother(0) < 0){   // direct gamma
+       fHistograms->FillHistogram("MC_allDirectGamma_Energy",particle->Energy());
+       fHistograms->FillHistogram("MC_allDirectGamma_Pt", particle->Pt());
+       fHistograms->FillHistogram("MC_allDirectGamma_Eta", particle->Eta());
+       fHistograms->FillHistogram("MC_allDirectGamma_Phi", tmpPhi);
+       fHistograms->FillHistogram("MC_allDirectGamma_Rapid", rapidity);                                
+      }
+                       
+                       
+      // looking for conversion (electron + positron from pairbuilding (= 5) )
+      TParticle* ePos = NULL;
+      TParticle* eNeg = NULL;
+                       
+      if(particle->GetNDaughters() >= 2){
+       for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
+         TParticle *tmpDaughter = fStack->Particle(daughterIndex);
+         if(tmpDaughter->GetUniqueID() == 5){
+           if(tmpDaughter->GetPdgCode() == 11){
+             eNeg = tmpDaughter;
+           }
+           else if(tmpDaughter->GetPdgCode() == -11){
+             ePos = tmpDaughter;
+           }
+         }
+       }
+      }
+                       
+                       
+      if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
+       continue;
+      }
+                       
+                       
+      Double_t ePosPhi = ePos->Phi();
+      if(ePos->Phi()> TMath::Pi()) ePosPhi = ePos->Phi()-(2*TMath::Pi());
+                       
+      Double_t eNegPhi = eNeg->Phi();
+      if(eNeg->Phi()> TMath::Pi()) eNegPhi = eNeg->Phi()-(2*TMath::Pi());
+                       
+                       
+      if(ePos->Pt()<fV0Reader->GetPtCut() || eNeg->Pt()<fV0Reader->GetPtCut()){
+       continue; // no reconstruction below the Pt cut
+      }
+                                       
+      if(TMath::Abs(ePos->Eta())> fV0Reader->GetEtaCut() || TMath::Abs(eNeg->Eta())> fV0Reader->GetEtaCut()){
+       continue;
+      }        
+                               
+      if(ePos->R()>fV0Reader->GetMaxRCut()){
+       continue; // cuts on distance from collision point
+      }
+                       
+      if(TMath::Abs(ePos->Vz()) > 240){
+       continue;   // outside material
+      }
+                       
+      if((TMath::Abs(ePos->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  > ePos->R()){
+       continue;               // line cut to exclude regions where we do not reconstruct
+      }                
+               
+      fHistograms->FillHistogram("MC_ConvGamma_Energy", particle->Energy());
+      fHistograms->FillHistogram("MC_ConvGamma_Pt", particle->Pt());
+      fHistograms->FillHistogram("MC_ConvGamma_Eta", particle->Eta());
+      fHistograms->FillHistogram("MC_ConvGamma_Phi", tmpPhi);
+      fHistograms->FillHistogram("MC_ConvGamma_Rapid", rapidity);
+      fHistograms->FillHistogram("MC_ConvGamma_Pt_Eta", particle->Pt(),particle->Eta());
+                       
+      fHistograms->FillHistogram("MC_E_Energy", eNeg->Energy());
+      fHistograms->FillHistogram("MC_E_Pt", eNeg->Pt());
+      fHistograms->FillHistogram("MC_E_Eta", eNeg->Eta());
+      fHistograms->FillHistogram("MC_E_Phi", eNegPhi);
+                       
+      fHistograms->FillHistogram("MC_P_Energy", ePos->Energy());
+      fHistograms->FillHistogram("MC_P_Pt", ePos->Pt());
+      fHistograms->FillHistogram("MC_P_Eta", ePos->Eta());
+      fHistograms->FillHistogram("MC_P_Phi", ePosPhi);
+                       
+                       
+                       
+      //cout << "filled histos for converted gamma, ePos, eNeg" << endl;
+                       
+      // begin Mapping 
+      Int_t rBin    = fHistograms->GetRBin(ePos->R());
+      Int_t phiBin  = fHistograms->GetPhiBin(particle->Phi());
+                       
+      TString nameMCMappingPhiR="";
+      nameMCMappingPhiR.Form("MC_Conversion_Mapping-Phi%02d-R%02d",phiBin,rBin);
+      fHistograms->FillHistogram(nameMCMappingPhiR, ePos->Vz(), particle->Eta());
+                       
+      TString nameMCMappingPhi="";
+      nameMCMappingPhi.Form("MC_Conversion_Mapping-Phi%02d",phiBin);
+      fHistograms->FillHistogram(nameMCMappingPhi, particle->Eta());
+                       
+      TString nameMCMappingR="";
+      nameMCMappingR.Form("MC_Conversion_Mapping-R%02d",rBin);
+      fHistograms->FillHistogram(nameMCMappingR, particle->Eta());
+                       
+      TString nameMCMappingPhiInR="";
+      nameMCMappingPhiInR.Form("MC_Conversion_Mapping_Phi_R-%02d",rBin);
+      fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);
+      //end mapping
+                       
+      fHistograms->FillHistogram("MC_Conversion_R",ePos->R());
+      fHistograms->FillHistogram("MC_Conversion_ZR",ePos->Vz(),ePos->R());
+      fHistograms->FillHistogram("MC_Conversion_XY",ePos->Vx(),ePos->Vy());
+      fHistograms->FillHistogram("MC_Conversion_OpeningAngle",GetMCOpeningAngle(ePos, eNeg));
+                       
+      //cout << "mapping is done" << endl;
+                       
+                       
+      if(particle->GetMother(0) < 0){ // no mother = direct gamma, still inside converted
+       fHistograms->FillHistogram("MC_ConvDirectGamma_Energy",particle->Energy());
+       fHistograms->FillHistogram("MC_ConvDirectGamma_Pt", particle->Pt());
+       fHistograms->FillHistogram("MC_ConvDirectGamma_Eta", particle->Eta());
+       fHistograms->FillHistogram("MC_ConvDirectGamma_Phi", tmpPhi);
+       fHistograms->FillHistogram("MC_ConvDirectGamma_Rapid", rapidity);
+                               
+      } // end direct gamma
+      else{   // mother exits 
+       if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==10441 ||//chic0 
+           fStack->Particle(particle->GetMother(0))->GetPdgCode()==20443 ||//psi2S
+           fStack->Particle(particle->GetMother(0))->GetPdgCode()==445  //chic2
+           ){ 
+         fMCGammaChic.push_back(particle);
+       }
+      }  // end if mother exits
+    } // end if particle is a photon
+               
+               
+               
+    // process motherparticles (2 gammas as daughters)
+    // the motherparticle had already to pass the R and the eta cut, but no line cut.
+    // the line cut is just valid for the conversions!
+               
+    if(particle->GetNDaughters() == 2){
+                       
+      TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());
+      TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());
+                       
+      if(daughter0->GetPdgCode() != 22 || daughter1->GetPdgCode() != 22) continue; //check for gamma gamma daughters
+                       
+      // Check the acceptance for both gammas
+      Bool_t GammaEtaCut = kTRUE;
+      if(TMath::Abs(daughter0->Eta()) > fV0Reader->GetEtaCut() || TMath::Abs(daughter1->Eta()) > fV0Reader->GetEtaCut()  ) GammaEtaCut = kFALSE;
+      Bool_t GammaRCut = kTRUE;
+      if(daughter0->R() > fV0Reader->GetMaxRCut() || daughter1->R() > fV0Reader->GetMaxRCut()  ) GammaRCut = kFALSE;
+                       
+                       
+                       
+      // check for conversions now -> have to pass eta, R and line cut!
+      Bool_t daughter0Electron = kFALSE;
+      Bool_t daughter0Positron = kFALSE;
+      Bool_t daughter1Electron = kFALSE;
+      Bool_t daughter1Positron = kFALSE;
+                       
+      if(daughter0->GetNDaughters() >= 2){  // first gamma
+       for(Int_t TrackIndex=daughter0->GetFirstDaughter();TrackIndex<=daughter0->GetLastDaughter();TrackIndex++){
+         TParticle *tmpDaughter = fStack->Particle(TrackIndex);
+         if(tmpDaughter->GetUniqueID() == 5){
+           if(tmpDaughter->GetPdgCode() == 11){
+             if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
+               if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  < tmpDaughter->R() ){
+                 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
+                   daughter0Electron = kTRUE;
+                 }
+               }
+                                                               
+             }
+           }
+           else if(tmpDaughter->GetPdgCode() == -11){
+             if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
+               if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  < tmpDaughter->R() ){
+                 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
+                   daughter0Positron = kTRUE;
+                 }
+               }
+                                                               
+             }
+                                                       
+           }
+         }
+       }
+      }
+                       
+                       
+      if(daughter1->GetNDaughters() >= 2){   // second gamma
+       for(Int_t TrackIndex=daughter1->GetFirstDaughter();TrackIndex<=daughter1->GetLastDaughter();TrackIndex++){
+         TParticle *tmpDaughter = fStack->Particle(TrackIndex);
+         if(tmpDaughter->GetUniqueID() == 5){
+           if(tmpDaughter->GetPdgCode() == 11){
+             if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
+               if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  < tmpDaughter->R() ){
+                 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
+                   daughter1Electron = kTRUE;
+                 }
+               }
+                                                               
+             }
+           }
+           else if(tmpDaughter->GetPdgCode() == -11){
+             if( TMath::Abs(tmpDaughter->Eta()) <= fV0Reader->GetEtaCut() ){
+               if( ( TMath::Abs(tmpDaughter->Vz()) * fV0Reader->GetLineCutZRSlope()) - fV0Reader->GetLineCutZValue()  < tmpDaughter->R() ){
+                 if(tmpDaughter->R()< fV0Reader->GetMaxRCut()){
+                   daughter1Positron = kTRUE;
+                 }
+               }
+                                                               
+             }
+                                                       
+           }
+         }
+       }
+      }
+                       
+                                                                                               
+                       
+                       
+      if(particle->GetPdgCode()==111){     //Pi0
+       if( iTracks >= fStack->GetNprimary()){
+         fHistograms->FillHistogram("MC_Pi0_Secondaries_Eta", particle->Eta());
+         fHistograms->FillHistogram("MC_Pi0_Secondaries_Rapid", rapidity);
+         fHistograms->FillHistogram("MC_Pi0_Secondaries_Phi", tmpPhi);
+         fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt", particle->Pt());
+         fHistograms->FillHistogram("MC_Pi0_Secondaries_Energy", particle->Energy());
+         fHistograms->FillHistogram("MC_Pi0_Secondaries_R", particle->R());
+         fHistograms->FillHistogram("MC_Pi0_Secondaries_ZR", particle->Vz(),particle->R());
+         fHistograms->FillHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
+         fHistograms->FillHistogram("MC_Pi0_Secondaries_XY", particle->Vx(),particle->Vy());//only fill from one daughter to avoid multiple filling
+                                       
+         if(GammaEtaCut && GammaRCut){  
+           //if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
+           fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
+           fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
+           if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
+             fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
+             fHistograms->FillHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
+           }
+         }
+       }
+       else{
+         fHistograms->FillHistogram("MC_Pi0_Eta", particle->Eta());    
+         fHistograms->FillHistogram("MC_Pi0_Rapid", rapidity);
+         fHistograms->FillHistogram("MC_Pi0_Phi", tmpPhi);
+         fHistograms->FillHistogram("MC_Pi0_Pt", particle->Pt());
+         fHistograms->FillHistogram("MC_Pi0_Energy", particle->Energy());
+         fHistograms->FillHistogram("MC_Pi0_R", particle->R());
+         fHistograms->FillHistogram("MC_Pi0_ZR", particle->Vz(),particle->R());
+         fHistograms->FillHistogram("MC_Pi0_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
+         fHistograms->FillHistogram("MC_Pi0_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
+
+         if(GammaEtaCut && GammaRCut){
+           //    if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
+           fHistograms->FillHistogram("MC_Pi0_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
+           fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
+           if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
+             fHistograms->FillHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
+             fHistograms->FillHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
+             fHistograms->FillHistogram("MC_Pi0_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
+           }
+         }
+       }
+      }
+                       
+      if(particle->GetPdgCode()==221){   //Eta
+       fHistograms->FillHistogram("MC_Eta_Eta", particle->Eta());
+       fHistograms->FillHistogram("MC_Eta_Rapid", rapidity);
+       fHistograms->FillHistogram("MC_Eta_Phi",tmpPhi);
+       fHistograms->FillHistogram("MC_Eta_Pt", particle->Pt());
+       fHistograms->FillHistogram("MC_Eta_Energy", particle->Energy());
+       fHistograms->FillHistogram("MC_Eta_R", particle->R());
+       fHistograms->FillHistogram("MC_Eta_ZR", particle->Vz(),particle->R());
+       fHistograms->FillHistogram("MC_Eta_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
+       fHistograms->FillHistogram("MC_Eta_XY", particle->Vx(), particle->Vy());//only fill from one daughter to avoid multiple filling
+                               
+       if(GammaEtaCut && GammaRCut){  
+       //      if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
+         fHistograms->FillHistogram("MC_Eta_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
+         fHistograms->FillHistogram("MC_Eta_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
+         if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
+           fHistograms->FillHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
+           fHistograms->FillHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
+           fHistograms->FillHistogram("MC_Eta_ZR_ConvGamma_withinAcceptance", particle->Vz(),particle->R());
+         }
+                                       
+       }
+                               
+      }
+                       
+      // all motherparticles with 2 gammas as daughters
+      fHistograms->FillHistogram("MC_Mother_R", particle->R());
+      fHistograms->FillHistogram("MC_Mother_ZR", particle->Vz(),particle->R());
+      fHistograms->FillHistogram("MC_Mother_XY", particle->Vx(),particle->Vy());
+      fHistograms->FillHistogram("MC_Mother_Mass", particle->GetCalcMass());
+      fHistograms->FillHistogram("MC_Mother_GammaDaughter_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));
+      fHistograms->FillHistogram("MC_Mother_Energy", particle->Energy());
+      fHistograms->FillHistogram("MC_Mother_Pt", particle->Pt());
+      fHistograms->FillHistogram("MC_Mother_Eta", particle->Eta());
+      fHistograms->FillHistogram("MC_Mother_Rapid", rapidity);
+      fHistograms->FillHistogram("MC_Mother_Phi",tmpPhi);
+      fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt",particle->GetMass(),particle->Pt());                        
+      
+      if(GammaEtaCut && GammaRCut){  
+  //      if(TMath::Abs(daughter0->Eta()) <= fV0Reader->GetEtaCut() && TMath::Abs(daughter1->Eta()) <= fV0Reader->GetEtaCut() ){
+       fHistograms->FillHistogram("MC_Mother_Pt_Eta_withinAcceptance", particle->Pt(),particle->Eta());
+       fHistograms->FillHistogram("MC_Mother_Pt_Rapid_withinAcceptance", particle->Pt(),rapidity);
+       fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance",particle->GetMass(),particle->Pt());                      
+       if(daughter0Electron && daughter0Positron && daughter1Electron && daughter1Positron){
+         fHistograms->FillHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance", particle->Pt(),particle->Eta());
+         fHistograms->FillHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance", particle->Pt(),rapidity);
+         fHistograms->FillHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance",particle->GetMass(),particle->Pt());                  
+
+       }
+                               
+                               
+      }  // end passed R and eta cut
+                                               
+    } // end if(particle->GetNDaughters() == 2)
+               
+  }// end for (Int_t iTracks = 0; iTracks < fStack->GetNtrack(); iTracks++)
+       
+  //cout << "right before the end of processMCdata" << endl;
+       
+} // end ProcessMCData
+
+
+
+void AliAnalysisTaskGammaConversion::FillNtuple(){
+  //Fills the ntuple with the different values
+
+  if(fGammaNtuple == NULL){
+    return;
+  }
+  Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
+  for(Int_t i=0;i<numberOfV0s;i++){
+    Float_t values[27] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+    AliESDv0 * cV0 = fV0Reader->GetV0(i);
+    Double_t negPID=0;
+    Double_t posPID=0;
+    fV0Reader->GetPIDProbability(negPID,posPID);
+    values[0]=cV0->GetOnFlyStatus();
+    values[1]=fV0Reader->CheckForPrimaryVertex();
+    values[2]=negPID;
+    values[3]=posPID;
+    values[4]=fV0Reader->GetX();
+    values[5]=fV0Reader->GetY();
+    values[6]=fV0Reader->GetZ();
+    values[7]=fV0Reader->GetXYRadius();
+    values[8]=fV0Reader->GetMotherCandidateNDF();
+    values[9]=fV0Reader->GetMotherCandidateChi2();
+    values[10]=fV0Reader->GetMotherCandidateEnergy();
+    values[11]=fV0Reader->GetMotherCandidateEta();
+    values[12]=fV0Reader->GetMotherCandidatePt();
+    values[13]=fV0Reader->GetMotherCandidateMass();
+    values[14]=fV0Reader->GetMotherCandidateWidth();
+    //    values[15]=fV0Reader->GetMotherMCParticle()->Pt();   MOVED TO THE END, HAS TO BE CALLED AFTER HasSameMother NB: still has the same entry in the array
+    values[16]=fV0Reader->GetOpeningAngle();
+    values[17]=fV0Reader->GetNegativeTrackEnergy();
+    values[18]=fV0Reader->GetNegativeTrackPt();
+    values[19]=fV0Reader->GetNegativeTrackEta();
+    values[20]=fV0Reader->GetNegativeTrackPhi();
+    values[21]=fV0Reader->GetPositiveTrackEnergy();
+    values[22]=fV0Reader->GetPositiveTrackPt();
+    values[23]=fV0Reader->GetPositiveTrackEta();
+    values[24]=fV0Reader->GetPositiveTrackPhi();
+    values[25]=fV0Reader->HasSameMCMother();
+    if(values[25] != 0){
+      values[26]=fV0Reader->GetMotherMCParticlePDGCode();
+      values[15]=fV0Reader->GetMotherMCParticle()->Pt();
+    }
+    fTotalNumberOfAddedNtupleEntries++;
+    fGammaNtuple->Fill(values);
+  }
+  fV0Reader->ResetV0IndexNumber();
+       
+}
+
+void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
+  // Process all the V0's without applying any cuts to it
+
+  Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
+  for(Int_t i=0;i<numberOfV0s;i++){
+    /*AliESDv0 * cV0 = */fV0Reader->GetV0(i);
+
+    if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
+      return;
+    }
+    
+    if(fDoMCTruth){
+      
+      if(fV0Reader->HasSameMCMother() == kFALSE){
+       continue;
+      }
+               
+      TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
+      TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
+
+      if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
+       continue;
+      }
+      if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
+       continue;
+      }
+       
+      if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
+      
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta", fV0Reader->GetMotherCandidateEta());                               
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
+
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
+                               
+       fHistograms->FillHistogram("ESD_NoCutConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
+       fHistograms->FillHistogram("ESD_NoCutConversion_R", fV0Reader->GetXYRadius());
+       fHistograms->FillHistogram("ESD_NoCutConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
+       fHistograms->FillHistogram("ESD_NoCutConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
+                               
+       //store MCTruth properties
+       fHistograms->FillHistogram("ESD_NoCutConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
+       fHistograms->FillHistogram("ESD_NoCutConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
+       fHistograms->FillHistogram("ESD_NoCutConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
+
+
+      }
+    }
+  }
+  fV0Reader->ResetV0IndexNumber();
+}
+
+void AliAnalysisTaskGammaConversion::ProcessV0s(){
+  // see header file for documentation
+       
+  if(fWriteNtuple == kTRUE){
+    FillNtuple();
+  }
+       
+  Int_t nSurvivingV0s=0;
+  while(fV0Reader->NextV0()){
+    nSurvivingV0s++;
+               
+               
+    //-------------------------- filling v0 information -------------------------------------
+    fHistograms->FillHistogram("ESD_Conversion_R", fV0Reader->GetXYRadius());
+    fHistograms->FillHistogram("ESD_Conversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
+    fHistograms->FillHistogram("ESD_Conversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
+    fHistograms->FillHistogram("ESD_Conversion_OpeningAngle", fV0Reader->GetOpeningAngle());    
+               
+    fHistograms->FillHistogram("ESD_E_Energy", fV0Reader->GetNegativeTrackEnergy());
+    fHistograms->FillHistogram("ESD_E_Pt", fV0Reader->GetNegativeTrackPt());
+    fHistograms->FillHistogram("ESD_E_Eta", fV0Reader->GetNegativeTrackEta());
+    fHistograms->FillHistogram("ESD_E_Phi", fV0Reader->GetNegativeTrackPhi());
+               
+    fHistograms->FillHistogram("ESD_P_Energy", fV0Reader->GetPositiveTrackEnergy());
+    fHistograms->FillHistogram("ESD_P_Pt", fV0Reader->GetPositiveTrackPt());
+    fHistograms->FillHistogram("ESD_P_Eta", fV0Reader->GetPositiveTrackEta());
+    fHistograms->FillHistogram("ESD_P_Phi", fV0Reader->GetPositiveTrackPhi());
+               
+    fHistograms->FillHistogram("ESD_ConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
+    fHistograms->FillHistogram("ESD_ConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
+    fHistograms->FillHistogram("ESD_ConvGamma_Eta", fV0Reader->GetMotherCandidateEta());
+    fHistograms->FillHistogram("ESD_ConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
+    fHistograms->FillHistogram("ESD_ConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
+    fHistograms->FillHistogram("ESD_ConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
+    fHistograms->FillHistogram("ESD_ConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
+    fHistograms->FillHistogram("ESD_ConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
+    fHistograms->FillHistogram("ESD_ConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
+    fHistograms->FillHistogram("ESD_ConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
+               
+    fHistograms->FillHistogram("ESD_ConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
+    fHistograms->FillHistogram("ESD_ConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
+               
+               
+               
+    // begin mapping
+    Int_t rBin    = fHistograms->GetRBin(fV0Reader->GetXYRadius());
+    Int_t phiBin  = fHistograms->GetPhiBin(fV0Reader->GetNegativeTrackPhi());
+    Double_t motherCandidateEta= fV0Reader->GetMotherCandidateEta();
+               
+    TString nameESDMappingPhiR="";
+    nameESDMappingPhiR.Form("ESD_Conversion_Mapping-Phi%02d-R%02d",phiBin,rBin);
+    fHistograms->FillHistogram(nameESDMappingPhiR, fV0Reader->GetZ(), motherCandidateEta);
+               
+    TString nameESDMappingPhi="";
+    nameESDMappingPhi.Form("ESD_Conversion_Mapping-Phi%02d",phiBin);
+    fHistograms->FillHistogram(nameESDMappingPhi, fV0Reader->GetZ(), motherCandidateEta);
+               
+    TString nameESDMappingR="";
+    nameESDMappingR.Form("ESD_Conversion_Mapping-R%02d",rBin);
+    fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);  
+               
+    TString nameESDMappingPhiInR="";
+    nameESDMappingPhiInR.Form("ESD_Conversion_Mapping_Phi_R-%02d",rBin);
+    fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());
+    // end mapping
+               
+    fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());
+    fElectronv1.push_back(fV0Reader->GetCurrentV0()->GetPindex());
+    fElectronv2.push_back(fV0Reader->GetCurrentV0()->GetNindex());
+
+               
+    //----------------------------------- checking for "real" conversions (MC match) --------------------------------------
+    if(fDoMCTruth){
+                       
+      if(fV0Reader->HasSameMCMother() == kFALSE){
+       fIsTrueReconstructedGammas.push_back(kFALSE);
+       continue;
+      }
+      
+               
+      TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
+      TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
+
+      if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
+       fIsTrueReconstructedGammas.push_back(kFALSE);
+       continue;
+      }
+      if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
+       fIsTrueReconstructedGammas.push_back(kFALSE);
+       continue;
+      }
+       
+      if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
+       fIsTrueReconstructedGammas.push_back(kTRUE);
+                               
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Eta", fV0Reader->GetMotherCandidateEta());                                
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Mass", fV0Reader->GetMotherCandidateMass());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Width", fV0Reader->GetMotherCandidateWidth());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Chi2", fV0Reader->GetMotherCandidateChi2());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_NDF", fV0Reader->GetMotherCandidateNDF());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Eta", fV0Reader->GetMotherCandidatePt(),fV0Reader->GetMotherCandidateEta());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Rapid", fV0Reader->GetMotherCandidateRapidity());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLength", /*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetNegativeTrackLength()*/fV0Reader->GetNegativeNTPCClusters(),fV0Reader->GetMotherCandidateMass());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass",/*fV0Reader->GetPositiveTrackLength()*/fV0Reader->GetPositiveNTPCClusters(),fV0Reader->GetMotherCandidateMass());
+
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Chi2", fV0Reader->GetMotherCandidatePt(), fV0Reader->GetMotherCandidateChi2());
+       fHistograms->FillHistogram("ESD_TrueConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
+
+                               
+       fHistograms->FillHistogram("ESD_TrueConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
+       fHistograms->FillHistogram("ESD_TrueConversion_R", fV0Reader->GetXYRadius());
+       fHistograms->FillHistogram("ESD_TrueConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
+       fHistograms->FillHistogram("ESD_TrueConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
+
+       //store MCTruth properties
+       fHistograms->FillHistogram("ESD_TrueConvGamma_MC_Pt_Eta", fV0Reader->GetMotherMCParticle()->Pt(),fV0Reader->GetMotherMCParticle()->Eta());
+       fHistograms->FillHistogram("ESD_TrueConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
+       fHistograms->FillHistogram("ESD_TrueConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
+
+       //resolution
+       Double_t mcpt   = fV0Reader->GetMotherMCParticle()->Pt();
+       Double_t esdpt  = fV0Reader->GetMotherCandidatePt();
+       Double_t resdPt = 0;
+       if(mcpt != 0){
+         resdPt = ((esdpt - mcpt)/mcpt)*100;
+       }
+                               
+       fHistograms->FillHistogram("Resolution_dPt", mcpt, resdPt);
+       fHistograms->FillHistogram("Resolution_MC_Pt", mcpt);
+       fHistograms->FillHistogram("Resolution_ESD_Pt", esdpt);
+                               
+       Double_t resdZ = 0;
+       if(fV0Reader->GetNegativeMCParticle()->Vz() != 0){
+         resdZ = ((fV0Reader->GetZ() -fV0Reader->GetNegativeMCParticle()->Vz())/fV0Reader->GetNegativeMCParticle()->Vz())*100;
+       }
+                               
+       fHistograms->FillHistogram("Resolution_dZ", fV0Reader->GetNegativeMCParticle()->Vz(), resdZ);
+       fHistograms->FillHistogram("Resolution_MC_Z", fV0Reader->GetNegativeMCParticle()->Vz());
+       fHistograms->FillHistogram("Resolution_ESD_Z", fV0Reader->GetZ());
+                               
+       Double_t resdR = 0;
+       if(fV0Reader->GetNegativeMCParticle()->R() != 0){
+         resdR = ((fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R())/fV0Reader->GetNegativeMCParticle()->R())*100;
+       }
+
+       fHistograms->FillHistogram("Resolution_dR", fV0Reader->GetNegativeMCParticle()->R(), resdR);
+       fHistograms->FillHistogram("Resolution_MC_R", fV0Reader->GetNegativeMCParticle()->R());
+       fHistograms->FillHistogram("Resolution_ESD_R", fV0Reader->GetXYRadius());
+       fHistograms->FillHistogram("Resolution_dR_dPt", resdR, resdPt);
+      }//if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22)
+      else{
+       fIsTrueReconstructedGammas.push_back(kFALSE);
+      }
+    }//if(fDoMCTruth)
+  }//while(fV0Reader->NextV0)
+  fHistograms->FillHistogram("ESD_NumberOfSurvivingV0s", nSurvivingV0s);
+  fHistograms->FillHistogram("ESD_NumberOfV0s", fV0Reader->GetNumberOfV0s());
+       
+  //cout << "nearly at the end of doMCTruth" << endl;
+       
+}
+
+void AliAnalysisTaskGammaConversion::FillAODWithConversionGammas(){
+  // Fill AOD with reconstructed Gamma
+  
+  for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
+    //Create AOD particle object from AliKFParticle
+
+    /*    AliKFParticle * gammakf = &fKFReconstructedGammas[gammaIndex];
+    //You could add directly AliKFParticle objects to the AOD, avoiding dependences with PartCorr
+    //but this means that I have to work a little bit more in my side.
+    //AODPWG4Particle objects are simpler and lighter, I think
+    AliAODPWG4Particle gamma = AliAODPWG4Particle(gammakf->Px(),gammakf->Py(),gammakf->Pz(), gammakf->E());
+    gamma.SetLabel(-1);//How to get the MC label of the reconstructed gamma?
+       gamma.SetCaloLabel(-1,-1); //How to get the MC label of the 2 electrons that form the gamma?
+       gamma.SetDetector("CTS"); //tag the gamma as reconstructed in the central barrel
+       gamma.SetPdg(AliCaloPID::kPhotonConv); //photon id
+       gamma.SetTag(-1); //Here I usually put a flag saying that montecarlo says it is prompt, decay fragmentation photon, or hadrons or whatever
+       
+       //Add it to the aod list
+       Int_t i = fAODBranch->GetEntriesFast();
+       new((*fAODBranch)[i])  AliAODPWG4Particle(gamma);
+    */
+    AliKFParticle * gammakf = &fKFReconstructedGammas[gammaIndex];
+    AliGammaConversionAODObject aodObject;
+    aodObject.SetPx(gammakf->GetPx());
+    aodObject.SetPy(gammakf->GetPy());
+    aodObject.SetPz(gammakf->GetPz());
+    aodObject.SetLabel1(fElectronv1[gammaIndex]);
+    aodObject.SetLabel2(fElectronv2[gammaIndex]);
+    Int_t i = fAODBranch->GetEntriesFast();
+    new((*fAODBranch)[i])  AliGammaConversionAODObject();
+   }
+
+}
+
+
+void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
+  // see header file for documentation
+       
+  for(UInt_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammas.size();firstGammaIndex++){
+    for(UInt_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFReconstructedGammas.size();secondGammaIndex++){
+                       
+      AliKFParticle * twoGammaDecayCandidateDaughter0 = &fKFReconstructedGammas[firstGammaIndex];
+      AliKFParticle * twoGammaDecayCandidateDaughter1 = &fKFReconstructedGammas[secondGammaIndex];
+      
+      if(fElectronv1[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv1[firstGammaIndex]==fElectronv2[secondGammaIndex]){
+       continue;
+      }
+      if(fElectronv2[firstGammaIndex]==fElectronv1[secondGammaIndex] || fElectronv2[firstGammaIndex]==fElectronv2[secondGammaIndex]){
+       continue;
+      }
+
+      /*
+       if(fIsTrueReconstructedGammas[firstGammaIndex] == kFALSE || fIsTrueReconstructedGammas[secondGammaIndex] == kFALSE){
+       continue;
+       }
+      */
+
+      AliKFParticle *twoGammaCandidate = new AliKFParticle(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
+                       
+      Double_t massTwoGammaCandidate = 0.;
+      Double_t widthTwoGammaCandidate = 0.;
+      Double_t chi2TwoGammaCandidate =10000.;  
+      twoGammaCandidate->GetMass(massTwoGammaCandidate,widthTwoGammaCandidate);
+      if(twoGammaCandidate->GetNDF()>0){
+       chi2TwoGammaCandidate = twoGammaCandidate->GetChi2()/twoGammaCandidate->GetNDF();
+                               
+       if(chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()){                                      
+                                       
+         TVector3 momentumVectorTwoGammaCandidate(twoGammaCandidate->GetPx(),twoGammaCandidate->GetPy(),twoGammaCandidate->GetPz());
+         TVector3 spaceVectorTwoGammaCandidate(twoGammaCandidate->GetX(),twoGammaCandidate->GetY(),twoGammaCandidate->GetZ());
+                                       
+         Double_t openingAngleTwoGammaCandidate = twoGammaDecayCandidateDaughter0->GetAngle(*twoGammaDecayCandidateDaughter1);                                 
+         Double_t rapidity;
+         if(twoGammaCandidate->GetE() - twoGammaCandidate->GetPz() == 0 || twoGammaCandidate->GetE() + twoGammaCandidate->GetPz() == 0){
+           rapidity=0;
+         }
+         else{
+           rapidity = 0.5*(TMath::Log((twoGammaCandidate->GetE() +twoGammaCandidate->GetPz()) / (twoGammaCandidate->GetE()-twoGammaCandidate->GetPz())));
+         }
+                                       
+         if(openingAngleTwoGammaCandidate < fMinOpeningAngleGhostCut) continue;   // minimum opening angle to avoid using ghosttracks
+
+         fHistograms->FillHistogram("ESD_Mother_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);
+         fHistograms->FillHistogram("ESD_Mother_Energy", twoGammaCandidate->GetE());
+         fHistograms->FillHistogram("ESD_Mother_Pt", momentumVectorTwoGammaCandidate.Pt());
+         fHistograms->FillHistogram("ESD_Mother_Eta", momentumVectorTwoGammaCandidate.Eta());
+         fHistograms->FillHistogram("ESD_Mother_Rapid", rapidity);                                     
+         fHistograms->FillHistogram("ESD_Mother_Phi", spaceVectorTwoGammaCandidate.Phi());
+         fHistograms->FillHistogram("ESD_Mother_Mass", massTwoGammaCandidate);
+         fHistograms->FillHistogram("ESD_Mother_R", spaceVectorTwoGammaCandidate.Pt());    // Pt in Space == R!!!
+         fHistograms->FillHistogram("ESD_Mother_ZR", twoGammaCandidate->GetZ(), spaceVectorTwoGammaCandidate.Pt());
+         fHistograms->FillHistogram("ESD_Mother_XY", twoGammaCandidate->GetX(), twoGammaCandidate->GetY());
+         fHistograms->FillHistogram("ESD_Mother_InvMass_vs_Pt",massTwoGammaCandidate ,momentumVectorTwoGammaCandidate.Pt());
+         fHistograms->FillHistogram("ESD_Mother_InvMass",massTwoGammaCandidate);
+       }
+      }
+      delete twoGammaCandidate;
+                       
+      //cout << "nearly at the end of processgamma for neutral meson ..." << endl;
+                       
+                       
+    }
+  }
+}
+
+void AliAnalysisTaskGammaConversion::CalculateBackground(){
+  // see header file for documentation
+       
+  vector<AliKFParticle> vectorCurrentEventGoodV0s = fV0Reader->GetCurrentEventGoodV0s();
+  vector<AliKFParticle> vectorPreviousEventGoodV0s = fV0Reader->GetPreviousEventGoodV0s();
+  for(UInt_t iCurrent=0;iCurrent<vectorCurrentEventGoodV0s.size();iCurrent++){
+    AliKFParticle * currentEventGoodV0 = &vectorCurrentEventGoodV0s.at(iCurrent);
+    for(UInt_t iPrevious=0;iPrevious<vectorPreviousEventGoodV0s.size();iPrevious++){
+      AliKFParticle * previousGoodV0 = &vectorPreviousEventGoodV0s.at(iPrevious);
+
+      AliKFParticle *backgroundCandidate = new AliKFParticle(*currentEventGoodV0,*previousGoodV0);
+                       
+      Double_t massBG =0.;
+      Double_t widthBG = 0.;
+      Double_t chi2BG =10000.; 
+      backgroundCandidate->GetMass(massBG,widthBG);
+      if(backgroundCandidate->GetNDF()>0){
+       chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();
+       if(chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()){
+                                       
+         TVector3 MomentumVectorbackgroundCandidate(backgroundCandidate->GetPx(),backgroundCandidate->GetPy(),backgroundCandidate->GetPz());
+         TVector3 SpaceVectorbackgroundCandidate(backgroundCandidate->GetX(),backgroundCandidate->GetY(),backgroundCandidate->GetZ());
+                                       
+         Double_t openingAngleBG = currentEventGoodV0->GetAngle(*previousGoodV0);
+
+         Double_t rapidity;
+         if(backgroundCandidate->GetE() - backgroundCandidate->GetPz() == 0 || backgroundCandidate->GetE() + backgroundCandidate->GetPz() == 0) rapidity=0;
+         else rapidity = 0.5*(TMath::Log((backgroundCandidate->GetE() +backgroundCandidate->GetPz()) / (backgroundCandidate->GetE()-backgroundCandidate->GetPz())));
+
+                                       
+                                       
+                                       
+         if(openingAngleBG < fMinOpeningAngleGhostCut ) continue;   // minimum opening angle to avoid using ghosttracks
+                       
+                                       
+         fHistograms->FillHistogram("ESD_Background_GammaDaughter_OpeningAngle", openingAngleBG);
+         fHistograms->FillHistogram("ESD_Background_Energy", backgroundCandidate->GetE());
+         fHistograms->FillHistogram("ESD_Background_Pt",  MomentumVectorbackgroundCandidate.Pt());
+         fHistograms->FillHistogram("ESD_Background_Eta", MomentumVectorbackgroundCandidate.Eta());
+         fHistograms->FillHistogram("ESD_Background_Rapidity", rapidity);
+         fHistograms->FillHistogram("ESD_Background_Phi", SpaceVectorbackgroundCandidate.Phi());
+         fHistograms->FillHistogram("ESD_Background_Mass", massBG);
+         fHistograms->FillHistogram("ESD_Background_R", SpaceVectorbackgroundCandidate.Pt());  // Pt in Space == R!!!!
+         fHistograms->FillHistogram("ESD_Background_ZR", backgroundCandidate->GetZ(), SpaceVectorbackgroundCandidate.Pt());
+         fHistograms->FillHistogram("ESD_Background_XY", backgroundCandidate->GetX(), backgroundCandidate->GetY());
+         fHistograms->FillHistogram("ESD_Background_InvMass_vs_Pt",massBG,MomentumVectorbackgroundCandidate.Pt());
+         fHistograms->FillHistogram("ESD_Background_InvMass",massBG);
+       }
+      }
+      delete backgroundCandidate;   
+      //cout << "nearly at the end of background" << endl;
+                       
+    }
+  }
+}
+
+
+
+void AliAnalysisTaskGammaConversion::ProcessGammasForGammaJetAnalysis(){
+  //ProcessGammasForGammaJetAnalysis
+  Double_t distIsoMin;
+
+  CreateListOfChargedParticles();
+
+
+  for(UInt_t gammaIndex=0;gammaIndex<fKFReconstructedGammas.size();gammaIndex++){
+    AliKFParticle * currentGamma = &fKFReconstructedGammas[gammaIndex];
+    TVector3 MomentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
+
+    if( MomentumVectorCurrentGamma.Pt()> fMinPtForGammaJet){
+      distIsoMin=GetMinimumDistanceToCharge(gammaIndex);
+
+      if (distIsoMin > fMinIsoConeSize && fLeadingChargedIndex>=0){
+       CalculateJetCone(gammaIndex,fLeadingChargedIndex);
+      }
+    }
+  }
+}
+
+void AliAnalysisTaskGammaConversion::CreateListOfChargedParticles(){
+  // CreateListOfChargedParticles
+
+  fESDEvent = fV0Reader->GetESDEvent();
+  for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
+    AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
+
+    if(!curTrack){
+      continue;
+    }
+
+    if(fEsdTrackCuts->AcceptTrack(curTrack) ){
+      fChargedParticles.push_back(curTrack);
+      fChargedParticlesId.push_back(iTracks);
+    }
+  }
+}
+void AliAnalysisTaskGammaConversion::CalculateJetCone(Int_t gammaIndex, Int_t fLeadingChargedIndex){
+  // CalculateJetCone
+
+  Double_t cone;
+  Double_t coneSize=0.3;
+  Double_t ptJet=0;
+  
+  AliKFParticle * currentGamma = &fKFReconstructedGammas[gammaIndex];
+  TVector3 MomentumVectorCurrentGamma(currentGamma->GetPx(),currentGamma->GetPy(),currentGamma->GetPz());
+
+  AliESDtrack* leadingCharged = fChargedParticles[fLeadingChargedIndex];
+  Double_t momLeadingCharged[3];
+  leadingCharged->GetConstrainedPxPyPz(momLeadingCharged);
+
+  TVector3 MomentumVectorLeadingCharged(momLeadingCharged[0],momLeadingCharged[1],momLeadingCharged[2]);
+
+  Double_t phi1=MomentumVectorLeadingCharged.Phi();
+  Double_t eta1=MomentumVectorLeadingCharged.Eta();
+  Double_t phi3=MomentumVectorCurrentGamma.Phi();
+
+  for(UInt_t iCh=0;iCh<fChargedParticles.size();iCh++){
+    AliESDtrack* curTrack = fChargedParticles[iCh];
+    Int_t chId = fChargedParticlesId[iCh];
+    if(fLeadingChargedIndex==chId || fLeadingChargedIndex==chId) continue;
+    Double_t mom[3];
+    curTrack->GetConstrainedPxPyPz(mom);
+    TVector3 MomentumVectorChargedParticle(mom[0],mom[1],mom[2]);
+    Double_t phi2=MomentumVectorChargedParticle.Phi();
+    Double_t eta2=MomentumVectorChargedParticle.Eta();
+
+
+    cone=100.;
+    if( TMath::Abs(phi2 - phi1) <= ( TMath::TwoPi()-coneSize) ){
+      cone = TMath::Sqrt(  TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-phi1),2) );
+    }else{
+      if( (phi2 - phi1)> TMath::TwoPi()-coneSize ){
+       cone = TMath::Sqrt(  TMath::Power((eta2-eta1),2)+ TMath::Power((phi2-TMath::TwoPi()-phi1),2) );
+      }
+      if( (phi2 - phi1)< -(TMath::TwoPi()-coneSize) ){
+       cone = TMath::Sqrt(  TMath::Power((eta2-eta1),2)+ TMath::Power((phi2+TMath::TwoPi()-phi1),2) );
+      }
+    }
+    
+    if(cone <coneSize&& MomentumVectorChargedParticle.Pt()>fMinPtJetCone ){
+      ptJet+= MomentumVectorChargedParticle.Pt();
+      Double_t ffzHdrGam = MomentumVectorChargedParticle.Pt()/MomentumVectorCurrentGamma.Pt();
+      Double_t imbalanceHdrGam=-MomentumVectorChargedParticle.Dot(MomentumVectorCurrentGamma)/MomentumVectorCurrentGamma.Mag2();
+      fHistograms->FillHistogram("ESD_FFzHdrGam",ffzHdrGam);
+      fHistograms->FillHistogram("ESD_ImbalanceHdrGam",imbalanceHdrGam);
+
+    }
+    
+    Double_t dphiHdrGam=phi3-phi2;
+    if ( dphiHdrGam < (-TMath::PiOver2())){
+      dphiHdrGam+=(TMath::TwoPi());
+    }
+    
+    if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
+      dphiHdrGam-=(TMath::TwoPi());
+    }
+
+    if (MomentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
+      fHistograms->FillHistogram("ESD_dphiHdrGamIsolated",dphiHdrGam);
+    }
+  }//track loop
+
+
+}
+
+Double_t AliAnalysisTaskGammaConversion::GetMinimumDistanceToCharge(Int_t indexHighestPtGamma){
+  // GetMinimumDistanceToCharge
+
+  Double_t fIsoMin=100.;
+  Double_t ptLeadingCharged=-1.;
+
+  AliKFParticle * gammaHighestPt = &fKFReconstructedGammas[indexHighestPtGamma];
+  TVector3 MomentumVectorgammaHighestPt(gammaHighestPt->GetPx(),gammaHighestPt->GetPy(),gammaHighestPt->GetPz());
+  Double_t phi1=MomentumVectorgammaHighestPt.Phi();
+  Double_t eta1=MomentumVectorgammaHighestPt.Eta();
+  
+  for(UInt_t iCh=0;iCh<fChargedParticles.size();iCh++){
+    AliESDtrack* curTrack = fChargedParticles[iCh];
+    Int_t chId = fChargedParticlesId[iCh];
+    if(fElectronv1[indexHighestPtGamma]==chId || fElectronv2[indexHighestPtGamma]==chId) continue;
+    Double_t mom[3];
+    curTrack->GetConstrainedPxPyPz(mom);
+    TVector3 MomentumVectorChargedParticle(mom[0],mom[1],mom[2]);
+    Double_t phi2=MomentumVectorChargedParticle.Phi();
+    Double_t eta2=MomentumVectorChargedParticle.Eta();
+    Double_t iso=pow(  (pow( (eta1-eta2),2)+ pow((phi1-phi2),2)),0.5 );
+    
+    if(MomentumVectorChargedParticle.Pt()>fMinPtIsoCone ){
+      if (iso<fIsoMin){
+       fIsoMin=iso;
+      }
+    }
+    
+    Double_t dphiHdrGam=phi1-phi2;
+    if ( dphiHdrGam < (-TMath::PiOver2())){
+      dphiHdrGam+=(TMath::TwoPi());
+    }
+    
+    if ( dphiHdrGam > (3.*TMath::PiOver2()) ){
+      dphiHdrGam-=(TMath::TwoPi());
+    }
+    if (MomentumVectorChargedParticle.Pt()>fMinPtGamChargedCorr){
+      fHistograms->FillHistogram("ESD_dphiHdrGam",dphiHdrGam);
+    }
+    
+    if (dphiHdrGam>0.9*TMath::Pi() && dphiHdrGam<1.1*TMath::Pi()){
+     if (MomentumVectorChargedParticle.Pt()> ptLeadingCharged && MomentumVectorChargedParticle.Pt()>0.1*MomentumVectorgammaHighestPt.Pt()){
+       ptLeadingCharged=MomentumVectorChargedParticle.Pt();
+       fLeadingChargedIndex=iCh;
+      }
+    }
+    
+  }//track loop
+  fHistograms->FillHistogram("ESD_MinimumIsoDistance",fIsoMin);
+  return fIsoMin;
+
+}
+
+ Int_t  AliAnalysisTaskGammaConversion::GetIndexHighestPtGamma(){
+   //GetIndexHighestPtGamma
+
+  Int_t indexHighestPtGamma=-1;
+  Double_t fGammaPtHighest = -100.;
+  
+  for(UInt_t firstGammaIndex=0;firstGammaIndex<fKFReconstructedGammas.size();firstGammaIndex++){
+     AliKFParticle * gammaHighestPtCandidate = &fKFReconstructedGammas[firstGammaIndex];
+     TVector3 MomentumVectorgammaHighestPtCandidate(gammaHighestPtCandidate->GetPx(),gammaHighestPtCandidate->GetPy(),gammaHighestPtCandidate->GetPz());
+     if (MomentumVectorgammaHighestPtCandidate.Pt() > fGammaPtHighest){
+       fGammaPtHighest=MomentumVectorgammaHighestPtCandidate.Pt();
+       //gammaHighestPt = gammaHighestPtCandidate;
+       indexHighestPtGamma=firstGammaIndex;
+     }
+  }
+  
+  return indexHighestPtGamma;
+
+}
+
+
+void AliAnalysisTaskGammaConversion::Terminate(Option_t */*option*/)
+{
+  // Terminate analysis
+  //
+  AliDebug(1,"Do nothing in Terminate");
+}
+
+void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
+{
+  //AOD
+  fAODBranch = new TClonesArray("AliGammaConversionAODObject", 0);
+  fAODBranch->SetName(fAODBranchName); 
+  AddAODBranch("TClonesArray", &fAODBranch);
+
+  // Create the output container
+  if(fOutputContainer != NULL){
+    delete fOutputContainer;
+    fOutputContainer = NULL;
+  }
+  if(fOutputContainer == NULL){
+    fOutputContainer = new TList();
+  }
+       
+  //Adding the histograms to the output container
+  fHistograms->GetOutputContainer(fOutputContainer);
+       
+       
+  if(fWriteNtuple){
+    if(fGammaNtuple == NULL){
+      fGammaNtuple = new TNtuple("V0ntuple","V0ntuple","OnTheFly:HasVertex:NegPIDProb:PosPIDProb:X:Y:Z:R:MotherCandidateNDF:MotherCandidateChi2:MotherCandidateEnergy:MotherCandidateEta:MotherCandidatePt:MotherCandidateMass:MotherCandidateWidth:MCMotherCandidatePT:EPOpeningAngle:ElectronEnergy:ElectronPt:ElectronEta:ElectronPhi:PositronEnergy:PositronPt:PositronEta:PositronPhi:HasSameMCMother:MotherMCParticlePIDCode",50000);
+    }
+    if(fNeutralMesonNtuple == NULL){
+      fNeutralMesonNtuple = new TNtuple("NeutralMesonNtuple","NeutralMesonNtuple","test");
+    }
+    TList * ntupleTList = new TList();
+    ntupleTList->SetName("Ntuple");
+    ntupleTList->Add((TNtuple*)fGammaNtuple);
+    fOutputContainer->Add(ntupleTList);
+  }
+       
+  fOutputContainer->SetName(GetName());
+}
+
+Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(TParticle* const daughter0, TParticle* const daughter1) const{
+  //helper function
+  TVector3 v3D0(daughter0->Px(),daughter0->Py(),daughter0->Pz());
+  TVector3 v3D1(daughter1->Px(),daughter1->Py(),daughter1->Pz());
+  return v3D0.Angle(v3D1);
+}
+
+void AliAnalysisTaskGammaConversion::CheckV0Efficiency(){
+  // see header file for documentation
+
+  vector<Int_t> indexOfGammaParticle;
+
+  fStack = fV0Reader->GetMCStack();
+
+  if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
+    return; // aborts if the primary vertex does not have contributors.
+  }
+
+  for (Int_t iTracks = 0; iTracks < fStack->GetNprimary(); iTracks++) {
+    TParticle* particle = (TParticle *)fStack->Particle(iTracks);
+    if(particle->GetPdgCode()==22){     //Gamma
+      if(particle->GetNDaughters() >= 2){
+       TParticle* electron=NULL;
+       TParticle* positron=NULL; 
+       for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
+         TParticle *tmpDaughter = fStack->Particle(daughterIndex);
+         if(tmpDaughter->GetUniqueID() == 5){
+           if(tmpDaughter->GetPdgCode() == 11){
+             electron = tmpDaughter;
+           }
+           else if(tmpDaughter->GetPdgCode() == -11){
+             positron = tmpDaughter;
+           }
+         }
+       }
+       if(electron!=NULL && positron!=0){
+         if(electron->R()<160){
+           indexOfGammaParticle.push_back(iTracks);
+         }
+       }
+      }
+    }
+  }
+
+  Int_t nFoundGammas=0;
+  Int_t nNotFoundGammas=0;
+
+  Int_t numberOfV0s = fV0Reader->GetNumberOfV0s();
+  for(Int_t i=0;i<numberOfV0s;i++){
+    fV0Reader->GetV0(i);
+    
+    if(fV0Reader->HasSameMCMother() == kFALSE){
+      continue;
+    }
+    
+    TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
+    TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
+    
+    if(TMath::Abs(negativeMC->GetPdgCode())!=11 || TMath::Abs(positiveMC->GetPdgCode())!=11){
+      continue;
+    }
+    if(negativeMC->GetPdgCode()==positiveMC->GetPdgCode()){
+      continue;
+    }
+    
+    if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){
+      //TParticle * v0Gamma = fV0Reader->GetMotherMCParticle();
+      for(UInt_t mcIndex=0;mcIndex<indexOfGammaParticle.size();mcIndex++){
+       if(negativeMC->GetFirstMother()==indexOfGammaParticle[mcIndex]){
+         nFoundGammas++;
+       }
+       else{
+         nNotFoundGammas++;
+       }
+      }
+    }
+  }
+  //  cout<<"Found: "<<nFoundGammas<<"  of: "<<indexOfGammaParticle.size()<<endl;
+}
+
+
+void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
+  // see header file for documantation
+
+  fESDEvent = fV0Reader->GetESDEvent();
+
+
+  vector <AliESDtrack*> vESDeNegTemp(0);
+  vector <AliESDtrack*> vESDePosTemp(0);
+  vector <AliESDtrack*> vESDxNegTemp(0);
+  vector <AliESDtrack*> vESDxPosTemp(0);
+  vector <AliESDtrack*> vESDeNegNoJPsi(0);
+  vector <AliESDtrack*> vESDePosNoJPsi(0); 
+
+
+
+  fHistograms->FillTable("Table_Electrons",0);//Count number of Events
+
+  for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
+    AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
+
+    if(!curTrack){
+      //print warning here
+      continue;
+    }
+
+    double p[3];if(!curTrack->GetConstrainedPxPyPz(p))continue;
+    double r[3];curTrack->GetConstrainedXYZ(r);
+
+    TVector3 rXYZ(r);
+
+    fHistograms->FillTable("Table_Electrons",4);//Count number of ESD tracks
+
+    Bool_t flagKink       =  kTRUE;
+    Bool_t flagTPCrefit   =  kTRUE;
+    Bool_t flagTRDrefit   =  kTRUE;
+    Bool_t flagITSrefit   =  kTRUE;
+    Bool_t flagTRDout     =  kTRUE;
+    Bool_t flagVertex     =  kTRUE;
+
+
+    //Cuts ---------------------------------------------------------------
+
+    if(curTrack->GetKinkIndex(0) > 0){
+      fHistograms->FillHistogram("Table_Electrons",5);//Count kink
+      flagKink = kFALSE;
+    }
+
+    ULong_t trkStatus = curTrack->GetStatus();
+
+    ULong_t tpcRefit = (trkStatus & AliESDtrack::kTPCrefit);
+
+    if(!tpcRefit){
+      fHistograms->FillHistogram("Table_Electrons",9);//Count not TPCrefit
+      flagTPCrefit = kFALSE;
+    }
+
+    ULong_t itsRefit = (trkStatus & AliESDtrack::kITSrefit);
+    if(!itsRefit){
+      fHistograms->FillHistogram("Table_Electrons",10);//Count not ITSrefit
+      flagITSrefit = kFALSE;
+    }
+
+    ULong_t trdRefit = (trkStatus & AliESDtrack::kTRDrefit);
+
+    if(!trdRefit){
+      fHistograms->FillHistogram("Table_Electrons",8); //Count not TRDrefit
+      flagTRDrefit = kFALSE;
+    }
+
+    ULong_t trdOut = (trkStatus & AliESDtrack::kTRDout);
+
+    if(!trdOut) {
+      fHistograms->FillHistogram("Table_Electrons",7); //Count not TRDout
+      flagTRDout = kFALSE;
+    }
+
+    double nsigmaToVxt = GetSigmaToVertex(curTrack);
+
+    if(nsigmaToVxt > 3){
+      fHistograms->FillHistogram("Table_Electrons",6); //Count Tracks with number of sigmas > 3
+      flagVertex = kFALSE;
+    }
+
+    if(! (flagKink && flagTPCrefit && flagITSrefit && flagTRDrefit && flagTRDout && flagVertex ) ) continue;
+    fHistograms->FillHistogram("Table_Electrons",11);//Count Tracks passed Cuts
+
+
+    Stat_t pid, weight;
+    GetPID(curTrack, pid, weight);
+
+    if(pid!=0){
+      fHistograms->FillHistogram("Table_Electrons",12); //Count Tracks with pid != 0
+    }
+
+    if(pid == 0){
+      fHistograms->FillHistogram("Table_Electrons",13); //Count Tracks with pid != 0
+    }
+
+
+
+
+    Int_t labelMC = TMath::Abs(curTrack->GetLabel());
+    TParticle* curParticle = fStack->Particle(labelMC);
+
+
+
+
+    TLorentzVector curElec;
+    curElec.SetXYZM(p[0],p[1],p[2],fElectronMass);
+
+
+
+
+    if(curTrack->GetSign() > 0){
+
+      vESDxPosTemp.push_back(curTrack);
+
+      if( pid == 0){
+
+       fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
+       fHistograms->FillHistogram("ESD_ElectronPosPt",curElec.Pt());
+       fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
+       fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
+       fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
+       vESDePosTemp.push_back(curTrack);
+
+
+
+      }
+
+    }
+    else {
+      vESDxNegTemp.push_back(curTrack);
+
+      if( pid == 0){
+
+       fHistograms->FillHistogram("ESD_ElectronPosNegPt",curElec.Pt());
+       fHistograms->FillHistogram("ESD_ElectronNegPt",curElec.Pt());
+       fHistograms->FillHistogram("MC_ElectronPosNegPt",curParticle->Pt());
+       fHistograms->FillHistogram("ESD_ElectronPosNegEta",curElec.Eta());
+       fHistograms->FillHistogram("MC_ElectronPosNegEta",curParticle->Eta());
+       vESDeNegTemp.push_back(curTrack);
+
+
+
+
+      }
+    }
+
+  }
+
+
+  Bool_t ePosJPsi = kFALSE;
+  Bool_t eNegJPsi = kFALSE;            
+  Bool_t ePosPi0  = kFALSE;
+  Bool_t eNegPi0  = kFALSE;
+       
+  UInt_t iePosJPsi=0,ieNegJPsi=0,iePosPi0=0,ieNegPi0=0;
+  for(UInt_t iNeg=0; iNeg < vESDeNegTemp.size(); iNeg++){
+    if(fStack->Particle(TMath::Abs(vESDeNegTemp[iNeg]->GetLabel()))->GetPdgCode() == 11)
+      if(fStack->Particle(TMath::Abs(vESDeNegTemp[iNeg]->GetLabel()))->GetMother(0) > -1){
+       Int_t labelMother = fStack->Particle(TMath::Abs(vESDeNegTemp[iNeg]->GetLabel()))->GetMother(0);
+       TParticle* partMother = fStack ->Particle(labelMother);
+       if (partMother->GetPdgCode() == 111){
+         ieNegPi0 = iNeg;
+         eNegPi0 = kTRUE;
+       }
+       if(partMother->GetPdgCode() == 443){ //Mother JPsi
+         fHistograms->FillTable("Table_Electrons",14);
+         ieNegJPsi = iNeg;
+         eNegJPsi = kTRUE;
+       }
+       else{   
+         vESDeNegNoJPsi.push_back(vESDeNegTemp[iNeg]);
+         //            cout<<"ESD No Positivo JPsi "<<endl;
+       }
+
+      }
+  }    
+
+  for(UInt_t iPos=0; iPos < vESDePosTemp.size(); iPos++){
+    if(fStack->Particle(TMath::Abs(vESDePosTemp[iPos]->GetLabel()))->GetPdgCode() == -11)
+      if(fStack->Particle(TMath::Abs(vESDePosTemp[iPos]->GetLabel()))->GetMother(0) > -1){
+       Int_t labelMother = fStack->Particle(TMath::Abs(vESDePosTemp[iPos]->GetLabel()))->GetMother(0);
+       TParticle* partMother = fStack ->Particle(labelMother);
+       if (partMother->GetPdgCode() == 111){
+         iePosPi0 = iPos;
+         ePosPi0 = kTRUE;
+       }
+       if(partMother->GetPdgCode() == 443){ //Mother JPsi
+         fHistograms->FillTable("Table_Electrons",15);
+         iePosJPsi = iPos;
+         ePosJPsi = kTRUE;
+       }
+       else{
+         vESDePosNoJPsi.push_back(vESDePosTemp[iPos]);
+         //            cout<<"ESD No Negativo JPsi "<<endl;
+       }
+
+      }
+  }
+       
+  if( eNegJPsi && ePosJPsi ){
+    TVector3 tempeNegV,tempePosV;
+    tempeNegV.SetXYZ(vESDeNegTemp[ieNegJPsi]->Px(),vESDeNegTemp[ieNegJPsi]->Py(),vESDeNegTemp[ieNegJPsi]->Pz());                       
+    tempePosV.SetXYZ(vESDePosTemp[iePosJPsi]->Px(),vESDePosTemp[iePosJPsi]->Py(),vESDePosTemp[iePosJPsi]->Pz());
+    fHistograms->FillTable("Table_Electrons",16);
+    fHistograms->FillHistogram("ESD_ElectronPosNegJPsiAngle",tempeNegV.Angle(tempePosV));      
+    fHistograms->FillHistogram("MC_ElectronPosNegJPsiAngle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(vESDeNegTemp[ieNegJPsi]->GetLabel())),
+                                                                             fStack->Particle(TMath::Abs(vESDePosTemp[iePosJPsi]->GetLabel()))));      
+  }
+       
+  if( eNegPi0 && ePosPi0 ){
+    TVector3 tempeNegV,tempePosV;
+    tempeNegV.SetXYZ(vESDeNegTemp[ieNegPi0]->Px(),vESDeNegTemp[ieNegPi0]->Py(),vESDeNegTemp[ieNegPi0]->Pz());
+    tempePosV.SetXYZ(vESDePosTemp[iePosPi0]->Px(),vESDePosTemp[iePosPi0]->Py(),vESDePosTemp[iePosPi0]->Pz());
+    fHistograms->FillHistogram("ESD_ElectronPosNegPi0Angle",tempeNegV.Angle(tempePosV));
+    fHistograms->FillHistogram("MC_ElectronPosNegPi0Angle",GetMCOpeningAngle(fStack->Particle(TMath::Abs(vESDeNegTemp[ieNegPi0]->GetLabel())),
+                                                                            fStack->Particle(TMath::Abs(vESDePosTemp[iePosPi0]->GetLabel()))));   
+  }
+        
+
+  FillAngle("ESD_eNegePosAngleBeforeCut",GetTLorentzVector(vESDeNegTemp),GetTLorentzVector(vESDePosTemp));
+
+  CleanWithAngleCuts(vESDeNegTemp,vESDePosTemp,fKFReconstructedGammas);
+       
+  vector <TLorentzVector> vCurrentTLVeNeg = GetTLorentzVector(fCurrentEventNegElectron);
+  vector <TLorentzVector> vCurrentTLVePos = GetTLorentzVector(fCurrentEventPosElectron);
+
+
+  FillAngle("ESD_eNegePosAngleAfterCut",vCurrentTLVeNeg,vCurrentTLVePos);
+
+
+
+  //FillAngle("ESD_eNegePosAngleAfterCut",CurrentTLVeNeg,CurrentTLVePos);
+
+
+  FillElectronInvMass("ESD_InvMass_ePluseMinus",vCurrentTLVeNeg,vCurrentTLVePos);
+  FillElectronInvMass("ESD_InvMass_xPlusxMinus",GetTLorentzVector(vESDxNegTemp),GetTLorentzVector(vESDxPosTemp));
+
+       
+
+  FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusChiC","ESD_InvMass_GammaePluseMinusChiCDiff",
+                          fKFReconstructedGammasCut,vCurrentTLVeNeg,vCurrentTLVePos);
+
+  FillGammaElectronInvMass("ESD_InvMass_GammaePluseMinusPi0","ESD_InvMass_GammaePluseMinusPi0Diff",
+                          fKFReconstructedGammasCut,vCurrentTLVeNeg,vCurrentTLVePos);
+
+  //BackGround
+
+  //Like Sign e+e-
+  ElectronBackground("ESD_ENegBackground",vCurrentTLVeNeg);
+  ElectronBackground("ESD_EPosBackground",vCurrentTLVePos);
+  ElectronBackground("ESD_EPosENegBackground",vCurrentTLVeNeg);
+  ElectronBackground("ESD_EPosENegBackground",vCurrentTLVePos);
+
+  //        Like Sign e+e- no JPsi
+  ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDeNegNoJPsi));
+  ElectronBackground("ESD_EPosENegNoJPsiBG",GetTLorentzVector(vESDePosNoJPsi));
+
+  //Mixed Event
+
+  if( fCurrentEventPosElectron.size() > 0 && fCurrentEventNegElectron.size() > 0 && fKFReconstructedGammasCut.size() > 0 ){
+    FillGammaElectronInvMass("ESD_EPosENegGammaBackgroundMX","ESD_EPosENegGammaBackgroundMXDiff",
+                            fKFReconstructedGammasCut,fPreviousEventTLVNegElectron,fPreviousEventTLVPosElectron);
+    fPreviousEventTLVNegElectron = vCurrentTLVeNeg;
+    fPreviousEventTLVPosElectron = vCurrentTLVePos;
+
+  }
+
+  /*
+  //Photons P
+  Double_t vtx[3];
+  vtx[0]=0;vtx[1]=0;vtx[2]=0;
+  for(UInt_t i=0;i<fKFReconstructedGammasChic.size();i++){
+
+  //      if(fMCGammaChicTempCut[i]->GetMother(0) < 0) continue;
+
+
+
+  Int_t tempLabel = fStack->Particle(fMCGammaChicTempCut[i]->GetMother(0))->GetPdgCode();
+  //      cout<<" Label Pedro Gonzalez " <<tempLabel <<endl;
+
+  //      cout<<" Label Distance"<<fKFReconstructedGammasChic[i].GetDistanceFromVertex(vtx)<<endl;
+
+  if( tempLabel == 10441 || tempLabel == 20443 || tempLabel == 445 )
+
+  fHistograms->FillHistogram("ESD_PhotonsMomentum",fKFReconstructedGammasChic[i].GetMomentum());
+
+
+  }
+
+
+  */
+
+
+}
+
+void AliAnalysisTaskGammaConversion::FillAngle(TString histoName,vector <TLorentzVector> tlVeNeg, vector <TLorentzVector> tlVePos){
+  //see header file for documentation
+  for( UInt_t iNeg=0; iNeg < tlVeNeg.size(); iNeg++){
+    for (UInt_t iPos=0; iPos < tlVePos.size(); iPos++){
+      fHistograms->FillHistogram(histoName.Data(),tlVeNeg[iNeg].Vect().Angle(tlVePos[iPos].Vect()));
+    }
+  }
+}
+void AliAnalysisTaskGammaConversion::FillElectronInvMass(TString histoName, vector <TLorentzVector> eNeg, vector <TLorentzVector> ePos){
+  //see header file for documentation
+  for( UInt_t n=0; n < eNeg.size(); n++){
+
+    TLorentzVector en = eNeg.at(n);
+    for (UInt_t p=0; p < ePos.size(); p++){
+      TLorentzVector ep = ePos.at(p);
+      TLorentzVector np = ep + en;
+      fHistograms->FillHistogram(histoName.Data(),np.M());
+    }
+  }
+
+}
+
+void AliAnalysisTaskGammaConversion::FillGammaElectronInvMass(TString histoMass,TString histoDiff,vector <AliKFParticle> fKFGammas,
+                                                             vector <TLorentzVector> tlVeNeg,vector<TLorentzVector> tlVePos)
+{
+  //see header file for documentation
+
+  for( UInt_t iNeg=0; iNeg < tlVeNeg.size(); iNeg++ ){
+
+    for (UInt_t iPos=0; iPos < tlVePos.size(); iPos++){
+
+      TLorentzVector xy = tlVePos[iPos] + tlVeNeg[iNeg];
+
+      for (UInt_t iGam=0; iGam < fKFGammas.size(); iGam++){
+
+       AliKFParticle * gammaCandidate = &fKFGammas[iGam];
+       TLorentzVector g;
+
+       g.SetXYZM(gammaCandidate->GetPx(),gammaCandidate->GetPy(),gammaCandidate->GetPz(),fGammaMass);
+       TLorentzVector xyg = xy + g;
+       fHistograms->FillHistogram(histoMass.Data(),xyg.M());
+       fHistograms->FillHistogram(histoDiff.Data(),(xyg.M()-xy.M()));
+      }
+    }
+  }
+
+}
+void AliAnalysisTaskGammaConversion::ElectronBackground(TString hBg, vector <TLorentzVector> e)
+{
+  // see header file for documentation
+  for(UInt_t i=0; i < e.size(); i++)
+    {
+      for (UInt_t j=i+1; j < e.size(); j++)
+       {
+         TLorentzVector ee = e[i] + e[j];
+
+         fHistograms->FillHistogram(hBg.Data(),ee.M());
+       }
+    }
+}
+
+
+void AliAnalysisTaskGammaConversion::CleanWithAngleCuts(vector <AliESDtrack*> negativeElectrons,
+                                                       vector <AliESDtrack*> positiveElectrons, vector <AliKFParticle> gammas){
+  // see header file for documentation
+
+  UInt_t  sizeN = negativeElectrons.size();
+  UInt_t  sizeP = positiveElectrons.size();
+  UInt_t  sizeG = gammas.size();
+
+
+
+  vector <Bool_t> xNegBand(sizeN);
+  vector <Bool_t> xPosBand(sizeP);
+  vector <Bool_t> gammaBand(sizeG);
+
+
+  for(UInt_t iNeg=0; iNeg < sizeN; iNeg++) xNegBand[iNeg]=kTRUE;
+  for(UInt_t iPos=0; iPos < sizeP; iPos++) xPosBand[iPos]=kTRUE;
+  for(UInt_t iGam=0; iGam < sizeG; iGam++) gammaBand[iGam]=kTRUE;
+
+
+  for(UInt_t iPos=0; iPos < sizeP; iPos++){
+       
+    Double_t aP[3]; positiveElectrons[iPos]->GetConstrainedPxPyPz(aP); 
+
+    TVector3 ePosV(aP[0],aP[1],aP[2]);
+
+    for(UInt_t iNeg=0; iNeg < sizeN; iNeg++){
+       
+      Double_t aN[3]; negativeElectrons[iNeg]->GetConstrainedPxPyPz(aN); 
+      TVector3 eNegV(aN[0],aN[1],aN[2]);
+
+      if(ePosV.Angle(eNegV) < 0.05){ //e+e- from gamma
+       xPosBand[iPos]=kFALSE;
+       xNegBand[iNeg]=kFALSE;
+      }
+
+      for(UInt_t iGam=0; iGam < sizeG; iGam++){
+       AliKFParticle* gammaCandidate = &gammas[iGam];
+       TVector3 gammaCandidateVector(gammaCandidate->Px(),gammaCandidate->Py(),gammaCandidate->Pz());
+       if(ePosV.Angle(gammaCandidateVector) < 0.05 || eNegV.Angle(gammaCandidateVector) < 0.05)
+         gammaBand[iGam]=kFALSE;
+      }
+    }
+  }
+
+
+
+
+  for(UInt_t iPos=0; iPos < sizeP; iPos++){
+    if(xPosBand[iPos]){
+      fCurrentEventPosElectron.push_back(positiveElectrons[iPos]);
+    }
+  }
+  for(UInt_t iNeg=0;iNeg < sizeN; iNeg++){
+    if(xNegBand[iNeg]){
+      fCurrentEventNegElectron.push_back(negativeElectrons[iNeg]);
+    }
+  }
+  for(UInt_t iGam=0; iGam < sizeG; iGam++){
+    if(gammaBand[iGam]){
+      fKFReconstructedGammasCut.push_back(gammas[iGam]);
+    }
+  }
+}
+
+
+void  AliAnalysisTaskGammaConversion::GetPID(AliESDtrack *track, Stat_t &pid, Stat_t &weight)
+{
+  // see header file for documentation
+  pid = -1;
+  weight = -1;
+
+  double wpart[5];
+  double wpartbayes[5];
+
+  //get probability of the diffenrent particle types
+  track->GetESDpid(wpart);
+
+  // Tentative particle type "concentrations"
+  double c[5]={0.01, 0.01, 0.85, 0.10, 0.05};
+
+  //Bayes' formula
+  double rcc = 0.;
+  for (int i = 0; i < 5; i++)
+    {
+      rcc+=(c[i] * wpart[i]);
+    }
+
+
+
+  for (int i=0; i<5; i++) {
+    if( rcc!=0){
+      wpartbayes[i] = c[i] * wpart[i] / rcc;
+    }
+  }
+
+
+
+  Float_t max=0.;
+  int ipid=-1;
+  //find most probable particle in ESD pid
+  //0:Electron - 1:Muon - 2:Pion - 3:Kaon - 4:Proton
+  for (int i = 0; i < 5; i++)
+    {
+      if (wpartbayes[i] > max)
+        {
+          ipid = i;
+          max = wpartbayes[i];
+        }
+    }
+
+  pid = ipid;
+  weight = max;
+}
+double AliAnalysisTaskGammaConversion::GetSigmaToVertex(AliESDtrack* t)
+{
+  // Calculates the number of sigma to the vertex.
+
+  Float_t b[2];
+  Float_t bRes[2];
+  Float_t bCov[3];
+  t->GetImpactParameters(b,bCov);
+  if (bCov[0]<=0 || bCov[2]<=0) {
+    AliDebug(1, "Estimated b resolution lower or equal zero!");
+    bCov[0]=0; bCov[2]=0;
+  }
+  bRes[0] = TMath::Sqrt(bCov[0]);
+  bRes[1] = TMath::Sqrt(bCov[2]);
+
+  // -----------------------------------
+  // How to get to a n-sigma cut?
+  //
+  // The accumulated statistics from 0 to d is
+  //
+  // ->  Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
+  // ->  1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
+  //
+  // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
+  // Can this be expressed in a different way?
+
+  if (bRes[0] == 0 || bRes[1] ==0)
+    return -1;
+
+  double d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
+
+  // stupid rounding problem screws up everything:
+  // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
+  if (TMath::Exp(-d * d / 2) < 1e-10)
+    return 1000;
+
+
+  d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
+  return d;
+}
+vector <TLorentzVector> AliAnalysisTaskGammaConversion::GetTLorentzVector(vector <AliESDtrack*> esdTrack){
+
+  vector <TLorentzVector> tlVtrack(0);
+
+  for(UInt_t itrack=0; itrack < esdTrack.size(); itrack++){
+    double P[3]; esdTrack[itrack]->GetConstrainedPxPyPz(P);
+    TLorentzVector currentTrack;
+    currentTrack.SetXYZM(P[0],P[1],P[2],fElectronMass);
+    tlVtrack.push_back(currentTrack);
+  }
+
+  return tlVtrack;
+}
+
index 68b828eb93e467217fbbfd47ff7c46559ed246ec..286116511fb2f3066da3f211aa1a692da81027b4 100644 (file)
-#ifndef ALIANALYSISTASKGAMMACONVERSION_H\r
-#define ALIANALYSISTASKGAMMACONVERSION_H\r
\r
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- * See cxx source for full Copyright notice                               */\r
-\r
-////////////////////////////////////////////////\r
-//--------------------------------------------- \r
-// Class used to do analysis on conversion pairs\r
-//---------------------------------------------\r
-////////////////////////////////////////////////\r
\r
-#include "AliAnalysisTaskSE.h"\r
-#include <vector>\r
-#include "AliV0Reader.h"\r
-\r
-class TNtuple;\r
-class AliGammaConversionHistograms;\r
-class AliESDv0;\r
-class AliKFParticle;\r
-class AliESDInputHandler;\r
-class AliESDEvent;\r
-class AliAODEvent;\r
-class TList;\r
-class AliStack;\r
-\r
-class AliAnalysisTaskGammaConversion : public AliAnalysisTaskSE\r
-{\r
- public:\r
-  AliAnalysisTaskGammaConversion();\r
-  AliAnalysisTaskGammaConversion(const char* name);\r
-  virtual ~AliAnalysisTaskGammaConversion() ;// virtual destructor\r
\r
-  // Implementation of interface methods\r
-  virtual void UserCreateOutputObjects();\r
-  virtual void Init();\r
-  virtual void LocalInit() {Init();}\r
-  virtual void Exec(Option_t *option);\r
-  virtual void Terminate(Option_t *option);\r
-  virtual void ConnectInputData(Option_t *);\r
-       \r
-  void ProcessMCData();\r
-  void ProcessV0sNoCut();\r
-  void ProcessV0s();\r
-  void ProcessGammasForNeutralMesonAnalysis();\r
-  void SetHistograms(AliGammaConversionHistograms *const histograms){fHistograms=histograms;}\r
-  void SetDoMCTruth(Bool_t flag){fDoMCTruth=flag;}\r
-  void SetElectronMass(Double_t electronMass){fElectronMass = electronMass;}\r
-  void SetGammaMass(Double_t gammaMass){fGammaMass = gammaMass;}\r
-  void SetGammaWidth(Double_t gammaWidth){fGammaWidth = gammaWidth;}\r
-  void SetPi0Mass(Double_t pi0Mass){fPi0Mass = pi0Mass;}\r
-  void SetPi0Width(Double_t pi0Width){fPi0Width = pi0Width;}\r
-  void SetEtaMass(Double_t etaMass){fEtaMass = etaMass;}\r
-  void SetEtaWidth(Double_t etaWidth){fEtaWidth = etaWidth;}\r
-  void SetMinOpeningAngleGhostCut(Double_t ghostCut){fMinOpeningAngleGhostCut = ghostCut;}\r
-  void SetV0Reader(AliV0Reader* const reader){fV0Reader=reader;}\r
-  void SetCalculateBackground(Bool_t bg){fCalculateBackground=bg;}\r
-  void CalculateBackground();\r
-  void SetWriteNtuple(Bool_t writeNtuple){fWriteNtuple = writeNtuple;}\r
-  void FillNtuple();\r
-  Double_t GetMCOpeningAngle(TParticle* const daughter0, TParticle* const daughter1) const;\r
-  void CheckV0Efficiency();\r
-\r
-\r
-  //////////////////Chi_c Analysis////////////////////////////\r
-  void GetPID(AliESDtrack *track, Stat_t &pid, Stat_t &weight);        \r
-  double GetSigmaToVertex(AliESDtrack* t);\r
-  void ElectronBackground(TString hBg, vector <TLorentzVector> e);\r
-  void FillAngle(TString histoName,vector <TLorentzVector> tlVeNeg, vector <TLorentzVector> tlVePos);\r
-  void FillElectronInvMass(TString histoName, vector <TLorentzVector> negativeElectron, \r
-       vector <TLorentzVector> positiveElectron);\r
-  void FillGammaElectronInvMass(TString histoMass,TString histoDiff,vector <AliKFParticle> fKFGammas,\r
-        vector <TLorentzVector> tlVeNeg,vector<TLorentzVector> tlVePos);\r
-  void CleanWithAngleCuts(vector <AliESDtrack*> negativeElectrons,\r
-       vector <AliESDtrack*> positiveElectrons, vector <AliKFParticle> gammas);\r
-  vector <TLorentzVector> GetTLorentzVector(vector <AliESDtrack*> esdTrack);   \r
-  void ProcessGammaElectronsForChicAnalysis();\r
-  ///////////////////////////////////////////////////////////////\r
-\r
-\r
-\r
- private:\r
-  AliAnalysisTaskGammaConversion(const AliAnalysisTaskGammaConversion&); // Not implemented\r
-  AliAnalysisTaskGammaConversion& operator=(const AliAnalysisTaskGammaConversion&); // Not implemented\r
-\r
-  AliV0Reader* fV0Reader; // The V0 reader object \r
-\r
-  AliStack * fStack; // pointer to the MC particle stack\r
-  AliESDEvent* fESDEvent; //pointer to the ESDEvent\r
-  TList * fOutputContainer ; // Histogram container\r
-\r
-  AliGammaConversionHistograms *fHistograms; // Pointer to the histogram handling class\r
-\r
-  Bool_t fDoMCTruth; // Flag to switch on/off MC truth \r
-    \r
-  vector<TParticle*> fMCAllGammas; // vector containing all MC gammas\r
-  vector<TParticle*> fMCPi0s; //vector containing all MC Pi0s\r
-  vector<TParticle*> fMCEtas; //vector containing all MC Etas\r
-  vector<TParticle*> fMCGammaChic; //vector containing all MC Chi_c's\r
-\r
-  vector<AliKFParticle> fKFReconstructedGammas; // vector containing all reconstructed gammas\r
-  vector<Bool_t> fIsTrueReconstructedGammas;    // vector containing information if this was a true gamma or not (follows the index of fKFReconstructedGammas)\r
-  vector<Int_t> fElectronv1; // vector containing index of electron 1\r
-  vector<Int_t> fElectronv2; // vector containing index of electron 2\r
-\r
-  ///////Chi_c Analysis///////////////////////////\r
-  vector<AliESDtrack*> fCurrentEventPosElectron;       // comment here\r
-  vector<AliESDtrack*> fPreviousEventPosElectron;      //comment here\r
-  vector<AliESDtrack*> fCurrentEventNegElectron;       //comment here\r
-  vector<AliESDtrack*> fPreviousEventNegElectron;      //comment here\r
-  vector<AliKFParticle> fKFReconstructedGammasCut;     //comment here\r
-  vector<TLorentzVector> fPreviousEventTLVNegElectron; //comment here\r
-  vector<TLorentzVector> fPreviousEventTLVPosElectron; //comment here\r
-  //////////////////////////////////////////////////   \r
-\r
-  //mass defines\r
-  Double_t fElectronMass; //electron mass\r
-  Double_t fGammaMass;    //gamma mass\r
-  Double_t fPi0Mass;      //pi0mass\r
-  Double_t fEtaMass;      //eta mass\r
-\r
-  // width defines\r
-  Double_t fGammaWidth; //gamma width cut\r
-  Double_t fPi0Width;   // pi0 width cut\r
-  Double_t fEtaWidth;   // eta width cut\r
-\r
-  Double_t fMinOpeningAngleGhostCut; // minimum angle cut\r
-\r
-  Bool_t fCalculateBackground; //flag to set backgrount calculation on/off\r
-  Bool_t fWriteNtuple;         // flag to set if writing to ntuple on/off\r
-  TNtuple *fGammaNtuple;       // Ntuple for gamma values\r
-  TNtuple *fNeutralMesonNtuple;// NTuple for mesons\r
-\r
-  Int_t fTotalNumberOfAddedNtupleEntries; // number of added ntuple entries\r
-\r
-  ClassDef(AliAnalysisTaskGammaConversion, 3); // Analysis task for gamma conversions\r
-};\r
\r
-#endif //ALIANALYSISTASKGAMMA_H\r
+#ifndef ALIANALYSISTASKGAMMACONVERSION_H
+#define ALIANALYSISTASKGAMMACONVERSION_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class used to do analysis on conversion pairs
+//---------------------------------------------
+////////////////////////////////////////////////
+#include "AliAnalysisTaskSE.h"
+#include <vector>
+#include "AliV0Reader.h"
+#include "AliGammaConversionAODObject.h"
+
+class TNtuple;
+class AliGammaConversionHistograms;
+class AliESDv0;
+class AliKFParticle;
+class AliESDInputHandler;
+class AliESDEvent;
+class AliAODEvent;
+class TList;
+class AliStack;
+class AliESDtrackCuts;
+
+
+class AliAnalysisTaskGammaConversion : public AliAnalysisTaskSE
+{
+ public:
+  AliAnalysisTaskGammaConversion();
+  AliAnalysisTaskGammaConversion(const char* name);
+  virtual ~AliAnalysisTaskGammaConversion() ;// virtual destructor
+  // Implementation of interface methods
+  virtual void UserCreateOutputObjects();
+  virtual void Init();
+  virtual void LocalInit() {Init();}
+  virtual void Exec(Option_t *option);
+  virtual void Terminate(Option_t *option);
+  virtual void ConnectInputData(Option_t *);
+       
+  void ProcessMCData();
+  void ProcessV0sNoCut();
+  void ProcessV0s();
+  void ProcessGammasForNeutralMesonAnalysis();
+
+  // AOD
+  TString GetAODBranchName() const {return  fAODBranchName;}
+  void SetAODBranchName(TString name)  {fAODBranchName = name ;}       
+  void FillAODWithConversionGammas();
+  // end AOD
+
+
+ // for GammaJetAnalysis
+  void ProcessGammasForGammaJetAnalysis();
+  void CreateListOfChargedParticles();
+  Double_t GetMinimumDistanceToCharge(Int_t);
+  void CalculateJetCone(Int_t,Int_t);
+  Int_t GetIndexHighestPtGamma();
+  void SetESDtrackCuts();
+  // end of Gamma Jet
+
+  void SetMinPtForGammaJet(Double_t minPtForGammaJet){fMinPtForGammaJet=minPtForGammaJet;}
+  void SetMinIsoConeSize(Double_t minIsoConeSize){fMinIsoConeSize=minIsoConeSize;}
+  void SetMinPtIsoCone(Double_t minPtIsoCone){fMinPtIsoCone=minPtIsoCone;}
+  void SetMinPtGamChargedCorr(Double_t minPtGamChargedCorr){fMinPtGamChargedCorr=minPtGamChargedCorr;}
+  void SetMinPtJetCone(Double_t minPtJetCone){fMinPtJetCone=minPtJetCone;}
+
+  void SetHistograms(AliGammaConversionHistograms *const histograms){fHistograms=histograms;}
+  void SetDoMCTruth(Bool_t flag){fDoMCTruth=flag;}
+  void SetDoNeutralMeson(Bool_t flag){fDoNeutralMeson=flag;}
+  void SetDoJet(Bool_t flag){fDoJet=flag;}
+  void SetDoChic(Bool_t flag){fDoChic=flag;}
+
+  void SetElectronMass(Double_t electronMass){fElectronMass = electronMass;}
+  void SetGammaMass(Double_t gammaMass){fGammaMass = gammaMass;}
+  void SetGammaWidth(Double_t gammaWidth){fGammaWidth = gammaWidth;}
+  void SetPi0Mass(Double_t pi0Mass){fPi0Mass = pi0Mass;}
+  void SetPi0Width(Double_t pi0Width){fPi0Width = pi0Width;}
+  void SetEtaMass(Double_t etaMass){fEtaMass = etaMass;}
+  void SetEtaWidth(Double_t etaWidth){fEtaWidth = etaWidth;}
+  void SetMinOpeningAngleGhostCut(Double_t ghostCut){fMinOpeningAngleGhostCut = ghostCut;}
+  void SetV0Reader(AliV0Reader* const reader){fV0Reader=reader;}
+  void SetCalculateBackground(Bool_t bg){fCalculateBackground=bg;}
+  void CalculateBackground();
+  void SetWriteNtuple(Bool_t writeNtuple){fWriteNtuple = writeNtuple;}
+  void FillNtuple();
+  Double_t GetMCOpeningAngle(TParticle* const daughter0, TParticle* const daughter1) const;
+  void CheckV0Efficiency();
+
+
+  //////////////////Chi_c Analysis////////////////////////////
+  void GetPID(AliESDtrack *track, Stat_t &pid, Stat_t &weight);        
+  double GetSigmaToVertex(AliESDtrack* t);
+  void ElectronBackground(TString hBg, vector <TLorentzVector> e);
+  void FillAngle(TString histoName,vector <TLorentzVector> tlVeNeg, vector <TLorentzVector> tlVePos);
+  void FillElectronInvMass(TString histoName, vector <TLorentzVector> negativeElectron, 
+       vector <TLorentzVector> positiveElectron);
+  void FillGammaElectronInvMass(TString histoMass,TString histoDiff,vector <AliKFParticle> fKFGammas,
+        vector <TLorentzVector> tlVeNeg,vector<TLorentzVector> tlVePos);
+  void CleanWithAngleCuts(vector <AliESDtrack*> negativeElectrons,
+       vector <AliESDtrack*> positiveElectrons, vector <AliKFParticle> gammas);
+  vector <TLorentzVector> GetTLorentzVector(vector <AliESDtrack*> esdTrack);   
+  void ProcessGammaElectronsForChicAnalysis();
+  ///////////////////////////////////////////////////////////////
+
+
+
+ private:
+  AliAnalysisTaskGammaConversion(const AliAnalysisTaskGammaConversion&); // Not implemented
+  AliAnalysisTaskGammaConversion& operator=(const AliAnalysisTaskGammaConversion&); // Not implemented
+
+  AliV0Reader* fV0Reader; // The V0 reader object 
+
+  AliStack * fStack; // pointer to the MC particle stack
+  AliESDEvent* fESDEvent; //pointer to the ESDEvent
+  TList * fOutputContainer ; // Histogram container
+
+  AliGammaConversionHistograms *fHistograms; // Pointer to the histogram handling class
+
+  Bool_t fDoMCTruth; // Flag to switch on/off MC truth 
+  Bool_t fDoNeutralMeson;
+  Bool_t fDoJet;
+  Bool_t fDoChic;
+    
+  vector<TParticle*> fMCAllGammas; // vector containing all MC gammas
+  vector<TParticle*> fMCPi0s; //vector containing all MC Pi0s
+  vector<TParticle*> fMCEtas; //vector containing all MC Etas
+  vector<TParticle*> fMCGammaChic; //vector containing all MC Chi_c's
+
+  vector<AliKFParticle> fKFReconstructedGammas; // vector containing all reconstructed gammas
+  vector<Bool_t> fIsTrueReconstructedGammas;    // vector containing information if this was a true gamma or not (follows the index of fKFReconstructedGammas)
+  vector<Int_t> fElectronv1; // vector containing index of electron 1
+  vector<Int_t> fElectronv2; // vector containing index of electron 2
+
+  ///////Chi_c Analysis///////////////////////////
+  vector<AliESDtrack*> fCurrentEventPosElectron;       // comment here
+  vector<AliESDtrack*> fPreviousEventPosElectron;      //comment here
+  vector<AliESDtrack*> fCurrentEventNegElectron;       //comment here
+  vector<AliESDtrack*> fPreviousEventNegElectron;      //comment here
+  vector<AliKFParticle> fKFReconstructedGammasCut;     //comment here
+  vector<TLorentzVector> fPreviousEventTLVNegElectron; //comment here
+  vector<TLorentzVector> fPreviousEventTLVPosElectron; //comment here
+  //////////////////////////////////////////////////   
+
+  //mass defines
+  Double_t fElectronMass; //electron mass
+  Double_t fGammaMass;    //gamma mass
+  Double_t fPi0Mass;      //pi0mass
+  Double_t fEtaMass;      //eta mass
+
+  // width defines
+  Double_t fGammaWidth; //gamma width cut
+  Double_t fPi0Width;   // pi0 width cut
+  Double_t fEtaWidth;   // eta width cut
+
+  Double_t fMinOpeningAngleGhostCut; // minimum angle cut
+
+  AliESDtrackCuts* fEsdTrackCuts;           // Object containing the parameters of the esd track cuts
+
+  Bool_t fCalculateBackground; //flag to set backgrount calculation on/off
+  Bool_t fWriteNtuple;         // flag to set if writing to ntuple on/off
+  TNtuple *fGammaNtuple;       // Ntuple for gamma values
+  TNtuple *fNeutralMesonNtuple;// NTuple for mesons
+
+  Int_t fTotalNumberOfAddedNtupleEntries; // number of added ntuple entries
+
+  vector<AliESDtrack*> fChargedParticles;
+  vector<Int_t> fChargedParticlesId;
+
+  Double_t fGammaPtHighest;
+  Double_t fMinPtForGammaJet;
+  Double_t fMinIsoConeSize;
+  Double_t fMinPtIsoCone;
+  Double_t fMinPtGamChargedCorr;
+  Double_t fMinPtJetCone;
+  Int_t    fLeadingChargedIndex;
+
+  TClonesArray* fAODBranch ;        //! selected particles branch
+  TString fAODBranchName; // New AOD branch name
+  
+  vector<AliGammaConversionAODObject> fAODObjects;
+
+  ClassDef(AliAnalysisTaskGammaConversion, 4); // Analysis task for gamma conversions
+};
+#endif //ALIANALYSISTASKGAMMA_H
diff --git a/PWG4/GammaConv/AliGammaConversionAODObject.cxx b/PWG4/GammaConv/AliGammaConversionAODObject.cxx
new file mode 100644 (file)
index 0000000..4166aab
--- /dev/null
@@ -0,0 +1,125 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt                        *
+ * Version 1.0                                                            *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class containing the aod information we need
+//---------------------------------------------
+////////////////////////////////////////////////
+
+#include "AliGammaConversionAODObject.h"
+#include "AliAODv0.h"
+#include "AliStack.h"
+#include "AliESDEvent.h"
+#include "AliESDtrack.h"
+#include "TParticle.h"
+
+using namespace std;
+
+ClassImp(AliGammaConversionAODObject)
+
+
+
+AliGammaConversionAODObject::AliGammaConversionAODObject() :
+  TObject(),
+  fPx(0),
+  fPy(0),
+  fPz(0),
+  fLabel1(-1),
+  fLabel2(-1),
+  fMCStack(NULL),
+  fESDEvent(NULL)
+{
+       
+}
+
+
+AliGammaConversionAODObject::AliGammaConversionAODObject(const AliGammaConversionAODObject & original) :
+  TObject(original),
+  fPx(original.fPx),
+  fPy(original.fPy),
+  fPz(original.fPz),
+  fLabel1(original.fLabel1),
+  fLabel2(original.fLabel2),
+  fMCStack(original.fMCStack),
+  fESDEvent(original.fESDEvent)
+{
+       
+}
+
+
+AliGammaConversionAODObject & AliGammaConversionAODObject::operator = (const AliGammaConversionAODObject & /*source*/)
+{
+  // assignment operator
+  return *this;
+}
+
+Int_t AliGammaConversionAODObject::GetGammaMCLabel() const{
+  // returns the MC label of the gamma (if both electrons have the same mother)
+  Int_t iResult = -1;
+  if(fMCStack != NULL){
+    Int_t mcLabel1= GetElectronMCLabel1();
+    Int_t mcLabel2= GetElectronMCLabel2();
+    if(mcLabel1>=0 && mcLabel2>=0){
+      TParticle *electron1 = fMCStack->Particle(mcLabel1);
+      TParticle *electron2 = fMCStack->Particle(mcLabel2);
+      if(electron1->GetMother(0) == electron2->GetMother(0)){
+       iResult = electron1->GetMother(0);
+      }
+    }
+  }
+  return iResult;
+}
+
+Int_t AliGammaConversionAODObject::GetElectronUniqueID() const{
+  // returns the unique id of the electrons if they have the same mother and unique id
+  Int_t iResult = -1;
+  if(fMCStack != NULL){
+    Int_t mcLabel1= GetElectronMCLabel1();
+    Int_t mcLabel2= GetElectronMCLabel2();
+    if(mcLabel1>=0 && mcLabel2>=0){
+      TParticle *electron1 = fMCStack->Particle(mcLabel1);
+      TParticle *electron2 = fMCStack->Particle(mcLabel2);
+      if(electron1->GetMother(0) == electron2->GetMother(0)){
+       if(electron1->GetUniqueID() == electron2->GetUniqueID()){
+         iResult = (Int_t)electron1->GetUniqueID();
+       }
+      }
+    }
+  }
+  return iResult;
+}
+
+Int_t AliGammaConversionAODObject::GetElectronMCLabel1() const{
+  //returns the MC label of the first electron
+  Int_t iResult=-1;
+  if(fESDEvent != NULL){
+    if(fLabel1>=0){
+      iResult = (fESDEvent->GetTrack(fLabel1))->GetLabel();
+    }
+  }
+  return iResult;
+}
+
+Int_t AliGammaConversionAODObject::GetElectronMCLabel2() const{
+  //returns the MC label of the first electron
+  Int_t iResult=-1;
+  if(fESDEvent != NULL){
+    if(fLabel2>=0){
+      iResult = (fESDEvent->GetTrack(fLabel2))->GetLabel();
+    }
+  }
+  return iResult;
+}
diff --git a/PWG4/GammaConv/AliGammaConversionAODObject.h b/PWG4/GammaConv/AliGammaConversionAODObject.h
new file mode 100644 (file)
index 0000000..6aea388
--- /dev/null
@@ -0,0 +1,124 @@
+#ifndef ALIGAMMACONVERSIONAODOBJECT_H
+#define ALIGAMMACONVERSIONAODOBJECT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class containing the aod information
+//---------------------------------------------
+////////////////////////////////////////////////
+
+// --- ROOT system ---
+#include "TObject.h" 
+class AliStack;
+class AliESDEvent;
+
+class AliGammaConversionAODObject : public TObject {
+
+ public: 
+
+  AliGammaConversionAODObject();                                        //constructor
+  AliGammaConversionAODObject(const AliGammaConversionAODObject & g);                   //copy constructor
+  AliGammaConversionAODObject & operator = (const AliGammaConversionAODObject & g);     //assignment operator
+  virtual ~AliGammaConversionAODObject() {;}                            //virtual destructor
+
+  /*
+   * This function sets the Px
+   */
+  void SetPx(Float_t px){fPx = px;}
+
+  /*
+   * This function sets the Py
+   */
+  void SetPy(Float_t py){fPy = py;}
+
+  /*
+   * This function sets the Pz
+   */
+  void SetPz(Float_t pz){fPz = pz;}
+
+  /*
+   * This function sets the esd label of the first electron
+   */
+  void SetLabel1(Int_t label){fLabel1 = label;}
+
+  /*
+   * This function sets the esd label of the second electron
+   */
+  void SetLabel2(Int_t label){fLabel2 = label;}
+  
+  /*
+   * This function returns the Px
+   */
+  Float_t GetGammaPx() const{return fPx;}
+
+  /*
+   * This function returns the Py
+   */
+  Float_t GetGammaPy() const{return fPy;}
+
+  /*
+   * This function returns the Pz
+   */
+  Float_t GetGammaPz() const{return fPz;}
+
+  /*
+   * This function returns the esd label of the first electron
+   */
+  Int_t GetElectronLabel1() const{return fLabel1;}
+
+  /*
+   * This function returns the esd label of the second electron
+   */
+  Int_t GetElectronLabel2()const {return fLabel2;}
+
+
+  /*
+   * This function sets the MC stack
+   */
+  void SetStack(AliStack* stack){fMCStack=stack;}
+
+  /*
+   * This function sets the ESD event
+   */
+  void SetESDEvent(AliESDEvent* esdEvent){fESDEvent = esdEvent;}
+
+  /*
+   * This function returns the Gamma MC label
+   */
+  Int_t GetGammaMCLabel() const;
+
+  /*
+   * This function returns the unique id  of the electrons (if they have the same mother and unique id)
+   */
+  Int_t GetElectronUniqueID() const;
+
+  /*
+   * This function returns the MC label of the first electron
+   */
+  Int_t GetElectronMCLabel1() const;
+
+  /*
+   * This function returns the MC label of the second electron
+   */
+  Int_t GetElectronMCLabel2() const;
+
+ private:
+
+  Float_t fPx;
+  Float_t fPy;
+  Float_t fPz;
+  Int_t fLabel1;
+  Int_t fLabel2;
+  AliStack* fMCStack;
+  AliESDEvent * fESDEvent;
+
+  ClassDef(AliGammaConversionAODObject,0)
+};
+
+
+#endif
+
+
+
index 14c603f8bebe80b2747e640c5810c906a383712b..f25e0ea160dc79f6a2fe54eb1af825c636bbdf08 100644 (file)
-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- *                                                                        *\r
- * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt                        *\r
- * Version 1.1                                                            *\r
- *                                                                        *\r
- * Permission to use, copy, modify and distribute this software and its   *\r
- * documentation strictly for non-commercial purposes is hereby granted   *\r
- * without fee, provided that the above copyright notice appears in all   *\r
- * copies and that both the copyright notice and this permission notice   *\r
- * appear in the supporting documentation. The authors make no claims     *\r
- * about the suitability of this software for any purpose. It is          *\r
- * provided "as is" without express or implied warranty.                  *\r
- **************************************************************************/\r
-\r
-////////////////////////////////////////////////\r
-//--------------------------------------------- \r
-// Class used to do analysis on conversion pairs\r
-//---------------------------------------------\r
-////////////////////////////////////////////////\r
-\r
-#include "AliGammaConversionHistograms.h"\r
-#include "TMath.h"\r
-#include "TObjString.h"\r
-#include "TMap.h"\r
-#include "TList.h"\r
-#include "TH1F.h"\r
-#include "TH2F.h"\r
-\r
-\r
-using namespace std;\r
-\r
-ClassImp(AliGammaConversionHistograms)\r
-\r
-\r
-AliGammaConversionHistograms::AliGammaConversionHistograms() :\r
-  fHistogramMap(new TMap()),\r
-  fNPhiIndex(0),\r
-  fNRIndex(0),\r
-  fMinRadius(0.),\r
-  fMaxRadius(0.),\r
-  fDeltaR(0.),\r
-  fMinPhi(0.),\r
-  fMaxPhi(0.),\r
-  fDeltaPhi(0.),\r
-  fMappingContainer(NULL),\r
-  fBackgroundContainer(NULL),\r
-  fDebugContainer(NULL),\r
-  fResolutionContainer(NULL),\r
-  fMatchContainer(NULL),\r
-  fESDContainer(NULL),\r
-  fMCContainer(NULL),\r
-  fTableContainer(NULL),       \r
-  fOtherContainer(NULL)\r
-{\r
-  // see header file for documenation\r
-}\r
-\r
-\r
-AliGammaConversionHistograms::AliGammaConversionHistograms(const AliGammaConversionHistograms & original) :\r
-  fHistogramMap(original.fHistogramMap),\r
-  fNPhiIndex(original.fNPhiIndex),\r
-  fNRIndex(original.fNRIndex),\r
-  fMinRadius(original.fMinRadius),\r
-  fMaxRadius(original.fMaxRadius),\r
-  fDeltaR(original.fDeltaR),\r
-  fMinPhi(original.fMinPhi),\r
-  fMaxPhi(original.fMaxPhi),\r
-  fDeltaPhi(original.fDeltaPhi),\r
-  fMappingContainer(original.fMappingContainer),\r
-  fBackgroundContainer(original.fBackgroundContainer),\r
-  fDebugContainer(original.fDebugContainer),\r
-  fResolutionContainer(original.fResolutionContainer),\r
-  fMatchContainer(original.fMatchContainer),\r
-  fESDContainer(original.fESDContainer),\r
-  fMCContainer(original.fMCContainer),\r
-  fTableContainer(original.fTableContainer), \r
-  fOtherContainer(original.fOtherContainer)\r
-{    \r
-  //see header file for documentation\r
-}\r
-\r
-\r
-AliGammaConversionHistograms & AliGammaConversionHistograms::operator = (const AliGammaConversionHistograms & /*original*/)\r
-{\r
-  // assignment operator\r
-  return *this;\r
-}\r
-\r
-\r
-AliGammaConversionHistograms::~AliGammaConversionHistograms() {\r
-  //destructor\r
-       \r
-       \r
-}\r
-\r
-void AliGammaConversionHistograms::AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX,Double_t lastX,TString xAxisTitle, TString yAxisTitle){\r
-  // see header file for documentation\r
-  TH1F *tmp = new TH1F(histogramName, histogramTitle,nXBins,firstX,lastX);\r
-  tmp->GetXaxis()->SetTitle(xAxisTitle);\r
-  tmp->GetYaxis()->SetTitle(yAxisTitle);\r
-  TObjString* tobjstring = new TObjString(histogramName.Data());\r
-  fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);\r
-}\r
-\r
-void AliGammaConversionHistograms::AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle, TString yAxisTitle){\r
-  // see header file for documentation\r
-  TH2F *tmp = new TH2F(histogramName, histogramTitle,nXBins,firstX,lastX,nYBins,firstY,lastY);\r
-  tmp->GetXaxis()->SetTitle(xAxisTitle);\r
-  tmp->GetYaxis()->SetTitle(yAxisTitle);\r
-  TObjString *tobjstring = new TObjString(histogramName.Data());\r
-  fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);\r
-}\r
-\r
-void AliGammaConversionHistograms::AddTable(TString tableName,TString tableTitle,Int_t nXBins,const char * axesLabel[]){\r
-\r
-\r
-        TH1F *tmp = new TH1F(tableName,tableTitle,nXBins,0,nXBins);\r
-        for(Int_t xbin=1; xbin<=nXBins; xbin++){\r
-         tmp->GetXaxis()->SetBinLabel(xbin,axesLabel[xbin-1]);\r
-        }\r
-        tmp->SetStats(0);\r
-\r
-        TObjString *tobjstring = new TObjString(tableName.Data());\r
-        fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);\r
-}\r
-\r
-void AliGammaConversionHistograms::FillTable(TString tableName,Double_t xValue) const {\r
-        TH1 *tmp = (TH1*)fHistogramMap->GetValue(tableName.Data());\r
-        if(tmp){\r
-             tmp->Fill(xValue);\r
-        }\r
-}\r
-\r
-void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue) const{\r
-  //see header file for documentation\r
-  TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());\r
-  if(tmp){\r
-    tmp->Fill(xValue);\r
-  }\r
-}\r
-\r
-void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue, Double_t yValue) const{\r
-  //see header file for documentation\r
-  TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());\r
-  if(tmp){\r
-    tmp->Fill(xValue, yValue);\r
-  }\r
-}\r
-\r
-void AliGammaConversionHistograms::GetOutputContainer(TList *fOutputContainer){\r
-  //checking if the container is alrerady created\r
-       \r
-  if(fOutputContainer == NULL){\r
-    //print warning\r
-    return;\r
-  }\r
-       \r
-  if(fHistogramMap != NULL){\r
-    TIter iter(fHistogramMap);\r
-    TObjString *histogramName;\r
-    while ((histogramName = (TObjString*) iter.Next())) {\r
-      TString histogramString = histogramName->GetString();\r
-      if(histogramString.Contains("Mapping")){// means it should be put in the mapping folder\r
-       if(fMappingContainer == NULL){\r
-         fMappingContainer = new TList();\r
-         fMappingContainer->SetName("Mapping histograms");\r
-       }\r
-       if(fMappingContainer != NULL){\r
-         fMappingContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));\r
-       }\r
-      }\r
-      else if(histogramString.Contains("Background")){// means it should be put in the background folder\r
-       if(fBackgroundContainer == NULL){\r
-         fBackgroundContainer = new TList();\r
-         fBackgroundContainer->SetName("Background histograms");\r
-       }\r
-       if(fBackgroundContainer != NULL){\r
-         fBackgroundContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));\r
-       }\r
-      }\r
-      else if(histogramString.Contains("Debug")){// means it should be put in the debug folder\r
-       if(fDebugContainer == NULL){\r
-         fDebugContainer = new TList();\r
-         fDebugContainer->SetName("Debug histograms");\r
-       }\r
-       if(fDebugContainer != NULL){\r
-         fDebugContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));\r
-       }\r
-      }\r
-      else if(histogramString.Contains("Resolution")){// means it should be put in the resolution folder\r
-       if(fResolutionContainer == NULL){\r
-         fResolutionContainer = new TList();\r
-         fResolutionContainer->SetName("Resolution histograms");\r
-       }\r
-       if(fResolutionContainer != NULL){\r
-         fResolutionContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));\r
-       }\r
-      }\r
-      else if(histogramString.Contains("Match")){// means it should be put in the mapping folder\r
-       if(fMatchContainer == NULL){\r
-         fMatchContainer = new TList();\r
-         fMatchContainer->SetName("Match histograms");\r
-       }\r
-       if(fMatchContainer != NULL){\r
-         fMatchContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));\r
-       }\r
-      }\r
-      else if(histogramString.Contains("ESD")){// means it should be put in the ESD folder\r
-       if(fESDContainer == NULL){\r
-         fESDContainer = new TList();\r
-         fESDContainer->SetName("ESD histograms");\r
-       }\r
-       if(fESDContainer != NULL){\r
-         fESDContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));\r
-       }\r
-      }\r
-      else if(histogramString.Contains("MC")){// means it should be put in the MC folder\r
-       if(fMCContainer == NULL){\r
-         fMCContainer = new TList();\r
-         fMCContainer->SetName("MC histograms");\r
-       }\r
-       if(fMCContainer != NULL){\r
-         fMCContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));\r
-       }\r
-      }\r
-      else if(histogramString.Contains("Table")){// means it should be put in the Table Folder\r
-       if(fTableContainer == NULL){\r
-          fTableContainer = new TList();\r
-          fTableContainer->SetName("Tables");\r
-       }\r
-       if(fTableContainer != NULL){\r
-          fTableContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));\r
-       }\r
-      }                        \r
-      else{\r
-       if(fOtherContainer == NULL){\r
-         fOtherContainer = new TList();\r
-         fOtherContainer->SetName("Other histograms");\r
-       }\r
-       if(fOtherContainer != NULL){\r
-         fOtherContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));\r
-       }\r
-      }\r
-      histogramName = NULL;\r
-    } // end while\r
-    if(fMappingContainer != NULL){\r
-      fOutputContainer->Add(fMappingContainer);\r
-    }\r
-    if(fBackgroundContainer != NULL){\r
-      fOutputContainer->Add(fBackgroundContainer);\r
-    }\r
-    if(fDebugContainer != NULL){\r
-      fOutputContainer->Add(fDebugContainer);\r
-    }\r
-    if(fResolutionContainer != NULL){\r
-      fOutputContainer->Add(fResolutionContainer);\r
-    }\r
-    if(fMatchContainer != NULL){\r
-      fOutputContainer->Add(fMatchContainer);\r
-    }\r
-    if(fESDContainer != NULL){\r
-      fOutputContainer->Add(fESDContainer);\r
-    }\r
-    if(fMCContainer != NULL){\r
-      fOutputContainer->Add(fMCContainer);\r
-    }\r
-    if(fTableContainer !=  NULL){\r
-       fOutputContainer->Add(fTableContainer); \r
-    }          \r
-    if(fOtherContainer != NULL){\r
-      fOutputContainer->Add(fMCContainer);\r
-    }\r
-  }\r
-}\r
-\r
-Int_t AliGammaConversionHistograms::GetRBin(Double_t radius) const{\r
-  // see header file for documentation\r
-  Int_t iResult=0;\r
-  if(fDeltaR>0){\r
-    iResult = (Int_t)((radius - fMinRadius)/fDeltaR);\r
-  }\r
-  return iResult;\r
-}\r
-\r
-Int_t AliGammaConversionHistograms::GetPhiBin(Double_t phi) const{\r
-  // see header file for documentation\r
-  Int_t iResult=0;\r
-  if(fDeltaPhi>0){\r
-    if(phi>TMath::Pi()){\r
-      phi-=2*TMath::Pi();\r
-    }\r
-    iResult = (Int_t)((phi - fMinPhi)/fDeltaPhi);\r
-  }\r
-  return iResult;\r
-}\r
-\r
-\r
-\r
-void AliGammaConversionHistograms::InitializeMappingValues(Int_t nPhiIndex, Int_t nRIndex, Int_t nBinsR, Double_t minRadius, Double_t maxRadius,Int_t nBinsPhi, Double_t minPhi, Double_t maxPhi){\r
-  // Initializing the valuse for the mapping\r
-       \r
-  fNPhiIndex = nPhiIndex;\r
-  fNRIndex   = nRIndex;\r
-  fMinRadius      = minRadius;\r
-  fMaxRadius      = maxRadius;\r
-  if(nBinsR>0 && nRIndex!=0){\r
-    fDeltaR       = (fMaxRadius - fMinRadius)/nRIndex;\r
-  }\r
-  fMinPhi         = minPhi;\r
-  fMaxPhi         = maxPhi;\r
-  if(nBinsPhi>0 && nPhiIndex!=0){\r
-    fDeltaPhi     = (fMaxPhi-fMinPhi)/nPhiIndex;\r
-  }\r
-}\r
-\r
-\r
-//mapping\r
-void AliGammaConversionHistograms::AddMappingHistograms(Int_t nPhiIndex, Int_t nRIndex,Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle, TString yAxisTitle){\r
-  // see header file for documentation\r
-       \r
-  for(Int_t phi =0; phi<=fNPhiIndex;phi++){\r
-               \r
-    for(Int_t r =0; r<fNRIndex;r++){\r
-                       \r
-      // setting axis to "" changes below\r
-      xAxisTitle="";\r
-      yAxisTitle="";\r
-      //Creating the axis titles\r
-      if(xAxisTitle.Length() == 0){\r
-       xAxisTitle.Form("Phi %02d",phi);\r
-      }\r
-                       \r
-      if(yAxisTitle.Length() == 0){\r
-       yAxisTitle.Form("R %02d",phi);\r
-      }\r
-                       \r
-      //MC\r
-      TString nameMC="";\r
-      nameMC.Form("MC_Conversion_Mapping-Phi%02d-R%02d",phi,r);\r
-      TString titleMC="";\r
-      titleMC.Form("Electron-Positron MC Mapping-Phi%02d-R%02d",phi,r);\r
-                       \r
-      AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);\r
-                       \r
-      //ESD\r
-      TString nameESD="";\r
-      nameESD.Form("ESD_Conversion_Mapping-Phi%02d-R%02d",phi,r);\r
-      TString titleESD="";\r
-      titleESD.Form("Electron-Positron ESD Mapping-Phi%02d-R%02d",phi,r);\r
-                       \r
-      AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);\r
-    }\r
-  }\r
-       \r
-       \r
-  for(Int_t phi =0; phi<=nPhiIndex;phi++){ \r
-               \r
-    // setting axis to "" changes below\r
-    xAxisTitle="";\r
-    yAxisTitle="";\r
-    //Creating the axis titles\r
-    if(xAxisTitle.Length() == 0){\r
-      xAxisTitle.Form("Phi %02d",phi);\r
-    }\r
-    if(yAxisTitle.Length() == 0){\r
-      yAxisTitle = "Counts";\r
-    }\r
-               \r
-    //MC\r
-    TString nameMC="";\r
-    nameMC.Form("MC_Conversion_Mapping-Phi%02d",phi);\r
-    TString titleMC="";\r
-    titleMC.Form("Electron-Positron MC Mapping-Phi%02d",phi);\r
-               \r
-    AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);\r
-               \r
-    //MC\r
-    TString nameESD="";\r
-    nameESD.Form("ESD_Conversion_Mapping-Phi%02d",phi);\r
-    TString titleESD="";\r
-    titleESD.Form("Electron-Positron ESD Mapping-Phi%02d",phi);\r
-               \r
-    AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);\r
-  }\r
-       \r
-       \r
-  for(Int_t r =0; r<=nRIndex;r++){\r
-               \r
-    // setting axis to "" changes below\r
-    xAxisTitle="";\r
-    yAxisTitle="";\r
-    //Creating the axis titles\r
-    if(xAxisTitle.Length() == 0){\r
-      xAxisTitle.Form("R %02d",r);\r
-    }\r
-    if(yAxisTitle.Length() == 0){\r
-      yAxisTitle = "Counts";\r
-    }\r
-               \r
-    //MC\r
-    TString nameMC="";\r
-    nameMC.Form("MC_Conversion_Mapping-R%02d",r);\r
-    TString titleMC="";\r
-    titleMC.Form("Electron-Positron MC Mapping-R%02d",r);\r
-               \r
-    AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);\r
-               \r
-    //ESD\r
-    TString nameESD="";\r
-    nameESD.Form("ESD_Conversion_Mapping-R%02d",r);\r
-    TString titleESD="";\r
-    titleESD.Form("Electron-Positron ESD Mapping-R%02d",r);\r
-               \r
-    AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);\r
-               \r
-    //Mapping Phi in R\r
-    TString nameMCPhiInR="";\r
-    nameMCPhiInR.Form("MC_Conversion_Mapping_Phi_R-%02d",r);\r
-    TString titleMCPhiInR="";\r
-    titleMCPhiInR.Form("MC Mapping of Phi in R%02d",r);\r
-    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);\r
-               \r
-    //Mapping Phi in R\r
-    TString nameESDPhiInR="";\r
-    nameESDPhiInR.Form("ESD_Conversion_Mapping_Phi_R-%02d",r);\r
-    TString titleESDPhiInR="";\r
-    titleESDPhiInR.Form("ESD Mapping of Phi in R%02d",r);\r
-    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    \r
-  }\r
-}\r
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt                        *
+ * Version 1.1                                                            *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class used to do analysis on conversion pairs
+//---------------------------------------------
+////////////////////////////////////////////////
+
+#include "AliGammaConversionHistograms.h"
+#include "TMath.h"
+#include "TObjString.h"
+#include "TMap.h"
+#include "TList.h"
+#include "TH1F.h"
+#include "TH2F.h"
+
+
+using namespace std;
+
+ClassImp(AliGammaConversionHistograms)
+
+
+AliGammaConversionHistograms::AliGammaConversionHistograms() :
+  fHistogramMap(new TMap()),
+  fNPhiIndex(0),
+  fNRIndex(0),
+  fMinRadius(0.),
+  fMaxRadius(0.),
+  fDeltaR(0.),
+  fMinPhi(0.),
+  fMaxPhi(0.),
+  fDeltaPhi(0.),
+  fMappingContainer(NULL),
+  fBackgroundContainer(NULL),
+  fDebugContainer(NULL),
+  fResolutionContainer(NULL),
+  fMatchContainer(NULL),
+  fESDContainer(NULL),
+  fMCContainer(NULL),
+  fTableContainer(NULL),       
+  fOtherContainer(NULL)
+{
+  // see header file for documenation
+}
+
+
+AliGammaConversionHistograms::AliGammaConversionHistograms(const AliGammaConversionHistograms & original) :
+  fHistogramMap(original.fHistogramMap),
+  fNPhiIndex(original.fNPhiIndex),
+  fNRIndex(original.fNRIndex),
+  fMinRadius(original.fMinRadius),
+  fMaxRadius(original.fMaxRadius),
+  fDeltaR(original.fDeltaR),
+  fMinPhi(original.fMinPhi),
+  fMaxPhi(original.fMaxPhi),
+  fDeltaPhi(original.fDeltaPhi),
+  fMappingContainer(original.fMappingContainer),
+  fBackgroundContainer(original.fBackgroundContainer),
+  fDebugContainer(original.fDebugContainer),
+  fResolutionContainer(original.fResolutionContainer),
+  fMatchContainer(original.fMatchContainer),
+  fESDContainer(original.fESDContainer),
+  fMCContainer(original.fMCContainer),
+  fTableContainer(original.fTableContainer), 
+  fOtherContainer(original.fOtherContainer)
+{    
+  //see header file for documentation
+}
+
+
+AliGammaConversionHistograms & AliGammaConversionHistograms::operator = (const AliGammaConversionHistograms & /*original*/)
+{
+  // assignment operator
+  return *this;
+}
+
+
+AliGammaConversionHistograms::~AliGammaConversionHistograms() {
+  //destructor
+       
+       
+}
+
+void AliGammaConversionHistograms::AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX,Double_t lastX,TString xAxisTitle, TString yAxisTitle){
+  // see header file for documentation
+  TH1F *tmp = new TH1F(histogramName, histogramTitle,nXBins,firstX,lastX);
+  tmp->GetXaxis()->SetTitle(xAxisTitle);
+  tmp->GetYaxis()->SetTitle(yAxisTitle);
+  TObjString* tobjstring = new TObjString(histogramName.Data());
+  fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
+}
+
+void AliGammaConversionHistograms::AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle, TString yAxisTitle){
+  // see header file for documentation
+  TH2F *tmp = new TH2F(histogramName, histogramTitle,nXBins,firstX,lastX,nYBins,firstY,lastY);
+  tmp->GetXaxis()->SetTitle(xAxisTitle);
+  tmp->GetYaxis()->SetTitle(yAxisTitle);
+  TObjString *tobjstring = new TObjString(histogramName.Data());
+  fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
+}
+
+void AliGammaConversionHistograms::AddTable(TString tableName,TString tableTitle,Int_t nXBins,const char * axesLabel[]){
+
+
+        TH1F *tmp = new TH1F(tableName,tableTitle,nXBins,0,nXBins);
+        for(Int_t xbin=1; xbin<=nXBins; xbin++){
+         tmp->GetXaxis()->SetBinLabel(xbin,axesLabel[xbin-1]);
+        }
+        tmp->SetStats(0);
+
+        TObjString *tobjstring = new TObjString(tableName.Data());
+        fHistogramMap->Add((TObject*)tobjstring,(TObject*)tmp);
+}
+
+void AliGammaConversionHistograms::FillTable(TString tableName,Double_t xValue) const {
+        TH1 *tmp = (TH1*)fHistogramMap->GetValue(tableName.Data());
+        if(tmp){
+             tmp->Fill(xValue);
+        }
+}
+
+void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue) const{
+  //see header file for documentation
+  TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());
+  if(tmp){
+    tmp->Fill(xValue);
+  }
+}
+
+void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue, Double_t yValue) const{
+  //see header file for documentation
+  TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());
+  if(tmp){
+    tmp->Fill(xValue, yValue);
+  }
+}
+
+void AliGammaConversionHistograms::GetOutputContainer(TList *fOutputContainer){
+  //checking if the container is alrerady created
+       
+  if(fOutputContainer == NULL){
+    cout<<"WARNING: GetOutputContainer: output container object is NULL"<<endl;
+    return;
+  }
+
+  if(fHistogramMap != NULL){
+    TIter iter(fHistogramMap);
+    TObjString *histogramName;
+    while ((histogramName = (TObjString*) iter.Next())) {
+      TString histogramString = histogramName->GetString();
+      if(histogramString.Contains("Mapping")){// means it should be put in the mapping folder
+       if(fMappingContainer == NULL){
+         fMappingContainer = new TList();
+         fMappingContainer->SetName("Mapping histograms");
+       }
+       if(fMappingContainer != NULL){
+         fMappingContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+       }
+      }
+      else if(histogramString.Contains("Background")){// means it should be put in the background folder
+       if(fBackgroundContainer == NULL){
+         fBackgroundContainer = new TList();
+         fBackgroundContainer->SetName("Background histograms");
+       }
+       if(fBackgroundContainer != NULL){
+         fBackgroundContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+       }
+      }
+      else if(histogramString.Contains("Debug")){// means it should be put in the debug folder
+       if(fDebugContainer == NULL){
+         fDebugContainer = new TList();
+         fDebugContainer->SetName("Debug histograms");
+       }
+       if(fDebugContainer != NULL){
+         fDebugContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+       }
+      }
+      else if(histogramString.Contains("Resolution")){// means it should be put in the resolution folder
+       if(fResolutionContainer == NULL){
+         fResolutionContainer = new TList();
+         fResolutionContainer->SetName("Resolution histograms");
+       }
+       if(fResolutionContainer != NULL){
+         fResolutionContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+       }
+      }
+      else if(histogramString.Contains("TrueConv")){// means it should be put in the true conv folder
+       if(fMatchContainer == NULL){
+         fMatchContainer = new TList();
+         fMatchContainer->SetName("True conversion histograms");
+       }
+       if(fMatchContainer != NULL){
+         fMatchContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+       }
+      }
+      else if(histogramString.Contains("ESD")){// means it should be put in the ESD folder
+       if(fESDContainer == NULL){
+         fESDContainer = new TList();
+         fESDContainer->SetName("ESD histograms");
+       }
+       if(fESDContainer != NULL){
+         fESDContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+       }
+      }
+      else if(histogramString.Contains("MC")){// means it should be put in the MC folder
+       if(fMCContainer == NULL){
+         fMCContainer = new TList();
+         fMCContainer->SetName("MC histograms");
+       }
+       if(fMCContainer != NULL){
+         fMCContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+       }
+      }
+      else if(histogramString.Contains("Table")){// means it should be put in the Table Folder
+       if(fTableContainer == NULL){
+          fTableContainer = new TList();
+          fTableContainer->SetName("Tables");
+       }
+       if(fTableContainer != NULL){
+          fTableContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+       }
+      }                        
+      else{
+       if(fOtherContainer == NULL){
+         fOtherContainer = new TList();
+         fOtherContainer->SetName("Other histograms");
+       }
+       if(fOtherContainer != NULL){
+         fOtherContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+       }
+      }
+      histogramName = NULL;
+    } // end while
+    if(fMappingContainer != NULL){
+      fOutputContainer->Add(fMappingContainer);
+    }
+    if(fBackgroundContainer != NULL){
+      fOutputContainer->Add(fBackgroundContainer);
+    }
+    if(fDebugContainer != NULL){
+      fOutputContainer->Add(fDebugContainer);
+    }
+    if(fResolutionContainer != NULL){
+      fOutputContainer->Add(fResolutionContainer);
+    }
+    if(fMatchContainer != NULL){
+      fOutputContainer->Add(fMatchContainer);
+    }
+    if(fESDContainer != NULL){
+      fOutputContainer->Add(fESDContainer);
+    }
+    if(fMCContainer != NULL){
+      fOutputContainer->Add(fMCContainer);
+    }
+    if(fTableContainer !=  NULL){
+       fOutputContainer->Add(fTableContainer); 
+    }          
+    if(fOtherContainer != NULL){
+      fOutputContainer->Add(fMCContainer);
+    }
+  }
+}
+
+Int_t AliGammaConversionHistograms::GetRBin(Double_t radius) const{
+  // see header file for documentation
+  Int_t iResult=0;
+  if(fDeltaR>0){
+    iResult = (Int_t)((radius - fMinRadius)/fDeltaR);
+  }
+  return iResult;
+}
+
+Int_t AliGammaConversionHistograms::GetPhiBin(Double_t phi) const{
+  // see header file for documentation
+  Int_t iResult=0;
+  if(fDeltaPhi>0){
+    if(phi>TMath::Pi()){
+      phi-=2*TMath::Pi();
+    }
+    iResult = (Int_t)((phi - fMinPhi)/fDeltaPhi);
+  }
+  return iResult;
+}
+
+
+
+void AliGammaConversionHistograms::InitializeMappingValues(Int_t nPhiIndex, Int_t nRIndex, Int_t nBinsR, Double_t minRadius, Double_t maxRadius,Int_t nBinsPhi, Double_t minPhi, Double_t maxPhi){
+  // Initializing the valuse for the mapping
+       
+  fNPhiIndex = nPhiIndex;
+  fNRIndex   = nRIndex;
+  fMinRadius      = minRadius;
+  fMaxRadius      = maxRadius;
+  if(nBinsR>0 && nRIndex!=0){
+    fDeltaR       = (fMaxRadius - fMinRadius)/nRIndex;
+  }
+  fMinPhi         = minPhi;
+  fMaxPhi         = maxPhi;
+  if(nBinsPhi>0 && nPhiIndex!=0){
+    fDeltaPhi     = (fMaxPhi-fMinPhi)/nPhiIndex;
+  }
+}
+
+
+//mapping
+void AliGammaConversionHistograms::AddMappingHistograms(Int_t nPhiIndex, Int_t nRIndex,Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle, TString yAxisTitle){
+  // see header file for documentation
+       
+  for(Int_t phi =0; phi<=fNPhiIndex;phi++){
+               
+    for(Int_t r =0; r<fNRIndex;r++){
+                       
+      // setting axis to "" changes below
+      xAxisTitle="";
+      yAxisTitle="";
+      //Creating the axis titles
+      if(xAxisTitle.Length() == 0){
+       xAxisTitle.Form("Phi %02d",phi);
+      }
+                       
+      if(yAxisTitle.Length() == 0){
+       yAxisTitle.Form("R %02d",phi);
+      }
+                       
+      //MC
+      TString nameMC="";
+      nameMC.Form("MC_Conversion_Mapping-Phi%02d-R%02d",phi,r);
+      TString titleMC="";
+      titleMC.Form("Electron-Positron MC Mapping-Phi%02d-R%02d",phi,r);
+                       
+      AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
+                       
+      //ESD
+      TString nameESD="";
+      nameESD.Form("ESD_Conversion_Mapping-Phi%02d-R%02d",phi,r);
+      TString titleESD="";
+      titleESD.Form("Electron-Positron ESD Mapping-Phi%02d-R%02d",phi,r);
+                       
+      AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, nYBins, firstY, lastY, xAxisTitle, yAxisTitle);
+    }
+  }
+       
+       
+  for(Int_t phi =0; phi<=nPhiIndex;phi++){ 
+               
+    // setting axis to "" changes below
+    xAxisTitle="";
+    yAxisTitle="";
+    //Creating the axis titles
+    if(xAxisTitle.Length() == 0){
+      xAxisTitle.Form("Phi %02d",phi);
+    }
+    if(yAxisTitle.Length() == 0){
+      yAxisTitle = "Counts";
+    }
+               
+    //MC
+    TString nameMC="";
+    nameMC.Form("MC_Conversion_Mapping-Phi%02d",phi);
+    TString titleMC="";
+    titleMC.Form("Electron-Positron MC Mapping-Phi%02d",phi);
+               
+    AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
+               
+    //MC
+    TString nameESD="";
+    nameESD.Form("ESD_Conversion_Mapping-Phi%02d",phi);
+    TString titleESD="";
+    titleESD.Form("Electron-Positron ESD Mapping-Phi%02d",phi);
+               
+    AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
+  }
+       
+       
+  for(Int_t r =0; r<=nRIndex;r++){
+               
+    // setting axis to "" changes below
+    xAxisTitle="";
+    yAxisTitle="";
+    //Creating the axis titles
+    if(xAxisTitle.Length() == 0){
+      xAxisTitle.Form("R %02d",r);
+    }
+    if(yAxisTitle.Length() == 0){
+      yAxisTitle = "Counts";
+    }
+               
+    //MC
+    TString nameMC="";
+    nameMC.Form("MC_Conversion_Mapping-R%02d",r);
+    TString titleMC="";
+    titleMC.Form("Electron-Positron MC Mapping-R%02d",r);
+               
+    AddHistogram(nameMC, titleMC, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
+               
+    //ESD
+    TString nameESD="";
+    nameESD.Form("ESD_Conversion_Mapping-R%02d",r);
+    TString titleESD="";
+    titleESD.Form("Electron-Positron ESD Mapping-R%02d",r);
+               
+    AddHistogram(nameESD, titleESD, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
+               
+    //Mapping Phi in R
+    TString nameMCPhiInR="";
+    nameMCPhiInR.Form("MC_Conversion_Mapping_Phi_R-%02d",r);
+    TString titleMCPhiInR="";
+    titleMCPhiInR.Form("MC Mapping of Phi in R%02d",r);
+    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
+               
+    //Mapping Phi in R
+    TString nameESDPhiInR="";
+    nameESDPhiInR.Form("ESD_Conversion_Mapping_Phi_R-%02d",r);
+    TString titleESDPhiInR="";
+    titleESDPhiInR.Form("ESD Mapping of Phi in R%02d",r);
+    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
+  }
+}
index 056f2fc12811958055c45a65476e87a7a99f09e9..2a6ff9bea974e6b06f5f554e58dd7326c89bdd73 100644 (file)
-#ifndef ALIGAMMACONVERSIONHISTOGRAMS_H\r
-#define ALIGAMMACONVERSIONHISTOGRAMS_H\r
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- * See cxx source for full Copyright notice     */\r
-\r
-////////////////////////////////////////////////\r
-//--------------------------------------------- \r
-// Class used to do analysis on conversion pairs\r
-//---------------------------------------------\r
-////////////////////////////////////////////////\r
-\r
-#include "TString.h"\r
-#include "Riostream.h"\r
-#include <vector>\r
-\r
-class TMap;\r
-class TList;\r
-class TH1F;\r
-class TH2F;\r
-\r
-class AliGammaConversionHistograms{\r
-\r
- public: \r
-  \r
-  AliGammaConversionHistograms();                                                                  //constructor\r
-  AliGammaConversionHistograms(const AliGammaConversionHistograms & original);                     //copy constructor\r
-  AliGammaConversionHistograms & operator = (const AliGammaConversionHistograms & original);       //assignment operator\r
-  virtual ~AliGammaConversionHistograms();                                                         //virtual destructor\r
-  \r
-\r
-  //  TList * GetOutputContainer();\r
-  void GetOutputContainer(TList *fOutputContainer);\r
-  \r
-  Int_t GetRBin(Double_t radius) const;\r
-  Int_t GetPhiBin(Double_t phi) const;\r
-\r
-  void InitializeMappingValues(Int_t nPhiHistograms, Int_t nRHistograms, Int_t nBinsR, Double_t minRadius, Double_t maxRadius,Int_t nBinsPhi, Double_t minPhi, Double_t maxPhi);\r
-\r
-  void AddMappingHistograms(Int_t nPhiHistograms, Int_t nRHistograms,Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle="", TString yAxisTitle="");\r
-\r
-  /*\r
-   * Adds a TH1F histogram to the histogram map and create a key for it \r
-   */\r
-  void AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX,Double_t lastX,TString xAxisTitle="", TString yAxisTitle="");\r
-\r
-  /*\r
-   * Adds a TH2F histogram to the histogram map and create a key for it \r
-   */\r
-  void AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle="", TString yAxisTitle="");\r
-\r
-  /*\r
-   *  Adds a TH1F Table to the table map and create a key for it\r
-   */\r
-  void AddTable(TString tableName,TString tableTitle,Int_t nXBins, const char * axesLabel[]);  \r
-\r
-\r
-  /*\r
-   * Fills a TH1F histogram with the given name with the given value \r
-   */\r
-  void FillHistogram(TString histogramName, Double_t xValue) const;\r
-\r
-  /*\r
-   * Fills a TH2F histogram with the given name with the given value \r
-   */\r
-  void FillHistogram(TString histogramName, Double_t xValue, Double_t yValue) const;\r
-\r
-  /*\r
-   * Fills a TH1F table with the given name with the given value\r
-   */                  \r
-  void FillTable(TString tableName, Double_t xValue) const;            \r
-\r
- private:\r
-  TMap* fHistogramMap; // histogram map\r
-\r
-  Int_t fNPhiIndex; //phi index\r
-  Int_t fNRIndex; //r index\r
-  Double_t fMinRadius; //min radius cut\r
-  Double_t fMaxRadius; //max radius cut\r
-  Double_t fDeltaR; // delta r\r
-  Double_t fMinPhi; //min phi\r
-  Double_t fMaxPhi; // max phi\r
-  Double_t fDeltaPhi;//delta phi\r
-\r
-  TList * fMappingContainer; //mapping container\r
-  TList * fBackgroundContainer; // background container\r
-  TList * fDebugContainer; // debug container\r
-  TList * fResolutionContainer; //resolution container\r
-  TList * fMatchContainer; //match container\r
-  TList * fESDContainer;//esd container\r
-  TList * fMCContainer; // MC container\r
-  TList * fTableContainer; // table container\r
-  TList * fOtherContainer; // other container\r
-\r
-  ClassDef(AliGammaConversionHistograms,2)\r
-};\r
-\r
-\r
-#endif\r
-\r
-\r
-\r
+#ifndef ALIGAMMACONVERSIONHISTOGRAMS_H
+#define ALIGAMMACONVERSIONHISTOGRAMS_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice     */
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class used to do analysis on conversion pairs
+//---------------------------------------------
+////////////////////////////////////////////////
+
+#include "TString.h"
+#include "Riostream.h"
+#include <vector>
+
+class TMap;
+class TList;
+class TH1F;
+class TH2F;
+
+class AliGammaConversionHistograms{
+
+ public: 
+  
+  AliGammaConversionHistograms();                                                                  //constructor
+  AliGammaConversionHistograms(const AliGammaConversionHistograms & original);                     //copy constructor
+  AliGammaConversionHistograms & operator = (const AliGammaConversionHistograms & original);       //assignment operator
+  virtual ~AliGammaConversionHistograms();                                                         //virtual destructor
+  
+
+  //  TList * GetOutputContainer();
+  void GetOutputContainer(TList *fOutputContainer);
+  
+  Int_t GetRBin(Double_t radius) const;
+  Int_t GetPhiBin(Double_t phi) const;
+
+  void InitializeMappingValues(Int_t nPhiHistograms, Int_t nRHistograms, Int_t nBinsR, Double_t minRadius, Double_t maxRadius,Int_t nBinsPhi, Double_t minPhi, Double_t maxPhi);
+
+  void AddMappingHistograms(Int_t nPhiHistograms, Int_t nRHistograms,Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle="", TString yAxisTitle="");
+
+  /*
+   * Adds a TH1F histogram to the histogram map and create a key for it 
+   */
+  void AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX,Double_t lastX,TString xAxisTitle="", TString yAxisTitle="");
+
+  /*
+   * Adds a TH2F histogram to the histogram map and create a key for it 
+   */
+  void AddHistogram(TString histogramName, TString histogramTitle, Int_t nXBins, Double_t firstX, Double_t lastX, Int_t nYBins, Double_t firstY, Double_t lastY, TString xAxisTitle="", TString yAxisTitle="");
+
+  /*
+   *  Adds a TH1F Table to the table map and create a key for it
+   */
+  void AddTable(TString tableName,TString tableTitle,Int_t nXBins, const char * axesLabel[]);  
+
+
+  /*
+   * Fills a TH1F histogram with the given name with the given value 
+   */
+  void FillHistogram(TString histogramName, Double_t xValue) const;
+
+  /*
+   * Fills a TH2F histogram with the given name with the given value 
+   */
+  void FillHistogram(TString histogramName, Double_t xValue, Double_t yValue) const;
+
+  /*
+   * Fills a TH1F table with the given name with the given value
+   */                  
+  void FillTable(TString tableName, Double_t xValue) const;            
+
+ private:
+  TMap* fHistogramMap; // histogram map
+
+  Int_t fNPhiIndex; //phi index
+  Int_t fNRIndex; //r index
+  Double_t fMinRadius; //min radius cut
+  Double_t fMaxRadius; //max radius cut
+  Double_t fDeltaR; // delta r
+  Double_t fMinPhi; //min phi
+  Double_t fMaxPhi; // max phi
+  Double_t fDeltaPhi;//delta phi
+
+  TList * fMappingContainer; //mapping container
+  TList * fBackgroundContainer; // background container
+  TList * fDebugContainer; // debug container
+  TList * fResolutionContainer; //resolution container
+  TList * fMatchContainer; //match container
+  TList * fESDContainer;//esd container
+  TList * fMCContainer; // MC container
+  TList * fTableContainer; // table container
+  TList * fOtherContainer; // other container
+
+  ClassDef(AliGammaConversionHistograms,2)
+};
+
+
+#endif
+
+
+
index 22d160abb8b255ba1689cd3134be6c9e27e57d8a..7a7bd22ac5ba7141ccc64f5a9d814636598bb244 100644 (file)
@@ -7,5 +7,6 @@
 #pragma link C++ class AliAnalysisTaskGammaConversion+;
 #pragma link C++ class AliV0Reader+;
 #pragma link C++ class AliGammaConversionHistograms+;
+#pragma link C++ class AliGammaConversionAODObject+;
 
 #endif
index 0141f576932ab018fe3db8827b11f317255f6445..0acc66932c69ca51d27cc06f304fc654ef8c53e8 100644 (file)
@@ -1,6 +1,6 @@
 #-*- Mode: Makefile -*-
 
-SRCS = GammaConv/AliV0Reader.cxx GammaConv/AliAnalysisTaskGammaConversion.cxx GammaConv/AliGammaConversionHistograms.cxx
+SRCS = GammaConv/AliV0Reader.cxx GammaConv/AliAnalysisTaskGammaConversion.cxx GammaConv/AliGammaConversionHistograms.cxx GammaConv/AliGammaConversionAODObject.cxx
       
 HDRS:= $(SRCS:.cxx=.h) 
 
diff --git a/PWG4/macros/AddTaskGammaConversion.C b/PWG4/macros/AddTaskGammaConversion.C
new file mode 100644 (file)
index 0000000..fe7d808
--- /dev/null
@@ -0,0 +1,10 @@
+
+
+AliAnalysisTaskGammaConversion * AddTaskGammaConversion(TString arguments,AliAnalysisDataContainer *cin_esd){
+
+  gROOT->LoadMacro("./ConfigGammaConversion.C"); // load the CreateChain macro
+
+  ConfigGammaConversion(arguments,cin_esd);
+  
+  return NULL;
+}
index 1bcf9a1b6df1f7202b84148ce6dfce7240290b0c..84a20b83a1eddcc359716459b5be42c8c00cb0f7 100644 (file)
@@ -1,23 +1,16 @@
-/** VERSION NUMBER 0 */
-/** new Version Kenneth */
-
-Bool_t usePWG4PartCorr = kTRUE;
+/** VERSION NUMBER 1.1 */
 
+class AliAnalysisDataContainer;
+class AliGammaConversionHistograms;
 
-/** ------------------------------ Monte Carlo flag -----------------------------------------*/
-Bool_t doMCTruth = kTRUE;
-/** ---------------------------- end Monte Carlo flag ---------------------------------------*/
-
-/** ------------------------- Choose KFParticle OR ESDTrack  --------------------------------*/
-Bool_t useKFParticle = kTRUE;
-Bool_t useESDTrack   = kFALSE;
-/** ----------------------- end Choose KFParticle OR ESDTrack  -----------------------------*/
-
-
-Bool_t calculateBackground = kTRUE;
-
+// set this to a number if you want to analyze a set number of files
+// if it is 0 it will analyze the files listed in the data list
 Int_t numberOfFilesToAnalyze=0;
 
+Bool_t runNeutralMeson = kTRUE;
+Bool_t runJet          = kFALSE;
+Bool_t runChic         = kFALSE;
+
 /** ---------------------------------- define cuts here ------------------------------------*/
 
 Int_t pidOfNegativeTrack=11;
@@ -26,7 +19,7 @@ Int_t pidOfPositiveTrack=-11;
 Double_t LineCutZRSlope = 0.662487;
 Double_t LineCutZValue = 7.;
 
-Double_t maxRCut   = 160.;
+Double_t maxRCut   = 180.;
 Double_t etaCut    = 1.2;
 Double_t ptCut     = 0.02;
 Double_t chi2CutConversion   = 20.;
@@ -69,10 +62,10 @@ Double_t minPhi      = -TMath::Pi();
 Double_t maxPhi      = TMath::Pi();
 /** ------------------------------- end Phi/R Mapping ------------------------------------*/
 
-
-
 /** ------------------- define which histograms to plot here --------------------------------*/
 /**   NB: to change the bin numbers, see below the histogram flags                           */
+
+// NEUTRAL MESON PLOTS
 Bool_t plotMCConversionR             = kTRUE;
 Bool_t plotMCConversionZR            = kTRUE;
 Bool_t plotMCConversionXY            = kTRUE;
@@ -108,7 +101,6 @@ Bool_t plotMCallDirectGammaEta     = kTRUE;
 Bool_t plotMCallDirectGammaPhi     = kTRUE;
 Bool_t plotMCallDirectGammaRapid   = kTRUE;
 
-
 Bool_t plotMCConvDirectGammaEnergy  = kTRUE;
 Bool_t plotMCConvDirectGammaPt      = kTRUE;
 Bool_t plotMCConvDirectGammaEta     = kTRUE;
@@ -131,21 +123,21 @@ Bool_t plotMCMotherPtvsEtaConvGammaWithinAcceptance     = kTRUE;
 Bool_t plotMCMotherPtvsRapidConvGammaWithinAcceptance   = kTRUE;
 Bool_t plotMCMotherSpectra                             = kTRUE;
 
-Bool_t plotMCPi0Eta                               = kTRUE;
-Bool_t plotMCPi0Rapid                              = kTRUE;
-Bool_t plotMCPi0Phi                                = kTRUE;
-Bool_t plotMCPi0Pt                                 = kTRUE;
-Bool_t plotMCPi0Energy                             = kTRUE;
-Bool_t plotMCPi0Mass                               = kTRUE;
-Bool_t plotMCPi0OpeningAngle                       = kTRUE;
-Bool_t plotMCPi0R                                  = kTRUE;
-Bool_t plotMCPi0ZR                                 = kTRUE;
-Bool_t plotMCPi0XY                                 = kTRUE;
-Bool_t plotMCPi0PtvsEtaWithinAcceptance            = kTRUE;
-Bool_t plotMCPi0PtvsRapidWithinAcceptance          = kTRUE;
-Bool_t plotMCPi0PtvsEtaConvGammaWithinAcceptance   = kTRUE;
-Bool_t plotMCPi0PtvsRapidConvGammaWithinAcceptance = kTRUE;
-
+Bool_t plotMCPi0Eta                                    = kTRUE;
+Bool_t plotMCPi0Rapid                                   = kTRUE;
+Bool_t plotMCPi0Phi                                     = kTRUE;
+Bool_t plotMCPi0Pt                                      = kTRUE;
+Bool_t plotMCPi0Energy                                  = kTRUE;
+Bool_t plotMCPi0Mass                                    = kTRUE;
+Bool_t plotMCPi0OpeningAngle                            = kTRUE;
+Bool_t plotMCPi0R                                       = kTRUE;
+Bool_t plotMCPi0ZR                                      = kTRUE;
+Bool_t plotMCPi0XY                                      = kTRUE;
+Bool_t plotMCPi0PtvsEtaWithinAcceptance                 = kTRUE;
+Bool_t plotMCPi0PtvsRapidWithinAcceptance               = kTRUE;
+Bool_t plotMCPi0PtvsEtaConvGammaWithinAcceptance        = kTRUE;
+Bool_t plotMCPi0PtvsRapidConvGammaWithinAcceptance      = kTRUE;
+Bool_t plotMCPi0ZRConvGammaWithinAcceptance            = kTRUE;
 
 Bool_t plotMCPi0SecondaryEta                                = kTRUE;
 Bool_t plotMCPi0SecondaryRapid                              = kTRUE;
@@ -162,7 +154,6 @@ Bool_t plotMCPi0SecondaryPtvsRapidWithinAcceptance          = kTRUE;
 Bool_t plotMCPi0SecondaryPtvsEtaConvGammaWithinAcceptance   = kTRUE;
 Bool_t plotMCPi0SecondaryPtvsRapidConvGammaWithinAcceptance = kTRUE;
 
-
 Bool_t plotMCEtaEta                                = kTRUE;
 Bool_t plotMCEtaRapid                              = kTRUE;
 Bool_t plotMCEtaPhi                                = kTRUE;
@@ -177,7 +168,7 @@ Bool_t plotMCEtaPtvsEtaWithinAcceptance                = kTRUE;
 Bool_t plotMCEtaPtvsRapidWithinAcceptance         = kTRUE;
 Bool_t plotMCEtaPtvsEtaConvGammaWithinAcceptance   = kTRUE;
 Bool_t plotMCEtaPtvsRapidConvGammaWithinAcceptance = kTRUE;
-
+Bool_t plotMCEtaZRConvGammaWithinAcceptance = kTRUE;
 
 // Histograms from esd tracks
 Bool_t plotESDConversionR            = kTRUE;
@@ -205,6 +196,8 @@ Bool_t plotESDConvGammaChi2   = kTRUE;
 Bool_t plotESDConvGammaNDF    = kTRUE;
 Bool_t plotESDConvGammaRapid  = kTRUE;
 Bool_t plotESDConvGammaPtvsEta = kTRUE;
+Bool_t plotESDConvGammaPtvsChi2 = kTRUE;
+Bool_t plotESDConvGammaEtavsChi2 = kTRUE;
 
 Bool_t plotESDTrueConvGammaEnergy         = kTRUE;
 Bool_t plotESDTrueConvGammaPt             = kTRUE;
@@ -220,6 +213,11 @@ Bool_t plotESDTrueConversionR             = kTRUE;
 Bool_t plotESDTrueConversionZR            = kTRUE;
 Bool_t plotESDTrueConversionXY            = kTRUE;
 Bool_t plotESDTrueConversionOpeningAngle  = kTRUE;
+Bool_t plotESDTrueConvGammaPtvsChi2       = kTRUE;
+Bool_t plotESDTrueConvGammaEtavsChi2      = kTRUE;
+Bool_t plotESDTrueConvGammaMCPtEta        = kTRUE;
+Bool_t plotESDTrueConversionMCZR          = kTRUE;
+Bool_t plotESDTrueConversionMCXY          = kTRUE;
 
 Bool_t plotESDNoCutConvGammaEnergy         = kTRUE;
 Bool_t plotESDNoCutConvGammaPt             = kTRUE;
@@ -235,6 +233,11 @@ Bool_t plotESDNoCutConversionR             = kTRUE;
 Bool_t plotESDNoCutConversionZR            = kTRUE;
 Bool_t plotESDNoCutConversionXY            = kTRUE;
 Bool_t plotESDNoCutConversionOpeningAngle  = kTRUE;
+Bool_t plotESDNoCutConvGammaPtvsChi2       = kTRUE;
+Bool_t plotESDNoCutConvGammaEtavsChi2      = kTRUE;
+Bool_t plotESDNoCutConvGammaMCPtEta        = kTRUE;
+Bool_t plotESDNoCutConversionMCZR          = kTRUE;
+Bool_t plotESDNoCutConversionMCXY          = kTRUE;
 
 Bool_t plotESDMotherOpeningAngleGamma = kTRUE;
 Bool_t plotESDMotherEnergy            = kTRUE;
@@ -247,7 +250,6 @@ Bool_t plotESDMotherZR                = kTRUE;
 Bool_t plotESDMotherXY                = kTRUE;
 Bool_t plotESDMotherRapid             = kTRUE;
 
-
 Bool_t plotESDBackgroundOpeningAngleGamma = kTRUE;
 Bool_t plotESDBackgroundEnergy            = kTRUE;
 Bool_t plotESDBackgroundPt                = kTRUE;
@@ -259,8 +261,6 @@ Bool_t plotESDBackgroundZR                = kTRUE;
 Bool_t plotESDBackgroundXY                = kTRUE;
 Bool_t plotESDBackgroundRapid             = kTRUE;
 
-
-
 Bool_t plotMapping = kFALSE;       
 
 Bool_t plotResolutiondPt = kTRUE;
@@ -296,7 +296,6 @@ Bool_t plotESDCutPt            = kTRUE;
 Bool_t plotESDTrueConvGammaTrackLength =kTRUE;
 Bool_t plotESDTrueConvGammaTrackLengthVSInvMass =kTRUE;
 
-
 Bool_t plotPi0Spectra = kTRUE;
 Bool_t plotEtaSpectra = kTRUE;
 
@@ -327,6 +326,15 @@ Bool_t plotESDEPosENegGammaBackgroundMX                    = kTRUE;
 Bool_t plotMCLabels                                        = kTRUE;
 ///////////////////////////////////////////////////////////////////
 
+//---------------- Gamma Jet analysis ----------------------------
+Bool_t plotdPhiHdrGam            = kTRUE;
+Bool_t plotdPhiHdrGamIsolated    = kTRUE;
+Bool_t plotMinimumIsoDistance    = kTRUE;
+Bool_t plotFFzHdrGam             = kTRUE;
+Bool_t plotImbalanceHdrGam       = kTRUE;
+//----------------------------------------------------------------
+
+
 /** ----------------- end define which histograms to plot here -------------------------------*/
 
 
@@ -533,9 +541,25 @@ const char * electronTable[] = {
   "Vertex Cut","TRDOut","TRDrefit","TPCrefit",
   "ITSrefit","TRDout+TPC+TPC+ITS+nsigma>3 Pass","pid!=0","ESDElec","ESD e+ JPsi",
   "ESD e- JPsi","ESD e+ e- JPSI","MC: gamma < 1.2","e+,e- < 0.9 g <1.2"
-
 };
 
+
+// for Gamma Jet analysis
+Int_t nXBinsdphiHdrGam = 100;
+Double_t firstXBindphiHdrGam = -TMath::PiOver2();
+Double_t lastXBindphiHdrGam = 3*TMath::PiOver2();
+
+Int_t nXBinsMinimumIsoDistance = 100;
+Double_t firstXBinMinimumIsoDistance = 0.;
+Double_t lastXBinMinimumIsoDistance = TMath::PiOver2();
+
+Int_t nXBinsFFzHdrGam = 100;
+Double_t firstXBinFFzHdrGam = 0.;
+Double_t lastXBinFFzHdrGam = 5;
+
+Int_t nXBinsImbalanceHdrGam = 100;
+Double_t firstXBinImbalanceHdrGam = -5.;
+Double_t lastXBinImbalanceHdrGam = 5.;
 ////////////////////////////////////////////////////////
 
 
@@ -553,12 +577,27 @@ TString outputFileName = "histogramsGammaConversion";
 TString outputFileAppendix = "";
 TString dataList = "";
 Bool_t writeNtuple = kFALSE;
+// WE DOO NOT NEED TO CHANGE THIS (usePWG4PartCorr) ANYMORE SINCE IT IS TAKEN CARE OF AUTOMATICALLY NOW
+Bool_t usePWG4PartCorr = kTRUE;
+
+/** Flag to enable running on train  */
+Bool_t runOnTrain = kFALSE;
+
+/** ------------------------------ Monte Carlo flag -----------------------------------------*/
+Bool_t doMCTruth = kTRUE;
+/** ---------------------------- end Monte Carlo flag ---------------------------------------*/
+
+/** ------------------------- Choose KFParticle OR ESDTrack  --------------------------------*/
+Bool_t useKFParticle = kTRUE;
+Bool_t useESDTrack   = kFALSE;
+/** ----------------------- end Choose KFParticle OR ESDTrack  -----------------------------*/
+
+
+Bool_t calculateBackground = kTRUE;
 
 Bool_t scanArguments(TString arguments){
   Bool_t iResult = kTRUE;
        
-  //  cout<<"All arguments: "<<arguments<<endl;
-       
   TString allArgs=arguments;
   TString argument;
   int bMissingParam=0;
@@ -597,6 +636,46 @@ Bool_t scanArguments(TString arguments){
        cout<<"Writing ntuple to file."<<endl;
        writeNtuple = kTRUE;
       }
+      else if (argument.CompareTo("-run-on-train") == 0){
+       cout<<"Running on train"<<endl;
+       runOnTrain = kTRUE;
+      }
+      else if (argument.CompareTo("-run-jet") == 0){
+       cout<<"Running jet analysis"<<endl;
+       runJet = kTRUE;
+      }
+      else if (argument.CompareTo("-run-neutralmeson") == 0){
+       cout<<"Running neutral meson analysis"<<endl;
+       runNeutralMeson = kTRUE;
+      }
+      else if (argument.CompareTo("-run-neutral-meson") == 0){
+       cout<<"Running neutral meson analysis"<<endl;
+       runNeutralMeson = kTRUE;
+      }
+      else if (argument.CompareTo("-run-chic") == 0){
+       cout<<"Running Chi_c analysis"<<endl;
+       runChic = kTRUE;
+      }
+      else if (argument.CompareTo("-jet-off") == 0){
+       cout<<"Skipping jet analysis"<<endl;
+       runJet = kFALSE;
+      }
+      else if (argument.CompareTo("-neutralmeson-off") == 0){
+       cout<<"Skipping neutral meson analysis"<<endl;
+       runNeutralMeson = kFALSE;
+      }
+      else if (argument.CompareTo("-neutral-meson-off") == 0){
+       cout<<"Skipping neutral meson analysis"<<endl;
+       runNeutralMeson = kFALSE;
+      }
+      else if (argument.CompareTo("-chic-off") == 0){
+       cout<<"Skipping Chi_c analysis"<<endl;
+       runChic = kFALSE;
+      }
+      else if (argument.CompareTo("-mc-off") == 0){
+       cout<<"Switching off doMCTruth"<<endl;
+       doMCTruth = kFALSE;
+      }
       else if(argument.CompareTo("-append-to-output-file") == 0){
        if((bMissingParam=(++i>=pTokens->GetEntries()))) break;
        outputFileAppendix = "_"+((TObjString*)pTokens->At(i))->GetString();
@@ -609,7 +688,6 @@ Bool_t scanArguments(TString arguments){
        }
       }
     }
-               
     delete pTokens;
   }
   if (bMissingParam) {
@@ -619,12 +697,48 @@ Bool_t scanArguments(TString arguments){
   return iResult;
 }
 
-void ConfigGammaConversion(TString arguments){
+void SetVersionLibrary(){
+  // Check if the file $ALICE_ROOT/PWG4/GammaConv/AliAnalysisTaskGammaConversion.cxx exists.
+  // If yes, we set usePWG4PartCorr to false since we have a newer version
+  // If no, usePWG4PartCorr is true.
+
+  TString file = gSystem->Getenv("ALICE_ROOT");
+  file+="/PWG4/PartCorr/AliAnalysisTaskGammaConversion.cxx";
+
+  ifstream stream;
+  stream.open(file.Data());
+
+  if(!stream){
+    usePWG4PartCorr=kFALSE;
+  }
+  else{
+    usePWG4PartCorr=kTRUE;
+  }
+  stream.close();
+}
+
+
+
+void ConfigGammaConversion(TString arguments,AliAnalysisDataContainer *cin_esd=NULL){
        
   if(!scanArguments(arguments)){
     break;
   }
-       
+  
+  SetVersionLibrary(); // checks if PWG4GammaConv or PWG4PartCorr is used
+
+  if(cin_esd == NULL && runOnTrain == kTRUE){
+    cout<<"Error: runOnTrain flag is set to true but the input AliAnalysisDataContainer is NULL"<<endl;
+    cout<<"       you must also supply the AliAnalysisDataContainer as an argument"<<endl;
+    return;
+  }
+
+  if(cin_esd != NULL && runOnTrain == kFALSE){
+    cout<<"Error: runOnTrain flag is set to false but the input AliAnalysisDataContainer is not null"<<endl;
+    cout<<"       add -run-on-train to the arguments to turn switch runOnTrain to kTRUE"<<endl;
+    return;
+  }
+
   if(numberOfFilesToAnalyze==0){
     ifstream dataInStream;
     dataInStream.open(dataList.Data());
@@ -642,361 +756,71 @@ void ConfigGammaConversion(TString arguments){
       }
   }
   cout<<"Number Of files to analyze: "<<numberOfFilesToAnalyze<<endl;
-       
-  build();//build (if necessary) and load the libraries needed
-       
-  gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C"); // load the CreateChain macro
-       
-  AliLog::SetGlobalLogLevel(AliLog::kError);
-       
-  //-------------------------------- Creating the histograms -------------------------------
-  AliGammaConversionHistograms * histograms = new AliGammaConversionHistograms();
-       
-  if(plotMCConversionR == kTRUE){ histograms->AddHistogram("MC_Conversion_R","Radius of gamma conversion points",nXBinsR, firstXBinR, lastXBinR,"counts","cm");}
-  if(plotMCConversionZR == kTRUE){ histograms->AddHistogram("MC_Conversion_ZR","Radius of gamma conversion points vs Z",nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "cm", "cm");}
-  if(plotMCConversionXY == kTRUE){ histograms->AddHistogram("MC_Conversion_XY","Gamma XY converison point.",nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "cm", "cm");}
-  if(plotMCConversionOpeningAngle == kTRUE){ histograms->AddHistogram("MC_Conversion_OpeningAngle","Opening angle of e+e- pairs from gamma conversion",nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "counts", "cm");}
-       
-  if(plotMCEEnergy == kTRUE){ histograms->AddHistogram("MC_E_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCEPt == kTRUE){ histograms->AddHistogram("MC_E_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCEEta == kTRUE){ histograms->AddHistogram("MC_E_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCEPhi == kTRUE){ histograms->AddHistogram("MC_E_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-       
-  if(plotMCPEnergy == kTRUE){ histograms->AddHistogram("MC_P_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCPPt == kTRUE){ histograms->AddHistogram("MC_P_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCPEta == kTRUE){ histograms->AddHistogram("MC_P_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCPPhi == kTRUE){ histograms->AddHistogram("MC_P_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-       
-  if(plotMCallGammaEnergy == kTRUE){ histograms->AddHistogram("MC_allGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCallGammaPt == kTRUE){ histograms->AddHistogram("MC_allGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCallGammaEta == kTRUE){ histograms->AddHistogram("MC_allGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCallGammaPhi == kTRUE){ histograms->AddHistogram("MC_allGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotMCallGammaRapid == kTRUE){ histograms->AddHistogram("MC_allGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-       
-  if(plotMCConvGammaEnergy == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCConvGammaPt == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCConvGammaEta == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCConvGammaPhi == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotMCConvGammaRapid == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotMCConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Pt_Eta","", nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta,"","");}
-       
-  if(plotMCallDirectGammaEnergy == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCallDirectGammaPt == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCallDirectGammaEta == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCallDirectGammaPhi == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotMCallDirectGammaRapid == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-       
-  if(plotMCConvDirectGammaEnergy == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCConvDirectGammaPt == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCConvDirectGammaEta == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCConvDirectGammaPhi == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotMCConvDirectGammaRapid == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-       
-  if(plotMCMotherEta == kTRUE){ histograms->AddHistogram("MC_Mother_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCMotherPhi == kTRUE){ histograms->AddHistogram("MC_Mother_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotMCMotherRapid == kTRUE){ histograms->AddHistogram("MC_Mother_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotMCMotherPt == kTRUE){ histograms->AddHistogram("MC_Mother_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCMotherEnergy == kTRUE){ histograms->AddHistogram("MC_Mother_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCMotherMass == kTRUE){ histograms->AddHistogram("MC_Mother_Mass" ,"" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
-  if(plotMCMotherOpeningAngle == kTRUE){ histograms->AddHistogram("MC_Mother_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
-  if(plotMCMotherR == kTRUE){ histograms->AddHistogram("MC_Mother_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
-  if(plotMCMotherZR == kTRUE){ histograms->AddHistogram("MC_Mother_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
-  if(plotMCMotherXY == kTRUE){ histograms->AddHistogram("MC_Mother_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
-  if(plotMCMotherPtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCMotherPtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotMCMotherPtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCMotherPtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-
-  if(plotMCMotherSpectra == kTRUE){ 
-    histograms->AddHistogram("MC_Mother_InvMass_vs_Pt" ,"" ,nXBinsSpectra, firstXBinSpectra, lastXBinSpectra, nYBinsSpectra, firstYBinSpectra, lastYBinSpectra, "", "");
-    histograms->AddHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance" ,"" ,nXBinsSpectra, firstXBinSpectra, lastXBinSpectra, nYBinsSpectra, firstYBinSpectra, lastYBinSpectra, "", "");
-    histograms->AddHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance" ,"" ,nXBinsSpectra, firstXBinSpectra, lastXBinSpectra, nYBinsSpectra, firstYBinSpectra, lastYBinSpectra, "", "");
+  
+  if(runOnTrain == kFALSE){
+    build();//build (if necessary) and load the libraries needed
   }
-       
-       
-  if(plotMCPi0Eta == kTRUE){ histograms->AddHistogram("MC_Pi0_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}       
-  if(plotMCPi0Rapid == kTRUE){ histograms->AddHistogram("MC_Pi0_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}     
-  if(plotMCPi0Phi == kTRUE){ histograms->AddHistogram("MC_Pi0_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotMCPi0Pt == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCPi0Energy == kTRUE){ histograms->AddHistogram("MC_Pi0_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCPi0Mass == kTRUE){ histograms->AddHistogram("MC_Pi0_Mass" ,"" , nXBinsPi0Mass, firstXBinPi0Mass, lastXBinPi0Mass, "", "");}
-  if(plotMCPi0OpeningAngle == kTRUE){ histograms->AddHistogram("MC_Pi0_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
-  if(plotMCPi0R == kTRUE){ histograms->AddHistogram("MC_Pi0_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
-  if(plotMCPi0ZR == kTRUE){ histograms->AddHistogram("MC_Pi0_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
-  if(plotMCPi0XY == kTRUE){ histograms->AddHistogram("MC_Pi0_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
-  if(plotMCPi0PtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCPi0PtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotMCPi0PtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCPi0PtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-       
-       
-  if(plotMCPi0SecondaryEta == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCPi0SecondaryRapid == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotMCPi0SecondaryPhi == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotMCPi0SecondaryPt == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCPi0SecondaryEnergy == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCPi0SecondaryMass == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Mass" ,"" , nXBinsPi0Mass, firstXBinPi0Mass, lastXBinPi0Mass, "", "");}
-  if(plotMCPi0SecondaryOpeningAngle == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
-  if(plotMCPi0SecondaryR == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
-  if(plotMCPi0SecondaryZR == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
-  if(plotMCPi0SecondaryXY == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
-  if(plotMCPi0SecondaryPtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCPi0SecondaryPtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotMCPi0SecondaryPtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCPi0SecondaryPtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-       
-       
-       
-  if(plotMCEtaEta == kTRUE){ histograms->AddHistogram("MC_Eta_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCEtaRapid == kTRUE){ histograms->AddHistogram("MC_Eta_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotMCEtaPhi == kTRUE){ histograms->AddHistogram("MC_Eta_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotMCEtaPt == kTRUE){ histograms->AddHistogram("MC_Eta_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotMCEtaEnergy == kTRUE){ histograms->AddHistogram("MC_Eta_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotMCEtaMass == kTRUE){ histograms->AddHistogram("MC_Eta_Mass" ,"" , nXBinsEtaMass, firstXBinEtaMass, lastXBinEtaMass, "", "");}
-  if(plotMCEtaOpeningAngleGamma == kTRUE){ histograms->AddHistogram("MC_Eta_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
-  if(plotMCEtaR == kTRUE){ histograms->AddHistogram("MC_Eta_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
-  if(plotMCEtaZR == kTRUE){ histograms->AddHistogram("MC_Eta_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
-  if(plotMCEtaXY == kTRUE){ histograms->AddHistogram("MC_Eta_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
-  if(plotMCEtaPtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCEtaPtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotMCEtaPtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotMCEtaPtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-       
-       
-  // Histograms from esd tracks        
-  if(plotESDEEnergy == kTRUE){ histograms->AddHistogram("ESD_E_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotESDEPt == kTRUE){ histograms->AddHistogram("ESD_E_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotESDEEta == kTRUE){ histograms->AddHistogram("ESD_E_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotESDEPhi == kTRUE){ histograms->AddHistogram("ESD_E_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-       
-  if(plotESDPEnergy == kTRUE){ histograms->AddHistogram("ESD_P_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotESDPPt == kTRUE){ histograms->AddHistogram("ESD_P_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotESDPEta == kTRUE){ histograms->AddHistogram("ESD_P_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotESDPPhi == kTRUE){ histograms->AddHistogram("ESD_P_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-       
-  if(plotESDConvGammaEnergy == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotESDConvGammaPt == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotESDConvGammaEta == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotESDConvGammaPhi == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotESDConvGammaMass == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Mass" ,"" ,  nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
-  if(plotESDConvGammaWidth == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Width" ,"" , nXBinsGammaWidth, firstXBinGammaWidth, lastXBinGammaWidth, "", "");}
-  if(plotESDConvGammaChi2 == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Chi2" ,"" , nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
-  if(plotESDConvGammaNDF == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_NDF" ,"" , nXBinsGammaNDF, firstXBinGammaNDF, lastXBinGammaNDF, "", "");}
-  if(plotESDConvGammaRapid == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotESDConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Pt_Eta","", nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta,"","" );}
-
-  if(plotESDConversionR == kTRUE){ histograms->AddHistogram("ESD_Conversion_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
-  if(plotESDConversionZR == kTRUE){ histograms->AddHistogram("ESD_Conversion_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
-  if(plotESDConversionXY == kTRUE){ histograms->AddHistogram("ESD_Conversion_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
-  if(plotESDConversionOpeningAngle == kTRUE){ histograms->AddHistogram("ESD_Conversion_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
-
-
-  if(plotESDTrueConvGammaEnergy == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotESDTrueConvGammaPt == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotESDTrueConvGammaEta == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotESDTrueConvGammaPhi == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotESDTrueConvGammaMass == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Mass" ,"" ,  nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
-  if(plotESDTrueConvGammaWidth == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Width" ,"" , nXBinsGammaWidth, firstXBinGammaWidth, lastXBinGammaWidth, "", "");}
-  if(plotESDTrueConvGammaChi2 == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Chi2" ,"" , nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
-  if(plotESDTrueConvGammaNDF == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_NDF" ,"" , nXBinsGammaNDF, firstXBinGammaNDF, lastXBinGammaNDF, "", "");}
-  if(plotESDTrueConvGammaRapid == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotESDTrueConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Pt_Eta" ,"" , nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-
-  if(plotESDTrueConversionR == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
-  if(plotESDTrueConversionZR == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
-  if(plotESDTrueConversionXY == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
-  if(plotESDTrueConversionOpeningAngle == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
-
-
-
-  if(plotESDNoCutConvGammaEnergy == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotESDNoCutConvGammaPt == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotESDNoCutConvGammaEta == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotESDNoCutConvGammaPhi == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotESDNoCutConvGammaMass == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Mass" ,"" ,  nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
-  if(plotESDNoCutConvGammaWidth == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Width" ,"" , nXBinsGammaWidth, firstXBinGammaWidth, lastXBinGammaWidth, "", "");}
-  if(plotESDNoCutConvGammaChi2 == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Chi2" ,"" , nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
-  if(plotESDNoCutConvGammaNDF == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_NDF" ,"" , nXBinsGammaNDF, firstXBinGammaNDF, lastXBinGammaNDF, "", "");}
-  if(plotESDNoCutConvGammaRapid == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-  if(plotESDNoCutConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Pt_Eta" ,"" , nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-
-  if(plotESDNoCutConversionR == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
-  if(plotESDNoCutConversionZR == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
-  if(plotESDNoCutConversionXY == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
-  if(plotESDNoCutConversionOpeningAngle == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
-
-
-
-
-  if(plotESDMotherOpeningAngleGamma == kTRUE){ histograms->AddHistogram("ESD_Mother_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
-  if(plotESDMotherEnergy == kTRUE){ histograms->AddHistogram("ESD_Mother_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotESDMotherPt == kTRUE){ histograms->AddHistogram("ESD_Mother_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotESDMotherEta == kTRUE){ histograms->AddHistogram("ESD_Mother_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotESDMotherPhi == kTRUE){ histograms->AddHistogram("ESD_Mother_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotESDMotherMass == kTRUE){ histograms->AddHistogram("ESD_Mother_Mass" ,"" , nXBinsPi0Mass, firstXBinPi0Mass, lastXBinPi0Mass, "", "");}
-  if(plotESDMotherR == kTRUE){ histograms->AddHistogram("ESD_Mother_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
-  if(plotESDMotherZR == kTRUE){ histograms->AddHistogram("ESD_Mother_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
-  if(plotESDMotherXY == kTRUE){ histograms->AddHistogram("ESD_Mother_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
-  if(plotESDMotherRapid == kTRUE){ histograms->AddHistogram("ESD_Mother_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
-
-       
-  if(plotESDBackgroundOpeningAngleGamma == kTRUE){ histograms->AddHistogram("ESD_Background_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
-  if(plotESDBackgroundEnergy == kTRUE){ histograms->AddHistogram("ESD_Background_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
-  if(plotESDBackgroundPt == kTRUE){ histograms->AddHistogram("ESD_Background_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
-  if(plotESDBackgroundEta == kTRUE){ histograms->AddHistogram("ESD_Background_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
-  if(plotESDBackgroundPhi == kTRUE){ histograms->AddHistogram("ESD_Background_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
-  if(plotESDBackgroundMass == kTRUE){ histograms->AddHistogram("ESD_Background_Mass" ,"" , nXBinsEtaMass, firstXBinEtaMass, lastXBinEtaMass, "", "");}
-  if(plotESDBackgroundR == kTRUE){ histograms->AddHistogram("ESD_Background_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
-  if(plotESDBackgroundZR == kTRUE){ histograms->AddHistogram("ESD_Background_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
-  if(plotESDBackgroundXY == kTRUE){ histograms->AddHistogram("ESD_Background_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
-  if(plotESDBackgroundRapid == kTRUE){ histograms->AddHistogram("ESD_Background_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
 
+  gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C"); // load the CreateChain macro
        
-  if(plotMapping == kTRUE){
-    histograms->InitializeMappingValues(nPhiIndex,nRIndex,nXBinsMapping,minRadius,maxRadius,nYBinsMapping,minPhi,maxPhi);
-    histograms->AddMappingHistograms(nPhiIndex,nRIndex,nXBinsMapping,minRadius,maxRadius,nYBinsMapping,minPhi,maxPhi);
-  }
-       
-  if(plotResolutiondPt == kTRUE){histograms->AddHistogram("Resolution_dPt" ,"" , nXBinsResdPt, firstXBinResdPt, lastXBinResdPt, nYBinsResdPt, firstYBinResdPt, lastYBinResdPt, "", "");}
-  if(plotResolutiondR == kTRUE){histograms->AddHistogram("Resolution_dR" ,"" , nXBinsResdR, firstXBinResdR, lastXBinResdR, nYBinsResdR, firstYBinResdR, lastYBinResdR, "", "");}
-  if(plotResolutiondZ == kTRUE){histograms->AddHistogram("Resolution_dZ" ,"" , nXBinsResdZ, firstXBinResdZ, lastXBinResdZ, nYBinsResdZ, firstYBinResdZ, lastYBinResdZ, "", "");}
-       
-  if(plotResolutiondRdPt == kTRUE){histograms->AddHistogram("Resolution_dR_dPt" ,"" , nXBinsResdRdPt, firstXBinResdRdPt, lastXBinResdRdPt, nYBinsResdRdPt, firstYBinResdRdPt, lastYBinResdRdPt, "", "");}
-       
-  if(plotResolutionMCPt == kTRUE){histograms->AddHistogram("Resolution_MC_Pt" ,"" , nXBinsResPt, firstXBinResPt, lastXBinResPt,"","");}
-  if(plotResolutionMCR == kTRUE){histograms->AddHistogram("Resolution_MC_R" ,"" , nXBinsResR, firstXBinResR, lastXBinResR,"","");}
-  if(plotResolutionMCZ == kTRUE){histograms->AddHistogram("Resolution_MC_Z" ,"" , nXBinsResZ, firstXBinResZ, lastXBinResZ,"","");}
-       
-  if(plotResolutionESDPt == kTRUE){histograms->AddHistogram("Resolution_ESD_Pt" ,"" , nXBinsResPt, firstXBinResPt, lastXBinResPt,"","");}
-  if(plotResolutionESDR == kTRUE){histograms->AddHistogram("Resolution_ESD_R" ,"" , nXBinsResR, firstXBinResR, lastXBinResR,"","");}
-  if(plotResolutionESDZ == kTRUE){histograms->AddHistogram("Resolution_ESD_Z" ,"" , nXBinsResZ, firstXBinResZ, lastXBinResZ,"","");}
-       
-  if(plotESDNumberOfV0s == kTRUE){histograms->AddHistogram("ESD_NumberOfV0s","Number of v0s",100, 0, 100,"","");}
-  if(plotESDNumberOfSurvivingV0s == kTRUE){histograms->AddHistogram("ESD_NumberOfSurvivingV0s","Number of surviving v0s",100, 0, 100,"","");}
+  AliLog::SetGlobalLogLevel(AliLog::kError);
        
-  //  debug histograms
-  if(plotESDCutGetOnFly == kTRUE){histograms->AddHistogram("ESD_CutGetOnFly_InvMass" ,"Not GetOnFly" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutNContributors == kTRUE){histograms->AddHistogram("ESD_CutNContributors_InvMass" ,"NContributors <= 0" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutLikeSign == kTRUE){histograms->AddHistogram("ESD_CutLikeSign_InvMass" ,"LikeSign" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutRefit == kTRUE){histograms->AddHistogram("ESD_CutRefit_InvMass" ,"No TPC refit" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutKink == kTRUE){histograms->AddHistogram("ESD_CutKink_InvMass" ,"Kinks" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutPIDProb == kTRUE){histograms->AddHistogram("ESD_CutPIDProb_InvMass" ,"wrong TPC PID" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutR == kTRUE){histograms->AddHistogram("ESD_CutR_InvMass" ,"Above RMax" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutNDF == kTRUE){histograms->AddHistogram("ESD_CutNDF_InvMass" ,"NDF <= 0" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutChi2 == kTRUE){histograms->AddHistogram("ESD_CutChi2_InvMass" ,"#chi^{2} > Max" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutEta == kTRUE){histograms->AddHistogram("ESD_CutEta_InvMass" ,"Above #eta max" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutPt == kTRUE){histograms->AddHistogram("ESD_CutPt_InvMass" ,"Below p_{t} min" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDCutLine == kTRUE){histograms->AddHistogram("ESD_CutLine_InvMass" ,"Out of reconstruction area" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
-  if(plotESDTrueConvGammaTrackLength == kTRUE){histograms->AddHistogram("ESD_TrueConvGamma_TrackLength","Track length of TrueConvGamma",nXBinsTrackLength,firstXBinTrackLength,lastXBinTrackLength,"","");}
-  if(plotESDTrueConvGammaTrackLengthVSInvMass == kTRUE){histograms->AddHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass","Track length of TrueConvGamma vs Inv mass",nXBinsTrackLength,firstXBinTrackLength,lastXBinTrackLength,nXBinsPt, firstXBinPt, lastXBinPt,"","");}
-
-
-  if(plotPi0Spectra == kTRUE){
-    histograms->AddHistogram("ESD_Mother_InvMass_vs_Pt" ,"Invariant Mass vs Pt" , nXBinsSpectra, firstXBinSpectra, lastXBinSpectra,nYBinsSpectra, firstYBinSpectra, lastYBinSpectra,"InvMass [GeV]","Pt [GeV]");
-    histograms->AddHistogram("ESD_Mother_InvMass","Invariant mass",nXBinsSpectra,firstXBinSpectra, lastXBinSpectra,"InvMass [GeV]","Counts");
+  AliGammaConversionHistograms* histograms = new AliGammaConversionHistograms();  
+  AddHistograms(histograms);
+       
+  // Create the Analysis manager
+  AliAnalysisManager *mgr =NULL;
+  if(runOnTrain == kFALSE){
+   mgr  = new AliAnalysisManager("My Manager", "My Analysis");
   }
-  if(plotPi0Spectra == kTRUE && calculateBackground == kTRUE){
-    histograms->AddHistogram("ESD_Background_InvMass_vs_Pt" ,"Background Invariant Mass vs Pt" , nXBinsSpectra, firstXBinSpectra, lastXBinSpectra,nYBinsSpectra, firstYBinSpectra, lastYBinSpectra,"InvMass [GeV]","Pt [GeV]");
-    histograms->AddHistogram("ESD_Background_InvMass","Invariant mass background",nXBinsSpectra,firstXBinSpectra, lastXBinSpectra,"InvMass BG [GeV]","Counts");
+  else{
+    mgr = AliAnalysisManager::GetAnalysisManager();
   }
-       
-//////////////////////////////Chi_c Analysis/////////////////////////////////////////////////////////////////
-
-     if(plotESDInvMassePluseMinus == kTRUE){histograms->AddHistogram("ESD_InvMass_ePluseMinus","",nXBinsJPsiMass, firstXBinJPsiMass, lastXBinJPsiMass, "",
-"");}
-      if(plotESDInvMassePluseMinus == kTRUE){histograms->AddHistogram("ESD_InvMass_ePluseMinusTest","",nXBinsJPsiMass, firstXBinJPsiMass, lastXBinJPsiMass,
- "","");}
-      if(plotESDInvMassePluseMinus == kTRUE){histograms->AddHistogram("ESD_InvMass_xPlusxMinus","",nXBinsJPsiMass, firstXBinJPsiMass, lastXBinJPsiMass, "",
-"");}
-
-
-     if(plotESDElectronPosNegPt == kTRUE){histograms->AddHistogram("ESD_ElectronPosNegPt","",nXBinsEPosNegPt,firstXBinEPosNegPt,lastXBinEPosNegPt,"","");}
-     if(plotESDElectronPosNegEta == kTRUE){histograms->AddHistogram("ESD_ElectronPosNegEta","",nXBinsEPosNegEta,firstXBinEPosNegEta,lastXBinEPosNegEta,"","
-");}
-
-
-     if(plotESDElectronPosNegPt == kTRUE){histograms->AddHistogram("ESD_ElectronPosPt","",nXBinsEPosNegPt,firstXBinEPosNegPt,lastXBinEPosNegPt,"","");}
-     if(plotESDElectronPosNegPt == kTRUE){histograms->AddHistogram("ESD_ElectronNegPt","",nXBinsEPosNegPt,firstXBinEPosNegPt,lastXBinEPosNegPt,"","");}
-
-
-     if(plotESDElectronPosNegAngle == kTRUE){histograms->AddHistogram("ESD_ElectronPosNegJPsiAngle","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinEPo
-sNegAngle,"","");}
-
-
-    if(plotMCElectronPosNegPt == kTRUE){histograms->AddHistogram("MC_ElectronPosNegPt","",nXBinsEPosNegPt,firstXBinEPosNegPt,lastXBinEPosNegPt,"","");}
-     if(plotMCElectronPosNegEta == kTRUE){histograms->AddHistogram("MC_ElectronPosNegEta","",nXBinsEPosNegEta,firstXBinEPosNegEta,lastXBinEPosNegEta,"","")
-;}
-     if(plotMCElectronPosNegJPsiAngle == kTRUE){histograms->AddHistogram("MC_ElectronPosNegJPsiAngle","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinE
-PosNegAngle,"","");}
-      if(plotESDePoseNegAngle == kTRUE){histograms->AddHistogram("ESD_eNegePosAngleBeforeCut","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinEPosNegAn
-gle,"","");}
-        if(plotESDePoseNegAngle == kTRUE){histograms->AddHistogram("ESD_eNegePosAngleAfterCut","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinEPosNegA
-ngle,"","");}
-
-
-     if(plotESDInvMassGammaePluseMinusChiC == kTRUE) {histograms->AddHistogram("ESD_InvMass_GammaePluseMinusChiC","",nXBinsChicMass,firstXBinChicMass,lastX
-BinChicMass,"","");}
-     if(plotESDInvMassGammaePluseMinusChiC == kTRUE) {histograms->AddHistogram("ESD_InvMass_GammaePluseMinusChiCDiff","",nXBinsChicMass,firstXBinChicMass,l
-astXBinChicMass,"","");}
-     if(plotESDInvMassGammaePluseMinusPi0 == kTRUE) {histograms->AddHistogram("ESD_InvMass_GammaePluseMinusPi0","",nXBinsPi0Mass,firstXBinPi0Mass,lastXBinP
-i0Mass,"","");}
-
-
-     if(plotESDElectronPosNegPi0Angle == kTRUE){histograms->AddHistogram("ESD_ElectronPosNegPi0Angle","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinE
-PosNegAngle,"","");}
-if(plotMCElectronPosNegPi0Angle == kTRUE){histograms->AddHistogram("MC_ElectronPosNegPi0Angle","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinEPosNegAngle,"","");}
-
-     if(plotESDEPosBackground == kTRUE){histograms->AddHistogram("ESD_EPosBackground","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
-
-    if(plotESDEPosBackground == kTRUE){histograms->AddHistogram("ESD_EPosENegNoJPsiBG","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
-
-
-   if(plotESDENegBackground == kTRUE){histograms->AddHistogram("ESD_ENegBackground","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
-     if(plotESDEPosENegBackground == kTRUE){histograms->AddHistogram("ESD_EPosENegBackground","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
-     if(plotESDEPosENegBackgroundCut == kTRUE){histograms->AddHistogram("ESD_EPosENegBackgroundCut","",nXBinsEBackgroundCut,firstXBinEBackgroundCut,lastXBinEBackgroundCut,"","");}
-
-     if(plotESDEPosENegGammaBackgroundMX == kTRUE){histograms->AddHistogram("ESD_EPosENegGammaBackgroundMX","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
-      if(plotESDEPosENegGammaBackgroundMX == kTRUE){histograms->AddHistogram("ESD_EPosENegGammaBackgroundMXDiff","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
-
-
 
-    if(plotTableElectrons == kTRUE){ histograms->AddTable("Table_Electrons","",nElementsElectronTable,electronTable);}
+  if (!mgr) {
+    ::Error("ConfigGammaConversion", "No analysis manager to connect to.");
+    return NULL;
+  }
 
-///////////////////////////////////////////////////End Chic_Analysis/////////////////////////////////////////////////////////////
-       
-       
-  //------------------------------ end Creating the histograms -----------------------------
-       
-  // Create the Analysis manager
-  AliAnalysisManager *mgr  = new AliAnalysisManager("My Manager", "My Analysis");
-       
   // Define Input Event Handler 
   AliESDInputHandler* inpHandler = new AliESDInputHandler();
        
-  // Define Output Event Handler
-  AliAODHandler* aodHandler = new AliAODHandler();
-  TString fileOutAOD = "AOD_"+ outputFileName + outputFileAppendix + ".root";
-  aodHandler->SetOutputFileName(fileOutAOD);
-  //  aodHandler->SetOutputFileName("aodAliGammaConversion.root");
-       
   // Define MC Truth Event Handler
   AliMCEventHandler* mcHandler = new AliMCEventHandler();
        
-  // Add Handlers to the Task Manager
-  mgr->SetInputEventHandler  (inpHandler);
-  mgr->SetOutputEventHandler (aodHandler);
-  mgr->SetMCtruthEventHandler(mcHandler);
-       
+  // Define Output Event Handler and ad
+  if(runOnTrain == kFALSE){
+    AliAODHandler* aodHandler = new AliAODHandler();
+    TString fileOutAOD = "AOD_"+ outputFileName + outputFileAppendix + ".root";
+    aodHandler->SetOutputFileName(fileOutAOD);
+    mgr->SetOutputEventHandler (aodHandler);
+  }
+
+  if(runOnTrain == kFALSE){
+    mgr->SetInputEventHandler  (inpHandler);
+    mgr->SetMCtruthEventHandler(mcHandler);
+  }
   // Be sure you are told what you are doing
   //  mgr->SetDebugLevel(10);
        
   // Declare Common Input Tchain
   AliAnalysisDataContainer *cinput1 = NULL;
   if(usePWG4PartCorr){
-    cinput1 = mgr->CreateContainer("Chain",TChain::Class(),AliAnalysisManager::kInputContainer);
+    if(runOnTrain == kFALSE){
+      cinput1 = mgr->CreateContainer("Chain",TChain::Class(),AliAnalysisManager::kInputContainer);
+    }
+    else{
+      cinput1 = cin_esd;
+    }
   }
   else{
-    cinput1 = mgr->GetCommonInputContainer();
+    if(runOnTrain == kFALSE){
+      cinput1 = mgr->GetCommonInputContainer();
+    }
+    else{
+      //      cinput = cin_esd;
+      cinput1 = mgr->GetCommonInputContainer();
+    }
   }
        
   // Common Output Tree in common Ã¢\80\98defaultâ\80\99 output file
@@ -1016,22 +840,20 @@ if(plotMCElectronPosNegPi0Angle == kTRUE){histograms->AddHistogram("MC_ElectronP
     outputFileAppendix.ReplaceAll(".root","");
   }
   TString fileOut = outputFileName + outputFileAppendix + ".root";
-       
+
   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("histogramsAliGammaConversion", TList::Class(),AliAnalysisManager::kOutputContainer, fileOut);
-       
-       
   //------------------------ END: Define input/output handlers ---------------------------------------------------
        
-       
   //check for errors in the specified data
   if(useKFParticle == kTRUE && useESDTrack == kTRUE){
     //Print warning, cannot use both
+    ::Error("ConfigGammaConversion","Both useKFParticle and useESDTracks can be true at the same time")
   }
   if(useKFParticle == kFALSE && useESDTrack == kFALSE){
     //Print warning, one have to be specified
+    ::Error("ConfigGammaConversion","Both useKFParticle and useESDTracks can be false at the same time")
   }
-       
-       
+               
   //Create the V0Reader
   AliV0Reader * v0Reader = new AliV0Reader();
   if(useKFParticle){
@@ -1087,36 +909,44 @@ if(plotMCElectronPosNegPi0Angle == kTRUE){histograms->AddHistogram("MC_ElectronP
   v0Reader->SetHistograms(histograms);// also give the pointer to the v0reader, for debugging cuts
        
   gammaconversion->SetDoMCTruth(doMCTruth);
-       
+
+  gammaconversion->SetDoNeutralMeson(runNeutralMeson);
+  gammaconversion->SetDoJet(runJet);
+  gammaconversion->SetDoChic(runChic);
+  
        
   // Add task to the manager 
   mgr->AddTask(gammaconversion);
        
   // Connect I/O to the task
   mgr->ConnectInput (gammaconversion, 0, cinput1);
-  mgr->ConnectOutput(gammaconversion, 0, coutput1);
-  mgr->ConnectOutput(gammaconversion, 1, coutput2);
-       
+  
+  if(runOnTrain == kFALSE){
+    mgr->ConnectOutput(gammaconversion, 0, coutput1);
+    mgr->ConnectOutput(gammaconversion, 1, coutput2);
+  }
   if(dataList.IsNull()){
     cout<<"Data list is not set, aborting."<<endl;
     return;
   }
+  
+  if(runOnTrain == kFALSE){
+    TChain* chain= CreateESDChain(dataList,numberOfFilesToAnalyze);
        
-  TChain* chain= CreateESDChain(dataList,numberOfFilesToAnalyze);
+    mgr->InitAnalysis();
+    
+    mgr->PrintStatus();
        
-  mgr->InitAnalysis();
-       
-  mgr->PrintStatus();
-       
-  mgr->StartAnalysis("local",chain);
+    mgr->StartAnalysis("local",chain);
+  }
 }
 
 void build() {
+  
   TStopwatch timer;
   timer.Start();
   gSystem->Load("libTree.so");
   gSystem->Load("libGeom");
-  //  gSystem->Load("libANALYSISalice");
        
   ////
   //Setting up ESD.par//
@@ -1156,20 +986,11 @@ void build() {
   gSystem->Load("libANALYSISalice.so");
        
   ////
-  //Setting up PWG4Gamma.par//
+  //Setting up PWG4GammaConv.par//
   ////
-  //  cout<<"compiling GammaConv"<<endl;
-       
-  if(usePWG4PartCorr == kTRUE){
-    cout<<"Using PWG4PartCorr library"<<endl;
-    setupPar("PWG4PartCorr");
-    gSystem->Load("libPWG4PartCorr.so");  
-  }
-  else{
-    setupPar("PWG4GammaConv");
-    gSystem->Load("libPWG4GammaConv.so");
-  }
-  //if head:: use PWG4PartCorr
+  cout<<"compiling PWG4GammaConv"<<endl;
+  setupPar("PWG4GammaConv");
+  gSystem->Load("libPWG4GammaConv.so");
 }
 
 Int_t setupPar(const char* pararchivename) {
@@ -1206,3 +1027,350 @@ Int_t setupPar(const char* pararchivename) {
   }                                                                                                                                               
   return 1;
 }
+
+
+
+void AddHistograms(AliGammaConversionHistograms *histograms){
+  //---------------------------------------------- Jets ---------------------------------------------------------
+  if(runJet == kTRUE){
+    if (plotdPhiHdrGam == kTRUE){
+      histograms->AddHistogram("ESD_dphiHdrGam","ESD_dphiHdrGam", nXBinsdphiHdrGam,firstXBindphiHdrGam,lastXBindphiHdrGam,"dphiHdrGam (rad)","Counts");
+    }
+    
+    if (plotdPhiHdrGamIsolated == kTRUE){
+      histograms->AddHistogram("ESD_dphiHdrGamIsolated","ESD_dphiHdrGamIsolated",  nXBinsdphiHdrGam,firstXBindphiHdrGam,lastXBindphiHdrGam,"dphiHdrGamIsolated (rad)","Counts");
+    }
+    
+    if (plotMinimumIsoDistance == kTRUE){
+      histograms->AddHistogram("ESD_MinimumIsoDistance","ESD_MinimumIsoDistance", nXBinsMinimumIsoDistance,firstXBinMinimumIsoDistance,lastXBinMinimumIsoDistance,"Minimum Iso Distance (rad)","Counts");
+    }
+    
+    if (plotFFzHdrGam == kTRUE){
+      histograms->AddHistogram("ESD_FFzHdrGam","ESD_FFzHdrGam", nXBinsFFzHdrGam, firstXBinFFzHdrGam,lastXBinFFzHdrGam,"FFz Hdr Gam","Counts");
+    }
+    
+    if (plotImbalanceHdrGam == kTRUE){
+      histograms->AddHistogram("ESD_ImbalanceHdrGam","ESD_ImbalanceHdrGam", nXBinsImbalanceHdrGam, firstXBinImbalanceHdrGam,lastXBinImbalanceHdrGam,"Imbalance Hdr Gam","Counts");
+    }
+  }//end if(runJet)
+
+  //---------------------------------------------- Chi_c ---------------------------------------------------------
+  if(runChic){
+
+    if(plotESDInvMassePluseMinus == kTRUE){histograms->AddHistogram("ESD_InvMass_ePluseMinus","",nXBinsJPsiMass, firstXBinJPsiMass, lastXBinJPsiMass, "",
+                                                                   "");}
+    if(plotESDInvMassePluseMinus == kTRUE){histograms->AddHistogram("ESD_InvMass_ePluseMinusTest","",nXBinsJPsiMass, firstXBinJPsiMass, lastXBinJPsiMass,
+                                                                   "","");}
+    if(plotESDInvMassePluseMinus == kTRUE){histograms->AddHistogram("ESD_InvMass_xPlusxMinus","",nXBinsJPsiMass, firstXBinJPsiMass, lastXBinJPsiMass, "",
+                                                                   "");}
+    if(plotESDElectronPosNegPt == kTRUE){histograms->AddHistogram("ESD_ElectronPosNegPt","",nXBinsEPosNegPt,firstXBinEPosNegPt,lastXBinEPosNegPt,"","");}
+    if(plotESDElectronPosNegEta == kTRUE){histograms->AddHistogram("ESD_ElectronPosNegEta","",nXBinsEPosNegEta,firstXBinEPosNegEta,lastXBinEPosNegEta,"","
+");}
+
+    if(plotESDElectronPosNegPt == kTRUE){histograms->AddHistogram("ESD_ElectronPosPt","",nXBinsEPosNegPt,firstXBinEPosNegPt,lastXBinEPosNegPt,"","");}
+    if(plotESDElectronPosNegPt == kTRUE){histograms->AddHistogram("ESD_ElectronNegPt","",nXBinsEPosNegPt,firstXBinEPosNegPt,lastXBinEPosNegPt,"","");}
+
+    if(plotESDElectronPosNegAngle == kTRUE){histograms->AddHistogram("ESD_ElectronPosNegJPsiAngle","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinEPo
+                                                                    sNegAngle,"","");}
+    if(plotMCElectronPosNegPt == kTRUE){histograms->AddHistogram("MC_ElectronPosNegPt","",nXBinsEPosNegPt,firstXBinEPosNegPt,lastXBinEPosNegPt,"","");}
+    if(plotMCElectronPosNegEta == kTRUE){histograms->AddHistogram("MC_ElectronPosNegEta","",nXBinsEPosNegEta,firstXBinEPosNegEta,lastXBinEPosNegEta,"","")
+       ;}
+    if(plotMCElectronPosNegJPsiAngle == kTRUE){histograms->AddHistogram("MC_ElectronPosNegJPsiAngle","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinE
+                                                                       PosNegAngle,"","");}
+    if(plotESDePoseNegAngle == kTRUE){histograms->AddHistogram("ESD_eNegePosAngleBeforeCut","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinEPosNegAn
+                                                              gle,"","");}
+    if(plotESDePoseNegAngle == kTRUE){histograms->AddHistogram("ESD_eNegePosAngleAfterCut","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinEPosNegA
+                                                              ngle,"","");}
+    if(plotESDInvMassGammaePluseMinusChiC == kTRUE) {histograms->AddHistogram("ESD_InvMass_GammaePluseMinusChiC","",nXBinsChicMass,firstXBinChicMass,lastX
+                                                                             BinChicMass,"","");}
+    if(plotESDInvMassGammaePluseMinusChiC == kTRUE) {histograms->AddHistogram("ESD_InvMass_GammaePluseMinusChiCDiff","",nXBinsChicMass,firstXBinChicMass,l
+                                                                             astXBinChicMass,"","");}
+    if(plotESDInvMassGammaePluseMinusPi0 == kTRUE) {histograms->AddHistogram("ESD_InvMass_GammaePluseMinusPi0","",nXBinsPi0Mass,firstXBinPi0Mass,lastXBinP
+                                                                            i0Mass,"","");}
+    if(plotESDElectronPosNegPi0Angle == kTRUE){histograms->AddHistogram("ESD_ElectronPosNegPi0Angle","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinE
+                                                                       PosNegAngle,"","");}
+    if(plotMCElectronPosNegPi0Angle == kTRUE){histograms->AddHistogram("MC_ElectronPosNegPi0Angle","",nXBinsEPosNegAngle,firstXBinEPosNegAngle,lastXBinEPosNegAngle,"","");}
+
+    if(plotESDEPosBackground == kTRUE){histograms->AddHistogram("ESD_EPosBackground","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
+
+    if(plotESDEPosBackground == kTRUE){histograms->AddHistogram("ESD_EPosENegNoJPsiBG","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
+
+
+    if(plotESDENegBackground == kTRUE){histograms->AddHistogram("ESD_ENegBackground","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
+    if(plotESDEPosENegBackground == kTRUE){histograms->AddHistogram("ESD_EPosENegBackground","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
+    if(plotESDEPosENegBackgroundCut == kTRUE){histograms->AddHistogram("ESD_EPosENegBackgroundCut","",nXBinsEBackgroundCut,firstXBinEBackgroundCut,lastXBinEBackgroundCut,"","");}
+
+    if(plotESDEPosENegGammaBackgroundMX == kTRUE){histograms->AddHistogram("ESD_EPosENegGammaBackgroundMX","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
+    if(plotESDEPosENegGammaBackgroundMX == kTRUE){histograms->AddHistogram("ESD_EPosENegGammaBackgroundMXDiff","",nXBinsEBackground,firstXBinEBackground,lastXBinEBackground,"","");}
+
+    if(plotTableElectrons == kTRUE){ histograms->AddTable("Table_Electrons","",nElementsElectronTable,electronTable);}
+  }// end runChic
+  
+  //---------------------------------------------- Neutral Meson ---------------------------------------------------------
+  if(runNeutralMeson){
+    if(plotMCConversionR == kTRUE){ histograms->AddHistogram("MC_Conversion_R","Radius of gamma conversion points",nXBinsR, firstXBinR, lastXBinR,"counts","cm");}
+    if(plotMCConversionZR == kTRUE){ histograms->AddHistogram("MC_Conversion_ZR","Radius of gamma conversion points vs Z",nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "cm", "cm");}
+    if(plotMCConversionXY == kTRUE){ histograms->AddHistogram("MC_Conversion_XY","Gamma XY converison point.",nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "cm", "cm");}
+    if(plotMCConversionOpeningAngle == kTRUE){ histograms->AddHistogram("MC_Conversion_OpeningAngle","Opening angle of e+e- pairs from gamma conversion",nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "counts", "cm");}
+       
+    if(plotMCEEnergy == kTRUE){ histograms->AddHistogram("MC_E_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCEPt == kTRUE){ histograms->AddHistogram("MC_E_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCEEta == kTRUE){ histograms->AddHistogram("MC_E_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCEPhi == kTRUE){ histograms->AddHistogram("MC_E_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+       
+    if(plotMCPEnergy == kTRUE){ histograms->AddHistogram("MC_P_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCPPt == kTRUE){ histograms->AddHistogram("MC_P_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCPEta == kTRUE){ histograms->AddHistogram("MC_P_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCPPhi == kTRUE){ histograms->AddHistogram("MC_P_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+       
+    if(plotMCallGammaEnergy == kTRUE){ histograms->AddHistogram("MC_allGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCallGammaPt == kTRUE){ histograms->AddHistogram("MC_allGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCallGammaEta == kTRUE){ histograms->AddHistogram("MC_allGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCallGammaPhi == kTRUE){ histograms->AddHistogram("MC_allGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotMCallGammaRapid == kTRUE){ histograms->AddHistogram("MC_allGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+       
+    if(plotMCConvGammaEnergy == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCConvGammaPt == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCConvGammaEta == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCConvGammaPhi == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotMCConvGammaRapid == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("MC_ConvGamma_Pt_Eta","", nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta,"","");}
+       
+    if(plotMCallDirectGammaEnergy == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCallDirectGammaPt == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCallDirectGammaEta == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCallDirectGammaPhi == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotMCallDirectGammaRapid == kTRUE){ histograms->AddHistogram("MC_allDirectGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+       
+    if(plotMCConvDirectGammaEnergy == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCConvDirectGammaPt == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCConvDirectGammaEta == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCConvDirectGammaPhi == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotMCConvDirectGammaRapid == kTRUE){ histograms->AddHistogram("MC_ConvDirectGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+       
+    if(plotMCMotherEta == kTRUE){ histograms->AddHistogram("MC_Mother_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCMotherPhi == kTRUE){ histograms->AddHistogram("MC_Mother_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotMCMotherRapid == kTRUE){ histograms->AddHistogram("MC_Mother_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCMotherPt == kTRUE){ histograms->AddHistogram("MC_Mother_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCMotherEnergy == kTRUE){ histograms->AddHistogram("MC_Mother_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCMotherMass == kTRUE){ histograms->AddHistogram("MC_Mother_Mass" ,"" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
+    if(plotMCMotherOpeningAngle == kTRUE){ histograms->AddHistogram("MC_Mother_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
+    if(plotMCMotherR == kTRUE){ histograms->AddHistogram("MC_Mother_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
+    if(plotMCMotherZR == kTRUE){ histograms->AddHistogram("MC_Mother_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotMCMotherXY == kTRUE){ histograms->AddHistogram("MC_Mother_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+    if(plotMCMotherPtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCMotherPtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCMotherPtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCMotherPtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Mother_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+
+    if(plotMCMotherSpectra == kTRUE){ 
+      histograms->AddHistogram("MC_Mother_InvMass_vs_Pt" ,"" ,nXBinsSpectra, firstXBinSpectra, lastXBinSpectra, nYBinsSpectra, firstYBinSpectra, lastYBinSpectra, "", "");
+      histograms->AddHistogram("MC_Mother_InvMass_vs_Pt_withinAcceptance" ,"" ,nXBinsSpectra, firstXBinSpectra, lastXBinSpectra, nYBinsSpectra, firstYBinSpectra, lastYBinSpectra, "", "");
+      histograms->AddHistogram("MC_Mother_InvMass_vs_Pt_ConvGamma_withinAcceptance" ,"" ,nXBinsSpectra, firstXBinSpectra, lastXBinSpectra, nYBinsSpectra, firstYBinSpectra, lastYBinSpectra, "", "");
+    }
+       
+       
+    if(plotMCPi0Eta == kTRUE){ histograms->AddHistogram("MC_Pi0_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}     
+    if(plotMCPi0Rapid == kTRUE){ histograms->AddHistogram("MC_Pi0_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}   
+    if(plotMCPi0Phi == kTRUE){ histograms->AddHistogram("MC_Pi0_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotMCPi0Pt == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCPi0Energy == kTRUE){ histograms->AddHistogram("MC_Pi0_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCPi0Mass == kTRUE){ histograms->AddHistogram("MC_Pi0_Mass" ,"" , nXBinsPi0Mass, firstXBinPi0Mass, lastXBinPi0Mass, "", "");}
+    if(plotMCPi0OpeningAngle == kTRUE){ histograms->AddHistogram("MC_Pi0_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
+    if(plotMCPi0R == kTRUE){ histograms->AddHistogram("MC_Pi0_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
+    if(plotMCPi0ZR == kTRUE){ histograms->AddHistogram("MC_Pi0_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotMCPi0XY == kTRUE){ histograms->AddHistogram("MC_Pi0_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+    if(plotMCPi0PtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCPi0PtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCPi0PtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCPi0PtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCPi0ZRConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_ZR_ConvGamma_withinAcceptance" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+       
+       
+    if(plotMCPi0SecondaryEta == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCPi0SecondaryRapid == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCPi0SecondaryPhi == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotMCPi0SecondaryPt == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCPi0SecondaryEnergy == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCPi0SecondaryMass == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Mass" ,"" , nXBinsPi0Mass, firstXBinPi0Mass, lastXBinPi0Mass, "", "");}
+    if(plotMCPi0SecondaryOpeningAngle == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
+    if(plotMCPi0SecondaryR == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
+    if(plotMCPi0SecondaryZR == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotMCPi0SecondaryXY == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+    if(plotMCPi0SecondaryPtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCPi0SecondaryPtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCPi0SecondaryPtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCPi0SecondaryPtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Pi0_Secondaries_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+       
+       
+       
+    if(plotMCEtaEta == kTRUE){ histograms->AddHistogram("MC_Eta_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCEtaRapid == kTRUE){ histograms->AddHistogram("MC_Eta_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCEtaPhi == kTRUE){ histograms->AddHistogram("MC_Eta_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotMCEtaPt == kTRUE){ histograms->AddHistogram("MC_Eta_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotMCEtaEnergy == kTRUE){ histograms->AddHistogram("MC_Eta_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotMCEtaMass == kTRUE){ histograms->AddHistogram("MC_Eta_Mass" ,"" , nXBinsEtaMass, firstXBinEtaMass, lastXBinEtaMass, "", "");}
+    if(plotMCEtaOpeningAngleGamma == kTRUE){ histograms->AddHistogram("MC_Eta_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
+    if(plotMCEtaR == kTRUE){ histograms->AddHistogram("MC_Eta_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
+    if(plotMCEtaZR == kTRUE){ histograms->AddHistogram("MC_Eta_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotMCEtaXY == kTRUE){ histograms->AddHistogram("MC_Eta_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+    if(plotMCEtaPtvsEtaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Eta_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCEtaPtvsRapidWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Rapid_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCEtaPtvsEtaConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Eta_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotMCEtaPtvsRapidConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_Pt_Rapid_ConvGamma_withinAcceptance" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotMCEtaZRConvGammaWithinAcceptance == kTRUE){ histograms->AddHistogram("MC_Eta_ZR_ConvGamma_withinAcceptance" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+       
+       
+    // Histograms from esd tracks      
+    if(plotESDEEnergy == kTRUE){ histograms->AddHistogram("ESD_E_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotESDEPt == kTRUE){ histograms->AddHistogram("ESD_E_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotESDEEta == kTRUE){ histograms->AddHistogram("ESD_E_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDEPhi == kTRUE){ histograms->AddHistogram("ESD_E_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+       
+    if(plotESDPEnergy == kTRUE){ histograms->AddHistogram("ESD_P_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotESDPPt == kTRUE){ histograms->AddHistogram("ESD_P_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotESDPEta == kTRUE){ histograms->AddHistogram("ESD_P_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDPPhi == kTRUE){ histograms->AddHistogram("ESD_P_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+       
+    if(plotESDConvGammaEnergy == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotESDConvGammaPt == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotESDConvGammaEta == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDConvGammaPhi == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotESDConvGammaMass == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Mass" ,"" ,  nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
+    if(plotESDConvGammaWidth == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Width" ,"" , nXBinsGammaWidth, firstXBinGammaWidth, lastXBinGammaWidth, "", "");}
+    if(plotESDConvGammaChi2 == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Chi2" ,"" , nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
+    if(plotESDConvGammaNDF == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_NDF" ,"" , nXBinsGammaNDF, firstXBinGammaNDF, lastXBinGammaNDF, "", "");}
+    if(plotESDConvGammaRapid == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotESDConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Pt_Eta","", nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta,"","" );}
+    if(plotESDConvGammaPtvsChi2 == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Pt_Chi2" ,"" ,nXBinsPt, firstXBinPt, lastXBinPt, nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
+    if(plotESDConvGammaEtavsChi2 == kTRUE){ histograms->AddHistogram("ESD_ConvGamma_Eta_Chi2" ,"" ,nXBinsEta, firstXBinEta, lastXBinEta, nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
+
+
+
+    if(plotESDConversionR == kTRUE){ histograms->AddHistogram("ESD_Conversion_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
+    if(plotESDConversionZR == kTRUE){ histograms->AddHistogram("ESD_Conversion_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotESDConversionXY == kTRUE){ histograms->AddHistogram("ESD_Conversion_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+    if(plotESDConversionOpeningAngle == kTRUE){ histograms->AddHistogram("ESD_Conversion_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
+
+
+    if(plotESDTrueConvGammaEnergy == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotESDTrueConvGammaPt == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotESDTrueConvGammaEta == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDTrueConvGammaPhi == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotESDTrueConvGammaMass == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Mass" ,"" ,  nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
+    if(plotESDTrueConvGammaWidth == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Width" ,"" , nXBinsGammaWidth, firstXBinGammaWidth, lastXBinGammaWidth, "", "");}
+    if(plotESDTrueConvGammaChi2 == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Chi2" ,"" , nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
+    if(plotESDTrueConvGammaNDF == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_NDF" ,"" , nXBinsGammaNDF, firstXBinGammaNDF, lastXBinGammaNDF, "", "");}
+    if(plotESDTrueConvGammaRapid == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotESDTrueConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Pt_Eta" ,"" , nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDTrueConvGammaPtvsChi2 == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Pt_Chi2" ,"" ,nXBinsPt, firstXBinPt, lastXBinPt, nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
+    if(plotESDTrueConvGammaEtavsChi2 == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_Eta_Chi2" ,"" ,nXBinsEta, firstXBinEta, lastXBinEta, nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
+
+    if(plotESDTrueConversionR == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
+    if(plotESDTrueConversionZR == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotESDTrueConversionXY == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+    if(plotESDTrueConversionOpeningAngle == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
+
+    if(plotESDTrueConvGammaMCPtEta == kTRUE){ histograms->AddHistogram("ESD_TrueConvGamma_MC_Pt_Eta" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDTrueConversionMCZR == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_MC_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotESDTrueConversionMCXY == kTRUE){ histograms->AddHistogram("ESD_TrueConversion_MC_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+
+
+
+    if(plotESDNoCutConvGammaEnergy == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotESDNoCutConvGammaPt == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotESDNoCutConvGammaEta == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDNoCutConvGammaPhi == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotESDNoCutConvGammaMass == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Mass" ,"" ,  nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass, "", "");}
+    if(plotESDNoCutConvGammaWidth == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Width" ,"" , nXBinsGammaWidth, firstXBinGammaWidth, lastXBinGammaWidth, "", "");}
+    if(plotESDNoCutConvGammaChi2 == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Chi2" ,"" , nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
+    if(plotESDNoCutConvGammaNDF == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_NDF" ,"" , nXBinsGammaNDF, firstXBinGammaNDF, lastXBinGammaNDF, "", "");}
+    if(plotESDNoCutConvGammaRapid == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+    if(plotESDNoCutConvGammaPtvsEta == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Pt_Eta" ,"" , nXBinsPt, firstXBinPt, lastXBinPt,nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDNoCutConvGammaPtvsChi2 == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Pt_Chi2" ,"" ,nXBinsPt, firstXBinPt, lastXBinPt, nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
+    if(plotESDNoCutConvGammaEtavsChi2 == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_Eta_Chi2" ,"" ,nXBinsEta, firstXBinEta, lastXBinEta, nXBinsGammaChi2, firstXBinGammaChi2, lastXBinGammaChi2, "", "");}
+
+    if(plotESDNoCutConversionR == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
+    if(plotESDNoCutConversionZR == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotESDNoCutConversionXY == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+    if(plotESDNoCutConversionOpeningAngle == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
+
+    if(plotESDNoCutConvGammaMCPtEta == kTRUE){ histograms->AddHistogram("ESD_NoCutConvGamma_MC_Pt_Eta" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDNoCutConversionMCZR == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_MC_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotESDNoCutConversionMCXY == kTRUE){ histograms->AddHistogram("ESD_NoCutConversion_MC_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+
+
+
+    if(plotESDMotherOpeningAngleGamma == kTRUE){ histograms->AddHistogram("ESD_Mother_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
+    if(plotESDMotherEnergy == kTRUE){ histograms->AddHistogram("ESD_Mother_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotESDMotherPt == kTRUE){ histograms->AddHistogram("ESD_Mother_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotESDMotherEta == kTRUE){ histograms->AddHistogram("ESD_Mother_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDMotherPhi == kTRUE){ histograms->AddHistogram("ESD_Mother_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotESDMotherMass == kTRUE){ histograms->AddHistogram("ESD_Mother_Mass" ,"" , nXBinsPi0Mass, firstXBinPi0Mass, lastXBinPi0Mass, "", "");}
+    if(plotESDMotherR == kTRUE){ histograms->AddHistogram("ESD_Mother_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
+    if(plotESDMotherZR == kTRUE){ histograms->AddHistogram("ESD_Mother_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotESDMotherXY == kTRUE){ histograms->AddHistogram("ESD_Mother_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+    if(plotESDMotherRapid == kTRUE){ histograms->AddHistogram("ESD_Mother_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+
+       
+    if(plotESDBackgroundOpeningAngleGamma == kTRUE){ histograms->AddHistogram("ESD_Background_GammaDaughter_OpeningAngle" ,"" , nXBinsOpeningAngle, firstXBinOpeningAngle, lastXBinOpeningAngle, "", "");}
+    if(plotESDBackgroundEnergy == kTRUE){ histograms->AddHistogram("ESD_Background_Energy" ,"" , nXBinsEnergy, firstXBinEnergy, lastXBinEnergy, "", "");}
+    if(plotESDBackgroundPt == kTRUE){ histograms->AddHistogram("ESD_Background_Pt" ,"" , nXBinsPt, firstXBinPt, lastXBinPt, "", "");}
+    if(plotESDBackgroundEta == kTRUE){ histograms->AddHistogram("ESD_Background_Eta" ,"" , nXBinsEta, firstXBinEta, lastXBinEta, "", "");}
+    if(plotESDBackgroundPhi == kTRUE){ histograms->AddHistogram("ESD_Background_Phi" ,"" , nXBinsPhi, firstXBinPhi, lastXBinPhi, "", "");}
+    if(plotESDBackgroundMass == kTRUE){ histograms->AddHistogram("ESD_Background_Mass" ,"" , nXBinsEtaMass, firstXBinEtaMass, lastXBinEtaMass, "", "");}
+    if(plotESDBackgroundR == kTRUE){ histograms->AddHistogram("ESD_Background_R" ,"" , nXBinsR, firstXBinR, lastXBinR, "", "");}
+    if(plotESDBackgroundZR == kTRUE){ histograms->AddHistogram("ESD_Background_ZR" ,"" , nXBinsZR, firstXBinZR, lastXBinZR, nYBinsZR, firstYBinZR, lastYBinZR, "", "");}
+    if(plotESDBackgroundXY == kTRUE){ histograms->AddHistogram("ESD_Background_XY" ,"" , nXBinsXY, firstXBinXY, lastXBinXY, nYBinsXY, firstYBinXY, lastYBinXY, "", "");}
+    if(plotESDBackgroundRapid == kTRUE){ histograms->AddHistogram("ESD_Background_Rapid" ,"" , nXBinsRapid, firstXBinRapid, lastXBinRapid, "", "");}
+
+       
+    if(plotMapping == kTRUE){
+      histograms->InitializeMappingValues(nPhiIndex,nRIndex,nXBinsMapping,minRadius,maxRadius,nYBinsMapping,minPhi,maxPhi);
+      histograms->AddMappingHistograms(nPhiIndex,nRIndex,nXBinsMapping,minRadius,maxRadius,nYBinsMapping,minPhi,maxPhi);
+    }
+       
+    if(plotResolutiondPt == kTRUE){histograms->AddHistogram("Resolution_dPt" ,"" , nXBinsResdPt, firstXBinResdPt, lastXBinResdPt, nYBinsResdPt, firstYBinResdPt, lastYBinResdPt, "", "");}
+    if(plotResolutiondR == kTRUE){histograms->AddHistogram("Resolution_dR" ,"" , nXBinsResdR, firstXBinResdR, lastXBinResdR, nYBinsResdR, firstYBinResdR, lastYBinResdR, "", "");}
+    if(plotResolutiondZ == kTRUE){histograms->AddHistogram("Resolution_dZ" ,"" , nXBinsResdZ, firstXBinResdZ, lastXBinResdZ, nYBinsResdZ, firstYBinResdZ, lastYBinResdZ, "", "");}
+       
+    if(plotResolutiondRdPt == kTRUE){histograms->AddHistogram("Resolution_dR_dPt" ,"" , nXBinsResdRdPt, firstXBinResdRdPt, lastXBinResdRdPt, nYBinsResdRdPt, firstYBinResdRdPt, lastYBinResdRdPt, "", "");}
+       
+    if(plotResolutionMCPt == kTRUE){histograms->AddHistogram("Resolution_MC_Pt" ,"" , nXBinsResPt, firstXBinResPt, lastXBinResPt,"","");}
+    if(plotResolutionMCR == kTRUE){histograms->AddHistogram("Resolution_MC_R" ,"" , nXBinsResR, firstXBinResR, lastXBinResR,"","");}
+    if(plotResolutionMCZ == kTRUE){histograms->AddHistogram("Resolution_MC_Z" ,"" , nXBinsResZ, firstXBinResZ, lastXBinResZ,"","");}
+       
+    if(plotResolutionESDPt == kTRUE){histograms->AddHistogram("Resolution_ESD_Pt" ,"" , nXBinsResPt, firstXBinResPt, lastXBinResPt,"","");}
+    if(plotResolutionESDR == kTRUE){histograms->AddHistogram("Resolution_ESD_R" ,"" , nXBinsResR, firstXBinResR, lastXBinResR,"","");}
+    if(plotResolutionESDZ == kTRUE){histograms->AddHistogram("Resolution_ESD_Z" ,"" , nXBinsResZ, firstXBinResZ, lastXBinResZ,"","");}
+       
+    if(plotESDNumberOfV0s == kTRUE){histograms->AddHistogram("ESD_NumberOfV0s","Number of v0s",100, 0, 100,"","");}
+    if(plotESDNumberOfSurvivingV0s == kTRUE){histograms->AddHistogram("ESD_NumberOfSurvivingV0s","Number of surviving v0s",100, 0, 100,"","");}
+       
+    //  debug histograms
+    if(plotESDCutGetOnFly == kTRUE){histograms->AddHistogram("ESD_CutGetOnFly_InvMass" ,"Not GetOnFly" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutNContributors == kTRUE){histograms->AddHistogram("ESD_CutNContributors_InvMass" ,"NContributors <= 0" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutLikeSign == kTRUE){histograms->AddHistogram("ESD_CutLikeSign_InvMass" ,"LikeSign" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutRefit == kTRUE){histograms->AddHistogram("ESD_CutRefit_InvMass" ,"No TPC refit" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutKink == kTRUE){histograms->AddHistogram("ESD_CutKink_InvMass" ,"Kinks" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutPIDProb == kTRUE){histograms->AddHistogram("ESD_CutPIDProb_InvMass" ,"wrong TPC PID" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutR == kTRUE){histograms->AddHistogram("ESD_CutR_InvMass" ,"Above RMax" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutNDF == kTRUE){histograms->AddHistogram("ESD_CutNDF_InvMass" ,"NDF <= 0" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutChi2 == kTRUE){histograms->AddHistogram("ESD_CutChi2_InvMass" ,"#chi^{2} > Max" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutEta == kTRUE){histograms->AddHistogram("ESD_CutEta_InvMass" ,"Above #eta max" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutPt == kTRUE){histograms->AddHistogram("ESD_CutPt_InvMass" ,"Below p_{t} min" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDCutLine == kTRUE){histograms->AddHistogram("ESD_CutLine_InvMass" ,"Out of reconstruction area" , nXBinsGammaMass, firstXBinGammaMass, lastXBinGammaMass,"","");}
+    if(plotESDTrueConvGammaTrackLength == kTRUE){histograms->AddHistogram("ESD_TrueConvGamma_TrackLength","Track length of TrueConvGamma",nXBinsTrackLength,firstXBinTrackLength,lastXBinTrackLength,"","");}
+    if(plotESDTrueConvGammaTrackLengthVSInvMass == kTRUE){histograms->AddHistogram("ESD_TrueConvGamma_TrackLengthVSInvMass","Track length of TrueConvGamma vs Inv mass",nXBinsTrackLength,firstXBinTrackLength,lastXBinTrackLength,nXBinsPt, firstXBinPt, lastXBinPt,"","");}
+
+
+    if(plotPi0Spectra == kTRUE){
+      histograms->AddHistogram("ESD_Mother_InvMass_vs_Pt" ,"Invariant Mass vs Pt" , nXBinsSpectra, firstXBinSpectra, lastXBinSpectra,nYBinsSpectra, firstYBinSpectra, lastYBinSpectra,"InvMass [GeV]","Pt [GeV]");
+      histograms->AddHistogram("ESD_Mother_InvMass","Invariant mass",nXBinsSpectra,firstXBinSpectra, lastXBinSpectra,"InvMass [GeV]","Counts");
+    }
+    if(plotPi0Spectra == kTRUE && calculateBackground == kTRUE){
+      histograms->AddHistogram("ESD_Background_InvMass_vs_Pt" ,"Background Invariant Mass vs Pt" , nXBinsSpectra, firstXBinSpectra, lastXBinSpectra,nYBinsSpectra, firstYBinSpectra, lastYBinSpectra,"InvMass [GeV]","Pt [GeV]");
+      histograms->AddHistogram("ESD_Background_InvMass","Invariant mass background",nXBinsSpectra,firstXBinSpectra, lastXBinSpectra,"InvMass BG [GeV]","Counts");
+    }
+  }// end runNeutralMeson
+}