Changed to new naming scheme for histograms, added functionality to the analysis...
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / AliAnalysisTaskGammaConversion.cxx
index 5df0c83..8e983c9 100644 (file)
@@ -46,7 +46,7 @@ ClassImp(AliAnalysisTaskGammaConversion)
 \r
 \r
 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():\r
-  AliAnalysisTaskSE(),\r
+AliAnalysisTaskSE(),\r
   fV0Reader(NULL),\r
   fStack(NULL),\r
   fOutputContainer(NULL),\r
@@ -57,6 +57,9 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
   fMCEtas(),\r
   fMCGammaChic(),\r
   fKFReconstructedGammas(),\r
+  fIsTrueReconstructedGammas(),\r
+  electronv1(),\r
+  electronv2(),\r
   fElectronMass(-1),\r
   fGammaMass(-1),\r
   fPi0Mass(-1),\r
@@ -64,6 +67,7 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
   fGammaWidth(-1),\r
   fPi0Width(-1),\r
   fEtaWidth(-1),\r
+  fMinOpeningAngleGhostCut(0.),\r
   fCalculateBackground(kFALSE),\r
   fWriteNtuple(kFALSE),\r
   fGammaNtuple(NULL),\r
@@ -74,7 +78,7 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
   // Common I/O in slot 0\r
   DefineInput (0, TChain::Class());\r
   DefineOutput(0, TTree::Class());\r
-\r
+       \r
   // Your private output\r
   DefineOutput(1, TList::Class());\r
 }\r
@@ -91,6 +95,9 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
   fMCEtas(),\r
   fMCGammaChic(),\r
   fKFReconstructedGammas(),\r
+  fIsTrueReconstructedGammas(),\r
+  electronv1(),\r
+  electronv2(),\r
   fElectronMass(-1),\r
   fGammaMass(-1),\r
   fPi0Mass(-1),\r
@@ -98,6 +105,7 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
   fGammaWidth(-1),\r
   fPi0Width(-1),\r
   fEtaWidth(-1),\r
+  fMinOpeningAngleGhostCut(0.),\r
   fCalculateBackground(kFALSE),\r
   fWriteNtuple(kFALSE),\r
   fGammaNtuple(NULL),\r
@@ -107,7 +115,7 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
   // Common I/O in slot 0\r
   DefineInput (0, TChain::Class());\r
   DefineOutput(0, TTree::Class());\r
-  \r
+       \r
   // Your private output\r
   DefineOutput(1, TList::Class());\r
 }\r
@@ -115,7 +123,7 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
 AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion() \r
 {\r
   // Remove all pointers\r
\r
+       \r
   if(fOutputContainer){\r
     fOutputContainer->Clear() ; \r
     delete fOutputContainer ;\r
@@ -139,257 +147,416 @@ void AliAnalysisTaskGammaConversion::Init()
 void AliAnalysisTaskGammaConversion::Exec(Option_t */*option*/)\r
 {\r
   // Execute analysis for current event\r
-  \r
+       \r
   ConnectInputData("");\r
-  \r
+       \r
   //clear vectors\r
   fMCAllGammas.clear();\r
   fMCPi0s.clear();\r
   fMCEtas.clear();\r
   fMCGammaChic.clear();\r
-\r
+       \r
   fKFReconstructedGammas.clear();\r
-\r
+  fIsTrueReconstructedGammas.clear();\r
+  electronv1.clear();\r
+  electronv2.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
+  \r
+  //Process the v0 information with no cuts\r
+  ProcessV0sNoCut();\r
+  \r
   // Process the v0 information\r
   ProcessV0s();\r
-\r
+  \r
   //calculate background if flag is set\r
   if(fCalculateBackground){\r
     CalculateBackground();\r
   }\r
-\r
+  \r
   // Process reconstructed gammas\r
   ProcessGammasForNeutralMesonAnalysis();\r
-\r
-  PostData(1, fOutputContainer);\r
   \r
+  PostData(1, fOutputContainer);\r
+       \r
 }\r
 \r
 void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t */*option*/){\r
   // see header file for documentation\r
-\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
+       \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
+               \r
     if (!particle) {\r
       //print warning here\r
       continue;\r
     }\r
-    \r
-    if(particle->Pt()<fV0Reader->GetPtCut()){\r
-      continue;\r
-    }\r
-    \r
-    if(TMath::Abs(particle->Eta())> fV0Reader->GetEtaCut()){\r
-      continue;\r
-    }\r
-\r
-    if(particle->R()>fV0Reader->GetMaxRCut()){ // cuts on distance from collision point\r
-      continue;\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
-    \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
-      fMCAllGammas.push_back(particle);\r
-      if(particle->GetMother(0)>-1){ //Means we have a mother\r
-       if( fStack->Particle(particle->GetMother(0))->GetPdgCode() != 22 ){//Checks for a non gamma mother.\r
-         fHistograms->FillHistogram("MC_Gamma_Energy", particle->Energy());\r
-         fHistograms->FillHistogram("MC_Gamma_Pt", particle->Pt());\r
-         fHistograms->FillHistogram("MC_Gamma_Eta", particle->Eta());\r
-         \r
-         fHistograms->FillHistogram("MC_Gamma_Phi", tmpPhi);\r
-\r
-         //adding the conversion points from all gammas with e+e- daughters\r
-         if(particle->GetNDaughters() >= 2){\r
-           TParticle* daughter0 = NULL;\r
-           TParticle* daughter1 = NULL;\r
-           \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
-                  daughter0 = tmpDaughter;\r
-               }\r
-               else if(tmpDaughter->GetPdgCode() == -11){\r
-                 daughter1 = tmpDaughter;\r
-               }\r
-             }\r
-           }\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(daughter0 == NULL || daughter1 == NULL){ // means we do not have two daughters from pair production\r
-             continue;\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
-           if(daughter0->R()>fV0Reader->GetMaxRCut() || daughter1->R()>fV0Reader->GetMaxRCut()){\r
-             continue;\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
-           if((daughter0->GetPdgCode() == -11 && daughter1->GetPdgCode()) == 11 ||\r
-              (daughter0->GetPdgCode() == 11 && daughter1->GetPdgCode() == -11)){\r
-\r
-             // begin Mapping \r
-             Int_t rBin    = fHistograms->GetRBin(daughter0->R());\r
-             Int_t phiBin  = fHistograms->GetPhiBin(daughter0->Phi());\r
-             \r
-             TString nameMCMappingPhiR="";\r
-             nameMCMappingPhiR.Form("MC_EP_Mapping-Phi%02d-R%02d",phiBin,rBin);\r
-             fHistograms->FillHistogram(nameMCMappingPhiR, daughter0->Vz(), particle->Eta());\r
-             \r
-             TString nameMCMappingPhi="";\r
-             nameMCMappingPhi.Form("MC_EP_Mapping-Phi%02d",phiBin);\r
-             fHistograms->FillHistogram(nameMCMappingPhi, particle->Eta());\r
-             \r
-             TString nameMCMappingR="";\r
-             nameMCMappingR.Form("MC_EP_Mapping-R%02d",rBin);\r
-             fHistograms->FillHistogram(nameMCMappingR, particle->Eta());\r
-             \r
-             TString nameMCMappingPhiInR="";\r
-             nameMCMappingPhiInR.Form("MC_EP_Mapping_Phi_R-%02d",rBin);\r
-             fHistograms->FillHistogram(nameMCMappingPhiInR, tmpPhi);\r
-             //end mapping\r
-\r
-             fHistograms->FillHistogram("MC_EP_R",daughter0->R());\r
-             fHistograms->FillHistogram("MC_EP_ZR",daughter0->Vz(),daughter0->R());\r
-             fHistograms->FillHistogram("MC_EP_XY",daughter0->Vx(),daughter0->Vy());\r
-             fHistograms->FillHistogram("MC_EP_OpeningAngle",GetMCOpeningAngle(daughter0, daughter1));\r
-           }// end if((daughter0->GetPdgCode() == -11 && daughter1->GetPdgCode()) == 11 ||....... approx 20 lines above\r
-         }// end if(particle->GetNDaughters() >= 2){\r
-       } // end if( fStack->Particle(particle->GetMother(0))->GetPdgCode() != 22 )\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(particle->GetMother(0)>-1)\r
-      else{//means we have a primary particle\r
-       fHistograms->FillHistogram("MC_DirectGamma_Energy",particle->Energy());\r
-       fHistograms->FillHistogram("MC_DirectGamma_Pt", particle->Pt());\r
-       fHistograms->FillHistogram("MC_DirectGamma_Eta", particle->Eta());\r
-       fHistograms->FillHistogram("MCDirectGammaPhi", tmpPhi);\r
-\r
-       //adding the conversion points from all gammas with e+e- daughters\r
-       if(particle->GetNDaughters() == 2){\r
-         TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());\r
-         TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());\r
-         if((daughter0->GetPdgCode() == -11 && daughter1->GetPdgCode() == 11) ||\r
-            (daughter0->GetPdgCode() == 11 && daughter1->GetPdgCode() == -11)){\r
-           \r
-           fHistograms->FillHistogram("MC_EP_R",daughter0->R());\r
-           fHistograms->FillHistogram("MC_EP_ZR",daughter0->Vz(),daughter0->R());\r
-           fHistograms->FillHistogram("MC_EP_XY",daughter0->Vx(),daughter0->Vy());\r
-           fHistograms->FillHistogram("MC_EP_OpeningAngle",GetMCOpeningAngle(daughter0, daughter1));\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
-      }// end else\r
-    }// end if (particle->GetPdgCode()== 22){\r
-    else if (TMath::Abs(particle->GetPdgCode())== 11){ // Means we have an electron or a positron\r
-      if(particle->GetMother(0)>-1){ // means we have a mother\r
-       if( fStack->Particle(particle->GetMother(0))->GetPdgCode()==22 ){ // Means we have a gamma mother\r
-         if(particle->GetPdgCode() == 11){//electron \r
-           fHistograms->FillHistogram("MC_E_Energy", particle->Energy());\r
-           fHistograms->FillHistogram("MC_E_Pt", particle->Pt());\r
-           fHistograms->FillHistogram("MC_E_Eta", particle->Eta());\r
-           fHistograms->FillHistogram("MC_E_Phi", tmpPhi);\r
-         }\r
-         if(particle->GetPdgCode() == -11){//positron \r
-           fHistograms->FillHistogram("MC_P_Energy", particle->Energy());\r
-           fHistograms->FillHistogram("MC_P_Pt", particle->Pt());\r
-           fHistograms->FillHistogram("MC_P_Eta", particle->Eta());\r
-           fHistograms->FillHistogram("MC_P_Phi", tmpPhi);\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
-    } // end else if (TMath::Abs(particle->GetPdgCode())== 11)\r
-    else if(particle->GetNDaughters() == 2){\r
-\r
-      TParticle* daughter0 = (TParticle*)fStack->Particle(particle->GetFirstDaughter());\r
-      TParticle* daughter1 = (TParticle*)fStack->Particle(particle->GetLastDaughter());\r
-      if(daughter0->GetPdgCode() == 22 && daughter1->GetPdgCode() == 22){//check for gamma gamma daughters\r
-       \r
-       if(particle->GetPdgCode()==111){//Pi0\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
-\r
-         if( iTracks >= fStack->GetNprimary()){\r
-           \r
-           fHistograms->FillHistogram("MC_Pi0_Secondaries_Eta", particle->Eta());\r
-\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
+         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
-         else{\r
-           fHistograms->FillHistogram("MC_Pi0_Eta", particle->Eta());\r
-\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
+       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
-       else if(particle->GetPdgCode()==221){//Eta\r
-         fHistograms->FillHistogram("MC_Eta_Eta", particle->Eta());\r
-\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
+                       \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
-       //the match data should be filled no matter which mother the gamma-gamma comes from\r
-       fHistograms->FillHistogram("MC_Match_Gamma_R", particle->R());\r
-       fHistograms->FillHistogram("MC_Match_Gamma_ZR", particle->Vz(),particle->R());\r
-       fHistograms->FillHistogram("MC_Match_Gamma_XY", particle->Vx(),particle->Vy());\r
-       fHistograms->FillHistogram("MC_Match_Gamma_Mass", particle->GetCalcMass());\r
-       fHistograms->FillHistogram("MC_Match_Gamma_OpeningAngle", GetMCOpeningAngle(daughter0,daughter1));\r
-       fHistograms->FillHistogram("MC_Match_Gamma_Energy", particle->Energy());\r
-       fHistograms->FillHistogram("MC_Match_Gamma_Pt", particle->Pt());\r
-       fHistograms->FillHistogram("MC_Match_Gamma_Eta", particle->Eta());\r
-       fHistograms->FillHistogram("MC_Match_Gamma_Phi",tmpPhi);\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
-    }// end else if(particle->GetNDaughters() == 2)\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
-void AliAnalysisTaskGammaConversion::FillNtuple(){\r
 \r
+\r
+void AliAnalysisTaskGammaConversion::FillNtuple(){\r
+       \r
   if(fGammaNtuple == NULL){\r
     return;\r
   }\r
@@ -434,92 +601,194 @@ void AliAnalysisTaskGammaConversion::FillNtuple(){
     fGammaNtuple->Fill(values);\r
   }\r
   fV0Reader->ResetV0IndexNumber();\r
-  \r
+       \r
+}\r
+\r
+void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){\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
+       \r
   if(fWriteNtuple == kTRUE){\r
     FillNtuple();\r
   }\r
-\r
+       \r
   Int_t nSurvivingV0s=0;\r
   while(fV0Reader->NextV0()){\r
     nSurvivingV0s++;\r
+               \r
+               \r
     //-------------------------- filling v0 information -------------------------------------\r
-    fHistograms->FillHistogram("ESD_EP_OpeningAngle", fV0Reader->GetOpeningAngle());    \r
-    fHistograms->FillHistogram("ESD_EP_R", fV0Reader->GetXYRadius());\r
-    fHistograms->FillHistogram("ESD_EP_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());\r
-    fHistograms->FillHistogram("ESD_EP_XY", fV0Reader->GetX(),fV0Reader->GetY());\r
-    \r
-    \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
+               \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_Gamma_Energy", fV0Reader->GetMotherCandidateEnergy());\r
-    fHistograms->FillHistogram("ESD_Gamma_Pt", fV0Reader->GetMotherCandidatePt());\r
-    fHistograms->FillHistogram("ESD_Gamma_Eta", fV0Reader->GetMotherCandidateEta());\r
-    fHistograms->FillHistogram("ESD_Gamma_Phi", fV0Reader->GetMotherCandidatePhi());\r
-\r
-\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
+               \r
     TString nameESDMappingPhiR="";\r
-    nameESDMappingPhiR.Form("ESD_EP_Mapping-Phi%02d-R%02d",phiBin,rBin);\r
+    nameESDMappingPhiR.Form("ESD_Conversion_Mapping-Phi%02d-R%02d",phiBin,rBin);\r
     fHistograms->FillHistogram(nameESDMappingPhiR, fV0Reader->GetZ(), motherCandidateEta);\r
-\r
+               \r
     TString nameESDMappingPhi="";\r
-    nameESDMappingPhi.Form("ESD_EP_Mapping-Phi%02d",phiBin);\r
+    nameESDMappingPhi.Form("ESD_Conversion_Mapping-Phi%02d",phiBin);\r
     fHistograms->FillHistogram(nameESDMappingPhi, fV0Reader->GetZ(), motherCandidateEta);\r
-\r
+               \r
     TString nameESDMappingR="";\r
-    nameESDMappingR.Form("ESD_EP_Mapping-R%02d",rBin);\r
+    nameESDMappingR.Form("ESD_Conversion_Mapping-R%02d",rBin);\r
     fHistograms->FillHistogram(nameESDMappingR, fV0Reader->GetZ(), motherCandidateEta);  \r
-\r
+               \r
     TString nameESDMappingPhiInR="";\r
-    nameESDMappingPhiInR.Form("ESD_EP_Mapping_Phi_R-%02d",rBin);\r
+    nameESDMappingPhiInR.Form("ESD_Conversion_Mapping_Phi_R-%02d",rBin);\r
     fHistograms->FillHistogram(nameESDMappingPhiInR, fV0Reader->GetMotherCandidatePhi());\r
     // end mapping\r
-    \r
+               \r
     fKFReconstructedGammas.push_back(*fV0Reader->GetMotherCandidateKFCombination());\r
+    electronv1.push_back(fV0Reader->GetCurrentV0()->GetPindex());\r
+    electronv2.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
+               \r
       TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();\r
       TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();\r
 \r
-      if(negativeMC->GetPdgCode()!=11 || positiveMC->GetPdgCode()!=-11){\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
-       fHistograms->FillHistogram("ESD_Match_Gamma_XY", fV0Reader->GetX(),fV0Reader->GetY());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_OpeningAngle", fV0Reader->GetOpeningAngle());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_Pt", fV0Reader->GetMotherCandidatePt());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_Energy", fV0Reader->GetMotherCandidateEnergy());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_Eta", fV0Reader->GetMotherCandidateEta());\r
-\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_Phi", fV0Reader->GetMotherCandidatePhi());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_Mass", fV0Reader->GetMotherCandidateMass());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_Width", fV0Reader->GetMotherCandidateWidth());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_Chi2", fV0Reader->GetMotherCandidateChi2());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_NDF", fV0Reader->GetMotherCandidateNDF());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_R", fV0Reader->GetXYRadius());\r
-       fHistograms->FillHistogram("ESD_Match_Gamma_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());\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
@@ -528,84 +797,114 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
        if(mcpt != 0){\r
          resdPt = ((esdpt - mcpt)/mcpt)*100;\r
        }\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
+                               \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
+                               \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
+                               \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
-    }\r
-  }\r
-  fHistograms->FillHistogram("NumberOfSurvivingV0s", nSurvivingV0s);\r
-  fHistograms->FillHistogram("NumberOfV0s", fV0Reader->GetNumberOfV0s());\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
+       \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
       \r
-      AliKFParticle *twoGammaCandidate = new AliKFParticle(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);\r
+      if(electronv1[firstGammaIndex]==electronv1[secondGammaIndex] || electronv1[firstGammaIndex]==electronv2[secondGammaIndex]){\r
+       continue;\r
+      }\r
+      if(electronv2[firstGammaIndex]==electronv1[secondGammaIndex] || electronv2[firstGammaIndex]==electronv2[secondGammaIndex]){\r
+       continue;\r
+      }\r
+\r
+      /*\r
+       if(fIsTrueReconstructedGammas[firstGammaIndex] == kFALSE || fIsTrueReconstructedGammas[secondGammaIndex] == kFALSE){\r
+       continue;\r
+       }\r
+      */\r
 \r
-      Double_t massTwoGammaCandidate =0.;\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
-       if(chi2TwoGammaCandidate>0 && chi2TwoGammaCandidate<fV0Reader->GetChi2CutMeson()){\r
-\r
-         TVector3 vectorTwoGammaCandidate(twoGammaCandidate->Px(),twoGammaCandidate->Py(),twoGammaCandidate->Pz());\r
-\r
-         Double_t openingAngleTwoGammaCandidate = twoGammaDecayCandidateDaughter0->GetAngle(*twoGammaDecayCandidateDaughter1);\r
-\r
-         //Calculating by hand the radius\r
-         Double_t tmpX= twoGammaCandidate->GetX();\r
-         Double_t tmpY= twoGammaCandidate->GetY();\r
-         \r
-         Double_t radiusTwoGammaCandidate = TMath::Sqrt(tmpX*tmpX + tmpY*tmpY);\r
-\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_GammaDaughter_OpeningAngle", openingAngleTwoGammaCandidate);\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_Energy", twoGammaCandidate->GetE());\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_Pt", sqrt(twoGammaCandidate->GetPx()*twoGammaCandidate->GetPx()+twoGammaCandidate->GetPy()*twoGammaCandidate->GetPy()));\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_Eta", vectorTwoGammaCandidate.Eta());\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_Phi", vectorTwoGammaCandidate.Phi());\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_Mass", massTwoGammaCandidate);\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_R", radiusTwoGammaCandidate);\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_ZR", tmpY, radiusTwoGammaCandidate);\r
-         fHistograms->FillHistogram("ESD_TwoGammaCombination_XY", tmpX, tmpY);\r
-         fHistograms->FillHistogram("InvMass_vs_Pt_Spectra",massTwoGammaCandidate ,sqrt(twoGammaCandidate->GetPx()*twoGammaCandidate->GetPx()+twoGammaCandidate->GetPy()*twoGammaCandidate->GetPy()));\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
        }\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
+       \r
   vector<AliKFParticle> vectorCurrentEventGoodV0s = fV0Reader->GetCurrentEventGoodV0s();\r
   vector<AliKFParticle> vectorPreviousEventGoodV0s = fV0Reader->GetPreviousEventGoodV0s();\r
   for(UInt_t iCurrent=0;iCurrent<vectorCurrentEventGoodV0s.size();iCurrent++){\r
@@ -614,7 +913,7 @@ void AliAnalysisTaskGammaConversion::CalculateBackground(){
       AliKFParticle * previousGoodV0 = &vectorPreviousEventGoodV0s.at(iPrevious);\r
 \r
       AliKFParticle *backgroundCandidate = new AliKFParticle(*currentEventGoodV0,*previousGoodV0);\r
-\r
+                       \r
       Double_t massBG =0.;\r
       Double_t widthBG = 0.;\r
       Double_t chi2BG =10000.; \r
@@ -622,30 +921,38 @@ void AliAnalysisTaskGammaConversion::CalculateBackground(){
       if(backgroundCandidate->GetNDF()>0){\r
        chi2BG = backgroundCandidate->GetChi2()/backgroundCandidate->GetNDF();\r
        if(chi2BG>0 && chi2BG<fV0Reader->GetChi2CutMeson()){\r
-\r
-         TVector3 vectorBGCandidate(backgroundCandidate->Px(),backgroundCandidate->Py(),backgroundCandidate->Pz());\r
-\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
-         //Calculating by hand the radius (find a better way)\r
-         Double_t tmpX= backgroundCandidate->GetX();\r
-         Double_t tmpY= backgroundCandidate->GetY();\r
-         \r
-         Double_t radiusBG = TMath::Sqrt(tmpX*tmpX + tmpY*tmpY);\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", sqrt(backgroundCandidate->GetPx()*backgroundCandidate->GetPx()+backgroundCandidate->GetPy()*backgroundCandidate->GetPy()));\r
-         fHistograms->FillHistogram("ESD_Background_Eta", vectorBGCandidate.Eta());\r
-         fHistograms->FillHistogram("ESD_Background_Phi", vectorBGCandidate.Phi());\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", radiusBG);\r
-         fHistograms->FillHistogram("ESD_Background_ZR", tmpY, radiusBG);\r
-         fHistograms->FillHistogram("ESD_Background_XY", tmpX, tmpY);\r
-         fHistograms->FillHistogram("Background_InvMass_vs_Pt_Spectra",massBG,sqrt(backgroundCandidate->GetPx()*backgroundCandidate->GetPx()+backgroundCandidate->GetPy()*backgroundCandidate->GetPy()));\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
        }\r
       }\r
       delete backgroundCandidate;   \r
+      //cout << "nearly at the end of background" << endl;\r
+                       \r
     }\r
   }\r
 }\r
@@ -667,11 +974,11 @@ void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
   if(fOutputContainer == NULL){\r
     fOutputContainer = new TList();\r
   }\r
-  \r
+       \r
   //Adding the histograms to the output container\r
   fHistograms->GetOutputContainer(fOutputContainer);\r
-\r
-  \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
@@ -684,7 +991,7 @@ void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
     ntupleTList->Add((TNtuple*)fGammaNtuple);\r
     fOutputContainer->Add(ntupleTList);\r
   }\r
-\r
+       \r
   fOutputContainer->SetName(GetName());\r
 }\r
 \r