]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGGA/PHOSTasks/PHOS_Correlation/AliPHOSCorrelations.cxx
Setters/getters updated, code polished
[u/mrichter/AliRoot.git] / PWGGA / PHOSTasks / PHOS_Correlation / AliPHOSCorrelations.cxx
index 2f03deba5367b5c9b0ed7536a7e3633d5e354714..ee4f602ae3698809ae7e9d5a24fd49001d3eb789 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
  
-// Analysis task for identified PHOS cluster from pi0 and extracting pi0-hadron correlation.
-// Authors:    Daniil Ponomarenko <Daniil.Ponomarenko@cern.ch>
-//             Dmitry Blau <Dmitry.Blau@cern.ch>
-// 09-Jul-2014
+// Analysis task for identifion PHOS cluster from Pi0 and extracting pi0-hadron correlation.
+// Author:     Daniil Ponomarenko <Daniil.Ponomarenko@cern.ch>
+// 20-Sept-2014
 
 #include <Riostream.h>
 #include "THashList.h"
@@ -68,115 +67,82 @@ ClassImp(AliPHOSCorrelations)
 AliPHOSCorrelations::AliPHOSCorrelations()
 :AliAnalysisTaskSE(),
        fPHOSGeo(0x0),
-       fOutputContainer(0x0),
-       fMinClusterEnergy(0.3),
-       fMinBCDistance(0),
-       fMinNCells(3),
-       fMinM02(0.2),
-       fTOFCutEnabled(1),
-       fTOFCut(100.e-9),
-       fNVtxZBins(1),
-       fCentEdges(10),
-       fCentNMixed(),
-       fNEMRPBins(9),
-       fAssocBins(),   
-    fUseMEAlgoritmForReal(true),
-    fUseMEAlgoritmForMix(true),
-    fUseEfficiency(true),
-    fMakePHOSModulesCorrFunctions(false),
-    fMakeTPCHalfBarrelCorrFunctions(false),
-       fCheckHibridGlobal(kOnlyHibridTracks),
+    fOutputContainer(0x0),
+    fEvent(0x0),
+    fEventESD(0x0),
+    fEventAOD(0x0),
+    fEventHandler(0),
+    fCaloPhotonsPHOS(0x0),
+    fTracksTPC(0x0),
+    fCaloPhotonsPHOSLists(0x0),
+    fTracksTPCLists(0x0),
+    fRunNumber(-999),
+    fInternalRunNumber(0),
+    fPeriod(kUndefinedPeriod),
        fPHOSEvent(false),
-       fMBEvent(false),
-       fPeriod(kUndefinedPeriod),
-       fMaxAbsVertexZ(10.),
-       fManualV0EPCalc(false),
-       fCentCutoffDown(0.),
-       fCentCutoffUp(90),
-       fMassInvMean(0.135),
-       fMassInvSigma(0.05),
-       fSigmaWidth(0.),
-       fMassMeanP0(1.00796e-05),
-       fMassMeanP1(0.136096),
-       fMassSigmaP0(0.00100059),
-       fMassSigmaP1(1.10485),
-       fMassSigmaP2(0.00570446),
-       fMassSigmaP3(0.00100001),
-       fEvent(0x0),
-       fEventESD(0x0),
-       fEventAOD(0x0),
-       fEventHandler(0),
-       fESDtrackCuts(0x0),
-       fRunNumber(-999),
-       fInternalRunNumber(0),
-       fMultV0(0x0),
-       fV0Cpol(0.),fV0Apol(0.),
-       fEPcalibFileName("$ALICE_ROOT/OADB/PHOS/PHOSflat.root"),
+    fMBEvent(false),
+    fNVtxZBins(10),
+    fCentEdges(10),
+    fCentNMixed(),
+    fNEMRPBins(9),
+    fAssocBins(),
        fVertexVector(),
-       fVtxBin(0),
-       fCentralityEstimator("V0M"),
-       fCentrality(0.),
-       fCentBin(0),
-       fHaveTPCRP(0),
-       fRP(0.),
-       fEMRPBin(0),
-       fCaloPhotonsPHOS(0x0),
-       fTracksTPC(0x0),
-       fCaloPhotonsPHOSLists(0x0),
-       fTracksTPCLists(0x0)
-{
-  //Deafult constructor, no memory allocations here
-}
-
-//_______________________________________________________________________________
-AliPHOSCorrelations::AliPHOSCorrelations(const char *name)
-:AliAnalysisTaskSE(name),
-    fPHOSGeo(0x0),
-    fOutputContainer(0x0),
+    fVtxBin(0),
+    fCentralityEstimator("V0M"),
+    fCentrality(0.),
+    fCentBin(0),
+    fHaveTPCRP(0),
+    fRP(0.),
+    fEMRPBin(0),
+    fMaxAbsVertexZ(10.),
+    fCentralityLowLimit(0.),
+    fCentralityHightLimit(90),
+    fESDtrackCuts(0x0),
+    fCheckHibridGlobal(kOnlyHibridTracks),
     fMinClusterEnergy(0.3),
     fMinBCDistance(0),
     fMinNCells(3),
     fMinM02(0.2),
     fTOFCutEnabled(1),
     fTOFCut(100.e-9),
-    fNVtxZBins(1),
-    fCentEdges(10),
-    fCentNMixed(),
-    fNEMRPBins(9),
-    fAssocBins(),
-    fUseMEAlgoritmForReal(true),
-    fUseMEAlgoritmForMix(true),
-    fUseEfficiency(true),
-    fMakePHOSModulesCorrFunctions(false),
-    fMakeTPCHalfBarrelCorrFunctions(false),
-    fCheckHibridGlobal(kOnlyHibridTracks),
-    fPHOSEvent(false),
-    fMBEvent(false),
-    fPeriod(kUndefinedPeriod),
-    fMaxAbsVertexZ(10.),
-    fManualV0EPCalc(false),
-    fCentCutoffDown(0.),
-    fCentCutoffUp(90),
     fMassInvMean(0.135),
     fMassInvSigma(0.05),
     fSigmaWidth(0.),
-    fMassMeanP0(1.00796e-05),
-       fMassMeanP1(0.136096),
-       fMassSigmaP0(0.00100059),
-       fMassSigmaP1(1.10485),
-       fMassSigmaP2(0.00570446),
-       fMassSigmaP3(0.00100001),
+    fUseEfficiency(true)
+{
+       //Deafult constructor, no memory allocations here
+       fMassMean[0] = 1.00796e-05 ;
+       fMassMean[1] = 0.136096    ;
+       fMassSigma[0] = 0.00100059 ;
+       fMassSigma[1] = 1.10485 ;
+       fMassSigma[2] = 0.00570446 ;
+       fMassSigma[3] = 0.00100001 ;
+}
+
+//_______________________________________________________________________________
+AliPHOSCorrelations::AliPHOSCorrelations(const char *name)
+:AliAnalysisTaskSE(name),
+    fPHOSGeo(0x0),
+    fOutputContainer(0x0),
     fEvent(0x0),
     fEventESD(0x0),
     fEventAOD(0x0),
     fEventHandler(0),
-    fESDtrackCuts(0x0),
+    fCaloPhotonsPHOS(0x0),
+    fTracksTPC(0x0),
+    fCaloPhotonsPHOSLists(0x0),
+    fTracksTPCLists(0x0),
     fRunNumber(-999),
     fInternalRunNumber(0),
-    fMultV0(0x0),
-    fV0Cpol(0.),fV0Apol(0.),
-    fEPcalibFileName("$ALICE_ROOT/OADB/PHOS/PHOSflat.root"),
-    fVertexVector(),
+    fPeriod(kUndefinedPeriod),
+       fPHOSEvent(false),
+    fMBEvent(false),
+    fNVtxZBins(10),
+    fCentEdges(10),
+    fCentNMixed(),
+    fNEMRPBins(9),
+    fAssocBins(),
+       fVertexVector(),
     fVtxBin(0),
     fCentralityEstimator("V0M"),
     fCentrality(0.),
@@ -184,28 +150,47 @@ AliPHOSCorrelations::AliPHOSCorrelations(const char *name)
     fHaveTPCRP(0),
     fRP(0.),
     fEMRPBin(0),
-    fCaloPhotonsPHOS(0x0),
-    fTracksTPC(0x0),
-    fCaloPhotonsPHOSLists(0x0),
-    fTracksTPCLists(0x0)
+    fMaxAbsVertexZ(10.),
+    fCentralityLowLimit(0.),
+    fCentralityHightLimit(90),
+    fESDtrackCuts(0x0),
+    fCheckHibridGlobal(kOnlyHibridTracks),
+    fMinClusterEnergy(0.3),
+    fMinBCDistance(0),
+    fMinNCells(3),
+    fMinM02(0.2),
+    fTOFCutEnabled(1),
+    fTOFCut(100.e-9),
+    fMassInvMean(0.135),
+    fMassInvSigma(0.05),
+    fSigmaWidth(0.),
+    fUseEfficiency(true)
 {
     // Constructor
     // Output slots #0 write into a TH1 container
     DefineOutput(1,THashList::Class());
 
-    const Int_t nPtAssoc=10 ;
-    Double_t ptAssocBins[nPtAssoc]={0.,0.5,1.0,1.5,2.0,3.,5.,7.,10.,16} ;
+    fMassMean[0] = 1.00796e-05 ;
+       fMassMean[1] = 0.136096    ;
+       fMassSigma[0] = 0.00100059 ;
+       fMassSigma[1] = 1.10485 ;
+       fMassSigma[2] = 0.00570446 ;
+       fMassSigma[3] = 0.00100001 ;
+
+    const Int_t nPtAssoc = 10 ;
+    Double_t ptAssocBins[nPtAssoc] = {0.,0.5,1.0,1.5,2.0,3.,5.,7.,10.,16} ;
     fAssocBins.Set(nPtAssoc,ptAssocBins) ;
 
     const int nbins = 9;
     Double_t edges[nbins+1] = {0., 5., 10., 20., 30., 40., 50., 60., 70., 80.};
-    TArrayD centEdges(nbins+1, edges);
+    TArrayD centEdges( nbins+1, edges );
     Int_t nMixed[nbins] = {4,4,6,10,20,30,50,100,100};
-    //Int_t nMixed[nbins] = {100,100,100,100,100,100,100,100,100};
     TArrayI centNMixed(nbins, nMixed);
     SetCentralityBinning(centEdges, centNMixed);
 
-    fVertex[0]=0; fVertex[1]=0; fVertex[2]=0;
+    fVertex[0] = 0; 
+    fVertex[1] = 0; 
+    fVertex[2] = 0;
 
     SetGeometry();
 
@@ -216,67 +201,60 @@ AliPHOSCorrelations::AliPHOSCorrelations(const char *name)
 AliPHOSCorrelations::AliPHOSCorrelations(const char *name, Period period)
 :AliAnalysisTaskSE(name),
        fPHOSGeo(0x0),
-       fOutputContainer(0x0),
-       fMinClusterEnergy(0.3),
-       fMinBCDistance(0),
-       fMinNCells(3),
-       fMinM02(0.2),
-       fTOFCutEnabled(1),
-       fTOFCut(100.e-9),
-       fNVtxZBins(1),
-       fCentEdges(10),
-       fCentNMixed(),
-       fNEMRPBins(9),
-       fAssocBins(),   
-    fUseMEAlgoritmForReal(true),
-    fUseMEAlgoritmForMix(true),
-    fUseEfficiency(true),
-    fMakePHOSModulesCorrFunctions(false),
-    fMakeTPCHalfBarrelCorrFunctions(false),
-       fCheckHibridGlobal(kOnlyHibridTracks),
+    fOutputContainer(0x0),
+    fEvent(0x0),
+    fEventESD(0x0),
+    fEventAOD(0x0),
+    fEventHandler(0),
+    fCaloPhotonsPHOS(0x0),
+    fTracksTPC(0x0),
+    fCaloPhotonsPHOSLists(0x0),
+    fTracksTPCLists(0x0),
+    fRunNumber(-999),
+    fInternalRunNumber(0),
+    fPeriod(period),
        fPHOSEvent(false),
-       fMBEvent(false),
-       fPeriod(period),
-       fMaxAbsVertexZ(10.),
-       fManualV0EPCalc(false),
-       fCentCutoffDown(0.),
-       fCentCutoffUp(90),
-       fMassInvMean(0.135),
-       fMassInvSigma(0.05),
-       fSigmaWidth(0.),
-       fMassMeanP0(1.00796e-05),
-       fMassMeanP1(0.136096),
-       fMassSigmaP0(0.00100059),
-       fMassSigmaP1(1.10485),
-       fMassSigmaP2(0.00570446),
-       fMassSigmaP3(0.00100001),
-       fEvent(0x0),
-       fEventESD(0x0),
-       fEventAOD(0x0),
-       fEventHandler(0),
-       fESDtrackCuts(0x0),
-       fRunNumber(-999),
-       fInternalRunNumber(0),
-       fMultV0(0x0),
-       fV0Cpol(0.),fV0Apol(0.),
-       fEPcalibFileName("$ALICE_ROOT/OADB/PHOS/PHOSflat.root"),
+    fMBEvent(false),
+    fNVtxZBins(10),
+    fCentEdges(10),
+    fCentNMixed(),
+    fNEMRPBins(9),
+    fAssocBins(),
        fVertexVector(),
-       fVtxBin(0),
-       fCentralityEstimator("V0M"),
-       fCentrality(0.),
-       fCentBin(0),
-       fHaveTPCRP(0),
-       fRP(0.),
-       fEMRPBin(0),
-       fCaloPhotonsPHOS(0x0),
-       fTracksTPC(0x0),
-       fCaloPhotonsPHOSLists(0x0),
-       fTracksTPCLists(0x0)
+    fVtxBin(0),
+    fCentralityEstimator("V0M"),
+    fCentrality(0.),
+    fCentBin(0),
+    fHaveTPCRP(0),
+    fRP(0.),
+    fEMRPBin(0),
+    fMaxAbsVertexZ(10.),
+    fCentralityLowLimit(0.),
+    fCentralityHightLimit(90),
+    fESDtrackCuts(0x0),
+    fCheckHibridGlobal(kOnlyHibridTracks),
+    fMinClusterEnergy(0.3),
+    fMinBCDistance(0),
+    fMinNCells(3),
+    fMinM02(0.2),
+    fTOFCutEnabled(1),
+    fTOFCut(100.e-9),
+    fMassInvMean(0.135),
+    fMassInvSigma(0.05),
+    fSigmaWidth(0.),
+    fUseEfficiency(true)
 {
        // Constructor
        // Output slots #0 write into a TH1 container
        DefineOutput(1,THashList::Class());
 
+       fMassMean[0] = 1.00796e-05 ;
+       fMassMean[1] = 0.136096    ;
+       fMassSigma[0] = 0.00100059 ;
+       fMassSigma[1] = 1.10485 ;
+       fMassSigma[2] = 0.00570446 ;
+       fMassSigma[3] = 0.00100001 ;
+
        const Int_t nPtAssoc=10 ;
        Double_t ptAssocBins[nPtAssoc]={0.,0.5,1.0,1.5,2.0,3.,5.,7.,10.,16} ;
        fAssocBins.Set(nPtAssoc,ptAssocBins) ;
@@ -289,12 +267,15 @@ AliPHOSCorrelations::AliPHOSCorrelations(const char *name, Period period)
        TArrayI centNMixed(nbins, nMixed);
        SetCentralityBinning(centEdges, centNMixed);
 
-       fVertex[0]=0; fVertex[1]=0; fVertex[2]=0; 
+       fVertex[0] = 0; 
+       fVertex[1] = 0; 
+       fVertex[2] = 0; 
 
        SetGeometry();
 
        ZeroingVariables();
 }
+
 //_______________________________________________________________________________
 AliPHOSCorrelations::~AliPHOSCorrelations()
 {
@@ -330,15 +311,16 @@ AliPHOSCorrelations::~AliPHOSCorrelations()
          fOutputContainer=0x0;
        }         
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::UserCreateOutputObjects()
 {
        // Create histograms
        // Called once
-       const Int_t nRuns=200 ;
-       const Int_t  ptMult = 200;
-       const Double_t ptMin = 0.;
-       const Double_t ptMax = 20.;
+       const Int_t     nRuns   =200 ;
+       const Int_t     ptMult  = 300;
+       const Double_t  ptMin   = 0.;
+       const Double_t  ptMax   = 30.;
 
        // Create histograms
        if(fOutputContainer != NULL) { delete fOutputContainer; }
@@ -346,28 +328,27 @@ void AliPHOSCorrelations::UserCreateOutputObjects()
        fOutputContainer->SetOwner(kTRUE);
        
     // Event selection
-    fOutputContainer->Add(new TH1F("hTriggerPassedEvents","Event selection passed Cuts", 20, 0., 20.) );
+    fOutputContainer->Add(new TH1F( "hTriggerPassedEvents","Event selection passed Cuts",      20, 0., 20.) );
     // Analysis event's progress
-    fOutputContainer->Add(new TH1F("hTotSelEvents","Event selection", 15, 0., 15)) ;
-       fOutputContainer->Add(new TH2F("hSelEvents","Event selection", kTotalSelected+1, 0., double(kTotalSelected+1), nRuns,0.,float(nRuns))) ;
+    fOutputContainer->Add(new TH1F( "hTotSelEvents","Event selection",                                                 15, 0., 15)) ;
+       fOutputContainer->Add(new TH2F( "hSelEvents","Event selection", kTotalSelected+1, 0., double(kTotalSelected+1), nRuns,0., float(nRuns) )) ;
     // Centrality, Reaction plane selection
-    fOutputContainer->Add(new TH2F("hCentrality","Event centrality of all events", 100,0.,100.,nRuns,0.,float(nRuns))) ;
-    fOutputContainer->Add(new TH2F("hCentralityTriggerEvent","Event centrality trigger events", 100,0.,100.,nRuns,0.,float(nRuns))) ;
-    fOutputContainer->Add(new TH2F("hCentralityMBEvent","Event centrality MB events", 100,0.,100.,nRuns,0.,float(nRuns))) ;
-
-       fOutputContainer->Add(new TH2F("phiRPflat","RP distribution with TPC flat", 100, 0., 2.*TMath::Pi(),20,0.,100.)) ;
+    fOutputContainer->Add(new TH2F( "hCentrality","Event centrality of all events",                            100, 0., 100., nRuns,0., float(nRuns)   )) ;
+    fOutputContainer->Add(new TH2F( "hCentralityTriggerEvent","Event centrality trigger events",       100, 0., 100., nRuns,0., float(nRuns)   )) ;
+    fOutputContainer->Add(new TH2F( "hCentralityMBEvent","Event centrality MB events",                                 100, 0., 100., nRuns,0., float(nRuns)   )) ;
+       fOutputContainer->Add(new TH2F( "phiRPflat","RP distribution with TPC flat",                                    100, 0., 2.*TMath::Pi(), 20, 0., 100.   )) ;
     // Mass selection
-       fOutputContainer->Add(new TH2F("massWindow","mean & sigma", 100,0.095,0.185,500,0.,0.05));
-    fOutputContainer->Add(new TH1F("massWindowPass","Mass selection", 10, 0., 10.)) ;
+       fOutputContainer->Add(new TH2F( "massWindow","mean & sigma",                                                                    100,0.095,0.185,500,0.,0.05));
+    fOutputContainer->Add(new TH1F( "massWindowPass","Mass selection",                                                                 10, 0., 10.)) ;
     // Cluster multiplisity
-       fOutputContainer->Add(new TH2F("hCluEvsClu","ClusterMult vs E",200,0.,10.,100,0.,100.)) ;
+       fOutputContainer->Add(new TH2F( "hCluEvsClu","ClusterMult vs E",                                                                200,0.,10.,100,0.,100.)) ;
        
 
        // Set hists, with track's and cluster's angle distributions.
        SetHistPtNumTrigger(ptMult, ptMin, ptMax);
        SetHistEtaPhi();
        SetHistPHOSClusterMap();
-       SetHistMass(ptMult, ptMin, ptMax);
+       SetHistMass       (ptMult, ptMin, ptMax);
        SetHistPtAssoc(ptMult, ptMin, ptMax);
 
        // Setup photon lists
@@ -380,13 +361,16 @@ void AliPHOSCorrelations::UserCreateOutputObjects()
 
        PostData(1, fOutputContainer);
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SetHistPtNumTrigger(Int_t  ptMult, Double_t ptMin, Double_t ptMax)
 {
        TString spid[4]={"all","cpv","disp","both"} ;
        for(Int_t ipid=0; ipid<4; ipid++)       
        {
-               fOutputContainer->Add(new TH1F(Form("nTrigger_%s", spid[ipid].Data()), Form("Num of trigger particle %s", spid[ipid].Data()), ptMult+300, ptMin, ptMax ) );
+               fOutputContainer->Add(new TH1F( Form("nTrigger_%s", spid[ipid].Data()), 
+                                                                               Form("Num of trigger particle %s", spid[ipid].Data()), 
+                                                                               ptMult+300, ptMin, ptMax ) );
                TH1F *h = static_cast<TH1F*>(fOutputContainer->Last()) ;
                h->Sumw2();
                h->GetXaxis()->SetTitle("Pt [GEV]");
@@ -394,13 +378,16 @@ void AliPHOSCorrelations::SetHistPtNumTrigger(Int_t  ptMult, Double_t ptMin, Dou
        }
        for(Int_t ipid=0; ipid<4; ipid++)       
        {
-               fOutputContainer->Add(new TH1F(Form("nTrigger_%s_MB", spid[ipid].Data()), Form("Num of trigger particle %s", spid[ipid].Data()), ptMult+300, ptMin, ptMax ) );
+               fOutputContainer->Add(new TH1F( Form("nTrigger_%s_MB", spid[ipid].Data()), 
+                                                                               Form("Num of trigger particle %s", spid[ipid].Data()), 
+                                                                               ptMult+300, ptMin, ptMax ) );
                TH1F *h = static_cast<TH1F*>(fOutputContainer->Last()) ;
                h->Sumw2();
                h->GetXaxis()->SetTitle("Pt [GEV]");
                //h->GetYaxis()->SetTitle("#varepsilon"); // 1/efficiensy
        }
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SetHistEtaPhi() 
 {
@@ -409,31 +396,35 @@ void AliPHOSCorrelations::SetHistEtaPhi()
        Float_t pi = TMath::Pi();
 
        //===
-       fOutputContainer->Add(new TH2F("clu_phieta","Cluster's #phi & #eta distribution", 300, double(-1.8), double(-0.6), 300, double(-0.2), double(0.2) ) );
+       fOutputContainer->Add(new TH2F( "clu_phieta","Cluster's #phi & #eta distribution", 
+                                                                       300, double(-1.8), double(-0.6), 
+                                                                       300, double(-0.2), double(0.2) ) );
        TH2F * h = static_cast<TH2F*>(fOutputContainer->Last()) ;
-       h->GetXaxis()->SetTitle("#phi [rad]");
+    h->GetXaxis()->SetTitle("#phi [rad]");
        h->GetYaxis()->SetTitle("#eta");
 
        //===
-               fOutputContainer->Add(new TH2F("clusingle_phieta","Cluster's  #phi & #eta distribution", 300, double(-1.8), double(-0.6), 300, double(-0.2), double(0.2) ) );
+               fOutputContainer->Add(new TH2F( "clusingle_phieta","Cluster's  #phi & #eta distribution", 
+                                                                               300, double(-1.8), double(-0.6), 
+                                                                               300, double(-0.2), double(0.2) ) );
        h = static_cast<TH2F*>(fOutputContainer->Last()) ;
-       h->GetXaxis()->SetTitle("#phi [rad]");
+    h->GetXaxis()->SetTitle("#phi [rad]");
        h->GetYaxis()->SetTitle("#eta");
        
        //===
-       fOutputContainer->Add(new TH2F("track_phieta","TPC track's  #phi & #eta distribution", 200, double(-pi-0.3), double(pi+0.3), 200, double(-0.9), double(0.9) ) );
+       fOutputContainer->Add(new TH2F( "track_phieta","TPC track's  #phi & #eta distribution", 
+                                                                       200, double(-pi-0.3), double(pi+0.3), 
+                                                                       200, double(-0.9), double(0.9) ) );
        h = static_cast<TH2F*>(fOutputContainer->FindObject("track_phieta")) ;
-       h->GetXaxis()->SetTitle("#phi [rad]");
+    h->GetXaxis()->SetTitle("#phi [rad]");
        h->GetYaxis()->SetTitle("#eta");
 } 
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SetHistMass(Int_t  ptMult, Double_t ptMin, Double_t ptMax) 
 {
-       // Set other histograms.
-       // cout<<"\nSetting output SetHist_CutDistribution...";
-       
-       // Double_t massMin = fMassInvMean-fMassInvSigma;
-       // Double_t massMax = fMassInvMean+fMassInvSigma;
+       // Set mass histograms.
+
        Double_t binMult = 400;
        Double_t massMin = 0.0;
        Double_t massMax = 0.4;
@@ -446,44 +437,9 @@ void AliPHOSCorrelations::SetHistMass(Int_t  ptMult, Double_t ptMin, Double_t pt
        {
                // Real ++++++++++++++++++++++++++++++
 
-               fOutputContainer->Add(new TH2F(Form("%s_mpt",spid[ipid].Data() )," real ", binMult, massMin, massMax, ptMult, ptMin, ptMax ) );
-               h = static_cast<TH2F*>(fOutputContainer->Last()) ;
-               //h->Sumw2();
-               h->GetXaxis()->SetTitle("Mass [GeV]");
-               h->GetYaxis()->SetTitle("Pt [GEV]");
-
-               // MIX +++++++++++++++++++++++++
-
-               fOutputContainer->Add(new TH2F(Form("mix_%s_mpt",spid[ipid].Data() )," mix ", binMult, massMin, massMax, ptMult, ptMin, ptMax ) );
-               h = static_cast<TH2F*>(fOutputContainer->Last()) ;
-               //h->Sumw2();
-           h->GetXaxis()->SetTitle("Mass [GeV]");
-               h->GetYaxis()->SetTitle("Pt [GEV]");
-       }
-
-       // Calibration PHOS Module Pi0peak {REAL}
-       for(Int_t mod=1; mod<4; mod++){
-         fOutputContainer->Add(new TH2F(Form("both%d_mpt",mod),Form("Both cuts (CPV + Disp) mod[%d]",mod), binMult, massMin, massMax, ptMult, ptMin, ptMax ) );
-         h = static_cast<TH2F*>(fOutputContainer->Last()) ;
-         //h->Sumw2();
-         h->GetXaxis()->SetTitle("Mass [GeV]");
-         h->GetYaxis()->SetTitle("Pt [GEV]");
-
-         // Calibration PHOS Module Pi0peak {MIX}
-         fOutputContainer->Add(new TH2F(Form("mix_both%d_mpt",mod),Form(" Both cuts (CPV + Disp) mod[%d]",mod), binMult, massMin, massMax, ptMult, ptMin, ptMax ) );
-         h = static_cast<TH2F*>(fOutputContainer->Last()) ;
-         //h->Sumw2();
-         h->GetXaxis()->SetTitle("Mass [GeV]");
-         h->GetYaxis()->SetTitle("Pt [GEV]");
-         
-       }
-
-       // For efficiensy.
-       for(Int_t ipid=0; ipid<4; ipid++)       
-       {
-               // Real ++++++++++++++++++++++++++++++
-
-               fOutputContainer->Add(new TH2F(Form("%s_mpt_eff",spid[ipid].Data() )," real ", binMult, massMin, massMax, ptMult, ptMin, ptMax ) );
+               fOutputContainer->Add(new TH2F(Form("%s_mpt", spid[ipid].Data() ), "Real", 
+                                                                                       binMult, massMin, massMax, 
+                                                                                       ptMult, ptMin, ptMax ) );
                h = static_cast<TH2F*>(fOutputContainer->Last()) ;
                h->Sumw2();
                h->GetXaxis()->SetTitle("Mass [GeV]");
@@ -491,62 +447,71 @@ void AliPHOSCorrelations::SetHistMass(Int_t  ptMult, Double_t ptMin, Double_t pt
 
                // MIX +++++++++++++++++++++++++
 
-               fOutputContainer->Add(new TH2F(Form("mix_%s_mpt_eff",spid[ipid].Data() )," mix ", binMult, massMin, massMax, ptMult, ptMin, ptMax ) );
+               fOutputContainer->Add(new TH2F(Form("mix_%s_mpt", spid[ipid].Data() ), "Mix", 
+                                                                                       binMult, massMin, massMax, 
+                                                                                       ptMult, ptMin, ptMax ) );
                h = static_cast<TH2F*>(fOutputContainer->Last()) ;
                h->Sumw2();
-       h->GetXaxis()->SetTitle("Mass [GeV]");
+           h->GetXaxis()->SetTitle("Mass [GeV]");
                h->GetYaxis()->SetTitle("Pt [GEV]");
        }
 
        // Calibration PHOS Module Pi0peak {REAL}
        for(Int_t mod=1; mod<4; mod++){
-         fOutputContainer->Add(new TH2F(Form("both%d_mpt_eff",mod),Form("Both cuts (CPV + Disp) mod[%d]",mod), binMult, massMin, massMax, ptMult, ptMin, ptMax ) );
+         fOutputContainer->Add(new TH2F(Form(  "both%d_mpt",mod), Form("Both cuts (CPV + Disp) mod[%d]",mod), 
+                                                                                       binMult, massMin, massMax, 
+                                                                                       ptMult, ptMin, ptMax ) );
          h = static_cast<TH2F*>(fOutputContainer->Last()) ;
          h->Sumw2();
-         h->GetXaxis()->SetTitle("Mass [GeV]");
+         h->GetXaxis()->SetTitle("Mass [GeV]");
          h->GetYaxis()->SetTitle("Pt [GEV]");
 
          // Calibration PHOS Module Pi0peak {MIX}
-         fOutputContainer->Add(new TH2F(Form("mix_both%d_mpt_eff",mod),Form(" Both cuts (CPV + Disp) mod[%d]",mod), binMult, massMin, massMax, ptMult, ptMin, ptMax ) );
+         fOutputContainer->Add(new TH2F(Form(  "mix_both%d_mpt",mod), Form(" Both cuts (CPV + Disp) mod[%d]",mod), 
+                                                                                       binMult, massMin, massMax, 
+                                                                                       ptMult, ptMin, ptMax ) );
          h = static_cast<TH2F*>(fOutputContainer->Last()) ;
          h->Sumw2();
-         h->GetXaxis()->SetTitle("Mass [GeV]");
+         h->GetXaxis()->SetTitle("Mass [GeV]");
          h->GetYaxis()->SetTitle("Pt [GEV]");
+         
        }
-
-       // cout<<"  OK!"<<endl;
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SetHistPtAssoc(Int_t  ptMult, Double_t ptMin, Double_t ptMax)
 {
        Double_t pi = TMath::Pi();
        
-       Int_t PhiMult  =  100;
-       Float_t PhiMin =  -0.5*pi;
-       Float_t PhiMax =  1.5*pi;
-       Int_t EtaMult  =  20; 
-       Float_t EtaMin = -1.;
-       Float_t EtaMax =  1.;
+       Int_t PhiMult  =  100           ;
+       Float_t PhiMin =  -0.5*pi       ;
+       Float_t PhiMax =  1.5*pi        ;
+       Int_t EtaMult  =  20            
+       Float_t EtaMin = -1.            ;
+       Float_t EtaMax =  1.            ;
 
        TString spid[4]={"all","cpv","disp","both"} ;
-       Int_t PhotonsInMod[6] = {1, 2, 3, 12, 13, 23};
        
        for (int i = 0; i<fAssocBins.GetSize()-1; i++){
          for(Int_t ipid=0; ipid<4; ipid++){
-               // Main histo for ConsiderPi0s() or ConsiderPi0sME().
-               fOutputContainer->Add(new TH3F(Form("%s_ptphieta_ptAssoc_%3.1f",spid[ipid].Data(),fAssocBins.At(i+1)),
-                                              Form("%s_ptphieta_ptAssoc_%3.1f",spid[ipid].Data(),fAssocBins.At(i+1)), 
-                                              ptMult, ptMin, ptMax,  PhiMult, PhiMin, PhiMax, EtaMult, EtaMin, EtaMax ) );
+               // Main histo for ConsiderPi0s().
+               fOutputContainer->Add(new TH3F(Form("%s_ptphieta_ptAssoc_%3.1f", spid[ipid].Data(), fAssocBins.At(i+1)),
+                                              Form("%s_ptphieta_ptAssoc_%3.1f", spid[ipid].Data(), fAssocBins.At(i+1)), 
+                                              ptMult, ptMin, ptMax,  
+                                              PhiMult, PhiMin, PhiMax, 
+                                              EtaMult, EtaMin, EtaMax ) );
                TH3F * h = static_cast<TH3F*>(fOutputContainer->Last()) ;
                h->Sumw2();
        h->GetXaxis()->SetTitle("Pt_{triger} [GEV]");
                h->GetYaxis()->SetTitle("#phi [rad]");
                h->GetZaxis()->SetTitle("#eta");
 
-               // For ConsiderPi0sME_MBSelection().
-               fOutputContainer->Add(new TH3F(Form("%s_ptphieta_ptAssoc_%3.1f_MB",spid[ipid].Data(),fAssocBins.At(i+1)),
-                                              Form("%s_ptphieta_ptAssoc_%3.1f",spid[ipid].Data(),fAssocBins.At(i+1)), 
-                                              ptMult, ptMin, ptMax,  PhiMult, PhiMin, PhiMax, EtaMult, EtaMin, EtaMax ) );
+               // For ConsiderPi0s_MBSelection().
+               fOutputContainer->Add(new TH3F(Form("%s_ptphieta_ptAssoc_%3.1f_MB", spid[ipid].Data(), fAssocBins.At(i+1)),
+                                              Form("%s_ptphieta_ptAssoc_%3.1f", spid[ipid].Data(), fAssocBins.At(i+1)), 
+                                              ptMult, ptMin, ptMax,  
+                                              PhiMult, PhiMin, PhiMax, 
+                                              EtaMult, EtaMin, EtaMax ) );
                h = static_cast<TH3F*>(fOutputContainer->Last()) ;
                h->Sumw2();
        h->GetXaxis()->SetTitle("Pt_{triger} [GEV]");
@@ -554,63 +519,44 @@ void AliPHOSCorrelations::SetHistPtAssoc(Int_t  ptMult, Double_t ptMin, Double_t
                h->GetZaxis()->SetTitle("#eta");
 
                // For Mixed events in ConsiderTracksMix()
-               fOutputContainer->Add(new TH3F(Form("mix_%s_ptphieta_ptAssoc_%3.1f",spid[ipid].Data(),fAssocBins.At(i+1)),
-                                              Form("Mixed %s_ptphieta_ptAssoc_%3.1f",spid[ipid].Data(),fAssocBins.At(i+1)),
-                                              ptMult, ptMin, ptMax,  PhiMult, PhiMin, PhiMax, EtaMult, EtaMin, EtaMax ) );
+               fOutputContainer->Add(new TH3F(Form("mix_%s_ptphieta_ptAssoc_%3.1f", spid[ipid].Data(), fAssocBins.At(i+1)),
+                                              Form("Mixed %s_ptphieta_ptAssoc_%3.1f", spid[ipid].Data(), fAssocBins.At(i+1)),
+                                              ptMult, ptMin, ptMax,  
+                                              PhiMult, PhiMin, PhiMax, 
+                                              EtaMult, EtaMin, EtaMax ) );
                h = static_cast<TH3F*>(fOutputContainer->Last()) ;
                h->Sumw2();
                h->GetXaxis()->SetTitle("Pt_{triger} [GEV]");
                h->GetYaxis()->SetTitle("#phi [rad]");
                h->GetZaxis()->SetTitle("#eta");
-
-               if(fMakePHOSModulesCorrFunctions)       // For checking PHOS module dependens correletion function.
-               for(Int_t m=0; m<6; m++)
-               {
-                       fOutputContainer->Add(new TH3F(Form("mix_%s_ptphieta_ptAssoc_%3.1f_mod%i",spid[ipid].Data(),fAssocBins.At(i+1), PhotonsInMod[m]),
-                                              Form("Mixed %s_ptphieta_ptAssoc_%3.1f_mod%i",spid[ipid].Data(),fAssocBins.At(i+1), PhotonsInMod[m]),
-                                              ptMult, ptMin, ptMax,  PhiMult, PhiMin, PhiMax, EtaMult, EtaMin, EtaMax ) );
-                       h = static_cast<TH3F*>(fOutputContainer->Last()) ;
-                       h->Sumw2();
-                       h->GetXaxis()->SetTitle("Pt_{triger} [GEV]");
-                       h->GetYaxis()->SetTitle("#phi [rad]");
-                       h->GetZaxis()->SetTitle("#eta");
-               }
-
-               if(fMakeTPCHalfBarrelCorrFunctions) // For checking TPC dependens correletion function.
-               for(Int_t itpc=1; itpc<3; itpc++)
-               {
-                       fOutputContainer->Add(new TH3F(Form("mix_%s_ptphieta_ptAssoc_%3.1f_tpc%i",spid[ipid].Data(),fAssocBins.At(i+1), itpc),
-                                              Form("Mixed %s_ptphieta_ptAssoc_%3.1f_tpc%i",spid[ipid].Data(),fAssocBins.At(i+1), itpc),
-                                              ptMult, ptMin, ptMax,  PhiMult, PhiMin, PhiMax, EtaMult, EtaMin, EtaMax ) );
-                       h = static_cast<TH3F*>(fOutputContainer->Last()) ;
-                       h->Sumw2();
-                       h->GetXaxis()->SetTitle("Pt_{triger} [GEV]");
-                       h->GetYaxis()->SetTitle("#phi [rad]");
-                       h->GetZaxis()->SetTitle("#eta");
-               }
          }
        }
 }
 
+//_______________________________________________________________________________
 void AliPHOSCorrelations::SetHistPHOSClusterMap()
 {
+       //  Cluster X/Z/E distribution.
        for(int i =  0; i<5; i++)
        {
-               //  Cluster X/Z/E distribution.
-               fOutputContainer->Add(new TH3F(Form("QA_cluXZE_mod%i", i),Form("PHOS Clusters XZE distribution of module %i", i), 70, 0, 70, 60, 0, 60, 200, 0, 20 ) );
+               fOutputContainer->Add(new TH3F( Form("QA_cluXZE_mod%i", i), Form("PHOS Clusters XZE distribution of module %i", i), 
+                                                                               70, 0, 70, 
+                                                                               60, 0, 60, 
+                                                                               200, 0, 20 ) );
                TH3F *h = static_cast<TH3F*>(fOutputContainer->Last()) ;
            h->GetXaxis()->SetTitle("X");
                h->GetYaxis()->SetTitle("Z");
                h->GetZaxis()->SetTitle("E");
        }       
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::UserExec(Option_t *) 
 {
        // Main loop, called for each event analyze ESD/AOD 
        // Step 0: Event Objects
-
     LogProgress(0);
+
        fEvent = InputEvent();
        if( ! fEvent ) 
        {
@@ -619,23 +565,23 @@ void AliPHOSCorrelations::UserExec(Option_t *)
                return ;
        }
     LogProgress(1);
-               
-    ZeroingVariables();
-
-       fEventESD = dynamic_cast<AliESDEvent*>(fEvent);
-       fEventAOD = dynamic_cast<AliAODEvent*>(fEvent);
 
        // Step 1(done once):  
        if( fRunNumber != fEvent->GetRunNumber() )
        {
                fRunNumber = fEvent->GetRunNumber();
                fInternalRunNumber = ConvertToInternalRunNumber(fRunNumber);
-               //SetGeometry();
                SetESDTrackCuts();
        }
+       LogProgress(2);
+
+       // Step 2: Preparation variables for new event
+    ZeroingVariables();
 
-       //Data
-       //get Event-Handler for the trigger information
+       fEventESD = dynamic_cast<AliESDEvent*>(fEvent);
+       fEventAOD = dynamic_cast<AliAODEvent*>(fEvent);
+
+       // Get Event-Handler for the trigger information
        fEventHandler= dynamic_cast<AliInputEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
        if (!fEventHandler) 
        {
@@ -643,16 +589,18 @@ void AliPHOSCorrelations::UserExec(Option_t *)
                PostData(1, fOutputContainer);
                return; // Reject!
        }
-    LogProgress(2);
+    LogProgress(3);
 
+    // Step 3: Event trigger selection
+    // fPHOSEvent, fMBEvent
        if( RejectTriggerMaskSelection() ) 
        {
                PostData(1, fOutputContainer);
                return; // Reject!
        }
-    LogProgress(3);
-       
-       // Step 2: Vertex
+    LogProgress(4);
+
+       // Step 4: Vertex
        // fVertex, fVertexVector, fVtxBin
        SetVertex();
        if( RejectEventVertex() ) 
@@ -660,9 +608,9 @@ void AliPHOSCorrelations::UserExec(Option_t *)
                PostData(1, fOutputContainer);
                return; // Reject!
        }
-    LogProgress(4);
+    LogProgress(5);
 
-       // Step 3: Centrality
+       // Step 5: Centrality
        // fCentrality, fCentBin
        SetCentrality(); 
        if( RejectEventCentrality() ) 
@@ -670,108 +618,80 @@ void AliPHOSCorrelations::UserExec(Option_t *)
                PostData(1, fOutputContainer);
                return; // Reject!
        }
-    LogProgress(5);
-    FillHistogram("hCentrality",fCentrality,fInternalRunNumber-0.5) ;
-    if(fPHOSEvent) FillHistogram("hCentralityTriggerEvent",fCentrality,fInternalRunNumber-0.5) ;
-    if(fMBEvent) FillHistogram("hCentralityMBEvent",fCentrality,fInternalRunNumber-0.5) ;
+    LogProgress(6);
+    if(fPHOSEvent)     FillHistogram( "hCentralityTriggerEvent",       fCentrality, fInternalRunNumber-0.5 ) ;
+    if(fMBEvent)       FillHistogram( "hCentralityMBEvent",            fCentrality, fInternalRunNumber-0.5 ) ;
+    FillHistogram( "hCentrality", fCentrality, fInternalRunNumber-0.5 ) ;
 
-       // Step 4: Reaction Plane
+       // Step 6: Reaction Plane
        // fHaveTPCRP, fRP, fRPV0A, fRPV0C, fRPBin
        EvalReactionPlane();  
        fEMRPBin = GetRPBin(); 
        
-       // Step 5: Event Photons (PHOS Clusters) selectionMakeFlat
+       // Step 7: Event Photons (PHOS Clusters) selection
        SelectPhotonClusters();
        if( ! fCaloPhotonsPHOS->GetEntriesFast() )      
                LogSelection(kHasPHOSClusters, fInternalRunNumber);
 
-       // Step 6: Event Associated particles (TPC Tracks) selection
+       // Step 8: Event Associated particles (TPC Tracks) selection
        SelectAccosiatedTracks();
        if( ! fTracksTPC->GetEntriesFast() )    
         LogSelection(kHasTPCTracks, fInternalRunNumber);
        LogSelection(kTotalSelected, fInternalRunNumber);
 
-    // Step 7: Make TPC's mask
+    // Step 9: Fill TPC's track mask
     FillTrackEtaPhi();
+    LogProgress(7);
 
-    LogProgress(6);
 
-    // Step 8: Start correlation analysis.
-    // Filling real histograms:
-    if (fUseMEAlgoritmForReal) // if true than use ME algoritm
-    {
-        LogProgress(7);
-        SelectTriggerPi0ME();   // Extract one most energetic pi0 candidate in this event.
-
-        if (fPHOSEvent)
-        {
-            ConsiderPi0sME(); // Consider the most energetic Pi0 in this event with all tracks of this event.
-            LogProgress(8);
-        }
-        
-        if(fPeriod == kLHC13 && fMBEvent) 
-        {
-               ConsiderPi0sME_MBSelection();
-               LogProgress(9);
-        }
+    // Step 10: Extract one most energetic pi0 candidate in this event.   
+    SelectTriggerPi0ME();
 
+    // Step 11: Start correlation analysis.
+    if (fPHOSEvent)
+    {
+        ConsiderPi0s(); // Consider the most energetic Pi0 in this event with all tracks of this event.
+        LogProgress(8);
     }
-    else //using common algoritm
+    
+    if(fPeriod == kLHC13 && fMBEvent) 
     {
-        LogProgress(11);
-        if (fPHOSEvent)
-        {
-            ConsiderPi0s(); // Extract all pi0 candidates and compare them with all track of this event.
-            LogProgress(12);
-        }
+       ConsiderPi0s_MBSelection();
+       LogProgress(9);
     }
 
     // Filling mixing histograms:
-    if(fUseMEAlgoritmForMix) // if true than use ME algoritm
+    if (fMBEvent)
     {
-        // Filling mixing histograms
-        if (fMBEvent)
-        {
-            if (!fUseMEAlgoritmForReal)  SelectTriggerPi0ME();   // Extract one most energetic pi0 candidate in this event if it not done yet.
+        ConsiderPi0sMix();      // Make background for extracting pi0 mass.
+        ConsiderTracksMix();  // Compare only one most energetic pi0 candidate with all tracks from previous MB events.
 
-            ConsiderPi0sMix();      // Make background for extracting pi0 mass.
-            ConsiderTracksMixME();  // Compare only one most energetic pi0 candidate with all tracks from previous MB events.
-
-            UpdatePhotonLists();    // Updating pull of photons.
-            UpdateTrackLists();     // Updating pull of tracks.
-            LogProgress(10);
-        }
-    }
-    else //using common algoritm
-    {
-        if (fMBEvent)
-        {
-            ConsiderPi0sMix();      // Make background for extracting pi0 mass.
-            ConsiderTracksMix();    // Compare all pi0 candidates in current event whit all tracks from previous MB events.
-
-            UpdatePhotonLists();
-            UpdateTrackLists();
-            LogProgress(13);
-        }
+        UpdatePhotonLists();    // Updating pull of photons.
+        UpdateTrackLists();     // Updating pull of tracks.
+        LogProgress(10);
     }
 
     LogProgress(14);
        // Post output data.
        PostData(1, fOutputContainer);
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SetESDTrackCuts()
 {
-  if( fEventESD ) {
-    // Create ESD track cut
-    fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts() ;
-    //fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
-    fESDtrackCuts->SetRequireTPCRefit(kTRUE);
-  }
+       if( fEventESD ) 
+       {
+               // Create ESD track cut
+               fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts() ;
+               fESDtrackCuts->SetRequireTPCRefit(kTRUE) ;
+       }
 }
+
 //_______________________________________________________________________________
-Int_t AliPHOSCorrelations::ConvertToInternalRunNumber(Int_t run){
-  if(fPeriod== kLHC11h){
+Int_t AliPHOSCorrelations::ConvertToInternalRunNumber(Int_t run)
+{
+       // Manual setup using data from logbook.
+       if(fPeriod== kLHC11h){
                                switch(run)
                                {
                                        case  170593 : return 179 ;
@@ -1281,7 +1201,7 @@ Int_t AliPHOSCorrelations::ConvertToInternalRunNumber(Int_t run){
                                        AliWarning("Period not defined");
                                }
                                return 1;
-                       }
+}
 
 //_______________________________________________________________________________
 Bool_t AliPHOSCorrelations::RejectTriggerMaskSelection()
@@ -1295,44 +1215,42 @@ Bool_t AliPHOSCorrelations::RejectTriggerMaskSelection()
 
        Int_t physSelMask = fEventHandler->IsEventSelected();
 
-       Bool_t isAny = physSelMask & AliVEvent::kAny;
+       Bool_t isAny             = physSelMask & AliVEvent::kAny;
 
-       Bool_t isPHI1 = physSelMask & AliVEvent::kPHI1;
-       Bool_t isPHI7 = physSelMask & AliVEvent::kPHI7;
-       Bool_t isPHI8 = physSelMask & AliVEvent::kPHI8;
-       Bool_t isCentral = physSelMask & AliVEvent::kCentral;
+       Bool_t isPHI1            = physSelMask & AliVEvent::kPHI1;
+       Bool_t isPHI7            = physSelMask & AliVEvent::kPHI7;
+       Bool_t isPHI8            = physSelMask & AliVEvent::kPHI8;
+       Bool_t isCentral         = physSelMask & AliVEvent::kCentral;
        Bool_t isSemiCentral = physSelMask & AliVEvent::kSemiCentral;
-       Bool_t isPHOSPb = physSelMask & AliVEvent::kPHOSPb;
-
-       Bool_t isMB = physSelMask & AliVEvent::kMB;
-       Bool_t isINT7 = physSelMask & AliVEvent::kINT7;
-       Bool_t isAnyINT = physSelMask & AliVEvent::kAnyINT;
+       Bool_t isPHOSPb          = physSelMask & AliVEvent::kPHOSPb;
 
+       Bool_t isMB              = physSelMask & AliVEvent::kMB;
+       Bool_t isINT7            = physSelMask & AliVEvent::kINT7;
+       Bool_t isAnyINT          = physSelMask & AliVEvent::kAnyINT;
 
+       FillHistogram("hTriggerPassedEvents", 0 );
        // All input events
-       FillHistogram("hTriggerPassedEvents", 0);
-       //if ( !isAny ) cout<<"Strange event"<<endl; // We loose some events O_o
-       if ( isAny ) FillHistogram("hTriggerPassedEvents", 1.);         
+       if ( isAny )             FillHistogram("hTriggerPassedEvents",  1.) ;           
 
        // PHOS events.
-       if ( isPHI1 ) FillHistogram("hTriggerPassedEvents",  2.);       
-       if ( isPHI7 ) FillHistogram("hTriggerPassedEvents",  3.);       
-       if ( isPHI8 ) FillHistogram("hTriggerPassedEvents",  4.); 
-       if ( isCentral ) FillHistogram("hTriggerPassedEvents", 5.);     
-       if ( isSemiCentral ) FillHistogram("hTriggerPassedEvents", 6.); 
-       if ( isPHOSPb ) FillHistogram("hTriggerPassedEvents", 7.);      
+       if ( isPHI1 )            FillHistogram("hTriggerPassedEvents",  2. );   
+       if ( isPHI7 )            FillHistogram("hTriggerPassedEvents",  3. );   
+       if ( isPHI8 )            FillHistogram("hTriggerPassedEvents",  4. ); 
+       if ( isCentral )         FillHistogram("hTriggerPassedEvents",  5. );   
+       if ( isSemiCentral ) FillHistogram("hTriggerPassedEvents",      6. ); 
+       if ( isPHOSPb )          FillHistogram("hTriggerPassedEvents",  7. );   
 
        // MB events.
-       if ( isMB ) FillHistogram("hTriggerPassedEvents", 8.);          
-       if ( isINT7 ) FillHistogram("hTriggerPassedEvents", 9.);
-       if ( isAnyINT ) FillHistogram("hTriggerPassedEvents", 10.);
+       if ( isMB )              FillHistogram("hTriggerPassedEvents",  8. );           
+       if ( isINT7 )            FillHistogram("hTriggerPassedEvents",  9. );
+       if ( isAnyINT )          FillHistogram("hTriggerPassedEvents", 10. );
 
 
        Bool_t isTriggerEvent ;
-       Bool_t isMIXEvent ;
+       Bool_t isMIXEvent         ;
 
-       fPHOSEvent = false;
-       fMBEvent = false;
+       fPHOSEvent      = false ;
+       fMBEvent        = false ;
 
        if(fPeriod == kLHC13) 
        {
@@ -1369,8 +1287,8 @@ Bool_t AliPHOSCorrelations::RejectTriggerMaskSelection()
                {
                        FillHistogram("hTriggerPassedEvents", 16.);
                        FillHistogram("hTriggerPassedEvents", 17.);
-                       fPHOSEvent = true;
-                       fMBEvent = true;
+                       fPHOSEvent      = true;
+                       fMBEvent        = true;
                        return ACCEPT;
                }
        }
@@ -1379,6 +1297,7 @@ Bool_t AliPHOSCorrelations::RejectTriggerMaskSelection()
        FillHistogram("hTriggerPassedEvents",  18.); 
        return REJECT;
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SetVertex()
 {
@@ -1400,19 +1319,19 @@ void AliPHOSCorrelations::SetVertex()
 
        fVtxBin=0 ;// No support for vtx binning implemented.
 }
+
 //_______________________________________________________________________________
 Bool_t AliPHOSCorrelations::RejectEventVertex()
 {
-  if( ! fEvent->GetPrimaryVertex() )
-    return true; // reject
+  if( ! fEvent->GetPrimaryVertex() ) return true; // reject
   LogSelection(kHasVertex, fInternalRunNumber);
  
-  if ( TMath::Abs(fVertexVector.z()) > fMaxAbsVertexZ )
-    return true; // reject
+  if ( TMath::Abs(fVertexVector.z()) > fMaxAbsVertexZ ) return true; // reject
   LogSelection(kHasAbsVertex, fInternalRunNumber);
  
   return false; // accept event.
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SetCentrality()
 {
@@ -1425,63 +1344,73 @@ void AliPHOSCorrelations::SetCentrality()
                fCentrality = -1.;
        }
 
-       //cout<<"fCentrality: "<<fCentrality<<endl;
-       //FillHistogram("hCentrality",fCentrality,fInternalRunNumber-0.5) ;
        fCentBin = GetCentralityBin(fCentrality);
 }
+
 //_______________________________________________________________________________
 Bool_t AliPHOSCorrelations::RejectEventCentrality()
 {
-       if (fCentrality<fCentCutoffDown)
+       if (fCentrality<fCentralityLowLimit)
+               return true; //reject
+       if(fCentrality>fCentralityHightLimit)
                return true; //reject
-       if(fCentrality>fCentCutoffUp)
-               return true;
 
        return false;  // accept event.
 }
+
 //_______________________________________________________________________________
-void AliPHOSCorrelations::SetCentralityBinning(const TArrayD& edges, const TArrayI& nMixed){
-// Define centrality bins by their edges
-  for(int i=0; i<edges.GetSize()-1; ++i)
-    if(edges.At(i) > edges.At(i+1)) AliFatal("edges are not sorted");
-  if( edges.GetSize() != nMixed.GetSize()+1) AliFatal("edges and nMixed don't have appropriate relative sizes");
-                 
-  fCentEdges = edges;
-  fCentNMixed = nMixed;
+void AliPHOSCorrelations::SetCentralityBinning(const TArrayD& edges, const TArrayI& nMixed)
+{
+       // Define centrality bins by their edges
+       for(int i=0; i<edges.GetSize()-1; ++i)
+       {
+               if(edges.At(i) > edges.At(i+1)) AliFatal("edges are not sorted");
+               if( edges.GetSize() != nMixed.GetSize()+1) AliFatal("edges and nMixed don't have appropriate relative sizes");
+         
+               fCentEdges = edges;
+               fCentNMixed = nMixed;
+       }
 }
+
 //_______________________________________________________________________________
-Int_t AliPHOSCorrelations::GetCentralityBin(Float_t centralityV0M){
-  int lastBinUpperIndex = fCentEdges.GetSize() -1;
-  if( centralityV0M > fCentEdges[lastBinUpperIndex] ) {
-    if( fDebug >= 1 )
-      AliWarning( Form("centrality (%f) larger then upper edge of last centrality bin (%f)!", centralityV0M, fCentEdges[lastBinUpperIndex]) );
-    return lastBinUpperIndex-1;
-  }
-  if( centralityV0M < fCentEdges[0] ) {
-    if( fDebug >= 1 )
-      AliWarning( Form("centrality (%f) smaller then lower edge of first bin (%f)!", centralityV0M, fCentEdges[0]) );
-    return 0;
-  }
-                 
-  fCentBin = TMath::BinarySearch<Double_t> ( GetNumberOfCentralityBins(), fCentEdges.GetArray(), centralityV0M );
-  return fCentBin;
+Int_t AliPHOSCorrelations::GetCentralityBin(Float_t centralityV0M)
+{
+       int lastBinUpperIndex = fCentEdges.GetSize() -1;
+       if( centralityV0M > fCentEdges[lastBinUpperIndex] ) 
+       {
+               if( fDebug >= 1 )
+                       AliWarning( Form("centrality (%f) larger then upper edge of last centrality bin (%f)!", centralityV0M, fCentEdges[lastBinUpperIndex]) );
+               return lastBinUpperIndex-1;
+       }
+       if( centralityV0M < fCentEdges[0] ) 
+       {
+               if( fDebug >= 1 )
+               AliWarning( Form("centrality (%f) smaller then lower edge of first bin (%f)!", centralityV0M, fCentEdges[0]) );
+               return 0;
+       }
+
+       fCentBin = TMath::BinarySearch<Double_t> ( GetNumberOfCentralityBins(), fCentEdges.GetArray(), centralityV0M );
+       return fCentBin;
 }
+
 //_______________________________________________________________________________
-void AliPHOSCorrelations::SetCentralityBorders (double down , double up ){
-  if (down < 0. || up > 100 || up<=down)
-     AliError( Form("Warning. Bad value of centrality borders. Setting as default: fCentCutoffDown=%2.f, fCentCutoffUp=%2.f",fCentCutoffDown,fCentCutoffUp) );
-  else{
-    fCentCutoffDown = down; 
-    fCentCutoffUp = up;
-    AliInfo( Form("Centrality border was set as fCentCutoffDown=%2.f, fCentCutoffUp=%2.f",fCentCutoffDown,fCentCutoffUp) );
-  }
+void AliPHOSCorrelations::SetCentralityBorders (double downLimit , double upLimit )
+{
+       if (downLimit < 0. || upLimit > 100 || upLimit<=downLimit)
+               AliError( Form("Warning. Bad value of centrality borders. Setting as default: fCentralityLowLimit=%2.f, fCentralityHightLimit=%2.f", fCentralityLowLimit, fCentralityHightLimit) );
+       else
+       {
+       fCentralityLowLimit     = downLimit; 
+       fCentralityHightLimit   = upLimit;
+       AliInfo( Form("Centrality border was set as fCentralityLowLimit=%2.f, fCentralityHightLimit=%2.f", fCentralityLowLimit, fCentralityHightLimit ) );
+       }
 }
 
 //_______________________________________________________________________________
 void AliPHOSCorrelations::EvalReactionPlane()
 {
        // assigns: fHaveTPCRP and fRP
-       // also does a few histogram fills
+       // also does RP histogram fill
 
        AliEventplane *eventPlane = fEvent->GetEventplane();
        if( ! eventPlane ) { AliError("Event has no event plane"); return; }
@@ -1495,6 +1424,7 @@ void AliPHOSCorrelations::EvalReactionPlane()
        }
        else
        {
+               //reaction plain defined
                fHaveTPCRP = kTRUE;
        }
 
@@ -1505,22 +1435,22 @@ void AliPHOSCorrelations::EvalReactionPlane()
        
        FillHistogram("phiRPflat",fRP,fCentrality) ;
 }
+
 //_______________________________________________________________________________
 Int_t AliPHOSCorrelations::GetRPBin()
 {
        Double_t averageRP;
-       averageRP = fRP ;       // If possible, it is better to have EP bin from TPC
-                               // to have similar events for miximng (including jets etc)   (fRPV0A+fRPV0C+fRP) /3.;
-
+       averageRP = fRP ;               // If possible, it is better to have EP bin from TPC
+                                                       // to have similar events for miximng (including jets etc)   (fRPV0A+fRPV0C+fRP) /3.;
        fEMRPBin = Int_t(fNEMRPBins*(averageRP)/TMath::Pi());
-
-       if( fEMRPBin > (Int_t)fNEMRPBins-1 ) 
+       if(fEMRPBin > (Int_t)fNEMRPBins-1) 
                fEMRPBin = fNEMRPBins-1 ;
        else 
-       if(fEMRPBin < 0) fEMRPBin=0;
+               if(fEMRPBin < 0) fEMRPBin=0;
 
        return fEMRPBin;
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SelectPhotonClusters()
 {
@@ -1535,9 +1465,9 @@ void AliPHOSCorrelations::SelectPhotonClusters()
                fCaloPhotonsPHOS->SetOwner();
        }
 
-       Int_t inPHOS=0 ;
+       Int_t inPHOS = 0 ;
 
-       for (Int_t i=0;  i<fEvent->GetNumberOfCaloClusters();  i++) 
+       for (Int_t i = 0;  i < fEvent->GetNumberOfCaloClusters();  i++) 
        {
                AliVCluster *clu = fEvent->GetCaloCluster(i);   
                if (!clu->IsPHOS() || clu->E()< fMinClusterEnergy) continue; // reject cluster
@@ -1552,13 +1482,12 @@ void AliPHOSCorrelations::SelectPhotonClusters()
                Int_t cellZPHOS = relId[3] ;
                
                Double_t distBC=clu->GetDistanceToBadChannel();
-               if(distBC<fMinBCDistance)
-                       continue ;
-
-               if(clu->GetNCells() < fMinNCells) continue ;
-               if(clu->GetM02() < fMinM02)   continue ;
+               if(distBC<fMinBCDistance)                       continue ; // reject cluster
+               if(clu->GetNCells() < fMinNCells)       continue ; // reject cluster
+               if(clu->GetM02() < fMinM02)             continue ; // reject cluster
 
-               if(fTOFCutEnabled){
+               if(fTOFCutEnabled)
+               {
                        Double_t tof = clu->GetTOF();
                        if(TMath::Abs(tof) > fTOFCut ) continue ;
                }
@@ -1566,20 +1495,19 @@ void AliPHOSCorrelations::SelectPhotonClusters()
                Double_t ecore = clu->GetCoreEnergy();
                //Double_t ecore = clu->E();
 
-               FillHistogram("hCluEvsClu", clu->E(), clu->GetNCells()) ;
+               FillHistogram("hCluEvsClu", clu->E(), clu->GetNCells()) ; 
 
                Double_t origo[3] = {0,0,0}; // don't rely on event vertex, assume (0,0,0) ?
-               //clu->GetMomentum(lorentzMomentum, fVertex);
                clu->GetMomentum(lorentzMomentum, origo);
        
-               if(inPHOS>=fCaloPhotonsPHOS->GetSize()){
+               if(inPHOS>=fCaloPhotonsPHOS->GetSize())
                        fCaloPhotonsPHOS->Expand(inPHOS+50) ;
-               }
         
-               AliCaloPhoton * ph =new((*fCaloPhotonsPHOS)[inPHOS]) AliCaloPhoton(lorentzMomentum.X(),lorentzMomentum.Py(),lorentzMomentum.Z(),lorentzMomentum.E());
+               AliCaloPhoton * ph =new((*fCaloPhotonsPHOS)[inPHOS]) AliCaloPhoton(lorentzMomentum.X(), lorentzMomentum.Py(), lorentzMomentum.Z(), lorentzMomentum.E());
                inPHOS++ ;
                ph->SetCluster(clu);
 
+               // Manual PHOS module number calculation
                /*Float_t cellId=clu->GetCellAbsId(0) ;
                Int_t mod = (Int_t)TMath:: Ceil(cellId/(56*64) ) ; */
                ph->SetModule(modPHOS) ;
@@ -1588,12 +1516,13 @@ void AliPHOSCorrelations::SelectPhotonClusters()
 
                //ph->SetNCells(clu->GetNCells());
                ph->SetMomV2(&lorentzMomentum) ;
-               ph->SetDispBit(clu->GetDispersion()<2.5) ;
-               ph->SetCPVBit(clu->GetEmcCpvDistance()>2.) ;
+               ph->SetDispBit(clu->GetDispersion() < 2.5) ;
+               ph->SetCPVBit(clu->GetEmcCpvDistance() > 2.) ;
 
                FillHistogram(Form("QA_cluXZE_mod%i", modPHOS), cellXPHOS, cellZPHOS, lorentzMomentum.E() ) ;
        }
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SelectAccosiatedTracks()
 {
@@ -1604,81 +1533,79 @@ void AliPHOSCorrelations::SelectAccosiatedTracks()
        {
                fTracksTPC = new TClonesArray("TLorentzVector",12000);
        }
-       Int_t iTracks=0 ;
-       for (Int_t i=0; i<fEvent->GetNumberOfTracks(); i++) 
+       Int_t iTracks = 0 ;
+       for (Int_t i = 0; i < fEvent->GetNumberOfTracks(); i++) 
        {
          
                AliVParticle *track = fEvent->GetTrack(i);
-                       if(fEventESD){
-                       if(!SelectESDTrack((AliESDtrack*)track)) continue ;
+       if(fEventESD)
+       {
+                               if(!SelectESDTrack((AliESDtrack*)track)) continue ; // reject track
                }
-               else{
-                       if(!SelectAODTrack((AliAODTrack*)track)) continue ;               
+               else
+               {
+                       if(!SelectAODTrack((AliAODTrack*)track)) continue ;     // reject track  
                }
+
                Double_t px = track->Px();
                Double_t py = track->Py();
-               Double_t pz = track->Pz() ;
-               Double_t e = track->E() ;
+               Double_t pz = track->Pz();
+               Double_t e  = track->E() ;
                
-               if(iTracks>=fTracksTPC->GetSize())
-                               fTracksTPC->Expand(iTracks+50) ;
+               if(iTracks >= fTracksTPC->GetSize())
+            fTracksTPC->Expand(iTracks+50) ;
                
-               new((*fTracksTPC)[iTracks]) TLorentzVector(px, py, pz,e);
+               new((*fTracksTPC)[iTracks]) TLorentzVector(px, py, pz, e);
                iTracks++ ;
        }
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::SelectTriggerPi0ME()
 {
-    const Int_t nPHOS=fCaloPhotonsPHOS->GetEntriesFast() ;
-    for(Int_t i1=0; i1 < nPHOS-1; i1++)
+    const Int_t nPHOS = fCaloPhotonsPHOS->GetEntriesFast() ;
+    for(Int_t i1 = 0; i1 < nPHOS-1; i1++)
     {
-        AliCaloPhoton * ph1=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i1) ;
-        for (Int_t i2=i1+1; i2<nPHOS; i2++)
+        AliCaloPhoton * ph1 = (AliCaloPhoton*)fCaloPhotonsPHOS->At(i1) ;
+        for (Int_t i2 = i1+1; i2 < nPHOS; i2++)
         {
             AliCaloPhoton * ph2=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i2) ;
-            TLorentzVector p12  = *ph1  + *ph2;
+            TLorentzVector p12 = *ph1 + *ph2;
 
-            Double_t phiTrigger=p12.Phi() ;
-            Double_t etaTrigger=p12.Eta() ;
+            Double_t phiTrigger = p12.Phi() ;
+            Double_t etaTrigger = p12.Eta() ;
 
-            Double_t m=p12.M() ;
-            Double_t pt=p12.Pt() ;
+            Double_t m          = p12.M() ;
+            Double_t pt  = p12.Pt();
             Double_t eff = 1./GetEfficiency(pt);
             int mod1 = ph1->Module() ;
             int mod2 = ph2->Module() ;
 
-            FillHistogram("clu_phieta",phiTrigger,etaTrigger);
-            FillHistogram("clusingle_phieta",ph1->Phi(), ph1->Eta());
-            FillHistogram("clusingle_phieta",ph2->Phi(), ph2->Eta());
-
+            FillHistogram("clu_phieta",          phiTrigger, etaTrigger );
+            FillHistogram("clusingle_phieta", ph1->Phi(), ph1->Eta() );
+            FillHistogram("clusingle_phieta", ph2->Phi(), ph2->Eta() );
 
-            FillHistogram("all_mpt",m, pt);
-            FillHistogram("all_mpt_eff",m, pt, eff);
+            FillHistogram("all_mpt", m, pt, eff );
       
             if ( ph1->IsCPVOK() && ph2->IsCPVOK() )
             {
-                FillHistogram("cpv_mpt",m, pt);
-                FillHistogram("cpv_mpt_eff",m, pt, eff);
+                FillHistogram("cpv_mpt", m, pt, eff );
                }
 
             if ( ph1->IsDispOK() && ph2->IsDispOK() )
             {
-                FillHistogram("disp_mpt",m, pt);
-                FillHistogram("disp_mpt_eff",m, pt, eff);
+                FillHistogram("disp_mpt", m, pt, eff );
                 if ( ph1->IsCPVOK() && ph2->IsCPVOK() )
                 {
-                    FillHistogram("both_mpt",m, pt);
-                    FillHistogram("both_mpt_eff",m, pt, eff);
+                    FillHistogram("both_mpt", m, pt, eff );
                     if(mod1 == mod2) // for each module
                     {
-                        FillHistogram(Form("both%d_mpt",mod1),m, pt);
-                        FillHistogram(Form("both%d_mpt_eff",mod1),m, pt, eff);
+                        FillHistogram(Form("both%d_mpt", mod1), m, pt, eff );
                     }
                 }
             }
 
-            if(!TestMass(m,pt)) continue;
+            if(!TestMass(m,pt)) continue; //reject this pair
 
             Int_t modCase = GetModCase(mod1, mod2);
 
@@ -1699,228 +1626,24 @@ void AliPHOSCorrelations::SelectTriggerPi0ME()
 //_______________________________________________________________________________
 void AliPHOSCorrelations::ConsiderPi0s()
 {
-    // Consider all photons from PHOS
-       const Int_t nPHOS=fCaloPhotonsPHOS->GetEntriesFast() ;
-       for(Int_t i1=0; i1 < nPHOS-1; i1++)
-       {
-               AliCaloPhoton * ph1=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i1) ;
-               for (Int_t i2=i1+1; i2<nPHOS; i2++)
-               {
-                       AliCaloPhoton * ph2=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i2) ;
-                       TLorentzVector p12  = *ph1  + *ph2;
-
-                       Double_t phiTrigger=p12.Phi() ;
-                       Double_t etaTrigger=p12.Eta() ;
-
-                       Double_t m=p12.M() ;
-                       Double_t pt=p12.Pt() ;
-                       Double_t eff = 1./GetEfficiency(pt);
-                       int mod1 = ph1->Module() ;
-                       int mod2 = ph2->Module() ;                              
-
-                       FillHistogram("clu_phieta",phiTrigger,etaTrigger);
-                       FillHistogram("clusingle_phieta",ph1->Phi(), ph1->Eta());
-                       FillHistogram("clusingle_phieta",ph2->Phi(), ph2->Eta());
-
-
-                       FillHistogram("all_mpt",m, pt);
-                       FillHistogram("all_mpt_eff",m, pt, eff);
-                       if ( ph1->IsCPVOK() && ph2->IsCPVOK() ) 
-                       {
-                               FillHistogram("cpv_mpt",m, pt);
-                               FillHistogram("cpv_mpt_eff",m, pt, eff);
-                       }
-
-                       if ( ph1->IsDispOK() && ph2->IsDispOK() )
-                       {
-                               FillHistogram("disp_mpt",m, pt);
-                               FillHistogram("disp_mpt_eff",m, pt, eff);
-                               if ( ph1->IsCPVOK() && ph2->IsCPVOK() ) 
-                               {
-                                       FillHistogram("both_mpt",m, pt);
-                                       FillHistogram("both_mpt_eff",m, pt, eff);
-                                       if(mod1 == mod2) // for each module
-                                       {
-                                               FillHistogram(Form("both%d_mpt",mod1),m, pt);
-                                               FillHistogram(Form("both%d_mpt_eff",mod1),m, pt, eff);
-                                       }
-                               }
-                       }       
-
-                       if(!TestMass(m,pt)) continue;
-
-            FillHistogram("nTrigger_all", pt, eff);
-                       if ( ph1->IsCPVOK() && ph2->IsCPVOK() ) 
-                               FillHistogram("nTrigger_cpv", pt, eff);
-                       if ( ph1->IsDispOK() && ph2->IsDispOK() )
-                       {
-                               FillHistogram("nTrigger_disp", pt, eff);
-                               if ( ph1->IsCPVOK() && ph2->IsCPVOK() ) 
-                                       FillHistogram("nTrigger_both", pt, eff);
-                       }
-
-                       // Take track's angles and compare with cluster's angles.
-                       for(Int_t i3=0; i3<fTracksTPC->GetEntriesFast(); i3++){
-                               TLorentzVector * track = (TLorentzVector*)fTracksTPC->At(i3);
-
-                               Double_t phiAssoc = track->Phi();
-                               Double_t etaAssoc = track->Eta();
-                               Double_t ptAssoc = track->Pt();
-
-                               Double_t dPhi = phiTrigger - phiAssoc;
-                               while (dPhi > 1.5*TMath::Pi()) dPhi-=2*TMath::Pi();
-                               while (dPhi < -.5*TMath::Pi()) dPhi+=2*TMath::Pi();
-
-                               Double_t dEta = etaTrigger - etaAssoc;          
-
-                               Double_t ptAssocBin=GetAssocBin(ptAssoc) ;
-                               FillHistogram(Form("all_ptphieta_ptAssoc_%3.1f",ptAssocBin), pt, dPhi, dEta, eff);                      
-                               if ( ph1->IsCPVOK() && ph2->IsCPVOK() ) 
-                                       FillHistogram(Form("cpv_ptphieta_ptAssoc_%3.1f",ptAssocBin), pt, dPhi, dEta, eff);                      
-
-                               if ( ph1->IsDispOK() && ph2->IsDispOK() ){
-                                       FillHistogram(Form("disp_ptphieta_ptAssoc_%3.1f",ptAssocBin), pt, dPhi, dEta, eff);                     
-                                       if ( ph1->IsCPVOK() && ph2->IsCPVOK() ) 
-                                               FillHistogram(Form("both_ptphieta_ptAssoc_%3.1f",ptAssocBin), pt, dPhi, dEta, eff);                     
-                               }
-                       }
-               }
-       }
-}
-
-//_______________________________________________________________________________
-void AliPHOSCorrelations::ConsiderPi0sMix()
-{
-       TList * arrayList = GetCaloPhotonsPHOSList(fVtxBin, fCentBin, fEMRPBin);
-       for(Int_t evi=0; evi<arrayList->GetEntries();evi++)
-       {
-               TClonesArray * mixPHOS = static_cast<TClonesArray*>(arrayList->At(evi));
-               for (Int_t i1=0; i1 < fCaloPhotonsPHOS->GetEntriesFast(); i1++)
-               {
-                       AliCaloPhoton * ph1 = (AliCaloPhoton*)fCaloPhotonsPHOS->At(i1) ;
-                       for(Int_t i2=0; i2 < mixPHOS->GetEntriesFast(); i2++)
-                       {
-                               AliCaloPhoton * ph2 = (AliCaloPhoton*)mixPHOS->At(i2) ;
-                               TLorentzVector p12  = *ph1  + *ph2;
-                               Double_t m=p12.M() ;
-                               Double_t pt=p12.Pt() ;
-                               Double_t eff = 1./GetEfficiency(pt);
-                               
-                               int mod1 = ph1->Module() ;
-                               int mod2 = ph2->Module() ;
-
-                               FillHistogram("mix_all_mpt", m, pt);
-                               FillHistogram("mix_all_mpt_eff", m, pt, eff);
-                               if ( ph1->IsCPVOK() && ph2->IsCPVOK() ) 
-                               {
-                                       FillHistogram("mix_cpv_mpt",m, pt);
-                                       FillHistogram("mix_cpv_mpt_eff",m, pt, eff);
-                               }
-                               if ( ph1->IsDispOK() && ph2->IsDispOK() )
-                               {
-                                       FillHistogram("mix_disp_mpt",m, pt);
-                                       FillHistogram("mix_disp_mpt_eff",m, pt, eff);
-                                       if ( ph1->IsCPVOK() && ph2->IsCPVOK() )
-                                       {
-                                               FillHistogram("mix_both_mpt",m, pt);
-                                               FillHistogram("mix_both_mpt_eff",m, pt, eff);
-                                               if (mod1 == mod2) // for each module
-                                               {
-                                                       FillHistogram(Form("mix_both%d_mpt",mod1),m, pt);
-                                                       FillHistogram(Form("mix_both%d_mpt_eff",mod1),m, pt, eff);
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-}
-//_______________________________________________________________________________
-void AliPHOSCorrelations::ConsiderTracksMix()
-{
-       TList * arrayList = GetTracksTPCList(fVtxBin, fCentBin, fEMRPBin);
-       for (Int_t i1=0; i1 < fCaloPhotonsPHOS->GetEntriesFast(); i1++) {
-               AliCaloPhoton * ph1=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i1) ;
-               for (Int_t i2=0; i2<fCaloPhotonsPHOS->GetEntriesFast(); i2++){
-                       AliCaloPhoton * ph2=(AliCaloPhoton*)fCaloPhotonsPHOS->At(i2) ;
-                       TLorentzVector p12  = *ph1  + *ph2;
-                       Double_t phiTrigger=p12.Phi() ;
-                       Double_t etaTrigger=p12.Eta() ;
-
-                       Double_t m=p12.M() ;
-                       Double_t pt=p12.Pt() ;
-                       Double_t eff = 1./GetEfficiency(pt);
-                       Int_t mod1 = ph1->Module();
-                       Int_t mod2 = ph2->Module();
-
-
-            if(!TestMass(m,pt)) continue;
-
-                       for(Int_t evi=0; evi<arrayList->GetEntries();evi++){
-                               TClonesArray * mixTracks = static_cast<TClonesArray*>(arrayList->At(evi));
-                               for(Int_t i3=0; i3<mixTracks->GetEntriesFast(); i3++){
-                                       TLorentzVector * track = (TLorentzVector*)mixTracks->At(i3);            
-
-                                       Double_t phiAssoc = track->Phi();
-                                       Double_t etaAssoc = track->Eta();
-                    Double_t ptAssoc =  track->Pt();
-
-                                       Double_t ptAssocBin=GetAssocBin(ptAssoc) ;
-
-                                       Double_t dPhi = phiTrigger - phiAssoc;
-                                       while (dPhi > 1.5*TMath::Pi()) dPhi-=2*TMath::Pi();
-                                       while (dPhi < -.5*TMath::Pi()) dPhi+=2*TMath::Pi();
-
-                    Double_t dEta = etaTrigger - etaAssoc;
-
-                                       FillHistogram(Form("mix_all_ptphieta_ptAssoc_%3.1f",ptAssocBin), pt, dPhi, dEta, eff);  
-                                       if(fMakePHOSModulesCorrFunctions) FillHistogram(Form("mix_all_ptphieta_ptAssoc_%3.1f_mod%i",ptAssocBin, GetModCase(mod1, mod2)), pt, dPhi, dEta, eff);  
-                    if(fMakeTPCHalfBarrelCorrFunctions) FillHistogram(Form("mix_all_ptphieta_ptAssoc_%3.1f_tpc%i",ptAssocBin, CheckTriggerEta(etaTrigger)), pt, dPhi, dEta, eff);
-
-                                       if ( ph1->IsCPVOK() && ph2->IsCPVOK() )
-                                       {
-                                               FillHistogram(Form("mix_cpv_ptphieta_ptAssoc_%3.1f",ptAssocBin), pt, dPhi, dEta, eff);  
-                                               if(fMakePHOSModulesCorrFunctions) FillHistogram(Form("mix_cpv_ptphieta_ptAssoc_%3.1f_mod%i",ptAssocBin, GetModCase(mod1, mod2)), pt, dPhi, dEta, eff);  
-                                               if(fMakeTPCHalfBarrelCorrFunctions) FillHistogram(Form("mix_cpv_ptphieta_ptAssoc_%3.1f_tpc%i",ptAssocBin, CheckTriggerEta(etaTrigger)), pt, dPhi, dEta, eff);   
-                                       }                       
-
-                                       if ( ph1->IsDispOK() && ph2->IsDispOK() ) {
-                                               FillHistogram(Form("mix_disp_ptphieta_ptAssoc_%3.1f",ptAssocBin), pt, dPhi, dEta, eff); 
-                                               if(fMakePHOSModulesCorrFunctions) FillHistogram(Form("mix_disp_ptphieta_ptAssoc_%3.1f_mod%i",ptAssocBin, GetModCase(mod1, mod2)), pt, dPhi, dEta, eff); 
-                                               if(fMakeTPCHalfBarrelCorrFunctions) FillHistogram(Form("mix_disp_ptphieta_ptAssoc_%3.1f_tpc%i",ptAssocBin, CheckTriggerEta(etaTrigger)), pt, dPhi, dEta, eff);                          
-                                               if ( ph1->IsCPVOK() && ph2->IsCPVOK() )
-                                               {
-                                                       FillHistogram(Form("mix_both_ptphieta_ptAssoc_%3.1f",ptAssocBin), pt, dPhi, dEta, eff); 
-                                                       if(fMakePHOSModulesCorrFunctions) FillHistogram(Form("mix_both_ptphieta_ptAssoc_%3.1f_mod%i",ptAssocBin, GetModCase(mod1, mod2)), pt, dPhi, dEta, eff);
-                                                       if(fMakeTPCHalfBarrelCorrFunctions) FillHistogram(Form("mix_both_ptphieta_ptAssoc_%3.1f_tpc%i",ptAssocBin, CheckTriggerEta(etaTrigger)), pt, dPhi, dEta, eff);  
-                                               }                               
-                                       }
-                               }
-                       } 
-               }
-       }
-}
-
-//_______________________________________________________________________________
-void AliPHOSCorrelations::ConsiderPi0sME()
-{
-       TString spid[4]={"all","cpv","disp","both"} ;
+       TString spid[4] = {"all","cpv","disp","both"} ;
     // Counting number of trigger particles.
        for (int ipid = 0; ipid < 4; ipid++)
        {
                if (fMEExists[ipid])
-            FillHistogram(Form("nTrigger_%s", spid[ipid].Data()), GetMEPt(ipid), 1./GetEfficiency(GetMEPt(ipid)));
+            FillHistogram( Form("nTrigger_%s", spid[ipid].Data()), GetMEPt(ipid), 1./GetEfficiency(GetMEPt(ipid)) );
        }
 
     // Take track's angles and compare with trigger's angles.
-    for(Int_t i3=0; i3<fTracksTPC->GetEntriesFast(); i3++){
+    for(Int_t i3 = 0; i3 < fTracksTPC->GetEntriesFast(); i3++)
+    {
                TLorentzVector * track = (TLorentzVector*)fTracksTPC->At(i3);
 
                Double_t phiAssoc = track->Phi();
                Double_t etaAssoc = track->Eta();
-               Double_t ptAssoc = track->Pt();
+               Double_t ptAssoc  = track->Pt() ;
 
-               Double_t ptAssocBin=GetAssocBin(ptAssoc) ;
+               Double_t ptAssocBin = GetAssocBin(ptAssoc) ;
                Double_t dPhi(0.), dEta(0.);
 
                for (int ipid = 0; ipid < 4; ipid++)
@@ -1928,37 +1651,39 @@ void AliPHOSCorrelations::ConsiderPi0sME()
             if (GetMEExists(ipid))
                        {
                 dPhi = GetMEPhi(ipid) - phiAssoc;
-                               while (dPhi > 1.5*TMath::Pi()) dPhi-=2*TMath::Pi();
-                               while (dPhi < -.5*TMath::Pi()) dPhi+=2*TMath::Pi();
+                               while (dPhi > 1.5*TMath::Pi()) dPhi -= 2*TMath::Pi();
+                               while (dPhi < -.5*TMath::Pi()) dPhi += 2*TMath::Pi();
                 dEta = GetMEEta(ipid) - etaAssoc;
-                FillHistogram(Form("%s_ptphieta_ptAssoc_%3.1f", spid[ipid].Data(), ptAssocBin),  GetMEPt(ipid), dPhi, dEta, 1./GetEfficiency(GetMEPt(ipid)) );
+                FillHistogram( Form("%s_ptphieta_ptAssoc_%3.1f", spid[ipid].Data(), ptAssocBin), GetMEPt(ipid), dPhi, dEta, 1./GetEfficiency(GetMEPt(ipid)) );
                        }       
                }
        } 
 }
+
 //_______________________________________________________________________________
-void AliPHOSCorrelations::ConsiderPi0sME_MBSelection()
+void AliPHOSCorrelations::ConsiderPi0s_MBSelection()
 {
-       TString spid[4]={"all","cpv","disp","both"} ;
+       TString spid[4] = {"all","cpv","disp","both"} ;
     // Counting number of trigger particles.
        for (int ipid = 0; ipid < 4; ipid++)
        {
                if (GetMEExists(ipid))
                {
                        
-            FillHistogram(Form("nTrigger_%s_MB", spid[ipid].Data()), GetMEPt(ipid), 1./GetEfficiency(GetMEPt(ipid)));
+            FillHistogram( Form("nTrigger_%s_MB", spid[ipid].Data()), GetMEPt(ipid), 1./GetEfficiency(GetMEPt(ipid)) );
                }
        }
 
     // Take track's angles and compare with trigger's angles.
-    for(Int_t i3=0; i3<fTracksTPC->GetEntriesFast(); i3++){
+    for(Int_t i3 = 0; i3 < fTracksTPC->GetEntriesFast(); i3++)
+    {
                TLorentzVector * track = (TLorentzVector*)fTracksTPC->At(i3);
 
                Double_t phiAssoc = track->Phi();
                Double_t etaAssoc = track->Eta();
-               Double_t ptAssoc = track->Pt();
+               Double_t ptAssoc  = track->Pt();
 
-               Double_t ptAssocBin=GetAssocBin(ptAssoc) ;
+               Double_t ptAssocBin = GetAssocBin(ptAssoc) ;
                Double_t dPhi(0.), dEta(0.);
 
                for (int ipid = 0; ipid < 4; ipid++)
@@ -1966,33 +1691,79 @@ void AliPHOSCorrelations::ConsiderPi0sME_MBSelection()
             if (GetMEExists(ipid))
                        {
                 dPhi = GetMEPhi(ipid) - phiAssoc;
-                               while (dPhi > 1.5*TMath::Pi()) dPhi-=2*TMath::Pi();
-                               while (dPhi < -.5*TMath::Pi()) dPhi+=2*TMath::Pi();
+                               while (dPhi > 1.5*TMath::Pi()) dPhi -= 2*TMath::Pi();
+                               while (dPhi < -.5*TMath::Pi()) dPhi += 2*TMath::Pi();
                 dEta = GetMEEta(ipid) - etaAssoc;
                 FillHistogram(Form("%s_ptphieta_ptAssoc_%3.1f_MB", spid[ipid].Data(), ptAssocBin),  GetMEPt(ipid), dPhi, dEta, 1./GetEfficiency(GetMEPt(ipid)) );
                        }       
                }
        } 
 }
+
 //_______________________________________________________________________________
-void AliPHOSCorrelations::ConsiderTracksMixME()
+void AliPHOSCorrelations::ConsiderPi0sMix()
 {
-       TString spid[4]={"all","cpv","disp","both"} ;
+       TList * arrayList = GetCaloPhotonsPHOSList(fVtxBin, fCentBin, fEMRPBin);
+       for(Int_t evi = 0; evi < arrayList->GetEntries(); evi++)
+       {
+               TClonesArray * mixPHOS = static_cast<TClonesArray*>(arrayList->At(evi));
+               for (Int_t i1 = 0; i1 < fCaloPhotonsPHOS->GetEntriesFast(); i1++)
+               {
+                       AliCaloPhoton * ph1 = (AliCaloPhoton*)fCaloPhotonsPHOS->At(i1) ;
+                       for(Int_t i2 = 0; i2 < mixPHOS->GetEntriesFast(); i2++)
+                       {
+                               AliCaloPhoton * ph2 = (AliCaloPhoton*)mixPHOS->At(i2) ;
+                               TLorentzVector p12 = *ph1 + *ph2;
+                               Double_t m       = p12.M() ;
+                               Double_t pt  = p12.Pt() ;
+                               Double_t eff = 1./GetEfficiency(pt);
+                               
+                               int mod1 = ph1->Module() ;
+                               int mod2 = ph2->Module() ;
+
+                               FillHistogram("mix_all_mpt", m, pt, eff);
+                               if ( ph1->IsCPVOK() && ph2->IsCPVOK() ) 
+                               {
+                                       FillHistogram("mix_cpv_mpt",m, pt, eff);
+                               }
+                               if ( ph1->IsDispOK() && ph2->IsDispOK() )
+                               {
+                                       FillHistogram("mix_disp_mpt",m, pt, eff);
+                                       if ( ph1->IsCPVOK() && ph2->IsCPVOK() )
+                                       {
+                                               FillHistogram("mix_both_mpt",m, pt, eff);
+                                               if (mod1 == mod2) // for each module
+                                               {
+                                                       FillHistogram(Form("mix_both%d_mpt",mod1),m, pt, eff);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+//_______________________________________________________________________________
+void AliPHOSCorrelations::ConsiderTracksMix()
+{
+       TString spid[4] = {"all","cpv","disp","both"} ;
 
        TList * arrayList = GetTracksTPCList(fVtxBin, fCentBin, fEMRPBin);
 
-       for(Int_t evi=0; evi<arrayList->GetEntries();evi++){
+       for(Int_t evi = 0; evi < arrayList->GetEntries();evi++)
+       {
                TClonesArray * mixTracks = static_cast<TClonesArray*>(arrayList->At(evi));
-               for(Int_t i3=0; i3<mixTracks->GetEntriesFast(); i3++){
+               for(Int_t i3 = 0; i3 < mixTracks->GetEntriesFast(); i3++)
+               {
                        TLorentzVector * track = (TLorentzVector*)mixTracks->At(i3);            
 
                        Double_t phiAssoc = track->Phi();
                        Double_t etaAssoc = track->Eta();
-                       Double_t ptAssoc =  track->Pt();
+                       Double_t ptAssoc  =  track->Pt();
 
-                       Double_t ptAssocBin=GetAssocBin(ptAssoc) ;
+                       Double_t ptAssocBin = GetAssocBin(ptAssoc) ;
 
-            Double_t ptTrigger (0.);
+            Double_t ptTrigger(0.);
 
                        Double_t dPhi(0.), dEta(0.);
 
@@ -2001,63 +1772,75 @@ void AliPHOSCorrelations::ConsiderTracksMixME()
                 if (GetMEExists(ipid))
                                {
                     dPhi = GetMEPhi(ipid) - phiAssoc;
-                                       while (dPhi > 1.5*TMath::Pi()) dPhi-=2*TMath::Pi();
-                                       while (dPhi < -.5*TMath::Pi()) dPhi+=2*TMath::Pi();
+                                       while (dPhi > 1.5*TMath::Pi()) dPhi -= 2*TMath::Pi();
+                                       while (dPhi < -.5*TMath::Pi()) dPhi += 2*TMath::Pi();
                     dEta = GetMEEta(ipid) - etaAssoc;
                     ptTrigger = GetMEPt(ipid);
 
                     FillHistogram(Form("mix_%s_ptphieta_ptAssoc_%3.1f", spid[ipid].Data(), ptAssocBin), ptTrigger, dPhi, dEta, 1./GetEfficiency(ptTrigger));
-                    if(fMakePHOSModulesCorrFunctions)  FillHistogram(Form("mix_%s_ptphieta_ptAssoc_%3.1f_mod%i", spid[ipid].Data(), ptAssocBin, GetMEModCase(ipid)), ptTrigger, dPhi, dEta, 1./GetEfficiency(ptTrigger));
-                    if(fMakeTPCHalfBarrelCorrFunctions) FillHistogram(Form("mix_%s_ptphieta_ptAssoc_%3.1f_tpc%i", spid[ipid].Data(), ptAssocBin, CheckTriggerEta(GetMEEta(ipid))), ptTrigger, dPhi, dEta, 1./GetEfficiency(ptTrigger));
-                               }       
+                }      
                        }
                }
        } 
 }
 
 //_______________________________________________________________________________
-TList* AliPHOSCorrelations::GetCaloPhotonsPHOSList(UInt_t vtxBin, UInt_t centBin, UInt_t rpBin){
-
-  int offset = vtxBin * GetNumberOfCentralityBins() * fNEMRPBins + centBin * fNEMRPBins + rpBin;
-  if( fCaloPhotonsPHOSLists->At(offset) ) {
-    TList* list = dynamic_cast<TList*> (fCaloPhotonsPHOSLists->At(offset));
-    return list;
-  }
-  else{ // no list for this bin has been created, yet
-    TList* list = new TList();
-    fCaloPhotonsPHOSLists->AddAt(list, offset);
-    return list;
-  }
+TList* AliPHOSCorrelations::GetCaloPhotonsPHOSList(UInt_t vtxBin, UInt_t centBin, UInt_t rpBin)
+{
+       int offset = vtxBin * GetNumberOfCentralityBins() * fNEMRPBins + centBin * fNEMRPBins + rpBin;
+       if( fCaloPhotonsPHOSLists->At(offset) ) 
+       {
+               // list exists
+               TList* list = dynamic_cast<TList*> (fCaloPhotonsPHOSLists->At(offset));
+               return list;
+       }
+       else
+       { 
+               // no list for this bin has been created, yet
+               TList* list = new TList();
+               fCaloPhotonsPHOSLists->AddAt(list, offset);
+               return list;
+       }
 }
+
 //_______________________________________________________________________________
-TList* AliPHOSCorrelations::GetTracksTPCList(UInt_t vtxBin, UInt_t centBin, UInt_t rpBin){
-               
-  int offset = vtxBin * GetNumberOfCentralityBins() * fNEMRPBins + centBin * fNEMRPBins + rpBin;
-  if( fTracksTPCLists->At(offset) ) { // list exists
-     TList* list = dynamic_cast<TList*> (fTracksTPCLists->At(offset));
-     return list;
-  }
-  else { // no list for this bin has been created, yet
-    TList* list = new TList();
-    fTracksTPCLists->AddAt(list, offset);
-    return list;
-  }
+TList* AliPHOSCorrelations::GetTracksTPCList(UInt_t vtxBin, UInt_t centBin, UInt_t rpBin)
+{              
+       int offset = vtxBin * GetNumberOfCentralityBins() * fNEMRPBins + centBin * fNEMRPBins + rpBin;
+       if( fTracksTPCLists->At(offset) ) 
+       { 
+               // list exists
+               TList* list = dynamic_cast<TList*> (fTracksTPCLists->At(offset));
+               return list;
+       }
+       else 
+       { 
+               // no list for this bin has been created, yet
+               TList* list = new TList();
+               fTracksTPCLists->AddAt(list, offset);
+               return list;
+       }
 }
+
 //_______________________________________________________________________________
 Double_t AliPHOSCorrelations::GetAssocBin(Double_t pt) const
 {
-  //Calculates bin of associated particle pt.
-  for(Int_t i=1; i<fAssocBins.GetSize(); i++){
-    if(pt>fAssocBins.At(i-1) && pt<fAssocBins.At(i))
-      return fAssocBins.At(i) ;
-  }
-  return fAssocBins.At(fAssocBins.GetSize()-1) ;
+       //Calculates bin of associated particle pt.
+       for(Int_t i=1; i<fAssocBins.GetSize(); i++)
+       {
+               if(pt>fAssocBins.At(i-1) && pt<fAssocBins.At(i))
+                       return fAssocBins.At(i) ;
+       }
+
+       return fAssocBins.At(fAssocBins.GetSize()-1) ;
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::FillTrackEtaPhi()
 {
        // Distribution TPC's tracks by angles.
-       for (Int_t i1=0; i1<fTracksTPC->GetEntriesFast(); i1++){
+       for (Int_t i1=0; i1<fTracksTPC->GetEntriesFast(); i1++)
+       {
                TLorentzVector * track = (TLorentzVector*)fTracksTPC->At(i1);
                FillHistogram( "track_phieta", track->Phi(), track->Eta() );
        }
@@ -2066,92 +1849,101 @@ void AliPHOSCorrelations::FillTrackEtaPhi()
 //_______________________________________________________________________________
 void AliPHOSCorrelations::UpdatePhotonLists()
 {
-  //Now we either add current events to stack or remove
-  //If no photons in current event - no need to add it to mixed
-
-  TList * arrayList = GetCaloPhotonsPHOSList(fVtxBin, fCentBin, fEMRPBin);
-  if( fDebug >= 2 )
-    AliInfo( Form("fCentBin=%d, fCentNMixed[]=%d",fCentBin,fCentNMixed[fCentBin]) );
-  if(fCaloPhotonsPHOS->GetEntriesFast()>0)
-  {
-    arrayList->AddFirst(fCaloPhotonsPHOS) ;
-    fCaloPhotonsPHOS=0x0;
-    if(arrayList->GetEntries() > fCentNMixed[fCentBin])
-    { // Remove redundant events
-      TClonesArray * tmp = static_cast<TClonesArray*>(arrayList->Last()) ;
-      arrayList->RemoveLast() ;
-      delete tmp; 
-    }
-  }
+       //Now we either add current events to stack or remove
+       //If no photons in current event - no need to add it to mixed
+
+       TList * arrayList = GetCaloPhotonsPHOSList(fVtxBin, fCentBin, fEMRPBin);
+       if( fDebug >= 2 )
+               AliInfo( Form("fCentBin=%d, fCentNMixed[]=%d",fCentBin,fCentNMixed[fCentBin]) );
+       if(fCaloPhotonsPHOS->GetEntriesFast()>0)
+       {
+               arrayList->AddFirst(fCaloPhotonsPHOS) ;
+               fCaloPhotonsPHOS=0x0;
+               if(arrayList->GetEntries() > fCentNMixed[fCentBin])
+               { 
+                       // Remove redundant events
+                       TClonesArray * tmp = static_cast<TClonesArray*>(arrayList->Last()) ;
+                       arrayList->RemoveLast() ;
+                       delete tmp; 
+               }
+       }
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::UpdateTrackLists()
 {
-  //Now we either add current events to stack or remove
-  //If no photons in current event - no need to add it to mixed
-
-  TList * arrayList = GetTracksTPCList(fVtxBin, fCentBin, fEMRPBin);
-
-  if( fDebug >= 2 )
-    AliInfo( Form("fCentBin=%d, fCentNMixed[]=%d",fCentBin,fCentNMixed[fCentBin]) );
-  if(fTracksTPC->GetEntriesFast()>0)
-  {
-
-    arrayList->AddFirst(fTracksTPC) ;
-    fTracksTPC=0x0;
-    if(arrayList->GetEntries() > fCentNMixed[fCentBin])
-    { // Remove redundant events
-      TClonesArray * tmp = static_cast<TClonesArray*>(arrayList->Last()) ;
-      arrayList->RemoveLast() ;
-      delete tmp; 
-    }
-  }
+       //Now we either add current events to stack or remove
+       //If no photons in current event - no need to add it to mixed
+
+       TList * arrayList = GetTracksTPCList(fVtxBin, fCentBin, fEMRPBin);
+
+       if( fDebug >= 2 )
+               AliInfo( Form("fCentBin=%d, fCentNMixed[]=%d",fCentBin,fCentNMixed[fCentBin]) );
+       if(fTracksTPC->GetEntriesFast()>0)
+       {
+               arrayList->AddFirst(fTracksTPC) ;
+               fTracksTPC=0x0;
+               if(arrayList->GetEntries() > fCentNMixed[fCentBin])
+               { 
+                       // Remove redundant events
+                       TClonesArray * tmp = static_cast<TClonesArray*>(arrayList->Last()) ;
+                       arrayList->RemoveLast() ;
+                       delete tmp; 
+               }
+       }
 }
+
 //_______________________________________________________________________________
 Bool_t AliPHOSCorrelations::SelectESDTrack(AliESDtrack * t) const
-// Estimate if this track can be used for the RP calculation. If all right - return "TRUE"
 {
+       // Estimate if this track can be used for the RP calculation. If all right - return "TRUE"
        Float_t pt=t->Pt();
-       if(pt<0.5 || pt>20.) return kFALSE ;
-       if(fabs( t->Eta() )>0.8) return kFALSE;
-       if(!fESDtrackCuts->AcceptTrack(t)) return kFALSE ;
+       if(pt<0.5 || pt>20.)                            return kFALSE ;
+       if(fabs( t->Eta() )>0.8)                        return kFALSE;
+       if(!fESDtrackCuts->AcceptTrack(t))      return kFALSE ;
        return kTRUE ;
 }
+
 //_______________________________________________________________________________
 Bool_t AliPHOSCorrelations::SelectAODTrack(AliAODTrack * t) const
-// Estimate if this track can be used for the RP calculation. If all right - return "TRUE"
 {
+       // Estimate if this track can be used for the RP calculation. If all right - return "TRUE"
        Float_t pt=t->Pt();
-       if(pt<0.5 || pt>20.) return kFALSE ;
+       if(pt<0.5 || pt>20.)     return kFALSE ;
        if(fabs( t->Eta() )>0.8) return kFALSE;
+
        if(fCheckHibridGlobal == kOnlyHibridTracks)
        {
                if(!t->IsHybridGlobalConstrainedGlobal()) 
                        return kFALSE ;
        }
-
+       else
        if (fCheckHibridGlobal == kWithOutHibridTracks)
        {
                if(t->IsHybridGlobalConstrainedGlobal()) 
                        return kFALSE ;
        }
+       else
+       if(fCheckHibridGlobal == kAllTracks)
+               return kTRUE;
 
        return kTRUE ;
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::LogProgress(int step)
-// Fill "step by step" hist
 {
-  //FillHistogram("hSelEvents", step+0.5, internalRunNumber-0.5);
-  FillHistogram("hTotSelEvents", step+0.5);
+       // Fill "step by step" hist
+       FillHistogram("hTotSelEvents", step+0.5);
 }
+
 //_______________________________________________________________________________
 void AliPHOSCorrelations::LogSelection(int step, int internalRunNumber)
 {
-  // the +0.5 is not realy neccisarry, but oh well... -henrik
-  FillHistogram("hSelEvents", step+0.5, internalRunNumber-0.5);
-  //FillHistogram("hTotSelEvents", step+0.5);
-}
+       // the +0.5 is not realy neccisarry, but oh well... -henrik
+       FillHistogram("hSelEvents", step+0.5, internalRunNumber-0.5);
+ }
+
 //_______________________________________________________________________________
 Bool_t AliPHOSCorrelations::TestMass(Double_t m, Double_t pt)
 {
@@ -2171,8 +1963,9 @@ Bool_t AliPHOSCorrelations::TestMass(Double_t m, Double_t pt)
             return false;
         }
        }
-       else                    // Parametrization
+       else
        {
+               // Parametrization
                FillHistogram("massWindow", MassMeanFunktion(pt), MassSigmaFunktion(pt)*fSigmaWidth);
         if ( MassMeanFunktion(pt)-MassSigmaFunktion(pt)*fSigmaWidth<m && m<MassMeanFunktion(pt)+MassSigmaFunktion(pt)*fSigmaWidth )
         {
@@ -2186,96 +1979,114 @@ Bool_t AliPHOSCorrelations::TestMass(Double_t m, Double_t pt)
         }
        }
 } 
+
 //_______________________________________________________________________________
 Double_t AliPHOSCorrelations::MassMeanFunktion(Double_t &pt) const
 {
        // Parametrization mean of mass window
-       return ( fMassMeanP0*pt + fMassMeanP1 );
+       return ( fMassMean[0]*pt + fMassMean[1] );
 }
+
 //_______________________________________________________________________________
 Double_t AliPHOSCorrelations::MassSigmaFunktion(Double_t &pt) const
 {
        // Parametrization sigma of mass window
-    //TODO:: Fix falling at large pT.
-       return ( -1*fMassSigmaP3*TMath::Sqrt(fMassSigmaP0*pt + fMassSigmaP1) + fMassSigmaP2 );
+       return ( -1*fMassSigma[3]*TMath::Sqrt(fMassSigma[0]*pt + fMassSigma[1]) + fMassSigma[2] );
 }
+
 //_____________________________________________________________________________
-void AliPHOSCorrelations::FillHistogram(const char * key,Double_t x)const{
-  //FillHistogram
-  TH1 * hist = dynamic_cast<TH1*>(fOutputContainer->FindObject(key)) ;
-  if(hist)
-    hist->Fill(x) ;
-  else
-    AliError(Form("can not find histogram (of instance TH1) <%s> ",key)) ;
+void AliPHOSCorrelations::FillHistogram(const char * key,Double_t x)const
+{
+       //FillHistogram
+       TH1 * hist = dynamic_cast<TH1*>(fOutputContainer->FindObject(key)) ;
+       if(hist)
+               hist->Fill(x) ;
+       else
+               AliError(Form("can not find histogram (of instance TH1) <%s> ",key)) ;
 }
+
 //_____________________________________________________________________________
-void AliPHOSCorrelations::FillHistogram(const char * key,Double_t x,Double_t y)const{
-  //FillHistogram
-  TH1 * th1 = dynamic_cast<TH1*> (fOutputContainer->FindObject(key));
-  if(th1)
-    th1->Fill(x, y) ;
-  else
-    AliError(Form("can not find histogram (of instance TH1) <%s> ",key)) ;
+void AliPHOSCorrelations::FillHistogram(const char * key,Double_t x,Double_t y)const
+{
+       //FillHistogram
+       TH1 * th1 = dynamic_cast<TH1*> (fOutputContainer->FindObject(key));
+       if(th1)
+               th1->Fill(x, y) ;
+       else
+               AliError(Form("can not find histogram (of instance TH1) <%s> ",key)) ;
 }
 
 //_____________________________________________________________________________
-void AliPHOSCorrelations::FillHistogram(const char * key,Double_t x,Double_t y, Double_t z) const{
-  //Fills 1D histograms with key
-  TObject * obj = fOutputContainer->FindObject(key);
-  
-  TH2 * th2 = dynamic_cast<TH2*> (obj);
-  if(th2) {
-    th2->Fill(x, y, z) ;
-    return;
-  }
-
-  TH3 * th3 = dynamic_cast<TH3*> (obj);
-  if(th3) {
-    th3->Fill(x, y, z) ;
-    return;
-  }
-  
-  AliError(Form("can not find histogram (of instance TH2) <%s> ",key)) ;
+void AliPHOSCorrelations::FillHistogram(const char * key,Double_t x,Double_t y, Double_t z) const
+{
+       //Fills 1D histograms with key
+       TObject * obj = fOutputContainer->FindObject(key);
+
+       TH2 * th2 = dynamic_cast<TH2*> (obj);
+       if(th2) 
+       {
+               th2->Fill(x, y, z) ;
+               return;
+       }
+
+       TH3 * th3 = dynamic_cast<TH3*> (obj);
+       if(th3) 
+       {
+               th3->Fill(x, y, z) ;
+               return;
+       }
+
+       AliError(Form("can not find histogram (of instance TH2) <%s> ",key)) ;
 }
+
 //_____________________________________________________________________________
-void AliPHOSCorrelations::FillHistogram(const char * key,Double_t x,Double_t y, Double_t z, Double_t w) const{
-  //Fills 1D histograms with key
-  TObject * obj = fOutputContainer->FindObject(key);
-  
-  TH3 * th3 = dynamic_cast<TH3*> (obj);
-  if(th3) {
-    th3->Fill(x, y, z, w) ;
-    return;
-  }
-  
-  AliError(Form("can not find histogram (of instance TH3) <%s> ",key)) ;
+void AliPHOSCorrelations::FillHistogram(const char * key,Double_t x,Double_t y, Double_t z, Double_t w) const
+{
+       //Fills 1D histograms with key
+       TObject * obj = fOutputContainer->FindObject(key);
+
+       TH3 * th3 = dynamic_cast<TH3*> (obj);
+       if(th3) 
+       {
+               th3->Fill(x, y, z, w) ;
+               return;
+       }
+
+       AliError(Form("can not find histogram (of instance TH3) <%s> ",key)) ;
 }
+
 //_____________________________________________________________________________
 void AliPHOSCorrelations::SetGeometry()
 {
-  // Initialize the PHOS geometry
-  //Init geometry
-  if(!fPHOSGeo){
-     AliOADBContainer geomContainer("phosGeo");
-     geomContainer.InitFromFile("$ALICE_ROOT/OADB/PHOS/PHOSGeometry.root","PHOSRotationMatrixes");
-     TObjArray *matrixes = (TObjArray*)geomContainer.GetObject(fRunNumber,"PHOSRotationMatrixes");
-     fPHOSGeo =  AliPHOSGeometry::GetInstance("IHEP") ;
-     for(Int_t mod=0; mod<5; mod++) {
-        if(!matrixes->At(mod)) {
-          if( fDebug )
-            AliInfo(Form("No PHOS Matrix for mod:%d, geo=%p\n", mod, fPHOSGeo));
-          continue;
-        }
-        else {
-             fPHOSGeo->SetMisalMatrix(((TGeoHMatrix*)matrixes->At(mod)),mod) ;
-             if( fDebug >1 )
-               AliInfo(Form("Adding PHOS Matrix for mod:%d, geo=%p\n", mod, fPHOSGeo));
-        }
-     }
-  } 
+       // Initialize the PHOS geometry
+       //Init geometry
+       if(!fPHOSGeo)
+       {
+               AliOADBContainer geomContainer("phosGeo");
+               geomContainer.InitFromFile("$ALICE_ROOT/OADB/PHOS/PHOSGeometry.root","PHOSRotationMatrixes");
+               TObjArray *matrixes = (TObjArray*)geomContainer.GetObject(fRunNumber,"PHOSRotationMatrixes");
+               fPHOSGeo =  AliPHOSGeometry::GetInstance("IHEP") ;
+               for(Int_t mod=0; mod<5; mod++) 
+               {
+                       if(!matrixes->At(mod)) 
+                       {
+                               if( fDebug )
+                               AliInfo(Form("No PHOS Matrix for mod:%d, geo=%p\n", mod, fPHOSGeo));
+                               continue;
+                       }
+                       else 
+                       {
+                               fPHOSGeo->SetMisalMatrix(((TGeoHMatrix*)matrixes->At(mod)),mod) ;
+                               if( fDebug >1 )
+                                       AliInfo(Form("Adding PHOS Matrix for mod:%d, geo=%p\n", mod, fPHOSGeo));
+                       }
+               }
+       } 
 }
+
 //_____________________________________________________________________________
-Double_t AliPHOSCorrelations::GetEfficiency(Double_t x) const {
+Double_t AliPHOSCorrelations::GetEfficiency(Double_t x) const 
+{
        //Efficiency for Both2core only!
        if (!fUseEfficiency)
                return 1.;
@@ -2290,31 +2101,31 @@ Double_t AliPHOSCorrelations::GetEfficiency(Double_t x) const {
        5: 60-80%
        6: 0-20%
        7: 0-10%*/
-       Double_t par0[9] = {-798863, 339.714, 6407.1, -457.778, 1283.65, -117.075, -19.3764, 0, 0};
-       Double_t par1[9] = {-799344, -1852.1, 3326.29, -384.229, 504.046, 562.608, 130.518, 0, 0};
-       Double_t par2[9] = {-858904, -1923.28, 5350.74, -568.946, 945.497, 419.647, 101.911, 0, 0};
-       Double_t par3[9] = {-795652, -1495.97, 2926.46, -357.804, 478.961, 551.127, 128.86, 0, 0};
-       Double_t par4[9] = {-891951, 279626, -123110, -5464.75, 27470.8, 283264, 15355.1, 192762, 44828.6};
-       Double_t par5[9] = {-1.1094e+06, -986.915, 2127.71, -268.908, 375.594, 380.791, 89.4053, 0, 0};
+       Double_t par0[9] = {-798863,      339.714,       6407.1,  -457.778, 1283.65, -117.075, -19.3764,       0,               0       };
+       Double_t par1[9] = {-799344,      -1852.1,      3326.29,  -384.229, 504.046,  562.608,  130.518,       0,               0       };
+       Double_t par2[9] = {-858904,     -1923.28,  5350.74,  -568.946, 945.497,  419.647,  101.911,       0,           0       };
+       Double_t par3[9] = {-795652,     -1495.97,  2926.46,  -357.804, 478.961,  551.127,   128.86,       0,           0       };
+       Double_t par4[9] = {-891951,       279626,      -123110,  -5464.75, 27470.8,   283264,  15355.1,  192762, 44828.6       };
+       Double_t par5[9] = {-1.1094e+06, -986.915,  2127.71,  -268.908, 375.594,  380.791,  89.4053,       0,       0   };
        // Double_t par6[7] = {4.86106e+09, 4.47013e+08, -1.48079e+09, 1.47233e+08, -2.62356e+08, -1.00639e+08, -2.45629e+07, 0, 0};
        // Double_t par7[7] = {-1.36243e+06, -26011.1, 135838, -12161.3, 24956.8, 4985.4, 1285.57, 0, 0};
 
-       // 8 for pPb13 and 0-100%
-        Double_t par8[9] = {6.87095e+06, 8.36553e+06, -3.29572e+06, 2.18688e+06, -739490, 521666, 106661, 0, 0};
+       // 8 bin for pPb13 and 0-100%
+       Double_t par8[9] = {6.87095e+06, 8.36553e+06, -3.29572e+06, 2.18688e+06, -739490, 521666, 106661, 0, 0};
                
         
        Double_t* pFitPoint;
 
        if(fPeriod == kLHC11h)
        {
-               if(x<1.) x = 1.; 
+               if(x < 1.) x = 1.; 
 
-               if (fCentrality<=5)  pFitPoint = &par0[0];
-               if (fCentrality>5 && fCentrality<=10) pFitPoint = &par1[0];
-               if (fCentrality>10 && fCentrality<=20) pFitPoint = &par2[0];
-               if (fCentrality>20 && fCentrality<=40) pFitPoint = &par3[0];
-               if (fCentrality>40 && fCentrality<=60) pFitPoint = &par4[0];
-               if (fCentrality>60) pFitPoint = &par5[0];
+               if (fCentrality <= 5)                                           pFitPoint = &par0[0];
+               if (fCentrality > 5 && fCentrality <= 10)       pFitPoint = &par1[0];
+               if (fCentrality > 10 && fCentrality <= 20)      pFitPoint = &par2[0];
+               if (fCentrality > 20 && fCentrality <= 40)      pFitPoint = &par3[0];
+               if (fCentrality > 40 && fCentrality <= 60)      pFitPoint = &par4[0];
+               if (fCentrality > 60)                                           pFitPoint = &par5[0];
 
                Double_t pFit[9];
                for (int i = 0; i < 9; ++i)
@@ -2322,7 +2133,7 @@ Double_t AliPHOSCorrelations::GetEfficiency(Double_t x) const {
                        pFit[i] = *(pFitPoint+i);
                }
 
-               if (fCentrality>40 && fCentrality<=60)
+               if (fCentrality > 40 && fCentrality <= 60)
                        e = TMath::Exp(-(((((1.+(pFit[1]*x))+(pFit[2]*(x*x)))+(pFit[5]*(x*(x*x))))+(pFit[7]*(x*(x*(x*x)))))/((((pFit[3]*x)+(pFit[4]*(x*x)))+(pFit[6]*(x*(x*x))))+(pFit[8]*(x*(x*(x*x))))))) ;
                else
                        e = TMath::Exp(-((((1.+(pFit[1]*x))+(pFit[2]*(x*x)))+(pFit[5]*(x*(x*x))))/(((pFit[3]*x)+(pFit[4]*(x*x)))+(pFit[6]*(x*(x*x)))))) ;
@@ -2349,9 +2160,10 @@ Double_t AliPHOSCorrelations::GetEfficiency(Double_t x) const {
        return e;
        // return 1.; // For test.
 }
-//_____________________________________________________________________________
-Int_t AliPHOSCorrelations::GetModCase(Int_t &mod1, Int_t &mod2) const {
 
+//_____________________________________________________________________________
+Int_t AliPHOSCorrelations::GetModCase(Int_t &mod1, Int_t &mod2) const 
+{
        // Return modules pair namber.
        if(mod1 == mod2)
        {
@@ -2376,22 +2188,17 @@ Int_t AliPHOSCorrelations::GetModCase(Int_t &mod1, Int_t &mod2) const {
        AliError(Form("No choise for mod1 = %i, mod2 = %i", mod1, mod2));
        return 1;
 }
-//_____________________________________________________________________________
-Int_t AliPHOSCorrelations::CheckTriggerEta(Double_t eta){
-       if (eta>=0.) 
-               return 1;
-       return 2;
-}
+
 //_____________________________________________________________________________
 void AliPHOSCorrelations::TestPi0ME(Int_t ipid, TLorentzVector p12, Int_t modCase)
 {
-       Double_t phiTrigger=p12.Phi() ;
-       Double_t etaTrigger=p12.Eta() ;
-       Double_t pt=p12.Pt() ;
+       Double_t phiTrigger = p12.Phi() ;
+       Double_t etaTrigger = p12.Eta() ;
+       Double_t pt             = p12.Pt() ;
 
     if ( GetMEExists(ipid) )
     {
-        if ( pt>=GetMEPt(ipid) )
+        if ( pt >= GetMEPt(ipid) )
         {
             SetMEPt(ipid,pt);
             SetMEPhi(ipid, phiTrigger);
@@ -2408,8 +2215,10 @@ void AliPHOSCorrelations::TestPi0ME(Int_t ipid, TLorentzVector p12, Int_t modCas
         SetMEExists(ipid);
     }
 }
+
 //_____________________________________________________________________________
-void AliPHOSCorrelations::ZeroingVariables(){
+void AliPHOSCorrelations::ZeroingVariables()
+{
        // Set Phi, Eta, pT, modNumber andtrigger variable of moust energetic trigger particle to zero.
        for (int i = 0; i < 4; ++i)
        {
@@ -2419,3 +2228,20 @@ void AliPHOSCorrelations::ZeroingVariables(){
        }
 }
 
+//_____________________________________________________________________________
+void AliPHOSCorrelations::SetMassMeanParametrs(Double_t par[2])                                      
+{ 
+       for (int i = 0; i < 2; ++i)
+       {
+               fMassMean[i] = par[i] ;  
+       }                  
+} 
+
+//_____________________________________________________________________________
+void AliPHOSCorrelations::SetMassSigmaParametrs(Double_t par[4])                                   
+{ 
+       for (int i = 0; i < 4; ++i)
+       {
+               fMassSigma[i] = par[i] ;    
+       }                  
+}