]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Update form Debojit: PID Correlation
authorsjena <sjena@cern.ch>
Mon, 7 Jul 2014 08:57:55 +0000 (10:57 +0200)
committersjena <sjena@cern.ch>
Mon, 7 Jul 2014 08:57:55 +0000 (10:57 +0200)
PWGCF/Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorr.cxx
PWGCF/Correlations/DPhi/TriggerPID/AliTwoParticlePIDCorr.h
PWGCF/Correlations/macros/TriggerPID/AddAliTwoParticlePIDCorrTask.C

index f333420ec2a01d9a26ac25106fab834e376e64d9..935520ab662926c7577d2f5c14fcc3c86c4d1215 100644 (file)
@@ -12,7 +12,6 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-//Source code::dphicorrelations, TaskBFpsi, AliHelperPID
 
 #include "AliTwoParticlePIDCorr.h"
 #include "AliVParticle.h"
@@ -23,6 +22,7 @@
 #include "TH1F.h"
 #include "TH2F.h"
 #include "TH3F.h"
+#include "TProfile.h"
 #include "TList.h"
 #include "TFile.h"
 #include "TGrid.h"
@@ -69,6 +69,7 @@
 #include "AliGenCocktailEventHeader.h"
 #include "AliGenEventHeader.h"
 #include "AliCollisionGeometry.h"
+#include "AliOADBContainer.h"
 
 #include "AliEventPoolManager.h"
 #include "AliAnalysisUtils.h"
@@ -81,12 +82,14 @@ ClassImp(LRCParticlePID)
 const char * kPIDTypeName[]={"TPC","TOF","TPC-TOF"} ;
 const char * kDetectorName[]={"ITS","TPC","TOF"} ;
 const char * kParticleSpeciesName[]={"Pions","Kaons","Protons","Undefined"} ;
+//Source code::dphicorrelations,VnV0, TaskBFpsi, AliHelperPID, 
 
 //________________________________________________________________________
 AliTwoParticlePIDCorr::AliTwoParticlePIDCorr() // All data members should be initialised here
 :AliAnalysisTaskSE(),
   fOutput(0),
    fOutputList(0),
+  fList(0),
   fCentralityMethod("V0A"),
   fSampleType("pPb"),
  fRequestEventPlane(kFALSE),
@@ -178,9 +181,50 @@ fCentralityWeights(0),
     fHistVZEROCvsVZEROAmultiplicity(0x0),
     fHistEQVZEROCvsEQVZEROAmultiplicity(0x0),
     fHistVZEROSignal(0x0),
-fHistEventPlaneReco(0x0),
 fHistEventPlaneTruth(0x0),
 fHistPsiMinusPhi(0x0),
+fEventPlanePID(0x0),
+evplaneMC(999.),
+ fgPsi2v0a(999.),
+    fgPsi2v0c(999.),
+    fgPsi2tpc(999.),
+    fgPsi3v0a(999.),
+    fgPsi3v0c(999.),
+    fgPsi3tpc(999.),
+    fgPsi2v0aMC(999.),
+    fgPsi2v0cMC(999.),
+    fgPsi2tpcMC(999.),
+    fgPsi3v0aMC(999.),
+    fgPsi3v0cMC(999.),
+    fgPsi3tpcMC(999.),
+ gReactionPlane(999.),
+  fV2(kTRUE),
+ fV3(kFALSE),
+ fIsAfter2011(kTRUE),
+  fRun(-1),
+  fNcluster(70),
+ fEPdet("V0A"),  
+ fMultV0(NULL),
+  fV0Cpol(100),
+  fV0Apol(100),
+ fHResTPCv0A2(NULL),
+fHResTPCv0C2(NULL),
+fHResv0Cv0A2(NULL),
+fHResTPCv0A3(NULL),
+fHResTPCv0C3(NULL),
+fHResv0Cv0A3(NULL),
+ fHResMA2(NULL),
+fHResMC2(NULL),
+fHResAC2(NULL),
+fHResMA3(NULL),
+fHResMC3(NULL),
+fHResAC3(NULL),
+fPhiRPTPC(NULL),
+fPhiRPTPCv3(NULL),
+fPhiRPv0A(NULL),
+fPhiRPv0C(NULL),
+fPhiRPv0Av3(NULL),
+fPhiRPv0Cv3(NULL),
  fControlConvResoncances(0),
   fHistoTPCdEdx(0x0),
   fHistoTOFbeta(0x0),
@@ -269,12 +313,22 @@ fAnalysisUtils(0x0),
 
  for(Int_t ipart=0;ipart<NSpecies;ipart++) {fHasDoubleCounting[ipart]=kFALSE;}
 
+  for(Int_t i = 0; i != 2; ++i)
+    for(Int_t j = 0; j != 2; ++j)
+      for(Int_t iC = 0; iC < 9; iC++){
+       fMeanQ[iC][i][j] = 0.;
+       fWidthQ[iC][i][j] = 1.;
+        fMeanQv3[iC][i][j] = 0.;
+       fWidthQv3[iC][i][j] = 1.;
+    }
+
   }
 //________________________________________________________________________
 AliTwoParticlePIDCorr::AliTwoParticlePIDCorr(const char *name) // All data members should be initialised here
   :AliAnalysisTaskSE(name),
  fOutput(0),
    fOutputList(0),
+   fList(0),
  fCentralityMethod("V0A"),
   fSampleType("pPb"),
  fRequestEventPlane(kFALSE),
@@ -366,9 +420,50 @@ fCentralityWeights(0),
     fHistVZEROCvsVZEROAmultiplicity(0x0),
     fHistEQVZEROCvsEQVZEROAmultiplicity(0x0),
     fHistVZEROSignal(0x0),
-fHistEventPlaneReco(0x0),
 fHistEventPlaneTruth(0x0),
-fHistPsiMinusPhi(0x0),
+   fHistPsiMinusPhi(0x0),
+fEventPlanePID(0x0),
+evplaneMC(999.),
+ fgPsi2v0a(999.),
+    fgPsi2v0c(999.),
+    fgPsi2tpc(999.),
+    fgPsi3v0a(999.),
+    fgPsi3v0c(999.),
+    fgPsi3tpc(999.),
+    fgPsi2v0aMC(999.),
+    fgPsi2v0cMC(999.),
+    fgPsi2tpcMC(999.),
+    fgPsi3v0aMC(999.),
+    fgPsi3v0cMC(999.),
+    fgPsi3tpcMC(999.),
+   gReactionPlane(999.),
+ fV2(kTRUE),
+ fV3(kFALSE),
+ fIsAfter2011(kTRUE),
+  fRun(-1),
+  fNcluster(70),
+   fEPdet("V0A"),  
+ fMultV0(NULL),
+  fV0Cpol(100),
+  fV0Apol(100),
+ fHResTPCv0A2(NULL),
+fHResTPCv0C2(NULL),
+fHResv0Cv0A2(NULL),
+fHResTPCv0A3(NULL),
+fHResTPCv0C3(NULL),
+fHResv0Cv0A3(NULL),
+ fHResMA2(NULL),
+fHResMC2(NULL),
+fHResAC2(NULL),
+fHResMA3(NULL),
+fHResMC3(NULL),
+fHResAC3(NULL),
+fPhiRPTPC(NULL),
+fPhiRPTPCv3(NULL),
+fPhiRPv0A(NULL),
+fPhiRPv0C(NULL),
+fPhiRPv0Av3(NULL),
+fPhiRPv0Cv3(NULL),
   fControlConvResoncances(0), 
   fHistoTPCdEdx(0x0),
   fHistoTOFbeta(0x0),
@@ -437,7 +532,9 @@ fRemoveDuplicates(kFALSE),
  fmesoneffrequired(kFALSE),
  fkaonprotoneffrequired(kFALSE),
    fAnalysisUtils(0x0),
-  fDCAXYCut(0)         
+  fDCAXYCut(0)    
+  // The last in the above list should not have a comma after it
+     
 {
   
    for ( Int_t i = 0; i < 16; i++) { 
@@ -456,7 +553,14 @@ for ( Int_t i = 0; i < 6; i++ ){
 
    for(Int_t ipart=0;ipart<NSpecies;ipart++) {fHasDoubleCounting[ipart]=kFALSE;}
 
-  // The last in the above list should not have a comma after it
+  for(Int_t i = 0; i != 2; ++i)
+    for(Int_t j = 0; j != 2; ++j)
+      for(Int_t iC = 0; iC < 9; iC++){
+       fMeanQ[iC][i][j] = 0.;
+       fWidthQ[iC][i][j] = 1.;
+        fMeanQv3[iC][i][j] = 0.;
+       fWidthQv3[iC][i][j] = 1.;
+    }
   
   // Constructor
   // Define input and output slots here (never in the dummy constructor)
@@ -529,21 +633,30 @@ void AliTwoParticlePIDCorr::UserCreateOutputObjects()
   Bool_t oldStatus = TH1::AddDirectoryStatus();
   TH1::AddDirectory(kFALSE);
 
+  const Int_t nPsiTOF = 10;  
+  const Int_t nCentrBin = 9;  
+
+
   fOutput = new TList();
   fOutput->SetOwner();  // IMPORTANT!  
 
   fOutputList = new TList;
   fOutputList->SetOwner();
   fOutputList->SetName("PIDQAList");
+
+  fList = new TList;
+  fList->SetOwner();
+  fList->SetName("EPQAList");
   
   fEventCounter = new TH1F("fEventCounter","EventCounter", 19, 0.5,19.5);
   fEventCounter->GetXaxis()->SetBinLabel(1,"Event Accesed");
   fEventCounter->GetXaxis()->SetBinLabel(3,"After PileUP Cut");//only for Data
   fEventCounter->GetXaxis()->SetBinLabel(5,"Have A Vertex");
   fEventCounter->GetXaxis()->SetBinLabel(7,"After vertex Cut");
-  fEventCounter->GetXaxis()->SetBinLabel(9,"After centrality flattening");
-  fEventCounter->GetXaxis()->SetBinLabel(11,"Within 0-100% centrality");
-  fEventCounter->GetXaxis()->SetBinLabel(13,"Event Analyzed");
+  fEventCounter->GetXaxis()->SetBinLabel(9,"Getting centrality");
+  fEventCounter->GetXaxis()->SetBinLabel(11,"After centrality flattening");
+  fEventCounter->GetXaxis()->SetBinLabel(13,"Within 0-100% centrality");
+  fEventCounter->GetXaxis()->SetBinLabel(15,"Event Analyzed");
   //fEventCounter->GetXaxis()->SetBinLabel(8,"Event Analysis finished");
   fOutput->Add(fEventCounter);
   
@@ -642,17 +755,16 @@ fHistEQVZEROCvsEQVZEROAmultiplicity = new TH2F("fHistEQVZEROCvsEQVZEROAmultiplic
   fOutput->Add(fHistVZEROSignal);
 }
 
- if(fSampleType=="PbPb" && fRequestEventPlane){
-//Event plane
-  fHistEventPlaneReco = new TH2F("fHistEventPlaneReco",";#Psi_{2} [deg.];Centrality percentile;Counts",100,0,360.,220,-5,105);
-  fOutput->Add(fHistEventPlaneReco);
+ if(fRequestEventPlane){
 
-//Event plane
-  fHistEventPlaneTruth = new TH2F("fHistEventPlaneTruth",";#Psi_{2} [deg.];Centrality percentile;Counts",100,0,360.,220,-5,105);
-  fOutput->Add(fHistEventPlaneTruth);
 
+//Event plane
   fHistPsiMinusPhi = new TH2D("fHistPsiMinusPhi","",4,-0.5,3.5,100,0,2.*TMath::Pi());
-  fOutput->Add(fHistPsiMinusPhi);
+  fList->Add(fHistPsiMinusPhi);
+
+  fEventPlanePID = new TH3F("fEventPlanePID",";centrality;eventplane;PID",20,0.0,100.0,4,-0.5,3.5,4,-0.5,3.5);
+  fList->Add(fEventPlanePID);
 
  }
  
@@ -882,6 +994,73 @@ if(fcontainPIDtrig && fcontainPIDasso){
         fmincentmult=dBinsPair[0][0];
         fmaxcentmult=dBinsPair[0][iBinPair[0]];
 
+       //event pool manager
+Int_t MaxNofEvents=1000;
+const Int_t NofVrtxBins=10+(1+10)*2;
+Double_t ZvrtxBins[NofVrtxBins+1]={ -10,   -8,  -6,  -4,  -2,   0,   2,   4,   6,   8,  10, 
+                                      90,  92,  94,  96,  98, 100, 102, 104, 106, 108, 110, 
+                                   190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210}; 
+
+if(fCentralityMethod.EndsWith("_MANUAL"))
+   {
+ const Int_t NofCentBins=9;
+ Double_t CentralityBins[NofCentBins+1]={0.,9.,14.,19.,26.,34.,44.,58.,80.,500.};//Is This binning is fine for pp, or we don't require them....
+if(fRequestEventPlane){
+    // Event plane angle (Psi) bins
+  /*
+    Double_t* psibins = NULL;
+    Int_t nPsiBins; 
+    psibins = GetBinning(fBinningString, "eventPlane", nPsiBins);
+  */
+ const Int_t  nPsiBins=6;
+ Double_t psibins[nPsiBins+1]={0.0*TMath::DegToRad(), 30.0*TMath::DegToRad(), 60.0*TMath::DegToRad(), 90.0*TMath::DegToRad(), 120.0*TMath::DegToRad(),150.0*TMath::DegToRad(),180.1*TMath::DegToRad()};
+fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins, nPsiBins, psibins);
+// if(psibins)  delete [] psibins; 
+                                   }
+
+ else{
+ const Int_t  nPsiBinsd=1;
+ Double_t psibinsd[nPsiBinsd+1]={0.0, 2000.0};
+fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins, nPsiBinsd, psibinsd);
+
+// fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
+ }  
+fPoolMgr->SetTargetValues(fMaxNofMixingTracks, 0.1, 5);
+
+   }
+ else
+   {
+ const Int_t  NofCentBins=15;
+Double_t CentralityBins[NofCentBins+1]={0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1 };
+ if(fRequestEventPlane){
+    // Event plane angle (Psi) bins
+   /*
+    Double_t* psibins = NULL;
+    Int_t nPsiBins; 
+    psibins = GetBinning(fBinningString, "eventPlane", nPsiBins);
+   */
+ const Int_t  nPsiBins=6;
+ Double_t psibins[nPsiBins+1]={0.0*TMath::DegToRad(), 30.0*TMath::DegToRad(), 60.0*TMath::DegToRad(), 90.0*TMath::DegToRad(), 120.0*TMath::DegToRad(),150.0*TMath::DegToRad(),180.1*TMath::DegToRad()};
+fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins, nPsiBins, psibins);
+// if(psibins)  delete [] psibins; 
+                                   }
+
+ else{
+const Int_t  nPsiBinsd=1;
+ Double_t psibinsd[nPsiBinsd+1]={0.0, 2000.0};
+fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins, nPsiBinsd, psibinsd);
+
+//fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
+ }  
+fPoolMgr->SetTargetValues(fMaxNofMixingTracks, 0.1, 5);
+   }
+
+   if(!fPoolMgr){
+      AliError("Event Mixing required, but Pool Manager not initialized...");
+      return;
+    }
+
        //fminPtComboeff=fminPtTrig;***then this value will be fixed ,even Setter can't change it's value
        //fmaxPtComboeff=fmaxPtTrig;
 //THnSparses for calculation of efficiency
@@ -1140,7 +1319,7 @@ fOutput->Add(fhistJetTrigestimate);
 
 
 //Mixing
-DefineEventPool();
+//DefineEventPool();
 
   if(fapplyTrigefficiency || fapplyAssoefficiency)
    {
@@ -1183,6 +1362,69 @@ effcorection[jj] = (THnSparseF*)fileT->Get(Nameg.Data());
 fileT->Close();
 
    }
+
+  //*************************************************************EP plots***********************************************//
+  if(fRequestEventPlane){
+  // TProfile for resolutions 3 subevents (V0A, V0C, TPC)
+  // v2
+  fHResTPCv0A2 = new TProfile("hResTPCv0A2","",nCentrBin,0,nCentrBin);
+  fHResTPCv0C2 = new TProfile("hResTPCv0C2","",nCentrBin,0,nCentrBin);
+  fHResv0Cv0A2 = new TProfile("hResv0Cv0A2","",nCentrBin,0,nCentrBin);
+
+  fList->Add(fHResTPCv0A2);
+  fList->Add(fHResTPCv0C2);
+  fList->Add(fHResv0Cv0A2);
+
+  // v3
+  fHResTPCv0A3 = new TProfile("hResTPCv0A3","",nCentrBin,0,nCentrBin);
+  fHResTPCv0C3 = new TProfile("hResTPCv0C3","",nCentrBin,0,nCentrBin);
+  fHResv0Cv0A3 = new TProfile("hResv0Cv0A3","",nCentrBin,0,nCentrBin);
+
+  fList->Add(fHResTPCv0A3);
+  fList->Add(fHResTPCv0C3);
+  fList->Add(fHResv0Cv0A3);
+
+  // MC as in the dataEP resolution (but using MC tracks)
+  if(fAnalysisType == "MCAOD"  && fV2){
+    fHResMA2 = new TProfile("hResMA2","",nCentrBin,0,nCentrBin);
+    fHResMC2 = new TProfile("hResMC2","",nCentrBin,0,nCentrBin);
+    fHResAC2 = new TProfile("hResAC2","",nCentrBin,0,nCentrBin);
+    fList->Add(fHResMA2); 
+    fList->Add(fHResMC2); 
+    fList->Add(fHResAC2); 
+  }
+  if(fAnalysisType == "MCAOD" && fV3){
+    fHResMA3 = new TProfile("hResMA3","",nCentrBin,0,nCentrBin);
+    fHResMC3 = new TProfile("hResMC3","",nCentrBin,0,nCentrBin);
+    fHResAC3 = new TProfile("hResAC3","",nCentrBin,0,nCentrBin);
+    fList->Add(fHResMA3); 
+    fList->Add(fHResMC3); 
+    fList->Add(fHResAC3); 
+  }
+
+
+  // V0A and V0C event plane distributions
+  //v2 
+  fPhiRPTPC = new TH2F("fPhiRPTPCv2","#phi distribution of EP TPC;centrality;#phi (rad)",nCentrBin,0,nCentrBin,nPsiTOF,-TMath::Pi()/2,TMath::Pi()/2);
+  fPhiRPTPCv3 = new TH2F("fPhiRPTPCv3","#phi distribution of EP TPC;centrality;#phi (rad)",nCentrBin,0,nCentrBin,nPsiTOF,-TMath::Pi()/3,TMath::Pi()/3);
+  fList->Add(fPhiRPTPC);
+  fList->Add(fPhiRPTPCv3);
+
+  fPhiRPv0A = new TH2F("fPhiRPv0Av2","#phi distribution of EP VZERO-A;centrality;#phi (rad)",nCentrBin,0,nCentrBin,nPsiTOF,-TMath::Pi()/2,TMath::Pi()/2);
+  fPhiRPv0C = new TH2F("fPhiRPv0Cv2","#phi distribution of EP VZERO-C;centrality;#phi (rad)",nCentrBin,0,nCentrBin,nPsiTOF,-TMath::Pi()/2,TMath::Pi()/2);
+  fList->Add(fPhiRPv0A);
+  fList->Add(fPhiRPv0C);
+
+  //v3
+  fPhiRPv0Av3 = new TH2F("fPhiRPv0Av3","#phi distribution of EP VZERO-A;centrality;#phi (rad)",nCentrBin,0,nCentrBin,nPsiTOF,-TMath::Pi()/3,TMath::Pi()/3);
+  fPhiRPv0Cv3 = new TH2F("fPhiRPv0Cv3","#phi distribution of EP VZERO-C;centrality;#phi (rad)",nCentrBin,0,nCentrBin,nPsiTOF,-TMath::Pi()/3,TMath::Pi()/3);
+  fList->Add(fPhiRPv0Av3);
+  fList->Add(fPhiRPv0Cv3);
+
+  fHistEventPlaneTruth = new TH2F("fHistEventPlaneTruth","#phi distribution of EP MCTRUTHheader;centrality;#phi (rad)",nCentrBin,0,nCentrBin,nPsiTOF,-TMath::Pi()/2,TMath::Pi()/2);
+  fList->Add(fHistEventPlaneTruth);
+
+  }
     
   //*****************************************************PIDQA histos*****************************************************//
 
@@ -1325,7 +1567,7 @@ fileT->Close();
 
   PostData(1, fOutput);              // Post data for ALL output slots >0 here, to get at least an empty histogram
   PostData(2, fOutputList);
-
+  if(fRequestEventPlane) PostData(3, fList);
   AliInfo("Finished setting up the Output");
 
   TH1::AddDirectory(oldStatus);
@@ -1366,11 +1608,19 @@ void AliTwoParticlePIDCorr::doMCAODevent()
 // count all events(physics triggered)   
   fEventCounter->Fill(1);
 
+    evplaneMC=999.;
+    fgPsi2v0aMC=999.;
+    fgPsi2v0cMC=999.;
+    fgPsi2tpcMC=999.;
+    fgPsi3v0aMC=999.;
+    fgPsi3v0cMC=999.;
+    fgPsi3tpcMC=999.;
+    gReactionPlane = 999.;
+
  // get centrality object and check quality(valid for p-Pb and Pb-Pb; coming soon for pp 7 TeV)
   Double_t cent_v0=-1.0;
   Double_t effcent=1.0;
   Double_t refmultReco =0.0;
-  Double_t gReactionPlane = -1.; 
 
 //check the PIDResponse handler
   if (!fPID) return;
@@ -1440,13 +1690,11 @@ skipParticlesAbove = eventHeader->NProduced();
  effcent=cent_v0;// This will be required for efficiency THn filling(specially in case of pp)
 
   //get the event plane in case of PbPb
-  if(fSampleType=="PbPb"){
    if(fRequestEventPlane){
-    gReactionPlane = GetEventPlane(aod,kTRUE);//get the truth event plane
-    fHistEventPlaneTruth->Fill(gReactionPlane,cent_v0);
-    if(gReactionPlane < 0) return;
+   gReactionPlane=GetEventPlane(aod,kTRUE,cent_v0);//get the truth event plane
+   if(gReactionPlane==999.) return;
  }
-  }
+  
 
    Double_t nooftrackstruth=0.0;//in case of pp this will give the multiplicity(for truth case) after the track loop(only for unidentified particles that pass  kinematic cuts)
 
@@ -1554,6 +1802,10 @@ if(ffillhistQATruth)
      }
  if(TMath::Abs(pdgtruth)!=211 && TMath::Abs(pdgtruth)!=321 && TMath::Abs(pdgtruth)!=2212)  particletypeTruth=unidentified;//*********************WARNING:: situation is different from reco MC and data case(here we don't have SpUndefined particles,because here unidentified=SpUndefined)
 
+    if(fRequestEventPlane){
+      FillPIDEventPlane(cent_v0,particletypeTruth,partMC->Phi(),gReactionPlane);
+    }
+
  // -- Fill THnSparse for efficiency and contamination calculation
  if (fSampleType=="pp" && fCentralityMethod.EndsWith("_MANUAL")) effcent=15.0;//integrated over multiplicity(so put any fixed value for each track so that practically means there is only one bin in multiplicity i.e. multiplicity intregated out )**************Important
 
@@ -1603,7 +1855,7 @@ if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)//hadron triggered correla
   Fillcorrelation(gReactionPlane,tracksMCtruth,0,cent_v0,zVtxmc,weghtval,kFALSE,bSign,fPtOrderMCTruth,kFALSE,kFALSE,"trigIDassoIDMCTRUTH");//mixcase=kFALSE for same event case
 
 //start mixing
-AliEventPool* pool2 = fPoolMgr->GetEventPool(cent_v0, zVtxmc+200);
+ AliEventPool* pool2 = fPoolMgr->GetEventPool(cent_v0, zVtxmc+200, gReactionPlane);
 if (pool2 && pool2->IsReady())
   {//start mixing only when pool->IsReady
 if(tracksMCtruth && tracksMCtruth->GetEntriesFast()>0)
@@ -1636,13 +1888,11 @@ if(tracksMCtruth) delete tracksMCtruth;
  if (fSampleType=="pp" && fCentralityMethod.EndsWith("_MANUAL")) cent_v0=refmultReco;
  effcent=cent_v0;// This will be required for efficiency THn filling(specially in case of pp)
 
-  if(fSampleType=="PbPb"){
  if(fRequestEventPlane){
-    gReactionPlane = GetEventPlane(aod,kFALSE);//get the reconstructed event plane
-    fHistEventPlaneReco->Fill(gReactionPlane,cent_v0);
-    if(gReactionPlane < 0) return;
+   gReactionPlane = GetEventPlane(aod,kFALSE,cent_v0);//get the reconstructed event plane
+    if(gReactionPlane==999.) return;
  }
-  }
+  
    //TObjArray* tracksUNID=0;
    TObjArray* tracksUNID = new TObjArray;
    tracksUNID->SetOwner(kTRUE);
@@ -1879,6 +2129,9 @@ if(particletypeMC==SpKaon )
 
  if(particletypeMC==SpUndefined) continue;
 
+    if(fRequestEventPlane){
+      FillPIDEventPlane(cent_v0,particletypeMC,track->Phi(),gReactionPlane);
+    }
 
  //fill tracking efficiency
  if(ffillefficiency)
@@ -1938,7 +2191,7 @@ if(trackscount>0.0)
  if (fSampleType=="pPb" || fSampleType=="PbPb") fCentralityCorrelation->Fill(cent_v0, trackscount);//only with unidentified tracks(i.e before PID selection);;;;;can be used to remove centrality outliers??????
 
 //count selected events having centrality betn 0-100%
- fEventCounter->Fill(11);
+ fEventCounter->Fill(13);
 
 //***************************************event no. counting
 Bool_t isbaryontrig=kFALSE;
@@ -1976,7 +2229,7 @@ if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
 //still in  main event loop
 //start mixing
  if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles
-AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
+  AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx,gReactionPlane);//In the pool there is tracksUNID(i.e associateds are unidentified)
 if (pool && pool->IsReady())
   {//start mixing only when pool->IsReady
     Float_t nmix1=(Float_t)pool->GetCurrentNEvents();  
@@ -1998,7 +2251,7 @@ if(pool)
  }//mixing with unidentified particles
 
  if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles
-AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
+  AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100,gReactionPlane);//In the pool1 there is tracksID(i.e associateds are identified)
 if (pool1 && pool1->IsReady())
   {//start mixing only when pool->IsReady
   Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();  
@@ -2021,7 +2274,7 @@ if(pool1)
  }//mixing with identified particles
 
   //no. of events analyzed
-fEventCounter->Fill(13);
+fEventCounter->Fill(15);
   }
 
 if(tracksUNID)  delete tracksUNID;
@@ -2050,9 +2303,16 @@ void AliTwoParticlePIDCorr::doAODevent()
 
 if (!fPID) return;//this should be available with each event even if we don't do PID selection
 
+    fgPsi2v0a=999.;
+    fgPsi2v0c=999.;
+    fgPsi2tpc=999.;
+    fgPsi3v0a=999.;
+    fgPsi3v0c=999.;
+    fgPsi3tpc=999.;
+    gReactionPlane = 999.;
+    
   Double_t cent_v0=   -999.;
   Double_t effcent=1.0;
-  Double_t gReactionPlane       = -1.; 
   Float_t bSign = 0.;
   Double_t trackscount=0;//counts particles passed filterbit cuts and kinematic cuts used in this analysis
 
@@ -2067,14 +2327,11 @@ if (!fPID) return;//this should be available with each event even if we don't do
   }
   
   //get the event plane in case of PbPb
-  if(fSampleType=="PbPb"){
     if(fRequestEventPlane){
-    gReactionPlane = GetEventPlane(aod,kFALSE);
-    fHistEventPlaneReco->Fill(gReactionPlane,cent_v0);
-    if(gReactionPlane < 0) return;
+      gReactionPlane = GetEventPlane(aod,kFALSE,cent_v0);
+    if(gReactionPlane==999.) return;
     }    
-  }
-
+  
    TObjArray*  tracksUNID= new TObjArray;//track info before doing PID
    tracksUNID->SetOwner(kTRUE);  // IMPORTANT!
 
@@ -2164,6 +2421,11 @@ if (!fPID) return;//this should be available with each event even if we don't do
 //ignore the Spundefined particles as they also contain pion, kaon, proton outside the nsigma cut(also if tracks don't have proper TOF PID in a certain Pt interval) & these tracks are actually counted when we do the the efficiency correction, so considering them as unidentified particles & doing the efficiency correction(i.e defining unidentified=pion+Kaon+proton+SpUndefined is right only without efficiency correction) for them will be two times wrong!!!!! 
   if (particletype==SpUndefined) continue;//this condition creating a modulated structure in delphi projection in mixed event case(only when we are dealing with identified particles i.e. tracksID)!!!!!!!!!!!
 
+    if(fRequestEventPlane){
+      FillPIDEventPlane(cent_v0,particletype,track->Phi(),gReactionPlane);
+    }
+
+
  //Pt, Eta , Phi distribution of the reconstructed identified particles
 if(ffillhistQAReco)
     {
@@ -2221,7 +2483,7 @@ if(trackscount<1.0){
 if(fSampleType=="pPb" || fSampleType=="PbPb") fCentralityCorrelation->Fill(cent_v0, trackscount);//only with unidentified tracks(i.e before PID selection);;;;;can be used to remove centrality outliers??????
 
 //count selected events having centrality betn 0-100%
- fEventCounter->Fill(11);
+ fEventCounter->Fill(13);
 
 //***************************************event no. counting
 Bool_t isbaryontrig=kFALSE;
@@ -2263,7 +2525,7 @@ if(tracksID && tracksID->GetEntriesFast()>0)//ID triggered correlation
 
 //start mixing
  if(ffilltrigassoUNID || ffilltrigIDassoUNID){//mixing with unidentified particles
-AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx);//In the pool there is tracksUNID(i.e associateds are unidentified)
+AliEventPool* pool = fPoolMgr->GetEventPool(cent_v0, zvtx,gReactionPlane);//In the pool there is tracksUNID(i.e associateds are unidentified)
 if (pool && pool->IsReady())
   {//start mixing only when pool->IsReady
   Float_t nmix1=(Float_t)pool->GetCurrentNEvents();  
@@ -2285,7 +2547,7 @@ if(pool)
 
 
  if(ffilltrigUNIDassoID || ffilltrigIDassoID){//mixing with identified particles
-AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100);//In the pool1 there is tracksID(i.e associateds are identified)
+ AliEventPool* pool1 = fPoolMgr->GetEventPool(cent_v0, zvtx+100,gReactionPlane);//In the pool1 there is tracksID(i.e associateds are identified)
 if (pool1 && pool1->IsReady())
   {//start mixing only when pool->IsReady
   Float_t nmix2=(Float_t)pool1->GetCurrentNEvents();  
@@ -2309,7 +2571,7 @@ if(pool1)
 
 
   //no. of events analyzed
-fEventCounter->Fill(13);
+fEventCounter->Fill(15);
  
 //still in main event loop
 
@@ -2341,7 +2603,7 @@ TObjArray* AliTwoParticlePIDCorr::CloneAndReduceTrackList(TObjArray* tracks)
 }
 
 //--------------------------------------------------------------------------------
-void AliTwoParticlePIDCorr::Fillcorrelation(Double_t gReactionPlane,TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t weight,Bool_t firstTime,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup)
+void AliTwoParticlePIDCorr::Fillcorrelation(Float_t ReactionPlane,TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t weight,Bool_t firstTime,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup)
 {
 
   //before calling this function check that either trackstrig & tracksasso are available 
@@ -2509,11 +2771,17 @@ if (fOnlyOneEtaSide != 0)
     Double_t gPsiMinusPhi    =   0.;
     Double_t gPsiMinusPhiBin = -10.;
 if(fRequestEventPlane){
-    gPsiMinusPhi   = TMath::Abs(trigphi - gReactionPlane);
-    //in-plane
+    gPsiMinusPhi   = TMath::Abs(trigphi - ReactionPlane);
+    //in-plane(Note thet event plane angle has to be defined within 0 to 180 degree(do not use this if event ), otherwise the definition of in plane and out plane particles is wrong)
     if((gPsiMinusPhi <= 7.5*TMath::DegToRad())||
+      (gPsiMinusPhi >= 352.5*TMath::DegToRad())||
        ((172.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 187.5*TMath::DegToRad())))
       gPsiMinusPhiBin = 0.0;
+    /*
+ if((gPsiMinusPhi <= 7.5*TMath::DegToRad())||
+       ((172.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 187.5*TMath::DegToRad())))
+      gPsiMinusPhiBin = 0.0;
+    */
     //intermediate
     else if(((37.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 52.5*TMath::DegToRad()))||
            ((127.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 142.5*TMath::DegToRad()))||
@@ -3633,6 +3901,7 @@ Float_t  AliTwoParticlePIDCorr::GetDPhiStar(Float_t phi1, Float_t pt1, Float_t c
   return dphistar;
 }
 //_________________________________________________________________________
+/*
 void AliTwoParticlePIDCorr ::DefineEventPool()
 {
 Int_t MaxNofEvents=1000;
@@ -3640,24 +3909,28 @@ const Int_t NofVrtxBins=10+(1+10)*2;
 Double_t ZvrtxBins[NofVrtxBins+1]={ -10,   -8,  -6,  -4,  -2,   0,   2,   4,   6,   8,  10, 
                                       90,  92,  94,  96,  98, 100, 102, 104, 106, 108, 110, 
                                      190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210 
-                                     };
- if (fSampleType=="pp"){
-const Int_t  NofCentBins=4;
- Double_t CentralityBins[NofCentBins+1]={0.,20., 40.,60.,200.1};//Is This binning is fine for pp, or we don't require them....
-fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
- }
-if (fSampleType=="pPb" || fSampleType=="PbPb")
-  {
-const Int_t  NofCentBins=15;
+
+//default values are for centrality
+Int_t  NofCentBins=15;
 Double_t CentralityBins[NofCentBins+1]={0., 1., 2., 3., 4., 5., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.1 };
+
+ if(fCentralityMethod.EndsWith("_MANUAL"))
+   {
+ Int_t  NofCentBins=9;
+ CentralityBins[NofCentBins+1]={0.,9.,14.,19.,26.,34.,44.,58.,80.,500.};//Is This binning is fine for pp, or we don't require them....
+   }
 fPoolMgr = new AliEventPoolManager(MaxNofEvents,fMaxNofMixingTracks,NofCentBins,CentralityBins,NofVrtxBins,ZvrtxBins);
-  }
+
+
+
+  
 fPoolMgr->SetTargetValues(fMaxNofMixingTracks, 0.1, 5);
 
 //if(!fPoolMgr) return kFALSE;
 //return kTRUE;
 
 }
+*/
 //------------------------------------------------------------------------
 Double_t* AliTwoParticlePIDCorr::GetBinning(const char* configuration, const char* tag, Int_t& nBins)
 {
@@ -4165,202 +4438,476 @@ fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]
 
 }
 //--------------------------------------------------------------------------------------------------------
-Double_t AliTwoParticlePIDCorr::GetEventPlane(AliAODEvent *event,Bool_t truth){
+Float_t AliTwoParticlePIDCorr::GetEventPlane(AliAODEvent *event,Bool_t truth, Double_t v0Centr)
+{
   // Get the event plane
+ //reset Q vector info 
 
+    Int_t run = event->GetRunNumber();
+
+    if(run != fRun){
+       // Load the calibrations run dependent
+      if(! fIsAfter2011) OpenInfoCalbration(run);
+      fRun=run;
+    }
+
+
+  Int_t iC = -1;  
+if (v0Centr < 80){ // analysis only for 0-80% centrality classes
+ // centrality bins
+    if(v0Centr < 5) iC = 0;
+    else if(v0Centr < 10) iC = 1;
+    else if(v0Centr < 20) iC = 2;
+    else if(v0Centr < 30) iC = 3;
+    else if(v0Centr < 40) iC = 4;
+    else if(v0Centr < 50) iC = 5;
+    else if(v0Centr < 60) iC = 6;
+    else if(v0Centr < 70) iC = 7;
+    else iC = 8;
+
+
+     Int_t iCcal = iC;
+
+ //reset Q vector info  
+    Double_t Qxa2 = 0, Qya2 = 0;
+    Double_t Qxc2 = 0, Qyc2 = 0;
+    Double_t Qxa3 = 0, Qya3 = 0;
+    Double_t Qxc3 = 0, Qyc3 = 0;
 
-  Float_t gVZEROEventPlane    = -10.;
-  Float_t gReactionPlane      = -10.;
-  Double_t qxTot = 0.0, qyTot = 0.0;
 
   //MC: from reaction plane
  if(truth)
 {
     AliAODMCHeader* header = (AliAODMCHeader*) event->GetList()->FindObject(AliAODMCHeader::StdBranchName());
     if (header){
-    
-      AliGenEventHeader* eventHeader = header->GetCocktailHeader(0);  // get first MC header from either ESD/AOD (including cocktail header if available)
+      evplaneMC = header->GetReactionPlaneAngle();//[0, 360]
+        //make it within [-pi/2,pi/2] to make it general
+       if(evplaneMC > TMath::Pi()/2 && evplaneMC <=  TMath::Pi()*3/2) evplaneMC-=TMath::Pi(); 
+       else if(evplaneMC > TMath::Pi()*3/2) evplaneMC-=2*TMath::Pi();
+         fHistEventPlaneTruth->Fill(iC,evplaneMC);
+       /*
+        AliGenEventHeader* eventHeader = header->GetCocktailHeader(0);  // get first MC header from either ESD/AOD (including cocktail header if available)
       if (eventHeader)
       {
              
        AliCollisionGeometry* collGeometry = dynamic_cast<AliCollisionGeometry*> (eventHeader);     
       
-     if (collGeometry)   gReactionPlane = collGeometry->ReactionPlaneAngle();
-    }
+       if (collGeometry){//get the reaction plane from MC header   
+         gReactionPlane = collGeometry->ReactionPlaneAngle();//[0,180]
+ }
+      }
+       */   
+     //taken from vnv0 code(get the TPC, V0A, V0C event plane using truth tracks)
+       TClonesArray *mcArray = NULL;
+       mcArray = (TClonesArray*)event->GetList()->FindObject(AliAODMCParticle::StdBranchName());
+       if(mcArray){
+         Float_t QxMCv2[3] = {0,0,0};
+         Float_t QyMCv2[3] = {0,0,0};
+         Float_t QxMCv3[3] = {0,0,0};
+         Float_t QyMCv3[3] = {0,0,0};
+         Float_t EvPlaneMCV2[3] = {0,0,0};
+         Float_t EvPlaneMCV3[3] = {0,0,0};
+         Float_t etaMin[3] = {2.8,-3.6,-0.8}; // A-side, C-side M-barrel
+         Float_t etaMax[3] = {4.88,-1.8,0.8};
+
+         // analysis on MC tracks
+         Int_t nMCtrack = mcArray->GetEntries() ;
+
+         // EP computation with MC tracks
+         for(Int_t iT=0;iT < nMCtrack;iT++){
+           AliAODMCParticle *mctr = (AliAODMCParticle*) mcArray->At(iT);
+           if(!mctr || !(mctr->IsPrimary()) || !(mctr->Charge()) || mctr->Pt() < 0.2) continue;
+           
+           Float_t eta = mctr->Eta();
+  for(Int_t iD=0;iD<3;iD++){
+             if(eta > etaMin[iD] && eta < etaMax[iD]){
+               Float_t phi = mctr->Phi();
+               QxMCv2[iD] += TMath::Cos(2*phi);
+               QyMCv2[iD] += TMath::Sin(2*phi);
+               QxMCv3[iD] += TMath::Cos(3*phi);
+               QyMCv3[iD] += TMath::Sin(3*phi);
+             }
+           }
+         }
+
+           EvPlaneMCV2[0] = TMath::ATan2(QyMCv2[0],QxMCv2[0])/2.;
+           EvPlaneMCV2[1] = TMath::ATan2(QyMCv2[1],QxMCv2[1])/2.;
+           EvPlaneMCV2[2] = TMath::ATan2(QyMCv2[2],QxMCv2[2])/2.;
+           fHResMA2->Fill(Double_t(iC), TMath::Cos(2*(EvPlaneMCV2[2]-EvPlaneMCV2[0])));
+           fHResMC2->Fill(Double_t(iC), TMath::Cos(2*(EvPlaneMCV2[2]-EvPlaneMCV2[1])));
+           fHResAC2->Fill(Double_t(iC), TMath::Cos(2*(EvPlaneMCV2[0]-EvPlaneMCV2[1])));
+            fgPsi2v0aMC = EvPlaneMCV2[0];
+            fgPsi2v0cMC = EvPlaneMCV2[1];
+            fgPsi2tpcMC = EvPlaneMCV2[2];
+         
+
+           EvPlaneMCV3[0] = TMath::ATan2(QyMCv3[0],QxMCv3[0])/3.;
+           EvPlaneMCV3[1] = TMath::ATan2(QyMCv3[1],QxMCv3[1])/3.;
+           EvPlaneMCV3[2] = TMath::ATan2(QyMCv3[2],QxMCv3[2])/3.;
+           fHResMA3->Fill(Double_t(iC), TMath::Cos(3*(EvPlaneMCV3[2]-EvPlaneMCV3[0])));
+           fHResMC3->Fill(Double_t(iC), TMath::Cos(3*(EvPlaneMCV3[2]-EvPlaneMCV3[1])));
+           fHResAC3->Fill(Double_t(iC), TMath::Cos(3*(EvPlaneMCV3[0]-EvPlaneMCV3[1])));
+            fgPsi3v0aMC = EvPlaneMCV3[0];
+            fgPsi3v0cMC = EvPlaneMCV3[1];
+            fgPsi3tpcMC = EvPlaneMCV3[2];
+         
+       }    
     }
+
     }
  else{
-   
-    AliEventplane *ep = event->GetEventplane();
-    if(ep){ 
-      gVZEROEventPlane = ep->CalculateVZEROEventPlane(event,10,2,qxTot,qyTot);
-      if(gVZEROEventPlane < 0.) gVZEROEventPlane += TMath::Pi();
-      //gReactionPlane = gVZEROEventPlane*TMath::RadToDeg();
-      gReactionPlane = gVZEROEventPlane;
-    }
-  }//AOD,ESD,ESDMC
-  return gReactionPlane; 
-}
-
+    Int_t nAODTracks = event->GetNumberOfTracks();
 
+// TPC EP needed for resolution studies (TPC subevent)
+   //AliEventplane * ep = (fAOD->GetHeader())->GetEventplaneP();
+   //Double_t psiTPC = ep->GetEventplane("Q", fAOD, 2); // in range of [0, pi]
+    Double_t Qx2 = 0, Qy2 = 0;
+    Double_t Qx3 = 0, Qy3 = 0;
 
+    for(Int_t iT = 0; iT < nAODTracks; iT++) {
+      
+      AliAODTrack* aodTrack = event->GetTrack(iT);
+      
+      if (!aodTrack){
+       continue;
+      }
+      
+      Bool_t trkFlag = aodTrack->TestFilterBit(1);
 
+      if ((TMath::Abs(aodTrack->Eta()) > 0.8) || (aodTrack->Pt() < 0.2) || (aodTrack->GetTPCNcls() < fNcluster)  || !trkFlag) 
+       continue;
+       
+      Double_t b[2] = {-99., -99.};
+      Double_t bCov[3] = {-99., -99., -99.};
 
 
-//____________________________________________________________________
-void AliTwoParticlePIDCorr::Terminate(Option_t *) 
-{
-  // Draw result to screen, or perform fitting, normalizations
-  // Called once at the end of the query
-  fOutput = dynamic_cast<TList*> (GetOutputData(1));
-  if(!fOutput) { Printf("ERROR: could not retrieve TList fOutput"); return; }
-  
-  
-}
-//------------------------------------------------------------------ 
-/*
+      AliAODTrack param(*aodTrack);
+      if (!param.PropagateToDCA(event->GetPrimaryVertex(), event->GetMagneticField(), 100., b, bCov)){
+       continue;
+      }
+           
+      if ((TMath::Abs(b[0]) > 3.0) || (TMath::Abs(b[1]) > 2.4))
+       continue;
+      
+      Qx2 += TMath::Cos(2*aodTrack->Phi()); 
+      Qy2 += TMath::Sin(2*aodTrack->Phi());
+      Qx3 += TMath::Cos(3*aodTrack->Phi()); 
+      Qy3 += TMath::Sin(3*aodTrack->Phi());
+      
+    }
+    
+   Float_t evPlAng2 = TMath::ATan2(Qy2, Qx2)/2.;
+   Float_t evPlAng3 = TMath::ATan2(Qy3, Qx3)/3.;
 
- // get centrality object and check quality
-  Double_t cent_v0=0;
+    fgPsi2tpc = evPlAng2;
+    fgPsi3tpc = evPlAng3;
 
+     fPhiRPTPC->Fill(iC,evPlAng2);
+     fPhiRPTPCv3->Fill(iC,evPlAng3);
 
-if(fCentralityMethod=="V0M" || fCentralityMethod=="V0A" || fCentralityMethod=="V0C")//for PbPb, pPb, pp7TeV(still to be introduced)
-    {
-  AliCentrality *centralityObj=0;
-  if(aod) 
-  AliAODHeader *header = (AliAODHeader*) aod->GetHeader();
-  if(header){
-  centralityObj = header->GetCentralityP();
-  // if (centrality->GetQuality() != 0) return ;
 
-  if(centralityObj)
-  {
-if(fSampleType=="pPb" || fSampleType=="PbPb" || fSampleType=="pp")   fHistCentStats->Fill(0.,centralityObj->GetCentralityPercentile("V0M"));//only available for LHC10d at present (Quantile info)
-if(fSampleType=="pPb" || fSampleType=="PbPb")      fHistCentStats->Fill(2.,centralityObj->GetCentralityPercentile("V0A"));
-if(fSampleType=="pPb" || fSampleType=="PbPb")      fHistCentStats->Fill(4.,centralityObj->GetCentralityPercentile("V0C"));
-if(fSampleType=="pPb" || fSampleType=="PbPb")      fHistCentStats->Fill(6.,centralityObj->GetCentralityPercentile("CL1"));
-if(fSampleType=="pPb" || fSampleType=="PbPb")      fHistCentStats->Fill(8.,centralityObj->GetCentralityPercentile("ZNA")); 
 
-      cent_v0 = centralityObj->GetCentralityPercentile(fCentralityMethod);
-  }
-  else
-    {
-  cent_v0= -1;
-     }
-  }//AOD header
-    }//centralitymethod condition
+//V0 info    
+    AliAODVZERO* aodV0 = event->GetVZEROData();
 
-else if(fCentralityMethod=="V0M_MANUAL" || fCentralityMethod=="V0A_MANUAL" || fCentralityMethod=="V0C_MANUAL" || fCentralityMethod=="TRACKS_MANUAL")
-   {
-    cent_v0 = GetReferenceMultiplicityVZEROFromAOD(aod);
-    fHistrefMultiplicity->Fill(cent_v0);
-   }
- else  cent_v0= -1;
+    for (Int_t iv0 = 0; iv0 < 64; iv0++) {
+      Double_t phiV0 = TMath::PiOver4()*(0.5 + iv0 % 8);
+      Float_t multv0 = aodV0->GetMultiplicity(iv0);
 
+      if(! fIsAfter2011){
+       if(fAnalysisType == "AOD"){//not for reco MC tracks, only for real data
+         if (iv0 < 32){ // V0C
+           Qxc2 += TMath::Cos(2*phiV0) * multv0*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+           Qyc2 += TMath::Sin(2*phiV0) * multv0*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+           Qxc3 += TMath::Cos(3*phiV0) * multv0*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+           Qyc3 += TMath::Sin(3*phiV0) * multv0*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+         } else {       // V0A
+           Qxa2 += TMath::Cos(2*phiV0) * multv0*fV0Apol/fMultV0->GetBinContent(iv0+1);
+           Qya2 += TMath::Sin(2*phiV0) * multv0*fV0Apol/fMultV0->GetBinContent(iv0+1);
+           Qxa3 += TMath::Cos(3*phiV0) * multv0*fV0Apol/fMultV0->GetBinContent(iv0+1);
+           Qya3 += TMath::Sin(3*phiV0) * multv0*fV0Apol/fMultV0->GetBinContent(iv0+1);
+         }
+       }
+       else{
+         if (iv0 < 32){ // V0C
+           Qxc2 += TMath::Cos(2*phiV0) * multv0;//*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+           Qyc2 += TMath::Sin(2*phiV0) * multv0;//*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+           Qxc3 += TMath::Cos(3*phiV0) * multv0;//*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+           Qyc3 += TMath::Sin(3*phiV0) * multv0;//*fV0Cpol/fMultV0->GetBinContent(iv0+1);
+         } else {       // V0A
+           Qxa2 += TMath::Cos(2*phiV0) * multv0;//*fV0Apol/fMultV0->GetBinContent(iv0+1);
+           Qya2 += TMath::Sin(2*phiV0) * multv0;//*fV0Apol/fMultV0->GetBinContent(iv0+1);
+           Qxa3 += TMath::Cos(3*phiV0) * multv0;//*fV0Apol/fMultV0->GetBinContent(iv0+1);
+           Qya3 += TMath::Sin(3*phiV0) * multv0;//*fV0Apol/fMultV0->GetBinContent(iv0+1);
+         }
+       }
+      }
+    }
+   //grab for each centrality the proper histo with the Qx and Qy to do the recentering
+    Double_t Qxamean2 = fMeanQ[iCcal][1][0];
+    Double_t Qxarms2  = fWidthQ[iCcal][1][0];
+    Double_t Qyamean2 = fMeanQ[iCcal][1][1];
+    Double_t Qyarms2  = fWidthQ[iCcal][1][1];
+    Double_t Qxamean3 = fMeanQv3[iCcal][1][0];
+    Double_t Qxarms3  = fWidthQv3[iCcal][1][0];
+    Double_t Qyamean3 = fMeanQv3[iCcal][1][1];
+    Double_t Qyarms3  = fWidthQv3[iCcal][1][1];
+    
+    Double_t Qxcmean2 = fMeanQ[iCcal][0][0];
+    Double_t Qxcrms2  = fWidthQ[iCcal][0][0];
+    Double_t Qycmean2 = fMeanQ[iCcal][0][1];
+    Double_t Qycrms2  = fWidthQ[iCcal][0][1];  
+    Double_t Qxcmean3 = fMeanQv3[iCcal][0][0];
+    Double_t Qxcrms3  = fWidthQv3[iCcal][0][0];
+    Double_t Qycmean3 = fMeanQv3[iCcal][0][1];
+    Double_t Qycrms3  = fWidthQv3[iCcal][0][1];        
+    
+    Double_t QxaCor2 = (Qxa2 - Qxamean2)/Qxarms2;
+    Double_t QyaCor2 = (Qya2 - Qyamean2)/Qyarms2;
+    Double_t QxcCor2 = (Qxc2 - Qxcmean2)/Qxcrms2;
+    Double_t QycCor2 = (Qyc2 - Qycmean2)/Qycrms2;
+    Double_t QxaCor3 = (Qxa3 - Qxamean3)/Qxarms3;
+    Double_t QyaCor3 = (Qya3 - Qyamean3)/Qyarms3;
+    Double_t QxcCor3 = (Qxc3 - Qxcmean3)/Qxcrms3;
+    Double_t QycCor3 = (Qyc3 - Qycmean3)/Qycrms3;
+    /*
+    //to calculate 2nd order event plane with v0M
+ Double_t QxCor2 = (Qxa2 - Qxamean2 + Qxc2 - Qxcmean2)
+    /TMath::Sqrt(Qxarms2*Qxarms2 + Qxcrms2*Qxcrms2);
+  Double_t QyCor2 = (Qya2 - Qyamean2 + Qyc2 - Qycmean2)
+    /TMath::Sqrt(Qyarms2*Qyarms2 + Qycrms2*Qycrms2);
+
+  //here the calculated event plane is within -Pi to +Pi(delete it , no use here , only for definition)
+  Double_t psiV0A =(TMath::Pi() + TMath::ATan2(-QyaCor2, -QxaCor2))/2.;
+  Double_t psiV0C = (TMath::Pi() + TMath::ATan2(-QycCor2, -QxcCor2))/2.;
+  Double_t psiVZero = (TMath::Pi() + TMath::ATan2(-QyCor2, -QxCor2))/2.;
+
+    */
+
+    Float_t evPlAngV0ACor2=999.;
+    Float_t evPlAngV0CCor2=999.;
+    Float_t evPlAngV0ACor3=999.;
+    Float_t evPlAngV0CCor3=999.;
+
+   if(! fIsAfter2011){
+      if(fAnalysisType == "AOD"){
+       evPlAngV0ACor2 = TMath::ATan2(QyaCor2, QxaCor2)/2.;
+       evPlAngV0CCor2 = TMath::ATan2(QycCor2, QxcCor2)/2.;
+       evPlAngV0ACor3 = TMath::ATan2(QyaCor3, QxaCor3)/3.;
+       evPlAngV0CCor3 = TMath::ATan2(QycCor3, QxcCor3)/3.;
+      }
+      else{
+       evPlAngV0ACor2 = TMath::ATan2(Qya2, Qxa2)/2.;
+       evPlAngV0CCor2 = TMath::ATan2(Qyc2, Qxc2)/2.;
+       evPlAngV0ACor3 = TMath::ATan2(Qya3, Qxa3)/3.;
+       evPlAngV0CCor3 = TMath::ATan2(Qyc3, Qxc3)/3.;
+      }
+    }
+    else{
+      AliEventplane *ep =  event->GetEventplane();
+      evPlAngV0ACor2 = ep->GetEventplane("V0A", event, 2);
+      evPlAngV0CCor2 = ep->GetEventplane("V0C", event, 2);
+      evPlAngV0ACor3 = ep->GetEventplane("V0A", event, 3);
+      evPlAngV0CCor3 = ep->GetEventplane("V0C", event, 3);
+    }
 
-if(fSampleType=="pPb" || fSampleType=="PbPb") if (cent_v0 < 0)  return;//for pp case it is the multiplicity
+    fgPsi2v0a = evPlAngV0ACor2;
+    fgPsi2v0c = evPlAngV0CCor2;
+    fgPsi3v0a = evPlAngV0ACor3;
+    fgPsi3v0c = evPlAngV0CCor3;
 
+ // Fill EP distribution histograms evPlAng
+    
+     fPhiRPv0A->Fill(iC,evPlAngV0ACor2);
+     fPhiRPv0C->Fill(iC,evPlAngV0CCor2);
+    
+     fPhiRPv0Av3->Fill(iC,evPlAngV0ACor3);
+     fPhiRPv0Cv3->Fill(iC,evPlAngV0CCor3);
 
+    // Fill histograms needed for resolution evaluation
+    fHResTPCv0A2->Fill(Double_t(iC), TMath::Cos(2*(evPlAng2 - evPlAngV0ACor2)));
+    fHResTPCv0C2->Fill(Double_t(iC), TMath::Cos(2*(evPlAng2 - evPlAngV0CCor2)));
+    fHResv0Cv0A2->Fill(Double_t(iC), TMath::Cos(2*(evPlAngV0ACor2 - evPlAngV0CCor2)));
+    
+    fHResTPCv0A3->Fill(Double_t(iC), TMath::Cos(3*(evPlAng3 - evPlAngV0ACor3)));
+    fHResTPCv0C3->Fill(Double_t(iC), TMath::Cos(3*(evPlAng3 - evPlAngV0CCor3)));
+    fHResv0Cv0A3->Fill(Double_t(iC), TMath::Cos(3*(evPlAngV0ACor3 - evPlAngV0CCor3)));
 
- Float_t bSign = (aod->GetMagneticField() > 0) ? 1 : -1;//for two track efficiency cut in correlation function calculation
- Float_t bSign1=aod->GetHeader()->GetMagneticField() ;//for dca cut in ClassifyTrack(), i.e in track loop
 
-// Pileup selection ************************************************
- if(frejectPileUp)  //applicable only for TPC only tracks,not for hybrid tracks?.
-      {
- if (fAnalysisUtils && fAnalysisUtils->IsPileUpEvent(aod)) return;
-//count events after PileUP cut
-   fEventCounter->Fill(3);
-  }
+    /*   
+ Float_t gVZEROEventPlane    = -10.;
+  Float_t gReactionPlane      = -10.;
+  Double_t qxTot = 0.0, qyTot = 0.0;
 
+    AliEventplane *ep = event->GetEventplane();
+    if(ep){ 
+      gVZEROEventPlane = ep->CalculateVZEROEventPlane(event,10,2,qxTot,qyTot);
+      if(gVZEROEventPlane < 0.) gVZEROEventPlane += TMath::Pi();
+      //gReactionPlane = gVZEROEventPlane*TMath::RadToDeg();
+      gReactionPlane = gVZEROEventPlane;
+    }
+    */
+  }//AOD,ESD,ESDMC
+ //return gReactionPlane;
+
+ //make the final 2nd order event plane within 0 to Pi
+     //using data and reco tracks only
+      if(fgPsi2v0a!=999. && fgPsi2v0a < 0.) fgPsi2v0a += TMath::Pi();
+      if(fgPsi2v0c!=999. && fgPsi2v0c < 0.) fgPsi2v0c += TMath::Pi();
+      if(fgPsi2tpc!=999. && fgPsi2tpc < 0.) fgPsi2tpc += TMath::Pi();
+      //using truth tracks only
+      if(evplaneMC!=999. && evplaneMC < 0.) evplaneMC += TMath::Pi();
+      if(fgPsi2v0aMC!=999. && fgPsi2v0aMC < 0.) fgPsi2v0aMC += TMath::Pi();
+      if(fgPsi2v0cMC!=999. && fgPsi2v0cMC < 0.) fgPsi2v0cMC += TMath::Pi();
+      if(fgPsi2tpcMC!=999. && fgPsi2tpcMC < 0.) fgPsi2tpcMC += TMath::Pi();
+      //for the time being leave the 3rd order event planes within -pi/3 t0 +pi/3
+
+      if(truth){//for truth MC
+       if(fV2 && fEPdet=="header")gReactionPlane=evplaneMC;
+       if(fV2 && fEPdet=="V0A")gReactionPlane=fgPsi2v0aMC;
+       if(fV2 && fEPdet=="V0C")gReactionPlane=fgPsi2v0cMC;
+       if(fV2 && fEPdet=="TPC")gReactionPlane=fgPsi2tpcMC;
+
+       if(fV3 && fEPdet=="V0A")gReactionPlane=fgPsi3v0aMC;
+       if(fV3 && fEPdet=="V0C")gReactionPlane=fgPsi3v0cMC;
+       if(fV3 && fEPdet=="TPC")gReactionPlane=fgPsi3tpcMC;
+}
+      else{//for data and recoMC
+       if(fV2 && fEPdet=="V0A")gReactionPlane=fgPsi2v0a;
+       if(fV2 && fEPdet=="V0C")gReactionPlane=fgPsi2v0c;
+       if(fV2 && fEPdet=="TPC")gReactionPlane=fgPsi2tpc;
 
- //vertex selection(is it fine for PP?)
- if ( fVertextype==1){//for pPb basically if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return; 
-  trkVtx = aod->GetPrimaryVertex();
-  if (!trkVtx || trkVtx->GetNContributors()<=0) return;
-  TString vtxTtl = trkVtx->GetTitle();
-  if (!vtxTtl.Contains("VertexerTracks")) return;
-   zvtx = trkVtx->GetZ();
-  const AliAODVertex* spdVtx = aod->GetPrimaryVertexSPD();
-  if (!spdVtx || spdVtx->GetNContributors()<=0) return;
-  TString vtxTyp = spdVtx->GetTitle();
-  Double_t cov[6]={0};
-  spdVtx->GetCovarianceMatrix(cov);
-  Double_t zRes = TMath::Sqrt(cov[5]);
-  if (vtxTyp.Contains("vertexer:Z") && (zRes>0.25)) return;
-   if (TMath::Abs(spdVtx->GetZ() - trkVtx->GetZ())>0.5) return;
-  }
-  else if(fVertextype==2) {//for pp and pb-pb case , taken from Jan's code
-       Int_t nVertex = aod->GetNumberOfVertices();
-       if( nVertex > 0 ) { 
-     trkVtx = aod->GetPrimaryVertex();
-               Int_t nTracksPrim = trkVtx->GetNContributors();
-                 zvtx = trkVtx->GetZ();
-               //if (fDebug > 1)AliInfo(Form(" Vertex in = %f with %d particles by  %s data ...",zVertex,nTracksPrim,vertex->GetName()));
-               // Reject TPC only vertex
-               TString name(trkVtx->GetName());
-               if (name.CompareTo("PrimaryVertex") && name.CompareTo("SPDVertex"))return;
+       if(fV3 && fEPdet=="V0A")gReactionPlane=fgPsi3v0a;
+       if(fV3 && fEPdet=="V0C")gReactionPlane=fgPsi3v0c;
+       if(fV3 && fEPdet=="TPC")gReactionPlane=fgPsi3tpc;
 
-               // Select a quality vertex by number of tracks?
-               if( nTracksPrim < fnTracksVertex ) {
-                 //if (fDebug > 1) AliInfo(" Primary-vertex Selection: event REJECTED ...");
-                       return ;
-                       }
-               // TODO remove vertexer Z events with dispersion > 0.02: Doesn't work for AOD at present
-                //if (strcmp(vertex->GetTitle(), "AliVertexerZ") == 0 && vertex->GetDispersion() > 0.02)
-                //  return kFALSE;
-               //      if (fDebug > 1) AliInfo(" Primary-vertex Selection: event ACCEPTED...");
-       }
-       else return;
+      }
+     
+ } //centrality cut condition
 
-  }
- else if(fVertextype==0){//default case
-  trkVtx = aod->GetPrimaryVertex();
-  if (!trkVtx || trkVtx->GetNContributors()<=0) return;//proper number of contributors
-  zvtx = trkVtx->GetZ();
-  Double32_t fCov[6];
-  trkVtx->GetCovarianceMatrix(fCov);
-  if(fCov[5] == 0) return;//proper vertex resolution
-  }
-  else {
-   AliInfo("Wrong Vertextype set for Primary-vertex Selection: event REJECTED ...");
-   return;//as there is no proper sample type
-  }
+return gReactionPlane;
+}
+//------------------------------------------------------------------------------------------------------------------
+void AliTwoParticlePIDCorr::OpenInfoCalbration(Int_t run){
+    TString oadbfilename = "$ALICE_ROOT/OADB/PWGCF/VZERO/VZEROcalibEP.root";
+    TFile *foadb = TFile::Open(oadbfilename.Data());
+
+    if(!foadb){
+       printf("OADB file %s cannot be opened\n",oadbfilename.Data());
+       return;
+    }
 
-  fHistQA[0]->Fill((trkVtx->GetX()));fHistQA[1]->Fill((trkVtx->GetY()));fHistQA[2]->Fill((trkVtx->GetZ())); //for trkVtx only before vertex cut |zvtx|<10 cm
+    AliOADBContainer *cont = (AliOADBContainer*) foadb->Get("hMultV0BefCorr");
+    if(!cont){
+       printf("OADB object hMultV0BefCorr is not available in the file\n");
+       return; 
+    }
 
-//count events having a proper vertex
-   fEventCounter->Fill(5);
+    if(!(cont->GetObject(run))){
+       printf("OADB object hMultV0BefCorr is not available for run %i (used run 137366)\n",run);
+       run = 137366;
+    }
+    fMultV0 = ((TH2F *) cont->GetObject(run))->ProfileX();
+
+    TF1 *fpol0 = new TF1("fpol0","pol0"); 
+    fMultV0->Fit(fpol0,"","",0,31);
+    fV0Cpol = fpol0->GetParameter(0);
+    fMultV0->Fit(fpol0,"","",32,64);
+    fV0Apol = fpol0->GetParameter(0);
+
+    for(Int_t iside=0;iside<2;iside++){
+       for(Int_t icoord=0;icoord<2;icoord++){
+           for(Int_t i=0;i  < 9;i++){
+               char namecont[100];
+               if(iside==0 && icoord==0)
+                 snprintf(namecont,100,"hQxc2_%i",i);
+               else if(iside==1 && icoord==0)
+                 snprintf(namecont,100,"hQxa2_%i",i);
+               else if(iside==0 && icoord==1)
+                 snprintf(namecont,100,"hQyc2_%i",i);
+               else if(iside==1 && icoord==1)
+                 snprintf(namecont,100,"hQya2_%i",i);
+
+               cont = (AliOADBContainer*) foadb->Get(namecont);
+               if(!cont){
+                   printf("OADB object %s is not available in the file\n",namecont);
+                   return;     
+               }
+               
+               if(!(cont->GetObject(run))){
+                   printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);
+                   run = 137366;
+               }
+               fMeanQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();
+               fWidthQ[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();
+
+               //for v3
+               if(iside==0 && icoord==0)
+                 snprintf(namecont,100,"hQxc3_%i",i);
+               else if(iside==1 && icoord==0)
+                 snprintf(namecont,100,"hQxa3_%i",i);
+               else if(iside==0 && icoord==1)
+                 snprintf(namecont,100,"hQyc3_%i",i);
+               else if(iside==1 && icoord==1)
+                 snprintf(namecont,100,"hQya3_%i",i);
+
+               cont = (AliOADBContainer*) foadb->Get(namecont);
+               if(!cont){
+                   printf("OADB object %s is not available in the file\n",namecont);
+                   return;     
+               }
+               
+               if(!(cont->GetObject(run))){
+                   printf("OADB object %s is not available for run %i (used run 137366)\n",namecont,run);
+                   run = 137366;
+               }
+               fMeanQv3[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetMean();
+               fWidthQv3[i][iside][icoord] = ((TH1F *) cont->GetObject(run))->GetRMS();
 
- if (TMath::Abs(zvtx) > fzvtxcut) return;
+           }
+       }
+    }
+}
+//____________________________________________________________________
+void AliTwoParticlePIDCorr::FillPIDEventPlane(Double_t centrality,Int_t par,Float_t trigphi,Float_t fReactionPlane) 
+{
 
-//count events after vertex cut
-  fEventCounter->Fill(7);
+ // Event plane (determine psi bin)
+    Double_t gPsiMinusPhi    =   0.;
+    Double_t gPsiMinusPhiBin = -10.;
+if(fRequestEventPlane){
+    gPsiMinusPhi   = TMath::Abs(trigphi - fReactionPlane);
+    //in-plane
+    if((gPsiMinusPhi <= 7.5*TMath::DegToRad())||
+      (gPsiMinusPhi >= 352.5*TMath::DegToRad())||
+       ((172.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 187.5*TMath::DegToRad())))
+      gPsiMinusPhiBin = 0.0;
+    //intermediate
+    else if(((37.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 52.5*TMath::DegToRad()))||
+           ((127.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 142.5*TMath::DegToRad()))||
+           ((217.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 232.5*TMath::DegToRad()))||
+           ((307.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 322.5*TMath::DegToRad())))
+      gPsiMinusPhiBin = 1.0;
+    //out of plane
+    else if(((82.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 97.5*TMath::DegToRad()))||
+           ((262.5*TMath::DegToRad() <= gPsiMinusPhi)&&(gPsiMinusPhi <= 277.5*TMath::DegToRad())))
+      gPsiMinusPhiBin = 2.0;
+    //everything else
+    else 
+      gPsiMinusPhiBin = 3.0;
 
+    fEventPlanePID->Fill(centrality,gPsiMinusPhiBin,(Float_t)par); 
+ }
+}
 
- //if(!fAnalysisUtils->IsVertexSelected2013pA(aod)) return;
+//----------------------------------------------------------
+void AliTwoParticlePIDCorr::Terminate(Option_t *) 
+{
+  // Draw result to screen, or perform fitting, normalizations
+  // Called once at the end of the query
+  fOutput = dynamic_cast<TList*> (GetOutputData(1));
+  if(!fOutput) { Printf("ERROR: could not retrieve TList fOutput"); return; }
   
- fHistQA[3]->Fill((trkVtx->GetX()));fHistQA[4]->Fill((trkVtx->GetY()));fHistQA[5]->Fill((trkVtx->GetZ()));//after vertex cut,for trkVtx only
-
-
- if(!aod) return; //for safety
-
- Double_t frefMult=0;
-
-//reference multiplicity for pp 7 TeV
- if ((fMultiplicityEstimator == "TRACKS_MANUAL") || (fMultiplicityEstimator == "V0M_MANUAL")|| (fMultiplicityEstimator == "V0A_MANUAL")||(fMultiplicityEstimator == "V0C_MANUAL")) {cent_v0=GetReferenceMultiplicityVZEROFromAOD(aod,bSign1);}
- else {frefMult=GetReferenceMultiplicityVZEROFromAOD(aod,bSign1);}
-
   
-// centrality weighting (optional for 2011 if central and semicentral triggers are used)
- if (fCentralityWeights && !AcceptEventCentralityWeight(cent_v0))
-  {
-    AliInfo(Form("Rejecting event because of centrality weighting: %f", cent_v0));
-    return;
-  }
-
-//count events after rejection due to centrality weighting
-  fEventCounter->Fill(9);
-*/
+}
+//------------------------------------------------------------------ 
index 3836d6074fa5bdd24ce06d7206c80b3bc38c525b..6dbb32cc484a71e9bd98dc6d69cd86ebacde7a26 100644 (file)
@@ -26,6 +26,7 @@ class AliCFContainer;
 class AliCFGridSparse;
 class THnBase;
 class AliTHn;
+class TProfile;
 
 
 #include <TObject.h> //LRCParticlePID is a derived class from"TObject"
@@ -113,7 +114,13 @@ class AliTwoParticlePIDCorr : public AliAnalysisTaskSE {
     void SetMaxNofMixingTracks(Int_t MaxNofMixingTracks) {fMaxNofMixingTracks=MaxNofMixingTracks;}               //Check it every time
   void SetCentralityEstimator(TString CentralityMethod) { fCentralityMethod = CentralityMethod;}
   void SetSampleType(TString SampleType) {fSampleType=SampleType;}
-  void SetRequestEventPlane(Bool_t RequestEventPlane){fRequestEventPlane=RequestEventPlane;}
+  void SetRequestEventPlane(Bool_t RequestEventPlane,Bool_t V2,Bool_t V3,TString EPdetector,Bool_t IsAfter2011){
+fRequestEventPlane=RequestEventPlane;
+fV2=V2;
+fV3=V3;
+fEPdet=EPdetector;
+fIsAfter2011=IsAfter2011;
+}
   void SetAnalysisType(TString AnalysisType){fAnalysisType=AnalysisType;}
   void SetFilterBit(Int_t FilterBit) {fFilterBit=FilterBit;}
   void SetTrackStatus(UInt_t status) { fTrackStatus = status; }
@@ -217,10 +224,31 @@ fPtTOFPIDmax=PtTOFPIDmax;
 
  void SetEffcorectionfilePathName(TString efffilename) {fefffilename=efffilename;}
  
- private:
+
+  //set cut on beyesian probability
+  void SetBayesCut(Double_t cut){fBayesCut=cut;}
+  void SetdiffPIDcutvalues(Bool_t diffPIDcutvalues,Double_t PIDCutval1, Double_t PIDCutval2, Double_t PIDCutval3,Double_t PIDCutval4){
+    fdiffPIDcutvalues=diffPIDcutvalues;
+    fPIDCutval1=PIDCutval1;
+    fPIDCutval2=PIDCutval2;
+    fPIDCutval3=PIDCutval3;
+    fPIDCutval4=PIDCutval4;
+  }
+ void  SetRandomizeReactionPlane(Bool_t RandomizeReactionPlane){fRandomizeReactionPlane=RandomizeReactionPlane;}
+   //****************************************************************************************EP related part
+  void OpenInfoCalbration(Int_t run);
+  void SetTPCclusterN(Int_t ncl){fNcluster=ncl;};
+   //****************************************************************************************EP related part
+
+
+ private:                                                                                      
  //histograms
     TList *fOutput;        //! Output list
     TList *fOutputList;        //! Output list
+    TList *fList;              //! List for output objects
+
 
     TString    fCentralityMethod;     // Method to determine centrality
     TString    fSampleType;     // pp,p-Pb,Pb-Pb
@@ -317,9 +345,61 @@ fPtTOFPIDmax=PtTOFPIDmax;
     TH2F *fHistVZEROCvsVZEROAmultiplicity;//!
     TH2F *fHistEQVZEROCvsEQVZEROAmultiplicity;//!
     TH2F *fHistVZEROSignal;//!
-    TH2F *fHistEventPlaneReco;//!
     TH2F *fHistEventPlaneTruth;//!
     TH2D *fHistPsiMinusPhi;//! psi - phi QA histogram
+    TH3F *fEventPlanePID;//!
+   //****************************************************************************************EP related part
+
+    Float_t evplaneMC,fgPsi2v0a,fgPsi2v0c,fgPsi2tpc; // current Psi2
+   Float_t fgPsi3v0a,fgPsi3v0c,fgPsi3tpc; // current Psi3
+   Float_t fgPsi2v0aMC,fgPsi2v0cMC,fgPsi2tpcMC; // current Psi2
+   Float_t fgPsi3v0aMC,fgPsi3v0cMC,fgPsi3tpcMC,gReactionPlane; // current Psi3
+  Bool_t fV2; // switch to set the harmonics
+  Bool_t fV3; // switch to set the harmonics
+  Bool_t fIsAfter2011; // switch for 2011 and later runs
+
+  //    Int_t nCentrBin = 9;          //  cenrality bins
+
+  //
+  // Cuts and options
+  //
+
+  Int_t fRun;                       // current run checked to load VZERO calibrations
+
+  Int_t fNcluster;           // Numer of TPC cluster required
+
+  TString fEPdet; //Set the name of the event plane to be used to reconstruct the event plane
+    
+  // Output objects
+  TProfile *fMultV0;                //! object containing VZERO calibration information
+  Float_t fV0Cpol;          //! loaded by OADB
+  Float_t fV0Apol;          //! loaded by OADB
+  Float_t fMeanQ[9][2][2];           // and recentering
+  Float_t fWidthQ[9][2][2];          // ...
+  Float_t fMeanQv3[9][2][2];         // also for v3
+  Float_t fWidthQv3[9][2][2];        // ...
+
+  TProfile *fHResTPCv0A2;   //! TProfile for subevent resolution (output)
+  TProfile *fHResTPCv0C2;   //! TProfile for subevent resolution (output)
+  TProfile *fHResv0Cv0A2;   //! TProfile for subevent resolution (output)
+  TProfile *fHResTPCv0A3;    //! also for v3
+  TProfile *fHResTPCv0C3;   //! also for v3
+  TProfile *fHResv0Cv0A3;   //! also for v3
+
+ TProfile *fHResMA2;   //! TProfile for subevent resolution (output)
+  TProfile *fHResMC2;   //! TProfile for subevent resolution (output)
+  TProfile *fHResAC2;   //! TProfile for subevent resolution (output)
+  TProfile *fHResMA3;    //! also for v3
+  TProfile *fHResMC3;   //! also for v3
+  TProfile *fHResAC3;   //! also for v3
+
+  TH2F *fPhiRPTPC;          //! EP distribution vs. centrality (v2)
+  TH2F *fPhiRPTPCv3;          //! EP distribution vs. centrality (v2)
+  TH2F *fPhiRPv0A;          //! EP distribution vs. centrality (v2)
+  TH2F *fPhiRPv0C;          //! EP distribution vs. centrality (v2)
+  TH2F *fPhiRPv0Av3;      //! EP distribution vs. centrality (v3)
+  TH2F *fPhiRPv0Cv3;      //! EP distribution vs. centrality (v3)
+    //****************************************************************************************EP related part
 
     TH2F* fControlConvResoncances; //! control histograms for cuts on conversions and resonances
 
@@ -339,7 +419,7 @@ fPtTOFPIDmax=PtTOFPIDmax;
     TH1F *fProtonPhi;//!
     // TH3F *fHistocentNSigmaTPC;//! nsigma TPC
     // TH3F *fHistocentNSigmaTOF;//! nsigma TOF 
-    
     AliTHn *fCorrelatonTruthPrimary;//!
     AliTHn *fCorrelatonTruthPrimarymix;//!
     AliTHn *fTHnCorrUNID;//!
@@ -353,7 +433,7 @@ fPtTOFPIDmax=PtTOFPIDmax;
     AliTHn* fTrackHistEfficiency[6]; //! container for tracking efficiency and contamination (all particles filled including leading one): axes: eta, pT, particle species:::::::::0 pion, 1 kaon,2 proton,3 mesons,4 kaons+protons,5 all
 
     
-    TH1F *fHistQA[16]; //!                  gReactionPlane
+    TH1F *fHistQA[16]; //!                  
      
    
     THnSparse *effcorection[6];//!
@@ -363,16 +443,18 @@ fPtTOFPIDmax=PtTOFPIDmax;
   Double_t* GetBinning(const char* configuration, const char* tag, Int_t& nBins);
 
 
-  void Fillcorrelation(Double_t gReactionPlane,TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t weight,Bool_t firstTime,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup);//mixcase=kTRUE in case of mixing; 
+  void Fillcorrelation(Float_t ReactionPlane,TObjArray *trackstrig,TObjArray *tracksasso,Double_t cent,Float_t vtx,Float_t weight,Bool_t firstTime,Float_t bSign,Bool_t fPtOrder,Bool_t twoTrackEfficiencyCut,Bool_t mixcase,TString fillup);//mixcase=kTRUE in case of mixing; 
  Float_t GetTrackbyTrackeffvalue(AliAODTrack* track,Double_t cent,Float_t evzvtx, Int_t parpid);
 
+ //Fill PID and Event planes
+ void FillPIDEventPlane(Double_t centrality,Int_t par,Float_t trigphi,Float_t fReactionPlane);
+
 //Mixing functions
-  void DefineEventPool();
// void DefineEventPool();
   AliEventPoolManager    *fPoolMgr;//! 
   TClonesArray          *fArrayMC;//!
   TString          fAnalysisType;          // "MC", "ESD", "AOD"
   TString fefffilename;
-
     //PID part histograms
 
   //PID functions
@@ -395,16 +477,7 @@ fPtTOFPIDmax=PtTOFPIDmax;
   //set PID Combined
   void SetPIDCombined(AliPIDCombined *obj){fPIDCombined=obj;}
   AliPIDCombined *GetPIDCombined(){return fPIDCombined;}
-  //set cut on beyesian probability
-  void SetBayesCut(Double_t cut){fBayesCut=cut;}
-  void SetdiffPIDcutvalues(Bool_t diffPIDcutvalues,Double_t PIDCutval1, Double_t PIDCutval2, Double_t PIDCutval3,Double_t PIDCutval4){
-    fdiffPIDcutvalues=diffPIDcutvalues;
-    fPIDCutval1=PIDCutval1;
-    fPIDCutval2=PIDCutval2;
-    fPIDCutval3=PIDCutval3;
-    fPIDCutval4=PIDCutval4;
-  }
- void  SetRandomizeReactionPlane(Bool_t RandomizeReactionPlane){fRandomizeReactionPlane=RandomizeReactionPlane;}
   Double_t GetBayesCut(){return fBayesCut;}
   Int_t GetIDBayes(AliAODTrack *trk, Bool_t FIllQAHistos);//calculate the PID according to bayesian PID
   UInt_t CalcPIDCombined(AliAODTrack *track,Int_t detMask, Double_t* prob) const;
@@ -468,7 +541,7 @@ Float_t GetInvMassSquaredCheap(Float_t pt1, Float_t eta1, Float_t phi1, Float_t
   Bool_t AcceptEventCentralityWeight(Double_t centrality);
 
   //get event plane
-  Double_t GetEventPlane(AliAODEvent *event,Bool_t truth);
+  Float_t GetEventPlane(AliAODEvent *event,Bool_t truth,Double_t v0Centr);
   Double_t GetAcceptedEventMultiplicity(AliAODEvent *aod,Bool_t truth);//returns centrality after event(mainly vertex) selection IsEventAccepted  GetAcceptedEventMultiplicity
   
   //get vzero equalization
index 1a45b5c489dbfe75fa29dd69ea5a82e3b545b55d..921fcb2b58b78ba0c6f2176fa721290e3ff71436 100644 (file)
@@ -9,7 +9,10 @@ AliAnalysisTask*  AddAliTwoParticlePIDCorrTask(TString  SampleType="pPb",//pp,pP
                                               const char* outputFileName = 0,
                                               const char* containerName = "TwoParticlePIDCorr",
                                               const char* QAContainername = "TwoParticlePIDCorr_PIDQA",
-                                              const char* folderName = "PWGCF_TwoParticlePIDCorr"
+                                              const char* folderName = "PWGCF_TwoParticlePIDCorr",
+                                              Bool_t RequestEventPlane=kFALSE,
+                                              const char* EPContainername = "TwoParticlePIDCorr_EP"
+
 )
 {
 
@@ -50,10 +53,13 @@ AliAnalysisTask*  AddAliTwoParticlePIDCorrTask(TString  SampleType="pPb",//pp,pP
 
   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(QAContainername, TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:%s", outputFileName, folderName));
 
+  if(RequestEventPlane==kTRUE) AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(EPContainername, TList::Class(),AliAnalysisManager::kOutputContainer,Form("%s:%s", outputFileName, folderName));
+
   
   mgr->ConnectInput  (PIDCorr, 0, mgr->GetCommonInputContainer());
   mgr->ConnectOutput (PIDCorr, 1, coutput1 );
   mgr->ConnectOutput (PIDCorr, 2, coutput2 );
+if(RequestEventPlane==kTRUE)  mgr->ConnectOutput (PIDCorr, 3, coutput3 );
 
   return PIDCorr;
 }