Added particle weighting to MC task.
authorhqvigsta <hqvigsta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 1 May 2013 15:05:15 +0000 (15:05 +0000)
committerhqvigsta <hqvigsta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 1 May 2013 15:05:15 +0000 (15:05 +0000)
PWGGA/PHOSTasks/PHOS_PbPb/AliAnalysisTaskPi0Flow.cxx
PWGGA/PHOSTasks/PHOS_PbPb/AliAnalysisTaskPi0Flow.h
PWGGA/PHOSTasks/PHOS_PbPb/AliAnalysisTaskPi0FlowMC.cxx
PWGGA/PHOSTasks/PHOS_PbPb/AliAnalysisTaskPi0FlowMC.h
PWGGA/PHOSTasks/PHOS_PbPb/macros/single-task/AddPi0FlowAndDependenciesMC.C

index a648769..9e58cf2 100644 (file)
@@ -341,8 +341,6 @@ void AliAnalysisTaskPi0Flow::UserCreateOutputObjects()
     fOutputContainer->Add(new TH2F(key,"Both clusters",nM,mMin,mMax,nPtPhot,0.,ptPhotMax));
   }
   
-  this->MakeMCHistograms();
-  
   // Setup photon lists
   Int_t kapacity = kNVtxZBins * GetNumberOfCentralityBins() * fNEMRPBins;
   fCaloPhotonsPHOSLists = new TObjArray(kapacity);
@@ -351,12 +349,7 @@ void AliAnalysisTaskPi0Flow::UserCreateOutputObjects()
   PostData(1, fOutputContainer);
 }
 
-void AliAnalysisTaskPi0Flow::MakeMCHistograms()
-{
-  //empty, MC extensions should override
-}
-
-void AliAnalysisTaskPi0Flow::DoMC()
+void AliAnalysisTaskPi0Flow::ProcessMC()
 {
   //empty, MC extensions should override
 }
@@ -443,8 +436,8 @@ void AliAnalysisTaskPi0Flow::UserExec(Option_t *)
 
 
   // Step 8: Event Photons (PHOS Clusters) selection
-  SelectPhotonClusters();
-  FillSelectedClusterHistograms();
+  this->SelectPhotonClusters();
+  this->FillSelectedClusterHistograms();
   LogProgress(8);
 
   if( ! fCaloPhotonsPHOS->GetEntriesFast() )
@@ -454,15 +447,15 @@ void AliAnalysisTaskPi0Flow::UserExec(Option_t *)
 
 
   // Step 9: Consider pi0 (photon/cluster) pairs.
-  ConsiderPi0s();
+  this->ConsiderPi0s();
   LogProgress(9);
 
   // Step 10; Mixing
-  ConsiderPi0sMix();
+  this->ConsiderPi0sMix();
   LogProgress(10);
   
   // Step 11: MC
-  this->DoMC();
+  this->ProcessMC();
 
   // Step 12: Update lists
   UpdateLists();
index 55818cb..b966977 100644 (file)
@@ -58,8 +58,6 @@ protected:
     AliAnalysisTaskPi0Flow(const AliAnalysisTaskPi0Flow&); // not implemented
     AliAnalysisTaskPi0Flow& operator=(const AliAnalysisTaskPi0Flow&); // not implemented
 
-    virtual void MakeMCHistograms();
-
     // Step 0:
     AliVEvent* GetEvent();
 
@@ -87,17 +85,17 @@ protected:
     void FillPHOSCellQAHists();
 
     // Step 8: Event Photons (PHOS Clusters) selection
-    void SelectPhotonClusters();
-    void FillSelectedClusterHistograms();
+    virtual void SelectPhotonClusters();
+    virtual void FillSelectedClusterHistograms();
 
     // Step 9: Consider pi0 (photon/cluster) pairs.
-    void ConsiderPi0s();
+    virtual void ConsiderPi0s();
 
     // Step 10; Mixing
-    void ConsiderPi0sMix();
+    virtual void ConsiderPi0sMix();
 
     // Step 11: MC
-    virtual void DoMC();
+    virtual void ProcessMC();
 
     // Step 12: Update lists
     void UpdateLists();
index d03293d..7a6c0eb 100644 (file)
@@ -34,6 +34,8 @@
 #include "TRandom.h"
 #include "TROOT.h"
 #include "THashList.h"
+#include "TArray.h"
+#include "TArrayD.h"
 
 
 #include "AliAnalysisManager.h"
@@ -67,6 +69,10 @@ ClassImp(AliAnalysisTaskPi0FlowMC);
 
 //TODO: rnlin?
 
+//TODO: Geometry IHEP?
+//TODO: PHOS matrix?
+//TODO: Centrality.?
+
 AliAnalysisTaskPi0FlowMC::AliAnalysisTaskPi0FlowMC(const char* name, AliAnalysisTaskPi0Flow::Period period)
 : AliAnalysisTaskPi0Flow(name, period),
   fStack(0x0)
@@ -77,9 +83,10 @@ AliAnalysisTaskPi0FlowMC::~AliAnalysisTaskPi0FlowMC()
 {
 }
 
-void AliAnalysisTaskPi0FlowMC::MakeMCHistograms()
+void AliAnalysisTaskPi0FlowMC::UserCreateOutputObjects()
 {
-  //AliAnalysisTaskPi0Flow::MakeMCHistograms();
+  // Do standard Pi0Flow CreateOuputObjects
+  AliAnalysisTaskPi0Flow::UserCreateOutputObjects();
   
   // MC Generated histograms
   char key[55];
@@ -223,29 +230,684 @@ void AliAnalysisTaskPi0FlowMC::MakeMCHistograms()
          fOutputContainer->Add(new TH1F(Form("%s_%s_cen%d",partTypes[itype],cPID[iPID],cen),"Cluster parents",nPt,ptMin,ptMax));
        }
      }
-   }  
+   }
+
+  PostData(1, fOutputContainer);
 }
 
-void AliAnalysisTaskPi0FlowMC::DoMC()
+void AliAnalysisTaskPi0FlowMC::UserExec(Option_t* option)
 {
-  //AliAnalysisTaskPi0Flow::DoMC();
   fStack = GetMCStack();
   
-  //TODO: Geometry IHEP?
-  //TODO: decalib.?
-  //TODO: PHOS matrix?
-  //TODO: Centrality.
+  AliAnalysisTaskPi0Flow::UserExec(option);
+}
+
+
+void AliAnalysisTaskPi0FlowMC::SelectPhotonClusters()
+{
+  AliAnalysisTaskPi0Flow::SelectPhotonClusters();
   
-  FillMCHist();
+  for (Int_t i1=0; i1<fCaloPhotonsPHOS->GetEntriesFast(); i1++) {
+    AliCaloPhoton * photon = (AliCaloPhoton*)fCaloPhotonsPHOS->At(i1);
+    AliVCluster* cluster = photon->GetCluster();
+    Bool_t sure=  kTRUE;
+    Int_t primary=FindPrimary(cluster,sure) ;
+    photon->SetPrimary(primary);
+    photon->SetWeight(PrimaryWeight(primary)) ;
+  }
+}
 
-  // Proccess all selected clusters
+void AliAnalysisTaskPi0FlowMC::FillSelectedClusterHistograms()
+{
   for (Int_t i1=0; i1<fCaloPhotonsPHOS->GetEntriesFast(); i1++) {
-    //Bool_t sure=  kTRUE;
-    //Int_t primary=FindPrimary(clu,sure) ;  //номер праймари частицы в стеке
-    //ph->SetPrimary(primary) ;
-    //ph->SetWeight(PrimaryWeight(primary)) ;
+    AliCaloPhoton * ph1=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i1) ;
+
+    Double_t dphiA=ph1->Phi()-fRPV0A ;
+    while(dphiA<0)dphiA+=TMath::Pi() ;
+    while(dphiA>TMath::Pi())dphiA-=TMath::Pi() ;
+
+    Double_t dphiC=ph1->Phi()-fRPV0C ;
+    while(dphiC<0)dphiC+=TMath::Pi() ;
+    while(dphiC>TMath::Pi())dphiC-=TMath::Pi() ;
+
+    Double_t dphiT=ph1->Phi()-fRP ;
+    while(dphiT<0)dphiT+=TMath::Pi() ;
+    while(dphiT>TMath::Pi())dphiT-=TMath::Pi() ;
+    
+    Double_t pt = ph1->Pt() ;
+    Double_t ptcore = ph1->GetMomV2()->Pt() ;
+    Double_t w = ph1->GetWeight();
+
+    FillHistogram(Form("hPhotPhiV0AAll_cen%d",fCentBin),pt,dphiA, w) ;
+    FillHistogram(Form("hPhotPhiV0CAll_cen%d",fCentBin),pt,dphiC, w) ;
+    if(fHaveTPCRP)
+      FillHistogram(Form("hPhotPhiTPCAll_cen%d",fCentBin),pt,dphiT, w) ;
+    FillHistogram(Form("hPhotPhiV0AAllcore_cen%d",fCentBin),ptcore,dphiA, w) ;
+    FillHistogram(Form("hPhotPhiV0CAllcore_cen%d",fCentBin),ptcore,dphiC, w) ;
+    if(fHaveTPCRP)
+      FillHistogram(Form("hPhotPhiTPCAllcore_cen%d",fCentBin),ptcore,dphiT, w) ;
+
+    FillHistogram(Form("hPhotAll_cen%d",fCentBin),pt, w) ;
+    FillHistogram(Form("hPhotAllcore_cen%d",fCentBin),ptcore, w) ;
+    if(ph1->IsntUnfolded()){
+      FillHistogram(Form("hPhotAllwou_cen%d",fCentBin),pt, w) ;
+      FillHistogram(Form("hPhotPhiV0AAllwou_cen%d",fCentBin),pt,dphiA, w) ;
+      FillHistogram(Form("hPhotPhiV0CAllwou_cen%d",fCentBin),pt,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hPhotPhiTPCAllwou_cen%d",fCentBin),pt,dphiT, w) ;
+    }
+    if(ph1->IsCPVOK()){
+      FillHistogram(Form("hPhotPhiV0ACPV_cen%d",fCentBin),pt,dphiA, w) ;
+      FillHistogram(Form("hPhotPhiV0CCPV_cen%d",fCentBin),pt,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hPhotPhiTPCCPV_cen%d",fCentBin),pt,dphiT, w) ;
+
+      FillHistogram(Form("hPhotPhiV0ACPVcore_cen%d",fCentBin),ptcore,dphiA, w) ;
+      FillHistogram(Form("hPhotPhiV0CCPVcore_cen%d",fCentBin),ptcore,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hPhotPhiTPCCPVcore_cen%d",fCentBin),ptcore,dphiT, w) ;
+
+      FillHistogram(Form("hPhotCPV_cen%d",fCentBin),pt, w) ;
+      FillHistogram(Form("hPhotCPVcore_cen%d",fCentBin),ptcore, w) ;
+    }
+    if(ph1->IsCPV2OK()){
+      FillHistogram(Form("hPhotPhiV0ACPV2_cen%d",fCentBin),pt,dphiA, w) ;
+      FillHistogram(Form("hPhotPhiV0CCPV2_cen%d",fCentBin),pt,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hPhotPhiTPCCPV2_cen%d",fCentBin),pt,dphiT, w) ;
+
+      FillHistogram(Form("hPhotPhiV0ACPV2core_cen%d",fCentBin),ptcore,dphiA, w) ;
+      FillHistogram(Form("hPhotPhiV0CCPV2core_cen%d",fCentBin),ptcore,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hPhotPhiTPCCPV2core_cen%d",fCentBin),ptcore,dphiT, w) ;
+      FillHistogram(Form("hPhotCPV2_cen%d",fCentBin),pt, w) ;
+      FillHistogram(Form("hPhotCPV2core_cen%d",fCentBin),ptcore, w) ;
+    }
+    if(ph1->IsDispOK()){
+      FillHistogram(Form("hPhotPhiV0ADisp_cen%d",fCentBin),pt,dphiA, w) ;
+      FillHistogram(Form("hPhotPhiV0CDisp_cen%d",fCentBin),pt,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hPhotPhiTPCDisp_cen%d",fCentBin),pt,dphiT, w) ;
+
+      FillHistogram(Form("hPhotPhiV0ADispcore_cen%d",fCentBin),ptcore,dphiA, w) ;
+      FillHistogram(Form("hPhotPhiV0CDispcore_cen%d",fCentBin),ptcore,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hPhotPhiTPCDispcore_cen%d",fCentBin),ptcore,dphiT, w) ;
+
+      if(ph1->IsntUnfolded()){
+        FillHistogram(Form("hPhotPhiV0ADispwou_cen%d",fCentBin),pt,dphiA, w) ;
+        FillHistogram(Form("hPhotPhiV0CDispwou_cen%d",fCentBin),pt,dphiC, w) ;
+        if(fHaveTPCRP)
+          FillHistogram(Form("hPhotPhiTPCDispwou_cen%d",fCentBin),pt,dphiT, w) ;
+
+      }
+      FillHistogram(Form("hPhotDisp_cen%d",fCentBin),pt, w) ;
+      FillHistogram(Form("hPhotDispcore_cen%d",fCentBin),ptcore, w) ;
+      if(ph1->IsntUnfolded()){
+        FillHistogram(Form("hPhotDispwou_cen%d",fCentBin),pt, w) ;
+      }
+      if(ph1->IsCPVOK()){
+       FillHistogram(Form("hPhotPhiV0ABoth_cen%d",fCentBin),pt,dphiA, w) ;
+       FillHistogram(Form("hPhotPhiV0CBoth_cen%d",fCentBin),pt,dphiC, w) ;
+        if(fHaveTPCRP)
+         FillHistogram(Form("hPhotPhiTPCBoth_cen%d",fCentBin),pt,dphiT, w) ;
+
+       FillHistogram(Form("hPhotPhiV0ABothcore_cen%d",fCentBin),ptcore,dphiA, w) ;
+       FillHistogram(Form("hPhotPhiV0CBothcore_cen%d",fCentBin),ptcore,dphiC, w) ;
+        if(fHaveTPCRP)
+         FillHistogram(Form("hPhotPhiTPCBothcore_cen%d",fCentBin),ptcore,dphiT, w) ;
+
+       FillHistogram(Form("hPhotBoth_cen%d",fCentBin),pt, w) ;
+       FillHistogram(Form("hPhotBothcore_cen%d",fCentBin),ptcore, w) ;
+      }
+    }
+    if(ph1->IsDisp2OK()){
+      FillHistogram(Form("hPhotPhiV0ADisp2_cen%d",fCentBin),pt,dphiA, w) ;
+      FillHistogram(Form("hPhotPhiV0CDisp2_cen%d",fCentBin),pt,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hPhotPhiTPCDisp2_cen%d",fCentBin),pt,dphiT, w) ;
+      FillHistogram(Form("hPhotPhiV0ADisp2core_cen%d",fCentBin),ptcore,dphiA, w) ;
+      FillHistogram(Form("hPhotPhiV0CDisp2core_cen%d",fCentBin),ptcore,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hPhotPhiTPCDisp2core_cen%d",fCentBin),ptcore,dphiT, w) ;
+
+      FillHistogram(Form("hPhotDisp2_cen%d",fCentBin),pt, w) ;
+      FillHistogram(Form("hPhotDisp2core_cen%d",fCentBin),ptcore, w) ;
+      if(ph1->IsCPVOK()){
+       FillHistogram(Form("hPhotPhiV0ABoth2_cen%d",fCentBin),pt,dphiA, w) ;
+       FillHistogram(Form("hPhotPhiV0CBoth2_cen%d",fCentBin),pt,dphiC, w) ;
+        if(fHaveTPCRP)
+         FillHistogram(Form("hPhotPhiTPCBoth2_cen%d",fCentBin),pt,dphiT, w) ;
+
+       FillHistogram(Form("hPhotPhiV0ABoth2core_cen%d",fCentBin),ptcore,dphiA, w) ;
+       FillHistogram(Form("hPhotPhiV0CBoth2core_cen%d",fCentBin),ptcore,dphiC, w) ;
+        if(fHaveTPCRP)
+         FillHistogram(Form("hPhotPhiTPCBoth2core_cen%d",fCentBin),ptcore,dphiT, w) ;
+
+       FillHistogram(Form("hPhotBoth2_cen%d",fCentBin),pt, w) ;
+       FillHistogram(Form("hPhotBoth2core_cen%d",fCentBin),ptcore, w) ;
+      }
+    }
   }
-  
+}
+
+void AliAnalysisTaskPi0FlowMC::ConsiderPi0s()
+{
+  char key[55];
+  for (Int_t i1=0; i1 < fCaloPhotonsPHOS->GetEntriesFast()-1; i1++) {
+    AliCaloPhoton * ph1=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i1) ;
+    const Double_t w1 = ph1->GetWeight();
+    for (Int_t i2=i1+1; i2<fCaloPhotonsPHOS->GetEntriesFast(); i2++) {
+      AliCaloPhoton * ph2=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i2) ;
+      TLorentzVector p12  = *ph1  + *ph2;
+      TLorentzVector pv12 = *(ph1->GetMomV2()) + *(ph2->GetMomV2());
+      
+      const Double_t w2 = ph2->GetWeight();
+      Double_t w = w1*w2;
+      if( FindCommonParent(ph1->GetPrimary(), ph1->GetPrimary()) )
+       w = w1*w2;
+      
+      FillHistogram("hPHOSphi",fCentralityV0M,p12.Pt(),p12.Phi(), w) ;
+      Double_t dphiA=p12.Phi()-fRPV0A ;
+      while(dphiA<0)dphiA+=TMath::Pi() ;
+      while(dphiA>TMath::Pi())dphiA-=TMath::Pi() ;
+
+      Double_t dphiC=p12.Phi()-fRPV0C ;
+      while(dphiC<0)dphiC+=TMath::Pi() ;
+      while(dphiC>TMath::Pi())dphiC-=TMath::Pi() ;
+
+      Double_t dphiT=p12.Phi()-fRP ;
+      while(dphiT<0)dphiT+=TMath::Pi() ;
+      while(dphiT>TMath::Pi())dphiT-=TMath::Pi() ;
+
+      Double_t a=TMath::Abs((ph1->E()-ph2->E())/(ph1->E()+ph2->E())) ;
+      Double_t m=p12.M() ;
+      Double_t mcore=pv12.M() ;
+      Double_t pt=p12.Pt() ;
+      Double_t ptcore=pv12.Pt() ;
+      Double_t pt1=ph1->Pt() ;
+      Double_t pt2=ph2->Pt() ;
+      Double_t ptcore1=ph1->GetMomV2()->Pt() ;
+      Double_t ptcore2=ph2->GetMomV2()->Pt() ;
+
+      FillHistogram(Form("hMassPtV0AAll_cen%d",fCentBin),m,pt,dphiA, w) ;
+      FillHistogram(Form("hMassPtV0CAll_cen%d",fCentBin),m,pt,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hMassPtTPCAll_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+      FillHistogram(Form("hMassPtV0AAllcore_cen%d",fCentBin),mcore,ptcore,dphiA, w) ;
+      FillHistogram(Form("hMassPtV0CAllcore_cen%d",fCentBin),mcore,ptcore,dphiC, w) ;
+      if(fHaveTPCRP)
+        FillHistogram(Form("hMassPtTPCAllcore_cen%d",fCentBin),mcore,ptcore,dphiT, w) ;
+
+
+      FillHistogram(Form("hPi0All_cen%d",fCentBin),m,pt, w) ;
+      FillHistogram(Form("hPi0Allcore_cen%d",fCentBin),mcore,ptcore, w) ;
+      if(ph1->IsntUnfolded() && ph2->IsntUnfolded()){
+        FillHistogram(Form("hPi0Allwou_cen%d",fCentBin),m,pt, w) ;
+        FillHistogram(Form("hMassPtV0AAllwou_cen%d",fCentBin),m,pt,dphiA, w) ;
+        FillHistogram(Form("hMassPtV0CAllwou_cen%d",fCentBin),m,pt,dphiC, w) ;
+        if(fHaveTPCRP)
+          FillHistogram(Form("hMassPtTPCAllwou_cen%d",fCentBin),m,pt,dphiT, w) ;
+      }
+
+      FillHistogram(Form("hSingleAll_cen%d",fCentBin),m,pt1, w) ;
+      FillHistogram(Form("hSingleAll_cen%d",fCentBin),m,pt2, w) ;
+      FillHistogram(Form("hSingleAllcore_cen%d",fCentBin),mcore,ptcore1, w) ;
+      FillHistogram(Form("hSingleAllcore_cen%d",fCentBin),mcore,ptcore2, w) ;
+      if(ph1->IsntUnfolded())
+        FillHistogram(Form("hSingleAllwou_cen%d",fCentBin),m,pt1, w) ;
+      if(ph2->IsntUnfolded())
+        FillHistogram(Form("hSingleAllwou_cen%d",fCentBin),m,pt2, w) ;
+      if(ph1->IsCPVOK()){
+        FillHistogram(Form("hSingleCPV_cen%d",fCentBin),m,pt1, w) ;
+        FillHistogram(Form("hSingleCPVcore_cen%d",fCentBin),mcore,ptcore1, w) ;
+      }
+      if(ph2->IsCPVOK()){
+        FillHistogram(Form("hSingleCPV_cen%d",fCentBin),m,pt2, w) ;
+        FillHistogram(Form("hSingleCPVcore_cen%d",fCentBin),mcore,ptcore2, w) ;
+      }
+      if(ph1->IsCPV2OK()){
+        FillHistogram(Form("hSingleCPV2_cen%d",fCentBin),m,pt1, w) ;
+        FillHistogram(Form("hSingleCPV2core_cen%d",fCentBin),mcore,ptcore2, w) ;
+      }
+      if(ph2->IsCPV2OK()){
+        FillHistogram(Form("hSingleCPV2_cen%d",fCentBin),m,pt2, w) ;
+        FillHistogram(Form("hSingleCPV2core_cen%d",fCentBin),mcore,ptcore2, w) ;
+      }
+      if(ph1->IsDispOK()){
+        FillHistogram(Form("hSingleDisp_cen%d",fCentBin),m,pt1, w) ;
+        if(ph1->IsntUnfolded()){
+          FillHistogram(Form("hSingleDispwou_cen%d",fCentBin),m,pt1, w) ;
+       }
+        FillHistogram(Form("hSingleDispcore_cen%d",fCentBin),mcore,ptcore1, w) ;
+      }
+      if(ph2->IsDispOK()){
+        FillHistogram(Form("hSingleDisp_cen%d",fCentBin),m,pt2, w) ;
+        if(ph1->IsntUnfolded()){
+          FillHistogram(Form("hSingleDispwou_cen%d",fCentBin),m,pt2, w) ;
+       }
+        FillHistogram(Form("hSingleDispcore_cen%d",fCentBin),mcore,ptcore2, w) ;
+      }
+      if(ph1->IsDisp2OK()){
+        FillHistogram(Form("hSingleDisp2_cen%d",fCentBin),m,pt1, w) ;
+        FillHistogram(Form("hSingleDisp2core_cen%d",fCentBin),mcore,ptcore1, w) ;
+      }
+      if(ph2->IsDisp2OK()){
+        FillHistogram(Form("hSingleDisp2_cen%d",fCentBin),m,pt2, w) ;
+        FillHistogram(Form("hSingleDisp2core_cen%d",fCentBin),mcore,ptcore1, w) ;
+      }
+      if(ph1->IsDispOK() && ph1->IsCPVOK()){
+        FillHistogram(Form("hSingleBoth_cen%d",fCentBin),m,pt1, w) ;
+        FillHistogram(Form("hSingleBothcore_cen%d",fCentBin),mcore,ptcore1, w) ;
+      }
+      if(ph2->IsDispOK() && ph2->IsCPVOK()){
+        FillHistogram(Form("hSingleBoth_cen%d",fCentBin),m,pt2, w) ;
+        FillHistogram(Form("hSingleBothcore_cen%d",fCentBin),mcore,ptcore2, w) ;
+      }
+      if(ph1->IsDisp2OK() && ph1->IsCPVOK()){
+        FillHistogram(Form("hSingleBoth2_cen%d",fCentBin),m,pt1, w) ;
+        FillHistogram(Form("hSingleBoth2core_cen%d",fCentBin),mcore,ptcore1, w) ;
+      }
+      if(ph2->IsDisp2OK() && ph2->IsCPVOK()){
+        FillHistogram(Form("hSingleBoth2_cen%d",fCentBin),m,pt2, w) ;
+        FillHistogram(Form("hSingleBoth2core_cen%d",fCentBin),mcore,ptcore2, w) ;
+      }
+
+
+      if(a<kAlphaCut){
+        FillHistogram(Form("hPi0All_a07_cen%d",fCentBin),m,pt, w) ;
+      }
+
+      if(ph1->IsCPVOK() && ph2->IsCPVOK()){
+       snprintf(key,55,"hMassPtCPV_cen%d",fCentBin) ;
+       FillHistogram(Form("hMassPtV0ACPV_cen%d",fCentBin),m,pt,dphiA, w) ;
+       FillHistogram(Form("hMassPtV0CCPV_cen%d",fCentBin),m,pt,dphiC, w) ;
+       if(fHaveTPCRP)
+         FillHistogram(Form("hMassPtTPCCPV_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+       FillHistogram(Form("hMassPtV0ACPVcore_cen%d",fCentBin),mcore,ptcore,dphiA, w) ;
+       FillHistogram(Form("hMassPtV0CCPVcore_cen%d",fCentBin),mcore,ptcore,dphiC, w) ;
+       if(fHaveTPCRP)
+         FillHistogram(Form("hMassPtTPCCPVcore_cen%d",fCentBin),mcore,ptcore,dphiT, w) ;
+
+       FillHistogram(Form("hPi0CPV_cen%d",fCentBin),m,pt, w) ;
+       FillHistogram(Form("hPi0CPVcore_cen%d",fCentBin),mcore, ptcore, w) ;
+
+        if(a<kAlphaCut){
+          FillHistogram(Form("hPi0CPV_a07_cen%d",fCentBin),m,pt, w) ;
+        }
+      }
+      if(ph1->IsCPV2OK() && ph2->IsCPV2OK()){
+       FillHistogram(Form("hMassPtV0ACPV2_cen%d",fCentBin),m,pt,dphiA, w) ;
+       FillHistogram(Form("hMassPtV0CCPV2_cen%d",fCentBin),m,pt,dphiC, w) ;
+       if(fHaveTPCRP)
+         FillHistogram(Form("hMassPtTPCCPV2_cen%d",fCentBin),m,pt,dphiT, w) ;
+       FillHistogram(Form("hMassPtV0ACPV2core_cen%d",fCentBin),mcore,ptcore,dphiA, w) ;
+       FillHistogram(Form("hMassPtV0CCPV2core_cen%d",fCentBin),mcore,ptcore,dphiC, w) ;
+       if(fHaveTPCRP)
+         FillHistogram(Form("hMassPtTPCCPV2core_cen%d",fCentBin),mcore,ptcore,dphiT, w) ;
+       
+       FillHistogram(Form("hPi0CPV2_cen%d",fCentBin),m,pt, w) ;
+       FillHistogram(Form("hPi0CPV2core_cen%d",fCentBin),mcore, ptcore, w) ;
+        if(a<kAlphaCut){
+          FillHistogram(Form("hPi0CPV2_a07_cen%d",fCentBin),m,pt, w) ;
+        }
+      }
+      if(ph1->IsDispOK() && ph2->IsDispOK()){
+       snprintf(key,55,"hMassPtDisp_cen%d",fCentBin) ;
+       FillHistogram(Form("hMassPtV0ADisp_cen%d",fCentBin),m,pt,dphiA, w) ;
+       FillHistogram(Form("hMassPtV0CDisp_cen%d",fCentBin),m,pt,dphiC, w) ;
+       if(fHaveTPCRP)
+         FillHistogram(Form("hMassPtTPCDisp_cen%d",fCentBin),m,pt,dphiT, w) ;
+       
+       FillHistogram(Form("hMassPtV0ADispcore_cen%d",fCentBin),mcore, ptcore,dphiA, w) ;
+       FillHistogram(Form("hMassPtV0CDispcore_cen%d",fCentBin),mcore, ptcore,dphiC, w) ;
+       if(fHaveTPCRP)
+         FillHistogram(Form("hMassPtTPCDispcore_cen%d",fCentBin),mcore, ptcore,dphiT, w) ;
+
+       FillHistogram(Form("hPi0Disp_cen%d",fCentBin),m,pt, w) ;
+       FillHistogram(Form("hPi0Dispcore_cen%d",fCentBin),mcore, ptcore, w) ;
+       
+       if(ph1->IsntUnfolded() && ph2->IsntUnfolded()){
+         FillHistogram(Form("hPi0Dispwou_cen%d",fCentBin),m,pt, w) ;
+
+         FillHistogram(Form("hMassPtV0ADispwou_cen%d",fCentBin),m,pt,dphiA, w) ;
+         FillHistogram(Form("hMassPtV0CDispwou_cen%d",fCentBin),m,pt,dphiC, w) ;
+         if(fHaveTPCRP)
+           FillHistogram(Form("hMassPtTPCDispwou_cen%d",fCentBin),m,pt,dphiT, w) ;
+       }
+
+        if(a<kAlphaCut){
+          FillHistogram(Form("hPi0Disp_a07_cen%d",fCentBin),m,pt, w) ;
+        }
+       if(ph1->IsCPVOK() && ph2->IsCPVOK()){
+         FillHistogram(Form("hMassPtV0ABoth_cen%d",fCentBin),m,pt,dphiA, w) ;
+         FillHistogram(Form("hMassPtV0CBoth_cen%d",fCentBin),m,pt,dphiC, w) ;
+          if(fHaveTPCRP)
+           FillHistogram(Form("hMassPtTPCBoth_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+         FillHistogram(Form("hMassPtV0ABothcore_cen%d",fCentBin),mcore,ptcore,dphiA, w) ;
+         FillHistogram(Form("hMassPtV0CBothcore_cen%d",fCentBin),mcore,ptcore,dphiC, w) ;
+          if(fHaveTPCRP)
+           FillHistogram(Form("hMassPtTPCBothcore_cen%d",fCentBin),mcore,ptcore,dphiT, w) ;
+
+         FillHistogram(Form("hPi0Both_cen%d",fCentBin),m,pt, w) ;
+         FillHistogram(Form("hPi0Bothcore_cen%d",fCentBin),mcore,ptcore, w) ;
+
+          if(a<kAlphaCut){
+            snprintf(key,55,"hPi0Both_a07_cen%d",fCentBin) ;
+            FillHistogram(Form("hPi0Both_a07_cen%d",fCentBin),m,pt, w) ;
+          }
+          if(ph1->Module()==1 && ph2->Module()==1)
+           FillHistogram("hPi0M11", m, pt, w) ;
+          else if(ph1->Module()==2 && ph2->Module()==2)
+           FillHistogram("hPi0M22", m, pt, w) ;
+          else if(ph1->Module()==3 && ph2->Module()==3)
+           FillHistogram("hPi0M33", m, pt, w) ;
+          else if(ph1->Module()==1 && ph2->Module()==2)
+           FillHistogram("hPi0M12", m, pt, w) ;
+          else if(ph1->Module()==1 && ph2->Module()==3)
+           FillHistogram("hPi0M13", m, pt, w) ;
+          else if(ph1->Module()==2 && ph2->Module()==3)
+           FillHistogram("hPi0M23", m, pt, w) ;
+
+        }
+       
+      }
+      
+      
+      if(ph1->IsDisp2OK() && ph2->IsDisp2OK()){
+       FillHistogram(Form("hPi0Disp2_cen%d",fCentBin),m,pt) ;
+       FillHistogram(Form("hPi0Disp2core_cen%d",fCentBin),mcore, ptcore, w) ;  
+
+       FillHistogram(Form("hMassPtV0ADisp2_cen%d",fCentBin),m,pt,dphiA, w) ;
+       FillHistogram(Form("hMassPtV0CDisp2_cen%d",fCentBin),m,pt,dphiC, w) ;
+       if(fHaveTPCRP)
+         FillHistogram(Form("hMassPtTPCDisp2_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+       FillHistogram(Form("hMassPtV0ADisp2core_cen%d",fCentBin),mcore, ptcore,dphiA, w) ;
+       FillHistogram(Form("hMassPtV0CDisp2core_cen%d",fCentBin),mcore, ptcore,dphiC, w) ;
+       if(fHaveTPCRP)
+         FillHistogram(Form("hMassPtTPCDisp2core_cen%d",fCentBin),mcore, ptcore,dphiT, w) ;
+         
+       if(ph1->IsCPVOK() && ph2->IsCPVOK()){
+         FillHistogram(Form("hMassPtV0ABoth2_cen%d",fCentBin),m,pt,dphiA, w) ;
+         FillHistogram(Form("hMassPtV0CBoth2_cen%d",fCentBin),m,pt,dphiC, w) ;
+          if(fHaveTPCRP)
+           FillHistogram(Form("hMassPtTPCBoth2_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+         FillHistogram(Form("hMassPtV0ABoth2core_cen%d",fCentBin),mcore,ptcore,dphiA, w) ;
+         FillHistogram(Form("hMassPtV0CBoth2core_cen%d",fCentBin),mcore,ptcore,dphiC, w) ;
+          if(fHaveTPCRP)
+           FillHistogram(Form("hMassPtTPCBoth2core_cen%d",fCentBin),mcore,ptcore,dphiT, w) ;
+
+         FillHistogram(Form("hPi0Both2_cen%d",fCentBin),m,pt, w) ;
+         FillHistogram(Form("hPi0Both2core_cen%d",fCentBin),mcore,ptcore, w) ;
+       }
+
+      }
+    } // end of loop i2
+  } // end of loop i1
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskPi0FlowMC::ConsiderPi0sMix()
+{
+  char key[55];
+
+  TList * arrayList = GetCaloPhotonsPHOSList(fVtxBin, fCentBin, fEMRPBin);
+
+  for (Int_t i1=0; i1<fCaloPhotonsPHOS->GetEntriesFast(); i1++) {
+    AliCaloPhoton * ph1=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i1) ;
+    const Double_t w1 = ph1->GetWeight();
+    for(Int_t evi=0; evi<arrayList->GetEntries();evi++){
+      TObjArray * mixPHOS = static_cast<TObjArray*>(arrayList->At(evi));
+      for(Int_t i2=0; i2<mixPHOS->GetEntriesFast();i2++){
+       AliCaloPhoton * ph2=(AliCaloPhoton*)mixPHOS->At(i2) ;
+       TLorentzVector p12  = *ph1  + *ph2;
+       TLorentzVector pv12 = *(ph1->GetMomV2()) + *(ph2->GetMomV2());
+       
+       const Double_t w2 = ph2->GetWeight();
+       Double_t w = w1*w2;
+
+       Double_t dphiA=p12.Phi()-fRPV0A ;
+       while(dphiA<0)dphiA+=TMath::Pi() ;
+       while(dphiA>TMath::Pi())dphiA-=TMath::Pi() ;
+
+       Double_t dphiC=p12.Phi()-fRPV0C ;
+       while(dphiC<0)dphiC+=TMath::Pi() ;
+       while(dphiC>TMath::Pi())dphiC-=TMath::Pi() ;
+
+       Double_t dphiT=p12.Phi()-fRP ;
+       while(dphiT<0)dphiT+=TMath::Pi() ;
+       while(dphiT>TMath::Pi())dphiT-=TMath::Pi() ;
+
+
+        Double_t a=TMath::Abs((ph1->E()-ph2->E())/(ph1->E()+ph2->E())) ;
+        Double_t m=p12.M() ;
+        Double_t mcore=pv12.M() ;
+        Double_t pt=p12.Pt() ;
+        Double_t ptcore=pv12.Pt() ;
+        Double_t pt1=ph1->Pt() ;
+        Double_t pt2=ph2->Pt() ;
+        Double_t ptcore1=ph1->GetMomV2()->Pt() ;
+        Double_t ptcore2=ph2->GetMomV2()->Pt() ;
+
+
+       snprintf(key,55,"hMiMassPtAll_cen%d",fCentBin) ;
+       FillHistogram(Form("hMiMassPtV0AAll_cen%d",fCentBin),m,pt,dphiA, w) ;
+       FillHistogram(Form("hMiMassPtV0CAll_cen%d",fCentBin),m,pt,dphiC, w) ;
+       if(fHaveTPCRP)
+         FillHistogram(Form("hMiMassPtTPCAll_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+       FillHistogram(Form("hMiMassPtV0AAllcore_cen%d",fCentBin),mcore, ptcore, dphiA, w) ;
+       FillHistogram(Form("hMiMassPtV0CAllcore_cen%d",fCentBin),mcore, ptcore, dphiC, w) ;
+        if(fHaveTPCRP)
+         FillHistogram(Form("hMiMassPtTPCAllcore_cen%d",fCentBin),mcore, ptcore, dphiT, w) ;
+
+       FillHistogram(Form("hMiPi0All_cen%d",fCentBin),m,pt, w) ;
+       FillHistogram(Form("hMiPi0Allcore_cen%d",fCentBin),mcore,ptcore, w) ;
+       if(ph1->IsntUnfolded() && ph2->IsntUnfolded()){
+         FillHistogram(Form("hMiPi0Allwou_cen%d",fCentBin),m,pt, w) ;
+          FillHistogram(Form("hMiMassPtV0AAllwou_cen%d",fCentBin),m,pt,dphiA, w) ;
+          FillHistogram(Form("hMiMassPtV0CAllwou_cen%d",fCentBin),m,pt,dphiC, w) ;
+          if(fHaveTPCRP)
+            FillHistogram(Form("hMiMassPtTPCAllwou_cen%d",fCentBin),m,pt,dphiT, w) ;
+       }
+
+        FillHistogram(Form("hMiSingleAll_cen%d",fCentBin),m,pt1, w) ;
+        FillHistogram(Form("hMiSingleAll_cen%d",fCentBin),m,pt2, w) ;
+        FillHistogram(Form("hMiSingleAllcore_cen%d",fCentBin),mcore,ptcore1, w) ;
+        FillHistogram(Form("hMiSingleAllcore_cen%d",fCentBin),mcore,ptcore2, w) ;
+        if(ph1->IsntUnfolded())
+          FillHistogram(Form("hMiSingleAllwou_cen%d",fCentBin),m,pt1, w) ;
+        if(ph2->IsntUnfolded())
+          FillHistogram(Form("hMiSingleAllwou_cen%d",fCentBin),m,pt2, w) ;
+        if(ph1->IsCPVOK()){
+          FillHistogram(Form("hMiSingleCPV_cen%d",fCentBin),m,pt1, w) ;
+          FillHistogram(Form("hMiSingleCPVcore_cen%d",fCentBin),mcore,ptcore1, w) ;
+        }
+        if(ph2->IsCPVOK()){
+          FillHistogram(Form("hMiSingleCPV_cen%d",fCentBin),m,pt2, w) ;
+          FillHistogram(Form("hMiSingleCPVcore_cen%d",fCentBin),mcore,ptcore2, w) ;
+        }
+        if(ph1->IsCPV2OK()){
+          FillHistogram(Form("hMiSingleCPV2_cen%d",fCentBin),m,pt1, w) ;
+          FillHistogram(Form("hMiSingleCPV2core_cen%d",fCentBin),mcore,ptcore1, w) ;
+        }
+        if(ph2->IsCPV2OK()){
+          FillHistogram(Form("hMiSingleCPV2_cen%d",fCentBin),m,pt2, w) ;
+          FillHistogram(Form("hMiSingleCPV2core_cen%d",fCentBin),mcore,ptcore2, w) ;
+        }
+        if(ph1->IsDispOK()){
+          FillHistogram(Form("hMiSingleDisp_cen%d",fCentBin),m,pt1, w) ;
+          if(ph1->IsntUnfolded()){
+            FillHistogram(Form("hMiSingleDispwou_cen%d",fCentBin),m,pt1, w) ;
+         }
+          FillHistogram(Form("hMiSingleDispcore_cen%d",fCentBin),mcore,ptcore1, w) ;
+        }
+        if(ph2->IsDispOK()){
+          FillHistogram(Form("hMiSingleDisp_cen%d",fCentBin),m,pt2, w) ;
+          if(ph1->IsntUnfolded()){
+            FillHistogram(Form("hMiSingleDispwou_cen%d",fCentBin),m,pt2, w) ;
+         }
+          FillHistogram(Form("hMiSingleDispcore_cen%d",fCentBin),mcore,ptcore2, w) ;
+        }
+        if(ph1->IsDisp2OK()){
+          FillHistogram(Form("hMiSingleDisp2_cen%d",fCentBin),m,pt1, w) ;
+          FillHistogram(Form("hMiSingleDisp2core_cen%d",fCentBin),mcore,ptcore1, w) ;
+        }
+        if(ph2->IsDisp2OK()){
+          FillHistogram(Form("hMiSingleDisp2_cen%d",fCentBin),m,pt2, w) ;
+          FillHistogram(Form("hMiSingleDisp2core_cen%d",fCentBin),mcore,ptcore2, w) ;
+        }
+        if(ph1->IsDispOK() && ph1->IsCPVOK()){
+          snprintf(key,55,"hMiSingleBoth_cen%d",fCentBin) ;
+          FillHistogram(key,m,pt1, w) ;
+          snprintf(key,55,"hMiSingleBothcore_cen%d",fCentBin);
+          FillHistogram(key,mcore,ptcore1, w) ;
+        }
+        if(ph2->IsDispOK() && ph2->IsCPVOK()){
+          snprintf(key,55,"hMiSingleBoth_cen%d",fCentBin);
+          FillHistogram(key,m,pt2, w) ;
+          snprintf(key,55,"hMiSingleBothcore_cen%d",fCentBin);
+          FillHistogram(key,mcore,ptcore2, w) ;
+        }
+        if(ph1->IsDisp2OK() && ph1->IsCPVOK()){
+          FillHistogram(Form("hMiSingleBoth2_cen%d",fCentBin),m,pt1, w) ;
+          FillHistogram(Form("hMiSingleBoth2core_cen%d",fCentBin),mcore,ptcore1, w) ;
+        }
+        if(ph2->IsDisp2OK() && ph2->IsCPVOK()){
+          FillHistogram(Form("hMiSingleBoth2_cen%d",fCentBin),m,pt2, w) ;
+          FillHistogram(Form("hMiSingleBoth2core_cen%d",fCentBin),mcore,ptcore2, w) ;
+        }
+
+
+
+        if(a<kAlphaCut){
+          FillHistogram(Form("hMiPi0All_a07_cen%d",fCentBin),m,pt, w) ;
+        }
+       if(ph1->IsCPVOK() && ph2->IsCPVOK()){
+         FillHistogram(Form("hMiMassPtV0ACPV_cen%d",fCentBin),m,pt,dphiA, w) ;
+         FillHistogram(Form("hMiMassPtV0CCPV_cen%d",fCentBin),m,pt,dphiC, w) ;
+         if(fHaveTPCRP)
+           FillHistogram(Form("hMiMassPtTPCCPV_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+         FillHistogram(Form("hMiMassPtV0ACPVcore_cen%d",fCentBin),mcore, ptcore,dphiA, w) ;
+         FillHistogram(Form("hMiMassPtV0CCPVcore_cen%d",fCentBin),mcore, ptcore,dphiC, w) ;
+         if(fHaveTPCRP)
+           FillHistogram(Form("hMiMassPtTPCCPVcore_cen%d",fCentBin),mcore, ptcore,dphiT, w) ;
+
+         FillHistogram(Form("hMiPi0CPV_cen%d",fCentBin),m,pt, w) ;
+         FillHistogram(Form("hMiPi0CPVcore_cen%d",fCentBin),mcore, ptcore, w) ;
+
+         if(a<kAlphaCut){
+            FillHistogram(Form("hMiPi0CPV_a07_cen%d",fCentBin),m,pt, w) ;
+          }
+       }
+       if(ph1->IsCPV2OK() && ph2->IsCPV2OK()){
+         FillHistogram(Form("hMiPi0CPV2_cen%d",fCentBin),m,pt, w) ;
+         FillHistogram(Form("hMiPi0CPV2core_cen%d",fCentBin),mcore, ptcore, w) ;
+
+         FillHistogram(Form("hMiMassPtV0ACPV2_cen%d",fCentBin),m,pt,dphiA, w) ;
+         FillHistogram(Form("hMiMassPtV0CCPV2_cen%d",fCentBin),m,pt,dphiC, w) ;
+         if(fHaveTPCRP)
+           FillHistogram(Form("hMiMassPtTPCCPV2_cen%d",fCentBin),m,pt,dphiT, w) ;
+         FillHistogram(Form("hMiMassPtV0ACPV2core_cen%d",fCentBin),mcore,ptcore,dphiA, w) ;
+         FillHistogram(Form("hMiMassPtV0CCPV2core_cen%d",fCentBin),mcore,ptcore,dphiC, w) ;
+         if(fHaveTPCRP)
+           FillHistogram(Form("hMiMassPtTPCCPV2core_cen%d",fCentBin),mcore,ptcore,dphiT, w) ;
+
+         if(a<kAlphaCut){
+            FillHistogram(Form("hMiPi0CPV2_a07_cen%d",fCentBin),m,pt, w) ;
+          }
+       }
+       if(ph1->IsDispOK() && ph2->IsDispOK()){
+         FillHistogram(Form("hMiMassPtV0ADisp_cen%d",fCentBin),m,pt,dphiA, w) ;
+         FillHistogram(Form("hMiMassPtV0CDisp_cen%d",fCentBin),m,pt,dphiC, w) ;
+          if(fHaveTPCRP)
+           FillHistogram(Form("hMiMassPtTPCDisp_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+         FillHistogram(Form("hMiMassPtV0ADispcore_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiA, w) ;
+         FillHistogram(Form("hMiMassPtV0CDispcore_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiC, w) ;
+          if(fHaveTPCRP)
+           FillHistogram(Form("hMiMassPtTPCDispcore_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiT, w) ;
+
+
+         FillHistogram(Form("hMiPi0Disp_cen%d",fCentBin),m,pt, w) ;
+         FillHistogram(Form("hMiPi0Dispcore_cen%d",fCentBin),pv12.M(),pv12.Pt(), w) ;
+          if(ph1->IsntUnfolded() && ph2->IsntUnfolded()){
+           FillHistogram(Form("hMiPi0Dispwou_cen%d",fCentBin),m,pt, w) ;
+           FillHistogram(Form("hMiMassPtV0ADispwou_cen%d",fCentBin),m,pt,dphiA, w) ;
+           FillHistogram(Form("hMiMassPtV0CDispwou_cen%d",fCentBin),m,pt,dphiC, w) ;
+            if(fHaveTPCRP)
+             FillHistogram(Form("hMiMassPtTPCDispwou_cen%d",fCentBin),m,pt,dphiT, w) ;
+         }
+
+         if(a<kAlphaCut){
+            FillHistogram(Form("hMiPi0Disp_a07_cen%d",fCentBin),m,pt, w) ;
+          }
+         if(ph1->IsCPVOK() && ph2->IsCPVOK()){
+           FillHistogram(Form("hMiMassPtV0ABoth_cen%d",fCentBin),m,pt,dphiA, w) ;
+           FillHistogram(Form("hMiMassPtV0CBoth_cen%d",fCentBin),m,pt,dphiC, w) ;
+           if(fHaveTPCRP)
+             FillHistogram(Form("hMiMassPtTPCBoth_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+           FillHistogram(Form("hMiMassPtV0ABothcore_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiA, w) ;
+           FillHistogram(Form("hMiMassPtV0CBothcore_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiC, w) ;
+           if(fHaveTPCRP)
+             FillHistogram(Form("hMiMassPtTPCBothcore_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiT, w) ;
+
+           FillHistogram(Form("hMiPi0Both_cen%d",fCentBin),m,pt, w) ;
+           FillHistogram(Form("hMiPi0Bothcore_cen%d",fCentBin),pv12.M(),pv12.Pt(), w) ;
+
+           if(a<kAlphaCut){
+              FillHistogram(Form("hMiPi0Both_a07_cen%d",fCentBin),m,pt, w) ;
+            }
+         }
+       }
+       
+       if(ph1->IsDisp2OK() && ph2->IsDisp2OK()){
+         FillHistogram(Form("hMiMassPtV0ADisp2_cen%d",fCentBin),m,pt,dphiA, w) ;
+         FillHistogram(Form("hMiMassPtV0CDisp2_cen%d",fCentBin),m,pt,dphiC, w) ;
+          if(fHaveTPCRP)
+           FillHistogram(Form("hMiMassPtTPCDisp2_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+         FillHistogram(Form("hMiMassPtV0ADisp2core_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiA, w) ;
+         FillHistogram(Form("hMiMassPtV0CDisp2core_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiC, w) ;
+          if(fHaveTPCRP)
+           FillHistogram(Form("hMiMassPtTPCDisp2core_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiT, w) ;
+
+
+         FillHistogram(Form("hMiPi0Disp2_cen%d",fCentBin),m,pt, w) ;
+         FillHistogram(Form("hMiPi0Disp2core_cen%d",fCentBin),pv12.M(),pv12.Pt(), w) ;
+
+         if(ph1->IsCPVOK() && ph2->IsCPVOK()){
+           FillHistogram(Form("hMiMassPtV0ABoth2_cen%d",fCentBin),m,pt,dphiA, w) ;
+           FillHistogram(Form("hMiMassPtV0CBoth2_cen%d",fCentBin),m,pt,dphiC, w) ;
+           if(fHaveTPCRP)
+             FillHistogram(Form("hMiMassPtTPCBoth2_cen%d",fCentBin),m,pt,dphiT, w) ;
+
+           FillHistogram(Form("hMiMassPtV0ABoth2core_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiA, w) ;
+           FillHistogram(Form("hMiMassPtV0CBoth2core_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiC, w) ;
+           if(fHaveTPCRP)
+             FillHistogram(Form("hMiMassPtTPCBoth2core_cen%d",fCentBin),pv12.M(),pv12.Pt(),dphiT, w) ;
+
+           FillHistogram(Form("hMiPi0Both2_cen%d",fCentBin),m,pt, w) ;
+           FillHistogram(Form("hMiPi0Both2core_cen%d",fCentBin),pv12.M(),pv12.Pt(), w) ;
+
+         }
+       }
+      } // end of loop i2
+    }
+  } // end of loop i1
+}
+
+
+void AliAnalysisTaskPi0FlowMC::ProcessMC()
+{
+  FillMCHist();
   FillSecondaries() ;
 }
 
@@ -308,8 +970,8 @@ void AliAnalysisTaskPi0FlowMC::FillSecondaries(){
   
   //Fill spectra of primary particles 
   //with proper weight
-  std::cout <<  fStack << std::endl;
-  AliInfo("start");
+  if( fDebug )
+    AliInfo("start");
   for(Int_t i=0; i<fStack->GetNtrack(); i++){
     TParticle * p = fStack->Particle(i) ;
     if(p->R()>kRCut)
@@ -361,7 +1023,8 @@ void AliAnalysisTaskPi0FlowMC::FillSecondaries(){
                  FillHistogram(Form("hPrimOther_cen%d",fCentBin),p->Pt(),w);    
       }
   }
-  AliInfo("Origins of secondary pi0s");
+  if(fDebug)
+    AliInfo("Origins of secondary pi0s");
   //Origins of secondary pi0s
   for(Int_t i=0; i<fStack->GetNtrack(); i++){
     TParticle * p = fStack->Particle(i) ;
@@ -406,7 +1069,7 @@ void AliAnalysisTaskPi0FlowMC::FillSecondaries(){
            }
            else{
               if(InPi0mass(p12.M() ,p12.Pt())){
-               printf("Common parent: %d \n",pdgCode) ;
+               if(fDebug >1) AliInfo(Form("Common parent: %d",pdgCode));
              }
               FillHistogram(Form("hParentOther_cen%d",fCentBin),p12.M(),p12.Pt(),w) ;
            }
@@ -700,5 +1363,91 @@ AliStack* AliAnalysisTaskPi0FlowMC::GetMCStack()
     if( mcEventHandler)
       fStack = static_cast<AliMCEventHandler*>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())->MCEvent()->Stack();
   }
+  
+  if( ! fStack )
+    AliError("Could not get MC Stack!");
   return fStack;
 }
+
+Int_t AliAnalysisTaskPi0FlowMC::FindPrimary(AliVCluster*clu,  Bool_t&sure){
+  //Finds primary and estimates if it unique one?
+  //First check can it be photon/electron
+  const Double_t emFraction=0.9; //part of energy of cluster to be assigned to EM particle
+  Int_t n=clu->GetNLabels() ;
+  for(Int_t i=0;  i<n;  i++){
+    TParticle*  p=  fStack->Particle(clu->GetLabelAt(i)) ;
+    Int_t pdg = p->GetPdgCode() ;
+    if(pdg==22  ||  pdg==11 || pdg == -11){
+      if(p->Energy()>emFraction*clu->E()){
+       sure=kTRUE ;
+       return clu->GetLabelAt(i);
+      }
+    }
+  }
+
+  Double_t*  Ekin=  new  Double_t[n] ;
+  for(Int_t i=0;  i<n;  i++){
+    TParticle*  p=  fStack->Particle(clu->GetLabelAt(i)) ;
+    Ekin[i]=p->P() ;  // estimate of kinetic energy
+    if(p->GetPdgCode()==-2212  ||  p->GetPdgCode()==-2112){
+      Ekin[i]+=1.8  ;  //due to annihilation
+    }
+  }
+  Int_t iMax=0;
+  Double_t eMax=0.,eSubMax=0. ;
+  for(Int_t i=0;  i<n;  i++){
+    if(Ekin[i]>eMax){
+      eSubMax=eMax;
+      eMax=Ekin[i];
+      iMax=i;
+    }
+  }
+  if(eSubMax>0.8*eMax)//not obvious primary
+    sure=kFALSE;
+  else
+    sure=kTRUE;
+  delete[]  Ekin;
+  return  clu->GetLabelAt(iMax) ;
+}
+
+//________________________________________________________________________
+Int_t AliAnalysisTaskPi0FlowMC::FindCommonParent(Int_t iPart, Int_t jPart){
+  //check if there is a common parent for particles i and j
+  // -1: no common parent or wrong iPart/jPart
+  
+  if(iPart==-1 || iPart>=fStack->GetNtrack() || 
+     jPart==-1 || jPart>=fStack->GetNtrack()) return -1;
+  
+  Int_t iprim1=iPart;
+  while(iprim1>-1){  
+     Int_t iprim2=jPart;
+     while(iprim2>-1){
+       if(iprim1==iprim2)
+        return iprim1 ;
+       iprim2=((TParticle *)fStack->Particle(iprim2))->GetFirstMother();
+     }
+     iprim1=((TParticle *)fStack->Particle(iprim1))->GetFirstMother();
+  }
+  return -1;
+}
+//________________________________________________________________________
+Bool_t AliAnalysisTaskPi0FlowMC::HaveParent(Int_t iPart, Int_t pdgParent){
+  //check if there is a common parent for particles i and j
+  // -1: no common parent or wrong iPart/jPart
+  
+  if(iPart==-1 || iPart>=fStack->GetNtrack()) return -1;
+  
+  Int_t iprim1=iPart;
+  while(iprim1>-1){  
+    TParticle * tmp = fStack->Particle(iprim1) ;
+    if(tmp->GetPdgCode()==pdgParent)
+      return kTRUE ;
+    iprim1=tmp->GetFirstMother();
+  }
+  return kFALSE;
+}
+//________________________________________________________________________
+Bool_t AliAnalysisTaskPi0FlowMC::InPi0mass(Double_t m, Double_t /*pt*/){
+
+ return TMath::Abs(m-0.135)<0.007*2.5 ;
+}
index fd946f6..3e80368 100644 (file)
@@ -22,15 +22,22 @@ public:
   AliAnalysisTaskPi0FlowMC(const char* name = "AliAnalysisTaskPi0Flow", Period period = kUndefinedPeriod);
   virtual ~AliAnalysisTaskPi0FlowMC();
 
+protected: // Override:
+  virtual void UserCreateOutputObjects();
+  virtual void UserExec(Option_t *option);
+  // Pi0FlowTask
+  virtual void SelectPhotonClusters();
+  virtual void FillSelectedClusterHistograms();
+  virtual void ConsiderPi0s();
+  virtual void ConsiderPi0sMix();
+  virtual void ProcessMC();
+
 protected: // member functions:
   AliAnalysisTaskPi0FlowMC(const AliAnalysisTaskPi0FlowMC&); // not implemented
   AliAnalysisTaskPi0FlowMC& operator=(const AliAnalysisTaskPi0FlowMC&); // not implemented
-
-  virtual void MakeMCHistograms();
-  virtual void DoMC();
   
   AliStack* GetMCStack();
-  
+
 protected: // member variables:
   AliStack* fStack;
   
@@ -39,6 +46,7 @@ protected: // member variables:
   Double_t PrimaryWeight(Int_t primary);
   Double_t PrimaryParticleWeight(TParticle * particle);
   void FillSecondaries() ;
+  Int_t FindPrimary(AliVCluster* clu,  Bool_t& sure);
   Int_t FindCommonParent(Int_t iPart, Int_t jPart) ;
   Bool_t HaveParent(Int_t iPart, Int_t pdgParent);
   Bool_t InPi0mass(Double_t m, Double_t pt);
@@ -47,8 +55,8 @@ protected: // member variables:
 
   static const Double_t kRCut = 1.;
   enum ParticleID {kEta=221};
-  
-  
+
+
   ClassDef(AliAnalysisTaskPi0FlowMC, 1); // PHOS analysis task
 };
 
index 75f25cd..923292b 100644 (file)
@@ -1,5 +1,8 @@
 void AddPi0FlowAndDependenciesMC()
 {
+  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddMCHandler.C");
+  AddMCHandler();
+
   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
   AddTaskEventplane();