updated task to make it possible to run on the grid
authorfbock <fbock@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 21 Mar 2013 15:38:01 +0000 (15:38 +0000)
committerfbock <fbock@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 21 Mar 2013 15:38:01 +0000 (15:38 +0000)
27 files changed:
PWGGA/GammaConv/AliAODConversionMother.cxx
PWGGA/GammaConv/AliAnaConvCorrBase.cxx
PWGGA/GammaConv/AliAnaConvCorrBase.h
PWGGA/GammaConv/AliAnalysisTaskConversionQA.cxx
PWGGA/GammaConv/AliAnalysisTaskConversionQA.h
PWGGA/GammaConv/AliAnalysisTaskGammaConvDalitzV1.cxx
PWGGA/GammaConv/AliAnalysisTaskGammaConvDalitzV1.h
PWGGA/GammaConv/AliAnalysisTaskGammaConvV1.cxx
PWGGA/GammaConv/AliAnalysisTaskGammaConvV1.h
PWGGA/GammaConv/AliAnalysisTaskGammaConversion.cxx
PWGGA/GammaConv/AliAnalysisTaskMaterial.cxx
PWGGA/GammaConv/AliAnalysisTaskMaterial.h
PWGGA/GammaConv/AliAnalysisTaskPi0v2.cxx
PWGGA/GammaConv/AliAnalysisTaskPi0v2.h
PWGGA/GammaConv/AliAnalysisTaskdPhi.cxx
PWGGA/GammaConv/AliConversionCuts.cxx
PWGGA/GammaConv/AliConversionCuts.h
PWGGA/GammaConv/AliConversionMesonCuts.cxx
PWGGA/GammaConv/AliConversionMesonCuts.h
PWGGA/GammaConv/AliConversionTrackCuts.cxx
PWGGA/GammaConv/AliDalitzElectronCuts.cxx
PWGGA/GammaConv/AliDalitzElectronCuts.h
PWGGA/GammaConv/AliDalitzElectronSelector.h
PWGGA/GammaConv/AliV0Reader.cxx
PWGGA/GammaConv/AliV0ReaderV1.cxx
PWGGA/GammaConv/AliV0ReaderV1.h
PWGGA/GammaConv/macros/AddTask_GammaConvV1.C

index 4d30c5f..216f402 100644 (file)
@@ -66,7 +66,7 @@ fWeight(1)
     //Set Decay Photon Labels
     fLabel[0]=-1;
     fLabel[1]=-1;
-        fLabel[2]=0;
+    fLabel[2]=0;
 }
 
 AliAODConversionMother::~AliAODConversionMother() {
index 0c7a0c1..ff5c9ac 100644 (file)
@@ -216,10 +216,10 @@ void AliAnaConvCorrBase::PrintStatistics()  {
 }
 
 
-//_______________________________________________________________________________
-void AliAnaConvCorrBase::FillTriggerCounters(const AliAODConversionParticle * particle, Int_t leading) {
+// //_______________________________________________________________________________
+// void AliAnaConvCorrBase::FillTriggerCounters(const AliAODConversionParticle * particle, Int_t leading) {
 
-}
+// }
 
 
 //________________________________________________________________
@@ -227,7 +227,7 @@ void AliAnaConvCorrBase::CorrelateWithTracks(AliAODConversionParticle * particle
   //Correlate particle with tracks
 
 
-  FillTriggerCounters(particle, isolated);
+   //FillTriggerCounters(particle, isolated);
 
   Int_t nDim = fAxesList.GetSize();
   Double_t dphivalues[nDim];
index 2730015..0255544 100644 (file)
@@ -64,7 +64,7 @@ public:
   void PrintStatistics();\r
 \r
   void CorrelateWithTracks(AliAODConversionParticle * particle, TObjArray * tracks, const Int_t tIDs[4], Int_t isolated);\r
-  virtual void FillTriggerCounters(const AliAODConversionParticle * particle, Int_t leading);\r
+  //virtual void FillTriggerCounters(const AliAODConversionParticle * particle, Int_t leading);\r
 \r
   TAxis& GetAxistPt()       { return fAxistPt;   }\r
   TAxis& GetAxiscPt()       { return fAxiscPt;   }\r
index 4cd0832..7579a79 100644 (file)
@@ -116,8 +116,11 @@ void AliAnalysisTaskConversionQA::UserCreateOutputObjects()
       fOutputList = new TList();
       fOutputList->SetOwner(kTRUE);
    }
+   
 
    if(ffillHistograms){
+      TH1::SetDefaultSumw2(kTRUE);
+      
       fESDList = new TList();
       fESDList->SetOwner(kTRUE);
       fESDList->SetName("ESD QA");
@@ -127,7 +130,7 @@ void AliAnalysisTaskConversionQA::UserCreateOutputObjects()
       fESDList->Add(hVertexZ);
       hNContributorsVertex = new TH1I("ContrVertex_Z","ContrVertex_Z",3000,0,3000);
       fESDList->Add(hNContributorsVertex);
-               if(fIsHeavyIon) hNGoodESDTracks = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
+      if(fIsHeavyIon) hNGoodESDTracks = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
       else hNGoodESDTracks = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
       fESDList->Add(hNGoodESDTracks);
       if(fIsHeavyIon) hNV0Tracks = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
@@ -211,19 +214,23 @@ void AliAnalysisTaskConversionQA::UserCreateOutputObjects()
          hTruePosiNfindableClsTPC = new TH1F("True_Positron_findableClusterTPC","True_Positron_findableClusterTPC",100,0,1);
          fTrueList->Add(hTruePosiNfindableClsTPC);
       }
+      if(fConversionCuts->GetCutHistograms()){
+         fOutputList->Add(fConversionCuts->GetCutHistograms());
+      }
+      TH1::SetDefaultSumw2(kFALSE);
    }
-
+   
    if(ffillTree){
-      TString cutnumber = fConversionCuts->GetCutNumber();   
-      fStreamQA = new TTreeSRedirector(Form("GammaConvV1_QATree_%s.root",cutnumber.Data()));
+      TString cutnumber = fConversionCuts->GetCutNumber();
+      fStreamQA = new TTreeSRedirector(Form("GammaConvV1_QATree_%s.root",cutnumber.Data()),"recreate");
    }
-   
+
    PostData(1, fOutputList);
 }
 
 //________________________________________________________________________
 void AliAnalysisTaskConversionQA::UserExec(Option_t *){
-   
+
    fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
 
    Int_t eventQuality = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetEventQuality();
@@ -248,209 +255,204 @@ void AliAnalysisTaskConversionQA::UserExec(Option_t *){
       }
    }
 
-   if(ffillTree)ProcessQATree();
    if(ffillHistograms){
       CountESDTracks();
-      ProcessQA();
+      hVertexZ->Fill(fInputEvent->GetPrimaryVertex()->GetZ());
+      hNContributorsVertex->Fill(fConversionCuts->GetNumberOfContributorsVtx(fInputEvent));
+      hNGoodESDTracks->Fill(fNumberOfESDTracks);
+      hNV0Tracks->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
    }
-   
-   PostData(1, fOutputList);
-}
-
 
-///________________________________________________________________________
-void AliAnalysisTaskConversionQA::ProcessQATree(){
-   
-   // Fill Histograms for QA and MC
-   AliESDEvent* event = (AliESDEvent*) InputEvent();
-   AliPIDResponse* pidResonse = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetPIDResponse();
    for(Int_t firstGammaIndex=0;firstGammaIndex<fConversionGammas->GetEntriesFast();firstGammaIndex++){
       AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fConversionGammas->At(firstGammaIndex));
-      if(!fConversionCuts->PhotonIsSelected(gamma,event)) continue;
       if(fMCEvent && fConversionCuts->GetSignalRejection() != 0){
          if(!fConversionCuts->IsParticleFromBGEvent(gamma->GetMCLabelPositive(), fMCStack))
             continue;
          if(!fConversionCuts->IsParticleFromBGEvent(gamma->GetMCLabelNegative(), fMCStack))
             continue;
       }
-      Float_t gammaPt = gamma->GetPhotonPt();
-      Float_t gammaPhi = gamma->GetPhotonPhi();
-      Float_t gammaTheta = gamma->Theta();
-      Float_t gammaChi2NDF = gamma->GetChi2perNDF();
-      Float_t gammaQt = gamma->GetArmenterosQt();
-      Float_t gammaAlpha = gamma->GetArmenterosAlpha();
-      Float_t gammaPsiPair = gamma->GetPsiPair();
-      Float_t gammaCosPointing = fConversionCuts->GetCosineOfPointingAngle(gamma,event);
-      TVectorF conversionPoint(3);
-      conversionPoint(0) = gamma->GetConversionX();
-      conversionPoint(1) = gamma->GetConversionY();
-      conversionPoint(2) = gamma->GetConversionZ();
-      TVectorF daughterProp(18);
-      AliESDtrack * negTrack = fConversionCuts->GetESDTrack(event, gamma->GetTrackLabelNegative());
-      AliESDtrack * posTrack = fConversionCuts->GetESDTrack(event, gamma->GetTrackLabelPositive());
-
-      if(!negTrack||!posTrack)return;
-
-      Bool_t isTruePhoton = kFALSE;
-      if(fMCEvent){
-         if(IsTruePhoton(gamma)) isTruePhoton = kTRUE;
+      if(!fConversionCuts->PhotonIsSelected(gamma,fInputEvent)){
+         continue;
       }
 
-      daughterProp(0) = posTrack->Pt();
-      daughterProp(7) = negTrack->Pt();
-      daughterProp(1) = posTrack->Theta();
-      daughterProp(8) = negTrack->Theta();
-      Double32_t signalPos[4] = {0,0,0,0};
-      Char_t nclPos[3];
-      Char_t nrowsPos[3];
-      if (posTrack->GetTPCdEdxInfo()) {
-         posTrack->GetTPCdEdxInfo()->GetTPCSignalRegionInfo(signalPos,nclPos,nrowsPos);
-         daughterProp(2) = signalPos[0];
-         daughterProp(14) = signalPos[1];
-         daughterProp(16) = signalPos[2];
-      } else {
-         daughterProp(2) = posTrack->GetTPCsignal();
-         daughterProp(14) = 0;
-         daughterProp(16) = 0;
-      }
-      Double32_t signalNeg[4] = {0,0,0,0};
-      Char_t nclNeg[3];
-      Char_t nrowsNeg[3];
-      if (negTrack->GetTPCdEdxInfo()) {
-         negTrack->GetTPCdEdxInfo()->GetTPCSignalRegionInfo(signalNeg,nclNeg,nrowsNeg);
-         daughterProp(9) = signalNeg[0];
-         daughterProp(15) = signalNeg[1];
-         daughterProp(17) = signalNeg[2];
-      } else {
-         daughterProp(9) = negTrack->GetTPCsignal();
-         daughterProp(15) = 0;
-         daughterProp(17) = 0;
-      }
-      daughterProp(3) = pidResonse->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
-      daughterProp(10) = pidResonse->NumberOfSigmasTPC(negTrack,AliPID::kElectron);
-      if((posTrack->GetStatus() & AliESDtrack::kTOFpid) && !(posTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
-         Double_t t0pos = pidResonse->GetTOFResponse().GetStartTime(posTrack->P());
-         Double_t timesPos[5];
-         posTrack->GetIntegratedTimes(timesPos);
-         Double_t TOFsignalPos =       posTrack->GetTOFsignal();
-         Double_t dTpos = TOFsignalPos - t0pos - timesPos[0];
-         daughterProp(4) = dTpos;
-         daughterProp(5) = pidResonse->NumberOfSigmasTOF(posTrack, AliPID::kElectron);
-      } else {
-         daughterProp(4) = 20000;
-         daughterProp(5) = -20;
-      }
-      if((negTrack->GetStatus() & AliESDtrack::kTOFpid) && !(negTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
-         Double_t t0neg = pidResonse->GetTOFResponse().GetStartTime(negTrack->P());
-         Double_t timesNeg[5];
-         negTrack->GetIntegratedTimes(timesNeg);
-         Double_t TOFsignalNeg =       negTrack->GetTOFsignal();
-         Double_t dTneg = TOFsignalNeg - t0neg - timesNeg[0];
-         daughterProp(11) = dTneg;
-         daughterProp(12) = pidResonse->NumberOfSigmasTOF(negTrack, AliPID::kElectron);
-      } else {
-         daughterProp(11) = 20000;
-         daughterProp(12) = -20;
+      if(ffillTree) ProcessQATree(gamma);
+      if(ffillHistograms) ProcessQA(gamma);
+   }
+
+   PostData(1, fOutputList);
+}
+
+
+///________________________________________________________________________
+void AliAnalysisTaskConversionQA::ProcessQATree(AliAODConversionPhoton *gamma){
+
+   // Fill Histograms for QA and MC
+   AliESDEvent* event = (AliESDEvent*) InputEvent();
+   AliPIDResponse* pidResonse = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetPIDResponse();
+
+   Float_t gammaPt = gamma->GetPhotonPt();
+   Float_t gammaPhi = gamma->GetPhotonPhi();
+   Float_t gammaTheta = gamma->Theta();
+   Float_t gammaChi2NDF = gamma->GetChi2perNDF();
+   Float_t gammaQt = gamma->GetArmenterosQt();
+   Float_t gammaAlpha = gamma->GetArmenterosAlpha();
+   Float_t gammaPsiPair = gamma->GetPsiPair();
+   Float_t gammaCosPointing = fConversionCuts->GetCosineOfPointingAngle(gamma,event);
+   TVectorF conversionPoint(3);
+   conversionPoint(0) = gamma->GetConversionX();
+   conversionPoint(1) = gamma->GetConversionY();
+   conversionPoint(2) = gamma->GetConversionZ();
+   TVectorF daughterProp(18);
+   AliESDtrack * negTrack = fConversionCuts->GetESDTrack(event, gamma->GetTrackLabelNegative());
+   AliESDtrack * posTrack = fConversionCuts->GetESDTrack(event, gamma->GetTrackLabelPositive());
+
+   if(!negTrack||!posTrack)return;
+
+   Bool_t isTruePhoton = kFALSE;
+   if(fMCEvent){
+      if(IsTruePhoton(gamma)) isTruePhoton = kTRUE;
+   }
+
+   daughterProp(0) = posTrack->Pt();
+   daughterProp(7) = negTrack->Pt();
+   daughterProp(1) = posTrack->Theta();
+   daughterProp(8) = negTrack->Theta();
+   Double32_t signalPos[4] = {0,0,0,0};
+   Char_t nclPos[3];
+   Char_t nrowsPos[3];
+   if (posTrack->GetTPCdEdxInfo()) {
+      posTrack->GetTPCdEdxInfo()->GetTPCSignalRegionInfo(signalPos,nclPos,nrowsPos);
+      daughterProp(2) = signalPos[0];
+      daughterProp(14) = signalPos[1];
+      daughterProp(16) = signalPos[2];
+   } else {
+      daughterProp(2) = posTrack->GetTPCsignal();
+      daughterProp(14) = 0;
+      daughterProp(16) = 0;
+   }
+   Double32_t signalNeg[4] = {0,0,0,0};
+   Char_t nclNeg[3];
+   Char_t nrowsNeg[3];
+   if (negTrack->GetTPCdEdxInfo()) {
+      negTrack->GetTPCdEdxInfo()->GetTPCSignalRegionInfo(signalNeg,nclNeg,nrowsNeg);
+      daughterProp(9) = signalNeg[0];
+      daughterProp(15) = signalNeg[1];
+      daughterProp(17) = signalNeg[2];
+   } else {
+      daughterProp(9) = negTrack->GetTPCsignal();
+      daughterProp(15) = 0;
+      daughterProp(17) = 0;
+   }
+   daughterProp(3) = pidResonse->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
+   daughterProp(10) = pidResonse->NumberOfSigmasTPC(negTrack,AliPID::kElectron);
+   if((posTrack->GetStatus() & AliESDtrack::kTOFpid) && !(posTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
+      Double_t t0pos = pidResonse->GetTOFResponse().GetStartTime(posTrack->P());
+      Double_t timesPos[5];
+      posTrack->GetIntegratedTimes(timesPos);
+      Double_t TOFsignalPos =  posTrack->GetTOFsignal();
+      Double_t dTpos = TOFsignalPos - t0pos - timesPos[0];
+      daughterProp(4) = dTpos;
+      daughterProp(5) = pidResonse->NumberOfSigmasTOF(posTrack, AliPID::kElectron);
+   } else {
+      daughterProp(4) = 20000;
+      daughterProp(5) = -20;
+   }
+   if((negTrack->GetStatus() & AliESDtrack::kTOFpid) && !(negTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
+      Double_t t0neg = pidResonse->GetTOFResponse().GetStartTime(negTrack->P());
+      Double_t timesNeg[5];
+      negTrack->GetIntegratedTimes(timesNeg);
+      Double_t TOFsignalNeg =  negTrack->GetTOFsignal();
+      Double_t dTneg = TOFsignalNeg - t0neg - timesNeg[0];
+      daughterProp(11) = dTneg;
+      daughterProp(12) = pidResonse->NumberOfSigmasTOF(negTrack, AliPID::kElectron);
+   } else {
+      daughterProp(11) = 20000;
+      daughterProp(12) = -20;
+   }
+
+   daughterProp(6) = (Float_t)posTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius()));
+   //posTrack->GetNcls(1)/(Float_t)posTrack->GetTPCNclsF();
+   daughterProp(13) = (Float_t)negTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius()));
+   //negTrack->GetNcls(1)/(Float_t)negTrack->GetTPCNclsF();
+
+   if (fStreamQA){
+      if(fMCEvent){
+         (*fStreamQA)<<"PhotonQA"
+                     << "pt=" << gammaPt
+                     << "phi=" << gammaPhi
+                     << "theta=" << gammaTheta
+                     << "chi2ndf=" << gammaChi2NDF
+                     << "qt="<< gammaQt
+                     << "alpha=" << gammaAlpha
+                     << "psipair=" << gammaPsiPair
+                     << "cosPoint=" << gammaCosPointing
+                     << "TruePhoton=" << isTruePhoton
+                     << "conversionPoint=" << &conversionPoint
+                     << "daugtherProp.=" << &daughterProp
+                     << "\n";
       }
-      
-      daughterProp(6) = (Float_t)posTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius()));
-      //posTrack->GetNcls(1)/(Float_t)posTrack->GetTPCNclsF();
-      daughterProp(13) = (Float_t)negTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius()));
-      //negTrack->GetNcls(1)/(Float_t)negTrack->GetTPCNclsF();
-
-      if (fStreamQA){
-         if(fMCEvent){
-            (*fStreamQA)<<"PhotonQA"
-                        << "pt=" << gammaPt
-                        << "phi=" << gammaPhi
-                        << "theta=" << gammaTheta
-                        << "chi2ndf=" << gammaChi2NDF
-                        << "qt="<< gammaQt
-                        << "alpha=" << gammaAlpha
-                        << "psipair=" << gammaPsiPair
-                        << "cosPoint=" << gammaCosPointing
-                        << "TruePhoton=" << isTruePhoton
-                        << "conversionPoint=" << &conversionPoint
-                        << "daugtherProp.=" << &daughterProp
-                        << "\n";
-         }
-         else{
-            (*fStreamQA)<<"PhotonQA"
-                        << "pt=" << gammaPt
-                        << "phi=" << gammaPhi
-                        << "theta=" << gammaTheta
-                        << "chi2ndf=" << gammaChi2NDF
-                        << "qt="<< gammaQt
-                        << "alpha=" << gammaAlpha
-                        << "psipair=" << gammaPsiPair
-                        << "cosPoint=" << gammaCosPointing
-                        << "conversionPoint=" << &conversionPoint
-                        << "daugtherProp.=" << &daughterProp
-                        << "\n";
-         }
+      else{
+         (*fStreamQA)<<"PhotonQA"
+                     << "pt=" << gammaPt
+                     << "phi=" << gammaPhi
+                     << "theta=" << gammaTheta
+                     << "chi2ndf=" << gammaChi2NDF
+                     << "qt="<< gammaQt
+                     << "alpha=" << gammaAlpha
+                     << "psipair=" << gammaPsiPair
+                     << "cosPoint=" << gammaCosPointing
+                     << "conversionPoint=" << &conversionPoint
+                     << "daugtherProp.=" << &daughterProp
+                     << "\n";
       }
    }
 }
+
 //_____________________________________________________________________________________________________
-void AliAnalysisTaskConversionQA::ProcessQA(){
+void AliAnalysisTaskConversionQA::ProcessQA(AliAODConversionPhoton *gamma){
 
-   hVertexZ->Fill(fInputEvent->GetPrimaryVertex()->GetZ());
-   hNContributorsVertex->Fill(fConversionCuts->GetNumberOfContributorsVtx(fInputEvent));
-   hNGoodESDTracks->Fill(fNumberOfESDTracks);
-   hNV0Tracks->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
 
    // Fill Histograms for QA and MC
-   for(Int_t gammaIndex=0;gammaIndex<fConversionGammas->GetEntriesFast();gammaIndex++){
-      AliAODConversionPhoton *gamma = dynamic_cast<AliAODConversionPhoton*>(fConversionGammas->At(gammaIndex));
-      if(!fConversionCuts->PhotonIsSelected(gamma,fInputEvent)) continue;
-
-      if(fMCEvent && fConversionCuts->GetSignalRejection() != 0){
-         if(!fConversionCuts->IsParticleFromBGEvent(gamma->GetMCLabelPositive(), fMCStack))
-            continue;
-         if(!fConversionCuts->IsParticleFromBGEvent(gamma->GetMCLabelNegative(), fMCStack))
-            continue;
+   hGammaPt->Fill(gamma->GetPhotonPt());
+   hGammaPhi->Fill(gamma->GetPhotonPhi());
+   hGammaEta->Fill(gamma->Eta());
+   hGammaChi2perNDF->Fill(gamma->GetChi2perNDF());
+   hGammaPsiPair->Fill(gamma->GetPsiPair());
+   hGammaQt->Fill(gamma->GetArmenterosQt());
+   hGammaCosinePointingAngle->Fill(fConversionCuts->GetCosineOfPointingAngle(gamma,fInputEvent));
+   hGammaXY->Fill(gamma->GetConversionX(),gamma->GetConversionY());
+   hGammaZR->Fill(gamma->GetConversionZ(),gamma->GetConversionRadius());
+
+   AliESDtrack * negTrack = fConversionCuts->GetESDTrack((AliESDEvent*)fInputEvent, gamma->GetTrackLabelNegative());
+   AliESDtrack * posTrack = fConversionCuts->GetESDTrack((AliESDEvent*)fInputEvent, gamma->GetTrackLabelPositive());
+   if(!negTrack||!posTrack)return;
+
+   Double_t negtrackPhi = negTrack->Phi();
+   Double_t postrackPhi = posTrack->Phi();
+   hITSClusterPhi->Fill(negtrackPhi,6);
+   hITSClusterPhi->Fill(postrackPhi,6);
+   for(Int_t itsLayer = 0; itsLayer<6;itsLayer++){
+      if(TESTBIT(negTrack->GetITSClusterMap(),itsLayer)){
+         hITSClusterPhi->Fill(negtrackPhi,itsLayer);
       }
-      hGammaPt->Fill(gamma->GetPhotonPt());
-      hGammaPhi->Fill(gamma->GetPhotonPhi());
-      hGammaEta->Fill(gamma->Eta());
-      hGammaChi2perNDF->Fill(gamma->GetChi2perNDF());
-      hGammaPsiPair->Fill(gamma->GetPsiPair());
-      hGammaQt->Fill(gamma->GetArmenterosQt());
-      hGammaCosinePointingAngle->Fill(fConversionCuts->GetCosineOfPointingAngle(gamma,fInputEvent));
-      hGammaXY->Fill(gamma->GetConversionX(),gamma->GetConversionY());
-      hGammaZR->Fill(gamma->GetConversionZ(),gamma->GetConversionRadius());
-
-      AliESDtrack * negTrack = fConversionCuts->GetESDTrack((AliESDEvent*)fInputEvent, gamma->GetTrackLabelNegative());
-      AliESDtrack * posTrack = fConversionCuts->GetESDTrack((AliESDEvent*)fInputEvent, gamma->GetTrackLabelPositive());
-      if(!negTrack||!posTrack)return;
-
-      Double_t negtrackPhi = negTrack->Phi();
-      Double_t postrackPhi = posTrack->Phi();
-      hITSClusterPhi->Fill(negtrackPhi,6);
-      hITSClusterPhi->Fill(postrackPhi,6);
-      for(Int_t itsLayer = 0; itsLayer<6;itsLayer++){
-         if(TESTBIT(negTrack->GetITSClusterMap(),itsLayer)){
-            hITSClusterPhi->Fill(negtrackPhi,itsLayer);
-         }
-         if(TESTBIT(posTrack->GetITSClusterMap(),itsLayer)){
-            hITSClusterPhi->Fill(postrackPhi,itsLayer);
-         }
+      if(TESTBIT(posTrack->GetITSClusterMap(),itsLayer)){
+         hITSClusterPhi->Fill(postrackPhi,itsLayer);
       }
+   }
 
-      hElecPt->Fill(negTrack->Pt(),posTrack->Pt());
-      hElecEta->Fill(negTrack->Eta(),posTrack->Eta());
-      hElecPhi->Fill(negTrack->Phi(),posTrack->Phi());
+   hElecPt->Fill(negTrack->Pt(),posTrack->Pt());
+   hElecEta->Fill(negTrack->Eta(),posTrack->Eta());
+   hElecPhi->Fill(negTrack->Phi(),posTrack->Phi());
 
-      hElecNfindableClsTPC->Fill((Float_t)posTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius())));
-      hPosiNfindableClsTPC->Fill((Float_t)negTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius())));
-      
-      // hElecNfindableClsTPC->Fill((Float_t)negTrack->GetNcls(1)/(Float_t)negTrack->GetTPCNclsF());
-      // hPosiNfindableClsTPC->Fill((Float_t)posTrack->GetNcls(1)/(Float_t)posTrack->GetTPCNclsF());
-      
-      if(fMCEvent)
-         ProcessTrueQA(gamma,negTrack,posTrack);
-   }
+   hElecNfindableClsTPC->Fill((Float_t)posTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius())));
+   hPosiNfindableClsTPC->Fill((Float_t)negTrack->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(gamma->GetConversionRadius())));
+
+   // hElecNfindableClsTPC->Fill((Float_t)negTrack->GetNcls(1)/(Float_t)negTrack->GetTPCNclsF());
+   // hPosiNfindableClsTPC->Fill((Float_t)posTrack->GetNcls(1)/(Float_t)posTrack->GetTPCNclsF());
+
+   if(fMCEvent) ProcessTrueQA(gamma,negTrack,posTrack);
 }
+
 //________________________________________________________________________
 void AliAnalysisTaskConversionQA::ProcessTrueQA(AliAODConversionPhoton *TruePhotonCandidate, AliESDtrack *elec, AliESDtrack *posi)
 {
@@ -466,7 +468,7 @@ void AliAnalysisTaskConversionQA::ProcessTrueQA(AliAODConversionPhoton *TruePhot
    hTrueResoulutionZ->Fill(TruePhotonCandidate->GetConversionZ(),
                            TruePhotonCandidate->GetConversionZ()-negDaughter->Vz());
    hTrueResoulutionPhi->Fill(TruePhotonCandidate->Phi(),
-                           TruePhotonCandidate->Phi()-mcPhoton->Phi());
+                             TruePhotonCandidate->Phi()-mcPhoton->Phi());
    hTrueGammaPt->Fill(TruePhotonCandidate->Pt());
    hTrueGammaPhi->Fill(TruePhotonCandidate->Phi());
    hTrueGammaEta->Fill(TruePhotonCandidate->Eta());
@@ -487,7 +489,7 @@ void AliAnalysisTaskConversionQA::ProcessTrueQA(AliAODConversionPhoton *TruePhot
       ->Fill((Float_t)posi->GetTPCClusterInfo(2,0,fConversionCuts->GetFirstTPCRow(TruePhotonCandidate->GetConversionRadius())));
    // hTrueElecNfindableClsTPC->Fill((Float_t)elec->GetNcls(1)/(Float_t)elec->GetTPCNclsF());
    // hTruePosiNfindableClsTPC->Fill((Float_t)posi->GetNcls(1)/(Float_t)posi->GetTPCNclsF());
-   
+
 }
 //________________________________________________________________________
 void AliAnalysisTaskConversionQA::CountESDTracks(){
@@ -519,7 +521,7 @@ Bool_t AliAnalysisTaskConversionQA::IsTruePhoton(AliAODConversionPhoton *TruePho
 {
    TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCStack);
    TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCStack);
-      
+
    if(posDaughter == NULL || negDaughter == NULL) return kFALSE; // One particle does not exist
    Int_t pdgCode[2] = {abs(posDaughter->GetPdgCode()),abs(negDaughter->GetPdgCode())};
    if(posDaughter->GetMother(0) != negDaughter->GetMother(0)) return kFALSE;
@@ -528,7 +530,7 @@ Bool_t AliAnalysisTaskConversionQA::IsTruePhoton(AliAODConversionPhoton *TruePho
    if(pdgCode[0]!=11 || pdgCode[1]!=11) return kFALSE; //One Particle is not electron
    if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return kFALSE; // Same Charge
    if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return kFALSE;// check if the daughters come from a conversion
-   
+
    TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCStack);
    if(Photon->GetPdgCode() != 22) return kFALSE; // Mother is no Photon
 
@@ -538,11 +540,5 @@ Bool_t AliAnalysisTaskConversionQA::IsTruePhoton(AliAODConversionPhoton *TruePho
 //________________________________________________________________________
 void AliAnalysisTaskConversionQA::Terminate(Option_t *)
 {
-   if(ffillHistograms && fConversionCuts->GetCutHistograms()){
-      fOutputList->Add(fConversionCuts->GetCutHistograms());
-   }
-   
-   // if (fStreamQA){
-   //    //fStreamQA->GetFile()->Write();
-   // }
+
 }
index c32aa9c..7dda119 100644 (file)
@@ -20,86 +20,89 @@ using namespace std;
 
 class AliAnalysisTaskConversionQA : public AliAnalysisTaskSE{
 
-public:
+ public:
 
-    AliAnalysisTaskConversionQA(const char *name);
-    virtual ~AliAnalysisTaskConversionQA();
+   AliAnalysisTaskConversionQA(const char *name);
+   virtual ~AliAnalysisTaskConversionQA();
 
-    virtual void   UserCreateOutputObjects();
-    virtual void   UserExec(Option_t *option);
-    virtual void   Terminate(Option_t *);
+   virtual void   UserCreateOutputObjects();
+   virtual void   UserExec(Option_t *option);
+   virtual void   Terminate(Option_t *);
 
-    void SetV0Reader(AliV0ReaderV1 *v0Reader){fV0Reader=v0Reader;}
-    void SetConversionCuts(AliConversionCuts* conversionCuts,Bool_t IsHeavyIon ){
-       fConversionCuts=conversionCuts;
-       fIsHeavyIon = IsHeavyIon;
-    }
-    void FillType(Bool_t fillTree, Bool_t fillHistorams){
-       ffillTree = fillTree;
-       ffillHistograms = fillHistorams;
-    }
+   void SetV0Reader(AliV0ReaderV1 *v0Reader){fV0Reader=v0Reader;}
+   void SetConversionCuts(AliConversionCuts* conversionCuts,Bool_t IsHeavyIon ){
+      fConversionCuts=conversionCuts;
+      fIsHeavyIon = IsHeavyIon;
+   }
+   void FillType(Bool_t fillTree, Bool_t fillHistorams){
+      ffillTree = fillTree;
+      ffillHistograms = fillHistorams;
+   }
     
-private:
+ private:
+    
+   AliAnalysisTaskConversionQA(const AliAnalysisTaskConversionQA&); // Prevent copy-construction
+   AliAnalysisTaskConversionQA &operator=(const AliAnalysisTaskConversionQA&); // Prevent assignment
 
-    void ProcessQATree();
-    void ProcessQA();
-    void ProcessTrueQA(AliAODConversionPhoton *TruePhotonCandidate, AliESDtrack *elec, AliESDtrack *posi);
-    Bool_t IsTruePhoton(AliAODConversionPhoton *TruePhotonCandidate);
-    void CountESDTracks();
+   void ProcessQATree(AliAODConversionPhoton *gamma);
+   void ProcessQA(AliAODConversionPhoton *gamma);
+   void ProcessTrueQA(AliAODConversionPhoton *TruePhotonCandidate, AliESDtrack *elec, AliESDtrack *posi);
+   Bool_t IsTruePhoton(AliAODConversionPhoton *TruePhotonCandidate);
+   void CountESDTracks();
        
-    AliV0ReaderV1 *fV0Reader;    
-    TClonesArray *fConversionGammas;
-    AliConversionCuts *fConversionCuts; // Cuts used by the V0Reader
-    AliVEvent *fInputEvent;
-    Int_t fNumberOfESDTracks;
-    AliMCEvent *fMCEvent;
-    AliStack *fMCStack;
-    TTreeSRedirector *fStreamQA;
-    Bool_t fIsHeavyIon;
-    Bool_t ffillTree;
-    Bool_t ffillHistograms;
-    TList *fOutputList;
-    TList *fESDList;
-    TH1F *hVertexZ;
-        TH1I *hNGoodESDTracks;
-    TH1I *hNV0Tracks;
-        TH1I *hNContributorsVertex;
-    TH2F *hITSClusterPhi;
-    TH1F *hGammaPt;
-    TH1F *hGammaPhi;
-    TH1F *hGammaEta;
-    TH1F *hGammaChi2perNDF;
-    TH1F *hGammaPsiPair;
-    TH1F *hGammaQt;
-    TH1F *hGammaCosinePointingAngle;
-    TH2F *hGammaXY;
-    TH2F *hGammaZR;
-    TH2F *hElecPt;
-    TH2F *hElecEta;
-    TH2F *hElecPhi;
-    TH1F *hElecNfindableClsTPC;
-    TH1F *hPosiNfindableClsTPC;
-    TList *fTrueList;
-    TH2F *hTrueResoulutionR;
-    TH2F *hTrueResoulutionZ;
-    TH2F *hTrueResoulutionPhi;
-    TH1F *hTrueGammaPt;
-    TH1F *hTrueGammaPhi;
-    TH1F *hTrueGammaEta;
-    TH1F *hTrueGammaMass;
-    TH1F *hTrueGammaChi2perNDF;
-    TH1F *hTrueGammaPsiPair;
-    TH1F *hTrueGammaQt;
-    TH1F *hTrueGammaCosinePointingAngle;
-    TH2F *hTrueGammaXY;
-    TH2F *hTrueGammaZR;
-    TH2F *hTrueElecPt;
-    TH2F *hTrueElecEta;
-    TH2F *hTrueElecPhi;
-    TH1F *hTrueElecNfindableClsTPC;
-    TH1F *hTruePosiNfindableClsTPC;
+   AliV0ReaderV1 *fV0Reader;    
+   TClonesArray *fConversionGammas;
+   AliConversionCuts *fConversionCuts; // Cuts used by the V0Reader
+   AliVEvent *fInputEvent;
+   Int_t fNumberOfESDTracks;
+   AliMCEvent *fMCEvent;
+   AliStack *fMCStack;
+   TTreeSRedirector *fStreamQA;
+   Bool_t fIsHeavyIon;
+   Bool_t ffillTree;
+   Bool_t ffillHistograms;
+   TList *fOutputList;
+   TList *fESDList;
+   TH1F *hVertexZ;
+   TH1I *hNGoodESDTracks;
+   TH1I *hNV0Tracks;
+   TH1I *hNContributorsVertex;
+   TH2F *hITSClusterPhi;
+   TH1F *hGammaPt;
+   TH1F *hGammaPhi;
+   TH1F *hGammaEta;
+   TH1F *hGammaChi2perNDF;
+   TH1F *hGammaPsiPair;
+   TH1F *hGammaQt;
+   TH1F *hGammaCosinePointingAngle;
+   TH2F *hGammaXY;
+   TH2F *hGammaZR;
+   TH2F *hElecPt;
+   TH2F *hElecEta;
+   TH2F *hElecPhi;
+   TH1F *hElecNfindableClsTPC;
+   TH1F *hPosiNfindableClsTPC;
+   TList *fTrueList;
+   TH2F *hTrueResoulutionR;
+   TH2F *hTrueResoulutionZ;
+   TH2F *hTrueResoulutionPhi;
+   TH1F *hTrueGammaPt;
+   TH1F *hTrueGammaPhi;
+   TH1F *hTrueGammaEta;
+   TH1F *hTrueGammaMass;
+   TH1F *hTrueGammaChi2perNDF;
+   TH1F *hTrueGammaPsiPair;
+   TH1F *hTrueGammaQt;
+   TH1F *hTrueGammaCosinePointingAngle;
+   TH2F *hTrueGammaXY;
+   TH2F *hTrueGammaZR;
+   TH2F *hTrueElecPt;
+   TH2F *hTrueElecEta;
+   TH2F *hTrueElecPhi;
+   TH1F *hTrueElecNfindableClsTPC;
+   TH1F *hTruePosiNfindableClsTPC;
     
-    ClassDef(AliAnalysisTaskConversionQA, 1);
+   ClassDef(AliAnalysisTaskConversionQA, 1);
 };
 
 #endif
index f21e7cd..9841fba 100644 (file)
@@ -56,7 +56,7 @@ ClassImp( AliAnalysisTaskGammaConvDalitzV1 )
 
 //-----------------------------------------------------------------------------------------------
 AliAnalysisTaskGammaConvDalitzV1::AliAnalysisTaskGammaConvDalitzV1():
-   fV0Reader(NULL),
+fV0Reader(NULL),
    fElecSelector(NULL),
    fBGHandler(NULL),
    fESDEvent(NULL),
@@ -84,12 +84,17 @@ AliAnalysisTaskGammaConvDalitzV1::AliAnalysisTaskGammaConvDalitzV1():
    hESDDalitzElectronPt(NULL),
    hESDDalitzPositronPt(NULL),
    hESDEposEnegPsiPairDPhi(NULL),
+   hESDEposEnegInvMassPt(NULL),
    hESDMotherInvMassPt(NULL),
+   hESDPi0MotherInvMassPt(NULL),
+   hESDPi0MotherDiffInvMassPt(NULL),
    sESDMotherInvMassPtZM(NULL),
    hESDMotherBackInvMassPt(NULL),
    sESDMotherBackInvMassPtZM(NULL),
    hMCPi0Pt(NULL),
+   hMCPi0GGPt(NULL),
    hMCEtaPt(NULL),
+   hMCEtaGGPt(NULL), 
    hMCPi0InAccPt(NULL),
    hMCEtaInAccPt(NULL),
    hESDTrueMotherInvMassPt(NULL),
@@ -116,9 +121,7 @@ AliAnalysisTaskGammaConvDalitzV1::AliAnalysisTaskGammaConvDalitzV1():
    fIsHeavyIon(kFALSE),
    fDoMesonAnalysis(kTRUE)
 {
-   // Define input and output slots here
-  // DefineInput(0, TChain::Class());
-  // DefineOutput(1, TList::Class());
+
 }
 
 //-----------------------------------------------------------------------------------------------
@@ -152,12 +155,17 @@ AliAnalysisTaskGammaConvDalitzV1::AliAnalysisTaskGammaConvDalitzV1( const char*
    hESDDalitzElectronPt(NULL),
    hESDDalitzPositronPt(NULL),
    hESDEposEnegPsiPairDPhi(NULL),
+   hESDEposEnegInvMassPt(NULL),
    hESDMotherInvMassPt(NULL),
+   hESDPi0MotherInvMassPt(NULL),
+   hESDPi0MotherDiffInvMassPt(NULL),
    sESDMotherInvMassPtZM(NULL),
    hESDMotherBackInvMassPt(NULL),
    sESDMotherBackInvMassPtZM(NULL),
    hMCPi0Pt(NULL),
+   hMCPi0GGPt(NULL),
    hMCEtaPt(NULL),
+   hMCEtaGGPt(NULL),
    hMCPi0InAccPt(NULL),
    hMCEtaInAccPt(NULL),
    hESDTrueMotherInvMassPt(NULL),
@@ -184,18 +192,16 @@ AliAnalysisTaskGammaConvDalitzV1::AliAnalysisTaskGammaConvDalitzV1( const char*
    fIsHeavyIon(kFALSE),
    fDoMesonAnalysis(kTRUE)
 {
-        DefineInput(0, TChain::Class());
-        DefineOutput(1, TList::Class());
-       // DefineOutput(2, TList::Class());
-
+   DefineOutput(1, TList::Class());
 }
 
 //-----------------------------------------------------------------------------------------------
 AliAnalysisTaskGammaConvDalitzV1::~AliAnalysisTaskGammaConvDalitzV1()
 {
-//
-// virtual destructor
-//
+   //
+   // virtual destructor
+   //
+   cout<<"Destructor"<<endl;
 
    if(fGoodGammas){
       delete fGoodGammas;
@@ -217,6 +223,10 @@ AliAnalysisTaskGammaConvDalitzV1::~AliAnalysisTaskGammaConvDalitzV1()
       delete[] fBGHandler;
       fBGHandler = 0x0;
    }
+   if( fGammasPool ){
+      delete[] fGammasPool;
+      fGammasPool = 0x0;
+   }
 }
 
 //___________________________________________________________
@@ -240,6 +250,7 @@ void AliAnalysisTaskGammaConvDalitzV1::InitBack(){
    multiplicityBinLimitsArrayTracks[3] = 27.5;
    multiplicityBinLimitsArrayTracks[4] = 41.5;
    multiplicityBinLimitsArrayTracks[5] = 200.;
+
    if(fIsHeavyIon){
       multiplicityBinLimitsArrayTracks[0] = 0;
       multiplicityBinLimitsArrayTracks[1] = 200.;
@@ -250,11 +261,13 @@ void AliAnalysisTaskGammaConvDalitzV1::InitBack(){
    }
 
    Double_t *multiplicityBinLimitsArrayV0s = new Double_t[5];
+
    multiplicityBinLimitsArrayV0s[0] = 2;
    multiplicityBinLimitsArrayV0s[1] = 3;
    multiplicityBinLimitsArrayV0s[2] = 4;
    multiplicityBinLimitsArrayV0s[3] = 5;
    multiplicityBinLimitsArrayV0s[4] = 9999;
+
    if(fIsHeavyIon){
       multiplicityBinLimitsArrayV0s[0] = 2;
       multiplicityBinLimitsArrayV0s[1] = 10;
@@ -264,21 +277,22 @@ void AliAnalysisTaskGammaConvDalitzV1::InitBack(){
    }
 
    const Int_t nDim = 4;
-   Int_t nBins[nDim] = {1000,250,8,5};
-   Double_t xMin[nDim] = {0,0, 0,0};
-   Double_t xMax[nDim] = {1,25,8,5};
+   Int_t    nBins[nDim] = {1000,250,8,5};
+   Double_t xMin[nDim]  = {0,0, 0,0};
+   Double_t xMax[nDim]  = {1,25,8,5};
 
-   sESDMotherInvMassPtZM = new THnSparseF*[fnCuts];
+   sESDMotherInvMassPtZM     = new THnSparseF*[fnCuts];
    sESDMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
 
+
    fBGHandler = new AliGammaConversionAODBGHandler*[fnCuts];
 
    for(Int_t iCut = 0; iCut<fnCuts;iCut++){
 
 
-      TString cutstringElectron =((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutNumber();
-      TString cutstringMeson= ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutNumber();
-      TString cutstringGamma = ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutNumber();
+      TString cutstringElectron     =   ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutNumber();
+      TString cutstringMeson        =   ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutNumber();
+      TString cutstringGamma        =   ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutNumber();
 
 
       fBackList[iCut] = new TList();
@@ -286,9 +300,6 @@ void AliAnalysisTaskGammaConvDalitzV1::InitBack(){
       fBackList[iCut]->SetOwner(kTRUE);
       fCutFolder[iCut]->Add(fBackList[iCut]);
 
-
-
-
       sESDMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
       sESDMotherInvMassPtZM[iCut]->Sumw2();
       fBackList[iCut]->Add(sESDMotherInvMassPtZM[iCut]);
@@ -296,249 +307,289 @@ void AliAnalysisTaskGammaConvDalitzV1::InitBack(){
       sESDMotherBackInvMassPtZM[iCut]->Sumw2();
       fBackList[iCut]->Add(sESDMotherBackInvMassPtZM[iCut]);
 
-      if(((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->UseTrackMultiplicity()){
-         fBGHandler[iCut] = new AliGammaConversionAODBGHandler(9,6,((AliConversionMesonCuts*)fCutGammaArray->At(iCut))->GetNumberOfBGEvents());
+      if(((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->UseTrackMultiplicity()) {
+         fBGHandler[iCut] = new AliGammaConversionAODBGHandler(9,6,((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->NumberOfRotationEvents());
          fBGHandler[iCut]->Initialize(zBinLimitsArray, multiplicityBinLimitsArrayTracks);
       }
       else{
-         fBGHandler[iCut] = new AliGammaConversionAODBGHandler(9,5,((AliConversionMesonCuts*)fCutGammaArray->At(iCut))->GetNumberOfBGEvents());
+         fBGHandler[iCut] = new AliGammaConversionAODBGHandler(9,5,((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->NumberOfRotationEvents());
          fBGHandler[iCut]->Initialize(zBinLimitsArray, multiplicityBinLimitsArrayV0s);
       }
+      if( ( (AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetBKGMethod() == 3 ){
+         fGammasPool[iCut] = new TList();
+      }
    }
+
 }
 
 //______________________________________________________________________
 void AliAnalysisTaskGammaConvDalitzV1::UserCreateOutputObjects()
 {
-//
-// Create ouput objects
-//
-
-       // Create the output container
-       if(fOutputContainer != NULL){
-               delete fOutputContainer;
-               fOutputContainer = NULL;
-       }
-       if(fOutputContainer == NULL){
-               fOutputContainer = new TList();
-               fOutputContainer->SetOwner(kTRUE);
-       }
-
-       fGoodGammas = new TList();
-        //fGoodGammas->SetOwner(kTRUE);
-
-       
-        fGoodVirtualGammas = new TList();
-           //fGoodVirtualGammas->SetOwner(kTRUE);
-
-
-       
-
-
-        fGammasPool = new TList*[fnCuts];
-
-       fCutFolder = new TList*[fnCuts];
-       fESDList = new TList*[fnCuts];
-       fBackList = new TList*[fnCuts];
-       hNEvents = new TH1I*[fnCuts];
-       hNGoodESDTracks = new TH1I*[fnCuts];
-       hESDConvGammaPt = new TH1F*[fnCuts];
-       hESDDalitzElectronPt = new TH1F*[fnCuts];
-       hESDDalitzPositronPt = new TH1F*[fnCuts];
-        hESDEposEnegPsiPairDPhi = new TH2F*[fnCuts];
-       
-       //if(fDoMesonAnalysis){
-               hESDMotherInvMassPt = new TH2F*[fnCuts];
-               hESDMotherBackInvMassPt = new TH2F*[fnCuts];
-       //}
-       for(Int_t iCut = 0; iCut<fnCuts;iCut++){
-
-
-               TString cutstringElectron =((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutNumber();
-               TString cutstringMeson= ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutNumber();
-               TString cutstringGamma = ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutNumber();
-
-               fCutFolder[iCut] = new TList();
-               fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s",cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
-               fCutFolder[iCut]->SetOwner(kTRUE);
-               fOutputContainer->Add(fCutFolder[iCut]);
-               fESDList[iCut] = new TList();
-               fESDList[iCut]->SetName(Form("%s_%s_%s ESD histograms",cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
-               fESDList[iCut]->SetOwner(kTRUE);
-               hNEvents[iCut] = new TH1I("NEvents","NEvents",7,-0.5,6.5);
-               fESDList[iCut]->Add(hNEvents[iCut]);
-               if(fIsHeavyIon) hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
-               else hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
-               fESDList[iCut]->Add(hNGoodESDTracks[iCut]);
-               hESDConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
-                fESDList[iCut]->Add(hESDConvGammaPt[iCut]);
-               hESDDalitzElectronPt[iCut] = new TH1F("ESD_DalitzElectron_Pt","ESD_DalitzElectron_Pt",250,0,25);
-                fESDList[iCut]->Add(hESDDalitzElectronPt[iCut]);
-               hESDDalitzPositronPt[iCut] = new TH1F("ESD_DalitzPositron_Pt","ESD_DalitzPositron_Pt",250,0,25);
-                fESDList[iCut]->Add(hESDDalitzPositronPt[iCut]);
-                
-         
-                hESDEposEnegPsiPairDPhi[iCut] = new TH2F("ESD_EposEneg_PsiPair_DPhi","ESD_EposEneg_PsiPair_DPhi", 100, -1.0*TMath::Pi(), TMath::Pi(),100,-1.0*TMath::Pi(), TMath::Pi() );
-                fESDList[iCut]->Add(hESDEposEnegPsiPairDPhi[iCut]);
+   //
+   // Create ouput objects
+   //
+
+   // Create the output container
+   if(fOutputContainer != NULL){
+      delete fOutputContainer;
+      fOutputContainer = NULL;
+   }
+   if(fOutputContainer == NULL){
+      fOutputContainer = new TList();
+      fOutputContainer->SetOwner(kTRUE);
+   }
+
+   fGoodGammas = new TList();
+   //fGoodGammas->SetOwner(kTRUE);
+
+
+   fGoodVirtualGammas = new TList();
+   //fGoodVirtualGammas->SetOwner(kTRUE);
+
+
+
+
+
+   fGammasPool                     = new TList*[fnCuts];
+   fCutFolder                      = new TList*[fnCuts];
+   fESDList                        = new TList*[fnCuts];
+   fBackList                       = new TList*[fnCuts];
+   hNEvents                        = new TH1I*[fnCuts];
+   hNGoodESDTracks                 = new TH1I*[fnCuts];
+   hESDConvGammaPt                 = new TH1F*[fnCuts];
+   hESDDalitzElectronPt            = new TH1F*[fnCuts];
+   hESDDalitzPositronPt            = new TH1F*[fnCuts];
+   hESDEposEnegPsiPairDPhi         = new TH2F*[fnCuts];
+   hESDEposEnegInvMassPt           = new TH2F*[fnCuts];
+   hESDMotherInvMassPt             = new TH2F*[fnCuts];
+   hESDPi0MotherInvMassPt          = new TH2F*[fnCuts];
+   hESDPi0MotherDiffInvMassPt      = new TH2F*[fnCuts];
+   hESDMotherBackInvMassPt         = new TH2F*[fnCuts];
+
+
+   for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+
+
+      TString cutstringElectron =((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutNumber();
+      TString cutstringMeson= ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutNumber();
+      TString cutstringGamma = ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutNumber();
+
+      fCutFolder[iCut] = new TList();
+      fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s",cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
+      fCutFolder[iCut]->SetOwner(kTRUE);
+      fOutputContainer->Add(fCutFolder[iCut]);
+
+      fESDList[iCut] = new TList();
+      fESDList[iCut]->SetName(Form("%s_%s_%s ESD histograms",cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
+      fESDList[iCut]->SetOwner(kTRUE);
+
+
+
+      hNEvents[iCut] = new TH1I("NEvents","NEvents",9,-0.5,8.5);
+      hNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
+      hNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
+      hNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Missing MC");
+      hNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
+      hNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
+      hNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
+      hNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
+      hNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
+      hNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
+      fESDList[iCut]->Add(hNEvents[iCut]);
+
+
+
+
+      if(fIsHeavyIon) hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
+      else hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
+      fESDList[iCut]->Add(hNGoodESDTracks[iCut]);
+
+      hESDConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
+      fESDList[iCut]->Add(hESDConvGammaPt[iCut]);
+
+      hESDDalitzElectronPt[iCut] = new TH1F("ESD_DalitzElectron_Pt","ESD_DalitzElectron_Pt",250,0,25);
+      fESDList[iCut]->Add(hESDDalitzElectronPt[iCut]);
+
+      hESDDalitzPositronPt[iCut] = new TH1F("ESD_DalitzPositron_Pt","ESD_DalitzPositron_Pt",250,0,25);
+      fESDList[iCut]->Add(hESDDalitzPositronPt[iCut]);
+
+
+      hESDEposEnegPsiPairDPhi[iCut] = new TH2F("ESD_EposEneg_PsiPair_DPhi","ESD_EposEneg_PsiPair_DPhi", 100, -1.0,1.0,100,-1.0,1.0 );
+      fESDList[iCut]->Add(hESDEposEnegPsiPairDPhi[iCut]);
+
+      hESDEposEnegInvMassPt[iCut] = new TH2F("ESD_EposEneg_InvMassPt","ESD_EposEneg_InvMassPt",5000,0.,5.,100,0.,10.);
+      fESDList[iCut]->Add(hESDEposEnegInvMassPt[iCut]);
+
+
+      hESDMotherInvMassPt[iCut] = new TH2F("ESD_DalitzMother_InvMass_Pt","ESD_DalitzMother_InvMass_Pt",1000,0,1,250,0,25);
+      fESDList[iCut]->Add(hESDMotherInvMassPt[iCut]);
+
+      hESDPi0MotherInvMassPt[iCut] = new TH2F("ESD_Pi0Mother_InvMass_Pt","ESD_Pi0Mother_InvMass_Pt",4000,0,4,250,0,25);
+      fESDList[iCut]->Add(hESDPi0MotherInvMassPt[iCut]);
                 
-                 
+      hESDPi0MotherDiffInvMassPt[iCut] = new TH2F("ESD_Pi0Mother_DiffInvMass_Pt","ESD_Pi0Mother_DiffInvMass_Pt",2000,0,2,250,0,25);
+      fESDList[iCut]->Add(hESDPi0MotherDiffInvMassPt[iCut]);
 
 
-               // hESDDalitzPositronPt[iCut] = new TH1F("ESD_EposEneg_PsiPair_vs_DPhi","ESD_EposEneg_PsiPair_vs_DPhi",250,0,25);
-     
-//             if(fDoMesonAnalysis){
-                       hESDMotherInvMassPt[iCut] = new TH2F("ESD_DalitzMother_InvMass_Pt","ESD_DalitzMother_InvMass_Pt",1000,0,1,250,0,25);
-                       fESDList[iCut]->Add(hESDMotherInvMassPt[iCut]);
-                       hESDMotherBackInvMassPt[iCut] = new TH2F("ESD_DalitzBackground_InvMass_Pt","ESD_DalitzBackground_InvMass_Pt",1000,0,1,250,0,25);
-                       fESDList[iCut]->Add(hESDMotherBackInvMassPt[iCut]);
-//             }
-               fCutFolder[iCut]->Add(fESDList[iCut]);
 
+      hESDMotherBackInvMassPt[iCut] = new TH2F("ESD_DalitzBackground_InvMass_Pt","ESD_DalitzBackground_InvMass_Pt",1000,0,1,250,0,25);
+      fESDList[iCut]->Add(hESDMotherBackInvMassPt[iCut]);
 
-             if( fCutElectronArray ){
-                if( ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutHistograms() ) {
-                    fCutFolder[iCut]->Add( ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutHistograms() );
-                }
-            }
+      fCutFolder[iCut]->Add(fESDList[iCut]);
 
-             if( fCutMesonArray  ) {
-                if( ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutHistograms() ) {
-                    fCutFolder[iCut]->Add( ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutHistograms());
-                }
-             }
 
-            if( fCutGammaArray ) {
-                if( ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutHistograms() ) {
-                    fCutFolder[iCut]->Add( ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutHistograms()  );
-                }
-            }
 
+   }
 
-       }
-
-       //if(fDoMesonAnalysis){
-               InitBack(); // Init Background Handler
-       //}
-
-       if(MCEvent()){
-               // MC Histogramms
-               fMCList = new TList*[fnCuts];
-               // True Histogramms
-               fTrueList = new TList*[fnCuts];
-               hESDTrueConvGammaPt = new TH1F*[fnCuts];        
-               //if(fDoMesonAnalysis){
-                       hMCPi0Pt = new TH1F*[fnCuts];
-                       hMCEtaPt = new TH1F*[fnCuts];
-                       hMCPi0InAccPt = new TH1F*[fnCuts];
-                       hMCEtaInAccPt = new TH1F*[fnCuts];
-
-                       hESDTrueMotherInvMassPt = new TH2F*[fnCuts];
-                        hESDTrueMotherPi0GGInvMassPt = new TH2F*[fnCuts];
-                       hESDTruePrimaryPi0DalitzESDPtMCPt = new TH2F*[fnCuts];
-                       hESDTruePrimaryMotherInvMassMCPt = new TH2F*[fnCuts];
-                       hESDTrueSecondaryMotherInvMassPt = new TH2F*[fnCuts];
-                       hESDTrueSecondaryMotherFromK0sInvMassPt = new TH2F*[fnCuts];
-                       hESDTrueBckGGInvMassPt = new TH2F*[fnCuts];
-                       hESDTrueBckContInvMassPt = new TH2F*[fnCuts];
-                       hESDTrueMotherGGInvMassPt = new TH2F*[fnCuts];
-               //}
-
-               for(Int_t iCut = 0; iCut<fnCuts;iCut++){
-                       TString cutstringElectron =((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutNumber();
-                       TString cutstringMeson= ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutNumber();
-                       TString cutstringGamma = ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutNumber();
-
-                       fMCList[iCut] = new TList();
-                       fMCList[iCut]->SetName(Form("%s_%s_%s MC histograms",cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
-                       fMCList[iCut]->SetOwner(kTRUE);
-                       fCutFolder[iCut]->Add(fMCList[iCut]);
-                       
-                               hMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",250,0,25);
-                               fMCList[iCut]->Add(hMCPi0Pt[iCut]);
-                               hMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
-                               fMCList[iCut]->Add(hMCEtaPt[iCut]);
-                               hMCPi0InAccPt[iCut] = new TH1F("MC_Pi0DalitzInAcc_Pt","MC_Pi0DalitzInAcc_Pt",250,0,25);
-                               fMCList[iCut]->Add(hMCPi0InAccPt[iCut]);
-                               hMCEtaInAccPt[iCut] = new TH1F("MC_EtaDalitzInAcc_Pt","MC_EtaDalitzInAcc_Pt",250,0,25);
-                               fMCList[iCut]->Add(hMCEtaInAccPt[iCut]);
-                       
-                       fTrueList[iCut] = new TList();
-                       fTrueList[iCut]->SetName(Form("%s_%s_%s True histograms",cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
-                       fTrueList[iCut]->SetOwner(kTRUE);
-                       fCutFolder[iCut]->Add(fTrueList[iCut]);
-
-                       hESDTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",250,0,25);
-                        fTrueList[iCut]->Add(hESDTrueConvGammaPt[iCut]);
-
-                       hESDTrueMotherInvMassPt[iCut] = new TH2F("ESD_TrueMother_InvMass_Pt","ESD_TrueMother_InvMass_Pt",1000,0,1,250,0,25);
-                       fTrueList[iCut]->Add(hESDTrueMotherInvMassPt[iCut]);
-
-                        hESDTrueMotherPi0GGInvMassPt[iCut] = new TH2F("ESD_TrueMotherPi0GG_InvMass_Pt","ESD_TrueMotherPi0GG_InvMass_Pt",1000,0,1,250,0,25);
-                                fTrueList[iCut]->Add(hESDTrueMotherPi0GGInvMassPt[iCut]);
-                               hESDTruePrimaryPi0DalitzESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryPi0Dalitz_ESDPt_MCPt","ESD_TruePrimaryPi0Dalitz_ESDPt_MCPt",250,0,25,250,0,25);
-                               fTrueList[iCut]->Add(hESDTruePrimaryPi0DalitzESDPtMCPt[iCut]);
-                               hESDTruePrimaryMotherInvMassMCPt[iCut] = new TH2F("ESD_TruePrimaryMother_InvMass_MCPt","ESD_TrueDalitzPrimaryMother_InvMass_MCPt",1000,0,1,250,0,25);
-                               fTrueList[iCut]->Add(hESDTruePrimaryMotherInvMassMCPt[iCut]);
-                               hESDTrueSecondaryMotherInvMassPt[iCut] = new TH2F("ESD_TrueDalitzSecondaryMother_InvMass_Pt","ESD_TrueDalitzSecondaryMother_InvMass_Pt",1000,0,1,250,0,25);
-                               fTrueList[iCut]->Add(hESDTrueSecondaryMotherInvMassPt[iCut]);
-//                             hESDTrueSecondaryMotherFromK0sInvMassPt[iCut] = new TH2F("ESD_TrueDalitzSecondaryMotherFromK0s_InvMass_Pt","ESD_TrueDalitzSecondaryMotherFromK0s_InvMass_Pt",1000,0,1,250,0,25);
-//                             fTrueList[iCut]->Add(hESDTrueSecondaryMotherFromK0sInvMassPt[iCut]);
-                               hESDTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueDalitzBckGG_InvMass_Pt","ESD_TrueDalitzBckGG_InvMass_Pt",1000,0,1,250,0,25);
-                               fTrueList[iCut]->Add(hESDTrueBckGGInvMassPt[iCut]);
-                               hESDTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueDalitzBckCont_InvMass_Pt","ESD_TrueDalitzBckCont_InvMass_Pt",1000,0,1,250,0,25);
-                               fTrueList[iCut]->Add(hESDTrueBckContInvMassPt[iCut]);
-//                             hESDTrueMotherGGInvMassPt[iCut] = new TH2F("ESD_TrueGammaGamma_InvMass_Pt","ESD_TrueGammaGamma_InvMass_Pt",1000,0,1,250,0,25);
-//                             fTrueList[iCut]->Add(hESDTrueMotherGGInvMassPt[iCut]);
-                       
-               }
-       }
-
-       PostData(1, fOutputContainer);
+
+   InitBack(); // Init Background Handler
+
+
+   if(MCEvent()){
+      // MC Histogramms
+      fMCList = new TList*[fnCuts];
+      // True Histogramms
+      fTrueList = new TList*[fnCuts];
+      hESDTrueConvGammaPt = new TH1F*[fnCuts];
+      //if(fDoMesonAnalysis){
+      hMCPi0Pt = new TH1F*[fnCuts];
+      hMCPi0GGPt =  new TH1F*[fnCuts];
+      hMCEtaPt = new TH1F*[fnCuts];
+      hMCEtaGGPt = new TH1F*[fnCuts];
+      hMCPi0InAccPt = new TH1F*[fnCuts];
+      hMCEtaInAccPt = new TH1F*[fnCuts];
+
+      hESDTrueMotherInvMassPt = new TH2F*[fnCuts];
+      hESDTrueMotherPi0GGInvMassPt = new TH2F*[fnCuts];
+      hESDTruePrimaryPi0DalitzESDPtMCPt = new TH2F*[fnCuts];
+      hESDTruePrimaryMotherInvMassMCPt = new TH2F*[fnCuts];
+      hESDTrueSecondaryMotherInvMassPt = new TH2F*[fnCuts];
+      hESDTrueSecondaryMotherFromK0sInvMassPt = new TH2F*[fnCuts];
+      hESDTrueBckGGInvMassPt = new TH2F*[fnCuts];
+      hESDTrueBckContInvMassPt = new TH2F*[fnCuts];
+      hESDTrueMotherGGInvMassPt = new TH2F*[fnCuts];
+      //}
+
+      for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+         TString cutstringElectron =((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutNumber();
+         TString cutstringMeson= ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutNumber();
+         TString cutstringGamma = ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutNumber();
+
+         fMCList[iCut] = new TList();
+         fMCList[iCut]->SetName(Form("%s_%s_%s MC histograms",cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
+         fMCList[iCut]->SetOwner(kTRUE);
+         fCutFolder[iCut]->Add(fMCList[iCut]);
+
+                hMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",250,0,25);
+                fMCList[iCut]->Add(hMCPi0Pt[iCut]);
+        
+                hMCPi0GGPt[iCut] = new TH1F("MC_Pi0_GG_Pt","MC_Pi0_GG_Pt",250,0,25);
+                fMCList[iCut]->Add(hMCPi0GGPt[iCut]);
+
+
+                hMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
+                fMCList[iCut]->Add(hMCEtaPt[iCut]);
+
+                hMCEtaGGPt[iCut] = new TH1F("MC_Eta_GG_Pt","MC_Eta_GG_Pt",250,0,25);
+                fMCList[iCut]->Add(hMCEtaGGPt[iCut]);
+
+
+                hMCPi0InAccPt[iCut] = new TH1F("MC_Pi0DalitzInAcc_Pt","MC_Pi0DalitzInAcc_Pt",250,0,25);
+                fMCList[iCut]->Add(hMCPi0InAccPt[iCut]);
+                hMCEtaInAccPt[iCut] = new TH1F("MC_EtaDalitzInAcc_Pt","MC_EtaDalitzInAcc_Pt",250,0,25);
+                fMCList[iCut]->Add(hMCEtaInAccPt[iCut]);
+
+         fTrueList[iCut] = new TList();
+         fTrueList[iCut]->SetName(Form("%s_%s_%s True histograms",cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
+         fTrueList[iCut]->SetOwner(kTRUE);
+         fCutFolder[iCut]->Add(fTrueList[iCut]);
+
+         hESDTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",250,0,25);
+         fTrueList[iCut]->Add(hESDTrueConvGammaPt[iCut]);
+
+         hESDTrueMotherInvMassPt[iCut] = new TH2F("ESD_TrueMother_InvMass_Pt","ESD_TrueMother_InvMass_Pt",1000,0,1,250,0,25);
+         fTrueList[iCut]->Add(hESDTrueMotherInvMassPt[iCut]);
+
+         hESDTrueMotherPi0GGInvMassPt[iCut] = new TH2F("ESD_TrueMotherPi0GG_InvMass_Pt","ESD_TrueMotherPi0GG_InvMass_Pt",1000,0,1,250,0,25);
+         fTrueList[iCut]->Add(hESDTrueMotherPi0GGInvMassPt[iCut]);
+         hESDTruePrimaryPi0DalitzESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryPi0Dalitz_ESDPt_MCPt","ESD_TruePrimaryPi0Dalitz_ESDPt_MCPt",250,0,25,250,0,25);
+         fTrueList[iCut]->Add(hESDTruePrimaryPi0DalitzESDPtMCPt[iCut]);
+         hESDTruePrimaryMotherInvMassMCPt[iCut] = new TH2F("ESD_TruePrimaryMother_InvMass_MCPt","ESD_TrueDalitzPrimaryMother_InvMass_MCPt",1000,0,1,250,0,25);
+         fTrueList[iCut]->Add(hESDTruePrimaryMotherInvMassMCPt[iCut]);
+         hESDTrueSecondaryMotherInvMassPt[iCut] = new TH2F("ESD_TrueDalitzSecondaryMother_InvMass_Pt","ESD_TrueDalitzSecondaryMother_InvMass_Pt",1000,0,1,250,0,25);
+         fTrueList[iCut]->Add(hESDTrueSecondaryMotherInvMassPt[iCut]);
+         //                            hESDTrueSecondaryMotherFromK0sInvMassPt[iCut] = new TH2F("ESD_TrueDalitzSecondaryMotherFromK0s_InvMass_Pt","ESD_TrueDalitzSecondaryMotherFromK0s_InvMass_Pt",1000,0,1,250,0,25);
+         //                            fTrueList[iCut]->Add(hESDTrueSecondaryMotherFromK0sInvMassPt[iCut]);
+         hESDTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueDalitzBckGG_InvMass_Pt","ESD_TrueDalitzBckGG_InvMass_Pt",1000,0,1,250,0,25);
+         fTrueList[iCut]->Add(hESDTrueBckGGInvMassPt[iCut]);
+         hESDTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueDalitzBckCont_InvMass_Pt","ESD_TrueDalitzBckCont_InvMass_Pt",1000,0,1,250,0,25);
+         fTrueList[iCut]->Add(hESDTrueBckContInvMassPt[iCut]);
+         //                            hESDTrueMotherGGInvMassPt[iCut] = new TH2F("ESD_TrueGammaGamma_InvMass_Pt","ESD_TrueGammaGamma_InvMass_Pt",1000,0,1,250,0,25);
+         //                            fTrueList[iCut]->Add(hESDTrueMotherGGInvMassPt[iCut]);
+
+      }
+   }
+
+   PostData(1, fOutputContainer);
 
 }
 
 //______________________________________________________________________
 void AliAnalysisTaskGammaConvDalitzV1::UserExec(Option_t *)
 {
-//
-// Execute analysis for current event
-//        
+
+   //
+   // Execute analysis for current event
+   //
+
 
    fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
    if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
 
+
    Int_t eventQuality = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetEventQuality();
 
-   if(eventQuality != 0){// Event Not Accepted
+   if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1
       for(Int_t iCut = 0; iCut<fnCuts; iCut++){
          hNEvents[iCut]->Fill(eventQuality);
       }
       return;
    }
 
+
+
+
    fElecSelector=(AliDalitzElectronSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("ElectronSelector");
    if(!fElecSelector){printf("Error: No ElectronSelector");return;} // GetV0Reader
 
 
-   
-   fMCEvent = MCEvent();
-   fESDEvent = (AliESDEvent*) InputEvent();
-   fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
+   fMCEvent         =  MCEvent();
+   fESDEvent        = (AliESDEvent*)InputEvent();
+   fReaderGammas    = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
    fSelectorElectronIndex = fElecSelector->GetReconstructedElectronsIndex(); // Electrons from default Cut
    fSelectorPositronIndex = fElecSelector->GetReconstructedPositronsIndex(); // Positrons from default Cut
-   CountESDTracks(); // Estimate Event Multiplicity
 
-   AddTaskContainers(); //Add conatiner
+   CountESDTracks(); // Estimate Event Multiplicity
+   //AddTaskContainers(); //Add conatiner
 
-    for(Int_t iCut = 0; iCut<fnCuts; iCut++){
+   for(Int_t iCut = 0; iCut<fnCuts; iCut++){
       fiCut = iCut;
 
-      if(fIsHeavyIon && !((AliConversionCuts*)fCutGammaArray->At(iCut))->IsCentralitySelected(fESDEvent)){
-
-         hNEvents[iCut]->Fill(1); // Check Centrality --> Not Accepted => eventQuality = 1
+      Int_t eventNotAccepted =
+         ((AliConversionCuts*)fCutGammaArray->At(iCut))
+         ->IsEventAcceptedByConversionCut(fV0Reader->GetConversionCuts(),fInputEvent,fMCEvent,fIsHeavyIon);
+      if(eventNotAccepted){
+         //                    cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
+         hNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
          continue;
+      }
 
+      if(eventQuality != 0){// Event Not Accepted
+         //                    cout << "event rejected due to: " <<eventQuality << endl;
+         hNEvents[iCut]->Fill(eventQuality);
+         continue;
       }
+
       hNEvents[iCut]->Fill(eventQuality);
 
       hNGoodESDTracks[iCut]->Fill(fNumberOfESDTracks);
@@ -548,79 +599,69 @@ void AliAnalysisTaskGammaConvDalitzV1::UserExec(Option_t *)
          ProcessMCParticles();
       }
 
+
+
       ProcessPhotonCandidates(); // Process this cuts gammas
       ProcessElectronCandidates(); // Process this cuts gammas
       CalculatePi0DalitzCandidates();
       CalculateBackground();
       UpdateEventByEventData();
-      
-               
-//       if(fDoMesonAnalysis){ // Meson Analysis
-//          CalculatePi0Candidates(); // Combine Gammas
-//          CalculateBackground(); // Combinatorial Background
-//          UpdateEventByEventData(); // Store Event for mixed Events  
-//        }
+
+
+
       fGoodGammas->Clear(); // delete this cuts good gammas
       fGoodVirtualGammas->Clear(); // delete this cuts good gammas
    }
 
-    fSelectorElectronIndex.clear();
-    fSelectorPositronIndex.clear();
+   fSelectorElectronIndex.clear();
+   fSelectorPositronIndex.clear();
 
-    PostData( 1, fOutputContainer );
+   PostData( 1, fOutputContainer );
 }
 
 void AliAnalysisTaskGammaConvDalitzV1::Terminate(const Option_t *)
 {
 
+   if( fElecSelector ){
 
-}
-
-void AliAnalysisTaskGammaConvDalitzV1::AddTaskContainers()
-{
-//
-
-
-   // cout<<"Entro a dfdsfasdfdsfasdfsdfds terminate: "<<endl;
-
-
-    if( fElecSelector ){
-        
-         //cout<<"Entro al fElecSelector: "<<endl;
-
-         TList *temp0 =  ((AliDalitzElectronCuts*)fElecSelector->GetDalitzElectronCuts())->GetCutHistograms(); 
+      if ( ((AliDalitzElectronCuts*)fElecSelector->GetDalitzElectronCuts())->GetCutHistograms() ){
+         fOutputContainer->Add( ((AliDalitzElectronCuts*)fElecSelector->GetDalitzElectronCuts())->GetCutHistograms() );
+      }
+   }
 
-        if (  temp0 ) {
 
-               if( ! fOutputContainer->Contains( temp0 ) ) { 
-                       fOutputContainer->Add( temp0 );
-                       cout<<" Add fElecSelector: "<<endl;
-               }
+   if ( fV0Reader ) {
 
-        }
-    }
+      if ( ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms() ){
+         fOutputContainer->Add(  ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms() );
+      }
+   }
 
 
-    if ( fV0Reader ) {
 
-       TList *temp1 = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms();
 
-        if(  temp1  ) {
-               if( ! fOutputContainer->Contains( temp1 ) ) {
+   for(Int_t iCut = 0; iCut<fnCuts;iCut++){
 
-                       fOutputContainer->Add( temp1 );
-                       cout<<"Add GammaConv"<<endl;
-               }
-        }
-    }
+      if( fCutElectronArray ){
+         if( ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutHistograms() ) {
+            fCutFolder[iCut]->Add( ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutHistograms() );
+         }
+      }
 
+      if( fCutMesonArray  ) {
+         if( ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutHistograms() ) {
+            fCutFolder[iCut]->Add( ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutHistograms());
+         }
+      }
 
-   // fOutputContainer->Print();
+      if( fCutGammaArray ) {
+         if( ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutHistograms() ) {
+            fCutFolder[iCut]->Add( ((AliConversionCuts*)fCutGammaArray->At(iCut))->GetCutHistograms()  );
+         }
+      }
+   }
 
-   // if( fDebug ) AliInfo("Not to do anything in Terminate");
 }
-
-
 //________________________________________________________________________
 void AliAnalysisTaskGammaConvDalitzV1::ProcessPhotonCandidates()
 {
@@ -632,8 +673,8 @@ void AliAnalysisTaskGammaConvDalitzV1::ProcessPhotonCandidates()
       AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
       if(!PhotonCandidate) continue;
       if(!((AliConversionCuts*)fCutGammaArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fESDEvent)) continue;
-      
-      if(!((AliConversionCuts*)fCutGammaArray->At(fiCut))->UseElecSharingCut() && 
+
+      if(!((AliConversionCuts*)fCutGammaArray->At(fiCut))->UseElecSharingCut() &&
          !((AliConversionCuts*)fCutGammaArray->At(fiCut))->UseToCloseV0sCut()){ // if no post reader loop is required add to events good gammas
          fGoodGammas->Add(PhotonCandidate);
          hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
@@ -646,7 +687,7 @@ void AliAnalysisTaskGammaConvDalitzV1::ProcessPhotonCandidates()
          nV0++;
          GoodGammasStepOne->Add(PhotonCandidate);
       }
-      else if(!((AliConversionCuts*)fCutGammaArray->At(fiCut))->UseElecSharingCut() && 
+      else if(!((AliConversionCuts*)fCutGammaArray->At(fiCut))->UseElecSharingCut() &&
               ((AliConversionCuts*)fCutGammaArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
          GoodGammasStepTwo->Add(PhotonCandidate);
       }
@@ -656,7 +697,7 @@ void AliAnalysisTaskGammaConvDalitzV1::ProcessPhotonCandidates()
          AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GoodGammasStepOne->At(i);
          if(!PhotonCandidate) continue;
          if(!((AliConversionCuts*)fCutGammaArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GoodGammasStepOne->GetEntries())) continue;
-         if(!((AliConversionCuts*)fCutGammaArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed 
+         if(!((AliConversionCuts*)fCutGammaArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
             fGoodGammas->Add(PhotonCandidate);
             hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
             if(fMCEvent){
@@ -712,107 +753,146 @@ void AliAnalysisTaskGammaConvDalitzV1::ProcessTruePhotonCandidates(AliAODConvers
 //________________________________________________________________________
 void AliAnalysisTaskGammaConvDalitzV1::ProcessElectronCandidates(){
 
-   Float_t magField = fInputEvent->GetMagneticField();
+   Double_t magField = fInputEvent->GetMagneticField();
 
 
    if( magField  < 0.0 ){
-       magField =  1.0;
+      magField =  1.0;
    }
    else {
-       magField =  -1.0;  
+      magField =  -1.0;
    }
-    
 
-  
 
-  
-    vector<Int_t> lGoodElectronIndex(0);
-    vector<Int_t> lGoodPositronIndex(0);
 
 
-    lGoodElectronIndex.clear();
-    lGoodPositronIndex.clear();
 
-    
-    for(UInt_t i = 0; i < fSelectorElectronIndex.size(); i++){
+   vector<Int_t> lGoodElectronIndex(0);
+   vector<Int_t> lGoodPositronIndex(0);
 
-        AliESDtrack* electronCandidate = fESDEvent->GetTrack(fSelectorElectronIndex[i]);
-        if(! ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelected(electronCandidate) ) continue;
-        lGoodElectronIndex.push_back(   fSelectorElectronIndex[i] );
-        hESDDalitzElectronPt[fiCut]->Fill(electronCandidate->Pt());
 
-    }
 
-    for(UInt_t i = 0; i < fSelectorPositronIndex.size(); i++){
+   for(UInt_t i = 0; i < fSelectorElectronIndex.size(); i++){
 
-        AliESDtrack* positronCandidate = fESDEvent->GetTrack(fSelectorPositronIndex[i]);
-        if(! ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelected(positronCandidate) ) continue;
-        lGoodPositronIndex.push_back(   fSelectorPositronIndex[i] );
-        hESDDalitzPositronPt[fiCut]->Fill(positronCandidate->Pt());
+      AliESDtrack* electronCandidate = fESDEvent->GetTrack(fSelectorElectronIndex[i]);
+      if(! ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelected(electronCandidate) ) continue;
+      lGoodElectronIndex.push_back(   fSelectorElectronIndex[i] );
+      if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->DoPsiPairCut() == kFALSE ){
+         hESDDalitzElectronPt[fiCut]->Fill(electronCandidate->Pt());
+      }
+
+   }
+
+   for(UInt_t i = 0; i < fSelectorPositronIndex.size(); i++){
+
+      AliESDtrack* positronCandidate = fESDEvent->GetTrack(fSelectorPositronIndex[i]);
+      if(! ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelected(positronCandidate) ) continue;
+      lGoodPositronIndex.push_back(   fSelectorPositronIndex[i] );
+      if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->DoPsiPairCut() == kFALSE ){
+         hESDDalitzPositronPt[fiCut]->Fill(positronCandidate->Pt());
+      }
+
+   }
+
+
+   vector<Bool_t> lElectronPsiIndex(lGoodElectronIndex.size(), kTRUE);
+   vector<Bool_t> lPositronPsiIndex(lGoodPositronIndex.size(), kTRUE);
+
+
+   if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->DoPsiPairCut() == kTRUE ){
+
+      for( UInt_t i = 0; i < lGoodElectronIndex.size(); i++ ) {
+
+         AliESDtrack *electronCandidate = fESDEvent->GetTrack(lGoodElectronIndex[i]);
+
+         for(UInt_t j = 0; j <  lGoodPositronIndex.size(); j++){
+            AliESDtrack *positronCandidate = fESDEvent->GetTrack(lGoodPositronIndex[j]);
+            Double_t psiPair = GetPsiPair(positronCandidate,electronCandidate);
+            Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->GetConstrainedParam()->Phi()-positronCandidate->GetConstrainedParam()->Phi());
+
+            if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->IsFromGammaConversion(psiPair,deltaPhi ) ){
+               lElectronPsiIndex[i] = kFALSE;
+               lPositronPsiIndex[j] = kFALSE;
+            }
+
+         }
+      }
+
+
+      for(UInt_t i = 0; i < lGoodElectronIndex.size(); i++){
+
+         if( lElectronPsiIndex[i] == kTRUE ){
+            AliESDtrack* electronCandidate = fESDEvent->GetTrack(lGoodElectronIndex[i]);
+            hESDDalitzElectronPt[fiCut]->Fill(electronCandidate->Pt());
+         }
+      }
+
+      for(UInt_t i = 0; i < lGoodPositronIndex.size(); i++){
+         if( lPositronPsiIndex[i] == kTRUE ) {
+            AliESDtrack* positronCandidate = fESDEvent->GetTrack(lGoodPositronIndex[i]);
+            hESDDalitzPositronPt[fiCut]->Fill(positronCandidate->Pt());
+         }
+      }
+   }
 
-    }
 
 
 
 
 
-       
    for(UInt_t i = 0; i < lGoodElectronIndex.size(); i++){
 
+      if( lElectronPsiIndex[i] == kFALSE ) continue;
 
-               AliESDtrack* electronCandidate = fESDEvent->GetTrack(lGoodElectronIndex[i]);
 
-               AliKFParticle electronCandidateKF( *electronCandidate->GetConstrainedParam(), ::kElectron );
-                
-               for(UInt_t j = 0; j < lGoodPositronIndex.size(); j++){
-                   AliESDtrack* positronCandidate = fESDEvent->GetTrack(lGoodPositronIndex[j]);
-                        AliKFParticle positronCandidateKF( *positronCandidate->GetConstrainedParam(), ::kPositron );
-                       
-                        if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->DoPsiPairCut() == kTRUE ){
-
-                           
-
-                            
-                            Double_t psiPair = ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetPsiPair(electronCandidate,positronCandidate);
-                            Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->GetConstrainedParam()->Phi()-positronCandidate->GetConstrainedParam()->Phi());
-
-                           
-
-                            if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->IsFromGammaConversion(psiPair,deltaPhi ) ){
-                                 continue;
-                            }
-                              hESDEposEnegPsiPairDPhi[fiCut]->Fill(deltaPhi,psiPair);
-
-                          }
-
-
-                          AliKFConversionPhoton* virtualPhoton = new AliKFConversionPhoton(electronCandidateKF,positronCandidateKF);
-
-                         //if(fUseImprovedVertex == kTRUE){
-                                AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
-                                primaryVertexImproved+=*virtualPhoton;
-                                virtualPhoton->SetProductionVertex(primaryVertexImproved);
-                         //}
-                          
-                          virtualPhoton->SetTrackLabels( lGoodPositronIndex[j], lGoodElectronIndex[i]);
-
-                          if(fMCEvent){
-
-                               // AliStack *fMCStack= fMCEvent->Stack();
-                                Int_t labeln=TMath::Abs(electronCandidate->GetLabel());
-                                Int_t labelp=TMath::Abs(positronCandidate->GetLabel());
-                                TParticle *fNegativeMCParticle = fMCStack->Particle(labeln);
-                                TParticle *fPositiveMCParticle = fMCStack->Particle(labelp);
-                                if( fPositiveMCParticle && fNegativeMCParticle) {
-                                    virtualPhoton->SetMCLabelPositive(labelp);
-                                    virtualPhoton->SetMCLabelNegative(labeln);
-                                }
-                          }
-                          AliAODConversionPhoton *vphoton = new AliAODConversionPhoton(virtualPhoton); //To Apply PsiPairCut
-                          fGoodVirtualGammas->Add(  vphoton );
+      AliESDtrack *electronCandidate = fESDEvent->GetTrack(lGoodElectronIndex[i]);
+
+      AliKFParticle electronCandidateKF( *electronCandidate->GetConstrainedParam(), ::kElectron );
+
+      for(UInt_t j = 0; j < lGoodPositronIndex.size(); j++){
+
+         if( lPositronPsiIndex[j] == kFALSE ) continue;
+
+         AliESDtrack *positronCandidate = fESDEvent->GetTrack(lGoodPositronIndex[j]);
+         AliKFParticle positronCandidateKF( *positronCandidate->GetConstrainedParam(), ::kPositron );
+
+         Double_t psiPair = GetPsiPair(positronCandidate,electronCandidate);
+         Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->GetConstrainedParam()->Phi()-positronCandidate->GetConstrainedParam()->Phi());
+         hESDEposEnegPsiPairDPhi[fiCut]->Fill(deltaPhi,psiPair);
+
+
+
+
+         AliKFConversionPhoton* virtualPhoton = new AliKFConversionPhoton(electronCandidateKF,positronCandidateKF);
+
+
+         AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
+         primaryVertexImproved+=*virtualPhoton;
+         virtualPhoton->SetProductionVertex(primaryVertexImproved);
+
+         virtualPhoton->SetTrackLabels( lGoodPositronIndex[j], lGoodElectronIndex[i]);
+
+         if(fMCEvent){
+
+            // AliStack *fMCStack= fMCEvent->Stack();
+            Int_t labeln=TMath::Abs(electronCandidate->GetLabel());
+            Int_t labelp=TMath::Abs(positronCandidate->GetLabel());
+            TParticle *fNegativeMCParticle = fMCStack->Particle(labeln);
+            TParticle *fPositiveMCParticle = fMCStack->Particle(labelp);
+            if( fPositiveMCParticle && fNegativeMCParticle) {
+               virtualPhoton->SetMCLabelPositive(labelp);
+               virtualPhoton->SetMCLabelNegative(labeln);
             }
+         }
+         AliAODConversionPhoton *vphoton = new AliAODConversionPhoton(virtualPhoton); //To Apply PsiPairCut
+        // cout<<"Virtual Photon Mass: "<<vphoton->GetMass()<<"  Pt: "<<vphoton->Pt()<<endl;
+    
+         hESDEposEnegInvMassPt[fiCut]->Fill(vphoton->GetMass(),vphoton->Pt());
+
+         fGoodVirtualGammas->Add(  vphoton );
+      }
    }
-   
+
 }
 
 //________________________________________________________________________
@@ -820,12 +900,12 @@ void AliAnalysisTaskGammaConvDalitzV1::CalculatePi0DalitzCandidates(){
 
    // Conversion Gammas
 
-  
+
 
 
    if( fGoodGammas->GetEntries() > 0 && fGoodVirtualGammas->GetEntries() > 0 ){
 
-   
+
       for(Int_t GammaIndex=0; GammaIndex<fGoodGammas->GetEntries(); GammaIndex++){
 
          AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(GammaIndex));
@@ -842,14 +922,19 @@ void AliAnalysisTaskGammaConvDalitzV1::CalculatePi0DalitzCandidates(){
             AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma,Vgamma);
             pi0cand->SetLabels(GammaIndex,virtualGammaIndex);
 
-              if( ( ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE)) ){
+            if( ( ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE)) ){
                hESDMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
-              // if(pi0cand->GetAlpha()<0.1){
-              //    hESDMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
-              // }
+               hESDPi0MotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
+                
+               Double_t diffMass = pi0cand->M() - Vgamma->GetMass();
+    
+               hESDPi0MotherDiffInvMassPt[fiCut]->Fill( diffMass , pi0cand->Pt() );
+               // if(pi0cand->GetAlpha()<0.1){
+               //    hESDMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
+               // }
                Int_t zbin= fBGHandler[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
                Int_t mbin = 0;
-               if(((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->UseTrackMultiplicity()){
+               if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->UseTrackMultiplicity() ){
                   mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fNumberOfESDTracks);
                } else {
                   mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
@@ -859,12 +944,12 @@ void AliAnalysisTaskGammaConvDalitzV1::CalculatePi0DalitzCandidates(){
                if(fMCEvent){
                   ProcessTrueMesonCandidates(pi0cand,gamma,Vgamma);
                }
-              }
+            }
             delete pi0cand;
             pi0cand=0x0;
          }
       }
-    }
+   }
 }
 
 //________________________________________________________________________
@@ -872,7 +957,7 @@ void AliAnalysisTaskGammaConvDalitzV1::CalculateBackground(){
 
    Int_t zbin= fBGHandler[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
    Int_t mbin = 0;
-   
+
    Int_t method = 0;
 
    method = ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->GetBKGMethod();
@@ -900,8 +985,8 @@ void AliAnalysisTaskGammaConvDalitzV1::CalculateBackground(){
 
             for(Int_t iCurrent=0;iCurrent<fGoodVirtualGammas->GetEntries();iCurrent++){
                AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualGammas->At(iCurrent));
-               
-                for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
+
+               for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
                   AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
 
                   if(fMoveParticleAccordingToVertex == kTRUE && method == 1 ){
@@ -928,7 +1013,9 @@ void AliAnalysisTaskGammaConvDalitzV1::CalculateBackground(){
                   bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
                }
                for(Int_t iCurrent=0;iCurrent<fGoodVirtualGammas->GetEntries();iCurrent++){
+
                   AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualGammas->At(iCurrent));
+
                   for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
 
                      AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
@@ -938,7 +1025,6 @@ void AliAnalysisTaskGammaConvDalitzV1::CalculateBackground(){
                      }
 
                      AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
-
                      if((((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE))){
                         hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
                         Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
@@ -955,27 +1041,27 @@ void AliAnalysisTaskGammaConvDalitzV1::CalculateBackground(){
 
    else if( method == 3 ){
 
-            for(Int_t iCurrent=0;iCurrent<fGoodVirtualGammas->GetEntries();iCurrent++){
+      for(Int_t iCurrent=0;iCurrent<fGoodVirtualGammas->GetEntries();iCurrent++){
 
-               AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualGammas->At(iCurrent));
+         AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualGammas->At(iCurrent));
 
-                for(Int_t iPrevious=0;iPrevious<fGammasPool[fiCut]->GetEntries();iPrevious++){
-                
-                  AliAODConversionPhoton previousGoodV0 = *(AliAODConversionPhoton*)((fGammasPool[fiCut]->At(iPrevious) ));
+         for(Int_t iPrevious=0;iPrevious<fGammasPool[fiCut]->GetEntries();iPrevious++){
 
-                
-                  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
+            AliAODConversionPhoton previousGoodV0 = *(AliAODConversionPhoton*)((fGammasPool[fiCut]->At(iPrevious) ));
 
-                  if((((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE))){
 
-                     hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
-                     Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
-                     sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
-                  }
-                  delete backgroundCandidate;
-                  backgroundCandidate = 0x0;
-               }
+            AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
+
+            if((((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE))){
+
+               hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
+               Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
+               sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
             }
+            delete backgroundCandidate;
+            backgroundCandidate = 0x0;
+         }
+      }
    }
 
 }
@@ -986,42 +1072,46 @@ void AliAnalysisTaskGammaConvDalitzV1::UpdateEventByEventData(){
    Int_t method = 0;
 
    method = ( (AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetBKGMethod();
-   
+
    if( method == 1 ) {
 
-   if(fGoodGammas->GetEntries() >0 ){
+      if(fGoodGammas->GetEntries() > 0 ){
 
-      if(((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->UseTrackMultiplicity()){
-         fBGHandler[fiCut]->AddEvent(fGoodGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fNumberOfESDTracks);
-      }
+         if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->UseTrackMultiplicity() ){
+            fBGHandler[fiCut]->AddEvent(fGoodGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fNumberOfESDTracks);
+         }
 
-      else{ // means we use #V0s for multiplicity
-         fBGHandler[fiCut]->AddEvent(fGoodGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fGoodGammas->GetEntries());
+         else{ // means we use #V0s for multiplicity
+            fBGHandler[fiCut]->AddEvent(fGoodGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fGoodGammas->GetEntries());
+         }
       }
-    }
    }
 
    else if ( method == 2 ){
-    
-    if(fGoodVirtualGammas->GetEntries() >0 ){
-      if(((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->UseTrackMultiplicity()){
-         fBGHandler[fiCut]->AddEvent(fGoodVirtualGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fNumberOfESDTracks);
+
+      if(fGoodVirtualGammas->GetEntries() > 0 ){
+         if(((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->UseTrackMultiplicity()){
+            fBGHandler[fiCut]->AddEvent(fGoodVirtualGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fNumberOfESDTracks);
+         }
+         else{ // means we use #V0s for multiplicity
+            fBGHandler[fiCut]->AddEvent(fGoodVirtualGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fGoodVirtualGammas->GetEntries());
+         }
       }
-      else{ // means we use #V0s for multiplicity
-         fBGHandler[fiCut]->AddEvent(fGoodVirtualGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fGoodGammas->GetEntries());
-     }
    }
-  }
-  else if ( method  == 3 ) {
-        
-               for(Int_t index = 0; index < fGoodGammas->GetEntries(); index ++){
+   else if ( method  == 3 ) {
+
+
+
+      for(Int_t index = 0; index < fGoodGammas->GetEntries(); index++){
+
+
+         if ( fGammasPool[fiCut]->GetEntries() > ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->NumberOfRotationEvents() ){
+            fGammasPool[fiCut]->RemoveLast();
+         }
+         fGammasPool[fiCut]->AddFirst( new AliAODConversionPhoton(*(AliAODConversionPhoton*)(fGoodGammas->At(index)) ) );
 
-                            if ( fGammasPool[fiCut]->GetEntries() > 10 ){
-                                    fGammasPool[fiCut]->RemoveLast();
-                            }
-                 fGammasPool[fiCut]->AddFirst(dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(index)));
-               }
       }
+   }
 }
 //______________________________________________________________________
 void AliAnalysisTaskGammaConvDalitzV1::ProcessTrueMesonCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate, AliAODConversionPhoton *TrueVirtualGammaCandidate)
@@ -1055,55 +1145,55 @@ void AliAnalysisTaskGammaConvDalitzV1::ProcessTrueMesonCandidates(AliAODConversi
          if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){  // Electrons ...
 
             if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
-               
-                    if(gammaMC->GetPdgCode() == 22){ // ... with Gamma Mother
-                     gammaMotherLabel=gammaMC->GetFirstMother();
-                    }
-           }
-        }
-       }
-
-
-         Int_t virtualGammaMCLabel = TrueVirtualGammaCandidate->GetMCParticleLabel(MCStack);
-         Int_t virtualGammaMotherLabel = -1;
-         Int_t virtualGamma = 1;
-
-         if(virtualGammaMCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
-            // Daughters Gamma 1
-            TParticle * negativeMC = (TParticle*)TrueVirtualGammaCandidate->GetNegativeMCDaughter(MCStack);
-            TParticle * positiveMC = (TParticle*)TrueVirtualGammaCandidate->GetPositiveMCDaughter(MCStack);
-            TParticle * virtualGammaMotherMC = (TParticle*)MCStack->Particle(virtualGammaMCLabel);
-            if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){  // Electrons ...
 
-            if( virtualGammaMotherMC->GetPdgCode() != 22 ){
-                  virtualGammaMotherLabel=virtualGammaMCLabel;
-            }                  
-             
-             else if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
-               
-                    virtualGammaMotherLabel=virtualGammaMotherMC->GetFirstMother();
-                    virtualGamma = 0; //no virtual gamma
-                
-             }
+               if(gammaMC->GetPdgCode() == 22){ // ... with Gamma Mother
+                  gammaMotherLabel=gammaMC->GetFirstMother();
+               }
             }
          }
+      }
+
+
+      Int_t virtualGammaMCLabel = TrueVirtualGammaCandidate->GetMCParticleLabel(MCStack);
+      Int_t virtualGammaMotherLabel = -1;
+      Int_t virtualGamma = 1;
 
+      if(virtualGammaMCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
+         // Daughters Gamma 1
+         TParticle * negativeMC = (TParticle*)TrueVirtualGammaCandidate->GetNegativeMCDaughter(MCStack);
+         TParticle * positiveMC = (TParticle*)TrueVirtualGammaCandidate->GetPositiveMCDaughter(MCStack);
+         TParticle * virtualGammaMotherMC = (TParticle*)MCStack->Particle(virtualGammaMCLabel);
 
-         if(gammaMotherLabel>=0 && ( gammaMotherLabel == virtualGammaMotherLabel) ){
+         if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){  // Electrons ...
 
-            if(((TParticle*)MCStack->Particle(virtualGammaMotherLabel))->GetPdgCode() == 111){
-               isTruePi0=kTRUE;
+            if( virtualGammaMotherMC->GetPdgCode() != 22 ){
+               virtualGammaMotherLabel=virtualGammaMCLabel;
             }
 
-            if(((TParticle*)MCStack->Particle(virtualGammaMotherLabel))->GetPdgCode() == 221){
-               isTrueEta=kTRUE;
+            else if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
+
+               virtualGammaMotherLabel=virtualGammaMotherMC->GetFirstMother();
+               virtualGamma = 0; //no virtual gamma
+
             }
+         }
+      }
+
+
+      if(gammaMotherLabel>=0 && ( gammaMotherLabel == virtualGammaMotherLabel) ){
 
+         if(((TParticle*)MCStack->Particle(virtualGammaMotherLabel))->GetPdgCode() == 111){
+            isTruePi0=kTRUE;
          }
 
-         if(isTruePi0 || isTrueEta ){ // True Pion or Eta
-            if ( virtualGamma == 1 ) { //True Dalitz
+         if(((TParticle*)MCStack->Particle(virtualGammaMotherLabel))->GetPdgCode() == 221){
+            isTrueEta=kTRUE;
+         }
+
+      }
+
+      if(isTruePi0 || isTrueEta ){ // True Pion or Eta
+         if ( virtualGamma == 1 ) { //True Dalitz
             hESDTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
             if(gammaMotherLabel <= MCStack->GetNprimary()){ // Only primary pi0 for efficiency calculation
                hESDTruePrimaryMotherInvMassMCPt[fiCut]->Fill(Pi0Candidate->M(),((TParticle*)MCStack->Particle(virtualGammaMotherLabel))->Pt());
@@ -1117,21 +1207,21 @@ void AliAnalysisTaskGammaConvDalitzV1::ProcessTrueMesonCandidates(AliAODConversi
                //   if(MCStack->Particle(((TParticle*)MCStack->Particle(virtualGammaMotherLabel))->GetMother(0))->GetPdgCode()==kK0Short){
                //      hESDTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
                //   }
-               }
-            }
-            else if ( virtualGamma == 0 ){
-              hESDTrueMotherPi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt()); // Pi0 from GG
             }
          }
-    
-        if(!isTruePi0 && !isTrueEta){ // Background
-            if(gammaMotherLabel>-1 && virtualGammaMotherLabel>-1 && virtualGamma == 0){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
-               hESDTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-            } else { // No photon or without mother
-               hESDTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-            } 
-        }
-    }
+         else if ( virtualGamma == 0 ){
+            hESDTrueMotherPi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt()); // Pi0 from GG
+         }
+      }
+
+      if(!isTruePi0 && !isTrueEta){ // Background
+         if(gammaMotherLabel>-1 && virtualGammaMotherLabel>-1 && virtualGamma == 0){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
+            hESDTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+         } else { // No photon or without mother
+            hESDTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+         }
+      }
+   }
 }
 //________________________________________________________________________
 void AliAnalysisTaskGammaConvDalitzV1::MoveParticleAccordingToVertex(AliAODConversionPhoton* particle,const AliGammaConversionAODBGHandler::GammaConversionVertex *vertex){
@@ -1179,44 +1269,82 @@ void AliAnalysisTaskGammaConvDalitzV1::ProcessMCParticles()
       TParticle* particle = (TParticle *)fMCStack->Particle(i);
       if (!particle) continue;
 
-     
-         if(((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelectedMCDalitz(particle,fMCStack)){
-            if(particle->GetPdgCode() == 111)hMCPi0Pt[fiCut]->Fill(particle->Pt()); // All MC Pi0
-            if(particle->GetPdgCode() == 221)hMCEtaPt[fiCut]->Fill(particle->Pt()); // All MC Eta
-            // Check the acceptance for both gammas
-            if(particle->GetNDaughters() == 3){
-               TParticle* gamma    = 0;
-               TParticle* electron = 0;
-               TParticle* positron = 0;
-              
-                 
-               for(Int_t index=particle->GetFirstDaughter(); index<= particle->GetLastDaughter();index++){
-               
-                       
-                    TParticle* temp = (TParticle*)fMCStack->Particle( index );
-
-                    switch( temp->GetPdgCode() ) {
-                                case ::kPositron:
-                                        electron = temp;
-                                        break;
-                                case ::kElectron:
-                                        positron = temp;
-                                        break;
-                                case ::kGamma:
-                                        gamma    = temp;
-                                        break;
-                        }
+
+
+     if(((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelectedMC(particle,fMCStack)){
+
+            if(particle->GetPdgCode() == 111)hMCPi0GGPt[fiCut]->Fill( particle->Pt() ); // All MC Pi0 GG decay
+            if(particle->GetPdgCode() == 221)hMCEtaGGPt[fiCut]->Fill( particle->Pt() ); // All MC Eta GG decay
+     }
+
+      if(((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelectedMCDalitz(particle,fMCStack)){
+         if(particle->GetPdgCode() == 111)hMCPi0Pt[fiCut]->Fill(particle->Pt()); // All MC Pi0
+         if(particle->GetPdgCode() == 221)hMCEtaPt[fiCut]->Fill(particle->Pt()); // All MC Eta
+         // Check the acceptance for both gammas
+         if(particle->GetNDaughters() == 3){
+            TParticle* gamma    = 0;
+            TParticle* electron = 0;
+            TParticle* positron = 0;
+
+
+            for(Int_t index=particle->GetFirstDaughter(); index<= particle->GetLastDaughter();index++){
+
+
+               TParticle* temp = (TParticle*)fMCStack->Particle( index );
+
+               switch( temp->GetPdgCode() ) {
+               case ::kPositron:
+                  electron = temp;
+                  break;
+               case ::kElectron:
+                  positron = temp;
+                  break;
+               case ::kGamma:
+                  gamma    = temp;
+                  break;
                }
-               if( gamma  && electron && positron ) {
+            }
+            if( gamma  && electron && positron ) {
 
-                 if(((AliConversionCuts*)fCutGammaArray->At(fiCut))->PhotonIsSelectedMC(gamma,fMCStack,kFALSE) &&
-                    TMath::Abs( electron->Eta() ) < ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetEtaCut()  &&
-                    TMath::Abs( positron->Eta() ) < ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetEtaCut() ){
+               if(((AliConversionCuts*)fCutGammaArray->At(fiCut))->PhotonIsSelectedMC(gamma,fMCStack,kFALSE) &&
+                  TMath::Abs( electron->Eta() ) < ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetEtaCut()  &&
+                  TMath::Abs( positron->Eta() ) < ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetEtaCut() ){
                   if(particle->GetPdgCode() == 111)hMCPi0InAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0Dalitz with gamma and e+e- in acc
                   if(particle->GetPdgCode() == 221)hMCEtaInAccPt[fiCut]->Fill(particle->Pt()); // MC EtaDalitz with gamma and e+e- in acc
                }
-              }
             }
          }
       }
+   }
+}
+//_____________________________________________________________________________
+Double_t AliAnalysisTaskGammaConvDalitzV1::GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg ) const
+{
+   //
+   // This angle is a measure for the contribution of the opening in polar
+   // direction Δ0 to the opening angle ξ Pair
+   //
+   // Ref. Measurement of photons via conversion pairs with the PHENIX experiment at RHIC
+   //      Master Thesis. Thorsten Dahms. 2005
+   // https://twiki.cern.ch/twiki/pub/ALICE/GammaPhysicsPublications/tdahms_thesis.pdf
+   //
+   Double_t momPos[3];
+   Double_t momNeg[3];
+   if( trackPos->GetConstrainedPxPyPz(momPos) == 0 ) trackPos->GetPxPyPz( momPos );
+   if( trackNeg->GetConstrainedPxPyPz(momNeg) == 0 ) trackNeg->GetPxPyPz( momNeg );
+
+   TVector3 posDaughter;
+   TVector3 negDaughter;
+
+   posDaughter.SetXYZ( momPos[0], momPos[1], momPos[2] );
+   negDaughter.SetXYZ( momNeg[0], momNeg[1], momNeg[2] );
+
+   Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta();
+   Double_t openingAngle =  posDaughter.Angle( negDaughter );  //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) );
+
+   if( openingAngle < 1e-20 ) return 0.;
+
+   Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle );
+
+   return psiAngle;
 }
index 1bcec15..cf2519a 100644 (file)
@@ -54,7 +54,6 @@ class AliAnalysisTaskGammaConvDalitzV1: public AliAnalysisTaskSE
 
        private:
 
-               void AddTaskContainers();
                void InitBack();
                void ProcessPhotonCandidates();
                void ProcessTruePhotonCandidates(AliAODConversionPhoton*);
@@ -66,6 +65,8 @@ class AliAnalysisTaskGammaConvDalitzV1: public AliAnalysisTaskSE
                 void CalculatePi0DalitzCandidates();
                 void CalculateBackground();
                 void UpdateEventByEventData();
+                Double_t GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg ) const;
+
                
                
 
@@ -97,12 +98,17 @@ class AliAnalysisTaskGammaConvDalitzV1: public AliAnalysisTaskSE
     TH1F **hESDDalitzElectronPt;
     TH1F **hESDDalitzPositronPt;
     TH2F **hESDEposEnegPsiPairDPhi;
+    TH2F **hESDEposEnegInvMassPt;
     TH2F **hESDMotherInvMassPt;
+    TH2F **hESDPi0MotherInvMassPt;
+    TH2F **hESDPi0MotherDiffInvMassPt;
     THnSparseF **sESDMotherInvMassPtZM;
     TH2F **hESDMotherBackInvMassPt;
     THnSparseF **sESDMotherBackInvMassPtZM;
     TH1F **hMCPi0Pt;
+    TH1F **hMCPi0GGPt;
     TH1F **hMCEtaPt;
+    TH1F **hMCEtaGGPt;
     TH1F **hMCPi0InAccPt;
     TH1F **hMCEtaInAccPt;
     TH2F **hESDTrueMotherInvMassPt;
index 871bd9e..5de8e58 100644 (file)
@@ -63,7 +63,7 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(): AliAnalysisTaskSE(),
    fHeaderNameList(NULL),
    fOutputContainer(0),
    fReaderGammas(NULL),
-   fGoodGammas(NULL),
+   fGammaCandidates(NULL),
    fCutArray(NULL),
    fConversionCuts(NULL),
    fMesonCutArray(NULL),
@@ -95,8 +95,10 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(): AliAnalysisTaskSE(),
    hMCEtaInAccPt(NULL),
    hESDTrueMotherInvMassPt(NULL),
    hESDTruePi0FromEtaInvMassPt(NULL),
+   hESDTruePrimaryMotherInvMassPt(NULL),
    hESDTruePrimaryMotherInvMassMCPt(NULL),
    hESDTruePrimaryPi0ESDPtMCPt(NULL),
+   hESDTruePrimaryEtaESDPtMCPt(NULL),
    hESDTrueSecondaryMotherInvMassPt(NULL),
    hESDTrueSecondaryMotherFromK0sInvMassPt(NULL),
    hESDTrueK0sWithPi0DaughterMCPt(NULL),
@@ -115,14 +117,12 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(): AliAnalysisTaskSE(),
    hESDTrueSecondaryConvGammaPt(NULL),
    hESDTrueSecondaryConvGammaR(NULL),
    hESDTrueSecondaryConvGammaFromXFromK0sPt(NULL),
-   hESDPi0Alpha(NULL),
-   hESDBackAlpha(NULL),
-   hESDTruePi0Alpha(NULL),
    hNEvents(NULL),
    hNGoodESDTracks(NULL),
+   hNGammaCandidates(NULL),
    hNV0Tracks(NULL),
    fRandom(0),
-   fnGoodGammas(0),
+   fnGammaCandidates(0),
    fUnsmearedPx(NULL),
    fUnsmearedPy(NULL),
    fUnsmearedPz(NULL),
@@ -133,11 +133,9 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(): AliAnalysisTaskSE(),
    fMoveParticleAccordingToVertex(kTRUE),
    fIsHeavyIon(kFALSE),
    fDoMesonAnalysis(kTRUE),
-   fIsFromBGEvent(kFALSE)
+   fIsFromMBHeader(kTRUE)
 {
-   // default Constructor
-   DefineInput(0, TChain::Class());
-   DefineOutput(1, TList::Class());
+
 }
 
 //________________________________________________________________________
@@ -158,7 +156,7 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(const char *name):
    fHeaderNameList(NULL),
    fOutputContainer(0),
    fReaderGammas(NULL),
-   fGoodGammas(NULL),
+   fGammaCandidates(NULL),
    fCutArray(NULL),
    fConversionCuts(NULL),
    fMesonCutArray(NULL),
@@ -190,8 +188,10 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(const char *name):
    hMCEtaInAccPt(NULL),
    hESDTrueMotherInvMassPt(NULL),
    hESDTruePi0FromEtaInvMassPt(NULL),
+   hESDTruePrimaryMotherInvMassPt(NULL),
    hESDTruePrimaryMotherInvMassMCPt(NULL),
    hESDTruePrimaryPi0ESDPtMCPt(NULL),
+   hESDTruePrimaryEtaESDPtMCPt(NULL),
    hESDTrueSecondaryMotherInvMassPt(NULL),
    hESDTrueSecondaryMotherFromK0sInvMassPt(NULL),
    hESDTrueK0sWithPi0DaughterMCPt(NULL),
@@ -210,14 +210,12 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(const char *name):
    hESDTrueSecondaryConvGammaPt(NULL),
    hESDTrueSecondaryConvGammaR(NULL),
    hESDTrueSecondaryConvGammaFromXFromK0sPt(NULL),
-   hESDPi0Alpha(NULL),
-   hESDBackAlpha(NULL),
-   hESDTruePi0Alpha(NULL),
    hNEvents(NULL),
    hNGoodESDTracks(NULL),
+   hNGammaCandidates(NULL),
    hNV0Tracks(NULL),
    fRandom(0),
-   fnGoodGammas(0),
+   fnGammaCandidates(0),
    fUnsmearedPx(NULL),
    fUnsmearedPy(NULL),
    fUnsmearedPz(NULL),
@@ -228,18 +226,17 @@ AliAnalysisTaskGammaConvV1::AliAnalysisTaskGammaConvV1(const char *name):
    fMoveParticleAccordingToVertex(kTRUE),
    fIsHeavyIon(kFALSE),
    fDoMesonAnalysis(kTRUE),
-   fIsFromBGEvent(kFALSE)
+   fIsFromMBHeader(kTRUE)
 {
-   // Define input and output slots here
-   DefineInput(0, TChain::Class());
+   // Define output slots here
    DefineOutput(1, TList::Class());
 }
 
 AliAnalysisTaskGammaConvV1::~AliAnalysisTaskGammaConvV1()
 {
-   if(fGoodGammas){
-      delete fGoodGammas;
-      fGoodGammas = 0x0;
+   if(fGammaCandidates){
+      delete fGammaCandidates;
+      fGammaCandidates = 0x0;
    }
    if(fBGHandler){
       delete[] fBGHandler;
@@ -351,6 +348,7 @@ void AliAnalysisTaskGammaConvV1::InitBack(){
 //________________________________________________________________________
 void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
 {
+   TH1::SetDefaultSumw2(kTRUE);
 
    // Create histograms
    if(fOutputContainer != NULL){
@@ -363,7 +361,7 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
    }
 
    // Array of current cut's gammas
-   fGoodGammas = new TList();
+   fGammaCandidates = new TList();
 
    fCutFolder = new TList*[fnCuts];
    fESDList = new TList*[fnCuts];
@@ -373,15 +371,13 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
    hESDConvGammaR = new TH1F*[fnCuts];
    hNEvents = new TH1I*[fnCuts];
    hNGoodESDTracks = new TH1I*[fnCuts];
+   hNGammaCandidates = new TH1I*[fnCuts];
    hNV0Tracks = new TH1I*[fnCuts];
 
    if(fDoMesonAnalysis){
       hESDMotherInvMassPt = new TH2F*[fnCuts];
       hESDMotherBackInvMassPt = new TH2F*[fnCuts];
       hESDMotherInvMassEalpha = new TH2F*[fnCuts];
-
-      hESDPi0Alpha = new TH1F*[fnCuts];
-      hESDBackAlpha = new TH1F*[fnCuts];
    }
    for(Int_t iCut = 0; iCut<fnCuts;iCut++){
 
@@ -395,6 +391,7 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
       fESDList[iCut] = new TList();
       fESDList[iCut]->SetName(Form("%s_%s ESD histograms",cutstring.Data(),cutstringMeson.Data()));
       fESDList[iCut]->SetOwner(kTRUE);
+      fCutFolder[iCut]->Add(fESDList[iCut]);
 
       hNEvents[iCut] = new TH1I("NEvents","NEvents",9,-0.5,8.5);
       hNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
@@ -410,6 +407,9 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
       if(fIsHeavyIon) hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
       else hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
       fESDList[iCut]->Add(hNGoodESDTracks[iCut]);
+      if(fIsHeavyIon) hNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",100,0,100);
+      else hNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",50,0,50);
+      fESDList[iCut]->Add(hNGammaCandidates[iCut]);
       if(fIsHeavyIon) hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
       else hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",2000,0,2000);
       fESDList[iCut]->Add(hNV0Tracks[iCut]);
@@ -426,14 +426,8 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
          fESDList[iCut]->Add(hESDMotherBackInvMassPt[iCut]);
          hESDMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha","ESD_Mother_InvMass_vs_E_alpha",800,0,0.8,250,0,25);
          fESDList[iCut]->Add(hESDMotherInvMassEalpha[iCut]);
-
-         hESDPi0Alpha[iCut] = new TH1F("ESD_Mother_Alpha_inPi0MassRange","ESD_Mother_Alpha_inPi0MassRange",100,0,1);
-         fESDList[iCut]->Add(hESDPi0Alpha[iCut]);
-         hESDBackAlpha[iCut] = new TH1F("ESD_Back_Alpha_inPi0MassRange","ESD_Back_Alpha_inPi0MassRange",100,0,1);
-         fESDList[iCut]->Add(hESDBackAlpha[iCut]);
       }
 
-      fCutFolder[iCut]->Add(fESDList[iCut]);
    }
    if(fDoMesonAnalysis){
       InitBack(); // Init Background Handler
@@ -479,9 +473,10 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
          hMCPi0InAccPt = new TH1F*[fnCuts];
          hMCEtaInAccPt = new TH1F*[fnCuts];
 
-         hESDTruePi0Alpha = new TH1F*[fnCuts];
          hESDTrueMotherInvMassPt = new TH2F*[fnCuts];
          hESDTruePrimaryPi0ESDPtMCPt = new TH2F*[fnCuts];
+         hESDTruePrimaryEtaESDPtMCPt = new TH2F*[fnCuts];
+         hESDTruePrimaryMotherInvMassPt = new TH2F*[fnCuts];
          hESDTruePrimaryMotherInvMassMCPt = new TH2F*[fnCuts];
          hESDTrueSecondaryMotherInvMassPt = new TH2F*[fnCuts];
          hESDTrueSecondaryMotherFromK0sInvMassPt = new TH2F*[fnCuts];
@@ -592,9 +587,14 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
             fTrueList[iCut]->Add(hESDTrueMotherInvMassPt[iCut]);
             hESDTruePrimaryPi0ESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryPi0_ESDPt_MCPt","ESD_TruePrimaryPi0_ESDPt_MCPt",250,0,25,250,0,25);
             fTrueList[iCut]->Add(hESDTruePrimaryPi0ESDPtMCPt[iCut]);
+            hESDTruePrimaryEtaESDPtMCPt[iCut]  = new TH2F("ESD_TruePrimaryPi0_ESDPt_MCPt","ESD_TruePrimaryPi0_ESDPt_MCPt",250,0,25,250,0,25);
+            fTrueList[iCut]->Add(hESDTruePrimaryEtaESDPtMCPt[iCut]);
             hESDTruePrimaryMotherInvMassMCPt[iCut]
                = new TH2F("ESD_TruePrimaryMother_InvMass_MCPt", "ESD_TruePrimaryMother_InvMass_MCPt", 800,0,0.8,250,0,25);
             fTrueList[iCut]->Add(hESDTruePrimaryMotherInvMassMCPt[iCut]);
+            hESDTruePrimaryMotherInvMassPt[iCut]
+               = new TH2F("ESD_TruePrimaryMother_InvMass_Pt", "ESD_TruePrimaryMother_InvMass_Pt", 800,0,0.8,250,0,25);
+            fTrueList[iCut]->Add(hESDTruePrimaryMotherInvMassPt[iCut]);
             hESDTrueSecondaryMotherInvMassPt[iCut]
                = new TH2F("ESD_TrueSecondaryMother_InvMass_Pt", "ESD_TrueSecondaryMother_InvMass_Pt", 800,0,0.8,250,0,25);
             fTrueList[iCut]->Add(hESDTrueSecondaryMotherInvMassPt[iCut]);
@@ -614,14 +614,33 @@ void AliAnalysisTaskGammaConvV1::UserCreateOutputObjects()
             fTrueList[iCut]->Add(hESDTrueBckContInvMassPt[iCut]);
             hESDTrueMotherDalitzInvMassPt[iCut] = new TH2F("ESD_TrueDalitz_InvMass_Pt","ESD_TrueDalitz_InvMass_Pt",800,0,0.8,250,0,25);
             fTrueList[iCut]->Add(hESDTrueMotherDalitzInvMassPt[iCut]);
-            hESDTruePi0Alpha[iCut] = new TH1F("ESD_TruePi0_Alpha","ESD_TruePi0_Alpha",100,0,1);
-            fTrueList[iCut]->Add(hESDTruePi0Alpha[iCut]);
          }
+      }
+   }
+
+
+
+   fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
+   if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
 
+   if(fV0Reader)
+      if((AliConversionCuts*)fV0Reader->GetConversionCuts())
+         if(((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
+            fOutputContainer->Add(((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
 
+   for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+      if(!((AliConversionCuts*)fCutArray->At(iCut))) continue;
+      if(((AliConversionCuts*)fCutArray->At(iCut))->GetCutHistograms()){
+         fCutFolder[iCut]->Add(((AliConversionCuts*)fCutArray->At(iCut))->GetCutHistograms());
+      }
+      if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
+      if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
+         fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
       }
    }
 
+   TH1::SetDefaultSumw2(kFALSE);
+
    PostData(1, fOutputContainer);
 }
 
@@ -631,9 +650,6 @@ void AliAnalysisTaskGammaConvV1::UserExec(Option_t *)
    //
    // Called for each event
    //
-   fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
-   if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
-
    Int_t eventQuality = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetEventQuality();
    if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1
       for(Int_t iCut = 0; iCut<fnCuts; iCut++){
@@ -660,19 +676,18 @@ void AliAnalysisTaskGammaConvV1::UserExec(Option_t *)
          ((AliConversionCuts*)fCutArray->At(iCut))
          ->IsEventAcceptedByConversionCut(fV0Reader->GetConversionCuts(),fInputEvent,fMCEvent,fIsHeavyIon);
       if(eventNotAccepted){
-         // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
+         //                    cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
          hNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
          continue;
       }
 
       if(eventQuality != 0){// Event Not Accepted
-         //                    cout << "event rejected due to: " <<eventQuality << endl;
+         //          cout << "event rejected due to: " <<eventQuality << endl;
          hNEvents[iCut]->Fill(eventQuality);
          continue;
       }
-      
-      hNEvents[iCut]->Fill(eventQuality); // Should be 0 here
 
+      hNEvents[iCut]->Fill(eventQuality); // Should be 0 here
       hNGoodESDTracks[iCut]->Fill(fNumberOfESDTracks);
       hNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
 
@@ -684,22 +699,23 @@ void AliAnalysisTaskGammaConvV1::UserExec(Option_t *)
          }
          ProcessMCParticles();
       }
-      
+
       ProcessPhotonCandidates(); // Process this cuts gammas
 
+      hNGammaCandidates[iCut]->Fill(fGammaCandidates->GetEntries());
       if(fDoMesonAnalysis){ // Meson Analysis
          if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fMCEvent){
-            fUnsmearedPx = new Double_t[fGoodGammas->GetEntries()]; // Store unsmeared Momenta
-            fUnsmearedPy = new Double_t[fGoodGammas->GetEntries()];
-            fUnsmearedPz = new Double_t[fGoodGammas->GetEntries()];
-            fUnsmearedE =  new Double_t[fGoodGammas->GetEntries()];
-
-            for(Int_t gamma=0;gamma<fGoodGammas->GetEntries();gamma++){ // Smear the AODPhotons in MC
-               fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->Px();
-               fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->Py();
-               fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->Pz();
-               fUnsmearedE[gamma] =  ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->E();
-               ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(gamma)));
+            fUnsmearedPx = new Double_t[fGammaCandidates->GetEntries()]; // Store unsmeared Momenta
+            fUnsmearedPy = new Double_t[fGammaCandidates->GetEntries()];
+            fUnsmearedPz = new Double_t[fGammaCandidates->GetEntries()];
+            fUnsmearedE =  new Double_t[fGammaCandidates->GetEntries()];
+
+            for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
+               fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Px();
+               fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Py();
+               fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Pz();
+               fUnsmearedE[gamma] =  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->E();
+               ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(gamma)));
             }
          }
 
@@ -711,15 +727,15 @@ void AliAnalysisTaskGammaConvV1::UserExec(Option_t *)
             }
             else{
                CalculateBackgroundRP(); // Combinatorial Background
-               fBGHandlerRP[iCut]->AddEvent(fGoodGammas,fInputEvent); // Store Event for mixed Events
+               fBGHandlerRP[iCut]->AddEvent(fGammaCandidates,fInputEvent); // Store Event for mixed Events
             }
          }
          if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fMCEvent){
-            for(Int_t gamma=0;gamma<fGoodGammas->GetEntries();gamma++){ // Smear the AODPhotons in MC
-               ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
-               ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->SetPy(fUnsmearedPy[gamma]);
-               ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->SetPz(fUnsmearedPz[gamma]);
-               ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->SetE(fUnsmearedE[gamma]);
+            for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
+               ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
+               ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPy(fUnsmearedPy[gamma]);
+               ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPz(fUnsmearedPz[gamma]);
+               ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetE(fUnsmearedE[gamma]);
             }
             delete[] fUnsmearedPx; fUnsmearedPx = 0x0;
             delete[] fUnsmearedPy; fUnsmearedPy = 0x0;
@@ -727,7 +743,7 @@ void AliAnalysisTaskGammaConvV1::UserExec(Option_t *)
             delete[] fUnsmearedE;  fUnsmearedE  = 0x0;
          }
       }
-      fGoodGammas->Clear(); // delete this cuts good gammas
+      fGammaCandidates->Clear(); // delete this cuts good gammas
 
    }
 
@@ -737,30 +753,30 @@ void AliAnalysisTaskGammaConvV1::UserExec(Option_t *)
 void AliAnalysisTaskGammaConvV1::ProcessPhotonCandidates()
 {
    Int_t nV0 = 0;
-   TList *GoodGammasStepOne = new TList();
-   TList *GoodGammasStepTwo = new TList();
+   TList *GammaCandidatesStepOne = new TList();
+   TList *GammaCandidatesStepTwo = new TList();
    // Loop over Photon Candidates allocated by ReaderV1
    for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
       AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
       if(!PhotonCandidate) continue;
-      fIsFromBGEvent = kFALSE;
+      fIsFromMBHeader = kTRUE;
       if(fMCEvent && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
-         if(!((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack)){
-            if(((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
-            fIsFromBGEvent = kTRUE;
-         }
-         if(!((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack)){
-            if(((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
-            fIsFromBGEvent = kTRUE;
-         }
+         Int_t isPosFromMBHeader
+            = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack);
+         if(isPosFromMBHeader == 0 && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
+         Int_t isNegFromMBHeader
+            = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack);
+         if(isNegFromMBHeader == 0 && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
+
+         if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
       }
 
       if(!((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
       if(!((AliConversionCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
          !((AliConversionCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
-         fGoodGammas->Add(PhotonCandidate); // if no second loop is required add to events good gammas
+         fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
 
-         if(!fIsFromBGEvent){
+         if(fIsFromMBHeader){
             hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
             hESDConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
          }
@@ -771,30 +787,29 @@ void AliAnalysisTaskGammaConvV1::ProcessPhotonCandidates()
       else if(((AliConversionCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
          ((AliConversionCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
          nV0++;
-         GoodGammasStepOne->Add(PhotonCandidate);
+         GammaCandidatesStepOne->Add(PhotonCandidate);
       }
       else if(!((AliConversionCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
               ((AliConversionCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
-         GoodGammasStepTwo->Add(PhotonCandidate);
+         GammaCandidatesStepTwo->Add(PhotonCandidate);
       }
    }
    if(((AliConversionCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
-      for(Int_t i = 0;i<GoodGammasStepOne->GetEntries();i++){
-         AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GoodGammasStepOne->At(i);
+      for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
+         AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
          if(!PhotonCandidate) continue;
-         fIsFromBGEvent = kFALSE;
+         fIsFromMBHeader = kTRUE;
          if(fMCEvent && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
-            if(!((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack)){
-               fIsFromBGEvent = kTRUE;
-            }
-            if(!((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack)){
-               fIsFromBGEvent = kTRUE;
-            }
+            Int_t isPosFromMBHeader
+               = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack);
+            Int_t isNegFromMBHeader
+               = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack);
+            if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
          }
-         if(!((AliConversionCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GoodGammasStepOne->GetEntries())) continue;
+         if(!((AliConversionCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
          if(!((AliConversionCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
-            fGoodGammas->Add(PhotonCandidate);
-            if(!fIsFromBGEvent){
+            fGammaCandidates->Add(PhotonCandidate);
+            if(fIsFromMBHeader){
                hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
                hESDConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
             }
@@ -802,25 +817,24 @@ void AliAnalysisTaskGammaConvV1::ProcessPhotonCandidates()
                ProcessTruePhotonCandidates(PhotonCandidate);
             }
          }
-         else GoodGammasStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
+         else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
       }
    }
    if(((AliConversionCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
-      for(Int_t i = 0;i<GoodGammasStepTwo->GetEntries();i++){
-         AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GoodGammasStepTwo->At(i);
+      for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
+         AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
          if(!PhotonCandidate) continue;
-         fIsFromBGEvent = kFALSE;
+         fIsFromMBHeader = kTRUE;
          if(fMCEvent && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
-            if(!((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack)){
-               fIsFromBGEvent = kTRUE;
-            }
-            if(!((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack)){
-               fIsFromBGEvent = kTRUE;
-            }
+            Int_t isPosFromMBHeader
+               = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack);
+            Int_t isNegFromMBHeader
+               = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack);
+            if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
          }
-         if(!((AliConversionCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GoodGammasStepTwo,i)) continue;
-         fGoodGammas->Add(PhotonCandidate); // Add gamma to current cut TList
-         if(!fIsFromBGEvent){
+         if(!((AliConversionCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
+         fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
+         if(fIsFromMBHeader){
             hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
             hESDConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
          }
@@ -830,10 +844,10 @@ void AliAnalysisTaskGammaConvV1::ProcessPhotonCandidates()
       }
    }
 
-   delete GoodGammasStepOne;
-   GoodGammasStepOne = 0x0;
-   delete GoodGammasStepTwo;
-   GoodGammasStepTwo = 0x0;
+   delete GammaCandidatesStepOne;
+   GammaCandidatesStepOne = 0x0;
+   delete GammaCandidatesStepTwo;
+   GammaCandidatesStepTwo = 0x0;
 
 }
 //________________________________________________________________________
@@ -850,61 +864,61 @@ void AliAnalysisTaskGammaConvV1::ProcessTruePhotonCandidates(AliAODConversionPho
 
    if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
       // Combinatorial Bck = 0 ee, 1 ep,i 2 ek, 3 ep, 4 emu, 5 pipi, 6 pik, 7 pip, 8 pimu, 9 kk, 10 kp, 11 kmu, 12 pp, 13 pmu, 14 mumu, 15 Rest
-      if(pdgCode[0]==11   && pdgCode[1]==11){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0);}
+      if(pdgCode[0]==11   && pdgCode[1]==11){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0);}
       else if( (pdgCode[0]==11   && pdgCode[1]==211) || (pdgCode[0]==211  && pdgCode[1]==11) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1);}
       else if( (pdgCode[0]==11   && pdgCode[1]==321) || (pdgCode[0]==321  && pdgCode[1]==11) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2);}
       else if( (pdgCode[0]==11   && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==11) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3);}
       else if( (pdgCode[0]==11   && pdgCode[1]==13) || (pdgCode[0]==13   && pdgCode[1]==11) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4);}
-      else if(  pdgCode[0]==211  && pdgCode[1]==211 ){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),5);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4);}
+      else if(  pdgCode[0]==211  && pdgCode[1]==211 ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),5);}
       else if( (pdgCode[0]==211  && pdgCode[1]==321) || (pdgCode[0]==321  && pdgCode[1]==211) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),6);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),6);}
       else if( (pdgCode[0]==211  && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==211) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),7);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),7);}
       else if( (pdgCode[0]==211  && pdgCode[1]==13) || (pdgCode[0]==13   && pdgCode[1]==211) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),8);}
-      else if(  pdgCode[0]==321  && pdgCode[1]==321 ){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),9);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),8);}
+      else if(  pdgCode[0]==321  && pdgCode[1]==321 ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),9);}
       else if( (pdgCode[0]==321  && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==321) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),10);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),10);}
       else if( (pdgCode[0]==321  && pdgCode[1]==13) || (pdgCode[0]==13   && pdgCode[1]==321) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),11);}
-      else if(  pdgCode[0]==2212   && pdgCode[1]==2212  ){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),12);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),11);}
+      else if(  pdgCode[0]==2212   && pdgCode[1]==2212  ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),12);}
       else if( (pdgCode[0]==2212  && pdgCode[1]==13) || (pdgCode[0]==13   && pdgCode[1]==2212) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),13);}
-      else if(  pdgCode[0]==13   && pdgCode[1]==13  ){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),14);}
-      else {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),15);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),13);}
+      else if(  pdgCode[0]==13   && pdgCode[1]==13  ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),14);}
+      else {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),15);}
       return;
    }
    else if(posDaughter->GetMother(0) == -1){
-      if(pdgCode[0]==11   && pdgCode[1]==11){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0);}
+      if(pdgCode[0]==11   && pdgCode[1]==11){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0);}
       else if( (pdgCode[0]==11   && pdgCode[1]==211) || (pdgCode[0]==211  && pdgCode[1]==11) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1);}
       else if( (pdgCode[0]==11   && pdgCode[1]==321) || (pdgCode[0]==321  && pdgCode[1]==11) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2);}
       else if( (pdgCode[0]==11   && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==11) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3);}
       else if( (pdgCode[0]==11   && pdgCode[1]==13) || (pdgCode[0]==13   && pdgCode[1]==11) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4);}
-      else if(  pdgCode[0]==211  && pdgCode[1]==211 ){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),5);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4);}
+      else if(  pdgCode[0]==211  && pdgCode[1]==211 ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),5);}
       else if( (pdgCode[0]==211  && pdgCode[1]==321) || (pdgCode[0]==321  && pdgCode[1]==211) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),6);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),6);}
       else if( (pdgCode[0]==211  && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==211) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),7);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),7);}
       else if( (pdgCode[0]==211  && pdgCode[1]==13) || (pdgCode[0]==13   && pdgCode[1]==211) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),8);}
-      else if(  pdgCode[0]==321  && pdgCode[1]==321 ){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),9);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),8);}
+      else if(  pdgCode[0]==321  && pdgCode[1]==321 ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),9);}
       else if( (pdgCode[0]==321  && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==321) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),10);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),10);}
       else if( (pdgCode[0]==321  && pdgCode[1]==13) || (pdgCode[0]==13   && pdgCode[1]==321) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),11);}
-      else if(  pdgCode[0]==2212   && pdgCode[1]==2212  ){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),12);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),11);}
+      else if(  pdgCode[0]==2212   && pdgCode[1]==2212  ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),12);}
       else if( (pdgCode[0]==2212  && pdgCode[1]==13) || (pdgCode[0]==13   && pdgCode[1]==2212) )
-         {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),13);}
-      else if(  pdgCode[0]==13   && pdgCode[1]==13  ){if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),14);}
-      else {if(!fIsFromBGEvent)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),15);}
+         {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),13);}
+      else if(  pdgCode[0]==13   && pdgCode[1]==13  ){if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),14);}
+      else {if(fIsFromMBHeader)hESDCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),15);}
       return;
    }
 
@@ -918,11 +932,11 @@ void AliAnalysisTaskGammaConvV1::ProcessTruePhotonCandidates(AliAODConversionPho
    if(Photon->GetPdgCode() != 22) return; // Mother is no Photon
 
    // True Photon
-   if(!fIsFromBGEvent)hESDTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+   if(fIsFromMBHeader)hESDTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
 
    if(posDaughter->GetMother(0) <= MCStack->GetNprimary()){
       // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
-      if(!fIsFromBGEvent){
+      if(fIsFromMBHeader){
          hESDTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
          hESDTruePrimaryConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius());
          hESDTruePrimaryConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta());
@@ -932,7 +946,7 @@ void AliAnalysisTaskGammaConvV1::ProcessTruePhotonCandidates(AliAODConversionPho
       // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
    }
    else{
-      if(!fIsFromBGEvent){
+      if(fIsFromMBHeader){
          hESDTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
          hESDTrueSecondaryConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius());
          if(MCStack->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
@@ -950,12 +964,13 @@ void AliAnalysisTaskGammaConvV1::ProcessMCParticles()
       TParticle* particle = (TParticle *)fMCStack->Particle(i);
       if (!particle) continue;
 
-      Bool_t mcIsFromBG = kFALSE;
+      Bool_t mcIsFromMB = kTRUE;
+      Int_t isMCFromMBHeader = -1;
       if(((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 0){
-         if(!((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack)){
-            if(((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
-            mcIsFromBG = kTRUE;
-         }
+         isMCFromMBHeader
+            = ((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack);
+         if(isMCFromMBHeader == 0 && ((AliConversionCuts*)fCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
+         if(isMCFromMBHeader != 2) mcIsFromMB = kFALSE;
       }
 
       if(((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCStack,kFALSE)){
@@ -981,7 +996,7 @@ void AliAnalysisTaskGammaConvV1::ProcessMCParticles()
                hMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
                break;
             case 3212: // Sigma
-               hMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
+               hMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt());
                break;
             }
          }
@@ -990,7 +1005,7 @@ void AliAnalysisTaskGammaConvV1::ProcessMCParticles()
          hMCConvGammaPt[fiCut]->Fill(particle->Pt());
          hMCConvGammaR[fiCut]->Fill(((TParticle*)fMCStack->Particle(particle->GetFirstDaughter()))->R());
          hMCConvGammaEta[fiCut]->Fill(particle->Eta());
-         if(!mcIsFromBG){
+         if(mcIsFromMB){
             hMCConvGammaRSPt[fiCut]->Fill(particle->Pt());
             hMCConvGammaRSR[fiCut]->Fill(((TParticle*)fMCStack->Particle(particle->GetFirstDaughter()))->R());
             hMCConvGammaRSEta[fiCut]->Fill(particle->Eta());
@@ -1001,14 +1016,26 @@ void AliAnalysisTaskGammaConvV1::ProcessMCParticles()
             TParticle* daughter0 = (TParticle*)fMCStack->Particle(particle->GetFirstDaughter());
             TParticle* daughter1 = (TParticle*)fMCStack->Particle(particle->GetLastDaughter());
 
-            if(particle->GetPdgCode() == 111)hMCPi0Pt[fiCut]->Fill(particle->Pt()); // All MC Pi0
-            else if(particle->GetPdgCode() == 221)hMCEtaPt[fiCut]->Fill(particle->Pt()); // All MC Eta
+            Float_t weighted= 1;
+            if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack)){
+               if (particle->Pt()>0.005){
+                  weighted= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack);
+               }
+            }
+            if(particle->GetPdgCode() == 111){
+               hMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
+            } else if(particle->GetPdgCode() == 221){
+               hMCEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
+            }
 
             // Check the acceptance for both gammas
             if(((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCStack,kFALSE) &&
                ((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCStack,kFALSE) ){
-               if(particle->GetPdgCode() == 111)hMCPi0InAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc
-               else if(particle->GetPdgCode() == 221)hMCEtaInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc
+               if(particle->GetPdgCode() == 111){
+                  hMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Pi0 with gamma in acc
+               } else if(particle->GetPdgCode() == 221){
+                  hMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Eta with gamma in acc
+               }
             }
          }
       }
@@ -1018,11 +1045,11 @@ void AliAnalysisTaskGammaConvV1::ProcessMCParticles()
 void AliAnalysisTaskGammaConvV1::CalculatePi0Candidates(){
 
    // Conversion Gammas
-   if(fGoodGammas->GetEntries()>1){
-      for(Int_t firstGammaIndex=0;firstGammaIndex<fGoodGammas->GetEntries()-1;firstGammaIndex++){
-         AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(firstGammaIndex));
-         for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGoodGammas->GetEntries();secondGammaIndex++){
-            AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(secondGammaIndex));
+   if(fGammaCandidates->GetEntries()>1){
+      for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries()-1;firstGammaIndex++){
+         AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
+         for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
+            AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
             //Check for same Electron ID
             if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
                gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
@@ -1034,21 +1061,20 @@ void AliAnalysisTaskGammaConvV1::CalculatePi0Candidates(){
 
             if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE))){
                hESDMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
-               if(pi0cand->M()>0.1 && pi0cand->M()<0.15)hESDPi0Alpha[fiCut]->Fill(pi0cand->GetAlpha());
 
                if(pi0cand->GetAlpha()<0.1)
                   hESDMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
-               
+
                if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
                   Int_t zbin = 0;
                   Int_t mbin = 0;
-                  
+
                   if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
                      zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
                      if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
                         mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fNumberOfESDTracks);
                      } else {
-                        mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
+                        mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
                      }
                   }
                   else{
@@ -1056,7 +1082,7 @@ void AliAnalysisTaskGammaConvV1::CalculatePi0Candidates(){
                      if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
                         mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fNumberOfESDTracks);
                      } else {
-                        mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
+                        mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
                      }
                   }
                   Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
@@ -1134,7 +1160,6 @@ void AliAnalysisTaskGammaConvV1::ProcessTrueMesonCandidates(AliAODConversionMoth
          }
          if(isTruePi0 || isTrueEta){// True Pion or Eta
             hESDTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-            if(Pi0Candidate->M()>0.1 && Pi0Candidate->M()<0.15)hESDTruePi0Alpha[fiCut]->Fill(Pi0Candidate->GetAlpha());
 
             if(gamma0MotherLabel >= MCStack->GetNprimary()){ // Secondary Meson
                hESDTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
@@ -1152,9 +1177,19 @@ void AliAnalysisTaskGammaConvV1::ProcessTrueMesonCandidates(AliAODConversionMoth
                }
             }
             else{ // Only primary pi0 for efficiency calculation
-               hESDTruePrimaryMotherInvMassMCPt[fiCut]->Fill(Pi0Candidate->M(),((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt());
-               if(isTruePi0){ // Only primaries for unfolding
-                  hESDTruePrimaryPi0ESDPtMCPt[fiCut]->Fill(Pi0Candidate->Pt(),((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt());
+               Float_t weighted= 1;
+               if(((AliConversionCuts*)fCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCStack)){
+                  if (((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt()>0.005){
+                     weighted= ((AliConversionCuts*)fCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, fMCStack);
+                  }
+               }
+               hESDTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
+               hESDTruePrimaryMotherInvMassMCPt[fiCut]->Fill(Pi0Candidate->M(),((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
+               if(isTruePi0){ // Only primary pi0 for unfolding
+                  hESDTruePrimaryPi0ESDPtMCPt[fiCut]->Fill(Pi0Candidate->Pt(),((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
+               }
+               if (isTrueEta){ // Only primary eta for unfolding
+                  hESDTruePrimaryEtaESDPtMCPt[fiCut]->Fill(Pi0Candidate->Pt(),((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
                }
             }
          }
@@ -1182,16 +1217,16 @@ void AliAnalysisTaskGammaConvV1::CalculateBackground(){
    if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
       mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fNumberOfESDTracks);
    } else {
-      mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
+      mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
    }
 
    if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
 
-      for(Int_t iCurrent=0;iCurrent<fGoodGammas->GetEntries();iCurrent++){
-         AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodGammas->At(iCurrent));
-         for(Int_t iCurrent2=iCurrent+1;iCurrent2<fGoodGammas->GetEntries();iCurrent2++){
+      for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
+         AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
+         for(Int_t iCurrent2=iCurrent+1;iCurrent2<fGammaCandidates->GetEntries();iCurrent2++){
             for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
-               AliAODConversionPhoton currentEventGoodV02 = *(AliAODConversionPhoton*)(fGoodGammas->At(iCurrent2));
+               AliAODConversionPhoton currentEventGoodV02 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent2));
 
                if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGProbability()){
                   AliAODConversionMother *backgroundCandidateProb = new AliAODConversionMother(&currentEventGoodV0,&currentEventGoodV02);
@@ -1212,8 +1247,6 @@ void AliAnalysisTaskGammaConvV1::CalculateBackground(){
                   hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
                   Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
                   sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
-                  if(backgroundCandidate->M()>0.1 && backgroundCandidate->M()<0.15)
-                     hESDBackAlpha[fiCut]->Fill(backgroundCandidate->GetAlpha());
                }
                delete backgroundCandidate;
                backgroundCandidate = 0x0;
@@ -1230,8 +1263,8 @@ void AliAnalysisTaskGammaConvV1::CalculateBackground(){
                bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
             }
 
-            for(Int_t iCurrent=0;iCurrent<fGoodGammas->GetEntries();iCurrent++){
-               AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodGammas->At(iCurrent));
+            for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
+               AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
                for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
                   AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
                   if(fMoveParticleAccordingToVertex == kTRUE){
@@ -1243,8 +1276,6 @@ void AliAnalysisTaskGammaConvV1::CalculateBackground(){
                      hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
                      Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
                      sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
-                     if(backgroundCandidate->M()>0.1 && backgroundCandidate->M()<0.15)
-                        hESDBackAlpha[fiCut]->Fill(backgroundCandidate->GetAlpha());
                   }
                   delete backgroundCandidate;
                   backgroundCandidate = 0x0;
@@ -1259,8 +1290,8 @@ void AliAnalysisTaskGammaConvV1::CalculateBackground(){
                if(fMoveParticleAccordingToVertex == kTRUE){
                   bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
                }
-               for(Int_t iCurrent=0;iCurrent<fGoodGammas->GetEntries();iCurrent++){
-                  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodGammas->At(iCurrent));
+               for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
+                  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
                   for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
 
                      AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
@@ -1275,8 +1306,6 @@ void AliAnalysisTaskGammaConvV1::CalculateBackground(){
                         hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
                         Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
                         sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
-                        if(backgroundCandidate->M()>0.1 && backgroundCandidate->M()<0.15)
-                           hESDBackAlpha[fiCut]->Fill(backgroundCandidate->GetAlpha());
                      }
                      delete backgroundCandidate;
                      backgroundCandidate = 0x0;
@@ -1295,7 +1324,7 @@ void AliAnalysisTaskGammaConvV1::CalculateBackgroundRP(){
    if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
       mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fNumberOfESDTracks);
    } else {
-      mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
+      mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
    }
 
 
@@ -1305,12 +1334,12 @@ void AliAnalysisTaskGammaConvV1::CalculateBackgroundRP(){
       // BG is for rotation the same, except for factor NRotations
       Double_t weight=1./Double_t(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents());
 
-      for(Int_t firstGammaIndex=0;firstGammaIndex<fGoodGammas->GetEntries();firstGammaIndex++){
+      for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
 
-         AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(firstGammaIndex));
+         AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
 
-         for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGoodGammas->GetEntries();secondGammaIndex++){
-            AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(secondGammaIndex));
+         for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
+            AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
             if(!((AliConversionCuts*)fCutArray->At(fiCut))->PhotonIsSelected(gamma1,fInputEvent))continue;
             for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
 
@@ -1322,8 +1351,6 @@ void AliAnalysisTaskGammaConvV1::CalculateBackgroundRP(){
                   hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt());
                   Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
                   sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight);
-                  if(backgroundCandidate.M()>0.1 && backgroundCandidate.M()<0.15)
-                     hESDBackAlpha[fiCut]->Fill(backgroundCandidate.GetAlpha());
                }
             }
          }
@@ -1331,9 +1358,9 @@ void AliAnalysisTaskGammaConvV1::CalculateBackgroundRP(){
    }
    else{
       // Do Event Mixing
-      for(Int_t nEventsInBG=0;nEventsInBG <fBGHandlerRP[fiCut]->GetNBGEvents(fGoodGammas,fInputEvent);nEventsInBG++){
+      for(Int_t nEventsInBG=0;nEventsInBG <fBGHandlerRP[fiCut]->GetNBGEvents(fGammaCandidates,fInputEvent);nEventsInBG++){
 
-         AliGammaConversionPhotonVector *previousEventGammas = fBGHandlerRP[fiCut]->GetBGGoodGammas(fGoodGammas,fInputEvent,nEventsInBG);
+         AliGammaConversionPhotonVector *previousEventGammas = fBGHandlerRP[fiCut]->GetBGGoodGammas(fGammaCandidates,fInputEvent,nEventsInBG);
 
          if(previousEventGammas){
             // test weighted background
@@ -1342,11 +1369,11 @@ void AliAnalysisTaskGammaConvV1::CalculateBackgroundRP(){
             // N gammas -> (N-1) + (N-2) +(N-3) ...+ (N-(N-1))  using sum formula sum(i)=N*(N-1)/2  -> N*(N-1)/2
             // real combinations (since you cannot combine a photon with its own)
             // but BG leads to N_{a}*N_{b} combinations
-            weight*=0.5*(Double_t(fGoodGammas->GetEntries()-1))/Double_t(previousEventGammas->size());
+            weight*=0.5*(Double_t(fGammaCandidates->GetEntries()-1))/Double_t(previousEventGammas->size());
 
-            for(Int_t iCurrent=0;iCurrent<fGoodGammas->GetEntries();iCurrent++){
+            for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
 
-               AliAODConversionPhoton *gamma0 = (AliAODConversionPhoton*)(fGoodGammas->At(iCurrent));
+               AliAODConversionPhoton *gamma0 = (AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
 
                for(UInt_t iPrevious=0;iPrevious<previousEventGammas->size();iPrevious++){
 
@@ -1358,8 +1385,6 @@ void AliAnalysisTaskGammaConvV1::CalculateBackgroundRP(){
                      hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt());
                      Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
                      sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight);
-                     if(backgroundCandidate.M()>0.1 && backgroundCandidate.M()<0.15)
-                        hESDBackAlpha[fiCut]->Fill(backgroundCandidate.GetAlpha());
                   }
                }
             }
@@ -1388,12 +1413,12 @@ void AliAnalysisTaskGammaConvV1::MoveParticleAccordingToVertex(AliAODConversionP
 //________________________________________________________________________
 void AliAnalysisTaskGammaConvV1::UpdateEventByEventData(){
    //see header file for documentation
-   if(fGoodGammas->GetEntries() >0 ){
+   if(fGammaCandidates->GetEntries() >0 ){
       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
-         fBGHandler[fiCut]->AddEvent(fGoodGammas,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fNumberOfESDTracks);
+         fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fNumberOfESDTracks);
       }
       else{ // means we use #V0s for multiplicity
-         fBGHandler[fiCut]->AddEvent(fGoodGammas,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodGammas->GetEntries());
+         fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGammaCandidates->GetEntries());
       }
    }
 }
@@ -1428,9 +1453,9 @@ void AliAnalysisTaskGammaConvV1::CountESDTracks(){
 void AliAnalysisTaskGammaConvV1::Terminate(const Option_t *)
 {
 
-   fOutputContainer->Add(((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
-
+   // Not Executed by GRID on SubJobLevel
    for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+      if(!((AliConversionCuts*)fCutArray->At(iCut))) continue;
       if(((AliConversionCuts*)fCutArray->At(iCut))->GetSignalRejection() == 2 && fMCEvent){
          fHeaderNameList[iCut] = new TList();
          TString HeaderNames = "Header:";
@@ -1450,13 +1475,7 @@ void AliAnalysisTaskGammaConvV1::Terminate(const Option_t *)
          fHeaderNameList[iCut]->SetOwner(kTRUE);
          fCutFolder[iCut]->Add(fHeaderNameList[iCut]);
       }
-
-      if(((AliConversionCuts*)fCutArray->At(iCut))->GetCutHistograms()){
-         fCutFolder[iCut]->Add(((AliConversionCuts*)fCutArray->At(iCut))->GetCutHistograms());
-      }
-      if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
-         fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
-      }
    }
-   fOutputContainer->Print();
+
+   //fOutputContainer->Print(); // Will crash on GRID
 }
index 80983f3..0dcade5 100644 (file)
@@ -64,7 +64,7 @@ class AliAnalysisTaskGammaConvV1 : public AliAnalysisTaskSE {
    TList **fHeaderNameList;
    TList *fOutputContainer;
    TClonesArray *fReaderGammas;
-   TList *fGoodGammas;
+   TList *fGammaCandidates;
    TList *fCutArray;
    AliConversionCuts *fConversionCuts;
    TList *fMesonCutArray;
@@ -96,8 +96,10 @@ class AliAnalysisTaskGammaConvV1 : public AliAnalysisTaskSE {
    TH1F **hMCEtaInAccPt;
    TH2F **hESDTrueMotherInvMassPt;
    TH2F **hESDTruePi0FromEtaInvMassPt;
+   TH2F **hESDTruePrimaryMotherInvMassPt;
    TH2F **hESDTruePrimaryMotherInvMassMCPt;
    TH2F **hESDTruePrimaryPi0ESDPtMCPt;
+   TH2F **hESDTruePrimaryEtaESDPtMCPt;
    TH2F **hESDTrueSecondaryMotherInvMassPt;
    TH2F **hESDTrueSecondaryMotherFromK0sInvMassPt;
    TH1F **hESDTrueK0sWithPi0DaughterMCPt;
@@ -116,28 +118,32 @@ class AliAnalysisTaskGammaConvV1 : public AliAnalysisTaskSE {
    TH1F **hESDTrueSecondaryConvGammaPt;
    TH1F **hESDTrueSecondaryConvGammaR;
    TH1F **hESDTrueSecondaryConvGammaFromXFromK0sPt;
-   TH1F **hESDPi0Alpha;
-   TH1F **hESDBackAlpha;
-   TH1F **hESDTruePi0Alpha;
    TH1I **hNEvents;
    TH1I **hNGoodESDTracks;
+   TH1I **hNGammaCandidates;
    TH1I **hNV0Tracks;
 
    TRandom3 fRandom;
-   Int_t fnGoodGammas;
-   Double_t *fUnsmearedPx; //[fnGoodGammas]
-   Double_t *fUnsmearedPy; //[fnGoodGammas]
-   Double_t *fUnsmearedPz; //[fnGoodGammas]
-   Double_t *fUnsmearedE;  //[fnGoodGammas]
+   Int_t fnGammaCandidates;
+   Double_t *fUnsmearedPx; //[fnGammaCandidates]
+   Double_t *fUnsmearedPy; //[fnGammaCandidates]
+   Double_t *fUnsmearedPz; //[fnGammaCandidates]
+   Double_t *fUnsmearedE;  //[fnGammaCandidates]
    Int_t fnCuts;
    Int_t fiCut;
    Int_t fNumberOfESDTracks;
    Bool_t fMoveParticleAccordingToVertex;
    Bool_t fIsHeavyIon;
    Bool_t fDoMesonAnalysis;
-   Bool_t fIsFromBGEvent;
+   Bool_t fIsFromMBHeader;
 
-   ClassDef(AliAnalysisTaskGammaConvV1, 2);
+private:
+
+   AliAnalysisTaskGammaConvV1(const AliAnalysisTaskGammaConvV1&); // Prevent copy-construction
+   AliAnalysisTaskGammaConvV1 &operator=(const AliAnalysisTaskGammaConvV1&); // Prevent assignment
+
+
+   ClassDef(AliAnalysisTaskGammaConvV1, 3);
 };
 
 #endif
index 29adf76..8a2e82d 100644 (file)
@@ -3273,13 +3273,13 @@ void AliAnalysisTaskGammaConversion::ProcessGammasForNeutralMesonAnalysis(){
                                                
                                        Int_t zbin= bgHandlerTest->GetZBinIndex(fV0Reader->GetVertexZ());
                                        Int_t mbin=0;
-                                       Int_t multKAA=0;
+                                       //Int_t multKAA=0;
                                        if(fUseTrackMultiplicityForBG == kTRUE){
-                                               multKAA=fV0Reader->CountESDTracks();
+                                           //multKAA=fV0Reader->CountESDTracks();
                                                mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->CountESDTracks());
                                        }
                                        else{// means we use #v0s for multiplicity
-                                               multKAA=fV0Reader->GetNGoodV0s();
+                                           //multKAA=fV0Reader->GetNGoodV0s();
                                                mbin = bgHandlerTest->GetMultiplicityBinIndex(fV0Reader->GetNGoodV0s());
                                        }
                                        //                      cout<<"Filling bin number "<<zbin<<" and "<<mbin<<endl;
index deba93d..7ffb164 100644 (file)
@@ -36,6 +36,7 @@ ClassImp(AliAnalysisTaskMaterial)
 
 //________________________________________________________________________
 AliAnalysisTaskMaterial::AliAnalysisTaskMaterial(const char *name) : AliAnalysisTaskSE(name),
+   fV0Reader(NULL),
    fConversionGammas(NULL),
    fConversionCuts(NULL),
    fStreamMaterial(NULL),
@@ -81,8 +82,8 @@ void AliAnalysisTaskMaterial::UserCreateOutputObjects()
    // V0 Reader Cuts
    TString cutnumber = fConversionCuts->GetCutNumber();
 
-   fStreamMaterial = new TTreeSRedirector(Form("GammaConvV1_Material_%s.root",cutnumber.Data()));
-       fStreamResolution = new TTreeSRedirector(Form("GammaConvV1_Resolution_%s.root",cutnumber.Data()));
+   fStreamMaterial = new TTreeSRedirector(Form("GammaConvV1_Material_%s.root",cutnumber.Data()),"recreate");
+        fStreamResolution = new TTreeSRedirector(Form("GammaConvV1_Resolution_%s.root",cutnumber.Data()),"recreate");
    PostData(1, fOutputList);
 }
 
@@ -379,7 +380,7 @@ Int_t AliAnalysisTaskMaterial::CountESDTracks0914(){
 
    AliESDtrackCuts *EsdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts");
    // Using standard function for setting Cuts ; We use TPCOnlyTracks for outer eta region
-   Bool_t selectPrimaries=kTRUE;
+   //Bool_t selectPrimaries=kTRUE;
         //   EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
    EsdTrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
         EsdTrackCuts->SetMaxDCAToVertexXY(5);
index 9ada50c..2b307ec 100644 (file)
@@ -20,42 +20,45 @@ using namespace std;
 
 class AliAnalysisTaskMaterial : public AliAnalysisTaskSE{
 
-public:
-
-    AliAnalysisTaskMaterial(const char *name);
-    virtual ~AliAnalysisTaskMaterial();
-
-    virtual void   UserCreateOutputObjects();
-    virtual void   UserExec(Option_t *option);
-    virtual void   Terminate(Option_t *);
-
-    void SetV0Reader(AliV0ReaderV1 *v0Reader){fV0Reader=v0Reader;}
-    void SetConversionCuts(AliConversionCuts* conversionCuts,Bool_t IsHeavyIon ){
-       fConversionCuts=conversionCuts;
-       fIsHeavyIon = IsHeavyIon;
-    }
-    
-private:
-
-    void ProcessPhotons();
-        void ProcessMCPhotons();
-        void FillMCTree(Int_t stackPos);
-        Int_t CountESDTracks14();
-        Int_t CountESDTracks0914();
-        Int_t CountESDTracks09();
-        
-    AliV0ReaderV1 *fV0Reader;
-    TClonesArray *fConversionGammas; //Reconstructed Photons;
-    AliConversionCuts *fConversionCuts; // Cuts used by the V0Reader
-    TTreeSRedirector *fStreamMaterial;
-        TTreeSRedirector *fStreamResolution;
-    Bool_t fIsHeavyIon;
-    TList *fOutputList;
-        AliESDEvent *fESDEvent;
-        AliMCEvent *fMCEvent;
-       
-    ClassDef(AliAnalysisTaskMaterial, 0);
+ public:
+
+   AliAnalysisTaskMaterial(const char *name);
+   virtual ~AliAnalysisTaskMaterial();
+
+   virtual void   UserCreateOutputObjects();
+   virtual void   UserExec(Option_t *option);
+   virtual void   Terminate(Option_t *);
+
+   void SetV0Reader(AliV0ReaderV1 *v0Reader){fV0Reader=v0Reader;}
+   void SetConversionCuts(AliConversionCuts* conversionCuts,Bool_t IsHeavyIon ){
+      fConversionCuts=conversionCuts;
+      fIsHeavyIon = IsHeavyIon;
+   }
+
+ private:
+
+   void ProcessPhotons();
+   void ProcessMCPhotons();
+   void FillMCTree(Int_t stackPos);
+   Int_t CountESDTracks14();
+   Int_t CountESDTracks0914();
+   Int_t CountESDTracks09();
+
+   AliV0ReaderV1 *fV0Reader;
+   TClonesArray *fConversionGammas; //Reconstructed Photons;
+   AliConversionCuts *fConversionCuts; // Cuts used by the V0Reader
+   TTreeSRedirector *fStreamMaterial;
+   TTreeSRedirector *fStreamResolution;
+   Bool_t fIsHeavyIon;
+   TList *fOutputList;
+   AliESDEvent *fESDEvent;
+   AliMCEvent *fMCEvent;
+
+   AliAnalysisTaskMaterial(const AliAnalysisTaskMaterial&); // not implemented
+   AliAnalysisTaskMaterial& operator=(const AliAnalysisTaskMaterial&); // not implemented
+
+
+   ClassDef(AliAnalysisTaskMaterial, 0);
 };
 
 #endif
-
index 3991f96..05bec6f 100644 (file)
@@ -65,6 +65,7 @@ ClassImp(AliAnalysisTaskPi0v2)
     fDoEPFlattening(kTRUE),
 
     hNEvents(NULL),
+    hEventSelection(NULL),
     hRPTPC(NULL),
     hRPV0A(NULL),
     hRPV0C(NULL),
@@ -352,7 +353,7 @@ void AliAnalysisTaskPi0v2::UserCreateOutputObjects()
         fRPList->Add(hEPVertex);
         */
 
-       const Int_t nRuns=270;
+       const Int_t nRuns=275;
        const Int_t nepbins=4;
        Int_t nbinsep[nepbins]={fNCentralityBins,180,nRuns,5};
        Double_t minep[nepbins]={-0.5,0,0.5,-0.5};
@@ -460,7 +461,15 @@ void AliAnalysisTaskPi0v2::UserCreateOutputObjects()
     }
     hNEvents=new TH1F("NEvents","NEvents",fNCentralityBins,fCentralityBins);
     fPhotonQAList->Add(hNEvents);
-   
+    hEventSelection=new TH1F("EventSelection","EventSelection",kEventSelected,0.5,kEventSelected+0.5);
+    hEventSelection->GetXaxis()->SetBinLabel(kEventIn,"in");
+    hEventSelection->GetXaxis()->SetBinLabel(kEventSelV0Reader,"v0reader");
+    hEventSelection->GetXaxis()->SetBinLabel(kEventCentrality,"centr");
+    hEventSelection->GetXaxis()->SetBinLabel(kEventRun,"run");
+    hEventSelection->GetXaxis()->SetBinLabel(kEventNoTPCEP,"no ep");
+    hEventSelection->GetXaxis()->SetBinLabel(kEventProcessEvent,"proc ev");
+    hEventSelection->GetXaxis()->SetBinLabel(kEventSelected,"selected");
+    fPhotonQAList->Add(hEventSelection);
 
     // V0 Reader Cuts
     TList *fV0ReaderCuts=fConversionCuts->GetCutHistograms();
@@ -475,7 +484,11 @@ void AliAnalysisTaskPi0v2::UserCreateOutputObjects()
 Bool_t AliAnalysisTaskPi0v2::InitEvent(){
 
     if(!fV0Reader){AliError("Error: No V0 Reader and Pi0 Reconstructor");return kFALSE;}
-    if(!fV0Reader->IsEventSelected())return kFALSE;
+    if(!fV0Reader->IsEventSelected()){
+       hEventSelection->Fill(kEventSelV0Reader);
+       return kFALSE;
+    }
+
     fConversionGammas=fV0Reader->GetReconstructedGammas();
 
     fIsAOD=(fInputEvent->IsA()==AliAODEvent::Class());
@@ -485,7 +498,10 @@ Bool_t AliAnalysisTaskPi0v2::InitEvent(){
        return kFALSE;
     }
 
-    if(!SetCentrality()){return kFALSE;}
+    if(!SetCentrality()){
+       hEventSelection->Fill(kEventCentrality);
+       return kFALSE;
+    }
 
     if(fConversionCuts->IsHeavyIon()&&!fMCEvent){
 
@@ -499,13 +515,18 @@ Bool_t AliAnalysisTaskPi0v2::InitEvent(){
        }
        if(fRunIndex<0){
            AliInfo("Run not selected");
+           hEventSelection->Fill(kEventRun);
            return kFALSE;
        }
 
        // TPC Event Plane
-       if(!GetTPCEventPlane())return kFALSE;
+       if(!GetTPCEventPlane()){
+           hEventSelection->Fill(kEventNoTPCEP);
+           return kFALSE;
+       }
        //fEP=fInputEvent->GetEventplane();
-       if(!fEP)return kFALSE;
+       //if(!fEP)return kFALSE;
+
        fRPTPCBF=GetCorrectedTPCEPAngle(NULL,NULL,kFALSE);
        fRPTPC=GetEventPlaneAngle(kTPC);
 
@@ -529,6 +550,10 @@ Bool_t AliAnalysisTaskPi0v2::InitEvent(){
 //________________________________________________________________________
 void AliAnalysisTaskPi0v2::UserExec(Option_t *) 
 {
+    cout<<hNEvents->GetEntries()<<endl;
+    if(hNEvents->GetEntries()>5)return;
+
+    hEventSelection->Fill(kEventIn);
 
     if(!InitEvent())return;
 
@@ -553,9 +578,13 @@ void AliAnalysisTaskPi0v2::UserExec(Option_t *)
            // QA
            if(fFillQA&&iCut==0)ProcessQA();
        }
+       else{
+           hEventSelection->Fill(kEventProcessEvent);
+       }
     }
 
     // Fill N Events
+    hEventSelection->Fill(kEventSelected);
     hNEvents->Fill(fCentrality);
 
     // EventPlaneResolution
@@ -1416,134 +1445,147 @@ Int_t AliAnalysisTaskPi0v2::GetRunIndex(Int_t run){
     case  137161 : return 1;
 
     // Default
-    default : return -1;
+    //default : return -1;
+    default : return 275;
     }
 }
 
 //____________________________________________________________________________
 void AliAnalysisTaskPi0v2::GetV0EP(AliVEvent * event,Double_t &rpv0a,Double_t &rpv0c){
 
-    // Corrected VZERO EP (from AliAnalysisTaskPi0Flow)
-
-    //VZERO data
-    AliESDVZERO* esdV0 = (AliESDVZERO*)event->GetVZEROData();
-
-    //reset Q vector info
-    Double_t Qxa2 = 0, Qya2 = 0;
-    Double_t Qxc2 = 0, Qyc2 = 0;
-
-    for (Int_t iv0 = 0; iv0 < 64; iv0++) {
-       Double_t phiV0 = TMath::PiOver4()*(0.5 + iv0 % 8);
-       Float_t multv0 = esdV0->GetMultiplicity(iv0);
-       Double_t lqx=TMath::Cos(fHarmonic*phiV0) * multv0*fV0Cpol/fMultV0->GetBinContent(iv0+1);
-       Double_t lqy=TMath::Sin(fHarmonic*phiV0) * multv0*fV0Cpol/fMultV0->GetBinContent(iv0+1);
-       if (iv0 < 32){ // V0C
-           Qxc2 += lqx;
-           Qyc2 += lqy;
-       } else {       // V0A
-           Qxa2 += lqx;
-           Qya2 += lqy;
+    if (fPeriod.CompareTo("LHC10h")==0){
+       // Corrected VZERO EP (from AliAnalysisTaskPi0Flow)
+       //VZERO data
+       AliESDVZERO* esdV0 = (AliESDVZERO*)event->GetVZEROData();
+
+       //reset Q vector info
+       Double_t Qxa2 = 0, Qya2 = 0;
+       Double_t Qxc2 = 0, Qyc2 = 0;
+
+       for (Int_t iv0 = 0; iv0 < 64; iv0++) {
+           Double_t phiV0 = TMath::PiOver4()*(0.5 + iv0 % 8);
+           Float_t multv0 = esdV0->GetMultiplicity(iv0);
+           Double_t lqx=TMath::Cos(fHarmonic*phiV0) * multv0*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+           Double_t lqy=TMath::Sin(fHarmonic*phiV0) * multv0*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+           if (iv0 < 32){ // V0C
+               Qxc2 += lqx;
+               Qyc2 += lqy;
+           } else {       // V0A
+               Qxa2 += lqx;
+               Qya2 += lqy;
+           }
        }
-    }
 
-    Int_t iC = -1;
-    // centrality bins
-    if(fCentrality < 5) iC = 0;
-    else if(fCentrality < 10) iC = 1;
-    else if(fCentrality < 20) iC = 2;
-    else if(fCentrality < 30) iC = 3;
-    else if(fCentrality < 40) iC = 4;
-    else if(fCentrality < 50) iC = 5;
-    else if(fCentrality < 60) iC = 6;
-    else if(fCentrality < 70) iC = 7;
-    else iC = 8;
-
-    //grab for each centrality the proper histo with the Qx and Qy to do the recentering
-    Double_t Qxamean2 = fMeanQ[iC][1][0];
-    Double_t Qxarms2  = fWidthQ[iC][1][0];
-    Double_t Qyamean2 = fMeanQ[iC][1][1];
-    Double_t Qyarms2  = fWidthQ[iC][1][1];
-    
-    Double_t Qxcmean2 = fMeanQ[iC][0][0];
-    Double_t Qxcrms2  = fWidthQ[iC][0][0];
-    Double_t Qycmean2 = fMeanQ[iC][0][1];
-    Double_t Qycrms2  = fWidthQ[iC][0][1];
+       Int_t iC = -1;
+       // centrality bins
+       if(fCentrality < 5) iC = 0;
+       else if(fCentrality < 10) iC = 1;
+       else if(fCentrality < 20) iC = 2;
+       else if(fCentrality < 30) iC = 3;
+       else if(fCentrality < 40) iC = 4;
+       else if(fCentrality < 50) iC = 5;
+       else if(fCentrality < 60) iC = 6;
+       else if(fCentrality < 70) iC = 7;
+       else iC = 8;
+
+       //grab for each centrality the proper histo with the Qx and Qy to do the recentering
+       Double_t Qxamean2 = fMeanQ[iC][1][0];
+       Double_t Qxarms2  = fWidthQ[iC][1][0];
+       Double_t Qyamean2 = fMeanQ[iC][1][1];
+       Double_t Qyarms2  = fWidthQ[iC][1][1];
+
+       Double_t Qxcmean2 = fMeanQ[iC][0][0];
+       Double_t Qxcrms2  = fWidthQ[iC][0][0];
+       Double_t Qycmean2 = fMeanQ[iC][0][1];
+       Double_t Qycrms2  = fWidthQ[iC][0][1];
+
+       Double_t QxaCor2 = (Qxa2 - Qxamean2)/Qxarms2;
+       Double_t QyaCor2 = (Qya2 - Qyamean2)/Qyarms2;
+       Double_t QxcCor2 = (Qxc2 - Qxcmean2)/Qxcrms2;
+       Double_t QycCor2 = (Qyc2 - Qycmean2)/Qycrms2;
+       rpv0a = TMath::ATan2(QyaCor2, QxaCor2)/Double_t(fHarmonic);
+       rpv0c = TMath::ATan2(QycCor2, QxcCor2)/Double_t(fHarmonic);
+
+       //rpv0a = TMath::ATan2(Qya2, Qxa2)/Double_t(fHarmonic);
+       //rpv0c = TMath::ATan2(Qyc2, Qxc2)/Double_t(fHarmonic);
+
+       // cout<<"Compare v"<<fHarmonic<<" "<<rpv0a<<" "<<fInputEvent->GetEventplane()->GetEventplane("V0A",fInputEvent,fHarmonic)<<endl;
 
-    Double_t QxaCor2 = (Qxa2 - Qxamean2)/Qxarms2;
-    Double_t QyaCor2 = (Qya2 - Qyamean2)/Qyarms2;
-    Double_t QxcCor2 = (Qxc2 - Qxcmean2)/Qxcrms2;
-    Double_t QycCor2 = (Qyc2 - Qycmean2)/Qycrms2;
-    rpv0a = TMath::ATan2(QyaCor2, QxaCor2)/Double_t(fHarmonic);
-    rpv0c = TMath::ATan2(QycCor2, QxcCor2)/Double_t(fHarmonic);
+    }
+    if (fPeriod.CompareTo("LHC11h")==0){
 
-    //rpv0a = TMath::ATan2(Qya2, Qxa2)/Double_t(fHarmonic);
-    //rpv0c = TMath::ATan2(Qyc2, Qxc2)/Double_t(fHarmonic);
+       AliEventplane *eventEP=fInputEvent->GetEventplane();
 
-   // cout<<"Compare v"<<fHarmonic<<" "<<rpv0a<<" "<<fInputEvent->GetEventplane()->GetEventplane("V0A",fInputEvent,fHarmonic)<<endl;
+        Double_t qx,qy;
+       rpv0a=eventEP->CalculateVZEROEventPlane(fInputEvent,8,fHarmonic,qx,qy);
+        rpv0c=eventEP->CalculateVZEROEventPlane(fInputEvent,9,fHarmonic,qx,qy);
+    }
 
     rpv0a=GetPsiInRange(rpv0a);
     rpv0c=GetPsiInRange(rpv0c);
-
 }
 
 //_____________________________________________________________________________
 void AliAnalysisTaskPi0v2::LoadVZEROCalibration(Int_t run){
 
-    // VZERO Phi Weights and Recentering
+    cout<<fPeriod.Data()<<endl;
 
-    TString oadbfilename = "$ALICE_ROOT/OADB/PWGCF/VZERO/VZEROcalibEP.root";
-    TFile *foadb = TFile::Open(oadbfilename.Data());
+    // VZERO Phi Weights and Recentering
+    if (fPeriod.CompareTo("LHC10h")==0){
+       TString oadbfilename = "$ALICE_ROOT/OADB/PWGCF/VZERO/VZEROcalibEP.root";
+       TFile *foadb = TFile::Open(oadbfilename.Data());
 
-    if(!foadb){
-       printf("OADB file %s cannot be opened\n",oadbfilename.Data());
-       return;
-    }
+       if(!foadb){
+           printf("OADB file %s cannot be opened\n",oadbfilename.Data());
+           return;
+       }
 
-    AliOADBContainer *cont = (AliOADBContainer*) foadb->Get("hMultV0BefCorr");
-    if(!cont){
-       printf("OADB object hMultV0BefCorr is not available in the file\n");
-       return;
-    }
+       AliOADBContainer *cont = (AliOADBContainer*) foadb->Get("hMultV0BefCorr");
+       if(!cont){
+           printf("OADB object hMultV0BefCorr is not available in the file\n");
+           return;
+       }
 
-    if(!(cont->GetObject(run))){
-       printf("OADB object hMultV0BefCorr is not available for run %i (used run 137366)\n",run);
-       run = 137366;
-    }
-    printf("Setting V0 calibration \n") ;
-    fMultV0 = ((TH2F *) cont->GetObject(run))->ProfileX();
-
-    TF1 *fpol0 = new TF1("fpol0","pol0"); 
-    fMultV0->Fit(fpol0,"0","",0,31);
-    fV0Cpol = fpol0->GetParameter(0);
-    fMultV0->Fit(fpol0,"0","",32,64);
-    fV0Apol = fpol0->GetParameter(0);
-
-    for(Int_t iside=0;iside<2;iside++){
-       for(Int_t icoord=0;icoord<2;icoord++){
-           for(Int_t i=0;i  < nCentrBinV0;i++){
-               char namecont[100];
-
-               if(iside==0 && icoord==0)
-                   snprintf(namecont,100,"hQxc%i_%i",fHarmonic,i);
-               else if(iside==1 && icoord==0)
-                   snprintf(namecont,100,"hQxa%i_%i",fHarmonic,i);
-               else if(iside==0 && icoord==1)
-                   snprintf(namecont,100,"hQyc%i_%i",fHarmonic,i);
-               else if(iside==1 && icoord==1)
-                   snprintf(namecont,100,"hQya%i_%i",fHarmonic,i);
-
-               cont = (AliOADBContainer*) foadb->Get(namecont);
-               if(!cont){
-                   printf("OADB object %s is not available in the file\n",namecont);
-                   return;
-               }
+       if(!(cont->GetObject(run))){
+           printf("OADB object hMultV0BefCorr is not available for run %i (used run 137366)\n",run);
+           run = 137366;
+       }
+       printf("Setting V0 calibration \n") ;
+       fMultV0 = ((TH2F *) cont->GetObject(run))->ProfileX();
+
+       TF1 *fpol0 = new TF1("fpol0","pol0");
+       fMultV0->Fit(fpol0,"0","",0,31);
+       fV0Cpol = fpol0->GetParameter(0);
+       fMultV0->Fit(fpol0,"0","",32,64);
+       fV0Apol = fpol0->GetParameter(0);
+
+       for(Int_t iside=0;iside<2;iside++){
+           for(Int_t icoord=0;icoord<2;icoord++){
+               for(Int_t i=0;i  < nCentrBinV0;i++){
+                   char namecont[100];
+
+                   if(iside==0 && icoord==0)
+                       snprintf(namecont,100,"hQxc%i_%i",fHarmonic,i);
+                   else if(iside==1 && icoord==0)
+                       snprintf(namecont,100,"hQxa%i_%i",fHarmonic,i);
+                   else if(iside==0 && icoord==1)
+                       snprintf(namecont,100,"hQyc%i_%i",fHarmonic,i);
+                   else if(iside==1 && icoord==1)
+                       snprintf(namecont,100,"hQya%i_%i",fHarmonic,i);
+
+                   cont = (AliOADBContainer*) foadb->Get(namecont);
+                   if(!cont){
+                       printf("OADB object %s is not available in the file\n",namecont);
+                       return;
+                   }
 
-               if(!(cont->GetObject(run))){
-                   printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);
-                   run = 137366;
+                   if(!(cont->GetObject(run))){
+                       printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);
+                       run = 137366;
+                   }
+                   fMeanQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();
+                   fWidthQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();
                }
-               fMeanQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();
-               fWidthQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();
            }
        }
     }
@@ -1556,7 +1598,7 @@ void AliAnalysisTaskPi0v2::LoadTPCCalibration(Int_t run){
     AliOADBContainer *fEPContainer=NULL;
     TString oadbfilename="";
 
-    if (run >= 136851 && run <= 139515){
+    if (fPeriod.CompareTo("LHC10h")==0){
        // LHC10h
 
        if(fIsAOD){
@@ -1600,8 +1642,8 @@ void AliAnalysisTaskPi0v2::LoadTPCCalibration(Int_t run){
        }
     }
 
-    if (run >= 166529 && run <= 170593){
-        // LHC11h
+    if (fPeriod.CompareTo("LHC11h")==0){
+       // LHC11h
 
        oadbfilename = (Form("%s/COMMON/EVENTPLANE/data/epphidist2011.root", AliAnalysisManager::GetOADBPath()));
        TFile *foadb = TFile::Open(oadbfilename);
@@ -1649,7 +1691,6 @@ void AliAnalysisTaskPi0v2::LoadTPCCalibration(Int_t run){
        }
        fSparseDist->GetAxis(0)->SetRange(1,2901);// reset run axis
     }
-
     if (!fPhiDist[0]) AliFatal(Form("Cannot find OADB phi distribution for run %d", run));
 
 }
@@ -2016,20 +2057,15 @@ Double_t AliAnalysisTaskPi0v2::GetPhiWeight(TObject* track1)
 TH1F* AliAnalysisTaskPi0v2::SelectPhiDist(AliVTrack *track)
 { 
   if (fPeriod.CompareTo("LHC10h")==0) return fPhiDist[0];
-  else if(fPeriod.CompareTo("LHC11h")==0)
-    {
-     if (track->Charge() < 0)
-       {
-        if(track->Eta() < 0.)       return fPhiDist[0];
-        else if (track->Eta() > 0.) return fPhiDist[2];
-       }
-      else if (track->Charge() > 0)
-       {
-        if(track->Eta() < 0.)       return fPhiDist[1];
-        else if (track->Eta() > 0.) return fPhiDist[3];
-       }
-       
-    }
+  else if(fPeriod.CompareTo("LHC11h")==0){
+      if (track->Charge() < 0){
+         if(track->Eta() < 0.)       return fPhiDist[0];
+         else if (track->Eta() > 0.) return fPhiDist[2];
+      }
+      else if (track->Charge() > 0){
+         if(track->Eta() < 0.)       return fPhiDist[1];
+         else if (track->Eta() > 0.) return fPhiDist[3];
+      }
+  }
   return 0;
 }
-
index f421254..5b5296d 100644 (file)
@@ -128,6 +128,17 @@ private:
        knbinsPi0
     };
 
+    enum EEventSelection{
+       kEventIn=1,
+        kEventSelV0Reader,
+       kEventCentrality,
+       kEventRun,
+       kEventNoTPCEP,
+        kEventProcessEvent,
+       kEventSelected
+    };
+
+
     static const Int_t knbinsGammaMult=3;
   
     static const Int_t kGCnYBinsSpectra = 80;
@@ -181,6 +192,7 @@ private:
     // Histograms
 
     TH1F *hNEvents;
+    TH1F *hEventSelection;
 
     // RP
     TH2F *hRPTPC;
index b7656c7..7946db2 100644 (file)
@@ -532,7 +532,7 @@ void AliAnalysisTaskdPhi::Process(TObjArray * gammas, TObjArray * tracks, Int_t
                
 
                Int_t leadingpi = fIsoAna->IsLeading(static_cast<AliAODConversionParticle*>(pion), tracks, tIDs);
-               piCorr->FillTriggerCounters(pion, leadingpi);
+               //piCorr->FillTriggerCounters(pion, leadingpi);
                tIDs[2] = ph2->GetLabel(0);
                tIDs[3] = ph2->GetLabel(1);
                if(pion->Pt() > fAxistPt.GetBinLowEdge(1) && 
index 1ffaafa..eb54d6b 100644 (file)
@@ -41,6 +41,9 @@
 #include "TList.h"
 #include "AliLog.h"
 #include "AliGenCocktailEventHeader.h"
+#include "AliGenDPMjetEventHeader.h"
+#include "AliGenPythiaEventHeader.h"
+#include "AliGenHijingEventHeader.h"
 #include "AliTriggerAnalysis.h"
 #include "AliV0ReaderV1.h"
 
@@ -189,7 +192,8 @@ AliConversionCuts::AliConversionCuts(const char *name,const char *title) :
    hV0EventCuts(NULL),
    hCentrality(NULL),
    hVertexZ(NULL),
-   hTriggerClass(NULL)
+   hTriggerClass(NULL),
+   hTriggerClassSelected(NULL)
 {
    InitPIDResponse();
    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
@@ -308,15 +312,17 @@ AliConversionCuts::AliConversionCuts(const AliConversionCuts &ref) :
    hV0EventCuts(NULL),
    hCentrality(NULL),
    hVertexZ(NULL),
-   hTriggerClass(NULL)
+   hTriggerClass(NULL),
+   hTriggerClassSelected(NULL)
 {
    // Copy Constructor
-    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=ref.fCuts[jj];}
-    fCutString=new TObjString((GetCutNumber()).Data());
-    fElectronLabelArray = new Int_t[fElectronArraySize];
-    // dont copy histograms (if you like histograms, call InitCutHistograms())
+   for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=ref.fCuts[jj];}
+   fCutString=new TObjString((GetCutNumber()).Data());
+   fElectronLabelArray = new Int_t[fElectronArraySize];
+   // dont copy histograms (if you like histograms, call InitCutHistograms())
 }
 
+
 //________________________________________________________________________
 AliConversionCuts::~AliConversionCuts() {
    // Destructor
@@ -502,7 +508,7 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
       hVertexZ=new TH1F(Form("VertexZ %s",GetCutNumber().Data()),"VertexZ",1000,-50,50);
       fHistograms->Add(hVertexZ);
 
-      hTriggerClass= new TH1F(Form("OfflineTrigger %s",GetCutNumber().Data()),"OfflineTrigger",33,-0.5,32.5);
+      hTriggerClass= new TH1F(Form("OfflineTrigger %s",GetCutNumber().Data()),"OfflineTrigger",34,-0.5,33.5);
       hTriggerClass->GetXaxis()->SetBinLabel( 1,"kMB");
       hTriggerClass->GetXaxis()->SetBinLabel( 2,"kINT7");
       hTriggerClass->GetXaxis()->SetBinLabel( 3,"kMUON");
@@ -536,7 +542,44 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
       hTriggerClass->GetXaxis()->SetBinLabel(31,"kAny");
       hTriggerClass->GetXaxis()->SetBinLabel(32,"V0AND");
       hTriggerClass->GetXaxis()->SetBinLabel(33,"NOT kFastOnly");
+      hTriggerClass->GetXaxis()->SetBinLabel(34,"failed Physics Selection");
       fHistograms->Add(hTriggerClass);
+
+      hTriggerClassSelected= new TH1F(Form("OfflineTriggerSelected %s",GetCutNumber().Data()),"OfflineTriggerSelected",33,-0.5,32.5);
+      hTriggerClassSelected->GetXaxis()->SetBinLabel( 1,"kMB");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel( 2,"kINT7");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel( 3,"kMUON");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel( 4,"kHighMult");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel( 5,"kKEMC1");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel( 6,"kCINT5");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel( 7,"kCMUS5/kMUSPB");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel( 8,"kMUSH7/kMUSHPB");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel( 9,"kMUL7/kMuonLikePB");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(10,"kMUU7/kMuonUnlikePB");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(11,"kEMC7/kEMC8");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(12,"kMUS7");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(13,"kPHI1");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(14,"kPHI7/kPHI8/kPHOSPb");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(15,"kEMCEJE");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(16,"kEMCEGA");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(17,"kCentral");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(18,"kSemiCentral");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(19,"kDG5");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(20,"kZED");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(21,"kSPI7/kSPI");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(22,"kINT8");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(23,"kMuonSingleLowPt8");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(24,"kMuonSingleHighPt8");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(25,"kMuonLikeLowPt8");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(26,"kMuonUnlikeLowPt8");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(27,"kMuonUnlikeLowPt0");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(28,"kUserDefined");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(29,"kFastOnly");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(30,"kAnyINT");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(31,"kAny");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(32,"V0AND");
+      hTriggerClassSelected->GetXaxis()->SetBinLabel(33,"NOT kFastOnly");
+      fHistograms->Add(hTriggerClassSelected);
    }
 }
 
@@ -592,7 +635,7 @@ Bool_t AliConversionCuts::EventIsSelected(AliVEvent *fInputEvent, AliVEvent *fMC
       return kFALSE;
    }
    cutindex++;
-   
+
    if(fInputEvent->IsA()==AliESDEvent::Class()){
       AliTriggerAnalysis fTriggerAnalysis;// = new AliTriggerAnalysis;
       fHasV0AND = fTriggerAnalysis.IsOfflineTriggerFired((AliESDEvent*)fInputEvent, AliTriggerAnalysis::kV0AND);
@@ -1147,17 +1190,17 @@ Bool_t AliConversionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
 
    // cout<<"Start"<<endl;
    // AliPIDResponse::EDetPidStatus status=fPIDResponse->CheckPIDStatus(AliPIDResponse::kTOF,fCurrentTrack);
-   
+
    // if( ( (status & AliVTrack::kTOFout) == AliVTrack::kTOFout ) && ( (status & AliVTrack::kTIME) == AliVTrack::kTIME ))
    //    {cout<<"TOF DA"<<endl;}
-   // if(status == AliPIDResponse::kDetPidOk){      
+   // if(status == AliPIDResponse::kDetPidOk){
    //    Float_t probMis = fPIDResponse->GetTOFMismatchProbability(fCurrentTrack);
    //    cout<<"--> "<<probMis<<endl;
    //    if(probMis > 0.01){
-         
+
    //    }
    // }
-   
+
    if((fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid) && !(fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
       if(hTOFbefore){
          Double_t t0 = fPIDResponse->GetTOFResponse().GetStartTime(fCurrentTrack->P());
@@ -1800,8 +1843,8 @@ Bool_t AliConversionCuts::SetEtaCut(Int_t etaCut)
       fEtaCutMin               = -0.1;
       fLineCutZRSlopeMin = 0.;
       break;
-   case 4: // 1.
-      fEtaCut          = 1.0;
+   case 4: // 0.75
+      fEtaCut          = 0.75;
       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
       fEtaCutMin               = -0.1;
       fLineCutZRSlopeMin = 0.;
@@ -2651,7 +2694,7 @@ Int_t AliConversionCuts::GetNumberOfContributorsVtx(AliVEvent *event){
             return fESDEvent->GetPrimaryVertex()->GetNContributors();
          }
       }
-      
+
       if(fESDEvent->GetPrimaryVertexSPD() !=NULL){
          if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
             return fESDEvent->GetPrimaryVertexSPD()->GetNContributors();
@@ -2668,7 +2711,7 @@ Int_t AliConversionCuts::GetNumberOfContributorsVtx(AliVEvent *event){
          if(fAODEvent->GetPrimaryVertex()->GetNContributors()>0) {
             return fAODEvent->GetPrimaryVertex()->GetNContributors();
          }
-      } 
+      }
       if(fAODEvent->GetPrimaryVertexSPD() !=NULL){
          if(fAODEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
             return fAODEvent->GetPrimaryVertexSPD()->GetNContributors();
@@ -2678,7 +2721,7 @@ Int_t AliConversionCuts::GetNumberOfContributorsVtx(AliVEvent *event){
          }
       }
    }
-   
+
    return 0;
 }
 
@@ -2700,7 +2743,7 @@ Bool_t AliConversionCuts::IsTriggerSelected()
 
    // Fill Histogram
    if(hTriggerClass){
-      if (!fIsSDDFired) hTriggerClass->Fill(32);
+      if (fIsSDDFired) hTriggerClass->Fill(32);
       if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
       if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
       if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
@@ -2709,8 +2752,6 @@ Bool_t AliConversionCuts::IsTriggerSelected()
       if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
       if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
       if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
@@ -2742,10 +2783,54 @@ Bool_t AliConversionCuts::IsTriggerSelected()
       if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(28);
       if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(29);
       if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(30);
+      if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(33);
+   }
+
+   if(hTriggerClassSelected && isSelected){
+      if (!fIsSDDFired) hTriggerClassSelected->Fill(32);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(28);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(29);
+      if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(30);
    }
 
    if(!isSelected)return kFALSE;
-      
+
    return kTRUE;
 
 }
@@ -2953,41 +3038,54 @@ void AliConversionCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderLi
                fNotRejectedStart[nummer] = firstindex;
                fNotRejectedEnd[nummer] = lastindex;
                fGeneratorNames[nummer] = GeneratorName;
+//                cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
                nummer++;
                continue;
             }
          }
          firstindex = firstindex + gh->NProduced();
       }
-   }
-   else{ // No Cocktail Header Found
+   } else { // No Cocktail Header Found
       fNotRejectedStart = new Int_t[1];
       fNotRejectedEnd = new Int_t[1];
 
       fnHeaders = 1;
       fNotRejectedStart[0] = 0;
       fNotRejectedEnd[0] = MCEvent->Stack()->GetNprimary()-1;
-      if(rejection == 2){
-         fGeneratorNames = new TString[1];
-         fGeneratorNames[0] = "NoCocktailGeneratorFound";
-      }
+//       if(rejection == 2){
+      fGeneratorNames = new TString[1];
+      fGeneratorNames[0] = "NoCocktailGeneratorFound";
+//       }
+            
+      AliGenPythiaEventHeader *mcHeaderPythia = dynamic_cast<AliGenPythiaEventHeader*>(MCEvent->GenEventHeader());      
+      if (mcHeaderPythia) fGeneratorNames[0] = "NoCocktailGeneratorFound_Pythia";
+      AliGenDPMjetEventHeader *mcHeaderPhojet = dynamic_cast<AliGenDPMjetEventHeader*>(MCEvent->GenEventHeader());      
+      if (mcHeaderPhojet) fGeneratorNames[0] = "NoCocktailGeneratorFound_Phojet";
+      AliGenHijingEventHeader *mcHeaderHijing = dynamic_cast<AliGenHijingEventHeader*>(MCEvent->GenEventHeader());      
+      if (mcHeaderHijing) fGeneratorNames[0] = "NoCocktailGeneratorFound_Hijing";
+
       SetRejectExtraSignalsCut(0);
    }
 
 }
 //_________________________________________________________________________
-Bool_t AliConversionCuts::IsParticleFromBGEvent(Int_t index, AliStack *MCStack){
+Int_t AliConversionCuts::IsParticleFromBGEvent(Int_t index, AliStack *MCStack){
+
+   // Not Accepted == kFALSE == 0
+   //     Accepted ==  kTRUE == 1
+   //  FirstHeader ==  kTRUE == 3
 
-   if(index < 0) return kFALSE; // No Particle
+   if(index < 0) return 0; // No Particle
 
-   Bool_t accepted = kFALSE;
+   Int_t accepted = 0;
    if( index >= MCStack->GetNprimary()){ // Secondary Particle
-      if( ((TParticle*)MCStack->Particle(index))->GetMother(0) < 0) return kTRUE; // Secondary Particle without Mother??
+      if( ((TParticle*)MCStack->Particle(index))->GetMother(0) < 0) return 1; // Secondary Particle without Mother??
       return IsParticleFromBGEvent(((TParticle*)MCStack->Particle(index))->GetMother(0),MCStack);
    }
    for(Int_t i = 0;i<fnHeaders;i++){
       if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
-         accepted = kTRUE;
+         accepted = 1;
+         if(i == 0) accepted = 2; // MB Header
       }
    }
 
@@ -2998,21 +3096,149 @@ Int_t AliConversionCuts::IsEventAcceptedByConversionCut(AliConversionCuts *Reade
 
    if(isHeavyIon && !(IsCentralitySelected(InputEvent,MCEvent)))
       return 1; // Check Centrality --> Not Accepted => eventQuality = 1
-   
+
    if(!isHeavyIon && GetIsFromPileup()){
       if(InputEvent->IsPileupFromSPD(3,0.8,3.,2.,5.)){
          return 6; // Check Pileup --> Not Accepted => eventQuality = 6
       }
    }
-   
+
    Bool_t hasV0And = ReaderCuts->HasV0AND();
    Bool_t isSDDFired = ReaderCuts->IsSDDFired();
    if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !MCEvent)
       return 7; // With SDD requested but no fired
-   
+
    if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
       return 8; // V0AND requested but no fired
-   
+
 
    return 0;
 }
+
+Float_t AliConversionCuts::GetWeightForMeson(TString period, Int_t index, AliStack *MCStack){
+   if (!(period.CompareTo("LHC12f1a") == 0 || period.CompareTo("LHC12f1b") == 0  || period.CompareTo("LHC12i3") == 0 )) return 1.;
+   
+   Int_t kCaseGen = 0;
+   for (Int_t i = 0; i < fnHeaders; i++){
+      if (index >= fNotRejectedStart[i] && index < fNotRejectedEnd[i]+1){
+//          cout << fGeneratorNames[i].Data() << endl;
+         if (fGeneratorNames[i].CompareTo("Pythia") == 0){
+            kCaseGen = 1;
+         } else if (fGeneratorNames[i].CompareTo("DPMJET") == 0){
+            kCaseGen = 2;
+         } else if (fGeneratorNames[i].CompareTo("HIJING") == 0){
+            kCaseGen = 3;
+         } else if (fGeneratorNames[i].CompareTo("BOX") == 0){
+            kCaseGen = 4;
+         } else if (fGeneratorNames[i].CompareTo("PARAM") == 0){
+            kCaseGen = 5;
+         } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound") == 0){
+            kCaseGen = 6;
+         } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Pythia") == 0){
+            kCaseGen = 1;
+         } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Phojet") == 0){
+            kCaseGen = 2;
+         } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Hijing") == 0){
+            kCaseGen = 3;
+         } 
+//          cout << "resulting kCaseGen :" << kCaseGen << endl;
+      }
+   }
+   
+   Double_t mesonPt = ((TParticle*)MCStack->Particle(index))->Pt();
+   
+//   Double_t mesonY = 10.;
+//   if(((TParticle*)MCStack->Particle(index))->Energy() - ((TParticle*)MCStack->Particle(index))->Pz() == 0 || ((TParticle*)MCStack->Particle(index))->Energy() + ((TParticle*)MCStack->Particle(index))->Pz() == 0){
+//      mesonY=10.;
+//   } else{
+//      mesonY = 0.5*(TMath::Log((((TParticle*)MCStack->Particle(index))->Energy()+((TParticle*)MCStack->Particle(index))->Pz()) / (((TParticle*)MCStack->Particle(index))->Energy()-((TParticle*)MCStack->Particle(index))->Pz())));
+//   }
+   Double_t mesonMass = ((TParticle*)MCStack->Particle(index))->GetCalcMass();
+   Float_t functionResult = 1.;
+   if (kCaseGen == 1){
+      Float_t dNdyMC = 2.1462;
+      Float_t nMC = 7.06055;
+      Float_t tMC = 0.12533;
+      if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  111){
+         dNdyMC = 2.1462;
+         nMC = 7.06055;
+         tMC = 0.12533;
+      } else if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  221){
+         dNdyMC = 0.2357;
+         nMC = 5.9105;
+         tMC = 0.1525;
+      }
+      functionResult = dNdyMC / ( 2 * TMath::Pi())*(nMC-1.)*(nMC-2.) / (nMC*tMC*(nMC*tMC+mesonMass*(nMC-2.)))  * pow(1.+(sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nMC*tMC), -nMC);
+   } else if (kCaseGen == 2){
+      Float_t dNdyMC = 2.35978;
+      Float_t nMC = 6.81795;
+      Float_t tMC = 0.11492;
+      if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  111){
+         dNdyMC = 2.35978;
+         nMC = 6.81795;
+         tMC = 0.11492;
+      } else if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  221){
+         dNdyMC = 0.3690;
+         nMC = 5.55809;
+         tMC = 0.13387;
+      }
+      functionResult = dNdyMC / ( 2 * TMath::Pi())*(nMC-1.)*(nMC-2.) / (nMC*tMC*(nMC*tMC+mesonMass*(nMC-2.)))  * pow(1.+(sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nMC*tMC), -nMC);
+   } else if (kCaseGen == 4){
+//       functionResult = 1./sqrt(1.-mesonMass*mesonMass/((mesonMass*mesonMass+mesonPt*mesonPt)*cosh(mesonY)*cosh(mesonY)));
+      Float_t a = 0.23437;
+      Float_t b = 5.6661;
+      Float_t c = -1430.5863;
+      Float_t d = -0.6966624;
+      Float_t e = 252.3742;
+      if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  111){
+         a = 0.23437;
+         b = 5.6661;
+         c = -1430.5863;
+         d = -0.6966624;
+         e = 252.3742;
+      } else if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  221){
+         a = 0.10399;
+         b = 4.35311;
+         c = -12.17723;
+         d = -0.01172;
+         e =1.85140;
+      }
+      functionResult = a*TMath::Power(mesonPt,-1.*(b+c/(TMath::Power(mesonPt,d)+e)))*1./mesonPt *1./1.6 *1./(2.* TMath::Pi());
+   }
+   
+   Float_t dNdyData = 2.2328;
+   Float_t nData = 7.1473;
+   Float_t tData = 0.1346;
+   if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  111){
+         dNdyData = 2.2328;
+         nData = 7.1473;
+         tData = 0.1346;
+      } else if ( ((TParticle*)MCStack->Particle(index))->GetPdgCode() ==  221){
+         dNdyData = 0.38992; //be careful this fit is not optimal, eta in data still has problems
+         nData = 5.72778;
+         tData = 0.13835;
+      }
+   Float_t tsallisData = dNdyData / ( 2 * TMath::Pi())*(nData-1.)*(nData-2.) / (nData*tData*(nData*tData+mesonMass*(nData-2.)))  * pow(1.+(sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nData*tData), -nData);
+//    cout << "tsallisData/functionResult: " << tsallisData/functionResult << endl;
+   return tsallisData/functionResult;
+//       return 
+}
+
+///________________________________________________________________________
+AliConversionCuts* AliConversionCuts::GetStandardCuts2010PbPb(){
+    //Create and return standard 2010 PbPb cuts
+    AliConversionCuts *cuts=new AliConversionCuts("StandardCuts2010PbPb","StandardCuts2010PbPb");
+    if(!cuts->InitializeCutsFromCutString("1000002042092970023220000")){
+       cout<<"Warning: Initialization of Standardcuts2010PbPb failed"<<endl;}
+    return cuts;
+}
+
+///________________________________________________________________________
+AliConversionCuts* AliConversionCuts::GetStandardCuts2010pp(){
+    //Create and return standard 2010 PbPb cuts
+    AliConversionCuts *cuts=new AliConversionCuts("StandardCuts2010pp","StandardCuts2010pp");
+    if(!cuts->InitializeCutsFromCutString("0000011002093663003800000")){
+       cout<<"Warning: Initialization of Standardcuts2010pp failed"<<endl;}
+    return cuts;
+}
+
index 7d4d70b..17e0a4d 100644 (file)
@@ -96,11 +96,14 @@ class AliConversionCuts : public AliAnalysisCuts {
   Bool_t GetIsFromPileup(){return fRemovePileUp;}
   
   AliConversionCuts(const char *name="V0Cuts", const char * title="V0 Cuts");
-  AliConversionCuts(const AliConversionCuts &ref);
-  AliConversionCuts& operator=(const AliConversionCuts&); // not implemented
+  AliConversionCuts(const AliConversionCuts&);
+  AliConversionCuts& operator=(const AliConversionCuts&);
 
   virtual ~AliConversionCuts();                            //virtual destructor
 
+  static AliConversionCuts * GetStandardCuts2010PbPb();
+  static AliConversionCuts * GetStandardCuts2010pp();
+
   virtual Bool_t IsSelected(TObject* /*obj*/){return kTRUE;}
   virtual Bool_t IsSelected(TList* /*list*/) {return kTRUE;}
 
@@ -153,7 +156,7 @@ class AliConversionCuts : public AliAnalysisCuts {
   Bool_t CosinePAngleCut(const AliConversionPhotonBase * photon, AliVEvent * event) const;
   Bool_t RejectSharedElectronV0s(AliAODConversionPhoton* photon, Int_t nV0, Int_t nV0s);
   Bool_t RejectToCloseV0s(AliAODConversionPhoton* photon, TList *photons, Int_t nV0);
-  Bool_t IsParticleFromBGEvent(Int_t index, AliStack *MCStack);
+  Int_t IsParticleFromBGEvent(Int_t index, AliStack *MCStack);
   void GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliMCEvent *MCEvent);
 
   // Event Cuts
@@ -197,12 +200,17 @@ class AliConversionCuts : public AliAnalysisCuts {
 
   Bool_t IsHeavyIon(){return fIsHeavyIon;}
   Int_t GetFirstTPCRow(Double_t radius);
+  Float_t GetWeightForMeson(TString period, Int_t index, AliStack *MCStack);
 
   Bool_t UseElecSharingCut(){return fDoSharedElecCut;}
   Bool_t UseToCloseV0sCut(){return fDoToCloseV0sCut;}
   Int_t GetMultiplicityMethod(){return fMultiplicityMethod;}
   Double_t GetEtaCut(){return fEtaCut;}
   Int_t GetSignalRejection(){return fRejectExtraSignals;}
+  Int_t GetNAcceptedHeaders(){return fnHeaders; }
+  TString * GetAcceptedHeaderNames(){return fGeneratorNames;}
+  Int_t * GetAcceptedHeaderStart(){return fNotRejectedStart;}
+  Int_t * GetAcceptedHeaderEnd(){return fNotRejectedEnd;}
   TList* GetAcceptedHeader(){return fHeaderList;}
 
   protected:
@@ -320,6 +328,8 @@ class AliConversionCuts : public AliAnalysisCuts {
   TH1F *hCentrality; // centrality distribution for selected events
   TH1F *hVertexZ; // vertex z distribution for selected events
   TH1F *hTriggerClass; //fired offline trigger class
+  TH1F *hTriggerClassSelected; //selected fired offline trigger class
+private:
 
   ClassDef(AliConversionCuts,3)
 };
index ee7e77f..b4bd352 100644 (file)
@@ -87,7 +87,7 @@ AliConversionMesonCuts::AliConversionMesonCuts(const char *name,const char *titl
    fPSigSmearingCte(0),
    fBrem(NULL),
    fRandom(0),
-   fElectronArraySize(500),
+   fElectronLabelArraySize(500),
    fElectronLabelArray(NULL),
    fBackgroundHandler(0),
    fCutString(NULL),
@@ -97,7 +97,7 @@ AliConversionMesonCuts::AliConversionMesonCuts(const char *name,const char *titl
 {
    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
    fCutString=new TObjString((GetCutNumber()).Data());
-   fElectronLabelArray = new Int_t[500];
+   fElectronLabelArray = new Int_t[fElectronLabelArraySize];
    if (fBrem == NULL){
       fBrem = new TF1("fBrem","pow(-log(x),[0]/log(2.0)-1.0)/TMath::Gamma([0]/log(2.0))",0.00001,0.999999999);
       // tests done with 1.0e-14
@@ -133,7 +133,7 @@ AliConversionMesonCuts::AliConversionMesonCuts(const AliConversionMesonCuts &ref
    fPSigSmearingCte(ref.fPSigSmearingCte),
    fBrem(NULL),
    fRandom(ref.fRandom),
-   fElectronArraySize(ref.fElectronArraySize),
+   fElectronLabelArraySize(ref.fElectronLabelArraySize),
    fElectronLabelArray(NULL),
    fBackgroundHandler(ref.fBackgroundHandler),
    fCutString(NULL),
@@ -141,14 +141,15 @@ AliConversionMesonCuts::AliConversionMesonCuts(const AliConversionMesonCuts &ref
    hMesonBGCuts(NULL)
    
 {
-    // Copy Constructor
-    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=ref.fCuts[jj];}
-    fCutString=new TObjString((GetCutNumber()).Data());
-    fElectronLabelArray = new Int_t[fElectronArraySize];
-    if (fBrem == NULL)fBrem = (TF1*)ref.fBrem->Clone("fBrem");
-    // Histograms are not copied, if you need them, call InitCutHistograms
+   // Copy Constructor
+   for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=ref.fCuts[jj];}
+   fCutString=new TObjString((GetCutNumber()).Data());
+   fElectronLabelArray = new Int_t[fElectronLabelArraySize];
+   if (fBrem == NULL)fBrem = (TF1*)ref.fBrem->Clone("fBrem");
+   // Histograms are not copied, if you need them, call InitCutHistograms
 }
 
+
 //________________________________________________________________________
 AliConversionMesonCuts::~AliConversionMesonCuts() {
    // Destructor
index c736443..d1d5990 100644 (file)
@@ -62,7 +62,7 @@ class AliConversionMesonCuts : public AliAnalysisCuts {
    
   AliConversionMesonCuts(const char *name="MesonCuts", const char * title="Meson Cuts");
   AliConversionMesonCuts(const AliConversionMesonCuts&);
-  AliConversionMesonCuts& operator=(const AliConversionMesonCuts&); // not implemented
+  AliConversionMesonCuts& operator=(const AliConversionMesonCuts&);
 
   virtual ~AliConversionMesonCuts();                            //virtual destructor
 
@@ -136,8 +136,8 @@ class AliConversionMesonCuts : public AliAnalysisCuts {
   Double_t fPSigSmearingCte; //
   TF1 *fBrem; //
   TRandom3 fRandom; //
-  Int_t fElectronArraySize; // size of electron label array
-  Int_t *fElectronLabelArray; //[fElectronArraySize]
+  Int_t fElectronLabelArraySize;
+  Int_t *fElectronLabelArray; //[fElectronLabelArraySize] Array with elec/pos v0 label
   Int_t fBackgroundHandler; //
   
   // Histograms
@@ -145,6 +145,10 @@ class AliConversionMesonCuts : public AliAnalysisCuts {
   TH1F *hMesonCuts; // bookkeeping for meson cuts
   TH1F *hMesonBGCuts; // bookkeeping for meson bg cuts
 
+
+private:
+
+
   ClassDef(AliConversionMesonCuts,3)
 };
 
index 795b070..08130ad 100644 (file)
@@ -68,7 +68,9 @@ AliAnalysisCuts(),
   fhPt(NULL),
   fhPhiPt(NULL),
   fhdcaxyPt(NULL),
-//  fCutAxis(),
+  fhdcazPt(NULL),
+  fhnclpt(NULL),
+  fhnclsfpt(NULL),
   fHistograms(NULL)
 {
   //Constructor
@@ -91,6 +93,7 @@ AliConversionTrackCuts::AliConversionTrackCuts(TString name, TString title = "ti
   fITSminNClusters(0),
   fITSmaxChi2(1E20),
   fTPCminNClusters(0),
+  fTPCClusOverFindable(0.0),
   fTPCmaxChi2(1E20),
   fAODTestFilterBit(-1),
   fRequireTPCRefit(kFALSE),
@@ -98,6 +101,9 @@ AliConversionTrackCuts::AliConversionTrackCuts(TString name, TString title = "ti
   fhPt(NULL),
   fhPhiPt(NULL),
   fhdcaxyPt(NULL),
+  fhdcazPt(NULL),
+  fhnclpt(NULL),
+  fhnclsfpt(NULL),
   fHistograms(NULL)
 {
   //Constructor
index efa58f2..5364132 100644 (file)
@@ -1,3 +1,4 @@
+
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                       *
@@ -59,6 +60,7 @@ const char* AliDalitzElectronCuts::fgkCutNames[AliDalitzElectronCuts::kNCuts] =
 "PsiPair",
 "RejectSharedElecGamma",
 "BackgroundScheme",
+"NumberOfRotations",
 };
 
 //________________________________________________________________________
@@ -101,6 +103,7 @@ AliDalitzElectronCuts::AliDalitzElectronCuts(const char *name,const char *title)
     fUseTOFpid(kFALSE),
     fUseTrackMultiplicityForBG(kFALSE),
     fBKGMethod(0),
+    fnumberOfRotationEventsForBG(0),
     fCutString(NULL),
     hCutIndex(NULL),
     hdEdxCuts(NULL),
@@ -108,6 +111,7 @@ AliDalitzElectronCuts::AliDalitzElectronCuts(const char *name,const char *title)
     hITSdEdxafter(NULL),
     hTPCdEdxbefore(NULL),
     hTPCdEdxafter(NULL),
+    hTPCdEdxSignalafter(NULL),
     hTOFbefore(NULL),
     hTOFafter(NULL)
    {
@@ -140,10 +144,18 @@ AliDalitzElectronCuts::~AliDalitzElectronCuts() {
 }
 
 //________________________________________________________________________
-void AliDalitzElectronCuts::InitCutHistograms(TString name, Bool_t preCut){
+void AliDalitzElectronCuts::InitCutHistograms(TString name, Bool_t preCut,TString cutNumber){
 
     // Initialize Cut Histograms for QA (only initialized and filled if function is called)
 
+     TString cutName = "";
+    
+     if( cutNumber==""){
+         cutName = GetCutNumber().Data();
+     }
+     else {
+            cutName = cutNumber.Data();
+     } 
 
     if(fHistograms != NULL){
        delete fHistograms;
@@ -151,12 +163,12 @@ void AliDalitzElectronCuts::InitCutHistograms(TString name, Bool_t preCut){
     }
     if(fHistograms==NULL){
        fHistograms=new TList();
-       if(name=="")fHistograms->SetName(Form("ElectronCuts_%s",GetCutNumber().Data()));
-       else fHistograms->SetName(Form("%s_%s",name.Data(),GetCutNumber().Data()));
+       if(name=="")fHistograms->SetName(Form("ElectronCuts_%s",cutName.Data()));
+       else fHistograms->SetName(Form("%s_%s",name.Data(),cutName.Data()));
     }
 
 
-    hCutIndex=new TH1F(Form("IsElectronSelected %s",GetCutNumber().Data()),"IsElectronSelected",10,-0.5,9.5);
+    hCutIndex=new TH1F(Form("IsElectronSelected %s",cutName.Data()),"IsElectronSelected",10,-0.5,9.5);
     hCutIndex->GetXaxis()->SetBinLabel(kElectronIn+1,"in");
     hCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks");
     hCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts");
@@ -167,7 +179,7 @@ void AliDalitzElectronCuts::InitCutHistograms(TString name, Bool_t preCut){
 
 
     // dEdx Cuts
-    hdEdxCuts=new TH1F(Form("dEdxCuts %s",GetCutNumber().Data()),"dEdxCuts",10,-0.5,9.5);
+    hdEdxCuts=new TH1F(Form("dEdxCuts %s",cutName.Data()),"dEdxCuts",10,-0.5,9.5);
     hdEdxCuts->GetXaxis()->SetBinLabel(1,"in");
     hdEdxCuts->GetXaxis()->SetBinLabel(2,"ITSelectron");
     hdEdxCuts->GetXaxis()->SetBinLabel(3,"TPCelectron");
@@ -189,28 +201,31 @@ void AliDalitzElectronCuts::InitCutHistograms(TString name, Bool_t preCut){
     if(preCut){
 
 
-       hITSdEdxbefore=new TH2F(Form("Electron_ITS_before %s",GetCutNumber().Data()),"ITS dEdx electron before" ,150,0.05,20,400,-10,10);
+       hITSdEdxbefore=new TH2F(Form("Electron_ITS_before %s",cutName.Data()),"ITS dEdx electron before" ,150,0.05,20,400,-10,10);
        fHistograms->Add(hITSdEdxbefore);
        AxisBeforeITS = hITSdEdxbefore->GetXaxis();
 
-       hTPCdEdxbefore=new TH2F(Form("Electron_dEdx_before %s",GetCutNumber().Data()),"dEdx electron before" ,150,0.05,20,400,-10,10);
+       hTPCdEdxbefore=new TH2F(Form("Electron_dEdx_before %s",cutName.Data()),"dEdx electron before" ,150,0.05,20,400,-10,10);
        fHistograms->Add(hTPCdEdxbefore);
        AxisBeforedEdx = hTPCdEdxbefore->GetXaxis();
 
-       hTOFbefore=new TH2F(Form("Electron_TOF_before %s",GetCutNumber().Data()),"TOF electron before" ,150,0.05,20,400,-6,10);
+       hTOFbefore=new TH2F(Form("Electron_TOF_before %s",cutName.Data()),"TOF electron before" ,150,0.05,20,400,-6,10);
        fHistograms->Add(hTOFbefore);
        AxisBeforeTOF = hTOFbefore->GetXaxis();
 
     }
 
 
-    hITSdEdxafter=new TH2F(Form("Electron_ITS_after %s",GetCutNumber().Data()),"ITS dEdx electron after" ,150,0.05,20,400, -10,10);
+    hITSdEdxafter=new TH2F(Form("Electron_ITS_after %s",cutName.Data()),"ITS dEdx electron after" ,150,0.05,20,400, -10,10);
     fHistograms->Add(hITSdEdxafter);
 
-    hTPCdEdxafter=new TH2F(Form("Electron_dEdx_after %s",GetCutNumber().Data()),"dEdx electron after" ,150,0.05,20,400, -10,10);
+    hTPCdEdxafter=new TH2F(Form("Electron_dEdx_after %s",cutName.Data()),"dEdx electron after" ,150,0.05,20,400, -10,10);
     fHistograms->Add(hTPCdEdxafter);
 
-    hTOFafter=new TH2F(Form("Electron_TOF_after %s",GetCutNumber().Data()),"TOF electron after" ,150,0.05,20,400,-6,10);
+    hTPCdEdxSignalafter=new TH2F(Form("Electron_dEdxSignal_after %s",cutName.Data()),"dEdx electron signal after" ,150,0.0,3.0,200,0.0,200);
+    fHistograms->Add(hTPCdEdxSignalafter);
+
+    hTOFafter=new TH2F(Form("Electron_TOF_after %s",cutName.Data()),"TOF electron after" ,150,0.05,20,400,-6,10);
     fHistograms->Add(hTOFafter);
 
     TAxis *AxisAfter = hTPCdEdxafter->GetXaxis(); 
@@ -224,9 +239,6 @@ void AliDalitzElectronCuts::InitCutHistograms(TString name, Bool_t preCut){
     AxisAfter->Set(bins, newBins);
     AxisAfter = hTOFafter->GetXaxis(); 
     AxisAfter->Set(bins, newBins);
-        AxisAfter = hITSdEdxafter->GetXaxis(); 
-    AxisAfter->Set(bins, newBins);
-
     if(preCut){
        AxisBeforeITS->Set(bins, newBins);
        AxisBeforedEdx->Set(bins, newBins);
@@ -473,8 +485,8 @@ Bool_t AliDalitzElectronCuts::dEdxCuts(AliVTrack *fCurrentTrack){
   cutIndex++;
 
    
-  if((fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid) && !(fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
-     if(hTOFbefore) hTOFbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron));
+  if( ( fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid ) && ( !( fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch) ) ){
+   if(hTOFbefore) hTOFbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron));
      if(fUseTOFpid){
         if(fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)>fTofPIDnSigmaAboveElectronLine ||
            fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron)<fTofPIDnSigmaBelowElectronLine ){
@@ -488,6 +500,7 @@ Bool_t AliDalitzElectronCuts::dEdxCuts(AliVTrack *fCurrentTrack){
 
   if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
   if(hTPCdEdxafter)hTPCdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron));
+  if(hTPCdEdxSignalafter)hTPCdEdxSignalafter->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal()));
 
   return kTRUE;
 }
@@ -538,8 +551,8 @@ Bool_t AliDalitzElectronCuts::RejectSharedElecGamma(TList *photons, Int_t indexE
 
    return kTRUE;
 }
-
-Double_t AliDalitzElectronCuts::GetPsiPair( const AliESDtrack* trackPos, const AliESDtrack* trackNeg ) const
+/*
+Double_t AliDalitzElectronCuts::GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg )
 {
 //
 // This angle is a measure for the contribution of the opening in polar
@@ -562,13 +575,15 @@ Double_t AliDalitzElectronCuts::GetPsiPair( const AliESDtrack* trackPos, const A
 
         Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta();
         Double_t openingAngle =  posDaughter.Angle( negDaughter );  //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) );
+
         if( openingAngle < 1e-20 ) return 0.;
+
         Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle );
 
         return psiAngle;
-}
+}*/
 
-Bool_t AliDalitzElectronCuts::IsFromGammaConversion( Double_t psiPair, Double_t deltaPhi ) const
+Bool_t AliDalitzElectronCuts::IsFromGammaConversion( Double_t psiPair, Double_t deltaPhi )
 {
 //
 // Returns true if it is a gamma conversion according to psi pair value
@@ -728,6 +743,13 @@ Bool_t AliDalitzElectronCuts::SetCut(cutIds cutID, const Int_t value) {
           return kTRUE;
         } else return kFALSE;
 
+  case kNumberOfRotations:
+        if( SetNumberOfRotations(value)) {
+          fCuts[kNumberOfRotations] = value;
+          UpdateCutString(cutID, value);
+          return kTRUE;
+        } else return kFALSE;
+
   case kNCuts:
        cout << "Error:: Cut id out of range"<< endl;
        return kFALSE;
@@ -1093,17 +1115,17 @@ Bool_t AliDalitzElectronCuts::SetLowPRejectionCuts(Int_t LowPRejectionSigmaCut)
         fDoKaonRejectionLowP=kTRUE;
         fDoProtonRejectionLowP=kTRUE;
         fDoPionRejectionLowP=kTRUE;
-       fPIDnSigmaAtLowPAroundKaonLine=0.;
-       fPIDnSigmaAtLowPAroundProtonLine=0.;
-       fPIDnSigmaAtLowPAroundPionLine=1;
+       fPIDnSigmaAtLowPAroundKaonLine=2.0;
+       fPIDnSigmaAtLowPAroundProtonLine=2.0;
+       fPIDnSigmaAtLowPAroundPionLine=2.0;
        break;
     case 5:  //
         fDoKaonRejectionLowP=kTRUE;
         fDoProtonRejectionLowP=kTRUE;
         fDoPionRejectionLowP=kTRUE;
-       fPIDnSigmaAtLowPAroundKaonLine=0.;
-       fPIDnSigmaAtLowPAroundProtonLine=0.;
-       fPIDnSigmaAtLowPAroundPionLine=1.5;
+       fPIDnSigmaAtLowPAroundKaonLine=2.0;
+       fPIDnSigmaAtLowPAroundProtonLine=2.0;
+       fPIDnSigmaAtLowPAroundPionLine=2.5;
        break;
     case 6:  //
         fDoKaonRejectionLowP=kTRUE;
@@ -1163,7 +1185,7 @@ Bool_t AliDalitzElectronCuts::SetPsiPairCut(Int_t psiCut) {
   switch(psiCut) {
   case 0:
         fDoPsiPairCut = kFALSE;
-        fPsiPairCut = 10000; //
+        fPsiPairCut = 10000.; //
         fDeltaPhiCutMin = -1000.;
         fDeltaPhiCutMax =  1000.;
         
@@ -1248,6 +1270,9 @@ Bool_t AliDalitzElectronCuts::SetBackgroundScheme(Int_t BackgroundScheme){
             fUseTrackMultiplicityForBG = kTRUE;
             fBKGMethod  = 2;
         break;
+    case 5: fUseTrackMultiplicityForBG = kTRUE;
+            fBKGMethod  = 3;
+        break;
 
     default:
         cout<<"Warning: BackgroundScheme not defined "<<BackgroundScheme<<endl;
@@ -1255,6 +1280,41 @@ Bool_t AliDalitzElectronCuts::SetBackgroundScheme(Int_t BackgroundScheme){
     }
     return kTRUE;
 }
+
+///________________________________________________________________________
+Bool_t AliDalitzElectronCuts::SetNumberOfRotations(Int_t NumberOfRotations)
+{   // Set Cut
+    switch(NumberOfRotations){
+    case 0:
+        fnumberOfRotationEventsForBG = 5;
+        break;
+    case 1:
+        fnumberOfRotationEventsForBG = 10;
+        break;
+    case 2:
+        fnumberOfRotationEventsForBG = 15;
+        break;
+    case 3:
+        fnumberOfRotationEventsForBG = 20;
+        break;
+    case 4:
+        fnumberOfRotationEventsForBG = 2;
+        break;
+    case 5:
+        fnumberOfRotationEventsForBG = 50;
+        break;
+    case 6:
+        fnumberOfRotationEventsForBG = 80;
+        break;
+    case 7:
+        fnumberOfRotationEventsForBG = 100;
+        break;
+    default:
+        cout<<"Warning: NumberOfRotations not defined "<<NumberOfRotations<<endl;
+        return kFALSE;
+    }
+    return kTRUE;
+}
 ///________________________________________________________________________
 TString AliDalitzElectronCuts::GetCutNumber(){
     // returns TString with current cut number
index d4d0e5d..38f607b 100644 (file)
@@ -53,6 +53,7 @@ class AliDalitzElectronCuts : public AliAnalysisCuts {
         kPsiPair,
         kRejectSharedElecGamma,
         kBackgroundScheme,
+        kNumberOfRotations,
        kNCuts
   };
 
@@ -97,8 +98,8 @@ class AliDalitzElectronCuts : public AliAnalysisCuts {
   
   void PrintCuts();
 
-  void InitCutHistograms(TString name="",Bool_t preCut = kTRUE);
-  void SetFillCutHistograms(TString name="",Bool_t preCut = kTRUE){if(!fHistograms){InitCutHistograms(name,preCut);};}
+  void InitCutHistograms(TString name="",Bool_t preCut = kTRUE,TString cutName="");
+  void SetFillCutHistograms(TString name="",Bool_t preCut = kTRUE,TString cutName=""){if(!fHistograms){InitCutHistograms(name,preCut,cutName);};}
   TList *GetCutHistograms(){return fHistograms;}
 
   static AliVTrack * GetTrack(AliVEvent * event, Int_t label);
@@ -109,11 +110,11 @@ class AliDalitzElectronCuts : public AliAnalysisCuts {
   Bool_t dEdxCuts(AliVTrack * track);
   Bool_t PIDProbabilityCut(AliConversionPhotonBase *photon, AliVEvent * event);
   Bool_t RejectSharedElecGamma(TList *photons, Int_t indexEle);
-  Bool_t IsFromGammaConversion( Double_t psiPair, Double_t deltaPhi ) const;
+  Bool_t IsFromGammaConversion( Double_t psiPair, Double_t deltaPhi );
 
   // Event Cuts
 
-  Double_t GetPsiPair( const AliESDtrack* trackPos, const AliESDtrack* trackNeg ) const;
+  //Double_t GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg );
 
   Bool_t SetTPCdEdxCutPionLine(Int_t pidedxSigmaCut);
   Bool_t SetTPCdEdxCutElectronLine(Int_t ededxSigmaCut);
@@ -129,6 +130,7 @@ class AliDalitzElectronCuts : public AliAnalysisCuts {
   Bool_t SetPsiPairCut(Int_t psiCut);
   Bool_t SetRejectSharedElecGamma(Int_t RCut);
   Bool_t SetBackgroundScheme(Int_t BackgroundScheme);
+  Bool_t SetNumberOfRotations(Int_t NumberOfRotations);
   
   // Request Flags
 
@@ -138,6 +140,7 @@ class AliDalitzElectronCuts : public AliAnalysisCuts {
   Double_t DoPsiPairCut(){return fDoPsiPairCut;}
   Bool_t   UseTrackMultiplicity(){ return fUseTrackMultiplicityForBG;}
   Int_t    GetBKGMethod(){ return fBKGMethod; }
+  Int_t    NumberOfRotationEvents(){return fnumberOfRotationEventsForBG;}
   
 
   
@@ -183,6 +186,7 @@ class AliDalitzElectronCuts : public AliAnalysisCuts {
   Bool_t   fUseTOFpid; // flag to use tof pid
   Bool_t   fUseTrackMultiplicityForBG; // use multiplicity
   Int_t    fBKGMethod;
+  Int_t    fnumberOfRotationEventsForBG;
 
 
   // Histograms
@@ -193,6 +197,7 @@ class AliDalitzElectronCuts : public AliAnalysisCuts {
   TH2F *hITSdEdxafter;
   TH2F *hTPCdEdxbefore; // TPC dEdx before cuts
   TH2F *hTPCdEdxafter; // TPC dEdx after cuts
+  TH2F *hTPCdEdxSignalafter; //TPC dEdx signal
   TH2F *hTOFbefore; // TOF after cuts
   TH2F *hTOFafter; // TOF after cuts
   
@@ -203,7 +208,7 @@ private:
   AliDalitzElectronCuts& operator=(const AliDalitzElectronCuts&); // not implemented
 
 
-  ClassDef(AliDalitzElectronCuts,1)
+  ClassDef(AliDalitzElectronCuts,2)
 };
 
 
index 404cd9e..7de54bd 100644 (file)
@@ -17,51 +17,59 @@ class TH2F;
 using namespace std;
 
 class AliDalitzElectronSelector : public AliAnalysisTaskSE {
-       
- public: 
-       
-  AliDalitzElectronSelector(const char *name="ElectronSelector");
-  virtual ~AliDalitzElectronSelector();                            //virtual destructor
-  void UserCreateOutputObjects();
-
-  virtual void UserExec(Option_t *option);
-  virtual void Terminate(Option_t *);
-  virtual void Init();
-
-  Bool_t ProcessEvent(AliVEvent *inputEvent,AliMCEvent *mcEvent=NULL);
-  Bool_t IsEventSelected(){return fEventIsSelected;}
-
-  // Return selected electron/positron array 
-  vector <Int_t> GetReconstructedElectronsIndex(){ return fElectronsIndex; }
-  vector <Int_t> GetReconstructedPositronsIndex(){ return fPositronsIndex; }
-  AliDalitzElectronCuts *GetDalitzElectronCuts(){   return fElectronCuts; }
-  TList *GetCutHistograms(){ if(fElectronCuts){return fElectronCuts->GetCutHistograms();} return NULL;}
-  // Set Options
-
-  void SetDalitzElectronCuts(const TString cut);
-  void SetDalitzElectronCuts(AliDalitzElectronCuts *cuts){fElectronCuts=cuts;}
-  
-protected:
-       //selected electron arrays
-
-    Bool_t ProcessESDs();
-    AliDalitzElectronCuts *fElectronCuts; // Pointer to the ConversionCut Selection
-    vector<Int_t> fPositronsIndex;
-    vector<Int_t> fElectronsIndex;
-    Bool_t fEventIsSelected;
-
-    ClassDef(AliDalitzElectronSelector,1)
-};
+
+ public:
+
+   AliDalitzElectronSelector(const char *name="ElectronSelector");
+   //Uncopyable & operator=(const Uncopyable&);
+
+   virtual ~AliDalitzElectronSelector();                            //virtual destructor
+   void UserCreateOutputObjects();
+
+   virtual void UserExec(Option_t *option);
+   virtual void Terminate(Option_t *);
+   virtual void Init();
+
+   Bool_t ProcessEvent(AliVEvent *inputEvent,AliMCEvent *mcEvent=NULL);
+   Bool_t IsEventSelected(){return fEventIsSelected;}
+
+   // Return selected electron/positron array
+   vector <Int_t> GetReconstructedElectronsIndex(){ return fElectronsIndex; }
+   vector <Int_t> GetReconstructedPositronsIndex(){ return fPositronsIndex; }
+   AliDalitzElectronCuts *GetDalitzElectronCuts(){   return fElectronCuts; }
+   TList *GetCutHistograms(){ if(fElectronCuts){return fElectronCuts->GetCutHistograms();} return NULL;}
+   // Set Options
+
+   void SetDalitzElectronCuts(const TString cut);
+   void SetDalitzElectronCuts(AliDalitzElectronCuts *cuts){fElectronCuts=cuts;}
+
+ protected:
+   //selected electron arrays
+   
+   Bool_t ProcessESDs();
+   AliDalitzElectronCuts *fElectronCuts; // Pointer to the ConversionCut Selection
+   vector<Int_t> fPositronsIndex;
+   vector<Int_t> fElectronsIndex;
+   Bool_t fEventIsSelected;
+
+ private:
+   AliDalitzElectronSelector (const AliDalitzElectronSelector&); // not implemented
+   AliDalitzElectronSelector & operator=(const AliDalitzElectronSelector&); // not implemented
+
+
+   
+   ClassDef(AliDalitzElectronSelector,1)
+      };
 
 inline void AliDalitzElectronSelector::SetDalitzElectronCuts(const TString cut){
    if(fElectronCuts != NULL){
-               delete fElectronCuts;
-               fElectronCuts=NULL;
-       }
-       if(fElectronCuts == NULL){
-               fElectronCuts=new AliDalitzElectronCuts("ElectronCuts","ElectronCuts");
-               fElectronCuts->InitializeCutsFromCutString(cut.Data());
-       }
+      delete fElectronCuts;
+      fElectronCuts=NULL;
+   }
+   if(fElectronCuts == NULL){
+      fElectronCuts=new AliDalitzElectronCuts("ElectronCuts","ElectronCuts");
+      fElectronCuts->InitializeCutsFromCutString(cut.Data());
+   }
 }
 
 
index 907b240..13c49f0 100644 (file)
@@ -2372,9 +2372,9 @@ const AliExternalTrackParam *AliV0Reader::GetExternalTrackParam(AliESDv0 *v0,Int
 
     if(!(charge==1||charge==-1)){AliError("Charge not defined");return 0x0;}
 
-    Int_t label;
-    if(charge>0)label=0;
-    else label=1;
+    // Int_t label;
+    // if(charge>0)label=0;
+    // else label=1;
     // Check for sign flip
 
     if(v0){
@@ -2505,7 +2505,7 @@ Int_t AliV0Reader::GetNumberOfHijingPlusPythiaPrimeries(Int_t excludeHeaderType)
 
 Bool_t AliV0Reader::IsParticleFromBGEvent(Int_t index){
 
-   Bool_t particleFromBG = kFALSE;
+   //Bool_t particleFromBG = kFALSE;
   
    if(index == -1) return kFALSE;
    if(index > fNumberOfPrimerisFromHijingAndPythia && index < fMCStack->GetNprimary()){
@@ -2517,8 +2517,8 @@ Bool_t AliV0Reader::IsParticleFromBGEvent(Int_t index){
    // cout<<fMCEvent->IsFromBGEvent(index)<<endl;
    TParticle *BGParticle = fMCStack->Particle(index);
    if(BGParticle->GetMother(0) > -1) return kFALSE;
-   Int_t indexMother = fMCStack->Particle(index)->GetMother(0);
-   particleFromBG = IsParticleFromBGEvent(indexMother);
+   //Int_t indexMother = fMCStack->Particle(index)->GetMother(0);
+   //particleFromBG = IsParticleFromBGEvent(indexMother);
    
    return kFALSE;
 }
index e52affa..b89a902 100644 (file)
 #include "AliAODHandler.h"
 #include "AliPIDResponse.h"
 #include "TChain.h"
+#include "TFile.h"
 #include "AliStack.h"
+#include "TString.h"
+#include "TObjArray.h"
 
 class iostream;
 
@@ -58,7 +61,8 @@ AliV0ReaderV1::AliV0ReaderV1(const char *name) : AliAnalysisTaskSE(name),
     fCreateAOD(kFALSE),
     fDeltaAODBranchName("GammaConv"),
     fDeltaAODFilename("AliAODGammaConversion.root"),
-    fEventIsSelected(kFALSE)
+    fEventIsSelected(kFALSE),
+    fPeriodName("")
 {
     // Default constructor
 
@@ -163,6 +167,27 @@ void AliV0ReaderV1::UserCreateOutputObjects()
 //________________________________________________________________________
 void AliV0ReaderV1::UserExec(Option_t *){
 
+   if (fPeriodName.CompareTo("") == 0){
+      AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+      if(man) {
+         AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+         if (inputHandler){
+            TTree* tree = (TTree*) inputHandler->GetTree();
+            TFile* file = (TFile*) tree->GetCurrentFile();
+            TString fileName(file->GetName());
+            TObjArray *arr = fileName.Tokenize("/");
+            for (Int_t i = 0; i < arr->GetEntriesFast();i++ ){
+               TObjString* testObjString = (TObjString*)arr->At(i);
+               if (testObjString->GetString().Contains("LHC")){
+                  fPeriodName = testObjString->GetString();
+                  i = arr->GetEntriesFast();
+               }
+            }     
+//             cout << fileName.Data() << "\t" <<fPeriodName.Data() << endl;
+         }
+      }
+   }
+
     // Check if correctly initialized
     if(!fConversionGammas)Init();
 
@@ -421,14 +446,71 @@ Double_t AliV0ReaderV1::GetPsiPair(const AliESDv0* v0, const AliExternalTrackPar
     // Angle between daughter momentum plane and plane
     //
 
-    AliExternalTrackParam nt(*negativeparam);
-    AliExternalTrackParam pt(*positiveparam);
+   AliExternalTrackParam nt(*negativeparam);
+   AliExternalTrackParam pt(*positiveparam);
 
    Float_t magField = fInputEvent->GetMagneticField();
 
    Double_t xyz[3] = {0.,0.,0.};
    v0->GetXYZ(xyz[0],xyz[1],xyz[2]);
 
+   // Double_t pPlus[3]  = {pt.Px(),pt.Py(),pt.Pz()};
+   // Double_t pMinus[3] = {nt.Px(),nt.Py(),nt.Pz()};
+
+   // Double_t u[3] = {pPlus[0]+pMinus[0],pPlus[1]+pMinus[1],pPlus[2]+pMinus[2]};
+   // Double_t normu = sqrt( (u[0]*u[0]) + (u[1]*u[1]) + (u[2]*u[2]) );
+   
+   // u[0] = u[0] / normu;
+   // u[1] = u[1] / normu;
+   // u[2] = u[2] / normu;
+
+   // Double_t normpPlus = sqrt( (pPlus[0]*pPlus[0]) + (pPlus[1]*pPlus[1]) + (pPlus[2]*pPlus[2]) );
+   // Double_t normpMinus = sqrt( (pMinus[0]*pMinus[0]) + (pMinus[1]*pMinus[1]) + (pMinus[2]*pMinus[2]) );
+
+   // pPlus[0] = pPlus[0] / normpPlus;
+   // pPlus[1] = pPlus[1] / normpPlus;
+   // pPlus[2] = pPlus[2] / normpPlus;
+
+   // pMinus[0] = pMinus[0] / normpMinus;
+   // pMinus[1] = pMinus[1] / normpMinus;
+   // pMinus[2] = pMinus[2] / normpMinus;
+
+   // Double_t v[3] = {0,0,0}; // pPlus X pMinus
+   // v[0] = (pPlus[1]*pMinus[2]) - (pPlus[2]*pMinus[1]);
+   // v[1] = (pPlus[2]*pMinus[0]) - (pPlus[0]*pMinus[2]);
+   // v[2] = (pPlus[0]*pMinus[1]) - (pPlus[1]*pMinus[0]);
+   
+   // Double_t w[3] = {0,0,0}; // u X v
+   // w[0] = (u[1]*v[2]) - (u[2]*v[1]);
+   // w[1] = (u[2]*v[0]) - (u[0]*v[2]);
+   // w[2] = (u[0]*v[1]) - (u[1]*v[0]);
+
+   // Double_t z[3] = {0,0,1};
+   // Double_t wc[3] = {0,0,0}; // u X v
+   // wc[0] = (u[1]*z[2]) - (u[2]*z[1]);
+   // wc[1] = (u[2]*z[0]) - (u[0]*z[2]);
+   // wc[2] = (u[0]*z[1]) - (u[1]*z[0]);
+
+   // Double_t PhiV = TMath::ACos((w[0]*wc[0]) + (w[1]*wc[1]) + (w[2]*wc[2]));
+   //return abs(PhiV);
+
+
+   // TVector3 pPlus(pt.Px(),pt.Py(),pt.Pz());
+   // TVector3 pMinus(nt.Px(),nt.Py(),nt.Pz());
+
+   // TVector3 u = pMinus + pPlus;
+   // u = u*(1/u.Mag());
+
+   // TVector3 pHPlus = pPlus*(1/pPlus.Mag());
+   // TVector3 pHMinus = pMinus*(1/pMinus.Mag());
+
+   // TVector3 v = pHPlus.Cross(pHMinus);
+   // TVector3 w = u.Cross(v);
+   // TVector3 z(0,0,1);
+   // TVector3 wc = u.Cross(z);
+
+   // Double_t PhiV = w * wc;
+
    Double_t mn[3] = {0,0,0};
    Double_t mp[3] = {0,0,0};
 
@@ -436,7 +518,7 @@ Double_t AliV0ReaderV1::GetPsiPair(const AliESDv0* v0, const AliExternalTrackPar
    v0->GetPPxPyPz(mp[0],mp[1],mp[2]);//reconstructed cartesian momentum components of positive daughter;
 
    Double_t deltat = 1.;
-   deltat = TMath::ATan(mp[2]/(TMath::Sqrt(mp[0]*mp[0] + mp[1]*mp[1])+1.e-13)) -  TMath::ATan(mn[2]/(TMath::Sqrt(mn[0]*mn[0] + mn[1]*mn[1])+1.e-13));//difference of angles of the two daughter tracks with z-axis
+   deltat = TMath::ATan(mp[2]/(TMath::Sqrt(mp[0]*mp[0] + mp[1]*mp[1])+1.e-13)) - TMath::ATan(mn[2]/(TMath::Sqrt(mn[0]*mn[0] + mn[1]*mn[1])+1.e-13));//difference of angles of the two daughter tracks with z-axis
    Double_t radiussum = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) + 50;//radius to which tracks shall be propagated
 
    Double_t momPosProp[3] = {0,0,0};
@@ -444,7 +526,6 @@ Double_t AliV0ReaderV1::GetPsiPair(const AliESDv0* v0, const AliExternalTrackPar
 
    Double_t psiPair = 4.;
    if(nt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency
-
    if(pt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency
 
    pt.GetPxPyPz(momPosProp);//Get momentum vectors of tracks after propagation
index b916fc2..c519a61 100644 (file)
@@ -51,6 +51,7 @@ class AliV0ReaderV1 : public AliAnalysisTaskSE {
   void SetCreateAODs(Bool_t k=kTRUE){fCreateAOD=k;}
   void SetDeltaAODFilename(TString s){fDeltaAODFilename=s;}
   void SetDeltaAODBranchName(TString string) { fDeltaAODBranchName = string;AliInfo(Form("Set DeltaAOD BranchName to: %s",fDeltaAODBranchName.Data()));}
+  TString GetPeriodName(){return fPeriodName;}
 
 protected:
     // Reconstruct Gammas
@@ -84,13 +85,14 @@ protected:
     TString     fDeltaAODBranchName;// File where Gamma Conv AOD is located, if not in default AOD
     TString fDeltaAODFilename; // set filename for delta/satellite aod
     Bool_t fEventIsSelected;
+    TString fPeriodName;
 
 private:
     AliV0ReaderV1(AliV0ReaderV1 &original);
     AliV0ReaderV1 &operator=(const AliV0ReaderV1 &ref);
 
 
-    ClassDef(AliV0ReaderV1,1)
+    ClassDef(AliV0ReaderV1,2)
 };
 
 inline void AliV0ReaderV1::SetConversionCuts(const TString cut){
index 6724ef6..afb02eb 100644 (file)
@@ -1,44 +1,94 @@
-AliAnalysisTask *AddTask_GammaConvV1(TString collisionSystem = "pp"){
-                       
-   //get the current analysis manager
+
+void AddTask_GammaConvV1(TString trainConfig = "pp",   Bool_t isMC     = kFALSE){
+
+   gSystem->Load("libCore.so");  
+   gSystem->Load("libTree.so");
+   gSystem->Load("libGeom.so");
+   gSystem->Load("libVMC.so");
+   gSystem->Load("libPhysics.so");
+   gSystem->Load("libMinuit");
+   gSystem->Load("libSTEERBase");
+   gSystem->Load("libESD");
+   gSystem->Load("libAOD");
+   gSystem->Load("libANALYSIS");
+   gSystem->Load("libANALYSISalice");  
+   gSystem->Load("libPWGGAGammaConv.so");
+   gSystem->Load("libCDB.so");
+   gSystem->Load("libSTEER.so");
+   gSystem->Load("libSTEERBase.so");
+   gSystem->Load("libTENDER.so");
+   gSystem->Load("libTENDERSupplies.so");
+      
+
    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
    if (!mgr) {
       Error("AddTask_GammaConvV1", "No analysis manager found.");
       return 0;
    }
-   
-   Bool_t IsHeavyIon=collisionSystem.Contains("PbPb");
+      
+   Bool_t IsHeavyIon=collisionSystem.Contains("Pb");
+
 
    TString cutnumber = "";
-       TString cutnumberMeson = "";
-   if(IsHeavyIon){ 
-               cutnumber = "1080000002084001001500000";cutnumberMeson = "01021035000"; 
-       } else{
-               cutnumber = "0000000002084001001500000";cutnumberMeson = "01631035000"; 
-       }
-       
+   if(IsHeavyIon){
+      cutnumber = "1000000002084001001500000";
+   } else{
+      cutnumber = "0000000002084000002200000";
+   }
+
    //========= Add PID Reponse to ANALYSIS manager ====
    if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
       gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
       AddTaskPIDResponse();
-   }
-   
-   //========= Add V0 Reader to  ANALYSIS manager =====
-   AliV0ReaderV1 *fV0ReaderV1=new AliV0ReaderV1("V0ReaderV1");
-   ConfigV0ReaderV1(fV0ReaderV1,cutnumber,IsHeavyIon);
-   mgr->AddTask(fV0ReaderV1);
   
+      
+   //========= Add V0 Reader to  ANALYSIS manager =====
+   AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
+   
+   fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
+   fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
+   fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
+
+   if (!mgr) {
+      Error("AddTask_V0ReaderV1", "No analysis manager found.");
+      return;
+   }
+   AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
+
+   if(inputHandler->IsA()==AliESDInputHandler::Class()){
+      // ESD mode
+   }
+
+   if(inputHandler->IsA()==AliAODInputHandler::Class()){
+      // AOD mode
+      //   task->SetUseSatelliteAODs(kTRUE);
+   }
+
+   // Set AnalysisCut Number
+   AliConversionCuts *fCuts=NULL;
+   if(cutnumber!=""){
+      fCuts= new AliConversionCuts(cutnumber.Data(),cutnumber.Data());
+      if(fCuts->InitializeCutsFromCutString(cutnumber.Data())){
+         fV0ReaderV1->SetConversionCuts(fCuts);
+         fCuts->SetFillCutHistograms("",kTRUE);
+      }
+   }
+   fV0ReaderV1->Init();
+
+
+
    AliLog::SetGlobalLogLevel(AliLog::kInfo);
 
-      //================================================
+   //================================================
    //              data containers
    //================================================
    //            find input container
    //below the trunk version
-   AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
+   AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
    //connect input V0Reader
-   mgr->ConnectInput (fV0ReaderV1,0,cinput);
-   
+   mgr->AddTask(fV0ReaderV1);
+   mgr->ConnectInput(fV0ReaderV1,0,cinput);
+
    //================================================
    //========= Add task to the ANALYSIS manager =====
    //================================================
@@ -47,416 +97,76 @@ AliAnalysisTask *AddTask_GammaConvV1(TString collisionSystem = "pp"){
    //            find input container
    AliAnalysisTaskGammaConvV1 *task=NULL;
    task= new AliAnalysisTaskGammaConvV1("GammaConvV1");
-   task->SetIsHeavyIon(IsHeavyIon); 
+   task->SetIsHeavyIon(IsHeavyIon);
    // Cut Numbers to use in Analysis
-   
    Int_t numberOfCuts = 1;
-   if(trainConfig.Contains("PbPb")) numberOfCuts = 21;
-   else if(trainConfig.Contains("pPb")) numberOfCuts = 1;
-       else numberOfCuts = 9;
-       
-   TString *cutarray = new TString[numberOfCuts];
-       TString *mesonCutArray = new TString[numberOfCuts];
-   if(trainConfig.Contains("PbPb")){
-               // Standard Cuts 
-//       cutarray[0] = "1000000042092970023220000"; mesonCutArray[0] = "01022045000";  //standard cut Pi0 PbPb 00-100
-//                     cutarray[0] = "1000001042092970023220000"; mesonCutArray[0] = "01022045000";  //standard cut Pi0 PbPb 00-100
-//       cutarray[2] = "1000002042092970023220000"; mesonCutArray[2] = "01022045000";  //standard cut Pi0 PbPb 00-100
-//                     cutarray[0] = "3010001042092970023220000"; mesonCutArray[0] = "01022045000";  //standard cut Pi0 PbPb 00-05
-//                     cutarray[1] = "3120001042092970023220000"; mesonCutArray[1] = "01022045000";  //standard cut Pi0 PbPb 05-10
-//                     cutarray[2] = "1010001042092970023220000"; mesonCutArray[2] = "01022045000";  //standard cut Pi0 PbPb 00-10
-//                     cutarray[3] = "1120001042092970023220000"; mesonCutArray[3] = "01022045000";  //standard cut Pi0 PbPb 10-20
-// //                  cutarray[4] = "1020001042092970023220000"; mesonCutArray[4] = "01022045000";  //standard cut Pi0 PbPb 00-20
-//                     cutarray[4] = "1240001042092970023220000"; mesonCutArray[4] = "01022045000";  //standard cut Pi0 PbPb 20-40     
-//                     cutarray[5] = "1460001042092970023220000"; mesonCutArray[5] = "01022065000";  //standard cut Pi0 PbPb 40-60
-//                     cutarray[6] = "1680001042092970023220000"; mesonCutArray[6] = "01022065000";  //standard cut Pi0 PbPb 60-80      
-// 
-//     //      CutStudies more BG events 20 events
-//                     cutarray[7] = "3010001042092970023220000"; mesonCutArray[7] = "01322045000";  
-//                     cutarray[8] = "3120001042092970023220000"; mesonCutArray[8] = "01322045000"; 
-//                     cutarray[9] = "1010001042092970023220000"; mesonCutArray[9] = "01322045000"; 
-//                     cutarray[10] = "1120001042092970023220000"; mesonCutArray[10] = "01322045000"; 
-// //                  cutarray[12] = "1020001042092970023220000"; mesonCutArray[12] = "01322045000"; 
-//                     cutarray[11] = "1240001042092970023220000"; mesonCutArray[11] = "01322045000"; 
-//                     cutarray[12] = "1460001042092970023220000"; mesonCutArray[12] = "01322065000";
-//                     cutarray[13] = "1680001042092970023220000"; mesonCutArray[13] = "01322065000"; 
-
-       //      CutStudies more BG events 50 events
-//                     cutarray[0] = "3010001042092970023220000"; mesonCutArray[0] = "01522045000"; 
-//                     cutarray[1] = "3120001042092970023220000"; mesonCutArray[1] = "01522045000"; 
-//                     cutarray[2] = "1010001042092970023220000"; mesonCutArray[2] = "01522045000"; 
-//                     cutarray[3] = "1120001042092970023220000"; mesonCutArray[3] = "01522045000"; 
-// //                  cutarray[4] = "1020001042092970023220000"; mesonCutArray[4] = "01522045000"; 
-//                     cutarray[4] = "1240001042092970023220000"; mesonCutArray[4] = "01522045000"; 
-//                     cutarray[5] = "1460001042092970023220000"; mesonCutArray[5] = "01522065000"; 
-//                     cutarray[6] = "1680001042092970023220000"; mesonCutArray[6] = "01522065000"; 
-
-               // Cutstudies 0-5% dEdx
-               //      cutarray[7] = "3010001042093970023220000"; mesonCutArray[7] = "01022045000"; 
-               //      cutarray[8] = "3010001042096970023220000"; mesonCutArray[8] = "01022045000"; 
-               //      cutarray[9] = "3010001042092470023220000"; mesonCutArray[9] = "01022045000"; 
-               //      cutarray[10] = "3010001042092770023220000"; mesonCutArray[10] = "01022045000"; 
-               //      cutarray[11] = "3010001042092950023220000"; mesonCutArray[11] = "01022045000"; 
-               // // Cutstudies 5-10% dEdx
-               //      cutarray[12] = "3120001042093970023220000"; mesonCutArray[12] = "01022045000"; 
-               //      cutarray[13] = "3120001042096970023220000"; mesonCutArray[13] = "01022045000"; 
-//                     cutarray[7] = "3120001042092470023220000"; mesonCutArray[7] = "01022045000"; 
-//                     cutarray[8] = "3120001042092770023220000"; mesonCutArray[8] = "01022045000"; 
-//                     cutarray[9] = "3120001042092950023220000"; mesonCutArray[9] = "01022045000"; 
-//             // Cutstudies 0-10% dEdx
-//                     cutarray[10] = "1010001042093970023220000"; mesonCutArray[10] = "01022045000"; 
-//                     cutarray[11] = "1010001042096970023220000"; mesonCutArray[11] = "01022045000"; 
-//                     cutarray[12] = "1010001042092470023220000"; mesonCutArray[12] = "01022045000"; 
-//                     cutarray[13] = "1010001042092770023220000"; mesonCutArray[13] = "01022045000"; 
-                       cutarray[0] = "1010001042092950023220000"; mesonCutArray[0] = "01022045000"; 
-               // Cutstudies 10-20% dEdx
-                       cutarray[1] = "1120001042093970023220000"; mesonCutArray[1] = "01022045000"; 
-                       cutarray[2] = "1120001042096970023220000"; mesonCutArray[2] = "01022045000";
-                       cutarray[3] = "1120001042092470023220000"; mesonCutArray[3] = "01022045000"; 
-                       cutarray[4] = "1120001042092770023220000"; mesonCutArray[4] = "01022045000"; 
-                       cutarray[5] = "1120001042092950023220000"; mesonCutArray[5] = "01022045000"; 
-//             Cutstudies 40-60% dEdx
-                       cutarray[6] = "1460001042093970023220000"; mesonCutArray[6] = "01022065000"; 
-                       cutarray[7] = "1460001042096970023220000"; mesonCutArray[7] = "01022065000"; 
-                       cutarray[8] = "1460001042092470023220000"; mesonCutArray[8] = "01022065000"; 
-                       cutarray[9] = "1460001042092770023220000"; mesonCutArray[9] = "01022065000"; 
-                       cutarray[10] = "1460001042092950023220000"; mesonCutArray[10] = "01022065000"; 
-               // Cutstudies 60-80% dEdx
-                       cutarray[11] = "1680001042093970023220000"; mesonCutArray[11] = "01022065000"; 
-                       cutarray[12] = "1680001042096970023220000"; mesonCutArray[12] = "01022065000"; 
-                       cutarray[13] = "1680001042092470023220000"; mesonCutArray[13] = "01022065000";
-                       cutarray[14] = "1680001042092770023220000"; mesonCutArray[14] = "01022065000"; 
-                       cutarray[15] = "1680001042092950023220000"; mesonCutArray[15] = "01022065000"; 
-               // Cutstudies 20-40% dEdx
-                       cutarray[16] = "1240001042093970023220000"; mesonCutArray[16] = "01022045000"; 
-                       cutarray[17] = "1240001042096970023220000"; mesonCutArray[17] = "01022045000";
-                       cutarray[18] = "1240001042092470023220000"; mesonCutArray[18] = "01022045000"; 
-                       cutarray[19] = "1240001042092770023220000"; mesonCutArray[19] = "01022045000"; 
-                       cutarray[20] = "1240001042092950023220000"; mesonCutArray[20] = "01022045000"; 
-
-               // Cutstudies 0-5% TOF
-//                     cutarray[5] = "3010001042092970033220000"; mesonCutArray[5] = "01022045000"; 
-//                     cutarray[6] = "3010001042092970043220000"; mesonCutArray[6] = "01022045000"; 
-               // Cutstudies 5-10% TOF
-//                     cutarray[7] = "3120001042092970033220000"; mesonCutArray[7] = "01022045000"; 
-//                     cutarray[8] = "3120001042092970043220000"; mesonCutArray[8] = "01022045000"; 
-               // Cutstudies 0-10% TOF
-//                     cutarray[9] = "1010001042092970033220000"; mesonCutArray[9] = "01022045000"; 
-//                     cutarray[10] = "1010001042092970043220000"; mesonCutArray[10] = "01022045000"; 
-               // Cutstudies 10-20% TOF
-//                     cutarray[11] = "1120001042092970033220000"; mesonCutArray[11] = "01022045000"; 
-//                     cutarray[12] = "1120001042092970043220000"; mesonCutArray[12] = "01022045000"; 
-               // Cutstudies 20-40% TOF
-//                     cutarray[13] = "1240001042092970033220000"; mesonCutArray[13] = "01022045000"; 
-//                     cutarray[14] = "1240001042092970043220000"; mesonCutArray[14] = "01022045000"; 
-               // Cutstudies 40-60% TOF
-//                     cutarray[15] = "1460001042092970033220000"; mesonCutArray[15] = "01022065000"; 
-//                     cutarray[16] = "1460001042092970043220000"; mesonCutArray[16] = "01022065000"; 
-               // Cutstudies 60-80% TOF
-//                     cutarray[17] = "1680001042092970033220000"; mesonCutArray[17] = "01022065000"; 
-//                     cutarray[18] = "1680001042092970043220000"; mesonCutArray[18] = "01022065000"; 
-
-               // Cutstudies 0-5% Alpha
-//                     cutarray[0] = "3010001042092970023220000"; mesonCutArray[0] = "01022085000"; 
-//                     cutarray[1] = "3010001042092970023220000"; mesonCutArray[1] = "01022005000"; 
-               // Cutstudies 5-10% Alpha
-//                     cutarray[2] = "3120001042092970023220000"; mesonCutArray[2] = "01022085000"; 
-//                     cutarray[3] = "3120001042092970023220000"; mesonCutArray[3] = "01022005000"; 
-               // Cutstudies 0-10% Alpha
-//                     cutarray[4] = "1010001042092970023220000"; mesonCutArray[4] = "01022085000"; 
-//                     cutarray[5] = "1010001042092970023220000"; mesonCutArray[5] = "01022005000"; 
-               // Cutstudies 10-20% Alpha
-//                     cutarray[6] = "1120001042092970023220000"; mesonCutArray[6] = "01022085000"; 
-//                     cutarray[7] = "1120001042092970023220000"; mesonCutArray[7] = "01022005000"; 
-               // Cutstudies 20-40% Alpha
-//       cutarray[8] = "1240001042092970023220000"; mesonCutArray[8] = "01022085000";
-//       cutarray[9] = "1240001042092970023220000"; mesonCutArray[9] = "01022005000"; 
-               // Cutstudies 60-80% Alpha
-//       cutarray[10] = "1680001042092970023220000"; mesonCutArray[10] = "01022075000"; 
-//       cutarray[11] = "1680001042092970023220000"; mesonCutArray[11] = "01022055000"; 
-               // Cutstudies 40-60% Alpha
-//       cutarray[12] = "1460001042092970023220000"; mesonCutArray[12] = "01022075000"; 
-//       cutarray[13] = "1460001042092970023220000"; mesonCutArray[13] = "01022055000"; 
-
-               // Cutstudies 0-5% Qt
-//                     cutarray[14] = "3010001042092970024220000"; mesonCutArray[14] = "01022045000"; 
-//                     cutarray[15] = "3010001042092970022220000"; mesonCutArray[15] = "01022045000"; 
-               // Cutstudies 5-10% Qt
-//                     cutarray[16] = "3120001042092970024220000"; mesonCutArray[16] = "01022045000"; 
-//                     cutarray[17] = "3120001042092970022220000"; mesonCutArray[17] = "01022045000"; 
-               // Cutstudies 0-10% Qt
-//                     cutarray[0] = "1010001042092970024220000"; mesonCutArray[0] = "01022045000"; 
-//                     cutarray[1] = "1010001042092970022220000"; mesonCutArray[1] = "01022045000"; 
-               // Cutstudies 10-20% Qt
-//                     cutarray[2] = "1120001042092970024220000"; mesonCutArray[2] = "01022045000"; 
-//                     cutarray[3] = "1120001042092970022220000"; mesonCutArray[3] = "01022045000"; 
-               // Cutstudies 20-40% Qt
-//                     cutarray[4] = "1240001042092970024220000"; mesonCutArray[4] = "01022045000"; 
-//                     cutarray[5] = "1240001042092970022220000"; mesonCutArray[5] = "01022045000"; 
-               // Cutstudies 40-60% Qt
-//                     cutarray[6] = "1460001042092970024220000"; mesonCutArray[6] = "01022065000"; 
-//                     cutarray[7] = "1460001042092970022220000"; mesonCutArray[7] = "01022065000"; 
-               // Cutstudies 60-80% Qt
-//                     cutarray[8] = "1680001042092970024220000"; mesonCutArray[8] = "01022065000"; 
-//                     cutarray[9] = "1680001042092970022220000"; mesonCutArray[9] = "01022065000"; 
+   if(trainConfig.Contains("PbPb")) numberOfCuts = 3;
+   else numberOfCuts = 1;
 
-               // Cutstudies 0-5% Single Pt
-//                     cutarray[10] = "3010001042492970023220000"; mesonCutArray[10] = "01022045000";
-//                     cutarray[11] = "3010001042192970023220000"; mesonCutArray[11] = "01022045000";
-               // Cutstudies 5-10% Single Pt
-//                     cutarray[12] = "3120001042492970023220000"; mesonCutArray[12] = "01022045000"; 
-//                     cutarray[13] = "3120001042192970023220000"; mesonCutArray[13] = "01022045000"; 
-               // Cutstudies 0-10% Single Pt
-//                     cutarray[14] = "1010001042492970023220000"; mesonCutArray[14] = "01022045000"; 
-//                     cutarray[15] = "1010001042192970023220000"; mesonCutArray[15] = "01022045000"; 
-               // Cutstudies 10-20% Single Pt
-//                     cutarray[16] = "1120001042492970023220000"; mesonCutArray[16] = "01022045000"; 
-//                     cutarray[17] = "1120001042192970023220000"; mesonCutArray[17] = "01022045000"; 
-               // Cutstudies 20-40% Single Pt
-//                     cutarray[0] = "1240001042492970023220000"; mesonCutArray[0] = "01022045000"; 
-//                     cutarray[1] = "1240001042192970023220000"; mesonCutArray[1] = "01022045000"; 
-               // Cutstudies 40-60% Single Pt
-//                     cutarray[2] = "1460001042492970023220000"; mesonCutArray[2] = "01022065000"; 
-//                     cutarray[3] = "1460001042192970023220000"; mesonCutArray[3] = "01022065000"; 
-               // Cutstudies 60-80% Single Pt
-//                     cutarray[4] = "1680001042492970023220000"; mesonCutArray[4] = "01022065000"; 
-//                     cutarray[5] = "1680001042192970023220000"; mesonCutArray[5] = "01022065000"; 
-
-               // Cutstudies 0-5% Chi2 Gamma
-//                     cutarray[6] = "3010001042092970023120000"; mesonCutArray[6] = "01022045000"; 
-//                     cutarray[7] = "3010001042092970023820000"; mesonCutArray[7] = "01022045000"; 
-               // Cutstudies 5-10% Chi2 Gamma
-//                     cutarray[8] = "3120001042092970023120000"; mesonCutArray[8] = "01022045000"; 
-//                     cutarray[9] = "3120001042092970023820000"; mesonCutArray[9] = "01022045000"; 
-               // Cutstudies 0-10% Chi2 Gamma
-//                     cutarray[10] = "1010001042092970023120000"; mesonCutArray[10] = "01022045000"; 
-//                     cutarray[11] = "1010001042092970023820000"; mesonCutArray[11] = "01022045000"; 
-               // Cutstudies 10-20% Chi2 Gamma
-//                     cutarray[12] = "1120001042092970023120000"; mesonCutArray[12] = "01022045000"; 
-//                     cutarray[13] = "1120001042092970023820000"; mesonCutArray[13] = "01022045000"; 
-               // Cutstudies 20-40% Chi2 Gamma
-//                     cutarray[14] = "1240001042092970023120000"; mesonCutArray[14] = "01022045000"; 
-//                     cutarray[15] = "1240001042092970023820000"; mesonCutArray[15] = "01022045000"; 
-               // Cutstudies 40-60% Chi2 Gamma
-//                     cutarray[16] = "1460001042092970023120000"; mesonCutArray[16] = "01022065000"; 
-//                     cutarray[17] = "1460001042092970023820000"; mesonCutArray[17] = "01022065000"; 
-               // Cutstudies 60-80% Chi2 Gamma
-//                     cutarray[18] = "1680001042092970023120000"; mesonCutArray[18] = "01022065000"; 
-//                     cutarray[19] = "1680001042092970023820000"; mesonCutArray[19] = "01022065000"; 
-
-               // Cutstudies 0-5% TPC Cluster
-//                     cutarray[0] = "3010001042062970023220000"; mesonCutArray[0] = "01022045000"; 
-//                     cutarray[1] = "3010001042082970023220000"; mesonCutArray[1] = "01022045000";
-               // Cutstudies 5-10% TPC Cluster
-//                     cutarray[2] = "3120001042062970023220000"; mesonCutArray[2] = "01022045000"; 
-//                     cutarray[3] = "3120001042082970023220000"; mesonCutArray[3] = "01022045000"; 
-               // Cutstudies 0-10% TPC Cluster
-//                     cutarray[4] = "1010001042062970023220000"; mesonCutArray[4] = "01022045000"; 
-//                     cutarray[5] = "1010001042082970023220000"; mesonCutArray[5] = "01022045000"; 
-               // Cutstudies 10-20% TPC Cluster
-//                     cutarray[6] = "1120001042062970023220000"; mesonCutArray[6] = "01022045000"; 
-//                     cutarray[7] = "1120001042082970023220000"; mesonCutArray[7] = "01022045000"; 
-               // Cutstudies 20-40% TPC Cluster
-//                     cutarray[8] = "1240001042062970023220000"; mesonCutArray[8] = "01022045000"; 
-//                     cutarray[9] = "1240001042082970023220000"; mesonCutArray[9] = "01022045000"; 
-               // Cutstudies 40-60% TPC Cluster
-//                     cutarray[10] = "1460001042062970023220000"; mesonCutArray[10] = "01022065000"; 
-//                     cutarray[11] = "1460001042082970023220000"; mesonCutArray[11] = "01022065000"; 
-               // Cutstudies 60-80% TPC Cluster
-//                     cutarray[12] = "1680001042062970023220000"; mesonCutArray[12] = "01022065000"; 
-//                     cutarray[13] = "1680001042082970023220000"; mesonCutArray[13] = "01022065000"; 
+   TString *cutarray = new TString[numberOfCuts];
+   TString *mesonCutArray = new TString[numberOfCuts];
 
-               // Cutstudies 0-5% Psi Pair
-//                     cutarray[14] = "3010001042092970023210000"; mesonCutArray[14] = "01022045000"; 
-//                     cutarray[15] = "3010001042092970023230000"; mesonCutArray[15] = "01022045000"; 
-               // Cutstudies 5-10% Psi Pair
-//                     cutarray[16] = "3120001042092970023210000"; mesonCutArray[16] = "01022045000"; 
-//                     cutarray[17] = "3120001042092970023230000"; mesonCutArray[17] = "01022045000"; 
-               // Cutstudies 0-10% Psi Pair
-//                     cutarray[0] = "1010001042092970023210000"; mesonCutArray[0] = "01022045000"; 
-//                     cutarray[1] = "1010001042092970023230000"; mesonCutArray[1] = "01022045000"; 
-               // Cutstudies 10-20% Psi Pair
-//                     cutarray[2] = "1120001042092970023210000"; mesonCutArray[2] = "01022045000"; 
-//                     cutarray[3] = "1120001042092970023230000"; mesonCutArray[3] = "01022045000";
-               // Cutstudies 20-40% Psi Pair
-//                     cutarray[4] = "1240001042092970023210000"; mesonCutArray[4] = "01022045000"; 
-//                     cutarray[5] = "1240001042092970023230000"; mesonCutArray[5] = "01022045000"; 
-               // Cutstudies 40-60% Psi Pair
-//                     cutarray[6] = "1460001042092970023210000"; mesonCutArray[6] = "01022065000"; 
-//                     cutarray[7] = "1460001042092970023230000"; mesonCutArray[7] = "01022065000"; 
-               // Cutstudies 60-80% Psi Pair
-//                     cutarray[8] = "1680001042092970023210000"; mesonCutArray[8] = "01022065000"; 
-//                     cutarray[9] = "1680001042092970023230000"; mesonCutArray[9] = "01022065000"; 
+   if(trainConfig.Contains("PbPb")){
+      cutarray[ 0] = "1000003042092970723220000"; mesonCutArray[ 0] = "01022045000";  // all centralities
+      cutarray[ 1] = "3010003042092970723220000"; mesonCutArray[ 1] = "01022045000";  // most central
+      cutarray[ 2] = "1680003042092970723220000"; mesonCutArray[ 2] = "01022065000";  // peripheral
 
-               // Cutstudies 0-5% R Cut
-//                     cutarray[10] = "3010001041092970023220000"; mesonCutArray[10] = "01022045000"; 
-//                     cutarray[11] = "3010001044092970023220000"; mesonCutArray[11] = "01022045000"; 
-               // Cutstudies 5-10% R Cut
-//                     cutarray[12] = "3120001041092970023220000"; mesonCutArray[12] = "01022045000"; 
-//                     cutarray[13] = "3120001044092970023220000"; mesonCutArray[13] = "01022045000";
-               // Cutstudies 0-10% R Cut
-//                     cutarray[14] = "1010001041092970023220000"; mesonCutArray[14] = "01022045000"; 
-//                     cutarray[15] = "1010001044092970023220000"; mesonCutArray[15] = "01022045000"; 
-               // Cutstudies 10-20% R Cut
-//                     cutarray[16] = "1120001041092970023220000"; mesonCutArray[16] = "01022045000"; 
-//                     cutarray[17] = "1120001044092970023220000"; mesonCutArray[17] = "01022045000"; 
-               // Cutstudies 20-40% R Cut
-//                     cutarray[0] = "1240001041092970023220000"; mesonCutArray[0] = "01022045000"; 
-//                     cutarray[1] = "1240001044092970023220000"; mesonCutArray[1] = "01022045000"; 
-               // Cutstudies 40-60% R Cut
-//                     cutarray[2] = "1460001041092970023220000"; mesonCutArray[2] = "01022065000"; 
-//                     cutarray[3] = "1460001044092970023220000"; mesonCutArray[3] = "01022065000"; 
-               // Cutstudies 60-80% R Cut
-//                     cutarray[4] = "1680001041092970023220000"; mesonCutArray[4] = "01022065000"; 
-//                     cutarray[5] = "1680001044092970023220000"; mesonCutArray[5] = "01022065000"; 
-       } else if(trainConfig.Contains("pPb")){ //pA needs thighter rapidity cut y < 0.5
-                cutarray[0] = "1000000042092172023220000"; mesonCutArray[0] = "01024045000";  //standard cut Pi0 PbPb 00-100
+   }
+   else if(trainConfig.Contains("pPb")){ //pA needs thighter rapidity cut y < 0.5
+      cutarray[0] = "1000000042092172023290000"; mesonCutArray[0] = "01024045000";  //standard cut Pi0 pPb 00-100
    } else {
-//        cutarray[0] = "0000010002093663003800000"; mesonCutArray[0] = "01631031009"; //Standard Cut Pi0 with PileUp Rejection
-//             // V0 finder      
-// //           cutarray[1] = "0000010102093663003800000"; mesonCutArray[1] = "01631031009"; //Standard Cut Pi0 with PileUp Rejection
-//        cutarray[1] = "0000011002093663003800000"; mesonCutArray[1] = "01631031009"; //Standard Cut only MinBias in MC
-//              cutarray[2] = "0000012002093663003800000"; mesonCutArray[2] = "01631031009"; //Standard Cut only added Signals in MC            
-// //       cutarray[1] = "0000010002093260043800000"; mesonCutArray[0] = "01631031009";  //Standard Cut Gamma with PileUp Rejection
-// 
-//             // dEdx e-line
-//       cutarray[3] = "0000011002091663003800000"; mesonCutArray[3] = "01631031009"; 
-//       cutarray[4] = "0000011002092663003800000"; mesonCutArray[4] = "01631031009";
-//             // dEdx pi-line
-//             cutarray[5] = "0000011002093863003800000"; mesonCutArray[5] = "01631031009"; 
-//             cutarray[6] = "0000011002093553003800000"; mesonCutArray[6] = "01631031009"; 
-//             cutarray[7] = "0000011002093100003800000"; mesonCutArray[7] = "01631031009"; 
-//             cutarray[8] = "0000011002093674003800000"; mesonCutArray[8] = "01631031009"; 
-//             // Alpha 
-//             cutarray[9] = "0000011002093663003800000"; mesonCutArray[9] = "01631001009"; 
-//             // chi2 gamma
-//       cutarray[10] = "0000011002093663003900000"; mesonCutArray[10] = "01631031009"; 
-//       cutarray[11] = "0000011002093663003200000"; mesonCutArray[11] = "01631031009"; 
-//             // pt single e+/e-
-//       cutarray[12] = "0000011002493663003800000"; mesonCutArray[12] = "01631031009"; 
-//       cutarray[13] = "0000011002193663003800000"; mesonCutArray[13] = "01631031009"; 
-               // findable cluster TPC
-               cutarray[0] = "0000010002003663003800000"; mesonCutArray[0] = "01631031009"; 
-               cutarray[1] = "0000010002083663003800000"; mesonCutArray[1] = "01631031009"; 
-               // qt variation
-               cutarray[2] = "0000010002093663004800000"; mesonCutArray[2] = "01631031009"; 
-               cutarray[3] = "0000010002093663002800000"; mesonCutArray[3] = "01631031009"; 
-               // TOF
-               cutarray[4] = "0000010002093663023800000"; mesonCutArray[4] = "01631031009"; 
-               cutarray[5] = "0000010002093663033800000"; mesonCutArray[5] = "01631031009"; 
-               cutarray[6] = "0000010002093663043800000"; mesonCutArray[6] = "01631031009"; 
-               // track sharing
-               cutarray[7] = "0000010002093663003800013"; mesonCutArray[7] = "01631031009"; 
-               cutarray[8] = "0000010002093663003800012"; mesonCutArray[8] = "01631031009"; 
-  }
-  
+      cutarray[ 0] = "0000011002093663003800000"; mesonCutArray[0] = "01631031009";
+   }
+
    TList *ConvCutList = new TList();
-       TList *MesonCutList = new TList();
+   TList *MesonCutList = new TList();
 
    TList *HeaderList = new TList();
-   TObjString *Header1 = new TObjString("PARAM");
-   HeaderList->Add(Header1);
-   TObjString *Header2 = new TObjString("BOX");
-   HeaderList->Add(Header2);
-   TObjString *Header3 = new TObjString("Pythia");
-   HeaderList->Add(Header3);
-   
+   // TObjString *Header1 = new TObjString("PARAM");
+   // HeaderList->Add(Header1);
+    TObjString *Header2 = new TObjString("BOX");
+    HeaderList->Add(Header2);
+//   TObjString *Header3 = new TObjString("Pythia");
+//   HeaderList->Add(Header3);
+//   TObjString *Header4 = new TObjString("Hijing");
+//   HeaderList->Add(Header4);
+
+
    ConvCutList->SetOwner(kTRUE);
    AliConversionCuts **analysisCuts = new AliConversionCuts*[numberOfCuts];
-       MesonCutList->SetOwner(kTRUE);
+   MesonCutList->SetOwner(kTRUE);
    AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
 
+
    for(Int_t i = 0; i<numberOfCuts; i++){
       analysisCuts[i] = new AliConversionCuts();
       analysisCuts[i]->InitializeCutsFromCutString(cutarray[i].Data());
-               if (trainConfig.Contains("pPb")) analysisCuts[i]->SelectCollisionCandidates(AliVEvent::kCINT5);
+      if (trainConfig.Contains("pPb")) analysisCuts[i]->SelectCollisionCandidates(AliVEvent::kINT7|AliVEvent::kTRD);
       ConvCutList->Add(analysisCuts[i]);
-               
+
       analysisCuts[i]->SetFillCutHistograms("",kFALSE);
-//      if(i == 2 ){
- //        analysisCuts[i]->SetAcceptedHeader(HeaderList);
-//      }
       analysisMesonCuts[i] = new AliConversionMesonCuts();
       analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
       MesonCutList->Add(analysisMesonCuts[i]);
-               analysisMesonCuts[i]->SetFillCutHistograms("",kFALSE);
-               if (i < 7 && trainConfig.Contains("PbPb")){
-                       AddQATaskV1(analysisCuts[i],IsHeavyIon);
-                       TString addoutput=gSystem->Getenv("ADD_OUTPUT_FILES");
-                       if (addoutput.Length()) addoutput+=",";
-                       addoutput+=Form("GammaConvV1_QA_%s.root",((analysisCuts[i])->GetCutNumber()).Data());
-                       gSystem->Setenv("ADD_OUTPUT_FILES",addoutput.Data());
-       }
+      analysisMesonCuts[i]->SetFillCutHistograms("");
+      analysisCuts[i]->SetAcceptedHeader(HeaderList);
    }
+
+
    task->SetConversionCutList(numberOfCuts,ConvCutList);
-       task->SetMesonCutList(numberOfCuts,MesonCutList);
+   task->SetMesonCutList(numberOfCuts,MesonCutList);
    task->SetMoveParticleAccordingToVertex(kTRUE);
    task->SetDoMesonAnalysis(kTRUE);
-   mgr->AddTask(task);
-  
+
    //connect containers
-   AliAnalysisDataContainer *coutput1 =
+   AliAnalysisDataContainer *coutput =
       mgr->CreateContainer("GammaConvV1", TList::Class(),
                            AliAnalysisManager::kOutputContainer,"GammaConvV1.root");
-   AliAnalysisDataContainer *coutput0 =
-      mgr->CreateContainer("kkoch_tree",
-                           TTree::Class(),
-                           AliAnalysisManager::kExchangeContainer,
-                           "kkoch_default");
-   mgr->ConnectInput  (task,  0, cinput );
-   mgr->ConnectOutput (task,  0, coutput0);
-   mgr->ConnectOutput (task,  1, coutput1);
-   return task;
-
-}
 
-void ConfigV0ReaderV1(AliV0ReaderV1 *fV0ReaderV1,TString analysiscut="",Bool_t IsHeavyIon=kFALSE){
-
-   fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
-   fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
-   fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
-
-   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
-   if (!mgr) {
-      Error("AddTask_V0ReaderV1", "No analysis manager found.");
-      return;
-   }
-   AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
-   
-   if(inputHandler->IsA()==AliESDInputHandler::Class()){
-      // ESD mode
-   }
-   
-   if(inputHandler->IsA()==AliAODInputHandler::Class()){
-      // AOD mode
-      //   task->SetUseSatelliteAODs(kTRUE);
-   }
+   mgr->AddTask(task);
+   mgr->ConnectInput(task,0,cinput);
+   mgr->ConnectOutput(task,1,coutput);
 
-   // Set AnalysisCut Number
-   AliConversionCuts *fCuts=NULL;
-   if(analysiscut!=""){
-      fCuts= new AliConversionCuts(analysiscut.Data(),analysiscut.Data());
-      if(fCuts->InitializeCutsFromCutString(analysiscut.Data())){
-         fV0ReaderV1->SetConversionCuts(fCuts);
-         fCuts->SetFillCutHistograms("",kTRUE);
-      }
-   }
-   fV0ReaderV1->Init();
-   
-}
+   return task;
 
-void AddQATaskV1(AliConversionCuts *ConversionCuts, Bool_t IsHeavyIon){
-   
-   //get the current analysis manager
-    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
-    if (!mgr) {
-       Error("AddTask_V0ReaderV1QA", "No analysis manager found.");
-       return 0;
-    }
-    AliAnalysisTaskConversionQA *fQA = new AliAnalysisTaskConversionQA(Form("%s_QA",(ConversionCuts->GetCutNumber()).Data()));
-    fQA->SetConversionCuts(ConversionCuts,IsHeavyIon);
-    mgr->AddTask(fQA);
-    
-    AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
-    mgr->ConnectInput (fQA,0,cinput);
 }