Introduce Jason's correlation analysis to JCORRAN, add configuration macros and plott...
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 31 Aug 2010 13:52:06 +0000 (13:52 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 31 Aug 2010 13:52:06 +0000 (13:52 +0000)
PWG4/JCORRAN/AliAnalysisTaskDiHadron.cxx [new file with mode: 0755]
PWG4/JCORRAN/AliAnalysisTaskDiHadron.h [new file with mode: 0755]
PWG4/PWG4JCORRANLinkDef.h
PWG4/libPWG4JCORRAN.pkg
PWG4/macros/AddTaskDiHadron.C [new file with mode: 0755]
PWG4/macros/jcorran/Draw3Particle.C [new file with mode: 0755]
PWG4/macros/jcorran/DrawDPhi.C [new file with mode: 0755]
PWG4/macros/jcorran/DrawSpectra.C [new file with mode: 0755]
PWG4/macros/jcorran/SingleEff.C [new file with mode: 0755]
PWG4/macros/jcorran/Util.C [new file with mode: 0755]

diff --git a/PWG4/JCORRAN/AliAnalysisTaskDiHadron.cxx b/PWG4/JCORRAN/AliAnalysisTaskDiHadron.cxx
new file mode 100755 (executable)
index 0000000..bd07fb1
--- /dev/null
@@ -0,0 +1,1205 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+//2- and 3-particle trigger particle correlation analysis
+//Author: Jason Glyndwr Ulery, ulery@uni-frankfurt.de
+
+
+#include "Riostream.h"
+#include "TChain.h"
+#include "TTree.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TH3F.h"
+#include "TFormula.h"
+#include "TF1.h"
+#include "TF2.h"
+#include "TF3.h"
+#include "TVector3.h"
+#include "TMath.h"
+
+
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+
+#include "AliESDEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliMCEvent.h"
+#include "AliMCEventHandler.h"
+#include "AliMCParticle.h"
+#include "AliStack.h"
+#include "AliESDVertex.h"
+#include "AliMultiplicity.h"
+#include "TParticle.h"
+
+
+//#include "AliHeader.h"
+//#include "AliGenEventHeader.h"
+
+
+
+#include "AliAnalysisTaskDiHadron.h"
+
+
+ClassImp(AliAnalysisTaskDiHadron)
+
+//----------------------------------------
+AliAnalysisTaskDiHadron::AliAnalysisTaskDiHadron(const char *name):
+AliAnalysisTask(name,""), fESD(0), fMC(0), fOutput(0),fMinClustersTPC(0),fMinClusterRatio(0),fMaxTPCchi2(0),fMinClustersITS(0),fEtaCut(0),fTrigEtaCut(0),fNearPhiCut(0),fXECut(0),fMaxDCA(0),fMaxDCAXY(0),fMaxDCAZ(0),fDCA2D(0),fTPCRefit(0),fITSRefit(0),fSPDCut(0),fMinPtAssoc(0),fMaxPtAssoc(0),fVzCut(0),fEfficiencyCorr(0),DEBUG(0),fnBinPhi(0),fnBinEta(0),fnBinPhiEtaPhi(0),fnBinPhiEtaEta(0),fnBinPhi3(0),fnBinEta3(0),fPi(3.1415926535898),fdPhiMin(0),fdPhiMax(0),fNTPtBins(0),fNMix(0),fNCentBins(0),fNAPtBins(0),fNAPt3Bins(0),fNVertexBins(0),fNXEBins(0),fNIDs(0),fEffFitPt(0),fNFitLowParam(0),fNFitHighParam(0),fMCHistos(0),fNFitLow(0),fNFitHigh(0),fFitLow(NULL),fFitHigh(NULL),fFitLowParam(NULL),fFitHighParam(NULL),fPtTrigArray(NULL),fPtAssocArray(NULL),fPtAssoc3Array1(NULL),fPtAssoc3Array2(NULL),fCentArrayMin(NULL),fCentArrayMax(NULL),fXEArray(NULL),fTrigIDArray(NULL),tPhi(NULL),tEta(NULL),tPt(NULL),tCharge(NULL),tEff(NULL),tPtAssoc3(NULL),tNPtAssoc3(NULL)
+  
+  {
+  //IO Slots
+  DefineInput(0, TChain::Class());
+  DefineOutput(0,TList::Class());
+  
+  
+  for(int c=0;c<fNCentBins;c++){
+    for(int v=0;v<fNVertexBins;v++){
+      for(int jmc=0;jmc<2;jmc++){
+       fMixPointer[c][v][jmc]=-1;
+       fMixEnd[c][v][jmc]=-1;
+       for(int ievts=0;ievts<fNMix;ievts++){
+         fMPt[ievts][c][v][jmc]=NULL;
+         fMPhi[ievts][c][v][jmc]=NULL;
+         fMEta[ievts][c][v][jmc]=NULL;
+         for(int dd=0;dd<10;dd++)fMPtAssoc3[ievts][c][v][jmc][dd]=NULL;
+         fMNPtAssoc3[ievts][c][v][jmc]=NULL;
+         fMixTrack[ievts][c][v][jmc]=0;
+       }
+      }
+    }
+  }
+  // tPhi=NULL;
+  //  tEta=NULL;
+  // tPt=NULL;
+
+  //fPi=3.1415926535898;
+
+
+  }
+//--------------------------------------
+void AliAnalysisTaskDiHadron::SetCuts(Int_t MinClustersTPC,  Float_t MinClusterRatio, Float_t MaxTPCchi2, Int_t MinClustersITS, Float_t EtaCut, Float_t TrigEtaCut, Float_t NearPhiCut, Float_t XECut, Float_t MaxDCA, Float_t MaxDCAXY, Float_t MaxDCAZ, Int_t DCA2D, Int_t TPCRefit, Int_t ITSRefit, Int_t SPDCut, Float_t MinPtAssoc, Float_t MaxPtAssoc, Float_t VzCut, Int_t NIDs, char **TrigIDArray){
+  fMinClustersTPC=MinClustersTPC;
+  fMinClusterRatio=MinClusterRatio;
+  fMaxTPCchi2=MaxTPCchi2;
+  fMinClustersITS=MinClustersITS;
+  fEtaCut=EtaCut;
+  fTrigEtaCut=TrigEtaCut;
+  fNearPhiCut=NearPhiCut;
+  fXECut=XECut;
+  fMaxDCA=MaxDCA;
+  fMaxDCAXY=MaxDCAXY;
+  fMaxDCAZ=MaxDCAZ;
+  fDCA2D=DCA2D;
+  fTPCRefit=TPCRefit;
+  fITSRefit=ITSRefit;
+  fSPDCut=SPDCut;
+  fMinPtAssoc=MinPtAssoc;
+  fMaxPtAssoc=MaxPtAssoc;
+  fVzCut=VzCut;
+  fNIDs=NIDs;
+   fTrigIDArray=(char**)TrigIDArray;
+
+   //  Printf("TPC%d R%2.1f Chi%2.1f ITS%d Eta%2.1f Near%2.1f NearX%2.1f DCA%2.1f DCAR%2.1f DCAZ%2.1f DCAM%d TPCFit%d ITSFit%d SPD%d MinPt%2.1f MaxPt%2.1f Vz%2.1f Trig_%s",fMinClustersTPC,fMinClusterRatio,fMaxTPCchi2,fMinClustersITS,fEtaCut,fNearPhiCut,fXECut,fMaxDCA,fMaxDCAXY,fMaxDCAZ,fDCA2D,fTPCRefit,fITSRefit,fSPDCut,fMinPtAssoc,fMaxPtAssoc,fVzCut,fTrigIDArray[0]);
+}
+//--------------------------------------------------------
+void AliAnalysisTaskDiHadron::SetOptions(Int_t EfficiencyCorr, Int_t fDEBUG,  Int_t MCHistos){
+  fEfficiencyCorr=EfficiencyCorr;
+  DEBUG=fDEBUG;
+  fMCHistos=MCHistos;
+  //Printf("Eff%d DEBUG%d MCHistos%d",fEfficiencyCorr,DEBUG,fMCHistos);
+}
+//------------------------------------------------------
+void AliAnalysisTaskDiHadron::SetBins(Int_t nBinPhi, Int_t nBinEta, Int_t nBinPhiEtaPhi, Int_t nBinPhiEtaEta, Int_t nBinPhi3, Int_t nBinEta3,Float_t dPhiMin, Float_t dPhiMax, Int_t NTPtBins, Int_t NMixBins, Int_t NCentBins,Int_t NAPtBins, Int_t NAPt3Bins, Int_t NVertexBins, Int_t NXEBins,Float_t *PtTrigArray, Float_t *PtAssocArray,Float_t *PtAssoc3Array1, Float_t *PtAssoc3Array2, Int_t *CentArrayMin, Int_t *CentArrayMax, Float_t *XEArray){
+  fnBinPhi=nBinPhi;
+  fnBinEta=nBinEta;
+  fnBinPhiEtaPhi=nBinPhiEtaPhi;
+  fnBinPhiEtaEta=nBinPhiEtaEta;
+  fnBinPhi3=nBinPhi3;
+  fnBinEta3=nBinEta3;
+  fdPhiMin=dPhiMin;
+  fdPhiMax=dPhiMax;
+  fNTPtBins=NTPtBins;
+  fNMix=NMixBins;
+  fNCentBins=NCentBins;
+  fNAPtBins=NAPtBins;
+  fNAPt3Bins=NAPt3Bins;
+  fNVertexBins=NVertexBins;
+  fNXEBins=NXEBins;
+  fPtTrigArray=(Float_t*)PtTrigArray;
+  fPtAssocArray=(Float_t*)PtAssocArray;
+  fPtAssoc3Array1=(Float_t*)PtAssoc3Array1;
+  fPtAssoc3Array2=(Float_t*)PtAssoc3Array2;
+  fCentArrayMin=(Int_t*)CentArrayMin;
+  fCentArrayMax=(Int_t*)CentArrayMax;
+  fXEArray=(Float_t*)XEArray;
+ for(int i=0;i<=fNVertexBins;i++)fVertexArray[i]=(2.*i/fNVertexBins-1)*fVzCut;
+ //Printf("BinPhi%d BinEta%d BinPhiEta%d %d Bin3Phi%d Bin3Eta%d VertexArray%2.1f %2.1f",fnBinPhi,fnBinEta,fnBinPhiEtaPhi,fnBinPhiEtaEta,fnBinPhi3,fnBinEta3,fVertexArray[0],fVertexArray[fNVertexBins]);
+}
+//-------------------------------------------------------
+void AliAnalysisTaskDiHadron::SetEfficiencies(Float_t EffFitPt, TF1 *FitLow, TF1 *FitHigh, Int_t NFitLowParam, Int_t NFitHighParam, Float_t *FitLowParam, Float_t *FitHighParam){
+  fEffFitPt=EffFitPt;
+  fFitLow=(TF1*)FitLow;
+  fFitHigh=(TF1*)FitHigh;
+  fNFitLowParam=NFitLowParam;
+  fNFitHighParam=NFitHighParam;
+  // Printf("NCent%d NFitLow%d NFitHigh%d",NCent,fNFitLowParam,fNFitHighParam);
+  //  Printf("FitLowParm%2.4f",FitLowParam[0]);
+  fFitLowParam=(Float_t*)FitLowParam;
+  fFitHighParam=(Float_t*)FitHighParam;
+  //Printf("fEffFitPt%2.1f FitParam%2.1f",fEffFitPt,fFitLowParam[0]);
+}
+
+//-----------------------------------------------------------
+void AliAnalysisTaskDiHadron::ConnectInputData(Option_t *){
+  //Connect to ESD
+  if(DEBUG)Printf("Connecting");
+   TTree* tree = dynamic_cast<TTree*> (GetInputData(0));
+   if (!tree&&DEBUG) {Printf("ERROR: Could not read chain from input slot 0");} 
+  else {
+    AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+    if (!esdH&&DEBUG) Printf("ERROR: Could not get ESDInputHandler");
+    else fESD = esdH->GetEvent();
+    
+    //MC Data handler (so one can calcualte eff)
+    AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
+    if(mcH)fMC=mcH->MCEvent();
+  }
+  if(DEBUG)Printf("Connected");
+}
+  
+//---------------------------------------------------------  
+void AliAnalysisTaskDiHadron::CreateOutputObjects(){
+  if(DEBUG)Printf("Output");
+  //Creates the histograms and list
+  fOutput=new TList();
+  fOutput->SetName(GetName());
+  char histname[100];
+  char histtitle[200];
+  int nptbins=fNAPtBins;
+  int lptbins=0;
+  char *cmc1[2]={"","_MC"};
+  char *cmc2[2]={""," MC"};
+  char *sign1[3]={"","_LS","_ULS"};
+  char *sign2[3]={""," Like-Sign"," Unlike-Sign"};
+  char *sign31[4]={"","_LS","_ULT","_ULA"};
+  char *sign32[4]={""," Like-Sign"," Trigger-Diff"," Assoc-Diff"};
+  Float_t EtaEdge=2*fEtaCut;
+  Float_t PhiArray[fnBinPhi+1];
+  Float_t EtaArray[fnBinEta+1];
+  Float_t PhiEtaArrayPhi[fnBinPhiEtaPhi+1];
+  Float_t PhiEtaArrayEta[fnBinPhiEtaEta+1];
+  for(int iphi=0;iphi<=fnBinPhi;iphi++){
+    PhiArray[iphi]=fdPhiMin+iphi*2*fPi/fnBinPhi;
+  }
+  for(int ieta=0;ieta<=fnBinEta;ieta++){
+    EtaArray[ieta]=-EtaEdge+ieta*2*EtaEdge/fnBinEta;
+  }
+  for(int iphi=0;iphi<=fnBinPhiEtaPhi;iphi++){
+    PhiEtaArrayPhi[iphi]=fdPhiMin+iphi*2*fPi/fnBinPhiEtaPhi;
+  }
+  for(int ieta=0;ieta<=fnBinPhiEtaEta;ieta++){
+    PhiEtaArrayEta[ieta]=-EtaEdge+ieta*2*EtaEdge/fnBinPhiEtaEta;
+  }
+  for(int imc=0;imc<=1;imc++){//MC loop
+    if(imc==1&&!fMCHistos) continue;
+    //Create the histograms
+    sprintf(histname,"fHistMult%s",cmc1[imc]);
+    sprintf(histtitle,"Multiplicity%s",cmc2[imc]);
+    fHistMult[imc]=new TH1F(histname,histtitle,2000,-0.5,1999.5);
+    fHistMult[imc]->Sumw2();
+    fHistMult[imc]->GetXaxis()->SetTitle("Number of tracks");
+    fHistMult[imc]->GetYaxis()->SetTitle("Counts");
+    fOutput->Add(fHistMult[imc]);
+    
+    for(int imult=0;imult<fNCentBins;imult++){//loop for multiplicity bins
+      
+      //Histograms that are independent of the trigger
+      sprintf(histname,"fHistPt_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"P_{T} Distribution of Tracks %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistPt[imult][imc]=new TH1F(histname,histtitle,nptbins,fPtAssocArray);
+      fHistPt[imult][imc]->Sumw2();
+      fHistPt[imult][imc]->GetXaxis()->SetTitle("p_{T}");
+      fHistPt[imult][imc]->GetYaxis()->SetTitle("Counts");
+      fOutput->Add(fHistPt[imult][imc]);
+
+ //Histograms that are independent of the trigger
+      sprintf(histname,"fHistPtEff_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"P_{T} Distribution of Tracks %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistPtEff[imult][imc]=new TH1F(histname,histtitle,1000,0,100);
+      fHistPtEff[imult][imc]->Sumw2();
+      fHistPtEff[imult][imc]->GetXaxis()->SetTitle("p_{T}");
+      fHistPtEff[imult][imc]->GetYaxis()->SetTitle("Counts");
+      fOutput->Add(fHistPtEff[imult][imc]);
+      
+      sprintf(histname,"fHistPhi_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"#phi Distribution of Tracks %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistPhi[imult][imc]=new TH2F(histname,histtitle,fnBinPhi,PhiArray,nptbins,fPtAssocArray);
+      fHistPhi[imult][imc]->Sumw2();
+      fHistPhi[imult][imc]->GetXaxis()->SetTitle("#phi");
+      fHistPhi[imult][imc]->GetYaxis()->SetTitle("P_{T}");
+      fOutput->Add(fHistPhi[imult][imc]);
+      
+      sprintf(histname,"fHistPhiPt_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"P_{T} weighted #phi Distribution of tracks %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistPhiPt[imult][imc]=new TH2F(histname,histtitle,fnBinPhi,PhiArray,nptbins,fPtAssocArray);
+      fHistPhiPt[imult][imc]->Sumw2();
+      fHistPhiPt[imult][imc]->GetXaxis()->SetTitle("#phi");
+      fHistPhiPt[imult][imc]->GetYaxis()->SetTitle("P_{T}");
+      fOutput->Add(fHistPhiPt[imult][imc]);
+      
+      sprintf(histname,"fHistEta_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"#eta Distribution of Tracks %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistEta[imult][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,nptbins,fPtAssocArray);
+      fHistEta[imult][imc]->Sumw2();
+      fHistEta[imult][imc]->GetXaxis()->SetTitle("#eta");
+      fHistEta[imult][imc]->GetYaxis()->SetTitle("P_{T}");
+      fOutput->Add(fHistEta[imult][imc]);
+      
+      sprintf(histname,"fHistEtaPt_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"P_{T} weighted #eta Distribution of tracks %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistEtaPt[imult][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,nptbins,fPtAssocArray);
+      fHistEtaPt[imult][imc]->Sumw2();
+      fHistEtaPt[imult][imc]->GetXaxis()->SetTitle("#eta");
+      fHistEtaPt[imult][imc]->GetYaxis()->SetTitle("P_{T}");
+      fOutput->Add(fHistEtaPt[imult][imc]);
+      
+      sprintf(histname,"fHistNEvents_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"Number of Events and Number Passing Cuts %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistNEvents[imult][imc]=new TH1F(histname,histtitle,2,-0.5,1.5);
+      fHistNEvents[imult][imc]->Sumw2();
+      fHistNEvents[imult][imc]->GetXaxis()->SetTitle("Events,Passing Cuts");
+      fHistNEvents[imult][imc]->GetYaxis()->SetTitle("Number of Events");
+      fOutput->Add(fHistNEvents[imult][imc]);
+      
+      sprintf(histname,"fHistNTrigger_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"Number of Triggers %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistNTrigger[imult][imc]=new TH1F(histname,histtitle,fNTPtBins,-0.5,fNTPtBins-0.5);
+      fHistNTrigger[imult][imc]->Sumw2();
+      fHistNTrigger[imult][imc]->GetXaxis()->SetTitle("Trigger Number");
+      fHistNTrigger[imult][imc]->GetYaxis()->SetTitle("Number of Triggers");
+      fOutput->Add(fHistNTrigger[imult][imc]);
+      
+      sprintf(histname,"fHistNTriggerPt_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"P_{T} Weighted Number of Triggers %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistNTriggerPt[imult][imc]=new TH1F(histname,histtitle,fNTPtBins,-0.5,fNTPtBins-0.5);
+      fHistNTriggerPt[imult][imc]->Sumw2();
+      fHistNTriggerPt[imult][imc]->GetXaxis()->SetTitle("Trigger Number");
+      fHistNTriggerPt[imult][imc]->GetYaxis()->SetTitle("Number of Triggers");
+      fOutput->Add(fHistNTriggerPt[imult][imc]);
+      
+      sprintf(histname,"fHistNMix_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"Number of Mixed Events %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistNMix[imult][imc]=new TH1F(histname,histtitle,fNTPtBins,-0.5,fNTPtBins-0.5);
+      fHistNMix[imult][imc]->Sumw2();
+      fHistNMix[imult][imc]->GetXaxis()->SetTitle("Trigger Number");
+      fHistNMix[imult][imc]->GetYaxis()->SetTitle("Number of Mixed Events");
+      fOutput->Add(fHistNMix[imult][imc]);
+      
+      sprintf(histname,"fHistPhiEta_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"#phi-#eta distribution of tracks %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistPhiEta[imult][imc]=new TH3F(histname, histtitle,fnBinPhiEtaPhi,PhiEtaArrayPhi,fnBinPhiEtaEta,PhiEtaArrayEta,nptbins,fPtAssocArray);
+      fHistPhiEta[imult][imc]->Sumw2();
+      fHistPhiEta[imult][imc]->GetXaxis()->SetTitle("#phi");
+      fHistPhiEta[imult][imc]->GetYaxis()->SetTitle("#eta");
+      fHistPhiEta[imult][imc]->GetZaxis()->SetTitle("p_{T}");
+      fOutput->Add(fHistPhiEta[imult][imc]);
+      
+      sprintf(histname,"fHistPhiEtaPt_C%d%s",imult,cmc1[imc]);
+      sprintf(histtitle,"Pt Weighted #phi-#eta distribution of tracks %dMult%d%s",fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistPhiEtaPt[imult][imc]=new TH3F(histname, histtitle,fnBinPhiEtaPhi,PhiEtaArrayPhi,fnBinPhiEtaEta,PhiEtaArrayEta,nptbins,fPtAssocArray);
+      fHistPhiEtaPt[imult][imc]->Sumw2();
+      fHistPhiEtaPt[imult][imc]->GetXaxis()->SetTitle("#phi");
+      fHistPhiEtaPt[imult][imc]->GetYaxis()->SetTitle("#eta");
+      fHistPhiEtaPt[imult][imc]->GetZaxis()->SetTitle("p_{T}");
+      fOutput->Add(fHistPhiEtaPt[imult][imc]);
+      
+      //if(DEBUG)Printf("OutPut2");
+      //Histograms with a trigger dependence
+      
+      for(int i=0;i<fNTPtBins;i++){
+       for(int j=1;j<fNAPtBins;j++){
+         if(fPtTrigArray[i]==fPtAssocArray[j])lptbins=j;
+       }
+       //if(DEBUG)Printf("Loop: %d Pt %3.2f",i,fPtTrigArray[i]/fPtBinWidth);
+       
+       //Ones with no centrality binning
+       if(imult==0){
+         sprintf(histname,"fHistMultTrig_P%d%s",i,cmc1[imc]);
+         sprintf(histtitle,"Distrubition of number of tracks in triggered events with %3.1f<p_{T}^{Trig}<%3.1f%s",fPtTrigArray[i],fPtTrigArray[i+1],cmc2[imc]);
+         fHistMultTrig[i][imc]=new TH1F(histname,histtitle,2000,0,2000);
+         fHistMultTrig[i][imc]->Sumw2();
+         fHistMultTrig[i][imc]->GetXaxis()->SetTitle("Number of Tracks");
+         fHistMultTrig[i][imc]->GetYaxis()->SetTitle("Counts");
+         fOutput->Add(fHistMultTrig[i][imc]);
+       }
+       sprintf(histname,"fHistPtTrig_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"P_{T} distribution in triggered events with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+       fHistPtTrig[i][imult][imc]=new TH1F(histname,histtitle,nptbins,fPtAssocArray);
+       fHistPtTrig[i][imult][imc]->Sumw2();
+       fHistPtTrig[i][imult][imc]->GetXaxis()->SetTitle("p_{T}");
+       fHistPtTrig[i][imult][imc]->GetYaxis()->SetTitle("Counts");
+       fOutput->Add(fHistPtTrig[i][imult][imc]);
+       
+       sprintf(histname,"fHistPhiTrig_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"Phi Distribution of triggered events with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+       fHistPhiTrig[i][imult][imc]=new TH2F(histname,histtitle,fnBinPhi,PhiArray,lptbins,fPtAssocArray);
+       fHistPhiTrig[i][imult][imc]->Sumw2();
+       fHistPhiTrig[i][imult][imc]->GetXaxis()->SetTitle("#phi");
+       fHistPhiTrig[i][imult][imc]->GetYaxis()->SetTitle("p_{T}");
+       fOutput->Add(fHistPhiTrig[i][imult][imc]);
+       
+       sprintf(histname,"fHistPhiTrigPt_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"P_{T} Weighted Phi Distribution of triggered events with %3.1f<p_{T}^{Trig}<%3.1f%s",fPtTrigArray[i],fPtTrigArray[i+1],cmc2[imc]);
+       fHistPhiTrigPt[i][imult][imc]=new TH2F(histname,histtitle,fnBinPhi,PhiArray,lptbins,fPtAssocArray);
+       fHistPhiTrigPt[i][imult][imc]->Sumw2();
+       fHistPhiTrigPt[i][imult][imc]->GetXaxis()->SetTitle("#phi");
+       fHistPhiTrigPt[i][imult][imc]->GetYaxis()->SetTitle("p_{T}");
+       fOutput->Add(fHistPhiTrigPt[i][imult][imc]);
+       
+       sprintf(histname,"fHistEtaTrig_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"Eta Distribution of triggered events with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+       fHistEtaTrig[i][imult][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+       fHistEtaTrig[i][imult][imc]->Sumw2();
+       fHistEtaTrig[i][imult][imc]->GetXaxis()->SetTitle("#eta");
+       fHistEtaTrig[i][imult][imc]->GetYaxis()->SetTitle("p_{T}");
+       fOutput->Add(fHistEtaTrig[i][imult][imc]);
+       
+       sprintf(histname,"fHistEtaTrigPt_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"P_{T} Weighted Eta Distribution of triggered events with %3.1f<p_{T}^{Trig}<%3.1f%s",fPtTrigArray[i],fPtTrigArray[i+1],cmc2[imc]);
+       fHistEtaTrigPt[i][imult][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+       fHistEtaTrigPt[i][imult][imc]->Sumw2();
+       fHistEtaTrigPt[i][imult][imc]->GetXaxis()->SetTitle("#eta");
+       fHistEtaTrigPt[i][imult][imc]->GetYaxis()->SetTitle("p_{T}");
+       fOutput->Add(fHistEtaTrigPt[i][imult][imc]);
+       
+       sprintf(histname,"fHistPhiEtaTrig_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"#phi-#eta distribution in triggered events %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+       fHistPhiEtaTrig[i][imult][imc]=new TH3F(histname,histtitle,fnBinPhiEtaPhi,PhiEtaArrayPhi,fnBinPhiEtaEta,PhiEtaArrayEta,lptbins,fPtAssocArray);
+       fHistPhiEtaTrig[i][imult][imc]->Sumw2();
+       fHistPhiEtaTrig[i][imult][imc]->GetXaxis()->SetTitle("#phi");
+       fHistPhiEtaTrig[i][imult][imc]->GetYaxis()->SetTitle("#eta");
+       fHistPhiEtaTrig[i][imult][imc]->GetZaxis()->SetTitle("p_{T}");
+       fOutput->Add(fHistPhiEtaTrig[i][imult][imc]);
+
+       sprintf(histname,"fHistXEN_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"Near-Side X_{E} distribution for %3.1f<p_{T}^{Lead}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+       fHistXEN[i][imult][imc]=new TH1F(histname,histtitle,fNXEBins,fXEArray);
+       fHistXEN[i][imult][imc]->Sumw2();
+       fHistXEN[i][imult][imc]->GetXaxis()->SetTitle("X_{E}");
+       fOutput->Add(fHistXEN[i][imult][imc]);
+
+       sprintf(histname,"fHistXENMixed_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"Mixed Near-Side X_{E} distribution for %3.1f<p_{T}^{Lead}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+       fHistXENMix[i][imult][imc]=new TH1F(histname,histtitle,fNXEBins,fXEArray);
+       fHistXENMix[i][imult][imc]->Sumw2();
+       fHistXENMix[i][imult][imc]->GetXaxis()->SetTitle("X_{E}");
+       fOutput->Add(fHistXENMix[i][imult][imc]);
+       
+       sprintf(histname,"fHistXEA_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"Away-Side X_{E} distribution for %3.1f<p_{T}^{Lead}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+       fHistXEA[i][imult][imc]=new TH1F(histname,histtitle,fNXEBins,fXEArray);
+       fHistXEA[i][imult][imc]->Sumw2();
+       fHistXEA[i][imult][imc]->GetXaxis()->SetTitle("X_{E}");
+       fOutput->Add(fHistXEA[i][imult][imc]);
+
+       sprintf(histname,"fHistXEAMixed_P%d_C%d%s",i,imult,cmc1[imc]);
+       sprintf(histtitle,"Mixed Away-Side X_{E} distribution for %3.1f<p_{T}^{Lead}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+       fHistXEAMix[i][imult][imc]=new TH1F(histname,histtitle,fNXEBins,fXEArray);
+       fHistXEAMix[i][imult][imc]->Sumw2();
+       fHistXEAMix[i][imult][imc]->GetXaxis()->SetTitle("X_{E}");
+       fOutput->Add(fHistXEAMix[i][imult][imc]);
+
+       //signloop
+       for(int isign=0;isign<3;isign++){
+         sprintf(histname,"fHistDeltaPhi_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"#Delta#phi Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaPhi[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinPhi,PhiArray,lptbins,fPtAssocArray);
+         fHistDeltaPhi[i][imult][isign][imc]->Sumw2();
+         fHistDeltaPhi[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#phi");
+         fHistDeltaPhi[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaPhi[i][imult][isign][imc]);
+         
+         sprintf(histname,"fHistDeltaPhiPt_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"P_{T} Weighted #Delta#phi Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaPhiPt[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinPhi,PhiArray,lptbins,fPtAssocArray);
+         fHistDeltaPhiPt[i][imult][isign][imc]->Sumw2();
+         fHistDeltaPhiPt[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#phi");
+         fHistDeltaPhiPt[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaPhiPt[i][imult][isign][imc]);
+         
+         sprintf(histname,"fHistDeltaPhiMix_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"#Delta#phi Mixed Event Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaPhiMix[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinPhi,PhiArray,lptbins,fPtAssocArray);
+         fHistDeltaPhiMix[i][imult][isign][imc]->Sumw2();
+         fHistDeltaPhiMix[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#phi");
+         fHistDeltaPhiMix[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaPhiMix[i][imult][isign][imc]);
+         
+         sprintf(histname,"fHistDeltaPhiMixPt_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"P_{T} Weighted #Delta#phi Mixed Event Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaPhiMixPt[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinPhi,PhiArray,lptbins,fPtAssocArray);
+         fHistDeltaPhiMixPt[i][imult][isign][imc]->Sumw2();
+         fHistDeltaPhiMixPt[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#phi");
+         fHistDeltaPhiMixPt[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaPhiMixPt[i][imult][isign][imc]);
+         
+         //etaNear
+         sprintf(histname,"fHistDeltaEtaN_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"Near-Side #Delta#eta Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaEtaN[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+         fHistDeltaEtaN[i][imult][isign][imc]->Sumw2();
+         fHistDeltaEtaN[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#eta");
+         fHistDeltaEtaN[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaEtaN[i][imult][isign][imc]);
+         
+         sprintf(histname,"fHistDeltaEtaNPt_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"Near-Side P_{T} Weighted #Delta#eta Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaEtaNPt[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+         fHistDeltaEtaNPt[i][imult][isign][imc]->Sumw2();
+         fHistDeltaEtaNPt[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#eta");
+         fHistDeltaEtaNPt[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaEtaNPt[i][imult][isign][imc]);
+         
+         sprintf(histname,"fHistDeltaEtaNMix_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"Near-Side #Delta#eta Mixed Event Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaEtaNMix[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+         fHistDeltaEtaNMix[i][imult][isign][imc]->Sumw2();
+         fHistDeltaEtaNMix[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#eta");
+         fHistDeltaEtaNMix[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaEtaNMix[i][imult][isign][imc]);
+         
+         sprintf(histname,"fHistDeltaEtaNMixPt_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"Near-Side P_{T} Weighted #Delta#eta Mixed Event Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaEtaNMixPt[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+         fHistDeltaEtaNMixPt[i][imult][isign][imc]->Sumw2();
+         fHistDeltaEtaNMixPt[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#eta");
+         fHistDeltaEtaNMixPt[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaEtaNMixPt[i][imult][isign][imc]);
+         
+         //Away Eta
+         sprintf(histname,"fHistDeltaEtaA_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"Away-Side #Delta#eta Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaEtaA[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+         fHistDeltaEtaA[i][imult][isign][imc]->Sumw2();
+         fHistDeltaEtaA[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#eta");
+         fHistDeltaEtaA[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaEtaA[i][imult][isign][imc]);
+         
+         sprintf(histname,"fHistDeltaEtaAPt_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"Away-Side P_{T} Weighted #Delta#eta Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaEtaAPt[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+         fHistDeltaEtaAPt[i][imult][isign][imc]->Sumw2();
+         fHistDeltaEtaAPt[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#eta");
+         fHistDeltaEtaAPt[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaEtaAPt[i][imult][isign][imc]);
+         
+         sprintf(histname,"fHistDeltaEtaAMix_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"Away-Side #Delta#eta Mixed Event Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaEtaAMix[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+         fHistDeltaEtaAMix[i][imult][isign][imc]->Sumw2();
+         fHistDeltaEtaAMix[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#eta");
+         fHistDeltaEtaAMix[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaEtaAMix[i][imult][isign][imc]);
+         
+         sprintf(histname,"fHistDeltaEtaAMixPt_P%d_C%d%s%s",i,imult,sign1[isign],cmc1[imc]);
+         sprintf(histtitle,"Away-Side P_{T} Weighted #Delta#eta Mixed Event Distribution with %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],sign2[isign],cmc2[imc]);
+         fHistDeltaEtaAMixPt[i][imult][isign][imc]=new TH2F(histname,histtitle,fnBinEta,EtaArray,lptbins,fPtAssocArray);
+         fHistDeltaEtaAMixPt[i][imult][isign][imc]->Sumw2();
+         fHistDeltaEtaAMixPt[i][imult][isign][imc]->GetXaxis()->SetTitle("#Delta#eta");
+         fHistDeltaEtaAMixPt[i][imult][isign][imc]->GetYaxis()->SetTitle("p_{T}");
+         fOutput->Add(fHistDeltaEtaAMixPt[i][imult][isign][imc]);
+
+
+      //====
+       }//end isignloop
+      sprintf(histname,"fHistDeltaPhiEta_P%d_C%d%s",i,imult,cmc1[imc]);
+      sprintf(histtitle,"#Delta#phi-#Delta#eta %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistDeltaPhiEta[i][imult][imc]=new TH3F(histname,histtitle,fnBinPhiEtaPhi,PhiEtaArrayPhi,fnBinPhiEtaEta,PhiEtaArrayEta,lptbins,fPtAssocArray);
+      fHistDeltaPhiEta[i][imult][imc]->Sumw2();
+      fHistDeltaPhiEta[i][imult][imc]->GetXaxis()->SetTitle("#phi");
+      fHistDeltaPhiEta[i][imult][imc]->GetYaxis()->SetTitle("#eta");
+      fHistDeltaPhiEta[i][imult][imc]->GetZaxis()->SetTitle("p_{T}");
+      fOutput->Add(fHistDeltaPhiEta[i][imult][imc]);
+      
+      sprintf(histname,"fHistDeltaPhiEtaMix_P%d_C%d%s",i,imult,cmc1[imc]);
+      sprintf(histtitle,"#Delta#phi-#Delta#eta from Mixed Events %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistDeltaPhiEtaMix[i][imult][imc]=new TH3F(histname,histtitle,fnBinPhiEtaPhi,PhiEtaArrayPhi,fnBinPhiEtaEta,PhiEtaArrayEta,lptbins,fPtAssocArray);
+      fHistDeltaPhiEtaMix[i][imult][imc]->Sumw2();
+      fHistDeltaPhiEtaMix[i][imult][imc]->GetXaxis()->SetTitle("#phi");
+      fHistDeltaPhiEtaMix[i][imult][imc]->GetYaxis()->SetTitle("#eta");
+      fHistDeltaPhiEtaMix[i][imult][imc]->GetZaxis()->SetTitle("p_{T}");
+      fOutput->Add(fHistDeltaPhiEtaMix[i][imult][imc]);
+      
+      sprintf(histname,"fHistPhiEtaTrigPt_P%d_C%d%s",i,imult,cmc1[imc]);
+      sprintf(histtitle,"P_{T}-Weighted #phi-#eta distribution in triggered events %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistPhiEtaTrigPt[i][imult][imc]=new TH3F(histname,histtitle,fnBinPhiEtaPhi,PhiEtaArrayPhi,fnBinPhiEtaEta,PhiEtaArrayEta,lptbins,fPtAssocArray);
+      fHistPhiEtaTrigPt[i][imult][imc]->Sumw2();
+      fHistPhiEtaTrigPt[i][imult][imc]->GetXaxis()->SetTitle("#phi");
+      fHistPhiEtaTrigPt[i][imult][imc]->GetYaxis()->SetTitle("#eta");
+      fHistPhiEtaTrigPt[i][imult][imc]->GetZaxis()->SetTitle("p_{T}");
+      fOutput->Add(fHistPhiEtaTrigPt[i][imult][imc]);
+    
+      sprintf(histname,"fHistDeltaPhiEtaPt_P%d_C%d%s",i,imult,cmc1[imc]);
+      sprintf(histtitle,"P_{T}-Weighted #Delta#phi-#Delta#eta %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistDeltaPhiEtaPt[i][imult][imc]=new TH3F(histname,histtitle,fnBinPhiEtaPhi,PhiEtaArrayPhi,fnBinPhiEtaEta,PhiEtaArrayEta,lptbins,fPtAssocArray);
+      fHistDeltaPhiEtaPt[i][imult][imc]->Sumw2();
+      fHistDeltaPhiEtaPt[i][imult][imc]->GetXaxis()->SetTitle("#phi");
+      fHistDeltaPhiEtaPt[i][imult][imc]->GetYaxis()->SetTitle("#eta");
+      fHistDeltaPhiEtaPt[i][imult][imc]->GetZaxis()->SetTitle("p_{T}");
+      fOutput->Add(fHistDeltaPhiEtaPt[i][imult][imc]);
+      
+      sprintf(histname,"fHistDeltaPhiEtaMixPt_P%d_C%d%s",i,imult,cmc1[imc]);
+      sprintf(histtitle,"P_{T}-Weighted #Delta#phi-#Delta#eta from Mixed Events %3.1f<p_{T}^{Trig}<%3.1f %dMult%d%s",fPtTrigArray[i],fPtTrigArray[i+1],fCentArrayMin[imult],fCentArrayMax[imult],cmc2[imc]);
+      fHistDeltaPhiEtaMixPt[i][imult][imc]=new TH3F(histname,histtitle,fnBinPhiEtaPhi,PhiEtaArrayPhi,fnBinPhiEtaEta,PhiEtaArrayEta,lptbins,fPtAssocArray);
+      fHistDeltaPhiEtaMixPt[i][imult][imc]->Sumw2();
+      fHistDeltaPhiEtaMixPt[i][imult][imc]->GetXaxis()->SetTitle("#phi");
+      fHistDeltaPhiEtaMixPt[i][imult][imc]->GetYaxis()->SetTitle("#eta");
+      fHistDeltaPhiEtaMixPt[i][imult][imc]->GetZaxis()->SetTitle("p_{T}");
+      fOutput->Add(fHistDeltaPhiEtaMixPt[i][imult][imc]);
+
+      //Three-Particle Histograms
+      for(int ipt=0;ipt<fNAPt3Bins;ipt++){
+       for(int iSign=0;iSign<4;iSign++){
+         sprintf(histname,"fHistDeltaPhiPhi_P%dp%d_C%d%s%s",i,ipt,imult,cmc1[imc],sign31[iSign]);
+         sprintf(histtitle,"Raw #Delta#phi-#Delta#phi %3.1f<p_{T}^{Trig}<%3.1f %3.2f<p_{T}^{Assoc}<%3.2f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fPtAssoc3Array1[ipt],fPtAssoc3Array2[ipt],fCentArrayMin[imult],fCentArrayMax[imult],sign32[iSign],cmc2[imc]);
+         fHistDeltaPhiPhi[i][ipt][imult][iSign][imc]=new TH2F(histname,histtitle,fnBinPhi3,fdPhiMin,fdPhiMax,fnBinPhi3,fdPhiMin,fdPhiMax);
+         fHistDeltaPhiPhi[i][ipt][imult][iSign][imc]->Sumw2();
+         fHistDeltaPhiPhi[i][ipt][imult][iSign][imc]->GetXaxis()->SetTitle("#Delta#phi_{1}");
+         fHistDeltaPhiPhi[i][ipt][imult][iSign][imc]->GetYaxis()->SetTitle("#Delta#phi_{2}");
+         fOutput->Add(fHistDeltaPhiPhi[i][ipt][imult][iSign][imc]);
+         
+         sprintf(histname,"fHistDeltaPhiPhiMix_P%dp%d_C%d%s%s",i,ipt,imult,cmc1[imc],sign31[iSign]);
+         sprintf(histtitle,"Mixed #Delta#phi-#Delta#phi %3.1f<p_{T}^{Trig}<%3.1f %3.2f<p_{T}^{Assoc}<%3.2f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fPtAssoc3Array1[ipt],fPtAssoc3Array2[ipt],fCentArrayMin[imult],fCentArrayMax[imult],sign32[iSign],cmc2[imc]);
+         fHistDeltaPhiPhiMix[i][ipt][imult][iSign][imc]=new TH2F(histname,histtitle,fnBinPhi3,fdPhiMin,fdPhiMax,fnBinPhi3,fdPhiMin,fdPhiMax);
+         fHistDeltaPhiPhiMix[i][ipt][imult][iSign][imc]->Sumw2();
+         fHistDeltaPhiPhiMix[i][ipt][imult][iSign][imc]->GetXaxis()->SetTitle("#Delta#phi_{1}");
+         fHistDeltaPhiPhiMix[i][ipt][imult][iSign][imc]->GetYaxis()->SetTitle("#Delta#phi_{2}");
+         fOutput->Add(fHistDeltaPhiPhiMix[i][ipt][imult][iSign][imc]);
+
+         sprintf(histname,"fHistDeltaPhiPhiSS_P%dp%d_C%d%s%s",i,ipt,imult,cmc1[imc],sign31[iSign]);
+         sprintf(histtitle,"Soft-Soft #Delta#phi-#Delta#phi %3.1f<p_{T}^{Trig}<%3.1f %3.2f<p_{T}^{Assoc}<%3.2f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fPtAssoc3Array1[ipt],fPtAssoc3Array2[ipt],fCentArrayMin[imult],fCentArrayMax[imult],sign32[iSign],cmc2[imc]);
+         fHistDeltaPhiPhiSS[i][ipt][imult][iSign][imc]=new TH2F(histname,histtitle,fnBinPhi3,fdPhiMin,fdPhiMax,fnBinPhi3,fdPhiMin,fdPhiMax);
+         fHistDeltaPhiPhiSS[i][ipt][imult][iSign][imc]->Sumw2();
+         fHistDeltaPhiPhiSS[i][ipt][imult][iSign][imc]->GetXaxis()->SetTitle("#Delta#phi_{1}");
+         fHistDeltaPhiPhiSS[i][ipt][imult][iSign][imc]->GetYaxis()->SetTitle("#Delta#phi_{2}");
+         fOutput->Add(fHistDeltaPhiPhiSS[i][ipt][imult][iSign][imc]);
+
+         sprintf(histname,"fHistDeltaEtaEta_P%dp%d_C%d%s%s",i,ipt,imult,cmc1[imc],sign31[iSign]);
+         sprintf(histtitle,"Raw #Delta#eta-#Delta#eta %3.1f<p_{T}^{Trig}<%3.1f %3.2f<p_{T}^{Assoc}<%3.2f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fPtAssoc3Array1[ipt],fPtAssoc3Array2[ipt],fCentArrayMin[imult],fCentArrayMax[imult],sign32[iSign],cmc2[imc]);
+         fHistDeltaEtaEta[i][ipt][imult][iSign][imc]=new TH2F(histname,histtitle,fnBinEta3,-EtaEdge,EtaEdge,fnBinEta3,-EtaEdge,EtaEdge);
+         fHistDeltaEtaEta[i][ipt][imult][iSign][imc]->Sumw2();
+         fHistDeltaEtaEta[i][ipt][imult][iSign][imc]->GetXaxis()->SetTitle("#Delta#eta_{1}");
+         fHistDeltaEtaEta[i][ipt][imult][iSign][imc]->GetYaxis()->SetTitle("#Delta#eta_{2}");
+         fOutput->Add(fHistDeltaEtaEta[i][ipt][imult][iSign][imc]);
+
+sprintf(histname,"fHistDeltaEtaEtaMix_P%dp%d_C%d%s%s",i,ipt,imult,cmc1[imc],sign31[iSign]);
+         sprintf(histtitle,"Mixed #Delta#eta-#Delta#eta %3.1f<p_{T}^{Trig}<%3.1f %3.2f<p_{T}^{Assoc}<%3.2f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fPtAssoc3Array1[ipt],fPtAssoc3Array2[ipt],fCentArrayMin[imult],fCentArrayMax[imult],sign32[iSign],cmc2[imc]);
+         fHistDeltaEtaEtaMix[i][ipt][imult][iSign][imc]=new TH2F(histname,histtitle,fnBinEta3,-EtaEdge,EtaEdge,fnBinEta3,-EtaEdge,EtaEdge);
+         fHistDeltaEtaEtaMix[i][ipt][imult][iSign][imc]->Sumw2();
+         fHistDeltaEtaEtaMix[i][ipt][imult][iSign][imc]->GetXaxis()->SetTitle("#Delta#eta_{1}");
+         fHistDeltaEtaEtaMix[i][ipt][imult][iSign][imc]->GetYaxis()->SetTitle("#Delta#eta_{2}");
+         fOutput->Add(fHistDeltaEtaEtaMix[i][ipt][imult][iSign][imc]);
+
+sprintf(histname,"fHistDeltaEtaEtaSS_P%dp%d_C%d%s%s",i,ipt,imult,cmc1[imc],sign31[iSign]);
+         sprintf(histtitle,"Soft-Soft #Delta#eta-#Delta#eta %3.1f<p_{T}^{Trig}<%3.1f %3.2f<p_{T}^{Assoc}<%3.2f %dMult%d%s%s",fPtTrigArray[i],fPtTrigArray[i+1],fPtAssoc3Array1[ipt],fPtAssoc3Array2[ipt],fCentArrayMin[imult],fCentArrayMax[imult],sign32[iSign],cmc2[imc]);
+         fHistDeltaEtaEtaSS[i][ipt][imult][iSign][imc]=new TH2F(histname,histtitle,fnBinEta3,-EtaEdge,EtaEdge,fnBinEta3,-EtaEdge,EtaEdge);
+         fHistDeltaEtaEtaSS[i][ipt][imult][iSign][imc]->Sumw2();
+         fHistDeltaEtaEtaSS[i][ipt][imult][iSign][imc]->GetXaxis()->SetTitle("#Delta#eta_{1}");
+         fHistDeltaEtaEtaSS[i][ipt][imult][iSign][imc]->GetYaxis()->SetTitle("#Delta#eta_{2}");
+         fOutput->Add(fHistDeltaEtaEtaSS[i][ipt][imult][iSign][imc]);
+
+       }//iSign
+      }//associated pt (ipt)
+      }//pt loop (i) 
+    }//centrality loop (imult)
+  }//imc
+  if(DEBUG)Printf("OutPut Created");
+}//CreateOutputObjects    
+
+Int_t AliAnalysisTaskDiHadron::CheckVertex(AliESDEvent *rESD){
+  Int_t rGood=-1;
+  Float_t Vtx[3];
+  Vtx[0]=rESD->GetPrimaryVertex()->GetX();
+  Vtx[1]=rESD->GetPrimaryVertex()->GetY();
+  Vtx[2]=rESD->GetPrimaryVertex()->GetZ();
+  if((Vtx[0]*Vtx[0]+Vtx[1]*Vtx[1])<9) rGood=0; //vertex out of beam pipe
+  if(fabs(Vtx[2])<fVzCut)rGood=0;//Vertex Z cut
+  if(DEBUG)Printf("VtxZ %f",Vtx[2]);
+  for(int i=0;i<fNVertexBins;i++){
+    if(Vtx[2]>fVertexArray[i]&&Vtx[2]<=fVertexArray[i+1]&&rGood==0)rGood=i;
+  }
+  return rGood;
+}
+
+Int_t AliAnalysisTaskDiHadron::CheckTrigger(AliESDEvent *rESD){
+  Int_t rGood=0;
+  TString trigID=rESD->GetFiredTriggerClasses();
+  for(int i=0;i<fNIDs;i++){
+    if(trigID.Contains(fTrigIDArray[i])) rGood=1;
+  }
+    return rGood;
+}
+
+Int_t AliAnalysisTaskDiHadron::TrackCuts(AliESDEvent *rESD, Float_t *rPt, Float_t *rEta, Float_t *rPhi, Short_t *rCharge, Float_t *rEff, Int_t **rPtAssoc3, Int_t *rNPtAssoc3, Int_t *rGoodTracks){
+    //fills arrays with all of the tracks passing cuts
+  rGoodTracks[0]=0;
+  Int_t Lead=0;
+  Float_t LeadPt=0;
+  Int_t rTrack=fESD->GetNumberOfTracks();
+  Float_t sPt, sEta, sPhi, sChi, sb[2], sbCov[3];
+  Int_t sNcls, sNclsF, sITScls;
+  Short_t sCharge;
+  for(int iTrack=0;iTrack<rTrack;iTrack++){
+    AliESDtrack *ESDtrack=rESD->GetTrack(iTrack);
+    const AliExternalTrackParam *ConTrack = ESDtrack->GetConstrainedParam();
+    if(!ConTrack)continue;
+    sPt=ConTrack->Pt();
+    //if(DEBUG)Printf("Pt%f",rPt);
+    sEta=ConTrack->Eta();
+    sPhi=ConTrack->Phi();
+    sCharge=ConTrack->Charge();
+    if(sPhi<fdPhiMin)sPhi+=2*fPi;
+    if(sPhi>fdPhiMax)sPhi-=2*fPi;
+    if(sPt<fMinPtAssoc||sPt>fMaxPtAssoc)continue;//set Pt range
+    if(fabs(sEta)>fEtaCut)continue;//set Eta Range
+    if(!sCharge)continue;
+    sNcls=ESDtrack->GetTPCNcls();
+    //if(DEBUG)Printf("NCLS%d",sNcls);
+    if(sNcls<fMinClustersTPC)continue;
+    sNclsF=ESDtrack->GetTPCNclsF();
+    if((1.0*sNcls/sNclsF)<fMinClusterRatio)continue;//Clusters fit/ Possible
+    sChi=(ESDtrack->GetTPCchi2())/sNcls;
+    if(sChi>fMaxTPCchi2)continue;
+    sITScls=ESDtrack->GetNcls(0);
+    if(sITScls<fMinClustersITS)continue;
+    ESDtrack->GetImpactParameters(sb,sbCov);
+    if(!fDCA2D&&(sb[0]*sb[0]+sb[1]*sb[1])>(fMaxDCA*fMaxDCA))continue;//DCA cut
+    if(fDCA2D==1&&(sb[0]*sb[0]/fMaxDCAXY/fMaxDCAXY+sb[1]*sb[1]/fMaxDCAZ/fMaxDCAZ)>1)continue;
+    if(fDCA2D==2&&(0.35+0.42*std::pow(double(sPt),-0.9))<(sb[0]*sb[0]))continue;
+    if(ESDtrack->GetKinkIndex(0)>0)continue;//removes kinked tracks
+    if(!ESDtrack->GetStatus()&AliESDtrack::kTPCrefit&&fTPCRefit)continue;//refit in TPC
+    if((fITSRefit==1||(fITSRefit==2&&sPt>5))&&!ESDtrack->GetStatus()&AliESDtrack::kITSrefit)continue;//refit of its tracks either for none,all, or >5 GeV/c
+    if(fSPDCut&&!ESDtrack->HasPointOnITSLayer(0)&&!ESDtrack->HasPointOnITSLayer(1))continue;
+    rPt[rGoodTracks[0]]=sPt;
+    rEta[rGoodTracks[0]]=sEta;
+    rPhi[rGoodTracks[0]]=sPhi;
+    rCharge[rGoodTracks[0]]=sCharge;
+    if(fEfficiencyCorr){
+    if(sPt<fEffFitPt)rEff[rGoodTracks[0]]=1./fFitLow->Eval(sPt);
+    else rEff[rGoodTracks[0]]=1./fFitHigh->Eval(sPt);
+    }
+    else rEff[rGoodTracks[0]]=1;
+    if(sPt>LeadPt)Lead=rGoodTracks[0];
+    //rPtAssoc3[rGoodTracks[0]]=new Int_t [10];
+    rNPtAssoc3[rGoodTracks[0]]=0;
+    for(int apt3=0;apt3<fNAPt3Bins;apt3++){
+      if(sPt<fPtAssoc3Array2[apt3]&&sPt>=fPtAssoc3Array1[apt3]){
+       rPtAssoc3[rGoodTracks[0]][rNPtAssoc3[rGoodTracks[0]]]=apt3;
+       rNPtAssoc3[rGoodTracks[0]]++;
+      }
+    }
+
+    rGoodTracks[0]++;
+    
+  }
+  return Lead;
+}
+
+Int_t AliAnalysisTaskDiHadron::TrackCutsMC(AliMCEvent *rMC, Float_t *rPt, Float_t *rEta, Float_t *rPhi, Short_t *rCharge, Float_t *rEff, Int_t **rPtAssoc3, Int_t *rNPtAssoc3, Int_t *rGoodTracks){//Fills Arrays of MC particles
+  rGoodTracks[1]=0;
+  AliStack *rStack=rMC->Stack();
+  Int_t rTrack=rStack->GetNtrack();
+  Float_t sPt, sEta, sPhi;
+  Short_t sCharge;
+  Int_t Lead=0;
+  Float_t LeadPt=0;
+  for(int iTrack=0;iTrack<rTrack;iTrack++){
+    TParticle *rParticle=rStack->Particle(iTrack);
+    sPt=rParticle->Pt();
+    //if(DEBUG)Printf("MCPt%f",rPt);
+    sEta=rParticle->Eta();
+    sPhi=rParticle->Phi();
+    sCharge=rMC->GetTrack(iTrack)->Charge();
+    if(sPhi<fdPhiMin)sPhi+=2*fPi;
+    if(sPhi>fdPhiMax)sPhi-=2*fPi;
+    if(sPt<fMinPtAssoc||sPt>fMaxPtAssoc)continue;//set Pt range
+    if(fabs(sEta)>fEtaCut)continue;//set Eta Range
+    if(!rStack->IsPhysicalPrimary(iTrack))continue;//primary particles only
+    if(!sCharge)continue;//only charged particles kept
+    rPt[rGoodTracks[1]]=sPt;
+    rEta[rGoodTracks[1]]=sEta;
+    rPhi[rGoodTracks[1]]=sPhi;
+    rCharge[rGoodTracks[1]]=sCharge;
+    rEff[rGoodTracks[1]]=1;
+    if(sPt>LeadPt)Lead=rGoodTracks[1];
+    rNPtAssoc3[rGoodTracks[1]]=0;
+    for(int apt3=0;apt3<fNAPt3Bins;apt3++){
+      if(sPt<fPtAssoc3Array2[apt3]&&sPt>=fPtAssoc3Array1[apt3]){
+       rPtAssoc3[rGoodTracks[1]][rNPtAssoc3[rGoodTracks[1]]]=apt3;
+       rNPtAssoc3[rGoodTracks[1]]++;
+      }
+    }
+    rGoodTracks[1]++;
+  }
+  return Lead;
+}
+//------------------------------------------------------------
+void AliAnalysisTaskDiHadron::Exec(Option_t *)
+{ 
+  if(DEBUG)Printf("Exec");
+
+  const int NTPtBins=fNTPtBins;
+  const int NCentBins=fNCentBins;
+  for(int ievent=0;ievent<=1;ievent++){
+
+  if(!fESD&&ievent==0){
+    if(DEBUG)Printf("Error: fESD not found");
+    break;
+  }
+  if(!fMC&&ievent==1){
+    break;
+  }
+  if(ievent==1&&!fMCHistos)break;//break out if MC event and we don't have fill of those set
+  //Secondary check
+  if(ievent==0){
+    if(fESD->GetNumberOfTracks()<=0){
+      if(DEBUG)Printf("Error: no tracks");
+      break;
+    }
+  }
+  //The previous check doesn't seem to work as a fMC is bad not NULL
+  if(ievent==1){
+    if(fMC->GetNumberOfTracks()<=0){
+      if(DEBUG)Printf("<=0 MCTracks");
+      break;
+    }
+  }
+  
+  //Check for Trigger only on real data
+  if(!fMC){
+    if(!CheckTrigger(fESD)) break;
+  }
+  //I'll only cut on the reconstructed vertex since these are the events that will be used
+  int VertexBin;
+  VertexBin=CheckVertex(fESD);
+  //else VertexBin=CheckVertex(fMC);
+  if(VertexBin<0)break;
+
+  Int_t nGoodTracks[2]={0,0}, nTriggers[NTPtBins][NCentBins][2];
+  Int_t nTrack;
+  if(!ievent)nTrack=fESD->GetNumberOfTracks();
+  else nTrack=fMC->Stack()->GetNtrack();
+  Float_t tdPhi, tdEta, tXE;
+  Float_t tdPhi2, tdEta2;
+  tPhi=new Float_t [nTrack];
+  tEta=new Float_t [nTrack];
+  tPt=new Float_t [nTrack];
+  tCharge=new Short_t [nTrack];
+  tEff=new Float_t [nTrack];
+  tPtAssoc3=new Int_t *[nTrack];
+  for(int i=0;i<nTrack;i++){
+    tPtAssoc3[i]=new Int_t [10];
+  }
+  tNPtAssoc3=new Int_t [nTrack];
+  Short_t Sign;
+
+  //will need to do something exta for the effieiency once it comes from embedding
+  for(int i=0;i<fNTPtBins;i++){
+    for(int c=0;c<fNCentBins;c++){
+    nTriggers[i][c][ievent]=0;
+    }
+  }
+  Int_t tMult=fESD->GetMultiplicity()->GetNumberOfTracklets();//I think this is the correct multiplicity to use
+  if(DEBUG)Printf("Mult%d",tMult);
+  
+  //Decide what multiplicy bins are filled with this event, note set to max of 4 as I didn't think more then 2 overlapping bins likely at one time, easliy changed
+  Int_t MultArray[4]={0,0,0,0};
+  Int_t MaxArray=0;
+  for(int imult=0;imult<fNCentBins;imult++){
+    if(tMult>=fCentArrayMin[imult]&&tMult<fCentArrayMax[imult]){
+      MultArray[MaxArray]=imult;
+      MaxArray++;
+    }
+  }
+  if(DEBUG)Printf("MaxArray%d",MaxArray);
+  //Set Efficiency for the centrality bin (lowest bin used in array if multiple overlap)
+  for(int ipar=0;ipar<fNFitLowParam;ipar++){
+    fFitLow->SetParameter(ipar,fFitLowParam[MultArray[0]*fNCentBins+ipar]);
+  }
+   for(int ipar=0;ipar<fNFitHighParam;ipar++){
+    fFitHigh->SetParameter(ipar,fFitHighParam[MultArray[0]*fNCentBins+ipar]);
+  }
+  fHistMult[ievent]->Fill(tMult);
+  for(int c=0;c<MaxArray;c++){fHistNEvents[MultArray[c]][ievent]->Fill(0);}//count the number of events used
+  Int_t LeadPart;
+  
+  //returns arrays filled up to nGoodTracks with tracks passing cuts
+  if(!ievent)LeadPart=TrackCuts(fESD,tPt,tEta,tPhi,tCharge,tEff,tPtAssoc3,tNPtAssoc3,nGoodTracks);
+  else LeadPart=TrackCutsMC(fMC,tPt,tEta,tPhi,tCharge,tEff,tPtAssoc3,tNPtAssoc3,nGoodTracks);
+  int NearEta=0,NearXE=0;
+  int NearEta2=0;
+  if(DEBUG)Printf("Track Loop");
+  for(int iTrack=0;iTrack<nGoodTracks[ievent];iTrack++){
+    if(DEBUG)Printf("Track%d Pt%f",iTrack,tPt[iTrack]);
+    //if(tPhi[iTrack]<fdPhiMin)tPhi[iTrack]+=2*fPi;
+    //if(tPhi[iTrack]>fdPhiMax)tPhi[iTrack]-=2*fPi;
+    for(int c=0;c<MaxArray;c++){
+      fHistPt[MultArray[c]][ievent]->Fill(tPt[iTrack],tEff[iTrack]);
+    fHistPtEff[MultArray[c]][ievent]->Fill(tPt[iTrack]);
+    fHistPhi[MultArray[c]][ievent]->Fill(tPhi[iTrack],tPt[iTrack],tEff[iTrack]);
+    fHistPhiPt[MultArray[c]][ievent]->Fill(tPhi[iTrack],tPt[iTrack],tPt[iTrack]*tEff[iTrack]);
+    fHistEta[MultArray[c]][ievent]->Fill(tEta[iTrack],tPt[iTrack],tEff[iTrack]);
+    fHistEtaPt[MultArray[c]][ievent]->Fill(tEta[iTrack],tPt[iTrack],tPt[iTrack]*tEff[iTrack]);
+    fHistPhiEta[MultArray[c]][ievent]->Fill(tPhi[iTrack],tEta[iTrack],tPt[iTrack],tEff[iTrack]);
+    fHistPhiEtaPt[MultArray[c]][ievent]->Fill(tPhi[iTrack],tEta[iTrack],tPt[iTrack],tPt[iTrack]*tEff[iTrack]);
+    }
+    for(int i=0;i<fNTPtBins;i++){
+      if(tPt[iTrack]>fPtTrigArray[i]&&tPt[iTrack]<fPtTrigArray[i+1]&&fabs(tEta[iTrack])<fTrigEtaCut){
+       if(DEBUG)Printf("In %fpt%f",fPtTrigArray[i],fPtTrigArray[i+1]);
+       fHistMultTrig[i][ievent]->Fill(tMult);
+       for(int c=0;c<MaxArray;c++){
+         nTriggers[i][MultArray[c]][ievent]++;
+         fHistNTrigger[MultArray[c]][ievent]->Fill(i);
+         fHistNTriggerPt[MultArray[c]][ievent]->Fill(i,tPt[iTrack]);
+       }
+       if(DEBUG)Printf("Assiciated Particle Loop");
+       for(int iTrack2=0;iTrack2<nGoodTracks[ievent];iTrack2++){
+         if(iTrack==iTrack2) continue;
+         if(tPt[iTrack2]>tPt[iTrack])continue;
+         tdPhi=tPhi[iTrack]-tPhi[iTrack2];
+         if(tdPhi<-fPi)tdPhi+=2*fPi;
+         if(tdPhi>fPi)tdPhi-=2*fPi;
+         if(fabs(tdPhi)<fNearPhiCut)NearEta=1;
+         else NearEta=0;
+         if(fabs(tdPhi)<fXECut)NearXE=1;
+         else NearXE=0;
+         if(fabs(tdPhi)<(fPi/2))tdEta=tEta[iTrack]-tEta[iTrack2];
+         else tdEta=tEta[iTrack]+tEta[iTrack2];
+         if(tdPhi<fdPhiMin)tdPhi+=2*fPi;
+         if(tdPhi>fdPhiMax)tdPhi-=2*fPi;
+         if((tCharge[iTrack]<0&&tCharge[iTrack2]<0)||(tCharge[iTrack]>0&&tCharge[iTrack2]>0))Sign=1;
+         else Sign=2;
+         if(DEBUG) Printf("dPhi %f  dEta %f",tdPhi,tdEta);
+         for(int c=0;c<MaxArray;c++){//loop over multiplicity bins
+           fHistPtTrig[i][MultArray[c]][ievent]->Fill(tPt[iTrack2],tEff[iTrack2]);
+           fHistPhiTrig[i][MultArray[c]][ievent]->Fill(tPhi[iTrack2],tPt[iTrack2],tEff[iTrack2]);
+           fHistPhiTrigPt[i][MultArray[c]][ievent]->Fill(tPhi[iTrack2],tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+           fHistEtaTrig[i][MultArray[c]][ievent]->Fill(tEta[iTrack2],tPt[iTrack2],tEff[iTrack2]);
+           fHistEtaTrigPt[i][MultArray[c]][ievent]->Fill(tEta[iTrack2],tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+
+           fHistPhiEtaTrig[i][MultArray[c]][ievent]->Fill(tPhi[iTrack2],tEta[iTrack2],tPt[iTrack2],tEff[iTrack2]);
+           fHistPhiEtaTrigPt[i][MultArray[c]][ievent]->Fill(tPhi[iTrack2],tEta[iTrack2],tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+           fHistDeltaPhi[i][MultArray[c]][0][ievent]->Fill(tdPhi,tPt[iTrack2],tEff[iTrack2]);
+           fHistDeltaPhiPt[i][MultArray[c]][0][ievent]->Fill(tdPhi,tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+           fHistDeltaPhi[i][MultArray[c]][Sign][ievent]->Fill(tdPhi,tPt[iTrack2],tEff[iTrack2]);
+           fHistDeltaPhiPt[i][MultArray[c]][Sign][ievent]->Fill(tdPhi,tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+
+           if(NearEta){
+           fHistDeltaEtaN[i][MultArray[c]][0][ievent]->Fill(tdEta,tPt[iTrack2],tEff[iTrack2]);
+           fHistDeltaEtaNPt[i][MultArray[c]][0][ievent]->Fill(tdEta,tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+           fHistDeltaEtaN[i][MultArray[c]][Sign][ievent]->Fill(tdEta,tPt[iTrack2],tEff[iTrack2]);
+           fHistDeltaEtaNPt[i][MultArray[c]][Sign][ievent]->Fill(tdEta,tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+           }
+           else{
+           fHistDeltaEtaA[i][MultArray[c]][0][ievent]->Fill(tdEta,tPt[iTrack2],tEff[iTrack2]);
+           fHistDeltaEtaAPt[i][MultArray[c]][0][ievent]->Fill(tdEta,tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+           fHistDeltaEtaA[i][MultArray[c]][Sign][ievent]->Fill(tdEta,tPt[iTrack2],tEff[iTrack2]);
+           fHistDeltaEtaAPt[i][MultArray[c]][Sign][ievent]->Fill(tdEta,tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+           }
+           fHistDeltaPhiEta[i][MultArray[c]][ievent]->Fill(tdPhi,tdEta,tPt[iTrack2],tEff[iTrack2]);
+           fHistDeltaPhiEtaPt[i][MultArray[c]][ievent]->Fill(tdPhi,tdEta,tPt[iTrack2],tPt[iTrack2]*tEff[iTrack2]);
+           
+           //only fill these if trigger particle is the leading particle
+           if(iTrack==LeadPart){
+             if(NearXE){
+               tXE=tPt[iTrack2]*cos(tdPhi)/tPt[iTrack];
+               fHistXEN[i][MultArray[c]][ievent]->Fill(tXE,tEff[iTrack2]);
+             }
+             else{
+               tXE=tPt[iTrack2]*cos(tdPhi+fPi)/tPt[iTrack];
+               fHistXEA[i][MultArray[c]][ievent]->Fill(tXE,tEff[iTrack2]);
+             }
+           }
+
+         }//Centrality loop (c)
+
+         //3-particle Correlations
+         for(int iTrack3=0;iTrack3<nGoodTracks[ievent];iTrack3++){
+           if(iTrack2==iTrack3)continue;
+           if(tPt[iTrack3]>tPt[iTrack])continue;
+           tdPhi2=tPhi[iTrack]-tPhi[iTrack3];
+           if(tdPhi2<-fPi)tdPhi2+=2*fPi;
+           if(tdPhi2>fPi)tdPhi2-=2*fPi;
+           if(fabs(tdPhi2)<fNearPhiCut&&NearEta==1)NearEta2=1;
+           else NearEta2=0;
+           //if(fabs(tdPhi)<fXECut)NearXE=1;
+           //else NearXE=0;
+           if(fabs(tdPhi2)<(fPi/2))tdEta2=tEta[iTrack]-tEta[iTrack3];
+           else tdEta2=tEta[iTrack]+tEta[iTrack3];
+           if(tdPhi2<fdPhiMin)tdPhi2+=2*fPi;
+           if(tdPhi2>fdPhiMax)tdPhi2-=2*fPi;
+           // if((tCharge[iTrack]<0&&tCharge[iTrack2]<0)||(tCharge[iTrack]>0&&tCharge[iTrack2]>0))Sign=1;
+           if((tCharge[iTrack]<0&&tCharge[iTrack2]<0&&tCharge[iTrack3]<0)||(tCharge[iTrack]>0&&tCharge[iTrack2]>0&&tCharge[iTrack3]>0))Sign=1;
+           else if((tCharge[iTrack3]<0&&tCharge[iTrack2]<0)||(tCharge[iTrack3]>0&&tCharge[iTrack2]>0))Sign=2;
+           else Sign=3;
+           for(int e=0;e<tNPtAssoc3[iTrack2];e++){//check associated pT bin
+             for(int f=0;f<tNPtAssoc3[iTrack3];f++){
+               if(tPtAssoc3[iTrack2][e]==tPtAssoc3[iTrack3][f]){
+                 for(int c=0;c<MaxArray;c++){//loop over multiplicity bins
+                   fHistDeltaPhiPhi[i][tPtAssoc3[iTrack2][e]][MultArray[c]][0][ievent]->Fill(tdPhi,tdPhi2,tEff[iTrack2]*tEff[iTrack3]);
+                   fHistDeltaPhiPhi[i][tPtAssoc3[iTrack2][e]][MultArray[c]][Sign][ievent]->Fill(tdPhi2,tdPhi,tEff[iTrack2]*tEff[iTrack3]);
+                
+
+                   if(NearEta2){
+                     fHistDeltaEtaEta[i][tPtAssoc3[iTrack2][e]][MultArray[c]][0][ievent]->Fill(tdEta,tdEta2,tEff[iTrack2]*tEff[iTrack3]);
+                     fHistDeltaEtaEta[i][tPtAssoc3[iTrack2][e]][MultArray[c]][Sign][ievent]->Fill(tdEta,tdEta2,tEff[iTrack2]*tEff[iTrack3]);
+                   }
+                 }//multiplicity loop (c)
+               }
+             }
+           }//track checking loops
+         }//iTrack3
+       }//iTrack2 (associated track loop)
+       
+       if(DEBUG)Printf("Mixed Event Loop");
+       for(int c=0;c<MaxArray;c++){
+         int d=MultArray[c];//Centrality bin we are in
+         if(fMixEnd[d][VertexBin][ievent]>=0){//check if there are any mixed events for this bin
+           for(int imix=0;imix<=fMixEnd[d][VertexBin][ievent];imix++){//loop over the stored mixed events
+             fHistNMix[d][ievent]->Fill(i);
+             for(int iTrack2=0;iTrack2<fMixTrack[imix][d][VertexBin][ievent];iTrack2++){
+               if(tPt[iTrack]<fMPt[imix][d][VertexBin][ievent][iTrack2])continue;
+               tdPhi=tPhi[iTrack]-fMPhi[imix][d][VertexBin][ievent][iTrack2];
+               if(tdPhi<-fPi)tdPhi+=2*fPi;
+               if(tdPhi>fPi)tdPhi-=2*fPi;
+               if(fabs(tdPhi)<fNearPhiCut)NearEta=1;
+               else NearEta=0;
+               if(fabs(tdPhi)<fXECut)NearXE=1;
+               else NearXE=0;
+               if(fabs(tdPhi)<(fPi/2))tdEta=tEta[iTrack]-fMEta[imix][d][VertexBin][ievent][iTrack2];
+               else tdEta=tEta[iTrack]+fMEta[imix][d][VertexBin][ievent][iTrack2];
+               if(tdPhi<fdPhiMin)tdPhi+=2*fPi; 
+               if(tdPhi>fdPhiMax)tdPhi-=2*fPi;
+               if((tCharge[iTrack]<0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]<0)||(tCharge[iTrack]>0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]>0))Sign=1;
+               else Sign=2;
+
+               fHistDeltaPhiMix[i][d][0][ievent]->Fill(tdPhi,fMPt[imix][d][VertexBin][ievent][iTrack2],fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaPhiMixPt[i][d][0][ievent]->Fill(tdPhi,fMPt[imix][d][VertexBin][ievent][iTrack2],fMPt[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaPhiMix[i][d][Sign][ievent]->Fill(tdPhi,fMPt[imix][d][VertexBin][ievent][iTrack2],fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaPhiMixPt[i][d][Sign][ievent]->Fill(tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMPt[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               if(NearEta){
+                 fHistDeltaEtaNMix[i][d][0][ievent]->Fill(tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaEtaNMixPt[i][d][0][ievent]->Fill(tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMPt[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaEtaNMix[i][d][Sign][ievent]->Fill(tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaEtaNMixPt[i][d][Sign][ievent]->Fill(tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMPt[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               }
+               else{
+                 fHistDeltaEtaAMix[i][d][0][ievent]->Fill(tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaEtaAMixPt[i][d][0][ievent]->Fill(tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMPt[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaEtaAMix[i][d][Sign][ievent]->Fill(tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaEtaAMixPt[i][d][Sign][ievent]->Fill(tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMPt[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               }       
+
+               fHistDeltaPhiEtaMix[i][d][ievent]->Fill(tdPhi,tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMEff[imix][d][VertexBin][ievent][iTrack2]);
+               fHistDeltaPhiEtaMixPt[i][d][ievent]->Fill(tdPhi,tdEta,fMPt[imix][d][VertexBin][ievent][iTrack2],fMPt[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack2]);
+
+               if(iTrack==LeadPart){
+                 if(NearXE){
+                   tXE=fMPt[imix][d][VertexBin][ievent][iTrack2]*cos(tdPhi)/tPt[iTrack];
+                   fHistXENMix[i][d][ievent]->Fill(tXE,fMEff[imix][d][VertexBin][ievent][iTrack2]);
+                 }
+                 else{
+                   tXE=fMPt[imix][d][VertexBin][ievent][iTrack2]*cos(tdPhi+fPi)/tPt[iTrack];
+                   fHistXEAMix[i][MultArray[c]][ievent]->Fill(tXE,fMEff[imix][d][VertexBin][ievent][iTrack2]);
+                 }
+               }
+               //3-particle correlation soft-soft term (both associated from the same event)
+               for(int iTrack3=0;iTrack3<fMixTrack[imix][d][VertexBin][ievent];iTrack3++){
+                 if(iTrack3==iTrack2)continue;
+                 if(tPt[iTrack]<fMPt[imix][d][VertexBin][ievent][iTrack3])continue;
+               tdPhi2=tPhi[iTrack]-fMPhi[imix][d][VertexBin][ievent][iTrack3];
+               if(tdPhi2<-fPi)tdPhi2+=2*fPi;
+               if(tdPhi2>fPi)tdPhi2-=2*fPi;
+               if(fabs(tdPhi2)<fNearPhiCut&&NearEta)NearEta2=1;
+               else NearEta2=0;
+               if(fabs(tdPhi2)<(fPi/2))tdEta2=tEta[iTrack]-fMEta[imix][d][VertexBin][ievent][iTrack3];
+               else tdEta2=tEta[iTrack]+fMEta[imix][d][VertexBin][ievent][iTrack3];
+               if(tdPhi2<fdPhiMin)tdPhi2+=2*fPi;       
+               if(tdPhi2>fdPhiMax)tdPhi2-=2*fPi;
+               //if((tCharge[iTrack]<0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]<0)||(tCharge[iTrack]>0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]>0))Sign=1;
+               //else Sign=2;
+               if((tCharge[iTrack]<0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]<0&&fMCharge[imix][d][VertexBin][ievent][iTrack3]<0)||(tCharge[iTrack]>0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]>0&&fMCharge[imix][d][VertexBin][ievent][iTrack3]>0))Sign=1;
+               else if((fMCharge[imix][d][VertexBin][ievent][iTrack3]<0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]<0)||(fMCharge[imix][d][VertexBin][ievent][iTrack3]>0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]>0))Sign=2;
+               else Sign=3;
+               for(int e=0;e<fMNPtAssoc3[imix][d][VertexBin][ievent][iTrack2];e++){//check associated pT bin
+                 for(int f=0;f<fMNPtAssoc3[imix][d][VertexBin][ievent][iTrack3];f++){
+                   if(fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]==fMPtAssoc3[imix][d][VertexBin][ievent][f][iTrack3]){
+                     fHistDeltaPhiPhiSS[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][0][ievent]->Fill(tdPhi,tdPhi2,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack3]);
+                     fHistDeltaPhiPhiSS[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][Sign][ievent]->Fill(tdPhi,tdPhi2,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack3]); 
+
+                     if(NearEta2){
+                       fHistDeltaEtaEtaSS[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][0][ievent]->Fill(tdEta,tdEta2,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack3]);
+                       fHistDeltaEtaEtaSS[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][Sign][ievent]->Fill(tdEta,tdEta2,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix][d][VertexBin][ievent][iTrack3]);
+                     }//near-side
+                   }
+                 }
+               }//associated pt bin
+               }//iTrack3
+
+               //3-particle mixed event (associated from different events)
+               //for(int imix2=0;imix2<=fMixEnd[d][VertexBin][ievent];imix2++){//loop over the stored mixed events
+               //if(imix2==imix)continue;
+                 int imix2=imix+1;
+                 if(imix2>=fMixEnd[d][VertexBin][ievent])imix2=0;
+                 if(imix2==imix)continue;//will kill it when there is only 1 mixed event (remember to scale by 1 less then the number of mixed events in others (number of mixed-mixed is 2*(mixed-1)))
+                 for(int iTrack3=0;iTrack3<fMixTrack[imix2][d][VertexBin][ievent];iTrack3++){
+                   if(tPt[iTrack]<fMPt[imix2][d][VertexBin][ievent][iTrack3])continue;
+                   tdPhi2=tPhi[iTrack]-fMPhi[imix2][d][VertexBin][ievent][iTrack3];
+                   if(tdPhi2<-fPi)tdPhi2+=2*fPi;
+                   if(tdPhi2>fPi)tdPhi2-=2*fPi;
+                   if(fabs(tdPhi2)<fNearPhiCut&&NearEta)NearEta2=1;
+                   else NearEta2=0;
+                   if(fabs(tdPhi2)<(fPi/2))tdEta2=tEta[iTrack]-fMEta[imix2][d][VertexBin][ievent][iTrack3];
+                   else tdEta2=tEta[iTrack]+fMEta[imix2][d][VertexBin][ievent][iTrack3];
+                   if(tdPhi2<fdPhiMin)tdPhi2+=2*fPi;   
+                   if(tdPhi2>fdPhiMax)tdPhi2-=2*fPi;
+                   //if((tCharge[iTrack]<0&&fMCharge[imix2][d][VertexBin][ievent][iTrack2]<0)||(tCharge[iTrack]>0&&fMCharge[imix2][d][VertexBin][ievent][iTrack2]>0))Sign=1;
+                   //else Sign=2;
+                   if((tCharge[iTrack]<0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]<0&&fMCharge[imix2][d][VertexBin][ievent][iTrack3]<0)||(tCharge[iTrack]>0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]>0&&fMCharge[imix2][d][VertexBin][ievent][iTrack3]>0))Sign=1;
+                   else if((fMCharge[imix2][d][VertexBin][ievent][iTrack3]<0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]<0)||(fMCharge[imix2][d][VertexBin][ievent][iTrack3]>0&&fMCharge[imix][d][VertexBin][ievent][iTrack2]>0))Sign=2;
+                   else Sign=3;
+                   for(int e=0;e<fMNPtAssoc3[imix][d][VertexBin][ievent][iTrack2];e++){//check associated pT bin
+                     for(int f=0;f<fMNPtAssoc3[imix2][d][VertexBin][ievent][iTrack3];f++){
+                       if(fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]==fMPtAssoc3[imix2][d][VertexBin][ievent][f][iTrack3]){
+                         fHistDeltaPhiPhiMix[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][0][ievent]->Fill(tdPhi,tdPhi2,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix2][d][VertexBin][ievent][iTrack3]);
+                         fHistDeltaPhiPhiMix[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][Sign][ievent]->Fill(tdPhi,tdPhi2,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix2][d][VertexBin][ievent][iTrack3]); 
+                         fHistDeltaPhiPhiMix[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][0][ievent]->Fill(tdPhi2,tdPhi,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix2][d][VertexBin][ievent][iTrack3]);//free factor of 2 in statistics
+                         fHistDeltaPhiPhiMix[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][Sign][ievent]->Fill(tdPhi2,tdPhi,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix2][d][VertexBin][ievent][iTrack3]); 
+                     if(NearEta2){
+                       fHistDeltaEtaEtaMix[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][0][ievent]->Fill(tdEta,tdEta2,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix2][d][VertexBin][ievent][iTrack3]);
+                       fHistDeltaEtaEtaMix[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][Sign][ievent]->Fill(tdEta,tdEta2,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix2][d][VertexBin][ievent][iTrack3]);
+                       fHistDeltaEtaEtaMix[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][0][ievent]->Fill(tdEta2,tdEta,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix2][d][VertexBin][ievent][iTrack3]);
+                       fHistDeltaEtaEtaMix[i][fMPtAssoc3[imix][d][VertexBin][ievent][e][iTrack2]][d][Sign][ievent]->Fill(tdEta2,tdEta,fMEff[imix][d][VertexBin][ievent][iTrack2]*fMEff[imix2][d][VertexBin][ievent][iTrack3]);
+                     }//near-side
+                       }
+                     }
+                   }//associated pt bin
+                 }//iTrack3
+
+             }//iTrack2
+             }//imix
+           }//fMixEnd
+         }//Centrality bins (c)
+       }//pt trig cuts
+      }//i Pt Trig
+    }//itrack    
+  
+  //now store this event for mixing (using these dynamic arrays instead of the other fix to save memory)
+    if(DEBUG)Printf("Store Event For Mixing");
+  for(int c=0;c<MaxArray;c++){//loops over centrality bins
+    int d=MultArray[c];//too many nested arrays looked confusing d=which centrality bin
+    if(fMixEnd[d][VertexBin][ievent]<(fNMix-1))fMixEnd[d][VertexBin][ievent]++;
+    if(fMixPointer[d][VertexBin][ievent]<(fNMix-1))fMixPointer[d][VertexBin][ievent]++;
+    else fMixPointer[d][VertexBin][ievent]=0;
+    int e=fMixPointer[d][VertexBin][ievent];//nested arrays (e is event number in pool)
+    delete [] fMPt[e][d][VertexBin][ievent];
+    delete [] fMPhi[e][d][VertexBin][ievent];
+    delete [] fMEta[e][d][VertexBin][ievent];
+    delete [] fMCharge[e][d][VertexBin][ievent];
+    delete [] fMEff[e][d][VertexBin][ievent];
+    delete [] fMNPtAssoc3[e][d][VertexBin][ievent];
+    for(int jj=0;jj<10;jj++){
+    delete [] fMPtAssoc3[e][d][VertexBin][ievent][jj];
+    }
+    fMPt[e][d][VertexBin][ievent]=new Float_t [nGoodTracks[ievent]];
+    fMPhi[e][d][VertexBin][ievent]=new Float_t [nGoodTracks[ievent]];
+    fMEta[e][d][VertexBin][ievent]=new Float_t [nGoodTracks[ievent]];
+    fMCharge[e][d][VertexBin][ievent]=new Short_t [nGoodTracks[ievent]];
+    fMEff[e][d][VertexBin][ievent]=new Float_t [nGoodTracks[ievent]];
+    fMixTrack[e][d][VertexBin][ievent]=nGoodTracks[ievent];
+    fMNPtAssoc3[e][d][VertexBin][ievent]=new Short_t [nGoodTracks[ievent]];
+    for(int jj=0;jj<10;jj++){
+    fMPtAssoc3[e][d][VertexBin][ievent][jj]=new Short_t [nGoodTracks[ievent]];
+    }
+
+    for(int iTrack=0;iTrack<nGoodTracks[ievent];iTrack++){
+      fMPt[e][d][VertexBin][ievent][iTrack]=tPt[iTrack];
+      fMPhi[e][d][VertexBin][ievent][iTrack]=tPhi[iTrack];
+      fMEta[e][d][VertexBin][ievent][iTrack]=tEta[iTrack];
+      fMCharge[e][d][VertexBin][ievent][iTrack]=tCharge[iTrack];
+      fMEff[e][d][VertexBin][ievent][iTrack]=tEff[iTrack];
+      fMNPtAssoc3[e][d][VertexBin][ievent][iTrack]=tNPtAssoc3[iTrack];
+      // fMPtAssoc3[e][d][VertexBin][ievent][iTrack]=new Int_t [tNPtAssoc3[iTrack]];
+      for(int jj=0;jj<tNPtAssoc3[iTrack];jj++){
+       //if(DEBUG) Printf("%d",tPtAssoc3[iTrack][jj]);
+       fMPtAssoc3[e][d][VertexBin][ievent][jj][iTrack]=tPtAssoc3[iTrack][jj];
+      }
+      
+    }//iTracks
+  }//Centrality (c)
+  }//ievent
+  //track=0;
+  //track2=0;
+
+  PostData(0, fOutput);
+  //get rid of these arrays from memory
+  delete [] tPhi;
+  delete [] tEta;
+  delete [] tPt;
+  delete [] tCharge;
+  delete [] tEff;
+  delete [] tNPtAssoc3;
+  delete [] tPtAssoc3;
+  tPhi=NULL;
+  tEta=NULL;
+  tPt=NULL;
+  tCharge=NULL;
+  tEff=NULL;
+  tNPtAssoc3=NULL;
+  tPtAssoc3=NULL;
+
+}//Exec
+
+//---------------------------------------------------
+void AliAnalysisTaskDiHadron::Terminate(Option_t *){
+  for(int ii=0;ii<fNMix;ii++){
+    for(int cc=0;cc<fNCentBins;cc++){
+      for(int vtx=0;vtx<fNVertexBins;vtx++){
+       for(int jj=0;jj<2;jj++){
+         delete [] fMPt[ii][cc][vtx][jj];
+         delete [] fMPhi[ii][cc][vtx][jj];
+         delete [] fMEta[ii][cc][vtx][jj];
+         delete [] fMCharge[ii][cc][vtx][jj];
+         delete [] fMEff[ii][cc][vtx][jj];
+         delete [] fMNPtAssoc3[ii][cc][vtx][jj];
+         for(int qq=0;qq<10;qq++){
+           delete [] fMPtAssoc3[ii][cc][vtx][jj][qq];
+           fMPtAssoc3[ii][cc][vtx][jj][qq]=NULL;
+         }
+         fMPt[ii][cc][vtx][jj]=NULL;
+         fMPhi[ii][cc][vtx][jj]=NULL;
+         fMEta[ii][cc][vtx][jj]=NULL;
+         fMCharge[ii][cc][vtx][jj]=NULL;
+         fMEff[ii][cc][vtx][jj]=NULL;
+         fMNPtAssoc3[ii][cc][vtx][jj]=NULL;
+
+       }
+      }
+    }
+  }
+  Printf("Terminate AliAnalysisTaskDiHadron");
+}
diff --git a/PWG4/JCORRAN/AliAnalysisTaskDiHadron.h b/PWG4/JCORRAN/AliAnalysisTaskDiHadron.h
new file mode 100755 (executable)
index 0000000..45cda05
--- /dev/null
@@ -0,0 +1,237 @@
+#ifndef AliAnalysisTaskDiHadron_cxx
+#define AliAnalysisTaskDiHadron_cxx
+
+
+class TH1F;
+class TH2F;
+class TH3F;
+class AliESDEvent;
+
+#include "TH1.h"
+#include "TH2.h"
+#include "TH3.h"
+#include "AliAnalysisTask.h"
+
+
+class AliAnalysisTaskDiHadron : public AliAnalysisTask{
+  //Default constructor
+ public:
+
+
+  AliAnalysisTaskDiHadron(const char *name="AliAnalysisTaskDiHadron");
+
+  virtual ~AliAnalysisTaskDiHadron() {}
+  //virtual ~AliAnalysisTaskDiHadron();
+
+
+  //AliAnalysisTask Functions
+  virtual void ConnectInputData(Option_t *option);
+  virtual void CreateOutputObjects();
+  virtual void Exec(Option_t *option);
+  virtual void Terminate(Option_t *);
+
+  void SetEfficiencies(Float_t EffFitPt, TF1 *FitLow, TF1 *FitHigh, Int_t NFitLowParam, Int_t NFitHighParam, Float_t *FitLowParam, Float_t *FitHighParam);
+  void SetBins(Int_t nBinPhi, Int_t nBinEta, Int_t nBinPhiEtaPhi, Int_t nBinPhiEtaEta, Int_t nBinPhi3, Int_t nBinEta3, Float_t dPhiMin, Float_t dPhiMax, Int_t NTPtBins, Int_t NMixBins, Int_t NCentBins,Int_t NAPtBins, Int_t NAPt3Bins, Int_t NVertexBins, Int_t NXEBin,Float_t *PtTrigArray, Float_t *PtAssocArray, Float_t *PtAssoc3Array1, Float_t *PtAssoc3Array2, Int_t *CentArrayMin, Int_t *CentArrayMax, Float_t *XEArray);
+  void SetOptions(Int_t fEfficiencyCorr, Int_t DEBUG,Int_t fMCHistos);
+  void SetCuts(Int_t MinClutersTPC, Float_t MinClusterRatio, Float_t MaxTPCchi2, Int_t MinClustersITS, Float_t EtaCut, Float_t TrigEtaCut, Float_t NearPhiCut, Float_t XECut, Float_t MaxDCA, Float_t MaxDCAXY, Float_t MaxDCAZ, Int_t DCA2D, Int_t TPCRefit, Int_t ITSRefit, Int_t SPDCut, Float_t MinPtAssoc, Float_t MaxPtAssoc, Float_t VzCut, Int_t NIDs, char **TrigIDArray);
+  Int_t CheckVertex(AliESDEvent *rESD);
+  Int_t CheckTrigger(AliESDEvent *rESD);
+  Int_t TrackCuts(AliESDEvent *rESD, Float_t *rPt, Float_t *rEta, Float_t *rPhi, Short_t *rCharge, Float_t *rEff, Int_t **rPtAssoc3, Int_t *rNPtAssoc3, Int_t *rGoodTracks);
+  Int_t TrackCutsMC(AliMCEvent *rMC, Float_t *rPt, Float_t *rEta, Float_t *rPhi, Short_t *rCharge, Float_t *rEff, Int_t **rPtAssoc3, Int_t *rNPtAssoc3, Int_t *rGoodTracks);
+
+  
+ private:
+
+//Maximum numbers for creating the arrays
+  enum{NUMBER_OF_PT_BINS=20, 
+       NUMBER_OF_CENT_BINS=10, 
+       NUMBER_OF_APT_BINS=50,
+       NUMBER_OF_APT3_BINS=50,
+       NUMBER_OF_TRIGGER_IDS=1,
+       NUMBER_OF_VERTEX_BINS=20,
+       NUMBER_OF_XE_BINS=20,
+       NUMBER_OF_EVENTS_TO_MIX=100};
+  // virtual void SetParameters();
+  AliESDEvent *fESD;
+  AliMCEvent *fMC;
+  TList *fOutput;
+  
+   //Cuts
+  
+    Int_t fMinClustersTPC;
+    Float_t fMinClusterRatio;
+    Float_t fMaxTPCchi2;
+    Int_t fMinClustersITS;
+    Float_t fEtaCut;
+    Float_t fTrigEtaCut;
+    Float_t fNearPhiCut;
+    Float_t fXECut;
+    Float_t fMaxDCA;
+    Float_t fMaxDCAXY;
+    Float_t fMaxDCAZ;
+    Int_t fDCA2D;
+    Int_t fTPCRefit;
+    Int_t fITSRefit;
+    Int_t fSPDCut;
+    Float_t fMinPtAssoc;
+    Float_t fMaxPtAssoc;
+    Float_t fVzCut;
+    Int_t fEfficiencyCorr;//Toggle correcting of efficiencies when filling histograms
+    Int_t DEBUG;
+    //Binning
+    Int_t fnBinPhi;
+    Int_t fnBinEta;
+    Int_t fnBinPhiEtaPhi;
+    Int_t fnBinPhiEtaEta;
+    Int_t fnBinPhi3;
+    Int_t fnBinEta3;
+    Float_t fPi;
+    Float_t fdPhiMin;
+    Float_t fdPhiMax;
+    //Parameters for settings
+    Int_t fNTPtBins;
+    Int_t fNMix;
+    Int_t fNCentBins;
+    Int_t fNAPtBins;
+    Int_t fNAPt3Bins;
+    Int_t fNVertexBins;
+    Int_t fNXEBins;
+    Int_t fNIDs;
+    Float_t fEffFitPt;
+    Int_t fNFitLowParam;
+    Int_t fNFitHighParam;
+    Int_t fMCHistos;
+    //TF1 *fFitLow;
+    //  TF1 *fFitHigh;
+    Int_t fNFitLow;
+    Int_t fNFitHigh;
+
+    TF1 *fFitLow;
+    TF1 *fFitHigh;
+    Float_t *fFitLowParam; 
+    Float_t *fFitHighParam;
+    Float_t *fPtTrigArray;
+    Float_t *fPtAssocArray;
+    Float_t *fPtAssoc3Array1;
+    Float_t *fPtAssoc3Array2; 
+    Int_t *fCentArrayMin;
+    Int_t *fCentArrayMax;
+    Float_t *fXEArray;
+    char **fTrigIDArray;
+
+    /*
+    //Float_t *FitLowParam;
+    //   Float_t *FitHighParam;
+    //    Float_t fPtTrigArray[(NUMBER_OF_PT_BINS+1)];
+    Float_t fPtAssocArray[(NUMBER_OF_APT_BINS+1)];
+    Float_t fPtAssoc3Array1[NUMBER_OF_APT3_BINS];
+    Float_t fPtAssoc3Array2[NUMBER_OF_APT3_BINS];
+    Int_t fCentArrayMin[NUMBER_OF_CENT_BINS];
+    Int_t fCentArrayMax[NUMBER_OF_CENT_BINS];
+    Float_t fXEArray[(NUMBER_OF_XE_BINS+1)];
+    char *fTrigIDArray[NUMBER_OF_TRIGGER_IDS];
+  */
+  Float_t fVertexArray[(NUMBER_OF_VERTEX_BINS+1)];
+  
+  //Histograms
+  TH1F *fHistPt[NUMBER_OF_CENT_BINS][2];
+  TH1F *fHistPtEff[NUMBER_OF_CENT_BINS][2];
+  TH1F *fHistPtTrig[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH1F *fHistMult[2];
+  TH1F *fHistMultTrig[NUMBER_OF_PT_BINS][2];
+
+  TH2F *fHistPhi[NUMBER_OF_CENT_BINS][2];
+  TH2F *fHistPhiTrig[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH2F *fHistDeltaPhi[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+  TH2F *fHistDeltaPhiMix[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+
+  TH2F *fHistPhiPt[NUMBER_OF_CENT_BINS][2];
+  TH2F *fHistPhiTrigPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH2F *fHistDeltaPhiPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+  TH2F *fHistDeltaPhiMixPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+
+  TH2F *fHistEta[NUMBER_OF_CENT_BINS][2];
+  TH2F *fHistEtaTrig[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+
+  TH2F *fHistEtaPt[NUMBER_OF_CENT_BINS][2];
+  TH2F *fHistEtaTrigPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+
+  TH2F *fHistDeltaEtaN[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+  TH2F *fHistDeltaEtaNMix[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+
+  TH2F *fHistDeltaEtaNPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+  TH2F *fHistDeltaEtaNMixPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+
+  TH2F *fHistDeltaEtaA[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+  TH2F *fHistDeltaEtaAMix[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+
+  TH2F *fHistDeltaEtaAPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+  TH2F *fHistDeltaEtaAMixPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][3][2];
+
+  TH1F *fHistNEvents[NUMBER_OF_CENT_BINS][2];
+  TH1F *fHistNTrigger[NUMBER_OF_CENT_BINS][2];
+  TH1F *fHistNTriggerPt[NUMBER_OF_CENT_BINS][2];
+  TH1F *fHistNMix[NUMBER_OF_CENT_BINS][2];
+
+  TH3F *fHistPhiEta[NUMBER_OF_CENT_BINS][2];
+  TH3F *fHistPhiEtaTrig[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH3F *fHistDeltaPhiEta[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH3F *fHistDeltaPhiEtaMix[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+
+  TH3F *fHistPhiEtaPt[NUMBER_OF_CENT_BINS][2];
+  TH3F *fHistPhiEtaTrigPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH3F *fHistDeltaPhiEtaPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH3F *fHistDeltaPhiEtaMixPt[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+
+  TH1F *fHistXEN[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH1F *fHistXENMix[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH1F *fHistXEA[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+  TH1F *fHistXEAMix[NUMBER_OF_PT_BINS][NUMBER_OF_CENT_BINS][2];
+
+  //Three-Particle Histograms
+  TH2F *fHistDeltaPhiPhi[NUMBER_OF_PT_BINS][NUMBER_OF_APT3_BINS][NUMBER_OF_CENT_BINS][4][2];
+  TH2F *fHistDeltaPhiPhiMix[NUMBER_OF_PT_BINS][NUMBER_OF_APT3_BINS][NUMBER_OF_CENT_BINS][4][2];
+  TH2F *fHistDeltaPhiPhiSS[NUMBER_OF_PT_BINS][NUMBER_OF_APT3_BINS][NUMBER_OF_CENT_BINS][4][2];
+  TH2F *fHistDeltaEtaEta[NUMBER_OF_PT_BINS][NUMBER_OF_APT3_BINS][NUMBER_OF_CENT_BINS][4][2];
+  TH2F *fHistDeltaEtaEtaMix[NUMBER_OF_PT_BINS][NUMBER_OF_APT3_BINS][NUMBER_OF_CENT_BINS][4][2];
+  TH2F *fHistDeltaEtaEtaSS[NUMBER_OF_PT_BINS][NUMBER_OF_APT3_BINS][NUMBER_OF_CENT_BINS][4][2];
+
+
+
+  //Arrays for event mixing
+  Float_t *fMPt[NUMBER_OF_EVENTS_TO_MIX][NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2];
+  Float_t *fMPhi[NUMBER_OF_EVENTS_TO_MIX][NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2]; 
+  Int_t fMixTrack[NUMBER_OF_EVENTS_TO_MIX][NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2];
+  Float_t *fMEta[NUMBER_OF_EVENTS_TO_MIX][NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2];
+  Short_t *fMCharge[NUMBER_OF_EVENTS_TO_MIX][NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2];
+   Float_t *fMEff[NUMBER_OF_EVENTS_TO_MIX][NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2];
+  Int_t fMixPointer[NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2];
+  Int_t fMixEnd[NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2]; 
+  //additional ones to speed up the 3-particle correlations
+  Short_t *fMPtAssoc3[NUMBER_OF_EVENTS_TO_MIX][NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2][10];//using a bit extra memory fixing the pt bins to 10, but makes the arrays much easier
+  Short_t *fMNPtAssoc3[NUMBER_OF_EVENTS_TO_MIX][NUMBER_OF_CENT_BINS][NUMBER_OF_VERTEX_BINS][2];
+  
+
+  //Arrays for Main Events
+  Float_t *tPhi;
+  Float_t *tEta;
+  Float_t *tPt;
+  Short_t *tCharge;
+  Float_t *tEff;
+  Int_t **tPtAssoc3;
+  Int_t *tNPtAssoc3;
+
+  AliAnalysisTaskDiHadron(const AliAnalysisTaskDiHadron&);//not implimented
+  AliAnalysisTaskDiHadron& operator=(const AliAnalysisTaskDiHadron&);//not implimnted
+
+  ClassDef(AliAnalysisTaskDiHadron,1);
+  
+};
+#endif
+  
+  
index bd4f947..22f6180 100755 (executable)
@@ -18,5 +18,5 @@
 #pragma link C++ class AliPhJPiZero+;
 #pragma link C++ class AliJCORRANSetup+;
 #pragma link C++ class AliJCORRANTask+;
-
+#pragma link C++ class AliAnalysisTaskDiHadron+;
 #endif /* __CINT__ */
index 35eb301..51158bd 100755 (executable)
@@ -13,7 +13,8 @@ SRCS=   JCORRAN/AliPhJBaseTrack.cxx \
         JCORRAN/AliPhJHeaderList.cxx \
         JCORRAN/AliJRunHeader.cxx \
        JCORRAN/AliJCORRANSetup.cxx \
-       JCORRAN/AliJCORRANTask.cxx
+       JCORRAN/AliJCORRANTask.cxx \
+       JCORRAN/AliAnalysisTaskDiHadron.cxx
 
 HDRS:= $(SRCS:.cxx=.h) JCORRAN/JConst.h 
 
diff --git a/PWG4/macros/AddTaskDiHadron.C b/PWG4/macros/AddTaskDiHadron.C
new file mode 100755 (executable)
index 0000000..191fd67
--- /dev/null
@@ -0,0 +1,136 @@
+//#include "exception.h"
+//For running at CERN
+AliAnalysisTask *AddTaskDiHadron(){
+  //get the current analysis manager
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    Error("AddTask_DiHadron", "No analysis manager found.");
+    return 0;
+  }
+
+  
+  //=========  Set initial parameters=====
+
+  //Track Quality Cuts
+  Int_t MinimumClustersTPC=70;
+  Float_t MinClusterRatio=0.1;//1/2 would remove split tracks if not for sharing of clusters
+  Float_t MaxTPCchi2=4;
+  Int_t MinimumClustersITS=0;
+  Float_t EtaCut=0.8;//Tracks in +/- Eta are used
+  Float_t TriggerEtaCut=0.5;//Smaller trigger for flat acceptance on near-side
+  Float_t NearPhiCut=1.5;//Cut used to seperate near and away side for delta eta plots
+  Float_t XECut=NearPhiCut;//For XE distribution near and away seperation
+  Float_t MaxDCA=3;//Total DCA Cut
+  Float_t MaxDCAXY=2.4;
+  Float_t MaxDCAZ=3.2;
+  Int_t DCAMethod=2;//0 MaxDCA used, 1 MaxDCAXY and MaxDCAZ used 2 pT dependent DCA cut
+  Int_t TPCRefit=1;
+  Int_t ITSRefit=1;//1 for all particles, 2 for particles above 5 GeV/c
+  Int_t SPDCut=1;//check for a point in 1 of first 2 layers of the its
+ Float_t MinimumPt=0.25;//Minimum Pt considered by the code
+  Float_t MaximumPt=50;
+  Float_t ZVertexCut=10;//in cm
+
+  Int_t EfficiencyCorrection=1;//do efficiency corrections in this code
+  Int_t MakeMCHistos=1;//if 0 MC histograms are not made (will be empty if 1 and ran on real data)
+  Int_t DEBUG=0;//for debugging
+  
+  //Binning
+  Int_t nBinPhi=60;//Number of bins for #Delta#phi histograms
+  Int_t nBinEta=54;//Number of bins for #Delta#eta histograms
+  Int_t nBinsPhiEtaPhi=20;//Number of bins for #Delta#phi-#Delta#eta in #Delta#phi
+  Int_t nBinsPhiEtaEta=18;//Number of bins for #Delta#phi-#Delta#eta in #Delta#phi
+  Int_t nBinsPhiPhi=30;//Number of bins for #Delta#phi-#Delta#phi
+  Int_t nBinsEtaEta=27;//Number of bins for #Delta#eta-#Delta#eta
+  const Float_t fPi=3.1415926535898;
+  Float_t PhiPlotMin=-fPi/3;//Min bin edge in #Delta#phi
+  Float_t PhiPlotMax=2*fPi+PhiPlotMin;//Max bin edge
+  
+  //Size of some arrays change array contents below
+  const Int_t NTriggerPtBins=12;//max=20
+  const Int_t NEventsToMix=100;//max=100
+  const Int_t NCentralityBins=4;//max=10
+  const Int_t NAssociatedPtBins=25;//max=50
+  const Int_t N3ParticleAssociatedPtBins=10;//max=50
+  const Int_t NZVertexBinsForMixing=7;//max=20
+  const Int_t NXEBins=11;//max=20
+  const Int_t NumberOfTriggerIDs=1;
+  Float_t EffFitPtCut=3;
+
+  TF1 *EfficiencyFitLow=new TF1("EfficiencyFitLow","[0]/[1]*exp(-0.5*pow(x/[1],2))+[2]+[3]*x",MinimumPt,EffFitPtCut);
+   TF1 *EfficiencyFitHigh=new TF1("EfficiencyFitHigh","[0]",EffFitPtCut,MaximumPt);
+   const Int_t NParamFitLow=4;
+   const Int_t NParamFitHigh=1;
+
+   //Not high enough occupancy to worry about the centrality in pp
+   //For overlapping centrality bins efficiencies from first bin are used
+   //7Pythia_LHC10b5
+   Float_t FitLowParam[NCentralityBins*NParamFitLow]={
+     -0.030749, 0.254311, 0.858824, -0.0323708,
+     -0.0304332, 0.252195, 0.851405, -0.03164,
+     -0.0295618, 0.248594, 0.869159, -0.0354148,
+     -0.0300529, 0.236693, 0.875875, -0.0370379};
+   
+   Float_t FitHighParam[NCentralityBins*NParamFitHigh]={
+     0.75813,
+     0.750521,
+     0.751902,
+     0.68658};
+
+   /*
+   //LHC10c6_900Pythia
+   Float_t FitLowParam[NCentralityBins*NParamFitLow]={
+     -0.027393, 0.236723, 0.814427, -0.023897,
+     -0.0271116, 0.232689, 0.809889, -0.0246341,
+     -0.0284658, 0.245163, 0.856043, -0.0318309,
+     -0.117114, 0.0355117, 0.828829, -0.0207492}
+   
+   Float_t FightHighParam[NCentralityBins*NParamFitHigh]={
+     0.729888,
+     0.719402,
+     0.708409,
+     0.829268}
+   */
+
+
+  Float_t TriggerPtBins[(NTriggerPtBins+1)]={2,2.5,3,4,6,8,10,15,20,30,40,50};
+  Float_t AssociatedPtBins[(NAssociatedPtBins+1)]={0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,12,15,20,25,30,40,50,70,100};
+  Float_t AssociatedPtBins31[N3ParticleAssociatedPtBins]={0.5,1.0,1.5,2.0,3,4,1};
+  Float_t AssociatedPtBins32[N3ParticleAssociatedPtBins]={1.0,1.5,2.0,3.0,4,5,2};
+  Int_t CentralityBins1[NCentralityBins]={0,     0, 20, 40};
+  Int_t CentralityBins2[NCentralityBins]={500,20,40,500};
+  Float_t XEBins[(NXEBins+1)]={0,0.05,0.1,0.15,0.2,0.3,0.4,0.5,0.6,0.7,0.8,1};
+  char *TriggerIDArray[NumberOfTriggerIDs]={"CINT1B"};
+
+  //==================================
+  //Add the task
+  //===================================
+  AliAnalysisTaskDiHadron *task = new AliAnalysisTaskDiHadron("DiHadron");
+  task->SetCuts(MinimumClustersTPC,MinClusterRatio,MaxTPCchi2,MinimumClustersITS, EtaCut,TriggerEtaCut,NearPhiCut,XECut,MaxDCA,MaxDCAXY,MaxDCAZ, DCAMethod, TPCRefit,ITSRefit,SPDCut,MinimumPt,MaximumPt,ZVertexCut,NumberOfTriggerIDs,TriggerIDArray);
+  task->SetOptions(EfficiencyCorrection,DEBUG,MakeMCHistos);
+  task->SetBins(nBinPhi,nBinEta,nBinsPhiEtaPhi,nBinsPhiEtaEta,nBinsPhiPhi,nBinsEtaEta,PhiPlotMin,PhiPlotMax,NTriggerPtBins,NEventsToMix,NCentralityBins,NAssociatedPtBins,N3ParticleAssociatedPtBins,NZVertexBinsForMixing,NXEBins,TriggerPtBins,AssociatedPtBins,AssociatedPtBins31,AssociatedPtBins32,CentralityBins1,CentralityBins2,XEBins);
+  task->SetEfficiencies(EffFitPtCut,EfficiencyFitLow,EfficiencyFitHigh,NParamFitLow,NParamFitHigh,FitLowParam,FitHighParam);
+  mgr->AddTask(task);
+
+
+  //================================================
+  //              data containers
+  //================================================
+ AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
+  mgr->ConnectInput(task, 0, cinput); 
+
+  
+  //            define output containers, please use 'username'_'somename'
+  AliAnalysisDataContainer *coutput1 = 
+    mgr->CreateContainer("DiHadron", TList::Class(),
+                            AliAnalysisManager::kOutputContainer,"DiHadron.root");
+
+  //           connect containers
+  mgr->ConnectInput  (task,  0, cinput );
+  mgr->ConnectOutput (task,  0, coutput1);
+
+  return task;
+}
diff --git a/PWG4/macros/jcorran/Draw3Particle.C b/PWG4/macros/jcorran/Draw3Particle.C
new file mode 100755 (executable)
index 0000000..f9de5db
--- /dev/null
@@ -0,0 +1,911 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+//Draw 3-Particle correlations plots (using output of AliAnalysisTaskDiHadron)
+//Author: Jason Glyndwr Ulery, ulery@uni-frankfurt.de
+
+#ifndef __CINT__
+#include <TF1.h>
+#include <TF2.h>
+#include "TSystem.h"
+#include <iostream>
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TRandom.h>
+#include <fstream>
+#include "TList.h"
+#include "TArrayF.h"
+#endif
+void Draw3Particle(float TPt1, float TPt2, float APt1, float APt2, float Cent1, float Cent2, int LSign=0){//ptWeighted 0 no weight, 1 weighted, 2 <pt>; Lsign 0-all, 1-like-sign 2-unlike-sign
+  gROOT->Reset();
+  gROOT->LoadMacro("Util9.C");
+  Style(1);
+  int SaveRoot=1;
+  int SavePS=1;
+  int SavePDF=0;
+  float ZYACent=1.5;//-0to-1.99 2-particle stripes -2 two-particle 3-D min, -3 3-particle PhiPhi Min
+  float ZYAWidth=0.2; 
+  int ReBinPhi=1;
+  int ReBinEta=1;
+  int DrawAsHisto=0;
+  int noTitle=1;
+  int SaveMacro=0;
+  int SaveText=1;
+  int DrawMC=1;
+  int EffMethod=0;//0 no correction, 1 angle dependent, 2 use mix for triggered, 3 <1>, 4 fits, 5  fits with VariablePtLimit
+  //int SaveEffFits=1;
+  char *fileType=".gif";
+  
+  //char *Folder="2010-08-17/LHC10b_7pass2";
+  //char *Folder="2010-08-17/LHC10c_900pass2";
+  //char *Folder="2010-08-17/LHC10c6_900Pythia";
+  char *Folder="2010-08-17/7Pythia_LHC10b5"; 
+
+  //char *EffFolder="2010-08-17/LHC10c6_900Pythia";
+  char *EffFolder="2010-08-17/7Pythia_LHC10b5"; 
+  
+  char *cPt[3]={"","Pt","MPt"};
+  char *cDelta[2]={"Delta",""};
+  char *csign[3]={"","LS","ULS"};
+  char name[300];
+  char inName[100];
+  char effName[100];
+  sprintf(inName,"%s/julery_DiHadron.root",Folder);
+  sprintf(effName,"%s/julery_DiHadron.root",EffFolder);
+  cout << inName << endl;
+  cout << effName << endl;
+  char *titArray[2]={"","_NoTitle"};
+  char *histArray[2]={"","_Histo"};
+  
+  Float_t MPt[4];//<pt>, error <pt>, # of triggers
+  Float_t MPt2[4];
+  Float_t TrigSum=0, TrigSum2=0;
+  
+  TH1F *hPhiRaw=new TH1F("hPhiRaw","",1,0,1);
+  TH1F *hPhiCorr=new TH1F("hPhiCorr","",1,0,1);
+  TH1F *hPhiEff=new TH1F("hPhiEff","",1,0,1);
+  TH1F *hPhiMC=new TH1F("hPhiMC","",1,0,1);
+  TH1F *hPhiMixRaw=new TH1F("hPhiMixRaw","",1,0,1);
+  TH1F *hPhiMixCorr=new TH1F("hPhiMixCorr","",1,0,1);
+  TH1F *hPhiMixEff=new TH1F("hPhiMixEff","",1,0,1);
+  TH1F *hPhiMixMC=new TH1F("hPhiMixMC","",1,0,1);
+  
+  TH1F *hEtaNRaw=new TH1F("hEtaNRaw","",1,0,1);
+  TH1F *hEtaNCorr=new TH1F("hEtaNCorr","",1,0,1);
+  TH1F *hEtaNEff=new TH1F("hEtaNEff","",1,0,1);
+  TH1F *hEtaNMC=new TH1F("hEtaNMC","",1,0,1);
+  TH1F *hEtaNMixRaw=new TH1F("hEtaNMixRaw","",1,0,1);
+  TH1F *hEtaNMixCorr=new TH1F("hEtaNMixCorr","",1,0,1);
+  TH1F *hEtaNMixEff=new TH1F("hEtaNMixEff","",1,0,1);
+  TH1F *hEtaNMixMC=new TH1F("hEtaNMixMC","",1,0,1);
+  
+  TH1F *hEtaARaw=new TH1F("hEtaARaw","",1,0,1);
+  TH1F *hEtaACorr=new TH1F("hEtaACorr","",1,0,1);
+  TH1F *hEtaAEff=new TH1F("hEtaAEff","",1,0,1);
+  TH1F *hEtaAMC=new TH1F("hEtaAMC","",1,0,1);
+  TH1F *hEtaAMixRaw=new TH1F("hEtaAMixRaw","",1,0,1);
+  TH1F *hEtaAMixCorr=new TH1F("hEtaAMixCorr","",1,0,1);
+  TH1F *hEtaAMixEff=new TH1F("hEtaAMixEff","",1,0,1);
+  TH1F *hEtaAMixMC=new TH1F("hEtaAMixMC","",1,0,1);
+  
+  TH2F *hPhiEtaRaw=new TH2F("hPhiEtaRaw","",1,0,1,1,0,1);
+  TH2F *hPhiEtaCorr=new TH2F("hPhiEtaCorr","",1,0,1,1,0,1);
+  TH2F *hPhiEtaEff=new TH2F("hPhiEtaEff","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMC=new TH2F("hPhiEtaMC","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixRaw=new TH2F("hPhiEtaMixRaw","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixCorr=new TH2F("hPhiEtaMixCorr","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixEff=new TH2F("hPhiEtaMixEff","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixMC=new TH2F("hPhiEtaMixMC","",1,0,1,1,0,1);
+  TH1F *hMult=new TH1F("hMult","",1,0,1);
+  TH1F *hTMult=new TH1F("hTMult","",1,0,1);
+  TH1F *hNTrig=new TH1F("hNTrig","Number of Triggers",1,-0.5,0.5);
+  
+  TH2F *hPhiPhiRaw=new TH2F("hPhiPhiRaw","",1,0,1,1,0,1);
+  TH2F *hPhiPhiCorr=new TH2F("hPhiPhiCorr","",1,0,1,1,0,1);
+  TH2F *hPhiPhiEff=new TH2F("hPhiPhiEff","",1,0,1,1,0,1);
+  TH2F *hPhiPhiMC=new TH2F("hPhiPhiMC","",1,0,1,1,0,1);
+  TH2F *hPhiPhiSSRaw=new TH2F("hPhiPhiSSRaw","",1,0,1,1,0,1);
+  TH2F *hPhiPhiSSCorr=new TH2F("hPhiPhiSSCorr","",1,0,1,1,0,1);
+  TH2F *hPhiPhiSSEff=new TH2F("hPhiPhiSSEff","",1,0,1,1,0,1);
+  TH2F *hPhiPhiSSMC=new TH2F("hPhiPhiSSMC","",1,0,1,1,0,1);
+  TH2F *hPhiPhiMixRaw=new TH2F("hPhiPhiMixRaw","",1,0,1,1,0,1);
+  TH2F *hPhiPhiMixCorr=new TH2F("hPhiPhiMixCorr","",1,0,1,1,0,1);
+  TH2F *hPhiPhiMixEff=new TH2F("hPhiPhiMixEff","",1,0,1,1,0,1);
+  TH2F *hPhiPhiMixMC=new TH2F("hPhiPhiMixMC","",1,0,1,1,0,1);
+  
+  TH2F *hEtaEtaRaw=new TH2F("hEtaEtaRaw","",1,0,1,1,0,1);
+  TH2F *hEtaEtaCorr=new TH2F("hEtaEtaCorr","",1,0,1,1,0,1);
+  TH2F *hEtaEtaEff=new TH2F("hEtaEtaEff","",1,0,1,1,0,1);
+  TH2F *hEtaEtaMC=new TH2F("hEtaEtaMC","",1,0,1,1,0,1);
+  TH2F *hEtaEtaSSRaw=new TH2F("hEtaEtaSSRaw","",1,0,1,1,0,1);
+  TH2F *hEtaEtaSSCorr=new TH2F("hEtaEtaSSCorr","",1,0,1,1,0,1);
+  TH2F *hEtaEtaSSEff=new TH2F("hEtaEtaSSEff","",1,0,1,1,0,1);
+  TH2F *hEtaEtaSSMC=new TH2F("hEtaEtaSSMC","",1,0,1,1,0,1);
+  TH2F *hEtaEtaMixRaw=new TH2F("hEtaEtaMixRaw","",1,0,1,1,0,1);
+  TH2F *hEtaEtaMixCorr=new TH2F("hEtaEtaMixCorr","",1,0,1,1,0,1);
+  TH2F *hEtaEtaMixEff=new TH2F("hEtaEtaMixEff","",1,0,1,1,0,1);
+  TH2F *hEtaEtaMixMC=new TH2F("hEtaEtaMixMC","",1,0,1,1,0,1);
+
+  TH1F *hPhiPhiNOn=new TH1F("hPhiPhiNOn","",1,0,1);
+  TH1F *hPhiPhiAOn=new TH1F("hPhiPhiAOn","",1,0,1);
+  TH1F *hPhiPhiNOff=new TH1F("hPhiPhiNOff","",1,0,1);
+  TH1F *hPhiPhiAOff=new TH1F("hPhiPhiAOff","",1,0,1);
+
+  TH1F *hEtaEtaNOn=new TH1F("hEtaEtaNOn","",1,0,1);
+    TH1F *hEtaEtaNOff=new TH1F("hEtaEtaNOff","",1,0,1);
+
+  //TH1F *hNEvents=new TH1F("hNEvents","Number of Events & In Selected Cent",2,-0.5,1.5);
+  
+  TF1 *ZeroLine=new TF1("ZeroLine","[0]",-2,7);
+  ZeroLine->SetParameter(0,0);
+  ZeroLine->SetLineStyle(2);
+  TF1 *fit1=new TF1("fit1","1/sqrt(2*3.1415926)*([0]/[1]*(exp(-0.5*pow(x/[1],2))+exp(-0.5*pow((x-6.29185)/[1],2)))+[2]/[3]*(exp(-0.5*pow((x-3.14159)/[3],2))+exp(-0.5*pow((x+3.14159)/[3],2))))+[4]");
+  fit1->SetParameters(.1,.2,.1,.35,.1);
+  fit1->SetParNames("Near-Yield", "Near-Width","Away-Yield","Away-Width","Bg-Level");
+  TF1 *fit2=new TF1("fit2","1/sqrt(2*3.1415926)*([0]/[1]*(exp(-0.5*pow(x/[1],2))))+[2]");
+  fit2->SetParameters(.1,.2,.1);
+  fit2->SetParNames("Near-Yield", "Near-Width","Bg-Level");
+  
+  int VariablePtLimit=0;//if 1 and EffMethod==4 then a variable upper limit on the associated pt is used
+  if(EffMethod==5)VariablePtLimit=1;
+  
+  TFile *inFile=new TFile(inName);
+  TList *inList=inFile->Get("julery_DiHadron");
+  //sprintf(xname,"fHistNEvents_C%d",xCent);
+  TH1F *hNEvents=(TH1F*)inList->FindObject("fHistNEvents_C0");
+  //cout << "Number of Events: " << hNEvents->GetBinContent(1) << endl;
+  TFile *effFile=new TFile(effName);
+  TList *effList=effFile->Get("julery_DiHadron");
+  for(int Cent=Cent1;Cent<=Cent2;Cent++){
+    MakeProjections(TPt1,TPt2,APt1,APt2,Cent,inList,hPhiRaw,hPhiMixRaw,hEtaNRaw,hEtaNMixRaw,hEtaARaw,hEtaAMixRaw,hPhiEtaRaw,hPhiEtaMixRaw,MPt,0,0,0,LSign);
+    MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiEff,hPhiMixEff,hEtaNEff,hEtaNMixEff,hEtaAEff,hEtaAMixEff,hPhiEtaEff,hPhiEtaMixEff,MPt2,0,0,0,LSign);
+    MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiMC,hPhiMixMC,hEtaNMC,hEtaNMixMC,hEtaAMC,hEtaAMixMC,hPhiEtaMC,hPhiEtaMixMC,MPt2,0,1,0,LSign);
+    
+    if(EffMethod<4){
+      EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hPhiEff,hPhiMC,hPhiMixEff,hPhiMixMC,hEtaNEff,hEtaNMC,hEtaNMixEff,hEtaNMixMC,hEtaAEff,hEtaAMC,hEtaAMixEff,hEtaAMixMC,hPhiEtaEff,hPhiEtaMC,hPhiEtaMixEff,hPhiEtaMixMC,EffMethod);
+    }
+    else{
+      EffFit(APt1,APt2,Cent,effList,hPhiEff,hPhiMixEff,hEtaNEff,hEtaNMixEff,hEtaAEff,hEtaAMixEff,hPhiEtaEff,hPhiEtaMixEff,LSign,VariablePtLimit);
+    }
+    //inFile->Close();
+    // TFile *inFile2=new TFile(inName);
+    // TList *inList2=inFile2->Get("julery_DiHadron");
+    Load3Particle(TPt1,TPt2,APt1,APt2,Cent,inList,hPhiPhiRaw,hPhiPhiSSRaw,hPhiPhiMixRaw,hEtaEtaRaw,hEtaEtaSSRaw,hEtaEtaMixRaw,0,LSign);
+    Load3Particle(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiPhiEff,hPhiPhiSSEff,hPhiPhiMixEff,hEtaEtaEff,hEtaEtaSSEff,hEtaEtaMixEff,0,LSign);
+    Load3Particle(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiPhiMC,hPhiPhiSSMC,hPhiPhiMixMC,hEtaEtaMC,hEtaEtaSSMC,hEtaEtaMixMC,1,LSign);
+    
+    EffCorr3Part(TPt1,TPt2,APt1,APt2,Cent,hPhiPhiEff,hPhiPhiMC,hPhiPhiSSEff,hPhiPhiSSMC,hPhiPhiMixEff,hPhiPhiMixMC,hEtaEtaEff,hEtaEtaMC,hEtaEtaSSEff,hEtaEtaSSMC,hEtaEtaMixEff,hEtaEtaMixMC,0);
+    
+    hPhiCorr=(TH1F*)hPhiRaw->Clone();
+    sprintf(name,"hPhiCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiCorr->SetName(name);
+    hPhiCorr->Divide(hPhiEff);
+    
+    hPhiMixCorr=(TH1F*)hPhiMixRaw->Clone();
+    sprintf(name,"hPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiMixCorr->SetName(name);
+    hPhiMixCorr->Divide(hPhiMixEff);
+    
+    hEtaNCorr=(TH1F*)hEtaNRaw->Clone();
+    sprintf(name,"hEtaNCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaNCorr->SetName(name);
+    hEtaNCorr->Divide(hEtaNEff);
+    
+    hEtaNMixCorr=(TH1F*)hEtaNMixRaw->Clone();
+    sprintf(name,"hEtaNMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaNMixCorr->SetName(name);
+    hEtaNMixCorr->Divide(hEtaNMixEff);
+    
+    hEtaACorr=(TH1F*)hEtaARaw->Clone();
+    sprintf(name,"hEtaACorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaACorr->SetName(name);
+    hEtaACorr->Divide(hEtaAEff);
+    
+    hEtaAMixCorr=(TH1F*)hEtaAMixRaw->Clone();
+    sprintf(name,"hEtaAMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaAMixCorr->SetName(name);
+    hEtaAMixCorr->Divide(hEtaAMixEff);
+    
+    hPhiEtaCorr=(TH2F*)hPhiEtaRaw->Clone();
+    sprintf(name,"hPhiEtaCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiEtaCorr->SetName(name);
+    hPhiEtaCorr->Divide(hPhiEtaEff);
+    
+    hPhiEtaMixCorr=(TH2F*)hPhiEtaMixRaw->Clone();
+    sprintf(name,"hPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiEtaMixCorr->SetName(name);
+    hPhiEtaMixCorr->Divide(hPhiEtaMixEff);
+    
+    hPhiPhiCorr=(TH2F*)hPhiPhiRaw->Clone();
+    sprintf(name,"hPhiPhiCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiPhiCorr->SetName(name);
+    hPhiPhiCorr->Divide(hPhiPhiEff);
+    
+    hPhiPhiSSCorr=(TH2F*)hPhiPhiSSRaw->Clone();
+    sprintf(name,"hPhiPhiSSCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiPhiSSCorr->SetName(name);
+    hPhiPhiSSCorr->Divide(hPhiPhiSSEff);
+    
+    hPhiPhiMixCorr=(TH2F*)hPhiPhiMixRaw->Clone();
+    sprintf(name,"hPhiPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiPhiMixCorr->SetName(name);
+    cout << "hPhiPhiMixCorr: " << hPhiPhiMixCorr->GetBinContent(1,1) << " " << hPhiPhiMixCorr->GetBinError(1,1) << endl;
+    hPhiPhiMixCorr->Divide(hPhiPhiMixEff);
+    hPhiPhiMixCorr->Scale(hPhiPhiSSCorr->GetSum()/hPhiPhiMixCorr->GetSum());
+     cout << "hPhiPhiMixCorr: " << hPhiPhiMixCorr->GetBinContent(1,1) << " " << hPhiPhiMixCorr->GetBinError(1,1) << endl;
+     cout << "hPhiPhiMixEff: " << hPhiPhiMixEff->GetBinContent(1,1) << " " << hPhiPhiMixEff->GetBinError(1,1) << endl;
+
+    hEtaEtaCorr=(TH2F*)hEtaEtaRaw->Clone();
+    sprintf(name,"hEtaEtaCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaEtaCorr->SetName(name);
+    hEtaEtaCorr->Divide(hEtaEtaEff);
+    
+    hEtaEtaSSCorr=(TH2F*)hEtaEtaSSRaw->Clone();
+    sprintf(name,"hEtaEtaSSCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaEtaSSCorr->SetName(name);
+    hEtaEtaSSCorr->Divide(hEtaEtaSSEff);
+    
+    hEtaEtaMixCorr=(TH2F*)hEtaEtaMixRaw->Clone();
+    sprintf(name,"hEtaEtaMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaEtaMixCorr->SetName(name);
+    
+    hEtaEtaMixCorr->Divide(hEtaEtaMixEff);
+    hEtaEtaMixCorr->Scale(hEtaEtaSSCorr->GetSum()/hEtaEtaMixCorr->GetSum());
+  
+    
+    //Deal with efficiencies of 0
+    for(int x=1;x<=hPhiCorr->GetNbinsX();x++){
+      if(hPhiEff->GetBinContent(x)<1E-10)hPhiCorr->SetBinContent(x,0);
+      if(hPhiMixEff->GetBinContent(x)<1E-10)hPhiMixCorr->SetBinContent(x,0);
+    }
+    for(int x=1;x<=hEtaNCorr->GetNbinsX();x++){
+      if(hEtaNEff->GetBinContent(x)<1E-10)hEtaNCorr->SetBinContent(x,0);
+      if(hEtaNMixEff->GetBinContent(x)<1E-10)hEtaNMixCorr->SetBinContent(x,0);
+      if(hEtaAEff->GetBinContent(x)<1E-10)hEtaACorr->SetBinContent(x,0);
+      if(hEtaAMixEff->GetBinContent(x)<1E-10)hEtaAMixCorr->SetBinContent(x,0);
+    }
+    for(int x=1;x<=hPhiEtaCorr->GetNbinsX();x++){ 
+      for(int y=1;y<=hPhiCorr->GetNbinsX();y++){
+       if(hPhiEtaEff->GetBinContent(x,y)<1E-10)hPhiEtaCorr->SetBinContent(x,y,0);
+       if(hPhiEtaMixEff->GetBinContent(x,y)<1E-10)hPhiEtaMixCorr->SetBinContent(x,y,0);
+      }
+    }
+    for(int x=1;x<=hPhiPhiCorr->GetNbinsX();x++){
+      for(int y=1;y<=hPhiPhiCorr->GetNbinsY();y++){
+       if(hPhiPhiCorr->GetBinContent(x,y)<1E-10)hPhiPhiCorr->SetBinContent(x,y,0);
+       if(hPhiPhiSSCorr->GetBinContent(x,y)<1E-10)hPhiPhiSSCorr->SetBinContent(x,y,0);
+       if(hPhiPhiMixCorr->GetBinContent(x,y)<1E-10)hPhiPhiMixCorr->SetBinContent(x,y,0);
+      }
+    }
+    for(int x=1;x<=hEtaEtaCorr->GetNbinsX();x++){
+      for(int y=1;y<=hEtaEtaCorr->GetNbinsY();y++){
+       if(hEtaEtaCorr->GetBinContent(x,y)<1E-10)hEtaEtaCorr->SetBinContent(x,y,0);
+       if(hEtaEtaSSCorr->GetBinContent(x,y)<1E-10)hEtaEtaSSCorr->SetBinContent(x,y,0);
+       if(hEtaEtaMixCorr->GetBinContent(x,y)<1E-10)hEtaEtaMixCorr->SetBinContent(x,y,0);
+      }
+    }
+
+    // GeoCorr2(hEtaNCorr,hEtaNMixCorr,hEtaACorr,hEtaAMixCorr,hPhiEtaCorr,hPhiEtaMixCorr);
+    //GeoCorr3Part2(hEtaEtaCorr,hEtaEtaSSCorr,hEtaEtaMixCorr, hEtaEtaHSCorr);
+    MixedCorrect(hPhiCorr,hPhiMixCorr,hEtaNCorr,hEtaNMixCorr,hEtaACorr,hEtaAMixCorr,hPhiEtaCorr,hPhiEtaMixCorr);
+    MixedCorrect3(hPhiPhiCorr,hPhiPhiSSCorr,hPhiPhiMixCorr,hEtaEtaCorr,hEtaEtaSSCorr,hEtaEtaMixCorr);
+
+    float a[3];
+    Float_t b=(hPhiPhiCorr->GetSum()/pow(hPhiCorr->GetSum(),2))/(hPhiPhiSSCorr->GetSum()/pow(hPhiMixCorr->GetSum(),2));
+    //  b=1;
+    cout << "b:= " << b << endl;
+ float bEta=(hEtaEtaCorr->GetSum()/pow(hEtaNCorr->GetSum(),2))/(hEtaEtaSSCorr->GetSum()/pow(hEtaNMixCorr->GetSum(),2));
+ float bEta2=bEta;
+ //bEta=b;
+    cout << "bEta:= " << bEta << endl;
+    if(ZYACent>0){
+      ZYA1(hPhiCorr,hPhiMixCorr,a,ZYACent,ZYAWidth);
+    cout << "a: "  << a[0] << "  Error: " << a[1] << "  Error Code: " << a[2] << "  <pT>: " << MPt[0]  << endl;
+    }
+    else if(ZYACent>-2){
+      ZYAM2D2(hPhiEtaCorr,hPhiEtaMixCorr,a,fabs(ZYACent),ZYAWidth);
+    cout << "a: "  << a[0] << "  Error: " << a[1] << "  Error Code: " << a[2] << "  <pT>: " << MPt[0]  << endl;
+    }
+    else if(fabs(ZYACent+2)<0.1) ZYAM2D(hPhiEtaCorr,hPhiEtaMixCorr,a,72,10);
+    else if(fabs(ZYACent+3)<0.1) ZYAM3(hPhiCorr, hPhiMixCorr, hPhiPhiCorr,hPhiPhiSSCorr,hPhiPhiMixCorr, a, b,36,50);
+
+    hPhiMixCorr->Scale(a[0]);
+    hEtaNMixCorr->Scale(a[0]);
+    float scale3=a[0]*a[0]*b;
+    //bEta2=0;
+    float scale3Eta=a[0]*a[0]*bEta;
+    float scale3Eta2=a[0]*a[0]*bEta2;
+    hPhiPhiMixCorr->Scale(scale3);
+    hPhiPhiSSCorr->Scale(scale3);
+    // hEtaEtaSSCorr->Add(hEtaEtaMixCorr,-1);
+    hEtaEtaMixCorr->Scale(scale3Eta2);
+    hEtaEtaSSCorr->Scale(scale3Eta);
+    // hEtaEtaSSCorr->Add(hEtaEtaMixCorr);
+
+    TH2F *hPhiPhiHSCorr=(TH2F*)hPhiPhiCorr->Clone();
+    hPhiPhiHSCorr->SetName("hPhiPhiHSCorr");
+    hPhiPhiHSCorr->SetTitle("Hard-Soft Term");
+    
+    /*
+    TH2F *hEtaEtaHSCorr=(TH2F*)hEtaEtaMixRaw->Clone();
+    hEtaEtaHSCorr->SetName("hEtaEtaHSCorr");
+    hEtaEtaHSCorr->SetTitle("Hard-Soft Term");
+    */
+    float binsx=hEtaEtaCorr->GetNbinsX();
+    float minx=hEtaEtaCorr->GetBinCenter(1)-hEtaEtaCorr->GetBinWidth(1)/2;
+    float maxx=hEtaEtaCorr->GetBinCenter(binsx)+hEtaEtaCorr->GetBinWidth(binsx)/2;
+    TH2F *hEtaEtaHSCorr=new TH2F("hEtaEtaHCCorr","Hard-Soft Term",binsx,minx,maxx,binsx,minx,maxx);
+    hEtaEtaHSCorr->Sumw2();
+
+    TH1F *hPhiCorr2=(TH1F*)hPhiCorr->Clone();
+    hPhiCorr2->SetName("hPhiCorr2");
+    hPhiCorr2->Add(hPhiMixCorr,-1);
+    
+    TH1F *hEtaNCorr2=(TH1F*)hEtaNCorr->Clone();
+    hEtaNCorr2->SetName("hEtaNCorr2");
+    hEtaNCorr2->Add(hEtaNMixCorr,-1);
+    
+    float sigX, sigY, esigX, esigY, sig;
+    float mixX, mixY, emixX, emixY, esig;
+    int binRatio=hPhiCorr->GetNbinsX()/hPhiPhiCorr->GetNbinsX();
+    float CheckRatio=hPhiCorr->GetNbinsX()/hPhiPhiCorr->GetNbinsX();
+    if(fabs(binRatio-CheckRatio)>0.01){
+      cout << "Warning Use Bins for 3-Particle That are Divisors of 2-Particle!!!!!!    Phi" << endl;
+}
+    // cout << "binRatio " << binRatio << endl;
+    for(int x=1;x<=hPhiPhiCorr->GetNbinsX();x++){
+      sigX=0; esigX=0; mixX=0; emixX=0;
+      for(int j=(binRatio*(x-1)+1);j<=(x*binRatio);j++){
+      sigX+=hPhiCorr2->GetBinContent(j);
+      esigX+=pow(hPhiCorr2->GetBinError(j),2);
+      mixX+=hPhiMixCorr->GetBinContent(j);
+      emixX+=pow(hPhiMixCorr->GetBinError(j),2);
+      }
+      for(int y=1;y<=hPhiPhiCorr->GetNbinsX();y++){
+       sigY=0; esigY=0; mixY=0; emixY=0;
+       for(int k=(binRatio*(y-1)+1);k<=(y*binRatio);k++){
+       sigY+=hPhiCorr2->GetBinContent(k);
+       esigY+=pow(hPhiCorr2->GetBinError(k),2);
+       mixY+=hPhiMixCorr->GetBinContent(k);
+       emixY+=pow(hPhiMixCorr->GetBinError(k),2);
+       }
+       //cout << sigX << " " << sigY << " " << esigX << " " << esigY << " " << mixX << " " << emixX << " " << mixY << " " << emixY << endl;
+       sig=sigX*mixY+sigY*mixX;
+       esig=pow(pow(sigX*mixY,2)*(esigX/sigX/sigX+emixY/mixY/mixY)+pow(sigY*mixX,2)*(esigY/sigY/sigY+emixX/mixX/mixX),0.5);
+       sig=sig/pow(binRatio,2);
+       esig=esig/pow(binRatio,2);
+       hPhiPhiHSCorr->SetBinContent(x,y,sig);
+       hPhiPhiHSCorr->SetBinError(x,y,esig);
+      }
+    }
+
+ float sigX, sigY, esigX, esigY, sig;
+    float mixX, mixY, emixX, emixY, esig;
+    float centX, centY;
+    int binRatio=hEtaNCorr->GetNbinsX()/hEtaEtaCorr->GetNbinsX();
+    float CheckRatio=hEtaNCorr->GetNbinsX()/hEtaEtaCorr->GetNbinsX();
+    float etaCut=hEtaNCorr->GetBinCenter(hEtaNCorr->GetNbinsX())+hEtaNCorr->GetBinWidth(1);
+    if(fabs(binRatio-CheckRatio)>0.01){
+   cout << "Warning Use Bins for 3-Particle That are Divisors of 2-Particle!!!!!!   Eta" << endl;
+    }
+    for(int x=1;x<=hEtaNCorr->GetNbinsX();x++){
+      sigX=0; esigX=0; mixX=0; emixX=0;
+      centX=hEtaEtaCorr->GetXaxis()->GetBinCenter(x);
+      for(int j=(binRatio*(x-1)+1);j<=(x*binRatio);j++){
+       sigX+=hEtaNCorr2->GetBinContent(j);
+       esigX+=hEtaNCorr2->GetBinError(j);
+       mixX+=hEtaNMixCorr->GetBinContent(j);
+       emixX+=hEtaNMixCorr->GetBinError(j);
+      }
+      for(int y=1;y<=hEtaNCorr->GetNbinsX();y++){
+       sigY=0; esigY=0; mixY=0; emixY=0;
+       centY=hEtaEtaCorr->GetXaxis()->GetBinCenter(y);
+       for(int k=(binRatio*(y-1)+1);k<=(y*binRatio);k++){
+         sigY+=hEtaNCorr2->GetBinContent(k);
+         esigY+=hEtaNCorr2->GetBinError(k);
+         mixY+=hEtaNMixCorr->GetBinContent(k);
+         emixY+=hEtaNMixCorr->GetBinError(k);
+       }
+       sig=sigX*mixY+sigY*mixX;
+
+       //divide by 0 protection
+       if(sigX==0)sigX=1E-5;
+       if(sigY==0)sigY=1E-5;
+       if(mixX==0)mixX=1E-5;
+       if(mixY==0)mixY=1E-5;
+       esig=pow(pow(sigX*mixY,2)*(pow(esigX/sigX,2)+pow(emixY/mixY,2))+pow(sigY*mixX,2)*(pow(esigY/sigY,2)+pow(emixX/mixX,2)),0.5);
+       //if(fabs(centX-centY)>etaCut){sig=0;esig=0;}
+       if(hEtaEtaMixCorr->GetBinContent(x,y)){
+       hEtaEtaHSCorr->SetBinContent(x,y,sig/binRatio/binRatio);
+       hEtaEtaHSCorr->SetBinError(x,y,esig/binRatio/binRatio);
+       }
+       //else cout << hEtaEtaSSCorr->GetBinContent(x,y)  << " " << hEtaEtaHSCorr->GetBinError(x,y) << endl;
+      }
+    }
+    
+   
+  
+    // hEtaNCorr2=(TH1F*)hEtaNCorr->Clone();
+    //  hEtaNCorr2->SetName("hEtaNCorr2");
+    //  hEtaNCorr2->Add(hEtaNMixCorr,-1);    
+
+
+    TH2F *hPhiPhiCorr2=(TH2F*)hPhiPhiCorr->Clone();
+    hPhiPhiCorr2->SetName("hPhiPhiCorr2");
+    hPhiPhiCorr2->SetTitle("Background Subtracted");
+    hPhiPhiCorr2->Add(hPhiPhiHSCorr,-1);
+    hPhiPhiCorr2->Add(hPhiPhiSSCorr,-1);
+
+    TH2F *hEtaEtaCorr2=(TH2F*)hEtaEtaCorr->Clone();
+    hEtaEtaCorr2->SetName("hEtaEtaCorr2");
+    hEtaEtaCorr2->SetTitle("Background Subtracted");
+    hEtaEtaCorr2->Add(hEtaEtaHSCorr,-1);
+    hEtaEtaCorr2->Add(hEtaEtaSSCorr,-1);
+
+    //here need to sum over the centralities
+
+    ProjPhiPhi(hPhiPhiCorr2,hPhiPhiNOn,hPhiPhiNOff,hPhiPhiAOn,hPhiPhiAOff,1,0.35);//0.35
+    ProjEtaEta(hEtaEtaCorr2,hEtaEtaNOn,hEtaEtaNOff,0.35);
+
+    cPhiAll=new TCanvas("cPhiAll","3-Particle Phi",1500,900);
+    cPhiAll->Divide(4,3);
+    //  SetMargins1D(cPhiAll_1);
+    //1-D plots
+    float RM1=0.02;
+    float LM1=0.16;
+    float TM1=0.1;
+    float BM1=0.15;
+    //colz
+    float RM2=0.25;
+    float LM2=0.12;
+    float TM2=0.1;
+    float BM2=0.15;
+    //surf
+    float RM3=0.05;
+    float LM3=0.21;
+    float TM3=0.05;
+    float BM3=0.15;
+
+    cPhiAll_1->SetRightMargin(RM1);
+    cPhiAll_1->SetLeftMargin(LM1);
+    cPhiAll_1->SetTopMargin(TM1);
+    cPhiAll_1->SetBottomMargin(BM1);
+
+    cPhiAll_2->SetRightMargin(RM1);
+    cPhiAll_2->SetLeftMargin(LM1);
+    cPhiAll_2->SetTopMargin(TM1);
+    cPhiAll_2->SetBottomMargin(BM1);
+
+    cPhiAll_3->SetRightMargin(RM3);
+    cPhiAll_3->SetLeftMargin(LM3);
+    cPhiAll_3->SetTopMargin(TM3);
+    cPhiAll_3->SetBottomMargin(BM3);
+
+    cPhiAll_4->SetRightMargin(RM2);
+    cPhiAll_4->SetLeftMargin(LM2);
+    cPhiAll_4->SetTopMargin(TM2);
+    cPhiAll_4->SetBottomMargin(BM2);
+    
+    cPhiAll_5->SetRightMargin(RM3);
+    cPhiAll_5->SetLeftMargin(LM3);
+    cPhiAll_5->SetTopMargin(TM3);
+    cPhiAll_5->SetBottomMargin(BM3);
+
+    cPhiAll_6->SetRightMargin(RM2);
+    cPhiAll_6->SetLeftMargin(LM2);
+    cPhiAll_6->SetTopMargin(TM2);
+    cPhiAll_6->SetBottomMargin(BM2);
+
+    cPhiAll_7->SetRightMargin(RM3);
+    cPhiAll_7->SetLeftMargin(LM3);
+    cPhiAll_7->SetTopMargin(TM3);
+    cPhiAll_7->SetBottomMargin(BM3);
+
+    cPhiAll_8->SetRightMargin(RM2);
+    cPhiAll_8->SetLeftMargin(LM2);
+    cPhiAll_8->SetTopMargin(TM2);
+    cPhiAll_8->SetBottomMargin(BM2);
+
+    cPhiAll_9->SetRightMargin(RM3);
+    cPhiAll_9->SetLeftMargin(LM3);
+    cPhiAll_9->SetTopMargin(TM3);
+    cPhiAll_9->SetBottomMargin(BM3);
+
+    cPhiAll_10->SetRightMargin(RM2);
+    cPhiAll_10->SetLeftMargin(LM2);
+    cPhiAll_10->SetTopMargin(TM2);
+    cPhiAll_10->SetBottomMargin(BM2);
+    
+    cPhiAll_11->SetRightMargin(RM1);
+    cPhiAll_11->SetLeftMargin(LM1);
+    cPhiAll_11->SetTopMargin(TM1);
+    cPhiAll_11->SetBottomMargin(BM1);
+
+    cPhiAll_12->SetRightMargin(RM1);
+    cPhiAll_12->SetLeftMargin(LM1);
+    cPhiAll_12->SetTopMargin(TM1);
+    cPhiAll_12->SetBottomMargin(BM1);
+
+    hPhiPhiCorr->SetTitle("Raw Signal");
+    hPhiPhiSSCorr->SetTitle("Soft-Soft Term");
+    hPhiPhiNOn->SetTitle("Near");
+    hPhiPhiNOff->SetTitle("Near");
+    hPhiPhiAOn->SetTitle("Away");
+    hPhiPhiAOff->SetTitle("Away");
+
+    cPhiAll_1->cd();
+    SetTitles1D(hPhiCorr);
+    hPhiCorr->Draw();
+    hPhiMixCorr->Draw("same");
+    
+    cPhiAll_2->cd();
+    SetTitles1D(hPhiCorr2);
+    hPhiCorr2->Draw();
+    ZeroLine->Draw("same");
+    
+    cPhiAll_3->cd();
+    SetTitles2D(hPhiPhiCorr);
+    hPhiPhiCorr->Draw("lego2");
+
+    cPhiAll_4->cd();
+    hPhiPhiCorr->Draw("colz");
+
+    cPhiAll_5->cd();
+    SetTitles2D(hPhiPhiHSCorr);
+    hPhiPhiHSCorr->Draw("lego2");
+    
+    cPhiAll_6->cd();
+    hPhiPhiHSCorr->Draw("colz");
+
+    cPhiAll_7->cd();
+    SetTitles2D(hPhiPhiMixCorr);
+    hPhiPhiSSCorr->Draw("lego2");
+    
+    cPhiAll_8->cd();
+    hPhiPhiSSCorr->Draw("colz");
+
+    cPhiAll_9->cd();
+    SetTitles2D(hPhiPhiCorr2);
+    hPhiPhiCorr2->Draw("lego2");
+    
+    cPhiAll_10->cd();
+    hPhiPhiCorr2->Draw("colz");
+
+    cPhiAll_11->cd();
+    hPhiPhiNOff->Draw();
+    hPhiPhiNOn->Draw("same");
+    keySymbol(0.2,0.85,"On",4,25,0.05,1.5);
+    keySymbol(0.2,0.8,"Off",2,20,0.05,1.5);
+
+    cPhiAll_12->cd();
+    hPhiPhiAOff->Draw();
+    hPhiPhiAOn->Draw("same");
+
+    sprintf(name,"%s/Draw3Particle_PhiAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhiAll->SaveAs(name);
+
+    cEtaAll=new TCanvas("cEtaAll","3-Particle Eta",1500,900);
+    cEtaAll->Divide(4,3);
+    //  SetMargins1D(cEtaAll_1);
+    /*
+    //1-D plots
+    float RM1=0.02;
+    float LM1=0.16;
+    float TM1=0.1;
+    float BM1=0.15;
+    //colz
+    float RM2=0.24;
+    float LM2=0.12;
+    float TM2=0.1;
+    float BM2=0.15;
+    //surf
+    float RM3=0.05;
+    float LM3=0.2;
+    float TM3=0.05;
+    float BM3=0.15;
+    */
+
+    cEtaAll_1->SetRightMargin(RM1);
+    cEtaAll_1->SetLeftMargin(LM1);
+    cEtaAll_1->SetTopMargin(TM1);
+    cEtaAll_1->SetBottomMargin(BM1);
+
+    cEtaAll_2->SetRightMargin(RM1);
+    cEtaAll_2->SetLeftMargin(LM1);
+    cEtaAll_2->SetTopMargin(TM1);
+    cEtaAll_2->SetBottomMargin(BM1);
+
+    cEtaAll_3->SetRightMargin(RM3);
+    cEtaAll_3->SetLeftMargin(LM3);
+    cEtaAll_3->SetTopMargin(TM3);
+    cEtaAll_3->SetBottomMargin(BM3);
+
+    cEtaAll_4->SetRightMargin(RM2);
+    cEtaAll_4->SetLeftMargin(LM2);
+    cEtaAll_4->SetTopMargin(TM2);
+    cEtaAll_4->SetBottomMargin(BM2);
+    
+    cEtaAll_5->SetRightMargin(RM3);
+    cEtaAll_5->SetLeftMargin(LM3);
+    cEtaAll_5->SetTopMargin(TM3);
+    cEtaAll_5->SetBottomMargin(BM3);
+
+    cEtaAll_6->SetRightMargin(RM2);
+    cEtaAll_6->SetLeftMargin(LM2);
+    cEtaAll_6->SetTopMargin(TM2);
+    cEtaAll_6->SetBottomMargin(BM2);
+
+    cEtaAll_7->SetRightMargin(RM3);
+    cEtaAll_7->SetLeftMargin(LM3);
+    cEtaAll_7->SetTopMargin(TM3);
+    cEtaAll_7->SetBottomMargin(BM3);
+
+    cEtaAll_8->SetRightMargin(RM2);
+    cEtaAll_8->SetLeftMargin(LM2);
+    cEtaAll_8->SetTopMargin(TM2);
+    cEtaAll_8->SetBottomMargin(BM2);
+
+    cEtaAll_9->SetRightMargin(RM3);
+    cEtaAll_9->SetLeftMargin(LM3);
+    cEtaAll_9->SetTopMargin(TM3);
+    cEtaAll_9->SetBottomMargin(BM3);
+
+    cEtaAll_10->SetRightMargin(RM2);
+    cEtaAll_10->SetLeftMargin(LM2);
+    cEtaAll_10->SetTopMargin(TM2);
+    cEtaAll_10->SetBottomMargin(BM2);
+    
+    cEtaAll_11->SetRightMargin(RM1);
+    cEtaAll_11->SetLeftMargin(LM1);
+    cEtaAll_11->SetTopMargin(TM1);
+    cEtaAll_11->SetBottomMargin(BM1);
+
+    cEtaAll_12->SetRightMargin(RM1);
+    cEtaAll_12->SetLeftMargin(LM1);
+    cEtaAll_12->SetTopMargin(TM1);
+    cEtaAll_12->SetBottomMargin(BM1);
+
+    hEtaEtaCorr->SetTitle("Raw Signal");
+    hEtaEtaSSCorr->SetTitle("Soft-Soft Term");
+    hEtaEtaNOn->SetTitle("Projections");
+    hEtaEtaNOff->SetTitle("Projections");
+
+    cEtaAll_1->cd();
+    SetTitles1D(hEtaNCorr);
+    hEtaNCorr->Draw();
+    hEtaNMixCorr->Draw("same");
+    
+    cEtaAll_2->cd();
+    SetTitles1D(hEtaNCorr2);
+    hEtaNCorr2->Draw();
+    ZeroLine->Draw("same");
+    
+    cEtaAll_3->cd();
+    SetTitles2D(hEtaEtaCorr);
+    hEtaEtaCorr->Draw("lego2");
+
+    cEtaAll_4->cd();
+    hEtaEtaCorr->Draw("colz");
+
+    cEtaAll_5->cd();
+    SetTitles2D(hEtaEtaHSCorr);
+    hEtaEtaHSCorr->Draw("lego2");
+    
+    cEtaAll_6->cd();
+    hEtaEtaHSCorr->Draw("colz");
+
+    cEtaAll_7->cd();
+    SetTitles2D(hEtaEtaMixCorr);
+    hEtaEtaSSCorr->Draw("lego2");
+    
+    cEtaAll_8->cd();
+    hEtaEtaSSCorr->Draw("colz");
+
+    cEtaAll_9->cd();
+    SetTitles2D(hEtaEtaCorr2);
+    hEtaEtaCorr2->Draw("lego2");
+    
+    cEtaAll_10->cd();
+    hEtaEtaCorr2->Draw("colz");
+
+    cEtaAll_11->cd();
+    hEtaEtaNOff->Draw();
+    hEtaEtaNOn->Draw("same");
+    keySymbol(0.2,0.85,"On",4,25,0.05,1.5);
+    keySymbol(0.2,0.8,"Off",2,20,0.05,1.5);
+
+
+    sprintf(name,"%s/Draw3Particle_EtaAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEtaAll->SaveAs(name);
+
+    cPhi1=new TCanvas("cPhi1","2-Particle",400,300);
+    SetMargins1D(cPhi1);
+    hPhiCorr->SetTitle("");
+    hPhiCorr->Draw();
+    hPhiMixCorr->Draw("same");
+    sprintf(name,"%s/Draw3Particle_PhiCorr_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi1->SaveAs(name);
+    
+    cPhi2=new TCanvas("cPhi2","2-Particle BgSub",400,350);
+    SetMargins1D(cPhi2);
+    hPhiCorr2->SetTitle("");
+    hPhiCorr2->Draw();
+    ZeroLine->Draw("same");
+    sprintf(name,"%s/Draw3Particle_PhiCorr2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi2->SaveAs(name);
+
+    cPhi3=new TCanvas("cPhi3","3-Particle lego",400,300);
+    SetMargins2DSurf(cPhi3);
+    hPhiPhiCorr->SetTitle("");
+    hPhiPhiCorr->Draw("lego2");
+    sprintf(name,"%s/Draw3Particle_PhiPhiCorrLego_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi3->SaveAs(name);
+
+    cPhi4=new TCanvas("cPhi4","3-Particle",400,350);
+    SetMargins2D(cPhi4);
+    hPhiPhiCorr->SetTitle("");
+    hPhiPhiCorr->Draw("colz");
+    sprintf(name,"%s/Draw3Particle_PhiPhiCorr_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi4->SaveAs(name);
+
+    cPhi5=new TCanvas("cPhi5","HS lego",400,300);
+    SetMargins2DSurf(cPhi5);
+    hPhiPhiHSCorr->SetTitle("");
+    hPhiPhiHSCorr->Draw("lego2");
+    sprintf(name,"%s/Draw3Particle_PhiPhiHSCorrLego_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi5->SaveAs(name);
+
+    cPhi6=new TCanvas("cPhi6","HS",400,350);
+    SetMargins2D(cPhi6);
+    hPhiPhiHSCorr->SetTitle("");
+    hPhiPhiHSCorr->Draw("colz");
+    sprintf(name,"%s/Draw3Particle_PhiPhiHSCorr_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi6->SaveAs(name);    
+
+     cPhi7=new TCanvas("cPhi3","SS lego",400,300);
+    SetMargins2DSurf(cPhi7);
+    hPhiPhiSSCorr->SetTitle("");
+    hPhiPhiSSCorr->Draw("lego2");
+    sprintf(name,"%s/Draw3Particle_PhiPhiSSCorrLego_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi7->SaveAs(name);
+
+    cPhi8=new TCanvas("cPhi8","SS",400,350);
+    SetMargins2D(cPhi8);
+    hPhiPhiSSCorr->SetTitle("");
+    hPhiPhiSSCorr->Draw("colz");
+    sprintf(name,"%s/Draw3Particle_PhiPhiSSCorr_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi8->SaveAs(name);
+
+    cPhi9=new TCanvas("cPhi9","3-Particle BGSub lego",400,300);
+    SetMargins2DSurf(cPhi9);
+    hPhiPhiCorr2->SetTitle("");
+    hPhiPhiCorr2->Draw("lego2");
+    sprintf(name,"%s/Draw3Particle_PhiPhiCorr2Lego_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi9->SaveAs(name);
+
+    cPhi10=new TCanvas("cPhi10","3-Particle BGSub",400,350);
+    SetMargins2D(cPhi10);
+    hPhiPhiCorr2->SetTitle("");
+    hPhiPhiCorr2->Draw("colz");
+    sprintf(name,"%s/Draw3Particle_PhiPhiCorr2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi10->SaveAs(name);
+
+     cPhi11=new TCanvas("cPhi11","Near Projection",400,300);
+     SetMargins1D(cPhi11);
+     hPhiPhiNOff->SetTitle("");
+     hPhiPhiNOff->Draw();
+    hPhiPhiNOn->Draw("same");
+    keySymbol(0.2,0.85,"On",4,25,0.05,1.5);
+    keySymbol(0.2,0.8,"Off",2,20,0.05,1.5);
+    sprintf(name,"%s/Draw3Particle_PhiProjN_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi11->SaveAs(name);
+    
+    cPhi12=new TCanvas("cPhi12","Away Projection",400,300);
+    SetMargins1D(cPhi12);
+    hPhiPhiAOff->SetTitle("");
+    hPhiPhiAOff->Draw();
+    hPhiPhiAOn->Draw("same");
+    keySymbol(0.2,0.85,"On",4,25,0.05,1.5);
+    keySymbol(0.2,0.8,"Off",2,20,0.05,1.5);
+    sprintf(name,"%s/Draw3Particle_PhiProjA_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cPhi12->SaveAs(name);
+
+   cEta1=new TCanvas("cEta1","2-Particle",400,300);
+    SetMargins1D(cEta1);
+    hEtaNCorr->SetTitle("");
+    hEtaNCorr->Draw();
+    hEtaNMixCorr->Draw("same");
+    sprintf(name,"%s/Draw3Particle_EtaNCorr_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta1->SaveAs(name);
+    
+    cEta2=new TCanvas("cEta2","2-Particle BgSub",400,350);
+    SetMargins1D(cEta2);
+    hEtaNCorr2->SetTitle("");
+    hEtaNCorr2->Draw();
+    ZeroLine->Draw("same");
+    sprintf(name,"%s/Draw3Particle_EtaNCorr2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta2->SaveAs(name);
+
+    cEta3=new TCanvas("cEta3","3-Particle lego",400,300);
+    SetMargins2DSurf(cEta3);
+    hEtaEtaCorr->SetTitle("");
+    hEtaEtaCorr->Draw("lego2");
+    sprintf(name,"%s/Draw3Particle_EtaEtaCorrLego_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta3->SaveAs(name);
+
+    cEta4=new TCanvas("cEta4","3-Particle",400,350);
+    SetMargins2D(cEta4);
+    hEtaEtaCorr->SetTitle("");
+    hEtaEtaCorr->Draw("colz");
+    sprintf(name,"%s/Draw3Particle_EtaEtaCorr_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta4->SaveAs(name);
+
+    cEta5=new TCanvas("cEta5","HS lego",400,300);
+    SetMargins2DSurf(cEta5);
+    hEtaEtaHSCorr->SetTitle("");
+    hEtaEtaHSCorr->Draw("lego2");
+    sprintf(name,"%s/Draw3Particle_EtaEtaHSCorrLego_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta5->SaveAs(name);
+
+    cEta6=new TCanvas("cEta6","HS",400,350);
+    SetMargins2D(cEta6);
+    hEtaEtaHSCorr->SetTitle("");
+    hEtaEtaHSCorr->Draw("colz");
+    sprintf(name,"%s/Draw3Particle_EtaEtaHSCorr_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta6->SaveAs(name);    
+
+     cEta7=new TCanvas("cEta3","SS lego",400,300);
+    SetMargins2DSurf(cEta7);
+    hEtaEtaSSCorr->SetTitle("");
+    hEtaEtaSSCorr->Draw("lego2");
+    sprintf(name,"%s/Draw3Particle_EtaEtaSSCorrLego_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta7->SaveAs(name);
+
+    cEta8=new TCanvas("cEta8","SS",400,350);
+    SetMargins2D(cEta8);
+    hEtaEtaSSCorr->SetTitle("");
+    hEtaEtaSSCorr->Draw("colz");
+    sprintf(name,"%s/Draw3Particle_EtaEtaSSCorr_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta8->SaveAs(name);
+
+    cEta9=new TCanvas("cEta9","3-Particle BGSub lego",400,300);
+    SetMargins2DSurf(cEta9);
+    hEtaEtaCorr2->SetTitle("");
+    hEtaEtaCorr2->Draw("lego2");
+    sprintf(name,"%s/Draw3Particle_EtaEtaCorr2Lego_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta9->SaveAs(name);
+
+    cEta10=new TCanvas("cEta10","3-Particle BGSub",400,350);
+    SetMargins2D(cEta10);
+    hEtaEtaCorr2->SetTitle("");
+    hEtaEtaCorr2->Draw("colz");
+    sprintf(name,"%s/Draw3Particle_EtaEtaCorr2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta10->SaveAs(name);
+
+     cEta11=new TCanvas("cEta11","Near Projection",400,300);
+     SetMargins1D(cEta11);
+     hEtaEtaNOff->SetTitle("");
+     hEtaEtaNOff->Draw();
+    hEtaEtaNOn->Draw("same");
+    keySymbol(0.2,0.85,"On",4,25,0.05,1.5);
+    keySymbol(0.2,0.8,"Off",2,20,0.05,1.5);
+    sprintf(name,"%s/Draw3Particle_EtaProjN_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_E%d_Z%1.2f%s",Folder,TPt1,TPt2,APt1,APt2,Cent1,Cent2,EffMethod,ZYACent,fileType);
+    cEta11->SaveAs(name);
+    
+   
+  }
+}
diff --git a/PWG4/macros/jcorran/DrawDPhi.C b/PWG4/macros/jcorran/DrawDPhi.C
new file mode 100755 (executable)
index 0000000..62733cc
--- /dev/null
@@ -0,0 +1,1421 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+//Draw the 2-particle correlation histograms (from output of AliAnalysisTaskDiHadron)
+//Author: Jason Glyndwr Ulery, ulery@uni-frankfurt.de
+
+#ifndef __CINT__
+#include <TF1.h>
+#include <TF2.h>
+#include "TSystem.h"
+#include <iostream>
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TRandom.h>
+#include <fstream>
+#include "TList.h"
+#include "TArrayF.h"
+#endif
+
+void DrawDPhi(float TPt1, float TPt2, float APt1, float APt2, float Cent1, float Cent2, int ptWeighted=0, int notDelta=0, int LSign=0){//ptWeighted 0 no weight, 1 weighted, 2 <pt>; Lsign 0-all, 1-like-sign 2-unlike-sign
+  gROOT->Reset();
+  gROOT->LoadMacro("Util9.C");
+  Style(1);
+  //gDebug=1;
+  int SaveRoot=1;
+  int SavePS=0;
+  int SavePDF=0;
+  float ZYACent=1.5;//0  for 2-D zyam lowest bins -number wanted for 2-D strips//1.5
+  float ZYAWidth=0.2; 
+  int ReBinPhi=1;
+  int ReBinEta=1;
+  int DrawAsHisto=0;
+  int noTitle=1;
+  int SaveMacro=0;
+  int SaveText=0;
+  int DrawMC=0;
+  int EffMethod=0;//0 no correction, 1 angle dependent, 2 use mix for triggered, 3 <1>, 4 fits, 5  fits with VariablePtLimit
+  //int SaveEffFits=1;
+
+  
+  //char *Folder="2010-03-10/pass5";
+  //char *Folder="2010-04-07/7_2010_04_05";
+  //char *EffFolder="2010-03-10/all_5";
+
+  //char *Folder="2010-04-12/pass5";
+  //char *EffFolder="2010-04-12/900Pythia";
+
+  // char *Folder="2010-04-26/7pass1";
+  //char *Folder="2010-04-26/7Pythia";
+  //char *Folder="2010-05-28/7Pythia2";//with new cut
+  //char *Folder="2010-05-28/900Pythia";//with new cut
+  //char *Folder="2010-05-28/7Pythia_LHC10b5";//newer pythia
+  //har *Folder="2010-06-30/7Pythia_LHC10b5";//newer pythia
+  /*
+  char *Folder="2010-07-02/LHC10c_900pass2";
+  //char *Folder="2010-07-02/LHC10c6_900Pythia";
+  char *EffFolder="2010-07-02/LHC10c6_900Pythia";
+  */
+  //12&21
+  //7-22 paper cuts, 7-27 papercuts and early corr, 7-12 old cuts, 8-4 more multiplicity cuts
+  char *Folder="2010-08-17/LHC10b_7pass2";
+  // char *Folder="2010-08-17/7Pythia_LHC10b5";
+  //char *Folder="2010-08-17/LHC10c_900pass2";
+  //char *Folder="2010-08-17/LHC10c6_900Pythia";
+
+   char *EffFolder="2010-08-17/7Pythia_LHC10b5";
+   //char *EffFolder="2010-08-17/LHC10c6_900Pythia";
+
+  //  char *EffFolder="2010-04-26/7Pythia";
+  // char *EffFolder="2010-05-28/7Pythia2";//with new cut
+  // char *EffFolder="2010-05-28/900Pythia";//with new cut
+  //char *EffFolder="2010-06-30/7Pythia_LHC10b5";//newer pythia
+  //char *EffFolder="2010-05-28/7Pythia_LHC10b5";//newer pythia
+
+
+  char *cPt[3]={"","Pt","MPt"};
+  char *cDelta[2]={"Delta",""};
+  char *csign[3]={"","LS","ULS"};
+  char name[300];
+  char inName[100];
+  char effName[100];
+  sprintf(inName,"%s/julery_DiHadron.root",Folder);
+  sprintf(effName,"%s/julery_DiHadron.root",EffFolder);
+  cout << inName << endl;
+  cout << effName << endl;
+  char *titArray[2]={"","_NoTitle"};
+  char *histArray[2]={"","_Histo"};
+  
+  Float_t MPt[4];//<pt>, error <pt>, # of triggers
+  Float_t MPt2[4];
+  Float_t TrigSum=0, TrigSum2=0;
+  
+  TH1F *hPhiRaw=new TH1F("hPhiRaw","",1,0,1);
+  TH1F *hPhiCorr=new TH1F("hPhiCorr","",1,0,1);
+  TH1F *hPhiEff=new TH1F("hPhiEff","",1,0,1);
+  TH1F *hPhiMC=new TH1F("hPhiMC","",1,0,1);
+  TH1F *hPhiMixRaw=new TH1F("hPhiMixRaw","",1,0,1);
+  TH1F *hPhiMixCorr=new TH1F("hPhiMixCorr","",1,0,1);
+  TH1F *hPhiMixEff=new TH1F("hPhiMixEff","",1,0,1);
+  TH1F *hPhiMixMC=new TH1F("hPhiMixMC","",1,0,1);
+
+  TH1F *hEtaNRaw=new TH1F("hEtaNRaw","",1,0,1);
+  TH1F *hEtaNCorr=new TH1F("hEtaNCorr","",1,0,1);
+  TH1F *hEtaNEff=new TH1F("hEtaNEff","",1,0,1);
+  TH1F *hEtaNMC=new TH1F("hEtaNMC","",1,0,1);
+  TH1F *hEtaNMixRaw=new TH1F("hEtaNMixRaw","",1,0,1);
+  TH1F *hEtaNMixCorr=new TH1F("hEtaNMixCorr","",1,0,1);
+  TH1F *hEtaNMixEff=new TH1F("hEtaNMixEff","",1,0,1);
+  TH1F *hEtaNMixMC=new TH1F("hEtaNMixMC","",1,0,1);
+
+  TH1F *hEtaARaw=new TH1F("hEtaARaw","",1,0,1);
+  TH1F *hEtaACorr=new TH1F("hEtaACorr","",1,0,1);
+  TH1F *hEtaAEff=new TH1F("hEtaAEff","",1,0,1);
+  TH1F *hEtaAMC=new TH1F("hEtaAMC","",1,0,1);
+  TH1F *hEtaAMixRaw=new TH1F("hEtaAMixRaw","",1,0,1);
+  TH1F *hEtaAMixCorr=new TH1F("hEtaAMixCorr","",1,0,1);
+  TH1F *hEtaAMixEff=new TH1F("hEtaAMixEff","",1,0,1);
+  TH1F *hEtaAMixMC=new TH1F("hEtaAMixMC","",1,0,1);
+
+  TH2F *hPhiEtaRaw=new TH2F("hPhiEtaRaw","",1,0,1,1,0,1);
+  TH2F *hPhiEtaCorr=new TH2F("hPhiEtaCorr","",1,0,1,1,0,1);
+  TH2F *hPhiEtaEff=new TH2F("hPhiEtaEff","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMC=new TH2F("hPhiEtaMC","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixRaw=new TH2F("hPhiEtaMixRaw","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixCorr=new TH2F("hPhiEtaMixCorr","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixEff=new TH2F("hPhiEtaMixEff","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixMC=new TH2F("hPhiEtaMixMC","",1,0,1,1,0,1);
+  TH1F *hMult=new TH1F("hMult","",1,0,1);
+  TH1F *hTMult=new TH1F("hTMult","",1,0,1);
+  TH1F *hNTrig=new TH1F("hNTrig","Number of Triggers",1,-0.5,0.5);
+  //TH1F *hNEvents=new TH1F("hNEvents","Number of Events & In Selected Cent",2,-0.5,1.5);
+
+  TF1 *ZeroLine=new TF1("ZeroLine","[0]",-2,7);
+  ZeroLine->SetParameter(0,0);
+  ZeroLine->SetLineStyle(2);
+   TF1 *fit1=new TF1("fit1","1/sqrt(2*3.1415926)*([0]/[1]*(exp(-0.5*pow(x/[1],2))+exp(-0.5*pow((x-6.29185)/[1],2)))+[2]/[3]*(exp(-0.5*pow((x-3.14159)/[3],2))+exp(-0.5*pow((x+3.14159)/[3],2))))+[4]");
+  fit1->SetParameters(.1,.2,.1,.35,.1);
+  fit1->SetParNames("Near-Yield", "Near-Width","Away-Yield","Away-Width","Bg-Level");
+   TF1 *fit2=new TF1("fit2","1/sqrt(2*3.1415926)*([0]/[1]*(exp(-0.5*pow(x/[1],2))))+[2]");
+  fit2->SetParameters(.1,.2,.1);
+  fit2->SetParNames("Near-Yield", "Near-Width","Bg-Level");
+
+ int VariablePtLimit=0;//if 1 and EffMethod==4 then a variable upper limit on the associated pt is used
+ if(EffMethod==5)VariablePtLimit=1;
+  
+  TFile *inFile=new TFile(inName);
+  TList *inList=inFile->Get("julery_DiHadron");
+  //sprintf(xname,"fHistNEvents_C%d",xCent);
+  TH1F *hNEvents=(TH1F*)inList->FindObject("fHistNEvents_C0");
+  //cout << "Number of Events: " << hNEvents->GetBinContent(1) << endl;
+  TFile *effFile=new TFile(effName);
+  TList *effList=effFile->Get("julery_DiHadron");
+  for(int Cent=Cent1;Cent<=Cent2;Cent++){
+    int qqx=0;
+    if(ptWeighted)qqx=1;
+    for(int ipt=0;ipt<=qqx;ipt++){
+    MakeProjections(TPt1,TPt2,APt1,APt2,Cent,inList,hPhiRaw,hPhiMixRaw,hEtaNRaw,hEtaNMixRaw,hEtaARaw,hEtaAMixRaw,hPhiEtaRaw,hPhiEtaMixRaw,MPt,ipt,0,notDelta,LSign);
+    MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiEff,hPhiMixEff,hEtaNEff,hEtaNMixEff,hEtaAEff,hEtaAMixEff,hPhiEtaEff,hPhiEtaMixEff,MPt2,ipt,0,notDelta,LSign);
+    MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiMC,hPhiMixMC,hEtaNMC,hEtaNMixMC,hEtaAMC,hEtaAMixMC,hPhiEtaMC,hPhiEtaMixMC,MPt2,ipt,1,notDelta,LSign);
+    c100xx=new TCanvas("c100");
+    hPhiMixEff->Draw();
+    c100xx->SaveAs("Mix.gif");
+    if(EffMethod<4){
+      EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hPhiEff,hPhiMC,hPhiMixEff,hPhiMixMC,hEtaNEff,hEtaNMC,hEtaNMixEff,hEtaNMixMC,hEtaAEff,hEtaAMC,hEtaAMixEff,hEtaAMixMC,hPhiEtaEff,hPhiEtaMC,hPhiEtaMixEff,hPhiEtaMixMC,EffMethod);
+    }
+    else{
+      EffFit(APt1,APt2,Cent,effList,hPhiEff,hPhiMixEff,hEtaNEff,hEtaNMixEff,hEtaAEff,hEtaAMixEff,hPhiEtaEff,hPhiEtaMixEff,LSign,VariablePtLimit);
+    }
+    //EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hPhiRaw,hPhiEff,hPhiMC,hPhiMixRaw,hPhiMixEff,hPhiMixMC,hEtaNRaw,hEtaNEff,hEtaNMC,hEtaNMixRaw,hEtaNMixEff,hEtaNMixMC,hEtaARaw,hEtaAEff,hEtaAMC,hEtaAMixRaw,hEtaAMixEff,hEtaAMixMC,hPhiEtaRaw,hPhiEtaEff,hPhiEtaMC,hPhiEtaMixRaw,hPhiEtaMixEff,hPhiEtaMixMC,EffMethod);
+    
+    hPhiCorr=(TH1F*)hPhiRaw->Clone();
+    sprintf(name,"hPhiCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiCorr->SetName(name);
+    hPhiCorr->Divide(hPhiEff);
+    
+    hPhiMixCorr=(TH1F*)hPhiMixRaw->Clone();
+    sprintf(name,"hPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiMixCorr->SetName(name);
+    hPhiMixCorr->Divide(hPhiMixEff);
+
+    hEtaNCorr=(TH1F*)hEtaNRaw->Clone();
+    sprintf(name,"hEtaNCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaNCorr->SetName(name);
+    hEtaNCorr->Divide(hEtaNEff);
+    
+    hEtaNMixCorr=(TH1F*)hEtaNMixRaw->Clone();
+    sprintf(name,"hEtaNMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaNMixCorr->SetName(name);
+    hEtaNMixCorr->Divide(hEtaNMixEff);
+
+    hEtaACorr=(TH1F*)hEtaARaw->Clone();
+    sprintf(name,"hEtaACorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaACorr->SetName(name);
+    hEtaACorr->Divide(hEtaAEff);
+    
+    hEtaAMixCorr=(TH1F*)hEtaAMixRaw->Clone();
+    sprintf(name,"hEtaAMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hEtaAMixCorr->SetName(name);
+    hEtaAMixCorr->Divide(hEtaAMixEff);
+    
+    hPhiEtaCorr=(TH2F*)hPhiEtaRaw->Clone();
+    sprintf(name,"hPhiEtaCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiEtaCorr->SetName(name);
+    hPhiEtaCorr->Divide(hPhiEtaEff);
+    
+    hPhiEtaMixCorr=(TH2F*)hPhiEtaMixRaw->Clone();
+    sprintf(name,"hPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hPhiEtaMixCorr->SetName(name);
+    hPhiEtaMixCorr->Divide(hPhiEtaMixEff);
+    //GeoCorr(hEtaNCorr,hEtaNMixCorr,hEtaNMixMC,hEtaACorr,hEtaAMixCorr,hEtaAMixMC,hPhiEtaCorr,hPhiEtaMixCorr,hPhiEtaMixMC);
+    //GeoCorr2(hEtaNCorr,hEtaNMixCorr,hEtaACorr,hEtaAMixCorr,hPhiEtaCorr,hPhiEtaMixCorr);
+     MixedCorrect(hPhiCorr,hPhiMixCorr,hEtaNCorr,hEtaNMixCorr,hEtaACorr,hEtaAMixCorr,hPhiEtaCorr,hPhiEtaMixCorr);
+    //Deal with efficiencies of 0
+    for(int x=1;x<=hPhiCorr->GetNbinsX();x++){
+      if(hPhiEff->GetBinContent(x)<1E-10)hPhiCorr->SetBinContent(x,0);
+      if(hPhiMixEff->GetBinContent(x)<1E-10)hPhiMixCorr->SetBinContent(x,0);
+    }
+    for(int x=1;x<=hEtaNCorr->GetNbinsX();x++){
+      if(hEtaNEff->GetBinContent(x)<1E-10)hEtaNCorr->SetBinContent(x,0);
+      if(hEtaNMixEff->GetBinContent(x)<1E-10)hEtaNMixCorr->SetBinContent(x,0);
+      if(hEtaAEff->GetBinContent(x)<1E-10)hEtaACorr->SetBinContent(x,0);
+      if(hEtaAMixEff->GetBinContent(x)<1E-10)hEtaAMixCorr->SetBinContent(x,0);
+    }
+    for(int x=1;x<=hPhiEtaCorr->GetNbinsX();x++){ 
+      for(int y=1;y<=hPhiCorr->GetNbinsX();y++){
+       if(hPhiEtaEff->GetBinContent(x,y)<1E-10)hPhiEtaCorr->SetBinContent(x,y,0);
+       if(hPhiEtaMixEff->GetBinContent(x,y)<1E-10)hPhiEtaMixCorr->SetBinContent(x,y,0);
+      }
+    }
+    
+  
+    if(!notDelta&&!ipt){
+      float a[3];
+      if(ZYACent>0.0001)ZYA1(hPhiCorr,hPhiMixCorr,a,ZYACent,ZYAWidth);
+      // cout << "a: "  << a[0] << "  Error: " << a[1] << "  Error Code: " << a[2] << "  <pT>: " << MPt[0]  << endl;
+      else if(ZYACent==0){
+       ZYAM2D(hPhiEtaCorr,hPhiEtaMixCorr,a,80,10);
+      }
+      else
+       ZYAM2D2(hPhiEtaCorr,hPhiEtaMixCorr,a,fabs(ZYACent),ZYAWidth);
+    }
+
+    if(ptWeighted==2&&ipt==0){
+      TH1F *TempPhiRaw=(TH1F*)hPhiRaw->Clone();
+      TempPhiRaw->SetName("TempPhiRaw");
+      TH1F *TempPhiMixRaw=(TH1F*)hPhiMixRaw->Clone();
+      TempPhiMixRaw->SetName("TempPhiMixRaw");
+      TH1F *TempPhiCorr=(TH1F*)hPhiCorr->Clone();
+      TempPhiCorr->SetName("TempPhiCorr");
+      TH1F *TempPhiMixCorr=(TH1F*)hPhiMixCorr->Clone();
+      TempPhiMixCorr->SetName("TemPhiMixCorr");
+      TH1F *TempPhiCorr2=(TH1F*)hPhiCorr->Clone();
+      TempPhiCorr2->SetName("TempPhiCorr2");
+      TH1F *TempPhiMixCorr2=(TH1F*)hPhiMixCorr->Clone();
+      TempPhiMixCorr2->SetName("TemPhiMixCorr2");
+      
+      TH1F *TempEtaNRaw=(TH1F*)hEtaNRaw->Clone();
+      TempEtaNRaw->SetName("TempEtaNRaw");
+      TH1F *TempEtaNMixRaw=(TH1F*)hEtaNMixRaw->Clone();
+      TempEtaNMixRaw->SetName("TempEtaNMixRaw");
+      TH1F *TempEtaNCorr=(TH1F*)hEtaNCorr->Clone();
+      TempEtaNCorr->SetName("TempEtaNCorr");
+      TH1F *TempEtaNMixCorr=(TH1F*)hEtaNMixCorr->Clone();
+      TempEtaNMixCorr->SetName("TemEtaNMixCorr");
+      TH1F *TempEtaNCorr2=(TH1F*)hEtaNCorr->Clone();
+      TempEtaNCorr2->SetName("TempEtaNCorr2");
+      TH1F *TempEtaNMixCorr2=(TH1F*)hEtaNMixCorr->Clone();
+      TempEtaNMixCorr2->SetName("TemEtaNMixCorr2");
+
+      TH1F *TempEtaARaw=(TH1F*)hEtaARaw->Clone();
+      TempEtaARaw->SetName("TempEtaARaw");
+      TH1F *TempEtaAMixRaw=(TH1F*)hEtaAMixRaw->Clone();
+      TempEtaAMixRaw->SetName("TempEtaAMixRaw");
+      TH1F *TempEtaACorr=(TH1F*)hEtaACorr->Clone();
+      TempEtaACorr->SetName("TempEtaACorr");
+      TH1F *TempEtaAMixCorr=(TH1F*)hEtaAMixCorr->Clone();
+      TempEtaAMixCorr->SetName("TemEtaAMixCorr");
+      TH1F *TempEtaACorr2=(TH1F*)hEtaACorr->Clone();
+      TempEtaACorr2->SetName("TempEtaAMixCorr2");
+      TH1F *TempEtaAMixCorr2=(TH1F*)hEtaAMixCorr->Clone();
+      TempEtaAMixCorr2->SetName("TemEtaAMixCorr2");
+
+      TH1F *TempPhiEtaRaw=(TH1F*)hPhiEtaRaw->Clone();
+      TempPhiEtaRaw->SetName("TempPhiEtaRaw");
+      TH1F *TempPhiEtaMixRaw=(TH1F*)hPhiEtaMixRaw->Clone();
+      TempPhiEtaMixRaw->SetName("TempPhiEtaMixRaw");
+      TH1F *TempPhiEtaCorr=(TH1F*)hPhiEtaCorr->Clone();
+      TempPhiEtaCorr->SetName("TempPhiEtaCorr");
+      TH1F *TempPhiEtaMixCorr=(TH1F*)hPhiEtaMixCorr->Clone();
+      TempPhiEtaMixCorr->SetName("TemPhiEtaMixCorr");
+      TH1F *TempPhiEtaCorr2=(TH1F*)hPhiEtaCorr->Clone();
+      TempPhiEtaCorr2->SetName("TempPhiEtaCorr2");
+      TH1F *TempPhiEtaMixCorr2=(TH1F*)hPhiEtaMixCorr->Clone();
+      TempPhiEtaMixCorr2->SetName("TempPhiEtaMixCorr2");
+
+    }
+    }//ptWeighted loop
+    
+    
+    TH1F *hPhiCorr2=(TH1F*)hPhiCorr->Clone();
+    hPhiCorr2->SetName("hPhiCorr2");
+    sprintf(name,"Bg Sub. %s",hPhiCorr2->GetTitle());
+    hPhiCorr2->SetTitle(name);
+    if(noTitle)hPhiCorr2->SetTitle("");
+    
+    TH1F *hPhiMixCorr2=(TH1F*)hPhiMixCorr->Clone();
+    hPhiMixCorr2->SetName("hPhiMixCorr2");
+    sprintf(name,"Normalized %1.3f %s",a[0],hPhiMixCorr2->GetTitle());
+    hPhiMixCorr2->SetTitle(name);
+    if(noTitle)hPhiMixCorr2->SetTitle("");
+    hPhiMixCorr2->SetMarkerStyle(25);
+    hPhiMixCorr2->SetMarkerColor(4);
+    hPhiMixCorr2->SetLineColor(4);
+
+    TH1F *hEtaNCorr2=(TH1F*)hEtaNCorr->Clone();
+    hEtaNCorr2->SetName("hEtaNCorr2");
+    sprintf(name,"Bg Sub. %s",hEtaNCorr2->GetTitle());
+    hEtaNCorr2->SetTitle(name);
+    if(noTitle)hEtaNCorr2->SetTitle("");
+    
+    TH1F *hEtaNMixCorr2=(TH1F*)hEtaNMixCorr->Clone();
+    hEtaNMixCorr2->SetName("hEtaNMixCorr2");
+    sprintf(name,"Normalized %1.3f %s",a[0],hEtaNMixCorr2->GetTitle());
+    hEtaNMixCorr2->SetTitle(name);
+    if(noTitle)hEtaNMixCorr2->SetTitle("");
+    hEtaNMixCorr2->SetMarkerStyle(25);
+    hEtaNMixCorr2->SetMarkerColor(4);
+    hEtaNMixCorr2->SetLineColor(4);
+
+    TH1F *hEtaACorr2=(TH1F*)hEtaACorr->Clone();
+    hEtaACorr2->SetName("hEtaACorr2");
+    sprintf(name,"Bg Sub. %s",hEtaACorr2->GetTitle());
+    hEtaACorr2->SetTitle(name);
+    if(noTitle)hEtaACorr2->SetTitle("");
+    
+    TH1F *hEtaAMixCorr2=(TH1F*)hEtaAMixCorr->Clone();
+    hEtaAMixCorr2->SetName("hEtaAMixCorr2");
+    sprintf(name,"Normalized %1.3f %s",a[0],hEtaAMixCorr2->GetTitle());
+    hEtaAMixCorr2->SetTitle(name);
+    if(noTitle)hEtaAMixCorr2->SetTitle("");
+    hEtaAMixCorr2->SetMarkerStyle(25);
+    hEtaAMixCorr2->SetMarkerColor(4);
+    hEtaAMixCorr2->SetLineColor(4);
+    
+    TH2F *hPhiEtaCorr2=(TH2F*)hPhiEtaCorr->Clone();
+    hPhiEtaCorr2->SetName("hPhiEtaCorr2");
+    sprintf(name,"BG Sub. %s",hPhiEtaCorr2->GetTitle());
+    hPhiEtaCorr2->SetTitle(name);
+    if(noTitle)hPhiEtaCorr2->SetTitle("");
+    
+    TH2F *hPhiEtaMixCorr2=(TH2F*)hPhiEtaMixCorr->Clone();
+    hPhiEtaMixCorr2->SetName("hPhiEtaMixCorr2");
+    sprintf(name,"Normalized %1.3f %s",a[0],hPhiEtaMixCorr2->GetTitle());
+    hPhiEtaMixCorr2->SetTitle(name);
+    if(noTitle)hPhiEtaMixCorr2->SetTitle("");
+    if(!notDelta){
+      hPhiMixCorr2->Scale(a[0]);
+      hEtaNMixCorr2->Scale(a[0]);
+      hEtaAMixCorr2->Scale(a[0]);
+      hPhiEtaMixCorr2->Scale(a[0]);
+      
+      //          hPhiCorr2->Add(hPhiMixCorr2,-1);
+      Add1D(hPhiCorr2,hPhiMixCorr2,-1);
+      Add1D(hEtaNCorr2,hEtaNMixCorr2,-1);
+      Add1D(hEtaACorr2,hEtaAMixCorr2,-1);
+      Add2D(hPhiEtaCorr2,hPhiEtaMixCorr2,-1); 
+      if(ptWeighted==2){
+       TempPhiMixCorr2->Scale(a[0]);
+       TempEtaNMixCorr2->Scale(a[0]);
+       TempEtaAMixCorr2->Scale(a[0]);
+       TempPhiEtaMixCorr2->Scale(a[0]);
+       Add1D(TempPhiCorr2,TempPhiMixCorr2,-1);
+       Add1D(TempEtaNCorr2,TempEtaNMixCorr2,-1);
+       Add1D(TempEtaACorr2,TempEtaAMixCorr2,-1);
+       //cout << TempPhiEtaCorr2->GetBinContent(1,1) << " " << TempPhiEtaMixCorr2->GetBinContent(1,1) << endl;
+       //Add2D(TempPhiEtaCorr2,TempPhiEtaMixCorr2,-1);         
+       TempPhiEtaCorr2->Add(TempPhiEtaMixCorr2,-1);
+
+
+       /*
+       hPhiRaw->Divide(TempPhiRaw);
+       hPhiCorr->Divide(TempPhiCorr);
+
+       hPhiMixRaw->Divide(TempPhiMixRaw);
+       hPhiMixCorr->Divide(TempPhiMixCorr);
+       hPhiMixCorr2->Divide(TemPhiMixCorr2);
+       */
+               hPhiCorr2->Divide(TempPhiCorr2);
+       DivideMean1D(hPhiRaw,TempPhiRaw,APt1,APt2,MPt[2]);
+       DivideMean1DCorr(hPhiCorr,TempPhiCorr,TempPhiRaw,APt1,APt2,MPt[2]);
+       //DivideMean1DBgSub(hPhiCorr2,TempPhiCorr2,TempPhiRaw,TempPhiMixRaw,APt1,APt2,MPt[2],MPt[3]);
+       DivideMean1D(hPhiMixRaw,TempPhiMixRaw,APt1,APt2,MPt[3]);
+       DivideMean1DCorr(hPhiMixCorr,TempPhiMixCorr,TempPhiMixRaw,APt1,APt2,MPt[3]);
+       DivideMean1DCorr(hPhiMixCorr2,TempPhiMixCorr2,TempPhiMixRaw,APt1,APt2,MPt[3]);
+
+       /*
+       hEtaNRaw->Divide(TempEtaNRaw);
+       hEtaNCorr->Divide(TempEtaNCorr);
+
+       hEtaNMixRaw->Divide(TempEtaNMixRaw);
+       hEtaNMixCorr->Divide(TempEtaNMixCorr);
+       hEtaNMixCorr2->Divide(TempEtaNMixCorr2);
+
+       hEtaARaw->Divide(TempEtaARaw);
+       hEtaACorr->Divide(TempEtaACorr);
+
+       hEtaAMixRaw->Divide(TempEtaAMixRaw);
+       hEtaAMixCorr->Divide(TempEtaAMixCorr);
+       hEtaAMixCorr2->Divide(TempEtaAMixCorr2);
+       */
+       hEtaNCorr2->Divide(TempEtaNCorr2);
+       DivideMean1D(hEtaNRaw,TempEtaNRaw,APt1,APt2,MPt[2]);
+       DivideMean1DCorr(hEtaNCorr,TempEtaNCorr,TempEtaNRaw,APt1,APt2,MPt[2]);
+       //DivideMean1DBgSub(hEtaNCorr2,TempEtaNCorr2,TempEtaNRaw,TempEtaNMixRaw,APt1,APt2,MPt[2],MPt[3]);
+       DivideMean1D(hEtaNMixRaw,TempEtaNMixRaw,APt1,APt2,MPt[3]);
+       DivideMean1DCorr(hEtaNMixCorr,TempEtaNMixCorr,TempEtaNMixRaw,APt1,APt2,MPt[3]);
+       DivideMean1DCorr(hEtaNMixCorr2,TempEtaNMixCorr2,TempEtaNMixRaw,APt1,APt2,MPt[3]);
+
+       hEtaACorr2->Divide(TempEtaACorr2);
+       DivideMean1D(hEtaARaw,TempEtaARaw,APt1,APt2,MPt[2]);
+       DivideMean1DCorr(hEtaACorr,TempEtaACorr,TempEtaARaw,APt1,APt2,MPt[2]);
+       //DivideMean1DBgSub(hEtaACorr2,TempEtaACorr2,TempEtaARaw,TempEtaAMixRaw,APt1,APt2,MPt[2],MPt[3]);
+       DivideMean1D(hEtaAMixRaw,TempEtaAMixRaw,APt1,APt2,MPt[3]);
+       DivideMean1DCorr(hEtaAMixCorr,TempEtaAMixCorr,TempEtaAMixRaw,APt1,APt2,MPt[3]);
+       DivideMean1DCorr(hEtaAMixCorr2,TempEtaAMixCorr2,TempEtaAMixRaw,APt1,APt2,MPt[3]);
+       /*
+       //Its not liking my 2D functions for some reason
+       DivideMean2D(hPhiEtaRaw,TempPhiEtaRaw,APt1,APt2,MPt[2]);
+       DivideMean2D(hPhiEtaCorr,TempPhiEtaCorr,APt1,APt2,MPt[2]);
+       DivideMean2D(hPhiEtaCorr2,TempPhiEtaCorr2,APt1,APt2,MPt[2]);
+       DivideMean2D(hPhiEtaMixRaw,TempPhiEtaMixRaw,APt1,APt2,MPt[3]);
+       DivideMean2D(hPhiEtaMixCorr,TempPhiEtaMixCorr,APt1,APt2,MPt[3]);
+       DivideMean2D(hPhiEtaMixCorr2,TempPhiEtaMixCorr2,APt1,APt2,MPt[3]);      
+       */
+       //Errors are messed up but its not liking my 2d divide
+       hPhiEtaRaw->Divide(TempPhiEtaRaw);
+       hPhiEtaCorr->Divide(TempPhiEtaCorr);
+       hPhiEtaCorr2->Divide(TempPhiEtaCorr2);
+       hPhiEtaMixRaw->Divide(TempPhiEtaMixRaw);
+       hPhiEtaMixCorr->Divide(TempPhiEtaMixCorr);
+       hPhiEtaMixCorr2->Divide(TempPhiEtaMixCorr2);
+       
+
+       hPhiRaw->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiCorr->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiCorr2->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiMixRaw->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiMixCorr->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiMixCorr2->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+
+       hEtaNRaw->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaNCorr->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaNCorr2->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaNMixRaw->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaNMixCorr->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaNMixCorr2->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+
+       hEtaARaw->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaACorr->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaACorr2->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaAMixRaw->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaAMixCorr->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hEtaAMixCorr2->GetYaxis()->SetTitle("<p_{T}^{Assoc}>");
+
+       hPhiEtaRaw->GetZaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiEtaCorr->GetZaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiEtaCorr2->GetZaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiEtaMixRaw->GetZaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiEtaMixCorr->GetZaxis()->SetTitle("<p_{T}^{Assoc}>");
+       hPhiEtaMixCorr2->GetZaxis()->SetTitle("<p_{T}^{Assoc}>");
+      }
+    }  
+    
+    if(Cent==Cent1){
+      TH1F *hPhiRawPlot=(TH1F*)hPhiRaw->Clone();
+      hPhiRawPlot->SetName("hPhiRawPlot");
+      TH1F *hPhiCorrPlot=(TH1F*)hPhiCorr->Clone();
+      hPhiCorrPlot->SetName("hPhiCorrPlot");
+      TH1F *hPhiCorr2Plot=(TH1F*)hPhiCorr2->Clone();
+      hPhiCorr2Plot->SetName("hPhiCorr2Plot");
+      TH1F *hPhiEffPlot=(TH1F*)hPhiEff->Clone();
+      hPhiEffPlot->SetName("hPhiEffPlot");
+      TH1F *hPhiMCPlot=(TH1F*)hPhiMC->Clone();
+      hPhiMCPlot->SetName("hPhiMCPlot");
+      TH1F *hPhiMixRawPlot=(TH1F*)hPhiMixRaw->Clone();
+      hPhiMixRawPlot->SetName("hPhiMixRawPlot");
+      TH1F *hPhiMixCorrPlot=(TH1F*)hPhiMixCorr->Clone();
+      hPhiMixCorrPlot->SetName("hPhiMixCorrPlot");
+      TH1F *hPhiMixCorr2Plot=(TH1F*)hPhiMixCorr2->Clone();
+      hPhiMixCorr2Plot->SetName("hPhiMixCorr2Plot");
+      TH1F *hPhiMixEffPlot=(TH1F*)hPhiMixEff->Clone();
+      hPhiMixEffPlot->SetName("hPhiMixEffPlot");
+      TH1F *hPhiMixMCPlot=(TH1F*)hPhiMixMC->Clone();
+      hPhiMixMCPlot->SetName("hPHiMixMCPlot");
+      
+
+      TH1F *hEtaNRawPlot=(TH1F*)hEtaNRaw->Clone();
+      hEtaNRawPlot->SetName("hEtaNRawPlot");
+      TH1F *hEtaNCorrPlot=(TH1F*)hEtaNCorr->Clone();
+      hEtaNCorrPlot->SetName("hEtaNCorrPlot");
+      TH1F *hEtaNCorr2Plot=(TH1F*)hEtaNCorr2->Clone();
+      hEtaNCorr2Plot->SetName("hEtaNCorr2Plot");
+      TH1F *hEtaNEffPlot=(TH1F*)hEtaNEff->Clone();
+      hEtaNEffPlot->SetName("hEtaNEffPlot");
+      TH1F *hEtaNMixRawPlot=(TH1F*)hEtaNMixRaw->Clone();
+      hEtaNMixRawPlot->SetName("hEtaNMixRawPlot");
+      TH1F *hEtaNMixCorrPlot=(TH1F*)hEtaNMixCorr->Clone();
+      hEtaNMixCorrPlot->SetName("hEtaNMixCorrPlot");
+      TH1F *hEtaNMixCorr2Plot=(TH1F*)hEtaNMixCorr2->Clone();
+      hEtaNMixCorr2Plot->SetName("hEtaNMixCorr2Plot");
+      TH1F *hEtaNMixEffPlot=(TH1F*)hEtaNMixEff->Clone();
+      hEtaNMixEffPlot->SetName("hEtaNMixEffPlot");
+
+      TH1F *hEtaARawPlot=(TH1F*)hEtaARaw->Clone();
+      hEtaARawPlot->SetName("hEtaARawPlot");
+      TH1F *hEtaACorrPlot=(TH1F*)hEtaACorr->Clone();
+      hEtaACorrPlot->SetName("hEtaACorrPlot");
+      TH1F *hEtaACorr2Plot=(TH1F*)hEtaACorr2->Clone();
+      hEtaACorr2Plot->SetName("hEtaACorr2Plot");
+      TH1F *hEtaAEffPlot=(TH1F*)hEtaAEff->Clone();
+      hEtaAEffPlot->SetName("hEtaAEffPlot");
+      TH1F *hEtaAMixRawPlot=(TH1F*)hEtaAMixRaw->Clone();
+      hEtaAMixRawPlot->SetName("hEtaAMixRawPlot");
+      TH1F *hEtaAMixCorrPlot=(TH1F*)hEtaAMixCorr->Clone();
+      hEtaAMixCorrPlot->SetName("hEtaAMixCorrPlot");
+      TH1F *hEtaAMixCorr2Plot=(TH1F*)hEtaAMixCorr2->Clone();
+      hEtaAMixCorr2Plot->SetName("hEtaAMixCorr2Plot");
+      TH1F *hEtaAMixEffPlot=(TH1F*)hEtaAMixEff->Clone();
+      hEtaAMixEffPlot->SetName("hEtaAMixEffPlot");
+
+      TH2F *hPhiEtaRawPlot=(TH2F*)hPhiEtaRaw->Clone();
+      hPhiEtaRawPlot->SetName("hPhiEtaRawPlot");
+      TH2F *hPhiEtaCorrPlot=(TH2F*)hPhiEtaCorr->Clone();
+      hPhiEtaCorrPlot->SetName("hPhiEtaCorrPlot");
+      TH2F *hPhiEtaCorr2Plot=(TH2F*)hPhiEtaCorr2->Clone();
+      hPhiEtaCorr2Plot->SetName("hPhiEtaCorr2Plot");
+      TH2F *hPhiEtaEffPlot=(TH2F*)hPhiEtaEff->Clone();
+      hPhiEtaEffPlot->SetName("hPhiEtaEffPlot");
+      TH2F *hPhiEtaMixRawPlot=(TH2F*)hPhiEtaMixRaw->Clone();
+      hPhiEtaMixRawPlot->SetName("hPhiEtaMixRawPlot");
+      TH2F *hPhiEtaMixCorrPlot=(TH2F*)hPhiEtaMixCorr->Clone();
+      hPhiEtaMixCorrPlot->SetName("hPhiEtaMixRawPlot");
+      TH2F *hPhiEtaMixCorr2Plot=(TH2F*)hPhiEtaMixCorr2->Clone();
+      hPhiEtaMixCorr2Plot->SetName("hPhiEtaMixCorr2Plot");
+      TH2F *hPhiEtaMixEffPlot=(TH2F*)hPhiEtaMixEff->Clone();
+      hPhiEtaMixEffPlot->SetName("hPhiEtaMixEffPlot");
+      
+      TrigSum=MPt[2];
+      TrigSum2=MPt2[2];
+
+      hPhiRawPlot->Scale(MPt[2]);
+      hPhiCorrPlot->Scale(MPt[2]);
+      hPhiCorr2Plot->Scale(MPt[2]);
+      hPhiEffPlot->Scale(MPt[2]);
+      hPhiMCPlot->Scale(MPt2[2]);
+      hPhiMixRawPlot->Scale(MPt[2]);
+      hPhiMixCorrPlot->Scale(MPt[2]);
+      hPhiMixCorr2Plot->Scale(MPt[2]);
+      hPhiMixEffPlot->Scale(MPt[2]);
+      hPhiMixMCPlot->Scale(MPt2[2]);
+
+      hEtaNRawPlot->Scale(MPt[2]);
+      hEtaNCorrPlot->Scale(MPt[2]);
+      hEtaNCorr2Plot->Scale(MPt[2]);
+      hEtaNEffPlot->Scale(MPt[2]);
+      hEtaNMixRawPlot->Scale(MPt[2]);
+      hEtaNMixCorrPlot->Scale(MPt[2]);
+      hEtaNMixCorr2Plot->Scale(MPt[2]);
+      hEtaNMixEffPlot->Scale(MPt[2]);
+
+      hEtaARawPlot->Scale(MPt[2]);
+      hEtaACorrPlot->Scale(MPt[2]);
+      hEtaACorr2Plot->Scale(MPt[2]);
+      hEtaAEffPlot->Scale(MPt[2]);
+      hEtaAMixRawPlot->Scale(MPt[2]);
+      hEtaAMixCorrPlot->Scale(MPt[2]);
+      hEtaAMixCorr2Plot->Scale(MPt[2]);
+      hEtaAMixEffPlot->Scale(MPt[2]);
+      
+      hPhiEtaRawPlot->Scale(MPt[2]);
+      hPhiEtaCorrPlot->Scale(MPt[2]);
+      hPhiEtaCorr2Plot->Scale(MPt[2]);
+      hPhiEtaEffPlot->Scale(MPt[2]);
+      hPhiEtaMixRawPlot->Scale(MPt[2]);
+      hPhiEtaMixCorrPlot->Scale(MPt[2]);
+      hPhiEtaMixCorr2Plot->Scale(MPt[2]);
+      hPhiEtaMixEffPlot->Scale(MPt[2]);
+    }
+    else{//I need to do trigger weighted averaging here so I need the trigger counts
+      hPhiRawPlot->Add(hPhiRaw,MPt[2]);
+      hPhiCorrPlot->Add(hPhiCorr,MPt[2]);
+      hPhiCorr2Plot->Add(hPhiCorr2,MPt[2]);
+      hPhiEffPlot->Add(hPhiEff,MPt[2]);
+      hPhiMCPlot->Add(hPhiMC,MPt2[2]);
+      hPhiMixRawPlot->Add(hPhiMixRaw,MPt[2]);
+      hPhiMixCorrPlot->Add(hPhiMixCorr,MPt[2]);
+      hPhiMixCorr2Plot->Add(hPhiMixCorr2,MPt[2]);
+      hPhiMixEffPlot->Add(hPhiMixEff,MPt[2]);
+      hPhiMCPlot->Add(hPhiMixMC,MPt2[2]);
+
+      hEtaNRawPlot->Add(hEtaNRaw,MPt[2]);
+      hEtaNCorrPlot->Add(hEtaNCorr,MPt[2]);
+      hEtaNCorr2Plot->Add(hEtaNCorr2,MPt[2]);
+      hEtaNEffPlot->Add(hEtaNEff,MPt[2]);
+      hEtaNMixRawPlot->Add(hEtaNMixRaw,MPt[2]);
+      hEtaNMixCorrPlot->Add(hEtaNMixCorr,MPt[2]);
+      hEtaNMixCorr2Plot->Add(hEtaNMixCorr2,MPt[2]);
+      hEtaNMixEffPlot->Add(hEtaNMixEff,MPt[2]);
+
+      hEtaARawPlot->Add(hEtaARaw,MPt[2]);
+      hEtaACorrPlot->Add(hEtaACorr,MPt[2]);
+      hEtaACorr2Plot->Add(hEtaACorr2,MPt[2]);
+      hEtaAEffPlot->Add(hEtaAEff,MPt[2]);
+      hEtaAMixRawPlot->Add(hEtaAMixRaw,MPt[2]);
+      hEtaAMixCorrPlot->Add(hEtaAMixCorr,MPt[2]);
+      hEtaAMixCorr2Plot->Add(hEtaAMixCorr2,MPt[2]);
+      hEtaAMixEffPlot->Add(hEtaAMixEff,MPt[2]);
+
+      hPhiEtaRawPlot->Add(hPhiEtaRaw,MPt[2]);
+      hPhiEtaCorrPlot->Add(hPhiEtaCorr,MPt[2]);
+      hPhiEtaCorr2Plot->Add(hPhiEtaCorr2,MPt[2]);
+      hPhiEtaEffPlot->Add(hPhiEtaEff,MPt[2]);
+      hPhiEtaMixRawPlot->Add(hPhiEtaMixRaw,MPt[2]);
+      hPhiEtaMixCorrPlot->Add(hPhiEtaCorr,MPt[2]);
+      hPhiEtaMixCorr2Plot->Add(hPhiEtaMixCorr2,MPt[2]);
+      hPhiEtaMixEffPlot->Add(hPhiEtaMixEff,MPt[2]);
+      TrigSum+=MPt[2];
+      TrigSum2+=MPt2[2];
+    }
+  }
+  if(TrigSum==0)cout << "TrigSum: " << TrigSum << endl;
+  hPhiRawPlot->Scale(1./TrigSum);
+  hPhiCorrPlot->Scale(1./TrigSum);
+  hPhiCorr2Plot->Scale(1./TrigSum);
+  hPhiEffPlot->Scale(1./TrigSum);
+  hPhiMCPlot->Scale(1./TrigSum2);
+  hPhiMixRawPlot->Scale(1./TrigSum);
+  hPhiMixCorrPlot->Scale(1./TrigSum);
+  hPhiMixCorr2Plot->Scale(1./TrigSum);
+  hPhiMixEffPlot->Scale(1./TrigSum);
+  hPhiMixMCPlot->Scale(1./TrigSum);
+
+  hEtaNRawPlot->Scale(1./TrigSum);
+  hEtaNCorrPlot->Scale(1./TrigSum);
+  hEtaNCorr2Plot->Scale(1./TrigSum);
+  hEtaNEffPlot->Scale(1./TrigSum);
+  hEtaNMixRawPlot->Scale(1./TrigSum);
+  hEtaNMixCorrPlot->Scale(1./TrigSum);
+  hEtaNMixCorr2Plot->Scale(1./TrigSum);
+  hEtaNMixEffPlot->Scale(1./TrigSum);
+
+  hEtaARawPlot->Scale(1./TrigSum);
+  hEtaACorrPlot->Scale(1./TrigSum);
+  hEtaACorr2Plot->Scale(1./TrigSum);
+  hEtaAEffPlot->Scale(1./TrigSum);
+  hEtaAMixRawPlot->Scale(1./TrigSum);
+  hEtaAMixCorrPlot->Scale(1./TrigSum);
+  hEtaAMixCorr2Plot->Scale(1./TrigSum);
+  hEtaAMixEffPlot->Scale(1./TrigSum);
+
+  hPhiEtaRawPlot->Scale(1./TrigSum);
+  hPhiEtaCorrPlot->Scale(1./TrigSum);
+  hPhiEtaCorr2Plot->Scale(1./TrigSum);
+  hPhiEtaEffPlot->Scale(1./TrigSum);
+  hPhiEtaMixRawPlot->Scale(1./TrigSum);
+  hPhiEtaMixCorrPlot->Scale(1./TrigSum);
+  hPhiEtaMixCorr2Plot->Scale(1./TrigSum);
+  hPhiEtaMixEffPlot->Scale(1./TrigSum); 
+  
+  if(noTitle){
+    hPhiRawPlot->SetTitle("");
+    hPhiCorrPlot->SetTitle("");
+    hPhiCorr2Plot->SetTitle("");
+    hPhiEffPlot->SetTitle("");
+    hPhiMCPlot->SetTitle("");
+    hPhiMixRawPlot->SetTitle("");
+    hPhiMixCorrPlot->SetTitle("");
+    hPhiMixCorr2Plot->SetTitle("");
+    hPhiMixEffPlot->SetTitle("");
+    hPhiMixMCPlot->SetTitle("");
+
+    hEtaNRawPlot->SetTitle("");
+    hEtaNCorrPlot->SetTitle("");
+    hEtaNCorr2Plot->SetTitle("");
+    hEtaNEffPlot->SetTitle("");
+    hEtaNMixRawPlot->SetTitle("");
+    hEtaNMixCorrPlot->SetTitle("");
+    hEtaNMixCorr2Plot->SetTitle("");
+    hEtaNMixEffPlot->SetTitle("");
+
+    hEtaARawPlot->SetTitle("");
+    hEtaACorrPlot->SetTitle("");
+    hEtaACorr2Plot->SetTitle("");
+    hEtaAEffPlot->SetTitle("");
+    hEtaAMixRawPlot->SetTitle("");
+    hEtaAMixCorrPlot->SetTitle("");
+    hEtaAMixCorr2Plot->SetTitle("");
+    hEtaAMixEffPlot->SetTitle("");
+    
+    hPhiEtaRawPlot->SetTitle("");
+    hPhiEtaCorrPlot->SetTitle("");
+    hPhiEtaCorr2Plot->SetTitle("");
+    hPhiEtaEffPlot->SetTitle("");
+    hPhiEtaMixRawPlot->SetTitle("");
+    hPhiEtaMixCorrPlot->SetTitle("");
+    hPhiEtaMixCorr2Plot->SetTitle("");
+    hPhiEtaMixEffPlot->SetTitle(""); 
+  }
+  
+  if(ReBinPhi>1){
+    rebin1D(hPhiRawPlot,ReBinPhi);
+    rebin1D(hPhiCorrPlot,ReBinPhi);
+    hPhiCorr2Plot=rebin1D(hPhiCorr2Plot,ReBinPhi);
+    hPhiEffPlot=rebin1D(hPhiEffPlot,ReBinPhi);
+    hPhiMCPlot=rebins1D(hPhiMCPlot,ReBinPhi);
+    hPhiMixRawPlot=rebin1D(hPhiMixRawPlot,ReBinPhi);
+    hPhiMixCorrPlot=rebin1D(hPhiMixCorrPlot,ReBinPhi);
+    hPhiMixCorr2Plot=rebin1D(hPhiMixCorr2Plot,ReBinPhi);
+    hPhiMixEffPlot=rebin1D(hPhiMixEffPlot,ReBinPhi);
+    hPhiMixMCPlot=rebin1D(hPhiMixMCPlot,ReBinPhi);
+  }
+ if(ReBinEta>1){
+    rebin1D(hEtaNRawPlot,ReBinEtaN);
+    rebin1D(hEtaNCorrPlot,ReBinEtaN);
+    hEtaNCorr2Plot=rebin1D(hEtaNCorr2Plot,ReBinEtaN);
+    hEtaNEffPlot=rebin1D(hEtaNEffPlot,ReBinEtaN);
+    hEtaNMixRawPlot=rebin1D(hEtaNMixRawPlot,ReBinEtaN);
+    hEtaNMixCorrPlot=rebin1D(hEtaNMixCorrPlot,ReBinEtaN);
+    hEtaNMixCorr2Plot=rebin1D(hEtaNMixCorr2Plot,ReBinEtaN);
+    hEtaNMixEffPlot=rebin1D(hEtaNMixEffPlot,ReBinEtaN);
+
+    rebin1D(hEtaARawPlot,ReBinEtaA);
+    rebin1D(hEtaACorrPlot,ReBinEtaA);
+    hEtaACorr2Plot=rebin1D(hEtaACorr2Plot,ReBinEtaA);
+    hEtaAEffPlot=rebin1D(hEtaAEffPlot,ReBinEtaA);
+    hEtaAMixRawPlot=rebin1D(hEtaAMixRawPlot,ReBinEtaA);
+    hEtaAMixCorrPlot=rebin1D(hEtaAMixCorrPlot,ReBinEtaA);
+    hEtaAMixCorr2Plot=rebin1D(hEtaAMixCorr2Plot,ReBinEtaA);
+    hEtaAMixEffPlot=rebin1D(hEtaAMixEffPlot,ReBinEtaA);
+  }
+
+
+ ///Phi Plots////////////////////////////
+  c1=new TCanvas("c1","PhiRaw");
+  SetMargins1D(c1);
+  // if(DrawAsHisto)gStyle->SetHistFillColor(2);
+  // cout << hPhiRawPlot->GetXaxis()->GetTitle() << endl;
+  hPhiRawPlot->Draw();
+  if(DrawAsHisto)DrawLego1D(c1,hPhiRawPlot);
+   
+  sprintf(name,"%s/%s%sPhiRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  c1->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS)c1->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+ if(SavePDF)c1->SaveAs(name,"landscape");
+ sprintf(name,"%s/%s%sPhiRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.C",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SaveMacro)c1->SaveAs(name);
+  hPhiRawPlot->GetXaxis()->SetLabelOffset(0.005);
+  sprintf(name,"%s/%s%sPhiRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.txt",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SaveText)SaveAsText(hPhiRawPlot,name);
+  
+  c2=new TCanvas("c2","PhiCorr");
+  SetMargins1D(c2);
+  hPhiCorrPlot->Draw();
+  if(DrawAsHisto)DrawLego1D(c2,hPhiCorrPlot);
+  sprintf(name,"%s/%s%sPhiCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  c2->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS) c2->SaveAs(name);
+  hPhiCorrPlot->GetXaxis()->SetLabelOffset(0.005);
+
+   
+ if(!notDelta){
+ c2bg=new TCanvas("c2bg","PhiCorrBgSub");
+ SetMargins1D(c2bg);
+ if(ptWeighted==2){
+   hPhiCorr2Plot->SetMaximum(APt2);
+   hPhiCorr2Plot->SetMinimum(APt1);
+ }
+  hPhiCorr2Plot->Draw();
+  ZeroLine->Draw("same");
+  if(DrawAsHisto)DrawLego1D(c2bg,hPhiCorr2Plot);
+  sprintf(name,"%s/%s%sPhiCorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  c2bg->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiCorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS)c2bg->SaveAs(name);
+  hPhiCorr2Plot->GetXaxis()->SetLabelOffset(0.005);
+  }
+ float maxeff=1.1;
+ float mineff=0.5;
+  c3=new TCanvas("c3","PhiEff");
+  SetMargins1D(c3);
+  // hPhiEffPlot->SetMaximum(maxeff);
+  // hPhiEffPlot->SetMinimum(mineff);
+  hPhiEffPlot->Draw();
+  sprintf(name,"%s/%s%sPhiEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  c3->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS)c3->SaveAs(name);
+
+  c3MC=new TCanvas("c3MC","PhiMC");
+  SetMargins1D(c3MC);
+  hPhiMCPlot->Draw();
+  sprintf(name,"%s/%s%sPhiMC_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(DrawMC)c3MC->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiMC_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS&&DrawMC)c3MC->SaveAs(name);
+
+  c4=new TCanvas("c4","PhiMixRaw");
+  SetMargins1D(c4);
+  hPhiMixRawPlot->Draw();
+  sprintf(name,"%s/%s%sPhiMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  c4->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)c4->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.C",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(SaveMacro)c4->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.txt",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(SaveText)SaveAsText(hPhiMixRawPlot,name);
+
+  c5=new TCanvas("c5","PhiMixCorr");
+  SetMargins1D(c5);
+  hPhiMixCorrPlot->Draw();
+  sprintf(name,"%s/%s%sPhiMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  c5->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)c5->SaveAs(name);
+  
+  if(!notDelta){
+  c5bg=new TCanvas("c5bg","PhiMixCorrNorm");
+  SetMargins1D(c5bg);
+  hPhiMixCorr2Plot->Draw();
+  sprintf(name,"%s/%s%sPhiMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  c5bg->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+    if(SavePS)c5bg->SaveAs(name);
+  }
+
+  c6=new TCanvas("c6","PhiMixEff");
+  SetMargins1D(c6);
+  //hPhiMixEffPlot->SetMaximum(maxeff);
+  //hPhiMixEffPlot->SetMinimum(mineff);
+  hPhiMixEffPlot->Draw();
+  sprintf(name,"%s/%s%sPhiMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  c6->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)c6->SaveAs(name);
+
+  c6MC=new TCanvas("c6MC","PhiMixMC");
+  SetMargins1D(c6MC);
+  hPhiMixMCPlot->Draw();
+  sprintf(name,"%s/%s%sPhiMixMC_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(DrawMC)c6MC->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiMixMC_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS&&DrawMC)c6MC->SaveAs(name);
+
+  c2Cyl=new TCanvas("c2Cyl","PhiCorrCyl");
+  SetMargins1DCyl(c2Cyl);
+  hPhiCorrPlot->Draw("legocyl");
+  sprintf(name,"%s/%s%sPhiCorr%dCyl_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  c2Cyl->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiCorr%dCyl_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)c2Cyl->SaveAs(name);
+
+  if(!notDelta){
+  c2All=new TCanvas("c2All","PhiCorrAll");
+  SetMargins1D(c2All);
+  TH1F *hPhiCorrAll=(TH1F*)hPhiCorrPlot->Clone();
+  hPhiCorrAll->SetName("hPhiCorrAll");
+  hPhiCorrAll->SetMinimum(hPhiMixCorr->GetMinimum()-fabs(hPhiMixCorr2->GetMinimum()-hPhiMixCorr->GetMinimum()));
+  if(hPhiCorrAll->GetMinimum()<0)hPhiCorrAll->SetMinimum(0);
+  hPhiCorrAll->Draw();
+  hPhiMixCorrPlot->Draw("same");
+  hPhiMixCorr2Plot->Draw("same");
+  hPhiCorrAll->Draw("same");
+  sprintf(name,"%s/%s%sPhiCorr%dAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  c2All->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiCorr%dAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)c2All->SaveAs(name);
+ sprintf(name,"%s/%s%sPhiCorr%dAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePDF)c2All->SaveAs(name);
+}
+
+  c2Fit=new TCanvas("c2Fit","PhiCorrFit");
+  SetMargins1D(c2Fit);
+  TH1F* hPhiCorrFitPlot=(TH1F*)hPhiCorrPlot->Clone();
+  hPhiCorrFitPlot->SetName("hPhiCorrFitPlot");
+  hPhiCorrFitPlot->Draw();
+  hPhiCorrFitPlot->Fit("fit1");
+  fit2->SetParameter(2,fit1->GetParameter(4));
+  fit2->SetParLimits(2,0,0);
+  if(DrawAsHisto)DrawLego1D(c2,hPhiCorrFitPlot);
+  sprintf(name,"%s/%s%sPhiCorr%dFit_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  c2Fit->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiCorr%dFit_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS) c2Fit->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiCorr%dFit_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePDF) c2Fit->SaveAs(name);
+  hPhiCorrPlot->GetXaxis()->SetLabelOffset(0.005);
+
+  ////Near-Side Eta Plots////////////////////////////////
+  cN1=new TCanvas("cN1","EtaNRaw");
+  SetMargins1D(cN1); 
+  hEtaNRawPlot->Draw();
+  if(DrawAsHisto)DrawLego1D(cN1,hEtaNRawPlot);
+  sprintf(name,"%s/%s%sEtaNRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  cN1->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS)cN1->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePDF)cN1->SaveAs(name);
+   sprintf(name,"%s/%s%sEtaNRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.C",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SaveMacro)cN1->SaveAs(name);
+  hEtaNRawPlot->GetXaxis()->SetLabelOffset(0.005);
+  sprintf(name,"%s/%s%sEtaNRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.txt",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SaveText)SaveAsText(hEtaNRawPlot,name);
+  
+  cN2=new TCanvas("cN2","EtaNCorr");
+  SetMargins1D(cN2);
+  hEtaNCorrPlot->Draw();
+  if(DrawAsHisto)DrawLego1D(cN2,hEtaNCorrPlot);
+  sprintf(name,"%s/%s%sEtaNCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  cN2->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS) cN2->SaveAs(name);
+ sprintf(name,"%s/%s%sEtaNCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePDF) cN2->SaveAs(name);
+  hEtaNCorrPlot->GetXaxis()->SetLabelOffset(0.005);
+   
+ if(!notDelta){
+   cN2bg=new TCanvas("cN2bg","EtaNCorrBgSub");
+   SetMargins1D(cN2bg);
+   if(ptWeighted==2){
+     hEtaNCorr2Plot->SetMaximum(APt2);
+     hEtaNCorr2Plot->SetMinimum(APt1);
+   }
+   hEtaNCorr2Plot->Draw();
+   ZeroLine->Draw("same");
+   if(DrawAsHisto)DrawLego1D(cN2bg,hEtaNCorr2Plot);
+   sprintf(name,"%s/%s%sEtaNCorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+   cN2bg->SaveAs(name);
+   sprintf(name,"%s/%s%sEtaNCorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+   if(SavePS)cN2bg->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNCorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+   if(SavePDF)cN2bg->SaveAs(name)
+   hEtaNCorr2Plot->GetXaxis()->SetLabelOffset(0.005);
+ }
+ float maxeff=1.1;
+ float mineff=0.5;
+  cN3=new TCanvas("cN3","EtaNEff");
+  SetMargins1D(cN3);
+  //hEtaNEffPlot->SetMaximum(maxeff);
+  //hEtaNEffPlot->SetMinimum(mineff);
+  hEtaNEffPlot->Draw();
+  sprintf(name,"%s/%s%sEtaNEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  cN3->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS)cN3->SaveAs(name);
+ sprintf(name,"%s/%s%sEtaNEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePDF)cN3->SaveAs(name);
+
+  cN4=new TCanvas("cN4","EtaNMixRaw");
+  SetMargins1D(cN4);
+  hEtaNMixRawPlot->Draw();
+  sprintf(name,"%s/%s%sEtaNMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cN4->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)cN4->SaveAs(name);
+sprintf(name,"%s/%s%sEtaNMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePDF)cN4->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.C",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SaveMacro)cN4->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.txt",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SaveText)SaveAsText(hEtaNMixRawPlot,name);
+
+  cN5=new TCanvas("cN5","EtaNMixCorr");
+  SetMargins1D(cN5);
+  hEtaNMixCorrPlot->Draw();
+  sprintf(name,"%s/%s%sEtaNMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cN5->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)cN5->SaveAs(name);
+  
+  if(!notDelta){
+  cN5bg=new TCanvas("cN5bg","EtaNMixCorrNorm");
+  SetMargins1D(cN5bg);
+  hEtaNMixCorr2Plot->Draw();
+  sprintf(name,"%s/%s%sEtaNMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cN5bg->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+    if(SavePS)cN5bg->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+    if(SavePDF)cN5bg->SaveAs(name);
+  }
+
+  cN6=new TCanvas("cN6","EtaNMixEff");
+  SetMargins1D(cN6);
+  //hEtaNMixEffPlot->SetMaximum(maxeff);
+  // hEtaNMixEffPlot->SetMinimum(mineff);
+  hEtaNMixEffPlot->Draw();
+  sprintf(name,"%s/%s%sEtaNMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cN6->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)cN6->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePDF)cN6->SaveAs(name);
+
+  if(!notDelta){
+  cN2All=new TCanvas("cN2All","EtaNCorrAll");
+  SetMargins1D(cN2All);
+  TH1F *hEtaNCorrAll=(TH1F*)hEtaNCorrPlot->Clone();
+  hEtaNCorrAll->SetName("hEtaNCorrAll");
+  hEtaNCorrAll->SetMinimum(hEtaNMixCorr->GetMinimum()-fabs(hEtaNMixCorr2->GetMinimum()-hEtaNMixCorr->GetMinimum()));
+  if(hEtaNCorrAll->GetMinimum()<0)hEtaNCorrAll->SetMinimum(0);
+  hEtaNCorrAll->Draw();
+  hEtaNMixCorrPlot->Draw("same");
+  hEtaNMixCorr2Plot->Draw("same");
+  hEtaNCorrAll->Draw("same");
+  sprintf(name,"%s/%s%sEtaNCorr%dAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cN2All->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNCorr%dAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)cN2All->SaveAs(name);
+ sprintf(name,"%s/%s%sEtaNCorr%dAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePDF)cN2All->SaveAs(name);
+}
+
+ cN2Fit=new TCanvas("cN2Fit","EtaNCorrFit");
+  SetMargins1D(cN2Fit);
+  TH1F *hEtaNCorrFitPlot=(TH1F*)hEtaNCorrPlot->Clone();
+  hEtaNCorrFitPlot->SetName("hEtaNCorrFitPlot");
+  hEtaNCorrFitPlot->Draw();
+  hEtaNCorrFitPlot->Fit("fit2");
+  if(DrawAsHisto)DrawLego1D(cN2,hEtaNCorrPlot);
+  sprintf(name,"%s/%s%sEtaNCorr%dFit_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  cN2Fit->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaNCorr%dFit_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS) cN2Fit->SaveAs(name);
+ sprintf(name,"%s/%s%sEtaNCorr%dFit_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePDF) cN2Fit->SaveAs(name);
+  hEtaNCorrPlot->GetXaxis()->SetLabelOffset(0.005);
+
+  /////Away-Side Eta Plots////////////////////////
+
+   cA1=new TCanvas("cA1","EtaARaw");
+  SetMargins1D(cA1);
+  // if(DrawAsHisto)gStyle->SetHistFillColor(2);
+  //cout << hEtaARawPlot->GetXaxis()->GetTitle() << endl;
+  hEtaARawPlot->Draw();
+  if(DrawAsHisto)DrawLego1D(cA1,hEtaARawPlot);
+  sprintf(name,"%s/%s%sEtaARaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  cA1->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaARaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS)cA1->SaveAs(name);
+ sprintf(name,"%s/%s%sEtaARaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePDF)cA1->SaveAs(name);
+   sprintf(name,"%s/%s%sEtaARaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.C",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SaveMacro)cA1->SaveAs(name);
+  hEtaARawPlot->GetXaxis()->SetLabelOffset(0.005);
+  sprintf(name,"%s/%s%sEtaARaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.txt",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SaveText)SaveAsText(hEtaARawPlot,name);
+  
+  cA2=new TCanvas("cA2","EtaACorr");
+  SetMargins1D(cA2);
+  hEtaACorrPlot->Draw();
+  if(DrawAsHisto)DrawLego1D(ca2,hEtaACorrPlot);
+  sprintf(name,"%s/%s%sEtaACorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  cA2->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaACorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS) cA2->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaACorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePDF) cA2->SaveAs(name);
+  hEtaACorrPlot->GetXaxis()->SetLabelOffset(0.005);
+   
+ if(!notDelta){
+ cA2bg=new TCanvas("cA2bg","EtaACorrBgSub");
+ SetMargins1D(cA2bg);
+ if(ptWeighted==2){
+   hEtaACorr2Plot->SetMaximum(APt2);
+   hEtaACorr2Plot->SetMinimum(APt1);
+ }
+  hEtaACorr2Plot->Draw();
+  ZeroLine->Draw("same");
+  if(DrawAsHisto)DrawLego1D(c2bg,hEtaACorr2Plot);
+  sprintf(name,"%s/%s%sEtaACorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  cA2bg->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaACorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS)cA2bg->SaveAs(name);
+ sprintf(name,"%s/%s%sEtaACorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePDF)cA2bg->SaveAs(name);
+  hEtaACorr2Plot->GetXaxis()->SetLabelOffset(0.005);
+  }
+ float maxeff=1.1;
+ float mineff=0.5;
+  cA3=new TCanvas("cA3","EtaAEff");
+  SetMargins1D(cA3);
+  //hEtaAEffPlot->SetMaximum(maxeff);
+  // hEtaAEffPlot->SetMinimum(mineff);
+  hEtaAEffPlot->Draw();
+  sprintf(name,"%s/%s%sEtaAEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  cA3->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePS)cA3->SaveAs(name);
+ sprintf(name,"%s/%s%sEtaAEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],histArray[DrawAsHisto],titArray[noTitle],ZYACent);
+  if(SavePDF)cA3->SaveAs(name);
+
+  cA4=new TCanvas("cA4","EtaAMixRaw");
+  SetMargins1D(cA4);
+  hEtaAMixRawPlot->Draw();
+  sprintf(name,"%s/%s%sEtaAMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cA4->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)cA4->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePDF)cA4->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.C",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SaveMacro)cA4->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.txt",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SaveText)SaveAsText(hEtaAMixRawPlot,name);
+
+  cA5=new TCanvas("cA5","EtaAMixCorr");
+  SetMargins1D(cA5);
+  hEtaAMixCorrPlot->Draw();
+  sprintf(name,"%s/%s%sEtaAMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cA5->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)cA5->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePDF)cA5->SaveAs(name);
+  
+  if(!notDelta){
+  cA5bg=new TCanvas("cA5bg","EtaAMixCorrNorm");
+  SetMargins1D(cA5bg);
+  hEtaAMixCorr2Plot->Draw();
+  sprintf(name,"%s/%s%sEtaAMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cA5bg->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+    if(SavePS)cA5bg->SaveAs(name);
+sprintf(name,"%s/%s%sEtaAMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+    if(SavePDF)cA5bg->SaveAs(name);
+  }
+
+  cA6=new TCanvas("cA6","EtaAMixEff");
+  SetMargins1D(cA6);
+  //hEtaAMixEffPlot->SetMaximum(maxeff);
+  //hEtaAMixEffPlot->SetMinimum(mineff);
+  hEtaAMixEffPlot->Draw();
+  sprintf(name,"%s/%s%sEtaAMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cA6->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)cA6->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaAMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePDF)cA6->SaveAs(name);
+
+  if(!notDelta){
+  cA2All=new TCanvas("cA2All","EtaACorrAll");
+  SetMargins1D(cA2All);
+  TH1F *hEtaACorrAll=(TH1F*)hEtaACorrPlot->Clone();
+  hEtaACorrAll->SetName("hEtaACorrAll");
+  hEtaACorrAll->SetMinimum(hEtaAMixCorr->GetMinimum()-fabs(hEtaAMixCorr2->GetMinimum()-hEtaAMixCorr->GetMinimum()));
+  if(hEtaACorrAll->GetMinimum()<0)hEtaACorrAll->SetMinimum(0);
+  hEtaACorrAll->Draw();
+  hEtaAMixCorrPlot->Draw("same");
+  hEtaAMixCorr2Plot->Draw("same");
+  hEtaACorrAll->Draw("same");
+  sprintf(name,"%s/%s%sEtaACorr%dAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  cA2All->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaACorr%dAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePS)cA2All->SaveAs(name);
+  sprintf(name,"%s/%s%sEtaACorr%dAll_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d%s%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+  if(SavePDF)cA2All->SaveAs(name);
+}
+
+
+  ////PhiEtaPlots/////////////////////////////
+  c10=new TCanvas("c10","PhiEtaRaw");
+  SetMargins2DSurf(c10);
+  hPhiEtaRawPlot->Draw("lego2");
+  sprintf(name,"%s/%s%sPhiEtaRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c10->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c10->SaveAs(name);
+ sprintf(name,"%s/%s%sPhiEtaRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c10->SaveAs(name);
+
+
+  c20=new TCanvas("c20","PhiEtaCorr");
+  SetMargins2DSurf(c20);
+  hPhiEtaCorrPlot->Draw("lego2");
+  sprintf(name,"%s/%s%sPhiEtaCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c20->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c20->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c20->SaveAs(name);
+  
+  if(!notDelta){
+  c20bg=new TCanvas("c20bg","PhiEtaCorrBgSub");
+  SetMargins2DSurf(c20bg);
+  if(ptWeighted==2){
+    hPhiEtaCorr2Plot->SetMaximum(APt2);
+    hPhiEtaCorr2Plot->SetMinimum(APt1);
+  }
+  hPhiEtaCorr2Plot->Draw("lego2");
+  sprintf(name,"%s/%s%sPhiEtaCorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c20bg->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaCorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c20bg->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaCorr%dBgSub_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c20bg->SaveAs(name);
+  }
+
+  c30=new TCanvas("c30","PhiEtaEff");
+  //hPhiEtaEffPlot->SetMaximum(maxeff);
+  //hPhiEtaEffPlot->SetMinimum(mineff);
+  SetMargins2DSurf(c30);
+  hPhiEtaEffPlot->Draw("lego2");
+  sprintf(name,"%s/%s%sPhiEtaEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c30->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c30->SaveAs(name);
+ sprintf(name,"%s/%s%sPhiEtaEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c30->SaveAs(name);
+
+  c40=new TCanvas("c40","PhiEtaMixRaw");
+  SetMargins2DSurf(c40);
+  hPhiEtaMixRawPlot->Draw("lego2");
+  sprintf(name,"%s/%s%sPhiEtaMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c40->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c40->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixRaw_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c40->SaveAs(name);
+
+  c50=new TCanvas("c50","PhiEtaMixCorr");
+  SetMargins2DSurf(c50);
+  hPhiEtaMixCorrPlot->Draw("lego2");
+  sprintf(name,"%s/%s%sPhiEtaMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c50->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c50->SaveAs(name);
+ sprintf(name,"%s/%s%sPhiEtaMixCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c50->SaveAs(name);
+  
+  if(!notDelta){
+  c50bg=new TCanvas("c50bg","PhiEtaMixCorr");
+  SetMargins2DSurf(c50bg);
+  hPhiEtaMixCorr2Plot->Draw("lego2");
+  sprintf(name,"%s/%s%sPhiEtaMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c50bg->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c50bg->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixCorr%dNorm_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c50bg->SaveAs(name);
+  }
+
+  c60=new TCanvas("c60","PhiEtaMixEff");
+  // hPhiEtaMixEffPlot->SetMaximum(maxeff);
+  //hPhiEtaMixEffPlot->SetMinimum(mineff);
+  SetMargins2DSurf(c60);
+  hPhiEtaMixEffPlot->Draw("lego2");
+  sprintf(name,"%s/%s%sPhiEtaMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c60->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c60->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixEff%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c60->SaveAs(name);
+
+   c100=new TCanvas("c100","PhiEtaRaw");
+  SetMargins2D(c100);
+  hPhiEtaRawPlot->Draw("colz");
+  sprintf(name,"%s/%s%sPhiEtaRaw_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c100->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaRaw_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c100->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaRaw_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c100->SaveAs(name);
+
+  c200=new TCanvas("c200","PhiEtaCorr");
+  SetMargins2D(c200);
+  hPhiEtaCorrPlot->Draw("colz");
+  sprintf(name,"%s/%s%sPhiEtaCorr%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c200->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaCorr%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c200->SaveAs(name);
+ sprintf(name,"%s/%s%sPhiEtaCorr%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c200->SaveAs(name);
+  
+   if(!notDelta){
+  c200bg=new TCanvas("c200bg","PhiEtaCorrBgSub");
+  SetMargins2D(c200bg);
+  hPhiEtaCorr2Plot->Draw("colz");
+  sprintf(name,"%s/%s%sPhiEtaCorr%dBgSub_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c200bg->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaCorr%dBgSub_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c200bg->SaveAs(name);
+ sprintf(name,"%s/%s%sPhiEtaCorr%dBgSub_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c200bg->SaveAs(name);
+  }
+
+  c300=new TCanvas("c300","PhiEtaEff");
+  SetMargins2D(c300);
+  hPhiEtaEffPlot->Draw("colz");
+  sprintf(name,"%s/%s%sPhiEtaEff%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c300->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaEff%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c300->SaveAs(name);
+
+  c400=new TCanvas("c400","PhiEtaMixRaw");
+  SetMargins2D(c400);
+  hPhiEtaMixRawPlot->Draw("colz");
+  sprintf(name,"%s/%s%sPhiEtaMixRaw_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c400->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixRaw_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c400->SaveAs(name);
+ sprintf(name,"%s/%s%sPhiEtaMixRaw_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c400->SaveAs(name);
+
+  c500=new TCanvas("c500","PhiEtaMixCorr");
+  SetMargins2D(c500);
+  hPhiEtaMixCorrPlot->Draw("colz");
+  sprintf(name,"%s/%s%sPhiEtaMixCorr%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c500->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixCorr%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c500->SaveAs(name);
+ sprintf(name,"%s/%s%sPhiEtaMixCorr%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c500->SaveAs(name);
+  
+   if(!notDelta){
+  c500bg=new TCanvas("c500bg","PhiEtaMixCorrNorm");
+  SetMargins2D(c500bg);
+  hPhiEtaMixCorr2Plot->Draw("colz");
+  sprintf(name,"%s/%s%sPhiEtaMixCorr%dNorm_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c500bg->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixCorr%dNorm_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c500bg->SaveAs(name);
+ sprintf(name,"%s/%s%sPhiEtaMixCorr%dNorm_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c500bg->SaveAs(name);
+  }
+   
+  c600=new TCanvas("c600","PhiEtaMixEff");
+  SetMargins2D(c600);
+  hPhiEtaMixEffPlot->Draw("colz");
+  sprintf(name,"%s/%s%sPhiEtaMixEff%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c600->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaMixEff%d_2_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c600->SaveAs(name);
+  
+
+  
+  c20Cyl=new TCanvas("c20Cyl","PhiEtaCorrCyl");
+  SetMargins2DSurf(c20Cyl);
+  c20Cyl->SetTheta(45);
+  c20Cyl->SetPhi(200);
+  hPhiEtaCorrPlot->Draw("surf1cyl");
+  sprintf(name,"%s/%s%sPhiEtaCorr%dCyl_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.gif",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  c20Cyl->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaCorr%dCyl_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.eps",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePS)c20Cyl->SaveAs(name);
+  sprintf(name,"%s/%s%sPhiEtaCorr%dCyl_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d%s_z%1.1f.pdf",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,titArray[noTitle],ZYACent);
+  if(SavePDF)c20Cyl->SaveAs(name);
+
+ if(SaveRoot){
+   sprintf(name,"%s/DrawDPhi%s%sCorr%d_%2.1fPt%2.1f_%1.2fpt%1.2f_%dC%d_R%d_%d%s%s_z%1.1f.root",Folder,cDelta[notDelta],cPt[ptWeighted],EffMethod,TPt1,TPt2,APt1,APt2,Cent1,Cent2,ReBinPhi,ReBinEta,csign[LSign],titArray[noTitle],ZYACent);
+       TFile *fout=new TFile(name,"recreate");
+       cout << "Writing Histograms to File: " << name << endl;
+       hNEvents->Write();
+       hNTrig->Write();
+       hPhiRawPlot->Write();
+       hPhiEffPlot->Write();
+       hPhiCorrPlot->Write();
+       hPhiMixRawPlot->Write();
+       hPhiMixEffPlot->Write();
+       hPhiMixCorrPlot->Write();
+       hEtaARawPlot->Write();
+       hEtaAEffPlot->Write();
+       hEtaACorrPlot->Write();
+       hEtaAMixRawPlot->Write();
+       hEtaAMixEffPlot->Write();
+       hEtaAMixCorrPlot->Write();
+       hEtaNRawPlot->Write();
+       hEtaNEffPlot->Write();
+       hEtaNCorrPlot->Write();
+       hEtaNMixRawPlot->Write();
+       hEtaNMixEffPlot->Write();
+       hEtaNMixCorrPlot->Write();
+       hPhiEtaRawPlot->Write();
+       hPhiEtaEffPlot->Write();
+       hPhiEtaCorrPlot->Write();
+       hPhiEtaMixRawPlot->Write();
+       hPhiEtaMixEffPlot->Write();
+       hPhiEtaMixCorrPlot->Write();
+       if(!notDelta){
+               hPhiCorr2Plot->Write();
+               hPhiMixCorr2Plot->Write();
+               hEtaNCorr2Plot->Write();
+               hEtaNMixCorr2Plot->Write();
+               hEtaACorr2Plot->Write();
+               hEtaAMixCorr2Plot->Write();
+               hPhiEtaCorr2Plot->Write();
+               hPhiEtaMixCorr2Plot->Write();
+       }
+       fout->Write();
+       fout->Close();
+}
+}
diff --git a/PWG4/macros/jcorran/DrawSpectra.C b/PWG4/macros/jcorran/DrawSpectra.C
new file mode 100755 (executable)
index 0000000..849aabd
--- /dev/null
@@ -0,0 +1,4260 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+//Draws jet-spectra,pt dependences, centrality dependcies, etc for output of AliAnalysisTaskDiHardron
+//Author: Jason Glyndwr Ulery, ulery@uni-frankfurt.de
+
+
+
+
+#ifndef __CINT__
+#include <TF1.h>
+#include <TF2.h>
+#include "TSystem.h"
+#include <iostream>
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TRandom.h>
+#include <fstream>
+#include "TList.h"
+#include "TArrayF.h"
+#endif
+
+void DrawSpectra(){
+  gROOT->Reset();
+  gROOT->LoadMacro("Util9.C");
+  Style(1);
+  gStyle->SetOptFit(1);
+  //Parameters to be changed
+  Int_t APtTPtMult=0;//0 Associated particle spectra, 1 Trigger particle dependence, 2 Centrality dependence
+  Float_t TPt1=4;
+  Float_t TPt2=6;
+  Float_t APt1=0.25;
+  Float_t APt2=2;
+  Float_t Mult1=0;
+  Float_t Mult2=0;
+  Int_t PtWeighted=0;
+  Int_t HorizontalErrors=0;
+  Int_t NoTitle=1;
+  Int_t DrawFit=1;
+  Int_t LSign=0;
+  Int_t SaveFits=1;
+  int EffMethod=0;//0 no correction, 1 angle dependent, 2 use mix for triggered, 3 <1> 
+  char *filetype=".gif"; //.gif, .eps etc...
+  // const Int_t nTPt=12;
+  //Float_t TPtBins[(nTPt+1)]={2.5,3,4,6,8,10,15,20,30,40,50,75,100};
+  /*
+  const Int_t nTPt=6;
+  Float_t TPtBins[(nTPt+1)]={2,2.5,3,4,6,10,20};
+  */
+  
+  //  const Int_t nTPt=11;
+  //Float_t TPtBins[(nTPt+1)]={2,2.5,3,4,5,6,8,10,15,20,30,50};
+   const Int_t nTPt=9;
+   Float_t TPtBins[(nTPt+1)]={2,2.5,3,4,5,6,8,10,15,20};
+   // const Int_t nAPt=30;
+   // Float_t APtBins[(nAPt+1)]={0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,12,15,20,25,30,35,40,45,50,60,70,80,90,100};
+  // const Int_t nAPt=17;//up to 15-20 for 7 TeV
+  // Float_t APtBins[(nAPt+1)]={0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,8,10,15,20,30};
+  // const Int_t nAPt=4;//from  20-30 for 7 TeV
+  //Float_t APtBins[(nAPt+1)]={0.25,1,2,4,30};
+  //const Int_t nAPt=9;
+  // Float_t APtBins[(nAPt+1)]={0.25,0.5,1,1.5,2,2.5,3,3.5,4,6};
+  const Int_t nAPt=6;
+  Float_t APtBins[(nAPt+1)]={0.25,0.5,0.75,1,2,3,4};
+  const Int_t nMult=2;
+  Float_t MultBins1[nMult]={1,2};
+  Float_t MultBins2[nMult]={1,2};
+  Float_t MultArray1[3]={0,0,20};//>=
+  Float_t MultArray2[3]={500,20,500};//<
+  Float_t ZYAMCent=1.5;
+  Float_t ZYAMWidth=0.2;
+  float Pi=3.1415926535898;
+  Float_t NearWidthPhi=1.5;
+  Float_t AwayWidthPhi=Pi-NearWidthPhi;
+  Float_t NearWidthEta=0.5;
+
+  // char *Folder="2009-09-30/v4-16-Rev-08/pdc1_resdb_100_0000";
+  // char *EffFolder="2009-09-30/v4-16-Rev-08/pdc1_resdb_100_0000";
+  //char *Folder="current/7";
+  //  char *EffFolder="current/7";
+  //char *Folder="2009-12-15/RealData";//LHC09b8
+  // char *EffFolder="2009-12-03/Combined900";
+  // char *Folder="2010-01-06/900Data";//LHC09b8
+  // char *Folder="2010-03-10/pass5";
+  // char *EffFolder="2010-03-10/all_5";
+  // char *Folder="2010-04-12/pass5";
+  //  char *EffFolder="2010-04-12/900Pythia";
+  /*
+  char *Folder="2010-08-17/LHC10b_7pass2";
+  char *EffFolder="2010-08-17/7Pythia_LHC10b5";
+  */
+  
+  char *Folder="2010-08-17/LHC10c_900pass2";
+  //char *Folder="2010-07-02/LHC10c6_900Pythia";
+   char *EffFolder="2010-08-17/LHC10c6_900Pythia";
+  
+
+ //Plotting 
+  Float_t MarkerSize=1.5;
+  Int_t ColorNearPhi=kBlack;
+  Int_t ColorAwayPhi=kRed;
+  Int_t ColorMin=kGreen+2;
+  Int_t ColorNearPhiFit=kBlue+2;
+  Int_t ColorAwayPhiFit=kRed+2;
+  Int_t ColorMinFit=kGreen+3;
+  Int_t ColorNearEta=kGreen+2;
+  Int_t ColorAwayEta=kMagenta+3;
+  Int_t ColorNearEtaFit=kGreen+3;
+  Int_t MarkerNearPhi=20;
+  Int_t MarkerAwayPhi=21;
+  Int_t MarkerMin=22;
+  Int_t MarkerNearPhiFit=24;
+  Int_t MarkerAwayPhiFit=25;
+  Int_t MarkerMinFit=26;
+  Int_t MarkerNearEta=29;
+  Int_t MarkerAwayEta=23;
+  Int_t MarkerNearEtaFit=30;
+  
+  
+  TF1 *fit1=new TF1("fit1","1/sqrt(2*3.1415926)*([0]/[1]*(exp(-0.5*pow(x/[1],2))+exp(-0.5*pow((x-6.29185)/[1],2)))+[2]/[3]*(exp(-0.5*pow((x-3.14159)/[3],2))+exp(-0.5*pow((x+3.14159)/[3],2))))+[4]");
+  fit1->SetParameters(.1,.2,.1,.35,.1);
+  fit1->SetParNames("Near-Yield", "Near-Width","Away-Yield","Away-Width","Bg-Level");
+  fit1->SetParLimits(0,1E-10,100);
+  fit1->SetParLimits(1,0.01,6);
+  fit1->SetParLimits(2,1E-10,100);
+  fit1->SetParLimits(3,0.01,6);
+  fit1->SetParLimits(4,1E-10,500);
+   TF1 *fit2=new TF1("fit2","1/sqrt(2*3.1415926)*([0]/[1]*(exp(-0.5*pow(x/[1],2))))+[2]");
+  fit2->SetParameters(.1,.2,.1);
+  fit2->SetParNames("Near-Yield", "Near-Width","Bg-Level");
+  fit2->SetParLimits(0,1E-10,100);
+  fit2->SetParLimits(1,0.01,6);
+  fit2->SetParLimits(2,1E-10,500);
+  //Bollow this users should not need to change
+  char *cPt[2]={"","PT"};
+  char name[250];
+  char inName[100];
+  char effName[100];
+  sprintf(inName,"%s/julery_DiHadron.root",Folder);
+  sprintf(effName,"%s/julery_DiHadron.root",EffFolder);
+  cout << inName << endl;
+  cout << effName << endl;
+  Float_t MPt[3];//<pt>, error <pt>, # of triggers
+  Float_t MPt2[3];
+  Float_t TrigSum=0;
+  
+  TH1F *hPhiRaw=new TH1F("hPhiRaw","",1,0,1);
+  TH1F *hPhiCorr=new TH1F("hPhiCorr","",1,0,1);
+  TH1F *hPhiEff=new TH1F("hPhiEff","",1,0,1);
+  TH1F *hPhiMC=new TH1F("hPhiMC","",1,0,1);
+  TH1F *hPhiMixRaw=new TH1F("hPhiMixRaw","",1,0,1);
+  TH1F *hPhiMixCorr=new TH1F("hPhiMixCorr","",1,0,1);
+  TH1F *hPhiMixEff=new TH1F("hPhiMixEff","",1,0,1);
+  TH1F *hPhiMixMC=new TH1F("hPhiMixMC","",1,0,1);
+  TH2F *hPhiEtaRaw=new TH2F("hPhiEtaRaw","",1,0,1,1,0,1);
+  TH2F *hPhiEtaCorr=new TH2F("hPhiEtaCorr","",1,0,1,1,0,1);
+  TH2F *hPhiEtaEff=new TH2F("hPhiEtaEff","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMC=new TH2F("hPhiEtaMC","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixRaw=new TH2F("hPhiEtaMixRaw","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixCorr=new TH2F("hPhiEtaMixCorr","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixEff=new TH2F("hPhiEtaMixEff","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixMC=new TH2F("hPhiEtaMixMC","",1,0,1,1,0,1);
+
+  TH1F *hEtaNRaw=new TH1F("hEtaNRaw","",1,0,1);
+  TH1F *hEtaNCorr=new TH1F("hEtaNCorr","",1,0,1);
+  TH1F *hEtaNEff=new TH1F("hEtaNEff","",1,0,1);
+  TH1F *hEtaNMC=new TH1F("hEtaNMC","",1,0,1);
+  TH1F *hEtaNMixRaw=new TH1F("hEtaNMixRaw","",1,0,1);
+  TH1F *hEtaNMixCorr=new TH1F("hEtaNMixCorr","",1,0,1);
+  TH1F *hEtaNMixEff=new TH1F("hEtaNMixEff","",1,0,1);
+  TH1F *hEtaNMixMC=new TH1F("hEtaNMixMC","",1,0,1);
+
+  TH1F *hEtaARaw=new TH1F("hEtaARaw","",1,0,1);
+  TH1F *hEtaACorr=new TH1F("hEtaACorr","",1,0,1);
+  TH1F *hEtaAEff=new TH1F("hEtaAEff","",1,0,1);
+  TH1F *hEtaAMC=new TH1F("hEtaAMC","",1,0,1);
+  TH1F *hEtaAMixRaw=new TH1F("hEtaAMixRaw","",1,0,1);
+  TH1F *hEtaAMixCorr=new TH1F("hEtaAMixCorr","",1,0,1);
+  TH1F *hEtaAMixEff=new TH1F("hEtaAMixEff","",1,0,1);
+  TH1F *hEtaAMixMC=new TH1F("hEtaAMixMC","",1,0,1);
+  
+  TH1F *hTPhiRaw=new TH1F("hTPhiRaw","For near-side pt sum",1,0,1);
+  TH1F *hTPhiCorr=new TH1F("hTPhiCorr","",1,0,1);
+  TH1F *hTPhiEff=new TH1F("hTPhiErr","",1,0,1);
+  TH1F *hTPhiMC=new TH1F("hTPhiMC","",1,0,1);
+  TH1F *hTPhiMixRaw=new TH1F("hTPhiMixRaw","",1,0,1);
+  TH1F *hTPhiMixCorr=new TH1F("hTPhiMixCorr","",1,0,1);
+  TH1F *hTPhiMixEff=new TH1F("hTPhiMixEff","",1,0,1);
+  TH1F *hTPhiMixMC=new TH1F("hTPhiMixMC","",1,0,1);
+  TH2F *hTPhiEtaRaw=new TH2F("hTPhiEtaRaw","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaCorr=new TH2F("hTPhiEtaCorr","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaEff=new TH2F("hTPhiEtaEff","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMC=new TH2F("hTPhiEtaMC","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMixRaw=new TH2F("hTPhiEtaMixRaw","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMixCorr=new TH2F("hTPhiEtaMixCorr","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMixEff=new TH2F("hTPhiEtaMixEff","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMixMC=new TH2F("hTPhiEtaMixMC","",1,0,1,1,0,1);
+
+  TH1F *hTEtaNRaw=new TH1F("hTEtaNRaw","",1,0,1);
+  TH1F *hTEtaNCorr=new TH1F("hTEtaNCorr","",1,0,1);
+  TH1F *hTEtaNEff=new TH1F("hTEtaNEff","",1,0,1);
+  TH1F *hTEtaNMC=new TH1F("hTEtaNMC","",1,0,1);
+  TH1F *hTEtaNMixRaw=new TH1F("hTEtaNMixRaw","",1,0,1);
+  TH1F *hTEtaNMixCorr=new TH1F("hTEtaNMixCorr","",1,0,1);
+  TH1F *hTEtaNMixEff=new TH1F("hTEtaNMixEff","",1,0,1);
+  TH1F *hTEtaNMixMC=new TH1F("hTEtaNMixMC","",1,0,1);
+
+  TH1F *hTEtaARaw=new TH1F("hTEtaARaw","",1,0,1);
+  TH1F *hTEtaACorr=new TH1F("hTEtaACorr","",1,0,1);
+  TH1F *hTEtaAEff=new TH1F("hTEtaAEff","",1,0,1);
+  TH1F *hTEtaAMC=new TH1F("hTEtaAMC","",1,0,1);
+  TH1F *hTEtaAMixRaw=new TH1F("hTEtaAMixRaw","",1,0,1);
+  TH1F *hTEtaAMixCorr=new TH1F("hTEtaAMixCorr","",1,0,1);
+  TH1F *hTEtaAMixEff=new TH1F("hTEtaAMixEff","",1,0,1);
+  TH1F *hTEtaAMixMC=new TH1F("hTEtaAMixMC","",1,0,1);
+  
+  TH1F *hPhiRawPt=new TH1F("hPhiRawPt","",1,0,1);
+  TH1F *hPhiCorrPt=new TH1F("hPhiCorrPt","",1,0,1);
+  TH1F *hPhiEffPt=new TH1F("hPhiEffPt","",1,0,1);
+  TH1F *hPhiMCPt=new TH1F("hPhiMCPt","",1,0,1);
+  TH1F *hPhiMixRawPt=new TH1F("hPhiMixRawPt","",1,0,1);
+  TH1F *hPhiMixCorrPt=new TH1F("hPhiMixCorrPt","",1,0,1);
+  TH1F *hPhiMixEffPt=new TH1F("hPhiMixEffPt","",1,0,1);
+  TH1F *hPhiMixMCPt=new TH1F("hPhiMixMCPt","",1,0,1);
+  TH2F *hPhiEtaRawPt=new TH2F("hPhiEtaRawPt","",1,0,1,1,0,1);
+  TH2F *hPhiEtaCorrPt=new TH2F("hPhiEtaCorrPt","",1,0,1,1,0,1);
+  TH2F *hPhiEtaEffPt=new TH2F("hPhiEtaEffPt","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMCPt=new TH2F("hPhiEtaMCPt","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixRawPt=new TH2F("hPhiEtaMixRawPt","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixCorrPt=new TH2F("hPhiEtaMixCorrPt","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixEffPt=new TH2F("hPhiEtaMixEffPt","",1,0,1,1,0,1);
+  TH2F *hPhiEtaMixMCPt=new TH2F("hPhiEtaMixMCPt","",1,0,1,1,0,1);
+
+  TH1F *hEtaNRawPt=new TH1F("hEtaNRawPt","",1,0,1);
+  TH1F *hEtaNCorrPt=new TH1F("hEtaNCorrPt","",1,0,1);
+  TH1F *hEtaNEffPt=new TH1F("hEtaNEffPt","",1,0,1);
+  TH1F *hEtaNMCPt=new TH1F("hEtaNMCPt","",1,0,1);
+  TH1F *hEtaNMixRawPt=new TH1F("hEtaNMixRawPt","",1,0,1);
+  TH1F *hEtaNMixCorrPt=new TH1F("hEtaNMixCorrPt","",1,0,1);
+  TH1F *hEtaNMixEffPt=new TH1F("hEtaNMixEffPt","",1,0,1);
+  TH1F *hEtaNMixMCPt=new TH1F("hEtaNMixMCPt","",1,0,1);
+
+  TH1F *hEtaARawPt=new TH1F("hEtaARawPt","",1,0,1);
+  TH1F *hEtaACorrPt=new TH1F("hEtaACorrPt","",1,0,1);
+  TH1F *hEtaAEffPt=new TH1F("hEtaAEffPt","",1,0,1);
+  TH1F *hEtaAMCPt=new TH1F("hEtaAMCPt","",1,0,1);
+  TH1F *hEtaAMixRawPt=new TH1F("hEtaAMixRawPt","",1,0,1);
+  TH1F *hEtaAMixCorrPt=new TH1F("hEtaAMixCorrPt","",1,0,1);
+  TH1F *hEtaAMixEffPt=new TH1F("hEtaAMixEffPt","",1,0,1);
+  TH1F *hEtaAMixMCPt=new TH1F("hEtaAMixMCPt","",1,0,1);
+  
+  TH1F *hTPhiRawPt=new TH1F("hTPhiRawPt","",1,0,1);
+  TH1F *hTPhiCorrPt=new TH1F("hTPhiCorrPt","",1,0,1);
+  TH1F *hTPhiEffPt=new TH1F("hTPhiEffPt","",1,0,1);
+  TH1F *hTPhiMCPt=new TH1F("hTPhiMCPt","",1,0,1);
+  TH1F *hTPhiMixRawPt=new TH1F("hTPhiMixRawPt","",1,0,1);
+  TH1F *hTPhiMixCorrPt=new TH1F("hTPhiMixCorrPt","",1,0,1);
+  TH1F *hTPhiMixEffPt=new TH1F("hTPhiMixEffPt","",1,0,1);
+  TH1F *hTPhiMixMCPt=new TH1F("hTPhiMixMCPt","",1,0,1);
+  TH2F *hTPhiEtaRawPt=new TH2F("hTPhiEtaRawPt","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaCorrPt=new TH2F("hTPhiEtaCorrPt","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaEffPt=new TH2F("hTPhiEtaEffPt","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMCPt=new TH2F("hTPhiEtaMCPt","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMixRawPt=new TH2F("hTPhiEtaMixRawPt","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMixCorrPt=new TH2F("hTPhiEtaMixCorrPt","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMixEffPt=new TH2F("hTPhiEtaMixEffPt","",1,0,1,1,0,1);
+  TH2F *hTPhiEtaMixMCPt=new TH2F("hTPhiEtaMixMCPt","",1,0,1,1,0,1);
+
+  TH1F *hTEtaNRawPt=new TH1F("hTEtaNRawPt","",1,0,1);
+  TH1F *hTEtaNCorrPt=new TH1F("hTEtaNCorrPt","",1,0,1);
+  TH1F *hTEtaNEffPt=new TH1F("hTEtaNEffPt","",1,0,1);
+  TH1F *hTEtaNMCPt=new TH1F("hTEtaNMCPt","",1,0,1);
+  TH1F *hTEtaNMixRawPt=new TH1F("hTEtaNMixRawPt","",1,0,1);
+  TH1F *hTEtaNMixCorrPt=new TH1F("hTEtaNMixCorrPt","",1,0,1);
+  TH1F *hTEtaNMixEffPt=new TH1F("hTEtaNMixEffPt","",1,0,1);
+  TH1F *hTEtaNMixMCPt=new TH1F("hTEtaNMixMCPt","",1,0,1);
+
+  TH1F *hTEtaARawPt=new TH1F("hTEtaARawPt","",1,0,1);
+  TH1F *hTEtaACorrPt=new TH1F("hTEtaACorrPt","",1,0,1);
+  TH1F *hTEtaAEffPt=new TH1F("hTEtaAEffPt","",1,0,1);
+  TH1F *hTEtaAMCPt=new TH1F("hTEtaAMCPt","",1,0,1);
+  TH1F *hTEtaAMixRawPt=new TH1F("hTEtaAMixRawPt","",1,0,1);
+  TH1F *hTEtaAMixCorrPt=new TH1F("hTEtaAMixCorrPt","",1,0,1);
+  TH1F *hTEtaAMixEffPt=new TH1F("hTEtaAMixEffPt","",1,0,1);
+  TH1F *hTEtaAMixMCPt=new TH1F("hTEtaAMixMCPt","",1,0,1);
+  
+  TH1F *hMult=new TH1F("hMult","",1,0,1);
+  TH1F *hMultTrig=new TH1F("hMultTrig","",1,0,1);
+  TH1F *hMult2=new TH1F("hMult2","",1,0,1);
+  TH1F *hMultTrig2=new TH1F("hMultTrig2","",1,0,1);
+  float plotmin=10,plotmax=11;
+  float plotmin2=10,plotmax2=11;
+  float plotmin3=10,plotmax3=11;
+  
+  //histograms for ZYAM
+  TH1F *hPhiCorr2;
+  TH1F *hPhiMixCorr2;
+  TH1F *hEtaNCorr2;
+  TH1F *hEtaACorr2;
+  TH1F *hEtaMixCorr2;
+  TH2F *hPhiEtaCorr2;
+  TH2F *hPhiEtaMixCorr2;
+  
+  TH1F *hPhiCorrPt2;
+  TH1F *hPhiMixCorrPt2;
+  TH1F *hEtaNCorrPt2;
+  TH1F *hEtaACorrPt2;
+  TH1F *hEtaMixCorr2;
+  TH2F *hPhiEtaCorrPt2;
+  TH2F *hPhiEtaMixCorrPt2;
+  
+  //histograms for summing the centraility bins
+  TH1F *hPhiCorrSum;
+  TH1F *hPhiCorr2Sum;
+  TH1F *hPhiMixCorrSum;
+  TH1F *hPhiMixCorr2Sum;
+  TH1F *hEtaNCorrSum;
+  TH1F *hEtaNCorr2Sum;
+  TH1F *hEtaNMixCorrSum;
+  TH1F *hEtaNMixCorr2Sum;
+  TH1F *hEtaACorrSum;
+  TH1F *hEtaACorr2Sum; 
+  TH1F *hEtaAMixCorrSum;
+  TH1F *hEtaAMixCorr2Sum;
+  TH2F *hPhiEtaCorrSum;
+  TH2F *hPhiEtaCorr2Sum;
+  TH2F *hPhiEtaMixCorrSum;
+  TH2F *hPhiEtaMixCorr2Sum;
+
+  TH1F *hPhiCorrPtSum;
+  TH1F *hPhiCorrPt2Sum;
+  TH1F *hPhiMixCorrPtSum;
+  TH1F *hPhiMixCorrPt2Sum;
+  TH1F *hEtaNCorrPtSum;
+  TH1F *hEtaNCorrPt2Sum;
+  TH1F *hEtaNMixCorrPtSum;
+  TH1F *hEtaNMixCorrPt2Sum;
+  TH1F *hEtaACorrPtSum;
+  TH1F *hEtaACorrPt2Sum;
+  TH1F *hEtaAMixCorrPtSum;
+  TH1F *hEtaAMixCorrPt2Sum;
+  TH2F *hPhiEtaCorrPtSum;
+  TH2F *hPhiEtaCorrPt2Sum;
+  TH2F *hPhiEtaMixCorrPtSum;
+  TH2F *hPhiEtaMixCorrPt2Sum;
+  TH1F *hTPhiCorrPt2Sum;
+  TH2F *hTPhiEtaCorrSum;
+  TH2F *hTPhiEtaCorrPt2Sum;
+  
+  int NearBinsPhi;
+  int AwayBinsPhi;
+  int MinBinsPhi;
+  int NearBinsEta;
+  int AwayBinsEta;
+  int NearBinsPhiEta1;
+  int NearBinsPhiEta2;
+  int AwayBinsPhiEta;
+  int MinBinsPhiEta;
+  float tempsum;
+  
+  TAxis *phiaxis;
+  TAxis *etaaxis;
+  
+  int loopSize=0;
+  int nAPt2=0;
+  for(int i=0;i<=nAPt;i++){if(fabs(TPt1-APtBins[i])<0.2)nAPt2=i;}
+  if(APtTPtMult==0)loopSize=nAPt2;
+  if(APtTPtMult==1)loopSize=nTPt;
+  if(APtTPtMult==2)loopSize=nMult;
+  const int nMainLoop=loopSize;
+  cout << "loopSize " << loopSize << endl;
+  if(loopSize==0){
+    cout << "Error: Check Arrays" << endl;
+    break;
+  }
+  Float_t MainArray[nMainLoop];
+  Float_t eMainArray[nMainLoop];
+  Float_t a[3];
+  float centx, centy;
+  float binwx, binwy;
+  const int nx=18;
+  //0 (x1+x2)/2, 1 e2, 2 <x>,  3 e2, 4 lower error of 1 and 2, 5 e3, 6 zt1_0, 7 e5, 8 zt1_2, 9 e7, 10 zt1_3, 11 e9, 12 zt2_0, 13 e11, 14 zt2_1, 15 e13, 16 zt2_2, 17 e15  (zt_0 is (pt1+pt2)/2 zt_1 is <pt> zt_2 is lower error)
+  float NXPhi[nx][nMainLoop];
+  float AXPhi[nx][nMainLoop];
+  float NXPhiFit[nx][nMainLoop];
+  float AXPhiFit[nx][nMainLoop];
+  float NXEta[nx][nMainLoop];
+  float AXEta[nx][nMainLoop];
+  float NXEtaFit[nx][nMainLoop];
+  float AXEtaFit[nx][nMainLoop];
+  float NXPhiEta1[nx][nMainLoop];
+  float NXPhiEta2[nx][nMainLoop];
+  float AXPhiEta[nx][nMainLoop];
+  //arrays for our tgraphs to store yields and averge bin contends
+  const int nyields=10;//0 yield, 1 eyield, 2 pt yield, 3 ept yield, 4 dN/dpt 5 e4 6 dN/dzt (zt=Trig) yield, 7 ezt yield, 8 dN/dzt (zt=near) yield, 9 ezt2 yield
+  float NYieldPhi[nyields][nMainLoop];
+  float NYieldPhiZYAM[nyields][nMainLoop];
+  float NYieldPhiFit[nyields][nMainLoop];
+  float NYieldEta[nyields][nMainLoop];
+  float NYieldEtaZYAM[nyields][nMainLoop];
+  float NYieldEtaFit[nyields][nMainLoop];
+  float NYieldPhiEta1[nyields][nMainLoop];
+  float NYieldPhiEta2[nyields][nMainLoop];
+  float NYieldPhiEta3[nyields][nMainLoop];//jet only
+  float NYieldPhiEta1ZYAM[nyields][nMainLoop];//Jet+Ridge
+  float NYieldPhiEta2ZYAM[nyields][nMainLoop];//Ridge
+  float NRMSPhi[nyields][nMainLoop];
+  float NRMSEta[nyields][nMainLoop];
+  float NWidthPhi[nyields][nMainLoop];
+  float NWidthEta[nyields][nMainLoop];
+  float NJtPhi[nyields][nMainLoop];
+  float NJtEta[nyields][nMainLoop];
+  float NRMSPhiEtaPhi[nyields][nMainLoop];
+  float NRMSPhiEtaEta[nyields][nMainLoop];
+  float AYieldPhi[nyields][nMainLoop];
+  float AYieldPhiZYAM[nyields][nMainLoop];
+  float AYieldPhiFit[nyields][nMainLoop];
+  float AYieldEta[nyields][nMainLoop];
+  float AYieldEtaZYAM[nyields][nMainLoop];
+  float AYieldEtaFit[nyields][nMainLoop];
+  float AYieldPhiEta[nyields][nMainLoop];
+  float AYieldPhiEtaZYAM[nyields][nMainLoop];
+  float ARMSPhi[nyields][nMainLoop];
+  float ARMSEta[nyields][nMainLoop];
+  float AWidthPhi[nyields][nMainLoop];
+  float AWidthEta[nyields][nMainLoop];
+  float AJtPhi[nyields][nMainLoop];
+  float AJtEta[nyields][nMainLoop];
+  float MYieldPhi[nyields][nMainLoop];
+  float MYieldPhiFit[nyields][nMainLoop];
+  float MYieldPhiEta[nyields][nMainLoop];
+  float MAvePhiEta[nyields][nMainLoop];
+
+  float TNYieldPhi[nyields][nMainLoop];
+  float TNYieldPhiZYAM[nyields][nMainLoop];
+  float TNYieldPhiFit[nyields][nMainLoop];
+  float TNYieldPhiEta1[nyields][nMainLoop];
+  float TNYieldPhiEta2[nyields][nMainLoop];
+  float TNYieldPhiEta3[nyields][nMainLoop];
+  float TAYieldPhi[nyields][nMainLoop];
+  float TAYieldPhiZYAM[nyields][nMainLoop];
+  float TAYieldPhiFit[nyields][nMainLoop];
+  float TAYieldPhiEta[nyields][nMainLoop];
+  float TAYieldPhiEtaZYAM[nyields][nMainLoop];
+
+  float NAvePhi[nyields][nMainLoop];
+  float NAvePhiZYAM[nyields][nMainLoop];
+  float NAvePhiFit[nyields][nMainLoop];
+  float NAveEta[nyields][nMainLoop];
+  float NAveEtaZYAM[nyields][nMainLoop];
+  float NAveEtaFit[nyields][nMainLoop];
+  float NAvePhiEta1[nyields][nMainLoop];
+  float NAvePhiEta2[nyields][nMainLoop];
+  float NAvePhiEta1ZYAM[nyields][nMainLoop];
+  float NAvePhiEta2ZYAM[nyields][nMainLoop];
+  float AAvePhi[nyields][nMainLoop];
+  float AAvePhiZYAM[nyields][nMainLoop];
+  float AAvePhiFit[nyields][nMainLoop];
+  float AAveEta[nyields][nMainLoop];
+  float AAveEtaZYAM[nyields][nMainLoop];
+  float AAveEtaFit[nyields][nMainLoop];
+  float AAvePhiEta[nyields][nMainLoop];
+  float AAvePhiEtaZYAM[nyields][nMainLoop];
+  float MAvePhi[nyields][nMainLoop];
+  float MAvePhiFit[nyields][nMainLoop];
+  float MAvePhiEta[nyields][nMainLoop];
+  float trms1;
+  float trms2;
+  float trms3;
+  TFile *inFile=new TFile(inName);
+  TList *inList=inFile->Get("julery_DiHadron");
+  TFile *effFile=new TFile(effName);
+  TList *effList=effFile->Get("julery_DiHadron");
+  char *FitTit[2]={"","_Fit"};
+  //loop for total near-side yield over full pt range
+  for(int Cent=Mult1;Cent<=Mult2;Cent++){
+ MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,inList,hTPhiRaw,hTPhiMixRaw,hTEtaNRaw,hTEtaNMixRaw,hTEtaARaw,hTEtaAMixRaw,hTPhiEtaRaw,hTPhiEtaMixRaw,MPt,1,0,0,0);
+    MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,effList,hTPhiEff,hTPhiMixEff,hTEtaNEff,hTEtaNMixEff,hTEtaAEff,hTEtaAMixEff,hTPhiEtaEff,hTPhiEtaMixEff,MPt2,0,0,0,0);
+    MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,effList,hTPhiMC,hTPhiMixMC,hTEtaNMC,hTEtaNMixMC,hTEtaAMC,hTEtaAMixMC,hTPhiEtaMC,hTPhiEtaMixMC,MPt2,0,1,0,0);
+    MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,inList,hTPhiRawPt,hTPhiMixRawPt,hTEtaNRawPt,hTEtaNMixRawPt,hTEtaARawPt,hTEtaAMixRawPt,hTPhiEtaRawPt,hTPhiEtaMixRawPt,MPt,1,0,0,0);
+    MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,effList,hTPhiEffPt,hTPhiMixEffPt,hTEtaNEffPt,hTEtaNMixEffPt,hTEtaAEffPt,hTEtaAMixEffPt,hTPhiEtaEffPt,hTPhiEtaMixEffPt,MPt2,1,0,0,0);
+    MakeProjections(TPt1,TPt2,0.25,TPt1,Cent,effList,hTPhiMCPt,hTPhiMixMCPt,hTEtaNMCPt,hTEtaNMixMCPt,hTEtaAMCPt,hTEtaAMixMCPt,hTPhiEtaMCPt,hTPhiEtaMixMCPt,MPt2,1,1,0,0);
+    // cout << "hTPhiRaw " << hTPhiRaw->GetBinContent(1) << endl;
+ if(EffMethod<4){
+      EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hTPhiEff,hTPhiMC,hTPhiMixEff,hTPhiMixMC,hTEtaNEff,hTEtaNMC,hTEtaNMixEff,hTEtaNMixMC,hTEtaAEff,hTEtaAMC,hTEtaAMixEff,hTEtaAMixMC,hTPhiEtaEff,hTPhiEtaMC,hTPhiEtaMixEff,hTPhiEtaMixMC,EffMethod);
+      EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hTPhiEffPt,hTPhiMCPt,hTPhiMixEffPt,hTPhiMixMCPt,hTEtaNEffPt,hTEtaNMCPt,hTEtaNMixEffPt,hTEtaNMixMCPt,hTEtaAEffPt,hTEtaAMCPt,hTEtaAMixEffPt,hTEtaAMixMCPt,hTPhiEtaEffPt,hTPhiEtaMCPt,hTPhiEtaMixEffPt,hTPhiEtaMixMCPt,EffMethod);
+    }
+    else{
+      EffFit(APt1,APt2,Cent,effList,hTPhiEff,hTPhiMixEff,hTEtaNEff,hTEtaNMixEff,hTEtaAEff,hTEtaAMixEff,hTPhiEtaEff,hTPhiEtaMixEff,LSign,VariablePtLimit);
+      EffFit(APt1,APt2,Cent,effList,hTPhiEffPt,hTPhiMixEffPt,hTEtaNEffPt,hTEtaNMixEffPt,hTEtaAEffPt,hTEtaAMixEffPt,hTPhiEtaEffPt,hTPhiEtaMixEffPt,LSign,VariablePtLimit);
+    }
+    /*
+    EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hTPhiRaw,hTPhiEff,hTPhiMC,hTPhiMixRaw,hTPhiMixEff,hTPhiMixMC,hTEtaNRaw,hTEtaNEff,hTEtaNMC,hTEtaNMixRaw,hTEtaNMixEff,hTEtaNMixMC,hTEtaARaw,hTEtaAEff,hTEtaAMC,hTEtaAMixRaw,hTEtaAMixEff,hTEtaAMixMC,hTPhiEtaRaw,hTPhiEtaEff,hTPhiEtaMC,hTPhiEtaMixRaw,hTPhiEtaMixEff,hTPhiEtaMixMC,EffMethod);
+    EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hTPhiRawPt,hTPhiEffPt,hTPhiMCPt,hTPhiMixRawPt,hTPhiMixEffPt,hTPhiMixMCPt,hTEtaNRawPt,hTEtaNEffPt,hTEtaNMCPt,hTEtaNMixRawPt,hTEtaNMixEffPt,hTEtaNMixMCPt,hTEtaARawPt,hTEtaAEffPt,hTEtaAMCPt,hTEtaAMixRawPt,hTEtaAMixEffPt,hTEtaAMixMCPt,hTPhiEtaRawPt,hTPhiEtaEffPt,hTPhiEtaMCPt,hTPhiEtaMixRawPt,hTPhiEtaMixEffPt,hTPhiEtaMixMCPt,EffMethod);
+    */
+    
+    hTPhiCorr=(TH1F*)hTPhiRaw->Clone();
+    sprintf(name,"hTPhiCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTPhiCorr->SetName(name);
+    hTPhiCorr->Divide(hTPhiEff);
+    
+    hTPhiMixCorr=(TH1F*)hTPhiMixRaw->Clone();
+    sprintf(name,"hTPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTPhiMixCorr->SetName(name);
+    hTPhiMixCorr->Divide(hTPhiMixEff);
+
+    hTEtaNCorr=(TH1F*)hTEtaNRaw->Clone();
+    sprintf(name,"hTEtaNCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTEtaNCorr->SetName(name);
+    hTEtaNCorr->Divide(hTEtaNEff);
+    
+    hTEtaNMixCorr=(TH1F*)hTEtaNMixRaw->Clone();
+    sprintf(name,"hTEtaNMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTEtaNMixCorr->SetName(name);
+    hTEtaNMixCorr->Divide(hTPhiMixEff);
+
+    hTEtaACorr=(TH1F*)hTEtaARaw->Clone();
+    sprintf(name,"hTEtaACorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTEtaACorr->SetName(name);
+    hTEtaACorr->Divide(hTEtaAEff);
+    
+    hTEtaAMixCorr=(TH1F*)hTEtaAMixRaw->Clone();
+    sprintf(name,"hTEtaAMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTEtaAMixCorr->SetName(name);
+    hTEtaAMixCorr->Divide(hTPhiMixEff);
+    
+    hTPhiEtaCorr=(TH2F*)hTPhiEtaRaw->Clone();
+    sprintf(name,"hTPhiEtaCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTPhiEtaCorr->SetName(name);
+    hTPhiEtaCorr->Divide(hTPhiEtaEff);
+    
+    hTPhiEtaMixCorr=(TH2F*)hTPhiEtaMixRaw->Clone();
+    sprintf(name,"hTPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTPhiEtaMixCorr->SetName(name);
+    hTPhiEtaMixCorr->Divide(hTPhiEtaMixEff);
+    
+    hTPhiCorrPt=(TH1F*)hTPhiRawPt->Clone();
+    sprintf(name,"hTPhiCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTPhiCorrPt->SetName(name);
+    hTPhiCorrPt->Divide(hTPhiEffPt);
+    
+    hTPhiMixCorrPt=(TH1F*)hTPhiMixRawPt->Clone();
+    sprintf(name,"hTPhiMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTPhiMixCorrPt->SetName(name);
+    hTPhiMixCorrPt->Divide(hTPhiMixEffPt);
+
+    hTEtaNCorrPt=(TH1F*)hTEtaNRawPt->Clone();
+    sprintf(name,"hTEtaNCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTEtaNCorrPt->SetName(name);
+    hTEtaNCorrPt->Divide(hTEtaNEffPt);
+    
+    hTEtaNMixCorrPt=(TH1F*)hTEtaNMixRawPt->Clone();
+    sprintf(name,"hTEtaNMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTEtaNMixCorrPt->SetName(name);
+    hTEtaNMixCorrPt->Divide(hTEtaNMixEffPt);
+
+    hTEtaACorrPt=(TH1F*)hTEtaARawPt->Clone();
+    sprintf(name,"hTEtaACorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTEtaACorrPt->SetName(name);
+    hTEtaACorrPt->Divide(hTEtaNEffPt);
+    
+    hTEtaAMixCorrPt=(TH1F*)hTEtaAMixRawPt->Clone();
+    sprintf(name,"hTEtaAMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTEtaAMixCorrPt->SetName(name);
+    hTEtaAMixCorrPt->Divide(hTEtaAMixEffPt);
+    
+    hTPhiEtaCorrPt=(TH2F*)hTPhiEtaRawPt->Clone();
+    sprintf(name,"hTPhiEtaCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTPhiEtaCorrPt->SetName(name);
+    hTPhiEtaCorrPt->Divide(hTPhiEtaEffPt);
+    
+    hTPhiEtaMixCorrPt=(TH2F*)hTPhiEtaMixRawPt->Clone();
+    sprintf(name,"hTPhiMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+    hTPhiEtaMixCorrPt->SetName(name);
+    hTPhiEtaMixCorrPt->Divide(hTPhiEtaMixEffPt);
+    //  cout << "hTPhiCorr " << hTPhiCorr->GetBinContent(1) << endl;
+    //GeoCorr(hTEtaNCorr,hTEtaNMixCorr,hTEtaNMixMC,hTEtaACorr,hTEtaAMixCorr,hTEtaAMixMC,hTPhiEtaCorr,hTPhiEtaMixCorr,hTPhiEtaMixMC);
+    //GeoCorr(hTEtaNCorrPt,hTEtaNMixCorrPt,hTEtaNMixMCPt,hTEtaACorrPt,hTEtaAMixCorrPt,hTEtaAMixMCPt,hTPhiEtaCorrPt,hTPhiEtaMixCorrPt,hTPhiEtaMixMCPt);
+    MixedCorrect(hTPhiCorr,hTPhiMixCorr,hTEtaNCorr,hTEtaNMixCorr,hTEtaACorr,hTEtaAMixCorr,hTPhiEtaCorr,hTPhiEtaMixCorr);
+  MixedCorrect(hTPhiCorrPt,hTPhiMixCorrPt,hTEtaNCorrPt,hTEtaNMixCorrPt,hTEtaACorrPt,hTEtaAMixCorrPt,hTPhiEtaCorrPt,hTPhiEtaMixCorrPt);
+    // cout << "hTPhiCorr " << hTPhiCorr->GetBinContent(1) << endl;
+  if(ZYAMCent>0)ZYA1(hTPhiCorr,hTPhiMixCorr,a,ZYAMCent,ZYAMWidth);
+  else ZYAM2D(hPhiEtaCorr,hPhiEtaMixCorr,a,72,10);
+    cout << "Normalization Factor: " << a[0] << endl;
+    hTPhiCorr2=(TH1F*)hTPhiCorr->Clone();
+    hTPhiCorr2->SetName("hTPhiCorr2");
+    sprintf(name,"Bg Sub. %s",hTPhiCorr2->GetTitle());
+    hTPhiCorr2->SetTitle(name);
+    
+    hTPhiMixCorr2=(TH1F*)hTPhiMixCorr->Clone();
+    hTPhiMixCorr2->SetName("hTPhiMixCorr2");
+    sprintf(name,"Normalized %1.3f %s",a[0],hTPhiMixCorr2->GetTitle());
+    hTPhiMixCorr2->SetTitle(name);
+    hTPhiMixCorr2->SetMarkerStyle(25);
+    hTPhiMixCorr2->SetMarkerColor(4);
+    hTPhiMixCorr2->SetLineColor(4);
+    
+    hTPhiEtaCorr2=(TH2F*)hTPhiEtaCorr->Clone();
+    hTPhiEtaCorr2->SetName("hTPhiEtaCorr2");
+    sprintf(name,"BG Sub. %s",hTPhiEtaCorr2->GetTitle());
+    hTPhiEtaCorr2->SetTitle(name);
+    
+    hTPhiEtaMixCorr2=(TH2F*)hTPhiEtaMixCorr->Clone();
+    hTPhiEtaMixCorr2->SetName("hTPhiEtaMixCorr2");
+    sprintf(name,"Normalized %1.3f %s",a[0],hTPhiEtaMixCorr2->GetTitle());
+    hTPhiEtaMixCorr2->SetTitle(name);
+    
+    hTPhiCorrPt2=(TH1F*)hTPhiCorrPt->Clone();
+    hTPhiCorrPt2->SetName("hTPhiCorrPt2");
+    sprintf(name,"Bg Sub. %s",hTPhiCorrPt2->GetTitle());
+    hTPhiCorrPt2->SetTitle(name);
+    
+    hTPhiMixCorrPt2=(TH1F*)hTPhiMixCorrPt->Clone();
+    hTPhiMixCorrPt2->SetName("hTPhiMixCorrPt2");
+    sprintf(name,"Normalized %1.3f %s",a[0],hTPhiMixCorrPt2->GetTitle());
+    hTPhiMixCorrPt2->SetTitle(name);
+    hTPhiMixCorrPt2->SetMarkerStyle(25);
+    hTPhiMixCorrPt2->SetMarkerColor(4);
+    hTPhiMixCorrPt2->SetLineColor(4);
+    
+    hTPhiEtaCorrPt2=(TH2F*)hTPhiEtaCorrPt->Clone();
+    hTPhiEtaCorrPt2->SetName("hTPhiEtaCorrPt2");
+    sprintf(name,"BG Sub. %s",hTPhiEtaCorrPt2->GetTitle());
+    hTPhiEtaCorrPt2->SetTitle(name);
+    
+    hTPhiEtaMixCorrPt2=(TH2F*)hTPhiEtaMixCorrPt->Clone();
+    hTPhiEtaMixCorrPt2->SetName("hTPhiEtaMixCorrPt2");
+    sprintf(name,"Normalized %1.3f %s",a[0],hTPhiEtaMixCorrPt2->GetTitle());
+    hTPhiEtaMixCorrPt2->SetTitle(name);
+    hTPhiMixCorr2->Scale(a[0]);
+    hTPhiEtaMixCorr2->Scale(a[0]);
+    hTPhiCorr2->Add(hTPhiMixCorr2,-1);
+    Add2D(hTPhiEtaCorr2,hTPhiEtaMixCorr2,-1);  
+    hTPhiMixCorrPt2->Scale(a[0]);
+    hTPhiEtaMixCorrPt2->Scale(a[0]);
+    hTPhiCorrPt2->Add(hTPhiMixCorrPt2,-1);
+    Add2D(hTPhiEtaCorrPt2,hTPhiEtaMixCorrPt2,-1); 
+    if(Cent==Mult1){
+      hTPhiCorrSum=(TH1F*)hTPhiCorr->Clone();
+      hTPhiCorrSum->SetName("hTPhiCorrSum");
+      hTPhiCorr2Sum=(TH1F*)hTPhiCorr2->Clone();
+      hTPhiCorr2Sum->SetName("hTPhiCorr2Sum");
+      hTPhiMixCorrSum=(TH1F*)hTPhiMixCorr->Clone();
+      hTPhiMixCorrSum->SetName("hTPhiMixCorrSum");
+      hTPhiMixCorr2Sum=(TH1F*)hTPhiMixCorr2->Clone();
+      hTPhiMixCorr2Sum->SetName("hTPhiMixCorr2Sum");
+      hTPhiEtaCorrSum=(TH2F*)hTPhiEtaCorr->Clone();
+      hTPhiEtaCorrSum->SetName("hTPhiEtaCorrSum");
+      hTPhiEtaCorr2Sum=(TH2F*)hTPhiEtaCorr2->Clone();
+      hTPhiEtaCorr2Sum->SetName("hTPhiEtaCorr2Sum");
+      hTPhiEtaMixCorrSum=(TH2F*)hTPhiEtaMixCorr->Clone();
+      hTPhiEtaMixCorrSum->SetName("hTPhiEtaMixCorrSum");
+      hTPhiEtaMixCorr2Sum=(TH2F*)hTPhiEtaMixCorr2->Clone();
+      hTPhiEtaMixCorr2Sum->SetName("hTPhiEtaMixCorr2Sum");     
+      
+      hTPhiCorrPtSum=(TH1F*)hTPhiCorrPt->Clone();
+      hTPhiCorrPtSum->SetName("hTPhiCorrPtSum");
+      hTPhiCorrPt2Sum=(TH1F*)hTPhiCorrPt2->Clone();
+      hTPhiCorrPt2Sum->SetName("hTPhiCorrPt2Sum");
+      hTPhiMixCorrPtSum=(TH1F*)hTPhiMixCorrPt->Clone();
+      hTPhiMixCorrPtSum->SetName("hTPhiMixCorrPtSum");
+      hTPhiMixCorrPt2Sum=(TH1F*)hTPhiMixCorrPt2->Clone();
+      hTPhiMixCorrPt2Sum->SetName("hTPhiMixCorrPt2Sum");
+      hTPhiEtaCorrPtSum=(TH2F*)hTPhiEtaCorrPt->Clone();
+      hTPhiEtaCorrPtSum->SetName("hTPhiEtaCorrPtSum");
+      hTPhiEtaCorrPt2Sum=(TH2F*)hTPhiEtaCorrPt2->Clone();
+      hTPhiEtaCorrPt2Sum->SetName("hTPhiEtaCorrPt2Sum");
+      hTPhiEtaMixCorrPtSum=(TH2F*)hTPhiEtaMixCorrPt->Clone();
+      hTPhiEtaMixCorrPtSum->SetName("hTPhiEtaMixCorrPtSum");
+      hTPhiEtaMixCorrPt2Sum=(TH2F*)hTPhiEtaMixCorrPt2->Clone();
+      hTPhiEtaMixCorrPt2Sum->SetName("hTPhiEtaMixCorrPt2Sum");
+      TrigSum=MPt[2];
+      hTPhiCorrSum->Scale(TrigSum);
+      hTPhiCorr2Sum->Scale(TrigSum);
+      hTPhiMixCorrSum->Scale(TrigSum);
+      hTPhiMixCorr2Sum->Scale(TrigSum);
+      hTPhiEtaCorrSum->Scale(TrigSum);
+      hTPhiEtaCorr2Sum->Scale(TrigSum);
+      hTPhiEtaMixCorrSum->Scale(TrigSum);
+      hTPhiEtaMixCorr2Sum->Scale(TrigSum);
+      
+      hTPhiCorrPtSum->Scale(TrigSum);
+      hTPhiCorrPt2Sum->Scale(TrigSum);
+      hTPhiMixCorrPtSum->Scale(TrigSum);
+      hTPhiMixCorrPt2Sum->Scale(TrigSum);
+      hTPhiEtaCorrPtSum->Scale(TrigSum);
+      hTPhiEtaCorrPt2Sum->Scale(TrigSum);
+      hTPhiEtaMixCorrPtSum->Scale(TrigSum);
+      hTPhiEtaMixCorrPt2Sum->Scale(TrigSum);
+    }
+    else{     
+      hTPhiCorrSum->Add(hTPhiCorr,MPt[2]);
+      hTPhiCorr2Sum->Add(hTPhiCorr2,MPt[2]);
+      hTPhiMixCorrSum->Add(hTPhiMixCorr,MPt[2]);
+      hTPhiMixCorr2Sum->Add(hTPhiMixCorr2,MPt[2]);
+      hTPhiEtaCorrSum->Add(hTPhiEtaCorr,MPt[2]);
+      hTPhiEtaCorr2Sum->Add(hTPhiEtaCorr2,MPt[2]);
+      hTPhiEtaMixCorrSum->Add(hTPhiEtaMixCorr,MPt[2]);
+      hTPhiEtaMixCorr2Sum->Add(hTPhiEtaMixCorr2,MPt[2]);
+      
+      hTPhiCorrPtSum->Add(hTPhiCorr,MPt[2]);
+      hTPhiCorrPt2Sum->Add(hTPhiCorr2,MPt[2]);
+      hTPhiMixCorrPtSum->Add(hTPhiMixCorr,MPt[2]);
+      hTPhiMixCorrPt2Sum->Add(hTPhiMixCorr2,MPt[2]);
+      hTPhiEtaCorrPtSum->Add(hTPhiEtaCorr,MPt[2]);
+      hTPhiEtaCorrPt2Sum->Add(hTPhiEtaCorr2,MPt[2]);
+      hTPhiEtaMixCorrPtSum->Add(hTPhiEtaMixCorr,MPt[2]);
+      hTPhiEtaMixCorrPt2Sum->Add(hTPhiEtaMixCorr2,MPt[2]);
+      TrigSum+=MPt[2];
+    }
+  }
+  cout << "TrigSum Inclusives: " << TrigSum << endl;
+  //rescale to per trigger
+  hTPhiCorrSum->Scale(1./TrigSum);
+  hTPhiCorr2Sum->Scale(1./TrigSum);
+  hTPhiMixCorrSum->Scale(1./TrigSum);
+  hTPhiMixCorr2Sum->Scale(1./TrigSum);
+  hTPhiEtaCorrSum->Scale(1./TrigSum);
+  hTPhiEtaCorr2Sum->Scale(1./TrigSum);
+  hTPhiEtaMixCorrSum->Scale(1./TrigSum);
+  hTPhiEtaMixCorr2Sum->Scale(1./TrigSum);
+  hTPhiCorrPtSum->Scale(1./TrigSum);
+  hTPhiCorrPt2Sum->Scale(1./TrigSum);
+  hTPhiMixCorrPtSum->Scale(1./TrigSum);
+  hTPhiMixCorrPt2Sum->Scale(1./TrigSum);
+  hTPhiEtaCorrPtSum->Scale(1./TrigSum);
+  hTPhiEtaCorrPt2Sum->Scale(1./TrigSum);
+  hTPhiEtaMixCorrPtSum->Scale(1./TrigSum);
+  hTPhiEtaMixCorrPt2Sum->Scale(1./TrigSum);
+
+  for(int MainLoop=0;MainLoop<nMainLoop;MainLoop++){
+  cout << "nMainLoop " << MainLoop << endl;
+    if(APtTPtMult==0){
+      APt1=APtBins[MainLoop];
+      APt2=APtBins[MainLoop+1];
+      MainArray[MainLoop]=(APt1+APt2)/2;
+      eMainArray[MainLoop]=(APt2-APt1)/2;
+      //cout << "APt1: " << APt1 << " APt2: " << APt2 << endl;
+    }
+    if(APtTPtMult==1){
+      TPt1=TPtBins[MainLoop];
+      TPt2=TPtBins[MainLoop+1];
+      MainArray[MainLoop]=(TPt1+TPt2)/2;
+      eMainArray[MainLoop]=(TPt2-TPt1)/2;
+      //cout << "TPt1: " << TPt1 << " TPt2: " << TPt2 << endl;
+    }
+    if(APtTPtMult==2){
+      Mult1=MultBins1[MainLoop];
+      Mult2=MultBins2[MainLoop];
+      MainArray[MainLoop]=(MultArray1[Mult1]+MultArray2[Mult2]-1)/2;
+      eMainArray[MainLoop]=(MultArray2[Mult2]-MultArray1[Mult1]-1)/2;          
+    }
+    for(int Cent=Mult1;Cent<=Mult2;Cent++){
+
+      MakeProjections(TPt1,TPt2,APt1,APt2,Cent,inList,hPhiRaw,hPhiMixRaw,hEtaNRaw,hEtaNMixRaw,hEtaARaw,hEtaAMixRaw,hPhiEtaRaw,hPhiEtaMixRaw,MPt,0,0,0,LSign);
+      MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiEff,hPhiMixEff,hEtaNEff,hEtaNMixEff,hEtaAEff,hEtaAMixEff,hPhiEtaEff,hPhiEtaMixEff,MPt2,0,0,0,LSign);
+      MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiMC,hPhiMixMC,hEtaNMC,hEtaNMixMC,hEtaAMC,hEtaAMixMC,hPhiEtaMC,hPhiEtaMixMC,MPt2,0,1,0,LSign);
+      
+      MakeProjections(TPt1,TPt2,APt1,APt2,Cent,inList,hPhiRawPt,hPhiMixRawPt,hEtaNRawPt,hEtaNMixRawPt,hEtaARawPt,hEtaAMixRawPt,hPhiEtaRawPt,hPhiEtaMixRawPt,MPt,1,0,0,LSign);
+      MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiEffPt,hPhiMixEffPt,hEtaNEffPt,hEtaNMixEffPt,hEtaAEffPt,hEtaAMixEffPt,hPhiEtaEffPt,hPhiEtaMixEffPt,MPt2,1,0,0,LSign);
+      MakeProjections(TPt1,TPt2,APt1,APt2,Cent,effList,hPhiMCPt,hPhiMixMCPt,hEtaNMCPt,hEtaNMixMCPt,hEtaAMCPt,hEtaAMixMCPt,hPhiEtaMCPt,hPhiEtaMixMCPt,MPt2,1,1,0,LSign);
+      /*
+      EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hPhiRaw,hPhiEff,hPhiMC,hPhiMixRaw,hPhiMixEff,hPhiMixMC,hEtaNRaw,hEtaNEff,hEtaNMC,hEtaNMixRaw,hEtaNMixEff,hEtaNMixMC,hEtaARaw,hEtaAEff,hEtaAMC,hEtaAMixRaw,hEtaAMixEff,hEtaAMixMC,hPhiEtaRaw,hPhiEtaEff,hPhiEtaMC,hPhiEtaMixRaw,hPhiEtaMixEff,hPhiEtaMixMC,EffMethod);
+      EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hPhiRawPt,hPhiEffPt,hPhiMCPt,hPhiMixRawPt,hPhiMixEffPt,hPhiMixMCPt,hEtaNRawPt,hEtaNEffPt,hEtaNMCPt,hEtaNMixRawPt,hEtaNMixEffPt,hEtaNMixMCPt,hEtaARawPt,hEtaAEffPt,hEtaAMCPt,hEtaAMixRawPt,hEtaAMixEffPt,hEtaAMixMCPt,hPhiEtaRawPt,hPhiEtaEffPt,hPhiEtaMCPt,hPhiEtaMixRawPt,hPhiEtaMixEffPt,hPhiEtaMixMCPt,EffMethod);
+      */
+       if(EffMethod<4){
+      EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hPhiEff,hPhiMC,hPhiMixEff,hPhiMixMC,hEtaNEff,hEtaNMC,hEtaNMixEff,hEtaNMixMC,hEtaAEff,hEtaAMC,hEtaAMixEff,hEtaAMixMC,hPhiEtaEff,hPhiEtaMC,hPhiEtaMixEff,hPhiEtaMixMC,EffMethod);
+   EffCorr2(TPt1,TPt2,APt1,APt2,Cent,hPhiEffPt,hPhiMCPt,hPhiMixEffPt,hPhiMixMCPt,hEtaNEffPt,hEtaNMCPt,hEtaNMixEffPt,hEtaNMixMCPt,hEtaAEffPt,hEtaAMCPt,hEtaAMixEffPt,hEtaAMixMCPt,hPhiEtaEffPt,hPhiEtaMCPt,hPhiEtaMixEffPt,hPhiEtaMixMCPt,EffMethod);
+    }
+    else{
+      EffFit(APt1,APt2,Cent,effList,hPhiEff,hPhiMixEff,hEtaNEff,hEtaNMixEff,hEtaAEff,hEtaAMixEff,hPhiEtaEff,hPhiEtaMixEff,LSign,VariablePtLimit);
+EffFit(APt1,APt2,Cent,effList,hPhiEffPt,hPhiMixEffPt,hEtaNEffPT,hEtaNMixEffPt,hEtaAEffPt,hEtaAMixEffPt,hPhiEtaEffPt,hPhiEtaMixEffPt,LSign,VariablePtLimit);
+    }
+
+      hPhiCorr=(TH1F*)hPhiRaw->Clone();
+      sprintf(name,"hPhiCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hPhiCorr->SetName(name);
+      hPhiCorr->Divide(hPhiEff);
+    
+      hPhiMixCorr=(TH1F*)hPhiMixRaw->Clone();
+      sprintf(name,"hPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hPhiMixCorr->SetName(name);
+      hPhiMixCorr->Divide(hPhiMixEff);
+
+      hEtaNCorr=(TH1F*)hEtaNRaw->Clone();
+      sprintf(name,"hEtaNCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hEtaNCorr->SetName(name);
+      hEtaNCorr->Divide(hEtaNEff);
+    
+      hEtaNMixCorr=(TH1F*)hEtaNMixRaw->Clone();
+      sprintf(name,"hEtaNMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hEtaNMixCorr->SetName(name);
+      hEtaNMixCorr->Divide(hEtaNMixEff);
+
+      hEtaACorr=(TH1F*)hEtaARaw->Clone();
+      sprintf(name,"hEtaACorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hEtaACorr->SetName(name);
+      hEtaACorr->Divide(hEtaAEff);
+    
+      hEtaAMixCorr=(TH1F*)hEtaAMixRaw->Clone();
+      sprintf(name,"hEtaAMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hEtaAMixCorr->SetName(name);
+      hEtaAMixCorr->Divide(hEtaAMixEff);
+      
+      hPhiEtaCorr=(TH2F*)hPhiEtaRaw->Clone();
+      sprintf(name,"hPhiEtaCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hPhiEtaCorr->SetName(name);
+      hPhiEtaCorr->Divide(hPhiEtaEff);
+      
+      hPhiEtaMixCorr=(TH2F*)hPhiEtaMixRaw->Clone();
+      sprintf(name,"hPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hPhiEtaMixCorr->SetName(name);
+      hPhiEtaMixCorr->Divide(hPhiEtaMixEff);
+      
+      hPhiCorrPt=(TH1F*)hPhiRawPt->Clone();
+      sprintf(name,"hPhiCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hPhiCorrPt->SetName(name);
+      hPhiCorrPt->Divide(hPhiEffPt);
+      
+      hPhiMixCorrPt=(TH1F*)hPhiMixRawPt->Clone();
+      sprintf(name,"hPhiMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hPhiMixCorrPt->SetName(name);
+      hPhiMixCorrPt->Divide(hPhiMixEffPt);
+
+      hEtaNCorrPt=(TH1F*)hEtaNRawPt->Clone();
+      sprintf(name,"hEtaNCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hEtaNCorrPt->SetName(name);
+      hEtaNCorrPt->Divide(hEtaNEffPt);
+      
+      hEtaNMixCorrPt=(TH1F*)hEtaNMixRawPt->Clone();
+      sprintf(name,"hEtaNMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hEtaNMixCorrPt->SetName(name);
+      hEtaNMixCorrPt->Divide(hEtaNMixEffPt);
+
+      hEtaACorrPt=(TH1F*)hEtaARawPt->Clone();
+      sprintf(name,"hEtaACorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hEtaACorrPt->SetName(name);
+      hEtaACorrPt->Divide(hEtaAEffPt);
+      
+      hEtaAMixCorrPt=(TH1F*)hEtaAMixRawPt->Clone();
+      sprintf(name,"hEtaAMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hEtaAMixCorrPt->SetName(name);
+      hEtaAMixCorrPt->Divide(hEtaAMixEffPt);
+      
+      hPhiEtaCorrPt=(TH2F*)hPhiEtaRawPt->Clone();
+      sprintf(name,"hPhiEtaCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hPhiEtaCorrPt->SetName(name);
+      hPhiEtaCorrPt->Divide(hPhiEtaEffPt);
+      
+      hPhiEtaMixCorrPt=(TH2F*)hPhiEtaMixRawPt->Clone();
+      sprintf(name,"hPhiMixCorrPt_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",TPt1,TPt2,APt1,APt2,Cent);
+      hPhiEtaMixCorrPt->SetName(name);
+      hPhiEtaMixCorrPt->Divide(hPhiEtaMixEffPt);
+   
+      //   GeoCorr(hEtaNCorr,hEtaNMixCorr,hEtaNMixMC,hEtaACorr,hEtaAMixCorr,hEtaAMixMC,hPhiEtaCorr,hPhiEtaMixCorr,hPhiEtaMixMC);
+      // GeoCorr(hEtaNCorrPt,hEtaNMixCorrPt,hEtaNMixMCPt,hEtaACorrPt,hEtaAMixCorrPt,hEtaAMixMCPt,hPhiEtaCorrPt,hPhiEtaMixCorrPt,hPhiEtaMixMCPt);
+      MixedCorrect(hPhiCorr,hPhiMixCorr,hEtaNCorr,hEtaNMixCorr,hEtaACorr,hEtaAMixCorr,hPhiEtaCorr,hPhiEtaMixCorr);
+      MixedCorrect(hPhiCorrPt,hPhiMixCorrPt,hEtaNCorrPt,hEtaNMixCorrPt,hEtaACorrPt,hEtaAMixCorrPt,hPhiEtaCorrPt,hPhiEtaMixCorrPt);
+      if(ZYAMCent>0)ZYA1(hPhiCorr,hPhiMixCorr,a,ZYAMCent,ZYAMWidth);
+      else ZYAM2D(hPhiEtaCorr,hPhiEtaMixCorr,a,72,10);
+   
+
+      hPhiCorr2=(TH1F*)hPhiCorr->Clone();
+      hPhiCorr2->SetName("hPhiCorr2");
+      sprintf(name,"Bg Sub. %s",hPhiCorr2->GetTitle());
+      hPhiCorr2->SetTitle(name);
+      
+      hPhiMixCorr2=(TH1F*)hPhiMixCorr->Clone();
+      hPhiMixCorr2->SetName("hPhiMixCorr2");
+      sprintf(name,"Normalized %1.3f %s",a[0],hPhiMixCorr2->GetTitle());
+      hPhiMixCorr2->SetTitle(name);
+      hPhiMixCorr2->SetMarkerStyle(25);
+      hPhiMixCorr2->SetMarkerColor(4);
+      hPhiMixCorr2->SetLineColor(4);
+
+      hEtaNCorr2=(TH1F*)hEtaNCorr->Clone();
+      hEtaNCorr2->SetName("hEtaNCorr2");
+      sprintf(name,"Bg Sub. %s",hEtaNCorr2->GetTitle());
+      hEtaNCorr2->SetTitle(name);
+      
+      hEtaNMixCorr2=(TH1F*)hEtaNMixCorr->Clone();
+      hEtaNMixCorr2->SetName("hEtaNMixCorr2");
+      sprintf(name,"Normalized %1.3f %s",a[0],hEtaNMixCorr2->GetTitle());
+      hEtaNMixCorr2->SetTitle(name);
+      hEtaNMixCorr2->SetMarkerStyle(25);
+      hEtaNMixCorr2->SetMarkerColor(4);
+      hEtaNMixCorr2->SetLineColor(4);
+
+      hEtaACorr2=(TH1F*)hEtaACorr->Clone();
+      hEtaACorr2->SetName("hEtaACorr2");
+      sprintf(name,"Bg Sub. %s",hEtaACorr2->GetTitle());
+      hEtaACorr2->SetTitle(name);
+      
+      hEtaAMixCorr2=(TH1F*)hEtaAMixCorr->Clone();
+      hEtaAMixCorr2->SetName("hEtaAMixCorr2");
+      sprintf(name,"Normalized %1.3f %s",a[0],hEtaAMixCorr2->GetTitle());
+      hEtaAMixCorr2->SetTitle(name);
+      hEtaAMixCorr2->SetMarkerStyle(25);
+      hEtaAMixCorr2->SetMarkerColor(4);
+      hEtaAMixCorr2->SetLineColor(4);
+      
+      hPhiEtaCorr2=(TH2F*)hPhiEtaCorr->Clone();
+      hPhiEtaCorr2->SetName("hPhiEtaCorr2");
+      sprintf(name,"BG Sub. %s",hPhiEtaCorr2->GetTitle());
+      hPhiEtaCorr2->SetTitle(name);
+      
+      hPhiEtaMixCorr2=(TH2F*)hPhiEtaMixCorr->Clone();
+      hPhiEtaMixCorr2->SetName("hPhiEtaMixCorr2");
+      sprintf(name,"Normalized %1.3f %s",a[0],hPhiEtaMixCorr2->GetTitle());
+      hPhiEtaMixCorr2->SetTitle(name);
+      
+      hPhiCorrPt2=(TH1F*)hPhiCorrPt->Clone();
+      hPhiCorrPt2->SetName("hPhiCorrPt2");
+      sprintf(name,"Bg Sub. %s",hPhiCorrPt2->GetTitle());
+      hPhiCorrPt2->SetTitle(name);
+      
+      hPhiMixCorrPt2=(TH1F*)hPhiMixCorrPt->Clone();
+      hPhiMixCorrPt2->SetName("hPhiMixCorrPt2");
+      sprintf(name,"Normalized %1.3f %s",a[0],hPhiMixCorrPt2->GetTitle());
+      hPhiMixCorrPt2->SetTitle(name);
+      hPhiMixCorrPt2->SetMarkerStyle(25);
+      hPhiMixCorrPt2->SetMarkerColor(4);
+      hPhiMixCorrPt2->SetLineColor(4);
+
+      hEtaNCorrPt2=(TH1F*)hEtaNCorrPt->Clone();
+      hEtaNCorrPt2->SetName("hEtaNCorrPt2");
+      sprintf(name,"Bg Sub. %s",hEtaNCorrPt2->GetTitle());
+      hEtaNCorrPt2->SetTitle(name);
+      
+      hEtaNMixCorrPt2=(TH1F*)hEtaNMixCorrPt->Clone();
+      hEtaNMixCorrPt2->SetName("hEtaNMixCorrPt2");
+      sprintf(name,"Normalized %1.3f %s",a[0],hEtaNMixCorrPt2->GetTitle());
+      hEtaNMixCorrPt2->SetTitle(name);
+      hEtaNMixCorrPt2->SetMarkerStyle(25);
+      hEtaNMixCorrPt2->SetMarkerColor(4);
+      hEtaNMixCorrPt2->SetLineColor(4);
+
+      hEtaACorrPt2=(TH1F*)hEtaACorrPt->Clone();
+      hEtaACorrPt2->SetName("hEtaACorrPt2");
+      sprintf(name,"Bg Sub. %s",hEtaACorrPt2->GetTitle());
+      hEtaACorrPt2->SetTitle(name);
+      
+      hEtaAMixCorrPt2=(TH1F*)hEtaAMixCorrPt->Clone();
+      hEtaAMixCorrPt2->SetName("hEtaAMixCorrPt2");
+      sprintf(name,"Normalized %1.3f %s",a[0],hEtaAMixCorrPt2->GetTitle());
+      hEtaAMixCorrPt2->SetTitle(name);
+      hEtaAMixCorrPt2->SetMarkerStyle(25);
+      hEtaAMixCorrPt2->SetMarkerColor(4);
+      hEtaAMixCorrPt2->SetLineColor(4);
+      
+      hPhiEtaCorrPt2=(TH2F*)hPhiEtaCorrPt->Clone();
+      hPhiEtaCorrPt2->SetName("hPhiEtaCorrPt2");
+      sprintf(name,"BG Sub. %s",hPhiEtaCorrPt2->GetTitle());
+      hPhiEtaCorrPt2->SetTitle(name);
+      
+      hPhiEtaMixCorrPt2=(TH2F*)hPhiEtaMixCorrPt->Clone();
+      hPhiEtaMixCorrPt2->SetName("hPhiEtaMixCorrPt2");
+      sprintf(name,"Normalized %1.3f %s",a[0],hPhiEtaMixCorrPt2->GetTitle());
+      hPhiEtaMixCorrPt2->SetTitle(name);
+      
+      hPhiMixCorr2->Scale(a[0]);
+      hEtaNMixCorr2->Scale(a[0]);
+      hEtaAMixCorr2->Scale(a[0]);
+      hPhiEtaMixCorr2->Scale(a[0]);
+      hPhiCorr2->Add(hPhiMixCorr2,-1);
+      hEtaNCorr2->Add(hEtaNMixCorr2,-1);
+      hEtaACorr2->Add(hEtaAMixCorr2,-1);
+      Add2D(hPhiEtaCorr2,hPhiEtaMixCorr2,-1);  
+      hPhiMixCorrPt2->Scale(a[0]);
+      hPhiEtaMixCorrPt2->Scale(a[0]);
+      hEtaNMixCorrPt2->Scale(a[0]);
+      hEtaAMixCorrPt2->Scale(a[0]);
+      hPhiCorrPt2->Add(hPhiMixCorrPt2,-1);
+      hEtaNCorrPt2->Add(hEtaNMixCorrPt2,-1);
+      hEtaACorrPt2->Add(hEtaAMixCorrPt2,-1);
+      Add2D(hPhiEtaCorrPt2,hPhiEtaMixCorrPt2,-1);      
+      
+      //Now we need to add up centrality bins
+      if(Cent==Mult1){
+       hPhiCorrSum=(TH1F*)hPhiCorr->Clone();
+       hPhiCorrSum->SetName("hPhiCorrSum");
+       hPhiCorr2Sum=(TH1F*)hPhiCorr2->Clone();
+       hPhiCorr2Sum->SetName("hPhiCorr2Sum");
+       hPhiMixCorrSum=(TH1F*)hPhiMixCorr->Clone();
+       hPhiMixCorrSum->SetName("hPhiMixCorrSum");
+       hPhiMixCorr2Sum=(TH1F*)hPhiMixCorr2->Clone();
+       hPhiMixCorr2Sum->SetName("hPhiMixCorr2Sum");
+       
+       hEtaNCorrSum=(TH1F*)hEtaNCorr->Clone();
+       hEtaNCorrSum->SetName("hEtaNCorrSum");
+       hEtaNCorr2Sum=(TH1F*)hEtaNCorr2->Clone();
+       hEtaNCorr2Sum->SetName("hEtaNCorr2Sum");
+       hEtaNMixCorrSum=(TH1F*)hEtaNMixCorr->Clone();
+       hEtaNMixCorrSum->SetName("hEtaNMixCorrSum");
+       hEtaNMixCorr2Sum=(TH1F*)hEtaNMixCorr2->Clone();
+       hEtaNMixCorr2Sum->SetName("hEtaNMixCorr2Sum");
+       
+       hEtaACorrSum=(TH1F*)hEtaACorr->Clone();
+       hEtaACorrSum->SetName("hEtaACorrSum");
+       hEtaACorr2Sum=(TH1F*)hEtaACorr2->Clone();
+       hEtaACorr2Sum->SetName("hEtaACorr2Sum");
+       hEtaAMixCorrSum=(TH1F*)hEtaAMixCorr->Clone();
+       hEtaAMixCorrSum->SetName("hEtaAMixCorrSum");
+       hEtaAMixCorr2Sum=(TH1F*)hEtaAMixCorr2->Clone();
+       hEtaAMixCorr2Sum->SetName("hEtaAMixCorr2Sum");
+
+       hPhiEtaCorrSum=(TH2F*)hPhiEtaCorr->Clone();
+       hPhiEtaCorrSum->SetName("hPhiEtaCorrSum");
+       hPhiEtaCorr2Sum=(TH2F*)hPhiEtaCorr2->Clone();
+       hPhiEtaCorr2Sum->SetName("hPhiEtaCorr2Sum");
+       hPhiEtaMixCorrSum=(TH2F*)hPhiEtaMixCorr->Clone();
+       hPhiEtaMixCorrSum->SetName("hPhiEtaMixCorrSum");
+       hPhiEtaMixCorr2Sum=(TH2F*)hPhiEtaMixCorr2->Clone();
+       hPhiEtaMixCorr2Sum->SetName("hPhiEtaMixCorr2Sum");      
+       
+       hPhiCorrPtSum=(TH1F*)hPhiCorrPt->Clone();
+       hPhiCorrPtSum->SetName("hPhiCorrPtSum");
+       hPhiCorrPt2Sum=(TH1F*)hPhiCorrPt2->Clone();
+       hPhiCorrPt2Sum->SetName("hPhiCorrPt2Sum");
+       hPhiMixCorrPtSum=(TH1F*)hPhiMixCorrPt->Clone();
+       hPhiMixCorrPtSum->SetName("hPhiMixCorrPtSum");
+       hPhiMixCorrPt2Sum=(TH1F*)hPhiMixCorrPt2->Clone();
+       hPhiMixCorrPt2Sum->SetName("hPhiMixCorrPt2Sum");
+
+       hEtaNCorrPtSum=(TH1F*)hEtaNCorrPt->Clone();
+       hEtaNCorrPtSum->SetName("hEtaNCorrPtSum");
+       hEtaNCorrPt2Sum=(TH1F*)hEtaNCorrPt2->Clone();
+       hEtaNCorrPt2Sum->SetName("hEtaNCorrPt2Sum");
+       hEtaNMixCorrPtSum=(TH1F*)hEtaNMixCorrPt->Clone();
+       hEtaNMixCorrPtSum->SetName("hEtaNMixCorrPtSum");
+       hEtaNMixCorrPt2Sum=(TH1F*)hEtaNMixCorrPt2->Clone();
+       hEtaNMixCorrPt2Sum->SetName("hEtaNMixCorrPt2Sum");
+
+       hEtaACorrPtSum=(TH1F*)hEtaACorrPt->Clone();
+       hEtaACorrPtSum->SetName("hEtaACorrPtSum");
+       hEtaACorrPt2Sum=(TH1F*)hEtaACorrPt2->Clone();
+       hEtaACorrPt2Sum->SetName("hEtaACorrPt2Sum");
+       hEtaAMixCorrPtSum=(TH1F*)hEtaAMixCorrPt->Clone();
+       hEtaAMixCorrPtSum->SetName("hEtaAMixCorrPtSum");
+       hEtaAMixCorrPt2Sum=(TH1F*)hEtaAMixCorrPt2->Clone();
+       hEtaAMixCorrPt2Sum->SetName("hEtaAMixCorrPt2Sum");
+
+       hPhiEtaCorrPtSum=(TH2F*)hPhiEtaCorrPt->Clone();
+       hPhiEtaCorrPtSum->SetName("hPhiEtaCorrPtSum");
+       hPhiEtaCorrPt2Sum=(TH2F*)hPhiEtaCorrPt2->Clone();
+       hPhiEtaCorrPt2Sum->SetName("hPhiEtaCorrPt2Sum");
+       hPhiEtaMixCorrPtSum=(TH2F*)hPhiEtaMixCorrPt->Clone();
+       hPhiEtaMixCorrPtSum->SetName("hPhiEtaMixCorrPtSum");
+       hPhiEtaMixCorrPt2Sum=(TH2F*)hPhiEtaMixCorrPt2->Clone();
+       hPhiEtaMixCorrPt2Sum->SetName("hPhiEtaMixCorrPt2Sum");  
+       
+       TrigSum=MPt[2];
+       
+       hPhiCorrSum->Scale(TrigSum);
+       hPhiCorr2Sum->Scale(TrigSum);
+       hPhiMixCorrSum->Scale(TrigSum);
+       hPhiMixCorr2Sum->Scale(TrigSum);
+       hEtaNCorrSum->Scale(TrigSum);
+       hEtaNCorr2Sum->Scale(TrigSum);
+       hEtaNMixCorrSum->Scale(TrigSum);
+       hEtaNMixCorr2Sum->Scale(TrigSum);
+       hEtaACorrSum->Scale(TrigSum);
+       hEtaACorr2Sum->Scale(TrigSum);
+       hEtaAMixCorrSum->Scale(TrigSum);
+       hEtaAMixCorr2Sum->Scale(TrigSum);
+       hPhiEtaCorrSum->Scale(TrigSum);
+       hPhiEtaCorr2Sum->Scale(TrigSum);
+       hPhiEtaMixCorrSum->Scale(TrigSum);
+       hPhiEtaMixCorr2Sum->Scale(TrigSum);
+       
+       hPhiCorrPtSum->Scale(TrigSum);
+       hPhiCorrPt2Sum->Scale(TrigSum);
+       hPhiMixCorrPtSum->Scale(TrigSum);
+       hPhiMixCorrPt2Sum->Scale(TrigSum);
+       hEtaNCorrPtSum->Scale(TrigSum);
+       hEtaNCorrPt2Sum->Scale(TrigSum);
+       hEtaNMixCorrPtSum->Scale(TrigSum);
+       hEtaNMixCorrPt2Sum->Scale(TrigSum);
+       hEtaACorrPtSum->Scale(TrigSum);
+       hEtaACorrPt2Sum->Scale(TrigSum);
+       hEtaAMixCorrSum->Scale(TrigSum);
+       hEtaAMixCorr2Sum->Scale(TrigSum);
+       hPhiEtaCorrPtSum->Scale(TrigSum);
+       hPhiEtaCorrPt2Sum->Scale(TrigSum);
+       hPhiEtaMixCorrPtSum->Scale(TrigSum);
+       hPhiEtaMixCorrPt2Sum->Scale(TrigSum);
+      }
+      else{//I need to do trigger weighted averaging here so I need the trigger counts
+       hPhiCorrSum->Add(hPhiCorr,MPt[2]);
+       hPhiCorr2Sum->Add(hPhiCorr2,MPt[2]);
+       hPhiMixCorrSum->Add(hPhiMixCorr,MPt[2]);
+       hPhiMixCorr2Sum->Add(hPhiMixCorr2,MPt[2]);
+       hEtaNCorrSum->Add(hEtaNCorr,MPt[2]);
+       hEtaNCorr2Sum->Add(hEtaNCorr2,MPt[2]);
+       hEtaNMixCorrSum->Add(hEtaNMixCorr,MPt[2]);
+       hEtaNMixCorr2Sum->Add(hEtaNMixCorr2,MPt[2]);
+       hEtaACorrSum->Add(hEtaACorr,MPt[2]);
+       hEtaACorr2Sum->Add(hEtaNCorr2,MPt[2]);
+       hEtaAMixCorrSum->Add(hEtaAMixCorr,MPt[2]);
+       hEtaAMixCorr2Sum->Add(hEtaAMixCorr2,MPt[2]);
+       hPhiEtaCorrSum->Add(hPhiEtaCorr,MPt[2]);
+       hPhiEtaCorr2Sum->Add(hPhiEtaCorr2,MPt[2]);
+       hPhiEtaMixCorrSum->Add(hPhiEtaMixCorr,MPt[2]);
+       hPhiEtaMixCorr2Sum->Add(hPhiEtaMixCorr2,MPt[2]);
+       
+       hPhiCorrPtSum->Add(hPhiCorr,MPt[2]);
+       hPhiCorrPt2Sum->Add(hPhiCorr2,MPt[2]);
+       hPhiMixCorrPtSum->Add(hPhiMixCorr,MPt[2]);
+       hPhiMixCorrPt2Sum->Add(hPhiMixCorr2,MPt[2]);
+       hEtaNCorrPtSum->Add(hEtaNCorrPt,MPt[2]);
+       hEtaNCorrPt2Sum->Add(hEtaNCorrPt2,MPt[2]);
+       hEtaNMixCorrPtSum->Add(hEtaNMixCorrPt,MPt[2]);
+       hEtaNMixCorrPt2Sum->Add(hEtaNMixCorrPt2,MPt[2]);
+       hEtaACorrPtSum->Add(hEtaACorrPt,MPt[2]);
+       hEtaACorrPt2Sum->Add(hEtaNCorrPt2,MPt[2]);
+       hEtaAMixCorrPtSum->Add(hEtaAMixCorrPt,MPt[2]);
+       hEtaAMixCorrPt2Sum->Add(hEtaAMixCorrPt2,MPt[2]);
+       hPhiEtaCorrPtSum->Add(hPhiEtaCorr,MPt[2]);
+       hPhiEtaCorrPt2Sum->Add(hPhiEtaCorr2,MPt[2]);
+       hPhiEtaMixCorrPtSum->Add(hPhiEtaMixCorr,MPt[2]);
+       hPhiEtaMixCorrPt2Sum->Add(hPhiEtaMixCorr2,MPt[2]);
+       TrigSum+=MPt[2];
+      }
+    }
+    //rescale to per trigger
+    // cout << "TrigSum " << TrigSum << endl;
+    hPhiCorrSum->Scale(1./TrigSum);
+    hPhiCorr2Sum->Scale(1./TrigSum);
+    hPhiMixCorrSum->Scale(1./TrigSum);
+    hPhiMixCorr2Sum->Scale(1./TrigSum);
+    hEtaNCorrSum->Scale(1./TrigSum);
+    hEtaNCorr2Sum->Scale(1./TrigSum);
+    hEtaNMixCorrSum->Scale(1./TrigSum);
+    hEtaNMixCorr2Sum->Scale(1./TrigSum);
+    hEtaACorrSum->Scale(1./TrigSum);
+    hEtaACorr2Sum->Scale(1./TrigSum);
+    hEtaAMixCorrSum->Scale(1./TrigSum);
+    hEtaAMixCorr2Sum->Scale(1./TrigSum);
+    hPhiEtaCorrSum->Scale(1./TrigSum);
+    hPhiEtaCorr2Sum->Scale(1./TrigSum);
+    hPhiEtaMixCorrSum->Scale(1./TrigSum);
+    hPhiEtaMixCorr2Sum->Scale(1./TrigSum);
+    
+    hPhiCorrPtSum->Scale(1./TrigSum);
+    hPhiCorrPt2Sum->Scale(1./TrigSum);
+    hPhiMixCorrPtSum->Scale(1./TrigSum);
+    hPhiMixCorrPt2Sum->Scale(1./TrigSum);
+    hEtaNCorrPtSum->Scale(1./TrigSum);
+    hEtaNCorrPt2Sum->Scale(1./TrigSum);
+    hEtaNMixCorrPtSum->Scale(1./TrigSum);
+    hEtaNMixCorrPt2Sum->Scale(1./TrigSum);
+    hEtaACorrPtSum->Scale(1./TrigSum);
+    hEtaACorrPt2Sum->Scale(1./TrigSum);
+    hEtaAMixCorrPtSum->Scale(1./TrigSum);
+    hEtaAMixCorrPt2Sum->Scale(1./TrigSum);
+    hPhiEtaCorrPtSum->Scale(1./TrigSum);
+    hPhiEtaCorrPt2Sum->Scale(1./TrigSum);
+    hPhiEtaMixCorrPtSum->Scale(1./TrigSum);
+    hPhiEtaMixCorrPt2Sum->Scale(1./TrigSum);
+    
+    //  for(int xs=0;xs<nx;xs++){xarray[xs][MainLoop]=0;}
+    for(int yields=0;yields<nyields;yields++){  
+      NYieldPhi[yields][MainLoop]=0;
+      NYieldPhiZYAM[yields][MainLoop]=0;
+      NYieldPhiFit[yields][MainLoop]=0;
+      NYieldEta[yields][MainLoop]=0;
+      NYieldEtaZYAM[yields][MainLoop]=0;
+      NYieldEtaFit[yields][MainLoop]=0;
+      NYieldPhiEta1[yields][MainLoop]=0;
+      NYieldPhiEta2[yields][MainLoop]=0;
+      NYieldPhiEta1ZYAM[yields][MainLoop]=0;
+      NYieldPhiEta2ZYAM[yields][MainLoop]=0;
+      NRMSPhi[yields][MainLoop]=0;
+      NWidthPhi[yields][MainLoop]=0;
+      AYieldPhi[yields][MainLoop]=0;
+      AYieldPhiZYAM[yields][MainLoop]=0;
+      AYieldPhiFit[yields][MainLoop]=0;
+      AYieldEta[yields][MainLoop]=0;
+      AYieldEtaZYAM[yields][MainLoop]=0;
+      AYieldEtaFit[yields][MainLoop]=0;
+      AYieldPhiEta[yields][MainLoop]=0;
+      AYieldPhiEtaZYAM[yields][MainLoop]=0;
+      MYieldPhi[yields][MainLoop]=0;
+      MYieldPhi[yields][MainLoop]=0;
+      MAvePhiEta[yields][MainLoop]=0;
+      NAvePhi[yields][MainLoop]=0;
+      NAvePhiZYAM[yields][MainLoop]=0;
+      NAvePhiFit[yields][MainLoop]=0;
+      NAveEta[yields][MainLoop]=0;
+      NAveEtaZYAM[yields][MainLoop]=0;
+      NAveEtaFit[yields][MainLoop]=0;
+      NAvePhiEta1[yields][MainLoop]=0;
+      NAvePhiEta2[yields][MainLoop]=0;
+      NAvePhiEta1ZYAM[yields][MainLoop]=0;
+      NAvePhiEta2ZYAM[yields][MainLoop]=0;
+      AAvePhi[yields][MainLoop]=0;
+      AAvePhiZYAM[yields][MainLoop]=0;
+      AAvePhiFit[yields][MainLoop]=0;
+      AAveEta[yields][MainLoop]=0;
+      AAveEtaZYAM[yields][MainLoop]=0;
+      AAveEtaFit[yields][MainLoop]=0;
+      AAvePhiEta[yields][MainLoop]=0;
+      AAvePhiEtaZYAM[yields][MainLoop]=0;
+      MAvePhi[yields][MainLoop]=0;
+      MAvePhiFit[yields][MainLoop]=0;
+      MAvePhiEta[yields][MainLoop]=0;
+      
+      TNYieldPhi[yields][MainLoop]=0;
+      TNYieldPhiZYAM[yields][MainLoop]=0;
+      TNYieldPhiFit[yields][MainLoop]=0;
+      TNYieldPhiEta1[yields][MainLoop]=0;
+      TNYieldPhiEta2[yields][MainLoop]=0;
+      TNYieldPhiEta3[yields][MainLoop]=0;
+      TAYieldPhi[yields][MainLoop]=0;
+      TAYieldPhiZYAM[yields][MainLoop]=0;
+      TAYieldPhiFit[yields][MainLoop]=0;
+      TAYieldPhiEta[yields][MainLoop]=0;
+      TAYieldPhiEtaZYAM[yields][MainLoop]=0;
+    }
+    //lets do the dphi histo yeilds
+    //Get our yields for the $\Delta\phi$ Histograms (from bin counting)
+    float nbinsPhiEtaPhi=hPhiEtaCorr->GetNbinsX();
+    float nbinsPhiEtaEta=hPhiEtaCorr->GetNbinsY();
+    binwx=hPhiCorr->GetBinWidth(1);
+    NearBinsPhi=0;
+    AwayBinsPhi=0;
+    MinBinsPhi=0;
+    NearBinsPhiEta1=0;
+    NearBinsPhiEta2=0;
+    AwayBinsPhiEta=0;
+    MinBinsPhiEta=0;
+    
+    //Bins with 0 content have messed up error bars and screw up the fits
+    for(int xx=1;xx<=hPhiCorrSum->GetNbinsX();xx++){
+      if(hPhiCorrSum->GetBinContent(xx)==0)hPhiCorrSum->SetBinError(xx,1./hPhiCorrSum->GetBinWidth(xx)/TrigSum);
+      if(hPhiCorrPtSum->GetBinContent(xx)==0)hPhiCorrSum->SetBinError(xx,1./pow(hPhiCorrPtSum->GetBinWidth(xx),2)/TrigSum);
+    }
+ for(int xx=1;xx<=hEtaNCorrSum->GetNbinsX();xx++){
+   if(hEtaNCorrSum->GetBinContent(xx)==0){
+     float acp=1-fabs(hEtaNCorr->GetBinCenter(xx))/1.8;
+     hEtaNCorrSum->SetBinError(xx,1./hEtaNCorrSum->GetBinWidth(xx)/TrigSum/acp);
+     // cout << "Error Eta" << hEtaNCorrSum->GetBinContent(xx) << " " << hEtaNCorrSum->GetBinError(xx) << endl;
+   }
+   if(hEtaNCorrPtSum->GetBinContent(xx)==0)hEtaNCorrPtSum->SetBinError(xx,1./hEtaNCorrPtSum->GetBinWidth(xx)/TrigSum/acp);
+    }
+    
+    //0 yield, 1 eyield, 2 pt yield, 3 ept yield, 4 pt/pt_trig yield, 5 ezt yield, 6 pt/pt_near yield, 7 ezt2 yield
+    trms1=0;trms2=0;trms3=0;
+    char outName[200];
+    cfit1=new TCanvas("cfit1","",800,600);
+    //Fit The Histograms
+    fit1->SetParameters(1,0.2,1,0.4,0.5);
+    hPhiCorrSum->Fit("fit1");
+    NYieldPhiFit[0][MainLoop]=fit1->GetParameter(0);
+    NYieldPhiFit[1][MainLoop]=fit1->GetParError(0);
+    NWidthPhi[0][MainLoop]=fit1->GetParameter(1);
+    NWidthPhi[1][MainLoop]=fit1->GetParError(1);
+    AYieldPhiFit[0][MainLoop]=fit1->GetParameter(2);
+    AYieldPhiFit[1][MainLoop]=fit1->GetParError(2);
+    AWidthPhi[0][MainLoop]=fit1->GetParameter(3);
+    AWidthPhi[1][MainLoop]=fit1->GetParError(3);
+    MYieldPhiFit[0][MainLoop]=fit1->GetParameter(4)*2*Pi;
+    MYieldPhiFit[1][MainLoop]=fit1->GetParError(4)*2*Pi;
+    sprintf(outName,"%s/DrawSpectra_FitPhiCorr%d_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_%d_%d%s",Folder,EffMethod,TPt1,TPt2,APt1,APt2,Mult1,Mult2,APtTPtMult,MainLoop,filetype);
+    if(SaveFits)cfit1->SaveAs(outName);
+
+    cfit2=new TCanvas("cfit2","",800,600);
+    //float par4=fit1->GetParameter(4)*1.5*4/(hEtaNCorrSum->GetNbinsX()*hEtaNCorrSum->GetBinWidth(1));//proper scaling (selfcorrects for different bin etc)
+    //  float par4=fit1->GetParameter(4)*hPhiCorrSum->GetBinWidth(1)/hEtaNCorrSum->GetBinWidth(1)*0.8/3.14159;
+    //float par4=fit1->GetParameter(4)*3/3.2;
+ float par4=fit1->GetParameter(4)*6.4/3;
+    fit2->SetParameter(2,par4);
+    // fit2->SetParLimits(2,par4,par4);
+    fit2->SetParameter(0,fit1->GetParameter(0));
+    fit2->SetParameter(1,fit1->GetParameter(1));
+    hEtaNCorrSum->Fit("fit2");
+    NYieldEtaFit[0][MainLoop]=fit2->GetParameter(0);
+    NYieldEtaFit[1][MainLoop]=fit2->GetParError(0);
+    NWidthEta[0][MainLoop]=fit2->GetParameter(1);
+    NWidthEta[1][MainLoop]=fit2->GetParError(1);
+    sprintf(outName,"%s/DrawSpectra_FitEtaCorr%d_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_%d_%d%s",Folder,EffMethod,TPt1,TPt2,APt1,APt2,Mult1,Mult2,APtTPtMult,MainLoop,filetype);
+    if(SaveFits)cfit2->SaveAs(outName);
+
+    hPhiCorrPtSum->Fit("fit1");
+    NYieldPhiFit[2][MainLoop]=fit1->GetParameter(0);
+    NYieldPhiFit[3][MainLoop]=fit1->GetParError(0);
+    NWidthPhi[2][MainLoop]=fit1->GetParameter(1);
+    NWidthPhi[3][MainLoop]=fit1->GetParError(1);
+    AYieldPhiFit[2][MainLoop]=fit1->GetParameter(2);
+    AYieldPhiFit[3][MainLoop]=fit1->GetParError(2);
+    AWidthPhi[2][MainLoop]=fit1->GetParameter(3);
+    AWidthPhi[3][MainLoop]=fit1->GetParError(3);
+    MYieldPhiFit[2][MainLoop]=fit1->GetParameter(4)*2*Pi;
+    MYieldPhiFit[3][MainLoop]=fit1->GetParError(4)*2*Pi;
+
+  
+    // par4=fit1->GetParameter(4)*hPhiCorrSum->GetBinWidth(1)/hEtaNCorrSum->GetBinWidth(1)*1.5/3.1415962;
+    //float par4=fit1->GetParameter(4)*1.5*2/1.8;
+    //float par4=fit1->GetParameter(4)*1.5*4/(hEtaNCorrPtSum->GetNbinsX()*hEtaNCorrPtSum->GetBinWidth(1));
+    //float par4=fit1->GetParameter(4)*hPhiCorrSum->GetBinWidth(1)/hEtaNCorrSum->GetBinWidth(1)*1.5/3.14159;
+    float par4=fit1->GetParameter(4)*6.4/3;
+    fit2->SetParameter(2,par4);
+    //fit2->SetParLimits(2,par4,par4);
+    fit2->SetParameter(0,fit1->GetParameter(0));
+    fit2->SetParameter(1,fit1->GetParameter(1));
+    //hEtaNCorrSum->Fit("fit2");
+    // fit2->SetParLimits(2,fit1->GetParameter(4),fit1->GetParameter(4));
+    hEtaNCorrPtSum->Fit("fit2");
+    NYieldEtaFit[2][MainLoop]=fit2->GetParameter(0);
+    NYieldEtaFit[3][MainLoop]=fit2->GetParError(0);
+    NWidthEta[2][MainLoop]=fit2->GetParameter(1);
+    NWidthEta[3][MainLoop]=fit2->GetParError(1);
+
+    //Not doing any away-side fits now but setting up non-zero values so no divide by zero later as code is inplace in case there are fits
+    AYieldEtaFit[0][MainLoop]=1;
+    AYieldEtaFit[1][MainLoop]=1;
+    AWidthEta[0][MainLoop]=1;
+    AWidthEta[1][MainLoop]=1;
+    AYieldEtaFit[2][MainLoop]=1;
+    AYieldEtaFit[3][MainLoop]=1;
+    AWidthEta[2][MainLoop]=1;
+    AWidthEta[3][MainLoop]=1;
+
+    //Average pT from fits
+    NAvePhiFit[0][MainLoop]=NYieldPhiFit[2][MainLoop]/NYieldPhiFit[0][MainLoop];
+    NAvePhiFit[1][MainLoop]=NAvePhiFit[0][MainLoop]*pow(pow(NYieldPhiFit[3][MainLoop]/NYieldPhiFit[2][MainLoop],2)+pow(NYieldPhiFit[1][MainLoop]/NYieldPhiFit[0][MainLoop],2),0.5);
+    AAvePhiFit[0][MainLoop]=AYieldPhiFit[2][MainLoop]/AYieldPhiFit[0][MainLoop];
+    AAvePhiFit[1][MainLoop]=AAvePhiFit[0][MainLoop]*pow(pow(AYieldPhiFit[3][MainLoop]/AYieldPhiFit[2][MainLoop],2)+pow(AYieldPhiFit[1][MainLoop]/AYieldPhiFit[0][MainLoop],2),0.5);
+    MAvePhiFit[0][MainLoop]=MYieldPhiFit[2][MainLoop]/MYieldPhiFit[0][MainLoop];
+    MAvePhiFit[1][MainLoop]=MAvePhiFit[0][MainLoop]*pow(pow(MYieldPhiFit[3][MainLoop]/MYieldPhiFit[2][MainLoop],2)+pow(MYieldPhiFit[1][MainLoop]/MYieldPhiFit[0][MainLoop],2),0.5);
+    NAveEtaFit[0][MainLoop]=NYieldEtaFit[2][MainLoop]/NYieldEtaFit[0][MainLoop];
+    NAveEtaFit[1][MainLoop]=NAveEtaFit[0][MainLoop]*pow(pow(NYieldEtaFit[3][MainLoop]/NYieldEtaFit[2][MainLoop],2)+pow(NYieldEtaFit[1][MainLoop]/NYieldEtaFit[0][MainLoop],2),0.5);
+
+    //Computer Jt from the fits
+    float meanptA=NYieldPhiFit[2][MainLoop]/NYieldPhiFit[0][MainLoop];
+    float EmeanptA=meanptA*sqrt(pow(NYieldPhiFit[3][MainLoop]/NYieldPhiFit[2][MainLoop],2)+pow(NYieldPhiFit[1][MainLoop]/NYieldPhiFit[0][MainLoop],2));
+    NJtPhi[0][MainLoop]=NWidthPhi[0][MainLoop]*meanptA*MPt[0]*pow(2/(meanptA*meanptA+MPt[0]*MPt[0]),0.5);
+    float temp1=pow(MPt[0]*MPt[0]+meanptA*meanptA,0.5);
+    float temp2=2*EmeanptA*meanptA+2*MPt[0]*MPt[1];
+    float temp3=0.5*temp2/temp1;
+    NJtPhi[1][MainLoop]=NJtPhi[0][MainLoop]*sqrt(pow(NWidthPhi[1][MainLoop]/NWidthPhi[0][MainLoop],2)+pow(EmeanptA/meanptA,2)+pow(MPt[1]/MPt[0],2)+temp3*temp3);
+
+    meanptA=NYieldEtaFit[2][MainLoop]/NYieldEtaFit[0][MainLoop];
+    EmeanptA=meanptA*sqrt(pow(NYieldEtaFit[3][MainLoop]/NYieldEtaFit[2][MainLoop],2)+pow(NYieldEtaFit[1][MainLoop]/NYieldEtaFit[0][MainLoop],2));
+    NJtEta[0][MainLoop]=NWidthEta[0][MainLoop]*meanptA*MPt[0]*pow(2/(meanptA*meanptA+MPt[0]*MPt[0]),0.5);
+    temp1=pow(MPt[0]*MPt[0]+meanptA*meanptA,0.5);
+    temp2=2*EmeanptA*meanptA+2*MPt[0]*MPt[1];
+    temp3=0.5*temp2/temp1;
+    NJtEta[1][MainLoop]=NJtEta[0][MainLoop]*sqrt(pow(NWidthEta[1][MainLoop]/NWidthEta[0][MainLoop],2)+pow(EmeanptA/meanptA,2)+pow(MPt[1]/MPt[0],2)+temp3*temp3);
+
+    //PhiLoop
+    for(int x1=0;x1<hPhiCorrSum->GetNbinsX();x1++){
+      centx=hPhiCorrSum->GetBinCenter(x1);
+      //Near-Side 1d
+      if(fabs(centx)<NearWidthPhi||fabs(centx-2*Pi)<NearWidthPhi||fabs(centx+2*Pi)<NearWidthPhi){
+       NYieldPhi[0][MainLoop]+=binwx*hPhiCorrSum->GetBinContent(x1);
+       NYieldPhi[1][MainLoop]+=pow(binwx*hPhiCorrSum->GetBinError(x1),2);
+       NYieldPhi[2][MainLoop]+=binwx*hPhiCorrPtSum->GetBinContent(x1);
+       NYieldPhi[3][MainLoop]+=pow(binwx*hPhiCorrPtSum->GetBinError(x1),2);
+       NYieldPhiZYAM[0][MainLoop]+=binwx*hPhiCorr2Sum->GetBinContent(x1);
+       NYieldPhiZYAM[1][MainLoop]+=pow(binwx*hPhiCorr2Sum->GetBinError(x1),2);
+       NYieldPhiZYAM[2][MainLoop]+=binwx*hPhiCorrPt2Sum->GetBinContent(x1);
+       NYieldPhiZYAM[3][MainLoop]+=pow(binwx*hPhiCorrPt2Sum->GetBinError(x1),2);
+       if(APtTPtMult==0){
+         TNYieldPhi[0][MainLoop]+=binwx*hTPhiCorrSum->GetBinContent(x1);
+         TNYieldPhi[1][MainLoop]+=pow(binwx*hTPhiCorrSum->GetBinError(x1),2);
+         TNYieldPhi[2][MainLoop]+=binwx*hTPhiCorrPtSum->GetBinContent(x1);
+         TNYieldPhi[3][MainLoop]+=pow(binwx*hTPhiCorrPtSum->GetBinError(x1),2);
+         TNYieldPhiZYAM[0][MainLoop]+=binwx*hTPhiCorr2Sum->GetBinContent(x1);
+         TNYieldPhiZYAM[1][MainLoop]+=pow(binwx*hTPhiCorr2Sum->GetBinError(x1),2);
+         TNYieldPhiZYAM[2][MainLoop]+=binwx*hTPhiCorrPt2Sum->GetBinContent(x1);
+         TNYieldPhiZYAM[3][MainLoop]+=pow(binwx*hTPhiCorrPt2Sum->GetBinError(x1),2);
+       }
+       NRMSPhi[0][MainLoop]+=pow(binwx*centx*hPhiCorr2Sum->GetBinContent(x1),2);
+       NRMSPhi[1][MainLoop]+=pow(2*binwx*centx*hPhiCorr2Sum->GetBinError(x1),2);
+       NRMSPhi[2][MainLoop]+=pow(binwx*centx*hPhiCorrPt2Sum->GetBinContent(x1),2);
+       NRMSPhi[3][MainLoop]+=pow(2*binwx*centx*hPhiCorrPt2Sum->GetBinError(x1),2);
+       //how do I want to do the errors
+       //1/RMS*(2*sum cont*centx/sum cont)(1/sum cont^2)*err
+       //later do NRMSPhi[0][MainLoop]=sqrt(NRMSPhi[0][Mainloop]/NYieldPhi[0][MainLoop]) and NRMSPhi[1][MainLoop]=0.5*sqrt(NRMSPhi[1]/NRMSPhi[0]^2+NYieldPhi[1]/NYieldPhi[0]^2) I'm assuming no sqrts on errors yet
+       NearBinsPhi++;
+      }
+      //AwaySide 1d
+      if(fabs(centx-Pi)<AwayWidthPhi||fabs(centx-3*Pi)<AwayWidthPhi||fabs(centx+Pi)<AwayWidthPhi){
+       trms1=(centx-Pi);
+       if(trms1<Pi)trms1+=2*Pi;
+       if(trms1>Pi)trms1-=2*Pi;
+       AYieldPhi[0][MainLoop]+=binwx*hPhiCorrSum->GetBinContent(x1);
+       AYieldPhi[1][MainLoop]+=pow(binwx*hPhiCorrSum->GetBinContent(x1),2);
+       AYieldPhi[2][MainLoop]+=binwx*hPhiCorrPtSum->GetBinContent(x1);
+       AYieldPhi[3][MainLoop]+=pow(binwx*hPhiCorrPtSum->GetBinError(x1),2);
+       AYieldPhiZYAM[0][MainLoop]+=binwx*hPhiCorr2Sum->GetBinContent(x1);
+       AYieldPhiZYAM[1][MainLoop]+=pow(binwx*hPhiCorr2Sum->GetBinError(x1),2);
+       AYieldPhiZYAM[2][MainLoop]+=binwx*hPhiCorrPt2Sum->GetBinContent(x1);
+       AYieldPhiZYAM[3][MainLoop]+=pow(binwx*hPhiCorrPt2Sum->GetBinError(x1),2);
+       ARMSPhi[0][MainLoop]+=pow(binwx*trms1*hPhiCorr2Sum->GetBinContent(x1),2);
+       ARMSPhi[1][MainLoop]+=pow(2*binwx*trms1*hPhiCorr2Sum->GetBinError(x1),2);
+       ARMSPhi[2][MainLoop]+=pow(binwx*trms1*hPhiCorrPt2Sum->GetBinContent(x1),2);
+       ARMSPhi[3][MainLoop]+=pow(2*binwx*trms1*hPhiCorrPt2Sum->GetBinError(x1),2);
+       AwayBinsPhi++;
+      }
+      //Minimum
+      if(fabs(centx-ZYAMCent)<ZYAMWidth||fabs(centx+ZYAMCent)<ZYAMWidth||fabs(centx-ZYAMCent+2*Pi)<ZYAMWidth||fabs(centx-ZYAMCent-2*Pi)<ZYAMWidth||fabs(centx+ZYAMCent+2*Pi)<ZYAMWidth||fabs(centx+ZYAMCent-2*Pi)<ZYAMWidth){
+       MYieldPhi[0][MainLoop]+=hPhiCorrSum->GetBinContent(x1);
+       MYieldPhi[1][MainLoop]+=pow(hPhiCorrSum->GetBinError(x1),2);
+       MYieldPhi[2][MainLoop]+=hPhiCorrPtSum->GetBinContent(x1);
+       MYieldPhi[3][MainLoop]+=pow(hPhiCorrPtSum->GetBinError(x1),2);
+       MinBinsPhi++;
+      }
+    }//Phi Loop
+
+    //EtaLoop
+    binwx=hEtaNCorrSum->GetBinWidth(1);
+    for(int x1=1;x1<=hEtaNCorrSum->GetNbinsX();x1++){
+      NYieldEta[0][MainLoop]+=binwx*hEtaNCorrSum->GetBinContent(x1);
+      NYieldEta[1][MainLoop]+=pow(binwx*hEtaNCorrSum->GetBinError(x1),2);
+      NYieldEta[2][MainLoop]+=binwx*hEtaNCorrPtSum->GetBinContent(x1);
+      NYieldEta[3][MainLoop]+=pow(binwx*hEtaNCorrPtSum->GetBinError(x1),2);
+      NYieldEtaZYAM[0][MainLoop]+=binwx*hEtaNCorr2Sum->GetBinContent(x1);
+      NYieldEtaZYAM[1][MainLoop]+=pow(binwx*hEtaNCorr2Sum->GetBinError(x1),2);
+      NYieldEtaZYAM[2][MainLoop]+=binwx*hEtaNCorrPt2Sum->GetBinContent(x1);
+      NYieldEtaZYAM[3][MainLoop]+=pow(binwx*hEtaNCorrPt2Sum->GetBinError(x1),2);
+      AYieldEta[0][MainLoop]+=binwx*hEtaACorrSum->GetBinContent(x1);
+      AYieldEta[1][MainLoop]+=pow(binwx*hEtaACorrSum->GetBinError(x1),2);
+      AYieldEta[2][MainLoop]+=binwx*hEtaACorrPtSum->GetBinContent(x1);
+      AYieldEta[3][MainLoop]+=pow(binwx*hEtaACorrPtSum->GetBinError(x1),2);
+      AYieldEtaZYAM[0][MainLoop]+=binwx*hEtaACorr2Sum->GetBinContent(x1);
+      AYieldEtaZYAM[1][MainLoop]+=pow(binwx*hEtaACorr2Sum->GetBinError(x1),2);
+      AYieldEtaZYAM[2][MainLoop]+=binwx*hEtaACorrPt2Sum->GetBinContent(x1);
+      AYieldEtaZYAM[3][MainLoop]+=pow(binwx*hEtaACorrPt2Sum->GetBinError(x1),2);
+    }//EtaLoop
+      
+
+    phiaxis=hPhiEtaCorrSum->GetXaxis();
+    etaaxis=hPhiEtaCorrSum->GetYaxis();
+    binwx=phiaxis->GetBinWidth(1);
+    binwy=etaaxis->GetBinWidth(1);
+    for(int x1=0;x1<hPhiEtaCorrSum->GetNbinsX();x1++){
+      centx=phiaxis->GetBinCenter(x1);
+      for(int y1=0;y1<hPhiEtaCorrSum->GetNbinsY();y1++){
+       centy=etaaxis->GetBinCenter(y1);
+       //Near-Side 2 d
+       if(fabs(centx)<NearWidthPhi||fabs(centx-2*Pi)<NearWidthPhi||fabs(centx+2*Pi)<NearWidthPhi){
+         //Jet Peak Area
+         if(fabs(centy)<NearWidthEta){
+           NYieldPhiEta1[0][MainLoop]+=binwx*binwy*hPhiEtaCorrSum->GetBinContent(x1,y1);
+           NYieldPhiEta1[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrSum->GetBinError(x1,y1),2);
+           NYieldPhiEta1[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPtSum->GetBinContent(x1,y1);
+           NYieldPhiEta1[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPtSum->GetBinError(x1,y1),2);
+           NYieldPhiEta1ZYAM[0][MainLoop]+=binwx*binwy*hPhiEtaCorr2Sum->GetBinContent(x1,y1);
+           NYieldPhiEta1ZYAM[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorr2Sum->GetBinError(x1,y1),2);
+           NYieldPhiEta1ZYAM[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPt2Sum->GetBinContent(x1,y1);
+           NYieldPhiEta1ZYAM[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPt2Sum->GetBinError(x1,y1),2);
+           NearBinsPhiEta1++;
+         }
+         //Ridge Area
+         else{
+           NYieldPhiEta2[0][MainLoop]+=binwx*binwy*hPhiEtaCorrSum->GetBinContent(x1,y1);
+           NYieldPhiEta2[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrSum->GetBinError(x1,y1),2);
+           NYieldPhiEta2[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPtSum->GetBinContent(x1,y1);
+           NYieldPhiEta2[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPtSum->GetBinError(x1,y1),2);
+           NYieldPhiEta2ZYAM[0][MainLoop]+=binwx*binwy*hPhiEtaCorr2Sum->GetBinContent(x1,y1);
+           NYieldPhiEta2ZYAM[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorr2Sum->GetBinError(x1,y1),2);
+           NYieldPhiEta2ZYAM[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPt2Sum->GetBinContent(x1,y1);
+           NYieldPhiEta2ZYAM[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPt2Sum->GetBinError(x1,y1),2);
+           NearBinsPhiEta2++;
+         }
+       }
+       //Away-side 2D
+       if(fabs(centx-Pi)<AwayWidthPhi||fabs(centx-3*Pi)<AwayWidthPhi||fabs(centx+Pi)<AwayWidthPhi){
+         AYieldPhiEta[0][MainLoop]+=binwx*binwy*hPhiEtaCorrSum->GetBinContent(x1,y1);
+         AYieldPhiEta[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrSum->GetBinError(x1,y1),2);
+         AYieldPhiEta[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPtSum->GetBinContent(x1,y1);
+         AYieldPhiEta[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPtSum->GetBinError(x1,y1),2);
+         AYieldPhiEtaZYAM[0][MainLoop]+=binwx*binwy*hPhiEtaCorr2Sum->GetBinContent(x1,y1);
+         AYieldPhiEtaZYAM[1][MainLoop]+=pow(binwx*binwy*hPhiEtaCorr2Sum->GetBinError(x1,y1),2);
+         AYieldPhiEtaZYAM[2][MainLoop]+=binwx*binwy*hPhiEtaCorrPt2Sum->GetBinContent(x1,y1);
+         AYieldPhiEtaZYAM[3][MainLoop]+=pow(binwx*binwy*hPhiEtaCorrPt2Sum->GetBinError(x1,y1),2);
+         AwayBinsPhiEta++;
+       }
+       //Minimum 2D
+       if(fabs(centx-ZYAMCent)<ZYAMWidth||fabs(centx+ZYAMCent)<ZYAMWidth||fabs(centx-ZYAMCent+2*Pi)<ZYAMWidth||fabs(centx-ZYAMCent-2*Pi)<ZYAMWidth||fabs(centx+ZYAMCent+2*Pi)<ZYAMWidth||fabs(centx+ZYAMCent-2*Pi)<ZYAMWidth){
+         MYieldPhiEta[0][MainLoop]+=hPhiEtaCorrSum->GetBinContent(x1,y1);
+         MYieldPhiEta[1][MainLoop]+=pow(hPhiEtaCorrSum->GetBinError(x1,y1),2);
+         MYieldPhiEta[2][MainLoop]+=hPhiEtaCorrPtSum->GetBinContent(x1,y1);
+         MYieldPhiEta[3][MainLoop]+=pow(hPhiEtaCorrPtSum->GetBinError(x1,y1),2);
+         MinBinsPhiEta++;
+       }//Min 2d
+      }//y
+    }//x
+
+    //Averages
+    
+    cout << NYieldPhiZYAM[0][MainLoop] << endl;
+    cout << AYieldPhiZYAM[0][MainLoop] << endl;
+    cout << MYieldPhi[0][MainLoop] << endl;
+    cout << NYieldEtaZYAM[0][MainLoop] << endl;
+    cout << AYieldEtaZYAM[0][MainLoop] << endl;
+    
+    NAvePhi[0][MainLoop]=NYieldPhiZYAM[2][MainLoop]/NYieldPhiZYAM[0][MainLoop];
+    AAvePhi[0][MainLoop]=AYieldPhiZYAM[2][MainLoop]/AYieldPhiZYAM[0][MainLoop];
+    if(MYieldPhi[0][MainLoop]) MAvePhi[0][MainLoop]=MYieldPhi[2][MainLoop]/MYieldPhi[0][MainLoop];
+    else MAvePhi[0][MainLoop]=0;
+    NAveEta[0][MainLoop]=NYieldEtaZYAM[2][MainLoop]/NYieldEtaZYAM[0][MainLoop];
+    AAveEta[0][MainLoop]=AYieldEtaZYAM[2][MainLoop]/AYieldEtaZYAM[0][MainLoop];
+    NAvePhi[1][MainLoop]=NAvePhi[0][MainLoop]*pow(NYieldPhiZYAM[1][MainLoop]/pow(NYieldPhiZYAM[0][MainLoop],2)+NYieldPhiZYAM[3][MainLoop]/pow(NYieldPhiZYAM[2][MainLoop],2),0.5);
+    AAvePhi[1][MainLoop]=AAvePhiZYAM[0][MainLoop]*pow(AYieldPhiZYAM[1][MainLoop]/pow(AYieldPhiZYAM[0][MainLoop],2)+AYieldPhiZYAM[3][MainLoop]/pow(AYieldPhiZYAM[2][MainLoop],2),0.5);
+    if(MYieldPhi[0][MainLoop])MAvePhi[1][MainLoop]=MAvePhi[0][MainLoop]*pow(MYieldPhi[1][MainLoop]/pow(MYieldPhi[0][MainLoop],2)+MYieldPhi[3][MainLoop]/pow(MYieldPhi[2][MainLoop],2),0.5);
+    else (MAvePhi[1][MainLoop])=1;
+    NAveEta[1][MainLoop]=NAveEta[0][MainLoop]*pow(NYieldEtaZYAM[1][MainLoop]/pow(NYieldEtaZYAM[0][MainLoop],2)+NYieldEtaZYAM[3][MainLoop]/pow(NYieldEtaZYAM[2][MainLoop],2),0.5);
+    AAveEta[1][MainLoop]=AAveEta[0][MainLoop]*pow(AYieldEtaZYAM[1][MainLoop]/pow(AYieldEtaZYAM[0][MainLoop],2)+AYieldEtaZYAM[3][MainLoop]/pow(AYieldEtaZYAM[2][MainLoop],2),0.5);
+
+    //Set up the Error bars correctly
+    NYieldPhi[1][MainLoop]=sqrt(NYieldPhi[1][MainLoop]);
+    NYieldPhi[3][MainLoop]=sqrt(NYieldPhi[3][MainLoop]);
+    AYieldPhi[1][MainLoop]=sqrt(AYieldPhi[1][MainLoop]);
+    AYieldPhi[3][MainLoop]=sqrt(AYieldPhi[3][MainLoop]);
+    NYieldPhiZYAM[1][MainLoop]=sqrt(NYieldPhiZYAM[1][MainLoop]);
+    NYieldPhiZYAM[3][MainLoop]=sqrt(NYieldPhiZYAM[3][MainLoop]);
+    AYieldPhiZYAM[1][MainLoop]=sqrt(AYieldPhiZYAM[1][MainLoop]);
+    AYieldPhiZYAM[3][MainLoop]=sqrt(AYieldPhiZYAM[3][MainLoop]);
+    MYieldPhi[1][MainLoop]=sqrt(MYieldPhi[1][MainLoop]);
+    MYieldPhi[3][MainLoop]=sqrt(MYieldPhi[3][MainLoop]);
+
+    NYieldEta[1][MainLoop]=sqrt(NYieldEta[1][MainLoop]);
+    NYieldEta[3][MainLoop]=sqrt(NYieldEta[3][MainLoop]);
+    AYieldEta[1][MainLoop]=sqrt(AYieldEta[1][MainLoop]);
+    AYieldEta[3][MainLoop]=sqrt(AYieldEta[3][MainLoop]);
+    NYieldEtaZYAM[1][MainLoop]=sqrt(NYieldEtaZYAM[1][MainLoop]);
+    NYieldEtaZYAM[3][MainLoop]=sqrt(NYieldEtaZYAM[3][MainLoop]);
+    AYieldEtaZYAM[1][MainLoop]=sqrt(AYieldEtaZYAM[1][MainLoop]);
+    AYieldEtaZYAM[3][MainLoop]=sqrt(AYieldEtaZYAM[3][MainLoop]);
+    
+    //Set Minimums to total number of charged particles
+    MYieldPhi[0][MainLoop]=MYieldPhi[0][MainLoop]/MinBinsPhi*2*Pi;
+    MYieldPhi[1][MainLoop]=MYieldPhi[1][MainLoop]/MinBinsPhi*2*Pi;
+    MYieldPhi[2][MainLoop]=MYieldPhi[2][MainLoop]/MinBinsPhi*2*Pi;
+    MYieldPhi[3][MainLoop]=MYieldPhi[3][MainLoop]/MinBinsPhi*2*Pi;
+    MYieldPhiEta[0][MainLoop]=MYieldPhiEta[0][MainLoop]/MinBinsPhiEta*2*Pi;
+    MYieldPhiEta[1][MainLoop]=MYieldPhiEta[1][MainLoop]/MinBinsPhiEta*2*Pi;
+    MYieldPhiEta[2][MainLoop]=MYieldPhiEta[2][MainLoop]/MinBinsPhiEta*2*Pi;
+    MYieldPhiEta[3][MainLoop]=MYieldPhiEta[3][MainLoop]/MinBinsPhiEta*2*Pi;
+  
+    //0 (x1+x2)/2, 1 e2, 2 <x>,  3 e2, 4 lower error of 1 and 2, 5 e3, 6 zt1_0, 7 e5, 8 zt1_2, 9 e7, 10 zt1_3, 11 e9, 12 zt2_0, 13 e11, 14 zt2_1, 15 e13, 16 zt2_2, 17 e15  (zt_0 is (pt1+pt2)/2 zt_1 is <pt> zt_2 is lower error)
+    NXPhi[0][MainLoop]=MainArray[MainLoop];
+    NXPhi[1][MainLoop]=eMainArray[MainLoop];
+    AXPhi[0][MainLoop]=MainArray[MainLoop];
+    AXPhi[1][MainLoop]=eMainArray[MainLoop];
+    NXPhiFit[0][MainLoop]=MainArray[MainLoop];
+    NXPhiFit[1][MainLoop]=eMainArray[MainLoop];
+    AXPhiFit[0][MainLoop]=MainArray[MainLoop];
+    AXPhiFit[1][MainLoop]=eMainArray[MainLoop];
+
+    NXEta[0][MainLoop]=MainArray[MainLoop];
+    NXEta[1][MainLoop]=eMainArray[MainLoop];
+    AXEta[0][MainLoop]=MainArray[MainLoop];
+    AXEta[1][MainLoop]=eMainArray[MainLoop];
+    NXEtaFit[0][MainLoop]=MainArray[MainLoop];
+    NXEtaFit[1][MainLoop]=eMainArray[MainLoop];
+    AXEtaFit[0][MainLoop]=MainArray[MainLoop];
+    AXEtaFit[1][MainLoop]=eMainArray[MainLoop];
+
+    NXPhiEta1[0][MainLoop]=MainArray[MainLoop];
+    NXPhiEta1[1][MainLoop]=eMainArray[MainLoop];
+    NXPhiEta2[0][MainLoop]=MainArray[MainLoop];
+    NXPhiEta2[1][MainLoop]=eMainArray[MainLoop];
+    AXPhiEta[0][MainLoop]=MainArray[MainLoop];
+    AXPhiEta[1][MainLoop]=eMainArray[MainLoop];
+  
+    if(APtTPtMult==0){//spectra so <pt_assoc>
+      if(NYieldPhiZYAM[0][MainLoop]==0) NYieldPhiZYAM[0][MainLoop]=0.00000001;
+      if(NYieldPhiZYAM[2][MainLoop]==0) NYieldPhiZYAM[2][MainLoop]=0.00000001;
+      if(AYieldPhiZYAM[0][MainLoop]==0) AYieldPhiZYAM[0][MainLoop]=0.00000001;
+      if(AYieldPhiZYAM[2][MainLoop]==0) AYieldPhiZYAM[2][MainLoop]=0.00000001;
+      NXPhi[2][MainLoop]=NYieldPhiZYAM[2][MainLoop]/NYieldPhiZYAM[0][MainLoop];
+      NXPhi[3][MainLoop]=NXPhi[2][MainLoop]*sqrt(pow(NYieldPhiZYAM[1][MainLoop]/NYieldPhiZYAM[0][MainLoop],2)+pow(NYieldPhiZYAM[3][MainLoop]/NYieldPhiZYAM[2][MainLoop],2));
+      AXPhi[2][MainLoop]=AYieldPhiZYAM[2][MainLoop]/AYieldPhiZYAM[0][MainLoop];
+      AXPhi[3][MainLoop]=AXPhi[2][MainLoop]*sqrt(pow(AYieldPhiZYAM[1][MainLoop]/AYieldPhiZYAM[0][MainLoop],2)+pow(AYieldPhiZYAM[3][MainLoop]/AYieldPhiZYAM[2][MainLoop],2));
+      NXPhiFit[2][MainLoop]=NYieldPhiFit[2][MainLoop]/NYieldPhiFit[0][MainLoop];
+      // cout << "Pt " << NXPhiFit[2][MainLoop] << endl;
+      NXPhiFit[3][MainLoop]=NXPhiFit[2][MainLoop]*sqrt(pow(NYieldPhiFit[1][MainLoop]/NYieldPhiFit[0][MainLoop],2)+pow(NYieldPhiFit[3][MainLoop]/NYieldPhiFit[2][MainLoop],2));
+      AXPhiFit[2][MainLoop]=AYieldPhiFit[2][MainLoop]/AYieldPhiFit[0][MainLoop];
+      AXPhiFit[3][MainLoop]=AXPhiFit[2][MainLoop]*sqrt(pow(AYieldPhiFit[1][MainLoop]/AYieldPhiFit[0][MainLoop],2)+pow(AYieldPhiFit[3][MainLoop]/AYieldPhiFit[2][MainLoop],2));
+
+      NXEta[2][MainLoop]=NYieldEtaZYAM[2][MainLoop]/NYieldEtaZYAM[0][MainLoop];
+      NXEta[3][MainLoop]=NXEta[2][MainLoop]*sqrt(pow(NYieldEtaZYAM[1][MainLoop]/NYieldEtaZYAM[0][MainLoop],2)+pow(NYieldEtaZYAM[3][MainLoop]/NYieldEtaZYAM[2][MainLoop],2));
+      AXEta[2][MainLoop]=AYieldEtaZYAM[2][MainLoop]/AYieldEtaZYAM[0][MainLoop];
+      AXEta[3][MainLoop]=AXEta[2][MainLoop]*sqrt(pow(AYieldEtaZYAM[1][MainLoop]/AYieldEtaZYAM[0][MainLoop],2)+pow(AYieldEtaZYAM[3][MainLoop]/AYieldEtaZYAM[2][MainLoop],2));
+      NXEtaFit[2][MainLoop]=NYieldEtaFit[2][MainLoop]/NYieldEtaFit[0][MainLoop];
+      NXEtaFit[3][MainLoop]=NXEtaFit[2][MainLoop]*sqrt(pow(NYieldEtaFit[1][MainLoop]/NYieldEtaFit[0][MainLoop],2)+pow(NYieldEtaFit[3][MainLoop]/NYieldEtaFit[2][MainLoop],2));
+      AXEtaFit[2][MainLoop]=AYieldEtaFit[2][MainLoop]/AYieldEtaFit[0][MainLoop];
+      AXEtaFit[3][MainLoop]=AXEtaFit[2][MainLoop]*sqrt(pow(AYieldEtaFit[1][MainLoop]/AYieldEtaFit[0][MainLoop],2)+pow(AYieldEtaFit[3][MainLoop]/AYieldEtaFit[2][MainLoop],2));
+
+      
+      /*
+       NXPhiEta1[2][MainLoop]=NYieldPhiEta1[2][MainLoop]/NYieldPhiEta1[0][MainLoop];
+       NXPhiEta1[3][MainLoop]=NXPhiEta1[2][MainLoop][0]*sqrt(pow(NYieldPhiEta1[1][MainLoop]/NYieldPhiEta1[0][MainLoop],2)+pow(NYieldPhiEta1[3][MainLoop]/NYieldPhiEta1[2][MainLoop],2));
+       NXPhiEta2[2][MainLoop]=NYieldPhiEta2[2][MainLoop]/NYieldPhiEta2[0][MainLoop];
+       NXPhiEta2[3][MainLoop]=NXPhiEta2[2][MainLoop][0]*sqrt(pow(NYieldPhiEta2[1][MainLoop]/NYieldPhiEta2[0][MainLoop],2)+pow(NYieldPhiEta2[3][MainLoop]/NYieldPhiEta2[2][MainLoop],2));
+       AXPhiEta[2][MainLoop]=AYieldPhiEta[2][MainLoop]/AYieldPhiEta[0][MainLoop];
+       AXPhiEta[3][MainLoop]=AXPhiEta[2][MainLoop][0]*sqrt(pow(AYieldPhiEta[1][MainLoop]/AYieldPhiEta[0][MainLoop],2)+pow(AYieldPhiEta[3][MainLoop]/AYieldPhiEta[2][MainLoop],2));
+      */
+   
+      if(NXPhi[1][MainLoop]<NXPhi[3][MainLoop]){
+       NXPhi[4][MainLoop]=NXPhi[0][MainLoop];
+       NXPhi[5][MainLoop]=NXPhi[1][MainLoop];
+      }
+      else{
+       NXPhi[4][MainLoop]=NXPhi[2][MainLoop];
+       NXPhi[5][MainLoop]=NXPhi[3][MainLoop];
+      } 
+      if(AXPhi[1][MainLoop]<AXPhi[3][MainLoop]){
+       AXPhi[4][MainLoop]=AXPhi[0][MainLoop];
+       AXPhi[5][MainLoop]=AXPhi[1][MainLoop];
+      }
+      else{
+       AXPhi[4][MainLoop]=AXPhi[2][MainLoop];
+       AXPhi[5][MainLoop]=AXPhi[3][MainLoop];
+      }        
+      if(NXPhiFit[1][MainLoop]<NXPhiFit[3][MainLoop]){
+       NXPhiFit[4][MainLoop]=NXPhiFit[0][MainLoop];
+       NXPhiFit[5][MainLoop]=NXPhiFit[1][MainLoop];
+      }
+      else{
+       NXPhiFit[4][MainLoop]=NXPhiFit[2][MainLoop];
+       NXPhiFit[5][MainLoop]=NXPhiFit[3][MainLoop];
+      } 
+      if(AXPhiFit[1][MainLoop]<AXPhiFit[3][MainLoop]){
+       AXPhiFit[4][MainLoop]=AXPhiFit[0][MainLoop];
+       AXPhiFit[5][MainLoop]=AXPhiFit[1][MainLoop];
+      }
+      else{
+       AXPhiFit[4][MainLoop]=AXPhiFit[2][MainLoop];
+       AXPhiFit[5][MainLoop]=AXPhiFit[3][MainLoop];
+      }        
+
+      if(NXEta[1][MainLoop]<NXEta[3][MainLoop]){
+       NXEta[4][MainLoop]=NXEta[0][MainLoop];
+       NXEta[5][MainLoop]=NXEta[1][MainLoop];
+      }
+      else{
+       NXEta[4][MainLoop]=NXEta[2][MainLoop];
+       NXEta[5][MainLoop]=NXEta[3][MainLoop];
+      } 
+      if(AXEta[1][MainLoop]<AXEta[3][MainLoop]){
+       AXEta[4][MainLoop]=AXEta[0][MainLoop];
+       AXEta[5][MainLoop]=AXEta[1][MainLoop];
+      }
+      else{
+       AXEta[4][MainLoop]=AXEta[2][MainLoop];
+       AXEta[5][MainLoop]=AXEta[3][MainLoop];
+      }        
+      if(NXEtaFit[1][MainLoop]<NXEtaFit[3][MainLoop]){
+       NXEtaFit[4][MainLoop]=NXEtaFit[0][MainLoop];
+       NXEtaFit[5][MainLoop]=NXEtaFit[1][MainLoop];
+      }
+      else{
+       NXEtaFit[4][MainLoop]=NXEtaFit[2][MainLoop];
+       NXEtaFit[5][MainLoop]=NXEtaFit[3][MainLoop];
+      } 
+      if(AXEtaFit[1][MainLoop]<AXEtaFit[3][MainLoop]){
+       AXEtaFit[4][MainLoop]=AXEtaFit[0][MainLoop];
+       AXEtaFit[5][MainLoop]=AXEtaFit[1][MainLoop];
+      }
+      else{
+       AXEtaFit[4][MainLoop]=AXEtaFit[2][MainLoop];
+       AXEtaFit[5][MainLoop]=AXEtaFit[3][MainLoop];
+      }        
+      
+      for(int tloop=0;tloop<=2; tloop++){
+       NXPhi[6+2*tloop][MainLoop]=NXPhi[0+2*tloop][MainLoop]/MPt[0];
+       NXPhi[7+2*tloop][MainLoop]=NXPhi[6+2*tloop][MainLoop]*sqrt(pow(NXPhi[1+2*tloop][MainLoop]/NXPhi[0+2*tloop][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+       NXPhi[12+2*tloop][MainLoop]=NXPhi[0+2*tloop][MainLoop]/(MPt[0]+TNYieldPhiZYAM[2][MainLoop]);
+       NXPhi[13+2*tloop][MainLoop]=NXPhi[12+2*tloop][MainLoop]*sqrt(pow(NXPhi[1+2*tloop][MainLoop]/NXPhi[0+2*tloop][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldPhiZYAM[3][MainLoop])/pow(MPt[0]+TNYieldPhiZYAM[2][MainLoop],2));
+       AXPhi[6+2*tloop][MainLoop]=AXPhi[0+2*tloop][MainLoop]/MPt[0];
+       AXPhi[7+2*tloop][MainLoop]=AXPhi[6+2*tloop][MainLoop]*sqrt(pow(AXPhi[1+2*tloop][MainLoop]/AXPhi[0+2*tloop][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+       AXPhi[12+2*tloop][MainLoop]=AXPhi[0+2*tloop][MainLoop]/(MPt[0]+TNYieldPhiZYAM[2][MainLoop]);
+       AXPhi[13+2*tloop][MainLoop]=AXPhi[12+2*tloop][MainLoop]*sqrt(pow(AXPhi[1+2*tloop][MainLoop]/AXPhi[0+2*tloop][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldPhiZYAM[3][MainLoop])/pow(MPt[0]+TNYieldPhiZYAM[2][MainLoop],2));
+
+       NXPhiFit[6+2*tloop][MainLoop]=NXPhiFit[0+2*tloop][MainLoop]/MPt[0];
+       NXPhiFit[7+2*tloop][MainLoop]=NXPhiFit[6+2*tloop][MainLoop]*sqrt(pow(NXPhiFit[1+2*tloop][MainLoop]/NXPhiFit[0+2*tloop][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+       //      NXPhi[12+2*tloop][MainLoop]=NXPhi[0+2*tloop][MainLoop]/(MPt[0]+TNYieldPhiZYAM[2][MainLoop]);
+       //      NXPhi[13+2*tloop][MainLoop]=NXPhi[12+2*tloop][MainLoop]*sqrt(pow(NXPhi[1+2*tloop][MainLoop]/NXPhi[0+2*tloop][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldPhiZYAM[3][MainLoop])/pow(MPt[0]+TNYieldPhiZYAM[2][MainLoop],2));
+       AXPhiFit[6+2*tloop][MainLoop]=AXPhiFit[0+2*tloop][MainLoop]/MPt[0];
+       AXPhiFit[7+2*tloop][MainLoop]=AXPhiFit[6+2*tloop][MainLoop]*sqrt(pow(AXPhiFit[1+2*tloop][MainLoop]/AXPhiFit[0+2*tloop][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+       //      AXPhi[12+2*tloop][MainLoop]=AXPhi[0+2*tloop][MainLoop]/(MPt[0]+TNYieldPhiZYAM[2][MainLoop]);
+       //      AXPhi[13+2*tloop][MainLoop]=AXPhi[12+2*tloop][MainLoop]*sqrt(pow(AXPhi[1+2*tloop][MainLoop]/AXPhi[0+2*tloop][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldPhiZYAM[3][MainLoop])/pow(MPt[0]+TNYieldPhiZYAM[2][MainLoop],2));
+
+       NXEta[6+2*tloop][MainLoop]=NXEta[0+2*tloop][MainLoop]/MPt[0];
+       NXEta[7+2*tloop][MainLoop]=NXEta[6+2*tloop][MainLoop]*sqrt(pow(NXEta[1+2*tloop][MainLoop]/NXEta[0+2*tloop][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+       //      NXEta[12+2*tloop][MainLoop]=NXEta[0+2*tloop][MainLoop]/(MPt[0]+TNYieldEtaZYAM[2][MainLoop]);
+       //      NXEta[13+2*tloop][MainLoop]=NXEta[12+2*tloop][MainLoop]*sqrt(pow(NXEta[1+2*tloop][MainLoop]/NXEta[0+2*tloop][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldEtaZYAM[3][MainLoop])/pow(MPt[0]+TNYieldEtaZYAM[2][MainLoop],2));
+       AXEta[6+2*tloop][MainLoop]=AXEta[0+2*tloop][MainLoop]/MPt[0];
+       AXEta[7+2*tloop][MainLoop]=AXEta[6+2*tloop][MainLoop]*sqrt(pow(AXEta[1+2*tloop][MainLoop]/AXEta[0+2*tloop][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+       //AXEta[12+2*tloop][MainLoop]=AXEta[0+2*tloop][MainLoop]/(MPt[0]+TNYieldEtaZYAM[2][MainLoop]);
+       //      AXEta[13+2*tloop][MainLoop]=AXEta[12+2*tloop][MainLoop]*sqrt(pow(AXEta[1+2*tloop][MainLoop]/AXEta[0+2*tloop][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldEtaZYAM[3][MainLoop])/pow(MPt[0]+TNYieldEtaZYAM[2][MainLoop],2));
+
+       NXEtaFit[6+2*tloop][MainLoop]=NXEtaFit[0+2*tloop][MainLoop]/MPt[0];
+       NXEtaFit[7+2*tloop][MainLoop]=NXEtaFit[6+2*tloop][MainLoop]*sqrt(pow(NXEtaFit[1+2*tloop][MainLoop]/NXEtaFit[0+2*tloop][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+       AXEtaFit[6+2*tloop][MainLoop]=AXEtaFit[0+2*tloop][MainLoop]/MPt[0];
+       AXEtaFit[7+2*tloop][MainLoop]=AXEtaFit[6+2*tloop][MainLoop]*sqrt(pow(AXEtaFit[1+2*tloop][MainLoop]/AXEtaFit[0+2*tloop][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+
+      }
+    
+      NYieldPhi[4][MainLoop]=NYieldPhi[0][MainLoop]/NXPhi[1][MainLoop];
+      NYieldPhi[5][MainLoop]=NYieldPhi[1][MainLoop]/NXPhi[1][MainLoop];
+      NYieldPhi[6][MainLoop]=NYieldPhi[0][MainLoop]/NXPhi[1][MainLoop]*MPt[0];
+      NYieldPhi[7][MainLoop]=NYieldPhi[6][MainLoop]*sqrt(pow(NYieldPhi[1][MainLoop]/NYieldPhi[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+      NYieldPhi[8][MainLoop]=NYieldPhi[0][MainLoop]/NXPhi[1][MainLoop]*(MPt[0]+TNYieldPhi[2][MainLoop]);
+      NYieldPhi[9][MainLoop]=NYieldPhi[8][MainLoop]*sqrt(pow(NYieldPhi[1][MainLoop]/NYieldPhi[0][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldPhi[3][MainLoop]*TNYieldPhi[3][MainLoop])/pow(MPt[0]+TNYieldPhi[2][MainLoop],2));
+      NYieldPhiFit[7][MainLoop]=NYieldPhiFit[6][MainLoop]*sqrt(pow(NYieldPhiFit[1][MainLoop]/NYieldPhiFit[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+      NYieldPhiZYAM[4][MainLoop]=NYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop];
+      NYieldPhiZYAM[5][MainLoop]=NYieldPhiZYAM[1][MainLoop]/NXPhi[1][MainLoop];
+      NYieldPhiZYAM[6][MainLoop]=NYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop]*MPt[0];
+      NYieldPhiZYAM[7][MainLoop]=NYieldPhiZYAM[6][MainLoop]*sqrt(pow(NYieldPhiZYAM[1][MainLoop]/NYieldPhiZYAM[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+      NYieldPhiZYAM[8][MainLoop]=NYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop]*(MPt[0]+TNYieldPhi[2][MainLoop]);
+      NYieldPhiZYAM[9][MainLoop]=NYieldPhiZYAM[8][MainLoop]*sqrt(pow(NYieldPhiZYAM[1][MainLoop]/NYieldPhiZYAM[0][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldPhi[3][MainLoop]*TNYieldPhi[3][MainLoop])/pow(MPt[0]+TNYieldPhi[2][MainLoop],2));
+      AYieldPhiZYAM[4][MainLoop]=AYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop];
+      AYieldPhiZYAM[5][MainLoop]=AYieldPhiZYAM[1][MainLoop]/NXPhi[1][MainLoop];
+      AYieldPhiZYAM[6][MainLoop]=AYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop]*MPt[0];
+      AYieldPhiZYAM[7][MainLoop]=AYieldPhiZYAM[6][MainLoop]*sqrt(pow(NYieldPhiZYAM[1][MainLoop]/NYieldPhiZYAM[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+      AYieldPhiZYAM[8][MainLoop]=AYieldPhiZYAM[0][MainLoop]/NXPhi[1][MainLoop]*(MPt[0]+TNYieldPhi[2][MainLoop]);
+      AYieldPhiZYAM[9][MainLoop]=AYieldPhiZYAM[8][MainLoop]*sqrt(pow(NYieldPhiZYAM[1][MainLoop]/NYieldPhiZYAM[0][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldPhi[3][MainLoop]*TNYieldPhi[3][MainLoop])/pow(MPt[0]+TNYieldPhi[2][MainLoop],2));
+      
+      NYieldPhiFit[4][MainLoop]=NYieldPhiFit[0][MainLoop]/NXPhiFit[1][MainLoop];
+      NYieldPhiFit[5][MainLoop]=NYieldPhiFit[1][MainLoop]/NXPhiFit[1][MainLoop];
+      NYieldPhiFit[6][MainLoop]=NYieldPhiFit[0][MainLoop]/NXPhiFit[1][MainLoop]*MPt[0];
+      AYieldPhiFit[4][MainLoop]=AYieldPhiFit[0][MainLoop]/AXPhiFit[1][MainLoop];
+      AYieldPhiFit[5][MainLoop]=AYieldPhiFit[1][MainLoop]/AXPhiFit[1][MainLoop];
+      AYieldPhiFit[6][MainLoop]=AYieldPhiFit[0][MainLoop]/AXPhiFit[1][MainLoop]*MPt[0];
+      AYieldPhiFit[7][MainLoop]=AYieldPhiFit[6][MainLoop]*sqrt(pow(NYieldPhiFit[1][MainLoop]/NYieldPhiFit[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+
+      NYieldEta[4][MainLoop]=NYieldEta[0][MainLoop]/NXEta[1][MainLoop];
+      NYieldEta[5][MainLoop]=NYieldEta[1][MainLoop]/NXEta[1][MainLoop];
+      NYieldEta[6][MainLoop]=NYieldEta[0][MainLoop]/NXEta[1][MainLoop]*MPt[0];
+      NYieldEta[7][MainLoop]=NYieldEta[6][MainLoop]*sqrt(pow(NYieldEta[1][MainLoop]/NYieldEta[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+      // NYieldEta[8][MainLoop]=NYieldEta[0][MainLoop]/NXEta[1][MainLoop]*(MPt[0]+TNYieldEta[2][MainLoop]);
+      //  NYieldEta[9][MainLoop]=NYieldEta[8][MainLoop]*sqrt(pow(NYieldEta[1][MainLoop]/NYieldEta[0][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldEta[3][MainLoop]*TNYieldEta[3][MainLoop])/pow(MPt[0]+TNYieldEta[2][MainLoop],2));
+      NYieldEtaFit[7][MainLoop]=NYieldEtaFit[6][MainLoop]*sqrt(pow(NYieldEtaFit[1][MainLoop]/NYieldEtaFit[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+      NYieldEtaZYAM[4][MainLoop]=NYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop];
+      NYieldEtaZYAM[5][MainLoop]=NYieldEtaZYAM[1][MainLoop]/NXEta[1][MainLoop];
+      NYieldEtaZYAM[6][MainLoop]=NYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop]*MPt[0];
+      NYieldEtaZYAM[7][MainLoop]=NYieldEtaZYAM[6][MainLoop]*sqrt(pow(NYieldEtaZYAM[1][MainLoop]/NYieldEtaZYAM[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+      // NYieldEtaZYAM[8][MainLoop]=NYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop]*(MPt[0]+TNYieldEta[2][MainLoop]);
+      //  NYieldEtaZYAM[9][MainLoop]=NYieldEtaZYAM[8][MainLoop]*sqrt(pow(NYieldEtaZYAM[1][MainLoop]/NYieldEtaZYAM[0][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldEta[3][MainLoop]*TNYieldEta[3][MainLoop])/pow(MPt[0]+TNYieldEta[2][MainLoop],2));
+      AYieldEtaZYAM[4][MainLoop]=AYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop];
+      AYieldEtaZYAM[5][MainLoop]=AYieldEtaZYAM[1][MainLoop]/NXEta[1][MainLoop];
+      AYieldEtaZYAM[6][MainLoop]=AYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop]*MPt[0];
+      AYieldEtaZYAM[7][MainLoop]=AYieldEtaZYAM[6][MainLoop]*sqrt(pow(NYieldEtaZYAM[1][MainLoop]/NYieldEtaZYAM[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+      //  AYieldEtaZYAM[8][MainLoop]=AYieldEtaZYAM[0][MainLoop]/NXEta[1][MainLoop]*(MPt[0]+TNYieldEta[2][MainLoop]);
+      //  AYieldEtaZYAM[9][MainLoop]=AYieldEtaZYAM[8][MainLoop]*sqrt(pow(NYieldEtaZYAM[1][MainLoop]/NYieldEtaZYAM[0][MainLoop],2)+(MPt[1]*MPt[1]+TNYieldEta[3][MainLoop]*TNYieldEta[3][MainLoop])/pow(MPt[0]+TNYieldEta[2][MainLoop],2));
+      
+      NYieldEtaFit[4][MainLoop]=NYieldEtaFit[0][MainLoop]/NXEtaFit[1][MainLoop];
+      NYieldEtaFit[5][MainLoop]=NYieldEtaFit[1][MainLoop]/NXEtaFit[1][MainLoop];
+      NYieldEtaFit[6][MainLoop]=NYieldEtaFit[0][MainLoop]/NXEtaFit[1][MainLoop]*MPt[0];
+      AYieldEtaFit[4][MainLoop]=AYieldEtaFit[0][MainLoop]/AXEtaFit[1][MainLoop];
+      AYieldEtaFit[5][MainLoop]=AYieldEtaFit[1][MainLoop]/AXEtaFit[1][MainLoop];
+      AYieldEtaFit[6][MainLoop]=AYieldEtaFit[0][MainLoop]/AXEtaFit[1][MainLoop]*MPt[0];
+      AYieldEtaFit[7][MainLoop]=AYieldEtaFit[6][MainLoop]*sqrt(pow(NYieldEtaFit[1][MainLoop]/NYieldEtaFit[0][MainLoop],2)+pow(MPt[1]/MPt[0],2));
+    } 
+  
+    if(APtTPtMult==1){//Trigger pt dependence so <pt_Trig>
+      NXPhi[2][MainLoop]=MPt[0];
+      NXPhi[3][MainLoop]=MPt[1];
+      AXPhi[2][MainLoop]=MPt[0];
+      AXPhi[3][MainLoop]=MPt[1];
+      NXPhiFit[2][MainLoop]=MPt[0];
+      NXPhiFit[3][MainLoop]=MPt[1];
+      AXPhiFit[2][MainLoop]=MPt[0];
+      AXPhiFit[3][MainLoop]=MPt[1];
+      
+      NXEta[2][MainLoop]=MPt[0];
+      NXEta[3][MainLoop]=MPt[1];
+      AXEta[2][MainLoop]=MPt[0];
+      AXEta[3][MainLoop]=MPt[1];
+      NXEtaFit[2][MainLoop]=MPt[0];
+      NXEtaFit[3][MainLoop]=MPt[1];
+      AXEtaFit[2][MainLoop]=MPt[0];
+      AXEtaFit[3][MainLoop]=MPt[1];
+
+      NXPhiEta1[2][MainLoop]=MPt[0];
+      NXPhiEta1[3][MainLoop]=MPt[1];
+      NXPhiEta2[2][MainLoop]=MPt[0];
+      NXPhiEta2[3][MainLoop]=MPt[1];
+      AXPhiEta[2][MainLoop]=MPt[0];
+      AXPhiEta[3][MainLoop]=MPt[1];
+
+      if(NXPhi[1][MainLoop]<NXPhi[3][MainLoop]){
+       NXPhi[4][MainLoop]=NXPhi[0][MainLoop];
+       NXPhi[5][MainLoop]=NXPhi[1][MainLoop];
+      }
+      else{
+       NXPhi[4][MainLoop]=NXPhi[2][MainLoop];
+       NXPhi[5][MainLoop]=NXPhi[3][MainLoop];
+      }
+      if(AXPhi[1][MainLoop]<AXPhi[3][MainLoop]){
+       AXPhi[4][MainLoop]=AXPhi[0][MainLoop];
+       AXPhi[5][MainLoop]=AXPhi[1][MainLoop];
+      }
+      else{
+       AXPhi[4][MainLoop]=AXPhi[2][MainLoop];
+       AXPhi[5][MainLoop]=AXPhi[3][MainLoop];
+      }        
+      if(NXPhiFit[1][MainLoop]<NXPhiFit[3][MainLoop]){
+       NXPhiFit[4][MainLoop]=NXPhiFit[0][MainLoop];
+       NXPhiFit[5][MainLoop]=NXPhiFit[1][MainLoop];
+      }
+      else{
+       NXPhiFit[4][MainLoop]=NXPhiFit[2][MainLoop];
+       NXPhiFit[5][MainLoop]=NXPhiFit[3][MainLoop];
+      }
+      if(AXPhiFit[1][MainLoop]<AXPhiFit[3][MainLoop]){
+       AXPhiFit[4][MainLoop]=AXPhiFit[0][MainLoop];
+       AXPhiFit[5][MainLoop]=AXPhiFit[1][MainLoop];
+      }
+      else{
+       AXPhiFit[4][MainLoop]=AXPhiFit[2][MainLoop];
+       AXPhiFit[5][MainLoop]=AXPhiFit[3][MainLoop];
+      }        
+
+      if(NXEta[1][MainLoop]<NXEta[3][MainLoop]){
+       NXEta[4][MainLoop]=NXEta[0][MainLoop];
+       NXEta[5][MainLoop]=NXEta[1][MainLoop];
+      }
+      else{
+       NXEta[4][MainLoop]=NXEta[2][MainLoop];
+       NXEta[5][MainLoop]=NXEta[3][MainLoop];
+      }
+      if(AXEta[1][MainLoop]<AXEta[3][MainLoop]){
+       AXEta[4][MainLoop]=AXEta[0][MainLoop];
+       AXEta[5][MainLoop]=AXEta[1][MainLoop];
+      }
+      else{
+       AXEta[4][MainLoop]=AXEta[2][MainLoop];
+       AXEta[5][MainLoop]=AXEta[3][MainLoop];
+      }        
+      if(NXEtaFit[1][MainLoop]<NXEtaFit[3][MainLoop]){
+       NXEtaFit[4][MainLoop]=NXEtaFit[0][MainLoop];
+       NXEtaFit[5][MainLoop]=NXEtaFit[1][MainLoop];
+      }
+      else{
+       NXEtaFit[4][MainLoop]=NXEtaFit[2][MainLoop];
+       NXEtaFit[5][MainLoop]=NXEtaFit[3][MainLoop];
+      }
+      if(AXEtaFit[1][MainLoop]<AXEtaFit[3][MainLoop]){
+       AXEtaFit[4][MainLoop]=AXEtaFit[0][MainLoop];
+       AXEtaFit[5][MainLoop]=AXEtaFit[1][MainLoop];
+      }
+      else{
+       AXEtaFit[4][MainLoop]=AXEtaFit[2][MainLoop];
+       AXEtaFit[5][MainLoop]=AXEtaFit[3][MainLoop];
+      }        
+
+      
+    }
+    if(APtTPtMult==2){//Centrality so Mult
+      NXPhi[2][MainLoop]=0;
+      NXPhi[3][MainLoop]=0;
+      tempsum=0;
+      for(int multx=(MultArray1[Mult1]+1);multx<(MultArray2[Mult2]+1);multx++){
+       NXPhi[2][MainLoop]+=hMult->GetBinCenter(multx)*(multx-1);
+       NXPhi[3][MainLoop]+=pow(hMult->GetBinError(multx),2);
+       tempsum+=hMult->GetBinCenter(multx);
+      }
+      NXPhi[2][MainLoop]/=tempsum;
+      NXPhi[3][MainLoop]=sqrt(NXPhi[3][MainLoop])/tempsum;
+      AXPhi[2][MainLoop]=NXPhi[2][MainLoop];
+      AXPhi[3][MainLoop]=NXPhi[3][MainLoop];
+      NXPhiFit[2][MainLoop]=NXPhi[2][MainLoop];
+      NXPhiFit[3][MainLoop]=NXPhi[3][MainLoop];
+      AXPhiFit[2][MainLoop]=AXPhi[2][MainLoop];
+      AXPhiFit[3][MainLoop]=AXPhi[3][MainLoop];
+      
+      NXPhiEta1[2][MainLoop]=NXPhi[2][MainLoop];
+      NXPhiEta1[3][MainLoop]=NXPhi[3][MainLoop];
+      NXPhiEta2[2][MainLoop]=NXPhi[2][MainLoop];
+      NXPhiEta2[3][MainLoop]=NXPhi[3][MainLoop];
+      AXPhiEta[2][MainLoop]=NXPhi[2][MainLoop];
+      AXPhiEta[3][MainLoop]=NXPhi[2][MainLoop];
+    }
+    
+  }//Sould end mainloop
+  //right now only finish up normal spectra and zT with assoc/trigger pt maybe do the assoc/near-side pt auch
+  //0 (x1+x2)/2, 1 e2, 2 <x>,  3 e2, 4 lower error of 1 and 2, 5 e3, 6 zt1_0, 7 e5, 8 zt1_2, 9 e7, 10 zt1_3, 11 e9, 12 zt2_0, 13 e11, 14 zt2_1, 15 e13, 16 zt2_2, 17 e15  (zt_0 is (pt1+pt2)/2 zt_1 is <pt> zt_2 is lower error)
+  //0 yield, 1 eyield, 2 pt yield, 3 ept yield, 4 dN/dpt 5 e4 6 dN/dzt (zt=Trig) yield, 7 ezt yield, 8 dN/dzt (zt=near) yield, 9 ezt2 yield
+  if(APtTPtMult==0){
+    if(HorizontalErrors==0){
+      for(int mloop=0;mloop<nMainLoop;mloop++){
+       NXPhi[1][mloop]=0;
+       NXPhi[3][mloop]=0;
+       NXPhi[5][mloop]=0;
+       NXPhi[7][mloop]=0;
+       NXPhi[9][mloop]=0;
+       NXPhi[11][mloop]=0;
+       NXPhi[13][mloop]=0;
+       NXPhi[15][mloop]=0;
+       NXPhi[17][mloop]=0;
+       AXPhi[1][mloop]=0;
+       AXPhi[3][mloop]=0;
+       AXPhi[5][mloop]=0;
+       AXPhi[7][mloop]=0;
+       AXPhi[9][mloop]=0;
+       AXPhi[11][mloop]=0;
+       AXPhi[13][mloop]=0;
+       AXPhi[15][mloop]=0;
+       AXPhi[17][mloop]=0;
+       NXPhiFit[1][mloop]=0;
+       NXPhiFit[3][mloop]=0;
+       NXPhiFit[5][mloop]=0;
+       NXPhiFit[7][mloop]=0;
+       NXPhiFit[9][mloop]=0;
+       NXPhiFit[11][mloop]=0;
+       NXPhiFit[13][mloop]=0;
+       NXPhiFit[15][mloop]=0;
+       NXPhiFit[17][mloop]=0;
+       AXPhiFit[1][mloop]=0;
+       AXPhiFit[3][mloop]=0;
+       AXPhiFit[5][mloop]=0;
+       AXPhiFit[7][mloop]=0;
+       AXPhiFit[9][mloop]=0;
+       AXPhiFit[11][mloop]=0;
+       AXPhiFit[13][mloop]=0;
+       AXPhiFit[15][mloop]=0;
+       AXPhiFit[17][mloop]=0;
+       NXEta[1][mloop]=0;
+       NXEta[3][mloop]=0;
+       NXEta[5][mloop]=0;
+       NXEta[7][mloop]=0;
+       NXEta[9][mloop]=0;
+       NXEta[11][mloop]=0;
+       NXEta[13][mloop]=0;
+       NXEta[15][mloop]=0;
+       NXEta[17][mloop]=0;
+       AXEta[1][mloop]=0;
+       AXEta[3][mloop]=0;
+       AXEta[5][mloop]=0;
+       AXEta[7][mloop]=0;
+       AXEta[9][mloop]=0;
+       AXEta[11][mloop]=0;
+       AXEta[13][mloop]=0;
+       AXEta[15][mloop]=0;
+       AXEta[17][mloop]=0;
+       NXEtaFit[1][mloop]=0;
+       NXEtaFit[3][mloop]=0;
+       NXEtaFit[5][mloop]=0;
+       NXEtaFit[7][mloop]=0;
+       NXEtaFit[9][mloop]=0;
+       NXEtaFit[11][mloop]=0;
+       NXEtaFit[13][mloop]=0;
+       NXEtaFit[15][mloop]=0;
+       NXEtaFit[17][mloop]=0;
+       AXEtaFit[1][mloop]=0;
+       AXEtaFit[3][mloop]=0;
+       AXEtaFit[5][mloop]=0;
+       AXEtaFit[7][mloop]=0;
+       AXEtaFit[9][mloop]=0;
+       AXEtaFit[11][mloop]=0;
+       AXEtaFit[13][mloop]=0;
+       AXEtaFit[15][mloop]=0;
+       AXEtaFit[17][mloop]=0;
+      }
+    }
+    gNPhiSpectraZYAM1=new TGraphErrors(nMainLoop,NXPhi[0],NYieldPhiZYAM[4],NXPhi[1],NYieldPhiZYAM[5]); 
+    gNPhiSpectraZYAM2=new TGraphErrors(nMainLoop,NXPhi[2],NYieldPhiZYAM[4],NXPhi[3],NYieldPhiZYAM[5]); 
+    gNPhiSpectraZYAM3=new TGraphErrors(nMainLoop,NXPhi[4],NYieldPhiZYAM[4],NXPhi[5],NYieldPhiZYAM[5]); 
+    gAPhiSpectraZYAM1=new TGraphErrors(nMainLoop,AXPhi[0],AYieldPhiZYAM[4],AXPhi[1],AYieldPhiZYAM[5]); 
+    gAPhiSpectraZYAM2=new TGraphErrors(nMainLoop,AXPhi[2],AYieldPhiZYAM[4],AXPhi[3],AYieldPhiZYAM[5]); 
+    gAPhiSpectraZYAM3=new TGraphErrors(nMainLoop,AXPhi[4],AYieldPhiZYAM[4],AXPhi[5],AYieldPhiZYAM[5]); 
+
+    gNPhiZt1ZYAM1=new TGraphErrors(nMainLoop,NXPhi[6],NYieldPhiZYAM[6],NXPhi[7],NYieldPhiZYAM[7]); 
+    gNPhiZt1ZYAM2=new TGraphErrors(nMainLoop,NXPhi[8],NYieldPhiZYAM[6],NXPhi[9],NYieldPhiZYAM[7]); 
+    gNPhiZt1ZYAM3=new TGraphErrors(nMainLoop,NXPhi[10],NYieldPhiZYAM[6],NXPhi[11],NYieldPhiZYAM[7]); 
+    gAPhiZt1ZYAM1=new TGraphErrors(nMainLoop,AXPhi[6],AYieldPhiZYAM[6],AXPhi[7],AYieldPhiZYAM[7]); 
+    gAPhiZt1ZYAM2=new TGraphErrors(nMainLoop,AXPhi[8],AYieldPhiZYAM[6],AXPhi[9],AYieldPhiZYAM[7]); 
+    gAPhiZt1ZYAM3=new TGraphErrors(nMainLoop,AXPhi[10],AYieldPhiZYAM[6],AXPhi[11],AYieldPhiZYAM[7]); 
+
+    gNPhiZt2ZYAM1=new TGraphErrors(nMainLoop,NXPhi[12],NYieldPhiZYAM[8],NXPhi[13],NYieldPhiZYAM[9]); 
+    gNPhiZt2ZYAM2=new TGraphErrors(nMainLoop,NXPhi[14],NYieldPhiZYAM[8],NXPhi[15],NYieldPhiZYAM[9]); 
+    gNPhiZt2ZYAM3=new TGraphErrors(nMainLoop,NXPhi[16],NYieldPhiZYAM[8],NXPhi[17],NYieldPhiZYAM[9]); 
+    gAPhiZt2ZYAM1=new TGraphErrors(nMainLoop,AXPhi[12],AYieldPhiZYAM[8],AXPhi[13],AYieldPhiZYAM[9]); 
+    gAPhiZt2ZYAM2=new TGraphErrors(nMainLoop,AXPhi[14],AYieldPhiZYAM[8],AXPhi[15],AYieldPhiZYAM[9]); 
+    gAPhiZt2ZYAM3=new TGraphErrors(nMainLoop,AXPhi[16],AYieldPhiZYAM[8],AXPhi[17],AYieldPhiZYAM[9]); 
+    // cout << "NXPhiFit[2] " << NXPhiFit[2][0] << " " << NXPhiFit[2][1] << endl;
+    gNPhiSpectraFit1=new TGraphErrors(nMainLoop,NXPhiFit[0],NYieldPhiFit[4],NXPhiFit[1],NYieldPhiFit[5]); 
+    gNPhiSpectraFit2=new TGraphErrors(nMainLoop,NXPhiFit[2],NYieldPhiFit[4],NXPhiFit[3],NYieldPhiFit[5]); 
+    gNPhiSpectraFit3=new TGraphErrors(nMainLoop,NXPhiFit[4],NYieldPhiFit[4],NXPhiFit[5],NYieldPhiFit[5]); 
+    gAPhiSpectraFit1=new TGraphErrors(nMainLoop,AXPhiFit[0],AYieldPhiFit[4],AXPhiFit[1],AYieldPhiFit[5]); 
+    gAPhiSpectraFit2=new TGraphErrors(nMainLoop,AXPhiFit[2],AYieldPhiFit[4],AXPhiFit[3],AYieldPhiFit[5]); 
+    gAPhiSpectraFit3=new TGraphErrors(nMainLoop,AXPhiFit[4],AYieldPhiFit[4],AXPhiFit[5],AYieldPhiFit[5]); 
+
+    gNPhiZt1Fit1=new TGraphErrors(nMainLoop,NXPhiFit[6],NYieldPhiFit[6],NXPhiFit[7],NYieldPhiFit[7]); 
+    gNPhiZt1Fit2=new TGraphErrors(nMainLoop,NXPhiFit[8],NYieldPhiFit[6],NXPhiFit[9],NYieldPhiFit[7]); 
+    gNPhiZt1Fit3=new TGraphErrors(nMainLoop,NXPhiFit[10],NYieldPhiFit[6],NXPhiFit[11],NYieldPhiFit[7]); 
+    gAPhiZt1Fit1=new TGraphErrors(nMainLoop,AXPhiFit[6],AYieldPhiFit[6],AXPhiFit[7],AYieldPhiFit[7]); 
+    gAPhiZt1Fit2=new TGraphErrors(nMainLoop,AXPhiFit[8],AYieldPhiFit[6],AXPhiFit[9],AYieldPhiFit[7]); 
+    gAPhiZt1Fit3=new TGraphErrors(nMainLoop,AXPhiFit[10],AYieldPhiFit[6],AXPhiFit[11],AYieldPhiFit[7]); 
+
+    gNPhiWidth1=new TGraphErrors(nMainLoop,NXPhiFit[0],NWidthPhi[0],NXPhiFit[1],NWidthPhi[1]);
+    gNPhiWidth2=new TGraphErrors(nMainLoop,NXPhiFit[2],NWidthPhi[0],NXPhiFit[3],NWidthPhi[1]);
+    gNPhiWidth3=new TGraphErrors(nMainLoop,NXPhiFit[4],NWidthPhi[0],NXPhiFit[5],NWidthPhi[1]);
+    gAPhiWidth1=new TGraphErrors(nMainLoop,AXPhiFit[0],AWidthPhi[0],AXPhiFit[1],AWidthPhi[1]);
+    gAPhiWidth2=new TGraphErrors(nMainLoop,AXPhiFit[2],AWidthPhi[0],AXPhiFit[3],AWidthPhi[1]);
+    gAPhiWidth3=new TGraphErrors(nMainLoop,AXPhiFit[4],AWidthPhi[0],AXPhiFit[5],AWidthPhi[1]);
+
+
+    gNEtaSpectraZYAM1=new TGraphErrors(nMainLoop,NXEta[0],NYieldEtaZYAM[4],NXEta[1],NYieldEtaZYAM[5]); 
+    gNEtaSpectraZYAM2=new TGraphErrors(nMainLoop,NXEta[2],NYieldEtaZYAM[4],NXEta[3],NYieldEtaZYAM[5]); 
+    gNEtaSpectraZYAM3=new TGraphErrors(nMainLoop,NXEta[4],NYieldEtaZYAM[4],NXEta[5],NYieldEtaZYAM[5]); 
+    gAEtaSpectraZYAM1=new TGraphErrors(nMainLoop,AXEta[0],AYieldEtaZYAM[4],AXEta[1],AYieldEtaZYAM[5]); 
+    gAEtaSpectraZYAM2=new TGraphErrors(nMainLoop,AXEta[2],AYieldEtaZYAM[4],AXEta[3],AYieldEtaZYAM[5]); 
+    gAEtaSpectraZYAM3=new TGraphErrors(nMainLoop,AXEta[4],AYieldEtaZYAM[4],AXEta[5],AYieldEtaZYAM[5]); 
+
+    gNEtaZt1ZYAM1=new TGraphErrors(nMainLoop,NXEta[6],NYieldEtaZYAM[6],NXEta[7],NYieldEtaZYAM[7]); 
+    gNEtaZt1ZYAM2=new TGraphErrors(nMainLoop,NXEta[8],NYieldEtaZYAM[6],NXEta[9],NYieldEtaZYAM[7]); 
+    gNEtaZt1ZYAM3=new TGraphErrors(nMainLoop,NXEta[10],NYieldEtaZYAM[6],NXEta[11],NYieldEtaZYAM[7]); 
+    gAEtaZt1ZYAM1=new TGraphErrors(nMainLoop,AXEta[6],AYieldEtaZYAM[6],AXEta[7],AYieldEtaZYAM[7]); 
+    gAEtaZt1ZYAM2=new TGraphErrors(nMainLoop,AXEta[8],AYieldEtaZYAM[6],AXEta[9],AYieldEtaZYAM[7]); 
+    gAEtaZt1ZYAM3=new TGraphErrors(nMainLoop,AXEta[10],AYieldEtaZYAM[6],AXEta[11],AYieldEtaZYAM[7]); 
+
+    gNEtaZt2ZYAM1=new TGraphErrors(nMainLoop,NXEta[12],NYieldEtaZYAM[8],NXEta[13],NYieldEtaZYAM[9]); 
+    gNEtaZt2ZYAM2=new TGraphErrors(nMainLoop,NXEta[14],NYieldEtaZYAM[8],NXEta[15],NYieldEtaZYAM[9]); 
+    gNEtaZt2ZYAM3=new TGraphErrors(nMainLoop,NXEta[16],NYieldEtaZYAM[8],NXEta[17],NYieldEtaZYAM[9]); 
+    gAEtaZt2ZYAM1=new TGraphErrors(nMainLoop,AXEta[12],AYieldEtaZYAM[8],AXEta[13],AYieldEtaZYAM[9]); 
+    gAEtaZt2ZYAM2=new TGraphErrors(nMainLoop,AXEta[14],AYieldEtaZYAM[8],AXEta[15],AYieldEtaZYAM[9]); 
+    gAEtaZt2ZYAM3=new TGraphErrors(nMainLoop,AXEta[16],AYieldEtaZYAM[8],AXEta[17],AYieldEtaZYAM[9]); 
+
+    gNEtaSpectraFit1=new TGraphErrors(nMainLoop,NXEtaFit[0],NYieldEtaFit[4],NXEtaFit[1],NYieldEtaFit[5]); 
+    //cout << "NXEtaFit[2] " << NXEtaFit[2][0] << " " << NXEtaFit[2][1] << endl;
+    gNEtaSpectraFit2=new TGraphErrors(nMainLoop,NXEtaFit[2],NYieldEtaFit[4],NXEtaFit[3],NYieldEtaFit[5]); 
+    gNEtaSpectraFit3=new TGraphErrors(nMainLoop,NXEtaFit[4],NYieldEtaFit[4],NXEtaFit[5],NYieldEtaFit[5]); 
+    gAEtaSpectraFit1=new TGraphErrors(nMainLoop,AXEtaFit[0],AYieldEtaFit[4],AXEtaFit[1],AYieldEtaFit[5]); 
+    gAEtaSpectraFit2=new TGraphErrors(nMainLoop,AXEtaFit[2],AYieldEtaFit[4],AXEtaFit[3],AYieldEtaFit[5]); 
+    gAEtaSpectraFit3=new TGraphErrors(nMainLoop,AXEtaFit[4],AYieldEtaFit[4],AXEtaFit[5],AYieldEtaFit[5]); 
+
+    gNEtaZt1Fit1=new TGraphErrors(nMainLoop,NXEtaFit[6],NYieldEtaFit[6],NXEtaFit[7],NYieldEtaFit[7]); 
+    gNEtaZt1Fit2=new TGraphErrors(nMainLoop,NXEtaFit[8],NYieldEtaFit[6],NXEtaFit[9],NYieldEtaFit[7]); 
+    gNEtaZt1Fit3=new TGraphErrors(nMainLoop,NXEtaFit[10],NYieldEtaFit[6],NXEtaFit[11],NYieldEtaFit[7]); 
+    gAEtaZt1Fit1=new TGraphErrors(nMainLoop,AXEtaFit[6],AYieldEtaFit[6],AXEtaFit[7],AYieldEtaFit[7]); 
+    gAEtaZt1Fit2=new TGraphErrors(nMainLoop,AXEtaFit[8],AYieldEtaFit[6],AXEtaFit[9],AYieldEtaFit[7]); 
+    gAEtaZt1Fit3=new TGraphErrors(nMainLoop,AXEtaFit[10],AYieldEtaFit[6],AXEtaFit[11],AYieldEtaFit[7]); 
+
+    gNEtaWidth1=new TGraphErrors(nMainLoop,NXEtaFit[0],NWidthEta[0],NXEtaFit[1],NWidthEta[1]);
+    gNEtaWidth2=new TGraphErrors(nMainLoop,NXEtaFit[2],NWidthEta[0],NXEtaFit[3],NWidthEta[1]);
+    gNEtaWidth3=new TGraphErrors(nMainLoop,NXEtaFit[4],NWidthEta[0],NXEtaFit[5],NWidthEta[1]);
+  
+    float plotmin=100, plotmax=-100;
+    float plotminW=100,plotmaxW=-100;
+    float plotminZt=100, plotmaxZt=-100;
+    // cout << plotmin << endl;
+    for(int i=4;i<=8;i+=2){
+      for(int j=0;j<nMainLoop;j++){
+       if(NYieldPhiZYAM[i][j]<plotmin&&NYieldPhiZYAM[i][j]>0)plotmin=NYieldPhiZYAM[i][j];
+       if(NYieldPhiZYAM[i][j]>plotmax&&NYieldPhiZYAM[i][j]>0)plotmax=NYieldPhiZYAM[i][j];
+       if(AYieldPhiZYAM[i][j]<plotmin&&AYieldPhiZYAM[i][j]>0)plotmin=AYieldPhiZYAM[i][j];
+       if(AYieldPhiZYAM[i][j]>plotmax&&AYieldPhiZYAM[i][j]>0)plotmax=AYieldPhiZYAM[i][j];
+       if(NYieldEtaZYAM[i][j]<plotmin&&NYieldEtaZYAM[i][j]>0)plotmin=NYieldEtaZYAM[i][j];
+       if(NYieldEtaZYAM[i][j]>plotmax&&NYieldEtaZYAM[i][j]>0)plotmax=NYieldEtaZYAM[i][j];
+       if(AYieldEtaZYAM[i][j]<plotmin&&AYieldEtaZYAM[i][j]>0)plotmin=AYieldEtaZYAM[i][j];
+       if(AYieldEtaZYAM[i][j]>plotmax&&AYieldEtaZYAM[i][j]>0)plotmax=AYieldEtaZYAM[i][j];
+       
+       if(i==6){
+         if(NYieldPhiZYAM[i][j]<plotminZt&&NYieldPhiZYAM[i][j]>0)plotminZt=NYieldPhiZYAM[i][j];
+         if(NYieldPhiZYAM[i][j]>plotmaxZt&&NYieldPhiZYAM[i][j]>0)plotmaxZt=NYieldPhiZYAM[i][j];
+         if(AYieldPhiZYAM[i][j]<plotminZt&&AYieldPhiZYAM[i][j]>0)plotminZt=AYieldPhiZYAM[i][j];
+         if(AYieldPhiZYAM[i][j]>plotmaxZt&&AYieldPhiZYAM[i][j]>0)plotmaxZt=AYieldPhiZYAM[i][j];
+         /*
+         if(NYieldEtaZYAM[i][j]<plotminZt&&NYieldEtaZYAM[i][j]>0)plotminZt=NYieldEtaZYAM[i][j];
+         if(NYieldEtaZYAM[i][j]>plotmaxZt&&NYieldEtaZYAM[i][j]>0)plotmaxZt=NYieldEtaZYAM[i][j];
+         if(AYieldEtaZYAM[i][j]<plotminZt&&AYieldEtaZYAM[i][j]>0)plotminZt=AYieldEtaZYAM[i][j];
+         if(AYieldEtaZYAM[i][j]>plotmaxZt&&AYieldEtaZYAM[i][j]>0)plotmaxZt=AYieldEtaZYAM[i][j];
+         */
+       }
+
+       if(DrawFit){
+         if(NYieldPhiFit[i][j]<plotmin&&NYieldPhiFit[i][j]>0)plotmin=NYieldPhiFit[i][j];
+         if(NYieldPhiFit[i][j]>plotmax&&NYieldPhiFit[i][j]>0)plotmax=NYieldPhiFit[i][j];
+         if(AYieldPhiFit[i][j]<plotmin&&AYieldPhiFit[i][j]>0)plotmin=AYieldPhiFit[i][j];
+         if(AYieldPhiFit[i][j]>plotmax&&AYieldPhiFit[i][j]>0)plotmax=AYieldPhiFit[i][j];
+       }
+       if(i==4){
+         if(NWidthPhi[0][j]<plotminW)plotminW=NWidthPhi[0][j];
+         if(NWidthPhi[0][j]>plotmaxW&&NWidthPhi[0][j]<5)plotmaxW=NWidthPhi[0][j];
+         if(AWidthPhi[0][j]<plotminW)plotminW=AWidthPhi[0][j];
+         if(AWidthPhi[0][j]>plotmaxW&&AWidthPhi[0][j]<5)plotmaxW=AWidthPhi[0][j];
+         if(NWidthEta[0][j]<plotminW)plotminW=NWidthEta[0][j];
+         if(NWidthEta[0][j]>plotmaxW&&NWidthEta[0][j]<5)plotmaxW=NWidthEta[0][j];
+       }
+      }
+    }
+    plotmin/=2;
+    plotmax*=100+1;
+    plotminZt/=2;
+    plotmaxZt*=2.2;
+    //cout << plotmin << endl;
+    //if(plotmin<=0)plotmin=0.0001;
+    plotminW=0;
+    plotmaxW*=1.1;
+    plotmaxW=1;
+
+    gNPhiSpectraZYAM1->SetMarkerStyle(MarkerNearPhi);
+    gNPhiSpectraZYAM1->SetMarkerSize(MarkerSize);
+    gNPhiSpectraZYAM1->SetMarkerColor(ColorNearPhi);
+    gNPhiSpectraZYAM1->SetLineColor(ColorNearPhi);
+    gNPhiSpectraZYAM2->SetMarkerStyle(MarkerNearPhi);
+    gNPhiSpectraZYAM2->SetMarkerSize(MarkerSize);
+    gNPhiSpectraZYAM2->SetMarkerColor(ColorNearPhi);
+    gNPhiSpectraZYAM2->SetLineColor(ColorNearPhi);
+    gNPhiSpectraZYAM3->SetMarkerStyle(MarkerNearPhi);
+    gNPhiSpectraZYAM3->SetMarkerSize(MarkerSize);
+    gNPhiSpectraZYAM3->SetMarkerColor(ColorNearPhi);
+    gNPhiSpectraZYAM3->SetLineColor(ColorNearPhi);
+    gNPhiZt1ZYAM1->SetMarkerStyle(MarkerNearPhi);
+    gNPhiZt1ZYAM1->SetMarkerSize(MarkerSize);
+    gNPhiZt1ZYAM1->SetLineColor(ColorNearPhi);
+    gNPhiZt1ZYAM1->SetMarkerColor(ColorNearPhi);
+    gNPhiZt1ZYAM2->SetMarkerStyle(MarkerNearPhi);
+    gNPhiZt1ZYAM2->SetMarkerSize(MarkerSize);
+    gNPhiZt1ZYAM2->SetLineColor(ColorNearPhi);
+    gNPhiZt1ZYAM2->SetMarkerColor(ColorNearPhi);
+    gNPhiZt1ZYAM3->SetMarkerStyle(MarkerNearPhi);
+    gNPhiZt1ZYAM3->SetMarkerSize(MarkerSize);
+    gNPhiZt1ZYAM3->SetLineColor(ColorNearPhi);
+    gNPhiZt1ZYAM3->SetMarkerColor(ColorNearPhi);
+    gNPhiZt2ZYAM3->SetMarkerStyle(MarkerNearPhi);
+    gNPhiZt2ZYAM3->SetMarkerSize(MarkerSize);
+    gNPhiZt2ZYAM1->SetLineColor(ColorNearPhi);
+    gNPhiZt2ZYAM1->SetMarkerColor(ColorNearPhi);
+    gNPhiZt2ZYAM2->SetMarkerStyle(MarkerNearPhi);
+    gNPhiZt2ZYAM2->SetMarkerSize(MarkerSize);
+    gNPhiZt2ZYAM2->SetLineColor(ColorNearPhi);
+    gNPhiZt2ZYAM2->SetMarkerColor(ColorNearPhi);
+    gNPhiZt2ZYAM3->SetMarkerStyle(MarkerNearPhi);
+    gNPhiZt2ZYAM3->SetMarkerSize(MarkerSize);
+    gNPhiZt2ZYAM3->SetLineColor(ColorNearPhi);
+    gNPhiZt2ZYAM3->SetMarkerColor(ColorNearPhi);
+
+    gAPhiSpectraZYAM1->SetMarkerStyle(MarkerAwayPhi);
+    gAPhiSpectraZYAM1->SetMarkerSize(MarkerSize);
+    gAPhiSpectraZYAM1->SetMarkerColor(ColorAwayPhi);
+    gAPhiSpectraZYAM1->SetLineColor(ColorAwayPhi);
+    gAPhiSpectraZYAM2->SetMarkerStyle(MarkerAwayPhi);
+    gAPhiSpectraZYAM2->SetMarkerSize(MarkerSize);
+    gAPhiSpectraZYAM2->SetMarkerColor(ColorAwayPhi);
+    gAPhiSpectraZYAM2->SetLineColor(ColorAwayPhi);
+    gAPhiSpectraZYAM3->SetMarkerStyle(MarkerAwayPhi);
+    gAPhiSpectraZYAM3->SetMarkerSize(MarkerSize);
+    gAPhiSpectraZYAM3->SetMarkerColor(ColorAwayPhi);
+    gAPhiSpectraZYAM3->SetLineColor(ColorAwayPhi);
+    gAPhiZt1ZYAM1->SetMarkerStyle(MarkerAwayPhi);
+    gAPhiZt1ZYAM1->SetMarkerSize(MarkerSize);
+    gAPhiZt1ZYAM1->SetLineColor(ColorAwayPhi);
+    gAPhiZt1ZYAM1->SetMarkerColor(ColorAwayPhi);
+    gAPhiZt1ZYAM2->SetMarkerStyle(MarkerAwayPhi);
+    gAPhiZt1ZYAM2->SetMarkerSize(MarkerSize);
+    gAPhiZt1ZYAM2->SetLineColor(ColorAwayPhi);
+    gAPhiZt1ZYAM2->SetMarkerColor(ColorAwayPhi);
+    gAPhiZt1ZYAM3->SetMarkerStyle(MarkerAwayPhi);
+    gAPhiZt1ZYAM3->SetMarkerSize(MarkerSize);
+    gAPhiZt1ZYAM3->SetLineColor(ColorAwayPhi);
+    gAPhiZt1ZYAM3->SetMarkerColor(ColorAwayPhi);
+    gAPhiZt2ZYAM3->SetMarkerStyle(MarkerAwayPhi);
+    gAPhiZt2ZYAM3->SetMarkerSize(MarkerSize);
+    gAPhiZt2ZYAM1->SetLineColor(ColorAwayPhi);
+    gAPhiZt2ZYAM1->SetMarkerColor(ColorAwayPhi);
+    gAPhiZt2ZYAM2->SetMarkerStyle(MarkerAwayPhi);
+    gAPhiZt2ZYAM2->SetMarkerSize(MarkerSize);
+    gAPhiZt2ZYAM2->SetLineColor(ColorAwayPhi);
+    gAPhiZt2ZYAM2->SetMarkerColor(ColorAwayPhi);
+    gAPhiZt2ZYAM3->SetMarkerStyle(MarkerAwayPhi);
+    gAPhiZt2ZYAM3->SetMarkerSize(MarkerSize);
+    gAPhiZt2ZYAM3->SetLineColor(ColorAwayPhi);
+    gAPhiZt2ZYAM3->SetMarkerColor(ColorAwayPhi);
+
+    gNPhiSpectraFit1->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiSpectraFit1->SetMarkerSize(MarkerSize);
+    gNPhiSpectraFit1->SetMarkerColor(ColorNearPhiFit);
+    gNPhiSpectraFit1->SetLineColor(ColorNearPhiFit);
+    gNPhiSpectraFit2->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiSpectraFit2->SetMarkerSize(MarkerSize);
+    gNPhiSpectraFit2->SetMarkerColor(ColorNearPhiFit);
+    gNPhiSpectraFit2->SetLineColor(ColorNearPhiFit);
+    gNPhiSpectraFit3->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiSpectraFit3->SetMarkerSize(MarkerSize);
+    gNPhiSpectraFit3->SetMarkerColor(ColorNearPhiFit);
+    gNPhiSpectraFit3->SetLineColor(ColorNearPhiFit);
+    gNPhiZt1Fit1->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiZt1Fit1->SetMarkerSize(MarkerSize);
+    gNPhiZt1Fit1->SetLineColor(ColorNearPhiFit);
+    gNPhiZt1Fit1->SetMarkerColor(ColorNearPhiFit);
+    gNPhiZt1Fit2->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiZt1Fit2->SetMarkerSize(MarkerSize);
+    gNPhiZt1Fit2->SetLineColor(ColorNearPhiFit);
+    gNPhiZt1Fit2->SetMarkerColor(ColorNearPhiFit);
+    gNPhiZt1Fit3->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiZt1Fit3->SetMarkerSize(MarkerSize);
+    gNPhiZt1Fit3->SetLineColor(ColorNearPhiFit);
+    gNPhiZt1Fit3->SetMarkerColor(ColorNearPhiFit);
+    /*
+      gNPhiZt2Fit3->SetMarkerStyle(24);
+      gNPhiZt2Fit1->SetLineColor(kBlue+3);
+      gNPhiZt2Fit1->SetMarkerColor(kBlue+3);
+      gNPhiZt2Fit2->SetMarkerStyle(24);
+      gNPhiZt2Fit2->SetLineColor(kBlue+3);
+      gNPhiZt2Fit2->SetMarkerColor(kBlue+3);
+      gNPhiZt2Fit3->SetMarkerStyle(24);
+      gNPhiZt2Fit3->SetLineColor(kBlue+3);
+      gNPhiZt2Fit3->SetMarkerColor(kBlue+3);
+    */
+    gAPhiSpectraFit1->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiSpectraFit1->SetMarkerSize(MarkerSize);
+    gAPhiSpectraFit1->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiSpectraFit1->SetLineColor(ColorAwayPhiFit);
+    gAPhiSpectraFit2->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiSpectraFit2->SetMarkerSize(MarkerSize);
+    gAPhiSpectraFit2->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiSpectraFit2->SetLineColor(ColorAwayPhiFit);
+    gAPhiSpectraFit3->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiSpectraFit3->SetMarkerSize(MarkerSize);
+    gAPhiSpectraFit3->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiSpectraFit3->SetLineColor(ColorAwayPhiFit);
+    gAPhiZt1Fit1->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiZt1Fit1->SetMarkerSize(MarkerSize);
+    gAPhiZt1Fit1->SetLineColor(ColorAwayPhiFit);
+    gAPhiZt1Fit1->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiZt1Fit2->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiZt1Fit2->SetMarkerSize(MarkerSize);
+    gAPhiZt1Fit2->SetLineColor(ColorAwayPhiFit);
+    gAPhiZt1Fit2->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiZt1Fit3->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiZt1Fit3->SetMarkerSize(MarkerSize);
+    gAPhiZt1Fit3->SetLineColor(ColorAwayPhiFit);
+    gAPhiZt1Fit3->SetMarkerColor(ColorAwayPhiFit);
+    /*
+      gAPhiZt2Fit3->SetMarkerStyle(25);
+      gAPhiZt2Fit1->SetLineColor(kRed+2);
+      gAPhiZt2Fit1->SetMarkerColor(kRed+2);
+      gAPhiZt2Fit2->SetMarkerStyle(25);
+      gAPhiZt2Fit2->SetLineColor(kRed+2);
+      gAPhiZt2Fit2->SetMarkerColor(kRed+2);
+      gAPhiZt2Fit3->SetMarkerStyle(25);
+      gAPhiZt2Fit3->SetLineColor(kRed+2);
+      gAPhiZt2Fit3->SetMarkerColor(kRed+2);
+    */
+  
+    gNPhiWidth1->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiWidth1->SetMarkerSize(MarkerSize);
+    gNPhiWidth1->SetMarkerColor(ColorNearPhiFit);
+    gNPhiWidth1->SetLineColor(ColorNearPhiFit);
+    gNPhiWidth2->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiWidth2->SetMarkerSize(MarkerSize);
+    gNPhiWidth2->SetMarkerColor(ColorNearPhiFit);
+    gNPhiWidth2->SetLineColor(ColorNearPhiFit);
+    gNPhiWidth3->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiWidth3->SetMarkerSize(MarkerSize);
+    gNPhiWidth3->SetMarkerColor(ColorNearPhiFit);
+    gNPhiWidth3->SetLineColor(ColorNearPhiFit);
+
+    gAPhiWidth1->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiWidth1->SetMarkerSize(MarkerSize);
+    gAPhiWidth1->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiWidth1->SetLineColor(ColorAwayPhiFit);
+    gAPhiWidth2->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiWidth2->SetMarkerSize(MarkerSize);
+    gAPhiWidth2->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiWidth2->SetLineColor(ColorAwayPhiFit);
+    gAPhiWidth3->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiWidth3->SetMarkerSize(MarkerSize);
+    gAPhiWidth3->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiWidth3->SetLineColor(ColorAwayPhiFit);
+
+
+    gNEtaSpectraZYAM1->SetMarkerStyle(MarkerNearEta);
+    gNEtaSpectraZYAM1->SetMarkerSize(MarkerSize);
+    gNEtaSpectraZYAM1->SetMarkerColor(ColorNearEta);
+    gNEtaSpectraZYAM1->SetLineColor(ColorNearEta);
+    gNEtaSpectraZYAM2->SetMarkerStyle(MarkerNearEta);
+    gNEtaSpectraZYAM2->SetMarkerSize(MarkerSize);
+    gNEtaSpectraZYAM2->SetMarkerColor(ColorNearEta);
+    gNEtaSpectraZYAM2->SetLineColor(ColorNearEta);
+    gNEtaSpectraZYAM3->SetMarkerStyle(MarkerNearEta);
+    gNEtaSpectraZYAM3->SetMarkerSize(MarkerSize);
+    gNEtaSpectraZYAM3->SetMarkerColor(ColorNearEta);
+    gNEtaSpectraZYAM3->SetLineColor(ColorNearEta);
+    gNEtaZt1ZYAM1->SetMarkerStyle(MarkerNearEta);
+    gNEtaZt1ZYAM1->SetMarkerSize(MarkerSize);
+    gNEtaZt1ZYAM1->SetLineColor(ColorNearEta);
+    gNEtaZt1ZYAM1->SetMarkerColor(ColorNearEta);
+    gNEtaZt1ZYAM2->SetMarkerStyle(MarkerNearEta);
+    gNEtaZt1ZYAM2->SetMarkerSize(MarkerSize);
+    gNEtaZt1ZYAM2->SetLineColor(ColorNearEta);
+    gNEtaZt1ZYAM2->SetMarkerColor(ColorNearEta);
+    gNEtaZt1ZYAM3->SetMarkerStyle(MarkerNearEta);
+    gNEtaZt1ZYAM3->SetMarkerSize(MarkerSize);
+    gNEtaZt1ZYAM3->SetLineColor(ColorNearEta);
+    gNEtaZt1ZYAM3->SetMarkerColor(ColorNearEta);
+    gNEtaZt2ZYAM3->SetMarkerStyle(MarkerNearEta);
+    gNEtaZt2ZYAM3->SetMarkerSize(MarkerSize);
+    gNEtaZt2ZYAM1->SetLineColor(ColorNearEta);
+    gNEtaZt2ZYAM1->SetMarkerColor(ColorNearEta);
+    gNEtaZt2ZYAM2->SetMarkerStyle(MarkerNearEta);
+    gNEtaZt2ZYAM2->SetMarkerSize(MarkerSize);
+    gNEtaZt2ZYAM2->SetLineColor(ColorNearEta);
+    gNEtaZt2ZYAM2->SetMarkerColor(ColorNearEta);
+    gNEtaZt2ZYAM3->SetMarkerStyle(MarkerNearEta);
+    gNEtaZt2ZYAM3->SetMarkerSize(MarkerSize);
+    gNEtaZt2ZYAM3->SetLineColor(ColorNearEta);
+    gNEtaZt2ZYAM3->SetMarkerColor(ColorNearEta);
+
+    gAEtaSpectraZYAM1->SetMarkerStyle(MarkerAwayEta);
+    gAEtaSpectraZYAM1->SetMarkerSize(MarkerSize);
+    gAEtaSpectraZYAM1->SetMarkerColor(ColorAwayEta);
+    gAEtaSpectraZYAM1->SetLineColor(ColorAwayEta);
+    gAEtaSpectraZYAM2->SetMarkerStyle(MarkerAwayEta);
+    gAEtaSpectraZYAM2->SetMarkerSize(MarkerSize);
+    gAEtaSpectraZYAM2->SetMarkerColor(ColorAwayEta);
+    gAEtaSpectraZYAM2->SetLineColor(ColorAwayEta);
+    gAEtaSpectraZYAM3->SetMarkerStyle(MarkerAwayEta);
+    gAEtaSpectraZYAM3->SetMarkerSize(MarkerSize);
+    gAEtaSpectraZYAM3->SetMarkerColor(ColorAwayEta);
+    gAEtaSpectraZYAM3->SetLineColor(ColorAwayEta);
+    gAEtaZt1ZYAM1->SetMarkerStyle(MarkerAwayEta);
+    gAEtaZt1ZYAM1->SetMarkerSize(MarkerSize);
+    gAEtaZt1ZYAM1->SetLineColor(ColorAwayEta);
+    gAEtaZt1ZYAM1->SetMarkerColor(ColorAwayEta);
+    gAEtaZt1ZYAM2->SetMarkerStyle(MarkerAwayEta);
+    gAEtaZt1ZYAM2->SetMarkerSize(MarkerSize);
+    gAEtaZt1ZYAM2->SetLineColor(ColorAwayEta);
+    gAEtaZt1ZYAM2->SetMarkerColor(ColorAwayEta);
+    gAEtaZt1ZYAM3->SetMarkerStyle(MarkerAwayEta);
+    gAEtaZt1ZYAM3->SetMarkerSize(MarkerSize);
+    gAEtaZt1ZYAM3->SetLineColor(ColorAwayEta);
+    gAEtaZt1ZYAM3->SetMarkerColor(ColorAwayEta);
+    gAEtaZt2ZYAM3->SetMarkerStyle(MarkerAwayEta);
+    gAEtaZt2ZYAM3->SetMarkerSize(MarkerSize);
+    gAEtaZt2ZYAM1->SetLineColor(ColorAwayEta);
+    gAEtaZt2ZYAM1->SetMarkerColor(ColorAwayEta);
+    gAEtaZt2ZYAM2->SetMarkerStyle(MarkerAwayEta);
+    gAEtaZt2ZYAM2->SetMarkerSize(MarkerSize);
+    gAEtaZt2ZYAM2->SetLineColor(ColorAwayEta);
+    gAEtaZt2ZYAM2->SetMarkerColor(ColorAwayEta);
+    gAEtaZt2ZYAM3->SetMarkerStyle(MarkerAwayEta);
+    gAEtaZt2ZYAM3->SetMarkerSize(MarkerSize);
+    gAEtaZt2ZYAM3->SetLineColor(ColorAwayEta);
+    gAEtaZt2ZYAM3->SetMarkerColor(ColorAwayEta);
+
+    gNEtaSpectraFit1->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaSpectraFit1->SetMarkerSize(MarkerSize);
+    gNEtaSpectraFit1->SetMarkerColor(ColorNearEtaFit);
+    gNEtaSpectraFit1->SetLineColor(ColorNearEtaFit);
+    gNEtaSpectraFit2->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaSpectraFit2->SetMarkerSize(MarkerSize);
+    gNEtaSpectraFit2->SetMarkerColor(ColorNearEtaFit);
+    gNEtaSpectraFit2->SetLineColor(ColorNearEtaFit);
+    gNEtaSpectraFit3->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaSpectraFit3->SetMarkerSize(MarkerSize);
+    gNEtaSpectraFit3->SetMarkerColor(ColorNearEtaFit);
+    gNEtaSpectraFit3->SetLineColor(ColorNearEtaFit);
+    gNEtaZt1Fit1->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaZt1Fit1->SetMarkerSize(MarkerSize);
+    gNEtaZt1Fit1->SetLineColor(ColorNearEtaFit);
+    gNEtaZt1Fit1->SetMarkerColor(ColorNearEtaFit);
+    gNEtaZt1Fit2->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaZt1Fit2->SetMarkerSize(MarkerSize);
+    gNEtaZt1Fit2->SetLineColor(ColorNearEtaFit);
+    gNEtaZt1Fit2->SetMarkerColor(ColorNearEtaFit);
+    gNEtaZt1Fit3->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaZt1Fit3->SetMarkerSize(MarkerSize);
+    gNEtaZt1Fit3->SetLineColor(ColorNearEtaFit);
+    gNEtaZt1Fit3->SetMarkerColor(ColorNearEtaFit);
+
+    gNEtaWidth1->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaWidth1->SetMarkerSize(MarkerSize);
+    gNEtaWidth1->SetMarkerColor(ColorNearEtaFit);
+    gNEtaWidth1->SetLineColor(ColorNearEtaFit);
+    gNEtaWidth2->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaWidth2->SetMarkerSize(MarkerSize);
+    gNEtaWidth2->SetMarkerColor(ColorNearEtaFit);
+    gNEtaWidth2->SetLineColor(ColorNearEtaFit);
+    gNEtaWidth3->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaWidth3->SetMarkerSize(MarkerSize);
+    gNEtaWidth3->SetMarkerColor(ColorNearEtaFit);
+    gNEtaWidth3->SetLineColor(ColorNearEtaFit);
+
+  
+    sprintf(outName,"%s/DrawSpectra_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_%d%s.root",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,APtTPtMult,FitTit[DrawFit]);
+    TFile *fout=new TFile(name,"recreate");
+
+
+    cSpectraZYAM1=new TCanvas("cSpectraZYAM1","Spectra MidPoint",800,600);
+    SetMargins1D(cSpectraZYAM1);
+    sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hSpectraZYAM1=new TH2F("hSpectraZYAM1",name,10,0,TPt1,10,plotmin,plotmax);
+    if(NoTitle)hSpectraZYAM1->SetTitle("");
+    hSpectraZYAM1->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
+    hSpectraZYAM1->GetXaxis()->SetTitleColor(1);
+    hSpectraZYAM1->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
+    SetTitles1D(hSpectraZYAM1);
+    hSpectraZYAM1->Draw();
+    cSpectraZYAM1->SetLogy(1);
+    gNPhiSpectraZYAM1->Draw("p");
+    gAPhiSpectraZYAM1->Draw("p");
+    if(DrawFit)gNPhiSpectraFit1->Draw("p");
+    if(DrawFit)gAPhiSpectraFit1->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_SpectraMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cSpectraZYAM1->SaveAs(outName);
+
+    cSpectraZYAM2=new TCanvas("cSpectraZYAM2","Spectra Average",800,600);
+    SetMargins1D(cSpectraZYAM2);
+    sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hSpectraZYAM2=new TH2F("hSpectraZYAM2",name,10,0,TPt1,10,plotmin,plotmax);
+    if(NoTitle)hSpectraZYAM2->SetTitle("");
+    hSpectraZYAM2->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
+    hSpectraZYAM2->GetXaxis()->SetTitleColor(1);
+    hSpectraZYAM2->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
+    SetTitles1D(hSpectraZYAM2);
+    hSpectraZYAM2->Draw();
+    cSpectraZYAM2->SetLogy(1);
+    gNPhiSpectraZYAM2->Draw("p");
+    gAPhiSpectraZYAM2->Draw("p");
+    if(DrawFit)gNPhiSpectraFit2->Draw("p");
+    if(DrawFit)gAPhiSpectraFit2->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_SpectraAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cSpectraZYAM2->SaveAs(outName);
+
+    cSpectraZYAM3=new TCanvas("cSpectraZYAM3","Spectra Lowest Error",800,600);
+    SetMargins1D(cSpectraZYAM3);
+    sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hSpectraZYAM3=new TH2F("hSpectraZYAM3",name,10,0,TPt1,10,plotmin,plotmax);
+    if(NoTitle)hSpectraZYAM3->SetTitle("");
+    hSpectraZYAM3->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
+    hSpectraZYAM3->GetXaxis()->SetTitleColor(1);
+    hSpectraZYAM3->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
+    SetTitles1D(hSpectraZYAM3);
+    hSpectraZYAM3->Draw();
+    cSpectraZYAM3->SetLogy(1);
+    gNPhiSpectraZYAM3->Draw("p");
+    gAPhiSpectraZYAM3->Draw("p");
+    if(DrawFit)gNPhiSpectraFit3->Draw("p");
+    if(DrawFit)gAPhiSpectraFit3->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_SpectraLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cSpectraZYAM3->SaveAs(outName);
+
+    cZt1ZYAM1=new TCanvas("cZt1ZYAM1","Zt Spectra MidPoint",800,600);
+    SetMargins1D(cZt1ZYAM1);
+    sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt1ZYAM1=new TH2F("hZt1ZYAM1",name,10,0,1,10,plotminZt,plotmaxZt);
+    if(NoTitle)hZt1ZYAM1->SetTitle("");
+    hZt1ZYAM1->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig}  ");
+    hZt1ZYAM1->GetXaxis()->SetTitleColor(1);
+    hZt1ZYAM1->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt1ZYAM1);
+    hZt1ZYAM1->Draw();
+    cZt1ZYAM1->SetLogy(1);
+    gNPhiZt1ZYAM1->Draw("p");
+    gAPhiZt1ZYAM1->Draw("p");
+    if(DrawFit)gNPhiZt1Fit1->Draw("p");
+    if(DrawFit)gAPhiZt1Fit1->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt1ZYAM1->SaveAs(outName);
+
+    cZt1ZYAM2=new TCanvas("cZt1ZYAM2","Zt Spectra Average",800,600);
+    SetMargins1D(cZt1ZYAM2);
+    sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt1ZYAM2=new TH2F("hZt1ZYAM2",name,10,0,1,10,plotminZt,plotmaxZt);
+    if(NoTitle)hZt1ZYAM2->SetTitle("");
+    hZt1ZYAM2->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig}  ");
+    hZt1ZYAM2->GetXaxis()->SetTitleColor(1);
+    hZt1ZYAM2->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt1ZYAM2);
+    hZt1ZYAM2->Draw();
+    cZt1ZYAM2->SetLogy(1);
+    gNPhiZt1ZYAM2->Draw("p");
+    gAPhiZt1ZYAM2->Draw("p");
+    if(DrawFit)gNPhiZt1Fit2->Draw("p");
+    if(DrawFit)gAPhiZt1Fit2->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt1ZYAM2->SaveAs(outName);
+
+    cZt1ZYAM3=new TCanvas("cZt1ZYAM3","Zt Spectra Lowest Error",800,600);
+    SetMargins1D(cZt1ZYAM3);
+    sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt1ZYAM3=new TH2F("hZt1ZYAM3",name,10,0,1,10,plotminZt,plotmaxZt);
+    if(NoTitle)hZt1ZYAM3->SetTitle("");
+    hZt1ZYAM3->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
+    hZt1ZYAM3->GetXaxis()->SetTitleColor(1);
+    hZt1ZYAM3->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt1ZYAM3);
+    hZt1ZYAM3->Draw();
+    cZt1ZYAM3->SetLogy(1);
+    gNPhiZt1ZYAM3->Draw("p");
+    gAPhiZt1ZYAM3->Draw("p");
+    if(DrawFit)gNPhiZt1Fit3->Draw("p");
+    if(DrawFit)gAPhiZt1Fit3->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt1ZYAM3->SaveAs(outName);
+  
+    /*
+      cZt2ZYAM1=new TCanvas("cZt2ZYAM1","Spectra MidPoint",800,600);
+      SetMargins1D(cZt2ZYAM1);
+      sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+      if(NoTitle)name="";
+      TH2F *hZt2ZYAM1=new TH2F("hZt2ZYAM1",name,10,0,1,10,plotmin,plotmax);
+      hZt2ZYAM1->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Near}  ");
+      hZt2ZYAM1->GetXaxis()->SetTitleColor(1);
+      hZt2ZYAM1->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+      hZt2ZYAM1->Draw();
+      cZt2ZYAM1->SetLogy(1);
+      gNPhiZt2ZYAM1->Draw("p");
+      gAPhiZt2ZYAM1->Draw("p");
+      gNPhiZt2Fit1->Draw("p");
+      gAPhiZt2Fit1->Draw("p");
+      sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+      keySymbol(.65,.85,name,1,20,0.06,1.5);
+      keySymbol(.65,.8,"Away",2,21,0.06,1.5);
+      keySymbol(.65,.75,"Near Fit",kBlue+3,24,0.06,1.5);
+      keySymbol(.65,.7,"Away Fit",kRed+2,25,0.06,1.5);
+      sprintf(outName,"%s/DrawSpectra_ZtNearMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,APtTPtMult);
+      cZt2ZYAM1->SaveAs(outName);
+
+      cZt2ZYAM2=new TCanvas("cZt2ZYAM2","Spectra Average",800,600);
+      SetMargins1D(cZt2ZYAM2);
+      sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+      if(NoTitle)name="";
+      TH2F *hZt2ZYAM2=new TH2F("hZt2ZYAM2",name,10,0,1,10,plotmin,plotmax);
+      hZt2ZYAM2->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Near} (GeV/c) ");
+      hZt2ZYAM2->GetXaxis()->SetTitleColor(1);
+      hZt2ZYAM2->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+      hZt2ZYAM2->Draw();
+      cZt2ZYAM2->SetLogy(1);
+      gNPhiZt2ZYAM2->Draw("p");
+      gAPhiZt2ZYAM2->Draw("p");
+      gNPhiZt2Fit2->Draw("p");
+      gAPhiZt2Fit2->Draw("p");
+      sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+      keySymbol(.65,.85,name,1,20,0.06,1.5);
+      keySymbol(.65,.8,"Away",2,21,0.06,1.5);
+      keySymbol(.65,.75,"Near Fit",kBlue+3,24,0.06,1.5);
+      keySymbol(.65,.7,"Away Fit",kRed+2,25,0.06,1.5);
+      sprintf(outName,"%s/DrawSpectra_ZtNearAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,APtTPtMult);
+      cZt2ZYAM2->SaveAs(outName);
+
+      cZt2ZYAM3=new TCanvas("cZt2ZYAM3","Spectra Lowest Error",800,600);
+      SetMargins1D(cZt2ZYAM3);
+      sprintf(name,"Associated Particle Z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+      if(NoTitle)name="";
+      TH2F *hZt2ZYAM3=new TH2F("hZt2ZYAM3",name,10,0,1,10,plotmin,plotmax);
+      hZt2ZYAM3->GetXaxis()->SetTitle("p_{T}^{Assoc}/p_{T}^{Near} (GeV/c) ");
+      hZt2ZYAM3->GetXaxis()->SetTitleColor(1);
+      hZt2ZYAM3->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+      hZt2ZYAM3->Draw();
+      cZt2ZYAM3->SetLogy(1);
+      gNPhiZt2ZYAM3->Draw("p");
+      gAPhiZt2ZYAM3->Draw("p");
+      gNPhiZt2Fit3->Draw("p");
+      gAPhiZt2Fit3->Draw("p");
+      sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+      keySymbol(.65,.85,name,1,20,0.06,1.5);
+      keySymbol(.65,.8,"Away",2,21,0.06,1.5);
+      keySymbol(.65,.75,"Near Fit",kBlue+3,24,0.06,1.5);
+      keySymbol(.65,.7,"Away Fit",kRed+2,25,0.06,1.5);
+      sprintf(outName,"%s/DrawSpectra_ZtNearLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,APtTPtMult);
+      cZt2ZYAM3->SaveAs(outName);
+  
+    */
+
+    cSpectraZYAM1E=new TCanvas("cSpectraZYAM1E","Spectra MidPoint",800,600);
+    SetMargins1D(cSpectraZYAM1E);
+    sprintf(name,"Associated Particle Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hSpectraZYAM1E=new TH2F("hSpectraZYAM1E",name,10,0,TPt1,10,plotmin,plotmax);
+    if(NoTitle)hSpectraZYAM1E->SetTitle("");
+    hSpectraZYAM1E->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
+    hSpectraZYAM1E->GetXaxis()->SetTitleColor(1);
+    hSpectraZYAM1E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
+    SetTitles1D(hSpectraZYAM1E);
+    hSpectraZYAM1E->Draw();
+    cSpectraZYAM1E->SetLogy(1);
+    gNEtaSpectraZYAM1->Draw("p");
+    gAEtaSpectraZYAM1->Draw("p");
+    if(DrawFit)gNEtaSpectraFit1->Draw("p");
+    // if(DrawFit)gAPhiSpectraFit1->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_SpectraEtaMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cSpectraZYAM1E->SaveAs(outName);
+
+    cSpectraZYAM2E=new TCanvas("cSpectraZYAM2E","Spectra Average",800,600);
+    SetMargins1D(cSpectraZYAM2E);
+    sprintf(name,"Associated Particle Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hSpectraZYAM2E=new TH2F("hSpectraZYAM2E",name,10,0,TPt1,10,plotmin,plotmax);
+    if(NoTitle)hSpectraZYAM2E->SetTitle("");
+    hSpectraZYAM2E->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
+    hSpectraZYAM2E->GetXaxis()->SetTitleColor(1);
+    hSpectraZYAM2E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
+    SetTitles1D(hSpectraZYAM2E);
+    hSpectraZYAM2E->Draw();
+    cSpectraZYAM2E->SetLogy(1);
+    gNEtaSpectraZYAM2->Draw("p");
+    gAEtaSpectraZYAM2->Draw("p");
+    if(DrawFit)gNEtaSpectraFit2->Draw("p");
+    //if(DrawFit)gAEtaSpectraFit2->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
+    keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_SpectraEtaAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d,%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cSpectraZYAM2E->SaveAs(outName);
+
+    cSpectraZYAM3E=new TCanvas("cSpectraZYAM3E","Spectra Lowest Error",800,600);
+    SetMargins1D(cSpectraZYAM3);
+    sprintf(name,"Associated Particle Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hSpectraZYAM3E=new TH2F("hSpectraZYAM3E",name,10,0,TPt1,10,plotmin,plotmax);
+    if(NoTitle)hSpectraZYAM3E->SetTitle("");
+    hSpectraZYAM3E->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
+    hSpectraZYAM3E->GetXaxis()->SetTitleColor(1);
+    hSpectraZYAM3E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
+    SetTitles1D(hSpectraZYAM3E);
+    hSpectraZYAM3E->Draw();
+    cSpectraZYAM3E->SetLogy(1);
+    gNEtaSpectraZYAM3->Draw("p");
+    gAEtaSpectraZYAM3->Draw("p");
+    if(DrawFit)gNEtaSpectraFit3->Draw("p");
+    //if(DrawFit)gAEtaSpectraFit3->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
+    keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_SpectraEtaLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cSpectraZYAM3E->SaveAs(outName);
+
+    cZt1ZYAM1E=new TCanvas("cZt1ZYAM1E","Spectra MidPoint",800,600);
+    SetMargins1D(cZt1ZYAM1E);
+    sprintf(name,"Associated Particle Z_{T} Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt1ZYAM1E=new TH2F("hZt1ZYAM1E",name,10,0,1,10,plotmin,plotmax);
+    if(NoTitle)hZt1ZYAM1E->SetTitle("");
+    hZt1ZYAM1E->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig}  ");
+    hZt1ZYAM1E->GetXaxis()->SetTitleColor(1);
+    hZt1ZYAM1E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt1ZYAM1E);
+    hZt1ZYAM1E->Draw();
+    cZt1ZYAM1E->SetLogy(1);
+    gNEtaZt1ZYAM1->Draw("p");
+    gAEtaZt1ZYAM1->Draw("p");
+    if(DrawFit)gNEtaZt1Fit1->Draw("p");
+    //if(DrawFit)gAEtaZt1Fit1->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
+    keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigEtaMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt1ZYAM1E->SaveAs(outName);
+
+    cZt1ZYAM2E=new TCanvas("cZt1ZYAM2E","Spectra Average",800,600);
+    SetMargins1D(cZt1ZYAM2E);
+    sprintf(name,"Associated Particle Z_{T} Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt1ZYAM2E=new TH2F("hZt1ZYAM2E",name,10,0,1,10,plotmin,plotmax);
+    if(NoTitle)hZt1ZYAM2E->SetTitle("");
+    hZt1ZYAM2E->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig}  ");
+    hZt1ZYAM2E->GetXaxis()->SetTitleColor(1);
+    hZt1ZYAM2E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt1ZYAM2E);
+    hZt1ZYAM2E->Draw();
+    cZt1ZYAM2E->SetLogy(1);
+    gNEtaZt1ZYAM2->Draw("p");
+    gAEtaZt1ZYAM2->Draw("p");
+    if(DrawFit)gNEtaZt1Fit2->Draw("p");
+    //if(DrawFit)gAEtaZt1Fit2->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
+    keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigEtaAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt1ZYAM2E->SaveAs(outName);
+
+    cZt1ZYAM3E=new TCanvas("cZt1ZYAM3E","Spectra Lowest Error",800,600);
+    SetMargins1D(cZt1ZYAM3E);
+    sprintf(name,"Associated Particle Z_{T} Spectra Eta %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt1ZYAM3E=new TH2F("hZt1ZYAM3E",name,10,0,1,10,plotmin,plotmax);
+    if(NoTitle)hZt1ZYAM3->SetTitle("");
+    hZt1ZYAM3E->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
+    hZt1ZYAM3E->GetXaxis()->SetTitleColor(1);
+    hZt1ZYAM3E->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt1ZYAM3E);
+    hZt1ZYAM3E->Draw();
+    cZt1ZYAM3E->SetLogy(1);
+    gNEtaZt1ZYAM3->Draw("p");
+    gAEtaZt1ZYAM3->Draw("p");
+    if(DrawFit)gNEtaZt1Fit3->Draw("p");
+    //if(DrawFit)gAEtaZt1Fit3->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthEta);
+    keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigEtaLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt1ZYAM3E->SaveAs(outName);
+
+
+    cSpectraZYAM1C=new TCanvas("cSpectraZYAM1C","Spectra MidPoint",800,600);
+    SetMargins1D(cSpectraZYAM1C);
+    sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hSpectraZYAM1C=new TH2F("hSpectraZYAM1C",name,10,0,TPt1,10,plotmin,plotmax);
+    if(NoTitle)hSpectraZYAM1C->SetTitle("");
+    hSpectraZYAM1C->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
+    hSpectraZYAM1C->GetXaxis()->SetTitleColor(1);
+    hSpectraZYAM1C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
+    SetTitles1D(hSpectraZYAM1C);
+    hSpectraZYAM1C->Draw();
+    cSpectraZYAM1C->SetLogy(1);
+    gNPhiSpectraZYAM1->Draw("p");
+    gAPhiSpectraZYAM1->Draw("p");
+    gNEtaSpectraZYAM1->Draw("p");
+    gAEtaSpectraZYAM1->Draw("p");
+    if(DrawFit)gNPhiSpectraFit1->Draw("p");
+    if(DrawFit)gAPhiSpectraFit1->Draw("p");
+    if(DrawFit)gNEtaSpectraFit1->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.7,"Away #Delta#eta Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_SpectraCombMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cSpectraZYAM1C->SaveAs(outName);
+
+    cSpectraZYAM2C=new TCanvas("cSpectraZYAM2C","Spectra MidPoint",800,600);
+    SetMargins1D(cSpectraZYAM2C);
+    sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hSpectraZYAM2C=new TH2F("hSpectraZYAM2C",name,10,0,TPt1,10,plotmin,plotmax);
+    if(NoTitle)hSpectraZYAM2C->SetTitle("");
+    hSpectraZYAM2C->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
+    hSpectraZYAM2C->GetXaxis()->SetTitleColor(1);
+    hSpectraZYAM2C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
+
+    SetTitles1D(hSpectraZYAM2C);
+    hSpectraZYAM2C->Draw();
+    cSpectraZYAM2C->SetLogy(1);
+    gNPhiSpectraZYAM2->Draw("p");
+    gAPhiSpectraZYAM2->Draw("p");
+    gNEtaSpectraZYAM2->Draw("p");
+    gAEtaSpectraZYAM2->Draw("p");
+    if(DrawFit)gNPhiSpectraFit2->Draw("p");
+    if(DrawFit)gAPhiSpectraFit2->Draw("p");
+    if(DrawFit)gNEtaSpectraFit2->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.7,"Away #Delta#eta Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_SpectraCombAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cSpectraZYAM2C->SaveAs(outName);
+
+    cSpectraZYAM3C=new TCanvas("cSpectraZYAM3C","Spectra MidPoint",800,600);
+    SetMargins1D(cSpectraZYAM3C);
+    sprintf(name,"Associated Particle Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hSpectraZYAM3C=new TH2F("hSpectraZYAM3C",name,10,0,TPt1,10,plotmin,plotmax);
+    if(NoTitle)hSpectraZYAM3C->SetTitle("");
+    hSpectraZYAM3C->GetXaxis()->SetTitle("p_{T}^{Associated} (GeV/c) ");
+    hSpectraZYAM3C->GetXaxis()->SetTitleColor(1);
+    hSpectraZYAM3C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dp_{T}}    ");
+    SetTitles1D(hSpectraZYAM3C);
+    hSpectraZYAM3C->Draw();
+    cSpectraZYAM3C->SetLogy(1);
+    gNPhiSpectraZYAM3->Draw("p");
+    gAPhiSpectraZYAM3->Draw("p");
+    gNEtaSpectraZYAM3->Draw("p");
+    gAEtaSpectraZYAM3->Draw("p");
+    if(DrawFit)gNPhiSpectraFit3->Draw("p");
+    if(DrawFit)gAPhiSpectraFit3->Draw("p");
+    if(DrawFit)gNEtaSpectraFit3->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_SpectraCombLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cSpectraZYAM3C->SaveAs(outName);
+
+
+    cZt1ZYAM1C=new TCanvas("cZt1ZYAM1C","ZT MidPoint",800,600);
+    SetMargins1D(cZt1ZYAM1C);
+    sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt1ZYAM1C=new TH2F("hZt1ZYAM1C",name,10,0,1,10,plotmin,plotmax);
+    if(NoTitle)hZt1ZYAM1C->SetTitle("");
+    hZt1ZYAM1C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
+    hZt1ZYAM1C->GetXaxis()->SetTitleColor(1);
+    hZt1ZYAM1C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt1ZYAM1C);
+    hZt1ZYAM1C->Draw();
+    cZt1ZYAM1C->SetLogy(1);
+    gNPhiZt1ZYAM1->Draw("p");
+    gAPhiZt1ZYAM1->Draw("p");
+    gNEtaZt1ZYAM1->Draw("p");
+    gAEtaZt1ZYAM1->Draw("p");
+    if(DrawFit)gNPhiZt1Fit1->Draw("p");
+    if(DrawFit)gAPhiZt1Fit1->Draw("p");
+    if(DrawFit)gNEtaZt1Fit1->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigCombMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt1ZYAM1C->SaveAs(outName);
+
+    cZt1ZYAM2C=new TCanvas("cZt1ZYAM2C","Zt MidPoint",800,600);
+    SetMargins1D(cZt1ZYAM2C);
+    sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt1ZYAM2C=new TH2F("hZt1ZYAM2C",name,10,0,1,10,plotmin,plotmax);
+    if(NoTitle)hZt1ZYAM2C->SetTitle("");
+    hZt1ZYAM2C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
+    hZt1ZYAM2C->GetXaxis()->SetTitleColor(1);
+    hZt1ZYAM2C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+  
+    SetTitles1D(hZt1ZYAM2C);
+    hZt1ZYAM2C->Draw();
+    cZt1ZYAM2C->SetLogy(1);
+    gNPhiZt1ZYAM2->Draw("p");
+    gAPhiZt1ZYAM2->Draw("p");
+    gNEtaZt1ZYAM2->Draw("p");
+    gAEtaZt1ZYAM2->Draw("p");
+    if(DrawFit)gNPhiZt1Fit2->Draw("p");
+    if(DrawFit)gAPhiZt1Fit2->Draw("p");
+    if(DrawFit)gNEtaZt1Fit2->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigCombAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt1ZYAM2C->SaveAs(outName);
+
+    cZt1ZYAM3C=new TCanvas("cZt1ZYAM3C","Zt1_3 MidPoint",800,600);
+    SetMargins1D(cZt1ZYAM3C);
+    sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt1ZYAM3C=new TH2F("hZt1ZYAM3C",name,10,0,1,10,plotmin,plotmax);
+    if(NoTitle)hZt1ZYAM3C->SetTitle("");
+    hZt1ZYAM3C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
+    hZt1ZYAM3C->GetXaxis()->SetTitleColor(1);
+    hZt1ZYAM3C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt1ZYAM3C);
+    hZt1ZYAM3C->Draw();
+    cZt1ZYAM3C->SetLogy(1);
+    gNPhiZt1ZYAM3->Draw("p");
+    gAPhiZt1ZYAM3->Draw("p");
+    gNEtaZt1ZYAM3->Draw("p");
+    gAEtaZt1ZYAM3->Draw("p");
+    if(DrawFit)gNPhiZt1Fit3->Draw("p");
+    if(DrawFit)gAPhiZt1Fit3->Draw("p");
+    if(DrawFit)gNEtaZt1Fit3->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.65,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.6,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.7,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigCombLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt1ZYAM3C->SaveAs(outName);
+    /*
+    cZt2ZYAM1C=new TCanvas("cZt2ZYAM1C"," MidPoint",800,600);
+    SetMargins1D(cZt2ZYAM1C);
+    sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt2ZYAM1C=new TH2F("hZt2ZYAM1C",name,10,0,1,10,plotmin,plotmax);
+    if(NoTitle)hZt2ZYAM1C->SetTitle("");
+    hZt2ZYAM1C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
+    hZt2ZYAM1C->GetXaxis()->SetTitleColor(1);
+    hZt2ZYAM1C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt2ZYAM1C);
+    hZt2ZYAM1C->Draw();
+    cZt2ZYAM1C->SetLogy(1);
+    gNPhiZt2ZYAM1->Draw("p");
+    gAPhiZt2ZYAM1->Draw("p");
+    gNEtaZt2ZYAM1->Draw("p");
+    gAEtaZt2ZYAM1->Draw("p");
+    //if(DrawFit)gNPhiZt2Fit1->Draw("p");
+    //if(DrawFit)gAPhiZt2Fit1->Draw("p");
+    //if(DrawFit)gNEtaZt2Fit1->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.85,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.75,"Near #Delta#etaFit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigCombMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt2ZYAM1C->SaveAs(outName);
+
+    cZt2ZYAM2C=new TCanvas("cZt2ZYAM2C"," MidPoint",800,600);
+    SetMargins1D(cZt2ZYAM2C);
+    sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt2ZYAM2C=new TH2F("hZt2ZYAM2C",name,10,0,1,10,plotmin,plotmax);
+    if(NoTitle)hZt2ZYAM2C->SetTitle("");
+  
+    hZt2ZYAM2C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
+    hZt2ZYAM2C->GetXaxis()->SetTitleColor(1);
+    hZt2ZYAM2C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+    SetTitles1D(hZt2ZYAM2C);
+    hZt2ZYAM2C->Draw();
+    cZt2ZYAM2C->SetLogy(1);
+    gNPhiZt2ZYAM2->Draw("p");
+    gAPhiZt2ZYAM2->Draw("p");
+    gNEtaZt2ZYAM2->Draw("p");
+    gAEtaZt2ZYAM2->Draw("p");
+    //if(DrawFit)gNPhiZt2Fit2->Draw("p");
+    //if(DrawFit)gAPhiZt2Fit2->Draw("p");
+    // if(DrawFit)gNEtaZt2Fit2->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    //  if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.85,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.75,"Near #Delta#etaFit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigCombAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt2ZYAM2C->SaveAs(outName);
+
+    cZt2ZYAM3C=new TCanvas("cZt2ZYAM3C"," MidPoint",800,600);
+    SetMargins1D(cZt2ZYAM3C);
+    sprintf(name,"Associated Particle z_{T} Spectra %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hZt2ZYAM3C=new TH2F("hZt2ZYAM3C",name,10,0,1,10,plotmin,plotmax);
+    if(NoTitle)hZt2ZYAM3C->SetTitle("");
+    hZt2ZYAM3C->GetXaxis()->SetTitle("z_{T}=p_{T}^{Assoc}/p_{T}^{Trig} ");
+    hZt2ZYAM3C->GetXaxis()->SetTitleColor(1);
+    hZt2ZYAM3C->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}#frac{dN}{dz_{T}}    ");
+  
+    SetTitles1D(hZt2ZYAM3C);
+    hZt2ZYAM3C->Draw();
+    cZt2ZYAM3C->SetLogy(1);
+    gNPhiZt2ZYAM3->Draw("p");
+    gAPhiZt2ZYAM3->Draw("p");
+    gNEtaZt2ZYAM3->Draw("p");
+    gAEtaZt2ZYAM3->Draw("p");
+    // if(DrawFit)gNPhiZt2Fit3->Draw("p");
+    // if(DrawFit)gAPhiZt2Fit3->Draw("p");
+    //  if(DrawFit)gNEtaZt2Fit3->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    //  if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.85,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    // if(DrawFit)keySymbol(.65,.75,"Near #Delta#etaFit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_ZtTrigCombLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,APtTPtMult,FitTit[DrawFit],filetype);
+    cZt2ZYAM3C->SaveAs(outName);
+    */
+
+    cWidth1=new TCanvas("cWidth1","Width MidPoint",800,600);
+    SetMargins1D(cWidth1);
+    sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hWidth1=new TH2F("hWidth1",name,10,0,TPt1,10,plotminW,plotmaxW);
+    if(NoTitle)hWidth1->SetTitle("");
+    hWidth1->GetXaxis()->SetTitle("p_{T}^{Assoc} (GeV/c) ");
+    hWidth1->GetXaxis()->SetTitleColor(1);
+    hWidth1->GetYaxis()->SetTitle("#sigma (radians)   ");
+    SetTitles1D(hWidth1);
+    hWidth1->Draw();
+    gNPhiWidth1->Draw("p");
+    gAPhiWidth1->Draw("p");
+    gNEtaWidth1->Draw("p");
+    keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_WidthMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_C%d_%dM%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,filetype);
+    cWidth1->SaveAs(outName);
+
+    cWidth2=new TCanvas("cWidth2","Width MidPoint",800,600);
+    SetMargins1D(cWidth2);
+    sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hWidth2=new TH2F("hWidth2",name,10,0,TPt1,10,plotminW,plotmaxW);
+    if(NoTitle)hWidth2->SetTitle("");
+    hWidth2->GetXaxis()->SetTitle("p_{T}^{Assoc} (GeV/c) ");
+    hWidth2->GetXaxis()->SetTitleColor(1);
+    hWidth2->GetYaxis()->SetTitle("#sigma (radians)   ");
+    SetTitles1D(hWidth2);
+    hWidth2->Draw();
+    gNPhiWidth2->Draw("p");
+    gAPhiWidth2->Draw("p");
+    gNEtaWidth2->Draw("p");
+    keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_WidthAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,filetype);
+    cWidth2->SaveAs(outName);
+
+    cWidth3=new TCanvas("cWidth3","Width MidPoint",800,600);
+    SetMargins1D(cWidth3);
+    sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hWidth3=new TH2F("hWidth3",name,10,0,TPt1,10,plotminW,plotmaxW);
+    if(NoTitle)hWidth3->SetTitle("");
+    hWidth3->GetXaxis()->SetTitle("p_{T}^{Assoc} (GeV/c) ");
+    hWidth3->GetXaxis()->SetTitleColor(1);
+    hWidth3->GetYaxis()->SetTitle("#sigma (radians)   ");
+    SetTitles1D(hWidth3);
+    hWidth3->Draw();
+    gNPhiWidth3->Draw("p");
+    gAPhiWidth3->Draw("p");
+    gNEtaWidth3->Draw("p");
+    keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_WidthLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffCorr,APtTPtMult,filetype);
+    cWidth3->SaveAs(outName);
+
+  }
+
+  if(APtTPtMult==1){
+    if(HorizontalErrors==0){
+      for(int mloop=0;mloop<nMainLoop;mloop++){
+       NXPhi[1][mloop]=0;
+       NXPhi[3][mloop]=0;
+       NXPhi[5][mloop]=0;
+       NXPhi[7][mloop]=0;
+       NXPhi[9][mloop]=0;
+       NXPhi[11][mloop]=0;
+       NXPhi[13][mloop]=0;
+       NXPhi[15][mloop]=0;
+       NXPhi[17][mloop]=0;
+       AXPhi[1][mloop]=0;
+       AXPhi[3][mloop]=0;
+       AXPhi[5][mloop]=0;
+       AXPhi[7][mloop]=0;
+       AXPhi[9][mloop]=0;
+       AXPhi[11][mloop]=0;
+       AXPhi[13][mloop]=0;
+       AXPhi[15][mloop]=0;
+       AXPhi[17][mloop]=0;
+       NXPhiFit[1][mloop]=0;
+       NXPhiFit[3][mloop]=0;
+       NXPhiFit[5][mloop]=0;
+       NXPhiFit[7][mloop]=0;
+       NXPhiFit[9][mloop]=0;
+       NXPhiFit[11][mloop]=0;
+       NXPhiFit[13][mloop]=0;
+       NXPhiFit[15][mloop]=0;
+       NXPhiFit[17][mloop]=0;
+       AXPhiFit[1][mloop]=0;
+       AXPhiFit[3][mloop]=0;
+       AXPhiFit[5][mloop]=0;
+       AXPhiFit[7][mloop]=0;
+       AXPhiFit[9][mloop]=0;
+       AXPhiFit[11][mloop]=0;
+       AXPhiFit[13][mloop]=0;
+       AXPhiFit[15][mloop]=0;
+       AXPhiFit[17][mloop]=0;
+       NXEta[1][mloop]=0;
+       NXEta[3][mloop]=0;
+       NXEta[5][mloop]=0;
+       NXEta[7][mloop]=0;
+       NXEta[9][mloop]=0;
+       NXEta[11][mloop]=0;
+       NXEta[13][mloop]=0;
+       NXEta[15][mloop]=0;
+       NXEta[17][mloop]=0;
+       AXEta[1][mloop]=0;
+       AXEta[3][mloop]=0;
+       AXEta[5][mloop]=0;
+       AXEta[7][mloop]=0;
+       AXEta[9][mloop]=0;
+       AXEta[11][mloop]=0;
+       AXEta[13][mloop]=0;
+       AXEta[15][mloop]=0;
+       AXEta[17][mloop]=0;
+       NXEtaFit[1][mloop]=0;
+       NXEtaFit[3][mloop]=0;
+       NXEtaFit[5][mloop]=0;
+       NXEtaFit[7][mloop]=0;
+       NXEtaFit[9][mloop]=0;
+       NXEtaFit[11][mloop]=0;
+       NXEtaFit[13][mloop]=0;
+       NXEtaFit[15][mloop]=0;
+       NXEtaFit[17][mloop]=0;
+       AXEtaFit[1][mloop]=0;
+       AXEtaFit[3][mloop]=0;
+       AXEtaFit[5][mloop]=0;
+       AXEtaFit[7][mloop]=0;
+       AXEtaFit[9][mloop]=0;
+       AXEtaFit[11][mloop]=0;
+       AXEtaFit[13][mloop]=0;
+       AXEtaFit[15][mloop]=0;
+       AXEtaFit[17][mloop]=0;
+      }
+    }
+    gNYieldPhi=new TGraphErrors(nMainLoop,NXPhi[0],NYieldPhiZYAM[0],NXPhi[1],NYieldPhiZYAM[1]);
+    gAYieldPhi=new TGraphErrors(nMainLoop,NXPhi[0],AYieldPhiZYAM[0],NXPhi[1],AYieldPhiZYAM[1]);
+    gMYieldPhi=new TGraphErrors(nMainLoop,NXPhi[0],MYieldPhi[0],NXPhi[1],MYieldPhi[1]);
+    gNYieldPhiPt=new TGraphErrors(nMainLoop,NXPhi[0],NYieldPhiZYAM[2],NXPhi[1],NYieldPhiZYAM[3]);
+    gAYieldPhiPt=new TGraphErrors(nMainLoop,NXPhi[0],AYieldPhiZYAM[2],NXPhi[1],AYieldPhiZYAM[3]);
+    gMYieldPhiPt=new TGraphErrors(nMainLoop,NXPhi[0],MYieldPhi[2],NXPhi[1],MYieldPhi[3]);
+
+    gNYieldPhi2=new TGraphErrors(nMainLoop,NXPhi[2],NYieldPhiZYAM[0],NXPhi[3],NYieldPhiZYAM[1]);
+    gAYieldPhi2=new TGraphErrors(nMainLoop,NXPhi[2],AYieldPhiZYAM[0],NXPhi[3],AYieldPhiZYAM[1]);
+    gMYieldPhi2=new TGraphErrors(nMainLoop,NXPhi[2],MYieldPhi[0],NXPhi[3],MYieldPhi[1]);
+    gNYieldPhiPt2=new TGraphErrors(nMainLoop,NXPhi[2],NYieldPhiZYAM[2],NXPhi[3],NYieldPhiZYAM[3]);
+    gAYieldPhiPt2=new TGraphErrors(nMainLoop,NXPhi[2],AYieldPhiZYAM[2],NXPhi[3],AYieldPhiZYAM[3]);
+    gMYieldPhiPt2=new TGraphErrors(nMainLoop,NXPhi[2],MYieldPhi[2],NXPhi[3],MYieldPhi[3]);
+
+    gNYieldPhi3=new TGraphErrors(nMainLoop,NXPhi[4],NYieldPhiZYAM[0],NXPhi[5],NYieldPhiZYAM[1]);
+    gAYieldPhi3=new TGraphErrors(nMainLoop,NXPhi[4],AYieldPhiZYAM[0],NXPhi[5],AYieldPhiZYAM[1]);
+    gMYieldPhi3=new TGraphErrors(nMainLoop,NXPhi[4],MYieldPhi[0],NXPhi[5],MYieldPhi[1]);
+    gNYieldPhiPt3=new TGraphErrors(nMainLoop,NXPhi[4],NYieldPhiZYAM[2],NXPhi[5],NYieldPhiZYAM[3]);
+    gAYieldPhiPt3=new TGraphErrors(nMainLoop,NXPhi[4],AYieldPhiZYAM[2],NXPhi[5],AYieldPhiZYAM[3]);
+    gMYieldPhiPt3=new TGraphErrors(nMainLoop,NXPhi[4],MYieldPhi[2],NXPhi[5],MYieldPhi[3]);
+
+    gNYieldPhiFit=new TGraphErrors(nMainLoop,NXPhiFit[0],NYieldPhiFit[0],NXPhiFit[1],NYieldPhiFit[1]);
+    gAYieldPhiFit=new TGraphErrors(nMainLoop,NXPhiFit[0],AYieldPhiFit[0],NXPhiFit[1],AYieldPhiFit[1]);
+    gMYieldPhiFit=new TGraphErrors(nMainLoop,NXPhiFit[0],MYieldPhiFit[0],NXPhiFit[1],MYieldPhiFit[1]);
+    gNYieldPhiFitPt=new TGraphErrors(nMainLoop,NXPhiFit[0],NYieldPhiFit[2],NXPhiFit[1],NYieldPhiFit[3]);
+    gAYieldPhiFitPt=new TGraphErrors(nMainLoop,NXPhiFit[0],AYieldPhiFit[2],NXPhiFit[1],AYieldPhiFit[3]);
+    gMYieldPhiFitPt=new TGraphErrors(nMainLoop,NXPhiFit[0],MYieldPhiFit[2],NXPhiFit[1],MYieldPhiFit[3]);
+
+    gNYieldPhiFit2=new TGraphErrors(nMainLoop,NXPhiFit[2],NYieldPhiFit[0],NXPhiFit[3],NYieldPhiFit[1]);
+    gAYieldPhiFit2=new TGraphErrors(nMainLoop,NXPhiFit[2],AYieldPhiFit[0],NXPhiFit[3],AYieldPhiFit[1]);
+    gMYieldPhiFit2=new TGraphErrors(nMainLoop,NXPhiFit[2],MYieldPhiFit[0],NXPhiFit[3],MYieldPhiFit[1]);
+    gNYieldPhiFitPt2=new TGraphErrors(nMainLoop,NXPhiFit[2],NYieldPhiFit[2],NXPhiFit[3],NYieldPhiFit[3]);
+    gAYieldPhiFitPt2=new TGraphErrors(nMainLoop,NXPhiFit[2],AYieldPhiFit[2],NXPhiFit[3],AYieldPhiFit[3]);
+    gMYieldPhiFitPt2=new TGraphErrors(nMainLoop,NXPhiFit[2],MYieldPhiFit[2],NXPhiFit[3],MYieldPhiFit[3]);
+
+    gNYieldPhiFit3=new TGraphErrors(nMainLoop,NXPhiFit[4],NYieldPhiFit[0],NXPhiFit[5],NYieldPhiFit[1]);
+    gAYieldPhiFit3=new TGraphErrors(nMainLoop,NXPhiFit[4],AYieldPhiFit[0],NXPhiFit[5],AYieldPhiFit[1]);
+    gMYieldPhiFit3=new TGraphErrors(nMainLoop,NXPhiFit[4],MYieldPhiFit[0],NXPhiFit[5],MYieldPhiFit[1]);
+    gNYieldPhiFitPt3=new TGraphErrors(nMainLoop,NXPhiFit[4],NYieldPhiFit[2],NXPhiFit[5],NYieldPhiFit[3]);
+    gAYieldPhiFitPt3=new TGraphErrors(nMainLoop,NXPhiFit[4],AYieldPhiFit[2],NXPhiFit[5],AYieldPhiFit[3]);
+    gMYieldPhiFitPt3=new TGraphErrors(nMainLoop,NXPhiFit[4],MYieldPhiFit[2],NXPhiFit[5],MYieldPhiFit[3]);
+   
+    gNPhiWidth1=new TGraphErrors(nMainLoop,NXPhiFit[0],NWidthPhi[0],NXPhiFit[1],NWidthPhi[1]);
+    gNPhiWidth2=new TGraphErrors(nMainLoop,NXPhiFit[2],NWidthPhi[0],NXPhiFit[3],NWidthPhi[1]);
+    gNPhiWidth3=new TGraphErrors(nMainLoop,NXPhiFit[4],NWidthPhi[0],NXPhiFit[5],NWidthPhi[1]);
+    gAPhiWidth1=new TGraphErrors(nMainLoop,AXPhiFit[0],AWidthPhi[0],AXPhiFit[1],AWidthPhi[1]);
+    gAPhiWidth2=new TGraphErrors(nMainLoop,AXPhiFit[2],AWidthPhi[0],AXPhiFit[3],AWidthPhi[1]);
+    gAPhiWidth3=new TGraphErrors(nMainLoop,AXPhiFit[4],AWidthPhi[0],AXPhiFit[5],AWidthPhi[1]);
+
+    gNPhiJt1=new TGraphErrors(nMainLoop,NXPhiFit[0],NJtPhi[0],NXPhiFit[1],NJtPhi[1]);
+    gNPhiJt2=new TGraphErrors(nMainLoop,NXPhiFit[2],NJtPhi[0],NXPhiFit[3],NJtPhi[1]);
+    gNPhiJt3=new TGraphErrors(nMainLoop,NXPhiFit[4],NJtPhi[0],NXPhiFit[5],NJtPhi[1]);
+
+    gNYieldEta=new TGraphErrors(nMainLoop,NXEta[0],NYieldEtaZYAM[0],NXEta[1],NYieldEtaZYAM[1]);
+    gAYieldEta=new TGraphErrors(nMainLoop,NXEta[0],AYieldEtaZYAM[0],NXEta[1],AYieldEtaZYAM[1]);
+    gNYieldEtaPt=new TGraphErrors(nMainLoop,NXEta[0],NYieldEtaZYAM[2],NXEta[1],NYieldEtaZYAM[3]);
+    gAYieldEtaPt=new TGraphErrors(nMainLoop,NXEta[0],AYieldEtaZYAM[2],NXEta[1],AYieldEtaZYAM[3]);
+  
+    gNYieldEta2=new TGraphErrors(nMainLoop,NXEta[2],NYieldEtaZYAM[0],NXEta[3],NYieldEtaZYAM[1]);
+    gAYieldEta2=new TGraphErrors(nMainLoop,NXEta[2],AYieldEtaZYAM[0],NXEta[3],AYieldEtaZYAM[1]);
+    gNYieldEtaPt2=new TGraphErrors(nMainLoop,NXEta[2],NYieldEtaZYAM[2],NXEta[3],NYieldEtaZYAM[3]);
+    gAYieldEtaPt2=new TGraphErrors(nMainLoop,NXEta[2],AYieldEtaZYAM[2],NXEta[3],AYieldEtaZYAM[3]);
+
+    gNYieldEta3=new TGraphErrors(nMainLoop,NXEta[4],NYieldEtaZYAM[0],NXEta[5],NYieldEtaZYAM[1]);
+    gAYieldEta3=new TGraphErrors(nMainLoop,NXEta[4],AYieldEtaZYAM[0],NXEta[5],AYieldEtaZYAM[1]);
+    gNYieldEtaPt3=new TGraphErrors(nMainLoop,NXEta[4],NYieldEtaZYAM[2],NXEta[5],NYieldEtaZYAM[3]);
+    gAYieldEtaPt3=new TGraphErrors(nMainLoop,NXEta[4],AYieldEtaZYAM[2],NXEta[5],AYieldEtaZYAM[3]);
+    gNYieldEtaFit=new TGraphErrors(nMainLoop,NXEtaFit[0],NYieldEtaFit[0],NXEtaFit[1],NYieldEtaFit[1]);
+    // gAYieldEtaFit=new TGraphErrors(nMainLoop,NXEtaFit[0],AYieldEtaFit[0],NXEtaFit[1],AYieldEtaFit[1]);
+    gNYieldEtaFitPt=new TGraphErrors(nMainLoop,NXEtaFit[0],NYieldEtaFit[2],NXEtaFit[1],NYieldEtaFit[3]);
+    // gAYieldEtaFitPt=new TGraphErrors(nMainLoop,NXEtaFit[0],AYieldEtaFit[2],NXEtaFit[1],AYieldEtaFit[3]);
+
+    gNYieldEtaFit2=new TGraphErrors(nMainLoop,NXEtaFit[2],NYieldEtaFit[0],NXEtaFit[3],NYieldEtaFit[1]);
+    //gAYieldEtaFit2=new TGraphErrors(nMainLoop,NXEtaFit[2],AYieldEtaFit[0],NXEtaFit[3],AYieldEtaFit[1]);
+    gNYieldEtaFitPt2=new TGraphErrors(nMainLoop,NXEtaFit[2],NYieldEtaFit[2],NXEtaFit[3],NYieldEtaFit[3]);
+    // gAYieldEtaFitPt2=new TGraphErrors(nMainLoop,NXEtaFit[2],AYieldEtaFit[2],NXEtaFit[3],AYieldEtaFit[3]);
+
+    gNYieldEtaFit3=new TGraphErrors(nMainLoop,NXEtaFit[4],NYieldEtaFit[0],NXEtaFit[5],NYieldEtaFit[1]);
+    // gAYieldEtaFit3=new TGraphErrors(nMainLoop,NXEtaFit[4],AYieldEtaFit[0],NXEtaFit[5],AYieldEtaFit[1]);
+    gNYieldEtaFitPt3=new TGraphErrors(nMainLoop,NXEtaFit[4],NYieldEtaFit[2],NXEtaFit[5],NYieldEtaFit[3]);
+    // gAYieldEtaFitPt3=new TGraphErrors(nMainLoop,NXEtaFit[4],AYieldEtaFit[2],NXEtaFit[5],AYieldEtaFit[3]);
+
+    gNEtaWidth1=new TGraphErrors(nMainLoop,NXPhiFit[0],NWidthEta[0],NXPhiFit[1],NWidthEta[1]);
+    gNEtaWidth2=new TGraphErrors(nMainLoop,NXPhiFit[2],NWidthEta[0],NXPhiFit[3],NWidthEta[1]);
+    gNEtaWidth3=new TGraphErrors(nMainLoop,NXPhiFit[4],NWidthEta[0],NXPhiFit[5],NWidthEta[1]);
+
+    gNEtaJt1=new TGraphErrors(nMainLoop,NXEtaFit[0],NJtEta[0],NXEtaFit[1],NJtEta[1]);
+    gNEtaJt2=new TGraphErrors(nMainLoop,NXEtaFit[2],NJtEta[0],NXEtaFit[3],NJtEta[1]);
+    gNEtaJt3=new TGraphErrors(nMainLoop,NXEtaFit[4],NJtEta[0],NXEtaFit[5],NJtEta[1]);
+
+    gNAvePhi1=new TGraphErrors(nMainLoop,NXPhi[0],NAvePhi[0],NXPhi[1],NAvePhi[1]);
+    gNAvePhi2=new TGraphErrors(nMainLoop,NXPhi[2],NAvePhi[0],NXPhi[3],NAvePhi[1]);
+    gNAvePhi3=new TGraphErrors(nMainLoop,NXPhi[4],NAvePhi[0],NXPhi[5],NAvePhi[1]);
+
+    gAAvePhi1=new TGraphErrors(nMainLoop,NXPhi[0],AAvePhi[0],NXPhi[1],AAvePhi[1]);
+    gAAvePhi2=new TGraphErrors(nMainLoop,NXPhi[2],AAvePhi[0],NXPhi[3],AAvePhi[1]);
+    gAAvePhi3=new TGraphErrors(nMainLoop,NXPhi[4],AAvePhi[0],NXPhi[5],AAvePhi[1]);
+
+    gMAvePhi1=new TGraphErrors(nMainLoop,NXPhi[0],MAvePhi[0],NXPhi[1],MAvePhi[1]);
+    gMAvePhi2=new TGraphErrors(nMainLoop,NXPhi[2],MAvePhi[0],NXPhi[3],MAvePhi[1]);
+    gMAvePhi3=new TGraphErrors(nMainLoop,NXPhi[4],MAvePhi[0],NXPhi[5],MAvePhi[1]);
+
+    gNAveEta1=new TGraphErrors(nMainLoop,NXEta[0],NAveEta[0],NXEta[1],NAveEta[1]);
+    gNAveEta2=new TGraphErrors(nMainLoop,NXEta[2],NAveEta[0],NXEta[3],NAveEta[1]);
+    gNAveEta3=new TGraphErrors(nMainLoop,NXEta[4],NAveEta[0],NXEta[5],NAveEta[1]);
+
+    gAAveEta1=new TGraphErrors(nMainLoop,NXEta[0],AAveEta[0],NXEta[1],AAveEta[1]);
+    gAAveEta2=new TGraphErrors(nMainLoop,NXEta[2],AAveEta[0],NXEta[3],AAveEta[1]);
+    gAAveEta3=new TGraphErrors(nMainLoop,NXEta[4],AAveEta[0],NXEta[5],AAveEta[1]);
+
+    gNAvePhiFit1=new TGraphErrors(nMainLoop,NXPhi[0],NAvePhiFit[0],NXPhi[1],NAvePhiFit[1]);
+    gNAvePhiFit2=new TGraphErrors(nMainLoop,NXPhi[2],NAvePhiFit[0],NXPhi[3],NAvePhiFit[1]);
+    gNAvePhiFit3=new TGraphErrors(nMainLoop,NXPhi[4],NAvePhiFit[0],NXPhi[5],NAvePhiFit[1]);
+
+    gAAvePhiFit1=new TGraphErrors(nMainLoop,NXPhi[0],AAvePhiFit[0],NXPhi[1],AAvePhiFit[1]);
+    gAAvePhiFit2=new TGraphErrors(nMainLoop,NXPhi[2],AAvePhiFit[0],NXPhi[3],AAvePhiFit[1]);
+    gAAvePhiFit3=new TGraphErrors(nMainLoop,NXPhi[4],AAvePhiFit[0],NXPhi[5],AAvePhiFit[1]);
+
+    gMAvePhiFit1=new TGraphErrors(nMainLoop,NXPhi[0],MAvePhiFit[0],NXPhi[1],MAvePhiFit[1]);
+    gMAvePhiFit2=new TGraphErrors(nMainLoop,NXPhi[2],MAvePhiFit[0],NXPhi[3],MAvePhiFit[1]);
+    gMAvePhiFit3=new TGraphErrors(nMainLoop,NXPhi[4],MAvePhiFit[0],NXPhi[5],MAvePhiFit[1]);
+
+    gNAveEtaFit1=new TGraphErrors(nMainLoop,NXEta[0],NAveEtaFit[0],NXEta[1],NAveEtaFit[1]);
+    gNAveEtaFit2=new TGraphErrors(nMainLoop,NXEta[2],NAveEtaFit[0],NXEta[3],NAveEtaFit[1]);
+    gNAveEtaFit3=new TGraphErrors(nMainLoop,NXEta[4],NAveEtaFit[0],NXEta[5],NAveEtaFit[1]);
+   
+    gNYieldPhi->SetMarkerStyle(MarkerNearPhi);
+    gAYieldPhi->SetMarkerStyle(MarkerAwayPhi);
+    gMYieldPhi->SetMarkerStyle(MarkerMin);
+    gNYieldPhiPt->SetMarkerStyle(MarkerNearPhi);
+    gAYieldPhiPt->SetMarkerStyle(MarkerAwayPhi);
+    gMYieldPhiPt->SetMarkerStyle(MarkerMin);
+    gNYieldPhi2->SetMarkerStyle(MarkerNearPhi);
+    gAYieldPhi2->SetMarkerStyle(MarkerAwayPhi);
+    gMYieldPhi2->SetMarkerStyle(MarkerMin);
+    gNYieldPhiPt2->SetMarkerStyle(MarkerNearPhi);
+    gAYieldPhiPt2->SetMarkerStyle(MarkerAwayPhi);
+    gMYieldPhiPt2->SetMarkerStyle(MarkerMin);
+    gNYieldPhi3->SetMarkerStyle(MarkerNearPhi);
+    gAYieldPhi3->SetMarkerStyle(MarkerAwayPhi);
+    gMYieldPhi3->SetMarkerStyle(MarkerMin);
+    gNYieldPhiPt3->SetMarkerStyle(MarkerNearPhi);
+    gAYieldPhiPt3->SetMarkerStyle(MarkerAwayPhi);
+    gMYieldPhiPt3->SetMarkerStyle(MarkerMin);
+    gNYieldPhi->SetMarkerColor(ColorNearPhi);
+    gAYieldPhi->SetMarkerColor(ColorAwayPhi);
+    gMYieldPhi->SetMarkerColor(ColorMin);
+    gNYieldPhi->SetLineColor(ColorNearPhi);
+    gAYieldPhi->SetLineColor(ColorAwayPhi);
+    gMYieldPhi->SetLineColor(ColorMin);
+    gNYieldPhiPt->SetMarkerColor(ColorNearPhi);
+    gAYieldPhiPt->SetMarkerColor(ColorAwayPhi);
+    gMYieldPhiPt->SetMarkerColor(ColorMin);
+    gNYieldPhiPt->SetLineColor(ColorNearPhi);
+    gAYieldPhiPt->SetLineColor(ColorAwayPhi);
+    gMYieldPhiPt->SetLineColor(ColorMin);
+    gNYieldPhi2->SetMarkerColor(ColorNearPhi);
+    gAYieldPhi2->SetMarkerColor(ColorAwayPhi);
+    gMYieldPhi2->SetMarkerColor(ColorMin);
+    gNYieldPhi2->SetLineColor(ColorNearPhi);
+    gAYieldPhi2->SetLineColor(ColorAwayPhi);
+    gMYieldPhi2->SetLineColor(ColorMin);
+    gNYieldPhiPt2->SetMarkerColor(ColorNearPhi);
+    gAYieldPhiPt2->SetMarkerColor(ColorAwayPhi);
+    gMYieldPhiPt2->SetMarkerColor(ColorMin);
+    gNYieldPhiPt2->SetLineColor(ColorNearPhi);
+    gAYieldPhiPt2->SetLineColor(ColorAwayPhi);
+    gMYieldPhiPt2->SetLineColor(ColorMin);
+    gNYieldPhi3->SetMarkerColor(ColorNearPhi);
+    gAYieldPhi3->SetMarkerColor(ColorAwayPhi);
+    gMYieldPhi3->SetMarkerColor(ColorMin);
+    gNYieldPhi3->SetLineColor(ColorNearPhi);
+    gAYieldPhi3->SetLineColor(ColorAwayPhi);
+    gMYieldPhi3->SetLineColor(ColorMin);
+    gNYieldPhiPt3->SetMarkerColor(ColorNearPhi);
+    gAYieldPhiPt3->SetMarkerColor(ColorAwayPhi);
+    gMYieldPhiPt3->SetMarkerColor(ColorMin);
+    gNYieldPhiPt3->SetLineColor(ColorNearPhi);
+    gAYieldPhiPt3->SetLineColor(ColorAwayPhi);
+    gMYieldPhiPt3->SetLineColor(ColorMin);
+    gNYieldPhi->SetMarkerSize(MarkerSize);
+    gAYieldPhi->SetMarkerSize(MarkerSize);
+    gMYieldPhi->SetMarkerSize(MarkerSize);
+    gNYieldPhiPt->SetMarkerSize(MarkerSize);
+    gAYieldPhiPt->SetMarkerSize(MarkerSize);
+    gMYieldPhiPt->SetMarkerSize(MarkerSize);
+    gNYieldPhi2->SetMarkerSize(MarkerSize);
+    gAYieldPhi2->SetMarkerSize(MarkerSize);
+    gMYieldPhi2->SetMarkerSize(MarkerSize);
+    gNYieldPhiPt2->SetMarkerSize(MarkerSize);
+    gAYieldPhiPt2->SetMarkerSize(MarkerSize);
+    gMYieldPhiPt2->SetMarkerSize(MarkerSize);
+    gNYieldPhi3->SetMarkerSize(MarkerSize);
+    gAYieldPhi3->SetMarkerSize(MarkerSize);
+    gMYieldPhi3->SetMarkerSize(MarkerSize);
+    gNYieldPhiPt3->SetMarkerSize(MarkerSize);
+    gAYieldPhiPt3->SetMarkerSize(MarkerSize);
+    gNYieldPhiPt3->SetMarkerSize(MarkerSize);
+
+    gNYieldPhiFit->SetMarkerStyle(MarkerNearPhiFit);
+    gNYieldPhiFit->SetMarkerSize(MarkerSize);
+    gNYieldPhiFit->SetMarkerColor(ColorNearPhiFit);
+    gNYieldPhiFit->SetLineColor(ColorNearPhiFit);
+    gNYieldPhiFit2->SetMarkerStyle(MarkerNearPhiFit);
+    gNYieldPhiFit2->SetMarkerSize(MarkerSize);
+    gNYieldPhiFit2->SetMarkerColor(ColorNearPhiFit);
+    gNYieldPhiFit2->SetLineColor(ColorNearPhiFit);
+    gNYieldPhiFit3->SetMarkerStyle(MarkerNearPhiFit);
+    gNYieldPhiFit3->SetMarkerSize(MarkerSize);
+    gNYieldPhiFit3->SetMarkerColor(ColorNearPhiFit);
+    gNYieldPhiFit3->SetLineColor(ColorNearPhiFit);
+
+    gAYieldPhiFit->SetMarkerStyle(MarkerAwayPhiFit);
+    gAYieldPhiFit->SetMarkerSize(MarkerSize);
+    gAYieldPhiFit->SetMarkerColor(ColorAwayPhiFit);
+    gAYieldPhiFit->SetLineColor(ColorAwayPhiFit);
+    gAYieldPhiFit2->SetMarkerStyle(MarkerAwayPhiFit);
+    gAYieldPhiFit2->SetMarkerSize(MarkerSize);
+    gAYieldPhiFit2->SetMarkerColor(ColorAwayPhiFit);
+    gAYieldPhiFit2->SetLineColor(ColorAwayPhiFit);
+    gAYieldPhiFit3->SetMarkerStyle(MarkerAwayPhiFit);
+    gAYieldPhiFit3->SetMarkerSize(MarkerSize);
+    gAYieldPhiFit3->SetMarkerColor(ColorAwayPhiFit);
+    gAYieldPhiFit3->SetLineColor(ColorAwayPhiFit);
+
+    gMYieldPhiFit->SetMarkerStyle(MarkerMinFit);
+    gMYieldPhiFit->SetMarkerSize(MarkerSize);
+    gMYieldPhiFit->SetMarkerColor(ColorMinFit);
+    gMYieldPhiFit->SetLineColor(ColorMinFit);
+    gMYieldPhiFit2->SetMarkerStyle(MarkerMinFit);
+    gMYieldPhiFit2->SetMarkerSize(MarkerSize);
+    gMYieldPhiFit2->SetMarkerColor(ColorMinFit);
+    gMYieldPhiFit2->SetLineColor(ColorMinFit);
+    gMYieldPhiFit3->SetMarkerStyle(MarkerMinFit);
+    gMYieldPhiFit3->SetMarkerSize(MarkerSize);
+    gMYieldPhiFit3->SetMarkerColor(ColorMinFit);
+    gMYieldPhiFit3->SetLineColor(ColorMinFit);
+
+    gNYieldPhiFitPt->SetMarkerStyle(MarkerNearPhiFit);
+    gNYieldPhiFitPt->SetMarkerSize(MarkerSize);
+    gNYieldPhiFitPt->SetMarkerColor(ColorNearPhiFit);
+    gNYieldPhiFitPt->SetLineColor(ColorNearPhiFit);
+    gNYieldPhiFitPt2->SetMarkerStyle(MarkerNearPhiFit);
+    gNYieldPhiFitPt2->SetMarkerSize(MarkerSize);
+    gNYieldPhiFitPt2->SetMarkerColor(ColorNearPhiFit);
+    gNYieldPhiFitPt2->SetLineColor(ColorNearPhiFit);
+    gNYieldPhiFitPt3->SetMarkerStyle(MarkerNearPhiFit);
+    gNYieldPhiFitPt3->SetMarkerSize(MarkerSize);
+    gNYieldPhiFitPt3->SetMarkerColor(ColorNearPhiFit);
+    gNYieldPhiFitPt3->SetLineColor(ColorNearPhiFit);
+
+    gAYieldPhiFitPt->SetMarkerStyle(MarkerAwayPhiFit);
+    gAYieldPhiFitPt->SetMarkerSize(MarkerSize);
+    gAYieldPhiFitPt->SetMarkerColor(ColorAwayPhiFit);
+    gAYieldPhiFitPt->SetLineColor(ColorAwayPhiFit);
+    gAYieldPhiFitPt2->SetMarkerStyle(MarkerAwayPhiFit);
+    gAYieldPhiFitPt2->SetMarkerSize(MarkerSize);
+    gAYieldPhiFitPt2->SetMarkerColor(ColorAwayPhiFit);
+    gAYieldPhiFitPt2->SetLineColor(ColorAwayPhiFit);
+    gAYieldPhiFitPt3->SetMarkerStyle(MarkerAwayPhiFit);
+    gAYieldPhiFitPt3->SetMarkerSize(MarkerSize);
+    gAYieldPhiFitPt3->SetMarkerColor(ColorAwayPhiFit);
+    gAYieldPhiFitPt3->SetLineColor(ColorAwayPhiFit);
+
+    gMYieldPhiFitPt->SetMarkerStyle(MarkerMinFit);
+    gMYieldPhiFitPt->SetMarkerSize(MarkerSize);
+    gMYieldPhiFitPt->SetMarkerColor(ColorMinFit);
+    gMYieldPhiFitPt->SetLineColor(ColorMinFit);
+    gMYieldPhiFitPt2->SetMarkerStyle(MarkerMinFit);
+    gMYieldPhiFitPt2->SetMarkerSize(MarkerSize);
+    gMYieldPhiFitPt2->SetMarkerColor(ColorMinFit);
+    gMYieldPhiFitPt2->SetLineColor(ColorMinFit);
+    gMYieldPhiFitPt3->SetMarkerStyle(MarkerMinFit);
+    gMYieldPhiFitPt3->SetMarkerSize(MarkerSize);
+    gMYieldPhiFitPt3->SetMarkerColor(ColorMinFit);
+    gMYieldPhiFitPt3->SetLineColor(ColorMinFit);
+
+    gNPhiWidth1->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiWidth1->SetMarkerSize(MarkerSize);
+    gNPhiWidth1->SetMarkerColor(ColorNearPhiFit);
+    gNPhiWidth1->SetLineColor(ColorNearPhiFit);
+    gNPhiWidth2->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiWidth2->SetMarkerSize(MarkerSize);
+    gNPhiWidth2->SetMarkerColor(ColorNearPhiFit);
+    gNPhiWidth2->SetLineColor(ColorNearPhiFit);
+    gNPhiWidth3->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiWidth3->SetMarkerSize(MarkerSize);
+    gNPhiWidth3->SetMarkerColor(ColorNearPhiFit);
+    gNPhiWidth3->SetLineColor(ColorNearPhiFit);
+
+    gAPhiWidth1->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiWidth1->SetMarkerSize(MarkerSize);
+    gAPhiWidth1->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiWidth1->SetLineColor(ColorAwayPhiFit);
+    gAPhiWidth2->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiWidth2->SetMarkerSize(MarkerSize);
+    gAPhiWidth2->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiWidth2->SetLineColor(ColorAwayPhiFit);
+    gAPhiWidth3->SetMarkerStyle(MarkerAwayPhiFit);
+    gAPhiWidth3->SetMarkerSize(MarkerSize);
+    gAPhiWidth3->SetMarkerColor(ColorAwayPhiFit);
+    gAPhiWidth3->SetLineColor(ColorAwayPhiFit);
+
+    gNPhiJt1->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiJt1->SetMarkerSize(MarkerSize);
+    gNPhiJt1->SetMarkerColor(ColorNearPhiFit);
+    gNPhiJt1->SetLineColor(ColorNearPhiFit);
+    gNPhiJt2->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiJt2->SetMarkerSize(MarkerSize);
+    gNPhiJt2->SetMarkerColor(ColorNearPhiFit);
+    gNPhiJt2->SetLineColor(ColorNearPhiFit);
+    gNPhiJt3->SetMarkerStyle(MarkerNearPhiFit);
+    gNPhiJt3->SetMarkerSize(MarkerSize);
+    gNPhiJt3->SetMarkerColor(ColorNearPhiFit);
+    gNPhiJt3->SetLineColor(ColorNearPhiFit);
+
+
+    gNYieldEta->SetMarkerStyle(MarkerNearEta);
+    gAYieldEta->SetMarkerStyle(MarkerAwayEta);
+    gNYieldEtaPt->SetMarkerStyle(MarkerNearEta);
+    gAYieldEtaPt->SetMarkerStyle(MarkerAwayEta);
+    gNYieldEta2->SetMarkerStyle(MarkerNearEta);
+    gAYieldEta2->SetMarkerStyle(MarkerAwayEta);
+    gNYieldEtaPt2->SetMarkerStyle(MarkerNearEta);
+    gAYieldEtaPt2->SetMarkerStyle(MarkerAwayEta);
+    gNYieldEta3->SetMarkerStyle(MarkerNearEta);
+    gAYieldEta3->SetMarkerStyle(MarkerAwayEta);
+    gNYieldEtaPt3->SetMarkerStyle(MarkerNearEta);
+    gAYieldEtaPt3->SetMarkerStyle(MarkerAwayEta);
+    gNYieldEta->SetMarkerColor(ColorNearEta);
+    gAYieldEta->SetMarkerColor(ColorAwayEta);
+    gNYieldEta->SetLineColor(ColorNearEta);
+    gAYieldEta->SetLineColor(ColorAwayEta);
+    gNYieldEtaPt->SetMarkerColor(ColorNearEta);
+    gAYieldEtaPt->SetMarkerColor(ColorAwayEta);
+    gNYieldEtaPt->SetLineColor(ColorNearEta);
+    gAYieldEtaPt->SetLineColor(ColorAwayEta);
+    gNYieldEta2->SetMarkerColor(ColorNearEta);
+    gAYieldEta2->SetMarkerColor(ColorAwayEta);
+    gNYieldEta2->SetLineColor(ColorNearEta);
+    gAYieldEta2->SetLineColor(ColorAwayEta);
+    gNYieldEtaPt2->SetMarkerColor(ColorNearEta);
+    gAYieldEtaPt2->SetMarkerColor(ColorAwayEta);
+    gNYieldEtaPt2->SetLineColor(ColorNearEta);
+    gAYieldEtaPt2->SetLineColor(ColorAwayEta);
+    gNYieldEta3->SetMarkerColor(ColorNearEta);
+    gAYieldEta3->SetMarkerColor(ColorAwayEta);
+    gNYieldEta3->SetLineColor(ColorNearEta);
+    gAYieldEta3->SetLineColor(ColorAwayEta);
+    gNYieldEtaPt3->SetMarkerColor(ColorNearEta);
+    gAYieldEtaPt3->SetMarkerColor(ColorAwayEta);
+    gNYieldEtaPt3->SetLineColor(ColorNearEta);
+    gAYieldEtaPt3->SetLineColor(ColorAwayEta);
+    gNYieldEta->SetMarkerSize(MarkerSize);
+    gAYieldEta->SetMarkerSize(MarkerSize);
+    gNYieldEtaPt->SetMarkerSize(MarkerSize);
+    gAYieldEtaPt->SetMarkerSize(MarkerSize);
+    gNYieldEta2->SetMarkerSize(MarkerSize);
+    gAYieldEta2->SetMarkerSize(MarkerSize);
+    gNYieldEtaPt2->SetMarkerSize(MarkerSize);
+    gAYieldEtaPt2->SetMarkerSize(MarkerSize);
+    gNYieldEta3->SetMarkerSize(MarkerSize);
+    gAYieldEta3->SetMarkerSize(MarkerSize);
+    gNYieldEtaPt3->SetMarkerSize(MarkerSize);
+    gAYieldEtaPt3->SetMarkerSize(MarkerSize);
+    gNYieldEtaPt3->SetMarkerSize(MarkerSize);
+
+    gNYieldEtaFit->SetMarkerStyle(MarkerNearEtaFit);
+    gNYieldEtaFit->SetMarkerSize(MarkerSize);
+    gNYieldEtaFit->SetMarkerColor(ColorNearEtaFit);
+    gNYieldEtaFit->SetLineColor(ColorNearEtaFit);
+    gNYieldEtaFit2->SetMarkerStyle(MarkerNearEtaFit);
+    gNYieldEtaFit2->SetMarkerSize(MarkerSize);
+    gNYieldEtaFit2->SetMarkerColor(ColorNearEtaFit);
+    gNYieldEtaFit2->SetLineColor(ColorNearEtaFit);
+    gNYieldEtaFit3->SetMarkerStyle(MarkerNearEtaFit);
+    gNYieldEtaFit3->SetMarkerSize(MarkerSize);
+    gNYieldEtaFit3->SetMarkerColor(ColorNearEtaFit);
+    gNYieldEtaFit3->SetLineColor(ColorNearEtaFit);
+
+    gNYieldEtaFitPt->SetMarkerStyle(MarkerNearEtaFit);
+    gNYieldEtaFitPt->SetMarkerSize(MarkerSize);
+    gNYieldEtaFitPt->SetMarkerColor(ColorNearEtaFit);
+    gNYieldEtaFitPt->SetLineColor(ColorNearEtaFit);
+    gNYieldEtaFitPt2->SetMarkerStyle(MarkerNearEtaFit);
+    gNYieldEtaFitPt2->SetMarkerSize(MarkerSize);
+    gNYieldEtaFitPt2->SetMarkerColor(ColorNearEtaFit);
+    gNYieldEtaFitPt2->SetLineColor(ColorNearEtaFit);
+    gNYieldEtaFitPt3->SetMarkerStyle(MarkerNearEtaFit);
+    gNYieldEtaFitPt3->SetMarkerSize(MarkerSize);
+    gNYieldEtaFitPt3->SetMarkerColor(ColorNearEtaFit);
+    gNYieldEtaFitPt3->SetLineColor(ColorNearEtaFit);
+
+    gNEtaWidth1->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaWidth1->SetMarkerSize(MarkerSize);
+    gNEtaWidth1->SetMarkerColor(ColorNearEtaFit);
+    gNEtaWidth1->SetLineColor(ColorNearEtaFit);
+    gNEtaWidth2->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaWidth2->SetMarkerSize(MarkerSize);
+    gNEtaWidth2->SetMarkerColor(ColorNearEtaFit);
+    gNEtaWidth2->SetLineColor(ColorNearEtaFit);
+    gNEtaWidth3->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaWidth3->SetMarkerSize(MarkerSize);
+    gNEtaWidth3->SetMarkerColor(ColorNearEtaFit);
+    gNEtaWidth3->SetLineColor(ColorNearEtaFit);
+
+    gNEtaJt1->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaJt1->SetMarkerSize(MarkerSize);
+    gNEtaJt1->SetMarkerColor(ColorNearEtaFit);
+    gNEtaJt1->SetLineColor(ColorNearEtaFit);
+    gNEtaJt2->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaJt2->SetMarkerSize(MarkerSize);
+    gNEtaJt2->SetMarkerColor(ColorNearEtaFit);
+    gNEtaJt2->SetLineColor(ColorNearEtaFit);
+    gNEtaJt3->SetMarkerStyle(MarkerNearEtaFit);
+    gNEtaJt3->SetMarkerSize(MarkerSize);
+    gNEtaJt3->SetMarkerColor(ColorNearEtaFit);
+    gNEtaJt3->SetLineColor(ColorNearEtaFit);
+    gNAvePhi1->SetMarkerStyle(MarkerNearPhi);
+    gNAvePhi1->SetMarkerSize(MarkerSize);
+    gNAvePhi1->SetMarkerColor(ColorNearPhi);
+    gNAvePhi1->SetLineColor(ColorNearPhi);
+    gAAvePhi1->SetMarkerStyle(MarkerAwayPhi);
+    gAAvePhi1->SetMarkerSize(MarkerSize);
+    gAAvePhi1->SetMarkerColor(ColorAwayPhi);
+    gAAvePhi1->SetLineColor(ColorAwayPhi);
+    gMAvePhi1->SetMarkerStyle(MarkerMin);
+    gMAvePhi1->SetMarkerSize(MarkerSize);
+    gMAvePhi1->SetMarkerColor(ColorMin);
+    gMAvePhi1->SetLineColor(ColorMin);
+    gNAvePhi2->SetMarkerStyle(MarkerNearPhi);
+    gNAvePhi2->SetMarkerSize(MarkerSize);
+    gNAvePhi2->SetMarkerColor(ColorNearPhi);
+    gNAvePhi2->SetLineColor(ColorNearPhi);
+    gAAvePhi2->SetMarkerStyle(MarkerAwayPhi);
+    gAAvePhi2->SetMarkerSize(MarkerSize);
+    gAAvePhi2->SetMarkerColor(ColorAwayPhi);
+    gAAvePhi2->SetLineColor(ColorAwayPhi);
+    gMAvePhi2->SetMarkerStyle(MarkerMin);
+    gMAvePhi2->SetMarkerSize(MarkerSize);
+    gMAvePhi2->SetMarkerColor(ColorMin);
+    gMAvePhi2->SetLineColor(ColorMin);
+
+
+    gNAvePhiFit1->SetMarkerStyle(MarkerNearPhiFit);
+    gNAvePhiFit1->SetMarkerSize(MarkerSize);
+    gNAvePhiFit1->SetMarkerColor(ColorNearPhiFit);
+    gNAvePhiFit1->SetLineColor(ColorNearPhiFit);
+    gAAvePhiFit1->SetMarkerStyle(MarkerAwayPhiFit);
+    gAAvePhiFit1->SetMarkerSize(MarkerSize);
+    gAAvePhiFit1->SetMarkerColor(ColorAwayPhiFit);
+    gAAvePhiFit1->SetLineColor(ColorAwayPhiFit);
+    gMAvePhiFit1->SetMarkerStyle(MarkerMinFit);
+    gMAvePhiFit1->SetMarkerSize(MarkerSize);
+    gMAvePhiFit1->SetMarkerColor(ColorMinFit);
+    gMAvePhiFit1->SetLineColor(ColorMinFit);
+  
+    gNAvePhiFit2->SetMarkerStyle(MarkerNearPhiFit);
+    gNAvePhiFit2->SetMarkerSize(MarkerSize);
+    gNAvePhiFit2->SetMarkerColor(ColorNearPhiFit);
+    gNAvePhiFit2->SetLineColor(ColorNearPhiFit);
+    gAAvePhiFit2->SetMarkerStyle(MarkerAwayPhiFit);
+    gAAvePhiFit2->SetMarkerSize(MarkerSize);
+    gAAvePhiFit2->SetMarkerColor(ColorAwayPhiFit);
+    gAAvePhiFit2->SetLineColor(ColorAwayPhiFit);
+    gMAvePhiFit2->SetMarkerStyle(MarkerMinFit);
+    gMAvePhiFit2->SetMarkerSize(MarkerSize);
+    gMAvePhiFit2->SetMarkerColor(ColorMinFit);
+    gMAvePhiFit2->SetLineColor(ColorMinFit);
+   
+    char outName[200];
+    sprintf(outName,"%s/DrawSpectra_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d.root",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult);
+    TFile *fout=new TFile(name,"recreate");
+   
+   
+    float plotmin=100, plotmax=-100;
+    plotmin2=100; plotmax2=-100;
+    plotmin3=100; plotmax3=-100;
+    float plotminW=100, plotmaxW=-100;
+    float plotminJ=100, plotmaxJ=-100;
+    float maxheight=100;
+    float plotminAve=100, plotmaxAve=-100;
+    for(int i=0;i<=2;i+=2){
+      for(int j=0;j<nMainLoop;j++){
+       if(NYieldPhiZYAM[i][j]<plotmin)plotmin=NYieldPhiZYAM[i][j];
+       if(NYieldPhiZYAM[i][j]>plotmax&&NYieldPhiZYAM[i][j]<maxheight)plotmax=NYieldPhiZYAM[i][j];
+       if(AYieldPhiZYAM[i][j]<plotmin)plotmin=AYieldPhiZYAM[i][j];
+       if(AYieldPhiZYAM[i][j]>plotmax&&AYieldPhiZYAM[i][j]<maxheight)plotmax=AYieldPhiZYAM[i][j];
+       if(NYieldEtaZYAM[i][j]<plotmin)plotmin=NYieldEtaZYAM[i][j];
+       if(NYieldEtaZYAM[i][j]>plotmax&&NYieldEtaZYAM[i][j]<maxheight)plotmax=NYieldEtaZYAM[i][j];
+       if(AYieldEtaZYAM[i][j]<plotmin)plotmin=AYieldEtaZYAM[i][j];
+       if(AYieldEtaZYAM[i][j]>plotmax&&AYieldEtaZYAM[i][j]<maxheight)plotmax=AYieldEtaZYAM[i][j];
+       if(MYieldPhi[i][j]<plotmin2)plotmin2=MYieldPhi[0][j];
+       if(MYieldPhi[i][j]>plotmax2&&MYieldPhi[0][j]<maxheight)plotmax2=MYieldPhi[0][j];
+       if(MYieldPhi[2][j]<plotmin3)plotmin3=MYieldPhi[2][j];
+       if(MYieldPhi[2][j]>plotmax3&&MYieldPhi[2][j]<maxheight)plotmax3=MYieldPhi[2][j];
+       if(DrawFit){
+         if(NYieldPhiFit[i][j]<plotmin)plotmin=NYieldPhiFit[i][j];
+         if(NYieldPhiFit[i][j]>plotmax&&NYieldPhiFit[i][j]<maxheight)plotmax=NYieldPhiFit[i][j];
+         if(AYieldPhiFit[i][j]<plotmin)plotmin=AYieldPhiFit[i][j];
+         if(AYieldPhiFit[i][j]>plotmax&&AYieldPhiFit[i][j]<maxheight)plotmax=AYieldPhiFit[i][j];
+         if(MYieldPhiFit[0][j]<plotmin2)plotmin2=MYieldPhiFit[0][j];
+         if(MYieldPhiFit[0][j]>plotmax2&&MYieldPhiFit[0][j]<maxheight)plotmax2=MYieldPhiFit[0][j];
+         if(MYieldPhiFit[2][j]<plotmin3)plotmin3=MYieldPhiFit[2][j];
+         if(MYieldPhiFit[2][j]>plotmax3&&MYieldPhiFit[2][j]<maxheight)plotmax3=MYieldPhiFit[2][j];
+       }
+       if(i==0){
+         if(NWidthPhi[0][j]<plotminW)plotminW=NWidthPhi[0][j];
+         if(NWidthPhi[0][j]>plotmaxW&&NWidthPhi[0][j]<5)plotmaxW=NWidthPhi[0][j];
+         if(AWidthPhi[0][j]<plotminW)plotminW=AWidthPhi[0][j];
+         if(AWidthPhi[0][j]>plotmaxW&&AWidthPhi[0][j]<6)plotmaxW=AWidthPhi[0][j];
+         if(NJtPhi[0][j]<plotminJ)plotminJ=NJtPhi[0][j];
+         if(NJtPhi[0][j]>plotmaxJ&&NJtPhi[0][j]<5)plotmaxJ=NJtPhi[0][j];
+         if(AJtPhi[0][j]<plotminJ)plotminJ=AJtPhi[0][j];
+         if(AJtPhi[0][j]>plotmaxJ&&AJtPhi[0][j]<6)plotmaxJ=AJtPhi[0][j];
+         if(NAvePhi[0][j]<plotminAve)plotminAve=NAvePhi[0][j];
+         if(NAvePhi[0][j]>plotmaxAve&&NAvePhi[0][j]<5)plotmaxW=NAvePhi[0][j];
+         if(AAvePhi[0][j]<plotminAve)plotminAve=AAvePhi[0][j];
+         if(AAvePhi[0][j]>plotmaxAve&&AAvePhi[0][j]<6)plotmaxAve=AAvePhi[0][j];
+       }
+      }
+    }
+    plotmin/=1.2-0.2;
+    plotmax*=1.2+0.2;
+    plotmin2/=1.5-0.2;
+    plotmax2*=1.5+0.2;
+    plotmin3/=1.5-0.2;
+    plotmax3*=1.5+0.2;
+    if(plotmax>maxheight)plotmax=maxheight;
+    if(plotmax2>maxheight)plotmax2=maxheight;
+    if(plotmax3>maxheight)plotmax3=maxheight;
+    plotminW/1.5-0.2;
+    plotmaxW*=1.5+0.2;
+    plotmaxJ*=1.5+0.2;
+    plotmaxAve*=1.5+1;
+    plotminAve/=1.6-0.2;
+    plotmin=0;
+    plotmin2=0;
+    plotmin3=0;
+    plotminW=0;
+    plotminJ=0;
+    plotminAve=0;
+    //plotminAve=0;
+    if(plotmin<=0)plotmin=-0.00001;
+    if(plotmin2<=0)plotmin2=-0.00001;
+    if(plotmin3<=0)plotmin3=-0.00001;
+    if(plotminW<=0)plotminW=-0.00001;
+    if(plotminAve<=0)plotminAve=-0.00001;
+    plotmaxW=1;
+
+    cTYield=new TCanvas("cTYield","P_{T}^{Trig} Dependence of Yields",800,600);
+    SetMargins1D(cTYield);
+    sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYield=new TH2F("hTYield",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYield->SetTitle("");
+    hTYield->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYield->GetXaxis()->SetTitleColor(1);
+    hTYield->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
+    SetTitles1D(hTYield);
+    hTYield->Draw();
+    //cTYield->SetLogy(1);
+    gNYieldPhi->Draw("p");
+    gAYieldPhi->Draw("p");
+    if(DrawFit)gNYieldPhiFit->Draw("p");
+    if(DrawFit)gAYieldPhiFit->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_YieldMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYield->SaveAs(outName);
+
+    cTYieldPt=new TCanvas("cTYieldPt","P_{T}^{Trig} Dependence of Peak P_{T}",800,600);
+    SetMargins1D(cTYieldPt);
+    sprintf(name,"Peak P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYieldPt=new TH2F("hTYieldPt",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYieldPt->SetTitle("");
+    hTYieldPt->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYieldPt->GetXaxis()->SetTitleColor(1);
+    hTYieldPt->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
+    SetTitles1D(hTYieldPt);
+    hTYieldPt->Draw();
+    // cTYieldPt->SetLogy(1);
+    gNYieldPhiPt->Draw("p");
+    gAYieldPhiPt->Draw("p");
+    if(DrawFit)gNYieldPhiFitPt->Draw("p");
+    if(DrawFit)gAYieldPhiFitPt->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_PtMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYieldPt->SaveAs(outName);
+
+    cTYield2=new TCanvas("cTYield2","P_{T}^{Trig} Dependence of Yields",800,600);
+    SetMargins1D(cTYield2);
+    sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYield2=new TH2F("hTYield2",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYield2->SetTitle("");
+    hTYield2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYield2->GetXaxis()->SetTitleColor(1);
+    hTYield2->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
+    SetTitles1D(hTYield2);
+    hTYield2->Draw();
+    //cTYield2->SetLogy(1);
+    gNYieldPhi2->Draw("p");
+    gAYieldPhi2->Draw("p");
+    if(DrawFit)gNYieldPhiFit2->Draw("p");
+    if(DrawFit)gAYieldPhiFit2->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_YieldAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYield2->SaveAs(outName);
+
+    cTYieldPt2=new TCanvas("cTYieldPt2","P_{T}^{Trig} Dependence of Peak P_{T}",800,600);
+    SetMargins1D(cTYieldPt2);
+    sprintf(name,"Peak P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYieldPt2=new TH2F("hTYieldPt2",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYieldPt2->SetTitle("");
+    hTYieldPt2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYieldPt2->GetXaxis()->SetTitleColor(1);
+    hTYieldPt2->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
+    SetTitles1D(hTYieldPt2);
+    hTYieldPt2->Draw();
+    //cTYieldPt2->SetLogy(1);
+    gNYieldPhiPt2->Draw("p");
+    gAYieldPhiPt2->Draw("p");
+    if(DrawFit)gNYieldPhiFitPt2->Draw("p");
+    if(DrawFit)gAYieldPhiFitPt2->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_PtAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYieldPt2->SaveAs(outName);
+
+    //low
+    cTYield3=new TCanvas("cTYield3","P_{T}^{Trig} Dependence of Yields",800,600);
+    SetMargins1D(cTYield3);
+    sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYield3=new TH2F("hTYield3",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYield3->SetTitle("");
+    hTYield3->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYield3->GetXaxis()->SetTitleColor(1);
+    hTYield3->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
+    SetTitles1D(hTYield2);
+    hTYield3->Draw();
+    //cTYield2->SetLogy(1);
+    gNYieldPhi3->Draw("p");
+    gAYieldPhi3->Draw("p");
+    if(DrawFit)gNYieldPhiFit3->Draw("p");
+    if(DrawFit)gAYieldPhiFit3->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_YieldLowErr_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYield3->SaveAs(outName);
+
+    cTYieldPt3=new TCanvas("cTYieldPt3","P_{T}^{Trig} Dependence of Peak P_{T}",800,600);
+    SetMargins1D(cTYieldPt3);
+    sprintf(name,"Peak P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYieldPt3=new TH2F("hTYieldPt3",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYieldPt3->SetTitle("");
+    hTYieldPt3->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYieldPt3->GetXaxis()->SetTitleColor(1);
+    hTYieldPt3->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
+    SetTitles1D(hTYieldPt3);
+    hTYieldPt3->Draw();
+    //cTYieldPt2->SetLogy(1);
+    gNYieldPhiPt3->Draw("p");
+    gAYieldPhiPt3->Draw("p");
+    if(DrawFit)gNYieldPhiFitPt3->Draw("p");
+    if(DrawFit)gAYieldPhiFitPt3->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_PtLowErr_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYieldPt3->SaveAs(outName);
+
+
+
+    cTYieldE=new TCanvas("cTYieldE","P_{T}^{Trig} Dependence of Eta Yields",800,600);
+    SetMargins1D(cTYieldE);
+    sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYield=new TH2F("hTYieldE",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYieldE->SetTitle("");
+    hTYieldE->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYieldE->GetXaxis()->SetTitleColor(1);
+    hTYieldE->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
+    SetTitles1D(hTYieldE);
+    hTYieldE->Draw();
+    //cTYield->SetLogy(1);
+    gNYieldEta->Draw("p");
+    gAYieldEta->Draw("p");
+    if(DrawFit)gNYieldEtaFit->Draw("p");
+    // if(DrawFit)gAYieldEtaFit->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_YieldEtaMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYieldE->SaveAs(outName);
+
+    cTYieldPtE=new TCanvas("cTYieldPtE","P_{T}^{Trig} Dependence of Peak P_{T} Eta",800,600);
+    SetMargins1D(cTYieldPtE);
+    sprintf(name,"Peak P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYieldPtE=new TH2F("hTYieldPtE",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYieldPtE->SetTitle("");
+    hTYieldPtE->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYieldPtE->GetXaxis()->SetTitleColor(1);
+    hTYieldPtE->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
+    SetTitles1D(hTYieldPtE);
+    hTYieldPtE->Draw();
+    // cTYieldPt->SetLogy(1);
+    gNYieldEtaPt->Draw("p");
+    gAYieldEtaPt->Draw("p");
+    if(DrawFit)gNYieldEtaFitPt->Draw("p");
+    //if(DrawFit)gAYieldEtaFitPt->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    //if(DrawFit)keySymbol(.65,.7,"Away Fit",ColorAwayEtaFit,MarkerAwayEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_PtEtaMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYieldPt->SaveAs(outName);
+
+  
+    cTYieldC=new TCanvas("cTYieldC","P_{T}^{Trig} Dependence of Yields",800,600);
+    SetMargins1D(cTYieldC);
+    sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYieldC=new TH2F("hTYieldC",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYieldC->SetTitle("");
+    hTYieldC->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYieldC->GetXaxis()->SetTitleColor(1);
+    hTYieldC->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
+    SetTitles1D(hTYieldC);
+    hTYieldC->Draw();
+    //cTYield->SetLogy(1);
+    gNYieldPhi->Draw("p");
+    gAYieldPhi->Draw("p");
+    if(DrawFit)gNYieldPhiFit->Draw("p");
+    if(DrawFit)gAYieldPhiFit->Draw("p");
+    gNYieldEta->Draw("p");
+    gAYieldEta->Draw("p");
+    if(DrawFit)gNYieldEtaFit->Draw("p");
+    // if(DrawFit)gAYieldEtaFit->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.65,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.6,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_YieldCombMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYieldC->SaveAs(outName);
+
+    cTYieldPtC=new TCanvas("cTYieldPtC","P_{T}^{Trig} Dependence of Yields",800,600);
+    SetMargins1D(cTYieldPtC);
+    sprintf(name,"Peak p_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYieldPtC=new TH2F("hTYieldPtC",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYieldPtC->SetTitle("");
+    hTYieldPtC->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYieldPtC->GetXaxis()->SetTitleColor(1);
+    hTYieldPtC->GetYaxis()->SetTitle("#frac{p_{T}^{ch}}{N_{Trigger}}    ");
+    SetTitles1D(hTYieldPtC);
+    hTYieldPtC->Draw();
+    //cTYield->SetLogy(1);
+    gNYieldPhiPt->Draw("p");
+    gAYieldPhiPt->Draw("p");
+    if(DrawFit)gNYieldPhiFitPt->Draw("p");
+    if(DrawFit)gAYieldPhiFitPt->Draw("p");
+    gNYieldEtaPt->Draw("p");
+    gAYieldEtaPt->Draw("p");
+    if(DrawFit)gNYieldEtaFitPt->Draw("p");
+    // if(DrawFit)gAYieldEtaFit->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.65,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.6,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_PtCombMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYieldPtC->SaveAs(outName);
+
+    //
+    cTYieldC2=new TCanvas("cTYieldC2","P_{T}^{Trig} Dependence of Yields 2",800,600);
+    SetMargins1D(cTYieldC2);
+    sprintf(name,"Yields %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYieldC2=new TH2F("hTYieldC2",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYieldC2->SetTitle("");
+    hTYieldC2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYieldC2->GetXaxis()->SetTitleColor(1);
+    hTYieldC2->GetYaxis()->SetTitle("#frac{N_{ch}}{N_{Trigger}}    ");
+    SetTitles1D(hTYieldC2);
+    hTYieldC2->Draw();
+    //cTYield->SetLogy(1);
+    gNYieldPhi2->Draw("p");
+    gAYieldPhi2->Draw("p");
+    if(DrawFit)gNYieldPhiFit2->Draw("p");
+    if(DrawFit)gAYieldPhiFit2->Draw("p");
+    gNYieldEta2->Draw("p");
+    gAYieldEta2->Draw("p");
+    if(DrawFit)gNYieldEtaFit2->Draw("p");
+    // if(DrawFit)gAYieldEtaFit->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.65,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.6,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_YieldCombAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYieldC2->SaveAs(outName);
+
+    cTYieldPtC2=new TCanvas("cTYieldPtC2","P_{T}^{Trig} Dependence of Yields",800,600);
+    SetMargins1D(cTYieldPtC2);
+    sprintf(name,"Peak p_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTYieldPtC2=new TH2F("hTYieldPtC2",name,10,0,TPt2+1,10,plotmin,plotmax);
+    if(NoTitle)hTYieldPtC2->SetTitle("");
+    hTYieldPtC2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTYieldPtC2->GetXaxis()->SetTitleColor(1);
+    hTYieldPtC2->GetYaxis()->SetTitle("#frac{p_{T}^{ch}}{N_{Trigger}}    ");
+    SetTitles1D(hTYieldPtC2);
+    hTYieldPtC2->Draw();
+    //cTYield->SetLogy(1);
+    gNYieldPhiPt2->Draw("p");
+    gAYieldPhiPt2->Draw("p");
+    if(DrawFit)gNYieldPhiFitPt2->Draw("p");
+    if(DrawFit)gAYieldPhiFitPt2->Draw("p");
+    gNYieldEtaPt2->Draw("p");
+    gAYieldEtaPt2->Draw("p");
+    if(DrawFit)gNYieldEtaFitPt2->Draw("p");
+    // if(DrawFit)gAYieldEtaFit->Draw("p");
+    sprintf(name,"Near #Delta#phi |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.65,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.75,"Near #Delta#phi Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.7,"Away #Delta#phi Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.65,"Near #Delta#eta",ColorNearEta,MarkerNearEta,0.06,1.2*MarkerSize);
+    keySymbol(.65,.6,"Away #Delta#eta",ColorAwayEta,MarkerAwayEta,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.65,.55,"Near #Delta#eta Fit",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_PtCombAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTYieldPtC2->SaveAs(outName);
+
+
+    //
+    cTMin=new TCanvas("cTMin","P_{T}^{Trig} Dependence of Underlying Event",800,600);
+    SetMargins1D(cTMin);
+    sprintf(name,"Underlying Event %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTMin=new TH2F("hTMin",name,10,0,TPt2+1,10,plotmin2,plotmax2);
+    if(NoTitle)hTMin->SetTitle("");
+    hTMin->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTMin->GetXaxis()->SetTitleColor(1);
+    hTMin->GetYaxis()->SetTitle("#frac{p_{T}^{ch}}{N_{Trigger}}    ");
+    SetTitles1D(hTMin);
+    hTMin->Draw();
+    // cTMin->SetLogy(1);
+    gMYieldPhi->Draw("p");
+    if(DrawFit)gMYieldPhiFit->Draw("p");
+    sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
+    keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_MinMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTMin->SaveAs(outName);
+
+    cTMinPt=new TCanvas("cTMinPt","P_{T}^{Trig} Dependence of Underlying Event P_{T}",800,600);
+    SetMargins1D(cTMinPt);
+    sprintf(name,"Min P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTMinPt=new TH2F("hTMinPt",name,10,0,TPt2+1,10,plotmin3,plotmax3);
+    if(NoTitle)hTMinPt->SetTitle("");
+    hTMinPt->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTMinPt->GetXaxis()->SetTitleColor(1);
+    hTMinPt->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
+    SetTitles1D(hTMinPt);
+    hTMinPt->Draw();
+    //cTMinPt->SetLogy(1);
+    gMYieldPhiPt->Draw("p");
+    if(DrawFit)gMYieldPhiFitPt->Draw("p");
+    sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
+    keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_MinPtMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTMinPt->SaveAs(outName);
+
+    cTMin2=new TCanvas("cTMin2","P_{T}^{Trig} Dependence of Underlying Event",800,600);
+    SetMargins1D(cTMin2);
+    sprintf(name,"Underlying Event %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTMin2=new TH2F("hTMin2",name,10,0,TPt2+1,10,plotmin2,plotmax2);
+    if(NoTitle)hTMin2->SetTitle("");
+    hTMin2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTMin2->GetXaxis()->SetTitleColor(1);
+    hTMin2->GetYaxis()->SetTitle("#frac{1}{N_{Trigger}}    ");
+    SetTitles1D(hTMin2);
+    hTMin2->Draw();
+    //cTMin2->SetLogy(1);
+    gMYieldPhi2->Draw("p");
+    if(DrawFit)gMYieldPhiFit2->Draw("p");
+    sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
+     keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_MinAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTMin2->SaveAs(outName);
+
+    cTMinPt2=new TCanvas("cTMinPt2","P_{T}^{Trig} Dependence of Underlying Event P_{T}",800,600);
+    SetMargins1D(cTMinPt2);
+    sprintf(name,"Min P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTMinPt2=new TH2F("hTMinPt2",name,10,0,TPt2+1,10,plotmin3,plotmax3);
+    if(NoTitle)hTMinPt2->SetTitle("");
+    hTMinPt2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTMinPt2->GetXaxis()->SetTitleColor(1);
+    hTMinPt2->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
+    SetTitles1D(hTMinPt2);
+    hTMinPt2->Draw();
+    //cTMinPt2->SetLogy(1);
+    gMYieldPhiPt2->Draw("p");
+    if(DrawFit)gMYieldPhiFitPt2->Draw("p");
+    sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
+    keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_MinPtAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffCorr,APtTPtMult,FitTit[DrawFit],filetype);
+    cTMinPt2->SaveAs(outName); 
+
+    cTMin3=new TCanvas("cTMin3","P_{T}^{Trig} Dependence of Underlying Event",800,600);
+    SetMargins1D(cTMin3);
+    sprintf(name,"Underlying Event %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTMin3=new TH2F("hTMin3",name,10,0,TPt2+1,10,plotmin2,plotmax2);
+    if(NoTitle)hTMin3->SetTitle("");
+    hTMin3->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTMin3->GetXaxis()->SetTitleColor(1);
+    hTMin3->GetYaxis()->SetTitle("#frac{N}{N_{Trigger}}    ");
+    SetTitles1D(hTMin3);
+    hTMin3->Draw();
+    //cTMin2->SetLogy(1);
+    gMYieldPhi3->Draw("p");
+    if(DrawFit)gMYieldPhiFit3->Draw("p");
+    sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
+    keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_MinLowErr_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffCorr,APtTPtMult,FitTit[DrawFit],filetype);
+    cTMin3->SaveAs(outName);
+
+    cTMinPt3=new TCanvas("cTMinPt3","P_{T}^{Trig} Dependence of Underlying Event P_{T}",800,600);
+    SetMargins1D(cTMinPt3);
+    sprintf(name,"Min P_{T} %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTMinPt3=new TH2F("hTMinPt3",name,10,0,TPt2+1,10,plotmin3,plotmax3);
+    if(NoTitle)hTMinPt3->SetTitle("");
+    hTMinPt3->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTMinPt3->GetXaxis()->SetTitleColor(1);
+    hTMinPt3->GetYaxis()->SetTitle("#frac{p_{T}}{N_{Trigger}}    ");
+    SetTitles1D(hTMinPt3);
+    hTMinPt3->Draw();
+    //cTMinPt2->SetLogy(1);
+    gMYieldPhiPt3->Draw("p");
+    if(DrawFit)gMYieldPhiFitPt3->Draw("p");
+    sprintf(name,"ZYAM |#Delta#phi#pm%1.1f|<%1.1f",ZYAMCent,ZYAMWidth);
+    keySymbol(.5,.85,name,ColorMin,MarkerMin,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.8,"Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_MinPtLowErr_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffCorr,APtTPtMult,filetype);
+    cTMinPt3->SaveAs(outName); 
+    cWidth1=new TCanvas("cWidth1","Width MidPoint",800,600);
+    SetMargins1D(cWidth1);
+    sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hWidth1=new TH2F("hWidth1",name,10,0,TPt2+1,10,plotminW,plotmaxW);
+    if(NoTitle)hWidth1->SetTitle("");
+    hWidth1->GetXaxis()->SetTitle("p_{T}^{Trig} (GeV/c) ");
+    hWidth1->GetXaxis()->SetTitleColor(1);
+    hWidth1->GetYaxis()->SetTitle("#sigma (radians)   ");
+    SetTitles1D(hWidth1);
+    hWidth1->Draw();
+    gNPhiWidth1->Draw("p");
+    gAPhiWidth1->Draw("p");
+    gNEtaWidth1->Draw("p");
+    keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_WidthTrigMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,filetype);
+    cWidth1->SaveAs(outName);
+
+    cWidth2=new TCanvas("cWidth2","Width Average",800,600);
+    SetMargins1D(cWidth2);
+    sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hWidth2=new TH2F("hWidth2",name,10,0,TPt2+1,10,plotminW,plotmaxW);
+    if(NoTitle)hWidth2->SetTitle("");
+    hWidth2->GetXaxis()->SetTitle("p_{T}^{Trig} (GeV/c) ");
+    hWidth2->GetXaxis()->SetTitleColor(1);
+    hWidth2->GetYaxis()->SetTitle("#sigma (radians)   ");
+    SetTitles1D(hWidth2);
+    hWidth2->Draw();
+    gNPhiWidth2->Draw("p");
+    gAPhiWidth2->Draw("p");
+    gNEtaWidth2->Draw("p");
+    keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_WidthTrigAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,filetype);
+    cWidth2->SaveAs(outName);
+
+    cWidth3=new TCanvas("cWidth3","Width Low Err",800,600);
+    SetMargins1D(cWidth3);
+    sprintf(name,"Peak Width %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hWidth3=new TH2F("hWidth3",name,10,0,TPt2+1,10,plotminW,plotmaxW);
+    if(NoTitle)hWidth3->SetTitle("");
+    hWidth3->GetXaxis()->SetTitle("p_{T}^{Trig} (GeV/c) ");
+    hWidth3->GetXaxis()->SetTitleColor(1);
+    hWidth3->GetYaxis()->SetTitle("#sigma (radians)   ");
+    SetTitles1D(hWidth3);
+    hWidth3->Draw();
+    gNPhiWidth3->Draw("p");
+    gAPhiWidth3->Draw("p");
+    gNEtaWidth3->Draw("p");
+    keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.75,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_WidthTrigLowError_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,filetype);
+    cWidth3->SaveAs(outName);
+
+    cJt1=new TCanvas("cJt1","Jt MidPoint",800,600);
+    SetMargins1D(cJt1);
+    sprintf(name,"Peak Jt %3.1f<Pt^{Trig}<%3.1f %dM%d",TPt1,TPt2,Mult1,Mult2);
+    TH2F *hJt1=new TH2F("hJt1",name,10,0,TPt2+1,10,plotminJ,plotmaxJ);
+    if(NoTitle)hJt1->SetTitle("");
+    hJt1->GetXaxis()->SetTitle("p_{T}^{Trig} (GeV/c) ");
+    hJt1->GetXaxis()->SetTitleColor(1);
+    hJt1->GetYaxis()->SetTitle("#sqrt{<j_{T}^{2}>}   ");
+    SetTitles1D(hJt1);
+    hJt1->Draw();
+    gNPhiJt1->Draw("p");
+    //  gAPhiJt1->Draw("p");
+    gNEtaJt1->Draw("p");
+    keySymbol(.65,.85,"Near #Delta#phi",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    // keySymbol(.65,.8,"Away #Delta#phi",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    keySymbol(.65,.8,"Near #Delta#eta",ColorNearEtaFit,MarkerNearEtaFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_JtTrigMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,filetype);
+    cJt1->SaveAs(outName);
+
+    cTAve=new TCanvas("cTAve","P_{T}^{Trig} Dependence of <p_{T}>",800,600);
+    SetMargins1D(cTAve);
+    sprintf(name,"<p_{T}^{Assoc}> %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTAve=new TH2F("hTAve",name,10,0,TPt2+1,10,plotminAve,plotmaxAve);
+    if(NoTitle)hTAve->SetTitle("");
+    hTAve->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTAve->GetXaxis()->SetTitleColor(1);
+    hTAve->GetYaxis()->SetTitle("<p_{T}^{Assoc}>    ");
+    SetTitles1D(hTAve);
+    hTAve->Draw();
+    //cTYield->SetLogy(1);
+    gNAvePhi1->Draw("p");
+    gAAvePhi1->Draw("p");
+    gMAvePhi1->Draw("p");
+    if(DrawFit)gNAvePhiFit1->Draw("p");
+    if(DrawFit)gAAvePhiFit1->Draw("p");
+    if(DrawFit)gMAvePhiFit1->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.50,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.50,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    keySymbol(.50,.75,"Underlying Event",ColorMin,MarkerMin,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.70,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.65,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.50,.6,"Underlying Event Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_AveMidPoint_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTAve->SaveAs(outName);
+
+    cTAve2=new TCanvas("cTAve2","P_{T}^{Trig} Dependence of <p_{T}>",800,600);
+    SetMargins1D(cTAve2);
+    sprintf(name,"<p_{T}^{Assoc}> %3.2f<Pt^{Assoc}<%3.1f %dM%d",APt1,APt2,Mult1,Mult2);
+    TH2F *hTAve2=new TH2F("hTAve2",name,10,0,TPt2+1,10,plotminAve,plotmaxAve);
+    if(NoTitle)hTAve2->SetTitle("");
+    hTAve2->GetXaxis()->SetTitle("p_{T}^{Trigger} (GeV/c) ");
+    hTAve2->GetXaxis()->SetTitleColor(1);
+    hTAve2->GetYaxis()->SetTitle("<p_{T}^{Assoc}>    ");
+    SetTitles1D(hTAve2);
+    hTAve2->Draw();
+    //cTYield->SetLogy(1);
+    gNAvePhi2->Draw("p");
+    gAAvePhi2->Draw("p");
+    gMAvePhi2->Draw("p");
+    if(DrawFit)gNAvePhiFit2->Draw("p");
+    if(DrawFit)gAAvePhiFit2->Draw("p");
+    if(DrawFit)gMAvePhiFit2->Draw("p");
+    sprintf(name,"Near |#Delta#phi|<%1.1f",NearWidthPhi);
+    keySymbol(.50,.85,name,ColorNearPhi,MarkerNearPhi,0.06,1.2*MarkerSize);
+    keySymbol(.50,.8,"Away",ColorAwayPhi,MarkerAwayPhi,0.06,1.2*MarkerSize);
+    keySymbol(.50,.75,"Underlying Event",ColorMin,MarkerMin,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.70,"Near Fit",ColorNearPhiFit,MarkerNearPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.5,.65,"Away Fit",ColorAwayPhiFit,MarkerAwayPhiFit,0.06,1.2*MarkerSize);
+    if(DrawFit)keySymbol(.50,.6,"Underlying Event Fit",ColorMinFit,MarkerMinFit,0.06,1.2*MarkerSize);
+    sprintf(outName,"%s/DrawSpectra_AveAve_%3.1fPT%3.1f_%3.1fpt%3.1f_%dM%d_C%d_%d%s%s",Folder,TPt1,TPt2,APt1,APt2,Mult1,Mult2,EffMethod,APtTPtMult,FitTit[DrawFit],filetype);
+    cTAve2->SaveAs(outName);
+  }
+}
diff --git a/PWG4/macros/jcorran/SingleEff.C b/PWG4/macros/jcorran/SingleEff.C
new file mode 100755 (executable)
index 0000000..899210f
--- /dev/null
@@ -0,0 +1,91 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+//Obtain single particle efficiencies from output AliAnalysisTaskDiHadron (when ran over MC events and MC histograms filled)
+//Author: Jason Glyndwr Ulery, ulery@uni-frankfurt.de
+
+
+
+#ifndef __CINT__
+#include <TF1.h>
+#include <TF2.h>
+#include "TSystem.h"
+#include <iostream>
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TRandom.h>
+#include <fstream>
+#include "TList.h"
+#include "TArrayF.h"
+#endif
+
+void SingleEff(int Cent){
+  gROOT->Reset();
+  gROOT->LoadMacro("Util9.C");
+  Style(1);
+  
+  
+  // char *EffFolder="2010-08-13/7Pythia_LHC10b5";
+     char *EffFolder="2010-08-13/LHC10c6_900Pythia";
+
+  char effName[100];
+  sprintf(effName,"%s/julery_DiHadron.root",EffFolder);
+  TFile *effFile=new TFile(effName);
+  TList *effList=effFile->Get("julery_DiHadron");
+
+  char name[100];
+  sprintf(name,"fHistPtEff_C%d",Cent);
+  TH1F *fHistPt=(TH1F*)effList->FindObject(name);
+  sprintf(name,"fHistPtEff_C%d_MC",Cent);
+  TH1F *fHistPtMC=(TH1F*)effList->FindObject(name);
+
+  TH1F *fHistEff=(TH1F*)fHistPt->Clone();
+  fHistEff->SetName("fHistEff");
+  fHistEff->GetYaxis()->SetTitle("Efficiency+Contamination");
+  fHistEff->SetTitle("");
+  fHistEff->Divide(fHistPtMC);
+
+  c1=new TCanvas("c1","",800,600);
+  fHistEff->Draw();
+  fHistEff->SetMaximum(1);
+  fHistEff->SetMinimum(0);
+  fHistEff->GetXaxis()->SetRange(0,100);
+  //c1->SetLogx(1);
+  //TF1 *fit1=new TF1("fit1","[0]+[1]*x+[2]*x**2+[3]*x**3+[4]*x**4+[5]*x**5",0,100);
+  //fit1->SetParameters(0.8,0.001,0.001,0.001,0.001,0.001)
+  fit2=new TF1("fit2","[0]",3,100);
+  fit2->SetParameter(0,0.8);
+    TF1 *fit3=new TF1("fit3","[0]/[1]*exp(-0.5*pow(x/[1],2))+[2]+[3]*x",0,3);
+    fit3->SetParameters(0.1,0.1,1,0.1,0.1,0.1);
+    fit3->SetParLimits(0,-2,0);
+    fit3->SetLineColor(4);
+  fHistEff->Fit(fit3,"r");
+  fit2->SetLineColor(2);
+  fHistEff->Fit(fit2,"r");
+  fit3->Draw("same");
+  sprintf(name,"%s/SingleEff1_%d.gif",EffFolder,Cent);
+  c1->SaveAs(name);
+   c2=new TCanvas("c2","",800,600);
+  fHistEff->GetXaxis()->SetRange(0,30);
+  fHistEff->Draw();
+  fit2->Draw("same");
+  fit3->Draw("same");
+  sprintf(name,"%s/SingleEff2_%d.gif",EffFolder,Cent);
+  c2->SaveAs(name);
+
+  cout << fit3->GetParameter(0) << ", " << fit3->GetParameter(1) << ", " << fit3->GetParameter(2) << ", " << fit3->GetParameter(3) << endl;
+  cout << fit2->GetParameter(0) << endl;
+
+}
diff --git a/PWG4/macros/jcorran/Util.C b/PWG4/macros/jcorran/Util.C
new file mode 100755 (executable)
index 0000000..8237845
--- /dev/null
@@ -0,0 +1,2352 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+//Functions used by the other macros
+//Author: Jason Glyndwr Ulery, ulery@uni-frankfurt.de
+
+void MakeProjections(Float_t &xTPt1, Float_t &xTPt2, Float_t &xAPt1, Float_t &xAPt2, Int_t xCent, TList *xList, TH1F *xOutHistPhi, TH1F *xOutHistPhiMix, TH1F *xOutHistEtaN, TH1F *xOutHistEtaNMix, TH1F *xOutHistEtaA, TH1F *xOutHistEtaAMix, TH2F *xOutHistPhiEta, TH2F *xOutHistPhiEtaMix, Float_t xMPt[4], Int_t xptweighted=0, Int_t xMC=0, Int_t xNotDelta=0, Int_t xSign=0){//(Trigger Pt Low, Trigger Pt High, Assoc Pt Low, Assoc Pt High, Centrality Bin, List, Hists, mean pt array, Pt weighted?, Monty Carlo?, gives phi from triggered and from all for delta phi and delta phi mixed respectively) 
+  // TFile *xFile=new TFile(xFileName);
+  //TList *xList=xFile->Get("julery_DiHadron");
+  //This needs changed if Input binning is changed
+  //cout << xptweighted << " " << xMC << " " << xNotDelta << " " << xSign << endl;
+  const int xnpt=12;
+  //float xptbins[(xnpt+1)]={2.5,3,4,6,8,10,15,20,30,40,50,75,100};
+  //IF you change also change in EffFit
+  float xptbins[(xnpt+1)]={2,2.5,3,4,5,6,8,10,15,20,30,40,50};
+  const int xapt=30;
+  float xaptbins[(xapt+1)]={0.25,0.5,0.75,1,1.5,2,2.5,3,3.5,4,4.5,5,6,7,8,9,10,12,15,20,25,30,35,40,45,50,60,70,80,90,100};
+  float xPi=3.1415926535898;
+  
+  //After this no changes should be needed
+  float xsum1,xsum2,xerr1,xerr2;
+  int xtpt1=-1,xtpt2=-1;
+  TH2F *xtemphist1;
+  TH2F *xtemphist2;
+  TH3F *xtemphist3;
+  TH3F *xtemphist4;
+  TH2F *xtemphistEN;
+  TH2F *xtemphistENM;
+  TH2F *xtemphistEA;
+  TH2F *xtemphistEAM;
+  int xapt1,xapt2,xapt3,xapt4;
+  
+  for(int xi=0;xi<=xnpt;xi++){
+    if(fabs(xTPt1-xptbins[xi])<0.2)xtpt1=xi;
+    if(fabs(xTPt2-xptbins[xi])<0.2)xtpt2=xi;
+  }
+  //cout << xtpt1 << " " << xtpt2 << endl;
+  if(xtpt1<0)cout << "Invalid Trigger Pt1" << endl;
+  if(xtpt2<0)cout << "Invalid Trigger Pt2" << endl;
+  if(xtpt1<0||xtpt2<0)break;
+  
+  
+  if(xAPt2>xTPt1){
+    cout << "Associateds must be less then trigger (Automatically forced)" << endl;
+    xAPt2=xTPt1;
+  }
+  for(int xi=0;xi<=xapt;xi++){
+    if(fabs(xAPt1-xaptbins[xi])<0.1)xapt1=xi+1;
+    if(fabs(xAPt2-xaptbins[xi])<0.1)xapt2=xi;
+  }
+  // cout << xapt1 << " " << xapt2 << endl;
+  //since there are some tolerences reset the values to what are actually used
+  // xAPt1=(xapt1-1)*xasswidth;
+  // xAPt2=(xapt2-1)*xasswidth;
+  xAPt1=xaptbins[xapt1-1];
+  xAPt2=xaptbins[xapt2];
+  xTPt1=xptbins[xtpt1];
+  xTPt2=xptbins[xtpt2];
+  cout << "xTPt: "<< xTPt1 <<  " - " << xTPt2 << endl; 
+  cout << "xAPt: " << xAPt1 << " - " << xAPt2 << endl;
+  float xntrig=0,xnmix=0,xntrigpt=0;
+  float exntrig=0,exntrigpt=0;
+  char xname[150];
+  char *cpt1[2]={"","Pt"};
+  char *cdelta2[2]={"DeltaPhiEta","PhiEtaTrig"};
+  char *cdelta1[2]={"DeltaPhi","PhiTrig"};
+  char *cmc1[2]={"","_MC"};
+  char *sign1[3]={"","_LS","_ULS"};
+  char *sign2[3]={""," LikeSign"," UnlikeSign"};
+  char *xEtaN[2]={"DeltaEtaN","EtaTrig"};
+  char *xEtaA[2]={"DeltaEtaA","EtaTrig"};
+  
+  
+  sprintf(xname,"fHistNTrigger_C%d%s",xCent,cmc1[xMC]);
+  TH1F *xNTrig=(TH1F*)xList->FindObject(xname);
+  sprintf(xname,"fHistNMix_C%d%s",xCent,cmc1[xMC]);
+  TH1F *xNMix=(TH1F*)xList->FindObject(xname);
+  sprintf(xname,"fHistNTriggerPt_C%d%s",xCent,cmc1[xMC]);
+  TH1F *xNTrigPt=(TH1F*)xList->FindObject(xname);
+  sprintf(xname,"fHistMult%s",cmc1[xMC]);
+  TH1F *xMult=(TH1F*)xList->FindObject(xname);
+  int xnevent=xMult->GetEntries();
+  
+  for(int xi=xtpt1;xi<xtpt2;xi++){//Do for all trigger pt ranges we are adding
+    sprintf(xname,"fHist%s%s_P%d_C%d%s%s",cdelta1[xNotDelta],cpt1[xptweighted],xi,xCent,sign1[xSign],cmc1[xMC]);
+    xtemphist1=(TH2F*)xList->FindObject(xname);
+    sprintf(xname,"fHistDeltaPhiMix%s_P%d_C%d%s%s",cpt1[xptweighted],xi,xCent,sign1[xSign],cmc1[xMC]);
+    if(xNotDelta) sprintf(xname,"fHistPhi%s_C%d%s",cpt1[xptweighted],xCent,cmc1[xMC]);
+    xtemphist2=(TH2F*)xList->FindObject(xname);
+    
+    sprintf(xname,"fHist%s%s_P%d_C%d%s%s",xEtaN[xNotDelta],cpt1[xptweighted],xi,xCent,sign1[xSign],cmc1[xMC]);
+    xtemphistEN=(TH2F*)xList->FindObject(xname);
+    
+    sprintf(xname,"fHistDeltaEtaNMix%s_P%d_C%d%s%s",cpt1[xptweighted],xi,xCent,sign1[xSign],cmc1[xMC]);
+    if(xNotDelta) sprintf(xname,"fHistEta%s_C%d%s",cpt1[xptweighted],xCent,cmc1[xMC]);
+    xtemphistENM=(TH2F*)xList->FindObject(xname);
+    
+    
+    sprintf(xname,"fHist%s%s_P%d_C%d%s%s",xEtaA[xNotDelta],cpt1[xptweighted],xi,xCent,sign1[xSign],cmc1[xMC]);
+    xtemphistEA=(TH2F*)xList->FindObject(xname);
+    sprintf(xname,"fHistDeltaEtaAMix%s_P%d_C%d%s%s",cpt1[xptweighted],xi,xCent,sign1[xSign],cmc1[xMC]);
+    if(xNotDelta) sprintf(xname,"fHistEta%s_C%d%s",cpt1[xptweighted],xCent,cmc1[xMC]);
+    xtemphistEAM=(TH2F*)xList->FindObject(xname);
+    
+    sprintf(xname,"fHist%s%s_P%d_C%d%s",cdelta2[xNotDelta],cpt1[xptweighted],xi,xCent,cmc1[xMC]);
+    xtemphist3=(TH3F*)xList->FindObject(xname);
+    sprintf(xname,"fHistDeltaPhiEtaMix%s_P%d_C%d%s",cpt1[xptweighted],xi,xCent,cmc1[xMC]);
+    if(xNotDelta) sprintf(xname,"fHistPhiEta%s_C%d%s",cpt1[xptweighted],xCent,cmc1[xMC]);
+    xtemphist4=(TH3F*)xList->FindObject(xname);
+    //c12355=new TCanvas("c12355","c12355");
+    // xtemphist4->Draw();
+    
+    xntrig+=xNTrig->GetBinContent(xi+1);
+    xnmix+=xNMix->GetBinContent(xi+1);
+    exntrig+=pow(xNTrig->GetBinError(xi+1),2);
+    xntrigpt+=xNTrigPt->GetBinContent(xi+1);
+    exntrigpt+=pow(xNTrigPt->GetBinError(xi+1),2);
+    if(xi==xtpt1){
+      TH2F *xDeltaPhi=(TH2F*)xtemphist1->Clone();
+      xDeltaPhi->SetName("xDeltaPhi");
+      TH2F *xDeltaPhiMix=(TH2F*)xtemphist2->Clone();
+      xDeltaPhiMix->SetName("xDeltaPhiMix");
+      int xnbins=xDeltaPhi->GetNbinsX();
+      float xmin=xDeltaPhi->GetBinCenter(1)-(xDeltaPhi->GetBinWidth(1))/2.;
+      float xmax=xDeltaPhi->GetBinCenter(xnbins)+(xDeltaPhi->GetBinWidth(xnbins))/2.;
+      
+      TH2F *xDeltaEtaN=(TH2F*)xtemphistEN->Clone();
+      xDeltaEtaN->SetName("xDeltaEtaN");
+      
+      TH2F *xDeltaEtaNMix=(TH2F*)xtemphistENM->Clone();
+      xDeltaEtaNMix->SetName("xDeltaEtaNMix");
+      int xnEbins=xDeltaEtaN->GetNbinsX();
+      //cout << xnEbins << "EtaBins" << endl;
+      float xEmin=xDeltaEtaN->GetBinCenter(1)-(xDeltaEtaN->GetBinWidth(1))/2.;
+      float xEmax=xDeltaEtaN->GetBinCenter(xnEbins)+(xDeltaEtaN->GetBinWidth(xnEbins))/2.; 
+      
+      TH2F *xDeltaEtaA=(TH2F*)xtemphistEA->Clone();
+      xDeltaEtaA->SetName("xDeltaEtaA");
+      TH2F *xDeltaEtaAMix=(TH2F*)xtemphistEAM->Clone();
+      xDeltaEtaAMix->SetName("xDeltaEtaAMix");
+      
+      TH3F *xDeltaPhiEta=(TH3F*)xtemphist3->Clone();
+      xDeltaPhiEta->SetName("xDeltaPhiEta");
+      TH3F *xDeltaPhiEtaMix=(TH3F*)xtemphist4->Clone();
+      xDeltaPhiEtaMix->SetName("xDeltaPhiEtaMix");
+      TAxis *xAxis=xDeltaPhiEta->GetXaxis();
+      TAxis *xAxis2=xDeltaPhiEta->GetXaxis();
+      TAxis *yAxis2=xDeltaPhiEta->GetYaxis();
+      int xnbins2=xAxis2->GetNbins();
+      int ynbins2=yAxis2->GetNbins();
+      float xmin2=xAxis2->GetBinCenter(1)-(xAxis2->GetBinWidth(1))/2.;
+      float xmax2=xAxis2->GetBinCenter(xnbins2)+(xAxis2->GetBinWidth(xnbins2))/2.;
+      float ymin2=yAxis2->GetBinCenter(1)-(yAxis2->GetBinWidth(1))/2.;
+      float ymax2=yAxis2->GetBinCenter(ynbins2)+(yAxis2->GetBinWidth(ynbins2))/2.;
+      //cout << "Sum Phi " << xDeltaPhi->GetSum() << endl;
+    }
+    else{
+      for(int xj=1;xj<=xnbins;xj++){
+       for(int xk=xapt1;xk<=xapt2;xk++){
+         xDeltaPhi->SetBinContent(xj,xk,(xDeltaPhi->GetBinContent(xj,xk)+xtemphist1->GetBinContent(xj,xk)));
+         xDeltaPhi->SetBinError(xj,xk,sqrt(pow(xDeltaPhi->GetBinError(xj,xk),2)+pow(xtemphist1->GetBinError(xj,xk),2)));
+         if(!xNotDelta)xDeltaPhiMix->SetBinContent(xj,xk,(xDeltaPhiMix->GetBinContent(xj,xk)+xtemphist2->GetBinContent(xj,xk)));
+         if(!xNotDelta)xDeltaPhiMix->SetBinError(xj,xk,sqrt(pow(xDeltaPhiMix->GetBinError(xj,xk),2)+pow(xtemphist2->GetBinError(xj,xk),2)));                   
+       }
+      }//end phi loop
+      
+      for(int xj=1;xj<=xnEbins;xj++){
+       for(int xk=xapt1;xk<=xapt2;xk++){
+         xDeltaEtaN->SetBinContent(xj,xk,(xDeltaEtaN->GetBinContent(xj,xk)+xtemphistEN->GetBinContent(xj,xk)));
+         xDeltaEtaN->SetBinError(xj,xk,sqrt(pow(xDeltaEtaN->GetBinError(xj,xk),2)+pow(xtemphistEN->GetBinError(xj,xk),2)));
+         if(!xNotDelta)xDeltaEtaNMix->SetBinContent(xj,xk,(xDeltaEtaNMix->GetBinContent(xj,xk)+xtemphistENM->GetBinContent(xj,xk)));
+         if(!xNotDelta)xDeltaEtaNMix->SetBinError(xj,xk,sqrt(pow(xDeltaEtaNMix->GetBinError(xj,xk),2)+pow(xtemphistENM->GetBinError(xj,xk),2)));
+         
+         xDeltaEtaA->SetBinContent(xj,xk,(xDeltaEtaA->GetBinContent(xj,xk)+xtemphistEA->GetBinContent(xj,xk)));
+         xDeltaEtaA->SetBinError(xj,xk,sqrt(pow(xDeltaEtaA->GetBinError(xj,xk),2)+pow(xtemphistEA->GetBinError(xj,xk),2)));
+         if(!xNotDelta)xDeltaEtaAMix->SetBinContent(xj,xk,(xDeltaEtaAMix->GetBinContent(xj,xk)+xtemphistEAM->GetBinContent(xj,xk)));
+         if(!xNotDelta)xDeltaEtaAMix->SetBinError(xj,xk,sqrt(pow(xDeltaEtaAMix->GetBinError(xj,xk),2)+pow(xtemphistEAM->GetBinError(xj,xk),2)));
+       }
+      }//end eta loop
+      
+      for(int xj=1;xj<=xnbins2;xj++){
+       for(int xk=1;xk<=ynbins2;xk++){
+         for(int xl=xapt1;xl<=xapt2;xl++){
+           xDeltaPhiEta->SetBinContent(xj,xk,xl,(xDeltaPhiEta->GetBinContent(xj,xk,xl)+xtemphist3->GetBinContent(xj,xk,xl)));
+           xDeltaPhiEta->SetBinError(xj,xk,xl,sqrt(pow(xDeltaPhiEta->GetBinError(xj,xk,xl),2)+pow(xtemphist3->GetBinError(xj,xk,xl),2)));
+           if(!xNotDelta)xDeltaPhiEtaMix->SetBinContent(xj,xk,xl,(xDeltaPhiEtaMix->GetBinContent(xj,xk,xl)+xtemphist4->GetBinContent(xj,xk,xl)));
+           if(!xNotDelta)xDeltaPhiEtaMix->SetBinError(xj,xk,xl,sqrt(pow(xDeltaPhiEtaMix->GetBinError(xj,xk,xl),2)+pow(xtemphist4->GetBinError(xj,xk,xl),2)));
+         }
+       }
+      }//end eta-phi loop
+    }//else
+  }//xi 
+  
+  /*
+    c124=new TCanvas("c124");
+    xtemphist4->Draw();
+    cout << xtemphist4->GetBinContent(10,10,2) << " " << xDeltaPhiEtaMix->GetBinContent(10,10,2) << endl;
+    cout << xtemphist4->GetBinError(10,10,2) << " " << xDeltaPhiEtaMix->GetBinError(10,10,2) << endl;
+    cout << xtemphist4->GetBinContent(10,1,2) << " " << xDeltaPhiEtaMix->GetBinContent(10,1,2) << endl;
+  */
+  
+  
+  cout << "Number of Triggers: " << xntrig << endl;
+  cout << "Number of Mixed Events: " << xnmix << endl;
+  sprintf(xname,"fHistNEvents_C%d",xCent);
+  TH1F *xNEvents=(TH1F*)xList->FindObject(xname);
+  cout << "Number of Events: " << xNEvents->GetBinContent(1) << endl;
+  if(xptweighted)cout << "<P_T Trigger>: " << xntrigpt/xntrig << endl;
+  //cout << xntrigpt << " " << exntrigpt << " " << xntrig << " " << exntrig << endl;
+  if(xptweighted)xMPt[0]=xntrigpt/xntrig;
+  exntrigpt=sqrt(exntrigpt);
+  exntrig=sqrt(exntrig);
+  if(xptweighted)xMPt[1]=xMPt[0]*sqrt(pow(exntrigpt/xntrigpt,2)+pow(exntrig/xntrig,2));
+  xMPt[2]=xntrig;
+  xMPt[3]=xnmix;
+  xDeltaPhi->Scale(xnbins/(2.*xPi)/xntrig);
+  xDeltaEtaN->Scale(xnEbins/(xEmax-xEmin)/xntrig);
+  xDeltaEtaA->Scale(xnEbins/(xEmax-xEmin)/xntrig);
+  xDeltaPhiEta->Scale(xnbins2/(2.*xPi)*ynbins2/(ymax2-ymin2)/xntrig);
+  if(!xNotDelta){
+    xDeltaPhiMix->Scale(xnbins/(2.*xPi)/xnmix);
+    xDeltaEtaNMix->Scale(xnEbins/(xEmax-xEmin)/xnmix);
+    xDeltaEtaAMix->Scale(xnEbins/(xEmax-xEmin)/xnmix);
+    xDeltaPhiEtaMix->Scale(xnbins2/(2.*xPi)*ynbins2/(ymax2-ymin2)/xnmix);
+  }
+  else{
+    xDeltaPhiMix->Scale(xnbins/(2.*xPi)/xnevent);
+    xDeltaEtaNMix->Scale(xnEbins/(xEmax-xEmin)/xnevent);
+    xDeltaEtaAMix->Scale(xnEbins/(xEmax-xEmin)/xnevent);
+    xDeltaPhiEtaMix->Scale(xnbins2/(2.*xPi)*ynbins2/(ymax2-ymin2)/xnevent);
+  }
+  
+  char *tit1="#Delta#phi";
+  if(xNotDelta)tit1="#phi";
+  char *tit11="";
+  if(xptweighted)tit11="p_{T} Weighted";
+  char *tit12="";
+  if(xNotDelta)tit12="Triggered";
+  char *tit2="1";
+  if(xptweighted)tit2="p_{T}";
+  char *tit3="Mixed #Delta#phi";
+  if(xNotDelta)tit3="#phi";
+  
+  sprintf(xname,"%s %s %s Distribution for %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f%s",tit12,tit11,tit1,xTPt1,xTPt2,xAPt1,xAPt2,sign2[xSign]);
+  *xOutHistPhi=new TH1F("dPhi",xname,xnbins,xmin,xmax);
+  xOutHistPhi->Sumw2();
+  sprintf(xname,"%s (radians)     ",tit1);
+  xOutHistPhi->GetXaxis()->SetTitle(xname);
+  sprintf(xname,"#frac{%s}{N_{Trig}}#frac{dN}{d%s}   ",tit2,tit1);
+  xOutHistPhi->GetYaxis()->SetTitle(xname);
+  SetTitles1D(xOutHistPhi);
+  xOutHistPhi->SetMarkerStyle(20);
+  xOutHistPhi->SetMarkerColor(2);
+  xOutHistPhi->SetLineColor(2);
+  
+  sprintf(xname,"%s %s Distribution for %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f%s",tit11,tit3, xTPt1,xTPt2,xAPt1,xAPt2,sign2[xSign]);
+  *xOutHistPhiMix=new TH1F("dMix",xname,xnbins,xmin,xmax);
+  xOutHistPhiMix->Sumw2();
+  sprintf(xname,"%s (radians)     ",tit1);
+  xOutHistPhiMix->GetXaxis()->SetTitle(xname);
+  sprintf(xname,"#frac{%s}{N_{Trig}}#frac{dN}{d%s}   ",tit2,tit1);
+  xOutHistPhiMix->GetYaxis()->SetTitle(xname);
+  SetTitles1D(xOutHistPhiMix);
+  xOutHistPhiMix->SetMarkerStyle(21);
+  xOutHistPhiMix->SetMarkerColor(1);
+  xOutHistPhiMix->SetLineColor(1);
+  
+  char *tit14="#Delta#eta";
+  if(xNotDelta) tit14="#eta";
+  char *tit15="Mixed #Delta#eta";
+  if(xNotDelta) tit15="#eta";
+  char *titNear="Near-Side";
+  if(xNotDelta)titNear="";
+  
+  sprintf(xname,"%s %s %s %s Distribution for %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f%s",tit12,titNear,tit11,tit14,xTPt1,xTPt2,xAPt1,xAPt2,sign2[xSign]);
+  *xOutHistEtaN=new TH1F("dEtaN",xname,xnEbins,xEmin,xEmax);
+  xOutHistEtaN->Sumw2();
+  sprintf(xname,"%s     ",tit14);
+  xOutHistEtaN->GetXaxis()->SetTitle(xname);
+  sprintf(xname,"#frac{%s}{N_{Trig}}#frac{dN}{d%s}   ",tit2,tit14);
+  xOutHistEtaN->GetYaxis()->SetTitle(xname);
+  SetTitles1D(xOutHistEtaN);
+  xOutHistEtaN->SetMarkerStyle(20);
+  xOutHistEtaN->SetMarkerColor(2);
+  xOutHistEtaN->SetLineColor(2);
+  
+  sprintf(xname,"%s %s %s Distribution for %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f%s",tit11,titNear,tit15,xTPt1,xTPt2,xAPt1,xAPt2,sign2[xSign]);
+  *xOutHistEtaNMix=new TH1F("dEtaMixN",xname,xnEbins,xEmin,xEmax);
+  xOutHistEtaNMix->Sumw2();
+  sprintf(xname,"%s (radians)     ",tit1);
+  xOutHistEtaNMix->GetXaxis()->SetTitle(xname);
+  sprintf(xname,"#frac{%s}{N_{Trig}}#frac{dN}{d%s}   ",tit2,tit14);
+  xOutHistEtaNMix->GetYaxis()->SetTitle(xname);
+  SetTitles1D(xOutHistEtaNMix);
+  xOutHistEtaNMix->SetMarkerStyle(21);
+  xOutHistEtaNMix->SetMarkerColor(1);
+  xOutHistEtaNMix->SetLineColor(1);
+  
+  char *titAway="Away-Side";
+  if(xNotDelta)titAway="";
+  
+  sprintf(xname,"%s %s %s %s Distribution for %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f%s",tit12,titAway,tit11,tit14,xTPt1,xTPt2,xAPt1,xAPt2,sign2[xSign]);
+  *xOutHistEtaA=new TH1F("dEtaA",xname,xnEbins,xEmin,xEmax);
+  xOutHistEtaA->Sumw2();
+  sprintf(xname,"%s     ",tit14);
+  xOutHistEtaA->GetXaxis()->SetTitle(xname);
+  sprintf(xname,"#frac{%s}{N_{Trig}}#frac{dN}{d%s}   ",tit2,tit14);
+  xOutHistEtaA->GetYaxis()->SetTitle(xname);
+  SetTitles1D(xOutHistEtaA);
+  xOutHistEtaA->SetMarkerStyle(20);
+  xOutHistEtaA->SetMarkerColor(2);
+  xOutHistEtaA->SetLineColor(2);
+  
+  sprintf(xname,"%s %s %s Distribution for %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f%s",tit11,titAway,tit15,xTPt1,xTPt2,xAPt1,xAPt2,sign2[xSign]);
+  *xOutHistEtaAMix=new TH1F("dEtaMixA",xname,xnEbins,xEmin,xEmax);
+  xOutHistEtaAMix->Sumw2();
+  sprintf(xname,"%s (radians)     ",tit1);
+  xOutHistEtaAMix->GetXaxis()->SetTitle(xname);
+  sprintf(xname,"#frac{%s}{N_{Trig}}#frac{dN}{d%s}   ",tit2,tit14);
+  xOutHistEtaAMix->GetYaxis()->SetTitle(xname);
+  SetTitles1D(xOutHistEtaAMix);
+  xOutHistEtaAMix->SetMarkerStyle(21);
+  xOutHistEtaAMix->SetMarkerColor(1);
+  xOutHistEtaAMix->SetLineColor(1);
+  
+  sprintf(xname,"%s %s %s-%s Distribution for %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f%s",tit12,tit11,tit1,tit14,xTPt1,xTPt2,xAPt1,xAPt2,sign2[xSign]);
+  *xOutHistPhiEta=new TH2F("dPhiEta",xname,xnbins2,xmin2,xmax2,ynbins2,ymin2,ymax2);
+  xOutHistPhiEta->Sumw2();
+  sprintf(xname,"%s (radians)     ",tit1);
+  xOutHistPhiEta->GetXaxis()->SetTitle(xname);
+  sprintf(xname,"%s     ",tit14);
+  xOutHistPhiEta->GetYaxis()->SetTitle(xname);
+  sprintf(xname,"#frac{%s}{N_{Trig}}#frac{dN}{d%sd%s}   ",tit2,tit1,tit14);
+  xOutHistPhiEta->GetZaxis()->SetTitle(xname);
+  SetTitles2D(xOutHistPhiEta);
+  
+  sprintf(xname,"%s %s-%s Distribution for %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f%s",tit11,tit3,tit14,xTPt1,xTPt2,xAPt1,xAPt2,sign2[xSign]);
+  *xOutHistPhiEtaMix=new TH2F("dPhiEtaMix",xname,xnbins2,xmin2,xmax2,ynbins2,ymin2,ymax2);
+  xOutHistPhiEtaMix->Sumw2();
+  sprintf(xname,"%s (radians)     ",tit1);
+  xOutHistPhiEtaMix->GetXaxis()->SetTitle(xname);
+  sprintf(xname,"%s     ",tit14);
+  xOutHistPhiEtaMix->GetYaxis()->SetTitle(xname);
+  sprintf(xname,"#frac{%s}{N_{Trig}}#frac{dN}{d%sd%s}   ",tit2,tit1,tit14);
+  xOutHistPhiEtaMix->GetZaxis()->SetTitle(xname);
+  SetTitles2D(xOutHistPhiEtaMix);
+  
+  float xsum1,xsum2,xerr1,xerr2,xsum3,xsum4,xerr3,xerr4;
+  for(int xi=1;xi<=xnbins;xi++){
+    xsum1=0; xerr1=0; xsum2=0; xerr2=0;
+    for(int xj=xapt1; xj<=xapt2;xj++){
+      xsum1+=xDeltaPhi->GetBinContent(xi,xj);
+      xerr1+=pow(xDeltaPhi->GetBinError(xi,xj),2);
+      xsum2+=xDeltaPhiMix->GetBinContent(xi,xj);
+      xerr2+=pow(xDeltaPhiMix->GetBinError(xi,xj),2);
+    }
+    
+    xOutHistPhi->SetBinContent(xi,xsum1);
+    xOutHistPhi->SetBinError(xi,sqrt(xerr1));
+    xOutHistPhiMix->SetBinContent(xi,xsum2);
+    xOutHistPhiMix->SetBinError(xi,sqrt(xerr2));
+  }//philoop
+  for(int xi=1;xi<=xnEbins;xi++){
+    xsum1=0; xerr1=0; xsum2=0; xerr2=0; 
+    xsum3=0; xerr3=0; xsum4=0; xerr4=0;
+    //cout << "apt" << xapt1 << " " << xapt2 << endl;
+    for(int xj=xapt1; xj<=xapt2;xj++){
+      xsum1+=xDeltaEtaN->GetBinContent(xi,xj);
+      xerr1+=pow(xDeltaEtaN->GetBinError(xi,xj),2);
+      xsum2+=xDeltaEtaNMix->GetBinContent(xi,xj);
+      xerr2+=pow(xDeltaEtaNMix->GetBinError(xi,xj),2);
+      xsum3+=xDeltaEtaA->GetBinContent(xi,xj);
+      xerr3+=pow(xDeltaEtaA->GetBinError(xi,xj),2);
+      xsum4+=xDeltaEtaAMix->GetBinContent(xi,xj);
+      xerr4+=pow(xDeltaEtaAMix->GetBinError(xi,xj),2);
+    }
+    xOutHistEtaN->SetBinContent(xi,xsum1);
+    xOutHistEtaN->SetBinError(xi,sqrt(xerr1));
+    xOutHistEtaNMix->SetBinContent(xi,xsum2);
+    xOutHistEtaNMix->SetBinError(xi,sqrt(xerr2));
+    xOutHistEtaA->SetBinContent(xi,xsum3);
+    xOutHistEtaA->SetBinError(xi,sqrt(xerr3));
+    xOutHistEtaAMix->SetBinContent(xi,xsum4);
+    xOutHistEtaAMix->SetBinError(xi,sqrt(xerr4));
+  }//etaloop
+  
+  for(int xi=1;xi<=xnbins2;xi++){
+    for(int xj=1;xj<=ynbins2;xj++){
+      xsum1=0; xerr1=0; xsum2=0; xerr2=0;
+      for(int xk=xapt1; xk<=xapt2;xk++){
+        xsum1+=xDeltaPhiEta->GetBinContent(xi,xj,xk);
+       xerr1+=pow(xDeltaPhiEta->GetBinError(xi,xj,xk),2);
+       xsum2+=xDeltaPhiEtaMix->GetBinContent(xi,xj,xk);
+       xerr2+=pow(xDeltaPhiEtaMix->GetBinError(xi,xj,xk),2);
+      }
+      //cout << xDeltaPhiEtaMix->GetYaxis()->GetBinCenter(xj) << " " << xOutHistPhiEtaMix->GetYaxis()->GetBinCenter(xj) << " " << xsum2 << endl;
+      xOutHistPhiEta->SetBinContent(xi,xj,xsum1);
+      xOutHistPhiEta->SetBinError(xi,xj,sqrt(xerr1));
+      xOutHistPhiEtaMix->SetBinContent(xi,xj,xsum2);
+      xOutHistPhiEtaMix->SetBinError(xi,xj,sqrt(xsum2));
+    }
+  }//phi-eta loop
+  
+  //c10=new TCanvas("c10","",800,600);
+  //xOutHistPhi->Draw();
+  //delete xDeltaPhi;
+  // delete xDeltaMix;
+  //delete xtemphist1;
+  //delete xtemphist2;
+  //xFile->Close();
+  
+}
+
+//--------------------------------------------------------------------------------------------------------              
+
+void ZYA1(TH1F *yHistSig, TH1F *yHistBg, float scalea[3], float ZYAMCent=1.,float ZYAMWidth=0.2){
+  //yerr=0 no error
+  //yerr=1 no mixed event
+  //yerr=2 no signal
+  //yerr=3 no signal and no mixed
+  
+  //float ZYAMCent=1.3;
+  //float ZYAMWidth=0.2;//window is cent +/- width so its really a 1/2 width of the window
+  float a,yea,yerr;
+  //static float scalea[3];
+  float ysumsig=0,ysumbg=0,yerrsig=0,yerrbg=0;
+  float ycent;
+  int ybins=yHistSig->GetNbinsX();
+  float yPi=3.1415926535898;
+  //cout << ybins << endl;
+  //cout << yHistSig->GetSum() << endl;
+  //c20=new TCanvas("c20","",800,600);
+  //yHistSig->Draw();
+  cout << "ZYAMRegion: " << (ZYAMCent-ZYAMWidth) << "-" << (ZYAMCent+ZYAMWidth) << endl;
+  
+  for(int yi=1;yi<=ybins;yi++){
+    ycent=yHistSig->GetBinCenter(yi);
+    if((fabs(fabs(ycent)-ZYAMCent)<ZYAMWidth)||(fabs(fabs(ycent)-(2*yPi-ZYAMCent))<ZYAMWidth)){
+      ysumsig+=yHistSig->GetBinContent(yi);
+      yerrsig+=pow(yHistSig->GetBinError(yi),2);
+      ysumbg+=yHistBg->GetBinContent(yi);
+      yerrbg+=pow(yHistBg->GetBinError(yi),2);
+    }
+  }
+  cout << ysumsig << " " << yerrsig << " " << ysumbg << " " << yerrbg << endl;
+  if(ysumbg==0&&ysumsig==0){
+    a=0;
+    yea=0;
+    yerr=3;
+  }
+  else if(ysumbg==0){
+    a=0;
+    yea=0;
+    yerr=1;
+    
+  }
+  else if(ysumsig==0){
+    a=0;
+    yea=0;
+    yerr=2;
+  }
+  else{
+    a=ysumsig/ysumbg;
+    yea=a*sqrt(yerrsig/ysumsig/ysumsig+yerrbg/ysumbg/ysumbg);
+    yerr=0;
+  }
+  cout << a << endl;
+  scalea[0]=a;
+  scalea[1]=yea;
+  scalea[2]=yerr;
+  if(yerr) cout << "ZYA1 Error:" << yerr << endl;
+  //return scalea;
+}
+//----------------------------------------------------------------------------------------------------
+void ZYAM2D(TH2F *yHistSig, TH2F *yHistBg, Float_t scalea[3], Int_t nMin=10, Int_t nIter=10){
+  //for pp nIter=1 might be fine, for heavy-ions where the background has shape it shouldn't
+
+  const Int_t NMin=100;
+  float sumSig, sumBg;
+  float esumSig, esumBg;
+  float sumMin, esumMin;
+  scalea[0]=1;
+  scalea[1]=0;
+  float MinArray[NMin][2];
+  float MinArraySig[NMin][2];
+  float MinArrayBg[NMin][2];
+  float maxBinVal;
+  int maxBin;
+  float bin, err;
+  float s,b,es,eb;
+  for(int i=0;i<nIter;i++){
+    for(int q=0;q<nMin;q++){
+      MinArray[q][0]=10000;
+    }
+    for(int x=1;x<=yHistSig->GetNbinsX();x++){
+      for(int y=2;y<=(yHistSig->GetNbinsY()-1);y++){
+       maxBinVal=-10000;
+       for(int j=0;j<nMin;j++){//Find highest bin
+         if(MinArray[j][0]>maxBinVal){
+           maxBinVal=MinArray[j][0];
+           maxBin=j;
+         }
+       }
+       s=yHistSig->GetBinContent(x,y);
+       b=yHistBg->GetBinContent(x,y);
+       es=yHistSig->GetBinError(x,y);
+       eb=yHistBg->GetBinError(x,y);
+       bin=s-scalea[0]*b;
+       //float a11=scalea[0];
+       //bin2=s-a11*b;
+       //cout << "s" << s << " " << "b"  << b << " " << bin << endl;
+       //cout << bin << " " << maxBinVal << " " << maxBin << endl;
+       if(bin<maxBinVal){//replce highest bin with current if lower
+         MinArray[maxBin][0]=bin;
+         // cout << maxBin << " " << maxBinVal << " " << bin << " " << MinArray[maxBin][0] << endl;
+         //divide by 0 protections
+         if(scalea[0]==0)scalea[0]=1E-10;
+         if(scalea[1]==0)scalea[1]=1E-10;
+         if(es==0)es=1E-10;
+         if(eb==0)eb=1E-10;
+         if(s==0)s=1E-10;
+         if(b==0)b=1E-10;
+         MinArray[maxBin][1]=pow(es,2)+pow(scalea[0]*b,2)*(pow(scalea[1]/scalea[0],2)+pow(eb/b,2));
+         MinArraySig[maxBin][0]=s;
+         MinArraySig[maxBin][1]=es*es;
+         MinArrayBg[maxBin][0]=b;
+         MinArrayBg[maxBin][1]=eb*eb;
+         //cout << s << " " << b << " " << bin  << " " << maxBin << endl;
+       }
+      }
+    }
+    sumSig=0, sumBg=0, esumSig=0, esumBg=0, sumMin=0, esumMin=0;
+    for(int j=0;j<nMin;j++){
+      //cout << MinArray[j][0] << endl;
+      if(MinArray[j][0]!=10000&&MinArraySig[j][0]>1E-9&&MinArrayBg[j][0]>1E-9){
+       //      cout << MinArraySig[j][0] << endl;
+      sumMin+=MinArray[j][0];
+      esumMin+=MinArray[j][1];
+      sumSig+=MinArraySig[j][0];
+      esumSig+=MinArraySig[j][1];
+      sumBg+=MinArrayBg[j][0];
+      esumBg+=MinArrayBg[j][1];
+      }
+    }
+    if(sumSig==0){sumSig=1E-10; cout << "Warning: Zero sumSig" << endl;}
+    if(sumBg==0){sumBg=1E-10; cout << "Warning: Zero sumBg" << endl;}
+    scalea[0]=sumSig/sumBg;
+    //cout << sumSig << endl;
+    if(sumSig==1E-10)scalea[0]=0;
+    scalea[1]=scalea[0]*pow(esumSig/sumSig/sumSig+esumBg/sumBg/sumBg,0.5);
+    esumMin=pow(esumMin,0.5);
+    esumSig=pow(esumSig,0.5);
+    esumBg=pow(esumBg,0.5);
+    cout << "Iter:  " << i << "   Min=" << sumMin << " +/- " << esumMin << "  a=" << scalea[0] << endl;  
+  }
+}
+//--------------------------------------------------------------------------------------------------
+void ZYAM2D2(TH2F *yHistSig, TH2F *yHistBg, float scalea[3], float ZYAMCent=1.,float ZYAMWidth=0.2){
+  //yerr=0 no error
+  //yerr=1 no mixed event
+  //yerr=2 no signal
+  //yerr=3 no signal and no mixed
+  
+  //float ZYAMCent=1.3;
+  //float ZYAMWidth=0.2;//window is cent +/- width so its really a 1/2 width of the window
+  float a,yea,yerr;
+  //static float scalea[3];
+  float ysumsig=0,ysumbg=0,yerrsig=0,yerrbg=0;
+  float xcent,ycent;
+  int xbins=yHistSig->GetNbinsX();
+  int ybins=yHistSig->GetNbinsY();
+  float yPi=3.1415926535898;
+  //cout << ybins << endl;
+  //cout << yHistSig->GetSum() << endl;
+  //c20=new TCanvas("c20","",800,600);
+  //yHistSig->Draw();
+  cout << "ZYAMRegion: " << (ZYAMCent-ZYAMWidth) << "-" << (ZYAMCent+ZYAMWidth) << endl;
+  for(int xi=1;xi<=xbins;xi++){
+   xcent=yHistSig->GetBinCenter(xi);
+    if((fabs(fabs(xcent)-ZYAMCent)<ZYAMWidth)||(fabs(fabs(xcent)-(2*yPi-ZYAMCent))<ZYAMWidth)){
+    for(int yi=1;yi<=ybins;yi++){
+      ysumsig+=yHistSig->GetBinContent(xi,yi);
+      yerrsig+=pow(yHistSig->GetBinError(xi,yi),2);
+      ysumbg+=yHistBg->GetBinContent(xi,yi);
+      yerrbg+=pow(yHistBg->GetBinError(xi,yi),2);
+    }
+    }
+  }
+  cout << ysumsig << " " << yerrsig << " " << ysumbg << " " << yerrbg << endl;
+  if(ysumbg==0&&ysumsig==0){
+    a=0;
+    yea=0;
+    yerr=3;
+  }
+  else if(ysumbg==0){
+    a=0;
+    yea=0;
+    yerr=1;
+    
+  }
+  else if(ysumsig==0){
+    a=0;
+    yea=0;
+    yerr=2;
+  }
+  else{
+    a=ysumsig/ysumbg;
+    yea=a*sqrt(yerrsig/ysumsig/ysumsig+yerrbg/ysumbg/ysumbg);
+    yerr=0;
+  }
+  cout << a << endl;
+  scalea[0]=a;
+  scalea[1]=yea;
+  scalea[2]=yerr;
+  if(yerr) cout << "ZYA1 Error:" << yerr << endl;
+  //return scalea;
+}
+//-------------------------------------------------------------------------------------------------------
+void EffCorr(Float_t &yTPt1, Float_t &yTPt2, Float_t &yAPt1, Float_t &yAPt2, Int_t  yCent, char *yFileName, char *yEffFileName, TH1F *yPhiRaw, TH1F *yPhiCorr, TH1F *yPhiEff,  TH1F *yPhiMixRaw, TH1F *yPhiMixCorr, TH1F *yPhiMixEff, TH2F *yPhiEtaRaw, TH2F *yPhiEtaCorr, TH2F *yPhiEtaEff,  TH2F *yPhiEtaMixRaw, TH2F *yPhiEtaMixCorr, TH2F *yPhiEtaMixEff, Float_t yMPt[3], Int_t yptweighted=0, Int_t yNotDelta=0, Int_t yMethod=1){
+  char name[120], name2[105];
+  
+  float yMPt2[2];
+  
+  MakeProjections(yTPt1,yTPt2,yAPt1,yAPt2,yCent,yFileName,yPhiRaw,yPhiMixRaw,yPhiEtaRaw,yPhiEtaMixRaw,yMPt,yptweighted,0,yNotDelta);
+  
+  sprintf(name,"yPhiRaw_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiRaw->SetName(name);
+  
+  sprintf(name,"yPhiMixRaw_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiMixRaw->SetName(name);
+  
+  sprintf(name,"yPhiEtaRaw_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiEtaRaw->SetName(name);
+  
+  sprintf(name,"yPhiEtaMixRaw_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiEtaMixRaw->SetName(name);
+  
+  
+  //Projections from MC (from eff file)
+  TH1F *yPhiMC=new TH1F("yPhiMC","",1,0,1);
+  TH1F *yPhiMixMC=new TH1F("yPhiMixMC","",1,0,1);
+  TH2F *yPhiEtaMC=new TH2F("yPhiEtaMC","",1,0,1,1,0,1);
+  TH2F *yPhiEtaMixMC=new TH2F("yPhiEtaMixMC","",1,0,1,1,0,1);
+  MakeProjections(yTPt1,yTPt2,yAPt1,yAPt2,yCent,yEffFileName,yPhiMC,yPhiMixMC,yPhiEtaMC,yPhiEtaMixMC,yMPt2,yptweighted,1,yNotDelta);
+  sprintf(name,"yPhiMC_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiMC->SetName(name);
+  sprintf(name,"yPhiMixMC_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiMixMC->SetName(name);
+  sprintf(name,"yPhiEtaMC_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiEtaMC->SetName(name);
+  sprintf(name,"yPhiEtaMixMC_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiEtaMixMC->SetName(name);
+  
+  //Efficiency Histograms
+  MakeProjections(yTPt1,yTPt2,yAPt1,yAPt2,yCent,yEffFileName,yPhiEff,yPhiMixEff,yPhiEtaEff,yPhiEtaMixEff,yMPt2,yptweighted,0,yNotDelta);
+  sprintf(name,"yPhiEff_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiEff->SetName(name);
+  sprintf(name2,"Efficiency %s",yPhiEff->GetTitle());
+  yPhiEff->SetTitle(name2);
+  
+  sprintf(name,"yPhiMixEff_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiMixEff->SetName(name);
+  sprintf(name2,"Efficiency %s",yPhiMixEff->GetTitle());
+  yPhiMixEff->SetTitle(name2);
+  
+  sprintf(name,"yPhiEtaEff_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiEtaEff->SetName(name);
+  sprintf(name2,"Efficiency %s",yPhiEtaEff->GetTitle());
+  yPhiEtaEff->SetTitle(name2);
+  
+  sprintf(name,"yPhiEtaMixEff_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiEtaMixEff->SetName(name);
+  sprintf(name2,"Efficiency %s",yPhiEtaMixEff->GetTitle());
+  yPhiEtaMixEff->SetTitle(name2);
+  
+  
+  //Calculate Eff
+  yPhiEff->Divide(yPhiMC);
+  yPhiMixEff->Divide(yPhiMixMC);
+  yPhiEtaEff->Divide(yPhiEtaMC);
+  yPhiEtaMixEff->Divide(yPhiEtaMixMC);
+  
+  // if(yMethod==0){
+  // yPhiEff
+  
+  //Corrected Plots
+  *yPhiCorr=(TH1F*)yPhiRaw->Clone();
+  sprintf(name,"yPhiCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiCorr->SetName(name);
+  yPhiCorr->Divide(yPhiEff);
+  
+  *yPhiMixCorr=(TH1F*)yPhiMixRaw->Clone();
+  sprintf(name,"yPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiMixCorr->SetName(name);
+  yPhiMixCorr->Divide(yPhiMixEff);
+  
+  *yPhiEtaCorr=(TH2F*)yPhiEtaRaw->Clone();
+  sprintf(name,"yPhiEtaCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiEtaCorr->SetName(name);
+  yPhiEtaCorr->Divide(yPhiEtaEff);
+  
+  *yPhiEtaMixCorr=(TH2F*)yPhiEtaMixRaw->Clone();
+  sprintf(name,"yPhiMixCorr_%2.2fPT%2.2f_%2.2fpt%2.2f_%d",yTPt1,yTPt2,yAPt1,yAPt2,yCent);
+  yPhiEtaMixCorr->SetName(name);
+  yPhiEtaMixCorr->Divide(yPhiEtaMixEff);
+  
+  //Change some titles
+  sprintf(name2,"Uncorrected %s",yPhiRaw->GetTitle());
+  yPhiRaw->SetTitle(name2);
+  sprintf(name2,"Uncorrected %s",yPhiMixRaw->GetTitle());
+  yPhiMixRaw->SetTitle(name2);
+  sprintf(name2,"Uncorrected %s",yPhiEtaRaw->GetTitle());
+  yPhiEtaRaw->SetTitle(name2);
+  sprintf(name2,"Uncorrected %s",yPhiEtaMixRaw->GetTitle());
+  yPhiEtaMixRaw->SetTitle(name2);
+  
+  //Geometry Correction for the eta-phi plots
+  if(!yNotDelta){
+    int xbins=yPhiEtaCorr->GetNbinsX();
+    int ybins=yPhiEtaCorr->GetNbinsY();
+    float corr;
+    float center;
+    float scale=0;
+    float sumy;
+    //uses the mc for the geomery correction
+    for(int yx=1;yx<=xbins;yx++){
+      scale+=yPhiEtaMixMC->GetBinContent(yx,ybins/2);
+      scale+=yPhiEtaMixMC->GetBinContent(yx,ybins/2+1);
+    }
+    scale/=2;
+    for(int yy=1;yy<=ybins;yy++){
+      sumy=0;
+      for(int yx=1;yx<=xbins;yx++){
+       sumy+=yPhiEtaMixMC->GetBinContent(yx,yy);
+      }
+      if(sumy==0)sumy=0.00001;
+      corr=scale/sumy;
+      for(int yx=1;yx<=xbins;yx++){
+       yPhiEtaCorr->SetBinContent(yx,yy,corr*yPhiEtaCorr->GetBinContent(yx,yy));
+       yPhiEtaCorr->SetBinError(yx,yy,corr*yPhiEtaCorr->GetBinError(yx,yy));
+       yPhiEtaMixCorr->SetBinContent(yx,yy,corr*yPhiEtaMixCorr->GetBinContent(yx,yy));
+       yPhiEtaMixCorr->SetBinError(yx,yy,corr*yPhiEtaMixCorr->GetBinError(yx,yy));
+      }
+    }
+  }
+  /*
+  //uses equation for the geometry correct, must be changed if trigger or associtated eta cuts change
+  TAxis *yAxis=yPhiEtaCorr->GetYaxis();
+  for(int yx=1;yx<=xbins;yx++){
+  for(int yy=1;yy<=xbins;yy++){
+  center=yAxis->GetBinCenter(yy);
+  if(center<0)corr=1/(1+center/1.8);
+  else corr=1/(1-center/1.8);
+  yPhiEtaCorr->SetBinContent(yx,yy,corr*yPhiEtaCorr->GetBinContent(yx,yy));
+  yPhiEtaCorr->SetBinError(yx,yy,corr*yPhiEtaCorr->GetBinError(yx,yy));
+  yPhiEtaMixCorr->SetBinContent(yx,yy,corr*yPhiEtaMixCorr->GetBinContent(yx,yy));
+  yPhiEtaMixCorr->SetBinError(yx,yy,corr*yPhiEtaMixCorr->GetBinError(yx,yy));
+  }
+  }
+  */
+}
+//----------------------------------------------------------------------------------------------------------
+void EffCorr2(Float_t yTPt1, Float_t yTPt2, Float_t yAPt1, Float_t yAPt2, Int_t yCent, TH1F *yPhiEff, TH1F *yPhiMC, TH1F *yPhiMixEff, TH1F *yPhiMixMC, TH1F *yEtaNEff, TH1F *yEtaNMC, TH1F *yEtaNMixEff, TH1F *yEtaNMixMC, TH1F *yEtaAEff, TH1F *yEtaAMC, TH1F *yEtaAMixEff, TH1F *yEtaAMixMC, TH2F *yPhiEtaEff,  TH2F *yPhiEtaMC, TH2F *yPhiEtaMixEff, TH2F *yPhiEtaMixMC, Int_t yMethod=1){//MovingMax is special for yMethod==4
+  char effname[120], effname2[105];
+  if(yMethod==0){
+    for(int i=1;i<=yPhiEff->GetNbinsX();i++){
+      yPhiEff->SetBinContent(i,1);
+      yPhiEff->SetBinError(i,0);
+      yPhiMixEff->SetBinContent(i,1);
+      yPhiMixEff->SetBinError(i,0);
+    }
+    for(int i=1;i<=yEtaNEff->GetNbinsX();i++){
+      yEtaNEff->SetBinContent(i,1);
+      yEtaNEff->SetBinError(i,0);
+      yEtaAEff->SetBinContent(i,1);
+      yEtaAEff->SetBinError(i,0);
+      yEtaNMixEff->SetBinContent(i,1);
+      yEtaNMixEff->SetBinError(i,0);
+      yEtaAMixEff->SetBinContent(i,1);
+      yEtaAMixEff->SetBinError(i,0);
+    }
+    for(int i=1;i<=yPhiEtaEff->GetXaxis()->GetNbins();i++){
+      for(int j=1;j<=yPhiEtaEff->GetYaxis()->GetNbins();j++){
+       yPhiEtaEff->SetBinContent(i,j,1);
+       yPhiEtaEff->SetBinError(i,j,0);
+       yPhiEtaMixEff->SetBinContent(i,j,1);
+       yPhiEtaMixEff->SetBinError(i,j,0);
+      }
+    }
+  }//yMethod==0
+  else{
+    //Calculate Eff (Method 1)
+    yPhiEff->Divide(yPhiMC);
+    yPhiMixEff->Divide(yPhiMixMC);
+    yEtaNEff->Divide(yEtaNMC);
+    yEtaNMixEff->Divide(yEtaNMixMC);
+    yEtaAEff->Divide(yEtaAMC);
+    yEtaAMixEff->Divide(yEtaAMixMC);
+    yPhiEtaEff->Divide(yPhiEtaMC);
+    yPhiEtaMixEff->Divide(yPhiEtaMixMC);
+    
+    if(yMethod==2){//Use mixed event efficiencys for triggered events
+      /*
+       yPhiEff=(TH1F*)yPhiMixEff->Clone();
+       yPhiEff->SetName("yPhiEff");
+      yEtaNEff=(TH1F*)yEtaNMixEff->Clone();
+      yEtaNEff->SetName("yEtaNEff");
+      yEtaAEff=(TH1F*)yEtaAMixEff->Clone();
+      yEtaAEff->SetName("yEtaAEff");
+      yPhiEtaEff=(TH1F*)yPhiEtaMixEff->Clone();
+      yPhiEtaEff->SetName("yPhiEtaEff");
+      */
+      for(int i=1;i<=yPhiEff->GetNbinsX();i++){
+       yPhiEff->SetBinContent(i,yPhiMixEff->GetBinContent(i));
+       yPhiEff->SetBinError(i,yPhiMixEff->GetBinError(i));
+      }
+      for(int i=1;i<=yEtaNEff->GetNbinsX();i++){
+       yEtaNEff->SetBinContent(i,yEtaNMixEff->GetBinContent(i));
+       yEtaNEff->SetBinError(i,yEtaNMixEff->GetBinError(i));
+       yEtaAEff->SetBinContent(i,yEtaAMixEff->GetBinContent(i));
+       yEtaAEff->SetBinError(i,yEtaAMixEff->GetBinError(i));
+      }
+      for(int i=1;i<=yPhiEtaEff->GetXaxis()->GetNbins();i++){
+       for(int j=1;j<=yPhiEtaEff->GetYaxis()->GetNbins();j++){
+         yPhiEtaEff->SetBinContent(i,j,yPhiEtaMixEff->GetBinContent(i,j));
+         yPhiEtaEff->SetBinError(i,j,yPhiEtaMixEff->GetBinError(i,j));
+       }
+      }
+    }
+    if(yMethod==3){//Sum one distribution and use it for all
+      float eff=0, effE=0, effM=0, effME=0;
+      for(int i=1;i<=yPhiEff->GetNbinsX();i++){
+       eff+=yPhiEff->GetBinContent(i);
+       effE+=pow(yPhiEff->GetBinError(i),2);
+       effM+=yPhiMixEff->GetBinContent(i);
+       effME+=pow(yPhiMixEff->GetBinError(i),2);
+      }
+      eff/=yPhiEff->GetNbinsX();
+      effM/=yPhiEff->GetNbinsX();
+      effE=sqrt(effE)/yPhiEff->GetNbinsX();
+      effME=sqrt(effME)/yPhiEff->GetNbinsX();
+      cout << "Triggered Event Eff: " << eff << " +/- " << effE << endl;
+      cout << "Mixed Event Efficie: " << effM << " +/- " << effME << endl;
+      
+      for(int i=1;i<=yPhiEff->GetNbinsX();i++){
+       yPhiEff->SetBinContent(i,eff);
+       yPhiEff->SetBinError(i,effE);
+       yPhiMixEff->SetBinContent(i,effM);
+       yPhiMixEff->SetBinError(i,effME);
+      }
+      for(int i=1;i<=yEtaNEff->GetNbinsX();i++){
+       yEtaNEff->SetBinContent(i,eff);
+       yEtaNEff->SetBinError(i,effE);
+       yEtaNMixEff->SetBinContent(i,effM);
+       yEtaNMixEff->SetBinError(i,effME);
+       yEtaAEff->SetBinContent(i,eff);
+       yEtaAEff->SetBinError(i,effE);
+       yEtaAMixEff->SetBinContent(i,effM);
+       yEtaAMixEff->SetBinError(i,effME);
+      }
+      for(int i=1;i<=yPhiEtaEff->GetXaxis()->GetNbins();i++){
+       for(int j=1;j<=yPhiEtaEff->GetYaxis()->GetNbins();j++){
+         yPhiEtaEff->SetBinContent(i,j,eff);
+         yPhiEtaEff->SetBinError(i,j,effE);
+         yPhiEtaMixEff->SetBinContent(i,j,effM);
+         yPhiEtaMixEff->SetBinError(i,j,effME);
+       }
+      }
+    }
+  }
+  
+  
+  yPhiEff->GetYaxis()->SetTitle("Efficiency+Contamination");
+  yPhiMixEff->GetYaxis()->SetTitle("Efficiency+Contamination");
+  yEtaNEff->GetYaxis()->SetTitle("Efficiency+Contamination");
+  yEtaNMixEff->GetYaxis()->SetTitle("Efficiency+Contamination");
+  yEtaAEff->GetYaxis()->SetTitle("Efficiency+Contamination");
+  yEtaAMixEff->GetYaxis()->SetTitle("Efficiency+Contamination");
+  yPhiEtaEff->GetZaxis()->SetTitle("Efficiency+Contamination");
+  yPhiEtaMixEff->GetZaxis()->SetTitle("Efficiency+Contamination");
+  sprintf(effname,"Efficiency Triggered %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f",yTPt1,yTPt2,yAPt1,yAPt2);
+  yPhiEff->SetTitle(effname);
+  sprintf(effname,"Efficiency Mixed %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f", yTPt1,yTPt2,yAPt1,yAPt2);
+  yPhiMixEff->SetTitle(effname);
+  
+  sprintf(effname,"Near-Side Efficiency Triggered %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f",yTPt1,yTPt2,yAPt1,yAPt2);
+  yEtaNEff->SetTitle(effname);
+  sprintf(effname,"Near-Side Efficiency Mixed %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f", yTPt1,yTPt2,yAPt1,yAPt2);
+  yEtaNMixEff->SetTitle(effname);
+  
+  sprintf(effname,"Away-Side Efficiency Triggered %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f",yTPt1,yTPt2,yAPt1,yAPt2);
+  yEtaAEff->SetTitle(effname);
+  sprintf(effname,"Away-Side Efficiency Mixed %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f", yTPt1,yTPt2,yAPt1,yAPt2);
+  yEtaAMixEff->SetTitle(effname);
+  
+  sprintf(effname,"Efficiency Triggered %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f",yTPt1,yTPt2,yAPt1,yAPt2);
+  yPhiEtaEff->SetTitle(effname);
+  sprintf(effname,"Efficiency Mixed %3.1f<p_{T}^{Trig}<%3.1f %2.2f<p_{T}^{Assoc}<%2.2f",yTPt1,yTPt2,yAPt1,yAPt2);
+  yPhiEtaMixEff->SetTitle(effname);
+  
+  
+  //Corrected Plots
+  //if still problems try shifting this to the other code
+  // yPhiCorr->Divide(yPhiEff);
+  /*
+  //Change some titles
+  sprintf(effname2,"Uncorrected %s",yPhiRaw->GetTitle());
+  yPhiRaw->SetTitle(effname2);
+  sprintf(effname2,"Uncorrected %s",yPhiMixRaw->GetTitle());
+  yPhiMixRaw->SetTitle(effname2);
+  sprintf(effname2,"Uncorrected %s",yPhiEtaRaw->GetTitle());
+  yPhiEtaRaw->SetTitle(effname2);
+  sprintf(effname2,"Uncorrected %s",yPhiEtaMixRaw->GetTitle());
+  yPhiEtaMixRaw->SetTitle(effname2);
+  */
+}
+
+//Efficiency Fits-----------------------------------------------------------------------
+void EffFit(Float_t yAPt1,Float_t yAPt2,Int_t Cent,TList *effList, TH1F *yPhiEff, TH1F *yPhiMixEff, TH1F *yEtaNEff, TH1F *yEtaNMixEff, TH1F* yEtaAEff, TH1F *yEtaAMixEff, TH2F *yPhiEtaEff, TH2F *yPhiEtaMixEff, Int_t LSign=0, Int_t VariablePt=0){
+
+  const int xnpt=12;
+  //float xptbins[(xnpt+1)]={2.5,3,4,6,8,10,15,20,30,40,50,75,100};
+  float xptbins[(xnpt+1)]={2,2.5,3,4,5,6,8,10,15,20,30,40,50};
+  
+  int maxPtTrig=10;//we don't want to go beyond our resolution/statistics
+  //if(yAPt1>0.5)maxPtTrig=15;
+  if(yAPt1>1)maxPtTrig=8;
+  if(yAPt1>1.5)maxPtTrig=6;
+
+  int minPtTri